@nebula-spatial/cad-loader 0.2.3 → 0.3.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.js CHANGED
@@ -1,17 +1,17 @@
1
- var Or = Object.defineProperty;
1
+ var _r = Object.defineProperty;
2
2
  var sn = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var _r = (t, n, e) => n in t ? Or(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
6
- var f = (t, n, e) => _r(t, typeof n != "symbol" ? n + "" : n, e), it = (t, n, e) => n.has(t) || sn("Cannot " + e);
5
+ var Gr = (t, n, e) => n in t ? _r(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
6
+ var f = (t, n, e) => Gr(t, typeof n != "symbol" ? n + "" : n, e), it = (t, n, e) => n.has(t) || sn("Cannot " + e);
7
7
  var g = (t, n, e) => (it(t, n, "read from private field"), e ? e.call(t) : n.get(t)), k = (t, n, e) => n.has(t) ? sn("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, e), G = (t, n, e, r) => (it(t, n, "write to private field"), r ? r.call(t, e) : n.set(t, e), e), V = (t, n, e) => (it(t, n, "access private method"), e);
8
- import { CadPackError as U, normalizeGeometrySegments as Gr, normalizeViewportRect as Ft, cloneViewportRect as qe, mergeViewportRects as fe, readGroup as Ur, transformBBoxByInstance as Nr, parseBinStreaming as Ot, isStrictTextRoundtripEnabled as zr, assertStrictTextRoundtrip as Hr, computeViewportRectFromPositions as _e, expandViewportRect as Je, viewportRectEquals as qr, viewportRectIntersects as Kn, viewportRectContains as _t, transformViewportRect as Kr, readExternalVariantDependencyPlan as Ke, readExternalAnnotationManifest as Gt, readExternalBlockAnnotations as Ut, readSceneAnnotationSidecar as Wr, parseBinPayload as Xr, parseBinBounds as Yr, readExternalVariantManifest as Qr } from "./core/index.js";
9
- import { readBlockAnnotationSidecar as Xo } from "./core/index.js";
10
- import { BufferAttribute as $, RawShaderMaterial as $r, Color as Wn, Vector2 as Xn, DoubleSide as vt, BufferGeometry as Nt, LineSegments as zt, InstancedInterleavedBuffer as an, InstancedBufferGeometry as Yn, Float32BufferAttribute as Qn, InterleavedBufferAttribute as De, Mesh as Ht, Vector3 as st, Box3 as jr, Sphere as Zr, Object3D as Rt, InstancedBufferAttribute as de, Points as $n, Group as ee, PointsMaterial as on, LineBasicMaterial as ln, MeshBasicMaterial as dn } from "three";
11
- import { BatchedText as cn, Text as Jr, preloadFont as We } from "troika-three-text";
12
- import ei from "rbush";
13
- const qt = 16.7, Kt = 6, Wt = 128 * 1024 * 1024, Xt = 64 * 1024 * 1024, Yt = 2, Qt = 1, ti = 3e5, ni = 22e4, un = 2;
14
- function K(t, n = "CAD load aborted") {
8
+ import { CadPackError as U, normalizeGeometrySegments as Ur, normalizeViewportRect as Ft, cloneViewportRect as qe, mergeViewportRects as fe, readGroup as Nr, transformBBoxByInstance as zr, parseBinStreaming as Ot, isStrictTextRoundtripEnabled as Hr, assertStrictTextRoundtrip as qr, computeViewportRectFromPositions as _e, expandViewportRect as Je, viewportRectEquals as Kr, viewportRectIntersects as Wn, viewportRectContains as _t, transformViewportRect as Wr, readExternalVariantDependencyPlan as Ke, readExternalAnnotationManifest as Gt, readExternalBlockAnnotations as Ut, readSceneAnnotationSidecar as Xr, parseBinPayload as Yr, parseBinBounds as Qr, readExternalVariantManifest as $r } from "./core/index.js";
9
+ import { readBlockAnnotationSidecar as Yo } from "./core/index.js";
10
+ import { BufferAttribute as $, RawShaderMaterial as jr, Color as Xn, Vector2 as Yn, DoubleSide as vt, BufferGeometry as Nt, LineSegments as zt, InstancedInterleavedBuffer as an, InstancedBufferGeometry as Qn, Float32BufferAttribute as $n, InterleavedBufferAttribute as De, Mesh as Ht, Vector3 as st, Box3 as Zr, Sphere as Jr, Object3D as Rt, InstancedBufferAttribute as ce, Points as jn, Group as ee, PointsMaterial as on, LineBasicMaterial as ln, MeshBasicMaterial as cn } from "three";
11
+ import { BatchedText as dn, Text as ei, configureTextBuilder as ti, preloadFont as We } from "troika-three-text";
12
+ import ni from "rbush";
13
+ const qt = 16.7, Kt = 6, Wt = 128 * 1024 * 1024, Xt = 64 * 1024 * 1024, Yt = 2, Qt = 1, ri = 3e5, ii = 22e4, un = 2;
14
+ function W(t, n = "CAD load aborted") {
15
15
  if (t instanceof Error && t.name === "AbortError") return t;
16
16
  const e = typeof t == "string" && t.length > 0 ? t : n, r = new Error(e, t === void 0 ? void 0 : { cause: t });
17
17
  return r.name = "AbortError", r;
@@ -25,10 +25,10 @@ function ue(t, n) {
25
25
  const e = () => n.abort(t.reason);
26
26
  return t.addEventListener("abort", e, { once: !0 }), () => t.removeEventListener("abort", e);
27
27
  }
28
- function jn(t, n, e = "CAD load aborted") {
29
- return n.aborted ? Promise.reject(K(n.reason, e)) : new Promise((r, i) => {
28
+ function Zn(t, n, e = "CAD load aborted") {
29
+ return n.aborted ? Promise.reject(W(n.reason, e)) : new Promise((r, i) => {
30
30
  const s = () => {
31
- a(), i(K(n.reason, e));
31
+ a(), i(W(n.reason, e));
32
32
  }, a = () => n.removeEventListener("abort", s);
33
33
  n.addEventListener("abort", s, { once: !0 }), t.then(
34
34
  (o) => {
@@ -46,16 +46,16 @@ function et(t) {
46
46
  function hn(t) {
47
47
  return et(t) && typeof t.arrayBuffer == "function";
48
48
  }
49
- function ri(t) {
49
+ function si(t) {
50
50
  return typeof URL == "function" && t instanceof URL;
51
51
  }
52
- function ii(t) {
52
+ function ai(t) {
53
53
  return et(t) && typeof t.aborted == "boolean" && typeof t.addEventListener == "function" && typeof t.removeEventListener == "function";
54
54
  }
55
55
  function tt(t, n) {
56
56
  if (t instanceof ArrayBuffer)
57
57
  return { source: { kind: "buffer", buffer: t } };
58
- if (typeof t == "string" || ri(t)) {
58
+ if (typeof t == "string" || si(t)) {
59
59
  const r = String(t);
60
60
  if (r.trim().length === 0)
61
61
  throw new U("E_SOURCE", "URL source must include a non-empty URL");
@@ -78,7 +78,7 @@ function tt(t, n) {
78
78
  case "url": {
79
79
  if (typeof e.url != "string" || e.url.trim().length === 0)
80
80
  throw new U("E_SOURCE", "URL source must include a non-empty URL");
81
- const r = ii(e.signal) ? e.signal : void 0;
81
+ const r = ai(e.signal) ? e.signal : void 0;
82
82
  return {
83
83
  source: { kind: "url", url: e.url, signal: n },
84
84
  sourceSignal: r
@@ -88,22 +88,22 @@ function tt(t, n) {
88
88
  throw new U("E_SOURCE", `Unsupported CAD load source kind: ${String(e.kind)}`);
89
89
  }
90
90
  }
91
- function si(t) {
91
+ function oi(t) {
92
92
  if (!et(t) || typeof t.kind != "string")
93
93
  throw new U("E_SOURCE", "Geo source must be an object");
94
94
  tt(t, new AbortController().signal);
95
95
  }
96
- function Ae() {
96
+ function Be() {
97
97
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
98
98
  }
99
- function ai(t) {
99
+ function li(t) {
100
100
  if (typeof queueMicrotask == "function") {
101
101
  queueMicrotask(t);
102
102
  return;
103
103
  }
104
104
  Promise.resolve().then(t);
105
105
  }
106
- class Zn {
106
+ class Jn {
107
107
  constructor(n) {
108
108
  f(this, "highWatermarkBytes");
109
109
  f(this, "lowWatermarkBytes");
@@ -143,40 +143,33 @@ class Zn {
143
143
  }
144
144
  async function Xe(t) {
145
145
  const n = fn(), e = t.fetchImpl ?? fetch, r = new Map(
146
- t.entries.map((l) => [l.id, l])
147
- ), i = Array.from(new Set(t.requiredVariantIds)).sort((l, u) => l - u), s = /* @__PURE__ */ new Map(), a = oi(t.concurrency);
148
- let o = 0;
149
- async function d() {
150
- var l;
151
- for (; o < i.length; ) {
152
- const u = i[o++], c = r.get(u);
153
- if (!c)
154
- throw new Error(`External block ${u} is missing from manifest`);
155
- const h = new URL(c.href, t.baseUrl).href, y = await e(h, { signal: t.signal });
156
- if (!y.ok) {
157
- const m = "status" in y ? y.status : void 0, b = "statusText" in y ? y.statusText : void 0, v = [m, b].filter((I) => I !== void 0 && I !== "").join(" ");
158
- throw new Error(`External block ${u} fetch failed${v ? `: ${v}` : ""}`);
159
- }
160
- const p = await y.arrayBuffer();
161
- if (p.byteLength !== c.raw_size)
162
- throw new Error(
163
- `External block ${u} raw_size mismatch: manifest=${c.raw_size}, response=${p.byteLength}`
164
- );
165
- s.set(u, p), await ((l = t.onBuffer) == null ? void 0 : l.call(t, u, p));
146
+ t.entries.map((o) => [o.id, o])
147
+ ), i = Array.from(new Set(t.requiredVariantIds)).sort((o, l) => o - l), s = /* @__PURE__ */ new Map();
148
+ async function a(o) {
149
+ var h;
150
+ const l = r.get(o);
151
+ if (!l)
152
+ throw new Error(`External block ${o} is missing from manifest`);
153
+ const c = new URL(l.href, t.baseUrl).href, u = await e(c, { signal: t.signal });
154
+ if (!u.ok) {
155
+ const y = "status" in u ? u.status : void 0, x = "statusText" in u ? u.statusText : void 0, m = [y, x].filter((b) => b !== void 0 && b !== "").join(" ");
156
+ throw new Error(`External block ${o} fetch failed${m ? `: ${m}` : ""}`);
166
157
  }
158
+ const d = await u.arrayBuffer();
159
+ if (d.byteLength !== l.raw_size)
160
+ throw new Error(
161
+ `External block ${o} raw_size mismatch: manifest=${l.raw_size}, response=${d.byteLength}`
162
+ );
163
+ s.set(o, d), await ((h = t.onBuffer) == null ? void 0 : h.call(t, o, d));
167
164
  }
168
- return await Promise.all(Array.from({ length: Math.min(a, i.length) }, d)), { buffers: s, fetchMs: fn() - n };
169
- }
170
- function oi(t) {
171
- const n = Math.floor(t ?? 3);
172
- return Number.isFinite(n) ? Math.max(1, Math.min(n, 8)) : 3;
165
+ return await Promise.all(i.map(a)), { buffers: s, fetchMs: fn() - n };
173
166
  }
174
167
  function fn() {
175
168
  var t, n;
176
169
  return ((n = (t = globalThis.performance) == null ? void 0 : t.now) == null ? void 0 : n.call(t)) ?? Date.now();
177
170
  }
178
171
  var te;
179
- class li {
172
+ class ci {
180
173
  constructor() {
181
174
  k(this, te, /* @__PURE__ */ new Map());
182
175
  }
@@ -187,27 +180,27 @@ class li {
187
180
  let e = 0;
188
181
  for (const r of n) {
189
182
  if (r.count <= 0) continue;
190
- const i = At(r.layerIndex, r.lineweightPx);
183
+ const i = Bt(r.layerIndex, r.lineweightPx);
191
184
  let s = g(this, te).get(i), a = r.pos, o = r.positionItemSize;
192
- const d = r.linePositionKind ?? null;
193
- s ? s.positionItemSize !== o && (yn(s), o !== 3 && (a = er(a, r.count, o)), s.positionItemSize = 3, o = 3, s.linePositionKind = null) : (s = {
185
+ const l = r.linePositionKind ?? null;
186
+ s ? s.positionItemSize !== o && (yn(s), o !== 3 && (a = tr(a, r.count, o)), s.positionItemSize = 3, o = 3, s.linePositionKind = null) : (s = {
194
187
  layerIndex: r.layerIndex,
195
188
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
196
189
  posParts: [],
197
190
  positionItemSize: o,
198
191
  colParts: [],
199
192
  colorRunParts: [],
200
- linePositionKind: d,
193
+ linePositionKind: l,
201
194
  count: 0,
202
195
  bbox: null
203
196
  }, g(this, te).set(i, s));
204
- const l = s.count > 0;
197
+ const c = s.count > 0;
205
198
  s.posParts.push(a), s.colParts.push(r.col);
206
- const u = mi(
207
- r.colorRuns ?? pi(r.col),
199
+ const u = pi(
200
+ r.colorRuns ?? xi(r.col),
208
201
  s.count
209
202
  );
210
- s.colorRunParts.push(u), s.linePositionKind !== d && (s.linePositionKind = null), s.positionItemSize === 2 && s.linePositionKind === null && yn(s), s.count += r.count, s.bbox = l && s.bbox === null ? null : ci(s.bbox, r.bbox), e += r.count;
203
+ s.colorRunParts.push(u), s.linePositionKind !== l && (s.linePositionKind = null), s.positionItemSize === 2 && s.linePositionKind === null && yn(s), s.count += r.count, s.bbox = c && s.bbox === null ? null : ui(s.bbox, r.bbox), e += r.count;
211
204
  }
212
205
  return e;
213
206
  }
@@ -215,7 +208,7 @@ class li {
215
208
  const n = [];
216
209
  for (const e of g(this, te).values()) {
217
210
  if (e.count <= 0) continue;
218
- const r = e.posParts.length === 1 ? e.posParts[0] : fi(e.posParts, e.count * e.positionItemSize), i = e.colParts.length === 1 ? e.colParts[0] : yi(e.colParts, e.count * 3), s = tr(e.colorRunParts.flat()), a = {
211
+ const r = e.posParts.length === 1 ? e.posParts[0] : yi(e.posParts, e.count * e.positionItemSize), i = e.colParts.length === 1 ? e.colParts[0] : mi(e.colParts, e.count * 3), s = nr(e.colorRunParts.flat()), a = {
219
212
  layerIndex: e.layerIndex,
220
213
  pos: r,
221
214
  positionItemSize: e.positionItemSize,
@@ -231,7 +224,7 @@ class li {
231
224
  }
232
225
  te = new WeakMap();
233
226
  function at() {
234
- return new li();
227
+ return new ci();
235
228
  }
236
229
  function di() {
237
230
  return {
@@ -240,7 +233,7 @@ function di() {
240
233
  dot: at()
241
234
  };
242
235
  }
243
- function ci(t, n) {
236
+ function ui(t, n) {
244
237
  const e = Ft(n);
245
238
  return t ? e ? {
246
239
  minX: Math.min(t.minX, e.minX),
@@ -251,17 +244,17 @@ function ci(t, n) {
251
244
  }
252
245
  function he(t, n = {}) {
253
246
  if (t.count <= 0) return [];
254
- const e = Gr(t), r = [], i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = n.markLinePositionXy === !0 || n.splitLineweight === !0;
247
+ const e = Ur(t), r = [], i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = n.markLinePositionXy === !0 || n.splitLineweight === !0;
255
248
  for (const m of e) {
256
249
  if (m.vertexCount <= 0) continue;
257
- const b = m.layerIndex, v = o ? m.lineweightPx : void 0, I = At(b, v), w = i.get(I);
258
- w === void 0 ? (i.set(I, m.vertexCount), s.set(I, b), a.set(I, v), r.push(I)) : i.set(I, w + m.vertexCount);
250
+ const b = m.layerIndex, R = o ? m.lineweightPx : void 0, I = Bt(b, R), w = i.get(I);
251
+ w === void 0 ? (i.set(I, m.vertexCount), s.set(I, b), a.set(I, R), r.push(I)) : i.set(I, w + m.vertexCount);
259
252
  }
260
- const d = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), h = n.markLinePositionXy === !0 ? "xy-zero-z" : void 0, y = h ? 2 : 3;
253
+ const l = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), h = n.markLinePositionXy === !0 ? "xy-zero-z" : void 0, y = h ? 2 : 3;
261
254
  for (const m of r) {
262
- const b = s.get(m), v = a.get(m), I = i.get(m) ?? 0, w = {
255
+ const b = s.get(m), R = a.get(m), I = i.get(m) ?? 0, w = {
263
256
  layerIndex: b,
264
- ...v === void 0 ? {} : { lineweightPx: v },
257
+ ...R === void 0 ? {} : { lineweightPx: R },
265
258
  pos: new Float32Array(I * y),
266
259
  positionItemSize: y,
267
260
  col: new Uint8Array(I * 3),
@@ -269,50 +262,50 @@ function he(t, n = {}) {
269
262
  bbox: null,
270
263
  colorRuns: []
271
264
  };
272
- h && (w.linePositionKind = h), d.set(m, w), l.set(m, 0), u.set(m, null);
265
+ h && (w.linePositionKind = h), l.set(m, w), c.set(m, 0), u.set(m, null);
273
266
  }
274
267
  for (const m of e) {
275
268
  if (m.vertexCount <= 0) continue;
276
- const b = m.layerIndex, v = o ? m.lineweightPx : void 0, I = At(b, v), w = d.get(I), T = l.get(I), A = T, B = m.color[0], E = m.color[1], S = m.color[2];
269
+ const b = m.layerIndex, R = o ? m.lineweightPx : void 0, I = Bt(b, R), w = l.get(I), T = c.get(I), B = T, A = m.color[0], E = m.color[1], S = m.color[2];
277
270
  for (let P = 0; P < m.vertexCount; P += 1) {
278
- const O = m.startVertex + P, W = T + P, M = W * y, _ = W * 3, X = O * 2, N = t.pos[X], C = t.pos[X + 1];
279
- w.pos[M] = N, w.pos[M + 1] = C, y === 3 && (w.pos[M + 2] = 0), w.col[_] = B, w.col[_ + 1] = E, w.col[_ + 2] = S;
271
+ const O = m.startVertex + P, K = T + P, M = K * y, _ = K * 3, X = O * 2, N = t.pos[X], C = t.pos[X + 1];
272
+ w.pos[M] = N, w.pos[M + 1] = C, y === 3 && (w.pos[M + 2] = 0), w.col[_] = A, w.col[_ + 1] = E, w.col[_ + 2] = S;
280
273
  const L = u.get(I);
281
- !Number.isFinite(N) || !Number.isFinite(C) ? c.add(I) : L ? (N < L.minX && (L.minX = N), C < L.minY && (L.minY = C), N > L.maxX && (L.maxX = N), C > L.maxY && (L.maxY = C)) : u.set(I, { minX: N, minY: C, maxX: N, maxY: C });
274
+ !Number.isFinite(N) || !Number.isFinite(C) ? d.add(I) : L ? (N < L.minX && (L.minX = N), C < L.minY && (L.minY = C), N > L.maxX && (L.maxX = N), C > L.maxY && (L.maxY = C)) : u.set(I, { minX: N, minY: C, maxX: N, maxY: C });
282
275
  }
283
276
  w.colorRuns.push({
284
- startVertex: A,
277
+ startVertex: B,
285
278
  vertexCount: m.vertexCount,
286
- color: [B, E, S]
287
- }), l.set(I, T + m.vertexCount);
279
+ color: [A, E, S]
280
+ }), c.set(I, T + m.vertexCount);
288
281
  }
289
- const p = [];
282
+ const x = [];
290
283
  for (const m of r) {
291
- const b = d.get(m);
292
- b && (b.bbox = c.has(m) ? null : Ft(u.get(m) ?? null), b.colorRuns = tr(b.colorRuns ?? []), p.push(b));
284
+ const b = l.get(m);
285
+ b && (b.bbox = d.has(m) ? null : Ft(u.get(m) ?? null), b.colorRuns = nr(b.colorRuns ?? []), x.push(b));
293
286
  }
294
- return p;
287
+ return x;
295
288
  }
296
- function At(t, n) {
289
+ function Bt(t, n) {
297
290
  return n === void 0 ? `${t}:` : `${t}:${n}`;
298
291
  }
299
- function ui(t, n) {
292
+ function hi(t, n) {
300
293
  return t.append(n);
301
294
  }
302
- function hi(t) {
295
+ function fi(t) {
303
296
  return t.drain();
304
297
  }
305
- function Jn(t) {
298
+ function er(t) {
306
299
  return t.reduce((n, e) => n + e.pos.byteLength + e.col.byteLength, 0);
307
300
  }
308
- function fi(t, n) {
301
+ function yi(t, n) {
309
302
  const e = new Float32Array(n);
310
303
  let r = 0;
311
304
  for (const i of t)
312
305
  e.set(i, r), r += i.length;
313
306
  return e;
314
307
  }
315
- function er(t, n, e) {
308
+ function tr(t, n, e) {
316
309
  if (e === 3) return t;
317
310
  const r = new Float32Array(n * 3);
318
311
  for (let i = 0; i < n; i += 1) {
@@ -324,23 +317,23 @@ function er(t, n, e) {
324
317
  function yn(t) {
325
318
  if (t.positionItemSize === 3) return;
326
319
  const n = t.positionItemSize;
327
- t.posParts = t.posParts.map((e) => er(e, e.length / n, n)), t.positionItemSize = 3, t.linePositionKind = null;
320
+ t.posParts = t.posParts.map((e) => tr(e, e.length / n, n)), t.positionItemSize = 3, t.linePositionKind = null;
328
321
  }
329
- function yi(t, n) {
322
+ function mi(t, n) {
330
323
  const e = new Uint8Array(n);
331
324
  let r = 0;
332
325
  for (const i of t)
333
326
  e.set(i, r), r += i.length;
334
327
  return e;
335
328
  }
336
- function mi(t, n) {
329
+ function pi(t, n) {
337
330
  return t.map((e) => ({
338
331
  startVertex: e.startVertex + n,
339
332
  vertexCount: e.vertexCount,
340
333
  color: [e.color[0], e.color[1], e.color[2]]
341
334
  }));
342
335
  }
343
- function tr(t) {
336
+ function nr(t) {
344
337
  const n = [];
345
338
  for (const e of t) {
346
339
  const r = n[n.length - 1];
@@ -359,25 +352,25 @@ function tr(t) {
359
352
  }
360
353
  return n;
361
354
  }
362
- function pi(t) {
355
+ function xi(t) {
363
356
  const n = Math.floor(t.length / 3), e = [];
364
357
  let r = 0;
365
358
  for (; r < n; ) {
366
359
  const i = r * 3, s = t[i] ?? 0, a = t[i + 1] ?? 0, o = t[i + 2] ?? 0;
367
- let d = r + 1;
368
- for (; d < n; ) {
369
- const l = d * 3;
370
- if (t[l] !== s || t[l + 1] !== a || t[l + 2] !== o) break;
371
- d += 1;
360
+ let l = r + 1;
361
+ for (; l < n; ) {
362
+ const c = l * 3;
363
+ if (t[c] !== s || t[c + 1] !== a || t[c + 2] !== o) break;
364
+ l += 1;
372
365
  }
373
- e.push({ startVertex: r, vertexCount: d - r, color: [s, a, o] }), r = d;
366
+ e.push({ startVertex: r, vertexCount: l - r, color: [s, a, o] }), r = l;
374
367
  }
375
368
  return e;
376
369
  }
377
- function xi(t, n, e = "u8") {
370
+ function gi(t, n, e = "u8") {
378
371
  if (n <= 0 && t.byteLength === 0)
379
372
  return { pos: new Float32Array(0), count: 0, segments: [] };
380
- const { buffer: r, startOffset: i, endOffset: s } = Ci(t), a = new DataView(r), o = Ur(r, a, i, n, s, e);
373
+ const { buffer: r, startOffset: i, endOffset: s } = wi(t), a = new DataView(r), o = Nr(r, a, i, n, s, e);
381
374
  if (o.offset !== s)
382
375
  throw new U(
383
376
  "E_GROUP_RANGE",
@@ -385,15 +378,15 @@ function xi(t, n, e = "u8") {
385
378
  );
386
379
  return o.chunk;
387
380
  }
388
- function gi(t) {
381
+ function bi(t) {
389
382
  const n = (e) => {
390
- const r = t[e], i = xi(
383
+ const r = t[e], i = gi(
391
384
  r.raw,
392
385
  r.count,
393
386
  r.groupLayerEncoding
394
387
  ), s = he(i, { splitLineweight: e === "line" }), a = /* @__PURE__ */ new Map();
395
388
  for (const o of s)
396
- a.set(bi(o.layerIndex, o.lineweightPx), {
389
+ a.set(Ii(o.layerIndex, o.lineweightPx), {
397
390
  layerIndex: o.layerIndex,
398
391
  ...o.lineweightPx === void 0 ? {} : { lineweightPx: o.lineweightPx },
399
392
  pos: o.pos,
@@ -409,17 +402,17 @@ function gi(t) {
409
402
  dot: n("dot")
410
403
  };
411
404
  }
412
- function bi(t, n) {
405
+ function Ii(t, n) {
413
406
  return n === void 0 ? `${t}:` : `${t}:${n}`;
414
407
  }
415
- function Ii(t, n) {
408
+ function Ci(t, n) {
416
409
  let e = n ? qe(n) : null;
417
410
  for (const r of ["line", "fill", "dot"])
418
411
  for (const i of t[r].values())
419
412
  e = fe(e, i.bbox);
420
413
  return e;
421
414
  }
422
- function Ci(t) {
415
+ function wi(t) {
423
416
  if (t.buffer instanceof ArrayBuffer)
424
417
  return {
425
418
  buffer: t.buffer,
@@ -433,22 +426,22 @@ function Ci(t) {
433
426
  endOffset: n.byteOffset + n.byteLength
434
427
  };
435
428
  }
436
- function wi(t) {
429
+ function vi(t) {
437
430
  const n = t.insertRuntime;
438
431
  if (!n || n.instances.length === 0) return null;
439
432
  const e = [], r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
440
- for (const d of n.variants) {
441
- const l = gi(d), u = ot(l.line), c = ot(l.fill), h = ot(l.dot), y = u.length > 0 || c.length > 0 || h.length > 0;
442
- r.set(d.id, y ? Ii(l, null) : null), y && (i.add(d.id), e.push({
443
- variantId: d.id,
433
+ for (const l of n.variants) {
434
+ const c = bi(l), u = ot(c.line), d = ot(c.fill), h = ot(c.dot), y = u.length > 0 || d.length > 0 || h.length > 0;
435
+ r.set(l.id, y ? Ci(c, null) : null), y && (i.add(l.id), e.push({
436
+ variantId: l.id,
444
437
  line: u,
445
- fill: c,
438
+ fill: d,
446
439
  dot: h
447
440
  }));
448
441
  }
449
- const s = n.instances.filter((d) => i.has(d.variantId));
442
+ const s = n.instances.filter((l) => i.has(l.variantId));
450
443
  if (s.length === 0) return null;
451
- const a = Ri(s, r), o = Bi(e, a);
444
+ const a = Bi(s, r), o = Vi(e, a);
452
445
  return {
453
446
  variants: e,
454
447
  instances: a,
@@ -459,10 +452,10 @@ function wi(t) {
459
452
  function ot(t) {
460
453
  const n = [];
461
454
  for (const e of t.values())
462
- e.count <= 0 || n.push(vi(e));
455
+ e.count <= 0 || n.push(Ri(e));
463
456
  return n;
464
457
  }
465
- function vi(t) {
458
+ function Ri(t) {
466
459
  return {
467
460
  pos: t.pos,
468
461
  col: t.col,
@@ -472,14 +465,14 @@ function vi(t) {
472
465
  bbox: t.bbox
473
466
  };
474
467
  }
475
- function Ri(t, n) {
468
+ function Bi(t, n) {
476
469
  const e = t.length, r = new Uint32Array(e * 3), i = new Float32Array(e * 6), s = new Float32Array(e * 4);
477
470
  for (let a = 0; a < e; a += 1) {
478
- const o = t[a], d = a * 3;
479
- r[d] = o.instanceId, r[d + 1] = o.variantId, r[d + 2] = o.insLayerIdx;
480
- const l = a * 6;
481
- i[l] = o.matA, i[l + 1] = o.matB, i[l + 2] = o.matC, i[l + 3] = o.matD, i[l + 4] = o.tx, i[l + 5] = o.ty;
482
- const u = Nr(n.get(o.variantId) ?? null, o);
471
+ const o = t[a], l = a * 3;
472
+ r[l] = o.instanceId, r[l + 1] = o.variantId, r[l + 2] = o.insLayerIdx;
473
+ const c = a * 6;
474
+ i[c] = o.matA, i[c + 1] = o.matB, i[c + 2] = o.matC, i[c + 3] = o.matD, i[c + 4] = o.tx, i[c + 5] = o.ty;
475
+ const u = zr(n.get(o.variantId) ?? null, o);
483
476
  Ai(s, a * 4, u);
484
477
  }
485
478
  return { meta: r, mats: i, bboxes: s, count: e };
@@ -491,7 +484,7 @@ function Ai(t, n, e) {
491
484
  }
492
485
  t[n] = e.minX, t[n + 1] = e.minY, t[n + 2] = e.maxX, t[n + 3] = e.maxY;
493
486
  }
494
- function Bi(t, n) {
487
+ function Vi(t, n) {
495
488
  let e = n.meta.byteLength + n.mats.byteLength + n.bboxes.byteLength;
496
489
  for (const r of t)
497
490
  e += lt(r.line), e += lt(r.fill), e += lt(r.dot);
@@ -500,27 +493,27 @@ function Bi(t, n) {
500
493
  function lt(t) {
501
494
  return t.reduce((n, e) => n + e.pos.byteLength + e.col.byteLength, 0);
502
495
  }
503
- const mn = 262144, Vi = Number.MAX_SAFE_INTEGER, pn = 524288, Ei = Number.MAX_SAFE_INTEGER, Si = 5e6, ki = 64;
504
- function Ti(t) {
496
+ const mn = 262144, Ei = Number.MAX_SAFE_INTEGER, pn = 524288, Si = Number.MAX_SAFE_INTEGER, ki = 5e6, Ti = 64;
497
+ function Pi(t) {
505
498
  return t.lineCount + t.fillCount + t.dotCount;
506
499
  }
507
- function Pi(t, n) {
508
- return Ti(t) >= Si ? {
500
+ function Li(t, n) {
501
+ return Pi(t) >= ki ? {
509
502
  initial: pn,
510
- steady: n ? pn : Ei
503
+ steady: n ? pn : Si
511
504
  } : {
512
505
  initial: mn,
513
- steady: n ? mn : Vi
506
+ steady: n ? mn : Ei
514
507
  };
515
508
  }
516
- function Li(t) {
517
- const n = !!(t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0), e = t.keepTextsForHiddenInstances === !0, r = t.loadBlocks !== !1, i = t.suppressExpandedInsertGeometry === !0, s = t.maxExpandedInstanceVertices, a = typeof s == "number" && Number.isFinite(s) && s >= 0, o = !!(t.externalVariantBuffers && t.externalVariantBuffers.size > 0), d = t.requiredExternalVariantIds !== void 0, l = t.externalVariantDeltaOnly === !0, u = t.deferExternalVariantGeometry === !0;
518
- if (!n && !e && r && !i && !a && !o && !d && !u && !l)
509
+ function Mi(t) {
510
+ const n = !!(t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0), e = t.keepTextsForHiddenInstances === !0, r = t.loadBlocks !== !1, i = t.suppressExpandedInsertGeometry === !0, s = t.maxExpandedInstanceVertices, a = typeof s == "number" && Number.isFinite(s) && s >= 0, o = !!(t.externalVariantBuffers && t.externalVariantBuffers.size > 0), l = t.requiredExternalVariantIds !== void 0, c = t.externalVariantDeltaOnly === !0, u = t.deferExternalVariantGeometry === !0;
511
+ if (!n && !e && r && !i && !a && !o && !l && !u && !c)
519
512
  return;
520
- const c = {};
521
- return n && (c.hiddenInstanceIds = t.hiddenInstanceIds), e && (c.keepTextsForHiddenInstances = !0), r || (c.loadBlocks = !1), i && (c.suppressExpandedInsertGeometry = !0), a && (c.maxExpandedInstanceVertices = s), o && (c.externalVariantBuffers = t.externalVariantBuffers), d && (c.requiredExternalVariantIds = t.requiredExternalVariantIds), u && (c.deferExternalVariantGeometry = !0), l && (c.externalVariantDeltaOnly = !0), c;
513
+ const d = {};
514
+ return n && (d.hiddenInstanceIds = t.hiddenInstanceIds), e && (d.keepTextsForHiddenInstances = !0), r || (d.loadBlocks = !1), i && (d.suppressExpandedInsertGeometry = !0), a && (d.maxExpandedInstanceVertices = s), o && (d.externalVariantBuffers = t.externalVariantBuffers), l && (d.requiredExternalVariantIds = t.requiredExternalVariantIds), u && (d.deferExternalVariantGeometry = !0), c && (d.externalVariantDeltaOnly = !0), d;
522
515
  }
523
- async function Mi(t) {
516
+ async function Di(t) {
524
517
  if (!t.externalVariantFetchSource || !t.externalVariantGeometryFetchIds || t.externalVariantGeometryFetchIds.size === 0)
525
518
  return t;
526
519
  const n = Array.from(t.externalVariantGeometryFetchIds).filter((i) => {
@@ -541,12 +534,12 @@ async function Mi(t) {
541
534
  externalVariantBuffers: r
542
535
  };
543
536
  }
544
- function Di(t) {
537
+ function Fi(t) {
545
538
  return t.reduce((n, e) => n + e.t.length * 2 + 128, 0);
546
539
  }
547
- async function dt(t, n, e, r) {
540
+ async function ct(t, n, e, r) {
548
541
  if (r()) return 0;
549
- const i = hi(n);
542
+ const i = fi(n);
550
543
  if (!i.length || r()) return 0;
551
544
  const s = i.reduce((a, o) => a + o.count, 0);
552
545
  return await e({
@@ -554,11 +547,11 @@ async function dt(t, n, e, r) {
554
547
  kind: t,
555
548
  layers: i,
556
549
  cost: s,
557
- bytes: Jn(i)
550
+ bytes: er(i)
558
551
  }), s;
559
552
  }
560
- async function Fi(t, n, e) {
561
- return await dt("line", t.line, n, e) + await dt("fill", t.fill, n, e) + await dt("dot", t.dot, n, e);
553
+ async function Oi(t, n, e) {
554
+ return await ct("line", t.line, n, e) + await ct("fill", t.fill, n, e) + await ct("dot", t.dot, n, e);
562
555
  }
563
556
  async function xn(t, n, e) {
564
557
  if (!t.length || e()) return 0;
@@ -567,7 +560,7 @@ async function xn(t, n, e) {
567
560
  type: "text",
568
561
  texts: r,
569
562
  cost: r.length,
570
- bytes: Di(r)
563
+ bytes: Fi(r)
571
564
  }), r.length;
572
565
  }
573
566
  function $t() {
@@ -579,46 +572,46 @@ function $t() {
579
572
  completion: Promise.resolve().then(async () => {
580
573
  if (await Promise.resolve(), r()) return;
581
574
  const s = di(), a = [];
582
- let o = 0, d = !1;
575
+ let o = 0, l = !1;
583
576
  if (r()) return;
584
- const l = await Mi(t);
577
+ const c = await Di(t);
585
578
  if (r()) return;
586
- const u = Ot(l.buffer, Li(l)), c = Pi(
579
+ const u = Ot(c.buffer, Mi(c)), d = Li(
587
580
  u.header,
588
581
  t.externalVariantDeltaOnly === !0
589
582
  );
590
583
  if (r()) return;
591
584
  await n({ type: "header", header: u.header });
592
585
  const h = async () => {
593
- const m = await Fi(s, n, r);
594
- return o = 0, m > 0 && (d = !0), m;
586
+ const m = await Oi(s, n, r);
587
+ return o = 0, m > 0 && (l = !0), m;
595
588
  };
596
589
  try {
597
590
  for (const m of u.chunks) {
598
591
  if (r()) return;
599
592
  if (m.kind === "text") {
600
593
  if (o > 0 && await h(), r()) return;
601
- a.push(m.payload), a.length >= ki && await xn(a, n, r);
594
+ a.push(m.payload), a.length >= Ti && await xn(a, n, r);
602
595
  continue;
603
596
  }
604
597
  const b = he(m.payload, {
605
598
  markLinePositionXy: m.kind === "line"
606
599
  });
607
- o += ui(s[m.kind], b);
608
- const v = d ? c.steady : c.initial;
609
- o >= v && await h();
600
+ o += hi(s[m.kind], b);
601
+ const R = l ? d.steady : d.initial;
602
+ o >= R && await h();
610
603
  }
611
604
  } catch (m) {
612
605
  throw await h(), m;
613
606
  }
614
607
  await h(), await xn(a, n, r), r() || await n({ type: "done" });
615
- const y = Ae(), p = wi(u.header);
616
- p && !r() && await n({
608
+ const y = Be(), x = vi(u.header);
609
+ x && !r() && await n({
617
610
  type: "insertModel",
618
- variants: p.variants,
619
- instances: p.instances,
620
- bytes: p.bytes,
621
- planMs: Ae() - y
611
+ variants: x.variants,
612
+ instances: x.instances,
613
+ bytes: x.bytes,
614
+ planMs: Be() - y
622
615
  });
623
616
  }),
624
617
  cancel() {
@@ -630,10 +623,10 @@ function $t() {
630
623
  }
631
624
  };
632
625
  }
633
- function Oi(t) {
626
+ function _i(t) {
634
627
  return t.reduce((n, e) => n + e.t.length * 2 + 128, 0);
635
628
  }
636
- function _i(t, n) {
629
+ function Gi(t, n) {
637
630
  const e = n ? {
638
631
  type: "parse",
639
632
  useRetainedMainBuffer: !0
@@ -644,16 +637,16 @@ function _i(t, n) {
644
637
  return t.hiddenInstanceIds && t.hiddenInstanceIds.size > 0 && (e.hiddenInstanceIds = Array.from(t.hiddenInstanceIds)), t.keepTextsForHiddenInstances === !0 && (e.keepTextsForHiddenInstances = !0), t.loadBlocks === !1 && (e.loadBlocks = !1), t.suppressExpandedInsertGeometry === !0 && (e.suppressExpandedInsertGeometry = !0), typeof t.maxExpandedInstanceVertices == "number" && Number.isFinite(t.maxExpandedInstanceVertices) && t.maxExpandedInstanceVertices >= 0 && (e.maxExpandedInstanceVertices = t.maxExpandedInstanceVertices), t.externalVariantFetchSource && (e.externalVariantFetchSource = t.externalVariantFetchSource), t.externalVariantBuffers && t.externalVariantBuffers.size > 0 && (e.externalVariantBuffers = Array.from(t.externalVariantBuffers, ([r, i]) => ({
645
638
  variantId: r,
646
639
  buffer: i
647
- }))), t.requiredExternalVariantIds !== void 0 && (e.requiredExternalVariantIds = Array.from(t.requiredExternalVariantIds)), t.externalVariantGeometryFetchIds !== void 0 && (e.externalVariantGeometryFetchIds = Array.from(t.externalVariantGeometryFetchIds)), t.deferExternalVariantGeometry === !0 && (e.deferExternalVariantGeometry = !0), t.externalVariantDeltaOnly === !0 && (e.externalVariantDeltaOnly = !0), e;
640
+ }))), t.requiredExternalVariantIds !== void 0 && (e.requiredExternalVariantIds = Array.from(t.requiredExternalVariantIds)), t.externalVariantGeometryFetchIds !== void 0 && (e.externalVariantGeometryFetchIds = Array.from(t.externalVariantGeometryFetchIds)), t.deferExternalVariantGeometry === !0 && (e.deferExternalVariantGeometry = !0), t.externalVariantDeltaOnly === !0 && (e.externalVariantDeltaOnly = !0), t.cacheDocument === !0 && (e.cacheDocument = !0), e;
648
641
  }
649
- function Gi(t, n) {
642
+ function Ui(t, n) {
650
643
  const e = n ? [] : [t.buffer];
651
644
  if (t.externalVariantBuffers && t.externalVariantBuffers.size > 0)
652
645
  for (const r of t.externalVariantBuffers.values())
653
646
  e.push(r);
654
647
  return e;
655
648
  }
656
- function Ui(t) {
649
+ function Ni(t) {
657
650
  const n = new Error(t.message);
658
651
  return typeof t.code == "string" && (n.code = t.code), n;
659
652
  }
@@ -664,79 +657,79 @@ function nt(t) {
664
657
  return typeof t == "function" || typeof Worker == "function" && typeof globalThis.document < "u";
665
658
  }
666
659
  function jt(t = {}) {
667
- return nr(t, !1);
660
+ return rr(t, !1);
668
661
  }
669
- function Ni(t = {}) {
670
- return nr(t, !0);
662
+ function zi(t = {}) {
663
+ return rr(t, !0);
671
664
  }
672
- function nr(t, n) {
665
+ function rr(t, n) {
673
666
  let e = null, r = !1, i = null, s = !1;
674
667
  const a = () => {
675
- var l;
668
+ var c;
676
669
  if (s)
677
670
  throw new Error("Geo prepare worker adapter is disposed");
678
671
  if (i)
679
672
  throw new Error("Geo prepare worker adapter already has an active run");
680
673
  if (n && e)
681
674
  return e;
682
- const d = ((l = t.workerFactory) == null ? void 0 : l.call(t)) ?? (t.workerUrl ? new Worker(t.workerUrl, { type: "module" }) : new Worker(new URL(
675
+ const l = ((c = t.workerFactory) == null ? void 0 : c.call(t)) ?? (t.workerUrl ? new Worker(t.workerUrl, { type: "module" }) : new Worker(new URL(
683
676
  /* @vite-ignore */
684
677
  "" + new URL("workers/geo-prepare.worker.js", import.meta.url).href,
685
678
  import.meta.url
686
679
  ), { type: "module" }));
687
- return n && (e = d, r = !1), d;
688
- }, o = (d, l) => {
689
- i = null, !(n && l && !s) && (e === d && (e = null, r = !1), d.terminate());
680
+ return n && (e = l, r = !1), l;
681
+ }, o = (l, c) => {
682
+ i = null, !(n && c && !s) && (e === l && (e = null, r = !1), l.terminate());
690
683
  };
691
684
  return {
692
685
  get mainBufferReuseReady() {
693
686
  return n && e !== null && r;
694
687
  },
695
- start(d, l) {
696
- const u = a(), c = n && d.externalVariantDeltaOnly === !0 && e === u && r;
697
- let h = !1, y = !1, p = !1, m = !1, b = Promise.resolve(), v, I, w, T;
698
- const A = new Promise((C, L) => {
699
- v = C, I = L;
700
- }), B = new Promise((C, L) => {
688
+ start(l, c) {
689
+ const u = a(), d = n && l.externalVariantDeltaOnly === !0 && e === u && r;
690
+ let h = !1, y = !1, x = !1, m = !1, b = Promise.resolve(), R, I, w, T;
691
+ const B = new Promise((C, L) => {
692
+ R = C, I = L;
693
+ }), A = new Promise((C, L) => {
701
694
  w = C, T = L;
702
695
  });
703
- B.catch(() => {
696
+ A.catch(() => {
704
697
  });
705
698
  const E = () => {
706
699
  typeof u.removeEventListener == "function" && (u.removeEventListener("message", _), u.removeEventListener("error", X), u.removeEventListener("messageerror", N));
707
700
  }, S = (C) => {
708
701
  m || (m = !0, E(), o(u, C));
709
702
  }, P = () => {
710
- h || (h = !0, v());
703
+ h || (h = !0, R());
711
704
  }, O = () => {
712
705
  y || (y = !0, w());
713
- }, W = (C) => {
706
+ }, K = (C) => {
714
707
  const L = gn(C);
715
- p = !1, h || (h = !0, I(L)), y || (y = !0, T(L));
708
+ x = !1, h || (h = !0, I(L)), y || (y = !0, T(L));
716
709
  }, M = async (C) => {
717
710
  if (!y) {
718
711
  if (C.type === "error")
719
- throw Ui(C);
712
+ throw Ni(C);
720
713
  if (C.type === "complete") {
721
- p = !0, n && (r = !0), P(), O();
714
+ x = !0, n && (r = !0), P(), O();
722
715
  return;
723
716
  }
724
717
  if (C.type === "header") {
725
- await l({ type: "header", header: C.header });
718
+ await c({ type: "header", header: C.header });
726
719
  return;
727
720
  }
728
721
  if (C.type === "geometry") {
729
- await l({
722
+ await c({
730
723
  type: "geometry",
731
724
  kind: C.kind,
732
725
  layers: C.layers,
733
726
  cost: C.cost,
734
- bytes: Jn(C.layers)
727
+ bytes: er(C.layers)
735
728
  });
736
729
  return;
737
730
  }
738
731
  if (C.type === "insertModel") {
739
- await l({
732
+ await c({
740
733
  type: "insertModel",
741
734
  variants: C.variants,
742
735
  instances: C.instances,
@@ -746,41 +739,41 @@ function nr(t, n) {
746
739
  return;
747
740
  }
748
741
  if (C.type === "text") {
749
- await l({
742
+ await c({
750
743
  type: "text",
751
744
  texts: C.texts,
752
745
  cost: C.cost,
753
- bytes: Oi(C.texts)
746
+ bytes: _i(C.texts)
754
747
  });
755
748
  return;
756
749
  }
757
- await l({ type: "done" }), P();
750
+ await c({ type: "done" }), P();
758
751
  }
759
752
  }, _ = (C) => {
760
753
  b = b.then(() => M(C.data)), b.catch((L) => {
761
- W(L), S(!1);
754
+ K(L), S(!1);
762
755
  });
763
756
  }, X = (C) => {
764
- W(new Error(C.message || "Geo prepare worker failed")), S(!1);
757
+ K(new Error(C.message || "Geo prepare worker failed")), S(!1);
765
758
  }, N = () => {
766
- W(new Error("Geo prepare worker message decode failed")), S(!1);
759
+ K(new Error("Geo prepare worker message decode failed")), S(!1);
767
760
  };
768
761
  u.addEventListener("message", _), u.addEventListener("error", X), u.addEventListener("messageerror", N), i = {
769
762
  abort: () => {
770
- W(new Error("Geo prepare worker run aborted")), S(!1);
763
+ K(new Error("Geo prepare worker run aborted")), S(!1);
771
764
  }
772
765
  };
773
766
  try {
774
767
  u.postMessage(
775
- _i(d, c),
776
- Gi(d, c)
768
+ Gi(l, d),
769
+ Ui(l, d)
777
770
  );
778
771
  } catch (C) {
779
- throw W(C), S(!1), gn(C);
772
+ throw K(C), S(!1), gn(C);
780
773
  }
781
774
  return {
782
- completion: A,
783
- backgroundCompletion: B,
775
+ completion: B,
776
+ backgroundCompletion: A,
784
777
  grant(C) {
785
778
  y || u.postMessage({ type: "grant", ...C });
786
779
  },
@@ -788,18 +781,18 @@ function nr(t, n) {
788
781
  y || (O(), u.postMessage({ type: "cancel" }));
789
782
  },
790
783
  dispose() {
791
- O(), S(p && y);
784
+ O(), S(x && y);
792
785
  }
793
786
  };
794
787
  },
795
788
  dispose() {
796
789
  s = !0, i == null || i.abort(), i = null;
797
- const d = e;
798
- e = null, r = !1, d == null || d.terminate();
790
+ const l = e;
791
+ e = null, r = !1, l == null || l.terminate();
799
792
  }
800
793
  };
801
794
  }
802
- async function zi(t) {
795
+ async function Hi(t) {
803
796
  if (!t.ok)
804
797
  throw new U("E_PACK_HTTP", t.statusText || `Pack request failed with HTTP ${t.status}`);
805
798
  return t.arrayBuffer();
@@ -813,9 +806,9 @@ async function Zt(t) {
813
806
  return t.file.arrayBuffer();
814
807
  case "url":
815
808
  try {
816
- return await zi(await fetch(t.url, { signal: t.signal }));
809
+ return await Hi(await fetch(t.url, { signal: t.signal }));
817
810
  } catch (e) {
818
- throw e instanceof U || e instanceof Error && e.name === "AbortError" ? e : (n = t.signal) != null && n.aborted ? K(t.signal.reason, "CAD pack request aborted") : new U("E_PACK_NETWORK", `Pack request failed: ${e.message}`);
811
+ throw e instanceof U || e instanceof Error && e.name === "AbortError" ? e : (n = t.signal) != null && n.aborted ? W(t.signal.reason, "CAD pack request aborted") : new U("E_PACK_NETWORK", `Pack request failed: ${e.message}`);
819
812
  }
820
813
  default: {
821
814
  const e = t;
@@ -824,7 +817,7 @@ async function Zt(t) {
824
817
  }
825
818
  }
826
819
  var me, se, pe, ae;
827
- class Hi {
820
+ class qi {
828
821
  constructor(n) {
829
822
  k(this, me, []);
830
823
  k(this, se, []);
@@ -866,13 +859,13 @@ function bn() {
866
859
  t = r, n = i;
867
860
  }), resolve: t, reject: n };
868
861
  }
869
- function qi(t) {
862
+ function Ki(t) {
870
863
  return t instanceof Error ? t : new Error(String(t));
871
864
  }
872
- function ct(t) {
865
+ function dt(t) {
873
866
  return t === void 0 ? void 0 : new Set(t);
874
867
  }
875
- function Ki(t) {
868
+ function Wi(t) {
876
869
  return {
877
870
  highWatermarkBytes: (t == null ? void 0 : t.highWatermarkBytes) ?? Wt,
878
871
  lowWatermarkBytes: (t == null ? void 0 : t.lowWatermarkBytes) ?? Xt,
@@ -880,15 +873,15 @@ function Ki(t) {
880
873
  initialTextCredits: (t == null ? void 0 : t.initialTextCredits) ?? Qt
881
874
  };
882
875
  }
883
- function Wi(t) {
876
+ function Xi(t) {
884
877
  if (t.positionItemSize === 2) return t.pos;
885
878
  const n = new Float32Array(t.count * 2);
886
879
  for (let e = 0; e < t.count; e += 1)
887
880
  n[e * 2] = t.pos[e * 3] ?? 0, n[e * 2 + 1] = t.pos[e * 3 + 1] ?? 0;
888
881
  return n;
889
882
  }
890
- function Xi(t) {
891
- return (t.colorRuns ?? Yi(t)).map((e) => ({
883
+ function Yi(t) {
884
+ return (t.colorRuns ?? Qi(t)).map((e) => ({
892
885
  startVertex: e.startVertex,
893
886
  vertexCount: e.vertexCount,
894
887
  color: [e.color[0], e.color[1], e.color[2]],
@@ -896,24 +889,24 @@ function Xi(t) {
896
889
  ...t.lineweightPx === void 0 ? {} : { lineweightPx: t.lineweightPx }
897
890
  }));
898
891
  }
899
- function Yi(t) {
892
+ function Qi(t) {
900
893
  return t.count <= 0 ? [] : [{
901
894
  startVertex: 0,
902
895
  vertexCount: t.count,
903
896
  color: [t.col[0] ?? 0, t.col[1] ?? 0, t.col[2] ?? 0]
904
897
  }];
905
898
  }
906
- function Qi(t) {
899
+ function $i(t) {
907
900
  const n = t.layerIndex <= 255 ? new Uint8Array(t.count).fill(t.layerIndex) : new Uint16Array(t.count).fill(t.layerIndex);
908
901
  return {
909
- pos: Wi(t),
902
+ pos: Xi(t),
910
903
  col: t.col,
911
904
  lay: n,
912
905
  count: t.count,
913
- segments: Xi(t)
906
+ segments: Yi(t)
914
907
  };
915
908
  }
916
- function $i(t) {
909
+ function ji(t) {
917
910
  const n = [];
918
911
  for (let e = 0; e < t.count; e += 1) {
919
912
  const r = e * 3, i = e * 6;
@@ -941,7 +934,7 @@ function ut(t) {
941
934
  ...t.bbox === void 0 ? {} : { bounds: t.bbox }
942
935
  };
943
936
  }
944
- function ji(t) {
937
+ function Zi(t) {
945
938
  return {
946
939
  variantId: t.variantId,
947
940
  line: t.line.map(ut),
@@ -949,14 +942,14 @@ function ji(t) {
949
942
  dot: t.dot.map(ut)
950
943
  };
951
944
  }
952
- var F, Be, Ve, Ee, xe, ne, q, ge, re, be, Se, Q, Ie, ke, Te, z, Pe, Le, R, rr, ir, sr, ce, Bt, ar, Re, Vt, Ge, Ue, Ne;
953
- class Zi {
945
+ var F, Ae, Ve, Ee, xe, ne, q, ge, re, be, Se, Q, Ie, ke, Te, z, Pe, Le, v, ir, sr, ar, de, At, or, Re, Vt, Ge, Ue, Ne;
946
+ class Ji {
954
947
  constructor(n, e) {
955
- k(this, R);
948
+ k(this, v);
956
949
  f(this, "events");
957
950
  f(this, "ready");
958
951
  k(this, F);
959
- k(this, Be);
952
+ k(this, Ae);
960
953
  k(this, Ve);
961
954
  k(this, Ee, new AbortController());
962
955
  k(this, xe, bn());
@@ -972,51 +965,51 @@ class Zi {
972
965
  k(this, Te, !1);
973
966
  k(this, z, !1);
974
967
  k(this, Pe, !1);
975
- k(this, Le, Ae());
968
+ k(this, Le, Be());
976
969
  G(this, F, e);
977
970
  const r = tt(n, g(this, Ee).signal);
978
- G(this, Be, r.source), G(this, Ve, r.sourceSignal), G(this, re, new Zn(Ki(e.flowControl))), G(this, q, new Hi((i) => V(this, R, ar).call(this, i))), this.events = g(this, q), this.ready = g(this, xe).promise, this.ready.catch(() => {
971
+ G(this, Ae, r.source), G(this, Ve, r.sourceSignal), G(this, re, new Jn(Wi(e.flowControl))), G(this, q, new qi((i) => V(this, v, or).call(this, i))), this.events = g(this, q), this.ready = g(this, xe).promise, this.ready.catch(() => {
979
972
  }), g(this, ne).promise.catch(() => {
980
- }), V(this, R, Vt).call(this, e.signal), V(this, R, Vt).call(this, g(this, Ve)), g(this, z) || V(this, R, rr).call(this);
973
+ }), V(this, v, Vt).call(this, e.signal), V(this, v, Vt).call(this, g(this, Ve)), g(this, z) || V(this, v, ir).call(this);
981
974
  }
982
975
  abort(n) {
983
- g(this, z) || V(this, R, Ge).call(this, K(n, "CAD load session aborted"));
976
+ g(this, z) || V(this, v, Ge).call(this, W(n, "CAD load session aborted"));
984
977
  }
985
978
  dispose() {
986
979
  var n;
987
980
  if (!g(this, Pe)) {
988
981
  if (G(this, Pe, !0), !g(this, z)) {
989
- V(this, R, Ge).call(this, K("CAD load session disposed"));
982
+ V(this, v, Ge).call(this, W("CAD load session disposed"));
990
983
  return;
991
984
  }
992
- (n = g(this, Q)) == null || n.dispose(), g(this, q).clear(), V(this, R, Ne).call(this);
985
+ (n = g(this, Q)) == null || n.dispose(), g(this, q).clear(), V(this, v, Ne).call(this);
993
986
  }
994
987
  }
995
988
  }
996
- F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), xe = new WeakMap(), ne = new WeakMap(), q = new WeakMap(), ge = new WeakMap(), re = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ke = new WeakMap(), Te = new WeakMap(), z = new WeakMap(), Pe = new WeakMap(), Le = new WeakMap(), R = new WeakSet(), rr = async function() {
989
+ F = new WeakMap(), Ae = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), xe = new WeakMap(), ne = new WeakMap(), q = new WeakMap(), ge = new WeakMap(), re = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ke = new WeakMap(), Te = new WeakMap(), z = new WeakMap(), Pe = new WeakMap(), Le = new WeakMap(), v = new WeakSet(), ir = async function() {
997
990
  var n, e;
998
991
  try {
999
992
  const r = await Promise.race([
1000
- Zt(g(this, Be)),
993
+ Zt(g(this, Ae)),
1001
994
  g(this, ne).promise
1002
995
  ]);
1003
996
  if (g(this, z)) return;
1004
997
  G(this, ke, r.byteLength);
1005
- const s = V(this, R, ir).call(this).start({
998
+ const s = V(this, v, sr).call(this).start({
1006
999
  buffer: r,
1007
- hiddenInstanceIds: ct(g(this, F).hiddenInstanceIds),
1000
+ hiddenInstanceIds: dt(g(this, F).hiddenInstanceIds),
1008
1001
  keepTextsForHiddenInstances: g(this, F).keepTextsForHiddenInstances || void 0,
1009
1002
  loadBlocks: g(this, F).loadBlocks,
1010
1003
  suppressExpandedInsertGeometry: g(this, F).loadBlocks !== !1,
1011
1004
  maxExpandedInstanceVertices: g(this, F).maxExpandedInstanceVertices,
1012
1005
  externalVariantFetchSource: g(this, F).externalVariantFetchSource,
1013
1006
  externalVariantBuffers: g(this, F).externalVariantBuffers,
1014
- requiredExternalVariantIds: ct(g(this, F).requiredExternalVariantIds),
1015
- externalVariantGeometryFetchIds: ct(g(this, F).externalVariantGeometryFetchIds)
1016
- }, (o) => V(this, R, sr).call(this, o));
1007
+ requiredExternalVariantIds: dt(g(this, F).requiredExternalVariantIds),
1008
+ externalVariantGeometryFetchIds: dt(g(this, F).externalVariantGeometryFetchIds)
1009
+ }, (o) => V(this, v, ar).call(this, o));
1017
1010
  if (G(this, Q, s), s.completion.catch(() => {
1018
1011
  }), (n = s.backgroundCompletion) == null || n.catch(() => {
1019
- }), V(this, R, Re).call(this, g(this, re).takeInitialGrant()), await Promise.race([s.completion, g(this, ne).promise]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, g(this, ne).promise]), g(this, z)) return;
1012
+ }), V(this, v, Re).call(this, g(this, re).takeInitialGrant()), await Promise.race([s.completion, g(this, ne).promise]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, g(this, ne).promise]), g(this, z)) return;
1020
1013
  if (!g(this, Te))
1021
1014
  throw new Error("CAD loader adapter completed without a done event");
1022
1015
  if (!g(this, Ie))
@@ -1026,28 +1019,28 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1026
1019
  chunks: g(this, ge),
1027
1020
  rawBytes: g(this, ke)
1028
1021
  };
1029
- G(this, z, !0), g(this, q).push({ event: { type: "ready", document: a } }), g(this, q).close(), g(this, xe).resolve(a), V(this, R, Ne).call(this);
1022
+ G(this, z, !0), g(this, q).push({ event: { type: "ready", document: a } }), g(this, q).close(), g(this, xe).resolve(a), V(this, v, Ne).call(this);
1030
1023
  } catch (r) {
1031
- g(this, z) || V(this, R, Ge).call(this, qi(r));
1024
+ g(this, z) || V(this, v, Ge).call(this, Ki(r));
1032
1025
  } finally {
1033
- (e = g(this, Q)) == null || e.dispose(), V(this, R, Ue).call(this);
1026
+ (e = g(this, Q)) == null || e.dispose(), V(this, v, Ue).call(this);
1034
1027
  }
1035
- }, ir = function() {
1028
+ }, sr = function() {
1036
1029
  return g(this, F).preferWorker !== !1 && nt(g(this, F).workerFactory) ? jt({
1037
1030
  workerUrl: g(this, F).workerUrl,
1038
1031
  workerFactory: g(this, F).workerFactory
1039
1032
  }) : $t();
1040
- }, sr = async function(n) {
1033
+ }, ar = async function(n) {
1041
1034
  if (!g(this, z)) {
1042
1035
  if (n.type === "header") {
1043
1036
  G(this, Ie, n.header), g(this, q).push({
1044
1037
  event: { type: "meta", meta: n.header, header: n.header }
1045
- }), await V(this, R, ce).call(this);
1038
+ }), await V(this, v, de).call(this);
1046
1039
  return;
1047
1040
  }
1048
1041
  if (n.type === "geometry") {
1049
1042
  const e = n.layers.map((r) => {
1050
- const i = Qi(r);
1043
+ const i = $i(r);
1051
1044
  return g(this, ge).push({ kind: n.kind, payload: i }), {
1052
1045
  event: {
1053
1046
  type: "geometry",
@@ -1059,40 +1052,40 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1059
1052
  }
1060
1053
  };
1061
1054
  });
1062
- await V(this, R, Bt).call(this, e, "geometry", n.bytes), await V(this, R, ce).call(this);
1055
+ await V(this, v, At).call(this, e, "geometry", n.bytes), await V(this, v, de).call(this);
1063
1056
  return;
1064
1057
  }
1065
1058
  if (n.type === "text") {
1066
1059
  const e = n.texts.map((r) => (g(this, ge).push({ kind: "text", payload: r }), { event: { type: "text", chunk: r } }));
1067
- await V(this, R, Bt).call(this, e, "text", n.bytes), await V(this, R, ce).call(this);
1060
+ await V(this, v, At).call(this, e, "text", n.bytes), await V(this, v, de).call(this);
1068
1061
  return;
1069
1062
  }
1070
1063
  if (n.type === "insertModel") {
1071
1064
  g(this, q).push({
1072
1065
  event: {
1073
1066
  type: "insert",
1074
- instances: $i(n.instances),
1075
- variants: n.variants.map(ji)
1067
+ instances: ji(n.instances),
1068
+ variants: n.variants.map(Zi)
1076
1069
  }
1077
- }), await V(this, R, ce).call(this);
1070
+ }), await V(this, v, de).call(this);
1078
1071
  return;
1079
1072
  }
1080
- G(this, Te, !0), await V(this, R, ce).call(this);
1073
+ G(this, Te, !0), await V(this, v, de).call(this);
1081
1074
  }
1082
- }, ce = async function() {
1075
+ }, de = async function() {
1083
1076
  const n = Math.max(0, (g(this, F).frameBudgetMs ?? qt) - (g(this, F).frameReserveMs ?? Kt));
1084
1077
  typeof performance > "u" || typeof performance.now != "function" || performance.now() - g(this, Le) < n || (await new Promise((e) => {
1085
1078
  typeof globalThis.requestAnimationFrame == "function" ? globalThis.requestAnimationFrame(() => e()) : setTimeout(e, 0);
1086
1079
  }), G(this, Le, performance.now()));
1087
- }, Bt = function(n, e, r) {
1080
+ }, At = function(n, e, r) {
1088
1081
  if (n.length === 0) {
1089
- V(this, R, Re).call(this, e === "geometry" ? { geometryCredits: 1, textCredits: 0 } : { geometryCredits: 0, textCredits: 1 });
1082
+ V(this, v, Re).call(this, e === "geometry" ? { geometryCredits: 1, textCredits: 0 } : { geometryCredits: 0, textCredits: 1 });
1090
1083
  return;
1091
1084
  }
1092
1085
  const i = { kind: e, bytes: Math.max(0, r), creditReplaced: !1 };
1093
1086
  g(this, re).onQueued(e, i.bytes);
1094
1087
  const s = g(this, re).onConsumed(e, 0);
1095
- if (i.creditReplaced = V(this, R, Re).call(this, s), n.forEach((a, o) => {
1088
+ if (i.creditReplaced = V(this, v, Re).call(this, s), n.forEach((a, o) => {
1096
1089
  g(this, q).push({
1097
1090
  ...a,
1098
1091
  batch: i,
@@ -1102,10 +1095,10 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1102
1095
  return new Promise((a) => {
1103
1096
  g(this, be).add(a);
1104
1097
  });
1105
- }, ar = function(n) {
1098
+ }, or = function(n) {
1106
1099
  if (!n.batch || !n.accountsBatch) return;
1107
1100
  const e = g(this, re).onConsumed(n.batch.kind, n.batch.bytes);
1108
- n.batch.creditReplaced || (n.batch.creditReplaced = V(this, R, Re).call(this, e)), e.paused || V(this, R, Ue).call(this);
1101
+ n.batch.creditReplaced || (n.batch.creditReplaced = V(this, v, Re).call(this, e)), e.paused || V(this, v, Ue).call(this);
1109
1102
  }, Re = function(n) {
1110
1103
  var e;
1111
1104
  return !((e = g(this, Q)) != null && e.grant) || g(this, z) || n.geometryCredits <= 0 && n.textCredits <= 0 ? !1 : (g(this, Q).grant({
@@ -1122,7 +1115,7 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1122
1115
  n.addEventListener("abort", e, { once: !0 }), g(this, Se).push(() => n.removeEventListener("abort", e));
1123
1116
  }, Ge = function(n) {
1124
1117
  var e, r, i;
1125
- g(this, z) || (G(this, z, !0), g(this, Ee).abort(n), (r = (e = g(this, Q)) == null ? void 0 : e.cancel) == null || r.call(e), (i = g(this, Q)) == null || i.dispose(), g(this, ne).reject(n), g(this, xe).reject(n), g(this, q).push({ event: { type: "error", error: n } }), g(this, q).close(), V(this, R, Ue).call(this), V(this, R, Ne).call(this));
1118
+ g(this, z) || (G(this, z, !0), g(this, Ee).abort(n), (r = (e = g(this, Q)) == null ? void 0 : e.cancel) == null || r.call(e), (i = g(this, Q)) == null || i.dispose(), g(this, ne).reject(n), g(this, xe).reject(n), g(this, q).push({ event: { type: "error", error: n } }), g(this, q).close(), V(this, v, Ue).call(this), V(this, v, Ne).call(this));
1126
1119
  }, Ue = function() {
1127
1120
  for (const n of g(this, be)) n();
1128
1121
  g(this, be).clear();
@@ -1130,9 +1123,9 @@ F = new WeakMap(), Be = new WeakMap(), Ve = new WeakMap(), Ee = new WeakMap(), x
1130
1123
  for (const n of g(this, Se).splice(0)) n();
1131
1124
  };
1132
1125
  function Vo(t, n = {}) {
1133
- return new Zi(t, n);
1126
+ return new Ji(t, n);
1134
1127
  }
1135
- class Ji {
1128
+ class es {
1136
1129
  constructor(n) {
1137
1130
  f(this, "queue", []);
1138
1131
  f(this, "budgetMs");
@@ -1169,13 +1162,13 @@ class Ji {
1169
1162
  };
1170
1163
  }
1171
1164
  }
1172
- function es(t) {
1165
+ function ts(t) {
1173
1166
  return t.lineCount + t.fillCount + t.dotCount;
1174
1167
  }
1175
- function ts(t) {
1168
+ function ns(t) {
1176
1169
  return t instanceof Error ? t : new Error(String(t));
1177
1170
  }
1178
- class ns {
1171
+ class rs {
1179
1172
  constructor(n) {
1180
1173
  f(this, "headerSeen", !1);
1181
1174
  f(this, "headerTexts", []);
@@ -1183,7 +1176,7 @@ class ns {
1183
1176
  }
1184
1177
  initFromHeader(n) {
1185
1178
  this.node._initFromHeader(n), this.node.updateAutoQualityContext({
1186
- visibleVertexCount: es(n),
1179
+ visibleVertexCount: ts(n),
1187
1180
  zoom: 1
1188
1181
  }), this.headerSeen = !0, this.headerTexts = n.texts;
1189
1182
  }
@@ -1203,9 +1196,9 @@ class ns {
1203
1196
  try {
1204
1197
  if (!this.headerSeen)
1205
1198
  throw new Error("Geo loader pipeline completed without header");
1206
- zr() && Hr("Boundary-3:header->node", this.headerTexts, this.node._collectTextUserDataForDebug()), await this.node._finalizeIncrementally(n);
1199
+ Hr() && qr("Boundary-3:header->node", this.headerTexts, this.node._collectTextUserDataForDebug()), await this.node._finalizeIncrementally(n);
1207
1200
  } catch (e) {
1208
- const r = ts(e);
1201
+ const r = ns(e);
1209
1202
  throw this.fail(r), r;
1210
1203
  }
1211
1204
  }
@@ -1216,17 +1209,17 @@ class ns {
1216
1209
  function In(t) {
1217
1210
  return t instanceof Error ? t : new Error(String(t));
1218
1211
  }
1219
- function rs() {
1212
+ function is() {
1220
1213
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1221
1214
  }
1222
- function is(t) {
1215
+ function ss(t) {
1223
1216
  return {
1224
1217
  frameBudgetMs: (t == null ? void 0 : t.frameBudgetMs) ?? qt,
1225
1218
  reserveMs: (t == null ? void 0 : t.reserveMs) ?? Kt,
1226
- now: (t == null ? void 0 : t.now) ?? rs
1219
+ now: (t == null ? void 0 : t.now) ?? is
1227
1220
  };
1228
1221
  }
1229
- function ss(t) {
1222
+ function as(t) {
1230
1223
  return {
1231
1224
  highWatermarkBytes: (t == null ? void 0 : t.highWatermarkBytes) ?? Wt,
1232
1225
  lowWatermarkBytes: (t == null ? void 0 : t.lowWatermarkBytes) ?? Xt,
@@ -1234,7 +1227,7 @@ function ss(t) {
1234
1227
  initialTextCredits: (t == null ? void 0 : t.initialTextCredits) ?? Qt
1235
1228
  };
1236
1229
  }
1237
- function as() {
1230
+ function os() {
1238
1231
  return new Promise((t) => {
1239
1232
  if (typeof globalThis.requestAnimationFrame == "function") {
1240
1233
  globalThis.requestAnimationFrame(() => t());
@@ -1244,23 +1237,23 @@ function as() {
1244
1237
  });
1245
1238
  }
1246
1239
  async function ht(t) {
1247
- await as(), await (t == null ? void 0 : t());
1240
+ await os(), await (t == null ? void 0 : t());
1248
1241
  }
1249
- async function or(t) {
1242
+ async function lr(t) {
1250
1243
  var tn, nn;
1251
- const { node: n } = t, e = new ns(n), r = t.appendExternalVariantDelta === !0, i = new Ji(is(t.scheduler));
1252
- let s = null, a = !0, o = null, d = !1, l = !1, u = !1, c = null, h = !1, y = null, p = null, m = null, b = !1;
1253
- const v = [], I = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), T = () => {
1254
- var x;
1255
- b || (b = !0, (x = t.onFirstRenderableAppend) == null || x.call(t));
1256
- }, A = new Promise((x, D) => {
1244
+ const { node: n } = t, e = new rs(n), r = t.appendExternalVariantDelta === !0, i = new es(ss(t.scheduler));
1245
+ let s = null, a = !0, o = null, l = !1, c = !1, u = !1, d = null, h = !1, y = null, x = null, m = null, b = !1;
1246
+ const R = [], I = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), T = () => {
1247
+ var p;
1248
+ b || (b = !0, (p = t.onFirstRenderableAppend) == null || p.call(t));
1249
+ }, B = new Promise((p, D) => {
1257
1250
  y = D;
1258
1251
  });
1259
- A.catch(() => {
1252
+ B.catch(() => {
1260
1253
  });
1261
- const B = (x) => {
1254
+ const A = (p) => {
1262
1255
  var oe;
1263
- const D = In(x);
1256
+ const D = In(p);
1264
1257
  if (!u) {
1265
1258
  u = !0, (oe = s == null ? void 0 : s.cancel) == null || oe.call(s);
1266
1259
  for (const j of I)
@@ -1269,52 +1262,52 @@ async function or(t) {
1269
1262
  }), y == null || y(D);
1270
1263
  }
1271
1264
  return D;
1272
- }, E = (x) => (w.add(x), x.then(
1265
+ }, E = (p) => (w.add(p), p.then(
1273
1266
  () => {
1274
- w.delete(x);
1267
+ w.delete(p);
1275
1268
  },
1276
1269
  () => {
1277
- w.delete(x);
1270
+ w.delete(p);
1278
1271
  }
1279
- ), x.catch(() => {
1280
- }), x), S = (x) => ({
1281
- geometryCredits: x.geometryCredits,
1282
- textCredits: x.textCredits
1283
- }), P = (x, D) => {
1284
- u || !(s != null && s.grant) || D && x.geometryCredits <= 0 && x.textCredits <= 0 || s.grant(S(x));
1285
- }, O = (x) => {
1286
- !o || x.flowQueued || (o.onQueued(x.kind, x.bytes), x.flowQueued = !0);
1287
- }, W = () => {
1288
- for (const x of I)
1289
- O(x);
1290
- }, M = (x, D) => {
1291
- if (!x.settled) {
1292
- if (x.settled = !0, I.delete(x), D) {
1293
- x.reject(D);
1272
+ ), p.catch(() => {
1273
+ }), p), S = (p) => ({
1274
+ geometryCredits: p.geometryCredits,
1275
+ textCredits: p.textCredits
1276
+ }), P = (p, D) => {
1277
+ u || !(s != null && s.grant) || D && p.geometryCredits <= 0 && p.textCredits <= 0 || s.grant(S(p));
1278
+ }, O = (p) => {
1279
+ !o || p.flowQueued || (o.onQueued(p.kind, p.bytes), p.flowQueued = !0);
1280
+ }, K = () => {
1281
+ for (const p of I)
1282
+ O(p);
1283
+ }, M = (p, D) => {
1284
+ if (!p.settled) {
1285
+ if (p.settled = !0, I.delete(p), D) {
1286
+ p.reject(D);
1294
1287
  return;
1295
1288
  }
1296
- x.resolve();
1289
+ p.resolve();
1297
1290
  }
1298
- }, _ = () => (h = !0, c || (c = Promise.resolve().then(async () => {
1291
+ }, _ = () => (h = !0, d || (d = Promise.resolve().then(async () => {
1299
1292
  for (; !u; ) {
1300
1293
  for (h = !1; !u && i.hasPending(); ) {
1301
- const x = await i.runFrame();
1302
- !u && x.exhausted && await ht(t.onYield);
1294
+ const p = await i.runFrame();
1295
+ !u && p.exhausted && await ht(t.onYield);
1303
1296
  }
1304
1297
  if (!h && !i.hasPending())
1305
1298
  break;
1306
1299
  }
1307
- }).catch((x) => {
1308
- throw B(x);
1300
+ }).catch((p) => {
1301
+ throw A(p);
1309
1302
  }).finally(() => {
1310
- c = null, !u && h && i.hasPending() && _();
1311
- }), c.catch(() => {
1312
- }), c)), X = (x, D, oe) => {
1303
+ d = null, !u && h && i.hasPending() && _();
1304
+ }), d.catch(() => {
1305
+ }), d)), X = (p, D, oe) => {
1313
1306
  let j = null, rn = null;
1314
1307
  const le = new Promise((Me, rt) => {
1315
1308
  j = Me, rn = rt;
1316
1309
  }), Z = {
1317
- kind: x,
1310
+ kind: p,
1318
1311
  bytes: D,
1319
1312
  append: oe,
1320
1313
  flowQueued: !1,
@@ -1332,94 +1325,94 @@ async function or(t) {
1332
1325
  ), le.catch(() => {
1333
1326
  }), O(Z), i.enqueue(() => {
1334
1327
  if (u) {
1335
- M(Z, B(new Error("Geo loader pipeline failed before append task ran")));
1328
+ M(Z, A(new Error("Geo loader pipeline failed before append task ran")));
1336
1329
  return;
1337
1330
  }
1338
1331
  try {
1339
1332
  Z.append(), o && Z.flowQueued && P(o.onConsumed(Z.kind, Z.bytes), !0), M(Z);
1340
1333
  } catch (Me) {
1341
1334
  const rt = In(Me);
1342
- throw M(Z, rt), B(Me);
1335
+ throw M(Z, rt), A(Me);
1343
1336
  }
1344
1337
  }), _(), le;
1345
- }, N = (x) => {
1346
- if (x.type === "geometry") {
1347
- e.appendGeometry(x.kind, x.layers);
1338
+ }, N = (p) => {
1339
+ if (p.type === "geometry") {
1340
+ e.appendGeometry(p.kind, p.layers);
1348
1341
  return;
1349
1342
  }
1350
- if (x.type === "text") {
1351
- e.appendText(x.texts);
1343
+ if (p.type === "text") {
1344
+ e.appendText(p.texts);
1352
1345
  return;
1353
1346
  }
1354
- if (x.type === "insertModel") {
1347
+ if (p.type === "insertModel") {
1355
1348
  e.appendInsertModel({
1356
- variants: x.variants,
1357
- instances: x.instances,
1358
- planMs: x.planMs
1349
+ variants: p.variants,
1350
+ instances: p.instances,
1351
+ planMs: p.planMs
1359
1352
  });
1360
1353
  return;
1361
1354
  }
1362
- }, C = (x) => X(x.type === "text" ? "text" : "geometry", x.bytes, () => {
1363
- if (l) {
1364
- N(x);
1355
+ }, C = (p) => X(p.type === "text" ? "text" : "geometry", p.bytes, () => {
1356
+ if (c) {
1357
+ N(p);
1365
1358
  return;
1366
1359
  }
1367
- v.push(x);
1368
- }), L = (x, D) => {
1360
+ R.push(p);
1361
+ }), L = (p, D) => {
1369
1362
  const oe = Promise.resolve().then(async () => {
1370
1363
  var j;
1371
- await ((j = t.beforeTextAppend) == null ? void 0 : j.call(t, x)), await D();
1364
+ await ((j = t.beforeTextAppend) == null ? void 0 : j.call(t, p)), await D();
1372
1365
  }).catch((j) => {
1373
- throw B(j);
1366
+ throw A(j);
1374
1367
  });
1375
1368
  return E(oe);
1376
- }, Fr = (x) => {
1369
+ }, Or = (p) => {
1377
1370
  if (!u) {
1378
- if (x.type === "header") {
1371
+ if (p.type === "header") {
1379
1372
  if (r) {
1380
- m = x.header;
1373
+ m = p.header;
1381
1374
  return;
1382
1375
  }
1383
- e.initFromHeader(x.header);
1376
+ e.initFromHeader(p.header);
1384
1377
  return;
1385
1378
  }
1386
- if (x.type === "geometry")
1379
+ if (p.type === "geometry")
1387
1380
  return r ? C({
1388
1381
  type: "geometry",
1389
- kind: x.kind,
1390
- layers: x.layers,
1391
- bytes: x.bytes
1392
- }) : X("geometry", x.bytes, () => {
1393
- e.appendGeometry(x.kind, x.layers), T();
1382
+ kind: p.kind,
1383
+ layers: p.layers,
1384
+ bytes: p.bytes
1385
+ }) : X("geometry", p.bytes, () => {
1386
+ e.appendGeometry(p.kind, p.layers), T();
1394
1387
  });
1395
- if (x.type === "text")
1396
- return r ? L(x.texts, () => C({
1388
+ if (p.type === "text")
1389
+ return r ? L(p.texts, () => C({
1397
1390
  type: "text",
1398
- texts: x.texts,
1399
- bytes: x.bytes
1400
- })) : L(x.texts, () => X("text", x.bytes, () => {
1401
- e.appendText(x.texts), T();
1391
+ texts: p.texts,
1392
+ bytes: p.bytes
1393
+ })) : L(p.texts, () => X("text", p.bytes, () => {
1394
+ e.appendText(p.texts), T();
1402
1395
  }));
1403
- if (x.type === "insertModel")
1396
+ if (p.type === "insertModel")
1404
1397
  return r ? C({
1405
1398
  type: "insertModel",
1406
- variants: x.variants,
1407
- instances: x.instances,
1408
- bytes: x.bytes,
1409
- planMs: x.planMs
1410
- }) : X("geometry", x.bytes, () => {
1399
+ variants: p.variants,
1400
+ instances: p.instances,
1401
+ bytes: p.bytes,
1402
+ planMs: p.planMs
1403
+ }) : X("geometry", p.bytes, () => {
1411
1404
  e.installInsertModel({
1412
- variants: x.variants,
1413
- instances: x.instances,
1414
- planMs: x.planMs
1405
+ variants: p.variants,
1406
+ instances: p.instances,
1407
+ planMs: p.planMs
1415
1408
  }), T();
1416
1409
  });
1417
- d = !0;
1410
+ l = !0;
1418
1411
  }
1419
1412
  };
1420
1413
  try {
1421
1414
  if ((tn = t.signal) != null && tn.aborted)
1422
- throw K(t.signal.reason);
1415
+ throw W(t.signal.reason);
1423
1416
  if (s = t.adapter.start(
1424
1417
  {
1425
1418
  buffer: t.buffer,
@@ -1433,48 +1426,49 @@ async function or(t) {
1433
1426
  requiredExternalVariantIds: t.requiredExternalVariantIds,
1434
1427
  externalVariantGeometryFetchIds: t.externalVariantGeometryFetchIds,
1435
1428
  deferExternalVariantGeometry: t.deferExternalVariantGeometry,
1436
- externalVariantDeltaOnly: t.externalVariantDeltaOnly
1429
+ externalVariantDeltaOnly: t.externalVariantDeltaOnly,
1430
+ cacheDocument: t.cacheDocument
1437
1431
  },
1438
- Fr
1432
+ Or
1439
1433
  ), s.completion.catch(() => {
1440
1434
  }), t.signal) {
1441
- const x = t.signal, D = () => {
1442
- B(K(x.reason));
1435
+ const p = t.signal, D = () => {
1436
+ A(W(p.reason));
1443
1437
  };
1444
- x.addEventListener("abort", D, { once: !0 }), p = () => x.removeEventListener("abort", D), x.aborted && D();
1438
+ p.addEventListener("abort", D, { once: !0 }), x = () => p.removeEventListener("abort", D), p.aborted && D();
1445
1439
  }
1446
- if (s.grant && (o = new Zn(ss(t.flowControl)), W(), P(o.takeInitialGrant(), !1)), await Promise.race([s.completion, A]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, A]), await _(), await Promise.all(Array.from(w)), !d)
1440
+ if (s.grant && (o = new Jn(as(t.flowControl)), K(), P(o.takeInitialGrant(), !1)), await Promise.race([s.completion, B]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, B]), await _(), await Promise.all(Array.from(w)), !l)
1447
1441
  throw new Error("Geo loader pipeline completed without done event");
1448
1442
  if (await ((nn = t.beforeFinalize) == null ? void 0 : nn.call(t)), r) {
1449
1443
  if (!m)
1450
1444
  throw new Error("Geo loader pipeline completed without delta header");
1451
1445
  n.appendExternalVariantDeltaHeader(m);
1452
- for (const x of v)
1453
- X(x.type === "text" ? "text" : "geometry", x.bytes, () => {
1454
- N(x);
1446
+ for (const p of R)
1447
+ X(p.type === "text" ? "text" : "geometry", p.bytes, () => {
1448
+ N(p);
1455
1449
  });
1456
1450
  await _(), await Promise.all(Array.from(w)), await n._finalizeIncrementally(() => ht(t.onYield));
1457
1451
  } else
1458
1452
  await e.finalize(() => ht(t.onYield));
1459
- if (l = !0, s.backgroundCompletion) {
1460
- const x = s;
1453
+ if (c = !0, s.backgroundCompletion) {
1454
+ const p = s;
1461
1455
  a = !1, s.backgroundCompletion.then(async () => {
1462
1456
  await _(), await Promise.all(Array.from(w));
1463
1457
  }).catch(() => {
1464
1458
  }).finally(() => {
1465
- x.dispose();
1459
+ p.dispose();
1466
1460
  });
1467
1461
  }
1468
- } catch (x) {
1469
- throw B(x);
1462
+ } catch (p) {
1463
+ throw A(p);
1470
1464
  } finally {
1471
- p == null || p(), a && (s == null || s.dispose());
1465
+ x == null || x(), a && (s == null || s.dispose());
1472
1466
  }
1473
1467
  }
1474
- function lr(t) {
1468
+ function cr(t) {
1475
1469
  return t instanceof Error ? t : new Error(String(t));
1476
1470
  }
1477
- function os(t) {
1471
+ function ls(t) {
1478
1472
  if (!t || t.size === 0)
1479
1473
  return t;
1480
1474
  const n = /* @__PURE__ */ new Map();
@@ -1482,22 +1476,22 @@ function os(t) {
1482
1476
  n.set(e, r.slice(0));
1483
1477
  return n;
1484
1478
  }
1485
- function ls() {
1479
+ function cs() {
1486
1480
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1487
1481
  }
1488
1482
  function dr(t = {}) {
1489
- var a, o, d, l, u, c, h;
1483
+ var a, o, l, c, u, d, h;
1490
1484
  const n = t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(), e = t.requiredExternalVariantIds !== void 0, r = e ? new Set(t.requiredExternalVariantIds) : /* @__PURE__ */ new Set(), i = t.externalVariantGeometryFetchIds !== void 0, s = i ? new Set(t.externalVariantGeometryFetchIds) : /* @__PURE__ */ new Set();
1491
1485
  return {
1492
1486
  scheduler: {
1493
1487
  frameBudgetMs: ((a = t.scheduler) == null ? void 0 : a.frameBudgetMs) ?? qt,
1494
1488
  reserveMs: ((o = t.scheduler) == null ? void 0 : o.reserveMs) ?? Kt,
1495
- now: ((d = t.scheduler) == null ? void 0 : d.now) ?? ls
1489
+ now: ((l = t.scheduler) == null ? void 0 : l.now) ?? cs
1496
1490
  },
1497
1491
  flowControl: {
1498
- highWatermarkBytes: ((l = t.flowControl) == null ? void 0 : l.highWatermarkBytes) ?? Wt,
1492
+ highWatermarkBytes: ((c = t.flowControl) == null ? void 0 : c.highWatermarkBytes) ?? Wt,
1499
1493
  lowWatermarkBytes: ((u = t.flowControl) == null ? void 0 : u.lowWatermarkBytes) ?? Xt,
1500
- initialGeometryCredits: ((c = t.flowControl) == null ? void 0 : c.initialGeometryCredits) ?? Yt,
1494
+ initialGeometryCredits: ((d = t.flowControl) == null ? void 0 : d.initialGeometryCredits) ?? Yt,
1501
1495
  initialTextCredits: ((h = t.flowControl) == null ? void 0 : h.initialTextCredits) ?? Qt
1502
1496
  },
1503
1497
  beforeTextAppend: t.beforeTextAppend,
@@ -1518,16 +1512,17 @@ function dr(t = {}) {
1518
1512
  externalVariantGeometryFetchIds: i ? s : void 0,
1519
1513
  deferExternalVariantGeometry: t.deferExternalVariantGeometry === !0,
1520
1514
  externalVariantDeltaOnly: t.externalVariantDeltaOnly === !0,
1515
+ cacheDocument: t.cacheDocument === !0,
1521
1516
  onFirstRenderableAppend: t.onFirstRenderableAppend
1522
1517
  };
1523
1518
  }
1524
- async function cr(t, n, e, r = {}) {
1519
+ async function ur(t, n, e, r = {}) {
1525
1520
  const i = dr(r), s = i.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), a = i.preferWorker && i.workerAdapter ? i.workerAdapter : i.preferWorker && nt(i.workerFactory) ? jt({
1526
1521
  workerUrl: i.workerUrl,
1527
1522
  workerFactory: i.workerFactory
1528
1523
  }) : $t();
1529
1524
  try {
1530
- await or({
1525
+ await lr({
1531
1526
  node: t,
1532
1527
  buffer: n,
1533
1528
  adapter: a,
@@ -1548,27 +1543,28 @@ async function cr(t, n, e, r = {}) {
1548
1543
  externalVariantGeometryFetchIds: i.externalVariantGeometryFetchIds,
1549
1544
  deferExternalVariantGeometry: i.deferExternalVariantGeometry,
1550
1545
  externalVariantDeltaOnly: i.externalVariantDeltaOnly,
1546
+ cacheDocument: i.cacheDocument,
1551
1547
  onFirstRenderableAppend: i.onFirstRenderableAppend
1552
1548
  });
1553
1549
  } catch (o) {
1554
- const d = lr(o);
1550
+ const l = cr(o);
1555
1551
  throw t.ready.catch(() => {
1556
- }), d;
1552
+ }), l;
1557
1553
  }
1558
1554
  }
1559
1555
  async function Et(t, n, e, r = {}) {
1560
- var c;
1556
+ var d;
1561
1557
  const i = dr({
1562
1558
  ...r,
1563
1559
  externalVariantDeltaOnly: !0
1564
1560
  }), s = i.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), a = i.preferWorker && (i.workerAdapter !== void 0 || nt(i.workerFactory)), o = i.preferWorker && i.workerAdapter ? i.workerAdapter : a ? jt({
1565
1561
  workerUrl: i.workerUrl,
1566
1562
  workerFactory: i.workerFactory
1567
- }) : $t(), d = a && i.externalVariantDeltaOnly && ((c = i.workerAdapter) == null ? void 0 : c.mainBufferReuseReady) === !0, l = a && !d ? n.slice(0) : n, u = a ? os(i.externalVariantBuffers) : i.externalVariantBuffers;
1563
+ }) : $t(), l = a && i.externalVariantDeltaOnly && ((d = i.workerAdapter) == null ? void 0 : d.mainBufferReuseReady) === !0, c = a && !l ? n.slice(0) : n, u = a ? ls(i.externalVariantBuffers) : i.externalVariantBuffers;
1568
1564
  try {
1569
- await or({
1565
+ await lr({
1570
1566
  node: t,
1571
- buffer: l,
1567
+ buffer: c,
1572
1568
  adapter: o,
1573
1569
  scheduler: i.scheduler,
1574
1570
  flowControl: i.flowControl,
@@ -1590,35 +1586,35 @@ async function Et(t, n, e, r = {}) {
1590
1586
  onFirstRenderableAppend: i.onFirstRenderableAppend
1591
1587
  });
1592
1588
  } catch (h) {
1593
- throw lr(h);
1589
+ throw cr(h);
1594
1590
  }
1595
1591
  }
1596
- const ds = "?", cs = {
1592
+ const ds = "?", us = {
1597
1593
  "℄": "CL",
1598
1594
  "∅": "Ø",
1599
1595
  "⌀": "Ø"
1600
1596
  };
1601
- function us(t) {
1597
+ function hs(t) {
1602
1598
  return t >= 0 && t <= 8 || t >= 11 && t <= 31 || t >= 127 && t <= 159 || t >= 65024 && t <= 65039 || t >= 917760 && t <= 917999;
1603
1599
  }
1604
- function hs(t) {
1600
+ function fs(t) {
1605
1601
  return t >= 13312 && t <= 19903 || t >= 131072 && t <= 173791 || t >= 173824 && t <= 177983 || t >= 177984 && t <= 178207 || t >= 178208 && t <= 183983 || t >= 183984 && t <= 191471 || t >= 191472 && t <= 192095 || t >= 196608 && t <= 201551 || t >= 201552 && t <= 205743 || t >= 194560 && t <= 195103;
1606
1602
  }
1607
- function fs(t) {
1603
+ function ys(t) {
1608
1604
  let n = !1, e = "";
1609
1605
  for (const r of t) {
1610
1606
  const i = r.codePointAt(0);
1611
1607
  if (i === void 0) continue;
1612
- const s = cs[r];
1608
+ const s = us[r];
1613
1609
  if (s !== void 0) {
1614
1610
  e += s, n = !0;
1615
1611
  continue;
1616
1612
  }
1617
- if (us(i)) {
1613
+ if (hs(i)) {
1618
1614
  n = !0;
1619
1615
  continue;
1620
1616
  }
1621
- if (hs(i)) {
1617
+ if (fs(i)) {
1622
1618
  e += ds, n = !0;
1623
1619
  continue;
1624
1620
  }
@@ -1626,26 +1622,26 @@ function fs(t) {
1626
1622
  }
1627
1623
  return { text: e, replacedUnsupported: n };
1628
1624
  }
1629
- function ur(t) {
1630
- return fs(t);
1625
+ function hr(t) {
1626
+ return ys(t);
1631
1627
  }
1632
1628
  function Cn(t) {
1633
1629
  if (!Number.isFinite(t)) return 0;
1634
1630
  const n = Math.round(t);
1635
1631
  return n < 0 ? 0 : n > 255 ? 255 : n;
1636
1632
  }
1637
- function hr(t) {
1633
+ function fr(t) {
1638
1634
  return Number.isFinite(t) ? t >= 0 && t <= 1 ? Cn(t * 255) : Cn(t) : 0;
1639
1635
  }
1640
- function fr(t) {
1636
+ function yr(t) {
1641
1637
  if (t instanceof Uint8Array)
1642
1638
  return t;
1643
1639
  const n = new Uint8Array(t.length);
1644
1640
  for (let e = 0; e < t.length; e += 1)
1645
- n[e] = hr(t[e] ?? 0);
1641
+ n[e] = fr(t[e] ?? 0);
1646
1642
  return n;
1647
1643
  }
1648
- function ys(t) {
1644
+ function ms(t) {
1649
1645
  const n = new Float32Array(t.length);
1650
1646
  for (let e = 0; e < t.length; e += 1)
1651
1647
  n[e] = (t[e] ?? 0) / 255;
@@ -1654,15 +1650,15 @@ function ys(t) {
1654
1650
  function wn(t) {
1655
1651
  return new $(t, 3, !0);
1656
1652
  }
1657
- function ms(t) {
1653
+ function ps(t) {
1658
1654
  const n = t.array;
1659
1655
  if (n instanceof Uint8Array)
1660
1656
  return n;
1661
1657
  if (n instanceof Float32Array)
1662
- return fr(n);
1658
+ return yr(n);
1663
1659
  const e = new Uint8Array(n.length);
1664
1660
  for (let r = 0; r < n.length; r += 1)
1665
- e[r] = hr(Number(n[r] ?? 0));
1661
+ e[r] = fr(Number(n[r] ?? 0));
1666
1662
  return e;
1667
1663
  }
1668
1664
  function Ye(t, n) {
@@ -1674,33 +1670,33 @@ function Ye(t, n) {
1674
1670
  return !1;
1675
1671
  return e === t;
1676
1672
  }
1677
- function ps(t, n) {
1673
+ function xs(t, n) {
1678
1674
  if (!Ye(t, n))
1679
1675
  throw new Error("Source color runs must be positive, contiguous, and cover the vertex count exactly.");
1680
1676
  }
1681
- function yr(t, n, e) {
1677
+ function mr(t, n, e) {
1682
1678
  return (t & 255) << 16 | (n & 255) << 8 | e & 255;
1683
1679
  }
1684
- function xs(t, n) {
1680
+ function gs(t, n) {
1685
1681
  const e = new Uint8Array(t.length), r = Math.floor(t.length / 3), i = /* @__PURE__ */ new Map();
1686
- let s = -1, a = [0, 0, 0], o = 0, d = 0, l = 0;
1682
+ let s = -1, a = [0, 0, 0], o = 0, l = 0, c = 0;
1687
1683
  for (let u = 0; u < r; u += 1) {
1688
- const c = u * 3, h = t[c] ?? 0, y = t[c + 1] ?? 0, p = t[c + 2] ?? 0, m = yr(h, y, p);
1684
+ const d = u * 3, h = t[d] ?? 0, y = t[d + 1] ?? 0, x = t[d + 2] ?? 0, m = mr(h, y, x);
1689
1685
  let b;
1690
1686
  if (m === s)
1691
- b = a, l += 1;
1687
+ b = a, c += 1;
1692
1688
  else {
1693
1689
  o += 1;
1694
- const v = i.get(m);
1695
- if (v)
1696
- b = v, d += 1;
1690
+ const R = i.get(m);
1691
+ if (R)
1692
+ b = R, l += 1;
1697
1693
  else {
1698
- const I = n([h, y, p]);
1694
+ const I = n([h, y, x]);
1699
1695
  b = [I[0], I[1], I[2]], i.set(m, b);
1700
1696
  }
1701
1697
  s = m, a = b;
1702
1698
  }
1703
- e[c] = b[0], e[c + 1] = b[1], e[c + 2] = b[2];
1699
+ e[d] = b[0], e[d + 1] = b[1], e[d + 2] = b[2];
1704
1700
  }
1705
1701
  return {
1706
1702
  color: e,
@@ -1708,8 +1704,8 @@ function xs(t, n) {
1708
1704
  vertexCount: r,
1709
1705
  runCount: o,
1710
1706
  uniqueColorCount: i.size,
1711
- cacheHitCount: d,
1712
- repeatedRunVertexCount: l
1707
+ cacheHitCount: l,
1708
+ repeatedRunVertexCount: c
1713
1709
  }
1714
1710
  };
1715
1711
  }
@@ -1720,52 +1716,52 @@ function vn(t, n, e) {
1720
1716
  stats: i
1721
1717
  };
1722
1718
  }
1723
- function gs(t, n, e) {
1724
- const r = new Float32Array(t * 3), i = bs(r, t, n, e);
1719
+ function bs(t, n, e) {
1720
+ const r = new Float32Array(t * 3), i = Is(r, t, n, e);
1725
1721
  return {
1726
1722
  color: r,
1727
1723
  stats: i
1728
1724
  };
1729
1725
  }
1730
1726
  function St(t, n, e, r) {
1731
- return mr(t, n, e, r, 1);
1727
+ return pr(t, n, e, r, 1);
1732
1728
  }
1733
- function bs(t, n, e, r) {
1734
- return mr(t, n, e, r, 1 / 255);
1729
+ function Is(t, n, e, r) {
1730
+ return pr(t, n, e, r, 1 / 255);
1735
1731
  }
1736
- function mr(t, n, e, r, i) {
1737
- ps(n, e);
1732
+ function pr(t, n, e, r, i) {
1733
+ xs(n, e);
1738
1734
  const s = n * 3;
1739
1735
  if (t.length !== s)
1740
1736
  throw new Error("Display color target must cover the vertex count exactly.");
1741
1737
  const a = /* @__PURE__ */ new Map();
1742
- let o = 0, d = 0;
1743
- for (const l of e) {
1744
- if (l.vertexCount <= 0) continue;
1745
- const u = l.color[0] ?? 0, c = l.color[1] ?? 0, h = l.color[2] ?? 0, y = yr(u, c, h);
1746
- let p = a.get(y);
1747
- if (p)
1738
+ let o = 0, l = 0;
1739
+ for (const c of e) {
1740
+ if (c.vertexCount <= 0) continue;
1741
+ const u = c.color[0] ?? 0, d = c.color[1] ?? 0, h = c.color[2] ?? 0, y = mr(u, d, h);
1742
+ let x = a.get(y);
1743
+ if (x)
1748
1744
  o += 1;
1749
1745
  else {
1750
- const b = r([u, c, h]);
1751
- p = [b[0], b[1], b[2]], a.set(y, p);
1746
+ const b = r([u, d, h]);
1747
+ x = [b[0], b[1], b[2]], a.set(y, x);
1752
1748
  }
1753
- d += Math.max(0, l.vertexCount - 1);
1754
- const m = Math.min(n, l.startVertex + l.vertexCount);
1755
- for (let b = l.startVertex; b < m; b += 1) {
1756
- const v = b * 3;
1757
- t[v] = p[0] * i, t[v + 1] = p[1] * i, t[v + 2] = p[2] * i;
1749
+ l += Math.max(0, c.vertexCount - 1);
1750
+ const m = Math.min(n, c.startVertex + c.vertexCount);
1751
+ for (let b = c.startVertex; b < m; b += 1) {
1752
+ const R = b * 3;
1753
+ t[R] = x[0] * i, t[R + 1] = x[1] * i, t[R + 2] = x[2] * i;
1758
1754
  }
1759
1755
  }
1760
1756
  return {
1761
1757
  vertexCount: n,
1762
- runCount: e.filter((l) => l.vertexCount > 0).length,
1758
+ runCount: e.filter((c) => c.vertexCount > 0).length,
1763
1759
  uniqueColorCount: a.size,
1764
1760
  cacheHitCount: o,
1765
- repeatedRunVertexCount: d
1761
+ repeatedRunVertexCount: l
1766
1762
  };
1767
1763
  }
1768
- const Is = {
1764
+ const Cs = {
1769
1765
  dark: {
1770
1766
  background: [12, 12, 20],
1771
1767
  foreground: [242, 244, 248],
@@ -1788,7 +1784,7 @@ const Is = {
1788
1784
  xrefOpacity: 0.32,
1789
1785
  hatchOpacity: 0.28
1790
1786
  }
1791
- }, Cs = {
1787
+ }, ws = {
1792
1788
  1: [255, 0, 0],
1793
1789
  2: [255, 255, 0],
1794
1790
  3: [0, 255, 0],
@@ -1797,35 +1793,35 @@ const Is = {
1797
1793
  6: [255, 0, 255],
1798
1794
  8: [128, 128, 128],
1799
1795
  9: [192, 192, 192]
1800
- }, ws = 8;
1801
- function pr(t) {
1802
- return Is[t];
1796
+ }, vs = 8;
1797
+ function xr(t) {
1798
+ return Cs[t];
1803
1799
  }
1804
1800
  function Rn(t, n) {
1805
- const e = pr(n.theme), r = n.elementKind ?? "line", i = n.state ?? "normal", s = ze(t, n, 0);
1806
- let a = Bs(s, e, r), o = s.kind === "aci" && xr(s.index) === 7;
1801
+ const e = xr(n.theme), r = n.elementKind ?? "line", i = n.state ?? "normal", s = ze(t, n, 0);
1802
+ let a = Vs(s, e, r), o = s.kind === "aci" && gr(s.index) === 7;
1807
1803
  if (n.enhanceContrast) {
1808
- const l = vs(a, {
1804
+ const c = Rs(a, {
1809
1805
  theme: n.theme,
1810
1806
  elementKind: r
1811
1807
  });
1812
- o || (o = !Es(a, l)), a = l;
1808
+ o || (o = !Ss(a, c)), a = c;
1813
1809
  }
1814
- let d = r === "hatch" ? e.hatchOpacity : 1;
1815
- return i === "hidden" && (d = 0), i === "locked" && (d *= e.lockedOpacity), i === "xrefFaded" && (d *= e.xrefOpacity), i === "hover" && (a = e.hover, o = !0), i === "selected" && (a = e.selected, o = !0), {
1810
+ let l = r === "hatch" ? e.hatchOpacity : 1;
1811
+ return i === "hidden" && (l = 0), i === "locked" && (l *= e.lockedOpacity), i === "xrefFaded" && (l *= e.xrefOpacity), i === "hover" && (a = e.hover, o = !0), i === "selected" && (a = e.selected, o = !0), {
1816
1812
  rgb: a,
1817
- opacity: d,
1813
+ opacity: l,
1818
1814
  raw: t,
1819
1815
  resolvedRaw: s,
1820
1816
  adapted: o
1821
1817
  };
1822
1818
  }
1823
- function vs(t, n) {
1824
- const e = pr(n.theme), r = n.elementKind === "text" ? 4.5 : n.elementKind === "hatch" ? 1.6 : 2.2;
1825
- return gr(t, e.background) >= r ? Ce(t) : Ss(t, e.background, r, n.theme);
1819
+ function Rs(t, n) {
1820
+ const e = xr(n.theme), r = n.elementKind === "text" ? 4.5 : n.elementKind === "hatch" ? 1.6 : 2.2;
1821
+ return br(t, e.background) >= r ? Ce(t) : ks(t, e.background, r, n.theme);
1826
1822
  }
1827
1823
  function ze(t, n, e = 0) {
1828
- return e > ws ? n.fallbackColor ?? { kind: "aci", index: 7 } : t.kind === "bylayer" ? ze(n.layerColor ?? n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t.kind === "byblock" ? ze(
1824
+ return e > vs ? n.fallbackColor ?? { kind: "aci", index: 7 } : t.kind === "bylayer" ? ze(n.layerColor ?? n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t.kind === "byblock" ? ze(
1829
1825
  n.byBlockColor ?? n.parentByBlockColor ?? n.fallbackColor ?? { kind: "aci", index: 7 },
1830
1826
  {
1831
1827
  ...n,
@@ -1834,69 +1830,69 @@ function ze(t, n, e = 0) {
1834
1830
  e + 1
1835
1831
  ) : t.kind === "none" ? ze(n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t;
1836
1832
  }
1837
- function Rs(t) {
1833
+ function Bs(t) {
1838
1834
  return Jt(t);
1839
1835
  }
1840
1836
  function Jt(t) {
1841
1837
  return Math.abs(t[0] - 200) <= 2 && Math.abs(t[1] - 200) <= 2 && Math.abs(t[2] - 200) <= 2;
1842
1838
  }
1843
1839
  function As(t, n = {}) {
1844
- return n.treatLegacyForegroundAsAci7 && Rs(t) ? { kind: "aci", index: 7 } : { kind: "truecolor", rgb: Ce(t) };
1840
+ return n.treatLegacyForegroundAsAci7 && Bs(t) ? { kind: "aci", index: 7 } : { kind: "truecolor", rgb: Ce(t) };
1845
1841
  }
1846
- function Bs(t, n, e) {
1847
- return t.kind === "truecolor" ? Ce(t.rgb) : t.kind === "aci" ? Vs(t.index, n) : (t.kind === "none", e === "text" ? n.defaultText : n.defaultLine);
1842
+ function Vs(t, n, e) {
1843
+ return t.kind === "truecolor" ? Ce(t.rgb) : t.kind === "aci" ? Es(t.index, n) : (t.kind === "none", e === "text" ? n.defaultText : n.defaultLine);
1848
1844
  }
1849
- function Vs(t, n) {
1850
- const e = xr(t);
1851
- return Ce(e === 7 || e === 0 || e === 256 ? n.foreground : Cs[e] ?? n.defaultLine);
1845
+ function Es(t, n) {
1846
+ const e = gr(t);
1847
+ return Ce(e === 7 || e === 0 || e === 256 ? n.foreground : ws[e] ?? n.defaultLine);
1852
1848
  }
1853
- function xr(t) {
1849
+ function gr(t) {
1854
1850
  return Number.isFinite(t) ? Math.abs(Math.trunc(t)) : 7;
1855
1851
  }
1856
1852
  function Ce(t) {
1857
1853
  return [Y(t[0]), Y(t[1]), Y(t[2])];
1858
1854
  }
1859
- function Es(t, n) {
1855
+ function Ss(t, n) {
1860
1856
  return t[0] === n[0] && t[1] === n[1] && t[2] === n[2];
1861
1857
  }
1862
1858
  function Y(t) {
1863
1859
  return Number.isFinite(t) ? Math.max(0, Math.min(255, Math.round(t))) : 0;
1864
1860
  }
1865
- function An(t) {
1861
+ function Bn(t) {
1866
1862
  const [n, e, r] = t.map((i) => {
1867
1863
  const s = Y(i) / 255;
1868
1864
  return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
1869
1865
  });
1870
1866
  return 0.2126 * (n ?? 0) + 0.7152 * (e ?? 0) + 0.0722 * (r ?? 0);
1871
1867
  }
1872
- function gr(t, n) {
1873
- const e = An(t), r = An(n), i = Math.max(e, r), s = Math.min(e, r);
1868
+ function br(t, n) {
1869
+ const e = Bn(t), r = Bn(n), i = Math.max(e, r), s = Math.min(e, r);
1874
1870
  return (i + 0.05) / (s + 0.05);
1875
1871
  }
1876
- function Ss(t, n, e, r) {
1877
- const i = ks(t);
1872
+ function ks(t, n, e, r) {
1873
+ const i = Ts(t);
1878
1874
  let s = 0, a = 1, o = Ce(t);
1879
- for (let d = 0; d < 16; d += 1) {
1880
- const l = (s + a) / 2, u = r === "light" ? i.l * (1 - l) : i.l + (1 - i.l) * l, c = Ts(i.h, i.s, u);
1881
- gr(c, n) >= e ? (o = c, a = l) : s = l;
1875
+ for (let l = 0; l < 16; l += 1) {
1876
+ const c = (s + a) / 2, u = r === "light" ? i.l * (1 - c) : i.l + (1 - i.l) * c, d = Ps(i.h, i.s, u);
1877
+ br(d, n) >= e ? (o = d, a = c) : s = c;
1882
1878
  }
1883
1879
  return o;
1884
1880
  }
1885
- function ks(t) {
1881
+ function Ts(t) {
1886
1882
  const n = Y(t[0]) / 255, e = Y(t[1]) / 255, r = Y(t[2]) / 255, i = Math.max(n, e, r), s = Math.min(n, e, r), a = (i + s) / 2;
1887
1883
  if (i === s) return { h: 0, s: 0, l: a };
1888
- const o = i - s, d = a > 0.5 ? o / (2 - i - s) : o / (i + s);
1889
- let l = 0;
1890
- return i === n ? l = (e - r) / o + (e < r ? 6 : 0) : i === e ? l = (r - n) / o + 2 : l = (n - e) / o + 4, l /= 6, { h: l, s: d, l: a };
1884
+ const o = i - s, l = a > 0.5 ? o / (2 - i - s) : o / (i + s);
1885
+ let c = 0;
1886
+ return i === n ? c = (e - r) / o + (e < r ? 6 : 0) : i === e ? c = (r - n) / o + 2 : c = (n - e) / o + 4, c /= 6, { h: c, s: l, l: a };
1891
1887
  }
1892
- function Ts(t, n, e) {
1888
+ function Ps(t, n, e) {
1893
1889
  if (n === 0) {
1894
1890
  const a = Y(e * 255);
1895
1891
  return [a, a, a];
1896
1892
  }
1897
- const r = (a, o, d) => {
1898
- let l = d;
1899
- return l < 0 && (l += 1), l > 1 && (l -= 1), l < 1 / 6 ? a + (o - a) * 6 * l : l < 1 / 2 ? o : l < 2 / 3 ? a + (o - a) * (2 / 3 - l) * 6 : a;
1893
+ const r = (a, o, l) => {
1894
+ let c = l;
1895
+ return c < 0 && (c += 1), c > 1 && (c -= 1), c < 1 / 6 ? a + (o - a) * 6 * c : c < 1 / 2 ? o : c < 2 / 3 ? a + (o - a) * (2 / 3 - c) * 6 : a;
1900
1896
  }, i = e < 0.5 ? e * (1 + n) : e + n - e * n, s = 2 * e - i;
1901
1897
  return [
1902
1898
  Y(r(s, i, t + 1 / 3) * 255),
@@ -1904,7 +1900,7 @@ function Ts(t, n, e) {
1904
1900
  Y(r(s, i, t - 1 / 3) * 255)
1905
1901
  ];
1906
1902
  }
1907
- const Ps = "dark", Ls = `
1903
+ const Ls = "dark", Ms = `
1908
1904
  precision highp float;
1909
1905
 
1910
1906
  uniform mat4 modelViewMatrix;
@@ -1955,7 +1951,7 @@ void main() {
1955
1951
  #endif
1956
1952
  vColor = mix(sourceColor, uLayerColor, uUseLayerColor);
1957
1953
  }
1958
- `, Ms = `
1954
+ `, Ds = `
1959
1955
  precision highp float;
1960
1956
 
1961
1957
  uniform float uOpacity;
@@ -1973,10 +1969,10 @@ void main() {
1973
1969
  gl_FragColor = vec4(linearToOutputSrgb(vColor), uOpacity);
1974
1970
  }
1975
1971
  `;
1976
- class br extends $r {
1972
+ class Ir extends jr {
1977
1973
  constructor(e) {
1978
1974
  var a, o;
1979
- const r = new Wn(16777215), i = new Xn(1, 1), s = e.variant === "fat";
1975
+ const r = new Xn(16777215), i = new Yn(1, 1), s = e.variant === "fat";
1980
1976
  super({
1981
1977
  glslVersion: null,
1982
1978
  defines: s ? { CAD_LINE_FAT: 1 } : {},
@@ -1988,8 +1984,8 @@ class br extends $r {
1988
1984
  uLayerColor: { value: r },
1989
1985
  uOpacity: { value: 1 }
1990
1986
  },
1991
- vertexShader: Ls,
1992
- fragmentShader: Ms,
1987
+ vertexShader: Ms,
1988
+ fragmentShader: Ds,
1993
1989
  vertexColors: !0
1994
1990
  });
1995
1991
  f(this, "color");
@@ -2020,7 +2016,7 @@ class br extends $r {
2020
2016
  this.uniforms.uResolution.value.set(Math.max(1, e), Math.max(1, r));
2021
2017
  }
2022
2018
  }
2023
- const Ds = new Float32Array([
2019
+ const Fs = new Float32Array([
2024
2020
  -1,
2025
2021
  1,
2026
2022
  1,
@@ -2045,7 +2041,7 @@ const Ds = new Float32Array([
2045
2041
  1,
2046
2042
  0,
2047
2043
  -1
2048
- ]), Fs = [
2044
+ ]), Os = [
2049
2045
  0,
2050
2046
  2,
2051
2047
  1,
@@ -2065,24 +2061,24 @@ const Ds = new Float32Array([
2065
2061
  7,
2066
2062
  5
2067
2063
  ];
2068
- function Os(t) {
2069
- const n = new st(t.minX, t.minY, 0), e = new st(t.maxX, t.maxY, 0), r = new jr(n, e), i = new st((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, 0), s = Math.hypot(t.maxX - t.minX, t.maxY - t.minY) / 2;
2070
- return { box: r, sphere: new Zr(i, s) };
2064
+ function _s(t) {
2065
+ const n = new st(t.minX, t.minY, 0), e = new st(t.maxX, t.maxY, 0), r = new Zr(n, e), i = new st((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, 0), s = Math.hypot(t.maxX - t.minX, t.maxY - t.minY) / 2;
2066
+ return { box: r, sphere: new Jr(i, s) };
2071
2067
  }
2072
- function Ir(t, n) {
2073
- const e = Os(n);
2068
+ function Cr(t, n) {
2069
+ const e = _s(n);
2074
2070
  t.boundingBox = e.box, t.boundingSphere = e.sphere;
2075
2071
  }
2076
- function _s(t) {
2072
+ function Gs(t) {
2077
2073
  const n = new Nt();
2078
- n.setAttribute("position", new $(t.position, t.positionItemSize)), n.setAttribute("color", new $(t.color, 3, !0)), Ir(n, t.bbox);
2079
- const e = new br({ variant: "thin" }), r = new zt(n, e);
2074
+ n.setAttribute("position", new $(t.position, t.positionItemSize)), n.setAttribute("color", new $(t.color, 3, !0)), Cr(n, t.bbox);
2075
+ const e = new Ir({ variant: "thin" }), r = new zt(n, e);
2080
2076
  return r.name = "cad-thin-line", r.renderOrder = 1, r.userData.kind = "line", r.userData.mode = "thin", r.userData.vertexCount = t.vertexCount, r.userData.bbox = t.bbox, r;
2081
2077
  }
2082
- function Gs(t) {
2083
- const n = Math.floor(t.vertexCount / 2), e = t.positionItemSize * 2, r = new an(t.position, e, 1), i = new an(t.color, 6, 1), s = new Yn();
2084
- s.setIndex(Fs), s.setAttribute("position", new Qn(Ds.slice(), 3)), s.setAttribute("instanceStart", new De(r, t.positionItemSize, 0)), s.setAttribute("instanceEnd", new De(r, t.positionItemSize, t.positionItemSize)), s.setAttribute("instanceColorStart", new De(i, 3, 0, !0)), s.setAttribute("instanceColorEnd", new De(i, 3, 3, !0)), s.instanceCount = n, Ir(s, t.bbox);
2085
- const a = new br({
2078
+ function Us(t) {
2079
+ const n = Math.floor(t.vertexCount / 2), e = t.positionItemSize * 2, r = new an(t.position, e, 1), i = new an(t.color, 6, 1), s = new Qn();
2080
+ s.setIndex(Os), s.setAttribute("position", new $n(Fs.slice(), 3)), s.setAttribute("instanceStart", new De(r, t.positionItemSize, 0)), s.setAttribute("instanceEnd", new De(r, t.positionItemSize, t.positionItemSize)), s.setAttribute("instanceColorStart", new De(i, 3, 0, !0)), s.setAttribute("instanceColorEnd", new De(i, 3, 3, !0)), s.instanceCount = n, Cr(s, t.bbox);
2081
+ const a = new Ir({
2086
2082
  variant: "fat",
2087
2083
  linewidthPx: t.linewidthPx,
2088
2084
  resolution: t.resolution
@@ -2095,8 +2091,8 @@ function ft(t) {
2095
2091
  const e = t.getAttribute("instanceColorStart"), r = t.getAttribute("instanceColorEnd");
2096
2092
  e && (e.needsUpdate = !0), r && (r.needsUpdate = !0);
2097
2093
  }
2098
- const Us = 65536;
2099
- class Ns {
2094
+ const Ns = 65536;
2095
+ class zs {
2100
2096
  constructor(n) {
2101
2097
  this.variants = n;
2102
2098
  }
@@ -2109,16 +2105,16 @@ class Ns {
2109
2105
  appendVariants(n) {
2110
2106
  const e = [];
2111
2107
  for (const r of n) {
2112
- const i = wr(r);
2108
+ const i = vr(r);
2113
2109
  if (!i) continue;
2114
2110
  const s = this.variants.get(i.variantId);
2115
- s && Bn(s), this.variants.set(i.variantId, i), e.push(i);
2111
+ s && An(s), this.variants.set(i.variantId, i), e.push(i);
2116
2112
  }
2117
2113
  return e;
2118
2114
  }
2119
2115
  dispose() {
2120
2116
  for (const n of this.variants.values())
2121
- Bn(n);
2117
+ An(n);
2122
2118
  this.variants.clear();
2123
2119
  }
2124
2120
  }
@@ -2126,12 +2122,12 @@ function yt(t, n) {
2126
2122
  const e = [];
2127
2123
  for (const r of n) {
2128
2124
  if (r.count <= 0) continue;
2129
- const i = r.bbox !== void 0 ? qs(r.bbox) : _e(r.pos, r.count, 3), s = zs(t);
2125
+ const i = r.bbox !== void 0 ? Ks(r.bbox) : _e(r.pos, r.count, 3), s = Hs(t);
2130
2126
  for (let a = 0; a < r.count; ) {
2131
- const o = Hs(a, r.count, s, Cr(t)), d = new Nt(), l = r.pos.subarray(a * 3, o * 3), u = r.col.subarray(a * 3, o * 3), c = o - a;
2132
- d.setAttribute("position", new $(l, 3)), d.setAttribute("color", new $(u, 3, !0)), e.push({
2133
- geometry: d,
2134
- vertexCount: c,
2127
+ const o = qs(a, r.count, s, wr(t)), l = new Nt(), c = r.pos.subarray(a * 3, o * 3), u = r.col.subarray(a * 3, o * 3), d = o - a;
2128
+ l.setAttribute("position", new $(c, 3)), l.setAttribute("color", new $(u, 3, !0)), e.push({
2129
+ geometry: l,
2130
+ vertexCount: d,
2135
2131
  layerIndex: r.layerIndex ?? 0,
2136
2132
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
2137
2133
  bbox: i
@@ -2140,14 +2136,14 @@ function yt(t, n) {
2140
2136
  }
2141
2137
  return e;
2142
2138
  }
2143
- function Cr(t) {
2139
+ function wr(t) {
2144
2140
  return t === "line" ? 2 : t === "fill" ? 3 : 1;
2145
2141
  }
2146
- function zs(t) {
2147
- const n = Cr(t);
2148
- return Math.max(n, Math.floor(Us / n) * n);
2142
+ function Hs(t) {
2143
+ const n = wr(t);
2144
+ return Math.max(n, Math.floor(Ns / n) * n);
2149
2145
  }
2150
- function Hs(t, n, e, r) {
2146
+ function qs(t, n, e, r) {
2151
2147
  let i = Math.min(n, t + e);
2152
2148
  if (i < n) {
2153
2149
  const s = t + Math.floor((i - t) / r) * r;
@@ -2155,18 +2151,18 @@ function Hs(t, n, e, r) {
2155
2151
  }
2156
2152
  return i > t ? i : n;
2157
2153
  }
2158
- function qs(t) {
2154
+ function Ks(t) {
2159
2155
  return t ? { minX: t.minX, minY: t.minY, maxX: t.maxX, maxY: t.maxY } : null;
2160
2156
  }
2161
- function Ks(t) {
2157
+ function Ws(t) {
2162
2158
  const n = /* @__PURE__ */ new Map();
2163
2159
  for (const e of t) {
2164
- const r = wr(e);
2160
+ const r = vr(e);
2165
2161
  r && n.set(r.variantId, r);
2166
2162
  }
2167
- return new Ns(n);
2163
+ return new zs(n);
2168
2164
  }
2169
- function wr(t) {
2165
+ function vr(t) {
2170
2166
  const n = /* @__PURE__ */ new Map(), e = yt("line", t.line);
2171
2167
  e.length > 0 && n.set("line", e);
2172
2168
  const r = yt("fill", t.fill);
@@ -2174,12 +2170,12 @@ function wr(t) {
2174
2170
  const i = yt("dot", t.dot);
2175
2171
  return i.length > 0 && n.set("dot", i), n.size > 0 ? { variantId: t.variantId, byKind: n } : null;
2176
2172
  }
2177
- function Bn(t) {
2173
+ function An(t) {
2178
2174
  for (const n of t.byKind.values())
2179
2175
  for (const e of n)
2180
2176
  e.geometry.dispose();
2181
2177
  }
2182
- class Ws {
2178
+ class Xs {
2183
2179
  constructor(n, e) {
2184
2180
  f(this, "mutableRecords");
2185
2181
  f(this, "indexByRecordKey", /* @__PURE__ */ new Map());
@@ -2245,14 +2241,14 @@ function kt(t, n) {
2245
2241
  };
2246
2242
  }
2247
2243
  function Vn(t) {
2248
- const n = new ei();
2244
+ const n = new ni();
2249
2245
  if (t.length > 0) {
2250
2246
  const e = new Array(t.length);
2251
2247
  for (let r = 0; r < t.length; r++)
2252
2248
  e[r] = kt(t[r], r);
2253
2249
  n.load(e);
2254
2250
  }
2255
- return new Ws(t, n);
2251
+ return new Xs(t, n);
2256
2252
  }
2257
2253
  class En {
2258
2254
  constructor(n) {
@@ -2282,11 +2278,11 @@ class En {
2282
2278
  this.removeVariantSlots(n.variantId);
2283
2279
  for (const [e, r] of n.byKind)
2284
2280
  for (const i of r) {
2285
- const s = this.initialCapacity, a = new Yn(), o = i.geometry.getAttribute("position"), d = i.geometry.getAttribute("color");
2286
- o && a.setAttribute("position", o), d && a.setAttribute("color", d), a.instanceCount = 0;
2287
- const l = new de(new Float32Array(s * 4), 4), u = new de(new Float32Array(s * 4), 4), c = new de(new Float32Array(s), 1);
2288
- a.setAttribute("promotedInstMatRow0", l), a.setAttribute("promotedInstMatRow1", u), a.setAttribute("promotedInstVisible", c);
2289
- const h = Ys(e, a, this.materialFactory(e));
2281
+ const s = this.initialCapacity, a = new Qn(), o = i.geometry.getAttribute("position"), l = i.geometry.getAttribute("color");
2282
+ o && a.setAttribute("position", o), l && a.setAttribute("color", l), a.instanceCount = 0;
2283
+ const c = new ce(new Float32Array(s * 4), 4), u = new ce(new Float32Array(s * 4), 4), d = new ce(new Float32Array(s), 1);
2284
+ a.setAttribute("promotedInstMatRow0", c), a.setAttribute("promotedInstMatRow1", u), a.setAttribute("promotedInstVisible", d);
2285
+ const h = Qs(e, a, this.materialFactory(e));
2290
2286
  h.visible = !1, h.frustumCulled = !1, h.userData.kind = e, h.userData.variantId = n.variantId, h.userData.insertPresenterMesh = !0, h.userData.vertexCount = 0, this.slots.push({
2291
2287
  variantId: n.variantId,
2292
2288
  kind: e,
@@ -2294,9 +2290,9 @@ class En {
2294
2290
  perVertexCount: i.vertexCount,
2295
2291
  localBBox: i.bbox,
2296
2292
  mesh: h,
2297
- matRow0Attr: l,
2293
+ matRow0Attr: c,
2298
2294
  matRow1Attr: u,
2299
- visibleAttr: c,
2295
+ visibleAttr: d,
2300
2296
  capacity: s
2301
2297
  }), this.group.add(h);
2302
2298
  }
@@ -2312,23 +2308,23 @@ class En {
2312
2308
  this.lastQueryAll = !1, this.lastQueryRect = null, this.lastQueryHits = [], this.invalidateFilteredQueryCache();
2313
2309
  }
2314
2310
  refresh(n, e, r, i) {
2315
- const s = n ? Je(n, this.marginRatio) : null, a = !s, o = i === void 0 ? `signature:${Xs(r)}` : `revision:${i}`;
2316
- if (this.cacheValid && this.lastLayerVersion === e.version && this.lastUserHiddenCacheKey === o && this.lastFilteredQueryAll === a && qr(this.lastFilteredQueryRect, s))
2311
+ const s = n ? Je(n, this.marginRatio) : null, a = !s, o = i === void 0 ? `signature:${Ys(r)}` : `revision:${i}`;
2312
+ if (this.cacheValid && this.lastLayerVersion === e.version && this.lastUserHiddenCacheKey === o && this.lastFilteredQueryAll === a && Kr(this.lastFilteredQueryRect, s))
2317
2313
  return;
2318
- const d = this.resolveQueryHits(s), l = /* @__PURE__ */ new Map();
2319
- for (const c of d) {
2320
- if (s && !Kn(s, c.bbox) || r.has(c.instanceId)) continue;
2321
- let h = l.get(c.variantId);
2322
- h || (h = [], l.set(c.variantId, h)), h.push(c);
2314
+ const l = this.resolveQueryHits(s), c = /* @__PURE__ */ new Map();
2315
+ for (const d of l) {
2316
+ if (s && !Wn(s, d.bbox) || r.has(d.instanceId)) continue;
2317
+ let h = c.get(d.variantId);
2318
+ h || (h = [], c.set(d.variantId, h)), h.push(d);
2323
2319
  }
2324
2320
  let u = 0;
2325
- for (const c of this.slots) {
2326
- const h = l.get(c.variantId), y = h == null ? void 0 : h.filter((p) => this.slotVisibleForRecord(c, p, e));
2321
+ for (const d of this.slots) {
2322
+ const h = c.get(d.variantId), y = h == null ? void 0 : h.filter((x) => this.slotVisibleForRecord(d, x, e));
2327
2323
  if (!y || y.length === 0) {
2328
- Sn(c.mesh, 0), c.mesh.userData.vertexCount = 0, c.mesh.visible = !1;
2324
+ Sn(d.mesh, 0), d.mesh.userData.vertexCount = 0, d.mesh.visible = !1;
2329
2325
  continue;
2330
2326
  }
2331
- this.ensureCapacity(c, y.length), this.writeMatRows(c, y), Sn(c.mesh, y.length), c.mesh.userData.vertexCount = y.length * c.perVertexCount, c.mesh.visible = !0, u += y.length * c.perVertexCount;
2327
+ this.ensureCapacity(d, y.length), this.writeMatRows(d, y), Sn(d.mesh, y.length), d.mesh.userData.vertexCount = y.length * d.perVertexCount, d.mesh.visible = !0, u += y.length * d.perVertexCount;
2332
2328
  }
2333
2329
  this.visibleVertexCount = u, this.lastLayerVersion = e.version, this.lastUserHiddenCacheKey = o, this.lastFilteredQueryAll = a, this.lastFilteredQueryRect = s ? {
2334
2330
  minX: s.minX,
@@ -2371,13 +2367,13 @@ class En {
2371
2367
  ensureCapacity(n, e) {
2372
2368
  if (n.capacity >= e) return;
2373
2369
  const r = Math.max(e, n.capacity * 2);
2374
- n.matRow0Attr = new de(new Float32Array(r * 4), 4), n.matRow1Attr = new de(new Float32Array(r * 4), 4), n.visibleAttr = new de(new Float32Array(r), 1), n.mesh.geometry.setAttribute("promotedInstMatRow0", n.matRow0Attr), n.mesh.geometry.setAttribute("promotedInstMatRow1", n.matRow1Attr), n.mesh.geometry.setAttribute("promotedInstVisible", n.visibleAttr), n.capacity = r;
2370
+ n.matRow0Attr = new ce(new Float32Array(r * 4), 4), n.matRow1Attr = new ce(new Float32Array(r * 4), 4), n.visibleAttr = new ce(new Float32Array(r), 1), n.mesh.geometry.setAttribute("promotedInstMatRow0", n.matRow0Attr), n.mesh.geometry.setAttribute("promotedInstMatRow1", n.matRow1Attr), n.mesh.geometry.setAttribute("promotedInstVisible", n.visibleAttr), n.capacity = r;
2375
2371
  }
2376
2372
  writeMatRows(n, e) {
2377
2373
  const r = n.matRow0Attr.array, i = n.matRow1Attr.array, s = n.visibleAttr.array;
2378
2374
  for (let o = 0; o < e.length; o += 1) {
2379
- const d = e[o], l = o * 4;
2380
- r[l] = d.matA, r[l + 1] = d.matC, r[l + 2] = d.tx, r[l + 3] = 0, i[l] = d.matB, i[l + 1] = d.matD, i[l + 2] = d.ty, i[l + 3] = 0, s[o] = 1;
2375
+ const l = e[o], c = o * 4;
2376
+ r[c] = l.matA, r[c + 1] = l.matC, r[c + 2] = l.tx, r[c + 3] = 0, i[c] = l.matB, i[c + 1] = l.matD, i[c + 2] = l.ty, i[c + 3] = 0, s[o] = 1;
2381
2377
  }
2382
2378
  const a = e.length * 4;
2383
2379
  n.matRow0Attr.clearUpdateRanges(), n.matRow1Attr.clearUpdateRanges(), n.visibleAttr.clearUpdateRanges(), n.matRow0Attr.addUpdateRange(0, a), n.matRow1Attr.addUpdateRange(0, a), n.visibleAttr.addUpdateRange(0, e.length), n.matRow0Attr.needsUpdate = !0, n.matRow1Attr.needsUpdate = !0, n.visibleAttr.needsUpdate = !0;
@@ -2387,11 +2383,11 @@ class En {
2387
2383
  return r.isVisible(i);
2388
2384
  }
2389
2385
  }
2390
- function Xs(t) {
2386
+ function Ys(t) {
2391
2387
  return t.size === 0 ? "0:" : `${t.size}:${Array.from(t).sort((n, e) => n - e).join(",")}`;
2392
2388
  }
2393
- function Ys(t, n, e) {
2394
- const r = t === "line" ? new zt(n, e) : t === "fill" ? new Ht(n, e) : new $n(n, e);
2389
+ function Qs(t, n, e) {
2390
+ const r = t === "line" ? new zt(n, e) : t === "fill" ? new Ht(n, e) : new jn(n, e);
2395
2391
  return r.count = 0, r;
2396
2392
  }
2397
2393
  function Sn(t, n) {
@@ -2404,36 +2400,36 @@ function kn(t) {
2404
2400
  }
2405
2401
  t.dispose();
2406
2402
  }
2407
- const vr = 64, Rr = 8;
2408
- function Qs() {
2403
+ const Rr = 64, Br = 8;
2404
+ function $s() {
2409
2405
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2410
2406
  }
2411
- async function $s(t, n = {}) {
2412
- const e = Math.max(1, Math.floor(n.opsPerPass ?? vr) || 1), r = Math.max(0, n.frameBudgetMs ?? Rr), i = n.now ?? Qs, s = i();
2413
- let a = s, o = 0, d = 0, l = 0, u = 0;
2414
- for (let c = 0; c < t.length; c += 1) {
2415
- const h = t[c];
2416
- d += 1, h.run() && (l += 1, o += 1), n.onYield && c < t.length - 1 && (o >= e || i() - a >= r) && (await n.onYield(), u += 1, a = i(), o = 0);
2407
+ async function js(t, n = {}) {
2408
+ const e = Math.max(1, Math.floor(n.opsPerPass ?? Rr) || 1), r = Math.max(0, n.frameBudgetMs ?? Br), i = n.now ?? $s, s = i();
2409
+ let a = s, o = 0, l = 0, c = 0, u = 0;
2410
+ for (let d = 0; d < t.length; d += 1) {
2411
+ const h = t[d];
2412
+ l += 1, h.run() && (c += 1, o += 1), n.onYield && d < t.length - 1 && (o >= e || i() - a >= r) && (await n.onYield(), u += 1, a = i(), o = 0);
2417
2413
  }
2418
2414
  return {
2419
- visited: d,
2420
- compacted: l,
2415
+ visited: l,
2416
+ compacted: c,
2421
2417
  yielded: u,
2422
2418
  elapsedMs: i() - s
2423
2419
  };
2424
2420
  }
2425
- function js(t, n) {
2426
- return n.zoom, t === "full" && n.visibleVertexCount >= ti ? "stress" : t === "stress" && n.visibleVertexCount <= ni ? "full" : t;
2421
+ function Zs(t, n) {
2422
+ return n.zoom, t === "full" && n.visibleVertexCount >= ri ? "stress" : t === "stress" && n.visibleVertexCount <= ii ? "full" : t;
2427
2423
  }
2428
- function Zs(t, n, e) {
2429
- return t === "full" || t === "stress" ? t : js(n, e);
2424
+ function Js(t, n, e) {
2425
+ return t === "full" || t === "stress" ? t : Zs(n, e);
2430
2426
  }
2431
- const Js = 1e-6;
2432
- function ea(t, n) {
2427
+ const ea = 1e-6;
2428
+ function ta(t, n) {
2433
2429
  let e = !0;
2434
2430
  for (let i = 0; i < n; i += 1) {
2435
2431
  const s = t[i * 3 + 2] ?? 0;
2436
- if (Math.abs(s) > Js) {
2432
+ if (Math.abs(s) > ea) {
2437
2433
  e = !1;
2438
2434
  break;
2439
2435
  }
@@ -2445,7 +2441,7 @@ function ea(t, n) {
2445
2441
  r[i * 2] = t[i * 3] ?? 0, r[i * 2 + 1] = t[i * 3 + 1] ?? 0;
2446
2442
  return { kind: "xy", xy: r };
2447
2443
  }
2448
- function ta(t, n, e = 3) {
2444
+ function na(t, n, e = 3) {
2449
2445
  if (e === 2) {
2450
2446
  const i = n * 2;
2451
2447
  if (t.length === i)
@@ -2460,7 +2456,7 @@ function ta(t, n, e = 3) {
2460
2456
  r[i * 2] = t[i * 3] ?? 0, r[i * 2 + 1] = t[i * 3 + 1] ?? 0;
2461
2457
  return { kind: "xy", xy: r };
2462
2458
  }
2463
- function na(t, n, e, r) {
2459
+ function ra(t, n, e, r) {
2464
2460
  const i = r * 3;
2465
2461
  if (t.kind === "xyz") {
2466
2462
  e.set(t.xyz.subarray(0, n * 3), i);
@@ -2471,9 +2467,9 @@ function na(t, n, e, r) {
2471
2467
  e[o] = t.xy[a] ?? 0, e[o + 1] = t.xy[a + 1] ?? 0, e[o + 2] = 0;
2472
2468
  }
2473
2469
  }
2474
- function ra(t, n, e, r, i) {
2470
+ function ia(t, n, e, r, i) {
2475
2471
  if (i === 3) {
2476
- na(t, n, e, r);
2472
+ ra(t, n, e, r);
2477
2473
  return;
2478
2474
  }
2479
2475
  const s = r * 2;
@@ -2482,11 +2478,11 @@ function ra(t, n, e, r, i) {
2482
2478
  return;
2483
2479
  }
2484
2480
  for (let a = 0; a < n; a += 1) {
2485
- const o = a * 3, d = s + a * 2;
2486
- e[d] = t.xyz[o] ?? 0, e[d + 1] = t.xyz[o + 1] ?? 0;
2481
+ const o = a * 3, l = s + a * 2;
2482
+ e[l] = t.xyz[o] ?? 0, e[l + 1] = t.xyz[o + 1] ?? 0;
2487
2483
  }
2488
2484
  }
2489
- function ia(t, n, e) {
2485
+ function sa(t, n, e) {
2490
2486
  const r = t.kind === "xy" ? e * 2 * Float32Array.BYTES_PER_ELEMENT : e * 3 * Float32Array.BYTES_PER_ELEMENT, i = Math.min(n.byteLength, e * 3);
2491
2487
  return {
2492
2488
  recordCount: 1,
@@ -2513,7 +2509,7 @@ function Tn() {
2513
2509
  totalBytes: 0
2514
2510
  };
2515
2511
  }
2516
- function sa(t, n) {
2512
+ function aa(t, n) {
2517
2513
  return {
2518
2514
  recordCount: t.recordCount + n.recordCount,
2519
2515
  vertexCount: t.vertexCount + n.vertexCount,
@@ -2526,7 +2522,7 @@ function sa(t, n) {
2526
2522
  totalBytes: t.totalBytes + n.totalBytes
2527
2523
  };
2528
2524
  }
2529
- function aa(t, n) {
2525
+ function oa(t, n) {
2530
2526
  return {
2531
2527
  recordCount: J(t.recordCount, n.recordCount, "recordCount"),
2532
2528
  vertexCount: J(t.vertexCount, n.vertexCount, "vertexCount"),
@@ -2545,10 +2541,10 @@ function J(t, n, e) {
2545
2541
  throw new Error(`Line canonical memory stat ${String(e)} became negative: ${t} - ${n}`);
2546
2542
  return Object.is(r, -0) ? 0 : r;
2547
2543
  }
2548
- const oa = {
2544
+ const la = {
2549
2545
  visibleVertexCount: 0,
2550
2546
  zoom: 1
2551
- }, Pn = /* @__PURE__ */ new Set(), la = Object.freeze({ kind: "structure" }), Eo = Object.freeze({ kind: "visual" });
2547
+ }, Pn = /* @__PURE__ */ new Set(), ca = Object.freeze({ kind: "structure" }), Eo = Object.freeze({ kind: "visual" });
2552
2548
  function da(t) {
2553
2549
  let n = null;
2554
2550
  for (const e of t)
@@ -2561,11 +2557,11 @@ function Tt(t) {
2561
2557
  function Ar(t, n, e) {
2562
2558
  return `${t}:${n}:${e}`;
2563
2559
  }
2564
- function ca(t) {
2560
+ function ua(t) {
2565
2561
  return t.recordKey ?? Ar(t.instanceId, t.variantId, 0);
2566
2562
  }
2567
- const pt = "geo-node:promoted-instanced-v1", Ln = "geo-node:text-batch-static-bounds-v1", Fe = "geo-node:text-batch-bounds-dirty-v1", Mn = 1.5, ua = 1, Dn = "geo-node:world-sized-points-v1", Br = "geo-node:world-sized-points-uniforms", ha = 16777216, fa = 25, ya = 28, ma = 29;
2568
- function pa() {
2563
+ const pt = "geo-node:promoted-instanced-v1", Ln = "geo-node:text-batch-static-bounds-v1", Fe = "geo-node:text-batch-bounds-dirty-v1", Mn = 1.5, ha = 1, Dn = "geo-node:world-sized-points-v1", Vr = "geo-node:world-sized-points-uniforms", fa = 16777216, ya = 25, ma = 28, pa = 29;
2564
+ function xa() {
2569
2565
  return {
2570
2566
  activeThinCount: 0,
2571
2567
  activeFatCount: 0,
@@ -2576,13 +2572,13 @@ function pa() {
2576
2572
  function we(t) {
2577
2573
  return [t[0], t[1], t[2], t[3]];
2578
2574
  }
2579
- function xa(t, n) {
2575
+ function ga(t, n) {
2580
2576
  return [Math.min(t[0], n[0]), Math.min(t[1], n[1]), Math.max(t[2], n[2]), Math.max(t[3], n[3])];
2581
2577
  }
2582
2578
  function H(t) {
2583
2579
  return [t[0], t[1], t[2]];
2584
2580
  }
2585
- function ga(t, n) {
2581
+ function ba(t, n) {
2586
2582
  return t[0] === n[0] && t[1] === n[1] && t[2] === n[2];
2587
2583
  }
2588
2584
  function Fn(t, n, e) {
@@ -2602,7 +2598,7 @@ function Pt(t) {
2602
2598
  vertexCount: e.vertexCount,
2603
2599
  color: H(e.color)
2604
2600
  }, i = n[n.length - 1];
2605
- if (i && i.startVertex + i.vertexCount === r.startVertex && ga(i.color, r.color)) {
2601
+ if (i && i.startVertex + i.vertexCount === r.startVertex && ba(i.color, r.color)) {
2606
2602
  n[n.length - 1] = {
2607
2603
  ...i,
2608
2604
  vertexCount: i.vertexCount + r.vertexCount
@@ -2619,16 +2615,16 @@ function On(t, n) {
2619
2615
  const e = Pt(t);
2620
2616
  return e.length <= Math.ceil(n / 2) ? e : void 0;
2621
2617
  }
2622
- function ba(t, n) {
2618
+ function Ia(t, n) {
2623
2619
  if (!n || n.size === 0) return t;
2624
2620
  const e = /* @__PURE__ */ new Map();
2625
2621
  for (const [r, i] of t)
2626
2622
  e.set(r, [...i]);
2627
2623
  for (const [r, i] of n)
2628
- e.set(r, Ia(e.get(r) ?? [], i));
2624
+ e.set(r, Ca(e.get(r) ?? [], i));
2629
2625
  return e;
2630
2626
  }
2631
- function Ia(t, n) {
2627
+ function Ca(t, n) {
2632
2628
  const e = /* @__PURE__ */ new Map();
2633
2629
  for (const r of t)
2634
2630
  e.set(r.variantId, {
@@ -2650,9 +2646,9 @@ function Ia(t, n) {
2650
2646
  for (const o of r.inserts)
2651
2647
  s.set(
2652
2648
  o.instanceId,
2653
- Ca(s.get(o.instanceId), o)
2649
+ wa(s.get(o.instanceId), o)
2654
2650
  );
2655
- const a = Array.from(s.values()).sort((o, d) => o.instanceId - d.instanceId);
2651
+ const a = Array.from(s.values()).sort((o, l) => o.instanceId - l.instanceId);
2656
2652
  e.set(r.variantId, {
2657
2653
  ...i,
2658
2654
  blockName: r.blockName || i.blockName,
@@ -2663,7 +2659,7 @@ function Ia(t, n) {
2663
2659
  }
2664
2660
  return Array.from(e.values()).sort((r, i) => i.instanceCount - r.instanceCount);
2665
2661
  }
2666
- function Ca(t, n) {
2662
+ function wa(t, n) {
2667
2663
  const e = fe((t == null ? void 0 : t.bbox) ?? null, n.bbox ?? null);
2668
2664
  if (e)
2669
2665
  return {
@@ -2677,7 +2673,7 @@ function Ca(t, n) {
2677
2673
  canHighlight: !1
2678
2674
  };
2679
2675
  }
2680
- function wa(t) {
2676
+ function va(t) {
2681
2677
  return t.line.count > 0 || t.fill.count > 0 || t.dot.count > 0 || t.line.raw.byteLength > 0 || t.fill.raw.byteLength > 0 || t.dot.raw.byteLength > 0;
2682
2678
  }
2683
2679
  function _n(t, n) {
@@ -2690,7 +2686,7 @@ function _n(t, n) {
2690
2686
  );
2691
2687
  return e;
2692
2688
  }
2693
- function va(t, n, e) {
2689
+ function Ra(t, n, e) {
2694
2690
  if (!n) return t;
2695
2691
  if (!t)
2696
2692
  return {
@@ -2700,7 +2696,7 @@ function va(t, n, e) {
2700
2696
  };
2701
2697
  const r = t.variants.slice();
2702
2698
  for (const s of n.variants)
2703
- (!r[s.id] || wa(s)) && (r[s.id] = s);
2699
+ (!r[s.id] || va(s)) && (r[s.id] = s);
2704
2700
  const i = /* @__PURE__ */ new Map();
2705
2701
  for (const [s, a] of t.textIndexesByInstanceId)
2706
2702
  i.set(s, [...a]);
@@ -2717,7 +2713,7 @@ function va(t, n, e) {
2717
2713
  ])
2718
2714
  };
2719
2715
  }
2720
- function Ra(t) {
2716
+ function Ba(t) {
2721
2717
  return {
2722
2718
  index: t.index,
2723
2719
  name: t.name,
@@ -2730,7 +2726,7 @@ function Aa(t) {
2730
2726
  const n = t >>> 0;
2731
2727
  return [n >> 16 & 255, n >> 8 & 255, n & 255];
2732
2728
  }
2733
- function Ba(t) {
2729
+ function Va(t) {
2734
2730
  return t[0] << 16 | t[1] << 8 | t[2];
2735
2731
  }
2736
2732
  function xt(t) {
@@ -2738,7 +2734,7 @@ function xt(t) {
2738
2734
  const n = Math.round(t);
2739
2735
  return n < 0 ? 0 : n > 255 ? 255 : n;
2740
2736
  }
2741
- function Va(t) {
2737
+ function Ea(t) {
2742
2738
  switch (t) {
2743
2739
  case "fill":
2744
2740
  return 1;
@@ -2755,11 +2751,11 @@ function Va(t) {
2755
2751
  return 0;
2756
2752
  }
2757
2753
  }
2758
- function Ea(t, n, e, r, i) {
2759
- return (n !== null && Jt(t) ? ha : xt(t[0]) << 16 | xt(t[1]) << 8 | xt(t[2])) | Va(e) << fa | (r === "light" ? 1 : 0) << ya | (i ? 1 : 0) << ma;
2754
+ function Sa(t, n, e, r, i) {
2755
+ return (n !== null && Jt(t) ? fa : xt(t[0]) << 16 | xt(t[1]) << 8 | xt(t[2])) | Ea(e) << ya | (r === "light" ? 1 : 0) << ma | (i ? 1 : 0) << pa;
2760
2756
  }
2761
2757
  function gt(t) {
2762
- return "color" in t && t.color instanceof Wn;
2758
+ return "color" in t && t.color instanceof Xn;
2763
2759
  }
2764
2760
  function bt(t) {
2765
2761
  const n = /* @__PURE__ */ new Set();
@@ -2776,7 +2772,7 @@ function bt(t) {
2776
2772
  i && !n.has(i) && (n.add(i), i.dispose()), e !== t && ((s = e.dispose) == null || s.call(e));
2777
2773
  });
2778
2774
  }
2779
- function Sa(t) {
2775
+ function ka(t) {
2780
2776
  var i;
2781
2777
  const n = t.userData;
2782
2778
  if (n[pt] === !0)
@@ -2817,13 +2813,13 @@ function Sa(t) {
2817
2813
  const r = (i = t.customProgramCacheKey) == null ? void 0 : i.bind(t);
2818
2814
  t.customProgramCacheKey = () => `${r ? r() : ""}|${pt}`, n[pt] = !0, t.needsUpdate = !0;
2819
2815
  }
2820
- function ka(t) {
2821
- const n = t.userData[Br];
2816
+ function Ta(t) {
2817
+ const n = t.userData[Vr];
2822
2818
  return n && typeof n == "object" ? n : null;
2823
2819
  }
2824
- function Ta(t, n) {
2820
+ function Pa(t, n) {
2825
2821
  var o;
2826
- const e = t.userData, r = ka(t);
2822
+ const e = t.userData, r = Ta(t);
2827
2823
  if (r)
2828
2824
  return r.uGeoPointWorldSize.value = n.pointWorldSize, r.uGeoPointViewportHeight.value = Math.max(1, Math.floor(n.viewportHeight) || 1), r.uGeoPointMinVisiblePixelSize.value = Mn, r;
2829
2825
  const i = {
@@ -2831,10 +2827,10 @@ function Ta(t, n) {
2831
2827
  uGeoPointViewportHeight: { value: Math.max(1, Math.floor(n.viewportHeight) || 1) },
2832
2828
  uGeoPointMinVisiblePixelSize: { value: Mn }
2833
2829
  };
2834
- e[Br] = i;
2830
+ e[Vr] = i;
2835
2831
  const s = t.onBeforeCompile;
2836
- t.onBeforeCompile = (d, l) => {
2837
- s == null || s(d, l), d.uniforms.uGeoPointWorldSize = i.uGeoPointWorldSize, d.uniforms.uGeoPointViewportHeight = i.uGeoPointViewportHeight, d.uniforms.uGeoPointMinVisiblePixelSize = i.uGeoPointMinVisiblePixelSize, d.vertexShader.includes("uGeoPointWorldSize") || (d.vertexShader = d.vertexShader.replace(
2832
+ t.onBeforeCompile = (l, c) => {
2833
+ s == null || s(l, c), l.uniforms.uGeoPointWorldSize = i.uGeoPointWorldSize, l.uniforms.uGeoPointViewportHeight = i.uGeoPointViewportHeight, l.uniforms.uGeoPointMinVisiblePixelSize = i.uGeoPointMinVisiblePixelSize, l.vertexShader.includes("uGeoPointWorldSize") || (l.vertexShader = l.vertexShader.replace(
2838
2834
  "#include <common>",
2839
2835
  [
2840
2836
  "#include <common>",
@@ -2882,7 +2878,7 @@ class ye extends ee {
2882
2878
  f(this, "bounds", [0, 0, 0, 0]);
2883
2879
  f(this, "originalLayerColorsByIndex", /* @__PURE__ */ new Map());
2884
2880
  f(this, "colorOverridesByIndex", /* @__PURE__ */ new Map());
2885
- f(this, "displayThemeName", Ps);
2881
+ f(this, "displayThemeName", Ls);
2886
2882
  f(this, "displayContrastEnhancement", !0);
2887
2883
  f(this, "displayHexMemo", /* @__PURE__ */ new Map());
2888
2884
  f(this, "layerStateRevision", 0);
@@ -2916,7 +2912,7 @@ class ye extends ee {
2916
2912
  f(this, "effectiveRenderQuality", "full");
2917
2913
  f(this, "interactionRenderQualityOverride", null);
2918
2914
  f(this, "lineModeSwitchingEnabled", !1);
2919
- f(this, "autoQualityContext", { ...oa });
2915
+ f(this, "autoQualityContext", { ...la });
2920
2916
  f(this, "lineChunkRecords", []);
2921
2917
  f(this, "lineCanonicalMemoryStats", Tn());
2922
2918
  f(this, "nonLineChunkStats", []);
@@ -2940,7 +2936,7 @@ class ye extends ee {
2940
2936
  f(this, "resolveReady");
2941
2937
  f(this, "rejectReady");
2942
2938
  f(this, "resolveTextFont");
2943
- this.name = "GeoNode", this.resolveTextFont = e.resolveTextFont ?? ur, this.startReadyCycle();
2939
+ this.name = "GeoNode", this.resolveTextFont = e.resolveTextFont ?? hr, this.startReadyCycle();
2944
2940
  }
2945
2941
  get ready() {
2946
2942
  return this.readyPromise;
@@ -2964,6 +2960,26 @@ class ye extends ee {
2964
2960
  const a = i.visible !== r;
2965
2961
  a && (this.layerStateRevision += 1, (o = this.viewportInstancePresenter) == null || o.invalidateQueryCache()), i.visible = r, s && (s.visible = r), this.refreshAnnotationTextVisibilityForLayer(e), a && this.refreshDefaultInsertPresenterIfUnmanaged(), a && this.notifyInternalChange();
2966
2962
  }
2963
+ setLayerVisibleBatch(e) {
2964
+ var s;
2965
+ if (e.length === 0) return 0;
2966
+ const r = /* @__PURE__ */ new Map();
2967
+ for (const a of e)
2968
+ Number.isInteger(a.layerIndex) && r.set(a.layerIndex, a.visible);
2969
+ const i = [];
2970
+ for (const [a, o] of r) {
2971
+ const l = this.layerStatesByIndex.get(a);
2972
+ if (!l || l.visible === o) continue;
2973
+ l.visible = o;
2974
+ const c = this.layerGroupsByIndex.get(a);
2975
+ c && (c.visible = o), i.push(a);
2976
+ }
2977
+ if (i.length === 0) return 0;
2978
+ this.layerStateRevision += 1, (s = this.viewportInstancePresenter) == null || s.invalidateQueryCache();
2979
+ for (const a of i)
2980
+ this.refreshAnnotationTextVisibilityForLayer(a);
2981
+ return this.refreshDefaultInsertPresenterIfUnmanaged(), this.notifyInternalChange(), i.length;
2982
+ }
2967
2983
  setAnnotationOverlayVisible(e) {
2968
2984
  if (this.annotationOverlayVisible !== e) {
2969
2985
  this.annotationOverlayVisible = e;
@@ -2980,13 +2996,13 @@ class ye extends ee {
2980
2996
  const i = this.layerStatesByIndex.get(e), s = this.layerGroupsByIndex.get(e), a = this.originalLayerColorsByIndex.get(e);
2981
2997
  if (!i || !s || !a) return;
2982
2998
  const o = r === null ? null : Aa(r);
2983
- o ? this.colorOverridesByIndex.set(e, H(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = H(o ?? a), this.layerStateRevision += 1, s.traverse((d) => {
2999
+ o ? this.colorOverridesByIndex.set(e, H(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = H(o ?? a), this.layerStateRevision += 1, s.traverse((l) => {
2984
3000
  var h;
2985
- const l = (h = d.userData) == null ? void 0 : h.kind;
2986
- if (l === "text" || l === "text-batch") return;
2987
- const u = d.material, c = Array.isArray(u) ? u : u ? [u] : [];
2988
- for (const y of c)
2989
- gt(y) && (this.applyLayerColorState(y, o, this.displayElementKindForObject(d)), y.needsUpdate = !0);
3001
+ const c = (h = l.userData) == null ? void 0 : h.kind;
3002
+ if (c === "text" || c === "text-batch") return;
3003
+ const u = l.material, d = Array.isArray(u) ? u : u ? [u] : [];
3004
+ for (const y of d)
3005
+ gt(y) && (this.applyLayerColorState(y, o, this.displayElementKindForObject(l)), y.needsUpdate = !0);
2990
3006
  }), this.applyCachedLineChunkColors(e, o), this.applyLayerTextColors(e, o), this.notifyInternalChange();
2991
3007
  }
2992
3008
  setRenderQuality(e) {
@@ -3020,7 +3036,7 @@ class ye extends ee {
3020
3036
  if (((r = this.layersSnapshotCache) == null ? void 0 : r.revision) === this.layerStateRevision)
3021
3037
  return this.layersSnapshotCache.value;
3022
3038
  const e = Object.freeze(
3023
- this.layerOrder.map((i) => this.layerStatesByIndex.get(i)).filter((i) => i !== void 0).map((i) => Object.freeze(Ra(i)))
3039
+ this.layerOrder.map((i) => this.layerStatesByIndex.get(i)).filter((i) => i !== void 0).map((i) => Object.freeze(Ba(i)))
3024
3040
  );
3025
3041
  return this.layersSnapshotCache = { revision: this.layerStateRevision, value: e }, e;
3026
3042
  }
@@ -3126,18 +3142,18 @@ class ye extends ee {
3126
3142
  const o = new En({
3127
3143
  registry: r,
3128
3144
  table: Vn(i),
3129
- materialFactory: (l) => this.createInsertPresenterMaterial(l),
3145
+ materialFactory: (c) => this.createInsertPresenterMaterial(c),
3130
3146
  initialCapacity: Math.max(1, i.length),
3131
3147
  marginRatio: 0
3132
3148
  });
3133
3149
  if (o.attach(a), o.refresh(null, this.getLayerVisibility(), Pn, 0), o.currentVisibleVertexCount() <= 0)
3134
3150
  return o.dispose(), null;
3135
- let d = !1;
3151
+ let l = !1;
3136
3152
  return {
3137
3153
  object: a,
3138
3154
  bounds: s,
3139
3155
  dispose: () => {
3140
- d || (d = !0, o.dispose(), a.clear());
3156
+ l || (l = !0, o.dispose(), a.clear());
3141
3157
  }
3142
3158
  };
3143
3159
  }
@@ -3163,29 +3179,29 @@ class ye extends ee {
3163
3179
  if (!this.insertInstanceTable) return !1;
3164
3180
  const i = this.insertPresenterRecordKeysByInstanceId.get(e);
3165
3181
  if (!i || i.size === 0) return !1;
3166
- const s = r.rotation * Math.PI / 180, a = Math.cos(s), o = Math.sin(s), d = r.scaleX * a, l = r.scaleX * o, u = -r.scaleY * o, c = r.scaleY * a;
3182
+ const s = r.rotation * Math.PI / 180, a = Math.cos(s), o = Math.sin(s), l = r.scaleX * a, c = r.scaleX * o, u = -r.scaleY * o, d = r.scaleY * a;
3167
3183
  let h = !0;
3168
- for (const p of i) {
3169
- const m = this.insertPresenterRecordsByKey.get(p);
3184
+ for (const x of i) {
3185
+ const m = this.insertPresenterRecordsByKey.get(x);
3170
3186
  if (!m) continue;
3171
3187
  const b = {
3172
3188
  ...m,
3173
- matA: d,
3174
- matB: l,
3189
+ matA: l,
3190
+ matB: c,
3175
3191
  matC: u,
3176
- matD: c,
3192
+ matD: d,
3177
3193
  tx: r.tx,
3178
3194
  ty: r.ty,
3179
3195
  bbox: this.computeInsertPresenterWorldBBox(m.variantId, {
3180
- matA: d,
3181
- matB: l,
3196
+ matA: l,
3197
+ matB: c,
3182
3198
  matC: u,
3183
- matD: c,
3199
+ matD: d,
3184
3200
  tx: r.tx,
3185
3201
  ty: r.ty
3186
3202
  }) ?? m.bbox
3187
3203
  };
3188
- this.insertPresenterRecordsByKey.set(p, b), this.insertInstanceTable.replaceRecord(b) || (h = !1);
3204
+ this.insertPresenterRecordsByKey.set(x, b), this.insertInstanceTable.replaceRecord(b) || (h = !1);
3189
3205
  }
3190
3206
  return h ? (y = this.viewportInstancePresenter) == null || y.invalidateQueryCache() : this.rebuildViewportInsertPresenter([...this.insertPresenterRecordsByKey.values()]), this.refreshDefaultInsertPresenterIfUnmanaged(), this.notifyInternalChange(), !0;
3191
3207
  }
@@ -3213,8 +3229,8 @@ class ye extends ee {
3213
3229
  return this.traverse((a) => {
3214
3230
  const o = a.geometry;
3215
3231
  if (!o) return;
3216
- const d = o.userData.cadDisplaySourceColor, l = o.userData.cadDisplayColorRuns;
3217
- d instanceof Uint8Array ? (e += 1, r += d.byteLength) : l && l.length > 0 && (e += 1);
3232
+ const l = o.userData.cadDisplaySourceColor, c = o.userData.cadDisplayColorRuns;
3233
+ l instanceof Uint8Array ? (e += 1, r += l.byteLength) : c && c.length > 0 && (e += 1);
3218
3234
  const u = o.getAttribute("color");
3219
3235
  u instanceof $ && ArrayBuffer.isView(u.array) && (i += u.array.byteLength, u.array instanceof Float32Array && (s += u.array.byteLength));
3220
3236
  }), Object.freeze({
@@ -3240,8 +3256,8 @@ class ye extends ee {
3240
3256
  for (const [s, a] of this.annotationTextRecordsByOwnerKey) {
3241
3257
  const o = e.get(s);
3242
3258
  if (o === void 0) continue;
3243
- const d = r.get(o), l = a.map((u) => this.createInsertVisibilityHandleForAnnotationText(u));
3244
- d ? d.push(...l) : r.set(o, [...l]);
3259
+ const l = r.get(o), c = a.map((u) => this.createInsertVisibilityHandleForAnnotationText(u));
3260
+ l ? l.push(...c) : r.set(o, [...c]);
3245
3261
  }
3246
3262
  return r;
3247
3263
  }
@@ -3350,14 +3366,14 @@ class ye extends ee {
3350
3366
  const r = [], i = this.createInsertInstanceRecords(e.instances);
3351
3367
  let s = !1, a = !1;
3352
3368
  for (const o of e.variants) {
3353
- const d = this.createVariantGeometryInput(o);
3354
- this.insertPresenterVariantInputs.has(o.variantId) && (s = !0), this.insertPresenterVariantInputs.set(o.variantId, d), r.push(d);
3369
+ const l = this.createVariantGeometryInput(o);
3370
+ this.insertPresenterVariantInputs.has(o.variantId) && (s = !0), this.insertPresenterVariantInputs.set(o.variantId, l), r.push(l);
3355
3371
  }
3356
3372
  for (const o of i) {
3357
- const d = ca(o);
3358
- this.insertPresenterRecordsByKey.has(d) && (a = !0), this.insertPresenterRecordsByKey.set(d, o);
3359
- let l = this.insertPresenterRecordKeysByInstanceId.get(o.instanceId);
3360
- l || (l = /* @__PURE__ */ new Set(), this.insertPresenterRecordKeysByInstanceId.set(o.instanceId, l)), l.add(d);
3373
+ const l = ua(o);
3374
+ this.insertPresenterRecordsByKey.has(l) && (a = !0), this.insertPresenterRecordsByKey.set(l, o);
3375
+ let c = this.insertPresenterRecordKeysByInstanceId.get(o.instanceId);
3376
+ c || (c = /* @__PURE__ */ new Set(), this.insertPresenterRecordKeysByInstanceId.set(o.instanceId, c)), c.add(l);
3361
3377
  }
3362
3378
  return { variantInputs: r, records: i, replacedVariant: s, replacedRecord: a };
3363
3379
  }
@@ -3390,7 +3406,7 @@ class ye extends ee {
3390
3406
  }
3391
3407
  rebuildViewportInsertPresenterFromAccumulatedModel() {
3392
3408
  var e, r;
3393
- (e = this.viewportInstancePresenter) == null || e.dispose(), this.viewportInstancePresenter = null, this.insertInstanceTable = null, (r = this.blockGeometryRegistry) == null || r.dispose(), this.blockGeometryRegistry = Ks([...this.insertPresenterVariantInputs.values()]), this.rebuildViewportInsertPresenter([...this.insertPresenterRecordsByKey.values()]);
3409
+ (e = this.viewportInstancePresenter) == null || e.dispose(), this.viewportInstancePresenter = null, this.insertInstanceTable = null, (r = this.blockGeometryRegistry) == null || r.dispose(), this.blockGeometryRegistry = Ws([...this.insertPresenterVariantInputs.values()]), this.rebuildViewportInsertPresenter([...this.insertPresenterRecordsByKey.values()]);
3394
3410
  }
3395
3411
  rebuildViewportInsertPresenter(e) {
3396
3412
  var r;
@@ -3407,11 +3423,11 @@ class ye extends ee {
3407
3423
  const i = (o = this.blockGeometryRegistry) == null ? void 0 : o.getVariant(e);
3408
3424
  if (!i) return null;
3409
3425
  let s = null;
3410
- for (const d of i.byKind.values())
3411
- for (const l of d)
3412
- s = fe(s, l.bbox);
3426
+ for (const l of i.byKind.values())
3427
+ for (const c of l)
3428
+ s = fe(s, c.bbox);
3413
3429
  if (!s) return null;
3414
- const a = Kr(s, r);
3430
+ const a = Wr(s, r);
3415
3431
  return Tt(a) ? a : null;
3416
3432
  }
3417
3433
  _debugHasInsertPresenter() {
@@ -3439,7 +3455,7 @@ class ye extends ee {
3439
3455
  }
3440
3456
  appendExternalVariantDeltaHeader(e) {
3441
3457
  if (this.disposed) return;
3442
- const r = this.meta.textCount, i = xa(this.bounds, e.bounds);
3458
+ const r = this.meta.textCount, i = ga(this.bounds, e.bounds);
3443
3459
  this.bounds = i, this.meta = {
3444
3460
  bounds: we(i),
3445
3461
  entityCount: this.meta.entityCount + e.entityCount,
@@ -3447,7 +3463,7 @@ class ye extends ee {
3447
3463
  fillCount: this.meta.fillCount + e.fillCount,
3448
3464
  dotCount: this.meta.dotCount + e.dotCount,
3449
3465
  textCount: this.meta.textCount + e.textCount
3450
- }, this.metaRevision += 1, this.layerBlockUsages = ba(this.layerBlockUsages, e.layerBlockUsages), this.insertRuntime = va(this.insertRuntime, e.insertRuntime, r), this.rebuildInsertRuntimeInstanceIndex(), this.updateAutoQualityContext({
3466
+ }, this.metaRevision += 1, this.layerBlockUsages = Ia(this.layerBlockUsages, e.layerBlockUsages), this.insertRuntime = Ra(this.insertRuntime, e.insertRuntime, r), this.rebuildInsertRuntimeInstanceIndex(), this.updateAutoQualityContext({
3451
3467
  visibleVertexCount: this.meta.lineCount + this.meta.fillCount + this.meta.dotCount,
3452
3468
  zoom: this.autoQualityContext.zoom
3453
3469
  }), this.notifyInternalChange();
@@ -3459,7 +3475,7 @@ class ye extends ee {
3459
3475
  }
3460
3476
  this.compactGeometryByLayer(), this.refreshDefaultInsertPresenterIfUnmanaged(), this.resolveReadyOnce();
3461
3477
  }
3462
- async _finalizeIncrementally(e, r = vr, i = {}) {
3478
+ async _finalizeIncrementally(e, r = Rr, i = {}) {
3463
3479
  if (this.disposed) {
3464
3480
  this.rejectReadyOnce(new U("E_DISPOSED", "GeoNode disposed before completion"));
3465
3481
  return;
@@ -3502,18 +3518,18 @@ class ye extends ee {
3502
3518
  sizeAttenuation: !1,
3503
3519
  depthTest: !1,
3504
3520
  depthWrite: !1
3505
- }), d = Ta(o, {
3521
+ }), l = Pa(o, {
3506
3522
  pointWorldSize: a,
3507
3523
  viewportHeight: this.lineResolution.height
3508
3524
  });
3509
- this.worldSizedPointUniforms.add(d);
3510
- const l = o.dispose.bind(o);
3525
+ this.worldSizedPointUniforms.add(l);
3526
+ const c = o.dispose.bind(o);
3511
3527
  return o.dispose = () => {
3512
- this.worldSizedPointUniforms.delete(d), l();
3528
+ this.worldSizedPointUniforms.delete(l), c();
3513
3529
  }, this.applyLayerColorState(o, r, i), o;
3514
3530
  }
3515
3531
  resolvePointWorldSize(e) {
3516
- return !Number.isFinite(e) || e <= 0 ? 1 : e * ua;
3532
+ return !Number.isFinite(e) || e <= 0 ? 1 : e * ha;
3517
3533
  }
3518
3534
  appendTextChunk(e) {
3519
3535
  const r = this.getOrCreateTextBatch(e.li), i = this.createRenderableTextChunk(e);
@@ -3538,19 +3554,19 @@ class ye extends ee {
3538
3554
  layerIndex: e.li,
3539
3555
  ownerKey: a,
3540
3556
  insertVisible: !0
3541
- }, d = this.annotationTextRecordsByLayerIndex.get(e.li) ?? [];
3542
- if (d.push(o), this.annotationTextRecordsByLayerIndex.set(e.li, d), a) {
3557
+ }, l = this.annotationTextRecordsByLayerIndex.get(e.li) ?? [];
3558
+ if (l.push(o), this.annotationTextRecordsByLayerIndex.set(e.li, l), a) {
3543
3559
  const u = this.annotationTextRecordsByOwnerKey.get(a) ?? [];
3544
3560
  u.push(o), this.annotationTextRecordsByOwnerKey.set(a, u);
3545
3561
  }
3546
3562
  this.applyAnnotationTextRenderableVisibility(o);
3547
- const l = Number(r.userData.textCount || 0);
3548
- r.userData.textCount = l + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: H(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3563
+ const c = Number(r.userData.textCount || 0);
3564
+ r.userData.textCount = c + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: H(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3549
3565
  }
3550
3566
  getOrCreateTextBatch(e) {
3551
3567
  const r = this.textBatchByLayerIndex.get(e);
3552
3568
  if (r) return r;
3553
- const i = cn, s = new i();
3569
+ const i = dn, s = new i();
3554
3570
  return this.configureTextBatchForStaticBounds(s), s.name = "text-batch", s.renderOrder = 3, s.depthOffset = -0.1, s.userData.kind = "text-batch", s.userData.layerIndex = e, s.userData.textCount = 0, typeof globalThis.self < "u" && s.addEventListener("synccomplete", () => {
3555
3571
  this.markTextBatchBoundsClean(s), this.notifyInternalChange();
3556
3572
  }), this.getOrCreateKindGroup(e, "text").add(s), this.textBatchByLayerIndex.set(e, s), s;
@@ -3558,7 +3574,7 @@ class ye extends ee {
3558
3574
  getOrCreateAnnotationTextBatch(e) {
3559
3575
  const r = this.annotationTextBatchByLayerIndex.get(e);
3560
3576
  if (r) return r;
3561
- const i = cn, s = new i();
3577
+ const i = dn, s = new i();
3562
3578
  return this.configureTextBatchForStaticBounds(s), s.name = "annotation-text-batch", s.renderOrder = 4, s.depthOffset = -0.2, s.visible = this.annotationOverlayVisible && this.isLayerVisible(e), s.userData.kind = "text-batch", s.userData.layerIndex = e, s.userData.textCount = 0, s.userData.annotationOverlay = !0, typeof globalThis.self < "u" && s.addEventListener("synccomplete", () => {
3563
3579
  this.markTextBatchBoundsClean(s), this.notifyInternalChange();
3564
3580
  }), this.getOrCreateAnnotationKindGroup(e, "text").add(s), this.annotationTextBatchByLayerIndex.set(e, s), s;
@@ -3577,7 +3593,7 @@ class ye extends ee {
3577
3593
  e && (e.userData[Fe] = !1);
3578
3594
  }
3579
3595
  scheduleTextBatchSync(e) {
3580
- this.pendingTextBatchSync.add(e), !this.textBatchSyncScheduled && (this.textBatchSyncScheduled = !0, ai(() => {
3596
+ this.pendingTextBatchSync.add(e), !this.textBatchSyncScheduled && (this.textBatchSyncScheduled = !0, li(() => {
3581
3597
  if (this.textBatchSyncScheduled = !1, this.disposed) {
3582
3598
  this.pendingTextBatchSync.clear();
3583
3599
  return;
@@ -3588,40 +3604,40 @@ class ye extends ee {
3588
3604
  i.parent && i.sync();
3589
3605
  }));
3590
3606
  }
3591
- createRenderableChunk(e, r, i, s, a, o, d) {
3592
- const l = new Nt();
3593
- l.setAttribute("position", new Qn(i, 3)), this.registerGeometryDisplayColors(
3594
- l,
3607
+ createRenderableChunk(e, r, i, s, a, o, l) {
3608
+ const c = new Nt();
3609
+ c.setAttribute("position", new $n(i, 3)), this.registerGeometryDisplayColors(
3610
+ c,
3595
3611
  s,
3596
3612
  r,
3597
3613
  e === "fill" ? "fill" : e === "dot" ? "dot" : "line",
3598
- d
3614
+ l
3599
3615
  );
3600
3616
  const u = this.colorOverridesByIndex.get(r) ?? null;
3601
- let c;
3617
+ let d;
3602
3618
  if (e === "line") {
3603
3619
  const y = new ln({ vertexColors: !0 });
3604
3620
  this.applyLayerColorState(y, u, e);
3605
- const p = new zt(l, y);
3606
- p.renderOrder = 1, c = p;
3621
+ const x = new zt(c, y);
3622
+ x.renderOrder = 1, d = x;
3607
3623
  } else if (e === "fill") {
3608
- const y = new dn({
3624
+ const y = new cn({
3609
3625
  vertexColors: !0,
3610
3626
  side: vt,
3611
3627
  depthWrite: !1
3612
3628
  });
3613
3629
  this.applyLayerColorState(y, u, e);
3614
- const p = new Ht(l, y);
3615
- p.renderOrder = 0, c = p;
3630
+ const x = new Ht(c, y);
3631
+ x.renderOrder = 0, d = x;
3616
3632
  } else {
3617
- const y = this.createPointMaterial(r, u, e), p = new $n(l, y);
3618
- p.renderOrder = 2, c = p;
3633
+ const y = this.createPointMaterial(r, u, e), x = new jn(c, y);
3634
+ x.renderOrder = 2, d = x;
3619
3635
  }
3620
- c.name = `${e}-chunk`, c.userData.kind = e, c.userData.layerIndex = r, c.userData.vertexCount = a;
3636
+ d.name = `${e}-chunk`, d.userData.kind = e, d.userData.layerIndex = r, d.userData.vertexCount = a;
3621
3637
  const h = o === void 0 ? _e(i, Math.floor(i.length / 3), 3) : o;
3622
- return c.userData.bbox = h, this.nonLineChunkStats.push({ layerIndex: r, vertexCount: a, bbox: h }), c;
3638
+ return d.userData.bbox = h, this.nonLineChunkStats.push({ layerIndex: r, vertexCount: a, bbox: h }), d;
3623
3639
  }
3624
- createRenderableLineChunk(e, r, i, s, a, o, d, l, u = 3, c) {
3640
+ createRenderableLineChunk(e, r, i, s, a, o, l, c, u = 3, d) {
3625
3641
  const h = this.makeLineChunkRecord(
3626
3642
  e,
3627
3643
  r,
@@ -3629,35 +3645,35 @@ class ye extends ee {
3629
3645
  s,
3630
3646
  a,
3631
3647
  o,
3632
- d,
3633
3648
  l,
3649
+ c,
3634
3650
  u,
3635
- c
3651
+ d
3636
3652
  );
3637
3653
  return this.registerLineChunkRecord(h), h.renderable;
3638
3654
  }
3639
- makeLineChunkRecord(e, r, i, s, a, o, d, l, u = 3, c) {
3640
- const h = this.resolveLineweightPx(r, c), y = a < 2 || a % 2 !== 0 || h <= 1, p = On(l, a), m = d === "xy-zero-z" || u === 2 ? ta(i, a, u) : ea(i, a), b = o === void 0 ? _e(i, a, u) : o, v = this.resolveInitialLineChunkVariant(r, a, y, c), I = this.buildLineRenderableViews(
3655
+ makeLineChunkRecord(e, r, i, s, a, o, l, c, u = 3, d) {
3656
+ const h = this.resolveLineweightPx(r, d), y = a < 2 || a % 2 !== 0 || h <= 1, x = On(c, a), m = l === "xy-zero-z" || u === 2 ? na(i, a, u) : ta(i, a), b = o === void 0 ? _e(i, a, u) : o, R = this.resolveInitialLineChunkVariant(r, a, y, d), I = this.buildLineRenderableViews(
3641
3657
  r,
3642
3658
  m,
3643
3659
  s,
3644
3660
  a,
3645
3661
  y,
3646
3662
  b,
3647
- p,
3648
- c
3649
- ), w = v === "fat" && I.fatRenderable ? I.fatRenderable : I.thinRenderable, T = {
3663
+ x,
3664
+ d
3665
+ ), w = R === "fat" && I.fatRenderable ? I.fatRenderable : I.thinRenderable, T = {
3650
3666
  layerIndex: r,
3651
- ...c === void 0 ? {} : { lineweightPx: c },
3667
+ ...d === void 0 ? {} : { lineweightPx: d },
3652
3668
  parent: e,
3653
3669
  position: m,
3654
- canonicalMemoryStats: ia(m, s, a),
3670
+ canonicalMemoryStats: sa(m, s, a),
3655
3671
  col: s,
3656
- colorRuns: p,
3672
+ colorRuns: x,
3657
3673
  vertexCount: a,
3658
3674
  bbox: b,
3659
3675
  forceThin: y,
3660
- activeVariant: v,
3676
+ activeVariant: R,
3661
3677
  renderable: w,
3662
3678
  thinRenderable: I.thinRenderable,
3663
3679
  fatRenderable: I.fatRenderable,
@@ -3670,19 +3686,19 @@ class ye extends ee {
3670
3686
  this.lineChunkRecords.push(e), this.addLineCanonicalStats(e);
3671
3687
  }
3672
3688
  addLineCanonicalStats(e) {
3673
- this.lineCanonicalMemoryStats = sa(
3689
+ this.lineCanonicalMemoryStats = aa(
3674
3690
  this.lineCanonicalMemoryStats,
3675
3691
  e.canonicalMemoryStats
3676
3692
  );
3677
3693
  }
3678
3694
  subtractLineCanonicalStats(e) {
3679
- this.lineCanonicalMemoryStats = aa(
3695
+ this.lineCanonicalMemoryStats = oa(
3680
3696
  this.lineCanonicalMemoryStats,
3681
3697
  e.canonicalMemoryStats
3682
3698
  );
3683
3699
  }
3684
3700
  rebuildLineVariantStats() {
3685
- const e = pa();
3701
+ const e = xa();
3686
3702
  for (const r of this.lineChunkRecords)
3687
3703
  r.activeVariant === "thin" && (e.activeThinCount += 1), r.activeVariant === "fat" && (e.activeFatCount += 1), r.thinRenderable && r.thinRenderable !== r.renderable && (e.cachedThinCount += 1), r.fatRenderable && r.fatRenderable !== r.renderable && (e.cachedFatCount += 1);
3688
3704
  return e;
@@ -3702,43 +3718,43 @@ class ye extends ee {
3702
3718
  shouldUseThinLineVariant(e, r, i) {
3703
3719
  return i || r < 2 || r % 2 !== 0 ? !0 : this.lineModeSwitchingEnabled ? this.effectiveRenderQuality === "stress" && e < un : e < un;
3704
3720
  }
3705
- buildLineRenderableViews(e, r, i, s, a, o, d, l) {
3706
- const u = this.resolveLineweightPx(e, l), c = r.kind === "xy" ? r.xy : r.xyz, h = r.kind === "xy" ? 2 : 3, y = o ?? _e(c, s, h) ?? {
3721
+ buildLineRenderableViews(e, r, i, s, a, o, l, c) {
3722
+ const u = this.resolveLineweightPx(e, c), d = r.kind === "xy" ? r.xy : r.xyz, h = r.kind === "xy" ? 2 : 3, y = o ?? _e(d, s, h) ?? {
3707
3723
  minX: 0,
3708
3724
  minY: 0,
3709
3725
  maxX: 0,
3710
3726
  maxY: 0
3711
- }, p = i.slice(), m = _s({
3712
- position: c,
3727
+ }, x = i.slice(), m = Gs({
3728
+ position: d,
3713
3729
  positionItemSize: h,
3714
3730
  color: i,
3715
3731
  vertexCount: s,
3716
3732
  bbox: y
3717
3733
  });
3718
- this.finalizeCadLineRenderable(m, e, s, y, i, p, d);
3734
+ this.finalizeCadLineRenderable(m, e, s, y, i, x, l);
3719
3735
  let b = null;
3720
- return !a && s >= 2 && s % 2 === 0 && (b = Gs({
3721
- position: c,
3736
+ return !a && s >= 2 && s % 2 === 0 && (b = Us({
3737
+ position: d,
3722
3738
  positionItemSize: h,
3723
3739
  color: i,
3724
3740
  vertexCount: s,
3725
3741
  linewidthPx: u,
3726
- resolution: new Xn(this.lineResolution.width, this.lineResolution.height),
3742
+ resolution: new Yn(this.lineResolution.width, this.lineResolution.height),
3727
3743
  bbox: y
3728
- }), this.finalizeCadLineRenderable(b, e, s, y, i, p, d)), {
3744
+ }), this.finalizeCadLineRenderable(b, e, s, y, i, x, l)), {
3729
3745
  thinRenderable: m,
3730
3746
  fatRenderable: b,
3731
3747
  thinMaterial: m.material,
3732
3748
  fatMaterial: (b == null ? void 0 : b.material) ?? null
3733
3749
  };
3734
3750
  }
3735
- finalizeCadLineRenderable(e, r, i, s, a, o, d) {
3751
+ finalizeCadLineRenderable(e, r, i, s, a, o, l) {
3736
3752
  e.name = "line-chunk", e.renderOrder = 1, e.userData.kind = "line", e.userData.layerIndex = r, e.userData.vertexCount = i, e.userData.bbox = s;
3737
- const l = e.geometry;
3738
- l.userData.cadDisplayColorTarget = {
3753
+ const c = e.geometry;
3754
+ c.userData.cadDisplayColorTarget = {
3739
3755
  array: a,
3740
- markNeedsUpdate: () => ft(l)
3741
- }, this.installGeometryDisplayColorMetadata(l, o, r, "line", d);
3756
+ markNeedsUpdate: () => ft(c)
3757
+ }, this.installGeometryDisplayColorMetadata(c, o, r, "line", l);
3742
3758
  const u = this.colorOverridesByIndex.get(r) ?? null;
3743
3759
  this.applyLayerColorState(e.material, u, "line"), e.material.needsUpdate = !0;
3744
3760
  }
@@ -3760,7 +3776,7 @@ class ye extends ee {
3760
3776
  this.applyDisplayColorsToGeometry(r.geometry);
3761
3777
  }
3762
3778
  createRenderableTextChunk(e) {
3763
- const r = Jr, i = this.resolveTextFont(e.t), s = new r();
3779
+ const r = ei, i = this.resolveTextFont(e.t), s = new r();
3764
3780
  s.text = i.text, s.fontSize = e.h, s.position.set(e.x, e.y, 0), s.rotation.z = (e.r || 0) * Math.PI / 180, s.color = this.resolveDisplayHexForRgb(e.c, e.li, "text"), s.anchorX = ye.resolveTextAnchorX(e.ha), s.anchorY = ye.resolveTextAnchorY(e.va), i.fontUrl && (s.font = i.fontUrl), e.w && (s.maxWidth = e.w), e.lh && (s.lineHeight = e.lh);
3765
3781
  const a = e.wf || 1;
3766
3782
  return s.scale.x = (e.mx ? -1 : 1) * a, e.my && (s.scale.y = -1), this.commitTroikaTextTransform(s), s.name = "text-chunk", s.userData.kind = "text", s.userData.layerIndex = e.li, s.userData.text = { ...e, c: H(e.c) }, s.userData.renderedText = i.text, s.userData.fontKind = i.kind ?? "default", s.userData.replacedUnsupportedText = i.replacedUnsupported === !0, s;
@@ -3803,7 +3819,7 @@ class ye extends ee {
3803
3819
  }
3804
3820
  getOrCreateAnnotationKindGroup(e, r) {
3805
3821
  const i = this.getOrCreateAnnotationOverlayGroup(e), s = r === "text" ? "annotation-text" : `annotation-${r}`, a = i.children.find(
3806
- (d) => d instanceof ee && d.name === s
3822
+ (l) => l instanceof ee && l.name === s
3807
3823
  );
3808
3824
  if (a) return a;
3809
3825
  const o = new ee();
@@ -3855,14 +3871,14 @@ class ye extends ee {
3855
3871
  const a = new ee();
3856
3872
  if (a.name = r ?? `Layer ${e}`, a.visible = ((o = this.layerStatesByIndex.get(e)) == null ? void 0 : o.visible) ?? i, a.userData.layerIndex = e, this.layerGroupsByIndex.set(e, a), this.add(a), !this.layerStatesByIndex.has(e)) {
3857
3873
  this.layerOrder.push(e);
3858
- const d = [255, 255, 255];
3874
+ const l = [255, 255, 255];
3859
3875
  this.layerStatesByIndex.set(e, {
3860
3876
  index: e,
3861
3877
  name: a.name,
3862
- color: H(d),
3878
+ color: H(l),
3863
3879
  lw_px: 1,
3864
3880
  visible: i
3865
- }), this.originalLayerColorsByIndex.set(e, H(d)), this.layerStateRevision += 1;
3881
+ }), this.originalLayerColorsByIndex.set(e, H(l)), this.layerStateRevision += 1;
3866
3882
  }
3867
3883
  return a;
3868
3884
  }
@@ -3886,9 +3902,9 @@ class ye extends ee {
3886
3902
  run: () => this.compactNonLineChunksForSingleLayer(s, "dot")
3887
3903
  }
3888
3904
  );
3889
- await $s(i, {
3905
+ await js(i, {
3890
3906
  opsPerPass: e,
3891
- frameBudgetMs: Rr,
3907
+ frameBudgetMs: Br,
3892
3908
  onYield: r
3893
3909
  }), this.rebuildNonLineChunkStats(), this.notifyInternalChange();
3894
3910
  }
@@ -3902,34 +3918,34 @@ class ye extends ee {
3902
3918
  return !1;
3903
3919
  const i = /* @__PURE__ */ new Set(), s = [];
3904
3920
  for (const o of r) {
3905
- let d = 0, l = null;
3921
+ let l = 0, c = null;
3906
3922
  for (const I of o.records)
3907
- d += I.vertexCount, l = fe(l, I.bbox);
3908
- const u = o.canonicalKind === "xy" ? 2 : 3, c = new Float32Array(d * u), h = new Uint8Array(d * 3), y = [];
3909
- let p = !0, m = 0;
3923
+ l += I.vertexCount, c = fe(c, I.bbox);
3924
+ const u = o.canonicalKind === "xy" ? 2 : 3, d = new Float32Array(l * u), h = new Uint8Array(l * 3), y = [];
3925
+ let x = !0, m = 0;
3910
3926
  for (const I of o.records)
3911
- ra(
3927
+ ia(
3912
3928
  I.position,
3913
3929
  I.vertexCount,
3914
- c,
3930
+ d,
3915
3931
  m,
3916
3932
  u
3917
- ), h.set(I.col, m * 3), I.colorRuns && I.colorRuns.length > 0 ? Fn(y, I.colorRuns, m) : p = !1, m += I.vertexCount;
3933
+ ), h.set(I.col, m * 3), I.colorRuns && I.colorRuns.length > 0 ? Fn(y, I.colorRuns, m) : x = !1, m += I.vertexCount;
3918
3934
  for (const I of o.records)
3919
3935
  i.add(I), this.subtractLineCanonicalStats(I), this.disposeLineChunkRecord(I);
3920
- const b = p ? Pt(y) : void 0, v = this.makeLineChunkRecord(
3936
+ const b = x ? Pt(y) : void 0, R = this.makeLineChunkRecord(
3921
3937
  o.parent,
3922
3938
  e,
3923
- c,
3924
- h,
3925
3939
  d,
3940
+ h,
3926
3941
  l,
3942
+ c,
3927
3943
  u === 2 ? "xy-zero-z" : void 0,
3928
3944
  b,
3929
3945
  u,
3930
3946
  o.lineweightPx
3931
3947
  );
3932
- o.parent.add(v.renderable), this.addLineCanonicalStats(v), s.push(v);
3948
+ o.parent.add(R.renderable), this.addLineCanonicalStats(R), s.push(R);
3933
3949
  }
3934
3950
  const a = this.lineChunkRecords.filter((o) => !i.has(o));
3935
3951
  return this.lineChunkRecords.length = 0, this.lineChunkRecords.push(...a, ...s), !0;
@@ -3955,7 +3971,7 @@ class ye extends ee {
3955
3971
  this.compactNonLineChunksForSingleLayer(r, e);
3956
3972
  }
3957
3973
  compactNonLineChunksForSingleLayer(e, r) {
3958
- var v, I;
3974
+ var R, I;
3959
3975
  const i = this.findKindGroup(e, r);
3960
3976
  if (!i || i.children.length <= 1)
3961
3977
  return !1;
@@ -3963,29 +3979,29 @@ class ye extends ee {
3963
3979
  if (s.length <= 1)
3964
3980
  return !1;
3965
3981
  let a = 0, o = null;
3966
- const d = [], l = [], u = [];
3967
- let c = !0;
3982
+ const l = [], c = [], u = [];
3983
+ let d = !0;
3968
3984
  for (const w of s) {
3969
- const A = w.geometry;
3970
- if (!A) continue;
3971
- const B = A.getAttribute("position"), E = A.getAttribute("color");
3972
- if (!(B instanceof $) || !(E instanceof $) || !(B.array instanceof Float32Array)) continue;
3973
- const S = Number(((v = w.userData) == null ? void 0 : v.vertexCount) || 0);
3985
+ const B = w.geometry;
3986
+ if (!B) continue;
3987
+ const A = B.getAttribute("position"), E = B.getAttribute("color");
3988
+ if (!(A instanceof $) || !(E instanceof $) || !(A.array instanceof Float32Array)) continue;
3989
+ const S = Number(((R = w.userData) == null ? void 0 : R.vertexCount) || 0);
3974
3990
  if (S <= 0) continue;
3975
- const P = A.userData.cadDisplaySourceColor, O = A.userData.cadDisplayColorRuns;
3976
- O && O.length > 0 ? Fn(u, O, a) : c = !1, a += S, d.push(B.array), l.push(P instanceof Uint8Array ? P : ms(E)), o = fe(o, ((I = w.userData) == null ? void 0 : I.bbox) ?? null);
3991
+ const P = B.userData.cadDisplaySourceColor, O = B.userData.cadDisplayColorRuns;
3992
+ O && O.length > 0 ? Fn(u, O, a) : d = !1, a += S, l.push(A.array), c.push(P instanceof Uint8Array ? P : ps(E)), o = fe(o, ((I = w.userData) == null ? void 0 : I.bbox) ?? null);
3977
3993
  }
3978
3994
  for (const w of s)
3979
3995
  i.remove(w), bt(w);
3980
3996
  if (a <= 0)
3981
3997
  return !1;
3982
3998
  const h = new Float32Array(a * 3), y = new Uint8Array(a * 3);
3983
- let p = 0;
3984
- for (let w = 0; w < d.length; w += 1) {
3985
- const T = Math.floor(d[w].length / 3), A = p * 3;
3986
- h.set(d[w], A), y.set(l[w], A), p += T;
3999
+ let x = 0;
4000
+ for (let w = 0; w < l.length; w += 1) {
4001
+ const T = Math.floor(l[w].length / 3), B = x * 3;
4002
+ h.set(l[w], B), y.set(c[w], B), x += T;
3987
4003
  }
3988
- const m = c ? Pt(u) : void 0, b = this.createRenderableChunk(
4004
+ const m = d ? Pt(u) : void 0, b = this.createRenderableChunk(
3989
4005
  r,
3990
4006
  e,
3991
4007
  h,
@@ -4004,9 +4020,9 @@ class ye extends ee {
4004
4020
  for (const a of this.layerOrder) {
4005
4021
  const o = this.findKindGroup(a, s);
4006
4022
  if (o)
4007
- for (const d of o.children) {
4008
- const l = Number(((r = d.userData) == null ? void 0 : r.vertexCount) || 0), u = ((i = d.userData) == null ? void 0 : i.bbox) ?? null;
4009
- this.nonLineChunkStats.push({ layerIndex: a, vertexCount: l, bbox: u });
4023
+ for (const l of o.children) {
4024
+ const c = Number(((r = l.userData) == null ? void 0 : r.vertexCount) || 0), u = ((i = l.userData) == null ? void 0 : i.bbox) ?? null;
4025
+ this.nonLineChunkStats.push({ layerIndex: a, vertexCount: c, bbox: u });
4010
4026
  }
4011
4027
  }
4012
4028
  }
@@ -4034,14 +4050,14 @@ class ye extends ee {
4034
4050
  }
4035
4051
  refreshDisplayColors() {
4036
4052
  this.traverse((e) => {
4037
- var u, c;
4053
+ var u, d;
4038
4054
  const r = (u = e.userData) == null ? void 0 : u.kind;
4039
4055
  if (r === "text" || r === "text-batch") return;
4040
4056
  const i = e.geometry;
4041
4057
  i && this.applyDisplayColorsToGeometry(i);
4042
- const s = e.material, a = Number.isInteger((c = e.userData) == null ? void 0 : c.layerIndex) ? Number(e.userData.layerIndex) : null, o = a === null ? null : this.colorOverridesByIndex.get(a) ?? null, d = this.displayElementKindForObject(e), l = Array.isArray(s) ? s : s ? [s] : [];
4043
- for (const h of l)
4044
- gt(h) && (this.applyLayerColorState(h, o, d), h.needsUpdate = !0);
4058
+ const s = e.material, a = Number.isInteger((d = e.userData) == null ? void 0 : d.layerIndex) ? Number(e.userData.layerIndex) : null, o = a === null ? null : this.colorOverridesByIndex.get(a) ?? null, l = this.displayElementKindForObject(e), c = Array.isArray(s) ? s : s ? [s] : [];
4059
+ for (const h of c)
4060
+ gt(h) && (this.applyLayerColorState(h, o, l), h.needsUpdate = !0);
4045
4061
  });
4046
4062
  for (const e of this.layerOrder)
4047
4063
  this.applyLayerTextColors(e, this.colorOverridesByIndex.get(e) ?? null);
@@ -4057,25 +4073,25 @@ class ye extends ee {
4057
4073
  this.applyDisplayColorsToGeometry(o);
4058
4074
  }
4059
4075
  installGeometryDisplayColorMetadata(e, r, i, s, a) {
4060
- const o = e, d = Math.floor(r.length / 3), l = On(a, d);
4061
- return l ? (delete o.userData.cadDisplaySourceColor, o.userData.cadDisplayColorRuns = l) : (o.userData.cadDisplaySourceColor = fr(r).slice(), delete o.userData.cadDisplayColorRuns), o.userData.cadDisplayVertexCount = d, o.userData.cadDisplayLayerIndex = i, o.userData.cadDisplayElementKind = s, o;
4076
+ const o = e, l = Math.floor(r.length / 3), c = On(a, l);
4077
+ return c ? (delete o.userData.cadDisplaySourceColor, o.userData.cadDisplayColorRuns = c) : (o.userData.cadDisplaySourceColor = yr(r).slice(), delete o.userData.cadDisplayColorRuns), o.userData.cadDisplayVertexCount = l, o.userData.cadDisplayLayerIndex = i, o.userData.cadDisplayElementKind = s, o;
4062
4078
  }
4063
4079
  applyDisplayColorsToGeometry(e) {
4064
- const r = e, i = r.userData.cadDisplaySourceColor, s = r.userData.cadDisplayColorRuns, a = Number(r.userData.cadDisplayVertexCount ?? 0), o = Number(r.userData.cadDisplayLayerIndex ?? 0), d = r.userData.cadDisplayElementKind ?? "line", l = s && s.length > 0 && Ye(a, s), u = r.userData.cadDisplayColorTarget;
4080
+ const r = e, i = r.userData.cadDisplaySourceColor, s = r.userData.cadDisplayColorRuns, a = Number(r.userData.cadDisplayVertexCount ?? 0), o = Number(r.userData.cadDisplayLayerIndex ?? 0), l = r.userData.cadDisplayElementKind ?? "line", c = s && s.length > 0 && Ye(a, s), u = r.userData.cadDisplayColorTarget;
4065
4081
  if (u) {
4066
- if (l) {
4082
+ if (c) {
4067
4083
  const y = a * 3;
4068
4084
  if (u.array.length !== y)
4069
4085
  throw new Error(
4070
4086
  `CAD display color target length mismatch: expected ${y}, received ${u.array.length}`
4071
4087
  );
4072
- const p = St(
4088
+ const x = St(
4073
4089
  u.array,
4074
4090
  a,
4075
4091
  s,
4076
- (m) => this.resolveDisplayRgbForLegacyRgb(m, o, d)
4092
+ (m) => this.resolveDisplayRgbForLegacyRgb(m, o, l)
4077
4093
  );
4078
- this.recordDisplayColorBuildStats(p), u.markNeedsUpdate();
4094
+ this.recordDisplayColorBuildStats(x), u.markNeedsUpdate();
4079
4095
  return;
4080
4096
  }
4081
4097
  if (i instanceof Uint8Array && i.length > 0) {
@@ -4083,72 +4099,72 @@ class ye extends ee {
4083
4099
  throw new Error(
4084
4100
  `CAD display color target length mismatch: expected ${i.length}, received ${u.array.length}`
4085
4101
  );
4086
- const y = this.buildDisplayColorBytes(i, o, d);
4102
+ const y = this.buildDisplayColorBytes(i, o, l);
4087
4103
  u.array.set(y), u.markNeedsUpdate();
4088
4104
  return;
4089
4105
  }
4090
4106
  return;
4091
4107
  }
4092
- if (l && typeof r.setColors == "function") {
4093
- const y = gs(
4108
+ if (c && typeof r.setColors == "function") {
4109
+ const y = bs(
4094
4110
  a,
4095
4111
  s,
4096
- (p) => this.resolveDisplayRgbForLegacyRgb(p, o, d)
4112
+ (x) => this.resolveDisplayRgbForLegacyRgb(x, o, l)
4097
4113
  );
4098
4114
  this.recordDisplayColorBuildStats(y.stats), r.setColors(y.color), r.getAttribute("instanceColorStart") && (r.getAttribute("instanceColorStart").needsUpdate = !0), r.getAttribute("instanceColorEnd") && (r.getAttribute("instanceColorEnd").needsUpdate = !0);
4099
4115
  return;
4100
4116
  }
4101
- if (l) {
4117
+ if (c) {
4102
4118
  const y = r.getAttribute("color");
4103
4119
  if (y instanceof $ && y.array instanceof Uint8Array && y.array.length === a * 3) {
4104
4120
  const m = St(
4105
4121
  y.array,
4106
4122
  a,
4107
4123
  s,
4108
- (b) => this.resolveDisplayRgbForLegacyRgb(b, o, d)
4124
+ (b) => this.resolveDisplayRgbForLegacyRgb(b, o, l)
4109
4125
  );
4110
4126
  this.recordDisplayColorBuildStats(m), y.normalized = !0, y.needsUpdate = !0;
4111
4127
  return;
4112
4128
  }
4113
- const p = vn(
4129
+ const x = vn(
4114
4130
  a,
4115
4131
  s,
4116
- (m) => this.resolveDisplayRgbForLegacyRgb(m, o, d)
4132
+ (m) => this.resolveDisplayRgbForLegacyRgb(m, o, l)
4117
4133
  );
4118
- this.recordDisplayColorBuildStats(p.stats), r.setAttribute("color", wn(p.color));
4134
+ this.recordDisplayColorBuildStats(x.stats), r.setAttribute("color", wn(x.color));
4119
4135
  return;
4120
4136
  }
4121
4137
  if (!(i instanceof Uint8Array) || i.length === 0) return;
4122
- const c = this.buildDisplayColorBytes(i, o, d);
4138
+ const d = this.buildDisplayColorBytes(i, o, l);
4123
4139
  if (typeof r.setColors == "function") {
4124
- r.setColors(ys(c)), r.getAttribute("instanceColorStart") && (r.getAttribute("instanceColorStart").needsUpdate = !0), r.getAttribute("instanceColorEnd") && (r.getAttribute("instanceColorEnd").needsUpdate = !0);
4140
+ r.setColors(ms(d)), r.getAttribute("instanceColorStart") && (r.getAttribute("instanceColorStart").needsUpdate = !0), r.getAttribute("instanceColorEnd") && (r.getAttribute("instanceColorEnd").needsUpdate = !0);
4125
4141
  return;
4126
4142
  }
4127
4143
  const h = r.getAttribute("color");
4128
- if (h instanceof $ && h.array instanceof Uint8Array && h.array.length === c.length) {
4129
- h.array.set(c), h.normalized = !0, h.needsUpdate = !0;
4144
+ if (h instanceof $ && h.array instanceof Uint8Array && h.array.length === d.length) {
4145
+ h.array.set(d), h.normalized = !0, h.needsUpdate = !0;
4130
4146
  return;
4131
4147
  }
4132
- r.setAttribute("color", wn(c));
4148
+ r.setAttribute("color", wn(d));
4133
4149
  }
4134
4150
  buildDisplayColorBytes(e, r, i, s, a) {
4135
- const d = s && s.length > 0 && typeof a == "number" && Ye(a, s) ? vn(
4151
+ const l = s && s.length > 0 && typeof a == "number" && Ye(a, s) ? vn(
4136
4152
  a,
4137
4153
  s,
4138
- (l) => this.resolveDisplayRgbForLegacyRgb(l, r, i)
4139
- ) : xs(
4154
+ (c) => this.resolveDisplayRgbForLegacyRgb(c, r, i)
4155
+ ) : gs(
4140
4156
  e,
4141
- (l) => this.resolveDisplayRgbForLegacyRgb(l, r, i)
4157
+ (c) => this.resolveDisplayRgbForLegacyRgb(c, r, i)
4142
4158
  );
4143
- return this.recordDisplayColorBuildStats(d.stats), d.color;
4159
+ return this.recordDisplayColorBuildStats(l.stats), l.color;
4144
4160
  }
4145
4161
  recordDisplayColorBuildStats(e) {
4146
4162
  this.colorRefreshStats.displayRefreshVertexTotal += e.vertexCount, this.colorRefreshStats.displayRefreshRunTotal += e.runCount, this.colorRefreshStats.displayRefreshUniqueColorTotal += e.uniqueColorCount, this.colorRefreshStats.displayRefreshCacheHitTotal += e.cacheHitCount, this.colorRefreshStats.displayRefreshRepeatedRunVertexTotal += e.repeatedRunVertexCount;
4147
4163
  }
4148
4164
  resolveDisplayHexForRgb(e, r, i) {
4149
- const s = Ea(e, r, i, this.displayThemeName, this.displayContrastEnhancement), a = this.displayHexMemo.get(s);
4165
+ const s = Sa(e, r, i, this.displayThemeName, this.displayContrastEnhancement), a = this.displayHexMemo.get(s);
4150
4166
  if (a !== void 0) return a;
4151
- const o = Ba(this.resolveDisplayRgbForLegacyRgb(e, r, i));
4167
+ const o = Va(this.resolveDisplayRgbForLegacyRgb(e, r, i));
4152
4168
  return this.displayHexMemo.set(s, o), o;
4153
4169
  }
4154
4170
  resolveDisplayRgbForLegacyRgb(e, r, i) {
@@ -4165,35 +4181,35 @@ class ye extends ee {
4165
4181
  return r === "text-batch" ? "text" : r === "fill" || r === "dot" || r === "text" || r === "hatch" || r === "overlay" ? r : "line";
4166
4182
  }
4167
4183
  createInsertInstanceRecords(e) {
4168
- const r = [], { meta: i, mats: s, bboxes: a, count: o } = e, d = /* @__PURE__ */ new Map();
4169
- for (let l = 0; l < o; l += 1) {
4170
- const u = i[l * 3], c = i[l * 3 + 1], h = `${u}:${c}`, y = d.get(h) ?? 0;
4171
- d.set(h, y + 1);
4172
- const p = {
4173
- minX: a[l * 4],
4174
- minY: a[l * 4 + 1],
4175
- maxX: a[l * 4 + 2],
4176
- maxY: a[l * 4 + 3]
4184
+ const r = [], { meta: i, mats: s, bboxes: a, count: o } = e, l = /* @__PURE__ */ new Map();
4185
+ for (let c = 0; c < o; c += 1) {
4186
+ const u = i[c * 3], d = i[c * 3 + 1], h = `${u}:${d}`, y = l.get(h) ?? 0;
4187
+ l.set(h, y + 1);
4188
+ const x = {
4189
+ minX: a[c * 4],
4190
+ minY: a[c * 4 + 1],
4191
+ maxX: a[c * 4 + 2],
4192
+ maxY: a[c * 4 + 3]
4177
4193
  };
4178
- Tt(p) && r.push({
4179
- recordKey: Ar(u, c, y),
4194
+ Tt(x) && r.push({
4195
+ recordKey: Ar(u, d, y),
4180
4196
  instanceId: u,
4181
- variantId: c,
4182
- layerIdx: i[l * 3 + 2],
4183
- matA: s[l * 6],
4184
- matB: s[l * 6 + 1],
4185
- matC: s[l * 6 + 2],
4186
- matD: s[l * 6 + 3],
4187
- tx: s[l * 6 + 4],
4188
- ty: s[l * 6 + 5],
4189
- bbox: p
4197
+ variantId: d,
4198
+ layerIdx: i[c * 3 + 2],
4199
+ matA: s[c * 6],
4200
+ matB: s[c * 6 + 1],
4201
+ matC: s[c * 6 + 2],
4202
+ matD: s[c * 6 + 3],
4203
+ tx: s[c * 6 + 4],
4204
+ ty: s[c * 6 + 5],
4205
+ bbox: x
4190
4206
  });
4191
4207
  }
4192
4208
  return r;
4193
4209
  }
4194
4210
  createInsertPresenterMaterial(e) {
4195
4211
  let r;
4196
- return e === "line" ? r = new ln({ vertexColors: !0 }) : e === "fill" ? r = new dn({
4212
+ return e === "line" ? r = new ln({ vertexColors: !0 }) : e === "fill" ? r = new cn({
4197
4213
  vertexColors: !0,
4198
4214
  side: vt,
4199
4215
  depthWrite: !1
@@ -4201,7 +4217,7 @@ class ye extends ee {
4201
4217
  vertexColors: !0,
4202
4218
  size: 2,
4203
4219
  sizeAttenuation: !1
4204
- }), Sa(r), r;
4220
+ }), ka(r), r;
4205
4221
  }
4206
4222
  clearViewportInsertPresenter() {
4207
4223
  var e, r;
@@ -4280,9 +4296,9 @@ class ye extends ee {
4280
4296
  e === this.effectiveRenderQuality && !r.forceLineRebuild || (this.effectiveRenderQuality = e, this.rebuildLineChunks(), this.notifyInternalChange());
4281
4297
  }
4282
4298
  resolveCurrentEffectiveRenderQuality() {
4283
- return this.interactionRenderQualityOverride ?? Zs(this.renderQualityMode, this.effectiveRenderQuality, this.autoQualityContext);
4299
+ return this.interactionRenderQualityOverride ?? Js(this.renderQualityMode, this.effectiveRenderQuality, this.autoQualityContext);
4284
4300
  }
4285
- notifyInternalChange(e = la) {
4301
+ notifyInternalChange(e = ca) {
4286
4302
  if (this.disposed) return;
4287
4303
  this.renderDebugRevision += 1;
4288
4304
  const r = this.internalChangeHook ? [this.internalChangeHook, ...this.changeListeners] : [...this.changeListeners];
@@ -4314,7 +4330,7 @@ class ye extends ee {
4314
4330
  this.readySettled || (this.readySettled = !0, this.rejectReady(e));
4315
4331
  }
4316
4332
  }
4317
- function Vr(t) {
4333
+ function Er(t) {
4318
4334
  if (t.kind !== "url") return null;
4319
4335
  try {
4320
4336
  const n = typeof document > "u" ? void 0 : document.baseURI;
@@ -4326,7 +4342,7 @@ function Vr(t) {
4326
4342
  function je(t) {
4327
4343
  return !!(t && (t.line.count > 0 || t.fill.count > 0 || t.dot.count > 0 || t.texts.length > 0));
4328
4344
  }
4329
- async function Er(t, n, e) {
4345
+ async function Sr(t, n, e) {
4330
4346
  if (!n) return null;
4331
4347
  const r = new URL(n.href, t).href, i = await fetch(r, { signal: e });
4332
4348
  if (!i.ok) {
@@ -4338,15 +4354,15 @@ async function Er(t, n, e) {
4338
4354
  throw new Error(
4339
4355
  `Scene annotation raw_size mismatch: manifest=${n.raw_size}, response=${s.byteLength}`
4340
4356
  );
4341
- const a = Wr(s);
4357
+ const a = Xr(s);
4342
4358
  if (a.line.count !== n.line_count || a.fill.count !== n.fill_count || a.dot.count !== n.dot_count || a.texts.length !== n.text_count)
4343
4359
  throw new Error(`Scene annotation count mismatch for ${r}`);
4344
4360
  return a;
4345
4361
  }
4346
- async function Pa(t, n, e, r, i) {
4362
+ async function La(t, n, e, r, i) {
4347
4363
  if (e.externalVariantFetchSource !== void 0 || e.externalVariantBuffers !== void 0 || e.requiredExternalVariantIds !== void 0 || e.externalVariantGeometryFetchIds !== void 0)
4348
4364
  return { annotations: [] };
4349
- const s = Vr(t);
4365
+ const s = Er(t);
4350
4366
  if (!s) return { annotations: [] };
4351
4367
  const a = Ke(n, {
4352
4368
  hiddenInstanceIds: r,
@@ -4356,22 +4372,22 @@ async function Pa(t, n, e, r, i) {
4356
4372
  entries: a.manifest,
4357
4373
  requiredVariantIds: a.requiredVariantIds,
4358
4374
  signal: i
4359
- }) : Promise.resolve({ buffers: /* @__PURE__ */ new Map(), fetchMs: 0 }), d = e.loadAnnotations === !1 ? null : Gt(n), [l, u] = await Promise.all([
4375
+ }) : Promise.resolve({ buffers: /* @__PURE__ */ new Map(), fetchMs: 0 }), l = e.loadAnnotations === !1 ? null : Gt(n), [c, u] = await Promise.all([
4360
4376
  o,
4361
- d != null && d.scene ? Er(s, d.scene, i) : Promise.resolve(null)
4362
- ]), c = [];
4363
- if (je(u) && c.push(u), e.loadAnnotations !== !1 && e.loadBlocks !== !1) {
4377
+ l != null && l.scene ? Sr(s, l.scene, i) : Promise.resolve(null)
4378
+ ]), d = [];
4379
+ if (je(u) && d.push(u), e.loadAnnotations !== !1 && e.loadBlocks !== !1) {
4364
4380
  const h = Ut(n, {
4365
- externalVariantBuffers: l.buffers,
4381
+ externalVariantBuffers: c.buffers,
4366
4382
  hiddenInstanceIds: r
4367
4383
  });
4368
- je(h) && c.push(h);
4384
+ je(h) && d.push(h);
4369
4385
  }
4370
4386
  return {
4371
- externalVariantBuffers: l.buffers,
4387
+ externalVariantBuffers: c.buffers,
4372
4388
  requiredExternalVariantIds: a.requiredVariantIds,
4373
4389
  externalVariantGeometryFetchIds: a.requiredVariantIds,
4374
- annotations: c
4390
+ annotations: d
4375
4391
  };
4376
4392
  }
4377
4393
  function Gn(t) {
@@ -4399,19 +4415,19 @@ async function So(t, n, e) {
4399
4415
  });
4400
4416
  }
4401
4417
  function ko(t) {
4402
- return Xr(t);
4418
+ return Yr(t);
4403
4419
  }
4404
- const La = {
4420
+ const Ma = {
4405
4421
  deferExternalVariantGeometry: !0
4406
4422
  };
4407
- function Ma(t) {
4408
- return Ot(t, La).header;
4423
+ function Da(t) {
4424
+ return Ot(t, Ma).header;
4409
4425
  }
4410
4426
  function To(t) {
4411
- return Yr(t);
4427
+ return Qr(t);
4412
4428
  }
4413
4429
  function Po(t) {
4414
- return Qr(t);
4430
+ return $r(t);
4415
4431
  }
4416
4432
  function Lo(t, n) {
4417
4433
  return Ke(t, n);
@@ -4437,9 +4453,9 @@ function Fo(t, n) {
4437
4453
  };
4438
4454
  }
4439
4455
  function Oo(t) {
4440
- si(t);
4456
+ oi(t);
4441
4457
  }
4442
- function Da(t) {
4458
+ function Fa(t) {
4443
4459
  return t instanceof Error ? t : typeof t == "string" ? new Error(t) : new Error(`Unknown geo load error: ${String(t)}`);
4444
4460
  }
4445
4461
  function en(t) {
@@ -4456,17 +4472,17 @@ function _o(t, n = {}) {
4456
4472
  ue(r.sourceSignal, e)
4457
4473
  ];
4458
4474
  $e(i, () => {
4459
- e.abort(K("GeoNode disposed during CAD load"));
4475
+ e.abort(W("GeoNode disposed during CAD load"));
4460
4476
  });
4461
- const a = en(n.hiddenInstanceIds), o = ie(n.requiredExternalVariantIds), d = ie(n.externalVariantGeometryFetchIds);
4477
+ const a = en(n.hiddenInstanceIds), o = ie(n.requiredExternalVariantIds), l = ie(n.externalVariantGeometryFetchIds);
4462
4478
  return (async () => {
4463
- var l;
4479
+ var c;
4464
4480
  try {
4465
- const u = await jn(
4481
+ const u = await Zn(
4466
4482
  Zt(r.source),
4467
4483
  e.signal,
4468
4484
  "CAD load aborted before decoding"
4469
- ), c = await Pa(
4485
+ ), d = await La(
4470
4486
  r.source,
4471
4487
  u,
4472
4488
  n,
@@ -4475,60 +4491,63 @@ function _o(t, n = {}) {
4475
4491
  ), h = {
4476
4492
  signal: e.signal,
4477
4493
  hiddenInstanceIds: a,
4478
- requiredExternalVariantIds: o ?? ie(c.requiredExternalVariantIds),
4479
- externalVariantGeometryFetchIds: d ?? ie(c.externalVariantGeometryFetchIds),
4494
+ requiredExternalVariantIds: o ?? ie(d.requiredExternalVariantIds),
4495
+ externalVariantGeometryFetchIds: l ?? ie(d.externalVariantGeometryFetchIds),
4480
4496
  beforeTextAppend: n.beforeTextAppend,
4481
4497
  beforeFinalize: async () => {
4482
4498
  var y;
4483
- for (const p of c.annotations)
4484
- await ((y = n.beforeTextAppend) == null ? void 0 : y.call(n, p.texts)), i.appendAnnotationOverlay(p);
4499
+ for (const x of d.annotations)
4500
+ await ((y = n.beforeTextAppend) == null ? void 0 : y.call(n, x.texts)), i.appendAnnotationOverlay(x);
4485
4501
  }
4486
4502
  };
4487
- n.loadBlocks === !1 && (h.loadBlocks = !1), typeof n.maxExpandedInstanceVertices == "number" && Number.isFinite(n.maxExpandedInstanceVertices) && n.maxExpandedInstanceVertices >= 0 && (h.maxExpandedInstanceVertices = n.maxExpandedInstanceVertices), n.preferWorker === !1 && (h.preferWorker = !1), n.workerUrl !== void 0 && (h.workerUrl = n.workerUrl), n.workerFactory && (h.workerFactory = n.workerFactory), n.externalVariantFetchSource && (h.externalVariantFetchSource = n.externalVariantFetchSource), n.externalVariantBuffers && n.externalVariantBuffers.size > 0 ? h.externalVariantBuffers = n.externalVariantBuffers : (l = c.externalVariantBuffers) != null && l.size && (h.externalVariantBuffers = c.externalVariantBuffers), await cr(i, u, void 0, {
4503
+ n.loadBlocks === !1 && (h.loadBlocks = !1), typeof n.maxExpandedInstanceVertices == "number" && Number.isFinite(n.maxExpandedInstanceVertices) && n.maxExpandedInstanceVertices >= 0 && (h.maxExpandedInstanceVertices = n.maxExpandedInstanceVertices), n.preferWorker === !1 && (h.preferWorker = !1), n.workerUrl !== void 0 && (h.workerUrl = n.workerUrl), n.workerFactory && (h.workerFactory = n.workerFactory), n.externalVariantFetchSource && (h.externalVariantFetchSource = n.externalVariantFetchSource), n.externalVariantBuffers && n.externalVariantBuffers.size > 0 ? h.externalVariantBuffers = n.externalVariantBuffers : (c = d.externalVariantBuffers) != null && c.size && (h.externalVariantBuffers = d.externalVariantBuffers), await ur(i, u, void 0, {
4488
4504
  ...h
4489
4505
  });
4490
4506
  } catch (u) {
4491
- i._fail(Da(u));
4507
+ i._fail(Fa(u));
4492
4508
  } finally {
4493
4509
  for (const u of s) u();
4494
4510
  $e(i, null);
4495
4511
  }
4496
4512
  })(), i;
4497
4513
  }
4498
- const Fa = 40;
4499
- function Sr(t) {
4514
+ function Go(t) {
4515
+ ti(t);
4516
+ }
4517
+ const Oa = 40;
4518
+ function kr(t) {
4500
4519
  return !!(t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY) && t.maxX >= t.minX && t.maxY >= t.minY);
4501
4520
  }
4502
- function Oa(t, n, e) {
4521
+ function _a(t, n, e) {
4503
4522
  return n.x >= t.minX - e && n.x <= t.maxX + e && n.y >= t.minY - e && n.y <= t.maxY + e;
4504
4523
  }
4505
- function _a(t, n) {
4524
+ function Ga(t, n) {
4506
4525
  return n.minX >= t.minX && n.maxX <= t.maxX && n.minY >= t.minY && n.maxY <= t.maxY;
4507
4526
  }
4508
- function Go(t, n) {
4527
+ function Uo(t, n) {
4509
4528
  return t.layerIndex === n.layerIndex && t.variantId === n.variantId && t.instanceId === n.instanceId;
4510
4529
  }
4511
- function Ga(t, n, e = {}) {
4530
+ function Ua(t, n, e = {}) {
4512
4531
  var a;
4513
4532
  if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) return null;
4514
- const r = Math.max(0, e.padding ?? Fa), i = t.getLayers();
4533
+ const r = Math.max(0, e.padding ?? Oa), i = t.getLayers();
4515
4534
  let s = null;
4516
4535
  for (let o = i.length - 1; o >= 0; o -= 1) {
4517
- const d = i[o];
4518
- if (!d || !d.visible) continue;
4519
- const l = t.getLayerBlockUsages(d.index);
4520
- for (let u = l.length - 1; u >= 0; u -= 1) {
4521
- const c = l[u];
4522
- for (let h = c.inserts.length - 1; h >= 0; h -= 1) {
4523
- const y = c.inserts[h];
4524
- if (!y.canHighlight || !Sr(y.bbox) || ((a = e.isInstanceVisible) == null ? void 0 : a.call(e, y.instanceId)) === !1 || !Oa(y.bbox, n, r)) continue;
4525
- const p = {
4536
+ const l = i[o];
4537
+ if (!l || !l.visible) continue;
4538
+ const c = t.getLayerBlockUsages(l.index);
4539
+ for (let u = c.length - 1; u >= 0; u -= 1) {
4540
+ const d = c[u];
4541
+ for (let h = d.inserts.length - 1; h >= 0; h -= 1) {
4542
+ const y = d.inserts[h];
4543
+ if (!y.canHighlight || !kr(y.bbox) || ((a = e.isInstanceVisible) == null ? void 0 : a.call(e, y.instanceId)) === !1 || !_a(y.bbox, n, r)) continue;
4544
+ const x = {
4526
4545
  kind: "insert",
4527
- layerIndex: d.index,
4528
- variantId: c.variantId,
4546
+ layerIndex: l.index,
4547
+ variantId: d.variantId,
4529
4548
  instanceId: y.instanceId
4530
4549
  };
4531
- if (s || (s = p), !e.viewport || _a(e.viewport, y.bbox)) return p;
4550
+ if (s || (s = x), !e.viewport || Ga(e.viewport, y.bbox)) return x;
4532
4551
  }
4533
4552
  }
4534
4553
  }
@@ -4536,7 +4555,7 @@ function Ga(t, n, e = {}) {
4536
4555
  }
4537
4556
  function It(t, n) {
4538
4557
  const e = t.getLayerBlockUsages(n.layerIndex).find((a) => a.variantId === n.variantId), r = e == null ? void 0 : e.inserts.find((a) => a.instanceId === n.instanceId);
4539
- if (!e || !r || !Sr(r.bbox)) return null;
4558
+ if (!e || !r || !kr(r.bbox)) return null;
4540
4559
  const i = t.getLayers().find((a) => a.index === n.layerIndex), s = t.getInsertInstanceBaseTransform(n.instanceId, n.variantId);
4541
4560
  return {
4542
4561
  id: { ...n },
@@ -4552,31 +4571,31 @@ function It(t, n) {
4552
4571
  bbox: Object.freeze({ ...r.bbox })
4553
4572
  };
4554
4573
  }
4555
- const Ua = 0.6;
4556
- function Na(t) {
4557
- const n = t.w ?? t.t.length * t.h * Ua, e = t.h * (t.lh || 1);
4574
+ const Na = 0.6;
4575
+ function za(t) {
4576
+ const n = t.w ?? t.t.length * t.h * Na, e = t.h * (t.lh || 1);
4558
4577
  let r = 0;
4559
4578
  t.ha === "center" ? r = -n / 2 : t.ha === "right" && (r = -n);
4560
4579
  let i = 0;
4561
4580
  return t.va === "middle" ? i = -e / 2 : t.va === "top" && (i = -e), { x0: r, y0: i, x1: r + n, y1: i + e };
4562
4581
  }
4563
- function za(t, n, e) {
4564
- const r = t.x - n.x, i = t.y - n.y, s = (n.r || 0) * Math.PI / 180, a = Math.cos(-s), o = Math.sin(-s), d = r * a - i * o, l = r * o + i * a;
4565
- return d >= e.x0 && d <= e.x1 && l >= e.y0 && l <= e.y1;
4582
+ function Ha(t, n, e) {
4583
+ const r = t.x - n.x, i = t.y - n.y, s = (n.r || 0) * Math.PI / 180, a = Math.cos(-s), o = Math.sin(-s), l = r * a - i * o, c = r * o + i * a;
4584
+ return l >= e.x0 && l <= e.x1 && c >= e.y0 && c <= e.y1;
4566
4585
  }
4567
- function Ha(t, n, e = {}) {
4586
+ function qa(t, n, e = {}) {
4568
4587
  if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) return null;
4569
4588
  const r = t.getTextEntries(), i = e.maxTextCount;
4570
4589
  if (r.length === 0) return null;
4571
4590
  const s = t.getLayers(), a = i === void 0 ? r.length - 1 : Math.min(r.length, Math.max(0, Math.floor(i))) - 1;
4572
4591
  for (let o = a; o >= 0; o -= 1) {
4573
- const d = r[o], l = s.find((u) => u.index === d.li);
4574
- if (!(l && l.visible === !1) && za(n, d, Na(d)))
4592
+ const l = r[o], c = s.find((u) => u.index === l.li);
4593
+ if (!(c && c.visible === !1) && Ha(n, l, za(l)))
4575
4594
  return { kind: "text", textId: o };
4576
4595
  }
4577
4596
  return null;
4578
4597
  }
4579
- function qa(t, n) {
4598
+ function Un(t, n) {
4580
4599
  if (n.kind !== "text" || !Number.isInteger(n.textId) || n.textId < 0) return null;
4581
4600
  const e = t.getTextEntries()[n.textId];
4582
4601
  if (!e) return null;
@@ -4592,10 +4611,10 @@ function qa(t, n) {
4592
4611
  layerIndex: e.li
4593
4612
  };
4594
4613
  }
4595
- function Uo(t, n) {
4614
+ function No(t, n) {
4596
4615
  return (t == null ? void 0 : t.kind) === "text" && (n == null ? void 0 : n.kind) === "text" && t.textId === n.textId;
4597
4616
  }
4598
- const No = [
4617
+ const zo = [
4599
4618
  "created",
4600
4619
  "header-ready",
4601
4620
  "initial-loading",
@@ -4606,7 +4625,7 @@ const No = [
4606
4625
  function Ka(t) {
4607
4626
  return `${Lt}${t.layerIndex}:${t.variantId}:${t.instanceId}`;
4608
4627
  }
4609
- function kr(t) {
4628
+ function Tr(t) {
4610
4629
  if (t.startsWith(Lt)) {
4611
4630
  const e = t.slice(Lt.length).split(":");
4612
4631
  if (e.length !== 3) return null;
@@ -4617,7 +4636,7 @@ function kr(t) {
4617
4636
  return Number.isInteger(n) ? { instanceId: n } : null;
4618
4637
  }
4619
4638
  function Wa(t) {
4620
- const n = kr(t);
4639
+ const n = Tr(t);
4621
4640
  return n ? n.instanceId : null;
4622
4641
  }
4623
4642
  function He(t) {
@@ -4633,7 +4652,7 @@ function He(t) {
4633
4652
  planar: !0
4634
4653
  } : null;
4635
4654
  }
4636
- function Un(t, n) {
4655
+ function Nn(t, n) {
4637
4656
  return t ? n ? {
4638
4657
  minX: Math.min(t.minX, n.minX),
4639
4658
  minY: Math.min(t.minY, n.minY),
@@ -4647,7 +4666,7 @@ function Un(t, n) {
4647
4666
  function Xa(t) {
4648
4667
  let n = 0, e = 0;
4649
4668
  return t.traverse((r) => {
4650
- if (!Pr(r) || !Tr(r)) return;
4669
+ if (!Lr(r) || !Pr(r)) return;
4651
4670
  n += 1;
4652
4671
  const i = Number(r.userData.vertexCount);
4653
4672
  Number.isFinite(i) && i > 0 && (e += i);
@@ -4677,7 +4696,7 @@ function $a(t) {
4677
4696
  function ja(t) {
4678
4697
  const n = /* @__PURE__ */ new Map();
4679
4698
  return t.traverse((e) => {
4680
- if (!Pr(e) || !Tr(e)) return;
4699
+ if (!Lr(e) || !Pr(e)) return;
4681
4700
  const r = $a(e), i = n.get(r) ?? {
4682
4701
  kind: r,
4683
4702
  label: Ya[r],
@@ -4691,11 +4710,11 @@ function ja(t) {
4691
4710
  renderDebugBreakdown: Qa.map((e) => n.get(e)).filter((e) => e !== void 0)
4692
4711
  };
4693
4712
  }
4694
- function Tr(t) {
4713
+ function Pr(t) {
4695
4714
  const n = t;
4696
4715
  return !!(n.isLine || n.isLineSegments || n.isMesh || n.isPoints || n.isInstancedMesh);
4697
4716
  }
4698
- function Pr(t) {
4717
+ function Lr(t) {
4699
4718
  let n = t;
4700
4719
  for (; n; ) {
4701
4720
  if (!n.visible) return !1;
@@ -4709,16 +4728,16 @@ function Ja(t) {
4709
4728
  for (const a of t.getLayers())
4710
4729
  for (const o of t.getLayerBlockUsages(a.index)) {
4711
4730
  n.add(o.variantId);
4712
- const d = e.get(o.variantId) ?? /* @__PURE__ */ new Set();
4713
- d.add(a.index), e.set(o.variantId, d);
4731
+ const l = e.get(o.variantId) ?? /* @__PURE__ */ new Set();
4732
+ l.add(a.index), e.set(o.variantId, l);
4714
4733
  for (const u of o.inserts) r.add(u.instanceId);
4715
- let l = i.get(o.variantId);
4716
- l || (l = {
4734
+ let c = i.get(o.variantId);
4735
+ c || (c = {
4717
4736
  variantId: o.variantId,
4718
4737
  blockName: o.blockName,
4719
4738
  instanceCount: 0,
4720
4739
  layers: /* @__PURE__ */ new Map()
4721
- }, i.set(o.variantId, l)), l.instanceCount += o.instanceCount, l.layers.set(a.index, a.name);
4740
+ }, i.set(o.variantId, c)), c.instanceCount += o.instanceCount, c.layers.set(a.index, a.name);
4722
4741
  }
4723
4742
  const s = [...i.values()].filter((a) => a.layers.size > 1).map((a) => ({
4724
4743
  variantId: a.variantId,
@@ -4743,27 +4762,27 @@ function eo(t) {
4743
4762
  s,
4744
4763
  r
4745
4764
  );
4746
- }, o = (c, h) => {
4747
- var y, p, m, b, v, I, w, T;
4748
- return c !== null && ((y = c.documentRect) == null ? void 0 : y.minX) === ((p = h.documentRect) == null ? void 0 : p.minX) && ((m = c.documentRect) == null ? void 0 : m.minY) === ((b = h.documentRect) == null ? void 0 : b.minY) && ((v = c.documentRect) == null ? void 0 : v.maxX) === ((I = h.documentRect) == null ? void 0 : I.maxX) && ((w = c.documentRect) == null ? void 0 : w.maxY) === ((T = h.documentRect) == null ? void 0 : T.maxY) && c.viewportWidthPx === h.viewportWidthPx && c.viewportHeightPx === h.viewportHeightPx && c.devicePixelRatio === h.devicePixelRatio && c.worldUnitsPerPixel === h.worldUnitsPerPixel && c.viewMode === h.viewMode && c.quality === h.quality;
4749
- }, d = (c) => {
4765
+ }, o = (d, h) => {
4766
+ var y, x, m, b, R, I, w, T;
4767
+ return d !== null && ((y = d.documentRect) == null ? void 0 : y.minX) === ((x = h.documentRect) == null ? void 0 : x.minX) && ((m = d.documentRect) == null ? void 0 : m.minY) === ((b = h.documentRect) == null ? void 0 : b.minY) && ((R = d.documentRect) == null ? void 0 : R.maxX) === ((I = h.documentRect) == null ? void 0 : I.maxX) && ((w = d.documentRect) == null ? void 0 : w.maxY) === ((T = h.documentRect) == null ? void 0 : T.maxY) && d.viewportWidthPx === h.viewportWidthPx && d.viewportHeightPx === h.viewportHeightPx && d.devicePixelRatio === h.devicePixelRatio && d.worldUnitsPerPixel === h.worldUnitsPerPixel && d.viewMode === h.viewMode && d.quality === h.quality;
4768
+ }, l = (d) => {
4750
4769
  var y;
4751
4770
  let h = !1;
4752
- for (const p of c) {
4753
- const m = Wa(p.insertId);
4754
- m !== null && (p.visible ? s.delete(m) && (h = !0) : s.has(m) || (s.add(m), h = !0));
4771
+ for (const x of d) {
4772
+ const m = Wa(x.insertId);
4773
+ m !== null && (x.visible ? s.delete(m) && (h = !0) : s.has(m) || (s.add(m), h = !0));
4755
4774
  }
4756
4775
  h && (r += 1, i.invalidateInsertPresenterQueryCache(), a(), t.onInsertVisibilityChange(), (y = i._notifyStructureChange) == null || y.call(i));
4757
- }, l = (c, h) => {
4776
+ }, c = (d, h) => {
4758
4777
  if (!h) return null;
4759
4778
  const y = i.getLayers();
4760
- return y.length === 0 || y.some((m) => typeof c.layerVisible == "function" ? c.layerVisible(m.index) : c.layerVisible ? c.layerVisible.get(m.index) ?? m.visible : m.visible) ? h : null;
4761
- }, u = (c) => {
4762
- var p;
4779
+ return y.length === 0 || y.some((m) => typeof d.layerVisible == "function" ? d.layerVisible(m.index) : d.layerVisible ? d.layerVisible.get(m.index) ?? m.visible : m.visible) ? h : null;
4780
+ }, u = (d) => {
4781
+ var x;
4763
4782
  const h = new Map(i.getLayers().map((m) => [m.index, m.visible]));
4764
4783
  let y = null;
4765
4784
  for (const m of i.getGeometryChunkStats())
4766
- !(typeof c.layerVisible == "function" ? c.layerVisible(m.layerIndex) : ((p = c.layerVisible) == null ? void 0 : p.get(m.layerIndex)) ?? h.get(m.layerIndex) ?? !0) || !m.bbox || (y = Un(y, He([
4785
+ !(typeof d.layerVisible == "function" ? d.layerVisible(m.layerIndex) : ((x = d.layerVisible) == null ? void 0 : x.get(m.layerIndex)) ?? h.get(m.layerIndex) ?? !0) || !m.bbox || (y = Nn(y, He([
4767
4786
  m.bbox.minX,
4768
4787
  m.bbox.minY,
4769
4788
  m.bbox.maxX,
@@ -4778,41 +4797,44 @@ function eo(t) {
4778
4797
  get contentRevision() {
4779
4798
  return n;
4780
4799
  },
4781
- getAuthoritativeBounds(c) {
4782
- return l(
4783
- c,
4784
- Un(t.getHeaderBounds(), He(i.getBounds()))
4800
+ getAuthoritativeBounds(d) {
4801
+ return c(
4802
+ d,
4803
+ Nn(t.getHeaderBounds(), He(i.getBounds()))
4785
4804
  );
4786
4805
  },
4787
- getMountedBounds(c) {
4788
- return u(c) ?? l(c, He(i.getBounds()));
4806
+ getMountedBounds(d) {
4807
+ return u(d) ?? c(d, He(i.getBounds()));
4789
4808
  },
4790
- getUnmountedExternalBounds(c) {
4791
- return c.includeUnmountedExternal === !1 ? null : l(c, t.getUnmountedBounds());
4809
+ getUnmountedExternalBounds(d) {
4810
+ return d.includeUnmountedExternal === !1 ? null : c(d, t.getUnmountedBounds());
4792
4811
  },
4793
- appendContent(c) {
4812
+ appendContent(d) {
4794
4813
  return n += 1, a(), !0;
4795
4814
  },
4796
- setDisplayContext(c) {
4797
- o(e, c) || (e = c, i.setViewportSize(c.viewportWidthPx, c.viewportHeightPx), c.quality === "auto" ? i.setInteractionRenderQualityOverride(null) : i.setInteractionRenderQualityOverride(c.quality), i.updateAutoQualityContext({
4815
+ setDisplayContext(d) {
4816
+ o(e, d) || (e = d, i.setViewportSize(d.viewportWidthPx, d.viewportHeightPx), d.quality === "auto" ? i.setInteractionRenderQualityOverride(null) : i.setInteractionRenderQualityOverride(d.quality), i.updateAutoQualityContext({
4798
4817
  visibleVertexCount: i.getMeta().lineCount + i.getMeta().fillCount + i.getMeta().dotCount,
4799
- zoom: c.worldUnitsPerPixel
4818
+ zoom: d.worldUnitsPerPixel
4800
4819
  }), a());
4801
4820
  },
4802
- setLayerVisible(c, h) {
4803
- i.setLayerVisible(c, h), a();
4821
+ setLayerVisible(d, h) {
4822
+ i.setLayerVisible(d, h), a();
4804
4823
  },
4805
- setLayerColorOverride(c, h) {
4806
- i.setLayerColor(c, h);
4824
+ setLayerVisibleBatch(d) {
4825
+ i.setLayerVisibleBatch(d) > 0 && a();
4807
4826
  },
4808
- setInsertVisible(c, h) {
4809
- d([{ insertId: c, visible: h }]);
4827
+ setLayerColorOverride(d, h) {
4828
+ i.setLayerColor(d, h);
4810
4829
  },
4811
- setInsertVisibleBatch(c) {
4812
- d(c);
4830
+ setInsertVisible(d, h) {
4831
+ l([{ insertId: d, visible: h }]);
4813
4832
  },
4814
- createInsertPreview(c) {
4815
- const h = i.createInsertPreviewResource(c);
4833
+ setInsertVisibleBatch(d) {
4834
+ l(d);
4835
+ },
4836
+ createInsertPreview(d) {
4837
+ const h = i.createInsertPreviewResource(d);
4816
4838
  return h ? {
4817
4839
  object: h.object,
4818
4840
  bounds: {
@@ -4828,58 +4850,58 @@ function eo(t) {
4828
4850
  } : null;
4829
4851
  },
4830
4852
  getDiagnostics() {
4831
- const c = i.getMeta(), h = Xa(i), y = ja(i), p = Ja(i);
4853
+ const d = i.getMeta(), h = Xa(i), y = ja(i), x = Ja(i);
4832
4854
  return {
4833
- entityCount: c.entityCount,
4834
- lineCount: c.lineCount,
4835
- fillCount: c.fillCount,
4836
- dotCount: c.dotCount,
4837
- textCount: c.textCount,
4855
+ entityCount: d.entityCount,
4856
+ lineCount: d.lineCount,
4857
+ fillCount: d.fillCount,
4858
+ dotCount: d.dotCount,
4859
+ textCount: d.textCount,
4838
4860
  lineRenderMode: i.getLineRenderMode(),
4839
4861
  ...h,
4840
4862
  ...y,
4841
- ...p
4863
+ ...x
4842
4864
  };
4843
4865
  },
4844
- onChange(c) {
4845
- return i.onChange(() => c());
4866
+ onChange(d) {
4867
+ return i.onChange(() => d());
4846
4868
  },
4847
4869
  dispose() {
4848
4870
  i.dispose();
4849
4871
  }
4850
4872
  };
4851
4873
  }
4852
- const to = 450, Lr = 250, no = 0.25;
4853
- function Nn(t) {
4854
- return !t.manifestBBox || !t.viewport || !Number.isFinite(t.worldUnitsPerPixel) || t.worldUnitsPerPixel <= 0 || t.worldUnitsPerPixel > Lr ? !1 : Kn(
4874
+ const to = 450, Mr = 250, no = 0.25;
4875
+ function zn(t) {
4876
+ return !t.manifestBBox || !t.viewport || !Number.isFinite(t.worldUnitsPerPixel) || t.worldUnitsPerPixel <= 0 || t.worldUnitsPerPixel > Mr ? !1 : Wn(
4855
4877
  Je(t.viewport, no),
4856
4878
  t.manifestBBox
4857
4879
  );
4858
4880
  }
4859
- function zn(t) {
4881
+ function Hn(t) {
4860
4882
  const n = t == null ? void 0 : t.bbox;
4861
4883
  return n ? { minX: n[0], minY: n[1], maxX: n[2], maxY: n[3] } : null;
4862
4884
  }
4863
4885
  function Ct(t) {
4864
4886
  return "annotation" in t && (t.annotation.line_count > 0 || t.annotation.fill_count > 0 || t.annotation.dot_count > 0 || t.annotation.text_count > 0);
4865
4887
  }
4866
- function Hn(t) {
4867
- return Number.isFinite(t) && t > 0 && t <= Lr;
4888
+ function qn(t) {
4889
+ return Number.isFinite(t) && t > 0 && t <= Mr;
4868
4890
  }
4869
4891
  function ro(t) {
4870
4892
  const n = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set();
4871
4893
  let r = !1;
4872
4894
  return {
4873
4895
  resolveTextFont: (s) => {
4874
- var c;
4875
- const a = ur(s), o = t.fontResolver;
4896
+ var d;
4897
+ const a = hr(s), o = t.fontResolver;
4876
4898
  if (!o || r) return a;
4877
- const d = { family: void 0 }, l = "";
4878
- if (e.has(l)) return a;
4879
- let u = n.get(l);
4880
- return u || (u = { promise: o.resolve(d, t.signal).then((y) => (u && (u.resolved = y), y != null && y.fontUrl && ao(y.fontUrl, a.text, t.signal).catch((p) => {
4881
- t.onNonFatalError(p instanceof Error ? p : new Error(String(p)));
4882
- }), y)).catch((y) => (e.add(l), t.onNonFatalError(y instanceof Error ? y : new Error(String(y))), null)), resolved: null }, n.set(l, u)), (c = u.resolved) != null && c.fontUrl ? { ...a, fontUrl: u.resolved.fontUrl, kind: u.resolved.family } : a;
4899
+ const l = { family: void 0 }, c = "";
4900
+ if (e.has(c)) return a;
4901
+ let u = n.get(c);
4902
+ return u || (u = { promise: o.resolve(l, t.signal).then((y) => (u && (u.resolved = y), y != null && y.fontUrl && ao(y.fontUrl, a.text, t.signal).catch((x) => {
4903
+ t.onNonFatalError(x instanceof Error ? x : new Error(String(x)));
4904
+ }), y)).catch((y) => (e.add(c), t.onNonFatalError(y instanceof Error ? y : new Error(String(y))), null)), resolved: null }, n.set(c, u)), (d = u.resolved) != null && d.fontUrl ? { ...a, fontUrl: u.resolved.fontUrl, kind: u.resolved.family } : a;
4883
4905
  },
4884
4906
  dispose() {
4885
4907
  r = !0, n.clear();
@@ -4893,19 +4915,19 @@ function so(t) {
4893
4915
  function ao(t, n, e) {
4894
4916
  return typeof We != "function" || e.aborted ? Promise.resolve() : new Promise((r, i) => {
4895
4917
  let s = !1;
4896
- const a = (d) => {
4897
- s || (s = !0, globalThis.clearTimeout(o), d());
4918
+ const a = (l) => {
4919
+ s || (s = !0, globalThis.clearTimeout(o), l());
4898
4920
  }, o = globalThis.setTimeout(() => {
4899
4921
  a(() => i(new Error(`Troika font warmup timed out for ${t}`)));
4900
4922
  }, io);
4901
4923
  try {
4902
- const d = We({ font: t, characters: n }, () => a(r));
4903
- so(d) && d.then(
4924
+ const l = We({ font: t, characters: n }, () => a(r));
4925
+ so(l) && l.then(
4904
4926
  () => a(r),
4905
- (l) => a(() => i(l instanceof Error ? l : new Error(String(l))))
4927
+ (c) => a(() => i(c instanceof Error ? c : new Error(String(c))))
4906
4928
  );
4907
- } catch (d) {
4908
- a(() => i(d instanceof Error ? d : new Error(String(d))));
4929
+ } catch (l) {
4930
+ a(() => i(l instanceof Error ? l : new Error(String(l))));
4909
4931
  }
4910
4932
  });
4911
4933
  }
@@ -4923,9 +4945,9 @@ function yo() {
4923
4945
  return typeof globalThis.document < "u" && typeof We == "function";
4924
4946
  }
4925
4947
  function mo(t) {
4926
- var v, I, w, T;
4927
- const n = ((v = t.options) == null ? void 0 : v.idleDelayMs) ?? oo, e = ((I = t.options) == null ? void 0 : I.maxUniqueCharsPerFont) ?? lo, r = ((w = t.options) == null ? void 0 : w.timeoutMs) ?? co, i = ((T = t.options) == null ? void 0 : T.signatureCacheLimit) ?? uo, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
4928
- let d = null, l = !1;
4948
+ var R, I, w, T;
4949
+ const n = ((R = t.options) == null ? void 0 : R.idleDelayMs) ?? oo, e = ((I = t.options) == null ? void 0 : I.maxUniqueCharsPerFont) ?? lo, r = ((w = t.options) == null ? void 0 : w.timeoutMs) ?? co, i = ((T = t.options) == null ? void 0 : T.signatureCacheLimit) ?? uo, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
4950
+ let l = null, c = !1;
4929
4951
  const u = {
4930
4952
  scheduledTexts: 0,
4931
4953
  preloadCalls: 0,
@@ -4934,23 +4956,23 @@ function mo(t) {
4934
4956
  timedOutWarmups: 0,
4935
4957
  evictedSignatures: 0
4936
4958
  };
4937
- function c(A) {
4938
- for (a.add(A); a.size > i; ) {
4939
- const B = a.values().next().value;
4940
- if (B === void 0) break;
4941
- a.delete(B), u.evictedSignatures += 1;
4959
+ function d(B) {
4960
+ for (a.add(B); a.size > i; ) {
4961
+ const A = a.values().next().value;
4962
+ if (A === void 0) break;
4963
+ a.delete(A), u.evictedSignatures += 1;
4942
4964
  }
4943
4965
  }
4944
- function h(A, B) {
4966
+ function h(B, A) {
4945
4967
  return new Promise((E, S) => {
4946
4968
  let P = !1;
4947
4969
  const O = (M) => {
4948
- P || (P = !0, globalThis.clearTimeout(W), M());
4949
- }, W = globalThis.setTimeout(() => {
4950
- u.timedOutWarmups += 1, O(() => S(new Error(`Troika font warmup timed out for ${A}`)));
4970
+ P || (P = !0, globalThis.clearTimeout(K), M());
4971
+ }, K = globalThis.setTimeout(() => {
4972
+ u.timedOutWarmups += 1, O(() => S(new Error(`Troika font warmup timed out for ${B}`)));
4951
4973
  }, r);
4952
4974
  try {
4953
- const M = We({ font: A, characters: B }, () => O(E));
4975
+ const M = We({ font: B, characters: A }, () => O(E));
4954
4976
  fo(M) && M.then(
4955
4977
  () => O(E),
4956
4978
  (_) => O(() => S(_ instanceof Error ? _ : new Error(String(_))))
@@ -4960,17 +4982,17 @@ function mo(t) {
4960
4982
  }
4961
4983
  });
4962
4984
  }
4963
- function y(A, B) {
4964
- const E = `${A}
4965
- ${B}`;
4985
+ function y(B, A) {
4986
+ const E = `${B}
4987
+ ${A}`;
4966
4988
  if (a.has(E))
4967
4989
  return u.skippedRepeatedSignatures += 1, Promise.resolve();
4968
4990
  const S = o.get(E);
4969
4991
  if (S !== void 0)
4970
4992
  return u.skippedRepeatedSignatures += 1, S;
4971
4993
  u.preloadCalls += 1;
4972
- const P = h(A, B).then(() => {
4973
- c(E);
4994
+ const P = h(B, A).then(() => {
4995
+ d(E);
4974
4996
  }).catch(() => {
4975
4997
  u.failedWarmups += 1;
4976
4998
  }).finally(() => {
@@ -4978,18 +5000,18 @@ ${B}`;
4978
5000
  });
4979
5001
  return o.set(E, P), P;
4980
5002
  }
4981
- function p() {
4982
- if (d = null, l || s.size === 0) return;
4983
- const A = [...s.entries()];
5003
+ function x() {
5004
+ if (l = null, c || s.size === 0) return;
5005
+ const B = [...s.entries()];
4984
5006
  s.clear();
4985
- for (const [B, E] of A)
4986
- E.size !== 0 && y(B, ho([...E].join("")));
4987
- }
4988
- function m(A) {
4989
- if (!(l || A.length === 0) && yo() && !t.signal.aborted) {
4990
- u.scheduledTexts += A.length;
4991
- for (const B of A) {
4992
- const E = t.resolveTextFont(B);
5007
+ for (const [A, E] of B)
5008
+ E.size !== 0 && y(A, ho([...E].join("")));
5009
+ }
5010
+ function m(B) {
5011
+ if (!(c || B.length === 0) && yo() && !t.signal.aborted) {
5012
+ u.scheduledTexts += B.length;
5013
+ for (const A of B) {
5014
+ const E = t.resolveTextFont(A);
4993
5015
  if (!E.fontUrl) continue;
4994
5016
  const S = s.get(E.fontUrl) ?? /* @__PURE__ */ new Set();
4995
5017
  if (s.set(E.fontUrl, S), !(S.size >= e))
@@ -4998,11 +5020,11 @@ ${B}`;
4998
5020
  S.add(P);
4999
5021
  }
5000
5022
  }
5001
- s.size === 0 || d !== null || (d = globalThis.setTimeout(p, n));
5023
+ s.size === 0 || l !== null || (l = globalThis.setTimeout(x, n));
5002
5024
  }
5003
5025
  }
5004
5026
  function b() {
5005
- l = !0, d !== null && (globalThis.clearTimeout(d), d = null), s.clear();
5027
+ c = !0, l !== null && (globalThis.clearTimeout(l), l = null), s.clear();
5006
5028
  }
5007
5029
  return {
5008
5030
  scheduleForTexts: m,
@@ -5016,7 +5038,7 @@ ${B}`;
5016
5038
  }
5017
5039
  };
5018
5040
  }
5019
- const Mr = 0.25, qn = 0.125;
5041
+ const Dr = 0.25, Kn = 0.125;
5020
5042
  function po(t) {
5021
5043
  const { viewport: n, worldUnitsPerPixel: e } = t;
5022
5044
  if (!n || !Number.isFinite(e) || e <= 0 || !Number.isFinite(n.minX) || !Number.isFinite(n.minY) || !Number.isFinite(n.maxX) || !Number.isFinite(n.maxY) || n.maxX <= n.minX || n.maxY <= n.minY)
@@ -5033,35 +5055,35 @@ function po(t) {
5033
5055
  function wt(t) {
5034
5056
  return Array.from(t).sort((n, e) => n - e).join(",");
5035
5057
  }
5036
- function Dr(t, n) {
5058
+ function Fr(t, n) {
5037
5059
  if (t === null || !Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) return !1;
5038
5060
  const e = n / t;
5039
- return e >= 1 - qn && e <= 1 + qn;
5061
+ return e >= 1 - Kn && e <= 1 + Kn;
5040
5062
  }
5041
5063
  function xo(t) {
5042
- return !t.viewport || !t.coverage || !_t(t.coverage, t.viewport) || !Dr(t.coverageWorldUnitsPerPixel, t.worldUnitsPerPixel) ? !1 : t.coverageHiddenSignature === t.hiddenSignature;
5064
+ return !t.viewport || !t.coverage || !_t(t.coverage, t.viewport) || !Fr(t.coverageWorldUnitsPerPixel, t.worldUnitsPerPixel) ? !1 : t.coverageHiddenSignature === t.hiddenSignature;
5043
5065
  }
5044
5066
  function go(t) {
5045
5067
  return !t.latestViewport || !_t(
5046
- Je(t.requestedViewport, Mr),
5068
+ Je(t.requestedViewport, Dr),
5047
5069
  t.latestViewport
5048
- ) || !Dr(t.requestedWorldUnitsPerPixel, t.latestWorldUnitsPerPixel) ? !1 : t.requestedHiddenSignature === t.latestHiddenSignature;
5070
+ ) || !Fr(t.requestedWorldUnitsPerPixel, t.latestWorldUnitsPerPixel) ? !1 : t.requestedHiddenSignature === t.latestHiddenSignature;
5049
5071
  }
5050
5072
  function Oe(t, n, e) {
5051
5073
  return {
5052
- coverage: Je(t, Mr),
5074
+ coverage: Je(t, Dr),
5053
5075
  worldUnitsPerPixel: n,
5054
5076
  hiddenSignature: e
5055
5077
  };
5056
5078
  }
5057
5079
  const Mt = /* @__PURE__ */ new WeakMap(), bo = 16;
5058
- function zo(t) {
5080
+ function Ho(t) {
5059
5081
  const n = Mt.get(t);
5060
5082
  if (!n)
5061
5083
  throw new Error("CAD document session has no render resource");
5062
5084
  return n;
5063
5085
  }
5064
- function Ho(t, n = {}) {
5086
+ function qo(t, n = {}) {
5065
5087
  return new Dt(t, n);
5066
5088
  }
5067
5089
  const Ze = class Ze {
@@ -5069,7 +5091,7 @@ const Ze = class Ze {
5069
5091
  f(this, "phase", "created");
5070
5092
  f(this, "headerReady");
5071
5093
  f(this, "initialContentReady");
5072
- f(this, "loadStartedAtMs", Ae());
5094
+ f(this, "loadStartedAtMs", Be());
5073
5095
  f(this, "loadTimingState", {
5074
5096
  startedAtMs: this.loadStartedAtMs,
5075
5097
  initialRequiredVariantCount: 0,
@@ -5107,6 +5129,7 @@ const Ze = class Ze {
5107
5129
  f(this, "initialViewportDemand", null);
5108
5130
  f(this, "initialRequiredVariantIds", /* @__PURE__ */ new Set());
5109
5131
  f(this, "pendingInitialVariantIds", /* @__PURE__ */ new Set());
5132
+ f(this, "initialFirstVariantAppendStarted", !1);
5110
5133
  f(this, "initialVariantAppendTimer", null);
5111
5134
  f(this, "initialVariantAppendInFlight", null);
5112
5135
  f(this, "initialViewportSettled", !1);
@@ -5137,7 +5160,7 @@ const Ze = class Ze {
5137
5160
  f(this, "handleBeforeTextAppend", (n) => {
5138
5161
  this.scheduleTextWarmup(n);
5139
5162
  });
5140
- this.sessionEpoch = Ze.nextEpoch++, this.documentKey = e.documentKey ?? null, this.filename = e.filename ?? null, this.loadAnnotations = e.loadAnnotations !== !1, this.workerUrl = e.workerUrl, this.workerFactory = e.workerFactory, this.workerAdapter = nt(this.workerFactory) ? Ni({
5163
+ this.sessionEpoch = Ze.nextEpoch++, this.documentKey = e.documentKey ?? null, this.filename = e.filename ?? null, this.loadAnnotations = e.loadAnnotations !== !1, this.workerUrl = e.workerUrl, this.workerFactory = e.workerFactory, this.workerAdapter = nt(this.workerFactory) ? zi({
5141
5164
  workerUrl: this.workerUrl,
5142
5165
  workerFactory: this.workerFactory
5143
5166
  }) : null, this.fontRuntime = ro({
@@ -5171,7 +5194,7 @@ const Ze = class Ze {
5171
5194
  ue(e.signal, this.sessionAbort),
5172
5195
  ue(r.sourceSignal, this.sessionAbort)
5173
5196
  ), $e(this.node, () => {
5174
- this.abort(K("GeoNode disposed during CAD load"));
5197
+ this.abort(W("GeoNode disposed during CAD load"));
5175
5198
  }), this.runLoad();
5176
5199
  }
5177
5200
  get loadTiming() {
@@ -5180,7 +5203,7 @@ const Ze = class Ze {
5180
5203
  markLoadTiming(n) {
5181
5204
  this.loadTimingState[n] === void 0 && (this.loadTimingState = {
5182
5205
  ...this.loadTimingState,
5183
- [n]: Ae() - this.loadStartedAtMs
5206
+ [n]: Be() - this.loadStartedAtMs
5184
5207
  }, this.emit("load-timing", { timing: this.loadTimingState }));
5185
5208
  }
5186
5209
  updateLoadTimingCounters(n) {
@@ -5202,7 +5225,7 @@ const Ze = class Ze {
5202
5225
  return;
5203
5226
  }
5204
5227
  if (n.interaction === "active") {
5205
- this.abortAnnotations("viewport interaction active"), this.demandAbort.abort(K("viewport interaction active")), this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5228
+ this.abortAnnotations("viewport interaction active"), this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5206
5229
  return;
5207
5230
  }
5208
5231
  this.maybeRefreshExternalSidecars(), this.maybeLoadVisibleAnnotations(), this.maybeMarkInitialViewportSettled();
@@ -5255,11 +5278,11 @@ const Ze = class Ze {
5255
5278
  return n;
5256
5279
  }
5257
5280
  getBlockDetails(n) {
5258
- const e = kr(n);
5281
+ const e = Tr(n);
5259
5282
  return e ? "kind" in e ? It(this.node, e) : this.findInsertDetailsByInstanceId(e.instanceId) : null;
5260
5283
  }
5261
5284
  pickInsertAtPoint(n, e) {
5262
- const r = Ga(
5285
+ const r = Ua(
5263
5286
  this.node,
5264
5287
  { x: n.x, y: n.y },
5265
5288
  {
@@ -5274,23 +5297,23 @@ const Ze = class Ze {
5274
5297
  } : null;
5275
5298
  }
5276
5299
  pickTextAtPoint(n) {
5277
- const e = Ha(this.node, { x: n.x, y: n.y });
5300
+ const e = qa(this.node, { x: n.x, y: n.y });
5278
5301
  return e ? {
5279
5302
  documentKey: this.documentKey,
5280
5303
  id: e,
5281
- details: qa(this.node, e)
5304
+ details: Un(this.node, e)
5282
5305
  } : null;
5283
5306
  }
5284
5307
  abort(n) {
5285
5308
  var r;
5286
5309
  if (this.disposed) return;
5287
- const e = K(n);
5310
+ const e = W(n);
5288
5311
  this.sessionAbort.abort(e), this.demandAbort.abort(e), this.annotationAbort.abort(e), (r = this.workerAdapter) == null || r.dispose(), !this.failed && this.fail(e);
5289
5312
  }
5290
5313
  dispose() {
5291
5314
  var e, r;
5292
5315
  if (this.disposed) return;
5293
- const n = K("CAD document session disposed");
5316
+ const n = W("CAD document session disposed");
5294
5317
  this.disposed = !0, this.sessionAbort.abort(n), this.demandAbort.abort(n), this.annotationAbort.abort(n), (e = this.workerAdapter) == null || e.dispose(), this.clearAnnotationTimer(), this.clearInitialVariantAppendTimer(), this.rejectHeader(n), this.rejectInitial(n), this.setPhase("disposed"), (r = this.textWarmup) == null || r.dispose(), this.fontRuntime.dispose(), this.listeners.clear();
5295
5318
  for (const i of this.signalCleanups) i();
5296
5319
  this.signalCleanups.length = 0, $e(this.node, null), this.node.ready.catch(() => {
@@ -5299,17 +5322,17 @@ const Ze = class Ze {
5299
5322
  async runLoad() {
5300
5323
  const n = this.sessionEpoch;
5301
5324
  try {
5302
- const e = await jn(
5325
+ const e = await Zn(
5303
5326
  Zt(this.normalizedSource),
5304
5327
  this.sessionAbort.signal,
5305
5328
  "CAD load aborted before decoding"
5306
5329
  );
5307
5330
  if (!this.isCurrent(n)) return;
5308
- this.mainBuffer = e, this.markLoadTiming("mainBufferLoadedMs"), this.sourceFingerprint = this.documentKey ?? Io(e), this.baseUrl = this.normalizedSource ? Vr(this.normalizedSource) : null;
5309
- const r = Ma(e), i = this.toDocumentHeader(r);
5331
+ this.mainBuffer = e, this.markLoadTiming("mainBufferLoadedMs"), this.sourceFingerprint = this.documentKey ?? Io(e), this.baseUrl = this.normalizedSource ? Er(this.normalizedSource) : null;
5332
+ const r = Da(e), i = this.toDocumentHeader(r);
5310
5333
  if (this.header = i, this.headerBounds = i.bounds, this.annotationManifest = this.loadAnnotations ? Gt(e) : null, this.setPhase("header-ready"), this.markLoadTiming("headerReadyMs"), this.emit("header", { header: i }), this.setPhase("initial-loading"), this.resolveHeader(i), await Promise.resolve(), !this.isCurrent(n)) return;
5311
5334
  const s = this.latestDemand ?? this.pendingDemand, a = this.planInitialExternalVariants(s);
5312
- if (this.initialViewportDemand = s, this.beginInitialExternalVariantLoad(a.requiredVariantIds), await cr(this.node, e.slice(0), void 0, {
5335
+ if (this.initialViewportDemand = s, this.beginInitialExternalVariantLoad(a.requiredVariantIds), await ur(this.node, e.slice(0), void 0, {
5313
5336
  signal: this.sessionAbort.signal,
5314
5337
  workerUrl: this.workerUrl,
5315
5338
  workerFactory: this.workerFactory,
@@ -5317,6 +5340,7 @@ const Ze = class Ze {
5317
5340
  hiddenInstanceIds: this.hiddenInstanceIds.size > 0 ? this.hiddenInstanceIds : void 0,
5318
5341
  requiredExternalVariantIds: a.requiredVariantIds,
5319
5342
  deferExternalVariantGeometry: a.requiredVariantIds.length > 0 && !!this.baseUrl,
5343
+ cacheDocument: this.workerAdapter !== null,
5320
5344
  onFirstRenderableAppend: () => this.markLoadTiming("firstRenderableReadyMs"),
5321
5345
  beforeTextAppend: this.handleBeforeTextAppend
5322
5346
  }), await this.node.ready, !this.isCurrent(n)) return;
@@ -5368,13 +5392,13 @@ const Ze = class Ze {
5368
5392
  });
5369
5393
  }
5370
5394
  async refreshExternalSidecarsForViewport(n, e) {
5371
- var c;
5395
+ var d;
5372
5396
  const r = this.sessionEpoch, i = this.mainBuffer;
5373
5397
  if (!i || !this.baseUrl) {
5374
5398
  this.emitDemandProgress(!0);
5375
5399
  return;
5376
5400
  }
5377
- if (((c = this.latestDemand) == null ? void 0 : c.interaction) === "active") {
5401
+ if (((d = this.latestDemand) == null ? void 0 : d.interaction) === "active") {
5378
5402
  this.externalViewportQueued = !0;
5379
5403
  return;
5380
5404
  }
@@ -5405,29 +5429,29 @@ const Ze = class Ze {
5405
5429
  signal: this.demandAbort.signal
5406
5430
  });
5407
5431
  if (!this.isCurrent(r)) return;
5408
- for (const [y, p] of h.buffers)
5409
- this.loadedSidecarBuffers.set(y, p), this.variantCoverage.set(y, "cached");
5432
+ for (const [y, x] of h.buffers)
5433
+ this.loadedSidecarBuffers.set(y, x), this.variantCoverage.set(y, "cached");
5410
5434
  }
5411
5435
  if (!this.isCurrent(r)) return;
5412
- const d = this.latestDemand;
5413
- if (!d || d.interaction === "active" || !go({
5436
+ const l = this.latestDemand;
5437
+ if (!l || l.interaction === "active" || !go({
5414
5438
  requestedViewport: n.documentRect,
5415
5439
  requestedWorldUnitsPerPixel: n.worldUnitsPerPixel,
5416
5440
  requestedHiddenSignature: e,
5417
- latestViewport: d.documentRect,
5418
- latestWorldUnitsPerPixel: d.worldUnitsPerPixel,
5441
+ latestViewport: l.documentRect,
5442
+ latestWorldUnitsPerPixel: l.worldUnitsPerPixel,
5419
5443
  latestHiddenSignature: wt(this.hiddenInstanceIds)
5420
5444
  })) {
5421
5445
  this.externalViewportQueued = !0, this.emitDemandProgress(!0);
5422
5446
  return;
5423
5447
  }
5424
- const l = a.filter((h) => !this.renderedRequiredVariantIds.has(h));
5425
- if (l.length === 0) {
5426
- this.lastCoverage = Oe(d.documentRect, d.worldUnitsPerPixel, e), this.emitDemandProgress(!0);
5448
+ const c = a.filter((h) => !this.renderedRequiredVariantIds.has(h));
5449
+ if (c.length === 0) {
5450
+ this.lastCoverage = Oe(l.documentRect, l.worldUnitsPerPixel, e), this.emitDemandProgress(!0);
5427
5451
  return;
5428
5452
  }
5429
5453
  const u = /* @__PURE__ */ new Map();
5430
- for (const h of l) {
5454
+ for (const h of c) {
5431
5455
  const y = this.loadedSidecarBuffers.get(h);
5432
5456
  if (!y)
5433
5457
  throw this.variantCoverage.set(h, "rejected"), new Error(`External block ${h} 尚未加载。`);
@@ -5440,13 +5464,13 @@ const Ze = class Ze {
5440
5464
  workerAdapter: this.workerAdapter ?? void 0,
5441
5465
  hiddenInstanceIds: this.hiddenInstanceIds,
5442
5466
  externalVariantBuffers: u,
5443
- requiredExternalVariantIds: l,
5467
+ requiredExternalVariantIds: c,
5444
5468
  beforeTextAppend: this.handleBeforeTextAppend
5445
5469
  }), !!this.isCurrent(r)) {
5446
- for (const h of l)
5470
+ for (const h of c)
5447
5471
  this.renderedRequiredVariantIds.add(h), this.variantCoverage.set(h, "loaded");
5448
- this.bumpContent("geometry"), this.lastCoverage = Oe(d.documentRect, d.worldUnitsPerPixel, e), this.emitDemandProgress(!0), l.some((h) => {
5449
- const y = this.variantManifest.find((p) => p.id === h);
5472
+ this.bumpContent("geometry"), this.lastCoverage = Oe(l.documentRect, l.worldUnitsPerPixel, e), this.emitDemandProgress(!0), c.some((h) => {
5473
+ const y = this.variantManifest.find((x) => x.id === h);
5450
5474
  return y ? Ct(y) : !1;
5451
5475
  }) && (this.blockAnnotationsLoaded = !1), this.maybeLoadVisibleAnnotations();
5452
5476
  }
@@ -5475,10 +5499,10 @@ const Ze = class Ze {
5475
5499
  }
5476
5500
  shouldScheduleAnnotationLoad(n) {
5477
5501
  var i;
5478
- if (!Hn(n.worldUnitsPerPixel)) return !1;
5502
+ if (!qn(n.worldUnitsPerPixel)) return !1;
5479
5503
  const e = (i = this.annotationManifest) == null ? void 0 : i.scene;
5480
- return e && !this.sceneAnnotationsLoaded && !this.sceneAnnotationsLoading && Nn({
5481
- manifestBBox: zn(e),
5504
+ return e && !this.sceneAnnotationsLoaded && !this.sceneAnnotationsLoading && zn({
5505
+ manifestBBox: Hn(e),
5482
5506
  viewport: n.documentRect,
5483
5507
  worldUnitsPerPixel: n.worldUnitsPerPixel
5484
5508
  }) ? !0 : !!(!this.blockAnnotationsLoaded && !this.blockAnnotationsLoading && this.variantManifest.some(Ct));
@@ -5512,14 +5536,14 @@ const Ze = class Ze {
5512
5536
  async loadSceneAnnotations(n) {
5513
5537
  var r;
5514
5538
  const e = (r = this.annotationManifest) == null ? void 0 : r.scene;
5515
- if (!(!e || this.sceneAnnotationsLoaded || this.sceneAnnotationsLoading) && this.baseUrl && Nn({
5516
- manifestBBox: zn(e),
5539
+ if (!(!e || this.sceneAnnotationsLoaded || this.sceneAnnotationsLoading) && this.baseUrl && zn({
5540
+ manifestBBox: Hn(e),
5517
5541
  viewport: n.documentRect,
5518
5542
  worldUnitsPerPixel: n.worldUnitsPerPixel
5519
5543
  })) {
5520
5544
  this.sceneAnnotationsLoading = !0;
5521
5545
  try {
5522
- const i = await Er(this.baseUrl, e, this.annotationAbort.signal);
5546
+ const i = await Sr(this.baseUrl, e, this.annotationAbort.signal);
5523
5547
  if (!this.isCurrent(this.sessionEpoch) || !je(i)) {
5524
5548
  this.sceneAnnotationsLoaded = !0;
5525
5549
  return;
@@ -5531,7 +5555,7 @@ const Ze = class Ze {
5531
5555
  }
5532
5556
  }
5533
5557
  async loadBlockAnnotations(n) {
5534
- if (!(this.blockAnnotationsLoaded || this.blockAnnotationsLoading) && this.mainBuffer && this.variantManifest.some(Ct) && Hn(n.worldUnitsPerPixel)) {
5558
+ if (!(this.blockAnnotationsLoaded || this.blockAnnotationsLoading) && this.mainBuffer && this.variantManifest.some(Ct) && qn(n.worldUnitsPerPixel)) {
5535
5559
  this.blockAnnotationsLoading = !0;
5536
5560
  try {
5537
5561
  const e = Ut(this.mainBuffer, {
@@ -5551,6 +5575,9 @@ const Ze = class Ze {
5551
5575
  for (const r of n.manifest) e.set(r.id, r);
5552
5576
  this.variantManifest = Array.from(e.values());
5553
5577
  }
5578
+ getTextDetails(n) {
5579
+ return Un(this.node, n);
5580
+ }
5554
5581
  planInitialExternalVariants(n) {
5555
5582
  const e = this.mainBuffer;
5556
5583
  if (!e || !n || !this.baseUrl)
@@ -5570,7 +5597,7 @@ const Ze = class Ze {
5570
5597
  return this.emitDemandProgress(!1), { requiredVariantIds: r.requiredVariantIds };
5571
5598
  }
5572
5599
  beginInitialExternalVariantLoad(n) {
5573
- !this.baseUrl || n.length === 0 || (this.replaceDemandAbort(), this.initialExternalLoading = !0, this.markLoadTiming("initialSidecarFetchStartedMs"), Xe({
5600
+ !this.baseUrl || n.length === 0 || (this.replaceDemandAbort(), this.initialExternalLoading = !0, this.initialFirstVariantAppendStarted = !1, this.markLoadTiming("initialSidecarFetchStartedMs"), Xe({
5574
5601
  baseUrl: this.baseUrl,
5575
5602
  entries: this.variantManifest,
5576
5603
  requiredVariantIds: n,
@@ -5593,49 +5620,56 @@ const Ze = class Ze {
5593
5620
  }));
5594
5621
  }
5595
5622
  scheduleInitialVariantAppend() {
5596
- !this.baseContentReady || this.initialExternalLoading || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight || this.initialVariantAppendTimer === null && (this.initialVariantAppendTimer = globalThis.setTimeout(() => {
5623
+ !this.baseContentReady || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight || this.initialFirstVariantAppendStarted && this.initialExternalLoading || this.initialVariantAppendTimer === null && (this.initialVariantAppendTimer = globalThis.setTimeout(() => {
5597
5624
  this.initialVariantAppendTimer = null, this.appendInitialVariantBatch();
5598
- }, bo));
5625
+ }, this.initialFirstVariantAppendStarted ? 0 : bo));
5599
5626
  }
5600
5627
  async appendInitialVariantBatch() {
5601
5628
  if (!this.baseContentReady || this.pendingInitialVariantIds.size === 0 || this.initialVariantAppendInFlight) return;
5602
- const n = Array.from(this.pendingInitialVariantIds).sort((r, i) => r - i);
5603
- n.forEach((r) => this.pendingInitialVariantIds.delete(r));
5604
- const e = /* @__PURE__ */ new Map();
5605
- for (const r of n) {
5606
- const i = this.loadedSidecarBuffers.get(r);
5607
- i && e.set(r, i);
5629
+ const n = !this.initialFirstVariantAppendStarted, e = Array.from(this.pendingInitialVariantIds).sort((i, s) => i - s);
5630
+ e.forEach((i) => this.pendingInitialVariantIds.delete(i));
5631
+ const r = /* @__PURE__ */ new Map();
5632
+ for (const i of e) {
5633
+ const s = this.loadedSidecarBuffers.get(i);
5634
+ s && r.set(i, s);
5608
5635
  }
5609
- if (e.size === 0) {
5636
+ if (r.size === 0) {
5610
5637
  this.scheduleInitialVariantAppend();
5611
5638
  return;
5612
5639
  }
5613
- this.initialVariantAppendInFlight = Et(this.node, this.mainBuffer, void 0, {
5640
+ this.initialFirstVariantAppendStarted = !0, this.initialVariantAppendInFlight = Et(this.node, this.mainBuffer, void 0, {
5614
5641
  signal: this.demandAbort.signal,
5615
5642
  workerUrl: this.workerUrl,
5616
5643
  workerFactory: this.workerFactory,
5617
5644
  workerAdapter: this.workerAdapter ?? void 0,
5618
5645
  hiddenInstanceIds: this.hiddenInstanceIds,
5619
- externalVariantBuffers: e,
5620
- requiredExternalVariantIds: n,
5646
+ externalVariantBuffers: r,
5647
+ requiredExternalVariantIds: e,
5621
5648
  beforeTextAppend: this.handleBeforeTextAppend
5622
5649
  }).then(() => {
5623
5650
  if (!this.isCurrent(this.sessionEpoch)) return;
5624
- for (const i of n)
5625
- this.renderedRequiredVariantIds.add(i), this.variantCoverage.set(i, "loaded");
5626
- this.initialRequiredVariantIds.size > 0 && Array.from(this.initialRequiredVariantIds).every((i) => this.renderedRequiredVariantIds.has(i)) && this.markLoadTiming("initialExternalContentReadyMs"), this.bumpContent("geometry");
5627
- const r = this.latestDemand ?? this.initialViewportDemand;
5628
- !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && r && Array.from(this.initialRequiredVariantIds).every((i) => this.renderedRequiredVariantIds.has(i)) && (this.lastCoverage = Oe(
5629
- r.documentRect,
5630
- r.worldUnitsPerPixel,
5651
+ for (const s of e)
5652
+ this.renderedRequiredVariantIds.add(s), this.variantCoverage.set(s, "loaded");
5653
+ this.initialRequiredVariantIds.size > 0 && Array.from(this.initialRequiredVariantIds).every((s) => this.renderedRequiredVariantIds.has(s)) && this.markLoadTiming("initialExternalContentReadyMs"), this.bumpContent("geometry");
5654
+ const i = this.latestDemand ?? this.initialViewportDemand;
5655
+ !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && i && Array.from(this.initialRequiredVariantIds).every((s) => this.renderedRequiredVariantIds.has(s)) && (this.lastCoverage = Oe(
5656
+ i.documentRect,
5657
+ i.worldUnitsPerPixel,
5631
5658
  wt(this.hiddenInstanceIds)
5632
5659
  )), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0), this.maybeMarkInitialViewportSettled();
5633
- }).catch((r) => {
5634
- const i = ve(r);
5635
- if (i.name !== "AbortError") {
5636
- for (const s of n) this.variantCoverage.set(s, "rejected");
5637
- this.emit("non-fatal-error", { error: i }), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0);
5660
+ }).catch((i) => {
5661
+ const s = ve(i);
5662
+ if (s.name === "AbortError") {
5663
+ if (this.isCurrent(this.sessionEpoch)) {
5664
+ this.replaceDemandAbort();
5665
+ for (const a of e)
5666
+ !this.renderedRequiredVariantIds.has(a) && this.loadedSidecarBuffers.has(a) && (this.pendingInitialVariantIds.add(a), this.variantCoverage.set(a, "cached"));
5667
+ n && (this.initialFirstVariantAppendStarted = !1), this.emitDemandProgress(!1);
5668
+ }
5669
+ return;
5638
5670
  }
5671
+ for (const a of e) this.variantCoverage.set(a, "rejected");
5672
+ this.emit("non-fatal-error", { error: s }), this.emitDemandProgress(!this.initialExternalLoading && this.pendingInitialVariantIds.size === 0);
5639
5673
  }).finally(() => {
5640
5674
  this.initialVariantAppendInFlight = null, this.scheduleInitialVariantAppend(), this.maybeMarkInitialViewportSettled(), this.externalViewportQueued && !this.initialExternalLoading && this.pendingInitialVariantIds.size === 0 && (this.externalViewportQueued = !1, this.maybeRefreshExternalSidecars());
5641
5675
  }), await this.initialVariantAppendInFlight;
@@ -5667,17 +5701,25 @@ const Ze = class Ze {
5667
5701
  });
5668
5702
  }
5669
5703
  toDocumentHeader(n) {
5704
+ var i, s, a;
5705
+ const e = typeof ((i = n.units) == null ? void 0 : i.source) == "string" && n.units.source.trim().length > 0 ? n.units.source.trim() : null, r = ((s = n.units) == null ? void 0 : s.scaleToMeters) ?? ((a = n.units) == null ? void 0 : a.scale_to_meters);
5670
5706
  return {
5671
5707
  bounds: He(n.bounds),
5672
- layers: n.layers.map((e) => ({
5673
- index: e.index,
5674
- name: e.name,
5675
- color: e.color,
5676
- visible: e.visible ?? !0
5708
+ layers: n.layers.map((o) => ({
5709
+ index: o.index,
5710
+ name: o.name,
5711
+ color: o.color,
5712
+ visible: o.visible ?? !0
5677
5713
  })),
5678
5714
  sourceFingerprint: this.sourceFingerprint,
5679
5715
  format: "dxb3",
5680
- filename: this.filename
5716
+ filename: this.filename,
5717
+ ...e ? {
5718
+ units: {
5719
+ source: e,
5720
+ ...Number.isFinite(r) ? { scaleToMeters: r } : {}
5721
+ }
5722
+ } : {}
5681
5723
  };
5682
5724
  }
5683
5725
  findInsertDetailsByInstanceId(n) {
@@ -5717,7 +5759,7 @@ const Ze = class Ze {
5717
5759
  this.annotationAbort.signal.aborted && (this.annotationAbort = new AbortController(), ue(this.sessionAbort.signal, this.annotationAbort));
5718
5760
  }
5719
5761
  abortAnnotations(n) {
5720
- this.clearAnnotationTimer(), this.annotationAbort.signal.aborted || this.annotationAbort.abort(K(n)), this.replaceAnnotationAbort();
5762
+ this.clearAnnotationTimer(), this.annotationAbort.signal.aborted || this.annotationAbort.abort(W(n)), this.replaceAnnotationAbort();
5721
5763
  }
5722
5764
  clearAnnotationTimer() {
5723
5765
  this.annotationTimer !== null && (globalThis.clearTimeout(this.annotationTimer), this.annotationTimer = null), this.annotationSeq += 1;
@@ -5742,45 +5784,46 @@ const Co = [
5742
5784
  "applyInsertTransform",
5743
5785
  "editBlock"
5744
5786
  ];
5745
- function qo(t) {
5787
+ function Ko(t) {
5746
5788
  return Co.includes(t);
5747
5789
  }
5748
5790
  export {
5749
5791
  Co as CAD_RENDER_NODE_EDIT_METHODS,
5750
- No as CAD_SESSION_PHASES,
5751
- la as GEO_NODE_STRUCTURE_CHANGE,
5792
+ zo as CAD_SESSION_PHASES,
5793
+ ca as GEO_NODE_STRUCTURE_CHANGE,
5752
5794
  Eo as GEO_NODE_VISUAL_CHANGE,
5753
5795
  U as GeoLoaderError,
5754
5796
  ye as GeoNode,
5755
5797
  So as appendExternalVariantDeltaToGeoNode,
5756
5798
  Oo as assertValidSourceOrThrow,
5757
- Go as cadInsertSelectionEquals,
5758
- Uo as cadTextSelectionEquals,
5759
- Ho as createCadDocumentSession,
5799
+ Uo as cadInsertSelectionEquals,
5800
+ No as cadTextSelectionEquals,
5801
+ Go as configureCadTextBuilder,
5802
+ qo as createCadDocumentSession,
5760
5803
  Vo as createLoadSession,
5761
5804
  Je as expandViewportRect,
5762
5805
  Ka as formatCadInsertId,
5763
- zo as getCadDocumentRenderResource,
5764
- qo as isCadRenderNodeEditMethod,
5806
+ Ho as getCadDocumentRenderResource,
5807
+ Ko as isCadRenderNodeEditMethod,
5765
5808
  Fo as loadExternalVariantDeltaFromBuffer,
5766
5809
  _o as loadGeo,
5767
5810
  fe as mergeViewportRects,
5768
- Da as normalizeGeoError,
5811
+ Fa as normalizeGeoError,
5769
5812
  ko as parseBuffer,
5770
5813
  To as parseBufferBounds,
5771
- Ma as parseBufferHeader,
5772
- kr as parseCadInsertId,
5773
- Ga as pickCadInsertAtPoint,
5774
- Ha as pickCadTextAtPoint,
5775
- Xo as readBlockAnnotationSidecar,
5814
+ Da as parseBufferHeader,
5815
+ Tr as parseCadInsertId,
5816
+ Ua as pickCadInsertAtPoint,
5817
+ qa as pickCadTextAtPoint,
5818
+ Yo as readBlockAnnotationSidecar,
5776
5819
  Mo as readBufferExternalAnnotationManifest,
5777
5820
  Do as readBufferExternalBlockAnnotations,
5778
5821
  Lo as readBufferExternalVariantDependencyPlan,
5779
5822
  Po as readBufferExternalVariantManifest,
5780
- Wr as readSceneAnnotationSidecar,
5823
+ Xr as readSceneAnnotationSidecar,
5781
5824
  It as resolveCadInsertDetails,
5782
- qa as resolveCadTextDetails,
5783
- Nr as transformBBoxByInstance,
5825
+ Un as resolveCadTextDetails,
5826
+ zr as transformBBoxByInstance,
5784
5827
  _t as viewportRectContains,
5785
- Kn as viewportRectIntersects
5828
+ Wn as viewportRectIntersects
5786
5829
  };