@nebula-spatial/cad-loader 0.2.2 → 0.2.4

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,149 +1,149 @@
1
- var ae = Object.defineProperty;
2
- var ie = (t, n, e) => n in t ? ae(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var mn = (t, n, e) => ie(t, typeof n != "symbol" ? n + "" : n, e);
4
- class l extends Error {
1
+ var xe = Object.defineProperty;
2
+ var ge = (t, n, e) => n in t ? xe(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var gn = (t, n, e) => ge(t, typeof n != "symbol" ? n + "" : n, e);
4
+ class u extends Error {
5
5
  constructor(e, o) {
6
6
  super(o);
7
- mn(this, "code");
7
+ gn(this, "code");
8
8
  this.name = "GeoLoaderError", this.code = e;
9
9
  }
10
10
  }
11
- const Lt = 4096;
12
- function To(t, n, e, o, a = "u8") {
11
+ const Yt = 4096;
12
+ function Oo(t, n, e, o, i = "u8") {
13
13
  return {
14
14
  count: o,
15
15
  raw: new Uint8Array(t, n, e - n).slice(),
16
- groupLayerEncoding: a
16
+ groupLayerEncoding: i
17
17
  };
18
18
  }
19
- function Wt(t) {
19
+ function Qt(t) {
20
20
  return t >= 6 ? "u16_lw" : t >= 5 ? "u8_lw" : t >= 4 ? "u16" : "u8";
21
21
  }
22
- function In(t) {
22
+ function bn(t) {
23
23
  return t === "u16_lw" ? 13 : t === "u8_lw" ? 12 : t === "u16" ? 9 : 8;
24
24
  }
25
- function Gn(t, n, e) {
25
+ function Bn(t, n, e) {
26
26
  return e === "u16" || e === "u16_lw" ? t.getUint16(n + 7, !0) : t.getUint8(n + 7);
27
27
  }
28
- function se(t) {
28
+ function he(t) {
29
29
  return t === "u16" || t === "u16_lw" ? 2 : 1;
30
30
  }
31
- function Vn(t, n, e) {
31
+ function Un(t, n, e) {
32
32
  if (!(e !== "u8_lw" && e !== "u16_lw"))
33
- return t.getFloat32(n + 7 + se(e), !0);
34
- }
35
- function lt(t, n, e, o, a = t.byteLength, r = "u8") {
36
- if (e > a || a > t.byteLength)
37
- throw new l("E_GROUP_RANGE", "Group byte range exceeds payload length");
38
- let i = e;
39
- const c = o * 2, s = c * 4;
40
- if (i + s > a)
41
- throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
42
- let u;
43
- if (c > 0) {
44
- const w = new Uint8Array(t, i, s), y = new Uint8Array(s), m = c;
45
- for (let x = 0; x < c; x++)
46
- y[x * 4] = w[x], y[x * 4 + 1] = w[m + x], y[x * 4 + 2] = w[m * 2 + x], y[x * 4 + 3] = w[m * 3 + x];
47
- u = new Float32Array(y.buffer);
33
+ return t.getFloat32(n + 7 + he(e), !0);
34
+ }
35
+ function ft(t, n, e, o, i = t.byteLength, r = "u8") {
36
+ if (e > i || i > t.byteLength)
37
+ throw new u("E_GROUP_RANGE", "Group byte range exceeds payload length");
38
+ let s = e;
39
+ const l = o * 2, a = l * 4;
40
+ if (s + a > i)
41
+ throw new u("E_GROUP_RANGE", "Group position bytes exceed payload length");
42
+ let c;
43
+ if (l > 0) {
44
+ const A = new Uint8Array(t, s, a), y = new Uint8Array(a), x = l;
45
+ for (let h = 0; h < l; h++)
46
+ y[h * 4] = A[h], y[h * 4 + 1] = A[x + h], y[h * 4 + 2] = A[x * 2 + h], y[h * 4 + 3] = A[x * 3 + h];
47
+ c = new Float32Array(y.buffer);
48
48
  } else
49
- u = new Float32Array(0);
50
- if (i += s, i + 4 > a)
51
- throw new l("E_GROUP_RANGE", "Missing seg_count field for group");
52
- const h = n.getUint32(i, !0);
53
- i += 4;
54
- const d = [];
55
- let _ = 0;
56
- const f = In(r);
57
- for (let w = 0; w < h; w++) {
58
- if (i + f > a)
59
- throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
60
- const y = n.getUint32(i, !0), m = n.getUint8(i + 4), x = n.getUint8(i + 5), G = n.getUint8(i + 6), N = Gn(n, i, r), R = Vn(n, i, r);
61
- if (_ + y > o)
62
- throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
63
- d.push({
64
- startVertex: _,
49
+ c = new Float32Array(0);
50
+ if (s += a, s + 4 > i)
51
+ throw new u("E_GROUP_RANGE", "Missing seg_count field for group");
52
+ const _ = n.getUint32(s, !0);
53
+ s += 4;
54
+ const f = [];
55
+ let d = 0;
56
+ const m = bn(r);
57
+ for (let A = 0; A < _; A++) {
58
+ if (s + m > i)
59
+ throw new u("E_GROUP_RANGE", "Segment record exceeds payload length");
60
+ const y = n.getUint32(s, !0), x = n.getUint8(s + 4), h = n.getUint8(s + 5), R = n.getUint8(s + 6), w = Bn(n, s, r), p = Un(n, s, r);
61
+ if (d + y > o)
62
+ throw new u("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
63
+ f.push({
64
+ startVertex: d,
65
65
  vertexCount: y,
66
- color: [m, x, G],
67
- layerIndex: N,
68
- ...R === void 0 ? {} : { lineweightPx: R }
69
- }), i += f;
70
- const P = _ * 2;
66
+ color: [x, h, R],
67
+ layerIndex: w,
68
+ ...p === void 0 ? {} : { lineweightPx: p }
69
+ }), s += m;
70
+ const v = d * 2;
71
71
  if (y > 1) {
72
- let B = u[P], D = u[P + 1];
73
- for (let C = 1; C < y; C++) {
74
- const $ = P + C * 2;
75
- B += u[$], D += u[$ + 1], u[$] = B, u[$ + 1] = D;
72
+ let U = c[v], D = c[v + 1];
73
+ for (let $ = 1; $ < y; $++) {
74
+ const M = v + $ * 2;
75
+ U += c[M], D += c[M + 1], c[M] = U, c[M + 1] = D;
76
76
  }
77
77
  }
78
- _ += y;
78
+ d += y;
79
79
  }
80
- if (_ !== o)
81
- throw new l("E_SEGMENT_SUM", `Segment vertex_count sum ${_} does not match group count ${o}`);
80
+ if (d !== o)
81
+ throw new u("E_SEGMENT_SUM", `Segment vertex_count sum ${d} does not match group count ${o}`);
82
82
  return {
83
- chunk: { pos: u, count: o, segments: d },
84
- offset: i
83
+ chunk: { pos: c, count: o, segments: f },
84
+ offset: s
85
85
  };
86
86
  }
87
- function ce(t, n, e, o, a = "u8") {
88
- const r = o * 2, i = r * 4;
89
- if (e + i > t.byteLength)
90
- throw new l("E_GROUP_RANGE", "Group position bytes exceed payload length");
91
- const c = new Uint8Array(t, e, i);
92
- let s = e + i;
93
- if (s + 4 > t.byteLength)
94
- throw new l("E_GROUP_RANGE", "Missing seg_count field for group");
95
- const u = n.getUint32(s, !0);
96
- s += 4;
97
- const h = [];
98
- let d = 0;
99
- const _ = In(a);
100
- for (let f = 0; f < u; f++) {
101
- if (s + _ > t.byteLength)
102
- throw new l("E_GROUP_RANGE", "Segment record exceeds payload length");
103
- const w = n.getUint32(s, !0), y = n.getUint8(s + 4), m = n.getUint8(s + 5), x = n.getUint8(s + 6), G = Gn(n, s, a), N = Vn(n, s, a);
104
- if (s += _, d + w > o)
105
- throw new l("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
106
- h.push({
107
- startVertex: d,
108
- vertexCount: w,
109
- color: [y, m, x],
110
- layerIndex: G,
111
- ...N === void 0 ? {} : { lineweightPx: N }
112
- }), d += w;
87
+ function ye(t, n, e, o, i = "u8") {
88
+ const r = o * 2, s = r * 4;
89
+ if (e + s > t.byteLength)
90
+ throw new u("E_GROUP_RANGE", "Group position bytes exceed payload length");
91
+ const l = new Uint8Array(t, e, s);
92
+ let a = e + s;
93
+ if (a + 4 > t.byteLength)
94
+ throw new u("E_GROUP_RANGE", "Missing seg_count field for group");
95
+ const c = n.getUint32(a, !0);
96
+ a += 4;
97
+ const _ = [];
98
+ let f = 0;
99
+ const d = bn(i);
100
+ for (let m = 0; m < c; m++) {
101
+ if (a + d > t.byteLength)
102
+ throw new u("E_GROUP_RANGE", "Segment record exceeds payload length");
103
+ const A = n.getUint32(a, !0), y = n.getUint8(a + 4), x = n.getUint8(a + 5), h = n.getUint8(a + 6), R = Bn(n, a, i), w = Un(n, a, i);
104
+ if (a += d, f + A > o)
105
+ throw new u("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
106
+ _.push({
107
+ startVertex: f,
108
+ vertexCount: A,
109
+ color: [y, x, h],
110
+ layerIndex: R,
111
+ ...w === void 0 ? {} : { lineweightPx: w }
112
+ }), f += A;
113
113
  }
114
- if (d !== o)
115
- throw new l("E_SEGMENT_SUM", `Segment vertex_count sum ${d} does not match group count ${o}`);
114
+ if (f !== o)
115
+ throw new u("E_SEGMENT_SUM", `Segment vertex_count sum ${f} does not match group count ${o}`);
116
116
  return {
117
- shuffled: c,
117
+ shuffled: l,
118
118
  plane: r,
119
- segments: h,
120
- offset: s
119
+ segments: _,
120
+ offset: a
121
121
  };
122
122
  }
123
- function le(t, n, e, o) {
123
+ function we(t, n, e, o) {
124
124
  if (o === 0)
125
125
  return new Float32Array(0);
126
- const a = new Uint8Array(o * 4);
126
+ const i = new Uint8Array(o * 4);
127
127
  for (let r = 0; r < o; r++)
128
- a[r * 4] = t[e + r], a[r * 4 + 1] = t[n + e + r], a[r * 4 + 2] = t[n * 2 + e + r], a[r * 4 + 3] = t[n * 3 + e + r];
129
- return new Float32Array(a.buffer);
128
+ i[r * 4] = t[e + r], i[r * 4 + 1] = t[n + e + r], i[r * 4 + 2] = t[n * 2 + e + r], i[r * 4 + 3] = t[n * 3 + e + r];
129
+ return new Float32Array(i.buffer);
130
130
  }
131
- function ue(t, n, e, o, a) {
132
- const r = le(
131
+ function Ae(t, n, e, o, i) {
132
+ const r = we(
133
133
  t.shuffled,
134
134
  t.plane,
135
135
  (n.startVertex + e) * 2,
136
136
  o * 2
137
137
  );
138
- let i = (a == null ? void 0 : a[0]) ?? 0, c = (a == null ? void 0 : a[1]) ?? 0;
138
+ let s = (i == null ? void 0 : i[0]) ?? 0, l = (i == null ? void 0 : i[1]) ?? 0;
139
139
  if (o > 0) {
140
- e === 0 ? (i = r[0], c = r[1]) : (i += r[0], c += r[1], r[0] = i, r[1] = c);
141
- for (let u = 1; u < o; u++) {
142
- const h = u * 2;
143
- i += r[h], c += r[h + 1], r[h] = i, r[h + 1] = c;
140
+ e === 0 ? (s = r[0], l = r[1]) : (s += r[0], l += r[1], r[0] = s, r[1] = l);
141
+ for (let c = 1; c < o; c++) {
142
+ const _ = c * 2;
143
+ s += r[_], l += r[_ + 1], r[_] = s, r[_ + 1] = l;
144
144
  }
145
145
  }
146
- const s = o > 0 ? [{
146
+ const a = o > 0 ? [{
147
147
  startVertex: 0,
148
148
  vertexCount: o,
149
149
  color: [n.color[0], n.color[1], n.color[2]],
@@ -151,30 +151,30 @@ function ue(t, n, e, o, a) {
151
151
  ...n.lineweightPx === void 0 ? {} : { lineweightPx: n.lineweightPx }
152
152
  }] : [];
153
153
  return {
154
- chunk: { pos: r, count: o, segments: s },
155
- lastPoint: o > 0 ? [i, c] : a
154
+ chunk: { pos: r, count: o, segments: a },
155
+ lastPoint: o > 0 ? [s, l] : i
156
156
  };
157
157
  }
158
- function* de(t, n, e, o, a = "u8") {
159
- const r = ce(t, n, e, o, a);
158
+ function* Re(t, n, e, o, i = "u8") {
159
+ const r = ye(t, n, e, o, i);
160
160
  if (o === 0)
161
161
  return yield { pos: new Float32Array(0), count: 0, segments: [] }, r.offset;
162
- for (const i of r.segments) {
163
- let c = null;
164
- for (let s = 0; s < i.vertexCount; s += Lt) {
165
- const u = Math.min(Lt, i.vertexCount - s), h = ue(r, i, s, u, c);
166
- c = h.lastPoint, yield h.chunk;
162
+ for (const s of r.segments) {
163
+ let l = null;
164
+ for (let a = 0; a < s.vertexCount; a += Yt) {
165
+ const c = Math.min(Yt, s.vertexCount - a), _ = Ae(r, s, a, c, l);
166
+ l = _.lastPoint, yield _.chunk;
167
167
  }
168
168
  }
169
169
  return r.offset;
170
170
  }
171
- function Tn() {
171
+ function Sn() {
172
172
  const t = globalThis.TextDecoder;
173
173
  if (!t)
174
- throw new l("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
174
+ throw new u("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
175
175
  return new t();
176
176
  }
177
- function Yt(t) {
177
+ function Ft(t) {
178
178
  return t ? {
179
179
  minX: t.minX,
180
180
  minY: t.minY,
@@ -182,73 +182,73 @@ function Yt(t) {
182
182
  maxY: t.maxY
183
183
  } : null;
184
184
  }
185
- function Ft(t) {
185
+ function zt(t) {
186
186
  return !!t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY);
187
187
  }
188
- function fe(t) {
189
- return Ft(t) ? Yt(t) : null;
188
+ function Ne(t) {
189
+ return zt(t) ? Ft(t) : null;
190
190
  }
191
- function me(t, n) {
192
- const e = Ft(t) ? t : null, o = Ft(n) ? n : null;
191
+ function pe(t, n) {
192
+ const e = zt(t) ? t : null, o = zt(n) ? n : null;
193
193
  return e ? o ? {
194
194
  minX: Math.min(e.minX, o.minX),
195
195
  minY: Math.min(e.minY, o.minY),
196
196
  maxX: Math.max(e.maxX, o.maxX),
197
197
  maxY: Math.max(e.maxY, o.maxY)
198
- } : Yt(e) : Yt(o);
198
+ } : Ft(e) : Ft(o);
199
199
  }
200
- function bn(t, n) {
200
+ function Cn(t, n) {
201
201
  return !(n.maxX < t.minX || n.minX > t.maxX || n.maxY < t.minY || n.minY > t.maxY);
202
202
  }
203
- function bo(t, n) {
203
+ function $o(t, n) {
204
204
  return t.minX <= n.minX && t.minY <= n.minY && t.maxX >= n.maxX && t.maxY >= n.maxY;
205
205
  }
206
- function Bo(t, n) {
206
+ function Mo(t, n) {
207
207
  return t === n ? !0 : !t || !n ? !1 : t.minX === n.minX && t.minY === n.minY && t.maxX === n.maxX && t.maxY === n.maxY;
208
208
  }
209
- function _e(t, n) {
210
- return bn(t, n) ? {
209
+ function Ie(t, n) {
210
+ return Cn(t, n) ? {
211
211
  minX: Math.max(t.minX, n.minX),
212
212
  minY: Math.max(t.minY, n.minY),
213
213
  maxX: Math.min(t.maxX, n.maxX),
214
214
  maxY: Math.min(t.maxY, n.maxY)
215
215
  } : null;
216
216
  }
217
- function he(t, n) {
218
- const e = Number.isFinite(n) ? Math.max(0, n) : 0, o = Math.max(0, t.maxX - t.minX), a = Math.max(0, t.maxY - t.minY), r = o * e, i = a * e;
217
+ function Ve(t, n) {
218
+ const e = Number.isFinite(n) ? Math.max(0, n) : 0, o = Math.max(0, t.maxX - t.minX), i = Math.max(0, t.maxY - t.minY), r = o * e, s = i * e;
219
219
  return {
220
220
  minX: t.minX - r,
221
- minY: t.minY - i,
221
+ minY: t.minY - s,
222
222
  maxX: t.maxX + r,
223
- maxY: t.maxY + i
223
+ maxY: t.maxY + s
224
224
  };
225
225
  }
226
- function Ee(t, n, e, o = 0, a = 1) {
226
+ function Ge(t, n, e, o = 0, i = 1) {
227
227
  if (n <= 0 || e <= 0) return null;
228
- let r = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, s = Number.NEGATIVE_INFINITY, u = !1;
229
- for (let h = 0; h < n; h += 1) {
230
- const d = h * e, _ = t[d + o], f = t[d + a];
231
- !Number.isFinite(_) || !Number.isFinite(f) || (_ < r && (r = _), f < i && (i = f), _ > c && (c = _), f > s && (s = f), u = !0);
228
+ let r = Number.POSITIVE_INFINITY, s = Number.POSITIVE_INFINITY, l = Number.NEGATIVE_INFINITY, a = Number.NEGATIVE_INFINITY, c = !1;
229
+ for (let _ = 0; _ < n; _ += 1) {
230
+ const f = _ * e, d = t[f + o], m = t[f + i];
231
+ !Number.isFinite(d) || !Number.isFinite(m) || (d < r && (r = d), m < s && (s = m), d > l && (l = d), m > a && (a = m), c = !0);
232
232
  }
233
- return u ? { minX: r, minY: i, maxX: c, maxY: s } : null;
233
+ return c ? { minX: r, minY: s, maxX: l, maxY: a } : null;
234
234
  }
235
- function Bn(t, n) {
236
- const e = t.minX, o = t.minY, a = t.maxX, r = t.maxY, { matA: i, matB: c, matC: s, matD: u, tx: h, ty: d } = n;
237
- let _ = i * e + s * o + h, f = c * e + u * o + d, w = _, y = f, m = _, x = f;
238
- return _ = i * e + s * r + h, f = c * e + u * r + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), _ = i * a + s * o + h, f = c * a + u * o + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), _ = i * a + s * r + h, f = c * a + u * r + d, _ < w && (w = _), f < y && (y = f), _ > m && (m = _), f > x && (x = f), { minX: w, minY: y, maxX: m, maxY: x };
235
+ function On(t, n) {
236
+ const e = t.minX, o = t.minY, i = t.maxX, r = t.maxY, { matA: s, matB: l, matC: a, matD: c, tx: _, ty: f } = n;
237
+ let d = s * e + a * o + _, m = l * e + c * o + f, A = d, y = m, x = d, h = m;
238
+ return d = s * e + a * r + _, m = l * e + c * r + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), d = s * i + a * o + _, m = l * i + c * o + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), d = s * i + a * r + _, m = l * i + c * r + f, d < A && (A = d), m < y && (y = m), d > x && (x = d), m > h && (h = m), { minX: A, minY: y, maxX: x, maxY: h };
239
239
  }
240
- function xe(t) {
240
+ function Te(t) {
241
241
  return Math.hypot(t.maxX - t.minX, t.maxY - t.minY);
242
242
  }
243
- function ge(t, n) {
244
- const e = (t.minX + t.maxX) / 2, o = (t.minY + t.maxY) / 2, a = (n.minX + n.maxX) / 2, r = (n.minY + n.maxY) / 2;
245
- return Math.hypot(e - a, o - r);
243
+ function be(t, n) {
244
+ const e = (t.minX + t.maxX) / 2, o = (t.minY + t.maxY) / 2, i = (n.minX + n.maxX) / 2, r = (n.minY + n.maxY) / 2;
245
+ return Math.hypot(e - i, o - r);
246
246
  }
247
- const ye = {};
248
- function _n(t) {
247
+ const Be = {};
248
+ function hn(t) {
249
249
  return typeof t == "object" && t !== null;
250
250
  }
251
- function gt(t, n) {
251
+ function yt(t, n) {
252
252
  return Object.prototype.hasOwnProperty.call(t, n);
253
253
  }
254
254
  function J(t) {
@@ -263,10 +263,10 @@ function J(t) {
263
263
  }
264
264
  return n;
265
265
  }
266
- function hn(t, n, e, o) {
267
- return new l("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${n} path=${e}: ${o}`);
266
+ function yn(t, n, e, o) {
267
+ return new u("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${n} path=${e}: ${o}`);
268
268
  }
269
- function kt(t, n, e) {
269
+ function Ht(t, n, e) {
270
270
  if (Object.is(t, n)) return null;
271
271
  if (Array.isArray(t)) {
272
272
  if (!Array.isArray(n))
@@ -274,211 +274,211 @@ function kt(t, n, e) {
274
274
  if (t.length !== n.length)
275
275
  return { path: J([...e, "length"]), reason: `array length ${t.length} !== ${n.length}` };
276
276
  for (let o = 0; o < t.length; o += 1) {
277
- const a = kt(t[o], n[o], [...e, o]);
278
- if (a) return a;
277
+ const i = Ht(t[o], n[o], [...e, o]);
278
+ if (i) return i;
279
279
  }
280
280
  return null;
281
281
  }
282
- if (_n(t)) {
283
- if (!_n(n) || Array.isArray(n))
282
+ if (hn(t)) {
283
+ if (!hn(n) || Array.isArray(n))
284
284
  return { path: J(e), reason: `expected object but found ${Array.isArray(n) ? "array" : typeof n}` };
285
- const o = Object.keys(t), a = Object.keys(n);
286
- if (o.length !== a.length) {
287
- const r = o.find((c) => !gt(n, c));
285
+ const o = Object.keys(t), i = Object.keys(n);
286
+ if (o.length !== i.length) {
287
+ const r = o.find((l) => !yt(n, l));
288
288
  if (r !== void 0)
289
289
  return {
290
290
  path: J([...e, r]),
291
291
  reason: "missing key on actual"
292
292
  };
293
- const i = a.find((c) => !gt(t, c));
294
- if (i !== void 0)
293
+ const s = i.find((l) => !yt(t, l));
294
+ if (s !== void 0)
295
295
  return {
296
- path: J([...e, i]),
296
+ path: J([...e, s]),
297
297
  reason: "extra key on actual"
298
298
  };
299
299
  }
300
300
  for (const r of o) {
301
- if (!gt(n, r))
301
+ if (!yt(n, r))
302
302
  return { path: J([...e, r]), reason: "missing key on actual" };
303
- const i = kt(t[r], n[r], [...e, r]);
304
- if (i) return i;
303
+ const s = Ht(t[r], n[r], [...e, r]);
304
+ if (s) return s;
305
305
  }
306
- for (const r of a)
307
- if (!gt(t, r))
306
+ for (const r of i)
307
+ if (!yt(t, r))
308
308
  return { path: J([...e, r]), reason: "extra key on actual" };
309
309
  return null;
310
310
  }
311
311
  return { path: J(e), reason: `expected ${String(t)} but found ${String(n)}` };
312
312
  }
313
- function we(t, n) {
314
- return kt(t, n, []);
313
+ function Ue(t, n) {
314
+ return Ht(t, n, []);
315
315
  }
316
- function En(t) {
316
+ function wn(t) {
317
317
  if (t === !0 || t === "1" || t === "true") return !0;
318
318
  if (t === !1 || t === "0" || t === "false") return !1;
319
319
  }
320
- function Ae() {
321
- var a, r;
322
- const t = globalThis.process, n = En(
323
- ((a = t == null ? void 0 : t.env) == null ? void 0 : a.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((r = t == null ? void 0 : t.env) == null ? void 0 : r.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
320
+ function Se() {
321
+ var i, r;
322
+ const t = globalThis.process, n = wn(
323
+ ((i = t == null ? void 0 : t.env) == null ? void 0 : i.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((r = t == null ? void 0 : t.env) == null ? void 0 : r.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
324
324
  );
325
325
  if (n !== void 0) return n;
326
- const e = ye, o = En(e == null ? void 0 : e.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
326
+ const e = Be, o = wn(e == null ? void 0 : e.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
327
327
  return o !== void 0 ? o : !1;
328
328
  }
329
- function Uo(t) {
329
+ function vo(t) {
330
330
  return t;
331
331
  }
332
- function Ne(t, n, e) {
332
+ function Ce(t, n, e) {
333
333
  if (n.length !== e.length)
334
- throw hn(t, Math.min(n.length, e.length), "$length", `text count ${n.length} !== ${e.length}`);
334
+ throw yn(t, Math.min(n.length, e.length), "$length", `text count ${n.length} !== ${e.length}`);
335
335
  for (let o = 0; o < n.length; o += 1) {
336
- const a = we(n[o], e[o]);
337
- if (a)
338
- throw hn(t, o, a.path, a.reason);
336
+ const i = Ue(n[o], e[o]);
337
+ if (i)
338
+ throw yn(t, o, i.path, i.reason);
339
339
  }
340
340
  }
341
- const Re = Tn(), pe = ["left", "center", "right"], Ie = ["top", "middle", "bottom", "alphabetic"];
342
- function xn(t, n) {
341
+ const Oe = Sn(), $e = ["left", "center", "right"], Me = ["top", "middle", "bottom", "alphabetic"];
342
+ function An(t, n) {
343
343
  if (t > BigInt(Number.MAX_SAFE_INTEGER))
344
- throw new l("E_GROUP_RANGE", `${n} exceeds safe integer range`);
344
+ throw new u("E_GROUP_RANGE", `${n} exceeds safe integer range`);
345
345
  return Number(t);
346
346
  }
347
- function zt(t, n, e, o) {
347
+ function jt(t, n, e, o) {
348
348
  if (!Number.isInteger(t) || !Number.isInteger(n) || t < 0 || n < 0 || t + n > e)
349
- throw new l("E_GROUP_RANGE", `${o} exceeds payload length`);
349
+ throw new u("E_GROUP_RANGE", `${o} exceeds payload length`);
350
350
  }
351
- function Ge(t) {
351
+ function ve(t) {
352
352
  if (t.byteLength < 4) return !1;
353
353
  const n = new Uint8Array(t, 0, 4);
354
354
  return n[0] === 68 && n[1] === 88 && n[2] === 66 && n[3] === 83;
355
355
  }
356
- function Jt(t) {
356
+ function tn(t) {
357
357
  if (t.byteLength < 20)
358
- throw new l("E_HEADER", "DXBS payload too small: missing container header");
359
- if (!Ge(t))
360
- throw new l("E_HEADER", "DXBS payload missing magic");
361
- const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), a = n.getUint16(8, !0), r = n.getUint16(10, !0), i = n.getUint16(12, !0), c = n.getUint16(14, !0), s = n.getUint32(16, !0);
358
+ throw new u("E_HEADER", "DXBS payload too small: missing container header");
359
+ if (!ve(t))
360
+ throw new u("E_HEADER", "DXBS payload missing magic");
361
+ const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), i = n.getUint16(8, !0), r = n.getUint16(10, !0), s = n.getUint16(12, !0), l = n.getUint16(14, !0), a = n.getUint32(16, !0);
362
362
  if (e !== 3 || o < 3 || o > 6)
363
- throw new l("E_GROUP_RANGE", `Unsupported DXBS version: ${e}.${o}`);
364
- if (a !== 0)
365
- throw new l("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${a}`);
366
- if (c !== 0)
367
- throw new l("E_GROUP_RANGE", `Invalid DXBS reserved field: ${c}`);
363
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS version: ${e}.${o}`);
364
+ if (i !== 0)
365
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${i}`);
366
+ if (l !== 0)
367
+ throw new u("E_GROUP_RANGE", `Invalid DXBS reserved field: ${l}`);
368
368
  if (r < 24)
369
- throw new l("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${r}`);
370
- if (s !== r * i)
371
- throw new l("E_GROUP_RANGE", "DXBS directory byte size mismatch");
372
- const u = 20;
373
- zt(u, s, t.byteLength, "DXBS section directory");
374
- const h = /* @__PURE__ */ new Map();
375
- for (let d = 0; d < i; d += 1) {
376
- const _ = u + d * r, f = n.getUint16(_, !0), w = n.getUint16(_ + 2, !0), y = n.getUint32(_ + 4, !0), m = xn(n.getBigUint64(_ + 8, !0), "DXBS section offset"), x = xn(n.getBigUint64(_ + 16, !0), "DXBS section length");
377
- if (w !== 0)
378
- throw new l("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${f}: ${w}`);
369
+ throw new u("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${r}`);
370
+ if (a !== r * s)
371
+ throw new u("E_GROUP_RANGE", "DXBS directory byte size mismatch");
372
+ const c = 20;
373
+ jt(c, a, t.byteLength, "DXBS section directory");
374
+ const _ = /* @__PURE__ */ new Map();
375
+ for (let f = 0; f < s; f += 1) {
376
+ const d = c + f * r, m = n.getUint16(d, !0), A = n.getUint16(d + 2, !0), y = n.getUint32(d + 4, !0), x = An(n.getBigUint64(d + 8, !0), "DXBS section offset"), h = An(n.getBigUint64(d + 16, !0), "DXBS section length");
377
+ if (A !== 0)
378
+ throw new u("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${m}: ${A}`);
379
379
  if (y !== 0)
380
- throw new l("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${f}: ${y}`);
381
- zt(m, x, t.byteLength, `DXBS section ${f}`), h.set(f, { type: f, flags: w, offset: m, length: x });
380
+ throw new u("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${m}: ${y}`);
381
+ jt(x, h, t.byteLength, `DXBS section ${m}`), _.set(m, { type: m, flags: A, offset: x, length: h });
382
382
  }
383
- return { versionMajor: e, versionMinor: o, sections: h };
383
+ return { versionMajor: e, versionMinor: o, sections: _ };
384
384
  }
385
- function et(t, n, e) {
385
+ function ot(t, n, e) {
386
386
  const o = t.sections.get(n);
387
387
  if (!o)
388
- throw new l("E_GROUP_RANGE", `Missing DXBS section ${e}`);
388
+ throw new u("E_GROUP_RANGE", `Missing DXBS section ${e}`);
389
389
  return o;
390
390
  }
391
- function Ve(t, n, e, o) {
392
- return zt(n, e, t.byteLength, o), Re.decode(t.subarray(n, n + e));
391
+ function Pe(t, n, e, o) {
392
+ return jt(n, e, t.byteLength, o), Oe.decode(t.subarray(n, n + e));
393
393
  }
394
- function Ut(t, n, e, o, a, r) {
394
+ function Ct(t, n, e, o, i, r) {
395
395
  if (e + 4 > o)
396
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
397
- const i = n.getUint32(e, !0), c = lt(t, n, e + 4, i, o, r);
398
- if (c.offset > o)
399
- throw new l("E_GROUP_RANGE", `${a} exceeds section bounds`);
400
- return c;
401
- }
402
- function Un(t, n, e, o) {
403
- const a = new DataView(t), r = e.offset + e.length, i = Wt(n.versionMinor), c = Ut(t, a, e.offset, r, `${o} line`, i), s = Ut(t, a, c.offset, r, `${o} fill`, i), u = Ut(t, a, s.offset, r, `${o} dot`, i);
404
- if (u.offset !== r)
405
- throw new l("E_GROUP_RANGE", `${o} has trailing bytes`);
406
- return { line: c.chunk, fill: s.chunk, dot: u.chunk };
407
- }
408
- function Te(t, n, e) {
409
- const o = t.getUint32(n, !0), a = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), i = t.getUint8(n + 43), c = t.getFloat32(n + 24, !0), s = t.getFloat32(n + 28, !0);
396
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
397
+ const s = n.getUint32(e, !0), l = ft(t, n, e + 4, s, o, r);
398
+ if (l.offset > o)
399
+ throw new u("E_GROUP_RANGE", `${i} exceeds section bounds`);
400
+ return l;
401
+ }
402
+ function $n(t, n, e, o) {
403
+ const i = new DataView(t), r = e.offset + e.length, s = Qt(n.versionMinor), l = Ct(t, i, e.offset, r, `${o} line`, s), a = Ct(t, i, l.offset, r, `${o} fill`, s), c = Ct(t, i, a.offset, r, `${o} dot`, s);
404
+ if (c.offset !== r)
405
+ throw new u("E_GROUP_RANGE", `${o} has trailing bytes`);
406
+ return { line: l.chunk, fill: a.chunk, dot: c.chunk };
407
+ }
408
+ function De(t, n, e) {
409
+ const o = t.getUint32(n, !0), i = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), s = t.getUint8(n + 43), l = t.getFloat32(n + 24, !0), a = t.getFloat32(n + 28, !0);
410
410
  return {
411
- t: Ve(e, o, a, "DXBS text value"),
411
+ t: Pe(e, o, i, "DXBS text value"),
412
412
  x: t.getFloat32(n + 8, !0),
413
413
  y: t.getFloat32(n + 12, !0),
414
414
  h: t.getFloat32(n + 16, !0),
415
415
  r: t.getFloat32(n + 20, !0),
416
416
  c: [t.getUint8(n + 36), t.getUint8(n + 37), t.getUint8(n + 38)],
417
417
  li: t.getUint16(n + 40, !0),
418
- ha: pe[r & 3] ?? "left",
419
- va: Ie[r >> 2 & 3] ?? "alphabetic",
418
+ ha: $e[r & 3] ?? "left",
419
+ va: Me[r >> 2 & 3] ?? "alphabetic",
420
420
  lh: t.getFloat32(n + 32, !0),
421
- ...c ? { w: c } : {},
422
- ...s !== 1 ? { wf: s } : {},
423
- ...i & 1 ? { mx: !0 } : {},
424
- ...i & 2 ? { my: !0 } : {}
421
+ ...l ? { w: l } : {},
422
+ ...a !== 1 ? { wf: a } : {},
423
+ ...s & 1 ? { mx: !0 } : {},
424
+ ...s & 2 ? { my: !0 } : {}
425
425
  };
426
426
  }
427
- function Sn(t, n, e, o) {
427
+ function Mn(t, n, e, o) {
428
428
  if (n.length % 44 !== 0)
429
- throw new l("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
430
- const a = new Uint8Array(t, e.offset, e.length), r = [], i = new DataView(t);
431
- for (let c = n.offset; c < n.offset + n.length; c += 44)
432
- r.push(Te(i, c, a));
429
+ throw new u("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
430
+ const i = new Uint8Array(t, e.offset, e.length), r = [], s = new DataView(t);
431
+ for (let l = n.offset; l < n.offset + n.length; l += 44)
432
+ r.push(De(s, l, i));
433
433
  return r;
434
434
  }
435
- function So(t) {
436
- const n = Jt(t), e = et(n, 513, "SCENE_ANNOTATION_GEOMETRY"), o = et(n, 514, "SCENE_ANNOTATION_TEXT_TABLE"), a = et(n, 515, "SCENE_ANNOTATION_STRING_TABLE");
435
+ function Po(t) {
436
+ const n = tn(t), e = ot(n, 513, "SCENE_ANNOTATION_GEOMETRY"), o = ot(n, 514, "SCENE_ANNOTATION_TEXT_TABLE"), i = ot(n, 515, "SCENE_ANNOTATION_STRING_TABLE");
437
437
  return {
438
- ...Un(t, n, e, "SCENE_ANNOTATION_GEOMETRY"),
439
- texts: Sn(t, o, a, "SCENE_ANNOTATION_TEXT_TABLE")
438
+ ...$n(t, n, e, "SCENE_ANNOTATION_GEOMETRY"),
439
+ texts: Mn(t, o, i, "SCENE_ANNOTATION_TEXT_TABLE")
440
440
  };
441
441
  }
442
- function be(t) {
443
- const n = Jt(t), e = et(n, 258, "BLOCK_ANNOTATION_GEOMETRY"), o = et(n, 259, "BLOCK_ANNOTATION_TEXT_TABLE"), a = et(n, 260, "BLOCK_ANNOTATION_STRING_TABLE");
442
+ function Xe(t) {
443
+ const n = tn(t), e = ot(n, 258, "BLOCK_ANNOTATION_GEOMETRY"), o = ot(n, 259, "BLOCK_ANNOTATION_TEXT_TABLE"), i = ot(n, 260, "BLOCK_ANNOTATION_STRING_TABLE");
444
444
  return {
445
- ...Un(t, n, e, "BLOCK_ANNOTATION_GEOMETRY"),
446
- texts: Sn(t, o, a, "BLOCK_ANNOTATION_TEXT_TABLE")
445
+ ...$n(t, n, e, "BLOCK_ANNOTATION_GEOMETRY"),
446
+ texts: Mn(t, o, i, "BLOCK_ANNOTATION_TEXT_TABLE")
447
447
  };
448
448
  }
449
- function It() {
449
+ function Vt() {
450
450
  return {
451
451
  pos: new Float32Array(0),
452
452
  count: 0,
453
453
  segments: []
454
454
  };
455
455
  }
456
- function ot(t) {
456
+ function rt(t) {
457
457
  if (t.segments && t.segments.length > 0)
458
- return Se(t.segments, t.count), t.segments;
458
+ return Ye(t.segments, t.count), t.segments;
459
459
  if (t.count <= 0) return [];
460
460
  if (!t.col || !t.lay)
461
- throw new l("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
462
- return Ue(t.col, t.lay, t.count);
461
+ throw new u("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
462
+ return ke(t.col, t.lay, t.count);
463
463
  }
464
- function Be(t) {
464
+ function Le(t) {
465
465
  if (t.col && t.lay)
466
466
  return { col: t.col, lay: t.lay };
467
- const n = ot(t), e = new Uint8Array(t.count * 3);
467
+ const n = rt(t), e = new Uint8Array(t.count * 3);
468
468
  let o = 0;
469
469
  for (const r of n)
470
470
  r.layerIndex > o && (o = r.layerIndex);
471
- const a = o > 255 ? new Uint16Array(t.count) : new Uint8Array(t.count);
471
+ const i = o > 255 ? new Uint16Array(t.count) : new Uint8Array(t.count);
472
472
  for (const r of n) {
473
- const i = r.startVertex + r.vertexCount;
474
- for (let c = r.startVertex; c < i; c += 1) {
475
- const s = c * 3;
476
- e[s] = r.color[0], e[s + 1] = r.color[1], e[s + 2] = r.color[2], a[c] = r.layerIndex;
473
+ const s = r.startVertex + r.vertexCount;
474
+ for (let l = r.startVertex; l < s; l += 1) {
475
+ const a = l * 3;
476
+ e[a] = r.color[0], e[a + 1] = r.color[1], e[a + 2] = r.color[2], i[l] = r.layerIndex;
477
477
  }
478
478
  }
479
- return { col: e, lay: a };
479
+ return { col: e, lay: i };
480
480
  }
481
- function Ht(t, n) {
481
+ function qt(t, n) {
482
482
  return t.map((e) => ({
483
483
  startVertex: e.startVertex + n,
484
484
  vertexCount: e.vertexCount,
@@ -487,7 +487,7 @@ function Ht(t, n) {
487
487
  ...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
488
488
  }));
489
489
  }
490
- function Cn(t, n) {
490
+ function vn(t, n) {
491
491
  return t.map((e) => ({
492
492
  startVertex: e.startVertex,
493
493
  vertexCount: e.vertexCount,
@@ -496,21 +496,21 @@ function Cn(t, n) {
496
496
  ...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
497
497
  }));
498
498
  }
499
- function Co(t, n, e) {
500
- const o = n + e, a = [];
499
+ function Do(t, n, e) {
500
+ const o = n + e, i = [];
501
501
  for (const r of t) {
502
- const i = r.startVertex, c = r.startVertex + r.vertexCount, s = Math.max(n, i), u = Math.min(o, c);
503
- s >= u || a.push({
504
- startVertex: s - n,
505
- vertexCount: u - s,
502
+ const s = r.startVertex, l = r.startVertex + r.vertexCount, a = Math.max(n, s), c = Math.min(o, l);
503
+ a >= c || i.push({
504
+ startVertex: a - n,
505
+ vertexCount: c - a,
506
506
  color: Gt(r),
507
507
  layerIndex: r.layerIndex,
508
508
  ...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx }
509
509
  });
510
510
  }
511
- return dt(a);
511
+ return mt(i);
512
512
  }
513
- function dt(t) {
513
+ function mt(t) {
514
514
  const n = [];
515
515
  for (const e of t) {
516
516
  const o = n[n.length - 1];
@@ -531,60 +531,60 @@ function dt(t) {
531
531
  }
532
532
  return n;
533
533
  }
534
- function Ue(t, n, e) {
534
+ function ke(t, n, e) {
535
535
  if (t.length < e * 3 || n.length < e)
536
- throw new l("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
536
+ throw new u("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
537
537
  const o = [];
538
- let a = 0;
539
- for (; a < e; ) {
540
- const r = a * 3, i = t[r] ?? 0, c = t[r + 1] ?? 0, s = t[r + 2] ?? 0, u = n[a] ?? 0;
541
- let h = a + 1;
542
- for (; h < e; ) {
543
- const d = h * 3;
544
- if (n[h] !== u || t[d] !== i || t[d + 1] !== c || t[d + 2] !== s)
538
+ let i = 0;
539
+ for (; i < e; ) {
540
+ const r = i * 3, s = t[r] ?? 0, l = t[r + 1] ?? 0, a = t[r + 2] ?? 0, c = n[i] ?? 0;
541
+ let _ = i + 1;
542
+ for (; _ < e; ) {
543
+ const f = _ * 3;
544
+ if (n[_] !== c || t[f] !== s || t[f + 1] !== l || t[f + 2] !== a)
545
545
  break;
546
- h += 1;
546
+ _ += 1;
547
547
  }
548
548
  o.push({
549
- startVertex: a,
550
- vertexCount: h - a,
551
- color: [i, c, s],
552
- layerIndex: u
553
- }), a = h;
549
+ startVertex: i,
550
+ vertexCount: _ - i,
551
+ color: [s, l, a],
552
+ layerIndex: c
553
+ }), i = _;
554
554
  }
555
555
  return o;
556
556
  }
557
- function Se(t, n) {
557
+ function Ye(t, n) {
558
558
  let e = 0;
559
559
  for (const o of t) {
560
560
  if (o.vertexCount < 0 || o.startVertex !== e)
561
- throw new l("E_SEGMENT_SUM", "Geometry segments must be contiguous and non-negative");
561
+ throw new u("E_SEGMENT_SUM", "Geometry segments must be contiguous and non-negative");
562
562
  e += o.vertexCount;
563
563
  }
564
564
  if (e !== n)
565
- throw new l("E_SEGMENT_SUM", `Geometry segment vertex sum ${e} does not match count ${n}`);
565
+ throw new u("E_SEGMENT_SUM", `Geometry segment vertex sum ${e} does not match count ${n}`);
566
566
  }
567
567
  function Gt(t) {
568
568
  return [t.color[0], t.color[1], t.color[2]];
569
569
  }
570
- const Ce = 8e6, Oe = 0.25, $e = 5, Me = 4, Pe = 2048, Zt = Tn(), De = ["left", "center", "right"], ve = ["top", "middle", "bottom", "alphabetic"];
571
- function At(t, n, e) {
570
+ const Fe = 8e6, ze = 0.25, He = 5, je = 4, qe = 2048, nn = Sn(), Ke = ["left", "center", "right"], We = ["top", "middle", "bottom", "alphabetic"];
571
+ function Rt(t, n, e) {
572
572
  for (const o of t)
573
573
  e(o);
574
574
  for (const o of n)
575
575
  e(o);
576
576
  }
577
- const gn = /* @__PURE__ */ new WeakMap();
578
- function ct(t) {
577
+ const Rn = /* @__PURE__ */ new WeakMap(), Pn = /* @__PURE__ */ new WeakSet();
578
+ function ut(t) {
579
579
  return typeof t == "object" && t !== null;
580
580
  }
581
- function Xe(t) {
581
+ function Je(t) {
582
582
  return Array.isArray(t) ? "array" : t === null ? "null" : typeof t;
583
583
  }
584
- function Le(t) {
585
- return !(!ct(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((n) => typeof n == "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);
584
+ function Ze(t) {
585
+ return !(!ut(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((n) => typeof n == "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);
586
586
  }
587
- function Ye(t) {
587
+ function Qe(t) {
588
588
  return t.map((n, e) => ({
589
589
  index: e,
590
590
  name: n.name,
@@ -593,26 +593,26 @@ function Ye(t) {
593
593
  visible: n.visible ?? !0
594
594
  }));
595
595
  }
596
- function Qt(t) {
597
- const n = t.texts, e = Array.isArray(n) ? n : [], o = e.filter(Le), a = Ae();
598
- if (a && n !== void 0 && !Array.isArray(n))
599
- throw new l(
596
+ function en(t) {
597
+ const n = t.texts, e = Array.isArray(n) ? n : [], o = e.filter(Ze), i = Se();
598
+ if (i && n !== void 0 && !Array.isArray(n))
599
+ throw new u(
600
600
  "E_TEXT_ROUNDTRIP",
601
- `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${Xe(n)}`
601
+ `Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${Je(n)}`
602
602
  );
603
- return a && Ne("Boundary-2:header->stream", e, o), {
603
+ return i && Ce("Boundary-2:header->stream", e, o), {
604
604
  bounds: [...t.bounds],
605
605
  entityCount: Number(t.entity_count || 0),
606
606
  lineCount: Number(t.line_count || 0),
607
607
  fillCount: Number(t.fill_count || 0),
608
608
  dotCount: Number(t.dot_count || 0),
609
609
  textCount: o.length,
610
- layers: Ye(t.layers ?? []),
610
+ layers: Qe(t.layers ?? []),
611
611
  texts: o
612
612
  };
613
613
  }
614
- function On(t) {
615
- const n = t == null ? void 0 : t.maxExpandedInstanceVertices, e = typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : Ce;
614
+ function Dn(t) {
615
+ const n = t == null ? void 0 : t.maxExpandedInstanceVertices, e = typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : Fe;
616
616
  return {
617
617
  hiddenInstanceIds: t != null && t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(),
618
618
  keepTextsForHiddenInstances: (t == null ? void 0 : t.keepTextsForHiddenInstances) === !0,
@@ -623,281 +623,282 @@ function On(t) {
623
623
  externalVariantBuffers: t == null ? void 0 : t.externalVariantBuffers,
624
624
  requiredExternalVariantIds: t == null ? void 0 : t.requiredExternalVariantIds,
625
625
  externalVariantDeltaOnly: (t == null ? void 0 : t.externalVariantDeltaOnly) === !0,
626
- deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0
626
+ deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0,
627
+ cacheDocument: (t == null ? void 0 : t.cacheDocument) === !0
627
628
  };
628
629
  }
629
- function Fe(t) {
630
+ function to(t) {
630
631
  return t.loadBlocks && !t.suppressExpandedInsertGeometry;
631
632
  }
632
633
  function Nt(t, n) {
633
- return Fe(n) && !n.hiddenInstanceIds.has(t);
634
+ return to(n) && !n.hiddenInstanceIds.has(t);
634
635
  }
635
- function $n(t, n, e) {
636
+ function Xn(t, n, e) {
636
637
  if (e <= 0)
637
638
  return;
638
639
  const o = t.expandedInstanceVertices + e;
639
640
  if (o > t.maxExpandedInstanceVertices)
640
- throw new l(
641
+ throw new u(
641
642
  "E_EXPANSION_BUDGET",
642
643
  `CPU-expanded ${n} instance vertices exceed budget: ${o}/${t.maxExpandedInstanceVertices}. Disable block loading or raise maxExpandedInstanceVertices.`
643
644
  );
644
645
  t.expandedInstanceVertices = o;
645
646
  }
646
- function ke(t, n, e) {
647
+ function no(t, n, e) {
647
648
  return e.loadBlocks ? e.hiddenInstanceIds.size === 0 || e.keepTextsForHiddenInstances ? t : t.filter((o) => {
648
649
  if (!Number.isInteger(o.iv) || !Number.isInteger(o.io))
649
650
  return !0;
650
- const a = n.get(`${o.iv}:${o.io}`);
651
- return a === void 0 || !e.hiddenInstanceIds.has(a);
651
+ const i = n.get(`${o.iv}:${o.io}`);
652
+ return i === void 0 || !e.hiddenInstanceIds.has(i);
652
653
  }) : t.filter((o) => !Number.isInteger(o.iv) || !Number.isInteger(o.io));
653
654
  }
654
- function ze(t, n) {
655
+ function eo(t, n) {
655
656
  const e = /* @__PURE__ */ new Map();
656
- return t.forEach((o, a) => {
657
+ return t.forEach((o, i) => {
657
658
  if (!Number.isInteger(o.iv) || !Number.isInteger(o.io))
658
659
  return;
659
660
  const r = n.get(`${o.iv}:${o.io}`);
660
661
  if (r === void 0)
661
662
  return;
662
- const i = e.get(r);
663
- i ? i.push(a) : e.set(r, [a]);
663
+ const s = e.get(r);
664
+ s ? s.push(i) : e.set(r, [i]);
664
665
  }), e;
665
666
  }
666
- function He(t, n, e, o, a, r, i) {
667
- const c = n.map((s, u) => ({
668
- id: s.id,
669
- blockName: Mn(s, u),
670
- line: e[u].line,
671
- fill: e[u].fill,
672
- dot: e[u].dot,
673
- texts: o.get(s.id) ?? []
667
+ function oo(t, n, e, o, i, r, s) {
668
+ const l = n.map((a, c) => ({
669
+ id: a.id,
670
+ blockName: Ln(a, c),
671
+ line: e[c].line,
672
+ fill: e[c].fill,
673
+ dot: e[c].dot,
674
+ texts: o.get(a.id) ?? []
674
675
  }));
675
676
  return {
676
677
  layer0Index: t,
677
- variants: c,
678
- instances: a,
679
- textIndexesByInstanceId: ze(r, i),
680
- ownerInstanceIdByVariantOrdinal: i
678
+ variants: l,
679
+ instances: i,
680
+ textIndexesByInstanceId: eo(r, s),
681
+ ownerInstanceIdByVariantOrdinal: s
681
682
  };
682
683
  }
683
- function je(t) {
684
+ function ro(t) {
684
685
  if (t.byteLength < 4)
685
- throw new l("E_HEADER", "Payload too small: missing header length");
686
- const n = new DataView(t), e = n.getUint32(0, !0), o = 4, a = o + e;
687
- if (a > t.byteLength)
688
- throw new l("E_HEADER", "Header length exceeds payload length");
686
+ throw new u("E_HEADER", "Payload too small: missing header length");
687
+ const n = new DataView(t), e = n.getUint32(0, !0), o = 4, i = o + e;
688
+ if (i > t.byteLength)
689
+ throw new u("E_HEADER", "Header length exceeds payload length");
689
690
  let r;
690
691
  try {
691
- r = JSON.parse(Zt.decode(new Uint8Array(t, o, e)));
692
- } catch (i) {
693
- throw new l("E_HEADER_JSON", `Invalid JSON header: ${i.message}`);
692
+ r = JSON.parse(nn.decode(new Uint8Array(t, o, e)));
693
+ } catch (s) {
694
+ throw new u("E_HEADER_JSON", `Invalid JSON header: ${s.message}`);
694
695
  }
695
696
  return {
696
697
  meta: r,
697
- header: Qt(r),
698
- dataOffset: a,
698
+ header: en(r),
699
+ dataOffset: i,
699
700
  view: n
700
701
  };
701
702
  }
702
- function Mn(t, n) {
703
- var r, i, c;
703
+ function Ln(t, n) {
704
+ var r, s, l;
704
705
  const e = (r = t.name) == null ? void 0 : r.trim();
705
706
  if (e)
706
707
  return e;
707
- const o = (i = t.block_name) == null ? void 0 : i.trim();
708
+ const o = (s = t.block_name) == null ? void 0 : s.trim();
708
709
  if (o)
709
710
  return o;
710
- const a = (c = t.blockName) == null ? void 0 : c.trim();
711
- return a || `block_${n}`;
711
+ const i = (l = t.blockName) == null ? void 0 : l.trim();
712
+ return i || `block_${n}`;
712
713
  }
713
- function qe(t) {
714
+ function io(t) {
714
715
  const n = Number(t.version ?? 1), e = String(t.encoding ?? "").toLowerCase();
715
716
  if (n === 2) {
716
717
  const o = e ? ` ${e}` : "";
717
- throw new l(
718
+ throw new u(
718
719
  "E_UNSUPPORTED_PACK_VERSION",
719
720
  `当前文件是 V2${o} pack,前端不再兼容解析;请升级到最新版本后再打开。`
720
721
  );
721
722
  }
722
723
  }
723
- function tn(t) {
724
- const n = je(t);
725
- return qe(n.meta), n;
724
+ function on(t) {
725
+ const n = ro(t);
726
+ return io(n.meta), n;
726
727
  }
727
- function rt(t) {
728
+ function Q(t) {
728
729
  if (t.byteLength < 4)
729
730
  return !1;
730
731
  const n = new Uint8Array(t, 0, 4);
731
732
  return n[0] === 68 && n[1] === 88 && n[2] === 66 && n[3] === 51;
732
733
  }
733
- function yn(t, n) {
734
+ function Nn(t, n) {
734
735
  if (t > BigInt(Number.MAX_SAFE_INTEGER))
735
- throw new l("E_GROUP_RANGE", `${n} exceeds safe integer range`);
736
+ throw new u("E_GROUP_RANGE", `${n} exceeds safe integer range`);
736
737
  return Number(t);
737
738
  }
738
- function ft(t, n, e, o) {
739
+ function _t(t, n, e, o) {
739
740
  if (!Number.isInteger(t) || !Number.isInteger(n) || t < 0 || n < 0 || t + n > e)
740
- throw new l("E_GROUP_RANGE", `${o} exceeds payload length`);
741
+ throw new u("E_GROUP_RANGE", `${o} exceeds payload length`);
741
742
  }
742
- function mt(t) {
743
+ function Et(t) {
743
744
  if (t.byteLength < 20)
744
- throw new l("E_HEADER", "V3 payload too small: missing container header");
745
- const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), a = n.getUint32(8, !0), r = n.getUint16(12, !0), i = n.getUint16(14, !0), c = n.getUint32(16, !0);
745
+ throw new u("E_HEADER", "V3 payload too small: missing container header");
746
+ const n = new DataView(t), e = n.getUint16(4, !0), o = n.getUint16(6, !0), i = n.getUint32(8, !0), r = n.getUint16(12, !0), s = n.getUint16(14, !0), l = n.getUint32(16, !0);
746
747
  if (e !== 3 || o > 6)
747
- throw new l("E_GROUP_RANGE", `Unsupported V3 version: ${e}.${o}`);
748
- if (a !== 0)
749
- throw new l("E_GROUP_RANGE", `Unsupported V3 file flags: ${a}`);
748
+ throw new u("E_GROUP_RANGE", `Unsupported V3 version: ${e}.${o}`);
749
+ if (i !== 0)
750
+ throw new u("E_GROUP_RANGE", `Unsupported V3 file flags: ${i}`);
750
751
  if (r < 24)
751
- throw new l("E_GROUP_RANGE", `Invalid V3 directory entry size: ${r}`);
752
- if (c !== r * i)
753
- throw new l("E_GROUP_RANGE", "V3 directory byte size mismatch");
754
- const s = 20;
755
- ft(s, c, t.byteLength, "V3 section directory");
756
- const u = /* @__PURE__ */ new Map();
757
- for (let h = 0; h < i; h += 1) {
758
- const d = s + h * r, _ = n.getUint16(d, !0), f = n.getUint16(d + 2, !0), w = n.getUint32(d + 4, !0), y = yn(n.getBigUint64(d + 8, !0), "V3 section offset"), m = yn(n.getBigUint64(d + 16, !0), "V3 section length");
759
- if (f !== 0)
760
- throw new l("E_GROUP_RANGE", `Unsupported V3 section flags for type ${_}: ${f}`);
761
- if (w !== 0)
762
- throw new l("E_GROUP_RANGE", `Invalid V3 section reserved field for type ${_}: ${w}`);
763
- ft(y, m, t.byteLength, `V3 section ${_}`), u.set(_, { type: _, flags: f, offset: y, length: m });
752
+ throw new u("E_GROUP_RANGE", `Invalid V3 directory entry size: ${r}`);
753
+ if (l !== r * s)
754
+ throw new u("E_GROUP_RANGE", "V3 directory byte size mismatch");
755
+ const a = 20;
756
+ _t(a, l, t.byteLength, "V3 section directory");
757
+ const c = /* @__PURE__ */ new Map();
758
+ for (let _ = 0; _ < s; _ += 1) {
759
+ const f = a + _ * r, d = n.getUint16(f, !0), m = n.getUint16(f + 2, !0), A = n.getUint32(f + 4, !0), y = Nn(n.getBigUint64(f + 8, !0), "V3 section offset"), x = Nn(n.getBigUint64(f + 16, !0), "V3 section length");
760
+ if (m !== 0)
761
+ throw new u("E_GROUP_RANGE", `Unsupported V3 section flags for type ${d}: ${m}`);
762
+ if (A !== 0)
763
+ throw new u("E_GROUP_RANGE", `Invalid V3 section reserved field for type ${d}: ${A}`);
764
+ _t(y, x, t.byteLength, `V3 section ${d}`), c.set(d, { type: d, flags: m, offset: y, length: x });
764
765
  }
765
- return { versionMinor: o, sections: u };
766
+ return { versionMinor: o, sections: c };
766
767
  }
767
- function X(t, n, e) {
768
+ function P(t, n, e) {
768
769
  const o = t.get(n);
769
770
  if (!o)
770
- throw new l("E_GROUP_RANGE", `Missing V3 section ${e}`);
771
+ throw new u("E_GROUP_RANGE", `Missing V3 section ${e}`);
771
772
  return o;
772
773
  }
773
- function ut(t, n) {
774
+ function dt(t, n) {
774
775
  return t.get(n) ?? { type: n, flags: 0, offset: 0, length: 0 };
775
776
  }
776
- function _t(t, n, e) {
777
+ function xt(t, n, e) {
777
778
  try {
778
- return JSON.parse(Zt.decode(new Uint8Array(t, n.offset, n.length)));
779
+ return JSON.parse(nn.decode(new Uint8Array(t, n.offset, n.length)));
779
780
  } catch (o) {
780
- throw new l("E_HEADER_JSON", `Invalid V3 ${e} JSON: ${o.message}`);
781
+ throw new u("E_HEADER_JSON", `Invalid V3 ${e} JSON: ${o.message}`);
781
782
  }
782
783
  }
783
- function nn(t) {
784
+ function rn(t) {
784
785
  const n = String(t.encoding ?? "").toLowerCase();
785
786
  return n === "nested_instanced_external" || n === "nested_instanced_external_annotations";
786
787
  }
787
- function en(t) {
788
+ function sn(t) {
788
789
  return String(t.encoding ?? "").toLowerCase() === "nested_instanced_external_annotations";
789
790
  }
790
- function Ke(t, n, e) {
791
- const o = t.features, a = o && typeof o == "object" && !Array.isArray(o) ? { ...o } : {};
792
- return n && (a.has_external_variant_geometry = !0), e && (a.has_external_annotations = !0), Object.keys(a).length ? a : void 0;
791
+ function so(t, n, e) {
792
+ const o = t.features, i = o && typeof o == "object" && !Array.isArray(o) ? { ...o } : {};
793
+ return n && (i.has_external_variant_geometry = !0), e && (i.has_external_annotations = !0), Object.keys(i).length ? i : void 0;
793
794
  }
794
- function q(t, n) {
795
+ function K(t, n) {
795
796
  if (!Number.isInteger(t) || Number(t) < 0)
796
- throw new l("E_HEADER", `${n} must be a non-negative integer`);
797
+ throw new u("E_HEADER", `${n} must be a non-negative integer`);
797
798
  return Number(t);
798
799
  }
799
- function Pn(t, n) {
800
+ function kn(t, n) {
800
801
  if (typeof t != "string" || !t.trim())
801
- throw new l("E_HEADER", `${n} must be a non-empty string`);
802
+ throw new u("E_HEADER", `${n} must be a non-empty string`);
802
803
  return t;
803
804
  }
804
- function wn(t, n) {
805
+ function pn(t, n) {
805
806
  if (t == null)
806
807
  return null;
807
808
  if (!Array.isArray(t) || t.length !== 4 || t.some((e) => typeof e != "number" || !Number.isFinite(e)))
808
- throw new l("E_HEADER", `${n} must be null or [minX, minY, maxX, maxY]`);
809
+ throw new u("E_HEADER", `${n} must be null or [minX, minY, maxX, maxY]`);
809
810
  return [t[0], t[1], t[2], t[3]];
810
811
  }
811
- function jt(t, n) {
812
- if (!ct(t) || Array.isArray(t))
813
- throw new l("E_HEADER", `${n} must be an object`);
812
+ function Kt(t, n) {
813
+ if (!ut(t) || Array.isArray(t))
814
+ throw new u("E_HEADER", `${n} must be an object`);
814
815
  return {
815
- line_count: q(t.line_count, `${n}.line_count`),
816
- fill_count: q(t.fill_count, `${n}.fill_count`),
817
- dot_count: q(t.dot_count, `${n}.dot_count`),
818
- bbox: wn(t.bbox, `${n}.bbox`),
819
- own_bbox: wn(t.own_bbox, `${n}.own_bbox`)
816
+ line_count: K(t.line_count, `${n}.line_count`),
817
+ fill_count: K(t.fill_count, `${n}.fill_count`),
818
+ dot_count: K(t.dot_count, `${n}.dot_count`),
819
+ bbox: pn(t.bbox, `${n}.bbox`),
820
+ own_bbox: pn(t.own_bbox, `${n}.own_bbox`)
820
821
  };
821
822
  }
822
- function We(t) {
823
+ function ao(t) {
823
824
  return t ? { minX: t[0], minY: t[1], maxX: t[2], maxY: t[3] } : null;
824
825
  }
825
- function Vt(t, n) {
826
+ function Tt(t, n) {
826
827
  const e = t.external_variants;
827
828
  if (!Array.isArray(e))
828
- throw new l("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
829
+ throw new u("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
829
830
  if (e.length !== n)
830
- throw new l(
831
+ throw new u(
831
832
  "E_GROUP_RANGE",
832
833
  `V3 external variant manifest count mismatch: manifest=${e.length}, table=${n}`
833
834
  );
834
- return e.map((o, a) => {
835
- if (!ct(o) || Array.isArray(o))
836
- throw new l("E_HEADER", `V3 external_variants[${a}] must be an object`);
837
- const r = q(o.id, `V3 external_variants[${a}].id`);
838
- if (r !== a)
839
- throw new l("E_GROUP_RANGE", `V3 external_variants[${a}].id must equal ${a}, found ${r}`);
840
- const i = Pn(o.href, `V3 external_variants[${a}].href`), c = q(o.raw_size, `V3 external_variants[${a}].raw_size`);
835
+ return e.map((o, i) => {
836
+ if (!ut(o) || Array.isArray(o))
837
+ throw new u("E_HEADER", `V3 external_variants[${i}] must be an object`);
838
+ const r = K(o.id, `V3 external_variants[${i}].id`);
839
+ if (r !== i)
840
+ throw new u("E_GROUP_RANGE", `V3 external_variants[${i}].id must equal ${i}, found ${r}`);
841
+ const s = kn(o.href, `V3 external_variants[${i}].href`), l = K(o.raw_size, `V3 external_variants[${i}].raw_size`);
841
842
  if ("normal" in o || "annotation" in o) {
842
- const s = jt(o.annotation, `V3 external_variants[${a}].annotation`);
843
+ const a = Kt(o.annotation, `V3 external_variants[${i}].annotation`);
843
844
  return {
844
845
  id: r,
845
- href: i,
846
- raw_size: c,
847
- normal: jt(o.normal, `V3 external_variants[${a}].normal`),
846
+ href: s,
847
+ raw_size: l,
848
+ normal: Kt(o.normal, `V3 external_variants[${i}].normal`),
848
849
  annotation: {
849
- ...s,
850
- text_count: q(
851
- ct(o.annotation) && !Array.isArray(o.annotation) ? o.annotation.text_count : void 0,
852
- `V3 external_variants[${a}].annotation.text_count`
850
+ ...a,
851
+ text_count: K(
852
+ ut(o.annotation) && !Array.isArray(o.annotation) ? o.annotation.text_count : void 0,
853
+ `V3 external_variants[${i}].annotation.text_count`
853
854
  )
854
855
  }
855
856
  };
856
857
  }
857
858
  return {
858
859
  id: r,
859
- href: i,
860
- raw_size: c,
861
- line_count: q(o.line_count, `V3 external_variants[${a}].line_count`),
862
- fill_count: q(o.fill_count, `V3 external_variants[${a}].fill_count`),
863
- dot_count: q(o.dot_count, `V3 external_variants[${a}].dot_count`)
860
+ href: s,
861
+ raw_size: l,
862
+ line_count: K(o.line_count, `V3 external_variants[${i}].line_count`),
863
+ fill_count: K(o.fill_count, `V3 external_variants[${i}].fill_count`),
864
+ dot_count: K(o.dot_count, `V3 external_variants[${i}].dot_count`)
864
865
  };
865
866
  });
866
867
  }
867
- function Dn(t) {
868
+ function Yn(t) {
868
869
  const n = t.external_annotations;
869
870
  if (n == null) return null;
870
- if (!ct(n) || Array.isArray(n))
871
- throw new l("E_HEADER", "V3 external_annotations must be an object");
871
+ if (!ut(n) || Array.isArray(n))
872
+ throw new u("E_HEADER", "V3 external_annotations must be an object");
872
873
  const e = n.scene;
873
874
  if (e == null) return {};
874
- if (!ct(e) || Array.isArray(e))
875
- throw new l("E_HEADER", "V3 external_annotations.scene must be an object");
876
- const o = jt(e, "V3 external_annotations.scene");
875
+ if (!ut(e) || Array.isArray(e))
876
+ throw new u("E_HEADER", "V3 external_annotations.scene must be an object");
877
+ const o = Kt(e, "V3 external_annotations.scene");
877
878
  return {
878
879
  scene: {
879
- href: Pn(e.href, "V3 external_annotations.scene.href"),
880
- raw_size: q(e.raw_size, "V3 external_annotations.scene.raw_size"),
880
+ href: kn(e.href, "V3 external_annotations.scene.href"),
881
+ raw_size: K(e.raw_size, "V3 external_annotations.scene.raw_size"),
881
882
  ...o,
882
- text_count: q(e.text_count, "V3 external_annotations.scene.text_count")
883
+ text_count: K(e.text_count, "V3 external_annotations.scene.text_count")
883
884
  }
884
885
  };
885
886
  }
886
- function vn(t) {
887
- const { sections: n } = mt(t), e = X(n, 1, "SCENE_META");
888
- return _t(t, e, "SCENE_META");
887
+ function Fn(t) {
888
+ const { sections: n } = Et(t), e = P(n, 1, "SCENE_META");
889
+ return xt(t, e, "SCENE_META");
889
890
  }
890
- function Oo(t) {
891
- if (!rt(t))
891
+ function Xo(t) {
892
+ if (!Q(t))
892
893
  return [];
893
- const { sections: n } = mt(t), e = X(n, 1, "SCENE_META"), o = X(n, 5, "VARIANT_TABLE"), a = _t(t, e, "SCENE_META");
894
- if (!nn(a))
894
+ const { sections: n } = Et(t), e = P(n, 1, "SCENE_META"), o = P(n, 5, "VARIANT_TABLE"), i = xt(t, e, "SCENE_META");
895
+ if (!rn(i))
895
896
  return [];
896
897
  if (o.length % 60 !== 0)
897
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
898
- return Vt(a, o.length / 60);
898
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
899
+ return Tt(i, o.length / 60);
899
900
  }
900
- function An() {
901
+ function In() {
901
902
  return {
902
903
  manifest: [],
903
904
  requiredVariantIds: [],
@@ -906,288 +907,288 @@ function An() {
906
907
  skippedVariantIds: []
907
908
  };
908
909
  }
909
- function Je(t, n) {
910
- return he(t, n);
910
+ function lo(t, n) {
911
+ return Ve(t, n);
911
912
  }
912
- function qt(t, n) {
913
- return bn(t, n);
913
+ function Wt(t, n) {
914
+ return Cn(t, n);
914
915
  }
915
- function Ze(t, n) {
916
- return _e(t, n);
916
+ function uo(t, n) {
917
+ return Ie(t, n);
917
918
  }
918
- function Qe(t, n, e, o) {
919
+ function co(t, n, e, o) {
919
920
  if (!n || e === void 0 || !Number.isFinite(e) || e <= 0 || !Number.isFinite(o) || o <= 0) return !1;
920
- const a = Ze(n, t);
921
- if (!a) return !0;
922
- const r = Math.max(0, a.maxX - a.minX) / e, i = Math.max(0, a.maxY - a.minY) / e;
923
- return r < o && i < o;
921
+ const i = uo(n, t);
922
+ if (!i) return !0;
923
+ const r = Math.max(0, i.maxX - i.minX) / e, s = Math.max(0, i.maxY - i.minY) / e;
924
+ return r < o && s < o;
924
925
  }
925
- function Xn(t) {
926
- const n = Math.min(t.minX, t.maxX), e = Math.max(t.minX, t.maxX), o = Math.min(t.minY, t.maxY), a = Math.max(t.minY, t.maxY);
927
- return [n, e, o, a].every(Number.isFinite) ? { minX: n, minY: o, maxX: e, maxY: a } : null;
926
+ function zn(t) {
927
+ const n = Math.min(t.minX, t.maxX), e = Math.max(t.minX, t.maxX), o = Math.min(t.minY, t.maxY), i = Math.max(t.minY, t.maxY);
928
+ return [n, e, o, i].every(Number.isFinite) ? { minX: n, minY: o, maxX: e, maxY: i } : null;
928
929
  }
929
- function to(t) {
930
+ function fo(t) {
930
931
  return Math.max(1, Math.abs(t.maxX - t.minX), Math.abs(t.maxY - t.minY));
931
932
  }
932
- function Ln(t, n) {
933
+ function Hn(t, n) {
933
934
  return `${t}:${n}`;
934
935
  }
935
- function no(t) {
936
- const n = t.map((o) => o.worldBBox && !o.unknownBBox ? to(o.worldBBox) : 0).filter((o) => Number.isFinite(o) && o > 0).sort((o, a) => o - a), e = n.length > 0 ? n[Math.floor(n.length / 2)] : 1;
937
- return Math.max(1, e * Me);
936
+ function mo(t) {
937
+ const n = t.map((o) => o.worldBBox && !o.unknownBBox ? fo(o.worldBBox) : 0).filter((o) => Number.isFinite(o) && o > 0).sort((o, i) => o - i), e = n.length > 0 ? n[Math.floor(n.length / 2)] : 1;
938
+ return Math.max(1, e * je);
938
939
  }
939
- function eo(t, n) {
940
- const e = t.map((i, c) => {
941
- const s = n(i), u = s.worldBBox ? Xn(s.worldBBox) : null;
940
+ function _o(t, n) {
941
+ const e = t.map((s, l) => {
942
+ const a = n(s), c = a.worldBBox ? zn(a.worldBBox) : null;
942
943
  return {
943
- sceneInstanceId: c,
944
- sceneInstance: i,
945
- worldBBox: u,
946
- unknownBBox: s.unknownBBox || !u
944
+ sceneInstanceId: l,
945
+ sceneInstance: s,
946
+ worldBBox: c,
947
+ unknownBBox: a.unknownBBox || !c
947
948
  };
948
- }), o = no(e), a = /* @__PURE__ */ new Map(), r = [];
949
- for (const i of e) {
950
- if (i.unknownBBox || !i.worldBBox) {
951
- r.push(i);
949
+ }), o = mo(e), i = /* @__PURE__ */ new Map(), r = [];
950
+ for (const s of e) {
951
+ if (s.unknownBBox || !s.worldBBox) {
952
+ r.push(s);
952
953
  continue;
953
954
  }
954
- const c = Math.floor(i.worldBBox.minX / o), s = Math.floor(i.worldBBox.maxX / o), u = Math.floor(i.worldBBox.minY / o), h = Math.floor(i.worldBBox.maxY / o), d = (s - c + 1) * (h - u + 1);
955
- if (!Number.isFinite(d) || d > Pe) {
956
- r.push(i);
955
+ const l = Math.floor(s.worldBBox.minX / o), a = Math.floor(s.worldBBox.maxX / o), c = Math.floor(s.worldBBox.minY / o), _ = Math.floor(s.worldBBox.maxY / o), f = (a - l + 1) * (_ - c + 1);
956
+ if (!Number.isFinite(f) || f > qe) {
957
+ r.push(s);
957
958
  continue;
958
959
  }
959
- for (let _ = c; _ <= s; _ += 1)
960
- for (let f = u; f <= h; f += 1) {
961
- const w = Ln(_, f), y = a.get(w);
962
- y ? y.push(i) : a.set(w, [i]);
960
+ for (let d = l; d <= a; d += 1)
961
+ for (let m = c; m <= _; m += 1) {
962
+ const A = Hn(d, m), y = i.get(A);
963
+ y ? y.push(s) : i.set(A, [s]);
963
964
  }
964
965
  }
965
- return { cellSize: o, cells: a, overflow: r, records: e };
966
+ return { cellSize: o, cells: i, overflow: r, records: e };
966
967
  }
967
- function oo(t, n, e) {
968
- const o = gn.get(t);
968
+ function Eo(t, n, e) {
969
+ const o = Rn.get(t);
969
970
  if (o && o.records.length === n.length)
970
971
  return o;
971
- const a = eo(n, e);
972
- return gn.set(t, a), a;
972
+ const i = _o(n, e);
973
+ return Rn.set(t, i), i;
973
974
  }
974
- function ro(t, n) {
975
- const e = Xn(n);
975
+ function xo(t, n) {
976
+ const e = zn(n);
976
977
  if (!e)
977
978
  return t.records;
978
- const o = /* @__PURE__ */ new Set(), a = Math.floor(e.minX / t.cellSize), r = Math.floor(e.maxX / t.cellSize), i = Math.floor(e.minY / t.cellSize), c = Math.floor(e.maxY / t.cellSize);
979
- for (let s = a; s <= r; s += 1)
980
- for (let u = i; u <= c; u += 1) {
981
- const h = t.cells.get(Ln(s, u));
982
- if (h)
983
- for (const d of h)
984
- d.worldBBox && qt(e, d.worldBBox) && o.add(d);
979
+ const o = /* @__PURE__ */ new Set(), i = Math.floor(e.minX / t.cellSize), r = Math.floor(e.maxX / t.cellSize), s = Math.floor(e.minY / t.cellSize), l = Math.floor(e.maxY / t.cellSize);
980
+ for (let a = i; a <= r; a += 1)
981
+ for (let c = s; c <= l; c += 1) {
982
+ const _ = t.cells.get(Hn(a, c));
983
+ if (_)
984
+ for (const f of _)
985
+ f.worldBBox && Wt(e, f.worldBBox) && o.add(f);
985
986
  }
986
- for (const s of t.overflow)
987
- (!s.worldBBox || qt(e, s.worldBBox)) && o.add(s);
988
- return Array.from(o).sort((s, u) => s.sceneInstanceId - u.sceneInstanceId);
989
- }
990
- function $o(t, n = {}) {
991
- if (!rt(t))
992
- return An();
993
- const e = new DataView(t), { sections: o } = mt(t), a = X(o, 1, "SCENE_META"), r = _t(t, a, "SCENE_META");
994
- if (!nn(r))
995
- return An();
996
- const i = X(o, 5, "VARIANT_TABLE");
997
- if (i.length % 60 !== 0)
998
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
999
- const c = i.length / 60, s = Vt(r, c), u = s.reduce((A, E) => A + E.raw_size, 0), h = n.viewport === void 0 ? void 0 : n.viewport, d = (A, E) => {
1000
- const p = Array.from(A).sort((U, V) => U - V), b = s.map((U) => U.id).filter((U) => !A.has(U)).sort((U, V) => U - V), S = p.reduce((U, V) => {
1001
- var k;
1002
- return U + (((k = s[V]) == null ? void 0 : k.raw_size) ?? 0);
1003
- }, 0), M = {
1004
- manifest: s,
1005
- requiredVariantIds: p,
1006
- requiredNormalBytes: S,
1007
- totalManifestBytes: u,
1008
- skippedVariantIds: b,
987
+ for (const a of t.overflow)
988
+ (!a.worldBBox || Wt(e, a.worldBBox)) && o.add(a);
989
+ return Array.from(o).sort((a, c) => a.sceneInstanceId - c.sceneInstanceId);
990
+ }
991
+ function Lo(t, n = {}) {
992
+ if (!Q(t))
993
+ return In();
994
+ const e = new DataView(t), { sections: o } = Et(t), i = P(o, 1, "SCENE_META"), r = xt(t, i, "SCENE_META");
995
+ if (!rn(r))
996
+ return In();
997
+ const s = P(o, 5, "VARIANT_TABLE");
998
+ if (s.length % 60 !== 0)
999
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1000
+ const l = s.length / 60, a = Tt(r, l), c = a.reduce((N, E) => N + E.raw_size, 0), _ = n.viewport === void 0 ? void 0 : n.viewport, f = (N, E) => {
1001
+ const V = Array.from(N).sort((B, O) => B - O), T = a.map((B) => B.id).filter((B) => !N.has(B)).sort((B, O) => B - O), C = V.reduce((B, O) => {
1002
+ var j;
1003
+ return B + (((j = a[O]) == null ? void 0 : j.raw_size) ?? 0);
1004
+ }, 0), b = {
1005
+ manifest: a,
1006
+ requiredVariantIds: V,
1007
+ requiredNormalBytes: C,
1008
+ totalManifestBytes: c,
1009
+ skippedVariantIds: T,
1009
1010
  includedSceneInstanceIds: [...E]
1010
1011
  };
1011
- return h === void 0 ? M : { ...M, viewport: h };
1012
+ return _ === void 0 ? b : { ...b, viewport: _ };
1012
1013
  };
1013
1014
  if (n.loadBlocks === !1)
1014
- return d(/* @__PURE__ */ new Set(), []);
1015
- const _ = X(o, 7, "SCENE_INSTANCE_TABLE"), f = ut(o, 8), w = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), y = Z(t, f, "V3 NESTED_INSTANCE_TABLE");
1016
- if (Number(r.variant_count ?? c) !== c)
1017
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1018
- if (Number(r.scene_instance_count ?? w.length) !== w.length)
1019
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1015
+ return f(/* @__PURE__ */ new Set(), []);
1016
+ const d = P(o, 7, "SCENE_INSTANCE_TABLE"), m = dt(o, 8), A = Z(t, d, "V3 SCENE_INSTANCE_TABLE"), y = Z(t, m, "V3 NESTED_INSTANCE_TABLE");
1017
+ if (Number(r.variant_count ?? l) !== l)
1018
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1019
+ if (Number(r.scene_instance_count ?? A.length) !== A.length)
1020
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1020
1021
  if (Number(r.nested_instance_count ?? y.length) !== y.length)
1021
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1022
- const m = /* @__PURE__ */ new Map(), x = [];
1023
- for (let A = 0; A < c; A += 1) {
1024
- const E = i.offset + A * 60, p = e.getUint32(E + 32, !0), b = e.getUint32(E + 36, !0);
1025
- if (p + b > y.length)
1026
- throw new l("E_GROUP_RANGE", `V3 variant ${A} nested range exceeds table`);
1027
- const S = s[A], M = rn(S);
1028
- x[A] = {
1029
- id: A,
1030
- nestedStart: p,
1031
- nestedCount: b,
1022
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1023
+ const x = /* @__PURE__ */ new Map(), h = [];
1024
+ for (let N = 0; N < l; N += 1) {
1025
+ const E = s.offset + N * 60, V = e.getUint32(E + 32, !0), T = e.getUint32(E + 36, !0);
1026
+ if (V + T > y.length)
1027
+ throw new u("E_GROUP_RANGE", `V3 variant ${N} nested range exceeds table`);
1028
+ const C = a[N], b = Ut(C);
1029
+ h[N] = {
1030
+ id: N,
1031
+ nestedStart: V,
1032
+ nestedCount: T,
1032
1033
  precisionOriginX: e.getFloat32(E + 48, !0),
1033
1034
  precisionOriginY: e.getFloat32(E + 52, !0),
1034
- bbox: M,
1035
- ownBBox: M
1035
+ bbox: b,
1036
+ ownBBox: b
1036
1037
  };
1037
- const U = [];
1038
- for (let V = 0; V < b; V += 1)
1039
- U.push(y[p + V].variantId);
1040
- m.set(A, U);
1038
+ const B = [];
1039
+ for (let O = 0; O < T; O += 1)
1040
+ B.push(y[V + O].variantId);
1041
+ x.set(N, B);
1041
1042
  }
1042
- At(w, y, (A) => {
1043
- if (!s[A.variantId])
1044
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A.variantId}`);
1043
+ Rt(A, y, (N) => {
1044
+ if (!a[N.variantId])
1045
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N.variantId}`);
1045
1046
  });
1046
- const G = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), R = (A, E, p) => {
1047
+ const R = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), p = (N, E, V) => {
1047
1048
  if (E > 64)
1048
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1049
- if (p.has(A))
1050
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${A}`);
1051
- if (!s[A])
1052
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A}`);
1053
- if (!N.has(A)) {
1054
- G.add(A), p.add(A);
1055
- for (const b of m.get(A) ?? [])
1056
- R(b, E + 1, p);
1057
- p.delete(A), N.add(A);
1049
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1050
+ if (V.has(N))
1051
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${N}`);
1052
+ if (!a[N])
1053
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N}`);
1054
+ if (!w.has(N)) {
1055
+ R.add(N), V.add(N);
1056
+ for (const T of x.get(N) ?? [])
1057
+ p(T, E + 1, V);
1058
+ V.delete(N), w.add(N);
1058
1059
  }
1059
- }, P = n.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), B = n.viewport == null ? null : Je(
1060
+ }, v = n.hiddenInstanceIds ?? /* @__PURE__ */ new Set(), U = n.viewport == null ? null : lo(
1060
1061
  n.viewport,
1061
- n.viewportPaddingRatio ?? Oe
1062
- ), D = n.minViewportPixelSize ?? $e, C = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Set(), O = (A, E, p) => {
1062
+ n.viewportPaddingRatio ?? ze
1063
+ ), D = n.minViewportPixelSize ?? He, $ = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Set(), Y = (N, E, V) => {
1063
1064
  if (E > 64)
1064
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1065
- if (p.has(A))
1066
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${A}`);
1067
- if (C.has(A))
1068
- return C.get(A) ?? null;
1069
- const b = x[A];
1070
- if (!b)
1071
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${A}`);
1072
- p.add(A);
1073
- let S = b.ownBBox, M = !1;
1074
- for (let U = 0; U < b.nestedCount; U += 1) {
1075
- const V = y[b.nestedStart + U], k = x[V.variantId];
1076
- if (!k)
1077
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${V.variantId}`);
1078
- const z = O(V.variantId, E + 1, p);
1079
- if ((!z || $.has(V.variantId)) && (M = !0), !z)
1065
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1066
+ if (V.has(N))
1067
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${N}`);
1068
+ if ($.has(N))
1069
+ return $.get(N) ?? null;
1070
+ const T = h[N];
1071
+ if (!T)
1072
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${N}`);
1073
+ V.add(N);
1074
+ let C = T.ownBBox, b = !1;
1075
+ for (let B = 0; B < T.nestedCount; B += 1) {
1076
+ const O = y[T.nestedStart + B], j = h[O.variantId];
1077
+ if (!j)
1078
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${O.variantId}`);
1079
+ const H = Y(O.variantId, E + 1, V);
1080
+ if ((!H || M.has(O.variantId)) && (b = !0), !H)
1080
1081
  continue;
1081
- const H = an(V, b, k);
1082
- S = Rt(S, pt(z, H));
1082
+ const X = ln(O, T, j);
1083
+ C = pt(C, It(H, X));
1083
1084
  }
1084
- return p.delete(A), C.set(A, S), (!S || M) && $.add(A), S;
1085
- }, v = [], K = (A, E, p) => {
1086
- P.has(E) || B && p && (!qt(B, p) || Qe(
1087
- p,
1085
+ return V.delete(N), $.set(N, C), (!C || b) && M.add(N), C;
1086
+ }, z = [], S = (N, E, V) => {
1087
+ v.has(E) || U && V && (!Wt(U, V) || co(
1088
+ V,
1088
1089
  n.viewport ?? null,
1089
1090
  n.worldUnitsPerPixel,
1090
1091
  D
1091
- )) || (v.push(E), R(A.variantId, 0, /* @__PURE__ */ new Set()));
1092
+ )) || (z.push(E), p(N.variantId, 0, /* @__PURE__ */ new Set()));
1092
1093
  };
1093
- if (B) {
1094
- const A = oo(t, w, (E) => {
1095
- const p = O(E.variantId, 0, /* @__PURE__ */ new Set()), b = !p || $.has(E.variantId);
1094
+ if (U) {
1095
+ const N = Eo(t, A, (E) => {
1096
+ const V = Y(E.variantId, 0, /* @__PURE__ */ new Set()), T = !V || M.has(E.variantId);
1096
1097
  return {
1097
- worldBBox: p ? pt(p, E) : null,
1098
- unknownBBox: b
1098
+ worldBBox: V ? It(V, E) : null,
1099
+ unknownBBox: T
1099
1100
  };
1100
1101
  });
1101
- for (const E of ro(A, B))
1102
- K(E.sceneInstance, E.sceneInstanceId, E.unknownBBox ? null : E.worldBBox);
1102
+ for (const E of xo(N, U))
1103
+ S(E.sceneInstance, E.sceneInstanceId, E.unknownBBox ? null : E.worldBBox);
1103
1104
  } else
1104
- w.forEach((A, E) => {
1105
- K(A, E, null);
1105
+ A.forEach((N, E) => {
1106
+ S(N, E, null);
1106
1107
  });
1107
- return d(G, v);
1108
+ return f(R, z);
1108
1109
  }
1109
- function Mo(t) {
1110
- if (!rt(t))
1110
+ function ko(t) {
1111
+ if (!Q(t))
1111
1112
  return null;
1112
- const n = vn(t);
1113
- return en(n) ? Dn(n) : null;
1113
+ const n = Fn(t);
1114
+ return sn(n) ? Yn(n) : null;
1114
1115
  }
1115
- function ao(t, n) {
1116
+ function go(t, n) {
1116
1117
  if (!Array.isArray(t) || t.length !== 4)
1117
- throw new l("E_HEADER", `${n} must be a four-number array`);
1118
+ throw new u("E_HEADER", `${n} must be a four-number array`);
1118
1119
  const e = t.map(Number);
1119
1120
  if (!e.every(Number.isFinite))
1120
- throw new l("E_HEADER", `${n} must contain finite numbers`);
1121
+ throw new u("E_HEADER", `${n} must contain finite numbers`);
1121
1122
  return [e[0], e[1], e[2], e[3]];
1122
1123
  }
1123
- function Tt(t, n, e, o) {
1124
- return ft(n, e, t.byteLength, o), Zt.decode(t.subarray(n, n + e));
1124
+ function bt(t, n, e, o) {
1125
+ return _t(n, e, t.byteLength, o), nn.decode(t.subarray(n, n + e));
1125
1126
  }
1126
- function Yn(t, n, e) {
1127
+ function jn(t, n, e) {
1127
1128
  if (n.length % 20 !== 0)
1128
- throw new l("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
1129
- const o = new DataView(t), a = [];
1129
+ throw new u("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
1130
+ const o = new DataView(t), i = [];
1130
1131
  for (let r = n.offset; r < n.offset + n.length; r += 20) {
1131
- const i = o.getUint32(r, !0), c = o.getUint32(r + 4, !0);
1132
- a.push({
1133
- name: Tt(e, i, c, "V3 layer name"),
1132
+ const s = o.getUint32(r, !0), l = o.getUint32(r + 4, !0);
1133
+ i.push({
1134
+ name: bt(e, s, l, "V3 layer name"),
1134
1135
  color: [o.getUint8(r + 8), o.getUint8(r + 9), o.getUint8(r + 10)],
1135
1136
  visible: o.getUint8(r + 11) !== 0,
1136
1137
  lw_px: o.getFloat32(r + 12, !0)
1137
1138
  });
1138
1139
  }
1139
- return a;
1140
+ return i;
1140
1141
  }
1141
- function yt(t, n, e, o, a, r) {
1142
+ function wt(t, n, e, o, i, r) {
1142
1143
  if (e + 4 > o)
1143
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
1144
- const i = n.getUint32(e, !0), c = e + 4, s = lt(t, n, c, i, o, r);
1145
- if (s.offset > o)
1146
- throw new l("E_GROUP_RANGE", `${a} exceeds section bounds`);
1144
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
1145
+ const s = n.getUint32(e, !0), l = e + 4, a = ft(t, n, l, s, o, r);
1146
+ if (a.offset > o)
1147
+ throw new u("E_GROUP_RANGE", `${i} exceeds section bounds`);
1147
1148
  return {
1148
- chunk: s.chunk,
1149
- offset: s.offset
1149
+ chunk: a.chunk,
1150
+ offset: a.offset
1150
1151
  };
1151
1152
  }
1152
- function Fn(t, n, e, o, a, r) {
1153
- const i = yt(t, n, e, o, a, r), c = e + 4;
1153
+ function qn(t, n, e, o, i, r) {
1154
+ const s = wt(t, n, e, o, i, r), l = e + 4;
1154
1155
  return {
1155
- chunk: i.chunk,
1156
+ chunk: s.chunk,
1156
1157
  snapshot: {
1157
- count: i.chunk.count,
1158
- raw: new Uint8Array(t, c, i.offset - c).slice(),
1158
+ count: s.chunk.count,
1159
+ raw: new Uint8Array(t, l, s.offset - l).slice(),
1159
1160
  groupLayerEncoding: r
1160
1161
  },
1161
- offset: i.offset
1162
+ offset: s.offset
1162
1163
  };
1163
1164
  }
1164
- function wt(t = "u8") {
1165
+ function At(t = "u8") {
1165
1166
  return {
1166
1167
  chunk: { pos: new Float32Array(0), col: new Uint8Array(0), lay: new Uint8Array(0), count: 0 },
1167
1168
  snapshot: { count: 0, raw: new Uint8Array(0), groupLayerEncoding: t }
1168
1169
  };
1169
1170
  }
1170
- function io(t = "u8") {
1171
+ function Kn(t = "u8") {
1171
1172
  return {
1172
- line: wt(t),
1173
- fill: wt(t),
1174
- dot: wt(t)
1173
+ line: At(t),
1174
+ fill: At(t),
1175
+ dot: At(t)
1175
1176
  };
1176
1177
  }
1177
- function so(t, n, e) {
1178
+ function Wn(t, n, e) {
1178
1179
  var o;
1179
1180
  return !!(n && e && t.deferExternalVariantGeometry && !((o = t.externalVariantBuffers) != null && o.has(n.id)));
1180
1181
  }
1181
- function St(t, n, e, o, a, r, i) {
1182
- if (a === 0)
1183
- return wt(i);
1184
- ft(o, a, e.length, r);
1185
- const c = e.offset + o, s = c + a, u = Fn(t, n, c, s, r, i);
1186
- if (u.offset !== s)
1187
- throw new l("E_GROUP_RANGE", `${r} has trailing bytes`);
1188
- return { chunk: u.chunk, snapshot: u.snapshot };
1182
+ function Ot(t, n, e, o, i, r, s) {
1183
+ if (i === 0)
1184
+ return At(s);
1185
+ _t(o, i, e.length, r);
1186
+ const l = e.offset + o, a = l + i, c = qn(t, n, l, a, r, s);
1187
+ if (c.offset !== a)
1188
+ throw new u("E_GROUP_RANGE", `${r} has trailing bytes`);
1189
+ return { chunk: c.chunk, snapshot: c.snapshot };
1189
1190
  }
1190
- function kn(t, n, e) {
1191
+ function an(t, n, e) {
1191
1192
  if ([
1192
1193
  t.getUint32(n + 8, !0),
1193
1194
  t.getUint32(n + 12, !0),
@@ -1195,206 +1196,233 @@ function kn(t, n, e) {
1195
1196
  t.getUint32(n + 20, !0),
1196
1197
  t.getUint32(n + 24, !0),
1197
1198
  t.getUint32(n + 28, !0)
1198
- ].some((a) => a !== 0))
1199
- throw new l("E_GROUP_RANGE", `V3 external variant ${e} must use zero inline geometry offsets`);
1199
+ ].some((i) => i !== 0))
1200
+ throw new u("E_GROUP_RANGE", `V3 external variant ${e} must use zero inline geometry offsets`);
1200
1201
  }
1201
- function st(t, n, e, o, a, r) {
1202
- const i = Fn(t, n, e, t.byteLength, a, r);
1203
- if (i.chunk.count !== o)
1204
- throw new l(
1202
+ function lt(t, n, e, o, i, r) {
1203
+ const s = qn(t, n, e, t.byteLength, i, r);
1204
+ if (s.chunk.count !== o)
1205
+ throw new u(
1205
1206
  "E_GROUP_RANGE",
1206
- `${a} vertex_count mismatch: manifest=${o}, sidecar=${i.chunk.count}`
1207
+ `${i} vertex_count mismatch: manifest=${o}, sidecar=${s.chunk.count}`
1207
1208
  );
1208
- return i;
1209
+ return s;
1209
1210
  }
1210
- function on(t) {
1211
+ function Bt(t) {
1211
1212
  return "normal" in t ? t.normal : t;
1212
1213
  }
1213
- function co(t, n, e) {
1214
- const o = on(t), a = new DataView(n);
1214
+ function ho(t, n, e) {
1215
+ const o = Bt(t), i = new DataView(n);
1215
1216
  let r = 0;
1216
- const i = st(n, a, r, o.line_count, `V3 external variant ${t.id} line blob`, e);
1217
- r = i.offset;
1218
- const c = st(n, a, r, o.fill_count, `V3 external variant ${t.id} fill blob`, e);
1219
- r = c.offset;
1220
- const s = st(n, a, r, o.dot_count, `V3 external variant ${t.id} dot blob`, e);
1221
- if (r = s.offset, r !== n.byteLength)
1222
- throw new l("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
1217
+ const s = lt(n, i, r, o.line_count, `V3 external variant ${t.id} line blob`, e);
1218
+ r = s.offset;
1219
+ const l = lt(n, i, r, o.fill_count, `V3 external variant ${t.id} fill blob`, e);
1220
+ r = l.offset;
1221
+ const a = lt(n, i, r, o.dot_count, `V3 external variant ${t.id} dot blob`, e);
1222
+ if (r = a.offset, r !== n.byteLength)
1223
+ throw new u("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
1223
1224
  return {
1224
- line: { chunk: i.chunk, snapshot: i.snapshot },
1225
- fill: { chunk: c.chunk, snapshot: c.snapshot },
1226
- dot: { chunk: s.chunk, snapshot: s.snapshot }
1225
+ line: { chunk: s.chunk, snapshot: s.snapshot },
1226
+ fill: { chunk: l.chunk, snapshot: l.snapshot },
1227
+ dot: { chunk: a.chunk, snapshot: a.snapshot }
1227
1228
  };
1228
1229
  }
1229
- function lo(t, n) {
1230
- const e = Jt(n), o = et(e, 257, "BLOCK_NORMAL_GEOMETRY"), a = new DataView(n);
1230
+ function yo(t, n) {
1231
+ const e = tn(n), o = ot(e, 257, "BLOCK_NORMAL_GEOMETRY"), i = new DataView(n);
1231
1232
  let r = o.offset;
1232
- const i = o.offset + o.length, c = Wt(e.versionMinor), s = st(n, a, r, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, c);
1233
- r = s.offset;
1234
- const u = st(n, a, r, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, c);
1235
- r = u.offset;
1236
- const h = st(n, a, r, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, c);
1237
- if (r = h.offset, r !== i)
1238
- throw new l("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
1233
+ const s = o.offset + o.length, l = Qt(e.versionMinor), a = lt(n, i, r, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, l);
1234
+ r = a.offset;
1235
+ const c = lt(n, i, r, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, l);
1236
+ r = c.offset;
1237
+ const _ = lt(n, i, r, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, l);
1238
+ if (r = _.offset, r !== s)
1239
+ throw new u("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
1239
1240
  return {
1240
- line: { chunk: s.chunk, snapshot: s.snapshot },
1241
- fill: { chunk: u.chunk, snapshot: u.snapshot },
1242
- dot: { chunk: h.chunk, snapshot: h.snapshot }
1241
+ line: { chunk: a.chunk, snapshot: a.snapshot },
1242
+ fill: { chunk: c.chunk, snapshot: c.snapshot },
1243
+ dot: { chunk: _.chunk, snapshot: _.snapshot }
1243
1244
  };
1244
1245
  }
1245
- function uo(t, n, e = "u8") {
1246
+ function wo(t, n, e = "u8") {
1246
1247
  if (n.byteLength !== t.raw_size)
1247
- throw new l(
1248
+ throw new u(
1248
1249
  "E_GROUP_RANGE",
1249
1250
  `V3 external variant ${t.id} raw_size mismatch: manifest=${t.raw_size}, sidecar=${n.byteLength}`
1250
1251
  );
1251
- return "normal" in t ? lo(t, n) : co(t, n, e);
1252
+ return "normal" in t ? yo(t, n) : ho(t, n, e);
1252
1253
  }
1253
- function fo(t, n, e) {
1254
+ function Jn(t, n, e) {
1254
1255
  const o = n == null ? void 0 : n.get(t.id);
1255
1256
  if (!o)
1256
- throw new l("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
1257
- return uo(t, o, e);
1257
+ throw new u("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
1258
+ return wo(t, o, e);
1258
1259
  }
1259
- function Ct(t, n, e, o, a) {
1260
+ function $t(t, n, e, o, i) {
1260
1261
  if (o === 0)
1261
1262
  return 0;
1262
- if (ft(e, o, n.length, a), o < 4)
1263
- throw new l("E_GROUP_RANGE", `Missing ${a} vertex_count`);
1263
+ if (_t(e, o, n.length, i), o < 4)
1264
+ throw new u("E_GROUP_RANGE", `Missing ${i} vertex_count`);
1264
1265
  return t.getUint32(n.offset + e, !0);
1265
1266
  }
1266
- function mo(t, n, e, o) {
1267
- const a = e.offset + e.length;
1267
+ function Ao(t, n, e, o) {
1268
+ const i = e.offset + e.length;
1268
1269
  let r = e.offset;
1269
- const i = yt(t, n, r, a, "V3 BASE_GEOMETRY line", o);
1270
- r = i.offset;
1271
- const c = yt(t, n, r, a, "V3 BASE_GEOMETRY fill", o);
1272
- r = c.offset;
1273
- const s = yt(t, n, r, a, "V3 BASE_GEOMETRY dot", o);
1274
- if (r = s.offset, r !== a)
1275
- throw new l("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
1270
+ const s = wt(t, n, r, i, "V3 BASE_GEOMETRY line", o);
1271
+ r = s.offset;
1272
+ const l = wt(t, n, r, i, "V3 BASE_GEOMETRY fill", o);
1273
+ r = l.offset;
1274
+ const a = wt(t, n, r, i, "V3 BASE_GEOMETRY dot", o);
1275
+ if (r = a.offset, r !== i)
1276
+ throw new u("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
1276
1277
  return {
1277
- line: i.chunk,
1278
- fill: c.chunk,
1279
- dot: s.chunk
1278
+ line: s.chunk,
1279
+ fill: l.chunk,
1280
+ dot: a.chunk
1280
1281
  };
1281
1282
  }
1282
- function Ot(t) {
1283
- return Ee(t.pos, t.count, 2);
1283
+ function Mt(t) {
1284
+ return Ge(t.pos, t.count, 2);
1284
1285
  }
1285
- function _o(t, n, e) {
1286
- return Rt(Rt(Ot(t), Ot(n)), Ot(e));
1286
+ function Zn(t, n, e) {
1287
+ return pt(pt(Mt(t), Mt(n)), Mt(e));
1287
1288
  }
1288
- function rn(t) {
1289
- return "normal" in t ? We(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
1289
+ function Ut(t) {
1290
+ return "normal" in t ? ao(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
1290
1291
  }
1291
- function ho(t, n, e, o, a, r, i, c) {
1292
+ function Ro(t, n, e, o, i, r, s, l) {
1292
1293
  if (e.length % 60 !== 0)
1293
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1294
- const s = [], u = /* @__PURE__ */ new Map(), h = [], d = e.length / 60;
1295
- for (let _ = 0; _ < d; _ += 1) {
1296
- const f = e.offset + _ * 60, w = n.getUint32(f, !0), y = n.getUint32(f + 4, !0), m = (r == null ? void 0 : r[_]) ?? null, x = !m || !c.requiredExternalVariantIds || c.requiredExternalVariantIds.has(_), G = so(c, m, x), N = m ? (kn(n, f, _), !x || G ? io(i) : fo(m, c.externalVariantBuffers, i)) : {
1297
- line: St(
1294
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1295
+ const a = [], c = /* @__PURE__ */ new Map(), _ = [], f = e.length / 60;
1296
+ for (let d = 0; d < f; d += 1) {
1297
+ const m = e.offset + d * 60, A = n.getUint32(m, !0), y = n.getUint32(m + 4, !0), x = (r == null ? void 0 : r[d]) ?? null, h = !x || !l.requiredExternalVariantIds || l.requiredExternalVariantIds.has(d), R = Wn(l, x, h), w = x ? (an(n, m, d), !h || R ? Kn(s) : Jn(x, l.externalVariantBuffers, s)) : {
1298
+ line: Ot(
1298
1299
  t,
1299
1300
  n,
1300
1301
  o,
1301
- n.getUint32(f + 8, !0),
1302
- n.getUint32(f + 12, !0),
1303
- `V3 variant ${_} line blob`,
1304
- i
1302
+ n.getUint32(m + 8, !0),
1303
+ n.getUint32(m + 12, !0),
1304
+ `V3 variant ${d} line blob`,
1305
+ s
1305
1306
  ),
1306
- fill: St(
1307
+ fill: Ot(
1307
1308
  t,
1308
1309
  n,
1309
1310
  o,
1310
- n.getUint32(f + 16, !0),
1311
- n.getUint32(f + 20, !0),
1312
- `V3 variant ${_} fill blob`,
1313
- i
1311
+ n.getUint32(m + 16, !0),
1312
+ n.getUint32(m + 20, !0),
1313
+ `V3 variant ${d} fill blob`,
1314
+ s
1314
1315
  ),
1315
- dot: St(
1316
+ dot: Ot(
1316
1317
  t,
1317
1318
  n,
1318
1319
  o,
1319
- n.getUint32(f + 24, !0),
1320
- n.getUint32(f + 28, !0),
1321
- `V3 variant ${_} dot blob`,
1322
- i
1320
+ n.getUint32(m + 24, !0),
1321
+ n.getUint32(m + 28, !0),
1322
+ `V3 variant ${d} dot blob`,
1323
+ s
1323
1324
  )
1324
- }, R = m ? on(m) : null, P = (R == null ? void 0 : R.line_count) ?? N.line.chunk.count, B = (R == null ? void 0 : R.fill_count) ?? N.fill.chunk.count, D = (R == null ? void 0 : R.dot_count) ?? N.dot.chunk.count, C = m && (!x || G) ? rn(m) : _o(N.line.chunk, N.fill.chunk, N.dot.chunk), $ = {
1325
- id: _,
1326
- name: Tt(a, w, y, `V3 variant ${_} name`),
1327
- line_count: G ? P : N.line.chunk.count,
1328
- fill_count: G ? B : N.fill.chunk.count,
1329
- dot_count: G ? D : N.dot.chunk.count,
1330
- sourceLineCount: P,
1331
- sourceFillCount: B,
1325
+ }, p = x ? Bt(x) : null, v = (p == null ? void 0 : p.line_count) ?? w.line.chunk.count, U = (p == null ? void 0 : p.fill_count) ?? w.fill.chunk.count, D = (p == null ? void 0 : p.dot_count) ?? w.dot.chunk.count, $ = x && (!h || R) ? Ut(x) : Zn(w.line.chunk, w.fill.chunk, w.dot.chunk), M = {
1326
+ id: d,
1327
+ name: bt(i, A, y, `V3 variant ${d} name`),
1328
+ line_count: R ? v : w.line.chunk.count,
1329
+ fill_count: R ? U : w.fill.chunk.count,
1330
+ dot_count: R ? D : w.dot.chunk.count,
1331
+ sourceLineCount: v,
1332
+ sourceFillCount: U,
1332
1333
  sourceDotCount: D,
1333
- nestedStart: n.getUint32(f + 32, !0),
1334
- nestedCount: n.getUint32(f + 36, !0),
1335
- textStart: n.getUint32(f + 40, !0),
1336
- textCount: n.getUint32(f + 44, !0),
1337
- precisionOriginX: n.getFloat32(f + 48, !0),
1338
- precisionOriginY: n.getFloat32(f + 52, !0),
1339
- lineSnapshot: N.line.snapshot,
1340
- fillSnapshot: N.fill.snapshot,
1341
- dotSnapshot: N.dot.snapshot,
1342
- bbox: C
1334
+ nestedStart: n.getUint32(m + 32, !0),
1335
+ nestedCount: n.getUint32(m + 36, !0),
1336
+ textStart: n.getUint32(m + 40, !0),
1337
+ textCount: n.getUint32(m + 44, !0),
1338
+ precisionOriginX: n.getFloat32(m + 48, !0),
1339
+ precisionOriginY: n.getFloat32(m + 52, !0),
1340
+ lineSnapshot: w.line.snapshot,
1341
+ fillSnapshot: w.fill.snapshot,
1342
+ dotSnapshot: w.dot.snapshot,
1343
+ bbox: $
1343
1344
  };
1344
- s.push($), u.set(_, { line: N.line.chunk, fill: N.fill.chunk, dot: N.dot.chunk }), h.push({ line: N.line.snapshot, fill: N.fill.snapshot, dot: N.dot.snapshot });
1345
+ a.push(M), c.set(d, { line: w.line.chunk, fill: w.fill.chunk, dot: w.dot.chunk }), _.push({ line: w.line.snapshot, fill: w.fill.snapshot, dot: w.dot.snapshot });
1345
1346
  }
1346
- return { variantsById: s, variants: u, snapshots: h };
1347
+ return { variantsById: a, variants: c, snapshots: _ };
1347
1348
  }
1348
- function zn(t, n, e, o, a) {
1349
+ function Jt(t, n, e, o, i) {
1349
1350
  if (n.length % 60 !== 0)
1350
- throw new l("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1351
- const r = [], i = n.length / 60;
1352
- for (let c = 0; c < i; c += 1) {
1353
- const s = n.offset + c * 60, u = t.getUint32(s, !0), h = t.getUint32(s + 4, !0), d = (a == null ? void 0 : a[c]) ?? null;
1354
- d && kn(t, s, c);
1355
- const _ = d ? on(d) : null, f = t.getFloat32(s + 48, !0), w = t.getFloat32(s + 52, !0);
1351
+ throw new u("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
1352
+ const r = [], s = n.length / 60;
1353
+ for (let l = 0; l < s; l += 1) {
1354
+ const a = n.offset + l * 60, c = t.getUint32(a, !0), _ = t.getUint32(a + 4, !0), f = (i == null ? void 0 : i[l]) ?? null;
1355
+ f && an(t, a, l);
1356
+ const d = f ? Bt(f) : null, m = t.getFloat32(a + 48, !0), A = t.getFloat32(a + 52, !0);
1356
1357
  r.push({
1357
- id: c,
1358
- name: Tt(o, u, h, `V3 variant ${c} name`),
1359
- line_count: d ? _.line_count : Ct(
1358
+ id: l,
1359
+ name: bt(o, c, _, `V3 variant ${l} name`),
1360
+ line_count: f ? d.line_count : $t(
1360
1361
  t,
1361
1362
  e,
1362
- t.getUint32(s + 8, !0),
1363
- t.getUint32(s + 12, !0),
1364
- `V3 variant ${c} line blob`
1363
+ t.getUint32(a + 8, !0),
1364
+ t.getUint32(a + 12, !0),
1365
+ `V3 variant ${l} line blob`
1365
1366
  ),
1366
- fill_count: d ? _.fill_count : Ct(
1367
+ fill_count: f ? d.fill_count : $t(
1367
1368
  t,
1368
1369
  e,
1369
- t.getUint32(s + 16, !0),
1370
- t.getUint32(s + 20, !0),
1371
- `V3 variant ${c} fill blob`
1370
+ t.getUint32(a + 16, !0),
1371
+ t.getUint32(a + 20, !0),
1372
+ `V3 variant ${l} fill blob`
1372
1373
  ),
1373
- dot_count: d ? _.dot_count : Ct(
1374
+ dot_count: f ? d.dot_count : $t(
1374
1375
  t,
1375
1376
  e,
1376
- t.getUint32(s + 24, !0),
1377
- t.getUint32(s + 28, !0),
1378
- `V3 variant ${c} dot blob`
1377
+ t.getUint32(a + 24, !0),
1378
+ t.getUint32(a + 28, !0),
1379
+ `V3 variant ${l} dot blob`
1379
1380
  ),
1380
- nestedStart: t.getUint32(s + 32, !0),
1381
- nestedCount: t.getUint32(s + 36, !0),
1382
- textStart: t.getUint32(s + 40, !0),
1383
- textCount: t.getUint32(s + 44, !0),
1384
- precisionOriginX: f,
1385
- precisionOriginY: w,
1386
- bbox: d ? rn(d) : null
1381
+ nestedStart: t.getUint32(a + 32, !0),
1382
+ nestedCount: t.getUint32(a + 36, !0),
1383
+ textStart: t.getUint32(a + 40, !0),
1384
+ textCount: t.getUint32(a + 44, !0),
1385
+ precisionOriginX: m,
1386
+ precisionOriginY: A,
1387
+ bbox: f ? Ut(f) : null
1387
1388
  });
1388
1389
  }
1389
1390
  return r;
1390
1391
  }
1392
+ function No(t, n, e) {
1393
+ var l;
1394
+ const o = new DataView(t), i = [], r = /* @__PURE__ */ new Map(), s = [];
1395
+ for (const a of n.variantHeaders) {
1396
+ const c = ((l = n.externalVariants) == null ? void 0 : l[a.id]) ?? null, _ = !c || !e.requiredExternalVariantIds || e.requiredExternalVariantIds.has(a.id), f = Wn(e, c, _), d = c ? (() => {
1397
+ const w = n.sections.get(5).offset + a.id * 60;
1398
+ return an(o, w, a.id), !_ || f ? Kn(n.groupLayerEncoding) : Jn(c, e.externalVariantBuffers, n.groupLayerEncoding);
1399
+ })() : n.internalVariants.get(a.id);
1400
+ if (!d)
1401
+ throw new u("E_GROUP_RANGE", `Missing cached V3 variant geometry for variant ${a.id}`);
1402
+ const m = c ? Bt(c) : null, A = (m == null ? void 0 : m.line_count) ?? d.line.chunk.count, y = (m == null ? void 0 : m.fill_count) ?? d.fill.chunk.count, x = (m == null ? void 0 : m.dot_count) ?? d.dot.chunk.count, h = c && (!_ || f) ? Ut(c) : Zn(d.line.chunk, d.fill.chunk, d.dot.chunk), R = {
1403
+ ...a,
1404
+ line_count: f ? A : d.line.chunk.count,
1405
+ fill_count: f ? y : d.fill.chunk.count,
1406
+ dot_count: f ? x : d.dot.chunk.count,
1407
+ sourceLineCount: A,
1408
+ sourceFillCount: y,
1409
+ sourceDotCount: x,
1410
+ lineSnapshot: d.line.snapshot,
1411
+ fillSnapshot: d.fill.snapshot,
1412
+ dotSnapshot: d.dot.snapshot,
1413
+ bbox: h
1414
+ };
1415
+ i.push(R), r.set(a.id, { line: d.line.chunk, fill: d.fill.chunk, dot: d.dot.chunk }), s.push({ line: d.line.snapshot, fill: d.fill.snapshot, dot: d.dot.snapshot });
1416
+ }
1417
+ return { variantsById: i, variants: r, snapshots: s };
1418
+ }
1391
1419
  function Z(t, n, e) {
1392
1420
  if (n.length % 32 !== 0)
1393
- throw new l("E_GROUP_RANGE", `${e} length must be a multiple of 32`);
1394
- const o = new DataView(t), a = [];
1421
+ throw new u("E_GROUP_RANGE", `${e} length must be a multiple of 32`);
1422
+ const o = new DataView(t), i = [];
1395
1423
  for (let r = n.offset; r < n.offset + n.length; r += 32) {
1396
- const i = o.getUint16(r + 30, !0);
1397
- Ao(i), a.push({
1424
+ const s = o.getUint16(r + 30, !0);
1425
+ bo(s), i.push({
1398
1426
  variantId: o.getUint32(r, !0),
1399
1427
  matA: o.getFloat32(r + 4, !0),
1400
1428
  matB: o.getFloat32(r + 8, !0),
@@ -1403,44 +1431,44 @@ function Z(t, n, e) {
1403
1431
  tx: o.getFloat32(r + 20, !0),
1404
1432
  ty: o.getFloat32(r + 24, !0),
1405
1433
  insLayerIdx: o.getUint16(r + 28, !0),
1406
- flags: i
1434
+ flags: s
1407
1435
  });
1408
1436
  }
1409
- return a;
1437
+ return i;
1410
1438
  }
1411
- function Eo(t, n, e) {
1412
- const o = t.getUint32(n, !0), a = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), i = t.getUint8(n + 43), c = t.getFloat32(n + 24, !0), s = t.getFloat32(n + 28, !0);
1439
+ function po(t, n, e) {
1440
+ const o = t.getUint32(n, !0), i = t.getUint32(n + 4, !0), r = t.getUint8(n + 42), s = t.getUint8(n + 43), l = t.getFloat32(n + 24, !0), a = t.getFloat32(n + 28, !0);
1413
1441
  return {
1414
- t: Tt(e, o, a, "V3 text value"),
1442
+ t: bt(e, o, i, "V3 text value"),
1415
1443
  x: t.getFloat32(n + 8, !0),
1416
1444
  y: t.getFloat32(n + 12, !0),
1417
1445
  h: t.getFloat32(n + 16, !0),
1418
1446
  r: t.getFloat32(n + 20, !0),
1419
1447
  c: [t.getUint8(n + 36), t.getUint8(n + 37), t.getUint8(n + 38)],
1420
1448
  li: t.getUint16(n + 40, !0),
1421
- ha: De[r & 3] ?? "left",
1422
- va: ve[r >> 2 & 3] ?? "alphabetic",
1449
+ ha: Ke[r & 3] ?? "left",
1450
+ va: We[r >> 2 & 3] ?? "alphabetic",
1423
1451
  lh: t.getFloat32(n + 32, !0),
1424
- ...c ? { w: c } : {},
1425
- ...s !== 1 ? { wf: s } : {},
1426
- ...i & 1 ? { mx: !0 } : {},
1427
- ...i & 2 ? { my: !0 } : {}
1452
+ ...l ? { w: l } : {},
1453
+ ...a !== 1 ? { wf: a } : {},
1454
+ ...s & 1 ? { mx: !0 } : {},
1455
+ ...s & 2 ? { my: !0 } : {}
1428
1456
  };
1429
1457
  }
1430
- function $t(t, n, e, o) {
1458
+ function vt(t, n, e, o) {
1431
1459
  if (n.length % 44 !== 0)
1432
- throw new l("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
1433
- const a = [], r = new DataView(t);
1434
- for (let i = n.offset; i < n.offset + n.length; i += 44)
1435
- a.push(Eo(r, i, e));
1436
- return a;
1460
+ throw new u("E_GROUP_RANGE", `${o} length must be a multiple of 44`);
1461
+ const i = [], r = new DataView(t);
1462
+ for (let s = n.offset; s < n.offset + n.length; s += 44)
1463
+ i.push(po(r, s, e));
1464
+ return i;
1437
1465
  }
1438
- function xo(t, n) {
1466
+ function Io(t, n) {
1439
1467
  if (t.length % 44 !== 0)
1440
- throw new l("E_GROUP_RANGE", `${n} length must be a multiple of 44`);
1468
+ throw new u("E_GROUP_RANGE", `${n} length must be a multiple of 44`);
1441
1469
  return t.length / 44;
1442
1470
  }
1443
- function Hn(t, n, e, o) {
1471
+ function Qn(t, n, e, o) {
1444
1472
  return {
1445
1473
  instanceId: e,
1446
1474
  variantId: n.variantId,
@@ -1453,187 +1481,189 @@ function Hn(t, n, e, o) {
1453
1481
  insLayerIdx: o
1454
1482
  };
1455
1483
  }
1456
- function jn(t, n, e, o) {
1484
+ function te(t, n, e, o) {
1457
1485
  var y;
1458
- const a = ((y = o[n.insLayerIdx]) == null ? void 0 : y.visible) === !1, r = n.matA * t.x + n.matC * t.y + n.tx, i = n.matB * t.x + n.matD * t.y + n.ty, c = Math.hypot(n.matA, n.matB), s = Math.hypot(n.matC, n.matD), u = s > 1e-12 ? s : c > 1e-12 ? c : 1, h = c > 1e-12 && u > 1e-12 ? c / u : 1, d = go(t, n), { mx: _, my: f, ...w } = t;
1486
+ const i = ((y = o[n.insLayerIdx]) == null ? void 0 : y.visible) === !1, r = n.matA * t.x + n.matC * t.y + n.tx, s = n.matB * t.x + n.matD * t.y + n.ty, l = Math.hypot(n.matA, n.matB), a = Math.hypot(n.matC, n.matD), c = a > 1e-12 ? a : l > 1e-12 ? l : 1, _ = l > 1e-12 && c > 1e-12 ? l / c : 1, f = Vo(t, n), { mx: d, my: m, ...A } = t;
1459
1487
  return {
1460
- ...w,
1488
+ ...A,
1461
1489
  x: r,
1462
- y: i,
1463
- h: t.h * u,
1464
- w: t.w === void 0 ? void 0 : t.w * u,
1465
- wf: (t.wf ?? 1) * h,
1466
- r: d.r,
1467
- ...d.mx ? { mx: !0 } : {},
1468
- ...d.my ? { my: !0 } : {},
1469
- li: a || t.li === e ? n.insLayerIdx : t.li
1490
+ y: s,
1491
+ h: t.h * c,
1492
+ w: t.w === void 0 ? void 0 : t.w * c,
1493
+ wf: (t.wf ?? 1) * _,
1494
+ r: f.r,
1495
+ ...f.mx ? { mx: !0 } : {},
1496
+ ...f.my ? { my: !0 } : {},
1497
+ li: i || t.li === e ? n.insLayerIdx : t.li
1470
1498
  };
1471
1499
  }
1472
- function go(t, n) {
1473
- const e = t.r * Math.PI / 180, o = Math.cos(e), a = Math.sin(e), r = t.mx ? -1 : 1, i = t.my ? -1 : 1, c = r * (n.matA * o + n.matC * a), s = r * (n.matB * o + n.matD * a), u = i * (n.matC * o - n.matA * a), h = i * (n.matD * o - n.matB * a), d = c * h - s * u, _ = Math.atan2(s, c) * 180 / Math.PI;
1474
- return d < 0 ? { r: Math.atan2(-s, -c) * 180 / Math.PI, mx: !0 } : { r: _ };
1500
+ function Vo(t, n) {
1501
+ const e = t.r * Math.PI / 180, o = Math.cos(e), i = Math.sin(e), r = t.mx ? -1 : 1, s = t.my ? -1 : 1, l = r * (n.matA * o + n.matC * i), a = r * (n.matB * o + n.matD * i), c = s * (n.matC * o - n.matA * i), _ = s * (n.matD * o - n.matB * i), f = l * _ - a * c, d = Math.atan2(a, l) * 180 / Math.PI;
1502
+ return f < 0 ? { r: Math.atan2(-a, -l) * 180 / Math.PI, mx: !0 } : { r: d };
1475
1503
  }
1476
- function Mt(t, n, e, o) {
1477
- var c;
1504
+ function Pt(t, n, e, o) {
1505
+ var l;
1478
1506
  if (t.count === 0)
1479
- return It();
1480
- const a = new Float32Array(t.count * 2);
1481
- for (let s = 0; s < t.count; s += 1) {
1482
- const u = s * 2, h = t.pos[u], d = t.pos[u + 1];
1483
- a[u] = n.matA * h + n.matC * d + n.tx, a[u + 1] = n.matB * h + n.matD * d + n.ty;
1507
+ return Vt();
1508
+ const i = new Float32Array(t.count * 2);
1509
+ for (let a = 0; a < t.count; a += 1) {
1510
+ const c = a * 2, _ = t.pos[c], f = t.pos[c + 1];
1511
+ i[c] = n.matA * _ + n.matC * f + n.tx, i[c + 1] = n.matB * _ + n.matD * f + n.ty;
1484
1512
  }
1485
- const r = ((c = o[n.insLayerIdx]) == null ? void 0 : c.visible) === !1, i = Cn(
1486
- ot(t),
1487
- (s) => r || s === e ? n.insLayerIdx : s
1513
+ const r = ((l = o[n.insLayerIdx]) == null ? void 0 : l.visible) === !1, s = vn(
1514
+ rt(t),
1515
+ (a) => r || a === e ? n.insLayerIdx : a
1488
1516
  );
1489
- return { pos: a, count: t.count, segments: i };
1517
+ return { pos: i, count: t.count, segments: s };
1490
1518
  }
1491
- function Pt(t) {
1492
- const n = t.reduce((r, i) => r + i.count, 0);
1519
+ function Dt(t) {
1520
+ const n = t.reduce((r, s) => r + s.count, 0);
1493
1521
  if (n === 0)
1494
- return It();
1522
+ return Vt();
1495
1523
  const e = new Float32Array(n * 2), o = [];
1496
- let a = 0;
1524
+ let i = 0;
1497
1525
  for (const r of t)
1498
- e.set(r.pos, a * 2), o.push(...Ht(ot(r), a)), a += r.count;
1499
- return { pos: e, count: n, segments: dt(o) };
1526
+ e.set(r.pos, i * 2), o.push(...qt(rt(r), i)), i += r.count;
1527
+ return { pos: e, count: n, segments: mt(o) };
1500
1528
  }
1501
- function qn(t, n) {
1529
+ function ne(t, n) {
1502
1530
  return t === n ? n : t;
1503
1531
  }
1504
- function Kn(t, n, e) {
1532
+ function ee(t, n, e) {
1505
1533
  return t === e ? n : t;
1506
1534
  }
1507
- function Wn(t, n) {
1508
- const e = new DataView(t), { versionMinor: o, sections: a } = mt(t), r = Wt(o), i = X(a, 1, "SCENE_META"), c = X(a, 2, "LAYER_TABLE"), s = X(a, 3, "STRING_TABLE"), u = X(a, 4, "BASE_GEOMETRY"), h = X(a, 5, "VARIANT_TABLE"), d = X(a, 6, "VARIANT_GEOMETRY"), _ = X(a, 7, "SCENE_INSTANCE_TABLE"), f = ut(a, 8), w = ut(a, 9), y = ut(a, 10), m = _t(t, i, "SCENE_META"), x = nn(m) ? Vt(m, h.length / 60) : null, G = en(m), N = G ? Dn(m) : null, R = Ke(m, x, G), P = G ? "nested_instanced_external_annotations" : x ? "nested_instanced_external" : "nested_instanced", B = new Uint8Array(t, s.offset, s.length), D = Yn(t, c, B), C = Number(m.layer0_index ?? 0), $ = Qt({
1509
- bounds: m.bounds ?? [0, 0, 0, 0],
1510
- entity_count: Number(m.entity_count ?? 0),
1511
- line_count: Number(m.base_line_count ?? 0),
1512
- fill_count: Number(m.base_fill_count ?? 0),
1513
- dot_count: Number(m.base_dot_count ?? 0),
1514
- layers: D,
1535
+ function oe(t, n, e) {
1536
+ const o = new DataView(t), i = e ? void 0 : Et(t), r = (e == null ? void 0 : e.versionMinor) ?? i.versionMinor, s = (e == null ? void 0 : e.sections) ?? i.sections, l = (e == null ? void 0 : e.groupLayerEncoding) ?? Qt(r), a = e ? e.sections.get(1) : P(s, 1, "SCENE_META"), c = e ? e.sections.get(2) : P(s, 2, "LAYER_TABLE"), _ = e ? e.sections.get(3) : P(s, 3, "STRING_TABLE"), f = e ? e.sections.get(4) : P(s, 4, "BASE_GEOMETRY"), d = e ? e.sections.get(5) : P(s, 5, "VARIANT_TABLE"), m = e ? e.sections.get(6) : P(s, 6, "VARIANT_GEOMETRY"), A = e ? e.sections.get(7) : P(s, 7, "SCENE_INSTANCE_TABLE"), y = (e == null ? void 0 : e.sections.get(8)) ?? dt(s, 8), x = (e == null ? void 0 : e.sections.get(9)) ?? dt(s, 9), h = (e == null ? void 0 : e.sections.get(10)) ?? dt(s, 10), R = (e == null ? void 0 : e.sceneMeta) ?? xt(t, a, "SCENE_META"), w = (e == null ? void 0 : e.externalVariants) ?? (rn(R) ? Tt(R, d.length / 60) : null), p = sn(R), v = (e == null ? void 0 : e.externalAnnotations) ?? (p ? Yn(R) : null), U = (e == null ? void 0 : e.geoMetaFeatures) ?? so(R, w, p), D = (e == null ? void 0 : e.geoMetaEncoding) ?? (p ? "nested_instanced_external_annotations" : w ? "nested_instanced_external" : "nested_instanced"), $ = (e == null ? void 0 : e.stringTable) ?? new Uint8Array(t, _.offset, _.length), M = e != null && e.layers ? [...e.layers] : jn(t, c, $), Y = (e == null ? void 0 : e.layer0Index) ?? Number(R.layer0_index ?? 0), z = (e == null ? void 0 : e.headerForValidation) ?? en({
1537
+ bounds: R.bounds ?? [0, 0, 0, 0],
1538
+ entity_count: Number(R.entity_count ?? 0),
1539
+ line_count: Number(R.base_line_count ?? 0),
1540
+ fill_count: Number(R.base_fill_count ?? 0),
1541
+ dot_count: Number(R.base_dot_count ?? 0),
1542
+ layers: M,
1515
1543
  texts: []
1516
1544
  });
1517
- Zn(C, $.layers);
1518
- const O = mo(t, e, u, r);
1545
+ ie(Y, z.layers);
1546
+ const S = (e == null ? void 0 : e.baseGeometry) ?? Ao(t, o, f, l);
1519
1547
  if (!n.loadBlocks) {
1520
- const g = zn(e, h, d, B, x), I = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), F = Z(t, f, "V3 NESTED_INSTANCE_TABLE"), L = $t(t, w, B, "V3 SCENE_TEXT_TABLE"), Y = xo(y, "V3 VARIANT_TEXT_TABLE");
1521
- if (Number(m.variant_count ?? g.length) !== g.length)
1522
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1523
- if (Number(m.scene_instance_count ?? I.length) !== I.length)
1524
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1525
- if (Number(m.nested_instance_count ?? F.length) !== F.length)
1526
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1527
- if (Number(m.scene_text_count ?? L.length) !== L.length)
1528
- throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1529
- if (Number(m.variant_text_count ?? Y) !== Y)
1530
- throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1531
- for (const T of g) {
1532
- if (T.nestedStart + T.nestedCount > F.length)
1533
- throw new l("E_GROUP_RANGE", `V3 variant ${T.id} nested range exceeds table`);
1534
- if (T.textStart + T.textCount > Y)
1535
- throw new l("E_GROUP_RANGE", `V3 variant ${T.id} text range exceeds table`);
1548
+ const g = (e == null ? void 0 : e.variantHeaders) ?? Jt(o, d, m, $, w), I = (e == null ? void 0 : e.sceneInstances) ?? Z(t, A, "V3 SCENE_INSTANCE_TABLE"), k = (e == null ? void 0 : e.nestedInstances) ?? Z(t, y, "V3 NESTED_INSTANCE_TABLE"), L = (e == null ? void 0 : e.sceneTexts) ?? vt(t, x, $, "V3 SCENE_TEXT_TABLE"), F = (e == null ? void 0 : e.variantTextCount) ?? Io(h, "V3 VARIANT_TEXT_TABLE");
1549
+ if (Number(R.variant_count ?? g.length) !== g.length)
1550
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1551
+ if (Number(R.scene_instance_count ?? I.length) !== I.length)
1552
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1553
+ if (Number(R.nested_instance_count ?? k.length) !== k.length)
1554
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1555
+ if (Number(R.scene_text_count ?? L.length) !== L.length)
1556
+ throw new u("E_GROUP_RANGE", "V3 scene text count mismatch");
1557
+ if (Number(R.variant_text_count ?? F) !== F)
1558
+ throw new u("E_GROUP_RANGE", "V3 variant text count mismatch");
1559
+ for (const G of g) {
1560
+ if (G.nestedStart + G.nestedCount > k.length)
1561
+ throw new u("E_GROUP_RANGE", `V3 variant ${G.id} nested range exceeds table`);
1562
+ if (G.textStart + G.textCount > F)
1563
+ throw new u("E_GROUP_RANGE", `V3 variant ${G.id} text range exceeds table`);
1536
1564
  }
1537
- return At(I, F, (T) => {
1538
- if (!g[T.variantId])
1539
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${T.variantId}`);
1540
- Kt(T.insLayerIdx, D.length);
1565
+ return Rt(I, k, (G) => {
1566
+ if (!g[G.variantId])
1567
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${G.variantId}`);
1568
+ Zt(G.insLayerIdx, M.length);
1541
1569
  }), {
1542
1570
  meta: {
1543
- bounds: m.bounds ?? [0, 0, 0, 0],
1544
- entity_count: Number(m.entity_count ?? 0),
1545
- line_count: O.line.count,
1546
- fill_count: O.fill.count,
1547
- dot_count: O.dot.count,
1571
+ bounds: R.bounds ?? [0, 0, 0, 0],
1572
+ entity_count: Number(R.entity_count ?? 0),
1573
+ line_count: S.line.count,
1574
+ fill_count: S.fill.count,
1575
+ dot_count: S.dot.count,
1548
1576
  version: 3,
1549
- version_minor: o,
1550
- encoding: P,
1551
- ...R ? { features: R } : {},
1552
- ...x ? { external_variants: [...x] } : {},
1553
- ...N ? { external_annotations: N } : {},
1554
- layer0_index: C,
1555
- block_variants: g.map((T) => ({
1556
- id: T.id,
1557
- name: T.name,
1558
- line_count: T.line_count,
1559
- fill_count: T.fill_count,
1560
- dot_count: T.dot_count
1577
+ version_minor: r,
1578
+ encoding: D,
1579
+ ...U ? { features: U } : {},
1580
+ ...w ? { external_variants: [...w] } : {},
1581
+ ...v ? { external_annotations: v } : {},
1582
+ layer0_index: Y,
1583
+ block_variants: g.map((G) => ({
1584
+ id: G.id,
1585
+ name: G.name,
1586
+ line_count: G.line_count,
1587
+ fill_count: G.fill_count,
1588
+ dot_count: G.dot_count
1561
1589
  })),
1562
1590
  instance_count: I.length,
1563
- layers: D,
1591
+ layers: M,
1564
1592
  texts: L
1565
1593
  },
1566
1594
  header: {
1567
- ...$,
1568
- lineCount: O.line.count,
1569
- fillCount: O.fill.count,
1570
- dotCount: O.dot.count,
1595
+ ...z,
1596
+ lineCount: S.line.count,
1597
+ fillCount: S.fill.count,
1598
+ dotCount: S.dot.count,
1571
1599
  textCount: L.length,
1572
1600
  texts: L
1573
1601
  },
1574
1602
  decoded: {
1575
- baseLine: O.line,
1576
- baseFill: O.fill,
1577
- baseDot: O.dot,
1603
+ baseLine: S.line,
1604
+ baseFill: S.fill,
1605
+ baseDot: S.dot,
1578
1606
  variants: /* @__PURE__ */ new Map(),
1579
1607
  instances: [],
1580
1608
  instanceIdByVariantOrdinal: /* @__PURE__ */ new Map()
1581
1609
  }
1582
1610
  };
1583
1611
  }
1584
- const { variantsById: v, variants: K, snapshots: A } = ho(
1612
+ const N = e ? No(t, e, n) : Ro(
1585
1613
  t,
1586
- e,
1587
- h,
1614
+ o,
1588
1615
  d,
1589
- B,
1590
- x,
1591
- r,
1616
+ m,
1617
+ $,
1618
+ w,
1619
+ l,
1592
1620
  n
1593
- ), E = Z(t, _, "V3 SCENE_INSTANCE_TABLE"), p = Z(t, f, "V3 NESTED_INSTANCE_TABLE"), b = $t(t, w, B, "V3 SCENE_TEXT_TABLE"), S = $t(t, y, B, "V3 VARIANT_TEXT_TABLE");
1594
- if (Number(m.variant_count ?? v.length) !== v.length)
1595
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1596
- if (Number(m.scene_instance_count ?? E.length) !== E.length)
1597
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1598
- if (Number(m.nested_instance_count ?? p.length) !== p.length)
1599
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1600
- if (Number(m.scene_text_count ?? b.length) !== b.length)
1601
- throw new l("E_GROUP_RANGE", "V3 scene text count mismatch");
1602
- if (Number(m.variant_text_count ?? S.length) !== S.length)
1603
- throw new l("E_GROUP_RANGE", "V3 variant text count mismatch");
1604
- for (const g of v) {
1605
- if (g.nestedStart + g.nestedCount > p.length)
1606
- throw new l("E_GROUP_RANGE", `V3 variant ${g.id} nested range exceeds table`);
1607
- if (g.textStart + g.textCount > S.length)
1608
- throw new l("E_GROUP_RANGE", `V3 variant ${g.id} text range exceeds table`);
1621
+ ), { variantsById: E, variants: V, snapshots: T } = N, C = (e == null ? void 0 : e.sceneInstances) ?? Z(t, A, "V3 SCENE_INSTANCE_TABLE"), b = (e == null ? void 0 : e.nestedInstances) ?? Z(t, y, "V3 NESTED_INSTANCE_TABLE"), B = (e == null ? void 0 : e.sceneTexts) ?? vt(t, x, $, "V3 SCENE_TEXT_TABLE"), O = (e == null ? void 0 : e.variantTexts) ?? vt(t, h, $, "V3 VARIANT_TEXT_TABLE");
1622
+ if (Number(R.variant_count ?? E.length) !== E.length)
1623
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1624
+ if (Number(R.scene_instance_count ?? C.length) !== C.length)
1625
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1626
+ if (Number(R.nested_instance_count ?? b.length) !== b.length)
1627
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1628
+ if (Number(R.scene_text_count ?? B.length) !== B.length)
1629
+ throw new u("E_GROUP_RANGE", "V3 scene text count mismatch");
1630
+ if (Number(R.variant_text_count ?? O.length) !== O.length)
1631
+ throw new u("E_GROUP_RANGE", "V3 variant text count mismatch");
1632
+ for (const g of E) {
1633
+ if (g.nestedStart + g.nestedCount > b.length)
1634
+ throw new u("E_GROUP_RANGE", `V3 variant ${g.id} nested range exceeds table`);
1635
+ if (g.textStart + g.textCount > O.length)
1636
+ throw new u("E_GROUP_RANGE", `V3 variant ${g.id} text range exceeds table`);
1609
1637
  }
1610
- At(E, p, (g) => {
1611
- if (!v[g.variantId])
1612
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${g.variantId}`);
1613
- Kt(g.insLayerIdx, D.length);
1638
+ Rt(C, b, (g) => {
1639
+ if (!E[g.variantId])
1640
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${g.variantId}`);
1641
+ Zt(g.insLayerIdx, M.length);
1614
1642
  });
1615
- const M = /* @__PURE__ */ new Map();
1616
- for (const g of v)
1617
- M.set(
1618
- g.id,
1619
- S.slice(g.textStart, g.textStart + g.textCount)
1620
- );
1621
- const U = [], V = n.externalVariantDeltaOnly, k = V ? [] : [...b], z = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map(), ht = /* @__PURE__ */ new Map(), bt = (g, I) => {
1622
- z.set(g, Rt(z.get(g) ?? null, I));
1623
- }, Et = (g, I, F, L, Y, Q) => {
1624
- var fn;
1625
- if (Y > 64)
1626
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1627
- if (Q.has(g))
1628
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${g}`);
1629
- const T = v[g];
1630
- if (!T)
1631
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${g}`);
1632
- Q.add(g);
1633
- const tt = !n.requiredExternalVariantIds || n.requiredExternalVariantIds.has(g), W = V ? ((fn = n.requiredExternalVariantIds) == null ? void 0 : fn.has(g)) === !0 : tt;
1634
- let j = !1;
1635
- const dn = !!(T.line_count || T.fill_count || T.dot_count), ne = T.textCount > 0;
1636
- if (W && (dn || ne) && (U.push({
1643
+ const j = (e == null ? void 0 : e.variantTextsByVariantId) ?? (() => {
1644
+ const g = /* @__PURE__ */ new Map();
1645
+ for (const I of E)
1646
+ g.set(
1647
+ I.id,
1648
+ O.slice(I.textStart, I.textStart + I.textCount)
1649
+ );
1650
+ return g;
1651
+ })(), H = [], X = n.externalVariantDeltaOnly, gt = X ? [] : [...B], ct = /* @__PURE__ */ new Map(), it = /* @__PURE__ */ new Map(), un = /* @__PURE__ */ new Map(), le = (g, I) => {
1652
+ ct.set(g, pt(ct.get(g) ?? null, I));
1653
+ }, cn = (g, I, k, L, F, tt) => {
1654
+ var xn;
1655
+ if (F > 64)
1656
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1657
+ if (tt.has(g))
1658
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${g}`);
1659
+ const G = E[g];
1660
+ if (!G)
1661
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${g}`);
1662
+ tt.add(g);
1663
+ const nt = !n.requiredExternalVariantIds || n.requiredExternalVariantIds.has(g), W = X ? ((xn = n.requiredExternalVariantIds) == null ? void 0 : xn.has(g)) === !0 : nt;
1664
+ let q = !1;
1665
+ const En = !!(G.line_count || G.fill_count || G.dot_count), de = G.textCount > 0;
1666
+ if (W && (En || de) && (H.push({
1637
1667
  instanceId: I.instanceId,
1638
1668
  variantId: g,
1639
1669
  matA: I.matA,
@@ -1643,29 +1673,29 @@ function Wn(t, n) {
1643
1673
  tx: I.tx,
1644
1674
  ty: I.ty,
1645
1675
  insLayerIdx: I.insLayerIdx
1646
- }), dn && bt(I.instanceId, T.bbox ? Jn(T.bbox, I) : null), j = !0), W) {
1647
- T.textCount > 0 && (j = !0);
1648
- for (let nt = 0; nt < T.textCount; nt += 1) {
1649
- const at = jn(S[T.textStart + nt], I, C, $.layers);
1650
- k.push({
1651
- ...at,
1652
- iv: F,
1676
+ }), En && le(I.instanceId, G.bbox ? re(G.bbox, I) : null), q = !0), W) {
1677
+ G.textCount > 0 && (q = !0);
1678
+ for (let et = 0; et < G.textCount; et += 1) {
1679
+ const st = te(O[G.textStart + et], I, Y, z.layers);
1680
+ gt.push({
1681
+ ...st,
1682
+ iv: k,
1653
1683
  io: L
1654
1684
  });
1655
1685
  }
1656
1686
  }
1657
- for (let nt = 0; nt < T.nestedCount; nt += 1) {
1658
- const at = p[T.nestedStart + nt], ee = Kn(at.insLayerIdx, I.insLayerIdx, C), oe = an(at, T, v[at.variantId]), re = Hn(I, oe, I.instanceId, ee);
1659
- j = Et(at.variantId, re, F, L, Y + 1, Q) || j;
1687
+ for (let et = 0; et < G.nestedCount; et += 1) {
1688
+ const st = b[G.nestedStart + et], me = ee(st.insLayerIdx, I.insLayerIdx, Y), _e = ln(st, G, E[st.variantId]), Ee = Qn(I, _e, I.instanceId, me);
1689
+ q = cn(st.variantId, Ee, k, L, F + 1, tt) || q;
1660
1690
  }
1661
- return Q.delete(g), j;
1662
- }, Bt = /* @__PURE__ */ new Map();
1663
- E.forEach((g, I) => {
1664
- if (!v[g.variantId])
1665
- throw new l("E_GROUP_RANGE", `Unknown V3 scene variantId ${g.variantId}`);
1666
- const L = ht.get(g.variantId) ?? 0;
1667
- ht.set(g.variantId, L + 1), H.set(`${g.variantId}:${L}`, I);
1668
- const Y = qn(g.insLayerIdx, C), Q = {
1691
+ return tt.delete(g), q;
1692
+ }, St = /* @__PURE__ */ new Map();
1693
+ C.forEach((g, I) => {
1694
+ if (!E[g.variantId])
1695
+ throw new u("E_GROUP_RANGE", `Unknown V3 scene variantId ${g.variantId}`);
1696
+ const L = un.get(g.variantId) ?? 0;
1697
+ un.set(g.variantId, L + 1), it.set(`${g.variantId}:${L}`, I);
1698
+ const F = ne(g.insLayerIdx, Y), tt = {
1669
1699
  instanceId: I,
1670
1700
  variantId: g.variantId,
1671
1701
  matA: g.matA,
@@ -1674,207 +1704,247 @@ function Wn(t, n) {
1674
1704
  matD: g.matD,
1675
1705
  tx: g.tx,
1676
1706
  ty: g.ty,
1677
- insLayerIdx: Y
1678
- }, T = Et(g.variantId, Q, g.variantId, L, 0, /* @__PURE__ */ new Set());
1679
- if (V && !T)
1707
+ insLayerIdx: F
1708
+ }, G = cn(g.variantId, tt, g.variantId, L, 0, /* @__PURE__ */ new Set());
1709
+ if (X && !G)
1680
1710
  return;
1681
- let tt = Bt.get(Y);
1682
- tt || (tt = /* @__PURE__ */ new Map(), Bt.set(Y, tt));
1683
- let W = tt.get(g.variantId);
1684
- W || (W = { count: 0, bboxes: [], inserts: [] }, tt.set(g.variantId, W)), W.count += 1;
1685
- const j = z.get(I) ?? null;
1686
- j && W.bboxes.push(j), W.inserts.push({
1711
+ let nt = St.get(F);
1712
+ nt || (nt = /* @__PURE__ */ new Map(), St.set(F, nt));
1713
+ let W = nt.get(g.variantId);
1714
+ W || (W = { count: 0, bboxes: [], inserts: [] }, nt.set(g.variantId, W)), W.count += 1;
1715
+ const q = ct.get(I) ?? null;
1716
+ q && W.bboxes.push(q), W.inserts.push({
1687
1717
  instanceId: I,
1688
1718
  variantId: g.variantId,
1689
1719
  label: `#${I + 1} (${g.tx.toFixed(1)}, ${g.ty.toFixed(1)})`,
1690
1720
  tx: g.tx,
1691
1721
  ty: g.ty,
1692
- canHighlight: j !== null,
1693
- ...j ? { bbox: j } : {}
1722
+ canHighlight: q !== null,
1723
+ ...q ? { bbox: q } : {}
1694
1724
  });
1695
1725
  });
1696
- const sn = /* @__PURE__ */ new Map();
1697
- for (const [g, I] of Bt) {
1698
- const F = [];
1699
- for (const [L, Y] of I)
1700
- F.push({
1726
+ const fn = /* @__PURE__ */ new Map();
1727
+ for (const [g, I] of St) {
1728
+ const k = [];
1729
+ for (const [L, F] of I)
1730
+ k.push({
1701
1731
  variantId: L,
1702
- blockName: Mn(v[L], L),
1703
- instanceCount: Y.count,
1704
- bboxes: Y.bboxes,
1705
- inserts: Y.inserts
1732
+ blockName: Ln(E[L], L),
1733
+ instanceCount: F.count,
1734
+ bboxes: F.bboxes,
1735
+ inserts: F.inserts
1706
1736
  });
1707
- F.sort((L, Y) => Y.instanceCount - L.instanceCount), sn.set(g, F);
1737
+ k.sort((L, F) => F.instanceCount - L.instanceCount), fn.set(g, k);
1708
1738
  }
1709
- let cn = V ? 0 : O.line.count, ln = V ? 0 : O.fill.count, un = V ? 0 : O.dot.count;
1710
- for (const g of U) {
1711
- const I = v[g.variantId];
1712
- !(n.deferExternalVariantGeometry && I.lineSnapshot.count === 0 && I.fillSnapshot.count === 0 && I.dotSnapshot.count === 0) && !Nt(g.instanceId, n) || (cn += I.line_count, ln += I.fill_count, un += I.dot_count);
1739
+ let dn = X ? 0 : S.line.count, mn = X ? 0 : S.fill.count, _n = X ? 0 : S.dot.count;
1740
+ for (const g of H) {
1741
+ const I = E[g.variantId];
1742
+ n.deferExternalVariantGeometry && I.lineSnapshot.count === 0 && I.fillSnapshot.count === 0 && I.dotSnapshot.count === 0 || !Nt(g.instanceId, n) || (dn += I.line_count, mn += I.fill_count, _n += I.dot_count);
1713
1743
  }
1714
- const xt = ke(k, H, n), Qn = {
1715
- bounds: m.bounds ?? [0, 0, 0, 0],
1716
- entity_count: V ? 0 : Number(m.entity_count ?? 0),
1717
- line_count: O.line.count,
1718
- fill_count: O.fill.count,
1719
- dot_count: O.dot.count,
1744
+ const ht = no(gt, it, n), ue = {
1745
+ bounds: R.bounds ?? [0, 0, 0, 0],
1746
+ entity_count: X ? 0 : Number(R.entity_count ?? 0),
1747
+ line_count: S.line.count,
1748
+ fill_count: S.fill.count,
1749
+ dot_count: S.dot.count,
1720
1750
  version: 3,
1721
- version_minor: o,
1722
- encoding: P,
1723
- ...R ? { features: R } : {},
1724
- ...x ? { external_variants: [...x] } : {},
1725
- ...N ? { external_annotations: N } : {},
1726
- layer0_index: C,
1727
- block_variants: v.map((g) => ({
1751
+ version_minor: r,
1752
+ encoding: D,
1753
+ ...U ? { features: U } : {},
1754
+ ...w ? { external_variants: [...w] } : {},
1755
+ ...v ? { external_annotations: v } : {},
1756
+ layer0_index: Y,
1757
+ block_variants: E.map((g) => ({
1728
1758
  id: g.id,
1729
1759
  name: g.name,
1730
1760
  line_count: g.sourceLineCount,
1731
1761
  fill_count: g.sourceFillCount,
1732
1762
  dot_count: g.sourceDotCount
1733
1763
  })),
1734
- instance_count: E.length,
1735
- layers: D,
1736
- texts: xt
1737
- }, te = {
1738
- ...$,
1739
- entityCount: V ? 0 : $.entityCount,
1740
- lineCount: cn,
1741
- fillCount: ln,
1742
- dotCount: un,
1743
- textCount: xt.length,
1744
- texts: xt,
1764
+ instance_count: C.length,
1765
+ layers: M,
1766
+ texts: ht
1767
+ }, ce = {
1768
+ ...z,
1769
+ entityCount: X ? 0 : z.entityCount,
1770
+ lineCount: dn,
1771
+ fillCount: mn,
1772
+ dotCount: _n,
1773
+ textCount: ht.length,
1774
+ texts: ht,
1745
1775
  ...n.loadBlocks ? {
1746
- layerBlockUsages: sn,
1747
- insertRuntime: He(
1748
- C,
1749
- v,
1750
- A,
1751
- M,
1752
- U,
1753
- xt,
1754
- H
1776
+ layerBlockUsages: fn,
1777
+ insertRuntime: oo(
1778
+ Y,
1779
+ E,
1780
+ T,
1781
+ j,
1782
+ H,
1783
+ ht,
1784
+ it
1755
1785
  )
1756
1786
  } : {}
1757
- };
1787
+ }, fe = e ?? (n.cacheDocument ? (() => {
1788
+ const g = /* @__PURE__ */ new Map();
1789
+ for (const [I, k] of V)
1790
+ w != null && w[I] || g.set(I, {
1791
+ line: { chunk: k.line, snapshot: T[I].line },
1792
+ fill: { chunk: k.fill, snapshot: T[I].fill },
1793
+ dot: { chunk: k.dot, snapshot: T[I].dot }
1794
+ });
1795
+ return {
1796
+ kind: "dxb3-v3",
1797
+ buffer: t,
1798
+ versionMinor: r,
1799
+ sections: s,
1800
+ groupLayerEncoding: l,
1801
+ sceneMeta: R,
1802
+ externalVariants: w,
1803
+ externalAnnotations: v,
1804
+ geoMetaFeatures: U,
1805
+ geoMetaEncoding: D,
1806
+ stringTable: $,
1807
+ layers: M,
1808
+ layer0Index: Y,
1809
+ headerForValidation: z,
1810
+ baseGeometry: S,
1811
+ variantHeaders: Jt(
1812
+ o,
1813
+ d,
1814
+ m,
1815
+ $,
1816
+ w
1817
+ ),
1818
+ internalVariants: g,
1819
+ sceneInstances: C,
1820
+ nestedInstances: b,
1821
+ sceneTexts: B,
1822
+ variantTexts: O,
1823
+ variantTextCount: O.length,
1824
+ variantTextsByVariantId: j
1825
+ };
1826
+ })() : void 0);
1758
1827
  return {
1759
- meta: Qn,
1760
- header: te,
1828
+ meta: ue,
1829
+ header: ce,
1830
+ documentCache: fe,
1761
1831
  decoded: {
1762
- baseLine: V ? Xt() : O.line,
1763
- baseFill: V ? Xt() : O.fill,
1764
- baseDot: V ? Xt() : O.dot,
1765
- variants: K,
1766
- instances: U,
1767
- instanceIdByVariantOrdinal: H
1832
+ baseLine: X ? kt() : S.line,
1833
+ baseFill: X ? kt() : S.fill,
1834
+ baseDot: X ? kt() : S.dot,
1835
+ variants: V,
1836
+ instances: H,
1837
+ instanceIdByVariantOrdinal: it
1768
1838
  }
1769
1839
  };
1770
1840
  }
1771
- function Nn(t) {
1841
+ function Vn(t) {
1772
1842
  return "annotation" in t && (t.annotation.line_count > 0 || t.annotation.fill_count > 0 || t.annotation.dot_count > 0 || t.annotation.text_count > 0);
1773
1843
  }
1774
- function yo(t, n) {
1844
+ function Go(t, n) {
1775
1845
  if (n.line.count !== t.annotation.line_count || n.fill.count !== t.annotation.fill_count || n.dot.count !== t.annotation.dot_count || n.texts.length !== t.annotation.text_count)
1776
- throw new l(
1846
+ throw new u(
1777
1847
  "E_GROUP_RANGE",
1778
1848
  `V3.3 external variant ${t.id} annotation count mismatch`
1779
1849
  );
1780
1850
  }
1781
- function wo(t, n, e, o, a, r) {
1851
+ function To(t, n, e, o, i, r) {
1782
1852
  return {
1783
- line: Mt(t.line, n, e, o),
1784
- fill: Mt(t.fill, n, e, o),
1785
- dot: Mt(t.dot, n, e, o),
1786
- texts: t.texts.map((i) => ({
1787
- ...jn(i, n, e, o),
1788
- iv: a,
1853
+ line: Pt(t.line, n, e, o),
1854
+ fill: Pt(t.fill, n, e, o),
1855
+ dot: Pt(t.dot, n, e, o),
1856
+ texts: t.texts.map((s) => ({
1857
+ ...te(s, n, e, o),
1858
+ iv: i,
1789
1859
  io: r
1790
1860
  }))
1791
1861
  };
1792
1862
  }
1793
- function Po(t, n) {
1794
- if (!rt(t))
1863
+ function Yo(t, n) {
1864
+ if (!Q(t))
1795
1865
  return null;
1796
- const e = new DataView(t), { sections: o } = mt(t), a = X(o, 1, "SCENE_META"), r = X(o, 2, "LAYER_TABLE"), i = X(o, 3, "STRING_TABLE"), c = X(o, 5, "VARIANT_TABLE"), s = X(o, 6, "VARIANT_GEOMETRY"), u = X(o, 7, "SCENE_INSTANCE_TABLE"), h = ut(o, 8), d = _t(t, a, "SCENE_META");
1797
- if (!en(d))
1866
+ const e = new DataView(t), { sections: o } = Et(t), i = P(o, 1, "SCENE_META"), r = P(o, 2, "LAYER_TABLE"), s = P(o, 3, "STRING_TABLE"), l = P(o, 5, "VARIANT_TABLE"), a = P(o, 6, "VARIANT_GEOMETRY"), c = P(o, 7, "SCENE_INSTANCE_TABLE"), _ = dt(o, 8), f = xt(t, i, "SCENE_META");
1867
+ if (!sn(f))
1798
1868
  return null;
1799
- const _ = Vt(d, c.length / 60);
1800
- if (!_.some(Nn))
1869
+ const d = Tt(f, l.length / 60);
1870
+ if (!d.some(Vn))
1801
1871
  return null;
1802
- const f = new Uint8Array(t, i.offset, i.length), w = Yn(t, r, f), y = Number(d.layer0_index ?? 0), m = Qt({
1803
- bounds: d.bounds ?? [0, 0, 0, 0],
1804
- entity_count: Number(d.entity_count ?? 0),
1805
- line_count: Number(d.base_line_count ?? 0),
1806
- fill_count: Number(d.base_fill_count ?? 0),
1807
- dot_count: Number(d.base_dot_count ?? 0),
1808
- layers: w,
1872
+ const m = new Uint8Array(t, s.offset, s.length), A = jn(t, r, m), y = Number(f.layer0_index ?? 0), x = en({
1873
+ bounds: f.bounds ?? [0, 0, 0, 0],
1874
+ entity_count: Number(f.entity_count ?? 0),
1875
+ line_count: Number(f.base_line_count ?? 0),
1876
+ fill_count: Number(f.base_fill_count ?? 0),
1877
+ dot_count: Number(f.base_dot_count ?? 0),
1878
+ layers: A,
1809
1879
  texts: []
1810
1880
  });
1811
- Zn(y, m.layers);
1812
- const x = zn(e, c, s, f, _), G = Z(t, u, "V3 SCENE_INSTANCE_TABLE"), N = Z(t, h, "V3 NESTED_INSTANCE_TABLE");
1813
- if (Number(d.variant_count ?? x.length) !== x.length)
1814
- throw new l("E_GROUP_RANGE", "V3 variant count mismatch");
1815
- if (Number(d.scene_instance_count ?? G.length) !== G.length)
1816
- throw new l("E_GROUP_RANGE", "V3 scene instance count mismatch");
1817
- if (Number(d.nested_instance_count ?? N.length) !== N.length)
1818
- throw new l("E_GROUP_RANGE", "V3 nested instance count mismatch");
1819
- for (const E of x)
1820
- if (E.nestedStart + E.nestedCount > N.length)
1821
- throw new l("E_GROUP_RANGE", `V3 variant ${E.id} nested range exceeds table`);
1822
- At(G, N, (E) => {
1823
- if (!x[E.variantId])
1824
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${E.variantId}`);
1825
- Kt(E.insLayerIdx, w.length);
1881
+ ie(y, x.layers);
1882
+ const h = Jt(e, l, a, m, d), R = Z(t, c, "V3 SCENE_INSTANCE_TABLE"), w = Z(t, _, "V3 NESTED_INSTANCE_TABLE");
1883
+ if (Number(f.variant_count ?? h.length) !== h.length)
1884
+ throw new u("E_GROUP_RANGE", "V3 variant count mismatch");
1885
+ if (Number(f.scene_instance_count ?? R.length) !== R.length)
1886
+ throw new u("E_GROUP_RANGE", "V3 scene instance count mismatch");
1887
+ if (Number(f.nested_instance_count ?? w.length) !== w.length)
1888
+ throw new u("E_GROUP_RANGE", "V3 nested instance count mismatch");
1889
+ for (const E of h)
1890
+ if (E.nestedStart + E.nestedCount > w.length)
1891
+ throw new u("E_GROUP_RANGE", `V3 variant ${E.id} nested range exceeds table`);
1892
+ Rt(R, w, (E) => {
1893
+ if (!h[E.variantId])
1894
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${E.variantId}`);
1895
+ Zt(E.insLayerIdx, A.length);
1826
1896
  });
1827
- const R = /* @__PURE__ */ new Map(), P = (E) => {
1828
- var U;
1829
- const p = _[E];
1830
- if (!p || !Nn(p))
1897
+ const p = /* @__PURE__ */ new Map(), v = (E) => {
1898
+ var B;
1899
+ const V = d[E];
1900
+ if (!V || !Vn(V))
1831
1901
  return null;
1832
- const b = R.get(E);
1833
- if (b)
1834
- return b;
1835
- const S = (U = n == null ? void 0 : n.externalVariantBuffers) == null ? void 0 : U.get(p.id);
1836
- if (!S)
1902
+ const T = p.get(E);
1903
+ if (T)
1904
+ return T;
1905
+ const C = (B = n == null ? void 0 : n.externalVariantBuffers) == null ? void 0 : B.get(V.id);
1906
+ if (!C)
1837
1907
  return null;
1838
- if (S.byteLength !== p.raw_size)
1839
- throw new l(
1908
+ if (C.byteLength !== V.raw_size)
1909
+ throw new u(
1840
1910
  "E_GROUP_RANGE",
1841
- `V3.3 annotation sidecar ${p.id} raw_size mismatch: manifest=${p.raw_size}, sidecar=${S.byteLength}`
1911
+ `V3.3 annotation sidecar ${V.id} raw_size mismatch: manifest=${V.raw_size}, sidecar=${C.byteLength}`
1842
1912
  );
1843
- const M = be(S);
1844
- return yo(p, M), R.set(E, M), M;
1845
- }, B = [], D = [], C = [], $ = [], O = (n == null ? void 0 : n.hiddenInstanceIds) ?? /* @__PURE__ */ new Set(), v = (E, p, b, S) => {
1846
- const M = wo(
1913
+ const b = Xe(C);
1914
+ return Go(V, b), p.set(E, b), b;
1915
+ }, U = [], D = [], $ = [], M = [], Y = (n == null ? void 0 : n.hiddenInstanceIds) ?? /* @__PURE__ */ new Set(), z = (E, V, T, C) => {
1916
+ const b = To(
1847
1917
  E,
1848
- p,
1918
+ V,
1849
1919
  y,
1850
- m.layers,
1851
- b,
1852
- S
1920
+ x.layers,
1921
+ T,
1922
+ C
1853
1923
  );
1854
- B.push(M.line), D.push(M.fill), C.push(M.dot), $.push(...M.texts);
1855
- }, K = (E, p, b, S, M, U) => {
1856
- if (M > 64)
1857
- throw new l("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1858
- if (U.has(E))
1859
- throw new l("E_GROUP_RANGE", `V3 nested variant cycle detected at ${E}`);
1860
- const V = x[E];
1861
- if (!V)
1862
- throw new l("E_GROUP_RANGE", `Unknown V3 variantId ${E}`);
1863
- U.add(E);
1864
- const k = P(E);
1865
- k && v(k, p, b, S);
1866
- for (let z = 0; z < V.nestedCount; z += 1) {
1867
- const H = N[V.nestedStart + z], ht = Kn(H.insLayerIdx, p.insLayerIdx, y), bt = an(H, V, x[H.variantId]), Et = Hn(p, bt, p.instanceId, ht);
1868
- K(H.variantId, Et, b, S, M + 1, U);
1924
+ U.push(b.line), D.push(b.fill), $.push(b.dot), M.push(...b.texts);
1925
+ }, S = (E, V, T, C, b, B) => {
1926
+ if (b > 64)
1927
+ throw new u("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
1928
+ if (B.has(E))
1929
+ throw new u("E_GROUP_RANGE", `V3 nested variant cycle detected at ${E}`);
1930
+ const O = h[E];
1931
+ if (!O)
1932
+ throw new u("E_GROUP_RANGE", `Unknown V3 variantId ${E}`);
1933
+ B.add(E);
1934
+ const j = v(E);
1935
+ j && z(j, V, T, C);
1936
+ for (let H = 0; H < O.nestedCount; H += 1) {
1937
+ const X = w[O.nestedStart + H], gt = ee(X.insLayerIdx, V.insLayerIdx, y), ct = ln(X, O, h[X.variantId]), it = Qn(V, ct, V.instanceId, gt);
1938
+ S(X.variantId, it, T, C, b + 1, B);
1869
1939
  }
1870
- U.delete(E);
1871
- }, A = /* @__PURE__ */ new Map();
1872
- return G.forEach((E, p) => {
1873
- const b = A.get(E.variantId) ?? 0;
1874
- if (A.set(E.variantId, b + 1), O.has(p))
1940
+ B.delete(E);
1941
+ }, N = /* @__PURE__ */ new Map();
1942
+ return R.forEach((E, V) => {
1943
+ const T = N.get(E.variantId) ?? 0;
1944
+ if (N.set(E.variantId, T + 1), Y.has(V))
1875
1945
  return;
1876
- const S = qn(E.insLayerIdx, y), M = {
1877
- instanceId: p,
1946
+ const C = ne(E.insLayerIdx, y), b = {
1947
+ instanceId: V,
1878
1948
  variantId: E.variantId,
1879
1949
  matA: E.matA,
1880
1950
  matB: E.matB,
@@ -1882,30 +1952,30 @@ function Po(t, n) {
1882
1952
  matD: E.matD,
1883
1953
  tx: E.tx,
1884
1954
  ty: E.ty,
1885
- insLayerIdx: S
1955
+ insLayerIdx: C
1886
1956
  };
1887
- K(E.variantId, M, E.variantId, b, 0, /* @__PURE__ */ new Set());
1888
- }), B.every((E) => E.count === 0) && D.every((E) => E.count === 0) && C.every((E) => E.count === 0) && $.length === 0 ? null : {
1889
- line: Pt(B),
1890
- fill: Pt(D),
1891
- dot: Pt(C),
1892
- texts: $
1957
+ S(E.variantId, b, E.variantId, T, 0, /* @__PURE__ */ new Set());
1958
+ }), U.every((E) => E.count === 0) && D.every((E) => E.count === 0) && $.every((E) => E.count === 0) && M.length === 0 ? null : {
1959
+ line: Dt(U),
1960
+ fill: Dt(D),
1961
+ dot: Dt($),
1962
+ texts: M
1893
1963
  };
1894
1964
  }
1895
- function Rt(t, n) {
1896
- return me(t, n);
1965
+ function pt(t, n) {
1966
+ return pe(t, n);
1897
1967
  }
1898
- function Jn(t, n) {
1899
- return Bn(t, n);
1968
+ function re(t, n) {
1969
+ return On(t, n);
1900
1970
  }
1901
- function Rn(t) {
1902
- return xe(t);
1971
+ function Gn(t) {
1972
+ return Te(t);
1903
1973
  }
1904
- function pn(t, n) {
1905
- return ge(t, n);
1974
+ function Tn(t, n) {
1975
+ return be(t, n);
1906
1976
  }
1907
- function pt(t, n) {
1908
- return Jn(t, {
1977
+ function It(t, n) {
1978
+ return re(t, {
1909
1979
  variantId: n.variantId,
1910
1980
  matA: n.matA,
1911
1981
  matB: n.matB,
@@ -1916,168 +1986,168 @@ function pt(t, n) {
1916
1986
  insLayerIdx: n.insLayerIdx
1917
1987
  });
1918
1988
  }
1919
- function an(t, n, e) {
1989
+ function ln(t, n, e) {
1920
1990
  if (!(e != null && e.bbox) || !n.bbox)
1921
1991
  return t;
1922
- const o = n.precisionOriginX, a = n.precisionOriginY;
1923
- if (!Number.isFinite(o) || !Number.isFinite(a) || o === 0 && a === 0)
1992
+ const o = n.precisionOriginX, i = n.precisionOriginY;
1993
+ if (!Number.isFinite(o) || !Number.isFinite(i) || o === 0 && i === 0)
1924
1994
  return t;
1925
1995
  const r = {
1926
1996
  ...t,
1927
1997
  tx: t.tx - o,
1928
- ty: t.ty - a
1929
- }, i = pt(e.bbox, t), c = pt(e.bbox, r), s = Math.max(Rn(n.bbox), Rn(e.bbox), 1), u = Math.hypot(o, a), h = Math.hypot(t.tx, t.ty), d = Math.hypot(r.tx, r.ty);
1930
- if (u <= s * 16 || h <= s * 16)
1998
+ ty: t.ty - i
1999
+ }, s = It(e.bbox, t), l = It(e.bbox, r), a = Math.max(Gn(n.bbox), Gn(e.bbox), 1), c = Math.hypot(o, i), _ = Math.hypot(t.tx, t.ty), f = Math.hypot(r.tx, r.ty);
2000
+ if (c <= a * 16 || _ <= a * 16)
1931
2001
  return t;
1932
- const _ = pn(n.bbox, i), f = pn(n.bbox, c);
1933
- return _ > s * 16 && f * 4 < _ && d * 4 < h ? r : t;
2002
+ const d = Tn(n.bbox, s), m = Tn(n.bbox, l);
2003
+ return d > a * 16 && m * 4 < d && f * 4 < _ ? r : t;
1934
2004
  }
1935
- function Kt(t, n) {
2005
+ function Zt(t, n) {
1936
2006
  if (t >= n)
1937
- throw new l("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${n}`);
2007
+ throw new u("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${n}`);
1938
2008
  }
1939
- function Zn(t, n) {
2009
+ function ie(t, n) {
1940
2010
  if (!Number.isInteger(t) || t < 0 || t >= n.length)
1941
- throw new l("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
2011
+ throw new u("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
1942
2012
  if (n[t].name !== "0")
1943
- throw new l("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
2013
+ throw new u("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
1944
2014
  }
1945
- function Ao(t) {
2015
+ function bo(t) {
1946
2016
  if (t !== 0)
1947
- throw new l("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
2017
+ throw new u("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
1948
2018
  }
1949
- function* No(t, n, e, o, a) {
2019
+ function* Bo(t, n, e, o, i) {
1950
2020
  let r = e;
1951
- const i = [
2021
+ const s = [
1952
2022
  { kind: "line", count: o.lineCount },
1953
2023
  { kind: "fill", count: o.fillCount },
1954
2024
  { kind: "dot", count: o.dotCount }
1955
2025
  ];
1956
- for (const c of i) {
1957
- const s = de(t, n, r, c.count);
2026
+ for (const l of s) {
2027
+ const a = Re(t, n, r, l.count);
1958
2028
  for (; ; ) {
1959
- const u = s.next();
1960
- if (u.done) {
1961
- r = u.value;
2029
+ const c = a.next();
2030
+ if (c.done) {
2031
+ r = c.value;
1962
2032
  break;
1963
2033
  }
1964
- yield { kind: c.kind, payload: u.value };
2034
+ yield { kind: l.kind, payload: c.value };
1965
2035
  }
1966
2036
  }
1967
2037
  if (r !== t.byteLength)
1968
- throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${r}, size=${t.byteLength}`);
1969
- for (const c of o.texts)
1970
- yield { kind: "text", payload: c };
2038
+ throw new u("E_GROUP_RANGE", `Trailing bytes detected: offset=${r}, size=${t.byteLength}`);
2039
+ for (const l of o.texts)
2040
+ yield { kind: "text", payload: l };
1971
2041
  }
1972
- function* Ro(t, n, e, o) {
1973
- yield* No(t, n, e, o);
2042
+ function* Uo(t, n, e, o) {
2043
+ yield* Bo(t, n, e, o);
1974
2044
  }
1975
- function Dt(t, n, e, o, a, r, i) {
1976
- let c = t.count, s = 0;
1977
- for (const f of e) {
1978
- if (!Nt(f.instanceId, i))
2045
+ function Xt(t, n, e, o, i, r, s) {
2046
+ let l = t.count, a = 0;
2047
+ for (const m of e) {
2048
+ if (!Nt(m.instanceId, s))
1979
2049
  continue;
1980
- const w = n.get(f.variantId);
1981
- if (!w)
1982
- throw new l("E_GROUP_RANGE", `Unknown variantId ${f.variantId}`);
1983
- const y = w[o].count;
1984
- s += y, c += y;
2050
+ const A = n.get(m.variantId);
2051
+ if (!A)
2052
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2053
+ const y = A[o].count;
2054
+ a += y, l += y;
1985
2055
  }
1986
- if ($n(i, o, s), c === 0)
1987
- return It();
1988
- const u = new Float32Array(c * 2), h = [];
1989
- let d = 0;
1990
- ((f) => {
1991
- u.set(f.pos, d * 2), h.push(...Ht(ot(f), d)), d += f.count;
2056
+ if (Xn(s, o, a), l === 0)
2057
+ return Vt();
2058
+ const c = new Float32Array(l * 2), _ = [];
2059
+ let f = 0;
2060
+ ((m) => {
2061
+ c.set(m.pos, f * 2), _.push(...qt(rt(m), f)), f += m.count;
1992
2062
  })(t);
1993
- for (const f of e) {
1994
- if (!Nt(f.instanceId, i))
2063
+ for (const m of e) {
2064
+ if (!Nt(m.instanceId, s))
1995
2065
  continue;
1996
- const w = n.get(f.variantId);
1997
- if (!w)
1998
- throw new l("E_GROUP_RANGE", `Unknown variantId ${f.variantId}`);
1999
- const y = w[o], m = r[f.insLayerIdx].visible === !1;
2000
- for (let x = 0; x < y.count; x += 1) {
2001
- const G = x * 2, R = (d + x) * 2, P = y.pos[G], B = y.pos[G + 1];
2002
- u[R] = f.matA * P + f.matC * B + f.tx, u[R + 1] = f.matB * P + f.matD * B + f.ty;
2066
+ const A = n.get(m.variantId);
2067
+ if (!A)
2068
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2069
+ const y = A[o], x = r[m.insLayerIdx].visible === !1;
2070
+ for (let h = 0; h < y.count; h += 1) {
2071
+ const R = h * 2, p = (f + h) * 2, v = y.pos[R], U = y.pos[R + 1];
2072
+ c[p] = m.matA * v + m.matC * U + m.tx, c[p + 1] = m.matB * v + m.matD * U + m.ty;
2003
2073
  }
2004
- h.push(...Ht(
2005
- Cn(
2006
- ot(y),
2007
- (x) => m || x === a ? f.insLayerIdx : x
2074
+ _.push(...qt(
2075
+ vn(
2076
+ rt(y),
2077
+ (h) => x || h === i ? m.insLayerIdx : h
2008
2078
  ),
2009
- d
2010
- )), d += y.count;
2079
+ f
2080
+ )), f += y.count;
2011
2081
  }
2012
- return { pos: u, count: c, segments: dt(h) };
2082
+ return { pos: c, count: l, segments: mt(_) };
2013
2083
  }
2014
- function* vt(t, n, e, o, a, r, i, c) {
2015
- if ($n(c, t, Math.max(0, n - e.count)), n === 0) {
2016
- yield { kind: t, payload: It() };
2084
+ function* Lt(t, n, e, o, i, r, s, l) {
2085
+ if (Xn(l, t, Math.max(0, n - e.count)), n === 0) {
2086
+ yield { kind: t, payload: Vt() };
2017
2087
  return;
2018
2088
  }
2019
- const s = Lt;
2020
- let u = new Float32Array(s * 2), h = [], d = 0, _ = 0;
2021
- const f = function* () {
2022
- if (d <= 0)
2089
+ const a = Yt;
2090
+ let c = new Float32Array(a * 2), _ = [], f = 0, d = 0;
2091
+ const m = function* () {
2092
+ if (f <= 0)
2023
2093
  return;
2024
- const m = d === s ? { pos: u, count: d, segments: dt(h) } : { pos: u.slice(0, d * 2), count: d, segments: dt(h) };
2025
- yield { kind: t, payload: m }, _ += d, d = 0, u = new Float32Array(s * 2), h = [];
2026
- }, w = (m, x, G, N) => {
2027
- if (m <= 0)
2094
+ const x = f === a ? { pos: c, count: f, segments: mt(_) } : { pos: c.slice(0, f * 2), count: f, segments: mt(_) };
2095
+ yield { kind: t, payload: x }, d += f, f = 0, c = new Float32Array(a * 2), _ = [];
2096
+ }, A = (x, h, R, w) => {
2097
+ if (x <= 0)
2028
2098
  return;
2029
- const R = h[h.length - 1];
2030
- if (R && R.startVertex + R.vertexCount === d && R.layerIndex === G && R.color[0] === x[0] && R.color[1] === x[1] && R.color[2] === x[2] && R.lineweightPx === N) {
2031
- h[h.length - 1] = {
2032
- ...R,
2033
- vertexCount: R.vertexCount + m
2099
+ const p = _[_.length - 1];
2100
+ if (p && p.startVertex + p.vertexCount === f && p.layerIndex === R && p.color[0] === h[0] && p.color[1] === h[1] && p.color[2] === h[2] && p.lineweightPx === w) {
2101
+ _[_.length - 1] = {
2102
+ ...p,
2103
+ vertexCount: p.vertexCount + x
2034
2104
  };
2035
2105
  return;
2036
2106
  }
2037
- h.push({
2038
- startVertex: d,
2039
- vertexCount: m,
2040
- color: [x[0], x[1], x[2]],
2041
- layerIndex: G,
2042
- ...N === void 0 ? {} : { lineweightPx: N }
2107
+ _.push({
2108
+ startVertex: f,
2109
+ vertexCount: x,
2110
+ color: [h[0], h[1], h[2]],
2111
+ layerIndex: R,
2112
+ ...w === void 0 ? {} : { lineweightPx: w }
2043
2113
  });
2044
2114
  };
2045
2115
  yield* function* () {
2046
- for (const m of ot(e)) {
2047
- let x = m.startVertex;
2048
- const G = m.startVertex + m.vertexCount;
2049
- for (; x < G; ) {
2050
- const N = Math.min(s - d, G - x), R = x * 2, P = d * 2;
2051
- u.set(e.pos.subarray(R, R + N * 2), P), w(N, m.color, m.layerIndex, m.lineweightPx), x += N, d += N, d === s && (yield* f());
2116
+ for (const x of rt(e)) {
2117
+ let h = x.startVertex;
2118
+ const R = x.startVertex + x.vertexCount;
2119
+ for (; h < R; ) {
2120
+ const w = Math.min(a - f, R - h), p = h * 2, v = f * 2;
2121
+ c.set(e.pos.subarray(p, p + w * 2), v), A(w, x.color, x.layerIndex, x.lineweightPx), h += w, f += w, f === a && (yield* m());
2052
2122
  }
2053
2123
  }
2054
2124
  }();
2055
- for (const m of a) {
2056
- if (!Nt(m.instanceId, c))
2125
+ for (const x of i) {
2126
+ if (!Nt(x.instanceId, l))
2057
2127
  continue;
2058
- const x = o.get(m.variantId);
2059
- if (!x)
2060
- throw new l("E_GROUP_RANGE", `Unknown variantId ${m.variantId}`);
2061
- const G = x[t], N = i[m.insLayerIdx].visible === !1;
2062
- for (const R of ot(G)) {
2063
- const P = N || R.layerIndex === r ? m.insLayerIdx : R.layerIndex;
2064
- let B = R.startVertex;
2065
- const D = R.startVertex + R.vertexCount;
2066
- for (; B < D; ) {
2067
- const C = Math.min(s - d, D - B);
2068
- for (let $ = 0; $ < C; $ += 1) {
2069
- const O = (B + $) * 2, v = (d + $) * 2, K = G.pos[O], A = G.pos[O + 1];
2070
- u[v] = m.matA * K + m.matC * A + m.tx, u[v + 1] = m.matB * K + m.matD * A + m.ty;
2128
+ const h = o.get(x.variantId);
2129
+ if (!h)
2130
+ throw new u("E_GROUP_RANGE", `Unknown variantId ${x.variantId}`);
2131
+ const R = h[t], w = s[x.insLayerIdx].visible === !1;
2132
+ for (const p of rt(R)) {
2133
+ const v = w || p.layerIndex === r ? x.insLayerIdx : p.layerIndex;
2134
+ let U = p.startVertex;
2135
+ const D = p.startVertex + p.vertexCount;
2136
+ for (; U < D; ) {
2137
+ const $ = Math.min(a - f, D - U);
2138
+ for (let M = 0; M < $; M += 1) {
2139
+ const Y = (U + M) * 2, z = (f + M) * 2, S = R.pos[Y], N = R.pos[Y + 1];
2140
+ c[z] = x.matA * S + x.matC * N + x.tx, c[z + 1] = x.matB * S + x.matD * N + x.ty;
2071
2141
  }
2072
- w(C, R.color, P, R.lineweightPx), B += C, d += C, d === s && (yield* f());
2142
+ A($, p.color, v, p.lineweightPx), U += $, f += $, f === a && (yield* m());
2073
2143
  }
2074
2144
  }
2075
2145
  }
2076
- if (yield* f(), _ !== n)
2077
- throw new l("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${n}, emitted=${_}`);
2146
+ if (yield* m(), d !== n)
2147
+ throw new u("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${n}, emitted=${d}`);
2078
2148
  }
2079
- function* po(t, n, e, o) {
2080
- yield* vt(
2149
+ function* So(t, n, e, o) {
2150
+ yield* Lt(
2081
2151
  "line",
2082
2152
  n.lineCount,
2083
2153
  t.baseLine,
@@ -2086,7 +2156,7 @@ function* po(t, n, e, o) {
2086
2156
  e.layer0_index,
2087
2157
  n.layers,
2088
2158
  o
2089
- ), yield* vt(
2159
+ ), yield* Lt(
2090
2160
  "fill",
2091
2161
  n.fillCount,
2092
2162
  t.baseFill,
@@ -2095,7 +2165,7 @@ function* po(t, n, e, o) {
2095
2165
  e.layer0_index,
2096
2166
  n.layers,
2097
2167
  o
2098
- ), yield* vt(
2168
+ ), yield* Lt(
2099
2169
  "dot",
2100
2170
  n.dotCount,
2101
2171
  t.baseDot,
@@ -2105,44 +2175,48 @@ function* po(t, n, e, o) {
2105
2175
  n.layers,
2106
2176
  o
2107
2177
  );
2108
- for (const a of n.texts)
2109
- yield { kind: "text", payload: a };
2110
- }
2111
- function Io(t, n) {
2112
- const e = On(n), o = Wn(t, e);
2113
- return {
2114
- header: o.header,
2115
- chunks: po(
2116
- o.decoded,
2117
- o.header,
2118
- { layer0_index: o.meta.layer0_index ?? 0 },
2119
- e
2178
+ for (const i of n.texts)
2179
+ yield { kind: "text", payload: i };
2180
+ }
2181
+ function se(t, n, e) {
2182
+ const o = Dn(n), i = oe(t, o, e);
2183
+ return i.documentCache && Pn.add(i.documentCache), {
2184
+ header: i.header,
2185
+ ...i.documentCache ? { documentCache: i.documentCache } : {},
2186
+ chunks: So(
2187
+ i.decoded,
2188
+ i.header,
2189
+ { layer0_index: i.meta.layer0_index ?? 0 },
2190
+ o
2120
2191
  )
2121
2192
  };
2122
2193
  }
2123
- function Go(t, n) {
2124
- if (rt(t))
2125
- return Io(t, n);
2126
- const e = tn(t);
2194
+ function ae(t, n) {
2195
+ if (Q(t))
2196
+ return se(t, n);
2197
+ const e = on(t);
2127
2198
  return {
2128
2199
  header: e.header,
2129
- chunks: Ro(t, e.view, e.dataOffset, e.header)
2200
+ chunks: Uo(t, e.view, e.dataOffset, e.header)
2130
2201
  };
2131
2202
  }
2132
- function Do(t) {
2133
- if (rt(t)) {
2134
- const n = vn(t);
2135
- return ao(n.bounds, "V3 SCENE_META bounds");
2203
+ function Fo(t, n, e) {
2204
+ return n.kind !== "dxb3-v3" || n.buffer !== t || !Pn.has(n) || !Q(t) ? ae(t, e) : se(t, e, n);
2205
+ }
2206
+ function zo(t) {
2207
+ if (Q(t)) {
2208
+ const n = Fn(t);
2209
+ return go(n.bounds, "V3 SCENE_META bounds");
2136
2210
  }
2137
- return tn(t).header.bounds;
2211
+ return on(t).header.bounds;
2138
2212
  }
2139
- function* vo(t, n) {
2140
- const e = Go(t, n);
2213
+ function* Ho(t, n) {
2214
+ const e = ae(t, n);
2141
2215
  for (const o of e.chunks)
2142
2216
  yield o;
2143
2217
  return e.header;
2144
2218
  }
2145
- function Xt() {
2219
+ function kt() {
2146
2220
  return {
2147
2221
  pos: new Float32Array(0),
2148
2222
  col: new Uint8Array(0),
@@ -2150,8 +2224,8 @@ function Xt() {
2150
2224
  count: 0
2151
2225
  };
2152
2226
  }
2153
- function it(t) {
2154
- const n = Be(t);
2227
+ function at(t) {
2228
+ const n = Le(t);
2155
2229
  return {
2156
2230
  pos: t.pos,
2157
2231
  col: n.col,
@@ -2159,104 +2233,105 @@ function it(t) {
2159
2233
  count: t.count
2160
2234
  };
2161
2235
  }
2162
- function Xo(t, n) {
2163
- if (rt(t)) {
2164
- const c = On(n), s = Wn(t, c), u = Dt(
2165
- s.decoded.baseLine,
2166
- s.decoded.variants,
2167
- s.decoded.instances,
2236
+ function jo(t, n) {
2237
+ if (Q(t)) {
2238
+ const l = Dn(n), a = oe(t, l), c = Xt(
2239
+ a.decoded.baseLine,
2240
+ a.decoded.variants,
2241
+ a.decoded.instances,
2168
2242
  "line",
2169
- s.meta.layer0_index ?? 0,
2170
- s.header.layers,
2171
- c
2172
- ), h = Dt(
2173
- s.decoded.baseFill,
2174
- s.decoded.variants,
2175
- s.decoded.instances,
2243
+ a.meta.layer0_index ?? 0,
2244
+ a.header.layers,
2245
+ l
2246
+ ), _ = Xt(
2247
+ a.decoded.baseFill,
2248
+ a.decoded.variants,
2249
+ a.decoded.instances,
2176
2250
  "fill",
2177
- s.meta.layer0_index ?? 0,
2178
- s.header.layers,
2179
- c
2180
- ), d = Dt(
2181
- s.decoded.baseDot,
2182
- s.decoded.variants,
2183
- s.decoded.instances,
2251
+ a.meta.layer0_index ?? 0,
2252
+ a.header.layers,
2253
+ l
2254
+ ), f = Xt(
2255
+ a.decoded.baseDot,
2256
+ a.decoded.variants,
2257
+ a.decoded.instances,
2184
2258
  "dot",
2185
- s.meta.layer0_index ?? 0,
2186
- s.header.layers,
2187
- c
2259
+ a.meta.layer0_index ?? 0,
2260
+ a.header.layers,
2261
+ l
2188
2262
  );
2189
2263
  return {
2190
- meta: s.meta,
2191
- line: it(u),
2192
- fill: it(h),
2193
- dot: it(d),
2264
+ meta: a.meta,
2265
+ line: at(c),
2266
+ fill: at(_),
2267
+ dot: at(f),
2194
2268
  rawBytes: t.byteLength
2195
2269
  };
2196
2270
  }
2197
- const e = tn(t);
2271
+ const e = on(t);
2198
2272
  let o = e.dataOffset;
2199
- const a = lt(t, e.view, o, e.header.lineCount);
2200
- o = a.offset;
2201
- const r = lt(t, e.view, o, e.header.fillCount);
2273
+ const i = ft(t, e.view, o, e.header.lineCount);
2274
+ o = i.offset;
2275
+ const r = ft(t, e.view, o, e.header.fillCount);
2202
2276
  o = r.offset;
2203
- const i = lt(t, e.view, o, e.header.dotCount);
2204
- if (o = i.offset, o !== t.byteLength)
2205
- throw new l("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
2277
+ const s = ft(t, e.view, o, e.header.dotCount);
2278
+ if (o = s.offset, o !== t.byteLength)
2279
+ throw new u("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
2206
2280
  return {
2207
2281
  meta: e.meta,
2208
- line: it(a.chunk),
2209
- fill: it(r.chunk),
2210
- dot: it(i.chunk),
2282
+ line: at(i.chunk),
2283
+ fill: at(r.chunk),
2284
+ dot: at(s.chunk),
2211
2285
  rawBytes: t.byteLength
2212
2286
  };
2213
2287
  }
2214
- function Lo(t, n) {
2215
- return t ? fe(Bn(t, n)) : null;
2288
+ function qo(t, n) {
2289
+ return t ? Ne(On(t, n)) : null;
2216
2290
  }
2217
2291
  export {
2218
- l as CadPackError,
2219
- l as GeoLoaderError,
2220
- Lt as STREAM_VERTEX_WINDOW,
2221
- Ne as assertStrictTextRoundtrip,
2222
- To as captureGroupSnapshot,
2223
- Yt as cloneViewportRect,
2224
- Ee as computeViewportRectFromPositions,
2225
- It as emptyGeometryChunk,
2226
- Be as expandGeometryChunkMetadata,
2227
- he as expandViewportRect,
2228
- et as getDxbsSection,
2229
- Wt as groupLayerEncodingForV3Minor,
2230
- _e as intersectViewportRects,
2231
- Ge as isDxbsPayload,
2232
- Ae as isStrictTextRoundtripEnabled,
2233
- dt as mergeAdjacentSegments,
2234
- me as mergeViewportRects,
2235
- ot as normalizeGeometrySegments,
2236
- fe as normalizeViewportRect,
2237
- Ht as offsetGeometrySegments,
2238
- Do as parseBinBounds,
2239
- Xo as parseBinPayload,
2240
- Go as parseBinStreaming,
2241
- vo as parseBinToChunks,
2242
- be as readBlockAnnotationSidecar,
2243
- Jt as readDxbsContainer,
2244
- Mo as readExternalAnnotationManifest,
2245
- Po as readExternalBlockAnnotations,
2246
- $o as readExternalVariantDependencyPlan,
2247
- uo as readExternalVariantGeometrySidecar,
2248
- Oo as readExternalVariantManifest,
2249
- lt as readGroup,
2250
- So as readSceneAnnotationSidecar,
2251
- Cn as remapGeometrySegmentLayers,
2252
- Uo as shouldAssertStrictTextRoundtrip,
2253
- Co as sliceGeometrySegments,
2254
- de as streamGroupChunks,
2255
- Lo as transformBBoxByInstance,
2256
- Bn as transformViewportRect,
2257
- ge as viewportRectCenterDistance,
2258
- bo as viewportRectContains,
2259
- xe as viewportRectDiagonal,
2260
- Bo as viewportRectEquals,
2261
- bn as viewportRectIntersects
2292
+ u as CadPackError,
2293
+ u as GeoLoaderError,
2294
+ Yt as STREAM_VERTEX_WINDOW,
2295
+ Ce as assertStrictTextRoundtrip,
2296
+ Oo as captureGroupSnapshot,
2297
+ Ft as cloneViewportRect,
2298
+ Ge as computeViewportRectFromPositions,
2299
+ Vt as emptyGeometryChunk,
2300
+ Le as expandGeometryChunkMetadata,
2301
+ Ve as expandViewportRect,
2302
+ ot as getDxbsSection,
2303
+ Qt as groupLayerEncodingForV3Minor,
2304
+ Ie as intersectViewportRects,
2305
+ ve as isDxbsPayload,
2306
+ Se as isStrictTextRoundtripEnabled,
2307
+ mt as mergeAdjacentSegments,
2308
+ pe as mergeViewportRects,
2309
+ rt as normalizeGeometrySegments,
2310
+ Ne as normalizeViewportRect,
2311
+ qt as offsetGeometrySegments,
2312
+ zo as parseBinBounds,
2313
+ jo as parseBinPayload,
2314
+ ae as parseBinStreaming,
2315
+ Fo as parseBinStreamingWithCache,
2316
+ Ho as parseBinToChunks,
2317
+ Xe as readBlockAnnotationSidecar,
2318
+ tn as readDxbsContainer,
2319
+ ko as readExternalAnnotationManifest,
2320
+ Yo as readExternalBlockAnnotations,
2321
+ Lo as readExternalVariantDependencyPlan,
2322
+ wo as readExternalVariantGeometrySidecar,
2323
+ Xo as readExternalVariantManifest,
2324
+ ft as readGroup,
2325
+ Po as readSceneAnnotationSidecar,
2326
+ vn as remapGeometrySegmentLayers,
2327
+ vo as shouldAssertStrictTextRoundtrip,
2328
+ Do as sliceGeometrySegments,
2329
+ Re as streamGroupChunks,
2330
+ qo as transformBBoxByInstance,
2331
+ On as transformViewportRect,
2332
+ be as viewportRectCenterDistance,
2333
+ $o as viewportRectContains,
2334
+ Te as viewportRectDiagonal,
2335
+ Mo as viewportRectEquals,
2336
+ Cn as viewportRectIntersects
2262
2337
  };