@nebula-spatial/cad-loader 0.2.2 → 0.2.3

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.
@@ -1,74 +1,74 @@
1
- var Fe = Object.defineProperty;
1
+ var Xe = Object.defineProperty;
2
2
  var jt = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Xe = (t, e, n) => e in t ? Fe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var J = (t, e, n) => Xe(t, typeof e != "symbol" ? e + "" : e, n), Ye = (t, e, n) => e.has(t) || jt("Cannot " + n);
7
- var et = (t, e, n) => (Ye(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Wt = (t, e, n) => e.has(t) ? jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n);
5
+ var Ye = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
+ var Z = (t, e, n) => Ye(t, typeof e != "symbol" ? e + "" : e, n), ze = (t, e, n) => e.has(t) || jt("Cannot " + n);
7
+ var et = (t, e, n) => (ze(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Wt = (t, e, n) => e.has(t) ? jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n);
8
8
  class l extends Error {
9
9
  constructor(n, r) {
10
10
  super(r);
11
- J(this, "code");
11
+ Z(this, "code");
12
12
  this.name = "GeoLoaderError", this.code = n;
13
13
  }
14
14
  }
15
15
  const Ut = 4096;
16
- function ye(t) {
16
+ function _e(t) {
17
17
  return t >= 6 ? "u16_lw" : t >= 5 ? "u8_lw" : t >= 4 ? "u16" : "u8";
18
18
  }
19
19
  function xe(t) {
20
20
  return t === "u16_lw" ? 13 : t === "u8_lw" ? 12 : t === "u16" ? 9 : 8;
21
21
  }
22
- function _e(t, e, n) {
22
+ function Ee(t, e, n) {
23
23
  return n === "u16" || n === "u16_lw" ? t.getUint16(e + 7, !0) : t.getUint8(e + 7);
24
24
  }
25
- function ze(t) {
25
+ function He(t) {
26
26
  return t === "u16" || t === "u16_lw" ? 2 : 1;
27
27
  }
28
- function Ee(t, e, n) {
28
+ function we(t, e, n) {
29
29
  if (!(n !== "u8_lw" && n !== "u16_lw"))
30
- return t.getFloat32(e + 7 + ze(n), !0);
30
+ return t.getFloat32(e + 7 + He(n), !0);
31
31
  }
32
- function we(t, e, n, r, o = t.byteLength, s = "u8") {
33
- if (n > o || o > t.byteLength)
32
+ function pe(t, e, n, r, s = t.byteLength, o = "u8") {
33
+ if (n > s || s > t.byteLength)
34
34
  throw new l("E_GROUP_RANGE", "Group byte range exceeds payload length");
35
35
  let i = n;
36
36
  const a = r * 2, c = a * 4;
37
- if (i + c > o)
37
+ if (i + c > s)
38
38
  throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
39
39
  let u;
40
40
  if (a > 0) {
41
41
  const w = new Uint8Array(t, i, c), y = new Uint8Array(c), f = a;
42
- for (let _ = 0; _ < a; _++)
43
- y[_ * 4] = w[_], y[_ * 4 + 1] = w[f + _], y[_ * 4 + 2] = w[f * 2 + _], y[_ * 4 + 3] = w[f * 3 + _];
42
+ for (let x = 0; x < a; x++)
43
+ y[x * 4] = w[x], y[x * 4 + 1] = w[f + x], y[x * 4 + 2] = w[f * 2 + x], y[x * 4 + 3] = w[f * 3 + x];
44
44
  u = new Float32Array(y.buffer);
45
45
  } else
46
46
  u = new Float32Array(0);
47
- if (i += c, i + 4 > o)
47
+ if (i += c, i + 4 > s)
48
48
  throw new l("E_GROUP_RANGE", "Missing seg_count field for group");
49
49
  const m = e.getUint32(i, !0);
50
50
  i += 4;
51
51
  const g = [];
52
52
  let d = 0;
53
- const h = xe(s);
53
+ const h = xe(o);
54
54
  for (let w = 0; w < m; w++) {
55
- if (i + h > o)
55
+ if (i + h > s)
56
56
  throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
57
- const y = e.getUint32(i, !0), f = e.getUint8(i + 4), _ = e.getUint8(i + 5), b = e.getUint8(i + 6), E = _e(e, i, s), p = Ee(e, i, s);
57
+ const y = e.getUint32(i, !0), f = e.getUint8(i + 4), x = e.getUint8(i + 5), p = e.getUint8(i + 6), E = Ee(e, i, o), b = we(e, i, o);
58
58
  if (d + y > r)
59
59
  throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
60
60
  g.push({
61
61
  startVertex: d,
62
62
  vertexCount: y,
63
- color: [f, _, b],
63
+ color: [f, x, p],
64
64
  layerIndex: E,
65
- ...p === void 0 ? {} : { lineweightPx: p }
65
+ ...b === void 0 ? {} : { lineweightPx: b }
66
66
  }), i += h;
67
- const S = d * 2;
67
+ const P = d * 2;
68
68
  if (y > 1) {
69
- let N = u[S], C = u[S + 1];
69
+ let N = u[P], C = u[P + 1];
70
70
  for (let G = 1; G < y; G++) {
71
- const U = S + G * 2;
71
+ const U = P + G * 2;
72
72
  N += u[U], C += u[U + 1], u[U] = N, u[U + 1] = C;
73
73
  }
74
74
  }
@@ -81,8 +81,8 @@ function we(t, e, n, r, o = t.byteLength, s = "u8") {
81
81
  offset: i
82
82
  };
83
83
  }
84
- function He(t, e, n, r, o = "u8") {
85
- const s = r * 2, i = s * 4;
84
+ function Ke(t, e, n, r, s = "u8") {
85
+ const o = r * 2, i = o * 4;
86
86
  if (n + i > t.byteLength)
87
87
  throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
88
88
  const a = new Uint8Array(t, n, i);
@@ -93,18 +93,18 @@ function He(t, e, n, r, o = "u8") {
93
93
  c += 4;
94
94
  const m = [];
95
95
  let g = 0;
96
- const d = xe(o);
96
+ const d = xe(s);
97
97
  for (let h = 0; h < u; h++) {
98
98
  if (c + d > t.byteLength)
99
99
  throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
100
- const w = e.getUint32(c, !0), y = e.getUint8(c + 4), f = e.getUint8(c + 5), _ = e.getUint8(c + 6), b = _e(e, c, o), E = Ee(e, c, o);
100
+ const w = e.getUint32(c, !0), y = e.getUint8(c + 4), f = e.getUint8(c + 5), x = e.getUint8(c + 6), p = Ee(e, c, s), E = we(e, c, s);
101
101
  if (c += d, g + w > r)
102
102
  throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
103
103
  m.push({
104
104
  startVertex: g,
105
105
  vertexCount: w,
106
- color: [y, f, _],
107
- layerIndex: b,
106
+ color: [y, f, x],
107
+ layerIndex: p,
108
108
  ...E === void 0 ? {} : { lineweightPx: E }
109
109
  }), g += w;
110
110
  }
@@ -112,32 +112,32 @@ function He(t, e, n, r, o = "u8") {
112
112
  throw new l("E_SEGMENT_SUM", `Segment vertex_count sum ${g} does not match group count ${r}`);
113
113
  return {
114
114
  shuffled: a,
115
- plane: s,
115
+ plane: o,
116
116
  segments: m,
117
117
  offset: c
118
118
  };
119
119
  }
120
- function Ke(t, e, n, r) {
120
+ function je(t, e, n, r) {
121
121
  if (r === 0)
122
122
  return new Float32Array(0);
123
- const o = new Uint8Array(r * 4);
124
- for (let s = 0; s < r; s++)
125
- o[s * 4] = t[n + s], o[s * 4 + 1] = t[e + n + s], o[s * 4 + 2] = t[e * 2 + n + s], o[s * 4 + 3] = t[e * 3 + n + s];
126
- return new Float32Array(o.buffer);
123
+ const s = new Uint8Array(r * 4);
124
+ for (let o = 0; o < r; o++)
125
+ s[o * 4] = t[n + o], s[o * 4 + 1] = t[e + n + o], s[o * 4 + 2] = t[e * 2 + n + o], s[o * 4 + 3] = t[e * 3 + n + o];
126
+ return new Float32Array(s.buffer);
127
127
  }
128
- function je(t, e, n, r, o) {
129
- const s = Ke(
128
+ function We(t, e, n, r, s) {
129
+ const o = je(
130
130
  t.shuffled,
131
131
  t.plane,
132
132
  (e.startVertex + n) * 2,
133
133
  r * 2
134
134
  );
135
- let i = (o == null ? void 0 : o[0]) ?? 0, a = (o == null ? void 0 : o[1]) ?? 0;
135
+ let i = (s == null ? void 0 : s[0]) ?? 0, a = (s == null ? void 0 : s[1]) ?? 0;
136
136
  if (r > 0) {
137
- n === 0 ? (i = s[0], a = s[1]) : (i += s[0], a += s[1], s[0] = i, s[1] = a);
137
+ n === 0 ? (i = o[0], a = o[1]) : (i += o[0], a += o[1], o[0] = i, o[1] = a);
138
138
  for (let u = 1; u < r; u++) {
139
139
  const m = u * 2;
140
- i += s[m], a += s[m + 1], s[m] = i, s[m + 1] = a;
140
+ i += o[m], a += o[m + 1], o[m] = i, o[m + 1] = a;
141
141
  }
142
142
  }
143
143
  const c = r > 0 ? [{
@@ -148,24 +148,24 @@ function je(t, e, n, r, o) {
148
148
  ...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
149
149
  }] : [];
150
150
  return {
151
- chunk: { pos: s, count: r, segments: c },
152
- lastPoint: r > 0 ? [i, a] : o
151
+ chunk: { pos: o, count: r, segments: c },
152
+ lastPoint: r > 0 ? [i, a] : s
153
153
  };
154
154
  }
155
- function* We(t, e, n, r, o = "u8") {
156
- const s = He(t, e, n, r, o);
155
+ function* qe(t, e, n, r, s = "u8") {
156
+ const o = Ke(t, e, n, r, s);
157
157
  if (r === 0)
158
- return yield { pos: new Float32Array(0), count: 0, segments: [] }, s.offset;
159
- for (const i of s.segments) {
158
+ return yield { pos: new Float32Array(0), count: 0, segments: [] }, o.offset;
159
+ for (const i of o.segments) {
160
160
  let a = null;
161
161
  for (let c = 0; c < i.vertexCount; c += Ut) {
162
- const u = Math.min(Ut, i.vertexCount - c), m = je(s, i, c, u, a);
162
+ const u = Math.min(Ut, i.vertexCount - c), m = We(o, i, c, u, a);
163
163
  a = m.lastPoint, yield m.chunk;
164
164
  }
165
165
  }
166
- return s.offset;
166
+ return o.offset;
167
167
  }
168
- function pe() {
168
+ function be() {
169
169
  const t = globalThis.TextDecoder;
170
170
  if (!t)
171
171
  throw new l("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
@@ -185,7 +185,7 @@ function Ct(t) {
185
185
  function mt(t) {
186
186
  return Ct(t) ? ot(t) : null;
187
187
  }
188
- function be(t, e) {
188
+ function Ae(t, e) {
189
189
  const n = Ct(t) ? t : null, r = Ct(e) ? e : null;
190
190
  return n ? r ? {
191
191
  minX: Math.min(n.minX, r.minX),
@@ -194,35 +194,35 @@ function be(t, e) {
194
194
  maxY: Math.max(n.maxY, r.maxY)
195
195
  } : ot(n) : ot(r);
196
196
  }
197
- function qe(t, e, n, r = 0, o = 1) {
197
+ function Je(t, e, n, r = 0, s = 1) {
198
198
  if (e <= 0 || n <= 0) return null;
199
- let s = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, u = !1;
199
+ let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, u = !1;
200
200
  for (let m = 0; m < e; m += 1) {
201
- const g = m * n, d = t[g + r], h = t[g + o];
202
- !Number.isFinite(d) || !Number.isFinite(h) || (d < s && (s = d), h < i && (i = h), d > a && (a = d), h > c && (c = h), u = !0);
201
+ const g = m * n, d = t[g + r], h = t[g + s];
202
+ !Number.isFinite(d) || !Number.isFinite(h) || (d < o && (o = d), h < i && (i = h), d > a && (a = d), h > c && (c = h), u = !0);
203
203
  }
204
- return u ? { minX: s, minY: i, maxX: a, maxY: c } : null;
204
+ return u ? { minX: o, minY: i, maxX: a, maxY: c } : null;
205
205
  }
206
- function Ae(t, e) {
207
- const n = t.minX, r = t.minY, o = t.maxX, s = t.maxY, { matA: i, matB: a, matC: c, matD: u, tx: m, ty: g } = e;
208
- let d = i * n + c * r + m, h = a * n + u * r + g, w = d, y = h, f = d, _ = h;
209
- return d = i * n + c * s + m, h = a * n + u * s + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > _ && (_ = h), d = i * o + c * r + m, h = a * o + u * r + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > _ && (_ = h), d = i * o + c * s + m, h = a * o + u * s + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > _ && (_ = h), { minX: w, minY: y, maxX: f, maxY: _ };
206
+ function Ie(t, e) {
207
+ const n = t.minX, r = t.minY, s = t.maxX, o = t.maxY, { matA: i, matB: a, matC: c, matD: u, tx: m, ty: g } = e;
208
+ let d = i * n + c * r + m, h = a * n + u * r + g, w = d, y = h, f = d, x = h;
209
+ return d = i * n + c * o + m, h = a * n + u * o + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > x && (x = h), d = i * s + c * r + m, h = a * s + u * r + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > x && (x = h), d = i * s + c * o + m, h = a * s + u * o + g, d < w && (w = d), h < y && (y = h), d > f && (f = d), h > x && (x = h), { minX: w, minY: y, maxX: f, maxY: x };
210
210
  }
211
- function Je(t) {
211
+ function Ze(t) {
212
212
  return Math.hypot(t.maxX - t.minX, t.maxY - t.minY);
213
213
  }
214
- function Ze(t, e) {
215
- const n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2, o = (e.minX + e.maxX) / 2, s = (e.minY + e.maxY) / 2;
216
- return Math.hypot(n - o, r - s);
214
+ function Qe(t, e) {
215
+ const n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2, s = (e.minX + e.maxX) / 2, o = (e.minY + e.maxY) / 2;
216
+ return Math.hypot(n - s, r - o);
217
217
  }
218
- const Qe = {};
218
+ const tn = {};
219
219
  function qt(t) {
220
220
  return typeof t == "object" && t !== null;
221
221
  }
222
222
  function ut(t, e) {
223
223
  return Object.prototype.hasOwnProperty.call(t, e);
224
224
  }
225
- function H(t) {
225
+ function K(t) {
226
226
  if (t.length === 0) return "$";
227
227
  let e = "";
228
228
  for (const n of t) {
@@ -237,76 +237,76 @@ function H(t) {
237
237
  function Jt(t, e, n, r) {
238
238
  return new l("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${e} path=${n}: ${r}`);
239
239
  }
240
- function Pt(t, e, n) {
240
+ function St(t, e, n) {
241
241
  if (Object.is(t, e)) return null;
242
242
  if (Array.isArray(t)) {
243
243
  if (!Array.isArray(e))
244
- return { path: H(n), reason: `expected array but found ${typeof e}` };
244
+ return { path: K(n), reason: `expected array but found ${typeof e}` };
245
245
  if (t.length !== e.length)
246
- return { path: H([...n, "length"]), reason: `array length ${t.length} !== ${e.length}` };
246
+ return { path: K([...n, "length"]), reason: `array length ${t.length} !== ${e.length}` };
247
247
  for (let r = 0; r < t.length; r += 1) {
248
- const o = Pt(t[r], e[r], [...n, r]);
249
- if (o) return o;
248
+ const s = St(t[r], e[r], [...n, r]);
249
+ if (s) return s;
250
250
  }
251
251
  return null;
252
252
  }
253
253
  if (qt(t)) {
254
254
  if (!qt(e) || Array.isArray(e))
255
- return { path: H(n), reason: `expected object but found ${Array.isArray(e) ? "array" : typeof e}` };
256
- const r = Object.keys(t), o = Object.keys(e);
257
- if (r.length !== o.length) {
258
- const s = r.find((a) => !ut(e, a));
259
- if (s !== void 0)
255
+ return { path: K(n), reason: `expected object but found ${Array.isArray(e) ? "array" : typeof e}` };
256
+ const r = Object.keys(t), s = Object.keys(e);
257
+ if (r.length !== s.length) {
258
+ const o = r.find((a) => !ut(e, a));
259
+ if (o !== void 0)
260
260
  return {
261
- path: H([...n, s]),
261
+ path: K([...n, o]),
262
262
  reason: "missing key on actual"
263
263
  };
264
- const i = o.find((a) => !ut(t, a));
264
+ const i = s.find((a) => !ut(t, a));
265
265
  if (i !== void 0)
266
266
  return {
267
- path: H([...n, i]),
267
+ path: K([...n, i]),
268
268
  reason: "extra key on actual"
269
269
  };
270
270
  }
271
- for (const s of r) {
272
- if (!ut(e, s))
273
- return { path: H([...n, s]), reason: "missing key on actual" };
274
- const i = Pt(t[s], e[s], [...n, s]);
271
+ for (const o of r) {
272
+ if (!ut(e, o))
273
+ return { path: K([...n, o]), reason: "missing key on actual" };
274
+ const i = St(t[o], e[o], [...n, o]);
275
275
  if (i) return i;
276
276
  }
277
- for (const s of o)
278
- if (!ut(t, s))
279
- return { path: H([...n, s]), reason: "extra key on actual" };
277
+ for (const o of s)
278
+ if (!ut(t, o))
279
+ return { path: K([...n, o]), reason: "extra key on actual" };
280
280
  return null;
281
281
  }
282
- return { path: H(n), reason: `expected ${String(t)} but found ${String(e)}` };
282
+ return { path: K(n), reason: `expected ${String(t)} but found ${String(e)}` };
283
283
  }
284
- function tn(t, e) {
285
- return Pt(t, e, []);
284
+ function en(t, e) {
285
+ return St(t, e, []);
286
286
  }
287
287
  function Zt(t) {
288
288
  if (t === !0 || t === "1" || t === "true") return !0;
289
289
  if (t === !1 || t === "0" || t === "false") return !1;
290
290
  }
291
- function en() {
292
- var o, s;
291
+ function nn() {
292
+ var s, o;
293
293
  const t = globalThis.process, e = Zt(
294
- ((o = t == null ? void 0 : t.env) == null ? void 0 : o.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((s = t == null ? void 0 : t.env) == null ? void 0 : s.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
294
+ ((s = t == null ? void 0 : t.env) == null ? void 0 : s.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((o = t == null ? void 0 : t.env) == null ? void 0 : o.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
295
295
  );
296
296
  if (e !== void 0) return e;
297
- const n = Qe, r = Zt(n == null ? void 0 : n.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
297
+ const n = tn, r = Zt(n == null ? void 0 : n.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
298
298
  return r !== void 0 ? r : !1;
299
299
  }
300
- function nn(t, e, n) {
300
+ function rn(t, e, n) {
301
301
  if (e.length !== n.length)
302
302
  throw Jt(t, Math.min(e.length, n.length), "$length", `text count ${e.length} !== ${n.length}`);
303
303
  for (let r = 0; r < e.length; r += 1) {
304
- const o = tn(e[r], n[r]);
305
- if (o)
306
- throw Jt(t, r, o.path, o.reason);
304
+ const s = en(e[r], n[r]);
305
+ if (s)
306
+ throw Jt(t, r, s.path, s.reason);
307
307
  }
308
308
  }
309
- pe();
309
+ be();
310
310
  function Qt(t, e) {
311
311
  if (t > BigInt(Number.MAX_SAFE_INTEGER))
312
312
  throw new l("E_GROUP_RANGE", `${e} exceeds safe integer range`);
@@ -316,60 +316,60 @@ function te(t, e, n, r) {
316
316
  if (!Number.isInteger(t) || !Number.isInteger(e) || t < 0 || e < 0 || t + e > n)
317
317
  throw new l("E_GROUP_RANGE", `${r} exceeds payload length`);
318
318
  }
319
- function rn(t) {
319
+ function on(t) {
320
320
  if (t.byteLength < 4) return !1;
321
321
  const e = new Uint8Array(t, 0, 4);
322
322
  return e[0] === 68 && e[1] === 88 && e[2] === 66 && e[3] === 83;
323
323
  }
324
- function on(t) {
324
+ function sn(t) {
325
325
  if (t.byteLength < 20)
326
326
  throw new l("E_HEADER", "DXBS payload too small: missing container header");
327
- if (!rn(t))
327
+ if (!on(t))
328
328
  throw new l("E_HEADER", "DXBS payload missing magic");
329
- const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), o = e.getUint16(8, !0), s = e.getUint16(10, !0), i = e.getUint16(12, !0), a = e.getUint16(14, !0), c = e.getUint32(16, !0);
329
+ const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), s = e.getUint16(8, !0), o = e.getUint16(10, !0), i = e.getUint16(12, !0), a = e.getUint16(14, !0), c = e.getUint32(16, !0);
330
330
  if (n !== 3 || r < 3 || r > 6)
331
331
  throw new l("E_GROUP_RANGE", `Unsupported DXBS version: ${n}.${r}`);
332
- if (o !== 0)
333
- throw new l("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${o}`);
332
+ if (s !== 0)
333
+ throw new l("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${s}`);
334
334
  if (a !== 0)
335
335
  throw new l("E_GROUP_RANGE", `Invalid DXBS reserved field: ${a}`);
336
- if (s < 24)
337
- throw new l("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${s}`);
338
- if (c !== s * i)
336
+ if (o < 24)
337
+ throw new l("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${o}`);
338
+ if (c !== o * i)
339
339
  throw new l("E_GROUP_RANGE", "DXBS directory byte size mismatch");
340
340
  const u = 20;
341
341
  te(u, c, t.byteLength, "DXBS section directory");
342
342
  const m = /* @__PURE__ */ new Map();
343
343
  for (let g = 0; g < i; g += 1) {
344
- const d = u + g * s, h = e.getUint16(d, !0), w = e.getUint16(d + 2, !0), y = e.getUint32(d + 4, !0), f = Qt(e.getBigUint64(d + 8, !0), "DXBS section offset"), _ = Qt(e.getBigUint64(d + 16, !0), "DXBS section length");
344
+ const d = u + g * o, h = e.getUint16(d, !0), w = e.getUint16(d + 2, !0), y = e.getUint32(d + 4, !0), f = Qt(e.getBigUint64(d + 8, !0), "DXBS section offset"), x = Qt(e.getBigUint64(d + 16, !0), "DXBS section length");
345
345
  if (w !== 0)
346
346
  throw new l("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${h}: ${w}`);
347
347
  if (y !== 0)
348
348
  throw new l("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${h}: ${y}`);
349
- te(f, _, t.byteLength, `DXBS section ${h}`), m.set(h, { type: h, flags: w, offset: f, length: _ });
349
+ te(f, x, t.byteLength, `DXBS section ${h}`), m.set(h, { type: h, flags: w, offset: f, length: x });
350
350
  }
351
351
  return { versionMajor: n, versionMinor: r, sections: m };
352
352
  }
353
- function sn(t, e, n) {
353
+ function an(t, e, n) {
354
354
  const r = t.sections.get(e);
355
355
  if (!r)
356
356
  throw new l("E_GROUP_RANGE", `Missing DXBS section ${n}`);
357
357
  return r;
358
358
  }
359
- function an() {
359
+ function cn() {
360
360
  return {
361
361
  pos: new Float32Array(0),
362
362
  count: 0,
363
363
  segments: []
364
364
  };
365
365
  }
366
- function St(t) {
366
+ function Pt(t) {
367
367
  if (t.segments && t.segments.length > 0)
368
- return un(t.segments, t.count), t.segments;
368
+ return ln(t.segments, t.count), t.segments;
369
369
  if (t.count <= 0) return [];
370
370
  if (!t.col || !t.lay)
371
371
  throw new l("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
372
- return cn(t.col, t.lay, t.count);
372
+ return un(t.col, t.lay, t.count);
373
373
  }
374
374
  function ee(t) {
375
375
  const e = [];
@@ -385,21 +385,21 @@ function ee(t) {
385
385
  e.push({
386
386
  startVertex: n.startVertex,
387
387
  vertexCount: n.vertexCount,
388
- color: ln(n),
388
+ color: fn(n),
389
389
  layerIndex: n.layerIndex,
390
390
  ...n.lineweightPx === void 0 ? {} : { lineweightPx: n.lineweightPx }
391
391
  });
392
392
  }
393
393
  return e;
394
394
  }
395
- function cn(t, e, n) {
395
+ function un(t, e, n) {
396
396
  if (t.length < n * 3 || e.length < n)
397
397
  throw new l("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
398
398
  const r = [];
399
- let o = 0;
400
- for (; o < n; ) {
401
- const s = o * 3, i = t[s] ?? 0, a = t[s + 1] ?? 0, c = t[s + 2] ?? 0, u = e[o] ?? 0;
402
- let m = o + 1;
399
+ let s = 0;
400
+ for (; s < n; ) {
401
+ const o = s * 3, i = t[o] ?? 0, a = t[o + 1] ?? 0, c = t[o + 2] ?? 0, u = e[s] ?? 0;
402
+ let m = s + 1;
403
403
  for (; m < n; ) {
404
404
  const g = m * 3;
405
405
  if (e[m] !== u || t[g] !== i || t[g + 1] !== a || t[g + 2] !== c)
@@ -407,15 +407,15 @@ function cn(t, e, n) {
407
407
  m += 1;
408
408
  }
409
409
  r.push({
410
- startVertex: o,
411
- vertexCount: m - o,
410
+ startVertex: s,
411
+ vertexCount: m - s,
412
412
  color: [i, a, c],
413
413
  layerIndex: u
414
- }), o = m;
414
+ }), s = m;
415
415
  }
416
416
  return r;
417
417
  }
418
- function un(t, e) {
418
+ function ln(t, e) {
419
419
  let n = 0;
420
420
  for (const r of t) {
421
421
  if (r.vertexCount < 0 || r.startVertex !== n)
@@ -425,10 +425,10 @@ function un(t, e) {
425
425
  if (n !== e)
426
426
  throw new l("E_SEGMENT_SUM", `Geometry segment vertex sum ${n} does not match count ${e}`);
427
427
  }
428
- function ln(t) {
428
+ function fn(t) {
429
429
  return [t.color[0], t.color[1], t.color[2]];
430
430
  }
431
- const fn = 8e6, Ot = pe(), dn = ["left", "center", "right"], mn = ["top", "middle", "bottom", "alphabetic"];
431
+ const dn = 8e6, Ot = be(), mn = ["left", "center", "right"], hn = ["top", "middle", "bottom", "alphabetic"];
432
432
  function ne(t, e, n) {
433
433
  for (const r of t)
434
434
  n(r);
@@ -438,13 +438,13 @@ function ne(t, e, n) {
438
438
  function rt(t) {
439
439
  return typeof t == "object" && t !== null;
440
440
  }
441
- function hn(t) {
441
+ function gn(t) {
442
442
  return Array.isArray(t) ? "array" : t === null ? "null" : typeof t;
443
443
  }
444
- function gn(t) {
444
+ function yn(t) {
445
445
  return !(!rt(t) || Array.isArray(t) || typeof t.t != "string" || typeof t.x != "number" || typeof t.y != "number" || typeof t.h != "number" || typeof t.r != "number" || !Array.isArray(t.c) || t.c.length !== 3 || !t.c.every((e) => typeof e == "number") || typeof t.li != "number" || t.ha !== "left" && t.ha !== "center" && t.ha !== "right" || t.va !== "top" && t.va !== "middle" && t.va !== "bottom" && t.va !== "alphabetic" || typeof t.lh != "number" || t.w !== void 0 && typeof t.w != "number" || t.wf !== void 0 && typeof t.wf != "number" || t.iv !== void 0 && typeof t.iv != "number" || t.io !== void 0 && typeof t.io != "number" || t.mx !== void 0 && t.mx !== !0 || t.my !== void 0 && t.my !== !0);
446
446
  }
447
- function yn(t) {
447
+ function _n(t) {
448
448
  return t.map((e, n) => ({
449
449
  index: n,
450
450
  name: e.name,
@@ -453,26 +453,26 @@ function yn(t) {
453
453
  visible: e.visible ?? !0
454
454
  }));
455
455
  }
456
- function Ie(t) {
457
- const e = t.texts, n = Array.isArray(e) ? e : [], r = n.filter(gn), o = en();
458
- if (o && e !== void 0 && !Array.isArray(e))
456
+ function Re(t) {
457
+ const e = t.texts, n = Array.isArray(e) ? e : [], r = n.filter(yn), s = nn();
458
+ if (s && e !== void 0 && !Array.isArray(e))
459
459
  throw new l(
460
460
  "E_TEXT_ROUNDTRIP",
461
- `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${hn(e)}`
461
+ `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${gn(e)}`
462
462
  );
463
- return o && nn("Boundary-2:header->stream", n, r), {
463
+ return s && rn("Boundary-2:header->stream", n, r), {
464
464
  bounds: [...t.bounds],
465
465
  entityCount: Number(t.entity_count || 0),
466
466
  lineCount: Number(t.line_count || 0),
467
467
  fillCount: Number(t.fill_count || 0),
468
468
  dotCount: Number(t.dot_count || 0),
469
469
  textCount: r.length,
470
- layers: yn(t.layers ?? []),
470
+ layers: _n(t.layers ?? []),
471
471
  texts: r
472
472
  };
473
473
  }
474
474
  function xn(t) {
475
- const e = t == null ? void 0 : t.maxExpandedInstanceVertices, n = typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : fn;
475
+ const e = t == null ? void 0 : t.maxExpandedInstanceVertices, n = typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : dn;
476
476
  return {
477
477
  hiddenInstanceIds: t != null && t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(),
478
478
  keepTextsForHiddenInstances: (t == null ? void 0 : t.keepTextsForHiddenInstances) === !0,
@@ -486,13 +486,13 @@ function xn(t) {
486
486
  deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0
487
487
  };
488
488
  }
489
- function _n(t) {
489
+ function En(t) {
490
490
  return t.loadBlocks && !t.suppressExpandedInsertGeometry;
491
491
  }
492
- function Re(t, e) {
493
- return _n(e) && !e.hiddenInstanceIds.has(t);
492
+ function Ve(t, e) {
493
+ return En(e) && !e.hiddenInstanceIds.has(t);
494
494
  }
495
- function En(t, e, n) {
495
+ function wn(t, e, n) {
496
496
  if (n <= 0)
497
497
  return;
498
498
  const r = t.expandedInstanceVertices + n;
@@ -503,30 +503,30 @@ function En(t, e, n) {
503
503
  );
504
504
  t.expandedInstanceVertices = r;
505
505
  }
506
- function wn(t, e, n) {
506
+ function pn(t, e, n) {
507
507
  return n.loadBlocks ? n.hiddenInstanceIds.size === 0 || n.keepTextsForHiddenInstances ? t : t.filter((r) => {
508
508
  if (!Number.isInteger(r.iv) || !Number.isInteger(r.io))
509
509
  return !0;
510
- const o = e.get(`${r.iv}:${r.io}`);
511
- return o === void 0 || !n.hiddenInstanceIds.has(o);
510
+ const s = e.get(`${r.iv}:${r.io}`);
511
+ return s === void 0 || !n.hiddenInstanceIds.has(s);
512
512
  }) : t.filter((r) => !Number.isInteger(r.iv) || !Number.isInteger(r.io));
513
513
  }
514
- function pn(t, e) {
514
+ function bn(t, e) {
515
515
  const n = /* @__PURE__ */ new Map();
516
- return t.forEach((r, o) => {
516
+ return t.forEach((r, s) => {
517
517
  if (!Number.isInteger(r.iv) || !Number.isInteger(r.io))
518
518
  return;
519
- const s = e.get(`${r.iv}:${r.io}`);
520
- if (s === void 0)
519
+ const o = e.get(`${r.iv}:${r.io}`);
520
+ if (o === void 0)
521
521
  return;
522
- const i = n.get(s);
523
- i ? i.push(o) : n.set(s, [o]);
522
+ const i = n.get(o);
523
+ i ? i.push(s) : n.set(o, [s]);
524
524
  }), n;
525
525
  }
526
- function bn(t, e, n, r, o, s, i) {
526
+ function An(t, e, n, r, s, o, i) {
527
527
  const a = e.map((c, u) => ({
528
528
  id: c.id,
529
- blockName: Ve(c, u),
529
+ blockName: Ne(c, u),
530
530
  line: n[u].line,
531
531
  fill: n[u].fill,
532
532
  dot: n[u].dot,
@@ -535,42 +535,42 @@ function bn(t, e, n, r, o, s, i) {
535
535
  return {
536
536
  layer0Index: t,
537
537
  variants: a,
538
- instances: o,
539
- textIndexesByInstanceId: pn(s, i),
538
+ instances: s,
539
+ textIndexesByInstanceId: bn(o, i),
540
540
  ownerInstanceIdByVariantOrdinal: i
541
541
  };
542
542
  }
543
- function An(t) {
543
+ function In(t) {
544
544
  if (t.byteLength < 4)
545
545
  throw new l("E_HEADER", "Payload too small: missing header length");
546
- const e = new DataView(t), n = e.getUint32(0, !0), r = 4, o = r + n;
547
- if (o > t.byteLength)
546
+ const e = new DataView(t), n = e.getUint32(0, !0), r = 4, s = r + n;
547
+ if (s > t.byteLength)
548
548
  throw new l("E_HEADER", "Header length exceeds payload length");
549
- let s;
549
+ let o;
550
550
  try {
551
- s = JSON.parse(Ot.decode(new Uint8Array(t, r, n)));
551
+ o = JSON.parse(Ot.decode(new Uint8Array(t, r, n)));
552
552
  } catch (i) {
553
553
  throw new l("E_HEADER_JSON", `Invalid JSON header: ${i.message}`);
554
554
  }
555
555
  return {
556
- meta: s,
557
- header: Ie(s),
558
- dataOffset: o,
556
+ meta: o,
557
+ header: Re(o),
558
+ dataOffset: s,
559
559
  view: e
560
560
  };
561
561
  }
562
- function Ve(t, e) {
563
- var s, i, a;
564
- const n = (s = t.name) == null ? void 0 : s.trim();
562
+ function Ne(t, e) {
563
+ var o, i, a;
564
+ const n = (o = t.name) == null ? void 0 : o.trim();
565
565
  if (n)
566
566
  return n;
567
567
  const r = (i = t.block_name) == null ? void 0 : i.trim();
568
568
  if (r)
569
569
  return r;
570
- const o = (a = t.blockName) == null ? void 0 : a.trim();
571
- return o || `block_${e}`;
570
+ const s = (a = t.blockName) == null ? void 0 : a.trim();
571
+ return s || `block_${e}`;
572
572
  }
573
- function In(t) {
573
+ function Rn(t) {
574
574
  const e = Number(t.version ?? 1), n = String(t.encoding ?? "").toLowerCase();
575
575
  if (e === 2) {
576
576
  const r = n ? ` ${n}` : "";
@@ -580,11 +580,11 @@ function In(t) {
580
580
  );
581
581
  }
582
582
  }
583
- function Rn(t) {
584
- const e = An(t);
585
- return In(e.meta), e;
586
- }
587
583
  function Vn(t) {
584
+ const e = In(t);
585
+ return Rn(e.meta), e;
586
+ }
587
+ function Nn(t) {
588
588
  if (t.byteLength < 4)
589
589
  return !1;
590
590
  const e = new Uint8Array(t, 0, 4);
@@ -599,23 +599,23 @@ function st(t, e, n, r) {
599
599
  if (!Number.isInteger(t) || !Number.isInteger(e) || t < 0 || e < 0 || t + e > n)
600
600
  throw new l("E_GROUP_RANGE", `${r} exceeds payload length`);
601
601
  }
602
- function Nn(t) {
602
+ function Gn(t) {
603
603
  if (t.byteLength < 20)
604
604
  throw new l("E_HEADER", "V3 payload too small: missing container header");
605
- const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), o = e.getUint32(8, !0), s = e.getUint16(12, !0), i = e.getUint16(14, !0), a = e.getUint32(16, !0);
605
+ const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), s = e.getUint32(8, !0), o = e.getUint16(12, !0), i = e.getUint16(14, !0), a = e.getUint32(16, !0);
606
606
  if (n !== 3 || r > 6)
607
607
  throw new l("E_GROUP_RANGE", `Unsupported V3 version: ${n}.${r}`);
608
- if (o !== 0)
609
- throw new l("E_GROUP_RANGE", `Unsupported V3 file flags: ${o}`);
610
- if (s < 24)
611
- throw new l("E_GROUP_RANGE", `Invalid V3 directory entry size: ${s}`);
612
- if (a !== s * i)
608
+ if (s !== 0)
609
+ throw new l("E_GROUP_RANGE", `Unsupported V3 file flags: ${s}`);
610
+ if (o < 24)
611
+ throw new l("E_GROUP_RANGE", `Invalid V3 directory entry size: ${o}`);
612
+ if (a !== o * i)
613
613
  throw new l("E_GROUP_RANGE", "V3 directory byte size mismatch");
614
614
  const c = 20;
615
615
  st(c, a, t.byteLength, "V3 section directory");
616
616
  const u = /* @__PURE__ */ new Map();
617
617
  for (let m = 0; m < i; m += 1) {
618
- const g = c + m * s, d = e.getUint16(g, !0), h = e.getUint16(g + 2, !0), w = e.getUint32(g + 4, !0), y = re(e.getBigUint64(g + 8, !0), "V3 section offset"), f = re(e.getBigUint64(g + 16, !0), "V3 section length");
618
+ const g = c + m * o, d = e.getUint16(g, !0), h = e.getUint16(g + 2, !0), w = e.getUint32(g + 4, !0), y = re(e.getBigUint64(g + 8, !0), "V3 section offset"), f = re(e.getBigUint64(g + 16, !0), "V3 section length");
619
619
  if (h !== 0)
620
620
  throw new l("E_GROUP_RANGE", `Unsupported V3 section flags for type ${d}: ${h}`);
621
621
  if (w !== 0)
@@ -624,39 +624,39 @@ function Nn(t) {
624
624
  }
625
625
  return { versionMinor: r, sections: u };
626
626
  }
627
- function Z(t, e, n) {
627
+ function Q(t, e, n) {
628
628
  const r = t.get(e);
629
629
  if (!r)
630
630
  throw new l("E_GROUP_RANGE", `Missing V3 section ${n}`);
631
631
  return r;
632
632
  }
633
- function xt(t, e) {
633
+ function _t(t, e) {
634
634
  return t.get(e) ?? { type: e, flags: 0, offset: 0, length: 0 };
635
635
  }
636
- function Gn(t, e, n) {
636
+ function Un(t, e, n) {
637
637
  try {
638
638
  return JSON.parse(Ot.decode(new Uint8Array(t, e.offset, e.length)));
639
639
  } catch (r) {
640
640
  throw new l("E_HEADER_JSON", `Invalid V3 ${n} JSON: ${r.message}`);
641
641
  }
642
642
  }
643
- function Un(t) {
643
+ function Cn(t) {
644
644
  const e = String(t.encoding ?? "").toLowerCase();
645
645
  return e === "nested_instanced_external" || e === "nested_instanced_external_annotations";
646
646
  }
647
- function Cn(t) {
647
+ function Sn(t) {
648
648
  return String(t.encoding ?? "").toLowerCase() === "nested_instanced_external_annotations";
649
649
  }
650
650
  function Pn(t, e, n) {
651
- const r = t.features, o = r && typeof r == "object" && !Array.isArray(r) ? { ...r } : {};
652
- return e && (o.has_external_variant_geometry = !0), n && (o.has_external_annotations = !0), Object.keys(o).length ? o : void 0;
651
+ const r = t.features, s = r && typeof r == "object" && !Array.isArray(r) ? { ...r } : {};
652
+ return e && (s.has_external_variant_geometry = !0), n && (s.has_external_annotations = !0), Object.keys(s).length ? s : void 0;
653
653
  }
654
- function k(t, e) {
654
+ function L(t, e) {
655
655
  if (!Number.isInteger(t) || Number(t) < 0)
656
656
  throw new l("E_HEADER", `${e} must be a non-negative integer`);
657
657
  return Number(t);
658
658
  }
659
- function Ne(t, e) {
659
+ function Ge(t, e) {
660
660
  if (typeof t != "string" || !t.trim())
661
661
  throw new l("E_HEADER", `${e} must be a non-empty string`);
662
662
  return t;
@@ -672,17 +672,17 @@ function Tt(t, e) {
672
672
  if (!rt(t) || Array.isArray(t))
673
673
  throw new l("E_HEADER", `${e} must be an object`);
674
674
  return {
675
- line_count: k(t.line_count, `${e}.line_count`),
676
- fill_count: k(t.fill_count, `${e}.fill_count`),
677
- dot_count: k(t.dot_count, `${e}.dot_count`),
675
+ line_count: L(t.line_count, `${e}.line_count`),
676
+ fill_count: L(t.fill_count, `${e}.fill_count`),
677
+ dot_count: L(t.dot_count, `${e}.dot_count`),
678
678
  bbox: oe(t.bbox, `${e}.bbox`),
679
679
  own_bbox: oe(t.own_bbox, `${e}.own_bbox`)
680
680
  };
681
681
  }
682
- function Sn(t) {
682
+ function Tn(t) {
683
683
  return t ? { minX: t[0], minY: t[1], maxX: t[2], maxY: t[3] } : null;
684
684
  }
685
- function Tn(t, e) {
685
+ function Bn(t, e) {
686
686
  const n = t.external_variants;
687
687
  if (!Array.isArray(n))
688
688
  throw new l("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
@@ -691,40 +691,40 @@ function Tn(t, e) {
691
691
  "E_GROUP_RANGE",
692
692
  `V3 external variant manifest count mismatch: manifest=${n.length}, table=${e}`
693
693
  );
694
- return n.map((r, o) => {
694
+ return n.map((r, s) => {
695
695
  if (!rt(r) || Array.isArray(r))
696
- throw new l("E_HEADER", `V3 external_variants[${o}] must be an object`);
697
- const s = k(r.id, `V3 external_variants[${o}].id`);
698
- if (s !== o)
699
- throw new l("E_GROUP_RANGE", `V3 external_variants[${o}].id must equal ${o}, found ${s}`);
700
- const i = Ne(r.href, `V3 external_variants[${o}].href`), a = k(r.raw_size, `V3 external_variants[${o}].raw_size`);
696
+ throw new l("E_HEADER", `V3 external_variants[${s}] must be an object`);
697
+ const o = L(r.id, `V3 external_variants[${s}].id`);
698
+ if (o !== s)
699
+ throw new l("E_GROUP_RANGE", `V3 external_variants[${s}].id must equal ${s}, found ${o}`);
700
+ const i = Ge(r.href, `V3 external_variants[${s}].href`), a = L(r.raw_size, `V3 external_variants[${s}].raw_size`);
701
701
  if ("normal" in r || "annotation" in r) {
702
- const c = Tt(r.annotation, `V3 external_variants[${o}].annotation`);
702
+ const c = Tt(r.annotation, `V3 external_variants[${s}].annotation`);
703
703
  return {
704
- id: s,
704
+ id: o,
705
705
  href: i,
706
706
  raw_size: a,
707
- normal: Tt(r.normal, `V3 external_variants[${o}].normal`),
707
+ normal: Tt(r.normal, `V3 external_variants[${s}].normal`),
708
708
  annotation: {
709
709
  ...c,
710
- text_count: k(
710
+ text_count: L(
711
711
  rt(r.annotation) && !Array.isArray(r.annotation) ? r.annotation.text_count : void 0,
712
- `V3 external_variants[${o}].annotation.text_count`
712
+ `V3 external_variants[${s}].annotation.text_count`
713
713
  )
714
714
  }
715
715
  };
716
716
  }
717
717
  return {
718
- id: s,
718
+ id: o,
719
719
  href: i,
720
720
  raw_size: a,
721
- line_count: k(r.line_count, `V3 external_variants[${o}].line_count`),
722
- fill_count: k(r.fill_count, `V3 external_variants[${o}].fill_count`),
723
- dot_count: k(r.dot_count, `V3 external_variants[${o}].dot_count`)
721
+ line_count: L(r.line_count, `V3 external_variants[${s}].line_count`),
722
+ fill_count: L(r.fill_count, `V3 external_variants[${s}].fill_count`),
723
+ dot_count: L(r.dot_count, `V3 external_variants[${s}].dot_count`)
724
724
  };
725
725
  });
726
726
  }
727
- function Bn(t) {
727
+ function $n(t) {
728
728
  const e = t.external_annotations;
729
729
  if (e == null) return null;
730
730
  if (!rt(e) || Array.isArray(e))
@@ -736,50 +736,50 @@ function Bn(t) {
736
736
  const r = Tt(n, "V3 external_annotations.scene");
737
737
  return {
738
738
  scene: {
739
- href: Ne(n.href, "V3 external_annotations.scene.href"),
740
- raw_size: k(n.raw_size, "V3 external_annotations.scene.raw_size"),
739
+ href: Ge(n.href, "V3 external_annotations.scene.href"),
740
+ raw_size: L(n.raw_size, "V3 external_annotations.scene.raw_size"),
741
741
  ...r,
742
- text_count: k(n.text_count, "V3 external_annotations.scene.text_count")
742
+ text_count: L(n.text_count, "V3 external_annotations.scene.text_count")
743
743
  }
744
744
  };
745
745
  }
746
746
  function ht(t, e, n, r) {
747
747
  return st(e, n, t.byteLength, r), Ot.decode(t.subarray(e, e + n));
748
748
  }
749
- function $n(t, e, n) {
749
+ function On(t, e, n) {
750
750
  if (e.length % 20 !== 0)
751
751
  throw new l("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
752
- const r = new DataView(t), o = [];
753
- for (let s = e.offset; s < e.offset + e.length; s += 20) {
754
- const i = r.getUint32(s, !0), a = r.getUint32(s + 4, !0);
755
- o.push({
752
+ const r = new DataView(t), s = [];
753
+ for (let o = e.offset; o < e.offset + e.length; o += 20) {
754
+ const i = r.getUint32(o, !0), a = r.getUint32(o + 4, !0);
755
+ s.push({
756
756
  name: ht(n, i, a, "V3 layer name"),
757
- color: [r.getUint8(s + 8), r.getUint8(s + 9), r.getUint8(s + 10)],
758
- visible: r.getUint8(s + 11) !== 0,
759
- lw_px: r.getFloat32(s + 12, !0)
757
+ color: [r.getUint8(o + 8), r.getUint8(o + 9), r.getUint8(o + 10)],
758
+ visible: r.getUint8(o + 11) !== 0,
759
+ lw_px: r.getFloat32(o + 12, !0)
760
760
  });
761
761
  }
762
- return o;
762
+ return s;
763
763
  }
764
- function ft(t, e, n, r, o, s) {
764
+ function ft(t, e, n, r, s, o) {
765
765
  if (n + 4 > r)
766
- throw new l("E_GROUP_RANGE", `Missing ${o} vertex_count`);
767
- const i = e.getUint32(n, !0), a = n + 4, c = we(t, e, a, i, r, s);
766
+ throw new l("E_GROUP_RANGE", `Missing ${s} vertex_count`);
767
+ const i = e.getUint32(n, !0), a = n + 4, c = pe(t, e, a, i, r, o);
768
768
  if (c.offset > r)
769
- throw new l("E_GROUP_RANGE", `${o} exceeds section bounds`);
769
+ throw new l("E_GROUP_RANGE", `${s} exceeds section bounds`);
770
770
  return {
771
771
  chunk: c.chunk,
772
772
  offset: c.offset
773
773
  };
774
774
  }
775
- function Ge(t, e, n, r, o, s) {
776
- const i = ft(t, e, n, r, o, s), a = n + 4;
775
+ function Ue(t, e, n, r, s, o) {
776
+ const i = ft(t, e, n, r, s, o), a = n + 4;
777
777
  return {
778
778
  chunk: i.chunk,
779
779
  snapshot: {
780
780
  count: i.chunk.count,
781
781
  raw: new Uint8Array(t, a, i.offset - a).slice(),
782
- groupLayerEncoding: s
782
+ groupLayerEncoding: o
783
783
  },
784
784
  offset: i.offset
785
785
  };
@@ -790,7 +790,7 @@ function dt(t = "u8") {
790
790
  snapshot: { count: 0, raw: new Uint8Array(0), groupLayerEncoding: t }
791
791
  };
792
792
  }
793
- function On(t = "u8") {
793
+ function Mn(t = "u8") {
794
794
  return {
795
795
  line: dt(t),
796
796
  fill: dt(t),
@@ -801,16 +801,16 @@ function vn(t, e, n) {
801
801
  var r;
802
802
  return !!(e && n && t.deferExternalVariantGeometry && !((r = t.externalVariantBuffers) != null && r.has(e.id)));
803
803
  }
804
- function _t(t, e, n, r, o, s, i) {
805
- if (o === 0)
804
+ function xt(t, e, n, r, s, o, i) {
805
+ if (s === 0)
806
806
  return dt(i);
807
- st(r, o, n.length, s);
808
- const a = n.offset + r, c = a + o, u = Ge(t, e, a, c, s, i);
807
+ st(r, s, n.length, o);
808
+ const a = n.offset + r, c = a + s, u = Ue(t, e, a, c, o, i);
809
809
  if (u.offset !== c)
810
- throw new l("E_GROUP_RANGE", `${s} has trailing bytes`);
810
+ throw new l("E_GROUP_RANGE", `${o} has trailing bytes`);
811
811
  return { chunk: u.chunk, snapshot: u.snapshot };
812
812
  }
813
- function Ue(t, e, n) {
813
+ function Ce(t, e, n) {
814
814
  if ([
815
815
  t.getUint32(e + 8, !0),
816
816
  t.getUint32(e + 12, !0),
@@ -818,30 +818,30 @@ function Ue(t, e, n) {
818
818
  t.getUint32(e + 20, !0),
819
819
  t.getUint32(e + 24, !0),
820
820
  t.getUint32(e + 28, !0)
821
- ].some((o) => o !== 0))
821
+ ].some((s) => s !== 0))
822
822
  throw new l("E_GROUP_RANGE", `V3 external variant ${n} must use zero inline geometry offsets`);
823
823
  }
824
- function nt(t, e, n, r, o, s) {
825
- const i = Ge(t, e, n, t.byteLength, o, s);
824
+ function nt(t, e, n, r, s, o) {
825
+ const i = Ue(t, e, n, t.byteLength, s, o);
826
826
  if (i.chunk.count !== r)
827
827
  throw new l(
828
828
  "E_GROUP_RANGE",
829
- `${o} vertex_count mismatch: manifest=${r}, sidecar=${i.chunk.count}`
829
+ `${s} vertex_count mismatch: manifest=${r}, sidecar=${i.chunk.count}`
830
830
  );
831
831
  return i;
832
832
  }
833
- function vt(t) {
833
+ function Mt(t) {
834
834
  return "normal" in t ? t.normal : t;
835
835
  }
836
- function Mn(t, e, n) {
837
- const r = vt(t), o = new DataView(e);
838
- let s = 0;
839
- const i = nt(e, o, s, r.line_count, `V3 external variant ${t.id} line blob`, n);
840
- s = i.offset;
841
- const a = nt(e, o, s, r.fill_count, `V3 external variant ${t.id} fill blob`, n);
842
- s = a.offset;
843
- const c = nt(e, o, s, r.dot_count, `V3 external variant ${t.id} dot blob`, n);
844
- if (s = c.offset, s !== e.byteLength)
836
+ function Dn(t, e, n) {
837
+ const r = Mt(t), s = new DataView(e);
838
+ let o = 0;
839
+ const i = nt(e, s, o, r.line_count, `V3 external variant ${t.id} line blob`, n);
840
+ o = i.offset;
841
+ const a = nt(e, s, o, r.fill_count, `V3 external variant ${t.id} fill blob`, n);
842
+ o = a.offset;
843
+ const c = nt(e, s, o, r.dot_count, `V3 external variant ${t.id} dot blob`, n);
844
+ if (o = c.offset, o !== e.byteLength)
845
845
  throw new l("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
846
846
  return {
847
847
  line: { chunk: i.chunk, snapshot: i.snapshot },
@@ -849,15 +849,15 @@ function Mn(t, e, n) {
849
849
  dot: { chunk: c.chunk, snapshot: c.snapshot }
850
850
  };
851
851
  }
852
- function Dn(t, e) {
853
- const n = on(e), r = sn(n, 257, "BLOCK_NORMAL_GEOMETRY"), o = new DataView(e);
854
- let s = r.offset;
855
- const i = r.offset + r.length, a = ye(n.versionMinor), c = nt(e, o, s, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, a);
856
- s = c.offset;
857
- const u = nt(e, o, s, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, a);
858
- s = u.offset;
859
- const m = nt(e, o, s, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, a);
860
- if (s = m.offset, s !== i)
852
+ function kn(t, e) {
853
+ const n = sn(e), r = an(n, 257, "BLOCK_NORMAL_GEOMETRY"), s = new DataView(e);
854
+ let o = r.offset;
855
+ const i = r.offset + r.length, a = _e(n.versionMinor), c = nt(e, s, o, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, a);
856
+ o = c.offset;
857
+ const u = nt(e, s, o, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, a);
858
+ o = u.offset;
859
+ const m = nt(e, s, o, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, a);
860
+ if (o = m.offset, o !== i)
861
861
  throw new l("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
862
862
  return {
863
863
  line: { chunk: c.chunk, snapshot: c.snapshot },
@@ -865,36 +865,36 @@ function Dn(t, e) {
865
865
  dot: { chunk: m.chunk, snapshot: m.snapshot }
866
866
  };
867
867
  }
868
- function kn(t, e, n = "u8") {
868
+ function Ln(t, e, n = "u8") {
869
869
  if (e.byteLength !== t.raw_size)
870
870
  throw new l(
871
871
  "E_GROUP_RANGE",
872
872
  `V3 external variant ${t.id} raw_size mismatch: manifest=${t.raw_size}, sidecar=${e.byteLength}`
873
873
  );
874
- return "normal" in t ? Dn(t, e) : Mn(t, e, n);
874
+ return "normal" in t ? kn(t, e) : Dn(t, e, n);
875
875
  }
876
- function Ln(t, e, n) {
876
+ function Fn(t, e, n) {
877
877
  const r = e == null ? void 0 : e.get(t.id);
878
878
  if (!r)
879
879
  throw new l("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
880
- return kn(t, r, n);
880
+ return Ln(t, r, n);
881
881
  }
882
- function Et(t, e, n, r, o) {
882
+ function Et(t, e, n, r, s) {
883
883
  if (r === 0)
884
884
  return 0;
885
- if (st(n, r, e.length, o), r < 4)
886
- throw new l("E_GROUP_RANGE", `Missing ${o} vertex_count`);
885
+ if (st(n, r, e.length, s), r < 4)
886
+ throw new l("E_GROUP_RANGE", `Missing ${s} vertex_count`);
887
887
  return t.getUint32(e.offset + n, !0);
888
888
  }
889
- function Fn(t, e, n, r) {
890
- const o = n.offset + n.length;
891
- let s = n.offset;
892
- const i = ft(t, e, s, o, "V3 BASE_GEOMETRY line", r);
893
- s = i.offset;
894
- const a = ft(t, e, s, o, "V3 BASE_GEOMETRY fill", r);
895
- s = a.offset;
896
- const c = ft(t, e, s, o, "V3 BASE_GEOMETRY dot", r);
897
- if (s = c.offset, s !== o)
889
+ function Xn(t, e, n, r) {
890
+ const s = n.offset + n.length;
891
+ let o = n.offset;
892
+ const i = ft(t, e, o, s, "V3 BASE_GEOMETRY line", r);
893
+ o = i.offset;
894
+ const a = ft(t, e, o, s, "V3 BASE_GEOMETRY fill", r);
895
+ o = a.offset;
896
+ const c = ft(t, e, o, s, "V3 BASE_GEOMETRY dot", r);
897
+ if (o = c.offset, o !== s)
898
898
  throw new l("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
899
899
  return {
900
900
  line: i.chunk,
@@ -903,21 +903,21 @@ function Fn(t, e, n, r) {
903
903
  };
904
904
  }
905
905
  function wt(t) {
906
- return qe(t.pos, t.count, 2);
906
+ return Je(t.pos, t.count, 2);
907
907
  }
908
- function Xn(t, e, n) {
908
+ function Yn(t, e, n) {
909
909
  return Bt(Bt(wt(t), wt(e)), wt(n));
910
910
  }
911
- function Ce(t) {
912
- return "normal" in t ? Sn(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
911
+ function Se(t) {
912
+ return "normal" in t ? Tn(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
913
913
  }
914
- function Yn(t, e, n, r, o, s, i, a) {
914
+ function zn(t, e, n, r, s, o, i, a) {
915
915
  if (n.length % 60 !== 0)
916
916
  throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
917
917
  const c = [], u = /* @__PURE__ */ new Map(), m = [], g = n.length / 60;
918
918
  for (let d = 0; d < g; d += 1) {
919
- const h = n.offset + d * 60, w = e.getUint32(h, !0), y = e.getUint32(h + 4, !0), f = (s == null ? void 0 : s[d]) ?? null, _ = !f || !a.requiredExternalVariantIds || a.requiredExternalVariantIds.has(d), b = vn(a, f, _), E = f ? (Ue(e, h, d), !_ || b ? On(i) : Ln(f, a.externalVariantBuffers, i)) : {
920
- line: _t(
919
+ const h = n.offset + d * 60, w = e.getUint32(h, !0), y = e.getUint32(h + 4, !0), f = (o == null ? void 0 : o[d]) ?? null, x = !f || !a.requiredExternalVariantIds || a.requiredExternalVariantIds.has(d), p = vn(a, f, x), E = f ? (Ce(e, h, d), !x || p ? Mn(i) : Fn(f, a.externalVariantBuffers, i)) : {
920
+ line: xt(
921
921
  t,
922
922
  e,
923
923
  r,
@@ -926,7 +926,7 @@ function Yn(t, e, n, r, o, s, i, a) {
926
926
  `V3 variant ${d} line blob`,
927
927
  i
928
928
  ),
929
- fill: _t(
929
+ fill: xt(
930
930
  t,
931
931
  e,
932
932
  r,
@@ -935,7 +935,7 @@ function Yn(t, e, n, r, o, s, i, a) {
935
935
  `V3 variant ${d} fill blob`,
936
936
  i
937
937
  ),
938
- dot: _t(
938
+ dot: xt(
939
939
  t,
940
940
  e,
941
941
  r,
@@ -944,13 +944,13 @@ function Yn(t, e, n, r, o, s, i, a) {
944
944
  `V3 variant ${d} dot blob`,
945
945
  i
946
946
  )
947
- }, p = f ? vt(f) : null, S = (p == null ? void 0 : p.line_count) ?? E.line.chunk.count, N = (p == null ? void 0 : p.fill_count) ?? E.fill.chunk.count, C = (p == null ? void 0 : p.dot_count) ?? E.dot.chunk.count, G = f && (!_ || b) ? Ce(f) : Xn(E.line.chunk, E.fill.chunk, E.dot.chunk), U = {
947
+ }, b = f ? Mt(f) : null, P = (b == null ? void 0 : b.line_count) ?? E.line.chunk.count, N = (b == null ? void 0 : b.fill_count) ?? E.fill.chunk.count, C = (b == null ? void 0 : b.dot_count) ?? E.dot.chunk.count, G = f && (!x || p) ? Se(f) : Yn(E.line.chunk, E.fill.chunk, E.dot.chunk), U = {
948
948
  id: d,
949
- name: ht(o, w, y, `V3 variant ${d} name`),
950
- line_count: b ? S : E.line.chunk.count,
951
- fill_count: b ? N : E.fill.chunk.count,
952
- dot_count: b ? C : E.dot.chunk.count,
953
- sourceLineCount: S,
949
+ name: ht(s, w, y, `V3 variant ${d} name`),
950
+ line_count: p ? P : E.line.chunk.count,
951
+ fill_count: p ? N : E.fill.chunk.count,
952
+ dot_count: p ? C : E.dot.chunk.count,
953
+ sourceLineCount: P,
954
954
  sourceFillCount: N,
955
955
  sourceDotCount: C,
956
956
  nestedStart: e.getUint32(h + 32, !0),
@@ -968,15 +968,15 @@ function Yn(t, e, n, r, o, s, i, a) {
968
968
  }
969
969
  return { variantsById: c, variants: u, snapshots: m };
970
970
  }
971
- function zn(t, e, n, r, o) {
971
+ function Hn(t, e, n, r, s) {
972
972
  if (e.length % 60 !== 0)
973
973
  throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
974
- const s = [], i = e.length / 60;
974
+ const o = [], i = e.length / 60;
975
975
  for (let a = 0; a < i; a += 1) {
976
- const c = e.offset + a * 60, u = t.getUint32(c, !0), m = t.getUint32(c + 4, !0), g = (o == null ? void 0 : o[a]) ?? null;
977
- g && Ue(t, c, a);
978
- const d = g ? vt(g) : null, h = t.getFloat32(c + 48, !0), w = t.getFloat32(c + 52, !0);
979
- s.push({
976
+ const c = e.offset + a * 60, u = t.getUint32(c, !0), m = t.getUint32(c + 4, !0), g = (s == null ? void 0 : s[a]) ?? null;
977
+ g && Ce(t, c, a);
978
+ const d = g ? Mt(g) : null, h = t.getFloat32(c + 48, !0), w = t.getFloat32(c + 52, !0);
979
+ o.push({
980
980
  id: a,
981
981
  name: ht(r, u, m, `V3 variant ${a} name`),
982
982
  line_count: g ? d.line_count : Et(
@@ -1006,43 +1006,43 @@ function zn(t, e, n, r, o) {
1006
1006
  textCount: t.getUint32(c + 44, !0),
1007
1007
  precisionOriginX: h,
1008
1008
  precisionOriginY: w,
1009
- bbox: g ? Ce(g) : null
1009
+ bbox: g ? Se(g) : null
1010
1010
  });
1011
1011
  }
1012
- return s;
1012
+ return o;
1013
1013
  }
1014
1014
  function lt(t, e, n) {
1015
1015
  if (e.length % 32 !== 0)
1016
1016
  throw new l("E_GROUP_RANGE", `${n} length must be a multiple of 32`);
1017
- const r = new DataView(t), o = [];
1018
- for (let s = e.offset; s < e.offset + e.length; s += 32) {
1019
- const i = r.getUint16(s + 30, !0);
1020
- nr(i), o.push({
1021
- variantId: r.getUint32(s, !0),
1022
- matA: r.getFloat32(s + 4, !0),
1023
- matB: r.getFloat32(s + 8, !0),
1024
- matC: r.getFloat32(s + 12, !0),
1025
- matD: r.getFloat32(s + 16, !0),
1026
- tx: r.getFloat32(s + 20, !0),
1027
- ty: r.getFloat32(s + 24, !0),
1028
- insLayerIdx: r.getUint16(s + 28, !0),
1017
+ const r = new DataView(t), s = [];
1018
+ for (let o = e.offset; o < e.offset + e.length; o += 32) {
1019
+ const i = r.getUint16(o + 30, !0);
1020
+ rr(i), s.push({
1021
+ variantId: r.getUint32(o, !0),
1022
+ matA: r.getFloat32(o + 4, !0),
1023
+ matB: r.getFloat32(o + 8, !0),
1024
+ matC: r.getFloat32(o + 12, !0),
1025
+ matD: r.getFloat32(o + 16, !0),
1026
+ tx: r.getFloat32(o + 20, !0),
1027
+ ty: r.getFloat32(o + 24, !0),
1028
+ insLayerIdx: r.getUint16(o + 28, !0),
1029
1029
  flags: i
1030
1030
  });
1031
1031
  }
1032
- return o;
1032
+ return s;
1033
1033
  }
1034
- function Hn(t, e, n) {
1035
- const r = t.getUint32(e, !0), o = t.getUint32(e + 4, !0), s = t.getUint8(e + 42), i = t.getUint8(e + 43), a = t.getFloat32(e + 24, !0), c = t.getFloat32(e + 28, !0);
1034
+ function Kn(t, e, n) {
1035
+ const r = t.getUint32(e, !0), s = t.getUint32(e + 4, !0), o = t.getUint8(e + 42), i = t.getUint8(e + 43), a = t.getFloat32(e + 24, !0), c = t.getFloat32(e + 28, !0);
1036
1036
  return {
1037
- t: ht(n, r, o, "V3 text value"),
1037
+ t: ht(n, r, s, "V3 text value"),
1038
1038
  x: t.getFloat32(e + 8, !0),
1039
1039
  y: t.getFloat32(e + 12, !0),
1040
1040
  h: t.getFloat32(e + 16, !0),
1041
1041
  r: t.getFloat32(e + 20, !0),
1042
1042
  c: [t.getUint8(e + 36), t.getUint8(e + 37), t.getUint8(e + 38)],
1043
1043
  li: t.getUint16(e + 40, !0),
1044
- ha: dn[s & 3] ?? "left",
1045
- va: mn[s >> 2 & 3] ?? "alphabetic",
1044
+ ha: mn[o & 3] ?? "left",
1045
+ va: hn[o >> 2 & 3] ?? "alphabetic",
1046
1046
  lh: t.getFloat32(e + 32, !0),
1047
1047
  ...a ? { w: a } : {},
1048
1048
  ...c !== 1 ? { wf: c } : {},
@@ -1053,17 +1053,17 @@ function Hn(t, e, n) {
1053
1053
  function pt(t, e, n, r) {
1054
1054
  if (e.length % 44 !== 0)
1055
1055
  throw new l("E_GROUP_RANGE", `${r} length must be a multiple of 44`);
1056
- const o = [], s = new DataView(t);
1056
+ const s = [], o = new DataView(t);
1057
1057
  for (let i = e.offset; i < e.offset + e.length; i += 44)
1058
- o.push(Hn(s, i, n));
1059
- return o;
1058
+ s.push(Kn(o, i, n));
1059
+ return s;
1060
1060
  }
1061
- function Kn(t, e) {
1061
+ function jn(t, e) {
1062
1062
  if (t.length % 44 !== 0)
1063
1063
  throw new l("E_GROUP_RANGE", `${e} length must be a multiple of 44`);
1064
1064
  return t.length / 44;
1065
1065
  }
1066
- function jn(t, e, n, r) {
1066
+ function Wn(t, e, n, r) {
1067
1067
  return {
1068
1068
  instanceId: n,
1069
1069
  variantId: e.variantId,
@@ -1076,12 +1076,12 @@ function jn(t, e, n, r) {
1076
1076
  insLayerIdx: r
1077
1077
  };
1078
1078
  }
1079
- function Wn(t, e, n, r) {
1079
+ function qn(t, e, n, r) {
1080
1080
  var y;
1081
- const o = ((y = r[e.insLayerIdx]) == null ? void 0 : y.visible) === !1, s = e.matA * t.x + e.matC * t.y + e.tx, i = e.matB * t.x + e.matD * t.y + e.ty, a = Math.hypot(e.matA, e.matB), c = Math.hypot(e.matC, e.matD), u = c > 1e-12 ? c : a > 1e-12 ? a : 1, m = a > 1e-12 && u > 1e-12 ? a / u : 1, g = qn(t, e), { mx: d, my: h, ...w } = t;
1081
+ const s = ((y = r[e.insLayerIdx]) == null ? void 0 : y.visible) === !1, o = e.matA * t.x + e.matC * t.y + e.tx, i = e.matB * t.x + e.matD * t.y + e.ty, a = Math.hypot(e.matA, e.matB), c = Math.hypot(e.matC, e.matD), u = c > 1e-12 ? c : a > 1e-12 ? a : 1, m = a > 1e-12 && u > 1e-12 ? a / u : 1, g = Jn(t, e), { mx: d, my: h, ...w } = t;
1082
1082
  return {
1083
1083
  ...w,
1084
- x: s,
1084
+ x: o,
1085
1085
  y: i,
1086
1086
  h: t.h * u,
1087
1087
  w: t.w === void 0 ? void 0 : t.w * u,
@@ -1089,21 +1089,21 @@ function Wn(t, e, n, r) {
1089
1089
  r: g.r,
1090
1090
  ...g.mx ? { mx: !0 } : {},
1091
1091
  ...g.my ? { my: !0 } : {},
1092
- li: o || t.li === n ? e.insLayerIdx : t.li
1092
+ li: s || t.li === n ? e.insLayerIdx : t.li
1093
1093
  };
1094
1094
  }
1095
- function qn(t, e) {
1096
- const n = t.r * Math.PI / 180, r = Math.cos(n), o = Math.sin(n), s = t.mx ? -1 : 1, i = t.my ? -1 : 1, a = s * (e.matA * r + e.matC * o), c = s * (e.matB * r + e.matD * o), u = i * (e.matC * r - e.matA * o), m = i * (e.matD * r - e.matB * o), g = a * m - c * u, d = Math.atan2(c, a) * 180 / Math.PI;
1095
+ function Jn(t, e) {
1096
+ const n = t.r * Math.PI / 180, r = Math.cos(n), s = Math.sin(n), o = t.mx ? -1 : 1, i = t.my ? -1 : 1, a = o * (e.matA * r + e.matC * s), c = o * (e.matB * r + e.matD * s), u = i * (e.matC * r - e.matA * s), m = i * (e.matD * r - e.matB * s), g = a * m - c * u, d = Math.atan2(c, a) * 180 / Math.PI;
1097
1097
  return g < 0 ? { r: Math.atan2(-c, -a) * 180 / Math.PI, mx: !0 } : { r: d };
1098
1098
  }
1099
- function Jn(t, e) {
1099
+ function Zn(t, e) {
1100
1100
  return t === e ? e : t;
1101
1101
  }
1102
- function Zn(t, e, n) {
1102
+ function Qn(t, e, n) {
1103
1103
  return t === n ? e : t;
1104
1104
  }
1105
- function Qn(t, e) {
1106
- const n = new DataView(t), { versionMinor: r, sections: o } = Nn(t), s = ye(r), i = Z(o, 1, "SCENE_META"), a = Z(o, 2, "LAYER_TABLE"), c = Z(o, 3, "STRING_TABLE"), u = Z(o, 4, "BASE_GEOMETRY"), m = Z(o, 5, "VARIANT_TABLE"), g = Z(o, 6, "VARIANT_GEOMETRY"), d = Z(o, 7, "SCENE_INSTANCE_TABLE"), h = xt(o, 8), w = xt(o, 9), y = xt(o, 10), f = Gn(t, i, "SCENE_META"), _ = Un(f) ? Tn(f, m.length / 60) : null, b = Cn(f), E = b ? Bn(f) : null, p = Pn(f, _, b), S = b ? "nested_instanced_external_annotations" : _ ? "nested_instanced_external" : "nested_instanced", N = new Uint8Array(t, c.offset, c.length), C = $n(t, a, N), G = Number(f.layer0_index ?? 0), U = Ie({
1105
+ function tr(t, e) {
1106
+ const n = new DataView(t), { versionMinor: r, sections: s } = Gn(t), o = _e(r), i = Q(s, 1, "SCENE_META"), a = Q(s, 2, "LAYER_TABLE"), c = Q(s, 3, "STRING_TABLE"), u = Q(s, 4, "BASE_GEOMETRY"), m = Q(s, 5, "VARIANT_TABLE"), g = Q(s, 6, "VARIANT_GEOMETRY"), d = Q(s, 7, "SCENE_INSTANCE_TABLE"), h = _t(s, 8), w = _t(s, 9), y = _t(s, 10), f = Un(t, i, "SCENE_META"), x = Cn(f) ? Bn(f, m.length / 60) : null, p = Sn(f), E = p ? $n(f) : null, b = Pn(f, x, p), P = p ? "nested_instanced_external_annotations" : x ? "nested_instanced_external" : "nested_instanced", N = new Uint8Array(t, c.offset, c.length), C = On(t, a, N), G = Number(f.layer0_index ?? 0), U = Re({
1107
1107
  bounds: f.bounds ?? [0, 0, 0, 0],
1108
1108
  entity_count: Number(f.entity_count ?? 0),
1109
1109
  line_count: Number(f.base_line_count ?? 0),
@@ -1112,28 +1112,28 @@ function Qn(t, e) {
1112
1112
  layers: C,
1113
1113
  texts: []
1114
1114
  });
1115
- er(G, U.layers);
1116
- const R = Fn(t, n, u, s);
1115
+ nr(G, U.layers);
1116
+ const R = Xn(t, n, u, o);
1117
1117
  if (!e.loadBlocks) {
1118
- const x = zn(n, m, g, N, _), A = lt(t, d, "V3 SCENE_INSTANCE_TABLE"), O = lt(t, h, "V3 NESTED_INSTANCE_TABLE"), P = pt(t, w, N, "V3 SCENE_TEXT_TABLE"), T = Kn(y, "V3 VARIANT_TEXT_TABLE");
1119
- if (Number(f.variant_count ?? x.length) !== x.length)
1118
+ const _ = Hn(n, m, g, N, x), A = lt(t, d, "V3 SCENE_INSTANCE_TABLE"), O = lt(t, h, "V3 NESTED_INSTANCE_TABLE"), S = pt(t, w, N, "V3 SCENE_TEXT_TABLE"), T = jn(y, "V3 VARIANT_TEXT_TABLE");
1119
+ if (Number(f.variant_count ?? _.length) !== _.length)
1120
1120
  throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1121
1121
  if (Number(f.scene_instance_count ?? A.length) !== A.length)
1122
1122
  throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1123
1123
  if (Number(f.nested_instance_count ?? O.length) !== O.length)
1124
1124
  throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1125
- if (Number(f.scene_text_count ?? P.length) !== P.length)
1125
+ if (Number(f.scene_text_count ?? S.length) !== S.length)
1126
1126
  throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1127
1127
  if (Number(f.variant_text_count ?? T) !== T)
1128
1128
  throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1129
- for (const I of x) {
1129
+ for (const I of _) {
1130
1130
  if (I.nestedStart + I.nestedCount > O.length)
1131
1131
  throw new l("E_GROUP_RANGE", `V3 variant ${I.id} nested range exceeds table`);
1132
1132
  if (I.textStart + I.textCount > T)
1133
1133
  throw new l("E_GROUP_RANGE", `V3 variant ${I.id} text range exceeds table`);
1134
1134
  }
1135
1135
  return ne(A, O, (I) => {
1136
- if (!x[I.variantId])
1136
+ if (!_[I.variantId])
1137
1137
  throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${I.variantId}`);
1138
1138
  ce(I.insLayerIdx, C.length);
1139
1139
  }), {
@@ -1145,12 +1145,12 @@ function Qn(t, e) {
1145
1145
  dot_count: R.dot.count,
1146
1146
  version: 3,
1147
1147
  version_minor: r,
1148
- encoding: S,
1149
- ...p ? { features: p } : {},
1150
- ..._ ? { external_variants: [..._] } : {},
1148
+ encoding: P,
1149
+ ...b ? { features: b } : {},
1150
+ ...x ? { external_variants: [...x] } : {},
1151
1151
  ...E ? { external_annotations: E } : {},
1152
1152
  layer0_index: G,
1153
- block_variants: x.map((I) => ({
1153
+ block_variants: _.map((I) => ({
1154
1154
  id: I.id,
1155
1155
  name: I.name,
1156
1156
  line_count: I.line_count,
@@ -1159,15 +1159,15 @@ function Qn(t, e) {
1159
1159
  })),
1160
1160
  instance_count: A.length,
1161
1161
  layers: C,
1162
- texts: P
1162
+ texts: S
1163
1163
  },
1164
1164
  header: {
1165
1165
  ...U,
1166
1166
  lineCount: R.line.count,
1167
1167
  fillCount: R.fill.count,
1168
1168
  dotCount: R.dot.count,
1169
- textCount: P.length,
1170
- texts: P
1169
+ textCount: S.length,
1170
+ texts: S
1171
1171
  },
1172
1172
  decoded: {
1173
1173
  baseLine: R.line,
@@ -1179,61 +1179,61 @@ function Qn(t, e) {
1179
1179
  }
1180
1180
  };
1181
1181
  }
1182
- const { variantsById: V, variants: L, snapshots: F } = Yn(
1182
+ const { variantsById: V, variants: F, snapshots: X } = zn(
1183
1183
  t,
1184
1184
  n,
1185
1185
  m,
1186
1186
  g,
1187
1187
  N,
1188
- _,
1189
- s,
1188
+ x,
1189
+ o,
1190
1190
  e
1191
- ), z = lt(t, d, "V3 SCENE_INSTANCE_TABLE"), $ = lt(t, h, "V3 NESTED_INSTANCE_TABLE"), v = pt(t, w, N, "V3 SCENE_TEXT_TABLE"), B = pt(t, y, N, "V3 VARIANT_TEXT_TABLE");
1191
+ ), H = lt(t, d, "V3 SCENE_INSTANCE_TABLE"), $ = lt(t, h, "V3 NESTED_INSTANCE_TABLE"), M = pt(t, w, N, "V3 SCENE_TEXT_TABLE"), B = pt(t, y, N, "V3 VARIANT_TEXT_TABLE");
1192
1192
  if (Number(f.variant_count ?? V.length) !== V.length)
1193
1193
  throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1194
- if (Number(f.scene_instance_count ?? z.length) !== z.length)
1194
+ if (Number(f.scene_instance_count ?? H.length) !== H.length)
1195
1195
  throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1196
1196
  if (Number(f.nested_instance_count ?? $.length) !== $.length)
1197
1197
  throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1198
- if (Number(f.scene_text_count ?? v.length) !== v.length)
1198
+ if (Number(f.scene_text_count ?? M.length) !== M.length)
1199
1199
  throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1200
1200
  if (Number(f.variant_text_count ?? B.length) !== B.length)
1201
1201
  throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1202
- for (const x of V) {
1203
- if (x.nestedStart + x.nestedCount > $.length)
1204
- throw new l("E_GROUP_RANGE", `V3 variant ${x.id} nested range exceeds table`);
1205
- if (x.textStart + x.textCount > B.length)
1206
- throw new l("E_GROUP_RANGE", `V3 variant ${x.id} text range exceeds table`);
1202
+ for (const _ of V) {
1203
+ if (_.nestedStart + _.nestedCount > $.length)
1204
+ throw new l("E_GROUP_RANGE", `V3 variant ${_.id} nested range exceeds table`);
1205
+ if (_.textStart + _.textCount > B.length)
1206
+ throw new l("E_GROUP_RANGE", `V3 variant ${_.id} text range exceeds table`);
1207
1207
  }
1208
- ne(z, $, (x) => {
1209
- if (!V[x.variantId])
1210
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${x.variantId}`);
1211
- ce(x.insLayerIdx, C.length);
1208
+ ne(H, $, (_) => {
1209
+ if (!V[_.variantId])
1210
+ throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${_.variantId}`);
1211
+ ce(_.insLayerIdx, C.length);
1212
1212
  });
1213
- const Mt = /* @__PURE__ */ new Map();
1214
- for (const x of V)
1215
- Mt.set(
1216
- x.id,
1217
- B.slice(x.textStart, x.textStart + x.textCount)
1213
+ const vt = /* @__PURE__ */ new Map();
1214
+ for (const _ of V)
1215
+ vt.set(
1216
+ _.id,
1217
+ B.slice(_.textStart, _.textStart + _.textCount)
1218
1218
  );
1219
- const it = [], M = e.externalVariantDeltaOnly, Dt = M ? [] : [...v], gt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), kt = /* @__PURE__ */ new Map(), $e = (x, A) => {
1220
- gt.set(x, Bt(gt.get(x) ?? null, A));
1221
- }, Lt = (x, A, O, P, T, j) => {
1219
+ const it = [], v = e.externalVariantDeltaOnly, Dt = v ? [] : [...M], gt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), kt = /* @__PURE__ */ new Map(), Oe = (_, A) => {
1220
+ gt.set(_, Bt(gt.get(_) ?? null, A));
1221
+ }, Lt = (_, A, O, S, T, W) => {
1222
1222
  var Kt;
1223
1223
  if (T > 64)
1224
1224
  throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1225
- if (j.has(x))
1226
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${x}`);
1227
- const I = V[x];
1225
+ if (W.has(_))
1226
+ throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${_}`);
1227
+ const I = V[_];
1228
1228
  if (!I)
1229
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${x}`);
1230
- j.add(x);
1231
- const W = !e.requiredExternalVariantIds || e.requiredExternalVariantIds.has(x), X = M ? ((Kt = e.requiredExternalVariantIds) == null ? void 0 : Kt.has(x)) === !0 : W;
1229
+ throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${_}`);
1230
+ W.add(_);
1231
+ const q = !e.requiredExternalVariantIds || e.requiredExternalVariantIds.has(_), Y = v ? ((Kt = e.requiredExternalVariantIds) == null ? void 0 : Kt.has(_)) === !0 : q;
1232
1232
  let D = !1;
1233
- const Ht = !!(I.line_count || I.fill_count || I.dot_count), Me = I.textCount > 0;
1234
- if (X && (Ht || Me) && (it.push({
1233
+ const Ht = !!(I.line_count || I.fill_count || I.dot_count), De = I.textCount > 0;
1234
+ if (Y && (Ht || De) && (it.push({
1235
1235
  instanceId: A.instanceId,
1236
- variantId: x,
1236
+ variantId: _,
1237
1237
  matA: A.matA,
1238
1238
  matB: A.matB,
1239
1239
  matC: A.matC,
@@ -1241,100 +1241,100 @@ function Qn(t, e) {
1241
1241
  tx: A.tx,
1242
1242
  ty: A.ty,
1243
1243
  insLayerIdx: A.insLayerIdx
1244
- }), Ht && $e(A.instanceId, I.bbox ? Pe(I.bbox, A) : null), D = !0), X) {
1244
+ }), Ht && Oe(A.instanceId, I.bbox ? Pe(I.bbox, A) : null), D = !0), Y) {
1245
1245
  I.textCount > 0 && (D = !0);
1246
- for (let q = 0; q < I.textCount; q += 1) {
1247
- const tt = Wn(B[I.textStart + q], A, G, U.layers);
1246
+ for (let J = 0; J < I.textCount; J += 1) {
1247
+ const tt = qn(B[I.textStart + J], A, G, U.layers);
1248
1248
  Dt.push({
1249
1249
  ...tt,
1250
1250
  iv: O,
1251
- io: P
1251
+ io: S
1252
1252
  });
1253
1253
  }
1254
1254
  }
1255
- for (let q = 0; q < I.nestedCount; q += 1) {
1256
- const tt = $[I.nestedStart + q], De = Zn(tt.insLayerIdx, A.insLayerIdx, G), ke = tr(tt, I, V[tt.variantId]), Le = jn(A, ke, A.instanceId, De);
1257
- D = Lt(tt.variantId, Le, O, P, T + 1, j) || D;
1255
+ for (let J = 0; J < I.nestedCount; J += 1) {
1256
+ const tt = $[I.nestedStart + J], ke = Qn(tt.insLayerIdx, A.insLayerIdx, G), Le = er(tt, I, V[tt.variantId]), Fe = Wn(A, Le, A.instanceId, ke);
1257
+ D = Lt(tt.variantId, Fe, O, S, T + 1, W) || D;
1258
1258
  }
1259
- return j.delete(x), D;
1259
+ return W.delete(_), D;
1260
1260
  }, yt = /* @__PURE__ */ new Map();
1261
- z.forEach((x, A) => {
1262
- if (!V[x.variantId])
1263
- throw new l("E_GROUP_RANGE", `Unknown V3 scene variantId ${x.variantId}`);
1264
- const P = kt.get(x.variantId) ?? 0;
1265
- kt.set(x.variantId, P + 1), at.set(`${x.variantId}:${P}`, A);
1266
- const T = Jn(x.insLayerIdx, G), j = {
1261
+ H.forEach((_, A) => {
1262
+ if (!V[_.variantId])
1263
+ throw new l("E_GROUP_RANGE", `Unknown V3 scene variantId ${_.variantId}`);
1264
+ const S = kt.get(_.variantId) ?? 0;
1265
+ kt.set(_.variantId, S + 1), at.set(`${_.variantId}:${S}`, A);
1266
+ const T = Zn(_.insLayerIdx, G), W = {
1267
1267
  instanceId: A,
1268
- variantId: x.variantId,
1269
- matA: x.matA,
1270
- matB: x.matB,
1271
- matC: x.matC,
1272
- matD: x.matD,
1273
- tx: x.tx,
1274
- ty: x.ty,
1268
+ variantId: _.variantId,
1269
+ matA: _.matA,
1270
+ matB: _.matB,
1271
+ matC: _.matC,
1272
+ matD: _.matD,
1273
+ tx: _.tx,
1274
+ ty: _.ty,
1275
1275
  insLayerIdx: T
1276
- }, I = Lt(x.variantId, j, x.variantId, P, 0, /* @__PURE__ */ new Set());
1277
- if (M && !I)
1276
+ }, I = Lt(_.variantId, W, _.variantId, S, 0, /* @__PURE__ */ new Set());
1277
+ if (v && !I)
1278
1278
  return;
1279
- let W = yt.get(T);
1280
- W || (W = /* @__PURE__ */ new Map(), yt.set(T, W));
1281
- let X = W.get(x.variantId);
1282
- X || (X = { count: 0, bboxes: [], inserts: [] }, W.set(x.variantId, X)), X.count += 1;
1279
+ let q = yt.get(T);
1280
+ q || (q = /* @__PURE__ */ new Map(), yt.set(T, q));
1281
+ let Y = q.get(_.variantId);
1282
+ Y || (Y = { count: 0, bboxes: [], inserts: [] }, q.set(_.variantId, Y)), Y.count += 1;
1283
1283
  const D = gt.get(A) ?? null;
1284
- D && X.bboxes.push(D), X.inserts.push({
1284
+ D && Y.bboxes.push(D), Y.inserts.push({
1285
1285
  instanceId: A,
1286
- variantId: x.variantId,
1287
- label: `#${A + 1} (${x.tx.toFixed(1)}, ${x.ty.toFixed(1)})`,
1288
- tx: x.tx,
1289
- ty: x.ty,
1286
+ variantId: _.variantId,
1287
+ label: `#${A + 1} (${_.tx.toFixed(1)}, ${_.ty.toFixed(1)})`,
1288
+ tx: _.tx,
1289
+ ty: _.ty,
1290
1290
  canHighlight: D !== null,
1291
1291
  ...D ? { bbox: D } : {}
1292
1292
  });
1293
1293
  });
1294
1294
  const Ft = /* @__PURE__ */ new Map();
1295
- for (const [x, A] of yt) {
1295
+ for (const [_, A] of yt) {
1296
1296
  const O = [];
1297
- for (const [P, T] of A)
1297
+ for (const [S, T] of A)
1298
1298
  O.push({
1299
- variantId: P,
1300
- blockName: Ve(V[P], P),
1299
+ variantId: S,
1300
+ blockName: Ne(V[S], S),
1301
1301
  instanceCount: T.count,
1302
1302
  bboxes: T.bboxes,
1303
1303
  inserts: T.inserts
1304
1304
  });
1305
- O.sort((P, T) => T.instanceCount - P.instanceCount), Ft.set(x, O);
1305
+ O.sort((S, T) => T.instanceCount - S.instanceCount), Ft.set(_, O);
1306
1306
  }
1307
- let Xt = M ? 0 : R.line.count, Yt = M ? 0 : R.fill.count, zt = M ? 0 : R.dot.count;
1308
- for (const x of it) {
1309
- const A = V[x.variantId];
1310
- !(e.deferExternalVariantGeometry && A.lineSnapshot.count === 0 && A.fillSnapshot.count === 0 && A.dotSnapshot.count === 0) && !Re(x.instanceId, e) || (Xt += A.line_count, Yt += A.fill_count, zt += A.dot_count);
1307
+ let Xt = v ? 0 : R.line.count, Yt = v ? 0 : R.fill.count, zt = v ? 0 : R.dot.count;
1308
+ for (const _ of it) {
1309
+ const A = V[_.variantId];
1310
+ e.deferExternalVariantGeometry && A.lineSnapshot.count === 0 && A.fillSnapshot.count === 0 && A.dotSnapshot.count === 0 || !Ve(_.instanceId, e) || (Xt += A.line_count, Yt += A.fill_count, zt += A.dot_count);
1311
1311
  }
1312
- const ct = wn(Dt, at, e), Oe = {
1312
+ const ct = pn(Dt, at, e), Me = {
1313
1313
  bounds: f.bounds ?? [0, 0, 0, 0],
1314
- entity_count: M ? 0 : Number(f.entity_count ?? 0),
1314
+ entity_count: v ? 0 : Number(f.entity_count ?? 0),
1315
1315
  line_count: R.line.count,
1316
1316
  fill_count: R.fill.count,
1317
1317
  dot_count: R.dot.count,
1318
1318
  version: 3,
1319
1319
  version_minor: r,
1320
- encoding: S,
1321
- ...p ? { features: p } : {},
1322
- ..._ ? { external_variants: [..._] } : {},
1320
+ encoding: P,
1321
+ ...b ? { features: b } : {},
1322
+ ...x ? { external_variants: [...x] } : {},
1323
1323
  ...E ? { external_annotations: E } : {},
1324
1324
  layer0_index: G,
1325
- block_variants: V.map((x) => ({
1326
- id: x.id,
1327
- name: x.name,
1328
- line_count: x.sourceLineCount,
1329
- fill_count: x.sourceFillCount,
1330
- dot_count: x.sourceDotCount
1325
+ block_variants: V.map((_) => ({
1326
+ id: _.id,
1327
+ name: _.name,
1328
+ line_count: _.sourceLineCount,
1329
+ fill_count: _.sourceFillCount,
1330
+ dot_count: _.sourceDotCount
1331
1331
  })),
1332
- instance_count: z.length,
1332
+ instance_count: H.length,
1333
1333
  layers: C,
1334
1334
  texts: ct
1335
1335
  }, ve = {
1336
1336
  ...U,
1337
- entityCount: M ? 0 : U.entityCount,
1337
+ entityCount: v ? 0 : U.entityCount,
1338
1338
  lineCount: Xt,
1339
1339
  fillCount: Yt,
1340
1340
  dotCount: zt,
@@ -1342,11 +1342,11 @@ function Qn(t, e) {
1342
1342
  texts: ct,
1343
1343
  ...e.loadBlocks ? {
1344
1344
  layerBlockUsages: Ft,
1345
- insertRuntime: bn(
1345
+ insertRuntime: An(
1346
1346
  G,
1347
1347
  V,
1348
- F,
1349
- Mt,
1348
+ X,
1349
+ vt,
1350
1350
  it,
1351
1351
  ct,
1352
1352
  at
@@ -1354,29 +1354,29 @@ function Qn(t, e) {
1354
1354
  } : {}
1355
1355
  };
1356
1356
  return {
1357
- meta: Oe,
1357
+ meta: Me,
1358
1358
  header: ve,
1359
1359
  decoded: {
1360
- baseLine: M ? At() : R.line,
1361
- baseFill: M ? At() : R.fill,
1362
- baseDot: M ? At() : R.dot,
1363
- variants: L,
1360
+ baseLine: v ? At() : R.line,
1361
+ baseFill: v ? At() : R.fill,
1362
+ baseDot: v ? At() : R.dot,
1363
+ variants: F,
1364
1364
  instances: it,
1365
1365
  instanceIdByVariantOrdinal: at
1366
1366
  }
1367
1367
  };
1368
1368
  }
1369
1369
  function Bt(t, e) {
1370
- return be(t, e);
1370
+ return Ae(t, e);
1371
1371
  }
1372
1372
  function Pe(t, e) {
1373
- return Ae(t, e);
1373
+ return Ie(t, e);
1374
1374
  }
1375
1375
  function se(t) {
1376
- return Je(t);
1376
+ return Ze(t);
1377
1377
  }
1378
1378
  function ie(t, e) {
1379
- return Ze(t, e);
1379
+ return Qe(t, e);
1380
1380
  }
1381
1381
  function ae(t, e) {
1382
1382
  return Pe(t, {
@@ -1390,65 +1390,65 @@ function ae(t, e) {
1390
1390
  insLayerIdx: e.insLayerIdx
1391
1391
  });
1392
1392
  }
1393
- function tr(t, e, n) {
1393
+ function er(t, e, n) {
1394
1394
  if (!(n != null && n.bbox) || !e.bbox)
1395
1395
  return t;
1396
- const r = e.precisionOriginX, o = e.precisionOriginY;
1397
- if (!Number.isFinite(r) || !Number.isFinite(o) || r === 0 && o === 0)
1396
+ const r = e.precisionOriginX, s = e.precisionOriginY;
1397
+ if (!Number.isFinite(r) || !Number.isFinite(s) || r === 0 && s === 0)
1398
1398
  return t;
1399
- const s = {
1399
+ const o = {
1400
1400
  ...t,
1401
1401
  tx: t.tx - r,
1402
- ty: t.ty - o
1403
- }, i = ae(n.bbox, t), a = ae(n.bbox, s), c = Math.max(se(e.bbox), se(n.bbox), 1), u = Math.hypot(r, o), m = Math.hypot(t.tx, t.ty), g = Math.hypot(s.tx, s.ty);
1402
+ ty: t.ty - s
1403
+ }, i = ae(n.bbox, t), a = ae(n.bbox, o), c = Math.max(se(e.bbox), se(n.bbox), 1), u = Math.hypot(r, s), m = Math.hypot(t.tx, t.ty), g = Math.hypot(o.tx, o.ty);
1404
1404
  if (u <= c * 16 || m <= c * 16)
1405
1405
  return t;
1406
1406
  const d = ie(e.bbox, i), h = ie(e.bbox, a);
1407
- return d > c * 16 && h * 4 < d && g * 4 < m ? s : t;
1407
+ return d > c * 16 && h * 4 < d && g * 4 < m ? o : t;
1408
1408
  }
1409
1409
  function ce(t, e) {
1410
1410
  if (t >= e)
1411
1411
  throw new l("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${e}`);
1412
1412
  }
1413
- function er(t, e) {
1413
+ function nr(t, e) {
1414
1414
  if (!Number.isInteger(t) || t < 0 || t >= e.length)
1415
1415
  throw new l("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
1416
1416
  if (e[t].name !== "0")
1417
1417
  throw new l("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
1418
1418
  }
1419
- function nr(t) {
1419
+ function rr(t) {
1420
1420
  if (t !== 0)
1421
1421
  throw new l("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
1422
1422
  }
1423
- function* rr(t, e, n, r, o) {
1424
- let s = n;
1423
+ function* or(t, e, n, r, s) {
1424
+ let o = n;
1425
1425
  const i = [
1426
1426
  { kind: "line", count: r.lineCount },
1427
1427
  { kind: "fill", count: r.fillCount },
1428
1428
  { kind: "dot", count: r.dotCount }
1429
1429
  ];
1430
1430
  for (const a of i) {
1431
- const c = We(t, e, s, a.count);
1431
+ const c = qe(t, e, o, a.count);
1432
1432
  for (; ; ) {
1433
1433
  const u = c.next();
1434
1434
  if (u.done) {
1435
- s = u.value;
1435
+ o = u.value;
1436
1436
  break;
1437
1437
  }
1438
1438
  yield { kind: a.kind, payload: u.value };
1439
1439
  }
1440
1440
  }
1441
- if (s !== t.byteLength)
1442
- throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${s}, size=${t.byteLength}`);
1441
+ if (o !== t.byteLength)
1442
+ throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
1443
1443
  for (const a of r.texts)
1444
1444
  yield { kind: "text", payload: a };
1445
1445
  }
1446
- function* or(t, e, n, r) {
1447
- yield* rr(t, e, n, r);
1446
+ function* sr(t, e, n, r) {
1447
+ yield* or(t, e, n, r);
1448
1448
  }
1449
- function* bt(t, e, n, r, o, s, i, a) {
1450
- if (En(a, t, Math.max(0, e - n.count)), e === 0) {
1451
- yield { kind: t, payload: an() };
1449
+ function* bt(t, e, n, r, s, o, i, a) {
1450
+ if (wn(a, t, Math.max(0, e - n.count)), e === 0) {
1451
+ yield { kind: t, payload: cn() };
1452
1452
  return;
1453
1453
  }
1454
1454
  const c = Ut;
@@ -1458,60 +1458,60 @@ function* bt(t, e, n, r, o, s, i, a) {
1458
1458
  return;
1459
1459
  const f = g === c ? { pos: u, count: g, segments: ee(m) } : { pos: u.slice(0, g * 2), count: g, segments: ee(m) };
1460
1460
  yield { kind: t, payload: f }, d += g, g = 0, u = new Float32Array(c * 2), m = [];
1461
- }, w = (f, _, b, E) => {
1461
+ }, w = (f, x, p, E) => {
1462
1462
  if (f <= 0)
1463
1463
  return;
1464
- const p = m[m.length - 1];
1465
- if (p && p.startVertex + p.vertexCount === g && p.layerIndex === b && p.color[0] === _[0] && p.color[1] === _[1] && p.color[2] === _[2] && p.lineweightPx === E) {
1464
+ const b = m[m.length - 1];
1465
+ if (b && b.startVertex + b.vertexCount === g && b.layerIndex === p && b.color[0] === x[0] && b.color[1] === x[1] && b.color[2] === x[2] && b.lineweightPx === E) {
1466
1466
  m[m.length - 1] = {
1467
- ...p,
1468
- vertexCount: p.vertexCount + f
1467
+ ...b,
1468
+ vertexCount: b.vertexCount + f
1469
1469
  };
1470
1470
  return;
1471
1471
  }
1472
1472
  m.push({
1473
1473
  startVertex: g,
1474
1474
  vertexCount: f,
1475
- color: [_[0], _[1], _[2]],
1476
- layerIndex: b,
1475
+ color: [x[0], x[1], x[2]],
1476
+ layerIndex: p,
1477
1477
  ...E === void 0 ? {} : { lineweightPx: E }
1478
1478
  });
1479
1479
  };
1480
1480
  yield* function* () {
1481
- for (const f of St(n)) {
1482
- let _ = f.startVertex;
1483
- const b = f.startVertex + f.vertexCount;
1484
- for (; _ < b; ) {
1485
- const E = Math.min(c - g, b - _), p = _ * 2, S = g * 2;
1486
- u.set(n.pos.subarray(p, p + E * 2), S), w(E, f.color, f.layerIndex, f.lineweightPx), _ += E, g += E, g === c && (yield* h());
1481
+ for (const f of Pt(n)) {
1482
+ let x = f.startVertex;
1483
+ const p = f.startVertex + f.vertexCount;
1484
+ for (; x < p; ) {
1485
+ const E = Math.min(c - g, p - x), b = x * 2, P = g * 2;
1486
+ u.set(n.pos.subarray(b, b + E * 2), P), w(E, f.color, f.layerIndex, f.lineweightPx), x += E, g += E, g === c && (yield* h());
1487
1487
  }
1488
1488
  }
1489
1489
  }();
1490
- for (const f of o) {
1491
- if (!Re(f.instanceId, a))
1490
+ for (const f of s) {
1491
+ if (!Ve(f.instanceId, a))
1492
1492
  continue;
1493
- const _ = r.get(f.variantId);
1494
- if (!_)
1493
+ const x = r.get(f.variantId);
1494
+ if (!x)
1495
1495
  throw new l("E_GROUP_RANGE", `Unknown variantId ${f.variantId}`);
1496
- const b = _[t], E = i[f.insLayerIdx].visible === !1;
1497
- for (const p of St(b)) {
1498
- const S = E || p.layerIndex === s ? f.insLayerIdx : p.layerIndex;
1499
- let N = p.startVertex;
1500
- const C = p.startVertex + p.vertexCount;
1496
+ const p = x[t], E = i[f.insLayerIdx].visible === !1;
1497
+ for (const b of Pt(p)) {
1498
+ const P = E || b.layerIndex === o ? f.insLayerIdx : b.layerIndex;
1499
+ let N = b.startVertex;
1500
+ const C = b.startVertex + b.vertexCount;
1501
1501
  for (; N < C; ) {
1502
1502
  const G = Math.min(c - g, C - N);
1503
1503
  for (let U = 0; U < G; U += 1) {
1504
- const R = (N + U) * 2, V = (g + U) * 2, L = b.pos[R], F = b.pos[R + 1];
1505
- u[V] = f.matA * L + f.matC * F + f.tx, u[V + 1] = f.matB * L + f.matD * F + f.ty;
1504
+ const R = (N + U) * 2, V = (g + U) * 2, F = p.pos[R], X = p.pos[R + 1];
1505
+ u[V] = f.matA * F + f.matC * X + f.tx, u[V + 1] = f.matB * F + f.matD * X + f.ty;
1506
1506
  }
1507
- w(G, p.color, S, p.lineweightPx), N += G, g += G, g === c && (yield* h());
1507
+ w(G, b.color, P, b.lineweightPx), N += G, g += G, g === c && (yield* h());
1508
1508
  }
1509
1509
  }
1510
1510
  }
1511
1511
  if (yield* h(), d !== e)
1512
1512
  throw new l("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${e}, emitted=${d}`);
1513
1513
  }
1514
- function* sr(t, e, n, r) {
1514
+ function* ir(t, e, n, r) {
1515
1515
  yield* bt(
1516
1516
  "line",
1517
1517
  e.lineCount,
@@ -1540,14 +1540,14 @@ function* sr(t, e, n, r) {
1540
1540
  e.layers,
1541
1541
  r
1542
1542
  );
1543
- for (const o of e.texts)
1544
- yield { kind: "text", payload: o };
1543
+ for (const s of e.texts)
1544
+ yield { kind: "text", payload: s };
1545
1545
  }
1546
- function ir(t, e) {
1547
- const n = xn(e), r = Qn(t, n);
1546
+ function ar(t, e) {
1547
+ const n = xn(e), r = tr(t, n);
1548
1548
  return {
1549
1549
  header: r.header,
1550
- chunks: sr(
1550
+ chunks: ir(
1551
1551
  r.decoded,
1552
1552
  r.header,
1553
1553
  { layer0_index: r.meta.layer0_index ?? 0 },
@@ -1555,13 +1555,13 @@ function ir(t, e) {
1555
1555
  )
1556
1556
  };
1557
1557
  }
1558
- function ar(t, e) {
1559
- if (Vn(t))
1560
- return ir(t, e);
1561
- const n = Rn(t);
1558
+ function cr(t, e) {
1559
+ if (Nn(t))
1560
+ return ar(t, e);
1561
+ const n = Vn(t);
1562
1562
  return {
1563
1563
  header: n.header,
1564
- chunks: or(t, n.view, n.dataOffset, n.header)
1564
+ chunks: sr(t, n.view, n.dataOffset, n.header)
1565
1565
  };
1566
1566
  }
1567
1567
  function At() {
@@ -1572,35 +1572,36 @@ function At() {
1572
1572
  count: 0
1573
1573
  };
1574
1574
  }
1575
- function cr(t, e) {
1576
- return t ? mt(Ae(t, e)) : null;
1575
+ function ur(t, e) {
1576
+ return t ? mt(Ie(t, e)) : null;
1577
1577
  }
1578
- async function ur(t) {
1578
+ async function lr(t) {
1579
1579
  const e = ue(), n = t.fetchImpl ?? fetch, r = new Map(
1580
1580
  t.entries.map((u) => [u.id, u])
1581
- ), o = Array.from(new Set(t.requiredVariantIds)).sort((u, m) => u - m), s = /* @__PURE__ */ new Map(), i = lr(t.concurrency);
1581
+ ), s = Array.from(new Set(t.requiredVariantIds)).sort((u, m) => u - m), o = /* @__PURE__ */ new Map(), i = fr(t.concurrency);
1582
1582
  let a = 0;
1583
1583
  async function c() {
1584
- for (; a < o.length; ) {
1585
- const u = o[a++], m = r.get(u);
1586
- if (!m)
1587
- throw new Error(`External block ${u} is missing from manifest`);
1588
- const g = new URL(m.href, t.baseUrl).href, d = await n(g, { signal: t.signal });
1589
- if (!d.ok) {
1590
- const w = "status" in d ? d.status : void 0, y = "statusText" in d ? d.statusText : void 0, f = [w, y].filter((_) => _ !== void 0 && _ !== "").join(" ");
1591
- throw new Error(`External block ${u} fetch failed${f ? `: ${f}` : ""}`);
1584
+ var u;
1585
+ for (; a < s.length; ) {
1586
+ const m = s[a++], g = r.get(m);
1587
+ if (!g)
1588
+ throw new Error(`External block ${m} is missing from manifest`);
1589
+ const d = new URL(g.href, t.baseUrl).href, h = await n(d, { signal: t.signal });
1590
+ if (!h.ok) {
1591
+ const y = "status" in h ? h.status : void 0, f = "statusText" in h ? h.statusText : void 0, x = [y, f].filter((p) => p !== void 0 && p !== "").join(" ");
1592
+ throw new Error(`External block ${m} fetch failed${x ? `: ${x}` : ""}`);
1592
1593
  }
1593
- const h = await d.arrayBuffer();
1594
- if (h.byteLength !== m.raw_size)
1594
+ const w = await h.arrayBuffer();
1595
+ if (w.byteLength !== g.raw_size)
1595
1596
  throw new Error(
1596
- `External block ${u} raw_size mismatch: manifest=${m.raw_size}, response=${h.byteLength}`
1597
+ `External block ${m} raw_size mismatch: manifest=${g.raw_size}, response=${w.byteLength}`
1597
1598
  );
1598
- s.set(u, h);
1599
+ o.set(m, w), await ((u = t.onBuffer) == null ? void 0 : u.call(t, m, w));
1599
1600
  }
1600
1601
  }
1601
- return await Promise.all(Array.from({ length: Math.min(i, o.length) }, c)), { buffers: s, fetchMs: ue() - e };
1602
+ return await Promise.all(Array.from({ length: Math.min(i, s.length) }, c)), { buffers: o, fetchMs: ue() - e };
1602
1603
  }
1603
- function lr(t) {
1604
+ function fr(t) {
1604
1605
  const e = Math.floor(t ?? 3);
1605
1606
  return Number.isFinite(e) ? Math.max(1, Math.min(e, 8)) : 3;
1606
1607
  }
@@ -1608,22 +1609,22 @@ function ue() {
1608
1609
  var t, e;
1609
1610
  return ((e = (t = globalThis.performance) == null ? void 0 : t.now) == null ? void 0 : e.call(t)) ?? Date.now();
1610
1611
  }
1611
- var K;
1612
- class fr {
1612
+ var j;
1613
+ class dr {
1613
1614
  constructor() {
1614
- Wt(this, K, /* @__PURE__ */ new Map());
1615
+ Wt(this, j, /* @__PURE__ */ new Map());
1615
1616
  }
1616
1617
  get size() {
1617
- return et(this, K).size;
1618
+ return et(this, j).size;
1618
1619
  }
1619
1620
  append(e) {
1620
1621
  let n = 0;
1621
1622
  for (const r of e) {
1622
1623
  if (r.count <= 0) continue;
1623
- const o = $t(r.layerIndex, r.lineweightPx);
1624
- let s = et(this, K).get(o), i = r.pos, a = r.positionItemSize;
1624
+ const s = $t(r.layerIndex, r.lineweightPx);
1625
+ let o = et(this, j).get(s), i = r.pos, a = r.positionItemSize;
1625
1626
  const c = r.linePositionKind ?? null;
1626
- s ? s.positionItemSize !== a && (le(s), a !== 3 && (i = Te(i, r.count, a)), s.positionItemSize = 3, a = 3, s.linePositionKind = null) : (s = {
1627
+ o ? o.positionItemSize !== a && (le(o), a !== 3 && (i = Be(i, r.count, a)), o.positionItemSize = 3, a = 3, o.linePositionKind = null) : (o = {
1627
1628
  layerIndex: r.layerIndex,
1628
1629
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
1629
1630
  posParts: [],
@@ -1633,47 +1634,47 @@ class fr {
1633
1634
  linePositionKind: c,
1634
1635
  count: 0,
1635
1636
  bbox: null
1636
- }, et(this, K).set(o, s));
1637
- const u = s.count > 0;
1638
- s.posParts.push(i), s.colParts.push(r.col);
1639
- const m = Er(
1640
- r.colorRuns ?? wr(r.col),
1641
- s.count
1637
+ }, et(this, j).set(s, o));
1638
+ const u = o.count > 0;
1639
+ o.posParts.push(i), o.colParts.push(r.col);
1640
+ const m = wr(
1641
+ r.colorRuns ?? pr(r.col),
1642
+ o.count
1642
1643
  );
1643
- s.colorRunParts.push(m), s.linePositionKind !== c && (s.linePositionKind = null), s.positionItemSize === 2 && s.linePositionKind === null && le(s), s.count += r.count, s.bbox = u && s.bbox === null ? null : mr(s.bbox, r.bbox), n += r.count;
1644
+ o.colorRunParts.push(m), o.linePositionKind !== c && (o.linePositionKind = null), o.positionItemSize === 2 && o.linePositionKind === null && le(o), o.count += r.count, o.bbox = u && o.bbox === null ? null : hr(o.bbox, r.bbox), n += r.count;
1644
1645
  }
1645
1646
  return n;
1646
1647
  }
1647
1648
  drain() {
1648
1649
  const e = [];
1649
- for (const n of et(this, K).values()) {
1650
+ for (const n of et(this, j).values()) {
1650
1651
  if (n.count <= 0) continue;
1651
- const r = n.posParts.length === 1 ? n.posParts[0] : xr(n.posParts, n.count * n.positionItemSize), o = n.colParts.length === 1 ? n.colParts[0] : _r(n.colParts, n.count * 3), s = Be(n.colorRunParts.flat()), i = {
1652
+ const r = n.posParts.length === 1 ? n.posParts[0] : xr(n.posParts, n.count * n.positionItemSize), s = n.colParts.length === 1 ? n.colParts[0] : Er(n.colParts, n.count * 3), o = $e(n.colorRunParts.flat()), i = {
1652
1653
  layerIndex: n.layerIndex,
1653
1654
  pos: r,
1654
1655
  positionItemSize: n.positionItemSize,
1655
- col: o,
1656
+ col: s,
1656
1657
  count: n.count,
1657
1658
  bbox: mt(n.bbox),
1658
- colorRuns: s
1659
+ colorRuns: o
1659
1660
  };
1660
1661
  n.lineweightPx !== void 0 && (i.lineweightPx = n.lineweightPx), n.linePositionKind && (i.linePositionKind = n.linePositionKind), e.push(i);
1661
1662
  }
1662
- return et(this, K).clear(), e;
1663
+ return et(this, j).clear(), e;
1663
1664
  }
1664
1665
  }
1665
- K = new WeakMap();
1666
+ j = new WeakMap();
1666
1667
  function It() {
1667
- return new fr();
1668
+ return new dr();
1668
1669
  }
1669
- function dr() {
1670
+ function mr() {
1670
1671
  return {
1671
1672
  line: It(),
1672
1673
  fill: It(),
1673
1674
  dot: It()
1674
1675
  };
1675
1676
  }
1676
- function mr(t, e) {
1677
+ function hr(t, e) {
1677
1678
  const n = mt(e);
1678
1679
  return t ? n ? {
1679
1680
  minX: Math.min(t.minX, n.minX),
@@ -1682,23 +1683,23 @@ function mr(t, e) {
1682
1683
  maxY: Math.max(t.maxY, n.maxY)
1683
1684
  } : null : n;
1684
1685
  }
1685
- function Se(t, e = {}) {
1686
+ function Te(t, e = {}) {
1686
1687
  if (t.count <= 0) return [];
1687
- const n = St(t), r = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = e.markLinePositionXy === !0 || e.splitLineweight === !0;
1688
+ const n = Pt(t), r = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = e.markLinePositionXy === !0 || e.splitLineweight === !0;
1688
1689
  for (const y of n) {
1689
1690
  if (y.vertexCount <= 0) continue;
1690
- const f = y.layerIndex, _ = a ? y.lineweightPx : void 0, b = $t(f, _), E = o.get(b);
1691
- E === void 0 ? (o.set(b, y.vertexCount), s.set(b, f), i.set(b, _), r.push(b)) : o.set(b, E + y.vertexCount);
1691
+ const f = y.layerIndex, x = a ? y.lineweightPx : void 0, p = $t(f, x), E = s.get(p);
1692
+ E === void 0 ? (s.set(p, y.vertexCount), o.set(p, f), i.set(p, x), r.push(p)) : s.set(p, E + y.vertexCount);
1692
1693
  }
1693
1694
  const c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), d = e.markLinePositionXy === !0 ? "xy-zero-z" : void 0, h = d ? 2 : 3;
1694
1695
  for (const y of r) {
1695
- const f = s.get(y), _ = i.get(y), b = o.get(y) ?? 0, E = {
1696
+ const f = o.get(y), x = i.get(y), p = s.get(y) ?? 0, E = {
1696
1697
  layerIndex: f,
1697
- ..._ === void 0 ? {} : { lineweightPx: _ },
1698
- pos: new Float32Array(b * h),
1698
+ ...x === void 0 ? {} : { lineweightPx: x },
1699
+ pos: new Float32Array(p * h),
1699
1700
  positionItemSize: h,
1700
- col: new Uint8Array(b * 3),
1701
- count: b,
1701
+ col: new Uint8Array(p * 3),
1702
+ count: p,
1702
1703
  bbox: null,
1703
1704
  colorRuns: []
1704
1705
  };
@@ -1706,36 +1707,36 @@ function Se(t, e = {}) {
1706
1707
  }
1707
1708
  for (const y of n) {
1708
1709
  if (y.vertexCount <= 0) continue;
1709
- const f = y.layerIndex, _ = a ? y.lineweightPx : void 0, b = $t(f, _), E = c.get(b), p = u.get(b), S = p, N = y.color[0], C = y.color[1], G = y.color[2];
1710
+ const f = y.layerIndex, x = a ? y.lineweightPx : void 0, p = $t(f, x), E = c.get(p), b = u.get(p), P = b, N = y.color[0], C = y.color[1], G = y.color[2];
1710
1711
  for (let U = 0; U < y.vertexCount; U += 1) {
1711
- const R = y.startVertex + U, V = p + U, L = V * h, F = V * 3, z = R * 2, $ = t.pos[z], v = t.pos[z + 1];
1712
- E.pos[L] = $, E.pos[L + 1] = v, h === 3 && (E.pos[L + 2] = 0), E.col[F] = N, E.col[F + 1] = C, E.col[F + 2] = G;
1713
- const B = m.get(b);
1714
- !Number.isFinite($) || !Number.isFinite(v) ? g.add(b) : B ? ($ < B.minX && (B.minX = $), v < B.minY && (B.minY = v), $ > B.maxX && (B.maxX = $), v > B.maxY && (B.maxY = v)) : m.set(b, { minX: $, minY: v, maxX: $, maxY: v });
1712
+ const R = y.startVertex + U, V = b + U, F = V * h, X = V * 3, H = R * 2, $ = t.pos[H], M = t.pos[H + 1];
1713
+ E.pos[F] = $, E.pos[F + 1] = M, h === 3 && (E.pos[F + 2] = 0), E.col[X] = N, E.col[X + 1] = C, E.col[X + 2] = G;
1714
+ const B = m.get(p);
1715
+ !Number.isFinite($) || !Number.isFinite(M) ? g.add(p) : B ? ($ < B.minX && (B.minX = $), M < B.minY && (B.minY = M), $ > B.maxX && (B.maxX = $), M > B.maxY && (B.maxY = M)) : m.set(p, { minX: $, minY: M, maxX: $, maxY: M });
1715
1716
  }
1716
1717
  E.colorRuns.push({
1717
- startVertex: S,
1718
+ startVertex: P,
1718
1719
  vertexCount: y.vertexCount,
1719
1720
  color: [N, C, G]
1720
- }), u.set(b, p + y.vertexCount);
1721
+ }), u.set(p, b + y.vertexCount);
1721
1722
  }
1722
1723
  const w = [];
1723
1724
  for (const y of r) {
1724
1725
  const f = c.get(y);
1725
- f && (f.bbox = g.has(y) ? null : mt(m.get(y) ?? null), f.colorRuns = Be(f.colorRuns ?? []), w.push(f));
1726
+ f && (f.bbox = g.has(y) ? null : mt(m.get(y) ?? null), f.colorRuns = $e(f.colorRuns ?? []), w.push(f));
1726
1727
  }
1727
1728
  return w;
1728
1729
  }
1729
1730
  function $t(t, e) {
1730
1731
  return e === void 0 ? `${t}:` : `${t}:${e}`;
1731
1732
  }
1732
- function hr(t, e) {
1733
+ function gr(t, e) {
1733
1734
  return t.append(e);
1734
1735
  }
1735
- function gr(t) {
1736
+ function yr(t) {
1736
1737
  return t.drain();
1737
1738
  }
1738
- function yr(t) {
1739
+ function _r(t) {
1739
1740
  const e = [], n = /* @__PURE__ */ new Set();
1740
1741
  for (const r of t)
1741
1742
  fe(e, n, r.pos.buffer), fe(e, n, r.col.buffer);
@@ -1744,39 +1745,39 @@ function yr(t) {
1744
1745
  function xr(t, e) {
1745
1746
  const n = new Float32Array(e);
1746
1747
  let r = 0;
1747
- for (const o of t)
1748
- n.set(o, r), r += o.length;
1748
+ for (const s of t)
1749
+ n.set(s, r), r += s.length;
1749
1750
  return n;
1750
1751
  }
1751
- function Te(t, e, n) {
1752
+ function Be(t, e, n) {
1752
1753
  if (n === 3) return t;
1753
1754
  const r = new Float32Array(e * 3);
1754
- for (let o = 0; o < e; o += 1) {
1755
- const s = o * 2, i = o * 3;
1756
- r[i] = t[s] ?? 0, r[i + 1] = t[s + 1] ?? 0, r[i + 2] = 0;
1755
+ for (let s = 0; s < e; s += 1) {
1756
+ const o = s * 2, i = s * 3;
1757
+ r[i] = t[o] ?? 0, r[i + 1] = t[o + 1] ?? 0, r[i + 2] = 0;
1757
1758
  }
1758
1759
  return r;
1759
1760
  }
1760
1761
  function le(t) {
1761
1762
  if (t.positionItemSize === 3) return;
1762
1763
  const e = t.positionItemSize;
1763
- t.posParts = t.posParts.map((n) => Te(n, n.length / e, e)), t.positionItemSize = 3, t.linePositionKind = null;
1764
+ t.posParts = t.posParts.map((n) => Be(n, n.length / e, e)), t.positionItemSize = 3, t.linePositionKind = null;
1764
1765
  }
1765
- function _r(t, e) {
1766
+ function Er(t, e) {
1766
1767
  const n = new Uint8Array(e);
1767
1768
  let r = 0;
1768
- for (const o of t)
1769
- n.set(o, r), r += o.length;
1769
+ for (const s of t)
1770
+ n.set(s, r), r += s.length;
1770
1771
  return n;
1771
1772
  }
1772
- function Er(t, e) {
1773
+ function wr(t, e) {
1773
1774
  return t.map((n) => ({
1774
1775
  startVertex: n.startVertex + e,
1775
1776
  vertexCount: n.vertexCount,
1776
1777
  color: [n.color[0], n.color[1], n.color[2]]
1777
1778
  }));
1778
1779
  }
1779
- function Be(t) {
1780
+ function $e(t) {
1780
1781
  const e = [];
1781
1782
  for (const n of t) {
1782
1783
  const r = e[e.length - 1];
@@ -1795,44 +1796,44 @@ function Be(t) {
1795
1796
  }
1796
1797
  return e;
1797
1798
  }
1798
- function wr(t) {
1799
+ function pr(t) {
1799
1800
  const e = Math.floor(t.length / 3), n = [];
1800
1801
  let r = 0;
1801
1802
  for (; r < e; ) {
1802
- const o = r * 3, s = t[o] ?? 0, i = t[o + 1] ?? 0, a = t[o + 2] ?? 0;
1803
+ const s = r * 3, o = t[s] ?? 0, i = t[s + 1] ?? 0, a = t[s + 2] ?? 0;
1803
1804
  let c = r + 1;
1804
1805
  for (; c < e; ) {
1805
1806
  const u = c * 3;
1806
- if (t[u] !== s || t[u + 1] !== i || t[u + 2] !== a) break;
1807
+ if (t[u] !== o || t[u + 1] !== i || t[u + 2] !== a) break;
1807
1808
  c += 1;
1808
1809
  }
1809
- n.push({ startVertex: r, vertexCount: c - r, color: [s, i, a] }), r = c;
1810
+ n.push({ startVertex: r, vertexCount: c - r, color: [o, i, a] }), r = c;
1810
1811
  }
1811
1812
  return n;
1812
1813
  }
1813
1814
  function fe(t, e, n) {
1814
1815
  n instanceof ArrayBuffer && (e.has(n) || (e.add(n), t.push(n)));
1815
1816
  }
1816
- function pr(t, e, n = "u8") {
1817
+ function br(t, e, n = "u8") {
1817
1818
  if (e <= 0 && t.byteLength === 0)
1818
1819
  return { pos: new Float32Array(0), count: 0, segments: [] };
1819
- const { buffer: r, startOffset: o, endOffset: s } = Rr(t), i = new DataView(r), a = we(r, i, o, e, s, n);
1820
- if (a.offset !== s)
1820
+ const { buffer: r, startOffset: s, endOffset: o } = Vr(t), i = new DataView(r), a = pe(r, i, s, e, o, n);
1821
+ if (a.offset !== o)
1821
1822
  throw new l(
1822
1823
  "E_GROUP_RANGE",
1823
- `Insert runtime geometry chunk has trailing bytes: offset=${a.offset - o}, length=${t.byteLength}`
1824
+ `Insert runtime geometry chunk has trailing bytes: offset=${a.offset - s}, length=${t.byteLength}`
1824
1825
  );
1825
1826
  return a.chunk;
1826
1827
  }
1827
- function br(t) {
1828
+ function Ar(t) {
1828
1829
  const e = (n) => {
1829
- const r = t[n], o = pr(
1830
+ const r = t[n], s = br(
1830
1831
  r.raw,
1831
1832
  r.count,
1832
1833
  r.groupLayerEncoding
1833
- ), s = Se(o, { splitLineweight: n === "line" }), i = /* @__PURE__ */ new Map();
1834
- for (const a of s)
1835
- i.set(Ar(a.layerIndex, a.lineweightPx), {
1834
+ ), o = Te(s, { splitLineweight: n === "line" }), i = /* @__PURE__ */ new Map();
1835
+ for (const a of o)
1836
+ i.set(Ir(a.layerIndex, a.lineweightPx), {
1836
1837
  layerIndex: a.layerIndex,
1837
1838
  ...a.lineweightPx === void 0 ? {} : { lineweightPx: a.lineweightPx },
1838
1839
  pos: a.pos,
@@ -1848,17 +1849,17 @@ function br(t) {
1848
1849
  dot: e("dot")
1849
1850
  };
1850
1851
  }
1851
- function Ar(t, e) {
1852
+ function Ir(t, e) {
1852
1853
  return e === void 0 ? `${t}:` : `${t}:${e}`;
1853
1854
  }
1854
- function Ir(t, e) {
1855
+ function Rr(t, e) {
1855
1856
  let n = e ? ot(e) : null;
1856
1857
  for (const r of ["line", "fill", "dot"])
1857
- for (const o of t[r].values())
1858
- n = be(n, o.bbox);
1858
+ for (const s of t[r].values())
1859
+ n = Ae(n, s.bbox);
1859
1860
  return n;
1860
1861
  }
1861
- function Rr(t) {
1862
+ function Vr(t) {
1862
1863
  if (t.buffer instanceof ArrayBuffer)
1863
1864
  return {
1864
1865
  buffer: t.buffer,
@@ -1872,22 +1873,22 @@ function Rr(t) {
1872
1873
  endOffset: e.byteOffset + e.byteLength
1873
1874
  };
1874
1875
  }
1875
- function Vr(t) {
1876
+ function Nr(t) {
1876
1877
  const e = t.insertRuntime;
1877
1878
  if (!e || e.instances.length === 0) return null;
1878
- const n = [], r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
1879
+ const n = [], r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
1879
1880
  for (const c of e.variants) {
1880
- const u = br(c), m = Rt(u.line), g = Rt(u.fill), d = Rt(u.dot), h = m.length > 0 || g.length > 0 || d.length > 0;
1881
- r.set(c.id, h ? Ir(u, null) : null), h && (o.add(c.id), n.push({
1881
+ const u = Ar(c), m = Rt(u.line), g = Rt(u.fill), d = Rt(u.dot), h = m.length > 0 || g.length > 0 || d.length > 0;
1882
+ r.set(c.id, h ? Rr(u, null) : null), h && (s.add(c.id), n.push({
1882
1883
  variantId: c.id,
1883
1884
  line: m,
1884
1885
  fill: g,
1885
1886
  dot: d
1886
1887
  }));
1887
1888
  }
1888
- const s = e.instances.filter((c) => o.has(c.variantId));
1889
- if (s.length === 0) return null;
1890
- const i = Ur(s, r), a = Pr(n, i);
1889
+ const o = e.instances.filter((c) => s.has(c.variantId));
1890
+ if (o.length === 0) return null;
1891
+ const i = Cr(o, r), a = Pr(n, i);
1891
1892
  return {
1892
1893
  variants: n,
1893
1894
  instances: i,
@@ -1895,22 +1896,22 @@ function Vr(t) {
1895
1896
  cost: i.count
1896
1897
  };
1897
1898
  }
1898
- function Nr(t) {
1899
- const e = [], n = /* @__PURE__ */ new Set(), r = (o) => {
1900
- n.has(o) || (n.add(o), e.push(o));
1899
+ function Gr(t) {
1900
+ const e = [], n = /* @__PURE__ */ new Set(), r = (s) => {
1901
+ n.has(s) || (n.add(s), e.push(s));
1901
1902
  };
1902
1903
  r(t.instances.meta.buffer), r(t.instances.mats.buffer), r(t.instances.bboxes.buffer);
1903
- for (const o of t.variants)
1904
- Nt(o.line, r), Nt(o.fill, r), Nt(o.dot, r);
1904
+ for (const s of t.variants)
1905
+ Nt(s.line, r), Nt(s.fill, r), Nt(s.dot, r);
1905
1906
  return e;
1906
1907
  }
1907
1908
  function Rt(t) {
1908
1909
  const e = [];
1909
1910
  for (const n of t.values())
1910
- n.count <= 0 || e.push(Gr(n));
1911
+ n.count <= 0 || e.push(Ur(n));
1911
1912
  return e;
1912
1913
  }
1913
- function Gr(t) {
1914
+ function Ur(t) {
1914
1915
  return {
1915
1916
  pos: t.pos,
1916
1917
  col: t.col,
@@ -1920,19 +1921,19 @@ function Gr(t) {
1920
1921
  bbox: t.bbox
1921
1922
  };
1922
1923
  }
1923
- function Ur(t, e) {
1924
- const n = t.length, r = new Uint32Array(n * 3), o = new Float32Array(n * 6), s = new Float32Array(n * 4);
1924
+ function Cr(t, e) {
1925
+ const n = t.length, r = new Uint32Array(n * 3), s = new Float32Array(n * 6), o = new Float32Array(n * 4);
1925
1926
  for (let i = 0; i < n; i += 1) {
1926
1927
  const a = t[i], c = i * 3;
1927
1928
  r[c] = a.instanceId, r[c + 1] = a.variantId, r[c + 2] = a.insLayerIdx;
1928
1929
  const u = i * 6;
1929
- o[u] = a.matA, o[u + 1] = a.matB, o[u + 2] = a.matC, o[u + 3] = a.matD, o[u + 4] = a.tx, o[u + 5] = a.ty;
1930
- const m = cr(e.get(a.variantId) ?? null, a);
1931
- Cr(s, i * 4, m);
1930
+ s[u] = a.matA, s[u + 1] = a.matB, s[u + 2] = a.matC, s[u + 3] = a.matD, s[u + 4] = a.tx, s[u + 5] = a.ty;
1931
+ const m = ur(e.get(a.variantId) ?? null, a);
1932
+ Sr(o, i * 4, m);
1932
1933
  }
1933
- return { meta: r, mats: o, bboxes: s, count: n };
1934
+ return { meta: r, mats: s, bboxes: o, count: n };
1934
1935
  }
1935
- function Cr(t, e, n) {
1936
+ function Sr(t, e, n) {
1936
1937
  if (!n) {
1937
1938
  t[e] = Number.POSITIVE_INFINITY, t[e + 1] = Number.POSITIVE_INFINITY, t[e + 2] = Number.NEGATIVE_INFINITY, t[e + 3] = Number.NEGATIVE_INFINITY;
1938
1939
  return;
@@ -1955,13 +1956,13 @@ function Nt(t, e) {
1955
1956
  function de() {
1956
1957
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1957
1958
  }
1958
- class Sr {
1959
+ class Tr {
1959
1960
  constructor() {
1960
- J(this, "geometryCredits", 0);
1961
- J(this, "textCredits", 0);
1962
- J(this, "cancelled", !1);
1963
- J(this, "geometryWaiters", []);
1964
- J(this, "textWaiters", []);
1961
+ Z(this, "geometryCredits", 0);
1962
+ Z(this, "textCredits", 0);
1963
+ Z(this, "cancelled", !1);
1964
+ Z(this, "geometryWaiters", []);
1965
+ Z(this, "textWaiters", []);
1965
1966
  }
1966
1967
  grant(e) {
1967
1968
  this.cancelled || (this.geometryCredits += Math.max(0, e.geometryCredits), this.textCredits += Math.max(0, e.textCredits), this.flushWaiters());
@@ -2005,91 +2006,91 @@ class Sr {
2005
2006
  return e === "geometry" ? this.geometryWaiters : this.textWaiters;
2006
2007
  }
2007
2008
  }
2008
- const me = 262144, Tr = Number.MAX_SAFE_INTEGER, he = 524288, Br = Number.MAX_SAFE_INTEGER, $r = 5e6, Or = 64, Q = self;
2009
- let Y = null;
2009
+ const me = 262144, Br = Number.MAX_SAFE_INTEGER, he = 524288, $r = Number.MAX_SAFE_INTEGER, Or = 5e6, Mr = 64, z = self;
2010
+ let k = null, ge = null;
2010
2011
  async function Gt(t, e, n) {
2011
- const r = gr(e);
2012
+ const r = yr(e);
2012
2013
  if (!r.length || !await n.take("geometry")) return 0;
2013
- const s = r.reduce((a, c) => a + c.count, 0), i = {
2014
+ const o = r.reduce((a, c) => a + c.count, 0), i = {
2014
2015
  type: "geometry",
2015
2016
  kind: t,
2016
2017
  layers: r,
2017
- cost: s
2018
+ cost: o
2018
2019
  };
2019
- return Q.postMessage(i, yr(r)), s;
2020
+ return z.postMessage(i, _r(r)), o;
2020
2021
  }
2021
2022
  async function vr(t, e) {
2022
2023
  return await Gt("line", t.line, e) + await Gt("fill", t.fill, e) + await Gt("dot", t.dot, e);
2023
2024
  }
2024
- async function ge(t, e) {
2025
+ async function ye(t, e) {
2025
2026
  if (!t.length || !await e.take("text")) return 0;
2026
2027
  const r = t.slice();
2027
2028
  t.length = 0;
2028
- const o = {
2029
+ const s = {
2029
2030
  type: "text",
2030
2031
  texts: r,
2031
2032
  cost: r.length
2032
2033
  };
2033
- return Q.postMessage(o), r.length;
2034
+ return z.postMessage(s), r.length;
2034
2035
  }
2035
- function Mr(t) {
2036
+ function Dr(t) {
2036
2037
  return t.lineCount + t.fillCount + t.dotCount;
2037
2038
  }
2038
- function Dr(t, e) {
2039
- return Mr(t) >= $r ? {
2039
+ function kr(t, e) {
2040
+ return Dr(t) >= Or ? {
2040
2041
  initial: he,
2041
- steady: e ? he : Br
2042
+ steady: e ? he : $r
2042
2043
  } : {
2043
2044
  initial: me,
2044
- steady: e ? me : Tr
2045
+ steady: e ? me : Br
2045
2046
  };
2046
2047
  }
2047
- function kr(t) {
2048
+ function Lr(t) {
2048
2049
  return t instanceof Error ? t : new Error(String(t));
2049
2050
  }
2050
- function Lr(t) {
2051
+ function Fr(t) {
2051
2052
  if (!(!t || t.length === 0))
2052
2053
  return new Map(t.map((e) => [e.variantId, e.buffer]));
2053
2054
  }
2054
- function Fr(t) {
2055
+ function Xr(t) {
2055
2056
  if (t !== void 0)
2056
2057
  return new Set(t);
2057
2058
  }
2058
- async function Xr(t, e, n) {
2059
- const r = Lr(e);
2059
+ async function Yr(t, e, n) {
2060
+ const r = Fr(e);
2060
2061
  if (!t || !n || n.length === 0)
2061
2062
  return r;
2062
- const o = Array.from(new Set(n)).filter((a) => !(r != null && r.has(a))).sort((a, c) => a - c);
2063
- if (o.length === 0)
2063
+ const s = Array.from(new Set(n)).filter((a) => !(r != null && r.has(a))).sort((a, c) => a - c);
2064
+ if (s.length === 0)
2064
2065
  return r;
2065
- const s = await ur({
2066
+ const o = await lr({
2066
2067
  baseUrl: t.baseUrl,
2067
2068
  entries: t.entries,
2068
- requiredVariantIds: o
2069
+ requiredVariantIds: s
2069
2070
  }), i = new Map(r ?? []);
2070
- for (const [a, c] of s.buffers)
2071
+ for (const [a, c] of o.buffers)
2071
2072
  i.set(a, c);
2072
2073
  return i;
2073
2074
  }
2074
- async function Yr(t, e, n, r, o = !0, s, i, a, c, u, m, g, d) {
2075
- const h = dr(), w = [];
2075
+ async function zr(t, e, n, r, s = !0, o, i, a, c, u, m, g, d) {
2076
+ const h = mr(), w = [];
2076
2077
  let y = 0, f = !1;
2077
- const _ = c === !0, b = typeof i == "number" && Number.isFinite(i) && i >= 0, E = await Xr(
2078
+ const x = c === !0, p = typeof i == "number" && Number.isFinite(i) && i >= 0, E = await Yr(
2078
2079
  a,
2079
2080
  u,
2080
2081
  g
2081
- ), p = Fr(m), S = n && n.length > 0 || r === !0 || o === !1 || s === !0 || b || _ || E || p !== void 0 || d === !0 ? {
2082
+ ), b = Xr(m), P = n && n.length > 0 || r === !0 || s === !1 || o === !0 || p || x || E || b !== void 0 || d === !0 ? {
2082
2083
  ...n && n.length > 0 ? { hiddenInstanceIds: new Set(n) } : {},
2083
2084
  ...r === !0 ? { keepTextsForHiddenInstances: !0 } : {},
2084
- ...o === !1 ? { loadBlocks: !1 } : {},
2085
- ...s === !0 ? { suppressExpandedInsertGeometry: !0 } : {},
2086
- ...b ? { maxExpandedInstanceVertices: i } : {},
2087
- ..._ ? { deferExternalVariantGeometry: !0 } : {},
2085
+ ...s === !1 ? { loadBlocks: !1 } : {},
2086
+ ...o === !0 ? { suppressExpandedInsertGeometry: !0 } : {},
2087
+ ...p ? { maxExpandedInstanceVertices: i } : {},
2088
+ ...x ? { deferExternalVariantGeometry: !0 } : {},
2088
2089
  ...E ? { externalVariantBuffers: E } : {},
2089
- ...p !== void 0 ? { requiredExternalVariantIds: p } : {},
2090
+ ...b !== void 0 ? { requiredExternalVariantIds: b } : {},
2090
2091
  ...d === !0 ? { externalVariantDeltaOnly: !0 } : {}
2091
- } : void 0, N = ar(t, S), C = Dr(N.header, d === !0);
2092
- Q.postMessage({
2092
+ } : void 0, N = cr(t, P), C = kr(N.header, d === !0);
2093
+ z.postMessage({
2093
2094
  type: "header",
2094
2095
  header: N.header
2095
2096
  });
@@ -2099,19 +2100,19 @@ async function Yr(t, e, n, r, o = !0, s, i, a, c, u, m, g, d) {
2099
2100
  };
2100
2101
  for (const V of N.chunks) {
2101
2102
  if (V.kind === "text") {
2102
- w.push(V.payload), w.length >= Or && await ge(w, e);
2103
+ w.push(V.payload), w.length >= Mr && await ye(w, e);
2103
2104
  continue;
2104
2105
  }
2105
- const L = Se(V.payload, {
2106
+ const F = Te(V.payload, {
2106
2107
  markLinePositionXy: V.kind === "line"
2107
2108
  });
2108
- y += hr(h[V.kind], L);
2109
- const F = f ? C.steady : C.initial;
2110
- y >= F && await G();
2109
+ y += gr(h[V.kind], F);
2110
+ const X = f ? C.steady : C.initial;
2111
+ y >= X && await G();
2111
2112
  }
2112
- await G(), await ge(w, e), Q.postMessage({ type: "done" });
2113
- const U = de(), R = Vr(N.header);
2114
- R && Q.postMessage(
2113
+ await G(), await ye(w, e), z.postMessage({ type: "done" });
2114
+ const U = de(), R = Nr(N.header);
2115
+ R && z.postMessage(
2115
2116
  {
2116
2117
  type: "insertModel",
2117
2118
  variants: R.variants,
@@ -2120,27 +2121,50 @@ async function Yr(t, e, n, r, o = !0, s, i, a, c, u, m, g, d) {
2120
2121
  bytes: R.bytes,
2121
2122
  planMs: de() - U
2122
2123
  },
2123
- Nr(R)
2124
- ), Q.postMessage({ type: "complete" });
2124
+ Gr(R)
2125
+ ), z.postMessage({ type: "complete" });
2125
2126
  }
2126
2127
  self.addEventListener("message", (t) => {
2127
2128
  const e = t.data;
2128
2129
  if (!e) return;
2129
2130
  if (e.type === "grant") {
2130
- Y == null || Y.grant({
2131
+ k == null || k.grant({
2131
2132
  geometryCredits: e.geometryCredits,
2132
2133
  textCredits: e.textCredits
2133
2134
  });
2134
2135
  return;
2135
2136
  }
2136
2137
  if (e.type === "cancel") {
2137
- Y == null || Y.cancel();
2138
+ k == null || k.cancel();
2138
2139
  return;
2139
2140
  }
2140
2141
  if (e.type !== "parse") return;
2141
- const n = new Sr();
2142
- Y = n, Yr(
2143
- e.buffer,
2142
+ const n = new Tr();
2143
+ k = n;
2144
+ const r = e.useRetainedMainBuffer === !0;
2145
+ if (r && e.buffer !== void 0) {
2146
+ const o = new Error("Geo prepare worker parse request cannot include both a retained and transferred main buffer");
2147
+ o.code = "E_MAIN_BUFFER_PROTOCOL", z.postMessage({
2148
+ type: "error",
2149
+ message: o.message,
2150
+ code: "E_MAIN_BUFFER_PROTOCOL"
2151
+ }), k = null;
2152
+ return;
2153
+ }
2154
+ const s = r ? ge : e.buffer;
2155
+ if (!s) {
2156
+ const o = new Error(
2157
+ r ? "Geo prepare worker has no retained main buffer for this delta parse" : "Geo prepare worker parse request is missing its main buffer"
2158
+ );
2159
+ o.code = "E_MAIN_BUFFER_MISSING", z.postMessage({
2160
+ type: "error",
2161
+ message: o.message,
2162
+ code: "E_MAIN_BUFFER_MISSING"
2163
+ }), k = null;
2164
+ return;
2165
+ }
2166
+ r || (ge = s), zr(
2167
+ s,
2144
2168
  n,
2145
2169
  e.hiddenInstanceIds,
2146
2170
  e.keepTextsForHiddenInstances,
@@ -2153,14 +2177,14 @@ self.addEventListener("message", (t) => {
2153
2177
  e.requiredExternalVariantIds,
2154
2178
  e.externalVariantGeometryFetchIds,
2155
2179
  e.externalVariantDeltaOnly
2156
- ).catch((r) => {
2157
- const o = kr(r), s = o.code;
2158
- Q.postMessage({
2180
+ ).catch((o) => {
2181
+ const i = Lr(o), a = i.code;
2182
+ z.postMessage({
2159
2183
  type: "error",
2160
- message: o.message,
2161
- code: typeof s == "string" ? s : void 0
2184
+ message: i.message,
2185
+ code: typeof a == "string" ? a : void 0
2162
2186
  });
2163
2187
  }).finally(() => {
2164
- Y === n && (Y = null);
2188
+ k === n && (k = null);
2165
2189
  });
2166
2190
  });