@thatopen/services 0.34.5 → 0.35.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,11 +1,11 @@
1
- var qa = Object.defineProperty;
2
- var go = (n) => {
1
+ var Ga = Object.defineProperty;
2
+ var wo = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var Va = (n, t, e) => t in n ? qa(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
- var he = (n, t, e) => Va(n, typeof t != "symbol" ? t + "" : t, e), yn = (n, t, e) => t.has(n) || go("Cannot " + e);
7
- var O = (n, t, e) => (yn(n, t, "read from private field"), e ? e.call(n) : t.get(n)), Lt = (n, t, e) => t.has(n) ? go("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), Ht = (n, t, e, s) => (yn(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), I = (n, t, e) => (yn(n, t, "access private method"), e);
8
- var wn = (n, t, e, s) => ({
5
+ var Ha = (n, t, e) => t in n ? Ga(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var le = (n, t, e) => Ha(n, typeof t != "symbol" ? t + "" : t, e), wn = (n, t, e) => t.has(n) || wo("Cannot " + e);
7
+ var O = (n, t, e) => (wn(n, t, "read from private field"), e ? e.call(n) : t.get(n)), Lt = (n, t, e) => t.has(n) ? wo("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), Ht = (n, t, e, s) => (wn(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), I = (n, t, e) => (wn(n, t, "access private method"), e);
8
+ var bn = (n, t, e, s) => ({
9
9
  set _(i) {
10
10
  Ht(n, t, i, e);
11
11
  },
@@ -21,63 +21,63 @@ _e.pong = "3";
21
21
  _e.message = "4";
22
22
  _e.upgrade = "5";
23
23
  _e.noop = "6";
24
- const Zs = /* @__PURE__ */ Object.create(null);
24
+ const Qs = /* @__PURE__ */ Object.create(null);
25
25
  Object.keys(_e).forEach((n) => {
26
- Zs[_e[n]] = n;
26
+ Qs[_e[n]] = n;
27
27
  });
28
- const _n = { type: "error", data: "parser error" }, Go = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ho = typeof ArrayBuffer == "function", zo = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, Qn = ({ type: n, data: t }, e, s) => Go && t instanceof Blob ? e ? s(t) : yo(t, s) : Ho && (t instanceof ArrayBuffer || zo(t)) ? e ? s(t) : yo(new Blob([t]), s) : s(_e[n] + (t || "")), yo = (n, t) => {
28
+ const Cn = { type: "error", data: "parser error" }, zo = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Wo = typeof ArrayBuffer == "function", Yo = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, ei = ({ type: n, data: t }, e, s) => zo && t instanceof Blob ? e ? s(t) : bo(t, s) : Wo && (t instanceof ArrayBuffer || Yo(t)) ? e ? s(t) : bo(new Blob([t]), s) : s(_e[n] + (t || "")), bo = (n, t) => {
29
29
  const e = new FileReader();
30
30
  return e.onload = function() {
31
31
  const s = e.result.split(",")[1];
32
32
  t("b" + (s || ""));
33
33
  }, e.readAsDataURL(n);
34
34
  };
35
- function wo(n) {
35
+ function vo(n) {
36
36
  return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
37
37
  }
38
- let bn;
39
- function Ga(n, t) {
40
- if (Go && n.data instanceof Blob)
41
- return n.data.arrayBuffer().then(wo).then(t);
42
- if (Ho && (n.data instanceof ArrayBuffer || zo(n.data)))
43
- return t(wo(n.data));
44
- Qn(n, !1, (e) => {
45
- bn || (bn = new TextEncoder()), t(bn.encode(e));
38
+ let vn;
39
+ function za(n, t) {
40
+ if (zo && n.data instanceof Blob)
41
+ return n.data.arrayBuffer().then(vo).then(t);
42
+ if (Wo && (n.data instanceof ArrayBuffer || Yo(n.data)))
43
+ return t(vo(n.data));
44
+ ei(n, !1, (e) => {
45
+ vn || (vn = new TextEncoder()), t(vn.encode(e));
46
46
  });
47
47
  }
48
- const bo = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Is = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
49
- for (let n = 0; n < bo.length; n++)
50
- Is[bo.charCodeAt(n)] = n;
51
- const Ha = (n) => {
48
+ const Eo = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ss = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
49
+ for (let n = 0; n < Eo.length; n++)
50
+ Ss[Eo.charCodeAt(n)] = n;
51
+ const Wa = (n) => {
52
52
  let t = n.length * 0.75, e = n.length, s, i = 0, r, a, l, p;
53
53
  n[n.length - 1] === "=" && (t--, n[n.length - 2] === "=" && t--);
54
54
  const d = new ArrayBuffer(t), c = new Uint8Array(d);
55
55
  for (s = 0; s < e; s += 4)
56
- r = Is[n.charCodeAt(s)], a = Is[n.charCodeAt(s + 1)], l = Is[n.charCodeAt(s + 2)], p = Is[n.charCodeAt(s + 3)], c[i++] = r << 2 | a >> 4, c[i++] = (a & 15) << 4 | l >> 2, c[i++] = (l & 3) << 6 | p & 63;
56
+ r = Ss[n.charCodeAt(s)], a = Ss[n.charCodeAt(s + 1)], l = Ss[n.charCodeAt(s + 2)], p = Ss[n.charCodeAt(s + 3)], c[i++] = r << 2 | a >> 4, c[i++] = (a & 15) << 4 | l >> 2, c[i++] = (l & 3) << 6 | p & 63;
57
57
  return d;
58
- }, za = typeof ArrayBuffer == "function", ti = (n, t) => {
58
+ }, Ya = typeof ArrayBuffer == "function", si = (n, t) => {
59
59
  if (typeof n != "string")
60
60
  return {
61
61
  type: "message",
62
- data: Wo(n, t)
62
+ data: Ko(n, t)
63
63
  };
64
64
  const e = n.charAt(0);
65
65
  return e === "b" ? {
66
66
  type: "message",
67
- data: Wa(n.substring(1), t)
68
- } : Zs[e] ? n.length > 1 ? {
69
- type: Zs[e],
67
+ data: Ka(n.substring(1), t)
68
+ } : Qs[e] ? n.length > 1 ? {
69
+ type: Qs[e],
70
70
  data: n.substring(1)
71
71
  } : {
72
- type: Zs[e]
73
- } : _n;
74
- }, Wa = (n, t) => {
75
- if (za) {
76
- const e = Ha(n);
77
- return Wo(e, t);
72
+ type: Qs[e]
73
+ } : Cn;
74
+ }, Ka = (n, t) => {
75
+ if (Ya) {
76
+ const e = Wa(n);
77
+ return Ko(e, t);
78
78
  } else
79
79
  return { base64: !0, data: n };
80
- }, Wo = (n, t) => {
80
+ }, Ko = (n, t) => {
81
81
  switch (t) {
82
82
  case "blob":
83
83
  return n instanceof Blob ? n : new Blob([n]);
@@ -85,27 +85,27 @@ const Ha = (n) => {
85
85
  default:
86
86
  return n instanceof ArrayBuffer ? n : n.buffer;
87
87
  }
88
- }, Yo = "", Ya = (n, t) => {
88
+ }, Xo = "", Xa = (n, t) => {
89
89
  const e = n.length, s = new Array(e);
90
90
  let i = 0;
91
91
  n.forEach((r, a) => {
92
- Qn(r, !1, (l) => {
93
- s[a] = l, ++i === e && t(s.join(Yo));
92
+ ei(r, !1, (l) => {
93
+ s[a] = l, ++i === e && t(s.join(Xo));
94
94
  });
95
95
  });
96
- }, Ka = (n, t) => {
97
- const e = n.split(Yo), s = [];
96
+ }, Za = (n, t) => {
97
+ const e = n.split(Xo), s = [];
98
98
  for (let i = 0; i < e.length; i++) {
99
- const r = ti(e[i], t);
99
+ const r = si(e[i], t);
100
100
  if (s.push(r), r.type === "error")
101
101
  break;
102
102
  }
103
103
  return s;
104
104
  };
105
- function Xa() {
105
+ function Qa() {
106
106
  return new TransformStream({
107
107
  transform(n, t) {
108
- Ga(n, (e) => {
108
+ za(n, (e) => {
109
109
  const s = e.length;
110
110
  let i;
111
111
  if (s < 126)
@@ -124,11 +124,11 @@ function Xa() {
124
124
  }
125
125
  });
126
126
  }
127
- let vn;
128
- function Ws(n) {
127
+ let En;
128
+ function Ys(n) {
129
129
  return n.reduce((t, e) => t + e.length, 0);
130
130
  }
131
- function Ys(n, t) {
131
+ function Ks(n, t) {
132
132
  if (n[0].length === t)
133
133
  return n.shift();
134
134
  const e = new Uint8Array(t);
@@ -137,51 +137,51 @@ function Ys(n, t) {
137
137
  e[i] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
138
138
  return n.length && s < n[0].length && (n[0] = n[0].slice(s)), e;
139
139
  }
140
- function Za(n, t) {
141
- vn || (vn = new TextDecoder());
140
+ function tc(n, t) {
141
+ En || (En = new TextDecoder());
142
142
  const e = [];
143
143
  let s = 0, i = -1, r = !1;
144
144
  return new TransformStream({
145
145
  transform(a, l) {
146
146
  for (e.push(a); ; ) {
147
147
  if (s === 0) {
148
- if (Ws(e) < 1)
148
+ if (Ys(e) < 1)
149
149
  break;
150
- const p = Ys(e, 1);
150
+ const p = Ks(e, 1);
151
151
  r = (p[0] & 128) === 128, i = p[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
152
152
  } else if (s === 1) {
153
- if (Ws(e) < 2)
153
+ if (Ys(e) < 2)
154
154
  break;
155
- const p = Ys(e, 2);
155
+ const p = Ks(e, 2);
156
156
  i = new DataView(p.buffer, p.byteOffset, p.length).getUint16(0), s = 3;
157
157
  } else if (s === 2) {
158
- if (Ws(e) < 8)
158
+ if (Ys(e) < 8)
159
159
  break;
160
- const p = Ys(e, 8), d = new DataView(p.buffer, p.byteOffset, p.length), c = d.getUint32(0);
160
+ const p = Ks(e, 8), d = new DataView(p.buffer, p.byteOffset, p.length), c = d.getUint32(0);
161
161
  if (c > Math.pow(2, 21) - 1) {
162
- l.enqueue(_n);
162
+ l.enqueue(Cn);
163
163
  break;
164
164
  }
165
165
  i = c * Math.pow(2, 32) + d.getUint32(4), s = 3;
166
166
  } else {
167
- if (Ws(e) < i)
167
+ if (Ys(e) < i)
168
168
  break;
169
- const p = Ys(e, i);
170
- l.enqueue(ti(r ? p : vn.decode(p), t)), s = 0;
169
+ const p = Ks(e, i);
170
+ l.enqueue(si(r ? p : En.decode(p), t)), s = 0;
171
171
  }
172
172
  if (i === 0 || i > n) {
173
- l.enqueue(_n);
173
+ l.enqueue(Cn);
174
174
  break;
175
175
  }
176
176
  }
177
177
  }
178
178
  });
179
179
  }
180
- const Ko = 4;
180
+ const Zo = 4;
181
181
  function oe(n) {
182
- if (n) return Qa(n);
182
+ if (n) return ec(n);
183
183
  }
184
- function Qa(n) {
184
+ function ec(n) {
185
185
  for (var t in oe.prototype)
186
186
  n[t] = oe.prototype[t];
187
187
  return n;
@@ -227,34 +227,34 @@ oe.prototype.listeners = function(n) {
227
227
  oe.prototype.hasListeners = function(n) {
228
228
  return !!this.listeners(n).length;
229
229
  };
230
- const un = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), we = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), tc = "arraybuffer";
231
- function Xo(n, ...t) {
230
+ const pn = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, e) => e(t, 0), we = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), sc = "arraybuffer";
231
+ function Qo(n, ...t) {
232
232
  return t.reduce((e, s) => (n.hasOwnProperty(s) && (e[s] = n[s]), e), {});
233
233
  }
234
- const ec = we.setTimeout, sc = we.clearTimeout;
235
- function pn(n, t) {
236
- t.useNativeTimers ? (n.setTimeoutFn = ec.bind(we), n.clearTimeoutFn = sc.bind(we)) : (n.setTimeoutFn = we.setTimeout.bind(we), n.clearTimeoutFn = we.clearTimeout.bind(we));
234
+ const nc = we.setTimeout, ic = we.clearTimeout;
235
+ function mn(n, t) {
236
+ t.useNativeTimers ? (n.setTimeoutFn = nc.bind(we), n.clearTimeoutFn = ic.bind(we)) : (n.setTimeoutFn = we.setTimeout.bind(we), n.clearTimeoutFn = we.clearTimeout.bind(we));
237
237
  }
238
- const nc = 1.33;
239
- function ic(n) {
240
- return typeof n == "string" ? rc(n) : Math.ceil((n.byteLength || n.size) * nc);
238
+ const rc = 1.33;
239
+ function oc(n) {
240
+ return typeof n == "string" ? ac(n) : Math.ceil((n.byteLength || n.size) * rc);
241
241
  }
242
- function rc(n) {
242
+ function ac(n) {
243
243
  let t = 0, e = 0;
244
244
  for (let s = 0, i = n.length; s < i; s++)
245
245
  t = n.charCodeAt(s), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (s++, e += 4);
246
246
  return e;
247
247
  }
248
- function Zo() {
248
+ function ta() {
249
249
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
250
250
  }
251
- function oc(n) {
251
+ function cc(n) {
252
252
  let t = "";
253
253
  for (let e in n)
254
254
  n.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(n[e]));
255
255
  return t;
256
256
  }
257
- function ac(n) {
257
+ function lc(n) {
258
258
  let t = {}, e = n.split("&");
259
259
  for (let s = 0, i = e.length; s < i; s++) {
260
260
  let r = e[s].split("=");
@@ -262,12 +262,12 @@ function ac(n) {
262
262
  }
263
263
  return t;
264
264
  }
265
- class cc extends Error {
265
+ class hc extends Error {
266
266
  constructor(t, e, s) {
267
267
  super(t), this.description = e, this.context = s, this.type = "TransportError";
268
268
  }
269
269
  }
270
- class ei extends oe {
270
+ class ni extends oe {
271
271
  /**
272
272
  * Transport abstract constructor.
273
273
  *
@@ -275,7 +275,7 @@ class ei extends oe {
275
275
  * @protected
276
276
  */
277
277
  constructor(t) {
278
- super(), this.writable = !1, pn(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
278
+ super(), this.writable = !1, mn(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
279
279
  }
280
280
  /**
281
281
  * Emits an error.
@@ -287,7 +287,7 @@ class ei extends oe {
287
287
  * @protected
288
288
  */
289
289
  onError(t, e, s) {
290
- return super.emitReserved("error", new cc(t, e, s)), this;
290
+ return super.emitReserved("error", new hc(t, e, s)), this;
291
291
  }
292
292
  /**
293
293
  * Opens the transport.
@@ -324,7 +324,7 @@ class ei extends oe {
324
324
  * @protected
325
325
  */
326
326
  onData(t) {
327
- const e = ti(t, this.socket.binaryType);
327
+ const e = si(t, this.socket.binaryType);
328
328
  this.onPacket(e);
329
329
  }
330
330
  /**
@@ -361,11 +361,11 @@ class ei extends oe {
361
361
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
362
362
  }
363
363
  _query(t) {
364
- const e = oc(t);
364
+ const e = cc(t);
365
365
  return e.length ? "?" + e : "";
366
366
  }
367
367
  }
368
- class lc extends ei {
368
+ class fc extends ni {
369
369
  constructor() {
370
370
  super(...arguments), this._polling = !1;
371
371
  }
@@ -421,7 +421,7 @@ class lc extends ei {
421
421
  return this.onClose({ description: "transport closed by the server" }), !1;
422
422
  this.onPacket(s);
423
423
  };
424
- Ka(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
424
+ Za(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
425
425
  }
426
426
  /**
427
427
  * For polling, send a close packet.
@@ -441,7 +441,7 @@ class lc extends ei {
441
441
  * @protected
442
442
  */
443
443
  write(t) {
444
- this.writable = !1, Ya(t, (e) => {
444
+ this.writable = !1, Xa(t, (e) => {
445
445
  this.doWrite(e, () => {
446
446
  this.writable = !0, this.emitReserved("drain");
447
447
  });
@@ -454,18 +454,18 @@ class lc extends ei {
454
454
  */
455
455
  uri() {
456
456
  const t = this.opts.secure ? "https" : "http", e = this.query || {};
457
- return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = Zo()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
457
+ return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = ta()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
458
458
  }
459
459
  }
460
- let Qo = !1;
460
+ let ea = !1;
461
461
  try {
462
- Qo = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
462
+ ea = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
463
463
  } catch {
464
464
  }
465
- const hc = Qo;
466
- function fc() {
465
+ const dc = ea;
466
+ function uc() {
467
467
  }
468
- class dc extends lc {
468
+ class pc extends fc {
469
469
  /**
470
470
  * XHR Polling constructor.
471
471
  *
@@ -515,7 +515,7 @@ class xe extends oe {
515
515
  * @package
516
516
  */
517
517
  constructor(t, e, s) {
518
- super(), this.createRequest = t, pn(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
518
+ super(), this.createRequest = t, mn(this, s), this._opts = s, this._method = s.method || "GET", this._uri = e, this._data = s.data !== void 0 ? s.data : null, this._create();
519
519
  }
520
520
  /**
521
521
  * Creates the XHR object and sends the request.
@@ -524,7 +524,7 @@ class xe extends oe {
524
524
  */
525
525
  _create() {
526
526
  var t;
527
- const e = Xo(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
527
+ const e = Qo(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
528
528
  e.xdomain = !!this._opts.xd;
529
529
  const s = this._xhr = this.createRequest(e);
530
530
  try {
@@ -578,7 +578,7 @@ class xe extends oe {
578
578
  */
579
579
  _cleanup(t) {
580
580
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
581
- if (this._xhr.onreadystatechange = fc, t)
581
+ if (this._xhr.onreadystatechange = uc, t)
582
582
  try {
583
583
  this._xhr.abort();
584
584
  } catch {
@@ -608,36 +608,36 @@ xe.requestsCount = 0;
608
608
  xe.requests = {};
609
609
  if (typeof document < "u") {
610
610
  if (typeof attachEvent == "function")
611
- attachEvent("onunload", vo);
611
+ attachEvent("onunload", To);
612
612
  else if (typeof addEventListener == "function") {
613
613
  const n = "onpagehide" in we ? "pagehide" : "unload";
614
- addEventListener(n, vo, !1);
614
+ addEventListener(n, To, !1);
615
615
  }
616
616
  }
617
- function vo() {
617
+ function To() {
618
618
  for (let n in xe.requests)
619
619
  xe.requests.hasOwnProperty(n) && xe.requests[n].abort();
620
620
  }
621
- const uc = function() {
622
- const n = ta({
621
+ const mc = function() {
622
+ const n = sa({
623
623
  xdomain: !1
624
624
  });
625
625
  return n && n.responseType !== null;
626
626
  }();
627
- class pc extends dc {
627
+ class gc extends pc {
628
628
  constructor(t) {
629
629
  super(t);
630
630
  const e = t && t.forceBase64;
631
- this.supportsBinary = uc && !e;
631
+ this.supportsBinary = mc && !e;
632
632
  }
633
633
  request(t = {}) {
634
- return Object.assign(t, { xd: this.xd }, this.opts), new xe(ta, this.uri(), t);
634
+ return Object.assign(t, { xd: this.xd }, this.opts), new xe(sa, this.uri(), t);
635
635
  }
636
636
  }
637
- function ta(n) {
637
+ function sa(n) {
638
638
  const t = n.xdomain;
639
639
  try {
640
- if (typeof XMLHttpRequest < "u" && (!t || hc))
640
+ if (typeof XMLHttpRequest < "u" && (!t || dc))
641
641
  return new XMLHttpRequest();
642
642
  } catch {
643
643
  }
@@ -647,13 +647,13 @@ function ta(n) {
647
647
  } catch {
648
648
  }
649
649
  }
650
- const ea = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
651
- class mc extends ei {
650
+ const na = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
651
+ class yc extends ni {
652
652
  get name() {
653
653
  return "websocket";
654
654
  }
655
655
  doOpen() {
656
- const t = this.uri(), e = this.opts.protocols, s = ea ? {} : Xo(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
656
+ const t = this.uri(), e = this.opts.protocols, s = na ? {} : Qo(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
657
657
  this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
658
658
  try {
659
659
  this.ws = this.createSocket(t, e, s);
@@ -679,12 +679,12 @@ class mc extends ei {
679
679
  this.writable = !1;
680
680
  for (let e = 0; e < t.length; e++) {
681
681
  const s = t[e], i = e === t.length - 1;
682
- Qn(s, this.supportsBinary, (r) => {
682
+ ei(s, this.supportsBinary, (r) => {
683
683
  try {
684
684
  this.doWrite(s, r);
685
685
  } catch {
686
686
  }
687
- i && un(() => {
687
+ i && pn(() => {
688
688
  this.writable = !0, this.emitReserved("drain");
689
689
  }, this.setTimeoutFn);
690
690
  });
@@ -701,19 +701,19 @@ class mc extends ei {
701
701
  */
702
702
  uri() {
703
703
  const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
704
- return this.opts.timestampRequests && (e[this.opts.timestampParam] = Zo()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
704
+ return this.opts.timestampRequests && (e[this.opts.timestampParam] = ta()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
705
705
  }
706
706
  }
707
- const En = we.WebSocket || we.MozWebSocket;
708
- class gc extends mc {
707
+ const Tn = we.WebSocket || we.MozWebSocket;
708
+ class wc extends yc {
709
709
  createSocket(t, e, s) {
710
- return ea ? new En(t, e, s) : e ? new En(t, e) : new En(t);
710
+ return na ? new Tn(t, e, s) : e ? new Tn(t, e) : new Tn(t);
711
711
  }
712
712
  doWrite(t, e) {
713
713
  this.ws.send(e);
714
714
  }
715
715
  }
716
- class yc extends ei {
716
+ class bc extends ni {
717
717
  get name() {
718
718
  return "webtransport";
719
719
  }
@@ -729,7 +729,7 @@ class yc extends ei {
729
729
  this.onError("webtransport error", t);
730
730
  }), this._transport.ready.then(() => {
731
731
  this._transport.createBidirectionalStream().then((t) => {
732
- const e = Za(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), i = Xa();
732
+ const e = tc(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(e).getReader(), i = Qa();
733
733
  i.readable.pipeTo(t.writable), this._writer = i.writable.getWriter();
734
734
  const r = () => {
735
735
  s.read().then(({ done: l, value: p }) => {
@@ -748,7 +748,7 @@ class yc extends ei {
748
748
  for (let e = 0; e < t.length; e++) {
749
749
  const s = t[e], i = e === t.length - 1;
750
750
  this._writer.write(s).then(() => {
751
- i && un(() => {
751
+ i && pn(() => {
752
752
  this.writable = !0, this.emitReserved("drain");
753
753
  }, this.setTimeoutFn);
754
754
  });
@@ -759,11 +759,11 @@ class yc extends ei {
759
759
  (t = this._transport) === null || t === void 0 || t.close();
760
760
  }
761
761
  }
762
- const wc = {
763
- websocket: gc,
764
- webtransport: yc,
765
- polling: pc
766
- }, bc = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, vc = [
762
+ const vc = {
763
+ websocket: wc,
764
+ webtransport: bc,
765
+ polling: gc
766
+ }, Ec = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Tc = [
767
767
  "source",
768
768
  "protocol",
769
769
  "authority",
@@ -779,29 +779,29 @@ const wc = {
779
779
  "query",
780
780
  "anchor"
781
781
  ];
782
- function An(n) {
782
+ function On(n) {
783
783
  if (n.length > 8e3)
784
784
  throw "URI too long";
785
785
  const t = n, e = n.indexOf("["), s = n.indexOf("]");
786
786
  e != -1 && s != -1 && (n = n.substring(0, e) + n.substring(e, s).replace(/:/g, ";") + n.substring(s, n.length));
787
- let i = bc.exec(n || ""), r = {}, a = 14;
787
+ let i = Ec.exec(n || ""), r = {}, a = 14;
788
788
  for (; a--; )
789
- r[vc[a]] = i[a] || "";
790
- return e != -1 && s != -1 && (r.source = t, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames = Ec(r, r.path), r.queryKey = Tc(r, r.query), r;
789
+ r[Tc[a]] = i[a] || "";
790
+ return e != -1 && s != -1 && (r.source = t, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames = Mc(r, r.path), r.queryKey = $c(r, r.query), r;
791
791
  }
792
- function Ec(n, t) {
792
+ function Mc(n, t) {
793
793
  const e = /\/{2,9}/g, s = t.replace(e, "/").split("/");
794
794
  return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
795
795
  }
796
- function Tc(n, t) {
796
+ function $c(n, t) {
797
797
  const e = {};
798
798
  return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, i, r) {
799
799
  i && (e[i] = r);
800
800
  }), e;
801
801
  }
802
- const Cn = typeof addEventListener == "function" && typeof removeEventListener == "function", Qs = [];
803
- Cn && addEventListener("offline", () => {
804
- Qs.forEach((n) => n());
802
+ const Rn = typeof addEventListener == "function" && typeof removeEventListener == "function", tn = [];
803
+ Rn && addEventListener("offline", () => {
804
+ tn.forEach((n) => n());
805
805
  }, !1);
806
806
  class We extends oe {
807
807
  /**
@@ -811,11 +811,11 @@ class We extends oe {
811
811
  * @param {Object} opts - options
812
812
  */
813
813
  constructor(t, e) {
814
- if (super(), this.binaryType = tc, 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) {
815
- const s = An(t);
814
+ if (super(), this.binaryType = sc, 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) {
815
+ const s = On(t);
816
816
  e.hostname = s.host, e.secure = s.protocol === "https" || s.protocol === "wss", e.port = s.port, s.query && (e.query = s.query);
817
- } else e.host && (e.hostname = An(e.host).host);
818
- pn(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) => {
817
+ } else e.host && (e.hostname = On(e.host).host);
818
+ mn(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) => {
819
819
  const i = s.prototype.name;
820
820
  this.transports.push(i), this._transportsByName[i] = s;
821
821
  }), this.opts = Object.assign({
@@ -832,13 +832,13 @@ class We extends oe {
832
832
  },
833
833
  transportOptions: {},
834
834
  closeOnBeforeunload: !1
835
- }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = ac(this.opts.query)), Cn && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
835
+ }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = lc(this.opts.query)), Rn && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
836
836
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
837
837
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
838
838
  this._onClose("transport close", {
839
839
  description: "network connection lost"
840
840
  });
841
- }, Qs.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
841
+ }, tn.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
842
842
  }
843
843
  /**
844
844
  * Creates transport of the given type.
@@ -849,7 +849,7 @@ class We extends oe {
849
849
  */
850
850
  createTransport(t) {
851
851
  const e = Object.assign({}, this.opts.query);
852
- e.EIO = Ko, e.transport = t, this.id && (e.sid = this.id);
852
+ e.EIO = Zo, e.transport = t, this.id && (e.sid = this.id);
853
853
  const s = Object.assign({}, this.opts, {
854
854
  query: e,
855
855
  socket: this,
@@ -967,7 +967,7 @@ class We extends oe {
967
967
  let e = 1;
968
968
  for (let s = 0; s < this.writeBuffer.length; s++) {
969
969
  const i = this.writeBuffer[s].data;
970
- if (i && (e += ic(i)), s > 0 && e > this._maxPayload)
970
+ if (i && (e += oc(i)), s > 0 && e > this._maxPayload)
971
971
  return this.writeBuffer.slice(0, s);
972
972
  e += 2;
973
973
  }
@@ -987,7 +987,7 @@ class We extends oe {
987
987
  if (!this._pingTimeoutTime)
988
988
  return !0;
989
989
  const t = Date.now() > this._pingTimeoutTime;
990
- return t && (this._pingTimeoutTime = 0, un(() => {
990
+ return t && (this._pingTimeoutTime = 0, pn(() => {
991
991
  this._onClose("ping timeout");
992
992
  }, this.setTimeoutFn)), t;
993
993
  }
@@ -1065,16 +1065,16 @@ class We extends oe {
1065
1065
  */
1066
1066
  _onClose(t, e) {
1067
1067
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
1068
- if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Cn && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1069
- const s = Qs.indexOf(this._offlineEventListener);
1070
- s !== -1 && Qs.splice(s, 1);
1068
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Rn && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1069
+ const s = tn.indexOf(this._offlineEventListener);
1070
+ s !== -1 && tn.splice(s, 1);
1071
1071
  }
1072
1072
  this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
1073
1073
  }
1074
1074
  }
1075
1075
  }
1076
- We.protocol = Ko;
1077
- class Mc extends We {
1076
+ We.protocol = Zo;
1077
+ class Ic extends We {
1078
1078
  constructor() {
1079
1079
  super(...arguments), this._upgrades = [];
1080
1080
  }
@@ -1146,67 +1146,67 @@ class Mc extends We {
1146
1146
  return e;
1147
1147
  }
1148
1148
  }
1149
- let $c = class extends Mc {
1149
+ let Sc = class extends Ic {
1150
1150
  constructor(t, e = {}) {
1151
1151
  const s = typeof t == "object", i = s ? { ...t } : { ...e };
1152
- (!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) => wc[r]).filter((r) => !!r)), super(s ? i : t, i);
1152
+ (!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) => vc[r]).filter((r) => !!r)), super(s ? i : t, i);
1153
1153
  }
1154
1154
  };
1155
- function Ic(n, t = "", e) {
1155
+ function xc(n, t = "", e) {
1156
1156
  let s = n;
1157
- 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 = An(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1157
+ 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 = On(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1158
1158
  const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1159
1159
  return s.id = s.protocol + "://" + r + ":" + s.port + t, s.href = s.protocol + "://" + r + (e && e.port === s.port ? "" : ":" + s.port), s;
1160
1160
  }
1161
- const Sc = typeof ArrayBuffer == "function", xc = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, sa = Object.prototype.toString, _c = typeof Blob == "function" || typeof Blob < "u" && sa.call(Blob) === "[object BlobConstructor]", Ac = typeof File == "function" || typeof File < "u" && sa.call(File) === "[object FileConstructor]";
1162
- function si(n) {
1163
- return Sc && (n instanceof ArrayBuffer || xc(n)) || _c && n instanceof Blob || Ac && n instanceof File;
1161
+ const _c = typeof ArrayBuffer == "function", Ac = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, ia = Object.prototype.toString, Cc = typeof Blob == "function" || typeof Blob < "u" && ia.call(Blob) === "[object BlobConstructor]", Oc = typeof File == "function" || typeof File < "u" && ia.call(File) === "[object FileConstructor]";
1162
+ function ii(n) {
1163
+ return _c && (n instanceof ArrayBuffer || Ac(n)) || Cc && n instanceof Blob || Oc && n instanceof File;
1164
1164
  }
1165
- function tn(n, t) {
1165
+ function en(n, t) {
1166
1166
  if (!n || typeof n != "object")
1167
1167
  return !1;
1168
1168
  if (Array.isArray(n)) {
1169
1169
  for (let e = 0, s = n.length; e < s; e++)
1170
- if (tn(n[e]))
1170
+ if (en(n[e]))
1171
1171
  return !0;
1172
1172
  return !1;
1173
1173
  }
1174
- if (si(n))
1174
+ if (ii(n))
1175
1175
  return !0;
1176
1176
  if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1177
- return tn(n.toJSON(), !0);
1177
+ return en(n.toJSON(), !0);
1178
1178
  for (const e in n)
1179
- if (Object.prototype.hasOwnProperty.call(n, e) && tn(n[e]))
1179
+ if (Object.prototype.hasOwnProperty.call(n, e) && en(n[e]))
1180
1180
  return !0;
1181
1181
  return !1;
1182
1182
  }
1183
- function Cc(n) {
1183
+ function Rc(n) {
1184
1184
  const t = [], e = n.data, s = n;
1185
- return s.data = On(e, t), s.attachments = t.length, { packet: s, buffers: t };
1185
+ return s.data = kn(e, t), s.attachments = t.length, { packet: s, buffers: t };
1186
1186
  }
1187
- function On(n, t) {
1187
+ function kn(n, t) {
1188
1188
  if (!n)
1189
1189
  return n;
1190
- if (si(n)) {
1190
+ if (ii(n)) {
1191
1191
  const e = { _placeholder: !0, num: t.length };
1192
1192
  return t.push(n), e;
1193
1193
  } else if (Array.isArray(n)) {
1194
1194
  const e = new Array(n.length);
1195
1195
  for (let s = 0; s < n.length; s++)
1196
- e[s] = On(n[s], t);
1196
+ e[s] = kn(n[s], t);
1197
1197
  return e;
1198
1198
  } else if (typeof n == "object" && !(n instanceof Date)) {
1199
1199
  const e = {};
1200
1200
  for (const s in n)
1201
- Object.prototype.hasOwnProperty.call(n, s) && (e[s] = On(n[s], t));
1201
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = kn(n[s], t));
1202
1202
  return e;
1203
1203
  }
1204
1204
  return n;
1205
1205
  }
1206
- function Oc(n, t) {
1207
- return n.data = Rn(n.data, t), delete n.attachments, n;
1206
+ function kc(n, t) {
1207
+ return n.data = Nn(n.data, t), delete n.attachments, n;
1208
1208
  }
1209
- function Rn(n, t) {
1209
+ function Nn(n, t) {
1210
1210
  if (!n)
1211
1211
  return n;
1212
1212
  if (n && n._placeholder === !0) {
@@ -1215,13 +1215,13 @@ function Rn(n, t) {
1215
1215
  throw new Error("illegal attachments");
1216
1216
  } else if (Array.isArray(n))
1217
1217
  for (let e = 0; e < n.length; e++)
1218
- n[e] = Rn(n[e], t);
1218
+ n[e] = Nn(n[e], t);
1219
1219
  else if (typeof n == "object")
1220
1220
  for (const e in n)
1221
- Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Rn(n[e], t));
1221
+ Object.prototype.hasOwnProperty.call(n, e) && (n[e] = Nn(n[e], t));
1222
1222
  return n;
1223
1223
  }
1224
- const Rc = [
1224
+ const Nc = [
1225
1225
  "connect",
1226
1226
  // used on the client side
1227
1227
  "connect_error",
@@ -1239,7 +1239,7 @@ var zt;
1239
1239
  (function(n) {
1240
1240
  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";
1241
1241
  })(zt || (zt = {}));
1242
- class kc {
1242
+ class Fc {
1243
1243
  /**
1244
1244
  * Encoder constructor
1245
1245
  *
@@ -1255,7 +1255,7 @@ class kc {
1255
1255
  * @param {Object} obj - packet object
1256
1256
  */
1257
1257
  encode(t) {
1258
- return (t.type === zt.EVENT || t.type === zt.ACK) && tn(t) ? this.encodeAsBinary({
1258
+ return (t.type === zt.EVENT || t.type === zt.ACK) && en(t) ? this.encodeAsBinary({
1259
1259
  type: t.type === zt.EVENT ? zt.BINARY_EVENT : zt.BINARY_ACK,
1260
1260
  nsp: t.nsp,
1261
1261
  data: t.data,
@@ -1275,11 +1275,11 @@ class kc {
1275
1275
  * a list of buffers.
1276
1276
  */
1277
1277
  encodeAsBinary(t) {
1278
- const e = Cc(t), s = this.encodeAsString(e.packet), i = e.buffers;
1278
+ const e = Rc(t), s = this.encodeAsString(e.packet), i = e.buffers;
1279
1279
  return i.unshift(s), i;
1280
1280
  }
1281
1281
  }
1282
- class ni extends oe {
1282
+ class ri extends oe {
1283
1283
  /**
1284
1284
  * Decoder constructor
1285
1285
  */
@@ -1301,8 +1301,8 @@ class ni extends oe {
1301
1301
  throw new Error("got plaintext data when reconstructing a packet");
1302
1302
  e = this.decodeString(t);
1303
1303
  const s = e.type === zt.BINARY_EVENT;
1304
- s || e.type === zt.BINARY_ACK ? (e.type = s ? zt.EVENT : zt.ACK, this.reconstructor = new Nc(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1305
- } else if (si(t) || t.base64)
1304
+ s || e.type === zt.BINARY_ACK ? (e.type = s ? zt.EVENT : zt.ACK, this.reconstructor = new Pc(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1305
+ } else if (ii(t) || t.base64)
1306
1306
  if (this.reconstructor)
1307
1307
  e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
1308
1308
  else
@@ -1331,7 +1331,7 @@ class ni extends oe {
1331
1331
  if (a != Number(a) || t.charAt(e) !== "-")
1332
1332
  throw new Error("Illegal attachments");
1333
1333
  const l = Number(a);
1334
- if (!Fc(l) || l < 0)
1334
+ if (!Lc(l) || l < 0)
1335
1335
  throw new Error("Illegal attachments");
1336
1336
  if (l > this.opts.maxAttachments)
1337
1337
  throw new Error("too many attachments");
@@ -1360,7 +1360,7 @@ class ni extends oe {
1360
1360
  }
1361
1361
  if (t.charAt(++e)) {
1362
1362
  const r = this.tryParse(t.substr(e));
1363
- if (ni.isPayloadValid(s.type, r))
1363
+ if (ri.isPayloadValid(s.type, r))
1364
1364
  s.data = r;
1365
1365
  else
1366
1366
  throw new Error("invalid payload");
@@ -1377,14 +1377,14 @@ class ni extends oe {
1377
1377
  static isPayloadValid(t, e) {
1378
1378
  switch (t) {
1379
1379
  case zt.CONNECT:
1380
- return Eo(e);
1380
+ return Mo(e);
1381
1381
  case zt.DISCONNECT:
1382
1382
  return e === void 0;
1383
1383
  case zt.CONNECT_ERROR:
1384
- return typeof e == "string" || Eo(e);
1384
+ return typeof e == "string" || Mo(e);
1385
1385
  case zt.EVENT:
1386
1386
  case zt.BINARY_EVENT:
1387
- return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Rc.indexOf(e[0]) === -1);
1387
+ return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && Nc.indexOf(e[0]) === -1);
1388
1388
  case zt.ACK:
1389
1389
  case zt.BINARY_ACK:
1390
1390
  return Array.isArray(e);
@@ -1397,7 +1397,7 @@ class ni extends oe {
1397
1397
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1398
1398
  }
1399
1399
  }
1400
- class Nc {
1400
+ class Pc {
1401
1401
  constructor(t) {
1402
1402
  this.packet = t, this.buffers = [], this.reconPack = t;
1403
1403
  }
@@ -1411,7 +1411,7 @@ class Nc {
1411
1411
  */
1412
1412
  takeBinaryData(t) {
1413
1413
  if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1414
- const e = Oc(this.reconPack, this.buffers);
1414
+ const e = kc(this.reconPack, this.buffers);
1415
1415
  return this.finishedReconstruction(), e;
1416
1416
  }
1417
1417
  return null;
@@ -1423,16 +1423,16 @@ class Nc {
1423
1423
  this.reconPack = null, this.buffers = [];
1424
1424
  }
1425
1425
  }
1426
- const Fc = Number.isInteger || function(n) {
1426
+ const Lc = Number.isInteger || function(n) {
1427
1427
  return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1428
1428
  };
1429
- function Eo(n) {
1429
+ function Mo(n) {
1430
1430
  return Object.prototype.toString.call(n) === "[object Object]";
1431
1431
  }
1432
- const Pc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1432
+ const Bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1433
1433
  __proto__: null,
1434
- Decoder: ni,
1435
- Encoder: kc,
1434
+ Decoder: ri,
1435
+ Encoder: Fc,
1436
1436
  get PacketType() {
1437
1437
  return zt;
1438
1438
  }
@@ -1442,7 +1442,7 @@ function Ee(n, t, e) {
1442
1442
  n.off(t, e);
1443
1443
  };
1444
1444
  }
1445
- const Lc = Object.freeze({
1445
+ const jc = Object.freeze({
1446
1446
  connect: 1,
1447
1447
  connect_error: 1,
1448
1448
  disconnect: 1,
@@ -1451,7 +1451,7 @@ const Lc = Object.freeze({
1451
1451
  newListener: 1,
1452
1452
  removeListener: 1
1453
1453
  });
1454
- class na extends oe {
1454
+ class ra extends oe {
1455
1455
  /**
1456
1456
  * `Socket` constructor.
1457
1457
  */
@@ -1567,7 +1567,7 @@ class na extends oe {
1567
1567
  */
1568
1568
  emit(t, ...e) {
1569
1569
  var s, i, r;
1570
- if (Lc.hasOwnProperty(t))
1570
+ if (jc.hasOwnProperty(t))
1571
1571
  throw new Error('"' + t.toString() + '" is a reserved event name');
1572
1572
  if (e.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1573
1573
  return this._addToQueue(e), this;
@@ -2043,10 +2043,10 @@ class na extends oe {
2043
2043
  }
2044
2044
  }
2045
2045
  }
2046
- function ps(n) {
2046
+ function ms(n) {
2047
2047
  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;
2048
2048
  }
2049
- ps.prototype.duration = function() {
2049
+ ms.prototype.duration = function() {
2050
2050
  var n = this.ms * Math.pow(this.factor, this.attempts++);
2051
2051
  if (this.jitter) {
2052
2052
  var t = Math.random(), e = Math.floor(t * this.jitter * n);
@@ -2054,27 +2054,27 @@ ps.prototype.duration = function() {
2054
2054
  }
2055
2055
  return Math.min(n, this.max) | 0;
2056
2056
  };
2057
- ps.prototype.reset = function() {
2057
+ ms.prototype.reset = function() {
2058
2058
  this.attempts = 0;
2059
2059
  };
2060
- ps.prototype.setMin = function(n) {
2060
+ ms.prototype.setMin = function(n) {
2061
2061
  this.ms = n;
2062
2062
  };
2063
- ps.prototype.setMax = function(n) {
2063
+ ms.prototype.setMax = function(n) {
2064
2064
  this.max = n;
2065
2065
  };
2066
- ps.prototype.setJitter = function(n) {
2066
+ ms.prototype.setJitter = function(n) {
2067
2067
  this.jitter = n;
2068
2068
  };
2069
- class kn extends oe {
2069
+ class Fn extends oe {
2070
2070
  constructor(t, e) {
2071
2071
  var s;
2072
- 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, pn(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 ps({
2072
+ 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, mn(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 ms({
2073
2073
  min: this.reconnectionDelay(),
2074
2074
  max: this.reconnectionDelayMax(),
2075
2075
  jitter: this.randomizationFactor()
2076
2076
  }), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
2077
- const i = e.parser || Pc;
2077
+ const i = e.parser || Bc;
2078
2078
  this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2079
2079
  }
2080
2080
  reconnection(t) {
@@ -2117,7 +2117,7 @@ class kn extends oe {
2117
2117
  open(t) {
2118
2118
  if (~this._readyState.indexOf("open"))
2119
2119
  return this;
2120
- this.engine = new $c(this.uri, this.opts);
2120
+ this.engine = new Sc(this.uri, this.opts);
2121
2121
  const e = this.engine, s = this;
2122
2122
  this._readyState = "opening", this.skipReconnect = !1;
2123
2123
  const i = Ee(e, "open", function() {
@@ -2187,7 +2187,7 @@ class kn extends oe {
2187
2187
  * @private
2188
2188
  */
2189
2189
  ondecoded(t) {
2190
- un(() => {
2190
+ pn(() => {
2191
2191
  this.emitReserved("packet", t);
2192
2192
  }, this.setTimeoutFn);
2193
2193
  }
@@ -2207,7 +2207,7 @@ class kn extends oe {
2207
2207
  */
2208
2208
  socket(t, e) {
2209
2209
  let s = this.nsps[t];
2210
- return s ? this._autoConnect && !s.active && s.connect() : (s = new na(this, t, e), this.nsps[t] = s), s;
2210
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new ra(this, t, e), this.nsps[t] = s), s;
2211
2211
  }
2212
2212
  /**
2213
2213
  * Called upon a socket close.
@@ -2304,31 +2304,31 @@ class kn extends oe {
2304
2304
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2305
2305
  }
2306
2306
  }
2307
- const bs = {};
2308
- function Cs(n, t) {
2307
+ const vs = {};
2308
+ function Os(n, t) {
2309
2309
  typeof n == "object" && (t = n, n = void 0), t = t || {};
2310
- const e = Ic(n, t.path || "/socket.io"), s = e.source, i = e.id, r = e.path, a = bs[i] && r in bs[i].nsps, l = t.forceNew || t["force new connection"] || t.multiplex === !1 || a;
2310
+ const e = xc(n, t.path || "/socket.io"), s = e.source, i = e.id, r = e.path, a = vs[i] && r in vs[i].nsps, l = t.forceNew || t["force new connection"] || t.multiplex === !1 || a;
2311
2311
  let p;
2312
- return l ? p = new kn(s, t) : (bs[i] || (bs[i] = new kn(s, t)), p = bs[i]), e.query && !t.query && (t.query = e.queryKey), p.socket(e.path, t);
2312
+ return l ? p = new Fn(s, t) : (vs[i] || (vs[i] = new Fn(s, t)), p = vs[i]), e.query && !t.query && (t.query = e.queryKey), p.socket(e.path, t);
2313
2313
  }
2314
- Object.assign(Cs, {
2315
- Manager: kn,
2316
- Socket: na,
2317
- io: Cs,
2318
- connect: Cs
2314
+ Object.assign(Os, {
2315
+ Manager: Fn,
2316
+ Socket: ra,
2317
+ io: Os,
2318
+ connect: Os
2319
2319
  });
2320
- class To extends Error {
2320
+ class $o extends Error {
2321
2321
  constructor(t, e) {
2322
2322
  super(
2323
2323
  `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.`
2324
2324
  ), this.expectedGuid = t, this.actualGuid = e, this.name = "StaleHistoryError";
2325
2325
  }
2326
2326
  }
2327
- const Mo = "bimterop", Nn = "revitflow_history.json", ia = "revitflow_model.frag", ra = "revitflow_", Bc = "bimterop-locks-anchor", vs = /* @__PURE__ */ new Map();
2328
- function jc(n, t) {
2327
+ const Io = "bimterop", Pn = "revitflow_history.json", oa = "revitflow_model.frag", aa = "revitflow_", Dc = "bimterop-locks-anchor", Es = /* @__PURE__ */ new Map();
2328
+ function Uc(n, t) {
2329
2329
  return n.filter((e) => String(e.parentId ?? "") === t);
2330
2330
  }
2331
- function Dc(n) {
2331
+ function Jc(n) {
2332
2332
  const t = n == null ? void 0 : n.hiddenFileId;
2333
2333
  if (typeof t != "string" || !t)
2334
2334
  throw new Error("The hidden-file upload answered without a hiddenFileId.");
@@ -2337,19 +2337,19 @@ function Dc(n) {
2337
2337
  function Ie(n) {
2338
2338
  return String(n._id ?? n.id ?? "");
2339
2339
  }
2340
- var ve, Ye, ke, Rs, ks, Fn;
2341
- class oa {
2340
+ var ve, Ye, ke, ks, Ns, Ln;
2341
+ class ca {
2342
2342
  constructor(t, e) {
2343
- Lt(this, ks);
2343
+ Lt(this, Ns);
2344
2344
  Lt(this, ve);
2345
2345
  Lt(this, Ye, /* @__PURE__ */ new Map());
2346
2346
  Lt(this, ke);
2347
- Lt(this, Rs, 0);
2347
+ Lt(this, ks, 0);
2348
2348
  this.client = t, this.projectId = e;
2349
2349
  }
2350
2350
  /** The project's connected documents. */
2351
2351
  async docs() {
2352
- const t = await I(this, ks, Fn).call(this);
2352
+ const t = await I(this, Ns, Ln).call(this);
2353
2353
  if (!t) return [];
2354
2354
  const e = await this.childFolders(t, !0), s = [];
2355
2355
  for (const i of e) {
@@ -2360,9 +2360,9 @@ class oa {
2360
2360
  folderId: Ie(i)
2361
2361
  })).map(
2362
2362
  (E) => String(E.name ?? "")
2363
- ), d = p.find((E) => E === ia) ?? p.find(
2364
- (E) => E.endsWith(".frag") && !E.startsWith(ra)
2365
- ), c = p.includes(Nn) || !!d;
2363
+ ), d = p.find((E) => E === oa) ?? p.find(
2364
+ (E) => E.endsWith(".frag") && !E.startsWith(aa)
2365
+ ), c = p.includes(Pn) || !!d;
2366
2366
  s.push({
2367
2367
  source: r.slice(0, a),
2368
2368
  docId: r.slice(a + 1),
@@ -2381,7 +2381,7 @@ class oa {
2381
2381
  doc(t, e) {
2382
2382
  const s = `${t}-${e}`;
2383
2383
  let i = O(this, Ye).get(s);
2384
- return i || (i = new $o(this.client, this, t, e), O(this, Ye).set(s, i)), i;
2384
+ return i || (i = new So(this.client, this, t, e), O(this, Ye).set(s, i)), i;
2385
2385
  }
2386
2386
  /**
2387
2387
  * The history of a document of the platform's own (a folder with its `document.json`, made from
@@ -2391,7 +2391,7 @@ class oa {
2391
2391
  document(t) {
2392
2392
  const e = `platform-${t}`;
2393
2393
  let s = O(this, Ye).get(e);
2394
- return s || (s = new $o(this.client, this, "platform", t, t), O(this, Ye).set(e, s)), s;
2394
+ return s || (s = new So(this.client, this, "platform", t, t), O(this, Ye).set(e, s)), s;
2395
2395
  }
2396
2396
  /**
2397
2397
  * @internal The documents' folders (the root's children), listed ONCE and
@@ -2402,7 +2402,7 @@ class oa {
2402
2402
  * folder is made, or when asked `fresh`.
2403
2403
  */
2404
2404
  async childFolders(t, e = !1) {
2405
- return (e || !O(this, ke) || Date.now() - O(this, Rs) > 3e4) && (Ht(this, Rs, Date.now()), Ht(this, ke, this.client.listFolders({ parentFolderId: t, projectId: this.projectId }).then((s) => jc(s, t))), O(this, ke).catch(() => {
2405
+ return (e || !O(this, ke) || Date.now() - O(this, ks) > 3e4) && (Ht(this, ks, Date.now()), Ht(this, ke, this.client.listFolders({ parentFolderId: t, projectId: this.projectId }).then((s) => Uc(s, t))), O(this, ke).catch(() => {
2406
2406
  Ht(this, ke, void 0);
2407
2407
  })), O(this, ke);
2408
2408
  }
@@ -2413,33 +2413,33 @@ class oa {
2413
2413
  /** @internal The `bimterop` folder id, resolved once. */
2414
2414
  async rootFolderId(t = !1) {
2415
2415
  if (O(this, ve)) return O(this, ve);
2416
- const e = await I(this, ks, Fn).call(this);
2416
+ const e = await I(this, Ns, Ln).call(this);
2417
2417
  if (e) return e;
2418
2418
  if (!t) return;
2419
2419
  const s = await this.client.createFolder(
2420
- Mo,
2420
+ Io,
2421
2421
  void 0,
2422
2422
  this.projectId
2423
2423
  );
2424
2424
  return Ht(this, ve, Ie(s)), O(this, ve);
2425
2425
  }
2426
2426
  }
2427
- ve = new WeakMap(), Ye = new WeakMap(), ke = new WeakMap(), Rs = new WeakMap(), ks = new WeakSet(), Fn = async function() {
2427
+ ve = new WeakMap(), Ye = new WeakMap(), ke = new WeakMap(), ks = new WeakMap(), Ns = new WeakSet(), Ln = async function() {
2428
2428
  if (O(this, ve)) return O(this, ve);
2429
2429
  const e = (await this.client.listFolders({
2430
2430
  projectId: this.projectId
2431
2431
  })).find(
2432
- (s) => String(s.name ?? "") === Mo && !s.parentId
2432
+ (s) => String(s.name ?? "") === Io && !s.parentId
2433
2433
  );
2434
2434
  return e && Ht(this, ve, Ie(e)), O(this, ve);
2435
2435
  };
2436
- var Me, Et, Oe, ss, Ue, $e, Ns, Pn, en, Je, aa, ca, sn, la, ha, fa;
2437
- class $o {
2436
+ var Me, Et, Oe, ss, Ue, $e, Fs, Bn, sn, Je, la, ha, nn, fa, da, ua;
2437
+ class So {
2438
2438
  constructor(t, e, s, i, r) {
2439
2439
  Lt(this, Et);
2440
2440
  Lt(this, Me);
2441
2441
  Lt(this, $e);
2442
- Lt(this, Ns, 0);
2442
+ Lt(this, Fs, 0);
2443
2443
  this.client = t, this.project = e, this.source = s, this.docId = i, Ht(this, Me, r);
2444
2444
  }
2445
2445
  // ─── Reading ───────────────────────────────────────────────────────────────
@@ -2449,8 +2449,8 @@ class $o {
2449
2449
  * Each version gets its `ordinal` filled in.
2450
2450
  */
2451
2451
  async timeline() {
2452
- const t = await I(this, Et, sn).call(this);
2453
- return da((t == null ? void 0 : t.commits) ?? []);
2452
+ const t = await I(this, Et, nn).call(this);
2453
+ return pa((t == null ? void 0 : t.commits) ?? []);
2454
2454
  }
2455
2455
  /** The head of the timeline, or null before the first sync. */
2456
2456
  async latest() {
@@ -2617,7 +2617,7 @@ class $o {
2617
2617
  * claims counts only for the earliest one, matching the plugins' rule.
2618
2618
  */
2619
2619
  async ownership() {
2620
- const t = await I(this, Et, en).call(this, Bc);
2620
+ const t = await I(this, Et, sn).call(this, Dc);
2621
2621
  if (!t) return [];
2622
2622
  const e = await this.client.getHiddenFilesByParent(t.id), s = await Promise.all(
2623
2623
  e.map(async (a) => {
@@ -2655,15 +2655,15 @@ class $o {
2655
2655
  async sync(t) {
2656
2656
  var l, p, d;
2657
2657
  const e = await I(this, Et, Ue).call(this, !0);
2658
- let s = await I(this, Et, sn).call(this) ?? {
2658
+ let s = await I(this, Et, nn).call(this) ?? {
2659
2659
  model: this.docId,
2660
2660
  commits: []
2661
2661
  };
2662
- const i = Io(s.commits);
2662
+ const i = xo(s.commits);
2663
2663
  if (t.expectedLatestGuid !== void 0 && (i == null ? void 0 : i.guid) !== t.expectedLatestGuid)
2664
- throw new To(t.expectedLatestGuid, i == null ? void 0 : i.guid);
2664
+ throw new $o(t.expectedLatestGuid, i == null ? void 0 : i.guid);
2665
2665
  const r = {
2666
- guid: ua(),
2666
+ guid: ma(),
2667
2667
  ...i ? { parents: [i.guid] } : {},
2668
2668
  author: t.author,
2669
2669
  source: t.source,
@@ -2675,30 +2675,30 @@ class $o {
2675
2675
  ...t.origin ? { origin: t.origin } : {},
2676
2676
  ...(l = t.origins) != null && l.length ? { origins: t.origins } : {},
2677
2677
  changes: t.changes,
2678
- counts: Uc(t.changes)
2678
+ counts: qc(t.changes)
2679
2679
  };
2680
- if (t.model && (await I(this, Et, fa).call(this, e, t.model), r.full = !0), t.delta) {
2680
+ if (t.model && (await I(this, Et, ua).call(this, e, t.model), r.full = !0), t.delta) {
2681
2681
  const c = ((p = await I(this, Et, Je).call(this)) == null ? void 0 : p.id) ?? ((d = t.file) == null ? void 0 : d.fileId) ?? void 0;
2682
2682
  if (!c)
2683
2683
  throw new Error(
2684
2684
  "A delta needs the model file to hang from: sync a full model first."
2685
2685
  );
2686
2686
  const E = await this.client.createHiddenFile(t.delta, c);
2687
- r.deltaId = Dc(E);
2687
+ r.deltaId = Jc(E);
2688
2688
  }
2689
- const a = await I(this, Et, sn).call(this);
2689
+ const a = await I(this, Et, nn).call(this);
2690
2690
  if (a) {
2691
2691
  s = a;
2692
- const c = Io(s.commits);
2692
+ const c = xo(s.commits);
2693
2693
  if (t.expectedLatestGuid !== void 0 && (c == null ? void 0 : c.guid) !== t.expectedLatestGuid)
2694
- throw new To(t.expectedLatestGuid, c == null ? void 0 : c.guid);
2694
+ throw new $o(t.expectedLatestGuid, c == null ? void 0 : c.guid);
2695
2695
  c && !r.parents && (r.parents = [c.guid]);
2696
2696
  }
2697
- return s.commits.push(r), await I(this, Et, la).call(this, e, Nn, s), r;
2697
+ return s.commits.push(r), await I(this, Et, fa).call(this, e, Pn, s), r;
2698
2698
  }
2699
2699
  }
2700
2700
  Me = new WeakMap(), Et = new WeakSet(), Oe = function() {
2701
- return new ma(this.client, this.project.projectId);
2701
+ return new ya(this.client, this.project.projectId);
2702
2702
  }, ss = function() {
2703
2703
  return `${this.source}-${this.docId}`;
2704
2704
  }, Ue = async function(t) {
@@ -2721,59 +2721,59 @@ Me = new WeakMap(), Et = new WeakSet(), Oe = function() {
2721
2721
  this.project.projectId
2722
2722
  );
2723
2723
  return this.project.forgetFolders(), Ht(this, Me, Ie(r)), O(this, Me);
2724
- }, $e = new WeakMap(), Ns = new WeakMap(), Pn = async function() {
2725
- return (!O(this, $e) || Date.now() - O(this, Ns) > 5e3) && (Ht(this, Ns, Date.now()), Ht(this, $e, (async () => {
2724
+ }, $e = new WeakMap(), Fs = new WeakMap(), Bn = async function() {
2725
+ return (!O(this, $e) || Date.now() - O(this, Fs) > 5e3) && (Ht(this, Fs, Date.now()), Ht(this, $e, (async () => {
2726
2726
  const t = await I(this, Et, Ue).call(this, !1);
2727
2727
  return t ? (await this.client.listFiles({ folderId: t, versions: !0 })).map((s) => ({
2728
2728
  id: Ie(s),
2729
2729
  name: String(s.name ?? ""),
2730
- stamp: Ln(s)
2730
+ stamp: jn(s)
2731
2731
  })) : [];
2732
2732
  })()), O(this, $e).catch(() => {
2733
2733
  Ht(this, $e, void 0);
2734
2734
  })), O(this, $e);
2735
- }, en = async function(t) {
2735
+ }, sn = async function(t) {
2736
2736
  try {
2737
- return (await I(this, Et, Pn).call(this)).find((e) => e.name === t);
2737
+ return (await I(this, Et, Bn).call(this)).find((e) => e.name === t);
2738
2738
  } catch {
2739
2739
  return;
2740
2740
  }
2741
2741
  }, Je = async function() {
2742
2742
  try {
2743
- const t = await I(this, Et, Pn).call(this);
2744
- return t.find((e) => e.name === ia) ?? t.find(
2745
- (e) => e.name.endsWith(".frag") && !e.name.startsWith(ra)
2743
+ const t = await I(this, Et, Bn).call(this);
2744
+ return t.find((e) => e.name === oa) ?? t.find(
2745
+ (e) => e.name.endsWith(".frag") && !e.name.startsWith(aa)
2746
2746
  );
2747
2747
  } catch {
2748
2748
  return;
2749
2749
  }
2750
- }, aa = async function(t) {
2751
- const e = await I(this, Et, en).call(this, t);
2750
+ }, la = async function(t) {
2751
+ const e = await I(this, Et, sn).call(this, t);
2752
2752
  if (!e) return;
2753
- const s = e.stamp ? vs.get(e.id) : void 0;
2753
+ const s = e.stamp ? Es.get(e.id) : void 0;
2754
2754
  if (s && s.stamp === e.stamp) return structuredClone(await s.value);
2755
- const i = I(this, Et, ca).call(this, e, t);
2756
- return e.stamp && (vs.set(e.id, { stamp: e.stamp, value: i }), i.catch(() => {
2755
+ const i = I(this, Et, ha).call(this, e, t);
2756
+ return e.stamp && (Es.set(e.id, { stamp: e.stamp, value: i }), i.catch(() => {
2757
2757
  var r;
2758
- ((r = vs.get(e.id)) == null ? void 0 : r.value) === i && vs.delete(e.id);
2758
+ ((r = Es.get(e.id)) == null ? void 0 : r.value) === i && Es.delete(e.id);
2759
2759
  })), structuredClone(await i);
2760
- }, ca = async function(t, e) {
2760
+ }, ha = async function(t, e) {
2761
2761
  const s = await this.client.downloadFile(t.id);
2762
2762
  if (!s.ok) throw new Error(`Reading ${e} answered ${s.status}`);
2763
2763
  const i = await s.text();
2764
2764
  if (i.trim())
2765
2765
  return JSON.parse(i);
2766
- }, sn = function() {
2767
- return I(this, Et, aa).call(this, Nn);
2768
- }, la = async function(t, e, s) {
2766
+ }, nn = function() {
2767
+ return I(this, Et, la).call(this, Pn);
2768
+ }, fa = async function(t, e, s) {
2769
2769
  const i = new Blob([JSON.stringify(s)], {
2770
2770
  type: "application/json"
2771
- }), r = await I(this, Et, en).call(this, e);
2772
- return r ? (vs.delete(r.id), await this.client.updateFile(r.id, {
2771
+ }), r = await I(this, Et, sn).call(this, e);
2772
+ return r ? (Es.delete(r.id), await this.client.updateFile(r.id, {
2773
2773
  file: i,
2774
2774
  versionTag: await this.client.nextVersionTag(r.id)
2775
- }), r) : await I(this, Et, ha).call(this, t, e, s);
2776
- }, ha = async function(t, e, s) {
2775
+ }), r) : await I(this, Et, da).call(this, t, e, s);
2776
+ }, da = async function(t, e, s) {
2777
2777
  const i = new Blob([JSON.stringify(s)], {
2778
2778
  type: "application/json"
2779
2779
  }), r = await this.client.createFile({
@@ -2786,7 +2786,7 @@ Me = new WeakMap(), Et = new WeakSet(), Oe = function() {
2786
2786
  Ht(this, $e, void 0);
2787
2787
  const a = r.item;
2788
2788
  return { id: Ie(a ?? r), name: e };
2789
- }, fa = async function(t, e) {
2789
+ }, ua = async function(t, e) {
2790
2790
  const s = await I(this, Et, Je).call(this);
2791
2791
  if (s)
2792
2792
  return await this.client.updateFile(s.id, {
@@ -2804,13 +2804,13 @@ Me = new WeakMap(), Et = new WeakSet(), Oe = function() {
2804
2804
  const a = r.item;
2805
2805
  return { id: Ie(a ?? r), name: i };
2806
2806
  };
2807
- function Uc(n) {
2807
+ function qc(n) {
2808
2808
  const t = { added: 0, modified: 0, removed: 0 };
2809
2809
  for (const e of n)
2810
2810
  e.type === "create" ? t.added++ : e.type === "delete" ? t.removed++ : t.modified++;
2811
2811
  return t;
2812
2812
  }
2813
- function da(n) {
2813
+ function pa(n) {
2814
2814
  var p;
2815
2815
  if (n.length <= 1)
2816
2816
  return n.forEach((d, c) => d.ordinal = c), [...n];
@@ -2837,18 +2837,18 @@ function da(n) {
2837
2837
  l.has(d.guid) || r.push(d);
2838
2838
  return r.forEach((d, c) => d.ordinal = c), r;
2839
2839
  }
2840
- function Io(n) {
2841
- const t = da(n);
2840
+ function xo(n) {
2841
+ const t = pa(n);
2842
2842
  return t[t.length - 1];
2843
2843
  }
2844
- function ua() {
2844
+ function ma() {
2845
2845
  const n = globalThis.crypto;
2846
2846
  return n != null && n.randomUUID ? n.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
2847
2847
  const e = Math.random() * 16 | 0;
2848
2848
  return (t === "x" ? e : e & 3 | 8).toString(16);
2849
2849
  });
2850
2850
  }
2851
- const pa = {
2851
+ const ga = {
2852
2852
  bim: { label: "BIM model", icon: "tabler:building" },
2853
2853
  // «Drawing set» (Antonio 25-10; was «Drawings», and «plan set» in the Planner). The key stays 'drawings'.
2854
2854
  drawings: { label: "Drawing set", icon: "tabler:layout-board" },
@@ -2858,7 +2858,7 @@ const pa = {
2858
2858
  // as a drawing set is («Coordination set», Antonio 22-10).
2859
2859
  coordination: { label: "Coordination set", icon: "tabler:messages" },
2860
2860
  generic: { label: "Generic", icon: "tabler:file" }
2861
- }, Jc = {
2861
+ }, Vc = {
2862
2862
  rvt: "bim",
2863
2863
  rfa: "bim",
2864
2864
  ifc: "bim",
@@ -2880,21 +2880,21 @@ const pa = {
2880
2880
  bcf: "coordination",
2881
2881
  bcfzip: "coordination"
2882
2882
  };
2883
- function So(n) {
2883
+ function _o(n) {
2884
2884
  var e;
2885
- if (n.type && n.type in pa)
2885
+ if (n.type && n.type in ga)
2886
2886
  return n.type;
2887
2887
  const t = [
2888
2888
  (e = n.native) == null ? void 0 : e.format,
2889
2889
  ...n.views.map((s) => s.format)
2890
2890
  ];
2891
2891
  for (const s of t) {
2892
- const i = s ? Jc[s.toLowerCase()] : void 0;
2892
+ const i = s ? Vc[s.toLowerCase()] : void 0;
2893
2893
  if (i) return i;
2894
2894
  }
2895
2895
  return "generic";
2896
2896
  }
2897
- const fn = "thatopen/document@1", Ks = "document.json", qc = [
2897
+ const dn = "thatopen/document@1", Xs = "document.json", Gc = [
2898
2898
  "pdf",
2899
2899
  "txt",
2900
2900
  "md",
@@ -2907,13 +2907,13 @@ function be(n) {
2907
2907
  return String(n._id ?? n.id ?? "");
2908
2908
  }
2909
2909
  const ts = /* @__PURE__ */ new Map();
2910
- let xo = !1;
2911
- const Ln = (n) => {
2910
+ let Ao = !1;
2911
+ const jn = (n) => {
2912
2912
  const t = n, e = [...t.versions ?? []].sort((i, r) => String(r.createdAt ?? "").localeCompare(String(i.createdAt ?? "")))[0], s = (e == null ? void 0 : e.tag) ?? t.versionTag;
2913
2913
  return s == null ? void 0 : String(s);
2914
2914
  };
2915
- var ne, ga, ya, Bn, wa, ba, va, Ea, Ss;
2916
- class ma {
2915
+ var ne, wa, ba, Dn, va, Ea, Ta, Ma, xs;
2916
+ class ya {
2917
2917
  constructor(t, e) {
2918
2918
  Lt(this, ne);
2919
2919
  this.client = t, this.projectId = e;
@@ -2927,8 +2927,8 @@ class ma {
2927
2927
  * folder, fetched in parallel — the storage offers nothing cheaper yet.
2928
2928
  */
2929
2929
  async list(t) {
2930
- const e = await I(this, ne, ga).call(this), s = t == null ? void 0 : t.types;
2931
- return s != null && s.length ? e.filter((i) => s.includes(So(i.descriptor))) : e;
2930
+ const e = await I(this, ne, wa).call(this), s = t == null ? void 0 : t.types;
2931
+ return s != null && s.length ? e.filter((i) => s.includes(_o(i.descriptor))) : e;
2932
2932
  }
2933
2933
  /**
2934
2934
  * Converts a loose file into a document: creates the document folder next
@@ -2943,34 +2943,34 @@ class ma {
2943
2943
  * document is born ready to visualize and the link concept retires.
2944
2944
  */
2945
2945
  async fromFile(t, e) {
2946
- const s = await this.client.getFile(t), i = String(s.name ?? ""), r = Tn(i, s.fileExtension), a = (e == null ? void 0 : e.name) ?? i.replace(/\.[^.]+$/, "") ?? i, l = new Set(
2946
+ const s = await this.client.getFile(t), i = String(s.name ?? ""), r = Mn(i, s.fileExtension), a = (e == null ? void 0 : e.name) ?? i.replace(/\.[^.]+$/, "") ?? i, l = new Set(
2947
2947
  (await this.list().catch(() => [])).map((N) => String(N.descriptor.name ?? "").toLowerCase())
2948
2948
  ), p = s.folderId ? String(s.folderId) : void 0;
2949
2949
  let d = a, c = "";
2950
2950
  for (let N = 1; N < 100; N++) {
2951
2951
  if (d = N === 1 ? a : `${a} (${N})`, l.has(d.toLowerCase())) continue;
2952
2952
  const Y = await this.client.createFolder(d, p, this.projectId);
2953
- if (c = be(Y), !await I(this, ne, Ss).call(this, c)) break;
2953
+ if (c = be(Y), !await I(this, ne, xs).call(this, c)) break;
2954
2954
  }
2955
2955
  await this.client.updateFile(t, { parentFolderId: c });
2956
- const E = [], b = await I(this, ne, ba).call(this, s);
2956
+ const E = [], b = await I(this, ne, Ea).call(this, s);
2957
2957
  if (b)
2958
2958
  try {
2959
2959
  const N = await this.client.getFile(b);
2960
2960
  await this.client.updateFile(b, { parentFolderId: c }), E.push({
2961
2961
  fileId: b,
2962
- format: Tn(String(N.name ?? ""), N.fileExtension)
2962
+ format: Mn(String(N.name ?? ""), N.fileExtension)
2963
2963
  });
2964
2964
  } catch {
2965
2965
  }
2966
- ((e == null ? void 0 : e.selfView) ?? qc.includes(r)) && E.push({ fileId: t, format: r });
2966
+ ((e == null ? void 0 : e.selfView) ?? Gc.includes(r)) && E.push({ fileId: t, format: r });
2967
2967
  const P = {
2968
- schema: fn,
2968
+ schema: dn,
2969
2969
  name: d,
2970
2970
  native: { fileId: t, format: r },
2971
2971
  views: E
2972
2972
  };
2973
- return P.type = (e == null ? void 0 : e.type) ?? So(P), await this.setDescriptor(c, P), await this.recordUpload(c, { fileId: t, name: i, format: r }, (e == null ? void 0 : e.author) ?? String(s.createdBy ?? "")), { folderId: c, descriptor: P };
2973
+ return P.type = (e == null ? void 0 : e.type) ?? _o(P), await this.setDescriptor(c, P), await this.recordUpload(c, { fileId: t, name: i, format: r }, (e == null ? void 0 : e.author) ?? String(s.createdBy ?? "")), { folderId: c, descriptor: P };
2974
2974
  }
2975
2975
  /**
2976
2976
  * Writes the step «uploaded to the platform» in a document's history: the first step of a
@@ -2978,13 +2978,13 @@ class ma {
2978
2978
  * file uploaded later. `author` is who uploaded it (a name, or the platform user id).
2979
2979
  */
2980
2980
  async recordUpload(t, e, s) {
2981
- const i = new oa(this.client, this.projectId).document(t), r = (await i.timeline()).length === 0;
2981
+ const i = new ca(this.client, this.projectId).document(t), r = (await i.timeline()).length === 0;
2982
2982
  await i.sync({
2983
2983
  author: s || "unknown",
2984
2984
  source: "platform",
2985
2985
  kind: "upload",
2986
2986
  message: r ? "Uploaded to the platform" : "New version uploaded",
2987
- file: { ...e, format: e.format ?? Tn(e.name, void 0) },
2987
+ file: { ...e, format: e.format ?? Mn(e.name, void 0) },
2988
2988
  changes: []
2989
2989
  });
2990
2990
  }
@@ -2993,8 +2993,8 @@ class ma {
2993
2993
  * has none yet (an old folder, or a plain folder that is not a document).
2994
2994
  */
2995
2995
  async descriptor(t) {
2996
- const e = await I(this, ne, Ss).call(this, t);
2997
- return e ? I(this, ne, Bn).call(this, e.id, e.stamp) : null;
2996
+ const e = await I(this, ne, xs).call(this, t);
2997
+ return e ? I(this, ne, Dn).call(this, e.id, e.stamp) : null;
2998
2998
  }
2999
2999
  /**
3000
3000
  * The first view whose format appears in `formats` — searched in the ORDER
@@ -3041,11 +3041,11 @@ class ma {
3041
3041
  async setDescriptor(t, e) {
3042
3042
  const s = {
3043
3043
  ...e,
3044
- schema: fn,
3044
+ schema: dn,
3045
3045
  views: e.views ?? []
3046
3046
  }, i = new Blob([JSON.stringify(s)], {
3047
3047
  type: "application/json"
3048
- }), r = await I(this, ne, Ss).call(this, t);
3048
+ }), r = await I(this, ne, xs).call(this, t);
3049
3049
  if (r) {
3050
3050
  ts.delete(r.id), await this.client.updateFile(r.id, {
3051
3051
  file: i,
@@ -3055,7 +3055,7 @@ class ma {
3055
3055
  }
3056
3056
  await this.client.createFile({
3057
3057
  file: i,
3058
- name: Ks,
3058
+ name: Xs,
3059
3059
  versionTag: "v1",
3060
3060
  parentFolderId: t,
3061
3061
  projectId: this.projectId
@@ -3067,37 +3067,37 @@ class ma {
3067
3067
  * history and never shows in the CDE. See {@link DocumentDrafts}.
3068
3068
  */
3069
3069
  drafts(t) {
3070
- return new Vc(this.client, () => I(this, ne, Ss).call(this, t));
3070
+ return new Hc(this.client, () => I(this, ne, xs).call(this, t));
3071
3071
  }
3072
3072
  }
3073
- ne = new WeakSet(), ga = async function() {
3074
- const t = await I(this, ne, ya).call(this);
3073
+ ne = new WeakSet(), wa = async function() {
3074
+ const t = await I(this, ne, ba).call(this);
3075
3075
  if (t) return t;
3076
3076
  const s = (await this.client.listFiles({ projectId: this.projectId })).filter(
3077
- (r) => String(r.name ?? "") === Ks
3077
+ (r) => String(r.name ?? "") === Xs
3078
3078
  );
3079
3079
  return (await Promise.all(
3080
3080
  s.map(async (r) => {
3081
3081
  const a = r, l = String(a.folderId ?? a.parentFolderId ?? "");
3082
3082
  if (!l) return null;
3083
- const p = await I(this, ne, Bn).call(this, be(r), Ln(r));
3083
+ const p = await I(this, ne, Dn).call(this, be(r), jn(r));
3084
3084
  return p ? { folderId: l, descriptor: p } : null;
3085
3085
  })
3086
3086
  )).filter((r) => r !== null);
3087
- }, ya = async function() {
3088
- if (xo) return null;
3087
+ }, ba = async function() {
3088
+ if (Ao) return null;
3089
3089
  let t;
3090
3090
  try {
3091
3091
  t = await this.client.listDocumentDescriptors(this.projectId);
3092
3092
  } catch (s) {
3093
3093
  const i = s.status;
3094
3094
  if (i === 404 || i === 400 || i === 405)
3095
- return xo = !0, null;
3095
+ return Ao = !0, null;
3096
3096
  throw s;
3097
3097
  }
3098
3098
  const e = [];
3099
3099
  for (const s of (t == null ? void 0 : t.documents) ?? []) {
3100
- const i = Ao(s.descriptor);
3100
+ const i = Oo(s.descriptor);
3101
3101
  !i || !s.folderId || (s.fileId && s.versionTag && ts.set(s.fileId, { stamp: s.versionTag, value: Promise.resolve(i) }), e.push({ folderId: String(s.folderId), descriptor: i }));
3102
3102
  }
3103
3103
  return e;
@@ -3106,15 +3106,15 @@ ne = new WeakSet(), ga = async function() {
3106
3106
  * the moment its listing says it last changed, for every list and panel of the page (the Coordinator's start read
3107
3107
  * the same 16 four times). Written here, it is forgotten.
3108
3108
  */
3109
- Bn = function(t, e) {
3109
+ Dn = function(t, e) {
3110
3110
  const s = e ? ts.get(t) : void 0;
3111
3111
  if (s && s.stamp === e) return s.value;
3112
- const i = I(this, ne, wa).call(this, t);
3112
+ const i = I(this, ne, va).call(this, t);
3113
3113
  return e && (ts.set(t, { stamp: e, value: i }), i.catch(() => {
3114
3114
  var r;
3115
3115
  ((r = ts.get(t)) == null ? void 0 : r.value) === i && ts.delete(t);
3116
3116
  })), i;
3117
- }, wa = async function(t) {
3117
+ }, va = async function(t) {
3118
3118
  const e = await this.client.downloadFile(t);
3119
3119
  if (!e.ok) throw new Error(`Reading a document's descriptor answered ${e.status}`);
3120
3120
  const s = await e.text();
@@ -3125,27 +3125,27 @@ Bn = function(t, e) {
3125
3125
  } catch {
3126
3126
  return null;
3127
3127
  }
3128
- return Ao(i);
3129
- }, ba = async function(t) {
3128
+ return Oo(i);
3129
+ }, Ea = async function(t) {
3130
3130
  let e = t.versions ?? [], s;
3131
3131
  if (e.length === 0) {
3132
3132
  s = await this.client.listFiles({ projectId: this.projectId }).catch(() => []);
3133
3133
  const d = s.find((c) => be(c) === be(t));
3134
3134
  e = (d == null ? void 0 : d.versions) ?? [];
3135
3135
  }
3136
- const i = await I(this, ne, Ea).call(this, t, e);
3136
+ const i = await I(this, ne, Ma).call(this, t, e);
3137
3137
  if (i) return i;
3138
3138
  const r = String(t.name ?? "").replace(/\.[^.]+$/, "").toLowerCase();
3139
3139
  if (!r) return;
3140
3140
  s ?? (s = await this.client.listFiles({ projectId: this.projectId }).catch(() => []));
3141
3141
  const a = (d) => String(d.folderId ?? d.parentFolderId ?? ""), l = new Set(
3142
- s.filter((d) => String(d.name ?? "") === Ks).map(a)
3142
+ s.filter((d) => String(d.name ?? "") === Xs).map(a)
3143
3143
  ), p = s.filter((d) => String(d.name ?? "").toLowerCase() === `${r}.frag` && !d.archived && be(d) !== be(t) && !l.has(a(d)));
3144
3144
  for (const d of p) {
3145
- const c = await I(this, ne, va).call(this, d);
3145
+ const c = await I(this, ne, Ta).call(this, d);
3146
3146
  if (c === void 0 || c === be(t)) return be(d);
3147
3147
  }
3148
- }, va = async function(t) {
3148
+ }, Ta = async function(t) {
3149
3149
  const s = [...t.versions ?? []].sort(
3150
3150
  (i, r) => String(r.createdAt ?? "").localeCompare(String(i.createdAt ?? ""))
3151
3151
  )[0];
@@ -3156,7 +3156,7 @@ Bn = function(t, e) {
3156
3156
  } catch {
3157
3157
  return;
3158
3158
  }
3159
- }, Ea = async function(t, e) {
3159
+ }, Ma = async function(t, e) {
3160
3160
  const s = [...e].sort(
3161
3161
  (i, r) => String(r.createdAt ?? "").localeCompare(String(i.createdAt ?? ""))
3162
3162
  );
@@ -3169,16 +3169,16 @@ Bn = function(t, e) {
3169
3169
  if (typeof a == "string" && a) return a;
3170
3170
  } catch {
3171
3171
  }
3172
- }, Ss = async function(t) {
3172
+ }, xs = async function(t) {
3173
3173
  if (!t) return;
3174
3174
  const s = (await this.client.listFiles({ folderId: t, versions: !0 })).find(
3175
- (i) => String(i.name ?? "") === Ks
3175
+ (i) => String(i.name ?? "") === Xs
3176
3176
  );
3177
- return s ? { id: be(s), stamp: Ln(s) } : void 0;
3177
+ return s ? { id: be(s), stamp: jn(s) } : void 0;
3178
3178
  };
3179
- const jn = "draft:", ns = "TODRAFT1";
3180
- var Se, xs, Dn;
3181
- class Vc {
3179
+ const Un = "draft:", ns = "TODRAFT1";
3180
+ var Se, _s, Jn;
3181
+ class Hc {
3182
3182
  constructor(t, e) {
3183
3183
  Lt(this, Se);
3184
3184
  this.client = t, this.holder = e;
@@ -3188,7 +3188,7 @@ class Vc {
3188
3188
  const t = await this.holder();
3189
3189
  if (!t) return [];
3190
3190
  const e = /* @__PURE__ */ new Map();
3191
- for (const s of await I(this, Se, xs).call(this, t.id)) {
3191
+ for (const s of await I(this, Se, _s).call(this, t.id)) {
3192
3192
  const i = e.get(s.userId);
3193
3193
  (!i || s.savedAt > i.savedAt) && e.set(s.userId, { userId: s.userId, savedAt: s.savedAt });
3194
3194
  }
@@ -3201,9 +3201,9 @@ class Vc {
3201
3201
  async get(t) {
3202
3202
  const e = await this.holder();
3203
3203
  if (!e) return null;
3204
- const i = (await I(this, Se, xs).call(this, e.id)).filter((p) => !(t != null && t.userId) || p.userId === t.userId).sort((p, d) => +d.savedAt - +p.savedAt)[0];
3204
+ const i = (await I(this, Se, _s).call(this, e.id)).filter((p) => !(t != null && t.userId) || p.userId === t.userId).sort((p, d) => +d.savedAt - +p.savedAt)[0];
3205
3205
  if (!i) return null;
3206
- const r = await this.client.downloadHiddenFile(i.hiddenId), { meta: a, blob: l } = await zc(await r.blob());
3206
+ const r = await this.client.downloadHiddenFile(i.hiddenId), { meta: a, blob: l } = await Yc(await r.blob());
3207
3207
  return { userId: i.userId, savedAt: i.savedAt, meta: a, blob: l };
3208
3208
  }
3209
3209
  /**
@@ -3215,53 +3215,53 @@ class Vc {
3215
3215
  const s = await this.holder();
3216
3216
  if (!s)
3217
3217
  throw new Error("This folder is not a document (no document.json): drafts need one.");
3218
- const i = Gc(e.userId), r = (await I(this, Se, xs).call(this, s.id)).filter((p) => p.userId === e.userId), l = (await this.client.createHiddenFile(
3219
- await Hc(t, e.meta ?? {}),
3218
+ const i = zc(e.userId), r = (await I(this, Se, _s).call(this, s.id)).filter((p) => p.userId === e.userId), l = (await this.client.createHiddenFile(
3219
+ await Wc(t, e.meta ?? {}),
3220
3220
  s.id,
3221
3221
  i
3222
3222
  )).hiddenFileId;
3223
3223
  if (!l) throw new Error("The draft upload answered without a hiddenFileId.");
3224
- return await I(this, Se, Dn).call(this, r.map((p) => p.hiddenId)), { userId: e.userId, savedAt: _o(l) };
3224
+ return await I(this, Se, Jn).call(this, r.map((p) => p.hiddenId)), { userId: e.userId, savedAt: Co(l) };
3225
3225
  }
3226
3226
  /** Deletes every draft of this user (on an explicit save, typically). */
3227
3227
  async delete(t) {
3228
3228
  const e = await this.holder();
3229
3229
  if (!e) return;
3230
- const s = (await I(this, Se, xs).call(this, e.id)).filter((i) => i.userId === t.userId);
3231
- await I(this, Se, Dn).call(this, s.map((i) => i.hiddenId));
3230
+ const s = (await I(this, Se, _s).call(this, e.id)).filter((i) => i.userId === t.userId);
3231
+ await I(this, Se, Jn).call(this, s.map((i) => i.hiddenId));
3232
3232
  }
3233
3233
  }
3234
- Se = new WeakSet(), xs = async function(t) {
3235
- return (await this.client.getHiddenFilesByParent(t)).filter((s) => typeof s.tag == "string" && s.tag.startsWith(jn)).map((s) => {
3234
+ Se = new WeakSet(), _s = async function(t) {
3235
+ return (await this.client.getHiddenFilesByParent(t)).filter((s) => typeof s.tag == "string" && s.tag.startsWith(Un)).map((s) => {
3236
3236
  const i = String(s._id);
3237
3237
  return {
3238
3238
  hiddenId: i,
3239
- userId: s.tag.slice(jn.length),
3240
- savedAt: _o(i)
3239
+ userId: s.tag.slice(Un.length),
3240
+ savedAt: Co(i)
3241
3241
  };
3242
3242
  });
3243
- }, Dn = async function(t) {
3243
+ }, Jn = async function(t) {
3244
3244
  for (const e of t)
3245
3245
  try {
3246
3246
  await this.client.deleteHiddenFile(e);
3247
3247
  } catch {
3248
3248
  }
3249
3249
  };
3250
- function Gc(n) {
3251
- const t = `${jn}${n}`;
3250
+ function zc(n) {
3251
+ const t = `${Un}${n}`;
3252
3252
  if (!/^[A-Za-z0-9][A-Za-z0-9:._-]{0,49}$/.test(t))
3253
3253
  throw new Error(`A draft cannot be tagged for user "${n}": ids must be letters, digits or :._- and short.`);
3254
3254
  return t;
3255
3255
  }
3256
- function _o(n) {
3256
+ function Co(n) {
3257
3257
  const t = parseInt(n.slice(0, 8), 16);
3258
3258
  return new Date(Number.isFinite(t) ? t * 1e3 : 0);
3259
3259
  }
3260
- async function Hc(n, t) {
3260
+ async function Wc(n, t) {
3261
3261
  const e = new TextEncoder().encode(JSON.stringify(t)), s = new Uint8Array(4);
3262
3262
  return new DataView(s.buffer).setUint32(0, e.length, !0), new Blob([new TextEncoder().encode(ns), s, e, n]);
3263
3263
  }
3264
- async function zc(n) {
3264
+ async function Yc(n) {
3265
3265
  const t = new Uint8Array(await n.slice(0, ns.length + 4).arrayBuffer());
3266
3266
  if (new TextDecoder().decode(t.slice(0, ns.length)) !== ns)
3267
3267
  return { meta: {}, blob: n };
@@ -3273,32 +3273,32 @@ async function zc(n) {
3273
3273
  }
3274
3274
  return { meta: r, blob: n.slice(s + e) };
3275
3275
  }
3276
- function Tn(n, t) {
3276
+ function Mn(n, t) {
3277
3277
  const e = (t ?? "").replace(/^\./, "").toLowerCase();
3278
3278
  if (e) return e;
3279
3279
  const s = n.lastIndexOf(".");
3280
3280
  return s > 0 ? n.slice(s + 1).toLowerCase() : "";
3281
3281
  }
3282
- function Ao(n) {
3282
+ function Oo(n) {
3283
3283
  if (!n || typeof n != "object") return null;
3284
3284
  const t = n;
3285
- if (t.schema !== fn || typeof t.name != "string") return null;
3285
+ if (t.schema !== dn || typeof t.name != "string") return null;
3286
3286
  const e = Array.isArray(t.views) ? t.views.filter(
3287
3287
  (l) => !!l && typeof l == "object" && typeof l.fileId == "string" && typeof l.format == "string"
3288
- ) : [], s = t.native, i = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string", r = typeof t.type == "string" && t.type in pa ? t.type : void 0, a = { ...t };
3288
+ ) : [], s = t.native, i = !!s && typeof s == "object" && typeof s.fileId == "string" && typeof s.format == "string", r = typeof t.type == "string" && t.type in ga ? t.type : void 0, a = { ...t };
3289
3289
  return delete a.type, delete a.native, {
3290
3290
  ...a,
3291
- schema: fn,
3291
+ schema: dn,
3292
3292
  name: t.name,
3293
3293
  ...r ? { type: r } : {},
3294
3294
  ...i ? { native: { fileId: s.fileId, format: s.format } } : {},
3295
3295
  views: e
3296
3296
  };
3297
3297
  }
3298
- const Wc = "flow:", Yc = "flow:op", Kc = "flow:source", Xc = "flow:host", Zc = "flow:print", Ta = "revitflow/op@2", Co = "REVITFLOWCHANGE", Oo = "REVITFLOWOPERATION";
3299
- class ii {
3298
+ const Kc = "flow:", Xc = "flow:op", Zc = "flow:source", Qc = "flow:host", tl = "flow:print", $a = "revitflow/op@2", Ro = "REVITFLOWCHANGE", ko = "REVITFLOWOPERATION";
3299
+ class oi {
3300
3300
  constructor(t) {
3301
- he(this, "changes", []);
3301
+ le(this, "changes", []);
3302
3302
  this.target = t;
3303
3303
  }
3304
3304
  /** How many changes are queued. An operation with none is refused by `build`. */
@@ -3364,7 +3364,7 @@ class ii {
3364
3364
  "An operation with no changes is not an operation. Add at least one."
3365
3365
  );
3366
3366
  const e = {
3367
- schema: Ta,
3367
+ schema: $a,
3368
3368
  opId: t,
3369
3369
  // Through the getters, so the envelope and the queue entry cannot drift
3370
3370
  // into disagreeing about the same operation.
@@ -3376,8 +3376,8 @@ class ii {
3376
3376
  ...this.userId ? { userId: this.userId } : {},
3377
3377
  title: this.title,
3378
3378
  summary: this.summary
3379
- }, [s, i] = await Qc();
3380
- return tl(
3379
+ }, [s, i] = await el();
3380
+ return sl(
3381
3381
  this.flatbuffer(s, i, t, JSON.stringify(e))
3382
3382
  );
3383
3383
  }
@@ -3386,8 +3386,8 @@ class ii {
3386
3386
  pack(t, e) {
3387
3387
  const s = {};
3388
3388
  for (const [i, r] of Object.entries(t ?? {}))
3389
- i.startsWith(Wc) && i !== Zc || (s[i] = String(r));
3390
- return e.position && (s.Position = e.position.map(Ro).join(",")), e.rotationDeg !== void 0 && (s.Rotation = Ro(e.rotationDeg)), e.source && (s[Kc] = e.source), e.host && (s[Xc] = e.host), s;
3389
+ i.startsWith(Kc) && i !== tl || (s[i] = String(r));
3390
+ return e.position && (s.Position = e.position.map(No).join(",")), e.rotationDeg !== void 0 && (s.Rotation = No(e.rotationDeg)), e.source && (s[Zc] = e.source), e.host && (s[Qc] = e.host), s;
3391
3391
  }
3392
3392
  requireId(t, e) {
3393
3393
  if (!t || !t.trim())
@@ -3417,11 +3417,11 @@ class ii {
3417
3417
  const Yt = a.endMeshes(c), at = c.createString(i), nt = /* @__PURE__ */ new Set(), pt = [];
3418
3418
  for (const rt of this.changes) {
3419
3419
  const _t = [], ie = {
3420
- [Yc]: rt.op,
3420
+ [Xc]: rt.op,
3421
3421
  ...rt.attrs
3422
3422
  };
3423
- for (const [Nt, le] of Object.entries(ie)) {
3424
- const me = JSON.stringify([Nt, le, "IFCTEXT"]);
3423
+ for (const [Nt, he] of Object.entries(ie)) {
3424
+ const me = JSON.stringify([Nt, he, "IFCTEXT"]);
3425
3425
  nt.add(me), _t.push(c.createString(me));
3426
3426
  }
3427
3427
  pt.push(
@@ -3438,9 +3438,9 @@ class ii {
3438
3438
  c,
3439
3439
  [...nt].map((rt) => c.createString(rt))
3440
3440
  ), Dt = this.changes.map(
3441
- () => c.createString(Co)
3441
+ () => c.createString(Ro)
3442
3442
  );
3443
- Dt.push(c.createString(Oo));
3443
+ Dt.push(c.createString(ko));
3444
3444
  const Xt = l.createCategoriesVector(c, Dt), Kt = [], Wt = [];
3445
3445
  this.changes.forEach((rt, _t) => {
3446
3446
  rt.item && (Kt.push(c.createString(rt.item)), Wt.push(b[_t]));
@@ -3449,13 +3449,13 @@ class ii {
3449
3449
  (rt, _t) => p.createSpatialStructure(
3450
3450
  c,
3451
3451
  b[_t],
3452
- c.createString(Co),
3452
+ c.createString(Ro),
3453
3453
  0
3454
3454
  )
3455
3455
  ), X = p.createSpatialStructure(
3456
3456
  c,
3457
3457
  P,
3458
- c.createString(Oo),
3458
+ c.createString(ko),
3459
3459
  p.createChildrenVector(c, ut)
3460
3460
  ), dt = c.createString(s);
3461
3461
  l.startModel(c), l.addMeshes(c, Yt), l.addMetadata(c, at), l.addAttributes(c, jt), l.addUniqueAttributes(c, Vt), l.addLocalIds(c, B), l.addCategories(c, Xt), l.addGuidsItems(c, Z), l.addGuids(c, U), l.addGuid(c, dt), l.addSpatialStructure(c, X), l.addMaxLocalId(c, $);
@@ -3463,7 +3463,7 @@ class ii {
3463
3463
  return l.finishModelBuffer(c, Mt), c.asUint8Array();
3464
3464
  }
3465
3465
  }
3466
- async function Qc() {
3466
+ async function el() {
3467
3467
  try {
3468
3468
  return await Promise.all([
3469
3469
  import("flatbuffers"),
@@ -3475,16 +3475,16 @@ async function Qc() {
3475
3475
  );
3476
3476
  }
3477
3477
  }
3478
- function Ro(n) {
3478
+ function No(n) {
3479
3479
  return Number.isFinite(n) ? String(n) : "0";
3480
3480
  }
3481
- async function tl(n) {
3481
+ async function sl(n) {
3482
3482
  const t = new Blob([n]).stream().pipeThrough(new CompressionStream("deflate"));
3483
3483
  return new Uint8Array(await new Response(t).arrayBuffer());
3484
3484
  }
3485
- async function ri(n) {
3486
- const [t, e] = await el(), s = e.Model.getRootAsModel(
3487
- new t.ByteBuffer(await sl(n))
3485
+ async function ai(n) {
3486
+ const [t, e] = await nl(), s = e.Model.getRootAsModel(
3487
+ new t.ByteBuffer(await il(n))
3488
3488
  );
3489
3489
  let i = {};
3490
3490
  try {
@@ -3519,7 +3519,7 @@ async function ri(n) {
3519
3519
  }
3520
3520
  return { metadata: i, items: a };
3521
3521
  }
3522
- async function el() {
3522
+ async function nl() {
3523
3523
  try {
3524
3524
  return await Promise.all([
3525
3525
  import("flatbuffers"),
@@ -3531,15 +3531,15 @@ async function el() {
3531
3531
  );
3532
3532
  }
3533
3533
  }
3534
- async function sl(n) {
3534
+ async function il(n) {
3535
3535
  const t = new Blob([n]).stream().pipeThrough(new DecompressionStream("deflate"));
3536
3536
  return new Uint8Array(await new Response(t).arrayBuffer());
3537
3537
  }
3538
- const Ma = "Element", $a = "Carried", rs = 1 / 0.3048;
3539
- function Ia(n) {
3538
+ const Ia = "Element", Sa = "Carried", rs = 1 / 0.3048;
3539
+ function xa(n) {
3540
3540
  const t = [];
3541
3541
  for (const e of n)
3542
- for (const s of [Ma, $a]) {
3542
+ for (const s of [Ia, Sa]) {
3543
3543
  const i = e.attrs[s];
3544
3544
  if (i)
3545
3545
  try {
@@ -3567,12 +3567,12 @@ function de(n, t) {
3567
3567
  return null;
3568
3568
  }
3569
3569
  }
3570
- function nl(n) {
3570
+ function rl(n) {
3571
3571
  const t = /* @__PURE__ */ new Map();
3572
- for (const [e, s] of oi(n)) t.set(e, s.name);
3572
+ for (const [e, s] of ci(n)) t.set(e, s.name);
3573
3573
  return t;
3574
3574
  }
3575
- function oi(n) {
3575
+ function ci(n) {
3576
3576
  const t = /* @__PURE__ */ new Map();
3577
3577
  for (const e of n) {
3578
3578
  if (e.kind !== "datum" || e.params.of !== "level") continue;
@@ -3581,7 +3581,7 @@ function oi(n) {
3581
3581
  }
3582
3582
  return t;
3583
3583
  }
3584
- function Sa(n) {
3584
+ function _a(n) {
3585
3585
  const t = /* @__PURE__ */ new Map();
3586
3586
  for (const e of n) {
3587
3587
  if (!e.kind.endsWith("Style")) continue;
@@ -3590,20 +3590,20 @@ function Sa(n) {
3590
3590
  }
3591
3591
  return t;
3592
3592
  }
3593
- function ai(n, t) {
3593
+ function li(n, t) {
3594
3594
  const e = /* @__PURE__ */ new Map();
3595
3595
  for (const [s, i] of n.made)
3596
3596
  e.set(s, i.id), i.print && (t == null || t.set(s, i.print));
3597
3597
  return e;
3598
3598
  }
3599
- function nn(n) {
3599
+ function rn(n) {
3600
3600
  const t = (i) => Array.isArray(i) ? i.map(t) : i && typeof i == "object" ? Object.fromEntries(Object.keys(i).sort().map((r) => [r, t(i[r])])) : i, e = JSON.stringify(t(n));
3601
3601
  let s = 2166136261;
3602
3602
  for (let i = 0; i < e.length; i++)
3603
3603
  s ^= e.charCodeAt(i), s = Math.imul(s, 16777619);
3604
3604
  return (s >>> 0).toString(36);
3605
3605
  }
3606
- async function ci(n, t) {
3606
+ async function hi(n, t) {
3607
3607
  var a, l;
3608
3608
  if (!(t != null && t.fileId)) throw new Error("Choose the model file to read.");
3609
3609
  n.progress(`Downloading ${t.name}`);
@@ -3619,13 +3619,13 @@ async function ci(n, t) {
3619
3619
  const p = n.client.recipes.importerFor(s);
3620
3620
  if (!p)
3621
3621
  throw new Error(`This app cannot read .${s} files: it provides no importer for them.`);
3622
- s === "ifc" && (i = xa(e));
3622
+ s === "ifc" && (i = Aa(e));
3623
3623
  const d = n.client.recipes.shapesFor(s);
3624
3624
  d && (n.progress(`Reading the shapes of ${t.name}`), r = await d(e, t.name)), n.progress(`Reading ${t.name}`), e = await p(e, t.name);
3625
3625
  }
3626
- return { picked: t, contents: await ri(e), site: i, shapes: r };
3626
+ return { picked: t, contents: await ai(e), site: i, shapes: r };
3627
3627
  }
3628
- function xa(n) {
3628
+ function Aa(n) {
3629
3629
  var wt;
3630
3630
  const t = new TextDecoder("latin1").decode(n), e = (Pt) => new RegExp(`^${Pt}=\\s*([A-Z0-9_]+)\\((.*)\\);\\s*$`, "m").exec(t), s = (Pt) => [...Pt.matchAll(/#\d+|\$/g)].map((tt) => tt[0]), i = (Pt) => [...Pt.matchAll(/-?\d+(?:\.\d*)?(?:E[-+]?\d+)?/gi)].map((tt) => Number(tt[0])), r = /^(#\d+)=\s*IFCSITE\((.*)\);\s*$/m.exec(t);
3631
3631
  if (!r) return null;
@@ -3649,77 +3649,77 @@ function xa(n) {
3649
3649
  const f = /IFCSIUNIT\([^)]*\.LENGTHUNIT\.\s*,\s*(\.([A-Z]+)\.|\$)\s*,\s*\.METRE\./i.exec(t), Tt = { MILLI: 1e-3, CENTI: 0.01, DECI: 0.1, KILO: 1e3 }, st = f ? f[2] ? Tt[f[2].toUpperCase()] ?? 1 : 1 : /IFCCONVERSIONBASEDUNIT\([^)]*\.LENGTHUNIT\.[^)]*'FOOT'/i.test(t) ? 0.3048 : 1;
3650
3650
  return { east: P * st, north: N * st, elevation: Y * st, angleDeg: z };
3651
3651
  }
3652
- const _a = "thatopen/recipe@1", ko = "__project_data", No = "recipes", il = (n) => `${n}.recipe.json`, rl = {
3653
- OperationBuilder: ii,
3654
- OP_SCHEMA: Ta,
3655
- readFrag: ri,
3656
- readPickedFrag: ci,
3657
- recordsOf: Ia,
3652
+ const Ca = "thatopen/recipe@1", Fo = "__project_data", Po = "recipes", ol = (n) => `${n}.recipe.json`, al = {
3653
+ OperationBuilder: oi,
3654
+ OP_SCHEMA: $a,
3655
+ readFrag: ai,
3656
+ readPickedFrag: hi,
3657
+ recordsOf: xa,
3658
3658
  innerJson: de,
3659
- levelsOf: oi,
3660
- levelNames: nl,
3661
- stylesOf: Sa,
3662
- printOf: nn,
3663
- siteLocationOf: xa,
3664
- whatItMadeBefore: ai,
3665
- ELEMENT_FIELD: Ma,
3666
- CARRIED_FIELD: $a,
3659
+ levelsOf: ci,
3660
+ levelNames: rl,
3661
+ stylesOf: _a,
3662
+ printOf: rn,
3663
+ siteLocationOf: Aa,
3664
+ whatItMadeBefore: li,
3665
+ ELEMENT_FIELD: Ia,
3666
+ CARRIED_FIELD: Sa,
3667
3667
  FEET_PER_METRE: rs
3668
- }, ol = /^[a-z0-9][a-z0-9-]{1,62}$/;
3669
- async function Aa(n, t, e) {
3668
+ }, cl = /^[a-z0-9][a-z0-9-]{1,62}$/;
3669
+ async function Oa(n, t, e) {
3670
3670
  const s = (d) => [...d].sort((c, E) => String(c._id).localeCompare(String(E._id)))[0], i = await n.listFolders({ projectId: t, archived: !1 });
3671
- let r = s(i.filter((d) => d.name === ko && !d.parentId));
3671
+ let r = s(i.filter((d) => d.name === Fo && !d.parentId));
3672
3672
  if (!r) {
3673
3673
  if (!e) return null;
3674
- r = await n.createFolder(ko, void 0, t);
3674
+ r = await n.createFolder(Fo, void 0, t);
3675
3675
  }
3676
3676
  const a = String(r._id), l = await n.listFolders({ parentFolderId: a, projectId: t, archived: !1 });
3677
- let p = s(l.filter((d) => d.name === No && String(d.parentId) === a));
3677
+ let p = s(l.filter((d) => d.name === Po && String(d.parentId) === a));
3678
3678
  if (!p) {
3679
3679
  if (!e) return null;
3680
- p = await n.createFolder(No, a, t);
3680
+ p = await n.createFolder(Po, a, t);
3681
3681
  }
3682
3682
  return String(p._id);
3683
3683
  }
3684
- const al = (n) => String(n._id ?? n.id ?? ""), cl = (n) => String(n.tag ?? n.versionTag ?? ""), Un = (n) => {
3684
+ const ll = (n) => String(n._id ?? n.id ?? ""), hl = (n) => String(n.tag ?? n.versionTag ?? ""), qn = (n) => {
3685
3685
  var t;
3686
3686
  return Number(((t = /(\d+)/.exec(n)) == null ? void 0 : t[1]) ?? -1);
3687
3687
  };
3688
- async function Es(n, t) {
3689
- const e = await Aa(n, t, !1);
3688
+ async function Ts(n, t) {
3689
+ const e = await Oa(n, t, !1);
3690
3690
  if (!e) return /* @__PURE__ */ new Map();
3691
3691
  const s = await n.listFiles({ folderId: e }), i = /* @__PURE__ */ new Map();
3692
3692
  for (const r of s) {
3693
3693
  const a = String(r.name ?? "");
3694
- a.endsWith(".recipe.json") && i.set(a.slice(0, -12), { id: al(r) });
3694
+ a.endsWith(".recipe.json") && i.set(a.slice(0, -12), { id: ll(r) });
3695
3695
  }
3696
3696
  return i;
3697
3697
  }
3698
- async function Xs(n, t, e) {
3698
+ async function Zs(n, t, e) {
3699
3699
  var r;
3700
3700
  const s = await n.downloadFile(t, e ? { versionTag: e } : void 0), i = JSON.parse(await s.text());
3701
- if ((i == null ? void 0 : i.schema) !== _a || !((r = i.manifest) != null && r.name) || typeof i.code != "string")
3701
+ if ((i == null ? void 0 : i.schema) !== Ca || !((r = i.manifest) != null && r.name) || typeof i.code != "string")
3702
3702
  throw new Error(`This is not a recipe this library can read (${String(i == null ? void 0 : i.schema)}).`);
3703
3703
  return i;
3704
3704
  }
3705
- async function Ts(n, t) {
3706
- return (await n.listVersions(t)).map((s) => ({ tag: cl(s), createdAt: String(s.createdAt ?? "") })).filter((s) => s.tag).sort((s, i) => Un(s.tag) - Un(i.tag));
3705
+ async function Ms(n, t) {
3706
+ return (await n.listVersions(t)).map((s) => ({ tag: hl(s), createdAt: String(s.createdAt ?? "") })).filter((s) => s.tag).sort((s, i) => qn(s.tag) - qn(i.tag));
3707
3707
  }
3708
- var Fs;
3709
- class ll {
3708
+ var Ps;
3709
+ class fl {
3710
3710
  constructor(t, e) {
3711
3711
  /** Compiled code, by file id and version: a version never changes, so it is compiled once. */
3712
- Lt(this, Fs, /* @__PURE__ */ new Map());
3712
+ Lt(this, Ps, /* @__PURE__ */ new Map());
3713
3713
  this.client = t, this.builtinNames = e;
3714
3714
  }
3715
3715
  /** The project's recipes, each its latest version. */
3716
3716
  async list(t) {
3717
- const e = await Es(this.client, t);
3717
+ const e = await Ts(this.client, t);
3718
3718
  return (await Promise.all(
3719
3719
  [...e.entries()].map(async ([, { id: i }]) => {
3720
3720
  var r;
3721
3721
  try {
3722
- const a = await Ts(this.client, i), l = (r = a[a.length - 1]) == null ? void 0 : r.tag, p = await Xs(this.client, i, l);
3722
+ const a = await Ms(this.client, i), l = (r = a[a.length - 1]) == null ? void 0 : r.tag, p = await Zs(this.client, i, l);
3723
3723
  return {
3724
3724
  manifest: p.manifest,
3725
3725
  origin: "project",
@@ -3735,13 +3735,13 @@ class ll {
3735
3735
  }
3736
3736
  /** Every saved version of a project recipe, oldest first. */
3737
3737
  async versions(t, e) {
3738
- const s = (await Es(this.client, t)).get(e);
3738
+ const s = (await Ts(this.client, t)).get(e);
3739
3739
  if (!s) throw new Error(`The project has no recipe named "${e}".`);
3740
- const i = await Ts(this.client, s.id);
3740
+ const i = await Ms(this.client, s.id);
3741
3741
  return await Promise.all(
3742
3742
  i.map(async ({ tag: r, createdAt: a }) => {
3743
3743
  try {
3744
- const l = await Xs(this.client, s.id, r);
3744
+ const l = await Zs(this.client, s.id, r);
3745
3745
  return { version: r, author: l.author, note: l.note, savedAt: l.savedAt ?? a };
3746
3746
  } catch {
3747
3747
  return { version: r, savedAt: a };
@@ -3752,11 +3752,11 @@ class ll {
3752
3752
  /** A project recipe's file as saved: its manifest and its code (the latest version unless one is named). */
3753
3753
  async source(t, e, s) {
3754
3754
  var a;
3755
- const i = (await Es(this.client, t)).get(e);
3755
+ const i = (await Ts(this.client, t)).get(e);
3756
3756
  if (!i) throw new Error(`The project has no recipe named "${e}".`);
3757
- const r = s ?? ((a = (await Ts(this.client, i.id)).pop()) == null ? void 0 : a.tag);
3757
+ const r = s ?? ((a = (await Ms(this.client, i.id)).pop()) == null ? void 0 : a.tag);
3758
3758
  if (!r) throw new Error(`The recipe "${e}" has no saved version.`);
3759
- return { ...await Xs(this.client, i.id, r), version: r };
3759
+ return { ...await Zs(this.client, i.id, r), version: r };
3760
3760
  }
3761
3761
  /**
3762
3762
  * Saves a recipe in the project: a new file the first time, a new version after. Checked before it is
@@ -3765,29 +3765,29 @@ class ll {
3765
3765
  */
3766
3766
  async save(t, e, s) {
3767
3767
  const { manifest: i, code: r } = e;
3768
- if (!ol.test((i == null ? void 0 : i.name) ?? ""))
3768
+ if (!cl.test((i == null ? void 0 : i.name) ?? ""))
3769
3769
  throw new Error('A recipe name is lower case letters, digits and dashes, 2 to 63 of them: "walls-from-ifc".');
3770
3770
  if (this.builtinNames().has(i.name))
3771
3771
  throw new Error(`"${i.name}" is a built-in recipe. Give yours a name of its own.`);
3772
3772
  if (!i.to || !i.description || !Array.isArray(i.inputs))
3773
3773
  throw new Error("A recipe says what it writes (`to`), what it does (`description`) and what it reads (`inputs`).");
3774
- await Fo(i, r);
3774
+ await Lo(i, r);
3775
3775
  const a = {
3776
- schema: _a,
3776
+ schema: Ca,
3777
3777
  manifest: i,
3778
3778
  code: r,
3779
3779
  author: s.author,
3780
3780
  ...s.note ? { note: s.note } : {},
3781
3781
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
3782
- }, l = new Blob([JSON.stringify(a, null, 2)], { type: "application/json" }), p = (await Es(this.client, t)).get(i.name);
3782
+ }, l = new Blob([JSON.stringify(a, null, 2)], { type: "application/json" }), p = (await Ts(this.client, t)).get(i.name);
3783
3783
  if (p) {
3784
- const c = await Ts(this.client, p.id), E = `v${Math.max(0, ...c.map((b) => Un(b.tag))) + 1}`;
3784
+ const c = await Ms(this.client, p.id), E = `v${Math.max(0, ...c.map((b) => qn(b.tag))) + 1}`;
3785
3785
  return await this.client.createVersion(p.id, l, E), E;
3786
3786
  }
3787
- const d = await Aa(this.client, t, !0);
3787
+ const d = await Oa(this.client, t, !0);
3788
3788
  return await this.client.createFile({
3789
3789
  file: l,
3790
- name: il(i.name),
3790
+ name: ol(i.name),
3791
3791
  versionTag: "v1",
3792
3792
  projectId: t,
3793
3793
  parentFolderId: d
@@ -3796,40 +3796,40 @@ class ll {
3796
3796
  /** A project recipe, ready to run: the latest version unless one is named. */
3797
3797
  async load(t, e, s) {
3798
3798
  var p;
3799
- const i = (await Es(this.client, t)).get(e);
3799
+ const i = (await Ts(this.client, t)).get(e);
3800
3800
  if (!i) throw new Error(`The project has no recipe named "${e}".`);
3801
- const r = s ?? ((p = (await Ts(this.client, i.id)).pop()) == null ? void 0 : p.tag);
3801
+ const r = s ?? ((p = (await Ms(this.client, i.id)).pop()) == null ? void 0 : p.tag);
3802
3802
  if (!r) throw new Error(`The recipe "${e}" has no saved version.`);
3803
3803
  const a = `${i.id}@${r}`;
3804
- let l = O(this, Fs).get(a);
3804
+ let l = O(this, Ps).get(a);
3805
3805
  if (!l) {
3806
- const d = await Xs(this.client, i.id, r);
3807
- l = await Fo(d.manifest, d.code), O(this, Fs).set(a, l);
3806
+ const d = await Zs(this.client, i.id, r);
3807
+ l = await Lo(d.manifest, d.code), O(this, Ps).set(a, l);
3808
3808
  }
3809
3809
  return { recipe: l, version: r };
3810
3810
  }
3811
3811
  }
3812
- Fs = new WeakMap();
3813
- async function Fo(n, t) {
3812
+ Ps = new WeakMap();
3813
+ async function Lo(n, t) {
3814
3814
  var i;
3815
3815
  let e;
3816
3816
  try {
3817
- e = await import(`data:text/javascript;base64,${hl(t)}`);
3817
+ e = await import(`data:text/javascript;base64,${dl(t)}`);
3818
3818
  } catch (r) {
3819
3819
  throw new Error(`The recipe's code does not load: ${r instanceof Error ? r.message : String(r)}`);
3820
3820
  }
3821
3821
  const s = e.run ?? ((i = e.default) == null ? void 0 : i.run);
3822
3822
  if (typeof s != "function") throw new Error("The recipe's code exports no `run(context)` function.");
3823
- return { ...n, run: (r) => s({ ...r, kit: rl }) };
3823
+ return { ...n, run: (r) => s({ ...r, kit: al }) };
3824
3824
  }
3825
- function hl(n) {
3825
+ function dl(n) {
3826
3826
  const t = new TextEncoder().encode(n);
3827
3827
  let e = "";
3828
3828
  for (let s = 0; s < t.length; s += 32768) e += String.fromCharCode(...t.subarray(s, s + 32768));
3829
3829
  return btoa(e);
3830
3830
  }
3831
- async function nh(n) {
3832
- const t = n instanceof Uint8Array ? n : new Uint8Array(await n.arrayBuffer()), { items: e, metadata: s } = await ri(t), i = e.filter((r) => r.attrs["flow:op"]).map((r) => {
3831
+ async function oh(n) {
3832
+ const t = n instanceof Uint8Array ? n : new Uint8Array(await n.arrayBuffer()), { items: e, metadata: s } = await ai(t), i = e.filter((r) => r.attrs["flow:op"]).map((r) => {
3833
3833
  const a = {};
3834
3834
  for (const [l, p] of Object.entries(r.attrs)) l.startsWith("flow:") || (a[l] = p);
3835
3835
  return {
@@ -3841,20 +3841,20 @@ async function nh(n) {
3841
3841
  });
3842
3842
  return { envelope: s ?? {}, changes: i };
3843
3843
  }
3844
- class Ca extends Error {
3844
+ class Ra extends Error {
3845
3845
  constructor(t) {
3846
3846
  super(t), this.name = "UpToDate";
3847
3847
  }
3848
3848
  }
3849
- var Ne, Ps, Ls;
3850
- class fl {
3849
+ var Ne, Ls, Bs;
3850
+ class ul {
3851
3851
  constructor(t) {
3852
3852
  Lt(this, Ne, /* @__PURE__ */ new Map());
3853
- Lt(this, Ps, /* @__PURE__ */ new Map());
3854
3853
  Lt(this, Ls, /* @__PURE__ */ new Map());
3854
+ Lt(this, Bs, /* @__PURE__ */ new Map());
3855
3855
  /** The project's own recipes: list, save, versions, load (see project-recipes.ts). */
3856
- he(this, "project");
3857
- this.client = t, this.project = new ll(t, () => new Set(O(this, Ne).keys()));
3856
+ le(this, "project");
3857
+ this.client = t, this.project = new fl(t, () => new Set(O(this, Ne).keys()));
3858
3858
  }
3859
3859
  /**
3860
3860
  * Says how this host turns files of one extension ('ifc') into records, so a
@@ -3863,19 +3863,19 @@ class fl {
3863
3863
  * that has it provides it.
3864
3864
  */
3865
3865
  provideImporter(t, e) {
3866
- O(this, Ps).set(t.toLowerCase(), e);
3866
+ O(this, Ls).set(t.toLowerCase(), e);
3867
3867
  }
3868
3868
  /** Says how this host reads a file's shapes (its geometry, per element and per type), for recipes that make families. */
3869
3869
  provideShapes(t, e) {
3870
- O(this, Ls).set(t.toLowerCase(), e);
3870
+ O(this, Bs).set(t.toLowerCase(), e);
3871
3871
  }
3872
3872
  /** The shapes reader provided for an extension, or undefined. */
3873
3873
  shapesFor(t) {
3874
- return O(this, Ls).get(t.toLowerCase());
3874
+ return O(this, Bs).get(t.toLowerCase());
3875
3875
  }
3876
3876
  /** The importer provided for an extension, or undefined. */
3877
3877
  importerFor(t) {
3878
- return O(this, Ps).get(t.toLowerCase());
3878
+ return O(this, Ls).get(t.toLowerCase());
3879
3879
  }
3880
3880
  /** Registers a recipe. One per name; a second with the same name throws. */
3881
3881
  register(t) {
@@ -3921,7 +3921,7 @@ class fl {
3921
3921
  if ((i == null ? void 0 : i.kind) !== "project-file") return [];
3922
3922
  const r = (i.extensions ?? []).map((d) => d.toLowerCase()), l = (await this.client.documents(e).list()).filter(
3923
3923
  (d) => d.descriptor.native && (r.length === 0 || r.includes(d.descriptor.native.format.toLowerCase()))
3924
- ), p = await dl(
3924
+ ), p = await pl(
3925
3925
  this.client,
3926
3926
  l.map((d) => d.descriptor.native.fileId)
3927
3927
  );
@@ -3952,7 +3952,7 @@ class fl {
3952
3952
  projectId: e.projectId,
3953
3953
  target: e.target,
3954
3954
  made: e.made ?? /* @__PURE__ */ new Map(),
3955
- opId: e.opId ?? ua(),
3955
+ opId: e.opId ?? ma(),
3956
3956
  input: e.input,
3957
3957
  settings: e.settings ?? {},
3958
3958
  progress: e.progress ?? (() => {
@@ -3960,8 +3960,8 @@ class fl {
3960
3960
  });
3961
3961
  }
3962
3962
  }
3963
- Ne = new WeakMap(), Ps = new WeakMap(), Ls = new WeakMap();
3964
- async function dl(n, t) {
3963
+ Ne = new WeakMap(), Ls = new WeakMap(), Bs = new WeakMap();
3964
+ async function pl(n, t) {
3965
3965
  const e = /* @__PURE__ */ new Map();
3966
3966
  if (t.length === 0) return e;
3967
3967
  const s = (r) => {
@@ -3984,8 +3984,8 @@ async function dl(n, t) {
3984
3984
  })
3985
3985
  ), e;
3986
3986
  }
3987
- const Po = 100;
3988
- function ul(n) {
3987
+ const Bo = 100;
3988
+ function ml(n) {
3989
3989
  try {
3990
3990
  const t = JSON.parse(n);
3991
3991
  if (t && typeof t == "object") {
@@ -4000,29 +4000,73 @@ function ul(n) {
4000
4000
  }
4001
4001
  return {};
4002
4002
  }
4003
- function pl(n) {
4003
+ function gl(n) {
4004
4004
  if (!n || typeof n != "object") return;
4005
4005
  const t = n.retryAfter;
4006
4006
  return typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
4007
4007
  }
4008
- class li extends Error {
4008
+ class fi extends Error {
4009
4009
  constructor(e, s, i, r) {
4010
- const a = ul(i);
4010
+ const a = ml(i);
4011
4011
  super(a.message ?? `${s || "Request failed"} (${e})`);
4012
- he(this, "status");
4013
- he(this, "code");
4014
- he(this, "details");
4015
- he(this, "body");
4012
+ le(this, "status");
4013
+ le(this, "code");
4014
+ le(this, "details");
4015
+ le(this, "body");
4016
4016
  /**
4017
4017
  * Seconds to wait before retrying, taken from the `Retry-After` header or
4018
4018
  * from `details.retryAfter`. Only present on rate-limited (429) responses.
4019
4019
  */
4020
- he(this, "retryAfter");
4021
- this.name = "RequestError", this.status = e, this.code = a.code, this.details = a.details, this.body = i, this.retryAfter = r ?? pl(a.details);
4020
+ le(this, "retryAfter");
4021
+ this.name = "RequestError", this.status = e, this.code = a.code, this.details = a.details, this.body = i, this.retryAfter = r ?? gl(a.details);
4022
+ }
4023
+ }
4024
+ const $n = () => {
4025
+ if (typeof window > "u") return null;
4026
+ const n = window.__THATOPEN_CONTEXT__;
4027
+ return n && typeof n.cacheSet == "function" ? n : null;
4028
+ };
4029
+ var as;
4030
+ class yl {
4031
+ constructor() {
4032
+ Lt(this, as, /* @__PURE__ */ new Map());
4033
+ }
4034
+ /** What was kept under `key`, or undefined. */
4035
+ get(t) {
4036
+ var s;
4037
+ const e = $n();
4038
+ return e ? (s = e.cache) == null ? void 0 : s[t] : O(this, as).get(t);
4039
+ }
4040
+ /** Kept for the next time this app opens in this project (structured-cloneable values, bytes too). */
4041
+ set(t, e) {
4042
+ const s = $n();
4043
+ s ? s.cacheSet(t, e) : O(this, as).set(t, e);
4044
+ }
4045
+ delete(t) {
4046
+ var s;
4047
+ const e = $n();
4048
+ e ? (s = e.cacheDelete) == null || s.call(e, t) : O(this, as).delete(t);
4049
+ }
4050
+ /** One of the project's listings as it was last answered, if it is this project's. */
4051
+ answer(t, e) {
4052
+ const s = this.get(t);
4053
+ return s && s.projectId === e ? s : void 0;
4054
+ }
4055
+ /** @internal The client keeping a fresh listing. */
4056
+ keepAnswer(t, e, s) {
4057
+ try {
4058
+ this.set(t, {
4059
+ projectId: e,
4060
+ value: s,
4061
+ at: Date.now()
4062
+ });
4063
+ } catch {
4064
+ }
4022
4065
  }
4023
4066
  }
4024
- const Te = "item/folder", Bt = "item", Lo = 12e3, je = "processor", ml = "npm-registry", Ae = "hidden", Mn = "FILE", $n = "TOOL", In = "APP", gl = 500, Bo = 3e4, yl = 2e3, wl = 15e3, bl = (n) => /^\/?project\/permissions\/check/.test(n), vl = (n) => /^\/?(item\/folder\/?$|item\/?$|item\/folder\/[^/]+\/items\/?$|project\/[^/]+\/data\/?$)/.test(n), Ms = /* @__PURE__ */ new Map(), El = 0.25, Tl = (n) => new Promise((t) => setTimeout(t, n));
4025
- function Ml(n) {
4067
+ as = new WeakMap();
4068
+ const Te = "item/folder", Bt = "item", jo = 12e3, je = "processor", wl = "npm-registry", Ae = "hidden", In = "FILE", Sn = "TOOL", xn = "APP", bl = 500, Do = 3e4, vl = 2e3, El = 15e3, Tl = (n) => /^\/?project\/permissions\/check/.test(n), Ml = (n) => /^\/?(item\/folder\/?$|item\/?$|item\/folder\/[^/]+\/items\/?$|project\/[^/]+\/data\/?$)/.test(n), $s = /* @__PURE__ */ new Map(), $l = 0.25, Il = (n) => new Promise((t) => setTimeout(t, n));
4069
+ function Sl(n) {
4026
4070
  var i, r;
4027
4071
  const t = (r = (i = n.headers) == null ? void 0 : i.get) == null ? void 0 : r.call(i, "Retry-After");
4028
4072
  if (!t) return;
@@ -4032,18 +4076,18 @@ function Ml(n) {
4032
4076
  if (!Number.isNaN(s))
4033
4077
  return Math.max(0, (s - Date.now()) / 1e3);
4034
4078
  }
4035
- function $l(n) {
4036
- return n instanceof li ? n.status === 429 || n.status >= 500 : !0;
4079
+ function xl(n) {
4080
+ return n instanceof fi ? n.status === 429 || n.status >= 500 : !0;
4037
4081
  }
4038
- function Il(n, t) {
4082
+ function _l(n, t) {
4039
4083
  const e = Math.min(
4040
- gl * 2 ** t,
4041
- Bo
4042
- ), s = e * El * Math.random(), i = n instanceof li && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
4043
- return i != null ? Math.min(i, Bo) + s : e + s;
4084
+ bl * 2 ** t,
4085
+ Do
4086
+ ), s = e * $l * Math.random(), i = n instanceof fi && n.retryAfter != null ? n.retryAfter * 1e3 : void 0;
4087
+ return i != null ? Math.min(i, Do) + s : e + s;
4044
4088
  }
4045
- var q, rn, vt, qn, qe, as, Oa, cs, dn, Bs, Ke, Xe, on, js, _s, an, cn, Vn, Gn, Hn;
4046
- const hi = class hi {
4089
+ var q, on, vt, Gn, qe, cs, ka, ls, un, js, Ke, Xe, an, Ds, As, cn, ln, Hn, zn, Wn;
4090
+ const di = class di {
4047
4091
  /**
4048
4092
  * Creates a new EngineServicesClient instance.
4049
4093
  * @param accessToken - API access token (obtained from the platform dashboard)
@@ -4053,31 +4097,38 @@ const hi = class hi {
4053
4097
  */
4054
4098
  constructor(t, e, s) {
4055
4099
  Lt(this, q);
4056
- he(this, "apiUrl");
4057
- he(this, "accessToken");
4058
- he(this, "wsUrl");
4059
- he(this, "retries");
4060
- he(this, "useBearer");
4061
- he(this, "builtInGlobals", null);
4100
+ le(this, "apiUrl");
4101
+ le(this, "accessToken");
4102
+ le(this, "wsUrl");
4103
+ le(this, "retries");
4104
+ le(this, "useBearer");
4105
+ le(this, "builtInGlobals", null);
4062
4106
  /**
4063
4107
  * URL of a local execution server (e.g. `http://localhost:4001`).
4064
4108
  * When set, execution methods are routed to this server instead of the cloud API.
4065
4109
  * Set to `null` to disable local routing and use the cloud API.
4066
4110
  */
4067
- he(this, "localServerUrl", null);
4111
+ le(this, "localServerUrl", null);
4068
4112
  /**
4069
4113
  * The platform context this client was created with.
4070
4114
  * Contains `appId`, `projectId`, `accessToken`, and `apiUrl`.
4071
4115
  * Populated automatically when using {@link fromPlatformContext}.
4072
4116
  */
4073
- he(this, "context");
4074
- Lt(this, as, /* @__PURE__ */ new Map());
4075
- Lt(this, cs);
4076
- Lt(this, dn, Date.now());
4077
- Lt(this, Bs, !1);
4117
+ le(this, "context");
4118
+ /**
4119
+ * What this app saw last time, to open on at once and correct afterwards
4120
+ * ({@link AppCache}): kept by the platform page, or in memory outside it. The
4121
+ * project's listings (`documents`, `files`, `projectData`) are kept here
4122
+ * whenever a fresh answer arrives; an app keeps its own under `app:` keys.
4123
+ */
4124
+ le(this, "cache", new yl());
4125
+ Lt(this, cs, /* @__PURE__ */ new Map());
4126
+ Lt(this, ls);
4127
+ Lt(this, un, Date.now());
4128
+ Lt(this, js, !1);
4078
4129
  Lt(this, Ke, 0);
4079
4130
  Lt(this, Xe, !1);
4080
- Lt(this, js);
4131
+ Lt(this, Ds);
4081
4132
  const { retries: i = 0, useBearer: r = !1, localServerUrl: a } = s || {};
4082
4133
  let l = e;
4083
4134
  if (l.charAt(l.length - 1) === "/" && (l = l.slice(0, -1)), this.apiUrl = `${l}/api`, this.accessToken = t, this.wsUrl = l, this.retries = i, this.useBearer = r, this.context = { appId: "", projectId: "", accessToken: t, apiUrl: e }, a) {
@@ -4102,7 +4153,7 @@ const hi = class hi {
4102
4153
  * ```
4103
4154
  */
4104
4155
  static fromPlatformContext(t) {
4105
- const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new hi(e.accessToken, e.apiUrl, {
4156
+ const e = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, s = new di(e.accessToken, e.apiUrl, {
4106
4157
  ...t,
4107
4158
  useBearer: !0
4108
4159
  });
@@ -4188,19 +4239,22 @@ const hi = class hi {
4188
4239
  */
4189
4240
  async listFiles(t) {
4190
4241
  const { folderId: e, archived: s, projectId: i, versions: r } = t || {};
4191
- return e ? await I(this, q, vt).call(this, "GET", `${Te}/${e}/items`, {
4192
- query: {
4193
- itemType: Mn,
4194
- archived: s,
4195
- ...r && { showVersions: !0 }
4196
- }
4197
- }) : await I(this, q, vt).call(this, "GET", `${Bt}`, {
4242
+ if (e)
4243
+ return await I(this, q, vt).call(this, "GET", `${Te}/${e}/items`, {
4244
+ query: {
4245
+ itemType: In,
4246
+ archived: s,
4247
+ ...r && { showVersions: !0 }
4248
+ }
4249
+ });
4250
+ const a = await I(this, q, vt).call(this, "GET", `${Bt}`, {
4198
4251
  query: {
4199
- itemType: Mn,
4252
+ itemType: In,
4200
4253
  archived: s,
4201
4254
  ...i && { projectId: i }
4202
4255
  }
4203
4256
  });
4257
+ return i && !s && this.cache.keepAnswer("files", i, a), a;
4204
4258
  }
4205
4259
  /**
4206
4260
  * Every document descriptor of a project in one request, read by the
@@ -4210,14 +4264,14 @@ const hi = class hi {
4210
4264
  * by one".
4211
4265
  */
4212
4266
  async listDocumentDescriptors(t) {
4213
- const e = O(this, as).get(t);
4267
+ const e = O(this, cs).get(t);
4214
4268
  if (e) return await e;
4215
- const s = I(this, q, Oa).call(this, t);
4216
- O(this, as).set(t, s);
4269
+ const s = I(this, q, ka).call(this, t);
4270
+ O(this, cs).set(t, s);
4217
4271
  try {
4218
4272
  return await s;
4219
4273
  } finally {
4220
- O(this, as).delete(t);
4274
+ O(this, cs).delete(t);
4221
4275
  }
4222
4276
  }
4223
4277
  async exportProjectDocuments(t, e) {
@@ -4233,7 +4287,7 @@ const hi = class hi {
4233
4287
  * @returns The file item, optionally with version history.
4234
4288
  */
4235
4289
  async getFile(t, e) {
4236
- return await I(this, q, Gn).call(this, t, e);
4290
+ return await I(this, q, zn).call(this, t, e);
4237
4291
  }
4238
4292
  /**
4239
4293
  * Uploads a new file.
@@ -4241,7 +4295,7 @@ const hi = class hi {
4241
4295
  * @returns The created item and its first version.
4242
4296
  */
4243
4297
  async createFile(t) {
4244
- return await I(this, q, cn).call(this, t, Mn);
4298
+ return await I(this, q, ln).call(this, t, In);
4245
4299
  }
4246
4300
  /**
4247
4301
  * Updates an existing file. Can rename, move to a different folder,
@@ -4251,7 +4305,7 @@ const hi = class hi {
4251
4305
  * @returns The updated item and/or the new version.
4252
4306
  */
4253
4307
  async updateFile(t, e) {
4254
- return await I(this, q, Vn).call(this, t, e);
4308
+ return await I(this, q, Hn).call(this, t, e);
4255
4309
  }
4256
4310
  /**
4257
4311
  * Archives (soft-deletes) a file. Can be recovered with {@link recoverFile}.
@@ -4274,7 +4328,7 @@ const hi = class hi {
4274
4328
  * @returns A fetch Response containing the file data.
4275
4329
  */
4276
4330
  async downloadFile(t, e) {
4277
- return await I(this, q, an).call(this, t, e);
4331
+ return await I(this, q, cn).call(this, t, e);
4278
4332
  }
4279
4333
  /**
4280
4334
  * Retrieves the free-JSON metadata for a specific file version.
@@ -4326,7 +4380,7 @@ const hi = class hi {
4326
4380
  */
4327
4381
  async getFileVersionMetadataBatch(t, e) {
4328
4382
  const { withDraft: s } = e || {};
4329
- return await I(this, q, _s).call(this, t, async (i) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/version-metadata`, {
4383
+ return await I(this, q, As).call(this, t, async (i) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/version-metadata`, {
4330
4384
  body: JSON.stringify({
4331
4385
  entries: i,
4332
4386
  ...s !== void 0 && { withDraft: s }
@@ -4371,7 +4425,7 @@ const hi = class hi {
4371
4425
  * @param folderIds - The folder ids to resolve.
4372
4426
  */
4373
4427
  async getFoldersBatch(t) {
4374
- return await I(this, q, _s).call(this, t, async (e) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/folders`, {
4428
+ return await I(this, q, As).call(this, t, async (e) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/folders`, {
4375
4429
  body: JSON.stringify({ folderIds: e }),
4376
4430
  contentType: "application/json"
4377
4431
  })).results);
@@ -4437,12 +4491,12 @@ const hi = class hi {
4437
4491
  const { folderId: e, ShowVersions: s, projectId: i } = t || {};
4438
4492
  return e ? await I(this, q, vt).call(this, "GET", `${Te}/${e}/items`, {
4439
4493
  query: {
4440
- itemType: $n,
4494
+ itemType: Sn,
4441
4495
  ...s && { ShowVersions: s }
4442
4496
  }
4443
4497
  }) : await I(this, q, vt).call(this, "GET", `${Bt}`, {
4444
4498
  query: {
4445
- itemType: $n,
4499
+ itemType: Sn,
4446
4500
  ...s && { ShowVersions: s },
4447
4501
  ...i && { projectId: i }
4448
4502
  }
@@ -4454,7 +4508,7 @@ const hi = class hi {
4454
4508
  * @param props - Options such as whether to include versions.
4455
4509
  */
4456
4510
  async getComponent(t, e) {
4457
- return await I(this, q, Gn).call(this, t, e);
4511
+ return await I(this, q, zn).call(this, t, e);
4458
4512
  }
4459
4513
  /**
4460
4514
  * Creates a new component with the given file and version properties.
@@ -4463,7 +4517,7 @@ const hi = class hi {
4463
4517
  */
4464
4518
  async createComponent(t) {
4465
4519
  const { componentProps: e } = t;
4466
- return await I(this, q, cn).call(this, t, $n, e);
4520
+ return await I(this, q, ln).call(this, t, Sn, e);
4467
4521
  }
4468
4522
  /**
4469
4523
  * Updates an existing component. Can rename, move, and/or upload a new version.
@@ -4473,7 +4527,7 @@ const hi = class hi {
4473
4527
  */
4474
4528
  async updateComponent(t, e) {
4475
4529
  const { componentProps: s } = e;
4476
- return await I(this, q, Vn).call(this, t, e, s);
4530
+ return await I(this, q, Hn).call(this, t, e, s);
4477
4531
  }
4478
4532
  /**
4479
4533
  * Downloads a component's full ZIP file. Returns the raw fetch Response.
@@ -4482,7 +4536,7 @@ const hi = class hi {
4482
4536
  * @returns A fetch Response containing the ZIP data.
4483
4537
  */
4484
4538
  async downloadComponent(t, e) {
4485
- return await I(this, q, an).call(this, t, e);
4539
+ return await I(this, q, cn).call(this, t, e);
4486
4540
  }
4487
4541
  /**
4488
4542
  * Downloads only the JavaScript bundle from a component's ZIP.
@@ -4599,11 +4653,11 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4599
4653
  throw new Error("globals.OBC must include Components");
4600
4654
  if (!(i != null && i.Manager)) throw new Error("globals.BUI must include Manager");
4601
4655
  const r = new s.Components();
4602
- if (i.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(r, ...e), r.init(), globalThis.__thatOpenShellSaysLoaded && !O(this, cs) && Ht(this, cs, this.holdAppLoaded()), Ht(this, Bs, !0), I(this, q, on).call(this), !O(this, Xe)) {
4603
- const a = typeof performance < "u" ? performance.now() : Date.now() - O(this, dn);
4656
+ if (i.Manager.init(), this.setBuiltInGlobals(t), await this.initBuiltInComponents(r, ...e), r.init(), globalThis.__thatOpenShellSaysLoaded && !O(this, ls) && Ht(this, ls, this.holdAppLoaded()), Ht(this, js, !0), I(this, q, an).call(this), !O(this, Xe)) {
4657
+ const a = typeof performance < "u" ? performance.now() : Date.now() - O(this, un);
4604
4658
  setTimeout(() => {
4605
- Ht(this, Ke, 0), I(this, q, on).call(this);
4606
- }, Math.max(0, Lo - a));
4659
+ Ht(this, Ke, 0), I(this, q, an).call(this);
4660
+ }, Math.max(0, jo - a));
4607
4661
  }
4608
4662
  return { components: r };
4609
4663
  }
@@ -4619,13 +4673,13 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4619
4673
  * after this client was made at the latest, before the platform's own
4620
4674
  * deadline (15 s) calls the app dead.
4621
4675
  */
4622
- holdAppLoaded(t = Lo) {
4676
+ holdAppLoaded(t = jo) {
4623
4677
  if (O(this, Xe)) return () => {
4624
4678
  };
4625
- wn(this, Ke)._++;
4679
+ bn(this, Ke)._++;
4626
4680
  let e = !1;
4627
4681
  const s = () => {
4628
- e || (e = !0, clearTimeout(i), wn(this, Ke)._--, I(this, q, on).call(this));
4682
+ e || (e = !0, clearTimeout(i), bn(this, Ke)._--, I(this, q, an).call(this));
4629
4683
  }, i = setTimeout(s, t);
4630
4684
  return s;
4631
4685
  }
@@ -4635,7 +4689,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4635
4689
  */
4636
4690
  appReady() {
4637
4691
  var t;
4638
- (t = O(this, cs)) == null || t.call(this);
4692
+ (t = O(this, ls)) == null || t.call(this);
4639
4693
  }
4640
4694
  /**
4641
4695
  * Reports an error to the platform via the {@link AppEventOrchestrator.appError} callback.
@@ -4656,12 +4710,12 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4656
4710
  const { folderId: e, ShowVersions: s, projectId: i } = t || {};
4657
4711
  return e ? await I(this, q, vt).call(this, "GET", `${Te}/${e}/items`, {
4658
4712
  query: {
4659
- itemType: In,
4713
+ itemType: xn,
4660
4714
  ...s && { ShowVersions: s }
4661
4715
  }
4662
4716
  }) : await I(this, q, vt).call(this, "GET", `${Bt}`, {
4663
4717
  query: {
4664
- itemType: In,
4718
+ itemType: xn,
4665
4719
  ...s && { ShowVersions: s },
4666
4720
  ...i && { projectId: i }
4667
4721
  }
@@ -4674,7 +4728,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4674
4728
  */
4675
4729
  async createApp(t) {
4676
4730
  const { appProps: e } = t;
4677
- return await I(this, q, cn).call(this, t, In, e);
4731
+ return await I(this, q, ln).call(this, t, xn, e);
4678
4732
  }
4679
4733
  /**
4680
4734
  * Downloads an app's full ZIP file. Returns the raw fetch Response.
@@ -4683,7 +4737,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4683
4737
  * @returns A fetch Response containing the ZIP data.
4684
4738
  */
4685
4739
  async downloadApp(t, e) {
4686
- return await I(this, q, an).call(this, t, e);
4740
+ return await I(this, q, cn).call(this, t, e);
4687
4741
  }
4688
4742
  /**
4689
4743
  * Downloads only the JavaScript bundle from an app's ZIP.
@@ -4718,7 +4772,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4718
4772
  * @returns The registry, scope, read-only token, and assembled `.npmrc`.
4719
4773
  */
4720
4774
  async getNpmCredentials() {
4721
- return await I(this, q, vt).call(this, "GET", `${ml}/credentials`);
4775
+ return await I(this, q, vt).call(this, "GET", `${wl}/credentials`);
4722
4776
  }
4723
4777
  // ─── Execution ───────────────────────────────────────────────────
4724
4778
  /**
@@ -4824,7 +4878,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4824
4878
  * @param onUpdateCallback - Callback invoked on each progress/result event.
4825
4879
  */
4826
4880
  async onExecutionProgress(t, e) {
4827
- const s = this.localServerUrl ?? this.wsUrl, i = await Cs(s, {
4881
+ const s = this.localServerUrl ?? this.wsUrl, i = await Os(s, {
4828
4882
  auth: { accessToken: this.accessToken },
4829
4883
  transports: ["websocket"]
4830
4884
  });
@@ -4843,7 +4897,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4843
4897
  * renderable views. See `src/core/documents.ts` for the model and schema.
4844
4898
  */
4845
4899
  documents(t) {
4846
- return new ma(this, t);
4900
+ return new ya(this, t);
4847
4901
  }
4848
4902
  /**
4849
4903
  * A project's history of connected documents (Revit models, AutoCAD
@@ -4852,14 +4906,14 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4852
4906
  * or write it; the storage underneath is private and will move.
4853
4907
  */
4854
4908
  history(t) {
4855
- return new oa(this, t);
4909
+ return new ca(this, t);
4856
4910
  }
4857
4911
  /**
4858
4912
  * The recipe registry and runner: scripts that write change requests in a
4859
4913
  * native application's language. See `src/core/recipes.ts`.
4860
4914
  */
4861
4915
  get recipes() {
4862
- return O(this, js) ?? Ht(this, js, new fl(this)), O(this, js);
4916
+ return O(this, Ds) ?? Ht(this, Ds, new ul(this)), O(this, Ds);
4863
4917
  }
4864
4918
  // ─── Hidden Files ────────────────────────────────────────────────
4865
4919
  /**
@@ -4955,7 +5009,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
4955
5009
  * 900 (15 min) server-side; values are clamped to that range.
4956
5010
  */
4957
5011
  async getHiddenFileSignedUrlsBatch(t, e) {
4958
- return await I(this, q, _s).call(this, t, async (s) => (await I(this, q, vt).call(this, "POST", `${Bt}/${Ae}/signed-url/batch`, {
5012
+ return await I(this, q, As).call(this, t, async (s) => (await I(this, q, vt).call(this, "POST", `${Bt}/${Ae}/signed-url/batch`, {
4959
5013
  body: JSON.stringify({
4960
5014
  hiddenFileIds: s,
4961
5015
  ...e != null && { expiresIn: e }
@@ -5087,7 +5141,7 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
5087
5141
  */
5088
5142
  async listVersionsBatch(t, e = {}) {
5089
5143
  const { archived: s } = e;
5090
- return await I(this, q, _s).call(this, t, async (i) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/versions`, {
5144
+ return await I(this, q, As).call(this, t, async (i) => (await I(this, q, vt).call(this, "POST", `${Bt}/batch/versions`, {
5091
5145
  body: JSON.stringify({
5092
5146
  itemIds: i,
5093
5147
  ...s !== void 0 && { archived: s }
@@ -5126,26 +5180,26 @@ return main;`)(...l), c = (d == null ? void 0 : d.componentDefinition) ?? d;
5126
5180
  return await I(this, q, vt).call(this, "DELETE", `${Bt}/${encodeURIComponent(t)}/version/${encodeURIComponent(e)}`);
5127
5181
  }
5128
5182
  };
5129
- q = new WeakSet(), rn = function(t) {
5183
+ q = new WeakSet(), on = function(t) {
5130
5184
  return `${this.apiUrl}/${t}`;
5131
5185
  }, vt = async function(t, e, s) {
5132
5186
  if (t === "GET" && (s == null ? void 0 : s.responseType) !== "blob" && !(s != null && s.retryAttempt)) {
5133
- const i = `${I(this, q, rn).call(this, e)}?${new URLSearchParams(I(this, q, Hn).call(this, s == null ? void 0 : s.query)).toString()}`, r = Date.now(), a = Ms.get(i);
5134
- if (a && (a.pending || r - a.at < (vl(e) ? wl : yl)))
5187
+ const i = `${I(this, q, on).call(this, e)}?${new URLSearchParams(I(this, q, Wn).call(this, s == null ? void 0 : s.query)).toString()}`, r = Date.now(), a = $s.get(i);
5188
+ if (a && (a.pending || r - a.at < (Ml(e) ? El : vl)))
5135
5189
  return a.answer.then((p) => p === void 0 ? p : structuredClone(p));
5136
- const l = { at: r, pending: !0, answer: I(this, q, qn).call(this, t, e, s) };
5137
- return Ms.set(i, l), l.answer.then(
5190
+ const l = { at: r, pending: !0, answer: I(this, q, Gn).call(this, t, e, s) };
5191
+ return $s.set(i, l), l.answer.then(
5138
5192
  () => {
5139
5193
  l.pending = !1, l.at = Date.now();
5140
5194
  },
5141
5195
  () => {
5142
- Ms.get(i) === l && Ms.delete(i);
5196
+ $s.get(i) === l && $s.delete(i);
5143
5197
  }
5144
5198
  ), l.answer.then((p) => p === void 0 ? p : structuredClone(p));
5145
5199
  }
5146
- return t !== "GET" && !bl(e) && Ms.clear(), I(this, q, qn).call(this, t, e, s);
5147
- }, qn = async function(t, e, s) {
5148
- const { body: i, query: r, contentType: a, retries: l, responseType: p, retryAttempt: d } = s || {}, c = I(this, q, rn).call(this, e), E = I(this, q, Hn).call(this, r), b = await this.resolveAccessToken(), $ = {
5200
+ return t !== "GET" && !Tl(e) && $s.clear(), I(this, q, Gn).call(this, t, e, s);
5201
+ }, Gn = async function(t, e, s) {
5202
+ const { body: i, query: r, contentType: a, retries: l, responseType: p, retryAttempt: d } = s || {}, c = I(this, q, on).call(this, e), E = I(this, q, Wn).call(this, r), b = await this.resolveAccessToken(), $ = {
5149
5203
  ...E,
5150
5204
  ...this.useBearer ? {} : { accessToken: b }
5151
5205
  };
@@ -5164,20 +5218,20 @@ q = new WeakSet(), rn = function(t) {
5164
5218
  );
5165
5219
  if (!P.ok) {
5166
5220
  const N = await P.text().then((Y) => Y).catch(() => "");
5167
- throw new li(
5221
+ throw new fi(
5168
5222
  P.status,
5169
5223
  P.statusText,
5170
5224
  N,
5171
- Ml(P)
5225
+ Sl(P)
5172
5226
  );
5173
5227
  }
5174
5228
  return p === "blob" ? await P.blob() : P.json().then((N) => N).catch(() => {
5175
5229
  });
5176
5230
  } catch (P) {
5177
5231
  const N = l ?? this.retries;
5178
- if (N > 0 && $l(P)) {
5232
+ if (N > 0 && xl(P)) {
5179
5233
  const Y = d ?? 0;
5180
- return await Tl(Il(P, Y)), await I(this, q, vt).call(this, t, e, {
5234
+ return await Il(_l(P, Y)), await I(this, q, vt).call(this, t, e, {
5181
5235
  ...s,
5182
5236
  retries: N - 1,
5183
5237
  retryAttempt: Y + 1
@@ -5186,7 +5240,7 @@ q = new WeakSet(), rn = function(t) {
5186
5240
  throw P;
5187
5241
  }
5188
5242
  }, qe = async function(t, e) {
5189
- const { query: s } = e || {}, i = I(this, q, rn).call(this, t), r = await this.resolveAccessToken(), a = {
5243
+ const { query: s } = e || {}, i = I(this, q, on).call(this, t), r = await this.resolveAccessToken(), a = {
5190
5244
  ...s,
5191
5245
  ...this.useBearer ? {} : { accessToken: r }
5192
5246
  };
@@ -5199,20 +5253,21 @@ q = new WeakSet(), rn = function(t) {
5199
5253
  }
5200
5254
  }
5201
5255
  );
5202
- }, as = new WeakMap(), Oa = async function(t) {
5203
- return await I(this, q, vt).call(this, "GET", `${Bt}/documents`, {
5256
+ }, cs = new WeakMap(), ka = async function(t) {
5257
+ const e = await I(this, q, vt).call(this, "GET", `${Bt}/documents`, {
5204
5258
  query: { projectId: t }
5205
5259
  });
5206
- }, cs = new WeakMap(), dn = new WeakMap(), Bs = new WeakMap(), Ke = new WeakMap(), Xe = new WeakMap(), on = function() {
5260
+ return this.cache.keepAnswer("documents", t, e), e;
5261
+ }, ls = new WeakMap(), un = new WeakMap(), js = new WeakMap(), Ke = new WeakMap(), Xe = new WeakMap(), an = function() {
5207
5262
  var t, e;
5208
- O(this, Xe) || !O(this, Bs) || O(this, Ke) > 0 || (Ht(this, Xe, !0), (e = (t = this.context.appEventOrchestrator) == null ? void 0 : t.appLoaded) == null || e.call(t));
5209
- }, js = new WeakMap(), _s = async function(t, e) {
5263
+ O(this, Xe) || !O(this, js) || O(this, Ke) > 0 || (Ht(this, Xe, !0), (e = (t = this.context.appEventOrchestrator) == null ? void 0 : t.appLoaded) == null || e.call(t));
5264
+ }, Ds = new WeakMap(), As = async function(t, e) {
5210
5265
  if (!t.length) return [];
5211
5266
  const s = [];
5212
- for (let r = 0; r < t.length; r += Po)
5213
- s.push(t.slice(r, r + Po));
5267
+ for (let r = 0; r < t.length; r += Bo)
5268
+ s.push(t.slice(r, r + Bo));
5214
5269
  return (await Promise.all(s.map(e))).flat();
5215
- }, an = async function(t, e) {
5270
+ }, cn = async function(t, e) {
5216
5271
  const { versionTag: s, withDraft: i } = e || {}, r = await I(this, q, qe).call(this, `${Bt}/${t}/download`, {
5217
5272
  query: {
5218
5273
  ...s && { versionTag: s },
@@ -5222,12 +5277,12 @@ q = new WeakSet(), rn = function(t) {
5222
5277
  if (r.status === 429 || r.status >= 500)
5223
5278
  throw new Error(`Downloading ${t} answered ${r.status}${r.status === 429 ? " (rate limited)" : ""}`);
5224
5279
  return r;
5225
- }, cn = async function(t, e, s) {
5280
+ }, ln = async function(t, e, s) {
5226
5281
  const { name: i, versionTag: r, parentFolderId: a, projectId: l, file: p, metadata: d } = t, c = new FormData();
5227
5282
  return c.append("file", p), c.append("name", i), c.append("versionTag", r), c.append("itemType", e), a && c.append("folderId", a), l && c.append("projectId", l), s && c.append("extraProps", JSON.stringify(s)), d && c.append("metadata", JSON.stringify(d)), await I(this, q, vt).call(this, "POST", Bt, {
5228
5283
  body: c
5229
5284
  });
5230
- }, Vn = async function(t, e, s) {
5285
+ }, Hn = async function(t, e, s) {
5231
5286
  const { name: i, versionTag: r, parentFolderId: a, file: l, metadata: p } = e;
5232
5287
  let d, c;
5233
5288
  if (l) {
@@ -5249,19 +5304,19 @@ q = new WeakSet(), rn = function(t) {
5249
5304
  });
5250
5305
  }
5251
5306
  return { item: d, version: c };
5252
- }, Gn = async function(t, e) {
5307
+ }, zn = async function(t, e) {
5253
5308
  const { showVersions: s = !1 } = e || {};
5254
5309
  return await I(this, q, vt).call(this, "GET", `${Bt}/${t}`, {
5255
5310
  query: { showVersions: s }
5256
5311
  });
5257
- }, Hn = function(t) {
5312
+ }, Wn = function(t) {
5258
5313
  return t && Object.entries(t).filter(([, e]) => e !== void 0).reduce(
5259
5314
  (e, [s, i]) => (e[s] = i, e),
5260
5315
  {}
5261
5316
  );
5262
5317
  };
5263
- let Jn = hi;
5264
- function Sl() {
5318
+ let Vn = di;
5319
+ function Al() {
5265
5320
  if (typeof window > "u" || window.parent === window)
5266
5321
  throw new Error(
5267
5322
  "client.channel only works inside a That Open app, which runs in an iframe of the platform."
@@ -5276,24 +5331,24 @@ function Sl() {
5276
5331
  }
5277
5332
  };
5278
5333
  }
5279
- const zn = "channel:", xl = 1e4;
5280
- function ln(n) {
5334
+ const Yn = "channel:", Cl = 1e4;
5335
+ function hn(n) {
5281
5336
  try {
5282
5337
  n();
5283
5338
  } catch (t) {
5284
5339
  console.error("[channel] a listener threw:", t);
5285
5340
  }
5286
5341
  }
5287
- var Fe, ge, ye, ls, hs, fs, ue, Wn, Yn, is;
5288
- class Ra {
5342
+ var Fe, ge, ye, hs, fs, ds, ue, Kn, Xn, is;
5343
+ class Na {
5289
5344
  constructor(t, e) {
5290
5345
  Lt(this, ue);
5291
5346
  Lt(this, Fe, !1);
5292
5347
  Lt(this, ge, []);
5293
5348
  Lt(this, ye, []);
5294
- Lt(this, ls, /* @__PURE__ */ new Set());
5295
5349
  Lt(this, hs, /* @__PURE__ */ new Set());
5296
5350
  Lt(this, fs, /* @__PURE__ */ new Set());
5351
+ Lt(this, ds, /* @__PURE__ */ new Set());
5297
5352
  this.transport = t, this.controls = e;
5298
5353
  }
5299
5354
  /** Whether the platform has confirmed this tab is in the room. */
@@ -5309,29 +5364,29 @@ class Ra {
5309
5364
  * refuses or does not answer in time. Joining twice is harmless.
5310
5365
  */
5311
5366
  join() {
5312
- return O(this, Fe) ? Promise.resolve() : I(this, ue, Wn).call(this, "joined", this.controls.join);
5367
+ return O(this, Fe) ? Promise.resolve() : I(this, ue, Kn).call(this, "joined", this.controls.join);
5313
5368
  }
5314
5369
  /** Leaves the room. Handlers stay registered, so `join()` resumes them. */
5315
5370
  leave() {
5316
- return !O(this, Fe) && !O(this, ye).some((t) => t.want === "joined") ? Promise.resolve() : I(this, ue, Wn).call(this, "left", this.controls.leave);
5371
+ return !O(this, Fe) && !O(this, ye).some((t) => t.want === "joined") ? Promise.resolve() : I(this, ue, Kn).call(this, "left", this.controls.leave);
5317
5372
  }
5318
5373
  /** Fires when `joined` or `peers` changes. Returns a function that stops it. */
5319
5374
  onChange(t) {
5320
- return O(this, ls).add(t), () => void O(this, ls).delete(t);
5375
+ return O(this, hs).add(t), () => void O(this, hs).delete(t);
5321
5376
  }
5322
5377
  onPeerJoined(t) {
5323
- return O(this, hs).add(t), () => void O(this, hs).delete(t);
5378
+ return O(this, fs).add(t), () => void O(this, fs).delete(t);
5324
5379
  }
5325
5380
  onPeerLeft(t) {
5326
- return O(this, fs).add(t), () => void O(this, fs).delete(t);
5381
+ return O(this, ds).add(t), () => void O(this, ds).delete(t);
5327
5382
  }
5328
5383
  /** @internal */
5329
5384
  applyJoined() {
5330
- Ht(this, Fe, !0), I(this, ue, Yn).call(this, "joined"), I(this, ue, is).call(this);
5385
+ Ht(this, Fe, !0), I(this, ue, Xn).call(this, "joined"), I(this, ue, is).call(this);
5331
5386
  }
5332
5387
  /** @internal */
5333
5388
  applyLeft() {
5334
- Ht(this, Fe, !1), Ht(this, ge, []), I(this, ue, Yn).call(this, "left"), I(this, ue, is).call(this);
5389
+ Ht(this, Fe, !1), Ht(this, ge, []), I(this, ue, Xn).call(this, "left"), I(this, ue, is).call(this);
5335
5390
  }
5336
5391
  /** @internal */
5337
5392
  applyPeers(t) {
@@ -5339,12 +5394,12 @@ class Ra {
5339
5394
  }
5340
5395
  /** @internal */
5341
5396
  applyPeerJoined(t) {
5342
- !O(this, Fe) || O(this, ge).some((e) => e.from === t.from) || (Ht(this, ge, [...O(this, ge), t]), O(this, hs).forEach((e) => ln(() => e(t))), I(this, ue, is).call(this));
5397
+ !O(this, Fe) || O(this, ge).some((e) => e.from === t.from) || (Ht(this, ge, [...O(this, ge), t]), O(this, fs).forEach((e) => hn(() => e(t))), I(this, ue, is).call(this));
5343
5398
  }
5344
5399
  /** @internal */
5345
5400
  applyPeerLeft(t) {
5346
5401
  const e = O(this, ge).find((s) => s.from === t);
5347
- e && (Ht(this, ge, O(this, ge).filter((s) => s.from !== t)), O(this, fs).forEach((s) => ln(() => s(e))), I(this, ue, is).call(this));
5402
+ e && (Ht(this, ge, O(this, ge).filter((s) => s.from !== t)), O(this, ds).forEach((s) => hn(() => s(e))), I(this, ue, is).call(this));
5348
5403
  }
5349
5404
  /** @internal */
5350
5405
  failPending(t) {
@@ -5357,7 +5412,7 @@ class Ra {
5357
5412
  this.transport.post(t);
5358
5413
  }
5359
5414
  }
5360
- Fe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), ls = new WeakMap(), hs = new WeakMap(), fs = new WeakMap(), ue = new WeakSet(), Wn = function(t, e) {
5415
+ Fe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), hs = new WeakMap(), fs = new WeakMap(), ds = new WeakMap(), ue = new WeakSet(), Kn = function(t, e) {
5361
5416
  return new Promise((s, i) => {
5362
5417
  const r = {
5363
5418
  want: t,
@@ -5369,58 +5424,58 @@ Fe = new WeakMap(), ge = new WeakMap(), ye = new WeakMap(), ls = new WeakMap(),
5369
5424
  `The platform did not confirm ${t === "joined" ? "joining" : "leaving"} in time.`
5370
5425
  )
5371
5426
  );
5372
- }, xl)
5427
+ }, Cl)
5373
5428
  };
5374
5429
  O(this, ye).push(r), this.transport.post({ type: "APP_CHANNEL_CONTROL", ...e });
5375
5430
  });
5376
- }, Yn = function(t) {
5431
+ }, Xn = function(t) {
5377
5432
  const e = O(this, ye).filter((s) => s.want === t);
5378
5433
  Ht(this, ye, O(this, ye).filter((s) => s.want !== t)), e.forEach((s) => {
5379
5434
  clearTimeout(s.timer), s.resolve();
5380
5435
  });
5381
5436
  }, is = function() {
5382
- O(this, ls).forEach((t) => ln(t));
5437
+ O(this, hs).forEach((t) => hn(t));
5383
5438
  };
5384
- var ds;
5385
- class _l extends Ra {
5439
+ var us;
5440
+ class Ol extends Na {
5386
5441
  /** @internal Use `client.channel.collab()`. */
5387
5442
  constructor(e) {
5388
5443
  super(e, {
5389
5444
  join: { action: "joinCollab" },
5390
5445
  leave: { action: "leaveCollab" }
5391
5446
  });
5392
- Lt(this, ds, /* @__PURE__ */ new Map());
5447
+ Lt(this, us, /* @__PURE__ */ new Map());
5393
5448
  }
5394
5449
  /**
5395
5450
  * Listens for an event other tabs send. Any number of listeners per event.
5396
5451
  * @returns a function that removes the listener.
5397
5452
  */
5398
5453
  on(e, s) {
5399
- const i = O(this, ds).get(e) ?? /* @__PURE__ */ new Set();
5400
- return i.add(s), O(this, ds).set(e, i), () => void i.delete(s);
5454
+ const i = O(this, us).get(e) ?? /* @__PURE__ */ new Set();
5455
+ return i.add(s), O(this, us).set(e, i), () => void i.delete(s);
5401
5456
  }
5402
5457
  /**
5403
5458
  * Sends an event to the other tabs in the room. Does nothing while this tab
5404
5459
  * is not in it, matching what the platform does with a message from outside.
5405
5460
  */
5406
5461
  send(e, s) {
5407
- if (e.startsWith(zn))
5408
- throw new Error(`Message types starting with '${zn}' are reserved.`);
5462
+ if (e.startsWith(Yn))
5463
+ throw new Error(`Message types starting with '${Yn}' are reserved.`);
5409
5464
  this.joined && this.post({ type: "APP_CHANNEL_PUBLISH", message: { type: e, payload: s } });
5410
5465
  }
5411
5466
  accepts(e) {
5412
5467
  return e === void 0 || e === "collab";
5413
5468
  }
5414
5469
  async handle(e) {
5415
- const s = O(this, ds).get(e.type);
5470
+ const s = O(this, us).get(e.type);
5416
5471
  if (!(s != null && s.size)) return { handled: !1 };
5417
- const i = ka(e);
5418
- return s.forEach((r) => ln(() => r(e.payload, i))), { handled: !0 };
5472
+ const i = Fa(e);
5473
+ return s.forEach((r) => hn(() => r(e.payload, i))), { handled: !0 };
5419
5474
  }
5420
5475
  }
5421
- ds = new WeakMap();
5476
+ us = new WeakMap();
5422
5477
  var Ve;
5423
- class Al extends Ra {
5478
+ class Rl extends Na {
5424
5479
  /** @internal Use `client.channel.external(kind)`. */
5425
5480
  constructor(e, s) {
5426
5481
  super(e, {
@@ -5458,7 +5513,7 @@ class Al extends Ra {
5458
5513
  const s = O(this, Ve).get(e.type);
5459
5514
  if (!s) return { handled: !1 };
5460
5515
  try {
5461
- return { handled: !0, value: await s(e.payload, ka(e)) };
5516
+ return { handled: !0, value: await s(e.payload, Fa(e)) };
5462
5517
  } catch (i) {
5463
5518
  return {
5464
5519
  handled: !0,
@@ -5468,7 +5523,7 @@ class Al extends Ra {
5468
5523
  }
5469
5524
  }
5470
5525
  Ve = new WeakMap();
5471
- function ka(n) {
5526
+ function Fa(n) {
5472
5527
  return {
5473
5528
  from: n.from,
5474
5529
  at: n.at,
@@ -5476,7 +5531,7 @@ function ka(n) {
5476
5531
  kind: n.kind
5477
5532
  };
5478
5533
  }
5479
- function Cl(n) {
5534
+ function kl(n) {
5480
5535
  const t = n;
5481
5536
  if ((t == null ? void 0 : t.type) !== "THATOPEN_CHANNEL_MESSAGE") return null;
5482
5537
  const e = t.message;
@@ -5490,20 +5545,20 @@ function Cl(n) {
5490
5545
  kind: typeof e.kind == "string" ? e.kind : void 0
5491
5546
  };
5492
5547
  }
5493
- var Ze, Ds, Pe, Ge, He, ce, Kn, hn, Na, Fa, Pa, Xn;
5494
- class Ol {
5548
+ var Ze, Us, Pe, Ge, He, ce, Zn, fn, Pa, La, Ba, Qn;
5549
+ class Nl {
5495
5550
  constructor(t) {
5496
5551
  Lt(this, ce);
5497
5552
  Lt(this, Ze);
5498
- Lt(this, Ds);
5553
+ Lt(this, Us);
5499
5554
  Lt(this, Pe);
5500
5555
  Lt(this, Ge, /* @__PURE__ */ new Map());
5501
5556
  Lt(this, He, /* @__PURE__ */ new Set());
5502
- Ht(this, Ze, t), Ht(this, Ds, t.listen((e) => void I(this, ce, Na).call(this, e)));
5557
+ Ht(this, Ze, t), Ht(this, Us, t.listen((e) => void I(this, ce, Pa).call(this, e)));
5503
5558
  }
5504
5559
  /** The collaboration room for this app. Always the same instance. */
5505
5560
  collab() {
5506
- return O(this, Pe) ?? Ht(this, Pe, new _l(O(this, Ze))), O(this, Pe);
5561
+ return O(this, Pe) ?? Ht(this, Pe, new Ol(O(this, Ze))), O(this, Pe);
5507
5562
  }
5508
5563
  /**
5509
5564
  * The room for commands from this account's external tools of one `kind`
@@ -5513,40 +5568,40 @@ class Ol {
5513
5568
  external(t) {
5514
5569
  const e = t ?? "";
5515
5570
  let s = O(this, Ge).get(e);
5516
- return s || (s = new Al(O(this, Ze), t), O(this, Ge).set(e, s)), s;
5571
+ return s || (s = new Rl(O(this, Ze), t), O(this, Ge).set(e, s)), s;
5517
5572
  }
5518
5573
  /** Stops listening. For tests and teardown; an app normally never calls it. */
5519
5574
  dispose() {
5520
- O(this, Ds).call(this);
5575
+ O(this, Us).call(this);
5521
5576
  }
5522
5577
  }
5523
- Ze = new WeakMap(), Ds = new WeakMap(), Pe = new WeakMap(), Ge = new WeakMap(), He = new WeakMap(), ce = new WeakSet(), Kn = function() {
5578
+ Ze = new WeakMap(), Us = new WeakMap(), Pe = new WeakMap(), Ge = new WeakMap(), He = new WeakMap(), ce = new WeakSet(), Zn = function() {
5524
5579
  return [...O(this, Pe) ? [O(this, Pe)] : [], ...O(this, Ge).values()];
5525
- }, hn = function(t, e) {
5580
+ }, fn = function(t, e) {
5526
5581
  if (t === "collab") return O(this, Pe);
5527
5582
  if (t === "external")
5528
5583
  return O(this, Ge).get(typeof e == "string" ? e : "");
5529
- }, Na = async function(t) {
5530
- const e = Cl(t);
5584
+ }, Pa = async function(t) {
5585
+ const e = kl(t);
5531
5586
  if (e) {
5532
- if (e.type.startsWith(zn)) {
5533
- I(this, ce, Fa).call(this, e);
5587
+ if (e.type.startsWith(Yn)) {
5588
+ I(this, ce, La).call(this, e);
5534
5589
  return;
5535
5590
  }
5536
- await I(this, ce, Pa).call(this, e);
5591
+ await I(this, ce, Ba).call(this, e);
5537
5592
  }
5538
- }, Fa = function(t) {
5593
+ }, La = function(t) {
5539
5594
  var s, i, r;
5540
5595
  const e = t.payload ?? {};
5541
5596
  switch (t.type) {
5542
5597
  case "channel:joined":
5543
- (s = I(this, ce, hn).call(this, e.scope, e.kind)) == null || s.applyJoined();
5598
+ (s = I(this, ce, fn).call(this, e.scope, e.kind)) == null || s.applyJoined();
5544
5599
  break;
5545
5600
  case "channel:left":
5546
- (i = I(this, ce, hn).call(this, e.scope, e.kind)) == null || i.applyLeft();
5601
+ (i = I(this, ce, fn).call(this, e.scope, e.kind)) == null || i.applyLeft();
5547
5602
  break;
5548
5603
  case "channel:peers":
5549
- (r = I(this, ce, hn).call(this, e.scope, e.kind)) == null || r.applyPeers(e.peers ?? []);
5604
+ (r = I(this, ce, fn).call(this, e.scope, e.kind)) == null || r.applyPeers(e.peers ?? []);
5550
5605
  break;
5551
5606
  case "channel:peer-joined":
5552
5607
  case "channel:peer-left": {
@@ -5560,22 +5615,22 @@ Ze = new WeakMap(), Ds = new WeakMap(), Pe = new WeakMap(), Ge = new WeakMap(),
5560
5615
  }
5561
5616
  case "channel:error": {
5562
5617
  const a = new Error(String(t.payload));
5563
- I(this, ce, Kn).call(this).map((p) => p.failPending(a)).some(Boolean) || console.error("[channel] error:", t.payload);
5618
+ I(this, ce, Zn).call(this).map((p) => p.failPending(a)).some(Boolean) || console.error("[channel] error:", t.payload);
5564
5619
  break;
5565
5620
  }
5566
5621
  }
5567
- }, Pa = async function(t) {
5568
- const e = I(this, ce, Kn).call(this).filter((r) => r.accepts(t.scope, t.kind));
5622
+ }, Ba = async function(t) {
5623
+ const e = I(this, ce, Zn).call(this).filter((r) => r.accepts(t.scope, t.kind));
5569
5624
  let s = !1;
5570
5625
  for (const r of e) {
5571
5626
  const a = await r.handle(t);
5572
- a.handled && (s = !0, t.requestId && I(this, ce, Xn).call(this, t.requestId, a));
5627
+ a.handled && (s = !0, t.requestId && I(this, ce, Qn).call(this, t.requestId, a));
5573
5628
  }
5574
- t.requestId && t.scope === "external" && e.length > 0 && !s && I(this, ce, Xn).call(this, t.requestId, {
5629
+ t.requestId && t.scope === "external" && e.length > 0 && !s && I(this, ce, Qn).call(this, t.requestId, {
5575
5630
  handled: !0,
5576
5631
  error: `No handler for "${t.type}".`
5577
5632
  });
5578
- }, Xn = function(t, e) {
5633
+ }, Qn = function(t, e) {
5579
5634
  O(this, He).has(t) || (O(this, He).add(t), O(this, He).size > 500 && O(this, He).delete(O(this, He).values().next().value), O(this, Ze).post({
5580
5635
  type: "APP_CHANNEL_PUBLISH",
5581
5636
  message: {
@@ -5585,9 +5640,9 @@ Ze = new WeakMap(), Ds = new WeakMap(), Pe = new WeakMap(), Ge = new WeakMap(),
5585
5640
  }
5586
5641
  }));
5587
5642
  };
5588
- const ae = "project", es = "notifications", $s = "tokens", Rl = 6e4;
5589
- var us, Us, ze;
5590
- const fi = class fi extends Jn {
5643
+ const ae = "project", es = "notifications", Is = "tokens", Fl = 6e4;
5644
+ var ps, Js, ze;
5645
+ const ui = class ui extends Vn {
5591
5646
  /**
5592
5647
  * @param token - A bearer JWT, OR a function returning the current JWT
5593
5648
  * (sync or async). When a function is passed, it's invoked before every
@@ -5598,13 +5653,13 @@ const fi = class fi extends Jn {
5598
5653
  */
5599
5654
  constructor(e, s, i) {
5600
5655
  super(typeof e == "string" ? e : "", s, { ...i, useBearer: !0 });
5601
- Lt(this, us);
5602
- Lt(this, Us);
5656
+ Lt(this, ps);
5657
+ Lt(this, Js);
5603
5658
  Lt(this, ze, /* @__PURE__ */ new Map());
5604
- typeof e == "function" && Ht(this, us, e);
5659
+ typeof e == "function" && Ht(this, ps, e);
5605
5660
  }
5606
5661
  async resolveAccessToken() {
5607
- return O(this, us) ? await O(this, us).call(this) : super.resolveAccessToken();
5662
+ return O(this, ps) ? await O(this, ps).call(this) : super.resolveAccessToken();
5608
5663
  }
5609
5664
  /**
5610
5665
  * Creates a client from the platform context injected into
@@ -5613,7 +5668,7 @@ const fi = class fi extends Jn {
5613
5668
  * carries a fresh JWT on every navigation.
5614
5669
  */
5615
5670
  static fromPlatformContext(e) {
5616
- const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, i = new fi(s.accessToken, s.apiUrl, e);
5671
+ const s = (typeof window < "u" ? window.__THATOPEN_CONTEXT__ : null) || { appId: "", projectId: "", accessToken: "", apiUrl: "" }, i = new ui(s.accessToken, s.apiUrl, e);
5617
5672
  return i.context = s, i;
5618
5673
  }
5619
5674
  /**
@@ -5641,7 +5696,7 @@ const fi = class fi extends Jn {
5641
5696
  * ```
5642
5697
  */
5643
5698
  get channel() {
5644
- return O(this, Us) ?? Ht(this, Us, new Ol(Sl())), O(this, Us);
5699
+ return O(this, Js) ?? Ht(this, Js, new Nl(Al())), O(this, Js);
5645
5700
  }
5646
5701
  // ─── Projects (JWT-only backend routes) ──────────────────────────
5647
5702
  /**
@@ -5675,12 +5730,13 @@ const fi = class fi extends Jn {
5675
5730
  */
5676
5731
  async getProjectData(e) {
5677
5732
  const s = O(this, ze).get(e);
5678
- if (s && Date.now() - s.at < Rl) return await s.data;
5733
+ if (s && Date.now() - s.at < Fl) return await s.data;
5679
5734
  const i = this.request(
5680
5735
  "GET",
5681
5736
  `${ae}/${e}/data`
5682
5737
  );
5683
- return O(this, ze).set(e, { at: Date.now(), data: i }), i.catch(() => {
5738
+ return O(this, ze).set(e, { at: Date.now(), data: i }), i.then((r) => this.cache.keepAnswer("projectData", e, r), () => {
5739
+ }), i.catch(() => {
5684
5740
  var r;
5685
5741
  ((r = O(this, ze).get(e)) == null ? void 0 : r.data) === i && O(this, ze).delete(e);
5686
5742
  }), await i;
@@ -5839,13 +5895,13 @@ const fi = class fi extends Jn {
5839
5895
  // permission, and revoked one by one (APOGEA 23-10, §2.5).
5840
5896
  /** The caller's API tokens (without their secret). */
5841
5897
  async listTokens() {
5842
- return await this.request("GET", $s);
5898
+ return await this.request("GET", Is);
5843
5899
  }
5844
5900
  /** A token's secret, to hand to the integration that will use it. */
5845
5901
  async getTokenSecret(e) {
5846
5902
  return await (await this.request(
5847
5903
  "GET",
5848
- `${$s}/${e}/token`,
5904
+ `${Is}/${e}/token`,
5849
5905
  { responseType: "blob" }
5850
5906
  )).text();
5851
5907
  }
@@ -5854,7 +5910,7 @@ const fi = class fi extends Jn {
5854
5910
  * them it may act on every project its owner can reach.
5855
5911
  */
5856
5912
  async createToken(e) {
5857
- return await this.request("POST", $s, {
5913
+ return await this.request("POST", Is, {
5858
5914
  body: JSON.stringify({
5859
5915
  urlRestrictions: [],
5860
5916
  ...e
@@ -5864,14 +5920,14 @@ const fi = class fi extends Jn {
5864
5920
  }
5865
5921
  /** Changes a token. `projectIds: []` lifts its project limit; leaving it out keeps it. */
5866
5922
  async updateToken(e, s) {
5867
- return await this.request("PUT", `${$s}/${e}`, {
5923
+ return await this.request("PUT", `${Is}/${e}`, {
5868
5924
  body: JSON.stringify(s),
5869
5925
  contentType: "application/json"
5870
5926
  });
5871
5927
  }
5872
5928
  /** Revokes a token: it stops working at once. */
5873
5929
  async revokeToken(e) {
5874
- return await this.request("DELETE", `${$s}/${e}`);
5930
+ return await this.request("DELETE", `${Is}/${e}`);
5875
5931
  }
5876
5932
  // ─── Account ──────────────────────────────────────────────────────
5877
5933
  /**
@@ -6067,7 +6123,7 @@ const fi = class fi extends Jn {
6067
6123
  * ```
6068
6124
  */
6069
6125
  async onNotification(e) {
6070
- const s = await this.resolveAccessToken(), i = Cs(`${this.socketOrigin}/notifications`, {
6126
+ const s = await this.resolveAccessToken(), i = Os(`${this.socketOrigin}/notifications`, {
6071
6127
  auth: { accessToken: s },
6072
6128
  transports: ["websocket"]
6073
6129
  });
@@ -6083,9 +6139,9 @@ const fi = class fi extends Jn {
6083
6139
  ), () => i.disconnect();
6084
6140
  }
6085
6141
  };
6086
- us = new WeakMap(), Us = new WeakMap(), ze = new WeakMap();
6087
- let jo = fi;
6088
- const Ce = 1 / 0.3048, kl = {
6142
+ ps = new WeakMap(), Js = new WeakMap(), ze = new WeakMap();
6143
+ let Uo = ui;
6144
+ const Ce = 1 / 0.3048, Pl = {
6089
6145
  IFCDOOR: "OST_Doors",
6090
6146
  IFCWINDOW: "OST_Windows",
6091
6147
  IFCFURNITURE: "OST_Furniture",
@@ -6100,13 +6156,13 @@ const Ce = 1 / 0.3048, kl = {
6100
6156
  IFCELECTRICAPPLIANCE: "OST_ElectricalEquipment",
6101
6157
  IFCELECTRICDISTRIBUTIONBOARD: "OST_ElectricalEquipment",
6102
6158
  IFCUNITARYEQUIPMENT: "OST_MechanicalEquipment"
6103
- }, Nl = "OST_GenericModel", Fl = /* @__PURE__ */ new Set(["IFCSPACE", "IFCOPENINGELEMENT", "IFCSITE", "IFCANNOTATION", "IFCGRID", "IFCVIRTUALELEMENT", "IFCBUILDING", "IFCBUILDINGSTOREY"]), Re = (n, t) => Math.round(n / t) * t, Pl = (n) => ({
6159
+ }, Ll = "OST_GenericModel", Bl = /* @__PURE__ */ new Set(["IFCSPACE", "IFCOPENINGELEMENT", "IFCSITE", "IFCANNOTATION", "IFCGRID", "IFCVIRTUALELEMENT", "IFCBUILDING", "IFCBUILDINGSTOREY"]), Re = (n, t) => Math.round(n / t) * t, jl = (n) => ({
6104
6160
  x: [n[0], n[1], n[2]],
6105
6161
  y: [n[4], n[5], n[6]],
6106
6162
  z: [n[8], n[9], n[10]],
6107
6163
  t: [n[12], n[13], n[14]]
6108
- }), Os = (n, t) => n[0] * t[0] + n[1] * t[1] + n[2] * t[2], Sn = (n) => Math.sqrt(Os(n, n)), os = (n, t) => [n[1] * t[2] - n[2] * t[1], n[2] * t[0] - n[0] * t[2], n[0] * t[1] - n[1] * t[0]];
6109
- function Ll(n, t, e, s) {
6164
+ }), Rs = (n, t) => n[0] * t[0] + n[1] * t[1] + n[2] * t[2], _n = (n) => Math.sqrt(Rs(n, n)), os = (n, t) => [n[1] * t[2] - n[2] * t[1], n[2] * t[0] - n[0] * t[2], n[0] * t[1] - n[1] * t[0]];
6165
+ function Dl(n, t, e, s) {
6110
6166
  var d, c, E;
6111
6167
  const i = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
6112
6168
  for (const b of t) {
@@ -6115,8 +6171,8 @@ function Ll(n, t, e, s) {
6115
6171
  }
6116
6172
  const a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), p = [];
6117
6173
  for (const b of n.elements.values()) {
6118
- if (i.has(b.gid) || Fl.has(b.ifcClass.toUpperCase()) || b.parent && i.has(b.parent) && !/^IFC(DOOR|WINDOW)$/i.test(b.ifcClass) && !(s != null && s.has(b.gid)) || b.pieces.length === 0) continue;
6119
- const P = /^IFCCOLUMN$/i.test(b.ifcClass) && (b.loadBearing || /structural|estructural|结构柱|tragend|tragwerk/i.test(`${b.typeName ?? ""} ${b.objectType ?? ""} ${b.name ?? ""}`)) ? "OST_StructuralColumns" : kl[b.ifcClass.toUpperCase()] ?? Nl, N = Pl(b.pieces[0].matrix), Y = Sn(N.x), z = Sn(N.y), D = Sn(N.z), f = N.z.map((U) => U / (D || 1)), Tt = Math.abs(f[2] - 1) < 1e-6 && Os(os(N.x, N.y), N.z) > 0 && Math.abs(Y - z) < 1e-6 && Math.abs(Y - D) < 1e-6, st = Os(os(N.x, N.y), N.z) > 0 && Math.abs(Y - z) < 1e-6 && Math.abs(Y - D) < 1e-6, wt = [N.x, N.y, N.z].map((U) => U.map((Z) => Z / (Y || 1))), Pt = st && !Tt && wt.some((U) => Math.abs(Math.abs(U[2]) - 1) < 1e-6) ? wt.find((U) => Math.abs(U[2]) < 1e-6) : void 0, tt = Tt ? Math.atan2(N.x[1], N.x[0]) : Pt ? Math.atan2(Pt[1], Pt[0]) : 0, ct = Math.cos(-tt), ht = Math.sin(-tt), kt = [N.t[0], N.t[1], N.t[2]], te = /COLUMN/i.test(P), Yt = (U) => {
6174
+ if (i.has(b.gid) || Bl.has(b.ifcClass.toUpperCase()) || b.parent && i.has(b.parent) && !/^IFC(DOOR|WINDOW)$/i.test(b.ifcClass) && !(s != null && s.has(b.gid)) || b.pieces.length === 0) continue;
6175
+ const P = /^IFCCOLUMN$/i.test(b.ifcClass) && (b.loadBearing || /structural|estructural|结构柱|tragend|tragwerk/i.test(`${b.typeName ?? ""} ${b.objectType ?? ""} ${b.name ?? ""}`)) ? "OST_StructuralColumns" : Pl[b.ifcClass.toUpperCase()] ?? Ll, N = jl(b.pieces[0].matrix), Y = _n(N.x), z = _n(N.y), D = _n(N.z), f = N.z.map((U) => U / (D || 1)), Tt = Math.abs(f[2] - 1) < 1e-6 && Rs(os(N.x, N.y), N.z) > 0 && Math.abs(Y - z) < 1e-6 && Math.abs(Y - D) < 1e-6, st = Rs(os(N.x, N.y), N.z) > 0 && Math.abs(Y - z) < 1e-6 && Math.abs(Y - D) < 1e-6, wt = [N.x, N.y, N.z].map((U) => U.map((Z) => Z / (Y || 1))), Pt = st && !Tt && wt.some((U) => Math.abs(Math.abs(U[2]) - 1) < 1e-6) ? wt.find((U) => Math.abs(U[2]) < 1e-6) : void 0, tt = Tt ? Math.atan2(N.x[1], N.x[0]) : Pt ? Math.atan2(Pt[1], Pt[0]) : 0, ct = Math.cos(-tt), ht = Math.sin(-tt), kt = [N.t[0], N.t[1], N.t[2]], te = /COLUMN/i.test(P), Yt = (U) => {
6120
6176
  const Z = U[0] - kt[0], B = U[1] - kt[1];
6121
6177
  return [ct * Z - ht * B, ht * Z + ct * B, U[2] - kt[2]];
6122
6178
  }, at = [], nt = [P];
@@ -6125,10 +6181,10 @@ function Ll(n, t, e, s) {
6125
6181
  if (!Z) continue;
6126
6182
  const B = U.matrix, ut = [];
6127
6183
  for (let Nt = 0; Nt < Z.verts.length; Nt += 3) {
6128
- const le = Z.verts[Nt], me = Z.verts[Nt + 1], Le = Z.verts[Nt + 2], re = [B[0] * le + B[4] * me + B[8] * Le + B[12], B[1] * le + B[5] * me + B[9] * Le + B[13], B[2] * le + B[6] * me + B[10] * Le + B[14]], Qe = Yt(re);
6184
+ const he = Z.verts[Nt], me = Z.verts[Nt + 1], Le = Z.verts[Nt + 2], re = [B[0] * he + B[4] * me + B[8] * Le + B[12], B[1] * he + B[5] * me + B[9] * Le + B[13], B[2] * he + B[6] * me + B[10] * Le + B[14]], Qe = Yt(re);
6129
6185
  ut.push(Re(Qe[0] * Ce, 1e-5), Re(Qe[1] * Ce, 1e-5), Re(Qe[2] * Ce, 1e-5));
6130
6186
  }
6131
- const X = Os(os([B[0], B[1], B[2]], [B[4], B[5], B[6]]), [B[8], B[9], B[10]]) < 0, dt = [];
6187
+ const X = Rs(os([B[0], B[1], B[2]], [B[4], B[5], B[6]]), [B[8], B[9], B[10]]) < 0, dt = [];
6132
6188
  for (let Nt = 0; Nt + 2 < Z.tris.length; Nt += 3)
6133
6189
  X ? dt.push(Z.tris[Nt], Z.tris[Nt + 2], Z.tris[Nt + 1]) : dt.push(Z.tris[Nt], Z.tris[Nt + 1], Z.tris[Nt + 2]);
6134
6190
  dt.length && at.push({ v: ut, t: dt });
@@ -6136,15 +6192,15 @@ function Ll(n, t, e, s) {
6136
6192
  nt.push(`${U.geometry}@${[...Mt, ...rt, ..._t, ...ie].map((Nt) => Re(Nt, 1e-4).toFixed(4)).join(",")}`);
6137
6193
  }
6138
6194
  if (at.length === 0) continue;
6139
- const pt = !b.host && at.length === 1 ? Dl(at[0]) : null;
6195
+ const pt = !b.host && at.length === 1 ? ql(at[0]) : null;
6140
6196
  if (pt) {
6141
- const U = jl(pt), Z = U.key, B = `prism|${P}|${U.axis}|${Z}`;
6197
+ const U = Jl(pt), Z = U.key, B = `prism|${P}|${U.axis}|${Z}`;
6142
6198
  let ut = a.get(B);
6143
6199
  if (!ut) {
6144
- const le = Do(b.typeName ?? b.objectType ?? b.name ?? b.ifcClass), me = (l.get(le.toLowerCase()) ?? 0) + 1;
6145
- l.set(le.toLowerCase(), me);
6146
- const Le = me === 1 ? le : `${le} (${me})`;
6147
- ut = { family: Le, type: Le, first: !0, key: Uo(B) }, a.set(B, ut);
6200
+ const he = Jo(b.typeName ?? b.objectType ?? b.name ?? b.ifcClass), me = (l.get(he.toLowerCase()) ?? 0) + 1;
6201
+ l.set(he.toLowerCase(), me);
6202
+ const Le = me === 1 ? he : `${he} (${me})`;
6203
+ ut = { family: Le, type: Le, first: !0, key: qo(B) }, a.set(B, ut);
6148
6204
  }
6149
6205
  const X = { ShapeCategory: P, Family: ut.family, Type: ut.type, ShapeKey: ut.key, PrismLength: String(Re(pt.length, 1e-5)), ...te ? { ColumnFree: "1" } : {} };
6150
6206
  ut.first && (X.Prism = JSON.stringify({ axis: U.axis, loops: U.loops }), ut.first = !1);
@@ -6159,10 +6215,10 @@ function Ll(n, t, e, s) {
6159
6215
  const jt = `${P}|${at.map((U) => `${U.v.map((Z) => Math.round(Z * 304.8 / 2)).join(",")}/${U.t.join(",")}`).join("|")}`, Vt = nt.join("|");
6160
6216
  let Dt = a.get(Vt) ?? a.get(jt);
6161
6217
  if (Dt && (a.set(Vt, Dt), a.set(jt, Dt)), !Dt) {
6162
- const U = Do(b.typeName ?? b.objectType ?? b.name ?? b.ifcClass), Z = (l.get(U.toLowerCase()) ?? 0) + 1;
6218
+ const U = Jo(b.typeName ?? b.objectType ?? b.name ?? b.ifcClass), Z = (l.get(U.toLowerCase()) ?? 0) + 1;
6163
6219
  l.set(U.toLowerCase(), Z);
6164
6220
  const B = Z === 1 ? U : `${U} (${Z})`;
6165
- Dt = { family: B, type: B, first: !0, key: Uo(jt) }, a.set(jt, Dt), a.set(Vt, Dt);
6221
+ Dt = { family: B, type: B, first: !0, key: qo(jt) }, a.set(jt, Dt), a.set(Vt, Dt);
6166
6222
  }
6167
6223
  const Xt = {
6168
6224
  ShapeCategory: P,
@@ -6186,7 +6242,7 @@ function Ll(n, t, e, s) {
6186
6242
  }
6187
6243
  }
6188
6244
  {
6189
- const B = Zn(n, Wt.gid).flatMap((dt) => dt.pts).map((dt) => Yt(dt).map((Mt) => Mt * Ce)), ut = /* @__PURE__ */ new Map();
6245
+ const B = ti(n, Wt.gid).flatMap((dt) => dt.pts).map((dt) => Yt(dt).map((Mt) => Mt * Ce)), ut = /* @__PURE__ */ new Map();
6190
6246
  for (const dt of B) {
6191
6247
  const Mt = Math.round(dt[1] * 200);
6192
6248
  ut.set(Mt, [...ut.get(Mt) ?? [], dt]);
@@ -6204,13 +6260,13 @@ function Ll(n, t, e, s) {
6204
6260
  })), Mt = [];
6205
6261
  for (let rt = 0; rt + 1 < dt.length; rt++) {
6206
6262
  const _t = dt[rt].r, ie = dt[rt + 1].r, Nt = [Math.max(_t[0], ie[0]), Math.min(_t[1], ie[1]), Math.max(_t[2], ie[2]), Math.min(_t[3], ie[3])];
6207
- Nt[1] - Nt[0] < 0.1 || Nt[3] - Nt[2] < 0.1 || dt[rt + 1].y - dt[rt].y < 0.01 || (Nt[0] < X[0] - 0.016 || Nt[1] > X[1] + 0.016 || Nt[2] < X[2] - 0.016 || Nt[3] > X[3] + 0.016) && Mt.push([Nt[0], dt[rt].y, Nt[2], Nt[1], dt[rt + 1].y, Nt[3]].map((le) => Re(le, 1e-5)));
6263
+ Nt[1] - Nt[0] < 0.1 || Nt[3] - Nt[2] < 0.1 || dt[rt + 1].y - dt[rt].y < 0.01 || (Nt[0] < X[0] - 0.016 || Nt[1] > X[1] + 0.016 || Nt[2] < X[2] - 0.016 || Nt[3] > X[3] + 0.016) && Mt.push([Nt[0], dt[rt].y, Nt[2], Nt[1], dt[rt + 1].y, Nt[3]].map((he) => Re(he, 1e-5)));
6208
6264
  }
6209
6265
  Mt.length && (Xt.OpeningSteps = JSON.stringify(Mt)), typeof process < "u" && ((d = process.env) != null && d.RECIPE_TRACE) && console.error(`[opening-steps] ${b.gid}: ${dt.length} planes, narrowest ${JSON.stringify(X.map((rt) => +rt.toFixed(3)))}, steps ${JSON.stringify(Mt)}`);
6210
6266
  }
6211
6267
  }
6212
6268
  if (Number.isFinite(U[0]) && (Xt.Opening = [...U, ...Z].map((B) => Re(B, 1e-5)).join(",")), typeof process < "u" && ((c = process.env) != null && c.RECIPE_CUT_LOST) && b.host && Number.isFinite(U[0])) {
6213
- const B = Zn(n, Wt.gid).flatMap((X) => X.pts), ut = Qt(n, b.host);
6269
+ const B = ti(n, Wt.gid).flatMap((X) => X.pts), ut = Qt(n, b.host);
6214
6270
  if (B.length && ut.length) {
6215
6271
  const X = [0, 1, 2].map((_t) => Math.min(...B.map((ie) => ie[_t])) - 0.01), dt = [0, 1, 2].map((_t) => Math.max(...B.map((ie) => ie[_t])) + 0.01), Mt = Math.min(...ut.map((_t) => _t[2])) + 0.01, rt = ut.filter((_t) => _t[0] > X[0] && _t[0] < dt[0] && _t[1] > X[1] && _t[1] < dt[1] && _t[2] > Math.max(X[2], Mt) && _t[2] < dt[2]).length;
6216
6272
  rt >= 4 && (Xt.CutIfLost = "1"), (E = process.env) != null && E.RECIPE_TRACE && console.error(`[cut-if-lost] ${b.gid}: ${rt} of its wall's corners in its opening → ${rt >= 4 ? "cut" : "not"}`);
@@ -6227,16 +6283,16 @@ function Ll(n, t, e, s) {
6227
6283
  }
6228
6284
  return p;
6229
6285
  }
6230
- function Do(n) {
6286
+ function Jo(n) {
6231
6287
  return (n.replace(/[\\:{}[\]|;<>?`~]/g, "-").replace(/\s+/g, " ").trim() || "Shape").slice(0, 120);
6232
6288
  }
6233
- function Uo(n) {
6289
+ function qo(n) {
6234
6290
  let t = 2166136261;
6235
6291
  for (let e = 0; e < n.length; e++)
6236
6292
  t ^= n.charCodeAt(e), t = Math.imul(t, 16777619);
6237
6293
  return (t >>> 0).toString(36);
6238
6294
  }
6239
- function Bl(n, t, e) {
6295
+ function Ul(n, t, e) {
6240
6296
  var r, a;
6241
6297
  const s = /* @__PURE__ */ new Map();
6242
6298
  for (const l of t) {
@@ -6251,10 +6307,10 @@ function Bl(n, t, e) {
6251
6307
  d && console.error(`[opening] ${l.gid}: its wall ${l.host} not written as a run`);
6252
6308
  continue;
6253
6309
  }
6254
- for (const c of Zn(n, l.gid)) {
6310
+ for (const c of ti(n, l.gid)) {
6255
6311
  const E = c.pts;
6256
6312
  if (E.length < 4) continue;
6257
- const b = Jl(Qt(n, l.host));
6313
+ const b = Gl(Qt(n, l.host));
6258
6314
  if (!b) continue;
6259
6315
  const $ = E.map((D) => (D[0] - b.a[0]) * b.u[0] + (D[1] - b.a[1]) * b.u[1]), P = E.map((D) => -(D[0] - b.a[0]) * b.u[1] + (D[1] - b.a[1]) * b.u[0]), N = (D) => Math.max(...D) - Math.min(...D), Y = N($) * N(P) * N(E.map((D) => D[2]));
6260
6316
  if (!(Y > 0) || Math.abs(c.volume) < 0.75 * Y) {
@@ -6271,7 +6327,7 @@ function Bl(n, t, e) {
6271
6327
  }
6272
6328
  return i;
6273
6329
  }
6274
- function jl(n) {
6330
+ function Jl(n) {
6275
6331
  const t = n.loops.flat(), e = [t.reduce((b, $) => b + $[0], 0) / t.length, t.reduce((b, $) => b + $[1], 0) / t.length], s = n.loops.map((b) => {
6276
6332
  const $ = b.map(([f, Tt]) => [f - e[0], Tt - e[1]]), P = $.map(([f, Tt]) => Math.hypot(f, Tt)), N = P.reduce((f, Tt) => f + Tt, 0) / P.length;
6277
6333
  if ($.length < 8 || N <= 0 || P.some((f) => Math.abs(f - N) > 0.02 * N)) return $;
@@ -6315,7 +6371,7 @@ function jl(n) {
6315
6371
  }
6316
6372
  return { axis: l, loops: c.loops, key: E, centre: e, turn: p + c.turn, flipped: c.flipped };
6317
6373
  }
6318
- function Dl(n) {
6374
+ function ql(n) {
6319
6375
  const e = n.v.length / 3;
6320
6376
  if (e < 6) return null;
6321
6377
  const s = [0, 1, 2].map((i) => {
@@ -6405,7 +6461,7 @@ function Dl(n) {
6405
6461
  }
6406
6462
  return null;
6407
6463
  }
6408
- function Ul(n, t) {
6464
+ function Vl(n, t) {
6409
6465
  const e = [];
6410
6466
  for (const s of n.elements.values()) {
6411
6467
  if (s.ifcClass.toUpperCase() !== "IFCSPACE") continue;
@@ -6442,7 +6498,7 @@ function Ul(n, t) {
6442
6498
  }
6443
6499
  return e;
6444
6500
  }
6445
- function Jl(n) {
6501
+ function Gl(n) {
6446
6502
  if (n.length < 2) return;
6447
6503
  let t = n[0], e = n[0], s = 0;
6448
6504
  for (const d of n) {
@@ -6476,7 +6532,7 @@ function Jl(n) {
6476
6532
  }
6477
6533
  return { a: t, u: [(e[0] - t[0]) / s, (e[1] - t[1]) / s] };
6478
6534
  }
6479
- function Zn(n, t) {
6535
+ function ti(n, t) {
6480
6536
  const e = n.elements.get(t);
6481
6537
  if (!e) return [];
6482
6538
  const s = [], i = [], r = /* @__PURE__ */ new Map();
@@ -6506,12 +6562,12 @@ function Zn(n, t) {
6506
6562
  let b = p.get(E);
6507
6563
  b || (b = { pts: /* @__PURE__ */ new Set(), volume: 0 }, p.set(E, b));
6508
6564
  const [$, P, N] = [s[i[c]], s[i[c + 1]], s[i[c + 2]]];
6509
- b.volume += Os($, os(P, N)) / 6, b.pts.add(i[c]), b.pts.add(i[c + 1]), b.pts.add(i[c + 2]);
6565
+ b.volume += Rs($, os(P, N)) / 6, b.pts.add(i[c]), b.pts.add(i[c + 1]), b.pts.add(i[c + 2]);
6510
6566
  }
6511
6567
  const d = [...p.values()];
6512
6568
  return d.map((c, E) => ({ pts: [...c.pts].map((b) => s[b]), volume: c.volume, index: E, of: d.length }));
6513
6569
  }
6514
- function ql(n, t, e, s, i, r) {
6570
+ function Hl(n, t, e, s, i, r) {
6515
6571
  const a = n.elements.get(t);
6516
6572
  if (!a) return null;
6517
6573
  const l = (E) => (E[0] - e[0]) * s[0] + (E[1] - e[1]) * s[1], p = (E) => -(E[0] - e[0]) * s[1] + (E[1] - e[1]) * s[0];
@@ -6554,7 +6610,7 @@ function Qt(n, t, e) {
6554
6610
  }
6555
6611
  return i;
6556
6612
  }
6557
- function Vl(n, t, e, s) {
6613
+ function zl(n, t, e, s) {
6558
6614
  var r;
6559
6615
  const i = [];
6560
6616
  for (const a of n.elements.values()) {
@@ -6586,7 +6642,7 @@ function Vl(n, t, e, s) {
6586
6642
  }
6587
6643
  return i;
6588
6644
  }
6589
- function xn(n, t, e, s, i = !1) {
6645
+ function An(n, t, e, s, i = !1) {
6590
6646
  const r = n.elements.get(t);
6591
6647
  if (!r) return null;
6592
6648
  const a = Math.hypot(s[0] - e[0], s[1] - e[1]);
@@ -6715,7 +6771,7 @@ function xn(n, t, e, s, i = !1) {
6715
6771
  for (let at = 1; at < Yt.length; at++) if (Yt[at][0] < Yt[at - 1][0] - 3e-3) return null;
6716
6772
  return Yt.length > 200 ? null : { lo: D, hi: f, bottom: Tt, chain: Yt };
6717
6773
  }
6718
- function Gl(n, t, e) {
6774
+ function Wl(n, t, e) {
6719
6775
  const s = Qt(n, t);
6720
6776
  if (s.length < 4 || e.length === 0) return;
6721
6777
  let i = s[0], r = s[0], a = 0;
@@ -6752,7 +6808,7 @@ const De = {
6752
6808
  structuralFoundations: "-2001300",
6753
6809
  stairs: "-2000120"
6754
6810
  };
6755
- function As(n) {
6811
+ function Cs(n) {
6756
6812
  const t = n.item.attrs.Name;
6757
6813
  if (typeof t != "string") return null;
6758
6814
  const e = t.indexOf(":"), s = t.lastIndexOf(":");
@@ -6760,18 +6816,18 @@ function As(n) {
6760
6816
  const i = t.slice(e + 1, s).trim();
6761
6817
  return i ? { family: t.slice(0, e).trim(), type: i } : null;
6762
6818
  }
6763
- function Jo(n) {
6764
- const t = As(n), e = n.item.attrs.PredefinedType;
6819
+ function Vo(n) {
6820
+ const t = Cs(n), e = n.item.attrs.PredefinedType;
6765
6821
  return t ? /escalera|stair|landing|descansillo/i.test(t.family) || e === "LANDING" || /plataforma|^pad\b|building pad/i.test(t.family) ? "other" : /cubierta|roof/i.test(t.family) || e === "ROOF" ? "roof" : /cimentaci|foundation/i.test(t.family) || e === "BASESLAB" ? "foundation" : "floor" : "floor";
6766
6822
  }
6767
- const qo = 180 / Math.PI;
6768
- function Vo(n) {
6823
+ const Go = 180 / Math.PI;
6824
+ function Ho(n) {
6769
6825
  if (typeof n != "string") return null;
6770
6826
  const t = n.indexOf(":");
6771
6827
  return t <= 0 || t === n.length - 1 ? null : { family: n.slice(0, t), type: n.slice(t + 1) };
6772
6828
  }
6773
6829
  const Ct = (n) => String(n);
6774
- function Hl(n) {
6830
+ function Yl(n) {
6775
6831
  const t = n.slice(), e = (s, i, r) => Math.abs((i[0] - s[0]) * (r[1] - s[1]) - (r[0] - s[0]) * (i[1] - s[1])) / 2;
6776
6832
  for (let s = !0; s && t.length > 3; ) {
6777
6833
  s = !1;
@@ -6782,13 +6838,13 @@ function Hl(n) {
6782
6838
  }
6783
6839
  return t;
6784
6840
  }
6785
- function La(n) {
6841
+ function ja(n) {
6786
6842
  return async (t) => {
6787
- var Ei, Ti, Mi, $i, Ii, Si, xi, _i, Ai, Ci, Oi, Ri, ki, Ni, Fi, Pi, Li, Bi, ji, Di, Ui, Ji, qi, Vi, Gi, Hi, zi, Wi, Yi, Ki, Xi, Zi, Qi, tr, er, sr, nr, ir, rr, or, ar, cr, lr, hr, fr, dr, ur, pr, mr, gr, yr, wr, br, vr, Er, Tr, Mr, $r, Ir, Sr, xr, _r, Ar, Cr, Or, Rr, kr, Nr, Fr, Pr, Lr, Br, jr, Dr, Ur, Jr, qr, Vr, Gr, Hr, zr, Wr, Yr, Kr, Xr, Zr, Qr, to, eo, so, no, io, ro, oo, ao, co, lo, ho, fo, uo, po;
6788
- const { picked: e, contents: s, site: i, shapes: r } = await ci(
6843
+ var Mi, $i, Ii, Si, xi, _i, Ai, Ci, Oi, Ri, ki, Ni, Fi, Pi, Li, Bi, ji, Di, Ui, Ji, qi, Vi, Gi, Hi, zi, Wi, Yi, Ki, Xi, Zi, Qi, tr, er, sr, nr, ir, rr, or, ar, cr, lr, hr, fr, dr, ur, pr, mr, gr, yr, wr, br, vr, Er, Tr, Mr, $r, Ir, Sr, xr, _r, Ar, Cr, Or, Rr, kr, Nr, Fr, Pr, Lr, Br, jr, Dr, Ur, Jr, qr, Vr, Gr, Hr, zr, Wr, Yr, Kr, Xr, Zr, Qr, to, eo, so, no, io, ro, oo, ao, co, lo, ho, fo, uo, po, mo, go;
6844
+ const { picked: e, contents: s, site: i, shapes: r } = await hi(
6789
6845
  t,
6790
6846
  t.input
6791
- ), a = Ia(s.items), l = /CoordinateBase:\s*(Coordenadas compartidas|Shared Coordinates|Shared)/i.test(
6847
+ ), a = xa(s.items), l = /CoordinateBase:\s*(Coordenadas compartidas|Shared Coordinates|Shared)/i.test(
6792
6848
  JSON.stringify(s.metadata ?? {})
6793
6849
  ), p = l && i ? [i.east * rs, i.north * rs, i.elevation * rs, i.angleDeg].map((o) => o.toFixed(6)).join(",") : void 0;
6794
6850
  if (a.length === 0)
@@ -6800,12 +6856,12 @@ function La(n) {
6800
6856
  throw new Error(
6801
6857
  "Free-standing instances can only be made by their style names: turn trustStyleNames on."
6802
6858
  );
6803
- const $ = oi(a), P = Sa(a);
6804
- if (typeof process < "u" && ((Ei = process.env) != null && Ei.RECIPE_STYLE))
6859
+ const $ = ci(a), P = _a(a);
6860
+ if (typeof process < "u" && ((Mi = process.env) != null && Mi.RECIPE_STYLE))
6805
6861
  for (const [o, h] of P) o.includes(process.env.RECIPE_STYLE) && console.error(`[style] ${o}: ${JSON.stringify(h).slice(0, 1500)}`);
6806
- const N = `recipe:${n}-to-revit`, Y = /* @__PURE__ */ new Map(), z = ai(t, Y);
6862
+ const N = `recipe:${n}-to-revit`, Y = /* @__PURE__ */ new Map(), z = li(t, Y);
6807
6863
  t.progress("Writing the changes for Revit");
6808
- const D = new ii({
6864
+ const D = new oi({
6809
6865
  project: t.projectId,
6810
6866
  document: t.target.docId ?? "",
6811
6867
  baseCommit: t.target.version ?? 0,
@@ -6856,10 +6912,10 @@ function La(n) {
6856
6912
  }, Yt = (o, h, w) => {
6857
6913
  if (!z.has(o)) return !1;
6858
6914
  const m = Y.get(o), F = l ? { ...h, Frame: "shared", ...p ? { SharedAt: p } : {} } : h;
6859
- return !m || m === nn({ attrs: F, placement: w ?? {} });
6915
+ return !m || m === rn({ attrs: F, placement: w ?? {} });
6860
6916
  }, at = /* @__PURE__ */ new Map(), nt = (o, h, w) => {
6861
6917
  wt.add(o), at.set(o, h);
6862
- const m = l ? { ...h, Frame: "shared", ...p ? { SharedAt: p } : {} } : h, F = nn({ attrs: m, placement: w ?? {} }), R = z.get(o);
6918
+ const m = l ? { ...h, Frame: "shared", ...p ? { SharedAt: p } : {} } : h, F = rn({ attrs: m, placement: w ?? {} }), R = z.get(o);
6863
6919
  if (R) {
6864
6920
  const k = Y.get(o);
6865
6921
  return !k || k === F ? (tt++, !1) : (D.remove(R), D.add({ ...m, "flow:print": F }, { ...w, source: o }), ct++, !1);
@@ -6885,7 +6941,7 @@ function La(n) {
6885
6941
  let Xt = 0;
6886
6942
  if (b)
6887
6943
  for (const [o, h] of $) {
6888
- const w = { CategoryId: De.levels, Name: h.name, Elevation: Ct(h.at * f) }, m = nn({ attrs: l ? { ...w, Frame: "shared", ...p ? { SharedAt: p } : {} } : w, placement: {} }), F = (Ti = [...Y].find(([R, k]) => k === m && z.has(R))) == null ? void 0 : Ti[0];
6944
+ const w = { CategoryId: De.levels, Name: h.name, Elevation: Ct(h.at * f) }, m = rn({ attrs: l ? { ...w, Frame: "shared", ...p ? { SharedAt: p } : {} } : w, placement: {} }), F = ($i = [...Y].find(([R, k]) => k === m && z.has(R))) == null ? void 0 : $i[0];
6889
6945
  nt(F ?? st(o), w) && Xt++;
6890
6946
  }
6891
6947
  let Kt = 0, Wt = 0;
@@ -6899,7 +6955,7 @@ function La(n) {
6899
6955
  }) : []), X = [];
6900
6956
  for (const o of a) {
6901
6957
  if (o.kind !== "run" || o.params.of !== "wall") continue;
6902
- const h = de(o, "run"), w = (($i = (Mi = h == null ? void 0 : h.run) == null ? void 0 : Mi.line) == null ? void 0 : $i.curves) ?? [], m = o.params.lookRef, F = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? ""));
6958
+ const h = de(o, "run"), w = ((Si = (Ii = h == null ? void 0 : h.run) == null ? void 0 : Ii.line) == null ? void 0 : Si.curves) ?? [], m = o.params.lookRef, F = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? ""));
6903
6959
  if (typeof m != "string" || typeof (h == null ? void 0 : h.height) != "number" || !F) {
6904
6960
  Wt++;
6905
6961
  continue;
@@ -6958,7 +7014,7 @@ function La(n) {
6958
7014
  }
6959
7015
  ie.set(o, w);
6960
7016
  }
6961
- const le = /* @__PURE__ */ new Map();
7017
+ const he = /* @__PURE__ */ new Map();
6962
7018
  if (r) {
6963
7019
  const o = (w) => {
6964
7020
  const m = Math.hypot(w.to[0] - w.from[0], w.to[1] - w.from[1]);
@@ -6968,7 +7024,7 @@ function La(n) {
6968
7024
  if (!R || X.filter((x) => x.record === w.record).length !== 1) return null;
6969
7025
  const { d: k } = o(w), V = Qt(r, R).map((x) => x[2]);
6970
7026
  if (!V.length) return null;
6971
- const u = ql(r, R, w.from, k, (m + F) / 2, (Math.min(...V) + Math.max(...V)) / 2);
7027
+ const u = Hl(r, R, w.from, k, (m + F) / 2, (Math.min(...V) + Math.max(...V)) / 2);
6972
7028
  return u ? u.hi - u.lo : null;
6973
7029
  };
6974
7030
  for (const w of X) {
@@ -6984,7 +7040,7 @@ function La(n) {
6984
7040
  const V = [F.from, F.to].map(($t) => ($t[0] - w.from[0]) * m.d[0] + ($t[1] - w.from[1]) * m.d[1]), u = Math.max(0, Math.min(...V)), x = Math.min(m.L, Math.max(...V));
6985
7041
  if (x - u < 0.3) continue;
6986
7042
  const gt = h(w, u, x);
6987
- typeof process < "u" && ((Si = (Ii = process.env) == null ? void 0 : Ii.RECIPE_WALL) != null && Si.split(",").includes(w.record.item.guid ?? "")) && console.error(`[cut-by?] ${w.record.item.guid} by ${F.record.item.guid}: off ${k.toFixed(3)}, along ${u.toFixed(2)}..${x.toFixed(2)}, shape ${gt}`), !(gt === null || gt > w.width - 0.01) && (typeof process < "u" && ((xi = process.env) != null && xi.RECIPE_TRACE) && console.error(`[cut-by] ${w.record.item.guid} (${(w.width * 1e3).toFixed(0)} mm, its shape ${(gt * 1e3).toFixed(0)}) cut by ${F.record.item.guid} over ${(x - u).toFixed(2)} m`), le.set(w, [...le.get(w) ?? [], F]));
7043
+ typeof process < "u" && ((_i = (xi = process.env) == null ? void 0 : xi.RECIPE_WALL) != null && _i.split(",").includes(w.record.item.guid ?? "")) && console.error(`[cut-by?] ${w.record.item.guid} by ${F.record.item.guid}: off ${k.toFixed(3)}, along ${u.toFixed(2)}..${x.toFixed(2)}, shape ${gt}`), !(gt === null || gt > w.width - 0.01) && (typeof process < "u" && ((Ai = process.env) != null && Ai.RECIPE_TRACE) && console.error(`[cut-by] ${w.record.item.guid} (${(w.width * 1e3).toFixed(0)} mm, its shape ${(gt * 1e3).toFixed(0)}) cut by ${F.record.item.guid} over ${(x - u).toFixed(2)} m`), he.set(w, [...he.get(w) ?? [], F]));
6988
7044
  }
6989
7045
  }
6990
7046
  }
@@ -7039,7 +7095,7 @@ function La(n) {
7039
7095
  const { record: h } = o;
7040
7096
  let w = [];
7041
7097
  const m = de(h, "run");
7042
- typeof process < "u" && ((Ai = (_i = process.env) == null ? void 0 : _i.RECIPE_WALL) != null && Ai.split(",").includes(h.item.guid ?? "")) && console.error(`[wall] ${h.item.guid}: params ${JSON.stringify(h.params).slice(0, 800)} seg ${JSON.stringify({ from: o.from, to: o.to, i: o.i })}`);
7098
+ typeof process < "u" && ((Oi = (Ci = process.env) == null ? void 0 : Ci.RECIPE_WALL) != null && Oi.split(",").includes(h.item.guid ?? "")) && console.error(`[wall] ${h.item.guid}: params ${JSON.stringify(h.params).slice(0, 800)} seg ${JSON.stringify({ from: o.from, to: o.to, i: o.i })}`);
7043
7099
  const F = typeof m.base == "number" ? m.base : 0, R = m.height, k = $.get(String(m.level ?? h.params.level ?? "")), V = h.params.lookRef;
7044
7100
  let { from: u, to: x } = o.arcMid ? { from: o.from, to: o.to } : ie.get(o);
7045
7101
  Math.hypot(x[0] - u[0], x[1] - u[1]) < 0.01 && ({ from: u, to: x } = o);
@@ -7052,8 +7108,8 @@ function La(n) {
7052
7108
  if (!J || !j) return null;
7053
7109
  const W = y[0] * j[0] + y[1] * j[1];
7054
7110
  return Math.abs(W) < 0.5 ? null : ((J[0] - S[0]) * j[0] + (J[1] - S[1]) * j[1]) / W;
7055
- }, T = h.params.wantedAtStart === "square" ? g(u, (Ci = L.start) == null ? void 0 : Ci[0]) : null, v = h.params.wantedAtEnd === "square" ? g(x, (Oi = L.end) == null ? void 0 : Oi[0]) : null;
7056
- T !== null && T > 5e-3 && T < Math.min(1, _ / 2) && (u = [u[0] + y[0] * T, u[1] + y[1] * T], gt.add("start")), v !== null && v < -5e-3 && v > -Math.min(1, _ / 2) && (x = [x[0] + y[0] * v, x[1] + y[1] * v], gt.add("end")), typeof process < "u" && ((Ri = process.env) != null && Ri.RECIPE_CUT_OUT) && (T !== null && T < -5e-3 && T > -1 && (u = [u[0] + y[0] * T, u[1] + y[1] * T], gt.add("start")), v !== null && v > 5e-3 && v < 1 && (x = [x[0] + y[0] * v, x[1] + y[1] * v], gt.add("end"))), typeof process < "u" && ((ki = process.env) != null && ki.RECIPE_TRACE) && (T !== null && Math.abs(T) > 5e-3 && Math.abs(T) < 1 || v !== null && Math.abs(v) > 5e-3 && Math.abs(v) < 1) && console.error(`[wall-to-cut] ${h.item.guid} ${V}: start ${T == null ? void 0 : T.toFixed(3)} end ${v == null ? void 0 : v.toFixed(3)}`), typeof process < "u" && ((Fi = (Ni = process.env) == null ? void 0 : Ni.RECIPE_WALL) != null && Fi.split(",").includes(h.item.guid ?? "")) && console.error(`[wall-cut] ${h.item.guid}: start ${T == null ? void 0 : T.toFixed(3)} end ${v == null ? void 0 : v.toFixed(3)}`);
7111
+ }, T = h.params.wantedAtStart === "square" ? g(u, (Ri = L.start) == null ? void 0 : Ri[0]) : null, v = h.params.wantedAtEnd === "square" ? g(x, (ki = L.end) == null ? void 0 : ki[0]) : null;
7112
+ T !== null && T > 5e-3 && T < Math.min(1, _ / 2) && (u = [u[0] + y[0] * T, u[1] + y[1] * T], gt.add("start")), v !== null && v < -5e-3 && v > -Math.min(1, _ / 2) && (x = [x[0] + y[0] * v, x[1] + y[1] * v], gt.add("end")), typeof process < "u" && ((Ni = process.env) != null && Ni.RECIPE_CUT_OUT) && (T !== null && T < -5e-3 && T > -1 && (u = [u[0] + y[0] * T, u[1] + y[1] * T], gt.add("start")), v !== null && v > 5e-3 && v < 1 && (x = [x[0] + y[0] * v, x[1] + y[1] * v], gt.add("end"))), typeof process < "u" && ((Fi = process.env) != null && Fi.RECIPE_TRACE) && (T !== null && Math.abs(T) > 5e-3 && Math.abs(T) < 1 || v !== null && Math.abs(v) > 5e-3 && Math.abs(v) < 1) && console.error(`[wall-to-cut] ${h.item.guid} ${V}: start ${T == null ? void 0 : T.toFixed(3)} end ${v == null ? void 0 : v.toFixed(3)}`), typeof process < "u" && ((Li = (Pi = process.env) == null ? void 0 : Pi.RECIPE_WALL) != null && Li.split(",").includes(h.item.guid ?? "")) && console.error(`[wall-cut] ${h.item.guid}: start ${T == null ? void 0 : T.toFixed(3)} end ${v == null ? void 0 : v.toFixed(3)}`);
7057
7113
  }
7058
7114
  }
7059
7115
  const $t = new Set(gt), Ot = !o.arcMid && r && h.item.guid && X.filter((L) => L.record === h).length === 1 ? r.elements.get(h.item.guid) : void 0;
@@ -7069,14 +7125,14 @@ function La(n) {
7069
7125
  }
7070
7126
  const It = (k.at + F) * f, yt = `${Ct(u[0] * f)},${Ct(u[1] * f)},${Ct(It)};${Ct(x[0] * f)},${Ct(x[1] * f)},${Ct(It)}`, A = {
7071
7127
  CategoryId: De.walls,
7072
- Type: ((Pi = As(h)) == null ? void 0 : Pi.type) ?? V,
7128
+ Type: ((Bi = Cs(h)) == null ? void 0 : Bi.type) ?? V,
7073
7129
  LocationLine: yt,
7074
7130
  Level: k.name,
7075
7131
  BaseOffset: Ct(F * f),
7076
7132
  Height: Ct(R * f),
7077
7133
  // (An arc: bent through its middle by the applier, its ends where the line's are.)
7078
7134
  ...o.arcMid ? { LocationArc: `${Ct(o.arcMid[0] * f)},${Ct(o.arcMid[1] * f)},${Ct(It)}` } : {}
7079
- }, Rt = le.get(o);
7135
+ }, Rt = he.get(o);
7080
7136
  Rt && (A.CutBy = Rt.flatMap((L) => {
7081
7137
  const _ = `${st(L.record.id)}#${L.i}`, y = z.get(_);
7082
7138
  return y ? [_, y] : [_];
@@ -7088,12 +7144,12 @@ function La(n) {
7088
7144
  const K = $.get(String(h.params.topLevel ?? ""));
7089
7145
  K && (A.TopLevel = K.name, A.TopOffset = Ct((k.at + F + R - K.at) * f));
7090
7146
  const G = m.profile;
7091
- let et = Array.isArray(G) ? Hl(G) : G;
7147
+ let et = Array.isArray(G) ? Yl(G) : G;
7092
7148
  if ((h.params.wantedAtStart === "mitre" || h.params.wantedAtEnd === "mitre") && Array.isArray(et) && et.length === 4) {
7093
7149
  const L = Math.hypot(o.to[0] - o.from[0], o.to[1] - o.from[1]), _ = m.height, y = (T, v) => Math.abs(T) < 1e-4 ? "lo" : Math.abs(T - v) < 1e-3 ? "hi" : null, g = et.map(([T, v]) => [y(T, L), y(v, _)]);
7094
7150
  g.every(([T, v]) => T && v) && new Set(g.map(([T, v]) => `${T}${v}`)).size === 4 && (et = void 0);
7095
7151
  }
7096
- if (typeof process < "u" && ((Li = process.env) != null && Li.RECIPE_LAYER_EXT) && Array.isArray(et) && et.length >= 4 && r && h.item.guid && typeof m.height == "number") {
7152
+ if (typeof process < "u" && ((ji = process.env) != null && ji.RECIPE_LAYER_EXT) && Array.isArray(et) && et.length >= 4 && r && h.item.guid && typeof m.height == "number") {
7097
7153
  const L = (() => {
7098
7154
  var _, y;
7099
7155
  try {
@@ -7107,7 +7163,7 @@ function La(n) {
7107
7163
  const ot = Qt(r, M.gid).map((Q) => [(Q[0] - o.from[0]) * g[0] + (Q[1] - o.from[1]) * g[1], Q[2] - T]);
7108
7164
  return ot.length ? [Math.min(...ot.map((Q) => Q[0])), Math.max(...ot.map((Q) => Q[0])), Math.min(...ot.map((Q) => Q[1])), Math.max(...ot.map((Q) => Q[1]))] : null;
7109
7165
  }).filter((M) => M !== null), S = Math.min(...et.map(([M]) => M)), C = Math.max(...et.map(([M]) => M)), J = ([M, ot]) => (Math.abs(M - S) < 5e-3 || Math.abs(M - C) < 5e-3) && (Math.abs(ot) < 5e-3 || Math.abs(ot - y) < 5e-3), j = ([M, ot]) => v.some((Q) => M >= Q[0] - 0.03 && M <= Q[1] + 0.03 && ot >= Q[2] - 0.15 && ot <= Q[3] + 0.03), W = et.filter((M) => !J(M));
7110
- et.filter(J).length === 4 && (W.length === 0 || v.length && W.every(j)) && (typeof process < "u" && ((Bi = process.env) != null && Bi.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${V}: its outline's ${W.length} notch corner(s) filled by what it hosts → a plain wall`), et = void 0);
7166
+ et.filter(J).length === 4 && (W.length === 0 || v.length && W.every(j)) && (typeof process < "u" && ((Di = process.env) != null && Di.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${V}: its outline's ${W.length} notch corner(s) filled by what it hosts → a plain wall`), et = void 0);
7111
7167
  }
7112
7168
  }
7113
7169
  if (!o.arcMid && Array.isArray(et) && et.length >= 3 && o.i === 0 && !X.some((L) => L !== o && L.record === h)) {
@@ -7122,7 +7178,7 @@ function La(n) {
7122
7178
  const se = A.Mitre.split(",").filter((Jt) => Zt.includes(Jt));
7123
7179
  se.length ? A.Mitre = se.join(",") : delete A.Mitre;
7124
7180
  }
7125
- ot.length && typeof process < "u" && ((ji = process.env) != null && ji.RECIPE_TRACE) && console.error(`[profile-face] ${h.item.guid} ${V}: ${ot.join(",")} to the far face`);
7181
+ ot.length && typeof process < "u" && ((Ui = process.env) != null && Ui.RECIPE_TRACE) && console.error(`[profile-face] ${h.item.guid} ${V}: ${ot.join(",")} to the far face`);
7126
7182
  }
7127
7183
  const C = (M, ot) => et.map(([Q, Ft], Ut) => {
7128
7184
  const Gt = Math.abs(Q) < 1e-6, ee = Math.abs(Q - L) < 1e-6;
@@ -7143,15 +7199,15 @@ function La(n) {
7143
7199
  const Ft = (Ut, Gt, ee) => (Gt[0] - Ut[0]) * (ee[1] - Ut[1]) - (Gt[1] - Ut[1]) * (ee[0] - Ut[0]);
7144
7200
  for (let Ut = 0; Ut < ot; Ut++) for (let Gt = Ut + 1; Gt < ot; Gt++) {
7145
7201
  if (Gt === Ut + 1 || Ut === 0 && Gt === ot - 1) continue;
7146
- const [ee, Zt] = Q[Ut], [se, Jt] = Q[Gt], fe = Ft(se, Jt, ee), Be = Ft(se, Jt, Zt), ws = Ft(ee, Zt, se), mo = Ft(ee, Zt, Jt);
7147
- if ((fe > 1e-9 && Be < -1e-9 || fe < -1e-9 && Be > 1e-9) && (ws > 1e-9 && mo < -1e-9 || ws < -1e-9 && mo > 1e-9)) return !1;
7202
+ const [ee, Zt] = Q[Ut], [se, Jt] = Q[Gt], fe = Ft(se, Jt, ee), Be = Ft(se, Jt, Zt), bs = Ft(ee, Zt, se), yo = Ft(ee, Zt, Jt);
7203
+ if ((fe > 1e-9 && Be < -1e-9 || fe < -1e-9 && Be > 1e-9) && (bs > 1e-9 && yo < -1e-9 || bs < -1e-9 && yo > 1e-9)) return !1;
7148
7204
  }
7149
7205
  return !0;
7150
7206
  };
7151
7207
  let j = C(g, T);
7152
7208
  if (!J(j)) {
7153
7209
  const ot = [[v, S], [0, 0]].find(([Q, Ft]) => J(C(Q, Ft)));
7154
- typeof process < "u" && ((Di = process.env) != null && Di.RECIPE_TRACE) && console.error(`[profile-folded] ${h.item.guid} ${V}: ends ${g.toFixed(3)}/${T.toFixed(3)} fold it → ${ot ? ot.map((Q) => Q.toFixed(3)).join("/") : "as given"}`), j = ot ? C(...ot) : et.map(([Q, Ft]) => [Q, Ft]);
7210
+ typeof process < "u" && ((Ji = process.env) != null && Ji.RECIPE_TRACE) && console.error(`[profile-folded] ${h.item.guid} ${V}: ends ${g.toFixed(3)}/${T.toFixed(3)} fold it → ${ot ? ot.map((Q) => Q.toFixed(3)).join("/") : "as given"}`), j = ot ? C(...ot) : et.map(([Q, Ft]) => [Q, Ft]);
7155
7211
  }
7156
7212
  const W = (M) => M.flatMap(([ot, Q]) => {
7157
7213
  const Ft = [o.from[0] + ot * _[0], o.from[1] + ot * _[1]];
@@ -7162,7 +7218,7 @@ function La(n) {
7162
7218
  const M = j.map(([, Jt]) => Jt), ot = Math.max(...M), Q = Math.min(...M), Ft = j.map(([Jt]) => Jt), Ut = Math.min(...Ft), Gt = Math.max(...Ft), ee = j.filter(([Jt]) => Jt > Ut + 5e-3 && Jt < Gt - 5e-3), Zt = [...new Set(ee.map(([Jt]) => +Jt.toFixed(4)))].sort((Jt, fe) => Jt - fe);
7163
7219
  if (j.filter(([Jt, fe]) => (Math.abs(Jt - Ut) < 5e-3 || Math.abs(Jt - Gt) < 5e-3) && (Math.abs(fe - ot) < 5e-3 || Math.abs(fe - Q) < 5e-3)).length === 4 && ee.length === 4 && Zt.length === 2 && Zt[1] - Zt[0] < 0.3 && ee.some(([, Jt]) => Math.abs(Jt - Q) < 5e-3) && ee.every(([, Jt]) => Math.abs(Jt - Q) < 5e-3 || ot - Jt < 0.3)) {
7164
7220
  const Jt = (fe, Be) => [[fe, Q], [Be, Q], [Be, ot], [fe, ot]];
7165
- A.Profile = JSON.stringify([W(Jt(Ut, Zt[0]))]), w = [JSON.stringify([W(Jt(Zt[1], Gt))])], typeof process < "u" && ((Ui = process.env) != null && Ui.RECIPE_TRACE) && console.error(`[slit-split] ${h.item.guid} ${V}: a slit ${((Zt[1] - Zt[0]) * 100).toFixed(0)} cm wide at ${Zt[0].toFixed(2)}, two walls`);
7221
+ A.Profile = JSON.stringify([W(Jt(Ut, Zt[0]))]), w = [JSON.stringify([W(Jt(Zt[1], Gt))])], typeof process < "u" && ((qi = process.env) != null && qi.RECIPE_TRACE) && console.error(`[slit-split] ${h.item.guid} ${V}: a slit ${((Zt[1] - Zt[0]) * 100).toFixed(0)} cm wide at ${Zt[0].toFixed(2)}, two walls`);
7166
7222
  }
7167
7223
  }
7168
7224
  delete A.TopLevel, delete A.TopOffset;
@@ -7182,15 +7238,15 @@ function La(n) {
7182
7238
  }
7183
7239
  A.Profile = JSON.stringify([S]), delete A.TopLevel, delete A.TopOffset;
7184
7240
  }
7185
- const mt = typeof St == "string" ? St : r && h.item.guid ? Gl(r, h.item.guid, Dt) : void 0;
7241
+ const mt = typeof St == "string" ? St : r && h.item.guid ? Wl(r, h.item.guid, Dt) : void 0;
7186
7242
  if (mt && !A.Profile) {
7187
7243
  A.AttachTop = st(mt);
7188
7244
  const L = z.get(st(mt));
7189
7245
  L && (A.AttachTopMade = L);
7190
7246
  }
7191
- if (mt && typeof St != "string" && typeof process < "u" && ((Ji = process.env) != null && Ji.RECIPE_TRACE) && console.error(`[attach] ${h.item.guid} ${h.item.name ?? ""} → ${mt}`), !A.Profile && !A.AttachTop && Ot) {
7247
+ if (mt && typeof St != "string" && typeof process < "u" && ((Vi = process.env) != null && Vi.RECIPE_TRACE) && console.error(`[attach] ${h.item.guid} ${h.item.name ?? ""} → ${mt}`), !A.Profile && !A.AttachTop && Ot) {
7192
7248
  const L = [...r.elements.values()].filter((T) => T.host === h.item.guid && !/^IFCOPENINGELEMENT$/i.test(T.ifcClass));
7193
- let _ = xn(r, h.item.guid, u, x, !0);
7249
+ let _ = An(r, h.item.guid, u, x, !0);
7194
7250
  const y = (T) => {
7195
7251
  const v = [];
7196
7252
  for (const S of T) (!v.length || Math.hypot(S[0] - v[v.length - 1][0], S[1] - v[v.length - 1][1]) >= 0.02) && v.push(S);
@@ -7209,11 +7265,11 @@ function La(n) {
7209
7265
  const W = Math.min(...j.map((Ft) => Ft[0])), M = Math.max(...j.map((Ft) => Ft[0])), ot = Math.min(...j.map((Ft) => Ft[1])), Q = Math.max(...j.map((Ft) => Ft[1]));
7210
7266
  return S.some((Ft) => Math.min(M, Ft[1]) - Math.max(W, Ft[0]) > 0.01 && Math.min(Q, Ft[3]) - Math.max(ot, Ft[2]) > 0.01);
7211
7267
  }, J = (_.holes ?? []).filter((j) => !C(j));
7212
- _ = !((qi = _.pieces) != null && qi.length) && (J.length || _.outline.length > 4) ? { ..._, holes: J } : null, _ && typeof process < "u" && ((Vi = process.env) != null && Vi.RECIPE_TRACE) && console.error(`[wall-outline] ${h.item.guid}: ${L.length} hosted, ${J.length} empty hole(s) kept`);
7268
+ _ = !((Gi = _.pieces) != null && Gi.length) && (J.length || _.outline.length > 4) ? { ..._, holes: J } : null, _ && typeof process < "u" && ((Hi = process.env) != null && Hi.RECIPE_TRACE) && console.error(`[wall-outline] ${h.item.guid}: ${L.length} hosted, ${J.length} empty hole(s) kept`);
7213
7269
  }
7214
- const g = _ != null && _.outline ? null : xn(r, h.item.guid, u, x);
7270
+ const g = _ != null && _.outline ? null : An(r, h.item.guid, u, x);
7215
7271
  if (g) {
7216
- typeof process < "u" && ((Gi = process.env) != null && Gi.RECIPE_TRACE) && console.error(`[wall-top] ${h.item.guid} ${h.item.name ?? ""}: ${g.chain.map(([J, j]) => `${J.toFixed(2)}/${j.toFixed(2)}`).join(" ")}`);
7272
+ typeof process < "u" && ((zi = process.env) != null && zi.RECIPE_TRACE) && console.error(`[wall-top] ${h.item.guid} ${h.item.name ?? ""}: ${g.chain.map(([J, j]) => `${J.toFixed(2)}/${j.toFixed(2)}`).join(" ")}`);
7217
7273
  const T = Math.hypot(x[0] - u[0], x[1] - u[1]), v = [(x[0] - u[0]) / T, (x[1] - u[1]) / T], S = [], C = (J, j) => {
7218
7274
  S.push((u[0] + J * v[0]) * f, (u[1] + J * v[1]) * f, j * f);
7219
7275
  };
@@ -7222,17 +7278,17 @@ function La(n) {
7222
7278
  A.Profile = JSON.stringify([S]), delete A.TopLevel, delete A.TopOffset;
7223
7279
  }
7224
7280
  if (_ != null && _.outline) {
7225
- typeof process < "u" && ((Hi = process.env) != null && Hi.RECIPE_TRACE) && console.error(`[wall-outline] ${h.item.guid} ${h.item.name ?? ""}: ${_.outline.length} corners`);
7281
+ typeof process < "u" && ((Wi = process.env) != null && Wi.RECIPE_TRACE) && console.error(`[wall-outline] ${h.item.guid} ${h.item.name ?? ""}: ${_.outline.length} corners`);
7226
7282
  const T = Math.hypot(x[0] - u[0], x[1] - u[1]), v = [(x[0] - u[0]) / T, (x[1] - u[1]) / T], S = (C) => C.flatMap(([J, j]) => [(u[0] + J * v[0]) * f, (u[1] + J * v[1]) * f, (j - re) * f]);
7227
7283
  A.Profile = JSON.stringify([S(_.outline), ...(_.holes ?? []).map(S)]), delete A.TopLevel, delete A.TopOffset, w = (_.pieces ?? []).map((C) => JSON.stringify([S(C)]));
7228
7284
  }
7229
7285
  } else if (A.Profile && Ot && !A.AttachTop) {
7230
- const _ = [...r.elements.values()].some((y) => y.host === h.item.guid && !/^IFCOPENINGELEMENT$/i.test(y.ifcClass)) ? null : xn(r, h.item.guid, u, x, !0);
7231
- if ((zi = _ == null ? void 0 : _.holes) != null && zi.length && !((Wi = _.pieces) != null && Wi.length)) {
7286
+ const _ = [...r.elements.values()].some((y) => y.host === h.item.guid && !/^IFCOPENINGELEMENT$/i.test(y.ifcClass)) ? null : An(r, h.item.guid, u, x, !0);
7287
+ if ((Yi = _ == null ? void 0 : _.holes) != null && Yi.length && !((Ki = _.pieces) != null && Ki.length)) {
7232
7288
  const y = Math.hypot(x[0] - u[0], x[1] - u[1]), g = [(x[0] - u[0]) / y, (x[1] - u[1]) / y], T = (v) => v.flatMap(([S, C]) => [(u[0] + S * g[0]) * f, (u[1] + S * g[1]) * f, (C - re) * f]);
7233
7289
  try {
7234
7290
  const v = JSON.parse(A.Profile);
7235
- A.Profile = JSON.stringify([...v, ..._.holes.map(T)]), typeof process < "u" && ((Yi = process.env) != null && Yi.RECIPE_TRACE) && console.error(`[wall-holes] ${h.item.guid} ${h.item.name ?? ""}: ${_.holes.length} hole(s) added to the converter's profile`);
7291
+ A.Profile = JSON.stringify([...v, ..._.holes.map(T)]), typeof process < "u" && ((Xi = process.env) != null && Xi.RECIPE_TRACE) && console.error(`[wall-holes] ${h.item.guid} ${h.item.name ?? ""}: ${_.holes.length} hole(s) added to the converter's profile`);
7236
7292
  } catch {
7237
7293
  }
7238
7294
  }
@@ -7264,7 +7320,7 @@ function La(n) {
7264
7320
  g = j;
7265
7321
  }
7266
7322
  const S = g.length >= 3 ? T(g) : 0;
7267
- S > 0.05 && v - S > 0.05 && (typeof process < "u" && ((Ki = process.env) != null && Ki.RECIPE_TRACE) && console.error(`[wall-clip] ${h.item.guid} ${h.item.name ?? ""}: ${At.length} plane(s), ${v.toFixed(2)} → ${S.toFixed(2)} m²`), A.Profile = JSON.stringify([g.flatMap((C) => [C[0] * f, C[1] * f, C[2] * f]), ...y.slice(1)]), delete A.TopLevel, delete A.TopOffset);
7323
+ S > 0.05 && v - S > 0.05 && (typeof process < "u" && ((Zi = process.env) != null && Zi.RECIPE_TRACE) && console.error(`[wall-clip] ${h.item.guid} ${h.item.name ?? ""}: ${At.length} plane(s), ${v.toFixed(2)} → ${S.toFixed(2)} m²`), A.Profile = JSON.stringify([g.flatMap((C) => [C[0] * f, C[1] * f, C[2] * f]), ...y.slice(1)]), delete A.TopLevel, delete A.TopOffset);
7268
7324
  } catch {
7269
7325
  }
7270
7326
  if (!A.Profile && Ot) {
@@ -7282,9 +7338,9 @@ function La(n) {
7282
7338
  const Ft = Math.min(Math.max(((Q[0] - u[0]) * y[0] + (Q[1] - u[1]) * y[1]) / _, 0), 1);
7283
7339
  return (Q[0] - u[0]) * g[0] + (Q[1] - u[1]) * g[1] - J - 4 * j * Ft * (1 - Ft);
7284
7340
  }), M = Math.max(...W) - Math.min(...W), ot = M < (v.w + S.w) / 2 + 0.01 && C.w > 0.5 * Math.min(v.w, S.w);
7285
- if (typeof process < "u" && ((Zi = (Xi = process.env) == null ? void 0 : Xi.RECIPE_WALL) != null && Zi.split(",").includes(h.item.guid ?? "")) && console.error(`[arc-bands] ${JSON.stringify({ b0: v, bm: C, b1: S, sag: j, spread: M })}`), ot && Math.abs(j) > 0.02 && Math.abs(j) < _ / 2) {
7341
+ if (typeof process < "u" && ((tr = (Qi = process.env) == null ? void 0 : Qi.RECIPE_WALL) != null && tr.split(",").includes(h.item.guid ?? "")) && console.error(`[arc-bands] ${JSON.stringify({ b0: v, bm: C, b1: S, sag: j, spread: M })}`), ot && Math.abs(j) > 0.02 && Math.abs(j) < _ / 2) {
7286
7342
  const Q = [(u[0] + x[0]) / 2 + g[0] * j, (u[1] + x[1]) / 2 + g[1] * j];
7287
- A.LocationArc = `${Ct(Q[0] * f)},${Ct(Q[1] * f)},${Ct(It)}`, typeof process < "u" && ((Qi = process.env) != null && Qi.RECIPE_TRACE) && console.error(`[wall-arc] ${h.item.guid} ${h.item.name ?? ""}: bows ${(j * 100).toFixed(1)} cm over ${_.toFixed(2)} m`);
7343
+ A.LocationArc = `${Ct(Q[0] * f)},${Ct(Q[1] * f)},${Ct(It)}`, typeof process < "u" && ((er = process.env) != null && er.RECIPE_TRACE) && console.error(`[wall-arc] ${h.item.guid} ${h.item.name ?? ""}: bows ${(j * 100).toFixed(1)} cm over ${_.toFixed(2)} m`);
7288
7344
  }
7289
7345
  }
7290
7346
  }
@@ -7297,7 +7353,7 @@ function La(n) {
7297
7353
  const qt = h.item.guid ? r == null ? void 0 : r.elements.get(h.item.guid) : void 0;
7298
7354
  if (qt != null && qt.layers && qt.layers.length > 1)
7299
7355
  A["Type.Layers"] = JSON.stringify([...qt.layers].reverse().map((L) => [+Ct(L.thickness * f), L.material ?? "", L.function ?? ""])), qt.layersFlipped && (A.FlipLayers = "1");
7300
- else if (typeof process < "u" && ((tr = process.env) != null && tr.RECIPE_PIECE_LAYERS) && qt && qt.pieces.length >= 2 && xt && h.item.guid) {
7356
+ else if (typeof process < "u" && ((sr = process.env) != null && sr.RECIPE_PIECE_LAYERS) && qt && qt.pieces.length >= 2 && xt && h.item.guid) {
7301
7357
  const L = Math.hypot(x[0] - u[0], x[1] - u[1]), _ = [(x[0] - u[0]) / L, (x[1] - u[1]) / L], y = [];
7302
7358
  qt.pieces.forEach((v, S) => {
7303
7359
  const C = Qt(r, h.item.guid, S);
@@ -7315,10 +7371,10 @@ function La(n) {
7315
7371
  W > 0 && y[W - 1][0] - j[1] > 3e-3 && v.push([M(y[W - 1][0] - j[1]), "", "air"]), v.push([M(j[1] - j[0]), "", ""]);
7316
7372
  });
7317
7373
  const S = JSON.stringify(v), C = JSON.stringify([...v].reverse()), J = Z.get(A.Type);
7318
- J === void 0 && Z.set(A.Type, S), J === void 0 || J === S ? A["Type.Layers"] = S : J === C && (A["Type.Layers"] = J, A.FlipLayers = "1"), typeof process < "u" && ((er = process.env) != null && er.RECIPE_TRACE) && console.error(`[piece-layers] ${h.item.guid} ${A.Type}: ${S}${J && J !== S ? J === C ? " (flipped)" : " (the type stacks otherwise: kept)" : ""}`);
7374
+ J === void 0 && Z.set(A.Type, S), J === void 0 || J === S ? A["Type.Layers"] = S : J === C && (A["Type.Layers"] = J, A.FlipLayers = "1"), typeof process < "u" && ((nr = process.env) != null && nr.RECIPE_TRACE) && console.error(`[piece-layers] ${h.item.guid} ${A.Type}: ${S}${J && J !== S ? J === C ? " (flipped)" : " (the type stacks otherwise: kept)" : ""}`);
7319
7375
  }
7320
7376
  }
7321
- if (!A["Type.Layers"] && typeof process < "u" && ((sr = process.env) != null && sr.RECIPE_LAYER_EXT)) {
7377
+ if (!A["Type.Layers"] && typeof process < "u" && ((ir = process.env) != null && ir.RECIPE_LAYER_EXT)) {
7322
7378
  const L = (() => {
7323
7379
  var y, g;
7324
7380
  try {
@@ -7335,11 +7391,11 @@ function La(n) {
7335
7391
  if (j.length < 4) return [];
7336
7392
  const W = [Math.min(...j.map((M) => M[0])), Math.min(...j.map((M) => M[1])), Math.max(...j.map((M) => M[0])), Math.max(...j.map((M) => M[1]))];
7337
7393
  return ut().filter((M) => M.box[0] < W[2] - 0.01 && W[0] < M.box[3] - 0.01 && M.box[1] < W[3] - 0.01 && W[1] < M.box[4] - 0.01 && M.box[2] < J - 0.01 && C < M.box[5] - 0.01).flatMap((M) => M.keys);
7338
- }, v = k.at + F + re, S = typeof process < "u" && ((nr = process.env) != null && nr.RECIPE_EXT_CUT) && !A.Profile && y > 1e-3 && g < 1e-3 ? T(v + R, v + R + y) : [];
7339
- S.length && (A.Height || A.TopOffset) ? (A["Type.Layers"] = JSON.stringify(_.map((C) => [+Ct((C.thickness ?? 0) * f), C.material ?? "", C.function ?? ""])), A.TopOffset ? A.TopOffset = Ct(Number(A.TopOffset) + y * f) : A.Height = Ct(Number(A.Height) + y * f), A.CutBy = [...A.CutBy ? A.CutBy.split("|") : [], ...S].join("|"), typeof process < "u" && ((ir = process.env) != null && ir.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${A.Type}: up ${y} to its finish's top, cut by ${S.length} slab(s)`)) : (y > 1e-3 && (A.TopExtension = Ct(y * f)), g > 1e-3 && (A.BaseExtension = Ct(g * f))), typeof process < "u" && ((rr = process.env) != null && rr.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${A.Type}: top ${y}, base ${g}`);
7394
+ }, v = k.at + F + re, S = typeof process < "u" && ((rr = process.env) != null && rr.RECIPE_EXT_CUT) && !A.Profile && y > 1e-3 && g < 1e-3 ? T(v + R, v + R + y) : [];
7395
+ S.length && (A.Height || A.TopOffset) ? (A["Type.Layers"] = JSON.stringify(_.map((C) => [+Ct((C.thickness ?? 0) * f), C.material ?? "", C.function ?? ""])), A.TopOffset ? A.TopOffset = Ct(Number(A.TopOffset) + y * f) : A.Height = Ct(Number(A.Height) + y * f), A.CutBy = [...A.CutBy ? A.CutBy.split("|") : [], ...S].join("|"), typeof process < "u" && ((or = process.env) != null && or.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${A.Type}: up ${y} to its finish's top, cut by ${S.length} slab(s)`)) : (y > 1e-3 && (A.TopExtension = Ct(y * f)), g > 1e-3 && (A.BaseExtension = Ct(g * f))), typeof process < "u" && ((ar = process.env) != null && ar.RECIPE_TRACE) && console.error(`[layer-extension] ${h.item.guid} ${A.Type}: top ${y}, base ${g}`);
7340
7396
  }
7341
7397
  }
7342
- typeof process < "u" && ((ar = (or = process.env) == null ? void 0 : or.RECIPE_WALL) != null && ar.split(",").includes(h.item.guid ?? "")) && console.error(`[wall-attrs] ${JSON.stringify(A).slice(0, 1500)} style ${JSON.stringify(((cr = P.get(V)) == null ? void 0 : cr.params) ?? null).slice(0, 800)}`), nt(`${st(h.id)}#${o.i}`, A) && Kt++, w.forEach((L, _) => {
7398
+ typeof process < "u" && ((lr = (cr = process.env) == null ? void 0 : cr.RECIPE_WALL) != null && lr.split(",").includes(h.item.guid ?? "")) && console.error(`[wall-attrs] ${JSON.stringify(A).slice(0, 1500)} style ${JSON.stringify(((hr = P.get(V)) == null ? void 0 : hr.params) ?? null).slice(0, 800)}`), nt(`${st(h.id)}#${o.i}`, A) && Kt++, w.forEach((L, _) => {
7343
7399
  nt(`${st(h.id)}#${o.i}p${_ + 1}`, { ...A, Profile: L }) && Kt++;
7344
7400
  });
7345
7401
  }
@@ -7349,12 +7405,12 @@ function La(n) {
7349
7405
  for (let k = F; k <= o + 1e-4; k += h) k > 1e-4 && k < o - 1e-4 && R.push(k);
7350
7406
  return R;
7351
7407
  };
7352
- let Js = 0, di = 0;
7353
- const ui = /* @__PURE__ */ new Map();
7408
+ let qs = 0, pi = 0;
7409
+ const mi = /* @__PURE__ */ new Map();
7354
7410
  for (const o of a) {
7355
7411
  if (o.kind !== "run" || o.params.of !== "curtainWall") continue;
7356
- di++;
7357
- const h = de(o, "run"), w = (fr = (hr = (lr = h == null ? void 0 : h.run) == null ? void 0 : lr.line) == null ? void 0 : hr.curves) == null ? void 0 : fr[0], m = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? "")), F = o.params.lookRef, R = typeof F == "string" ? (dr = P.get(F)) == null ? void 0 : dr.params : void 0;
7412
+ pi++;
7413
+ const h = de(o, "run"), w = (ur = (dr = (fr = h == null ? void 0 : h.run) == null ? void 0 : fr.line) == null ? void 0 : dr.curves) == null ? void 0 : ur[0], m = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? "")), F = o.params.lookRef, R = typeof F == "string" ? (pr = P.get(F)) == null ? void 0 : pr.params : void 0;
7358
7414
  if (!(w != null && w.from) || !w.to || typeof (h == null ? void 0 : h.height) != "number" || !m || !R) continue;
7359
7415
  const k = (y) => typeof y == "number" ? y : Number(y) || 0, V = Math.hypot(w.to[0] - w.from[0], w.to[1] - w.from[1]), u = [(w.to[0] - w.from[0]) / V, (w.to[1] - w.from[1]) / V], x = k(R.uprightWidth) > 0 ? null : Le(o.item.guid ?? void 0, u), gt = (k(R.uprightWidth) || (x ? x.width / f : 0)) / 2, $t = (k(R.horizontalWidth) || (x ? x.width / f : 0)) / 2, Ot = { start: !1, end: !1, bottom: !1, top: !1 };
7360
7416
  let It = [];
@@ -7367,12 +7423,12 @@ function La(n) {
7367
7423
  }, T = y.map((S) => g(S.gid)).filter((S) => S !== null), v = y.filter((S) => /^IFCMEMBER$/i.test(S.ifcClass)).map((S) => g(S.gid)).filter((S) => S !== null);
7368
7424
  if (v.length && T.length) {
7369
7425
  const S = Math.min(...T.map((M) => M.t0)), C = Math.max(...T.map((M) => M.t1)), J = Math.min(...T.map((M) => M.z0)), j = Math.max(...T.map((M) => M.z1)), W = (M) => M.t1 - M.t0 > M.z1 - M.z0;
7370
- Ot.bottom = !v.some((M) => W(M) && Math.abs(M.z0 - J) < 0.01), Ot.top = !v.some((M) => W(M) && Math.abs(M.z1 - j) < 0.01), Ot.start = !v.some((M) => !W(M) && Math.abs(M.t0 - S) < 0.01), Ot.end = !v.some((M) => !W(M) && Math.abs(M.t1 - C) < 0.01), It = [...new Set(v.filter((M) => !W(M) && M.t0 > S + 0.01 && M.t1 < C - 0.01).map((M) => +((M.t0 + M.t1) / 2).toFixed(4)))].sort((M, ot) => M - ot), Object.values(Ot).some(Boolean) && typeof process < "u" && ((ur = process.env) != null && ur.RECIPE_TRACE) && console.error(`[curtain-bare] ${o.item.guid}: no bar at its ${Object.entries(Ot).filter(([, M]) => M).map(([M]) => M).join(", ")}`);
7426
+ Ot.bottom = !v.some((M) => W(M) && Math.abs(M.z0 - J) < 0.01), Ot.top = !v.some((M) => W(M) && Math.abs(M.z1 - j) < 0.01), Ot.start = !v.some((M) => !W(M) && Math.abs(M.t0 - S) < 0.01), Ot.end = !v.some((M) => !W(M) && Math.abs(M.t1 - C) < 0.01), It = [...new Set(v.filter((M) => !W(M) && M.t0 > S + 0.01 && M.t1 < C - 0.01).map((M) => +((M.t0 + M.t1) / 2).toFixed(4)))].sort((M, ot) => M - ot), Object.values(Ot).some(Boolean) && typeof process < "u" && ((mr = process.env) != null && mr.RECIPE_TRACE) && console.error(`[curtain-bare] ${o.item.guid}: no bar at its ${Object.entries(Ot).filter(([, M]) => M).map(([M]) => M).join(", ")}`);
7371
7427
  }
7372
7428
  }
7373
- const yt = Ot.start ? 0 : gt, A = Ot.end ? 0 : gt, Rt = Ot.bottom ? 0 : $t, lt = Ot.top ? 0 : $t, bt = [w.from[0] - u[0] * yt, w.from[1] - u[1] * yt], K = [w.to[0] + u[0] * A, w.to[1] + u[1] * A], G = (typeof h.base == "number" ? h.base : 0) - Rt, et = h.height + Rt + lt, H = (m.at + G) * f, St = Qe(V, k(R.alongSpacing), R.alongJustify), it = !((pr = h.lines) != null && pr.along) && It.length > 0 && (It.length !== St.length || It.some((y, g) => Math.abs(y - St[g]) > 0.01));
7374
- it && typeof process < "u" && ((mr = process.env) != null && mr.RECIPE_TRACE) && console.error(`[curtain-lines] ${o.item.guid}: ${It.length} from its bars, not the type's ${St.length}`);
7375
- const ft = ((gr = h.lines) == null ? void 0 : gr.along) ?? (it ? It : St), mt = ((yr = h.lines) == null ? void 0 : yr.up) ?? Qe(h.height, k(R.upSpacing), R.upJustify), At = (h.omitted ?? []).flatMap((y) => {
7429
+ const yt = Ot.start ? 0 : gt, A = Ot.end ? 0 : gt, Rt = Ot.bottom ? 0 : $t, lt = Ot.top ? 0 : $t, bt = [w.from[0] - u[0] * yt, w.from[1] - u[1] * yt], K = [w.to[0] + u[0] * A, w.to[1] + u[1] * A], G = (typeof h.base == "number" ? h.base : 0) - Rt, et = h.height + Rt + lt, H = (m.at + G) * f, St = Qe(V, k(R.alongSpacing), R.alongJustify), it = !((gr = h.lines) != null && gr.along) && It.length > 0 && (It.length !== St.length || It.some((y, g) => Math.abs(y - St[g]) > 0.01));
7430
+ it && typeof process < "u" && ((yr = process.env) != null && yr.RECIPE_TRACE) && console.error(`[curtain-lines] ${o.item.guid}: ${It.length} from its bars, not the type's ${St.length}`);
7431
+ const ft = ((wr = h.lines) == null ? void 0 : wr.along) ?? (it ? It : St), mt = ((br = h.lines) == null ? void 0 : br.up) ?? Qe(h.height, k(R.upSpacing), R.upJustify), At = (h.omitted ?? []).flatMap((y) => {
7376
7432
  const g = /^(horizontal|vertical)@(-?[\d.]+):(-?[\d.]+)$/.exec(y);
7377
7433
  if (!g) return [];
7378
7434
  const T = g[1] === "horizontal", v = Number(g[2]) / 1e3 + (T ? Rt : yt), S = Number(g[3]) / 1e3 + (T ? yt : Rt);
@@ -7390,7 +7446,7 @@ function La(n) {
7390
7446
  return g ? [{ along: (Number(g[1]) / 1e3 + yt) * f, up: (Number(g[2]) / 1e3 + Rt) * f }] : [];
7391
7447
  });
7392
7448
  if (r && o.item.guid)
7393
- for (const y of Vl(r, o.item.guid, k(R.panelDepth), [-u[1], u[0]])) {
7449
+ for (const y of zl(r, o.item.guid, k(R.panelDepth), [-u[1], u[0]])) {
7394
7450
  const g = (y.centre[0] - w.from[0]) * u[0] + (y.centre[1] - w.from[1]) * u[1], T = y.centre[2] - re - (m.at + (typeof h.base == "number" ? h.base : 0));
7395
7451
  if (g < -0.01 || g > V + 0.01 || T < -0.01 || T > h.height + 0.01) continue;
7396
7452
  const v = Math.max(0, ...ft.filter((C) => C <= g + 1e-6)), S = Math.max(0, ...mt.filter((C) => C <= T + 1e-6));
@@ -7398,7 +7454,7 @@ function La(n) {
7398
7454
  }
7399
7455
  const L = {
7400
7456
  CategoryId: De.walls,
7401
- Type: ((wr = As(o)) == null ? void 0 : wr.type) ?? String(F),
7457
+ Type: ((vr = Cs(o)) == null ? void 0 : vr.type) ?? String(F),
7402
7458
  LocationLine: `${Ct(bt[0] * f)},${Ct(bt[1] * f)},${Ct(H)};${Ct(K[0] * f)},${Ct(K[1] * f)},${Ct(H)}`,
7403
7459
  Level: m.name,
7404
7460
  BaseOffset: Ct(G * f),
@@ -7422,8 +7478,8 @@ function La(n) {
7422
7478
  return C + J[0] * W[1] - W[0] * J[1];
7423
7479
  }, 0) > 0 ? 1 : -1, T = _.length, v = _.map((C, J) => {
7424
7480
  const j = _[(J - 1 + T) % T], W = _[(J + 1) % T], M = (Gt, ee) => {
7425
- const Zt = ee[0] - Gt[0], se = ee[1] - Gt[1], Jt = Math.hypot(Zt, se) || 1, fe = g * se / Jt, Be = -g * Zt / Jt, ws = Math.abs(fe) > Math.abs(Be) ? gt : $t;
7426
- return { p: [Gt[0] + fe * ws, Gt[1] + Be * ws], d: [Zt, se] };
7481
+ const Zt = ee[0] - Gt[0], se = ee[1] - Gt[1], Jt = Math.hypot(Zt, se) || 1, fe = g * se / Jt, Be = -g * Zt / Jt, bs = Math.abs(fe) > Math.abs(Be) ? gt : $t;
7482
+ return { p: [Gt[0] + fe * bs, Gt[1] + Be * bs], d: [Zt, se] };
7427
7483
  }, ot = M(j, C), Q = M(C, W), Ft = ot.d[0] * Q.d[1] - ot.d[1] * Q.d[0];
7428
7484
  if (Math.abs(Ft) < 1e-12) return [Q.p[0], Q.p[1]];
7429
7485
  const Ut = ((Q.p[0] - ot.p[0]) * Q.d[1] - (Q.p[1] - ot.p[1]) * Q.d[0]) / Ft;
@@ -7434,13 +7490,13 @@ function La(n) {
7434
7490
  L.Profile = JSON.stringify([S]);
7435
7491
  }
7436
7492
  {
7437
- const y = JSON.parse(L.Curtain), g = y.mullion, T = (br = y.panel) != null && br.thickness ? `, ${Math.round(y.panel.thickness / f * 1e3)} mm glass` : "", v = `${Math.round(g.width / f * 1e3)} x ${Math.round(g.depth / f * 1e3)}${T}${y.noBorders ? ", no borders" : ""}`, S = ui.get(L.Type);
7438
- S === void 0 ? ui.set(L.Type, v) : S !== v && (typeof process < "u" && ((vr = process.env) != null && vr.RECIPE_TRACE) && console.error(`[curtain-type] ${o.item.guid}: ${L.Type} first made with ${S}, this one ${v}`), L.Type = `${L.Type} · ${v}`);
7493
+ const y = JSON.parse(L.Curtain), g = y.mullion, T = (Er = y.panel) != null && Er.thickness ? `, ${Math.round(y.panel.thickness / f * 1e3)} mm glass` : "", v = `${Math.round(g.width / f * 1e3)} x ${Math.round(g.depth / f * 1e3)}${T}${y.noBorders ? ", no borders" : ""}`, S = mi.get(L.Type);
7494
+ S === void 0 ? mi.set(L.Type, v) : S !== v && (typeof process < "u" && ((Tr = process.env) != null && Tr.RECIPE_TRACE) && console.error(`[curtain-type] ${o.item.guid}: ${L.Type} first made with ${S}, this one ${v}`), L.Type = `${L.Type} · ${v}`);
7439
7495
  }
7440
- nt(st(o.id), L) && Js++;
7496
+ nt(st(o.id), L) && qs++;
7441
7497
  }
7442
- let qs = 0, pi = 0;
7443
- const mi = (o, h, w) => {
7498
+ let Vs = 0, gi = 0;
7499
+ const yi = (o, h, w) => {
7444
7500
  if (!r || !o) return null;
7445
7501
  const m = Math.hypot(w[0] - h[0], w[1] - h[1]);
7446
7502
  if (!(m > 0)) return null;
@@ -7451,14 +7507,14 @@ function La(n) {
7451
7507
  };
7452
7508
  for (const o of a) {
7453
7509
  if (o.kind !== "stair" || o.params.of !== "stair") continue;
7454
- pi++;
7455
- const h = de(o, "stair"), w = o.params.lookRef, m = typeof w == "string" ? (Er = P.get(w)) == null ? void 0 : Er.params : void 0, F = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? ""));
7510
+ gi++;
7511
+ const h = de(o, "stair"), w = o.params.lookRef, m = typeof w == "string" ? (Mr = P.get(w)) == null ? void 0 : Mr.params : void 0, F = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? ""));
7456
7512
  if (!(h != null && h.start) || !h.end || !(Number(h.rise) > 0) || !F || !m) continue;
7457
- const R = (K) => typeof K == "number" ? K : Number(K) || 0, k = Number(h.rise), V = R(m.maxRiser) > 0 ? R(m.maxRiser) : (Mr = (Tr = h.sketch) == null ? void 0 : Tr.risers) != null && Mr.length ? k / (h.sketch.risers.length + 1) : 0.18, u = Math.max(1, Math.ceil(k / V - 1e-6)), x = R(m.tread), gt = (K) => [K[0] * f, K[1] * f];
7513
+ const R = (K) => typeof K == "number" ? K : Number(K) || 0, k = Number(h.rise), V = R(m.maxRiser) > 0 ? R(m.maxRiser) : (Ir = ($r = h.sketch) == null ? void 0 : $r.risers) != null && Ir.length ? k / (h.sketch.risers.length + 1) : 0.18, u = Math.max(1, Math.ceil(k / V - 1e-6)), x = R(m.tread), gt = (K) => [K[0] * f, K[1] * f];
7458
7514
  let $t = F.at + R(o.params.base), Ot = !1;
7459
7515
  if (r && o.item.guid) {
7460
7516
  const K = Qt(r, o.item.guid).map((H) => H[2] - re), G = k / u, et = K.length ? Math.min(...K) : $t;
7461
- $t - et > 0.5 * G && $t - et < 1.5 * G && (typeof process < "u" && (($r = process.env) != null && $r.RECIPE_TRACE) && console.error(`[stair-base] ${o.item.guid} ${o.item.name ?? ""}: base ${$t.toFixed(3)} → its shape's ${et.toFixed(3)}`), $t = et, Ot = !0);
7517
+ $t - et > 0.5 * G && $t - et < 1.5 * G && (typeof process < "u" && ((Sr = process.env) != null && Sr.RECIPE_TRACE) && console.error(`[stair-base] ${o.item.guid} ${o.item.name ?? ""}: base ${$t.toFixed(3)} → its shape's ${et.toFixed(3)}`), $t = et, Ot = !0);
7462
7518
  }
7463
7519
  const It = {
7464
7520
  // (Its family, the element's number off its end: the first of «Assembled Stair:Stair», the second of «Stairs : Assembled Stair : Stair», as GNI model_78
@@ -7471,7 +7527,7 @@ function La(n) {
7471
7527
  height: k * f,
7472
7528
  risers: u,
7473
7529
  tread: x * f,
7474
- width: (R(m.width) > 0 ? R(m.width) : mi(o.item.guid ?? void 0, h.start, h.end) ?? 0) * f,
7530
+ width: (R(m.width) > 0 ? R(m.width) : yi(o.item.guid ?? void 0, h.start, h.end) ?? 0) * f,
7475
7531
  // 🔴 ENDING ON A RISER, when its own shape stops a riser under its rise (DACH 24-10: two flights and a landing,
7476
7532
  // the first a tread too long and a riser too high — the landing is that tread).
7477
7533
  endsWithRiser: (() => {
@@ -7497,7 +7553,7 @@ function La(n) {
7497
7553
  ...m.nosing !== void 0 && Number.isFinite(Number(m.nosing)) ? { nosing: Number(m.nosing) * f } : {}
7498
7554
  }
7499
7555
  };
7500
- typeof process < "u" && ((Ir = process.env) != null && Ir.RECIPE_TRACE) && console.error(`[stair-end] ${o.item.guid} ${o.item.name ?? ""}: ${u} risers, ends with riser ${It.endsWithRiser}`);
7556
+ typeof process < "u" && ((xr = process.env) != null && xr.RECIPE_TRACE) && console.error(`[stair-end] ${o.item.guid} ${o.item.name ?? ""}: ${u} risers, ends with riser ${It.endsWithRiser}`);
7501
7557
  const yt = h.sketch;
7502
7558
  if (yt != null && yt.boundary && yt.risers && yt.risers.length >= 2) {
7503
7559
  const K = (it) => [(it[0][0] + it[1][0]) / 2, (it[0][1] + it[1][1]) / 2], G = yt.risers.filter((it, ft, mt) => ft === 0 || Math.hypot(K(it)[0] - K(mt[ft - 1])[0], K(it)[1] - K(mt[ft - 1])[1]) > 0.01), et = (it, ft) => Math.hypot(it[0] - ft[0], it[1] - ft[1]) < 0.01, H = yt.boundary, St = (it) => H.some((ft, mt) => {
@@ -7515,14 +7571,14 @@ function La(n) {
7515
7571
  }
7516
7572
  _ && G.unshift(_);
7517
7573
  }
7518
- G.length !== yt.risers.length && typeof process < "u" && ((Sr = process.env) != null && Sr.RECIPE_TRACE) && console.error(`[stair-sketch] ${o.item.guid}: riser lines ${yt.risers.length} → ${G.length}`), yt.risers = G;
7574
+ G.length !== yt.risers.length && typeof process < "u" && ((_r = process.env) != null && _r.RECIPE_TRACE) && console.error(`[stair-sketch] ${o.item.guid}: riser lines ${yt.risers.length} → ${G.length}`), yt.risers = G;
7519
7575
  }
7520
7576
  if (yt != null && yt.boundary && yt.boundary.length >= 4 && yt.risers && yt.risers.length >= 2) {
7521
7577
  const K = yt.risers[0], G = (g, T) => Math.hypot(g[0] - T[0], g[1] - T[1]) < 0.01, et = yt.boundary.findIndex((g, T, v) => {
7522
7578
  const S = v[(T + 1) % v.length];
7523
7579
  return G(g, K[0]) && G(S, K[1]) || G(g, K[1]) && G(S, K[0]);
7524
7580
  }), H = et > 0 ? [...yt.boundary.slice(et), ...yt.boundary.slice(0, et)] : yt.boundary;
7525
- typeof process < "u" && ((xr = process.env) == null ? void 0 : xr.RECIPE_STAIR) === o.item.guid && console.error(`[stair-sketch] boundary ${JSON.stringify(H)} (turned by ${et}) risers ${JSON.stringify(yt.risers)} tread ${x}`);
7581
+ typeof process < "u" && ((Ar = process.env) == null ? void 0 : Ar.RECIPE_STAIR) === o.item.guid && console.error(`[stair-sketch] boundary ${JSON.stringify(H)} (turned by ${et}) risers ${JSON.stringify(yt.risers)} tread ${x}`);
7526
7582
  const St = yt.risers[yt.risers.length - 1], it = (g) => [(g[0][0] + g[1][0]) / 2, (g[0][1] + g[1][1]) / 2], ft = it(St);
7527
7583
  let mt = 1, At = 1 / 0;
7528
7584
  for (let g = 1; g < H.length; g++) {
@@ -7545,11 +7601,11 @@ function La(n) {
7545
7601
  for (let S = g; S !== T; S = (S + 1) % H.length) v.push([gt(H[S]), gt(H[(S + 1) % H.length])]);
7546
7602
  return v;
7547
7603
  }, qt = [...xt(1, mt), ...xt((mt + 1) % H.length, 0)];
7548
- typeof process < "u" && ((_r = process.env) == null ? void 0 : _r.RECIPE_STAIR) === o.item.guid && console.error(`[stair-sketch] end edge ${mt} of ${H.length}`);
7604
+ typeof process < "u" && ((Cr = process.env) == null ? void 0 : Cr.RECIPE_STAIR) === o.item.guid && console.error(`[stair-sketch] end edge ${mt} of ${H.length}`);
7549
7605
  const L = yt.risers.map(([g, T]) => [gt(g), gt(T)]);
7550
7606
  gt(H[mt]), gt(H[(mt + 1) % H.length]);
7551
7607
  const _ = L.map(([g, T]) => [(g[0] + T[0]) / 2, (g[1] + T[1]) / 2]);
7552
- if (It.sketch = { boundary: qt, risers: L, path: _ }, It.path = [_[0], _[_.length - 1]], It.width || (It.width = Math.hypot(L[0][1][0] - L[0][0][0], L[0][1][1] - L[0][0][1])), typeof process < "u" && ((Ar = process.env) != null && Ar.RECIPE_TRACE)) {
7608
+ if (It.sketch = { boundary: qt, risers: L, path: _ }, It.path = [_[0], _[_.length - 1]], It.width || (It.width = Math.hypot(L[0][1][0] - L[0][0][0], L[0][1][1] - L[0][0][1])), typeof process < "u" && ((Or = process.env) != null && Or.RECIPE_TRACE)) {
7553
7609
  const g = (T) => Math.hypot(T[1][0] - T[0][0], T[1][1] - T[0][1]) / f;
7554
7610
  console.error(`[stair] ${o.item.guid} ${o.item.name ?? ""}: ${qt.length} sides (shortest ${(Math.min(...qt.map(g)) * 1e3).toFixed(2)} mm), ${L.length} risers (shortest ${(Math.min(...L.map(g)) * 1e3).toFixed(2)} mm), walk ${_.length} points (shortest step ${(Math.min(..._.slice(1).map((T, v) => g([_[v], T]))) * 1e3).toFixed(2)} mm)`);
7555
7611
  }
@@ -7572,12 +7628,12 @@ function La(n) {
7572
7628
  const G = Math.hypot(h.end[0] - h.start[0], h.end[1] - h.start[1]) / u;
7573
7629
  It.tread = G * f, It.sizes.minTread = G * f;
7574
7630
  }
7575
- typeof process < "u" && ((Cr = process.env) != null && Cr.RECIPE_TRACE) && console.error(`[stair] ${o.item.guid} ${o.item.name ?? ""}: straight, ${Math.hypot(h.end[0] - h.start[0], h.end[1] - h.start[1]).toFixed(3)} m, rise ${k}, ${u} risers, width ${R(m.width)}, measured ${mi(o.item.guid ?? void 0, h.start, h.end)}`);
7631
+ typeof process < "u" && ((Rr = process.env) != null && Rr.RECIPE_TRACE) && console.error(`[stair] ${o.item.guid} ${o.item.name ?? ""}: straight, ${Math.hypot(h.end[0] - h.start[0], h.end[1] - h.start[1]).toFixed(3)} m, rise ${k}, ${u} risers, width ${R(m.width)}, measured ${yi(o.item.guid ?? void 0, h.start, h.end)}`);
7576
7632
  }
7577
7633
  const A = String(o.item.attrs.Name ?? ""), Rt = A.replace(/ Run \d+$/, ""), lt = [];
7578
7634
  for (const K of a) {
7579
7635
  if (K.kind !== "extrusion" || Rt === A || !new RegExp(`^${Rt.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")} Landing \\d+$`).test(String(K.item.attrs.Name ?? ""))) continue;
7580
- const G = de(K, "extrusion"), et = G == null ? void 0 : G.on, H = (((Rr = (Or = G == null ? void 0 : G.profile) == null ? void 0 : Or.outline) == null ? void 0 : Rr.curves) ?? []).flatMap((S) => S.from ? [S.from] : []), St = pt(K.params.lookRef), it = $.get(String((G == null ? void 0 : G.level) ?? K.params.level ?? ""));
7636
+ const G = de(K, "extrusion"), et = G == null ? void 0 : G.on, H = (((Nr = (kr = G == null ? void 0 : G.profile) == null ? void 0 : kr.outline) == null ? void 0 : Nr.curves) ?? []).flatMap((S) => S.from ? [S.from] : []), St = pt(K.params.lookRef), it = $.get(String((G == null ? void 0 : G.level) ?? K.params.level ?? ""));
7581
7637
  if (!(et != null && et.origin) || !et.u || !et.v || Math.abs(et.v[2] ?? 0) < 0.99 || !H.length || !St || !it) continue;
7582
7638
  const [ft, mt] = [Math.min(...H.map((S) => S[0])), Math.max(...H.map((S) => S[0]))], [At, xt] = [Math.min(...H.map((S) => S[1])), Math.max(...H.map((S) => S[1]))], qt = et.origin, L = et.u;
7583
7639
  let _ = [L[1], -L[0]];
@@ -7593,13 +7649,13 @@ function La(n) {
7593
7649
  lt.length && (It.landings = lt);
7594
7650
  const bt = {
7595
7651
  CategoryId: De.stairs,
7596
- Type: ((kr = As(o)) == null ? void 0 : kr.type) ?? String(w),
7652
+ Type: ((Fr = Cs(o)) == null ? void 0 : Fr.type) ?? String(w),
7597
7653
  Level: F.name,
7598
7654
  Stairs: JSON.stringify(It)
7599
7655
  };
7600
- typeof process < "u" && (((Nr = process.env) == null ? void 0 : Nr.RECIPE_STAIR) === o.item.guid || ((Fr = process.env) == null ? void 0 : Fr.RECIPE_STAIR) === "*") && console.error(`[stair-spec] ${bt.Stairs} style ${JSON.stringify(m)}`), nt(st(o.id), bt) && qs++;
7656
+ typeof process < "u" && (((Pr = process.env) == null ? void 0 : Pr.RECIPE_STAIR) === o.item.guid || ((Lr = process.env) == null ? void 0 : Lr.RECIPE_STAIR) === "*") && console.error(`[stair-spec] ${bt.Stairs} style ${JSON.stringify(m)}`), nt(st(o.id), bt) && Vs++;
7601
7657
  }
7602
- const gi = /* @__PURE__ */ new Map(), ms = { floor: 0, foundation: 0, roof: 0, ceiling: 0 }, pe = { floor: 0, foundation: 0, roof: 0, ceiling: 0 }, yi = a.flatMap((o) => {
7658
+ const wi = /* @__PURE__ */ new Map(), gs = { floor: 0, foundation: 0, roof: 0, ceiling: 0 }, pe = { floor: 0, foundation: 0, roof: 0, ceiling: 0 }, bi = a.flatMap((o) => {
7603
7659
  var R, k;
7604
7660
  if (o.kind !== "extrusion" || o.params.of !== "form") return [];
7605
7661
  const h = de(o, "extrusion"), w = $.get(String((h == null ? void 0 : h.level) ?? o.params.level ?? "")), m = (((k = (R = h == null ? void 0 : h.profile) == null ? void 0 : R.outline) == null ? void 0 : k.curves) ?? []).flatMap((V) => V.from ? [V.from] : []);
@@ -7610,18 +7666,18 @@ function La(n) {
7610
7666
  for (const o of a) {
7611
7667
  const h = o.params.of;
7612
7668
  if (o.kind !== "extrusion" || h !== "slab" && h !== "roof" && h !== "covering") continue;
7613
- let w = h === "covering" ? "ceiling" : h === "roof" ? "roof" : Jo(o);
7614
- if (w === "other" || r && o.item.guid && /^IFCRAMP(FLIGHT)?$/i.test(((Pr = r.elements.get(o.item.guid)) == null ? void 0 : Pr.ifcClass) ?? "")) continue;
7669
+ let w = h === "covering" ? "ceiling" : h === "roof" ? "roof" : Vo(o);
7670
+ if (w === "other" || r && o.item.guid && /^IFCRAMP(FLIGHT)?$/i.test(((Br = r.elements.get(o.item.guid)) == null ? void 0 : Br.ifcClass) ?? "")) continue;
7615
7671
  const m = de(o, "extrusion"), F = m == null ? void 0 : m.on;
7616
- if (F && (Math.abs(((Lr = F.u) == null ? void 0 : Lr[2]) ?? 0) > 1e-3 || Math.abs(((Br = F.v) == null ? void 0 : Br[2]) ?? 0) > 1e-3)) continue;
7672
+ if (F && (Math.abs(((jr = F.u) == null ? void 0 : jr[2]) ?? 0) > 1e-3 || Math.abs(((Dr = F.v) == null ? void 0 : Dr[2]) ?? 0) > 1e-3)) continue;
7617
7673
  if (w === "roof" && !jt(o)) {
7618
- const lt = m, bt = ((Dr = (jr = m == null ? void 0 : m.profile) == null ? void 0 : jr.outline) == null ? void 0 : Dr.curves) ?? [];
7674
+ const lt = m, bt = ((Jr = (Ur = m == null ? void 0 : m.profile) == null ? void 0 : Ur.outline) == null ? void 0 : Jr.curves) ?? [];
7619
7675
  if (lt != null && lt.slope && typeof lt.slope.by == "number" && Math.abs(lt.slope.by) > 1e-3 && typeof lt.slope.toward == "number" && !(Array.isArray(lt.slopes) && lt.slopes.some((K) => typeof K == "number")) && bt.length >= 3) {
7620
7676
  const K = [Math.cos(lt.slope.toward), Math.sin(lt.slope.toward)], G = bt.map((it) => it.from).filter(Boolean), et = G.map((it) => it[0] * K[0] + it[1] * K[1]), H = Math.min(...et);
7621
- G.some((it, ft) => Math.abs(et[ft] - H) < 0.01 && Math.abs(et[(ft + 1) % G.length] - H) < 0.01) || (w = "floor", typeof process < "u" && ((Ur = process.env) != null && Ur.RECIPE_TRACE) && console.error(`[roof-as-floor] ${o.item.guid} ${o.params.lookRef}: its low side a corner, a sloped floor`));
7677
+ G.some((it, ft) => Math.abs(et[ft] - H) < 0.01 && Math.abs(et[(ft + 1) % G.length] - H) < 0.01) || (w = "floor", typeof process < "u" && ((qr = process.env) != null && qr.RECIPE_TRACE) && console.error(`[roof-as-floor] ${o.item.guid} ${o.params.lookRef}: its low side a corner, a sloped floor`));
7622
7678
  }
7623
7679
  }
7624
- ms[w]++, typeof process < "u" && ((Jr = process.env) == null ? void 0 : Jr.RECIPE_SLAB) === o.item.guid && console.error(`[slab] ${o.item.guid}: params ${JSON.stringify(o.params).slice(0, 600)} body ${JSON.stringify(m).slice(0, 1500)}`);
7680
+ gs[w]++, typeof process < "u" && ((Vr = process.env) == null ? void 0 : Vr.RECIPE_SLAB) === o.item.guid && console.error(`[slab] ${o.item.guid}: params ${JSON.stringify(o.params).slice(0, 600)} body ${JSON.stringify(m).slice(0, 1500)}`);
7625
7681
  const R = typeof o.params.base == "number" ? o.params.base : 0, k = $.get(String((m == null ? void 0 : m.level) ?? o.params.level ?? "")), V = o.params.lookRef, u = (lt) => {
7626
7682
  if (!(lt != null && lt.length)) return null;
7627
7683
  const bt = [];
@@ -7630,17 +7686,17 @@ function La(n) {
7630
7686
  bt.push(K.from[0] * f, K.from[1] * f, R * f);
7631
7687
  }
7632
7688
  return bt.length >= 9 ? bt : null;
7633
- }, x = u((Vr = (qr = m == null ? void 0 : m.profile) == null ? void 0 : qr.outline) == null ? void 0 : Vr.curves);
7689
+ }, x = u((Hr = (Gr = m == null ? void 0 : m.profile) == null ? void 0 : Gr.outline) == null ? void 0 : Hr.curves);
7634
7690
  if (typeof V != "string" || !k || !x) continue;
7635
7691
  const gt = [x], $t = w === "roof" ? jt(o) : null;
7636
- for (const lt of ((Gr = m == null ? void 0 : m.profile) == null ? void 0 : Gr.holes) ?? []) {
7692
+ for (const lt of ((zr = m == null ? void 0 : m.profile) == null ? void 0 : zr.holes) ?? []) {
7637
7693
  const bt = u(lt == null ? void 0 : lt.curves);
7638
7694
  if (bt && $t)
7639
7695
  for (let K = 0; K + 2 < bt.length; K += 3) bt[K + 2] = $t.zAt(bt[K] / f, bt[K + 1] / f) * f;
7640
7696
  bt && gt.push(bt);
7641
7697
  }
7642
7698
  const Ot = [...(m == null ? void 0 : m.cuts) ?? []], It = k.at + R, yt = It + (Number(o.params.depth) || 0);
7643
- for (const lt of yi) lt.from < yt - 1e-3 && It < lt.to - 1e-3 && Ot.push({ outline: lt.outline, through: [0, 0, lt.to - lt.from] });
7699
+ for (const lt of bi) lt.from < yt - 1e-3 && It < lt.to - 1e-3 && Ot.push({ outline: lt.outline, through: [0, 0, lt.to - lt.from] });
7644
7700
  for (const lt of Ot) {
7645
7701
  const bt = lt.through, K = lt.outline;
7646
7702
  if (!Array.isArray(K) || K.length < 3 || !Array.isArray(bt) || Math.abs(bt[2]) < 0.99 * Math.hypot(bt[0], bt[1], bt[2])) continue;
@@ -7655,7 +7711,7 @@ function La(n) {
7655
7711
  return T;
7656
7712
  };
7657
7713
  if (!G.every((y) => et(y[0], y[1]))) {
7658
- typeof process < "u" && ((Hr = process.env) != null && Hr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid}: a cut across its edge, left`);
7714
+ typeof process < "u" && ((Wr = process.env) != null && Wr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid}: a cut across its edge, left`);
7659
7715
  continue;
7660
7716
  }
7661
7717
  const H = (y) => [Math.min(...y.map((g) => g[0])), Math.min(...y.map((g) => g[1])), Math.max(...y.map((g) => g[0])), Math.max(...y.map((g) => g[1]))], St = (y) => {
@@ -7677,26 +7733,26 @@ function La(n) {
7677
7733
  return Math.hypot(y[0] - (g[0] + j * S), y[1] - (g[1] + j * C)) < 0.01;
7678
7734
  }));
7679
7735
  if (xt || L) {
7680
- typeof process < "u" && ((zr = process.env) != null && zr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid}: a cut ${xt ? "over another hole" : "at its edge"}, left`);
7736
+ typeof process < "u" && ((Yr = process.env) != null && Yr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid}: a cut ${xt ? "over another hole" : "at its edge"}, left`);
7681
7737
  continue;
7682
7738
  }
7683
7739
  const _ = G.flatMap((y) => [y[0] * f, y[1] * f, ($t ? $t.zAt(y[0], y[1]) : R) * f]);
7684
- gt.push(_), typeof process < "u" && ((Wr = process.env) != null && Wr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid} ${o.item.name ?? ""}: a hole of ${G.length} corners`);
7740
+ gt.push(_), typeof process < "u" && ((Kr = process.env) != null && Kr.RECIPE_TRACE) && console.error(`[slab-cut] ${o.item.guid} ${o.item.name ?? ""}: a hole of ${G.length} corners`);
7685
7741
  }
7686
7742
  const A = {
7687
7743
  CategoryId: w === "roof" ? De.roofs : w === "ceiling" ? De.ceilings : w === "foundation" ? De.structuralFoundations : De.floors,
7688
- Type: ((Yr = As(o)) == null ? void 0 : Yr.type) ?? V,
7744
+ Type: ((Xr = Cs(o)) == null ? void 0 : Xr.type) ?? V,
7689
7745
  Profile: JSON.stringify(gt),
7690
7746
  Level: k.name
7691
7747
  };
7692
7748
  let Rt = pt(V);
7693
7749
  if (w === "roof" && r && o.item.guid) {
7694
- const lt = (Kr = r.elements.get(o.item.guid)) == null ? void 0 : Kr.layers, bt = (lt == null ? void 0 : lt.reduce((K, G) => K + (G.thickness > 0 ? G.thickness : 0), 0)) ?? 0;
7750
+ const lt = (Zr = r.elements.get(o.item.guid)) == null ? void 0 : Zr.layers, bt = (lt == null ? void 0 : lt.reduce((K, G) => K + (G.thickness > 0 ? G.thickness : 0), 0)) ?? 0;
7695
7751
  bt > 0 && (!Rt || Math.abs(bt * f - Rt) > 0.2 * Rt) && (Rt = bt * f);
7696
7752
  }
7697
7753
  if (Rt && (A["Type.Width"] = Ct(Rt)), Rt) {
7698
- const lt = gi.get(A.Type);
7699
- lt === void 0 ? gi.set(A.Type, Rt) : Math.abs(lt - Rt) > 1e-3 && (A.Type = `${A.Type} · ${Math.round(Rt / f * 1e3)} mm`);
7754
+ const lt = wi.get(A.Type);
7755
+ lt === void 0 ? wi.set(A.Type, Rt) : Math.abs(lt - Rt) > 1e-3 && (A.Type = `${A.Type} · ${Math.round(Rt / f * 1e3)} mm`);
7700
7756
  }
7701
7757
  if (w === "floor" && r && o.item.guid) {
7702
7758
  const lt = Qt(r, o.item.guid);
@@ -7709,12 +7765,12 @@ function La(n) {
7709
7765
  const ft = `${st(G.record.id)}#${G.i}`, mt = z.get(ft);
7710
7766
  return mt ? [ft, mt] : [ft];
7711
7767
  });
7712
- K.length && (A.CutBy = [...new Set(K)].join("|"), typeof process < "u" && ((Xr = process.env) != null && Xr.RECIPE_TRACE) && console.error(`[floor-cut] ${o.item.guid} ${o.item.name ?? ""}: cut by ${K.length} wall(s)`));
7768
+ K.length && (A.CutBy = [...new Set(K)].join("|"), typeof process < "u" && ((Qr = process.env) != null && Qr.RECIPE_TRACE) && console.error(`[floor-cut] ${o.item.guid} ${o.item.name ?? ""}: cut by ${K.length} wall(s)`));
7713
7769
  }
7714
7770
  }
7715
7771
  if (w === "roof" || w === "ceiling") {
7716
7772
  A.BaseOffset = Ct(R * f);
7717
- const lt = Number(o.params.drop ?? ((Zr = m == null ? void 0 : m.said) == null ? void 0 : Zr.drop));
7773
+ const lt = Number(o.params.drop ?? ((to = m == null ? void 0 : m.said) == null ? void 0 : to.drop));
7718
7774
  if (w === "ceiling" && Number.isFinite(lt) && Rt) {
7719
7775
  const H = [...$.values()].filter((St) => St.at > k.at + 1e-6).sort((St, it) => St.at - it.at)[0];
7720
7776
  H && (A.BaseOffset = Ct((H.at - lt - Rt / f - k.at) * f));
@@ -7731,9 +7787,9 @@ function La(n) {
7731
7787
  const qt = St.filter((W, M) => it[M] < ft + 2e-3), L = (W) => [Math.min(...W.map((M) => M[0])), Math.min(...W.map((M) => M[1])), Math.max(...W.map((M) => M[0])), Math.max(...W.map((M) => M[1]))], [_, y, g, T] = L(St), [v, S, C, J] = L(qt), j = v - _ > 0.01 && S - y > 0.01 && g - C > 0.01 && T - J > 0.01;
7732
7788
  A.EaveCut = j ? "TwoCutSquare" : "TwoCutPlumb", A.FasciaDepth = Ct((j ? xt * Math.sqrt(1 + H * H) : xt) * f);
7733
7789
  }
7734
- typeof process < "u" && ((Qr = process.env) != null && Qr.RECIPE_TRACE) && console.error(`[roof-eave] ${o.item.guid} ${V}: plumb low ${At.toFixed(3)}, its lowest ${ft.toFixed(3)} → ${A.EaveCut ?? "plumb"}${A.FasciaDepth ? `, fascia ${(Number(A.FasciaDepth) / f).toFixed(3)}` : ""}`);
7790
+ typeof process < "u" && ((eo = process.env) != null && eo.RECIPE_TRACE) && console.error(`[roof-eave] ${o.item.guid} ${V}: plumb low ${At.toFixed(3)}, its lowest ${ft.toFixed(3)} → ${A.EaveCut ?? "plumb"}${A.FasciaDepth ? `, fascia ${(Number(A.FasciaDepth) / f).toFixed(3)}` : ""}`);
7735
7791
  }
7736
- typeof process < "u" && ((to = process.env) != null && to.RECIPE_TRACE) && console.error(`[roof] ${o.item.guid} ${V}: slopes ${JSON.stringify(bt)} base ${R} width ${Rt} edges ${gt[0] ? gt[0].length / 3 : 0} profile ${JSON.stringify((eo = gt[0]) == null ? void 0 : eo.map((it) => +it.toFixed(2)))}`);
7792
+ typeof process < "u" && ((so = process.env) != null && so.RECIPE_TRACE) && console.error(`[roof] ${o.item.guid} ${V}: slopes ${JSON.stringify(bt)} base ${R} width ${Rt} edges ${gt[0] ? gt[0].length / 3 : 0} profile ${JSON.stringify((no = gt[0]) == null ? void 0 : no.map((it) => +it.toFixed(2)))}`);
7737
7793
  }
7738
7794
  const K = w === "roof" ? jt(o) : null;
7739
7795
  if (K) {
@@ -7744,7 +7800,7 @@ function La(n) {
7744
7800
  length: L * f
7745
7801
  }), delete A.Slopes;
7746
7802
  }
7747
- const G = m == null ? void 0 : m.slope, et = ((no = (so = m == null ? void 0 : m.profile) == null ? void 0 : so.outline) == null ? void 0 : no.curves) ?? [];
7803
+ const G = m == null ? void 0 : m.slope, et = ((ro = (io = m == null ? void 0 : m.profile) == null ? void 0 : io.outline) == null ? void 0 : ro.curves) ?? [];
7748
7804
  if (w === "roof" && !K && !A.Slopes && G && typeof G.by == "number" && Math.abs(G.by) > 1e-3 && typeof G.toward == "number" && et.length >= 3) {
7749
7805
  const H = [Math.cos(G.toward), Math.sin(G.toward)], St = et.map((At) => At.from).filter(Boolean), it = St.map((At) => At[0] * H[0] + At[1] * H[1]), ft = Math.min(...it), mt = St.map((At, xt) => Math.abs(it[xt] - ft) < 0.01 && Math.abs(it[(xt + 1) % St.length] - ft) < 0.01);
7750
7806
  if (St.length === et.length && mt.some(Boolean)) {
@@ -7755,11 +7811,11 @@ function La(n) {
7755
7811
  k.at + R - xt > 0.5 * Math.tan(Math.abs(G.by)) * (Math.max(...it) - ft) && (A.BaseOffset = Ct((xt - k.at) * f));
7756
7812
  }
7757
7813
  }
7758
- typeof process < "u" && ((io = process.env) != null && io.RECIPE_TRACE) && console.error(`[roof-plane] ${o.item.guid} ${V}: ${(G.by * 180 / Math.PI).toFixed(1)}° toward ${(G.toward * 180 / Math.PI).toFixed(1)}°, eaves ${JSON.stringify(mt)}`);
7814
+ typeof process < "u" && ((oo = process.env) != null && oo.RECIPE_TRACE) && console.error(`[roof-plane] ${o.item.guid} ${V}: ${(G.by * 180 / Math.PI).toFixed(1)}° toward ${(G.toward * 180 / Math.PI).toFixed(1)}°, eaves ${JSON.stringify(mt)}`);
7759
7815
  }
7760
7816
  } else if (Rt) {
7761
7817
  A.HeightOffset = Ct(R * f + Rt);
7762
- const lt = m == null ? void 0 : m.slope, bt = ((oo = (ro = m == null ? void 0 : m.profile) == null ? void 0 : ro.outline) == null ? void 0 : oo.curves) ?? [];
7818
+ const lt = m == null ? void 0 : m.slope, bt = ((co = (ao = m == null ? void 0 : m.profile) == null ? void 0 : ao.outline) == null ? void 0 : co.curves) ?? [];
7763
7819
  if (lt && typeof lt.by == "number" && Math.abs(lt.by) > 1e-4 && typeof lt.toward == "number" && bt.length >= 3) {
7764
7820
  const K = [Math.cos(lt.toward), Math.sin(lt.toward)], G = bt.map((mt) => mt.from).filter(Boolean), et = G.map((mt) => mt[0] * K[0] + mt[1] * K[1]), H = Math.min(...et), St = Math.max(...et), it = G[et.indexOf(H)], ft = Math.tan(lt.by);
7765
7821
  if (St - H > 1e-3) {
@@ -7767,20 +7823,20 @@ function La(n) {
7767
7823
  const mt = r && o.item.guid ? Qt(r, o.item.guid) : [];
7768
7824
  if (mt.length >= 4) {
7769
7825
  const At = Math.min(...mt.map((xt) => xt[2])) - re;
7770
- A.HeightOffset = Ct((At - k.at) * f + Rt * Math.sqrt(1 + ft * ft)), typeof process < "u" && ((ao = process.env) != null && ao.RECIPE_TRACE) && console.error(`[slab-slope] ${o.item.guid} ${V}: lowest ${At.toFixed(3)} level ${k.at.toFixed(3)} base ${R.toFixed(3)} rise ${(ft * (St - H)).toFixed(3)}: top at its low corner ${(At + Rt * Math.sqrt(1 + ft * ft) / f).toFixed(3)} (by base ${(k.at + R + Rt / f - ft * (St - H)).toFixed(3)})`);
7826
+ A.HeightOffset = Ct((At - k.at) * f + Rt * Math.sqrt(1 + ft * ft)), typeof process < "u" && ((lo = process.env) != null && lo.RECIPE_TRACE) && console.error(`[slab-slope] ${o.item.guid} ${V}: lowest ${At.toFixed(3)} level ${k.at.toFixed(3)} base ${R.toFixed(3)} rise ${(ft * (St - H)).toFixed(3)}: top at its low corner ${(At + Rt * Math.sqrt(1 + ft * ft) / f).toFixed(3)} (by base ${(k.at + R + Rt / f - ft * (St - H)).toFixed(3)})`);
7771
7827
  }
7772
7828
  }
7773
7829
  }
7774
7830
  }
7775
7831
  nt(st(o.id), A) && pe[w]++;
7776
7832
  }
7777
- let Vs = 0, wi = 0;
7833
+ let Gs = 0, vi = 0;
7778
7834
  for (const o of a) {
7779
7835
  if (o.kind !== "member" || o.params.of !== "column") continue;
7780
- wi++;
7836
+ vi++;
7781
7837
  const h = de(o, "member"), w = h == null ? void 0 : h.start;
7782
7838
  if (!w || w.length !== 3) continue;
7783
- const m = c ? Vo(o.params.lookRef) : null;
7839
+ const m = c ? Ho(o.params.lookRef) : null;
7784
7840
  if (c && !m || !m && !d) continue;
7785
7841
  const F = m ?? {
7786
7842
  family: d.family,
@@ -7796,61 +7852,61 @@ function La(n) {
7796
7852
  },
7797
7853
  {
7798
7854
  position: [w[0] * f, w[1] * f, w[2] * f],
7799
- rotationDeg: (Number((h == null ? void 0 : h.roll) ?? 0) || 0) * qo
7855
+ rotationDeg: (Number((h == null ? void 0 : h.roll) ?? 0) || 0) * Go
7800
7856
  }
7801
- ) && Vs++;
7857
+ ) && Gs++;
7802
7858
  }
7803
- let Gs = 0, bi = 0, mn = 0;
7859
+ let Hs = 0, Ei = 0, gn = 0;
7804
7860
  for (const o of a) {
7805
7861
  if (o.kind !== "familyInstance") continue;
7806
7862
  if (o.params.host) {
7807
- mn++;
7863
+ gn++;
7808
7864
  continue;
7809
7865
  }
7810
- if (bi++, !E) continue;
7811
- const h = de(o, "instance"), w = (co = h == null ? void 0 : h.placement) == null ? void 0 : co.at;
7866
+ if (Ei++, !E) continue;
7867
+ const h = de(o, "instance"), w = (ho = h == null ? void 0 : h.placement) == null ? void 0 : ho.at;
7812
7868
  if (!w || w.length !== 3) continue;
7813
- const m = Vo(o.params.type);
7869
+ const m = Ho(o.params.type);
7814
7870
  if (!m) continue;
7815
- const F = (lo = h == null ? void 0 : h.placement) == null ? void 0 : lo.right, R = F ? Math.atan2(F[1], F[0]) * qo : 0;
7871
+ const F = (fo = h == null ? void 0 : h.placement) == null ? void 0 : fo.right, R = F ? Math.atan2(F[1], F[0]) * Go : 0;
7816
7872
  nt(
7817
7873
  st(o.id),
7818
7874
  { Family: m.family, Type: m.type },
7819
7875
  { position: [w[0] * f, w[1] * f, w[2] * f], rotationDeg: R }
7820
- ) && Gs++;
7876
+ ) && Hs++;
7821
7877
  }
7822
- Pt.size && typeof process < "u" && ((ho = process.env) != null && ho.RECIPE_TRACE) && console.error(`[shaped-panels] ${Pt.size} curtain panel(s) made as families of their shape`);
7823
- const gs = r ? Ll(r, wt, e.fileId, Pt).filter((o) => !yi.some((h) => h.guid && o.key.includes(h.guid))) : [];
7824
- if (typeof process < "u" && ((fo = process.env) != null && fo.RECIPE_GID))
7825
- for (const o of gs.filter((h) => h.key.includes(process.env.RECIPE_GID))) console.error(`[shaped] ${o.key} at ${o.at} turn ${o.rotationDeg} host ${o.host} ${JSON.stringify({ ...o.attrs, Shape: o.attrs.Shape ? "…" : void 0 })}`);
7826
- let Hs = 0;
7827
- const zs = /* @__PURE__ */ new Map();
7828
- for (const o of gs) {
7829
- if (!o.attrs.Family || zs.has(o.attrs.Family)) continue;
7878
+ Pt.size && typeof process < "u" && ((uo = process.env) != null && uo.RECIPE_TRACE) && console.error(`[shaped-panels] ${Pt.size} curtain panel(s) made as families of their shape`);
7879
+ const ys = r ? Dl(r, wt, e.fileId, Pt).filter((o) => !bi.some((h) => h.guid && o.key.includes(h.guid))) : [];
7880
+ if (typeof process < "u" && ((po = process.env) != null && po.RECIPE_GID))
7881
+ for (const o of ys.filter((h) => h.key.includes(process.env.RECIPE_GID))) console.error(`[shaped] ${o.key} at ${o.at} turn ${o.rotationDeg} host ${o.host} ${JSON.stringify({ ...o.attrs, Shape: o.attrs.Shape ? "…" : void 0 })}`);
7882
+ let zs = 0;
7883
+ const Ws = /* @__PURE__ */ new Map();
7884
+ for (const o of ys) {
7885
+ if (!o.attrs.Family || Ws.has(o.attrs.Family)) continue;
7830
7886
  const h = {};
7831
7887
  for (const w of ["Shape", "Prism"]) o.attrs[w] && (h[w] = o.attrs[w]);
7832
- Object.keys(h).length && zs.set(o.attrs.Family, h);
7888
+ Object.keys(h).length && Ws.set(o.attrs.Family, h);
7833
7889
  }
7834
- const vi = /* @__PURE__ */ new Set();
7835
- for (const o of gs) {
7890
+ const Ti = /* @__PURE__ */ new Set();
7891
+ for (const o of ys) {
7836
7892
  const h = o.attrs.Family;
7837
- !h || !zs.has(h) || !(o.attrs.Shape || o.attrs.Prism) || Yt(o.key, o.host && z.get(o.host) ? { ...o.attrs, HostMade: z.get(o.host) } : o.attrs, {
7893
+ !h || !Ws.has(h) || !(o.attrs.Shape || o.attrs.Prism) || Yt(o.key, o.host && z.get(o.host) ? { ...o.attrs, HostMade: z.get(o.host) } : o.attrs, {
7838
7894
  position: [o.at[0] * f, o.at[1] * f, (o.at[2] - re) * f],
7839
7895
  rotationDeg: o.rotationDeg,
7840
7896
  ...o.host ? { host: o.host } : {}
7841
- }) && vi.add(h);
7897
+ }) && Ti.add(h);
7842
7898
  }
7843
- for (const o of gs) {
7844
- const h = o.attrs.Family, w = { position: [o.at[0] * f, o.at[1] * f, (o.at[2] - re) * f], rotationDeg: o.rotationDeg, ...o.host ? { host: o.host } : {} }, m = o.host && z.get(o.host) ? { ...o.attrs, HostMade: z.get(o.host) } : o.attrs, F = h && vi.has(h) && !(o.attrs.Shape || o.attrs.Prism) && !Yt(o.key, m, w) ? { ...o.attrs, ...zs.get(h) } : o.attrs;
7899
+ for (const o of ys) {
7900
+ const h = o.attrs.Family, w = { position: [o.at[0] * f, o.at[1] * f, (o.at[2] - re) * f], rotationDeg: o.rotationDeg, ...o.host ? { host: o.host } : {} }, m = o.host && z.get(o.host) ? { ...o.attrs, HostMade: z.get(o.host) } : o.attrs, F = h && Ti.has(h) && !(o.attrs.Shape || o.attrs.Prism) && !Yt(o.key, m, w) ? { ...o.attrs, ...Ws.get(h) } : o.attrs;
7845
7901
  nt(o.key, o.host && z.get(o.host) ? { ...F, HostMade: z.get(o.host) } : F, {
7846
7902
  position: [o.at[0] * f, o.at[1] * f, (o.at[2] - re) * f],
7847
7903
  rotationDeg: o.rotationDeg,
7848
7904
  ...o.host ? { host: o.host } : {}
7849
- }) && Hs++;
7905
+ }) && zs++;
7850
7906
  }
7851
7907
  if (r)
7852
- for (const o of Bl(r, wt, e.fileId)) {
7853
- const h = (uo = at.get(o.host)) == null ? void 0 : uo.Profile;
7908
+ for (const o of Ul(r, wt, e.fileId)) {
7909
+ const h = (mo = at.get(o.host)) == null ? void 0 : mo.Profile;
7854
7910
  if (h)
7855
7911
  try {
7856
7912
  const w = JSON.parse(h), m = [];
@@ -7864,7 +7920,7 @@ function La(n) {
7864
7920
  return gt[0] < R[x][1] + 0.03 && R[x][0] < gt[1] + 0.03;
7865
7921
  });
7866
7922
  })) {
7867
- typeof process < "u" && ((po = process.env) != null && po.RECIPE_TRACE) && console.error(`[opening] ${o.key}: its wall's outline has its holes`);
7923
+ typeof process < "u" && ((go = process.env) != null && go.RECIPE_TRACE) && console.error(`[opening] ${o.key}: its wall's outline has its holes`);
7868
7924
  continue;
7869
7925
  }
7870
7926
  } catch {
@@ -7872,39 +7928,39 @@ function La(n) {
7872
7928
  nt(o.key, { WallOpening: o.box.map((w, m) => Ct((m % 3 === 2 ? w - re : w) * f)).join(","), ...z.get(o.host) ? { HostMade: z.get(o.host) } : {} }, { host: o.host });
7873
7929
  }
7874
7930
  if (r)
7875
- for (const o of Ul(r, e.fileId))
7931
+ for (const o of Vl(r, e.fileId))
7876
7932
  nt(o.key, { Room: "1", Name: o.name, Number: o.number, Height: Ct(o.height * f) }, { position: [o.at[0] * f, o.at[1] * f, (o.at[2] - re) * f] });
7877
- let gn = 0;
7878
- const Ua = /* @__PURE__ */ new Set(["slab", "roof", "covering"]);
7933
+ let yn = 0;
7934
+ const qa = /* @__PURE__ */ new Set(["slab", "roof", "covering"]);
7879
7935
  for (const o of a) {
7880
7936
  const h = o.params.of;
7881
- (o.kind === "footing" || o.kind === "ramp" || o.kind === "stair" && h !== "stair" || o.kind === "extrusion" && !Ua.has(String(h)) || o.kind === "extrusion" && h === "slab" && Jo(o) === "other" && !/ Landing \d+$/.test(String(o.item.attrs.Name ?? "")) || o.kind === "run" && h !== "wall" && h !== "curtainWall") && gn++;
7937
+ (o.kind === "footing" || o.kind === "ramp" || o.kind === "stair" && h !== "stair" || o.kind === "extrusion" && !qa.has(String(h)) || o.kind === "extrusion" && h === "slab" && Vo(o) === "other" && !/ Landing \d+$/.test(String(o.item.attrs.Name ?? "")) || o.kind === "run" && h !== "wall" && h !== "curtainWall") && yn++;
7882
7938
  }
7883
7939
  te();
7884
- let ys = 0;
7940
+ let ws = 0;
7885
7941
  for (const [o, h] of z)
7886
- !o.startsWith(`${e.fileId}:`) || wt.has(o) || (D.remove(h), ys++);
7942
+ !o.startsWith(`${e.fileId}:`) || wt.has(o) || (D.remove(h), ws++);
7887
7943
  if (D.length === 0)
7888
- throw new Ca(
7889
- `Up to date: "${e.name}" holds ${tt} element(s) this recipe already made, ${mn + gn} waiting on the applier, and nothing is left to remove.`
7944
+ throw new Ra(
7945
+ `Up to date: "${e.name}" holds ${tt} element(s) this recipe already made, ${gn + yn} waiting on the applier, and nothing is left to remove.`
7890
7946
  );
7891
- const Ja = [
7947
+ const Va = [
7892
7948
  Xt ? `${Xt} level(s)` : "",
7893
7949
  Kt ? `${Kt} wall(s)` : "",
7894
- Js ? `${Js} curtain wall(s)` : "",
7950
+ qs ? `${qs} curtain wall(s)` : "",
7895
7951
  pe.floor ? `${pe.floor} floor(s)` : "",
7896
7952
  pe.foundation ? `${pe.foundation} foundation slab(s)` : "",
7897
7953
  pe.roof ? `${pe.roof} roof(s)` : "",
7898
7954
  pe.ceiling ? `${pe.ceiling} ceiling(s)` : "",
7899
- qs ? `${qs} stair(s)` : "",
7900
- Vs ? `${Vs} column(s)` : "",
7901
- Gs ? `${Gs} instance(s)` : "",
7902
- Hs ? `${Hs} family instance(s)` : "",
7955
+ Vs ? `${Vs} stair(s)` : "",
7956
+ Gs ? `${Gs} column(s)` : "",
7957
+ Hs ? `${Hs} instance(s)` : "",
7958
+ zs ? `${zs} family instance(s)` : "",
7903
7959
  ct ? `${ct} changed` : "",
7904
- ys ? `${ys} gone` : ""
7960
+ ws ? `${ws} gone` : ""
7905
7961
  ].filter(Boolean);
7906
7962
  return {
7907
- title: `${n === "ifc" ? "IFC" : "Model"} to Revit: ${Ja.join(", ")}`,
7963
+ title: `${n === "ifc" ? "IFC" : "Model"} to Revit: ${Va.join(", ")}`,
7908
7964
  verb: D.summary,
7909
7965
  targets: D.length,
7910
7966
  payload: new Blob([await D.build(t.opId)]),
@@ -7913,21 +7969,21 @@ function La(n) {
7913
7969
  ruleTallies: [
7914
7970
  { read: $.size, written: Xt },
7915
7971
  { read: X.length + Wt, written: Kt },
7916
- { read: di, written: Js },
7917
- { read: ms.floor + ms.foundation, written: pe.floor + pe.foundation },
7918
- { read: ms.roof, written: pe.roof },
7919
- { read: ms.ceiling, written: pe.ceiling },
7920
7972
  { read: pi, written: qs },
7921
- { read: wi, written: Vs },
7922
- { read: bi, written: Gs },
7923
- { read: gs.length, written: Hs },
7924
- { read: ys, written: ys },
7925
- { read: mn + gn, written: 0 }
7973
+ { read: gs.floor + gs.foundation, written: pe.floor + pe.foundation },
7974
+ { read: gs.roof, written: pe.roof },
7975
+ { read: gs.ceiling, written: pe.ceiling },
7976
+ { read: gi, written: Vs },
7977
+ { read: vi, written: Gs },
7978
+ { read: Ei, written: Hs },
7979
+ { read: ys.length, written: zs },
7980
+ { read: ws, written: ws },
7981
+ { read: gn + yn, written: 0 }
7926
7982
  ]
7927
7983
  };
7928
7984
  };
7929
7985
  }
7930
- const zl = {
7986
+ const Kl = {
7931
7987
  type: "object",
7932
7988
  properties: {
7933
7989
  columnType: {
@@ -7957,7 +8013,7 @@ const zl = {
7957
8013
  default: !0
7958
8014
  }
7959
8015
  }
7960
- }, Wl = [
8016
+ }, Xl = [
7961
8017
  { reads: "Levels (datums)", writes: "The same level in Revit, ensured by name" },
7962
8018
  { reads: "Wall runs, one per straight segment", writes: "A native wall: line, type (made from its width when missing), level, height, joins; its edited profile or its top on a roof" },
7963
8019
  { reads: "Curtain wall runs", writes: "Revit's curtain wall: its grid lines, mullions and panels" },
@@ -7970,7 +8026,7 @@ const zl = {
7970
8026
  { reads: "Everything else with a body: doors, windows, furniture, fixtures, proxies, columns, railings", writes: "A family made from the file's own shape, one per shape, placed where the file has it (doors and windows in their wall)" },
7971
8027
  { reads: "Things this recipe made whose record is gone", writes: "That element removed" },
7972
8028
  { reads: "Hosted doors/windows, footings, ramps, other bodies", writes: "Nothing yet - read and counted" }
7973
- ], Ba = `
8029
+ ], Da = `
7974
8030
  ## How to use it
7975
8031
 
7976
8032
  In Revit, with the That Open plugin: **That Open > Select recipe**, pick this
@@ -8018,19 +8074,19 @@ are read and counted, and their rule row says so.
8018
8074
  Records are metres and radians, Z up; Revit gets feet and degrees. Types are
8019
8075
  matched exactly by name; Revit refuses the whole apply when a loadable type is
8020
8076
  missing (system types are created from their width instead).
8021
- `, ja = {
8077
+ `, Ua = {
8022
8078
  name: "frag-to-revit",
8023
8079
  title: "Platform model to Revit",
8024
8080
  description: "Builds in Revit the platform records of a .frag: levels, walls, curtain walls, floors, roofs, ceilings, stairs, columns, instances.",
8025
8081
  to: "revit",
8026
8082
  inputs: ["frag-model"],
8027
8083
  source: { kind: "project-file", extensions: ["frag"] },
8028
- settingsSchema: zl,
8029
- rules: Wl,
8030
- doc: Ba,
8031
- run: La("frag")
8032
- }, Yl = {
8033
- ...ja,
8084
+ settingsSchema: Kl,
8085
+ rules: Xl,
8086
+ doc: Da,
8087
+ run: ja("frag")
8088
+ }, Zl = {
8089
+ ...Ua,
8034
8090
  name: "ifc-to-revit",
8035
8091
  title: "IFC to Revit",
8036
8092
  description: "Builds an IFC of the project in Revit as native elements: levels, walls, floors, roofs, stairs, curtain walls, columns, instances.",
@@ -8042,9 +8098,9 @@ missing (system types are created from their width instead).
8042
8098
  It reads the IFC file itself, the version uploaded last. Its first step
8043
8099
  converts it into the platform's records - what each element is, not only its
8044
8100
  shape - and Revit gets those. Nothing has to be prepared before.
8045
- ` + Ba,
8046
- run: La("ifc")
8047
- }, Kl = {
8101
+ ` + Da,
8102
+ run: ja("ifc")
8103
+ }, Ql = {
8048
8104
  millimeters: 1e-3,
8049
8105
  millimetres: 1e-3,
8050
8106
  mm: 1e-3,
@@ -8058,13 +8114,13 @@ shape - and Revit gets those. Nothing has to be prepared before.
8058
8114
  in: 0.0254,
8059
8115
  feet: 0.3048,
8060
8116
  ft: 0.3048
8061
- }, Da = "rhino-to-revit", Xl = `recipe:${Da}`;
8062
- function Zl(n) {
8117
+ }, Ja = "rhino-to-revit", th = `recipe:${Ja}`;
8118
+ function eh(n) {
8063
8119
  const t = (n.attrs.Position ?? "").split(",").map((e) => Number(e.trim()));
8064
8120
  return t.length !== 3 || t.some((e) => !Number.isFinite(e)) ? null : [t[0], t[1], t[2]];
8065
8121
  }
8066
- const Ql = {
8067
- name: Da,
8122
+ const sh = {
8123
+ name: Ja,
8068
8124
  title: "Rhino to Revit",
8069
8125
  description: "Places in Revit an instance of a chosen type at each placed object of a Rhino layer.",
8070
8126
  to: "revit",
@@ -8131,13 +8187,13 @@ point's height.
8131
8187
  `,
8132
8188
  async run(n) {
8133
8189
  var Tt;
8134
- const { picked: t, contents: e } = await ci(
8190
+ const { picked: t, contents: e } = await hi(
8135
8191
  n,
8136
8192
  n.input
8137
8193
  ), { layer: s, instanceType: i } = n.settings;
8138
8194
  if (!s || !i)
8139
8195
  throw new Error("Choose the layer and the Revit type.");
8140
- const r = (Tt = e.metadata) == null ? void 0 : Tt.data, a = r == null ? void 0 : r.units, l = typeof a == "string" ? Kl[a.trim().toLowerCase()] : void 0;
8196
+ const r = (Tt = e.metadata) == null ? void 0 : Tt.data, a = r == null ? void 0 : r.units, l = typeof a == "string" ? Ql[a.trim().toLowerCase()] : void 0;
8141
8197
  if (!l)
8142
8198
  throw new Error(
8143
8199
  `"${t.name}" does not say what units its data is in${a ? ` ("${String(a)}" is not one this recipe knows)` : ""}, so nothing can be converted from it.`
@@ -8147,11 +8203,11 @@ point's height.
8147
8203
  throw new Error(
8148
8204
  `"${t.name}" declares its data as "${p}"; this recipe only converts Z up.`
8149
8205
  );
8150
- const d = l * rs, c = ai(n), E = new ii({
8206
+ const d = l * rs, c = li(n), E = new oi({
8151
8207
  project: n.projectId,
8152
8208
  document: n.target.docId ?? "",
8153
8209
  baseCommit: n.target.version ?? 0,
8154
- author: Xl
8210
+ author: th
8155
8211
  });
8156
8212
  let b = 0, $ = 0, P = 0;
8157
8213
  const N = /* @__PURE__ */ new Set(), Y = [];
@@ -8161,7 +8217,7 @@ point's height.
8161
8217
  P++;
8162
8218
  continue;
8163
8219
  }
8164
- const wt = Zl(st);
8220
+ const wt = eh(st);
8165
8221
  if (!wt) continue;
8166
8222
  N.add(st.guid);
8167
8223
  const Pt = [
@@ -8185,7 +8241,7 @@ point's height.
8185
8241
  N.has(st) || (E.remove(wt), z++);
8186
8242
  const D = b + $ + z;
8187
8243
  if (D === 0)
8188
- throw new Ca(
8244
+ throw new Ra(
8189
8245
  `Nothing to write: layer "${s}" of "${t.name}" has no placed object, and nothing of this recipe is left to remove.`
8190
8246
  );
8191
8247
  return {
@@ -8205,68 +8261,69 @@ point's height.
8205
8261
  ]
8206
8262
  };
8207
8263
  }
8208
- }, th = [
8209
- Ql,
8210
- Yl,
8211
- ja
8264
+ }, nh = [
8265
+ sh,
8266
+ Zl,
8267
+ Ua
8212
8268
  ];
8213
- function ih(n) {
8214
- for (const t of th) n.recipes.register(t);
8269
+ function ah(n) {
8270
+ for (const t of nh) n.recipes.register(t);
8215
8271
  }
8216
- const rh = {
8272
+ const ch = {
8217
8273
  MAX_FIELDS: 200,
8218
8274
  MAX_KEY_LENGTH: 50,
8219
8275
  MAX_VALUE_LENGTH: 50
8220
- }, oh = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, ah = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, ch = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, lh = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, hh = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, fh = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, dh = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, uh = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, ph = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
8276
+ }, lh = { uuid: "a3f82c1d-5b74-4e9a-bc30-d7e12f894a61" }, hh = { uuid: "2c9f4e8d-3a1b-4c5e-9d7f-0a2b6c8e1d3f" }, fh = { uuid: "b0b5e2a2-0b3a-4a6b-8b1c-0b1c4a6b8b1c" }, dh = { uuid: "d8f3a1c2-6b4e-4f9a-8c1d-2e7b5a9f3c60" }, uh = { uuid: "3f9c1a7e-6b2d-4e18-9a5c-7d0e2f4b6c81" }, ph = { uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96" }, mh = { uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f" }, gh = { uuid: "69af63aa-19ba-4fc7-b17b-75647bac1d76" }, yh = { uuid: "234f1416-528d-452a-9cc9-a16c5239b2eb" };
8221
8277
  export {
8222
- oh as CDEManager,
8223
- Ol as ChannelClient,
8224
- Ra as ChannelRoom,
8225
- ah as ClashesManager,
8226
- _l as CollabRoom,
8227
- Ks as DOCUMENT_FILE,
8228
- fn as DOCUMENT_SCHEMA,
8229
- pa as DOCUMENT_TYPES,
8230
- Vc as DocumentDrafts,
8231
- Jn as EngineServicesClient,
8232
- Al as ExternalRoom,
8233
- ch as FileList,
8234
- $o as FlowDoc,
8235
- lh as GISManager,
8236
- hh as GitHistoryManager,
8237
- fh as HelloWorld,
8238
- rh as METADATA_LIMITS,
8239
- Ta as OP_SCHEMA,
8240
- ii as OperationBuilder,
8241
- _a as PROJECT_RECIPE_SCHEMA,
8242
- jo as PlatformClient,
8243
- ma as ProjectDocuments,
8244
- oa as ProjectHistory,
8245
- dh as ProjectManager,
8246
- ll as ProjectRecipes,
8247
- ol as RECIPE_NAME,
8248
- rl as RecipeKit,
8249
- fl as Recipes,
8250
- li as RequestError,
8251
- qc as SELF_VIEWING_FORMATS,
8252
- Po as STORAGE_BATCH_MAX,
8253
- To as StaleHistoryError,
8254
- uh as TopicsManager,
8255
- ph as UIManager,
8256
- Ca as UpToDate,
8257
- th as builtinRecipes,
8258
- Fo as compileRecipe,
8259
- nh as describeChanges,
8260
- So as documentTypeOf,
8261
- ja as fragToRevit,
8262
- Yl as ifcToRevit,
8263
- dl as latestVersions,
8264
- ua as mintGuid,
8265
- da as orderByGraph,
8266
- ri as readFrag,
8267
- ih as registerBuiltinRecipes,
8268
- Ql as rhinoToRevit,
8269
- Ln as stampOf,
8270
- Sl as windowTransport
8278
+ yl as AppCache,
8279
+ lh as CDEManager,
8280
+ Nl as ChannelClient,
8281
+ Na as ChannelRoom,
8282
+ hh as ClashesManager,
8283
+ Ol as CollabRoom,
8284
+ Xs as DOCUMENT_FILE,
8285
+ dn as DOCUMENT_SCHEMA,
8286
+ ga as DOCUMENT_TYPES,
8287
+ Hc as DocumentDrafts,
8288
+ Vn as EngineServicesClient,
8289
+ Rl as ExternalRoom,
8290
+ fh as FileList,
8291
+ So as FlowDoc,
8292
+ dh as GISManager,
8293
+ uh as GitHistoryManager,
8294
+ ph as HelloWorld,
8295
+ ch as METADATA_LIMITS,
8296
+ $a as OP_SCHEMA,
8297
+ oi as OperationBuilder,
8298
+ Ca as PROJECT_RECIPE_SCHEMA,
8299
+ Uo as PlatformClient,
8300
+ ya as ProjectDocuments,
8301
+ ca as ProjectHistory,
8302
+ mh as ProjectManager,
8303
+ fl as ProjectRecipes,
8304
+ cl as RECIPE_NAME,
8305
+ al as RecipeKit,
8306
+ ul as Recipes,
8307
+ fi as RequestError,
8308
+ Gc as SELF_VIEWING_FORMATS,
8309
+ Bo as STORAGE_BATCH_MAX,
8310
+ $o as StaleHistoryError,
8311
+ gh as TopicsManager,
8312
+ yh as UIManager,
8313
+ Ra as UpToDate,
8314
+ nh as builtinRecipes,
8315
+ Lo as compileRecipe,
8316
+ oh as describeChanges,
8317
+ _o as documentTypeOf,
8318
+ Ua as fragToRevit,
8319
+ Zl as ifcToRevit,
8320
+ pl as latestVersions,
8321
+ ma as mintGuid,
8322
+ pa as orderByGraph,
8323
+ ai as readFrag,
8324
+ ah as registerBuiltinRecipes,
8325
+ sh as rhinoToRevit,
8326
+ jn as stampOf,
8327
+ Al as windowTransport
8271
8328
  };
8272
8329
  //# sourceMappingURL=index.es.js.map