@flyfish-dev/cad-viewer 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- var Kt = Object.defineProperty;
2
- var Jt = (e, t, r) => t in e ? Kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var d = (e, t, r) => Jt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { openDwfDocument as Qt, DwfViewer as te } from "dwf-viewer";
5
- async function _(e) {
1
+ var ee = Object.defineProperty;
2
+ var re = (e, t, r) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var d = (e, t, r) => re(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { openDwfDocument as ie, DwfViewer as se } from "dwf-viewer";
5
+ async function U(e) {
6
6
  if (e.buffer instanceof Uint8Array) return e.buffer;
7
7
  if (e.buffer instanceof ArrayBuffer) return new Uint8Array(e.buffer);
8
8
  if (e.file) return new Uint8Array(await e.file.arrayBuffer());
9
9
  throw new Error("CadLoadInput requires a File, ArrayBuffer, or Uint8Array.");
10
10
  }
11
- function ee(e) {
11
+ function ne(e) {
12
12
  return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
13
13
  }
14
14
  function L(e) {
@@ -16,7 +16,7 @@ function L(e) {
16
16
  const t = e.fileName ?? ((i = e.file) == null ? void 0 : i.name) ?? "", r = t.lastIndexOf(".");
17
17
  return r >= 0 ? t.slice(r + 1).toLowerCase() : "";
18
18
  }
19
- function A(e, t) {
19
+ function B(e, t) {
20
20
  const r = L(e);
21
21
  if (r === "dwg") return "dwg";
22
22
  if (r === "dxf") return "dxf";
@@ -24,19 +24,19 @@ function A(e, t) {
24
24
  if (r === "xps") return "xps";
25
25
  if (r === "dwf") return "dwf";
26
26
  if (t && t.byteLength >= 6) {
27
- const i = vt(t.slice(0, 6));
27
+ const i = xt(t.slice(0, 6));
28
28
  if (/^AC10/.test(i)) return "dwg";
29
29
  if (t[0] === 80 && t[1] === 75) return "dwfx";
30
- const s = vt(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
30
+ const s = xt(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
31
31
  if (s.includes("SECTION") && s.includes("ENTITIES")) return "dxf";
32
32
  if (s.includes("DWF")) return "dwf";
33
33
  }
34
34
  return "unknown";
35
35
  }
36
- function vt(e) {
36
+ function xt(e) {
37
37
  return Array.from(e, (t) => t >= 32 && t <= 126 ? String.fromCharCode(t) : " ").join("");
38
38
  }
39
- class re {
39
+ class oe {
40
40
  constructor(t = []) {
41
41
  d(this, "loaders", []);
42
42
  for (const r of t) this.register(r);
@@ -53,7 +53,7 @@ class re {
53
53
  return [...this.loaders];
54
54
  }
55
55
  async detect(t) {
56
- const r = await _(t), i = A(t, r), s = this.loaders.find((o) => o.formats.includes(i) && o.accepts(t, r));
56
+ const r = await U(t), i = B(t, r), s = this.loaders.find((o) => o.formats.includes(i) && o.accepts(t, r));
57
57
  if (s) return { loader: s, bytes: r, format: i };
58
58
  const n = this.loaders.find((o) => o.accepts(t, r));
59
59
  if (n) return { loader: n, bytes: r, format: i };
@@ -64,27 +64,27 @@ class re {
64
64
  return i.load({ ...t, buffer: s }, r);
65
65
  }
66
66
  }
67
- class ie {
67
+ class ae {
68
68
  constructor() {
69
69
  d(this, "worker");
70
70
  d(this, "sequence", 0);
71
71
  d(this, "pending", /* @__PURE__ */ new Map());
72
72
  }
73
73
  load(t, r, i = {}) {
74
- var h, l;
75
- if (!lt()) throw new Error("Web Worker is not available in this runtime.");
76
- const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((h = r.file) == null ? void 0 : h.name), c = ne(t, r, i);
77
- return (l = i.onProgress) == null || l.call(i, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((f, u) => {
74
+ var l, h;
75
+ if (!dt()) throw new Error("Web Worker is not available in this runtime.");
76
+ const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((l = r.file) == null ? void 0 : l.name), c = le(t, r, i);
77
+ return (h = i.onProgress) == null || h.call(i, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((f, u) => {
78
78
  var g;
79
79
  if ((g = i.signal) != null && g.aborted) {
80
- u($());
80
+ u(j());
81
81
  return;
82
82
  }
83
83
  const p = { resolve: f, reject: u, onProgress: i.onProgress, signal: i.signal };
84
84
  o > 0 && (p.timer = setTimeout(() => {
85
85
  this.pending.delete(n), this.resetWorker(), u(new Error(`DWG worker timed out after ${o} ms.`));
86
86
  }, o)), i.signal && (p.abortHandler = () => {
87
- this.pending.delete(n), this.resetWorker(), u($());
87
+ this.pending.delete(n), this.resetWorker(), u(j());
88
88
  }, i.signal.addEventListener("abort", p.abortHandler, { once: !0 })), this.pending.set(n, p);
89
89
  try {
90
90
  s.postMessage({
@@ -92,21 +92,21 @@ class ie {
92
92
  requestId: n,
93
93
  bytes: c,
94
94
  fileName: a,
95
- options: yt(i)
95
+ options: Ct(i)
96
96
  }, [c]);
97
97
  } catch (S) {
98
- this.pending.delete(n), V(p), u(S instanceof Error ? S : new Error(String(S)));
98
+ this.pending.delete(n), $(p), u(S instanceof Error ? S : new Error(String(S)));
99
99
  }
100
100
  });
101
101
  }
102
102
  preload(t = {}) {
103
103
  var n;
104
- if (!lt()) return Promise.reject(new Error("Web Worker is not available in this runtime."));
104
+ if (!dt()) return Promise.reject(new Error("Web Worker is not available in this runtime."));
105
105
  const r = this.ensureWorker(t), i = ++this.sequence, s = Math.max(0, Number(t.workerTimeoutMs ?? 0));
106
106
  return (n = t.onProgress) == null || n.call(t, { phase: "worker-start", format: "dwg", message: "Starting DWG worker warmup…" }), new Promise((o, a) => {
107
- var h;
108
- if ((h = t.signal) != null && h.aborted) {
109
- a($());
107
+ var l;
108
+ if ((l = t.signal) != null && l.aborted) {
109
+ a(j());
110
110
  return;
111
111
  }
112
112
  const c = {
@@ -118,12 +118,12 @@ class ie {
118
118
  s > 0 && (c.timer = setTimeout(() => {
119
119
  this.pending.delete(i), this.resetWorker(), a(new Error(`DWG worker warmup timed out after ${s} ms.`));
120
120
  }, s)), t.signal && (c.abortHandler = () => {
121
- this.pending.delete(i), this.resetWorker(), a($());
121
+ this.pending.delete(i), this.resetWorker(), a(j());
122
122
  }, t.signal.addEventListener("abort", c.abortHandler, { once: !0 })), this.pending.set(i, c);
123
123
  try {
124
- r.postMessage({ type: "warmup", requestId: i, options: yt(t) });
125
- } catch (l) {
126
- this.pending.delete(i), V(c), a(l instanceof Error ? l : new Error(String(l)));
124
+ r.postMessage({ type: "warmup", requestId: i, options: Ct(t) });
125
+ } catch (h) {
126
+ this.pending.delete(i), $(c), a(h instanceof Error ? h : new Error(String(h)));
127
127
  }
128
128
  });
129
129
  }
@@ -131,7 +131,7 @@ class ie {
131
131
  this.resetWorker();
132
132
  }
133
133
  ensureWorker(t) {
134
- return this.worker || (this.worker = se(t), this.worker.onmessage = (r) => this.handleMessage(r.data), this.worker.onerror = (r) => {
134
+ return this.worker || (this.worker = ce(t), this.worker.onmessage = (r) => this.handleMessage(r.data), this.worker.onerror = (r) => {
135
135
  const i = r.message || "DWG worker failed.";
136
136
  this.rejectAll(new Error(i)), this.resetWorker(!1);
137
137
  }, this.worker.onmessageerror = () => {
@@ -147,7 +147,7 @@ class ie {
147
147
  (s = r.onProgress) == null || s.call(r, t.progress);
148
148
  return;
149
149
  }
150
- if (this.pending.delete(t.requestId), V(r), t.type === "result") {
150
+ if (this.pending.delete(t.requestId), $(r), t.type === "result") {
151
151
  r.resolve(t.result);
152
152
  return;
153
153
  }
@@ -160,7 +160,7 @@ class ie {
160
160
  }
161
161
  rejectAll(t) {
162
162
  for (const [, r] of this.pending)
163
- V(r), r.reject(t);
163
+ $(r), r.reject(t);
164
164
  this.pending.clear();
165
165
  }
166
166
  resetWorker(t = !0) {
@@ -168,77 +168,77 @@ class ie {
168
168
  t && this.rejectAll(new Error("DWG worker was terminated.")), (r = this.worker) == null || r.terminate(), this.worker = void 0;
169
169
  }
170
170
  }
171
- function lt() {
171
+ function dt() {
172
172
  return typeof Worker < "u" && typeof URL < "u";
173
173
  }
174
- function se(e) {
174
+ function ce(e) {
175
175
  return e.workerFactory ? e.workerFactory() : e.workerUrl ? new Worker(e.workerUrl, { type: "module", name: "lightweight-cad-dwg-loader" }) : new Worker(new URL(
176
176
  /* @vite-ignore */
177
177
  "/assets/DwgWorker-CuZJ5EUe.js",
178
178
  import.meta.url
179
179
  ), { type: "module", name: "lightweight-cad-dwg-loader" });
180
180
  }
181
- function yt(e) {
181
+ function Ct(e) {
182
182
  return {
183
183
  // Resolve the asset directory on the UI thread. Relative paths such as
184
184
  // './wasm' must be relative to the document URL, not to the generated
185
185
  // worker chunk URL. Otherwise the worker may request /assets/wasm/... and
186
186
  // receive the app's HTML fallback instead of libredwg-web.wasm.
187
- wasmPath: oe(e.wasmPath),
187
+ wasmPath: he(e.wasmPath),
188
188
  includePaperSpace: e.includePaperSpace,
189
189
  maxInsertDepth: e.maxInsertDepth,
190
190
  keepRaw: !!e.keepRaw
191
191
  };
192
192
  }
193
- function ne(e, t, r) {
194
- return !!t.file || r.transferInputBuffer === !0 ? ee(e) : e.slice().buffer;
193
+ function le(e, t, r) {
194
+ return !!t.file || r.transferInputBuffer === !0 ? ne(e) : e.slice().buffer;
195
195
  }
196
- function V(e) {
196
+ function $(e) {
197
197
  e.timer && clearTimeout(e.timer), e.signal && e.abortHandler && e.signal.removeEventListener("abort", e.abortHandler);
198
198
  }
199
- function $() {
199
+ function j() {
200
200
  if (typeof DOMException < "u") return new DOMException("DWG loading was aborted.", "AbortError");
201
201
  const e = new Error("DWG loading was aborted.");
202
202
  return e.name = "AbortError", e;
203
203
  }
204
- function oe(e) {
204
+ function he(e) {
205
205
  const t = ((e == null ? void 0 : e.trim()) || "/wasm").replace(/\/+$/, "");
206
- return t === "" ? xt() : ae(t) ? t : t.startsWith("/") ? `${xt()}${t}` : new URL(t, Ot()).href.replace(/\/+$/, "");
206
+ return t === "" ? Pt() : fe(t) ? t : t.startsWith("/") ? `${Pt()}${t}` : new URL(t, Yt()).href.replace(/\/+$/, "");
207
207
  }
208
- function Ot() {
208
+ function Yt() {
209
209
  return typeof document < "u" && document.baseURI ? document.baseURI : typeof location < "u" && location.href ? location.href : "http://localhost/";
210
210
  }
211
- function xt() {
212
- return typeof location < "u" && location.origin ? location.origin : new URL(Ot()).origin;
211
+ function Pt() {
212
+ return typeof location < "u" && location.origin ? location.origin : new URL(Yt()).origin;
213
213
  }
214
- function ae(e) {
214
+ function fe(e) {
215
215
  return /^[a-z][a-z0-9+.-]*:/i.test(e);
216
216
  }
217
- class ce {
217
+ class de {
218
218
  constructor(t = {}) {
219
219
  d(this, "id", "dwg");
220
220
  d(this, "label", "DWG / LibreDWG WebAssembly");
221
221
  d(this, "formats", ["dwg"]);
222
222
  d(this, "defaults");
223
- d(this, "workerClient", new ie());
223
+ d(this, "workerClient", new ae());
224
224
  this.defaults = { useWorker: !0, ...t };
225
225
  }
226
226
  accepts(t, r) {
227
- return L(t) === "dwg" ? !0 : A(t, r) === "dwg";
227
+ return L(t) === "dwg" ? !0 : B(t, r) === "dwg";
228
228
  }
229
229
  async load(t, r = {}) {
230
230
  var o, a;
231
231
  const i = { ...this.defaults, ...r };
232
232
  (o = i.onProgress) == null || o.call(i, { phase: "read", format: "dwg", message: "Reading DWG bytes…" });
233
- const s = await _(t), n = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
233
+ const s = await U(t), n = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
234
234
  if (i.useWorker === !1)
235
235
  throw new Error("DWG main-thread parsing is intentionally not bundled by the default viewer. Keep useWorker enabled, or register a custom DWG loader for non-browser runtimes.");
236
- if (!lt())
236
+ if (!dt())
237
237
  throw new Error("DWG loading requires Web Worker support in this build. Provide a custom loader for this runtime.");
238
238
  try {
239
239
  return await this.workerClient.load(s, t, { ...i, fileName: n });
240
240
  } catch (c) {
241
- throw he(c) ? c : le(c);
241
+ throw ue(c) ? c : me(c);
242
242
  }
243
243
  }
244
244
  terminateWorker() {
@@ -249,14 +249,14 @@ class ce {
249
249
  return r.useWorker === !1 ? Promise.reject(new Error("DWG preload requires worker mode in the default viewer.")) : this.workerClient.preload(r);
250
250
  }
251
251
  }
252
- function he(e) {
252
+ function ue(e) {
253
253
  return e instanceof Error && e.name === "AbortError";
254
254
  }
255
- function le(e) {
255
+ function me(e) {
256
256
  const t = e instanceof Error ? e.message : String(e);
257
257
  return new Error(`${t} If the worker asset cannot be resolved by your bundler/CDN, pass workerUrl or workerFactory to CadViewer.`);
258
258
  }
259
- function zt(e) {
259
+ function Xt(e) {
260
260
  return {
261
261
  format: e.format,
262
262
  sourceName: e.sourceName,
@@ -322,18 +322,18 @@ function R(e) {
322
322
  return "unsupported";
323
323
  }
324
324
  }
325
- function fe(e, t, r = {}) {
325
+ function pe(e, t, r = {}) {
326
326
  const i = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), s = r.includeUnknownProperties === !1 ? { type: i, kind: R(i) } : { ...e, type: i, kind: R(i) };
327
327
  r.keepRaw && (s.raw = e), s.handle = C(e.handle ?? e.id), s.layer = C(e.layer ?? e.layerName), s.lineType = C(e.lineType ?? e.linetype);
328
328
  const n = r.numericColorMode ?? "auto", o = y(e.color), a = y(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
329
329
  s.colorIndex = a ?? (n !== "rgb" && o !== void 0 && Math.abs(o) <= 257 ? o : void 0);
330
- const c = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, h = o !== void 0 && o >= 0 && o <= 16777215 && (n === "rgb" || n === "auto" && Math.abs(o) > 257);
331
- s.trueColor = c ?? (h ? o : void 0), (typeof e.color == "string" || typeof e.color == "number") && (s.color = e.color), s.colorNumber = y(e.colorNumber) ?? s.colorNumber, s.colorName = C(e.colorName ?? e.color_name) ?? s.colorName, s.fillColor = e.fillColor ?? e.fill_color, s.fillColorIndex = y(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? s.fillColorIndex, s.opacity = y(e.opacity ?? e.alpha) ?? s.opacity, s.lineweight = y(e.lineweight ?? e.lineWeight), s.isVisible = !(e.isVisible === !1 || e.visible === !1), s.startPoint = P(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? s.startPoint, s.endPoint = P(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? s.endPoint, s.center = P(e.center ?? e.centerPoint) ?? s.center, s.insertionPoint = P(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? s.insertionPoint, s.radius = y(e.radius) ?? s.radius, s.startAngle = y(e.startAngle ?? e.start_angle) ?? s.startAngle, s.endAngle = y(e.endAngle ?? e.end_angle) ?? s.endAngle, s.majorAxisEndPoint = P(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? s.majorAxisEndPoint, s.axisRatio = y(e.axisRatio ?? e.ratio) ?? s.axisRatio, s.height = y(e.height ?? e.textHeight) ?? s.height, s.textHeight = y(e.textHeight ?? e.height) ?? s.textHeight, s.rotation = y(e.rotation ?? e.angle) ?? s.rotation, s.text = C(e.text ?? e.value ?? e.string ?? e.contents) ?? s.text, s.name = C(e.name ?? e.blockName) ?? s.name, s.blockName = C(e.blockName ?? e.name) ?? s.blockName;
332
- const l = et(e.vertices ?? e.points);
333
- l.length > 0 && (s.vertices = l);
334
- const f = et(e.controlPoints ?? e.control_points);
330
+ const c = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, l = o !== void 0 && o >= 0 && o <= 16777215 && (n === "rgb" || n === "auto" && Math.abs(o) > 257);
331
+ s.trueColor = c ?? (l ? o : void 0), (typeof e.color == "string" || typeof e.color == "number") && (s.color = e.color), s.colorNumber = y(e.colorNumber) ?? s.colorNumber, s.colorName = C(e.colorName ?? e.color_name) ?? s.colorName, s.fillColor = e.fillColor ?? e.fill_color, s.fillColorIndex = y(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? s.fillColorIndex, s.opacity = y(e.opacity ?? e.alpha) ?? s.opacity, s.lineweight = y(e.lineweight ?? e.lineWeight), s.isVisible = !(e.isVisible === !1 || e.visible === !1), s.startPoint = P(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? s.startPoint, s.endPoint = P(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? s.endPoint, s.center = P(e.center ?? e.centerPoint) ?? s.center, s.insertionPoint = P(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? s.insertionPoint, s.radius = y(e.radius) ?? s.radius, s.startAngle = y(e.startAngle ?? e.start_angle) ?? s.startAngle, s.endAngle = y(e.endAngle ?? e.end_angle) ?? s.endAngle, s.majorAxisEndPoint = P(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? s.majorAxisEndPoint, s.axisRatio = y(e.axisRatio ?? e.ratio) ?? s.axisRatio, s.height = y(e.height ?? e.textHeight) ?? s.height, s.textHeight = y(e.textHeight ?? e.height) ?? s.textHeight, s.rotation = y(e.rotation ?? e.angle) ?? s.rotation, s.text = C(e.text ?? e.value ?? e.string ?? e.contents) ?? s.text, s.name = C(e.name ?? e.blockName) ?? s.name, s.blockName = C(e.blockName ?? e.name) ?? s.blockName;
332
+ const h = rt(e.vertices ?? e.points);
333
+ h.length > 0 && (s.vertices = h);
334
+ const f = rt(e.controlPoints ?? e.control_points);
335
335
  f.length > 0 && (s.controlPoints = f);
336
- const u = et(e.fitPoints ?? e.fit_points);
336
+ const u = rt(e.fitPoints ?? e.fit_points);
337
337
  return u.length > 0 && (s.fitPoints = u), s;
338
338
  }
339
339
  function P(e) {
@@ -342,7 +342,7 @@ function P(e) {
342
342
  if (!(!Number.isFinite(r) || !Number.isFinite(i)))
343
343
  return Number.isFinite(n) ? { x: r, y: i, z: n } : { x: r, y: i };
344
344
  }
345
- function et(e) {
345
+ function rt(e) {
346
346
  if (!Array.isArray(e)) return [];
347
347
  const t = [];
348
348
  for (const r of e) {
@@ -357,7 +357,7 @@ function et(e) {
357
357
  }
358
358
  return t;
359
359
  }
360
- function j(e) {
360
+ function G(e) {
361
361
  var r;
362
362
  const t = {};
363
363
  for (const i of e.entities) {
@@ -375,13 +375,13 @@ function j(e) {
375
375
  warnings: [...e.warnings]
376
376
  };
377
377
  }
378
- function wt(e, t) {
378
+ function kt(e, t) {
379
379
  t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
380
380
  }
381
- function de(e, t) {
381
+ function ge(e, t) {
382
382
  t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
383
383
  }
384
- function ue(e) {
384
+ function be(e) {
385
385
  return e != null && e.length ? e.flatMap((t) => t.entities.map((r) => ({ ...r, pageIndex: t.index }))) : [];
386
386
  }
387
387
  function y(e) {
@@ -393,75 +393,75 @@ function C(e) {
393
393
  const t = String(e);
394
394
  return t.length > 0 ? t : void 0;
395
395
  }
396
- function M() {
396
+ function N() {
397
397
  return { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
398
398
  }
399
- function D(e) {
399
+ function O(e) {
400
400
  return Number.isFinite(e.minX) && Number.isFinite(e.minY) && Number.isFinite(e.maxX) && Number.isFinite(e.maxY) && e.maxX >= e.minX && e.maxY >= e.minY;
401
401
  }
402
402
  function v(e, t) {
403
403
  m(t) && (e.minX = Math.min(e.minX, t.x), e.minY = Math.min(e.minY, t.y), e.maxX = Math.max(e.maxX, t.x), e.maxY = Math.max(e.maxY, t.y));
404
404
  }
405
- function Yt(e, t, r) {
405
+ function Ut(e, t, r) {
406
406
  if (!m(t) || !Number.isFinite(r)) return;
407
407
  const i = Math.abs(r);
408
408
  v(e, { x: t.x - i, y: t.y - i }), v(e, { x: t.x + i, y: t.y + i });
409
409
  }
410
- function Ht(e, t = 0.02, r = 1e-6) {
411
- if (!D(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
410
+ function Vt(e, t = 0.02, r = 1e-6) {
411
+ if (!O(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
412
412
  const i = Math.max((e.maxX - e.minX) * t, r), s = Math.max((e.maxY - e.minY) * t, r);
413
413
  return { minX: e.minX - i, minY: e.minY - s, maxX: e.maxX + i, maxY: e.maxY + s };
414
414
  }
415
415
  function m(e) {
416
416
  return !!e && typeof e == "object" && Number.isFinite(e.x) && Number.isFinite(e.y);
417
417
  }
418
- function x(e) {
418
+ function w(e) {
419
419
  return { x: e.x, y: e.y };
420
420
  }
421
- function E(e) {
421
+ function I(e) {
422
422
  return e * Math.PI / 180;
423
423
  }
424
- function q(e, t, r, i, s = !0, n = 64) {
424
+ function K(e, t, r, i, s = !0, n = 64) {
425
425
  if (!m(e) || !Number.isFinite(t)) return [];
426
426
  let o = r, a = i;
427
427
  if (!Number.isFinite(o) || !Number.isFinite(a)) return [];
428
- (Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = E(o), a = E(a)), s && a < o && (a += Math.PI * 2), !s && o < a && (o += Math.PI * 2);
429
- const c = a - o, h = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * n))), l = [];
430
- for (let f = 0; f <= h; f++) {
431
- const u = o + c * (f / h);
432
- l.push({ x: e.x + Math.cos(u) * t, y: e.y + Math.sin(u) * t });
428
+ (Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = I(o), a = I(a)), s && a < o && (a += Math.PI * 2), !s && o < a && (o += Math.PI * 2);
429
+ const c = a - o, l = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * n))), h = [];
430
+ for (let f = 0; f <= l; f++) {
431
+ const u = o + c * (f / l);
432
+ h.push({ x: e.x + Math.cos(u) * t, y: e.y + Math.sin(u) * t });
433
433
  }
434
- return l;
434
+ return h;
435
435
  }
436
- function K(e, t, r = 1, i = 0, s = Math.PI * 2, n = 96) {
436
+ function J(e, t, r = 1, i = 0, s = Math.PI * 2, n = 96) {
437
437
  if (!m(e) || !m(t)) return [];
438
438
  const o = Math.hypot(t.x, t.y);
439
439
  if (!Number.isFinite(o) || o <= 0) return [];
440
440
  const a = o * (Number.isFinite(r) && r > 0 ? r : 1), c = Math.atan2(t.y, t.x);
441
- let h = Number.isFinite(i) ? i : 0, l = Number.isFinite(s) ? s : Math.PI * 2;
442
- (Math.abs(h) > Math.PI * 2 + 1e-6 || Math.abs(l) > Math.PI * 2 + 1e-6) && (h = E(h), l = E(l)), l < h && (l += Math.PI * 2);
443
- const f = Math.max(12, Math.min(256, Math.ceil(Math.abs(l - h) / (Math.PI * 2) * n))), u = [], p = Math.cos(c), g = Math.sin(c);
441
+ let l = Number.isFinite(i) ? i : 0, h = Number.isFinite(s) ? s : Math.PI * 2;
442
+ (Math.abs(l) > Math.PI * 2 + 1e-6 || Math.abs(h) > Math.PI * 2 + 1e-6) && (l = I(l), h = I(h)), h < l && (h += Math.PI * 2);
443
+ const f = Math.max(12, Math.min(256, Math.ceil(Math.abs(h - l) / (Math.PI * 2) * n))), u = [], p = Math.cos(c), g = Math.sin(c);
444
444
  for (let S = 0; S <= f; S++) {
445
- const O = h + (l - h) * (S / f), z = Math.cos(O) * o, Y = Math.sin(O) * a;
446
- u.push({ x: e.x + z * p - Y * g, y: e.y + z * g + Y * p });
445
+ const z = l + (h - l) * (S / f), _ = Math.cos(z) * o, H = Math.sin(z) * a;
446
+ u.push({ x: e.x + _ * p - H * g, y: e.y + _ * g + H * p });
447
447
  }
448
448
  return u;
449
449
  }
450
- function Xt(e, t, r = 0, i = 16) {
451
- if (!Number.isFinite(r) || Math.abs(r) < 1e-12) return [x(e), x(t)];
450
+ function $t(e, t, r = 0, i = 16) {
451
+ if (!Number.isFinite(r) || Math.abs(r) < 1e-12) return [w(e), w(t)];
452
452
  const s = Math.hypot(t.x - e.x, t.y - e.y);
453
- if (s <= 1e-12) return [x(e), x(t)];
454
- const n = 4 * Math.atan(r), o = Math.abs(s / (2 * Math.sin(n / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / s, h = (t.y - e.y) / s, l = r >= 0 ? 1 : -1, f = Math.sqrt(Math.max(o * o - (s / 2) ** 2, 0)), u = { x: a.x - l * h * f, y: a.y + l * c * f }, p = Math.atan2(e.y - u.y, e.x - u.x), g = Math.atan2(t.y - u.y, t.x - u.x);
455
- return q(u, o, p, g, r >= 0, i);
453
+ if (s <= 1e-12) return [w(e), w(t)];
454
+ const n = 4 * Math.atan(r), o = Math.abs(s / (2 * Math.sin(n / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / s, l = (t.y - e.y) / s, h = r >= 0 ? 1 : -1, f = Math.sqrt(Math.max(o * o - (s / 2) ** 2, 0)), u = { x: a.x - h * l * f, y: a.y + h * c * f }, p = Math.atan2(e.y - u.y, e.x - u.x), g = Math.atan2(t.y - u.y, t.x - u.x);
455
+ return K(u, o, p, g, r >= 0, i);
456
456
  }
457
- function _t(e) {
457
+ function jt(e) {
458
458
  return e.replace(/\\P/g, `
459
459
  `).replace(/\\~|\\ /g, " ").replace(/\\[A-Za-z][^;]*;/g, "").replace(/[{}]/g, "").replace(/\\[A-Za-z]/g, "").trim();
460
460
  }
461
- function T(e, t, r) {
461
+ function A(e, t, r) {
462
462
  return Math.min(r, Math.max(t, e));
463
463
  }
464
- class me {
464
+ class ve {
465
465
  constructor(t = {}) {
466
466
  d(this, "id", "dxf");
467
467
  d(this, "label", "DXF / JavaScript parser");
@@ -470,29 +470,28 @@ class me {
470
470
  this.defaults = t;
471
471
  }
472
472
  accepts(t, r) {
473
- return L(t) === "dxf" || A(t, r) === "dxf";
473
+ return L(t) === "dxf" || B(t, r) === "dxf";
474
474
  }
475
475
  async load(t, r = {}) {
476
- var l;
477
- ({ ...this.defaults, ...r });
478
- const i = performance.now(), s = await _(t), n = Ce(s), o = [];
479
- let a;
476
+ var f;
477
+ const i = { ...this.defaults, ...r }, s = performance.now(), n = await U(t), o = Ne(n, i.dxfEncoding), a = [];
478
+ let c;
480
479
  try {
481
- a = await pe(n);
482
- } catch (f) {
483
- o.push(`dxf-parser failed, using built-in fallback parser: ${f instanceof Error ? f.message : String(f)}`), a = Pe(n);
480
+ c = await ye(o);
481
+ } catch (u) {
482
+ a.push(`dxf-parser failed, using built-in fallback parser: ${u instanceof Error ? u.message : String(u)}`), c = Le(o);
484
483
  }
485
- const c = ge(a, t.fileName ?? ((l = t.file) == null ? void 0 : l.name), o), h = performance.now() - i;
486
- return { document: c, raw: a, bytes: s.byteLength, elapsedMs: h, format: "dxf", warnings: c.warnings };
484
+ const l = we(c, t.fileName ?? ((f = t.file) == null ? void 0 : f.name), a), h = performance.now() - s;
485
+ return { document: l, raw: c, bytes: n.byteLength, elapsedMs: h, format: "dxf", warnings: l.warnings };
487
486
  }
488
487
  }
489
- async function pe(e) {
488
+ async function ye(e) {
490
489
  const t = await import("dxf-parser"), r = t.default ?? t.DxfParser;
491
490
  if (!r) throw new Error("dxf-parser did not expose a parser constructor.");
492
491
  return new r().parseSync(e);
493
492
  }
494
- function ge(e, t, r = []) {
495
- const i = e && typeof e == "object" ? e : {}, s = be(i), n = ve(i), a = (Array.isArray(i.entities) ? i.entities : []).filter((h) => !!h && typeof h == "object").map((h) => pt(h)), c = zt({
493
+ function we(e, t, r = []) {
494
+ const i = e && typeof e == "object" ? e : {}, s = xe(i), n = Ce(i), a = (Array.isArray(i.entities) ? i.entities : []).filter((l) => !!l && typeof l == "object").map((l) => vt(l)), c = Xt({
496
495
  format: "dxf",
497
496
  sourceName: t,
498
497
  header: i.header && typeof i.header == "object" ? i.header : {},
@@ -505,26 +504,26 @@ function ge(e, t, r = []) {
505
504
  });
506
505
  return a.length === 0 && c.warnings.push("DXF file did not expose any ENTITIES."), c;
507
506
  }
508
- function pt(e) {
509
- const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r = fe(e, t), i = y(e.colorIndex ?? e.colorNumber ?? e.aci), s = y(e.color);
510
- if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = C(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = P(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = P(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = P(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text = C(e.text ?? e.string ?? e.value) ?? r.text, r.textHeight = y(e.textHeight ?? e.height) ?? r.textHeight, r.rotation = Pt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (r.startAngle = kt(e.startAngle ?? e.start_angle), r.endAngle = kt(e.endAngle ?? e.end_angle)), t === "INSERT") {
507
+ function vt(e) {
508
+ const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r = pe(e, t), i = y(e.colorIndex ?? e.colorNumber ?? e.aci), s = y(e.color);
509
+ if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = C(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = P(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = P(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = P(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text = Ae(e.text ?? e.string ?? e.value) ?? r.text, r.textHeight = y(e.textHeight ?? e.height) ?? r.textHeight, r.rotation = Nt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (r.startAngle = Mt(e.startAngle ?? e.start_angle), r.endAngle = Mt(e.endAngle ?? e.end_angle)), t === "INSERT") {
511
510
  r.blockName = C(e.name ?? e.blockName) ?? r.blockName, r.insertionPoint = P(e.position ?? e.insertionPoint ?? e.point) ?? r.insertionPoint;
512
511
  const n = y(e.xScale ?? e.scaleX ?? e.xscale), o = y(e.yScale ?? e.scaleY ?? e.yscale), a = y(e.zScale ?? e.scaleZ ?? e.zscale);
513
- (n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation = Pt(e.rotation ?? e.angle);
512
+ (n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation = Nt(e.rotation ?? e.angle);
514
513
  }
515
514
  if (t === "SPLINE") {
516
- const n = J(e.controlPoints ?? e.control_points ?? e.points);
515
+ const n = Q(e.controlPoints ?? e.control_points ?? e.points);
517
516
  n.length && (r.controlPoints = n);
518
- const o = J(e.fitPoints ?? e.fit_points);
517
+ const o = Q(e.fitPoints ?? e.fit_points);
519
518
  o.length && (r.fitPoints = o);
520
519
  }
521
- return t === "HATCH" && (r.loops = we(e), r.fillColorIndex = r.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (r.vertices = xe(e), r.fillColorIndex = r.colorIndex), r;
520
+ return t === "HATCH" && (r.loops = Se(e), r.fillColorIndex = r.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (r.vertices = ke(e), r.fillColorIndex = r.colorIndex), r;
522
521
  }
523
- function be(e) {
524
- const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s = ye(i);
522
+ function xe(e) {
523
+ const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s = Pe(i);
525
524
  for (const n of s) {
526
525
  const o = n, a = C(o.name ?? o.layerName);
527
- a && wt(t, {
526
+ a && kt(t, {
528
527
  name: a,
529
528
  color: o.color ?? o.colorNumber ?? o.colorIndex,
530
529
  colorIndex: y(o.colorNumber ?? o.colorIndex ?? o.color),
@@ -535,36 +534,36 @@ function be(e) {
535
534
  raw: o
536
535
  });
537
536
  }
538
- return t[0] || wt(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
537
+ return t[0] || kt(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
539
538
  }
540
- function ve(e) {
539
+ function Ce(e) {
541
540
  const t = {}, r = e.blocks;
542
541
  if (!r || typeof r != "object") return t;
543
542
  if (Array.isArray(r))
544
- for (const i of r) Ct(t, i);
543
+ for (const i of r) St(t, i);
545
544
  else
546
- for (const [i, s] of Object.entries(r)) Ct(t, s, i);
545
+ for (const [i, s] of Object.entries(r)) St(t, s, i);
547
546
  return t;
548
547
  }
549
- function Ct(e, t, r) {
548
+ function St(e, t, r) {
550
549
  if (!t || typeof t != "object") return;
551
550
  const i = t, s = C(i.name ?? i.blockName ?? r);
552
551
  if (!s) return;
553
- const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) => pt(a));
554
- de(e, { name: s, basePoint: P(i.basePoint ?? i.position) ?? { x: 0, y: 0 }, entities: o, raw: i });
552
+ const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) => vt(a));
553
+ ge(e, { name: s, basePoint: P(i.basePoint ?? i.position) ?? { x: 0, y: 0 }, entities: o, raw: i });
555
554
  }
556
- function ye(e) {
555
+ function Pe(e) {
557
556
  if (!e) return [];
558
557
  if (Array.isArray(e)) return e;
559
558
  if (typeof e != "object") return [];
560
559
  const t = e;
561
560
  return Array.isArray(t.entries) ? t.entries : Array.isArray(t.records) ? t.records : Array.isArray(t.layers) ? t.layers : Object.values(t).filter((r) => r && typeof r == "object");
562
561
  }
563
- function J(e) {
562
+ function Q(e) {
564
563
  return Array.isArray(e) ? e.map(P).filter((t) => !!t) : [];
565
564
  }
566
- function xe(e) {
567
- const t = J(e.vertices ?? e.points);
565
+ function ke(e) {
566
+ const t = Q(e.vertices ?? e.points);
568
567
  if (t.length) return t;
569
568
  const r = [];
570
569
  for (let i = 0; i < 4; i++) {
@@ -573,36 +572,149 @@ function xe(e) {
573
572
  }
574
573
  return r;
575
574
  }
576
- function we(e) {
575
+ function Se(e) {
577
576
  const t = e.boundaryLoops ?? e.loops ?? e.paths;
578
577
  if (Array.isArray(t))
579
578
  return t.map((r) => {
580
579
  const i = r;
581
- return { vertices: J(i.vertices ?? i.points), isClosed: !0 };
580
+ return { vertices: Q(i.vertices ?? i.points), isClosed: !0 };
582
581
  }).filter((r) => r.vertices && r.vertices.length > 0);
583
582
  }
584
- function Pt(e) {
583
+ function Nt(e) {
585
584
  const t = y(e);
586
585
  if (t !== void 0)
587
- return Math.abs(t) > Math.PI * 2 + 1e-6 ? E(t) : t;
586
+ return Math.abs(t) > Math.PI * 2 + 1e-6 ? I(t) : t;
588
587
  }
589
- function kt(e) {
588
+ function Mt(e) {
590
589
  const t = y(e);
591
590
  if (t !== void 0)
592
- return Math.abs(t) > Math.PI * 2 + 1e-6 ? E(t) : t;
591
+ return Math.abs(t) > Math.PI * 2 + 1e-6 ? I(t) : t;
592
+ }
593
+ function Ne(e, t) {
594
+ const r = ut(t);
595
+ if (r) return M(e, r);
596
+ const i = Me(e);
597
+ if (i) return M(e, i);
598
+ const s = ut(Ee(e));
599
+ if (s) return M(e, s);
600
+ const n = M(e, "utf-8");
601
+ return n.includes("�") ? Ie(e) : n;
602
+ }
603
+ const Et = {
604
+ ANSI_874: "windows-874",
605
+ ANSI_932: "shift_jis",
606
+ ANSI_936: "gb18030",
607
+ ANSI_949: "euc-kr",
608
+ ANSI_950: "big5",
609
+ ANSI_1250: "windows-1250",
610
+ ANSI_1251: "windows-1251",
611
+ ANSI_1252: "windows-1252",
612
+ ANSI_1253: "windows-1253",
613
+ ANSI_1254: "windows-1254",
614
+ ANSI_1255: "windows-1255",
615
+ ANSI_1256: "windows-1256",
616
+ ANSI_1257: "windows-1257",
617
+ ANSI_1258: "windows-1258",
618
+ BIG5: "big5",
619
+ CP874: "windows-874",
620
+ CP932: "shift_jis",
621
+ CP936: "gb18030",
622
+ CP949: "euc-kr",
623
+ CP950: "big5",
624
+ CP1250: "windows-1250",
625
+ CP1251: "windows-1251",
626
+ CP1252: "windows-1252",
627
+ CP1253: "windows-1253",
628
+ CP1254: "windows-1254",
629
+ CP1255: "windows-1255",
630
+ CP1256: "windows-1256",
631
+ CP1257: "windows-1257",
632
+ CP1258: "windows-1258",
633
+ GB18030: "gb18030",
634
+ GB2312: "gb18030",
635
+ GBK: "gb18030",
636
+ SHIFT_JIS: "shift_jis",
637
+ SHIFTJIS: "shift_jis",
638
+ SJIS: "shift_jis",
639
+ UTF8: "utf-8",
640
+ UTF_8: "utf-8",
641
+ UTF16: "utf-16le",
642
+ UTF_16: "utf-16le",
643
+ UTF16LE: "utf-16le",
644
+ UTF_16LE: "utf-16le",
645
+ UTF16BE: "utf-16be",
646
+ UTF_16BE: "utf-16be"
647
+ };
648
+ function Me(e) {
649
+ if (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191) return "utf-8";
650
+ if (e.length >= 2 && e[0] === 255 && e[1] === 254) return "utf-16le";
651
+ if (e.length >= 2 && e[0] === 254 && e[1] === 255) return "utf-16be";
593
652
  }
594
- function Ce(e) {
595
- const t = new TextDecoder("utf-8", { fatal: !1 }).decode(e);
596
- return t.includes("SECTION") ? t : new TextDecoder("iso-8859-1", { fatal: !1 }).decode(e);
653
+ function Ee(e) {
654
+ var i, s, n, o;
655
+ const r = M(e.subarray(0, Math.min(e.byteLength, 131072)), "iso-8859-1").replace(/\r\n/g, `
656
+ `).replace(/\r/g, `
657
+ `).split(`
658
+ `);
659
+ for (let a = 0; a < r.length - 3; a++)
660
+ if (!(((i = r[a]) == null ? void 0 : i.trim()) !== "9" || ((s = r[a + 1]) == null ? void 0 : s.trim().toUpperCase()) !== "$DWGCODEPAGE"))
661
+ for (let c = a + 2; c < Math.min(a + 10, r.length - 1); c += 2) {
662
+ const l = (n = r[c]) == null ? void 0 : n.trim(), h = (o = r[c + 1]) == null ? void 0 : o.trim();
663
+ if (l === "3" && h) return h;
664
+ }
597
665
  }
598
- function Pe(e) {
599
- var h, l;
666
+ function ut(e) {
667
+ const t = e == null ? void 0 : e.trim();
668
+ if (!t) return;
669
+ const r = t.replace(/[-\s]+/g, "_").toUpperCase();
670
+ if (Et[r]) return Et[r];
671
+ const i = /^ANSI_(\d{3,4})$/.exec(r);
672
+ if (i) return ut(`cp${i[1]}`);
673
+ const s = /^CP(\d{3,4})$/.exec(r);
674
+ return s ? s[1] === "936" ? "gb18030" : s[1] === "950" ? "big5" : s[1] === "932" ? "shift_jis" : s[1] === "949" ? "euc-kr" : `windows-${s[1]}` : t;
675
+ }
676
+ function M(e, t) {
677
+ try {
678
+ return new TextDecoder(t, { fatal: !1 }).decode(e);
679
+ } catch {
680
+ return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
681
+ }
682
+ }
683
+ function Ie(e) {
684
+ const t = ["windows-1252", "gb18030", "big5", "shift_jis", "euc-kr", "iso-8859-1"];
685
+ let r = "", i = Number.POSITIVE_INFINITY;
686
+ for (const s of t) {
687
+ const n = M(e, s), o = Te(n, s);
688
+ o < i && (i = o, r = n);
689
+ }
690
+ return r || M(e, "utf-8");
691
+ }
692
+ function Te(e, t) {
693
+ const r = it(e, /\uFFFD/g), i = it(e, /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g), s = it(e, /[\u3400-\u9FFF\uF900-\uFAFF]/g), n = e.includes("SECTION") && (e.includes("ENTITIES") || e.includes("HEADER"));
694
+ let o = r * 1e4 + i * 1e3;
695
+ return n && (o -= 500), t === "windows-1252" && (o -= 2), t === "gb18030" && s >= 2 && (o -= 50 + Math.min(s, 200) * 2), o;
696
+ }
697
+ function it(e, t) {
698
+ var r;
699
+ return ((r = e.match(t)) == null ? void 0 : r.length) ?? 0;
700
+ }
701
+ function Ae(e) {
702
+ const t = C(e);
703
+ if (t !== void 0)
704
+ return t.replace(/\\U\+([0-9a-fA-F]{4,6})/g, (r, i) => {
705
+ const s = Number.parseInt(i, 16);
706
+ return Number.isFinite(s) && s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : r;
707
+ }).replace(/%%[cC]/g, "∅").replace(/%%[dD]/g, "°").replace(/%%[pP]/g, "±").replace(/\\P/g, `
708
+ `);
709
+ }
710
+ function Le(e) {
711
+ var l, h;
600
712
  const t = e.replace(/\r\n/g, `
601
713
  `).replace(/\r/g, `
602
714
  `).split(`
603
715
  `), r = [];
604
716
  for (let f = 0; f < t.length - 1; f += 2) {
605
- const u = Number((h = t[f]) == null ? void 0 : h.trim()), p = t[f + 1] ?? "";
717
+ const u = Number((l = t[f]) == null ? void 0 : l.trim()), p = t[f + 1] ?? "";
606
718
  Number.isFinite(u) && r.push({ code: u, value: p.trimEnd() });
607
719
  }
608
720
  const i = [], s = {};
@@ -610,7 +722,7 @@ function Pe(e) {
610
722
  for (let f = 0; f < r.length; f++) {
611
723
  const u = r[f];
612
724
  if (u.code === 0 && u.value === "SECTION") {
613
- n = ((l = r[f + 1]) == null ? void 0 : l.code) === 2 ? r[f + 1].value.toUpperCase() : "", f++;
725
+ n = ((h = r[f + 1]) == null ? void 0 : h.code) === 2 ? r[f + 1].value.toUpperCase() : "", f++;
614
726
  continue;
615
727
  }
616
728
  if (u.code === 0 && u.value === "ENDSEC") {
@@ -625,7 +737,7 @@ function Pe(e) {
625
737
  if (!o.length) return;
626
738
  const f = (p = o[0]) == null ? void 0 : p.value.toUpperCase();
627
739
  if (f === "VERTEX" && a) {
628
- const g = w(o, 10, 20, 30);
740
+ const g = x(o, 10, 20, 30);
629
741
  g && (a.vertices ?? (a.vertices = [])).push({ ...g, bulge: b(o, 42) }), o = [];
630
742
  return;
631
743
  }
@@ -637,85 +749,85 @@ function Pe(e) {
637
749
  o = [];
638
750
  return;
639
751
  }
640
- const u = ke(f, o);
752
+ const u = Be(f, o);
641
753
  f === "POLYLINE" ? a = u : i.push(u), o = [];
642
754
  }
643
755
  }
644
- function ke(e, t) {
756
+ function Be(e, t) {
645
757
  const r = {
646
758
  type: e,
647
- handle: H(t, 5),
648
- layer: H(t, 8) ?? "0",
759
+ handle: Y(t, 5),
760
+ layer: Y(t, 8) ?? "0",
649
761
  colorIndex: b(t, 62),
650
762
  trueColor: b(t, 420),
651
- lineType: H(t, 6),
763
+ lineType: Y(t, 6),
652
764
  lineweight: b(t, 370)
653
765
  };
654
766
  switch (e) {
655
767
  case "LINE":
656
- Object.assign(r, { startPoint: w(t, 10, 20, 30), endPoint: w(t, 11, 21, 31) });
768
+ Object.assign(r, { startPoint: x(t, 10, 20, 30), endPoint: x(t, 11, 21, 31) });
657
769
  break;
658
770
  case "CIRCLE":
659
- Object.assign(r, { center: w(t, 10, 20, 30), radius: b(t, 40) });
771
+ Object.assign(r, { center: x(t, 10, 20, 30), radius: b(t, 40) });
660
772
  break;
661
773
  case "ARC":
662
- Object.assign(r, { center: w(t, 10, 20, 30), radius: b(t, 40), startAngle: G(b(t, 50)), endAngle: G(b(t, 51)) });
774
+ Object.assign(r, { center: x(t, 10, 20, 30), radius: b(t, 40), startAngle: Z(b(t, 50)), endAngle: Z(b(t, 51)) });
663
775
  break;
664
776
  case "POINT":
665
- Object.assign(r, { point: w(t, 10, 20, 30) });
777
+ Object.assign(r, { point: x(t, 10, 20, 30) });
666
778
  break;
667
779
  case "TEXT":
668
780
  case "MTEXT":
669
- Object.assign(r, { insertionPoint: w(t, 10, 20, 30), text: Ne(t), textHeight: b(t, 40), rotation: G(b(t, 50)) });
781
+ Object.assign(r, { insertionPoint: x(t, 10, 20, 30), text: We(t), textHeight: b(t, 40), rotation: Z(b(t, 50)) });
670
782
  break;
671
783
  case "LWPOLYLINE":
672
- Object.assign(r, { vertices: Me(t), flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
784
+ Object.assign(r, { vertices: De(t), flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
673
785
  break;
674
786
  case "POLYLINE":
675
787
  Object.assign(r, { vertices: [], flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
676
788
  break;
677
789
  case "ELLIPSE":
678
- Object.assign(r, { center: w(t, 10, 20, 30), majorAxisEndPoint: w(t, 11, 21, 31), axisRatio: b(t, 40), startAngle: b(t, 41), endAngle: b(t, 42) });
790
+ Object.assign(r, { center: x(t, 10, 20, 30), majorAxisEndPoint: x(t, 11, 21, 31), axisRatio: b(t, 40), startAngle: b(t, 41), endAngle: b(t, 42) });
679
791
  break;
680
792
  case "SPLINE":
681
- Object.assign(r, { controlPoints: Se(t, 10, 20, 30), degree: b(t, 71), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
793
+ Object.assign(r, { controlPoints: Fe(t, 10, 20, 30), degree: b(t, 71), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
682
794
  break;
683
795
  case "INSERT":
684
- Object.assign(r, { name: H(t, 2), blockName: H(t, 2), insertionPoint: w(t, 10, 20, 30), rotation: G(b(t, 50)), scale: { x: b(t, 41) ?? 1, y: b(t, 42) ?? b(t, 41) ?? 1, z: b(t, 43) ?? 1 } });
796
+ Object.assign(r, { name: Y(t, 2), blockName: Y(t, 2), insertionPoint: x(t, 10, 20, 30), rotation: Z(b(t, 50)), scale: { x: b(t, 41) ?? 1, y: b(t, 42) ?? b(t, 41) ?? 1, z: b(t, 43) ?? 1 } });
685
797
  break;
686
798
  case "SOLID":
687
799
  case "TRACE":
688
800
  case "3DFACE":
689
- Object.assign(r, { vertices: [w(t, 10, 20, 30), w(t, 11, 21, 31), w(t, 12, 22, 32), w(t, 13, 23, 33)].filter(Boolean) });
801
+ Object.assign(r, { vertices: [x(t, 10, 20, 30), x(t, 11, 21, 31), x(t, 12, 22, 32), x(t, 13, 23, 33)].filter(Boolean) });
690
802
  break;
691
803
  }
692
- return pt(r);
804
+ return vt(r);
693
805
  }
694
806
  function b(e, t) {
695
807
  var s;
696
808
  const r = (s = e.find((n) => n.code === t)) == null ? void 0 : s.value, i = Number(r);
697
809
  return Number.isFinite(i) ? i : void 0;
698
810
  }
699
- function H(e, t) {
811
+ function Y(e, t) {
700
812
  var i;
701
813
  const r = (i = e.find((s) => s.code === t)) == null ? void 0 : i.value;
702
814
  return r && r.length > 0 ? r : void 0;
703
815
  }
704
- function w(e, t, r, i) {
816
+ function x(e, t, r, i) {
705
817
  const s = b(e, t), n = b(e, r), o = b(e, i);
706
818
  if (!(s === void 0 || n === void 0))
707
819
  return o === void 0 ? { x: s, y: n } : { x: s, y: n, z: o };
708
820
  }
709
- function Se(e, t, r, i) {
821
+ function Fe(e, t, r, i) {
710
822
  const s = [];
711
823
  for (let n = 0; n < e.length; n++) {
712
824
  if (e[n].code !== t) continue;
713
- const o = Number(e[n].value), a = e.slice(n + 1).find((f) => f.code === r), c = e.slice(n + 1).find((f) => f.code === i), h = Number(a == null ? void 0 : a.value), l = Number(c == null ? void 0 : c.value);
714
- Number.isFinite(o) && Number.isFinite(h) && s.push(Number.isFinite(l) ? { x: o, y: h, z: l } : { x: o, y: h });
825
+ const o = Number(e[n].value), a = e.slice(n + 1).find((f) => f.code === r), c = e.slice(n + 1).find((f) => f.code === i), l = Number(a == null ? void 0 : a.value), h = Number(c == null ? void 0 : c.value);
826
+ Number.isFinite(o) && Number.isFinite(l) && s.push(Number.isFinite(h) ? { x: o, y: l, z: h } : { x: o, y: l });
715
827
  }
716
828
  return s;
717
829
  }
718
- function Me(e) {
830
+ function De(e) {
719
831
  const t = [];
720
832
  for (let r = 0; r < e.length; r++) {
721
833
  if (e[r].code !== 10) continue;
@@ -727,14 +839,14 @@ function Me(e) {
727
839
  }
728
840
  return t;
729
841
  }
730
- function Ne(e) {
842
+ function We(e) {
731
843
  const t = e.filter((r) => r.code === 1 || r.code === 3).map((r) => r.value);
732
844
  return t.length ? t.join("") : void 0;
733
845
  }
734
- function G(e) {
735
- return typeof e == "number" && Number.isFinite(e) ? E(e) : void 0;
846
+ function Z(e) {
847
+ return typeof e == "number" && Number.isFinite(e) ? I(e) : void 0;
736
848
  }
737
- class Ee {
849
+ class Re {
738
850
  constructor(t = {}) {
739
851
  d(this, "id", "dwf");
740
852
  d(this, "label", "DWF/DWFx native viewer powered by dwf-viewer");
@@ -749,29 +861,29 @@ class Ee {
749
861
  accepts(t, r) {
750
862
  const i = L(t);
751
863
  if (i === "dwf" || i === "dwfx" || i === "xps") return !0;
752
- const s = A(t, r);
864
+ const s = B(t, r);
753
865
  return s === "dwf" || s === "dwfx" || s === "xps";
754
866
  }
755
867
  async load(t, r = {}) {
756
868
  var f, u, p, g;
757
- const i = { ...this.defaults, ...r }, s = performance.now(), n = t.fileName ?? ((f = t.file) == null ? void 0 : f.name), o = await _(t), a = Nt(A(t, o), L(t));
869
+ const i = { ...this.defaults, ...r }, s = performance.now(), n = t.fileName ?? ((f = t.file) == null ? void 0 : f.name), o = await U(t), a = At(B(t, o), L(t));
758
870
  (u = i.onProgress) == null || u.call(i, { phase: "parse", format: a, message: "Opening DWF/DWFx with dwf-viewer…", percent: 48 });
759
- const c = await Qt(o, { fileName: n });
871
+ const c = await ie(o, { fileName: n });
760
872
  (p = i.onProgress) == null || p.call(i, { phase: "normalize", format: a, message: "Reading DWF pages, sheets and model metadata…", percent: 76 });
761
- const h = St(c, n, a, i.keepRaw === !0), l = performance.now() - s;
762
- return (g = i.onProgress) == null || g.call(i, { phase: "done", format: h.format, message: "DWF/DWFx document ready.", percent: 100, elapsedMs: l }), { document: h, raw: i.keepRaw ? c : void 0, bytes: o.byteLength, elapsedMs: l, format: h.format, warnings: h.warnings };
873
+ const l = It(c, n, a, i.keepRaw === !0), h = performance.now() - s;
874
+ return (g = i.onProgress) == null || g.call(i, { phase: "done", format: l.format, message: "DWF/DWFx document ready.", percent: 100, elapsedMs: h }), { document: l, raw: i.keepRaw ? c : void 0, bytes: o.byteLength, elapsedMs: h, format: l.format, warnings: l.warnings };
763
875
  }
764
876
  async mount(t, r, i = {}) {
765
- var O, z, Y, gt, bt;
766
- const s = { ...this.defaults, ...i }, n = performance.now(), o = t.fileName ?? ((O = t.file) == null ? void 0 : O.name), a = await _(t), c = Nt(A(t, a), L(t)), h = Be(s), l = Et(s), f = Fe(s, h, l), u = Ut(s, h, l);
767
- (z = s.onProgress) == null || z.call(s, { phase: "native-render", format: c, message: "Mounting native DWF renderer…", percent: 28 }), this.unmount(), this.host = r, r.replaceChildren(), this.native = new te(r, f), (Y = s.onProgress) == null || Y.call(s, { phase: "parse", format: c, message: "Parsing DWF package and page streams…", percent: 58 }), await this.native.load(a, {
877
+ var z, _, H, yt, wt;
878
+ const s = { ...this.defaults, ...i }, n = performance.now(), o = t.fileName ?? ((z = t.file) == null ? void 0 : z.name), a = await U(t), c = At(B(t, a), L(t)), l = Ye(s), h = Lt(s), f = Xe(s, l, h), u = Gt(s, l, h);
879
+ (_ = s.onProgress) == null || _.call(s, { phase: "native-render", format: c, message: "Mounting native DWF renderer…", percent: 28 }), this.unmount(), this.host = r, r.replaceChildren(), this.native = new se(r, f), (H = s.onProgress) == null || H.call(s, { phase: "parse", format: c, message: "Parsing DWF package and page streams…", percent: 58 }), await this.native.load(a, {
768
880
  fileName: o,
769
881
  ...u
770
- }), (gt = s.onProgress) == null || gt.call(s, { phase: "render", format: c, message: "Rendering DWF/DWFx with dwf-viewer…", percent: 88 }), this.lastStats = await this.native.render();
771
- const p = this.native.getDocument(), g = St(p, o, c, s.keepRaw === !0);
882
+ }), (yt = s.onProgress) == null || yt.call(s, { phase: "render", format: c, message: "Rendering DWF/DWFx with dwf-viewer…", percent: 88 }), this.lastStats = await this.native.render();
883
+ const p = this.native.getDocument(), g = It(p, o, c, s.keepRaw === !0);
772
884
  g.metadata.loaderMode = "Native DWF", g.metadata.nativeRenderer = "dwf-viewer", g.metadata.nativeRenderStats = this.lastStats ? { ...this.lastStats, warnings: this.lastStats.warnings.length } : void 0;
773
885
  const S = performance.now() - n;
774
- return (bt = s.onProgress) == null || bt.call(s, { phase: "done", format: g.format, message: "DWF/DWFx rendered.", percent: 100, elapsedMs: S }), { document: g, raw: s.keepRaw ? p : void 0, bytes: a.byteLength, elapsedMs: S, format: g.format, warnings: g.warnings };
886
+ return (wt = s.onProgress) == null || wt.call(s, { phase: "done", format: g.format, message: "DWF/DWFx rendered.", percent: 100, elapsedMs: S }), { document: g, raw: s.keepRaw ? p : void 0, bytes: a.byteLength, elapsedMs: S, format: g.format, warnings: g.warnings };
775
887
  }
776
888
  unmount() {
777
889
  var t;
@@ -801,43 +913,43 @@ class Ee {
801
913
  if (r) {
802
914
  if (typeof t.dwfBackground == "string") r.background = t.dwfBackground;
803
915
  else {
804
- const a = Et(t);
916
+ const a = Lt(t);
805
917
  a && (r.background = a);
806
918
  }
807
- typeof t.dwfPreferWebgl == "boolean" && ((i = r.setPreferWebgl) == null || i.call(r, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((s = r.setPreferWasm) == null || s.call(r, t.dwfPreferWasm)), t.dwfLineWeightMode && ((n = r.setLineWeightMode) == null || n.call(r, t.dwfLineWeightMode)), Z(r, "minStrokeCssPx", t.dwfMinStrokeCssPx), Z(r, "maxOverviewStrokeCssPx", t.dwfMaxOverviewStrokeCssPx), Z(r, "minTextCssPx", t.dwfMinTextCssPx), Z(r, "minFilledAreaCssPx", t.dwfMinFilledAreaCssPx), (o = r.render) == null || o.call(r);
919
+ typeof t.dwfPreferWebgl == "boolean" && ((i = r.setPreferWebgl) == null || i.call(r, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((s = r.setPreferWasm) == null || s.call(r, t.dwfPreferWasm)), t.dwfLineWeightMode && ((n = r.setLineWeightMode) == null || n.call(r, t.dwfLineWeightMode)), q(r, "minStrokeCssPx", t.dwfMinStrokeCssPx), q(r, "maxOverviewStrokeCssPx", t.dwfMaxOverviewStrokeCssPx), q(r, "minTextCssPx", t.dwfMinTextCssPx), q(r, "minFilledAreaCssPx", t.dwfMinFilledAreaCssPx), (o = r.render) == null || o.call(r);
808
920
  }
809
921
  }
810
922
  getLastNativeStats() {
811
923
  return this.lastStats;
812
924
  }
813
925
  }
814
- function St(e, t, r, i) {
926
+ function It(e, t, r, i) {
815
927
  var a, c;
816
- const s = Mt((e == null ? void 0 : e.diagnostics) ?? []), n = ((e == null ? void 0 : e.pageData) ?? []).map((h, l) => Ie(h, l));
817
- for (const h of (e == null ? void 0 : e.pageData) ?? []) s.push(...Mt(h.diagnostics));
928
+ const s = Tt((e == null ? void 0 : e.diagnostics) ?? []), n = ((e == null ? void 0 : e.pageData) ?? []).map((l, h) => Oe(l, h));
929
+ for (const l of (e == null ? void 0 : e.pageData) ?? []) s.push(...Tt(l.diagnostics));
818
930
  const o = {
819
931
  parser: "dwf-viewer",
820
932
  nativeRenderer: "dwf-viewer",
821
933
  dwfKind: e == null ? void 0 : e.kind,
822
934
  packageEntries: ((a = e == null ? void 0 : e.packageEntries) == null ? void 0 : a.length) ?? 0,
823
935
  resources: ((c = e == null ? void 0 : e.resources) == null ? void 0 : c.length) ?? 0,
824
- pageKinds: De(((e == null ? void 0 : e.pageData) ?? []).map((h) => h.kind)),
825
- pageNames: ((e == null ? void 0 : e.pages) ?? []).map((h) => h.name)
936
+ pageKinds: $e(((e == null ? void 0 : e.pageData) ?? []).map((l) => l.kind)),
937
+ pageNames: ((e == null ? void 0 : e.pages) ?? []).map((l) => l.name)
826
938
  };
827
- return zt({
939
+ return Xt({
828
940
  format: r,
829
941
  sourceName: t,
830
942
  layers: {},
831
943
  blocks: {},
832
944
  pages: n,
833
- entities: ue(n),
945
+ entities: be(n),
834
946
  metadata: o,
835
- warnings: Oe(s),
947
+ warnings: je(s),
836
948
  raw: i ? e : void 0
837
949
  });
838
950
  }
839
- function Ie(e, t) {
840
- const r = Te(e, t);
951
+ function Oe(e, t) {
952
+ const r = ze(e, t);
841
953
  return {
842
954
  index: t,
843
955
  name: e.name || e.sourcePath || `${t + 1}`,
@@ -846,18 +958,18 @@ function Ie(e, t) {
846
958
  entities: r
847
959
  };
848
960
  }
849
- function Te(e, t) {
850
- return e.kind === "w2d-text" ? e.primitives.flatMap((r, i) => Le(r, t, i)) : e.kind === "image" ? [{ type: "DWF_IMAGE_PAGE", kind: "image", pageIndex: t, width: e.width, height: e.height, imageSource: e.sourcePath }] : e.kind === "w3d-model" ? e.model.meshes.map((r, i) => ({
961
+ function ze(e, t) {
962
+ return e.kind === "w2d-text" ? e.primitives.flatMap((r, i) => _e(r, t, i)) : e.kind === "image" ? [{ type: "DWF_IMAGE_PAGE", kind: "image", pageIndex: t, width: e.width, height: e.height, imageSource: e.sourcePath }] : e.kind === "w3d-model" ? e.model.meshes.map((r, i) => ({
851
963
  id: r.id,
852
964
  type: "W3D_MESH",
853
965
  kind: "solid",
854
966
  pageIndex: t,
855
- color: r.color ? Re(r.color) : void 0,
967
+ color: r.color ? Ve(r.color) : void 0,
856
968
  name: r.name || `mesh-${i + 1}`,
857
969
  raw: { vertexCount: r.vertexCount, triangleCount: r.triangleCount, materialId: r.materialId }
858
970
  })) : e.kind === "xps-fixed-page" ? [{ type: "XPS_FIXED_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }] : [{ type: "DWF_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }];
859
971
  }
860
- function Le(e, t, r) {
972
+ function _e(e, t, r) {
861
973
  const i = {
862
974
  id: `dwf-${t}-${r}`,
863
975
  pageIndex: t,
@@ -871,7 +983,7 @@ function Le(e, t, r) {
871
983
  ...i,
872
984
  type: e.type === "polygon" ? "DWF_POLYGON" : "DWF_POLYLINE",
873
985
  kind: "polyline",
874
- vertices: Ae(e.points),
986
+ vertices: He(e.points),
875
987
  isClosed: e.type === "polygon"
876
988
  }];
877
989
  if (e.type === "path")
@@ -902,36 +1014,36 @@ function Le(e, t, r) {
902
1014
  }
903
1015
  return [];
904
1016
  }
905
- function Ae(e) {
1017
+ function He(e) {
906
1018
  const t = [];
907
1019
  for (let r = 0; r + 1 < e.length; r += 2) t.push({ x: e[r], y: e[r + 1], z: 0 });
908
1020
  return t;
909
1021
  }
910
- function Mt(e) {
1022
+ function Tt(e) {
911
1023
  return e.filter((t) => t.level !== "info").map((t) => `${t.code}: ${t.message}${t.source ? ` (${t.source})` : ""}`);
912
1024
  }
913
- function Nt(e, t) {
1025
+ function At(e, t) {
914
1026
  return t === "dwf" || t === "dwfx" || t === "xps" ? t : e === "dwf" || e === "dwfx" || e === "xps" ? e : "dwf";
915
1027
  }
916
- function Be(e) {
1028
+ function Ye(e) {
917
1029
  if (e.dwfWasmUrl) return e.dwfWasmUrl;
918
1030
  if (typeof document > "u") return;
919
- const t = e.wasmPath ? new URL(We(e.wasmPath), document.baseURI).href : new URL("wasm/", document.baseURI).href;
1031
+ const t = e.wasmPath ? new URL(Ue(e.wasmPath), document.baseURI).href : new URL("wasm/", document.baseURI).href;
920
1032
  return new URL("dwfv-render.wasm", t).href;
921
1033
  }
922
- function Et(e) {
1034
+ function Lt(e) {
923
1035
  if (e.dwfBackground) return e.dwfBackground;
924
1036
  const t = e.canvasOptions;
925
1037
  return (t == null ? void 0 : t.background) ?? "#05070d";
926
1038
  }
927
- function Fe(e, t, r) {
1039
+ function Xe(e, t, r) {
928
1040
  return {
929
- ...Ut(e, t, r),
1041
+ ...Gt(e, t, r),
930
1042
  maxDevicePixelRatio: e.dwfMaxDevicePixelRatio ?? 2,
931
1043
  maxCanvasPixels: e.dwfMaxCanvasPixels ?? 16777216
932
1044
  };
933
1045
  }
934
- function Ut(e, t, r) {
1046
+ function Gt(e, t, r) {
935
1047
  return {
936
1048
  wasmUrl: t,
937
1049
  preferWebgl: e.dwfPreferWebgl ?? !0,
@@ -946,39 +1058,39 @@ function Ut(e, t, r) {
946
1058
  minFilledAreaCssPx: e.dwfMinFilledAreaCssPx
947
1059
  };
948
1060
  }
949
- function Z(e, t, r) {
1061
+ function q(e, t, r) {
950
1062
  typeof r == "number" && Number.isFinite(r) && (e[t] = r);
951
1063
  }
952
- function We(e) {
1064
+ function Ue(e) {
953
1065
  return e.endsWith("/") ? e : `${e}/`;
954
1066
  }
955
- function Re(e) {
1067
+ function Ve(e) {
956
1068
  const [t, r, i] = e.map((s) => Math.max(0, Math.min(255, Math.round(s * 255))));
957
- return `#${rt(t)}${rt(r)}${rt(i)}`;
1069
+ return `#${st(t)}${st(r)}${st(i)}`;
958
1070
  }
959
- function rt(e) {
1071
+ function st(e) {
960
1072
  return e.toString(16).padStart(2, "0");
961
1073
  }
962
- function De(e) {
1074
+ function $e(e) {
963
1075
  const t = {};
964
1076
  for (const r of e) t[r] = (t[r] ?? 0) + 1;
965
1077
  return t;
966
1078
  }
967
- function Oe(e) {
1079
+ function je(e) {
968
1080
  return Array.from(new Set(e));
969
1081
  }
970
- function ze(e = {}) {
971
- return new re([
972
- new ce(e),
973
- new me(e),
974
- new Ee(e)
1082
+ function Ge(e = {}) {
1083
+ return new oe([
1084
+ new de(e),
1085
+ new ve(e),
1086
+ new Re(e)
975
1087
  ]);
976
1088
  }
977
- function Ye(e) {
1089
+ function Ze(e) {
978
1090
  const t = e;
979
1091
  return t.nativeRenderer === !0 && typeof t.mount == "function";
980
1092
  }
981
- const He = {
1093
+ const qe = {
982
1094
  1: "#ff0000",
983
1095
  2: "#ffff00",
984
1096
  3: "#00ff00",
@@ -1234,19 +1346,19 @@ const He = {
1234
1346
  254: "#bebebe",
1235
1347
  255: "#ffffff"
1236
1348
  };
1237
- function N(e, t = "#ffffff", r = t) {
1349
+ function E(e, t = "#ffffff", r = t) {
1238
1350
  if (typeof e != "number" || Number.isNaN(e)) return t;
1239
1351
  const i = Math.abs(Math.trunc(e));
1240
- return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r : He[i] ?? t;
1352
+ return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r : qe[i] ?? t;
1241
1353
  }
1242
- function U(e, t = "rgb") {
1354
+ function V(e, t = "rgb") {
1243
1355
  const r = Math.max(0, Math.trunc(e)) & 16777215, i = r >> 16 & 255, s = r >> 8 & 255, n = r & 255;
1244
1356
  return `rgb(${t === "rgb" ? i : n}, ${s}, ${t === "rgb" ? n : i})`;
1245
1357
  }
1246
- function B(e) {
1358
+ function F(e) {
1247
1359
  if (typeof e == "string") {
1248
1360
  const t = e.trim();
1249
- return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? Xe(t) ?? t : {
1361
+ return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? Ke(t) ?? t : {
1250
1362
  red: "#ff0000",
1251
1363
  yellow: "#ffff00",
1252
1364
  green: "#00ff00",
@@ -1265,111 +1377,111 @@ function B(e) {
1265
1377
  return Number.isFinite(n) && n >= 0 && n < 1 ? `rgba(${r}, ${i}, ${s}, ${n})` : `rgb(${r}, ${i}, ${s})`;
1266
1378
  }
1267
1379
  }
1268
- function Xe(e) {
1380
+ function Ke(e) {
1269
1381
  if (!e) return;
1270
1382
  const t = e.trim();
1271
1383
  if (/^#[0-9a-f]{8}$/i.test(t)) {
1272
1384
  const r = parseInt(t.slice(1, 3), 16) / 255, i = parseInt(t.slice(3, 5), 16), s = parseInt(t.slice(5, 7), 16), n = parseInt(t.slice(7, 9), 16);
1273
- return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${ut(r)})`;
1385
+ return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${gt(r)})`;
1274
1386
  }
1275
1387
  if (/^#[0-9a-f]{6}$/i.test(t) || /^#[0-9a-f]{3}$/i.test(t)) return t;
1276
1388
  if (/^sc#/i.test(t)) {
1277
1389
  const r = t.slice(3).split(",").map((a) => Number(a.trim())), [i, s, n, o] = r.length === 4 ? r : [1, ...r];
1278
- if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${ut(i)})`;
1390
+ if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${gt(i)})`;
1279
1391
  }
1280
1392
  }
1281
- function F(e, t, r = {}) {
1393
+ function D(e, t, r = {}) {
1282
1394
  const i = r.foreground ?? "#ffffff", s = i;
1283
1395
  let n;
1284
- const o = B(e.trueColor) ?? B(e.color) ?? B(e.colorName);
1396
+ const o = F(e.trueColor) ?? F(e.color) ?? F(e.colorName);
1285
1397
  if (o && (n = o), !n) {
1286
- const a = Ge(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
1287
- typeof a == "number" && a >= 0 && a <= 16777215 && (n = U(a, r.trueColorByteOrder ?? "rgb"));
1398
+ const a = ir(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
1399
+ typeof a == "number" && a >= 0 && a <= 16777215 && (n = V(a, r.trueColorByteOrder ?? "rgb"));
1288
1400
  }
1289
1401
  if (!n) {
1290
- const a = Gt(e.colorIndex, e.colorNumber, e.aci);
1291
- typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n = N(a, s, i));
1402
+ const a = Jt(e.colorIndex, e.colorNumber, e.aci);
1403
+ typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n = E(a, s, i));
1292
1404
  }
1293
1405
  if (!n && typeof e.color == "number") {
1294
1406
  const a = Number(e.color);
1295
- Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n = N(a, s, i)) : n = U(a, r.trueColorByteOrder ?? "rgb");
1407
+ Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n = E(a, s, i)) : n = V(a, r.trueColorByteOrder ?? "rgb");
1296
1408
  }
1297
1409
  if (!n) {
1298
- const a = je(t, e.layer);
1299
- n = Ue(a, r);
1410
+ const a = rr(t, e.layer);
1411
+ n = Qe(a, r);
1300
1412
  }
1301
- return Vt(n ?? s, r);
1413
+ return Zt(n ?? s, r);
1302
1414
  }
1303
- function ft(e, t, r = {}) {
1415
+ function mt(e, t, r = {}) {
1304
1416
  let i;
1305
- const s = B(e.fillColor);
1417
+ const s = F(e.fillColor);
1306
1418
  if (s && (i = s), !i && typeof e.fillColor == "number") {
1307
1419
  const n = e.fillColor;
1308
- i = Math.abs(n) <= 257 ? N(n, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff") : U(n, r.trueColorByteOrder ?? "rgb");
1420
+ i = Math.abs(n) <= 257 ? E(n, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff") : V(n, r.trueColorByteOrder ?? "rgb");
1309
1421
  }
1310
- return !i && typeof e.fillColorIndex == "number" && (i = N(e.fillColorIndex, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff")), i ? Vt(i, r) : void 0;
1422
+ return !i && typeof e.fillColorIndex == "number" && (i = E(e.fillColorIndex, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff")), i ? Zt(i, r) : void 0;
1311
1423
  }
1312
- function Vt(e, t = {}) {
1424
+ function Zt(e, t = {}) {
1313
1425
  if (t.contrastMode !== "adaptive") return e;
1314
1426
  const r = t.background ?? "#0b1020", i = t.foreground ?? "#ffffff";
1315
- return _e(e, r, i, t.minColorContrast ?? 2.4);
1427
+ return Je(e, r, i, t.minColorContrast ?? 2.4);
1316
1428
  }
1317
- function _e(e, t, r, i = 2.4) {
1318
- const s = it(r) ?? { r: 255, g: 255, b: 255, a: 1 }, n = it(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = it(e);
1429
+ function Je(e, t, r, i = 2.4) {
1430
+ const s = nt(r) ?? { r: 255, g: 255, b: 255, a: 1 }, n = nt(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = nt(e);
1319
1431
  if (!o) return e;
1320
- const a = It(o, n);
1321
- if (st(a, n) >= i) return e;
1322
- const c = dt(n), h = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
1323
- for (const l of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
1324
- const f = Ze(o, h, l);
1325
- if (st(It(f, n), n) >= i) return Tt(f);
1432
+ const a = Bt(o, n);
1433
+ if (ot(a, n) >= i) return e;
1434
+ const c = pt(n), l = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
1435
+ for (const h of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
1436
+ const f = sr(o, l, h);
1437
+ if (ot(Bt(f, n), n) >= i) return Ft(f);
1326
1438
  }
1327
- return st(s, n) >= i ? Tt(s) : c < 0.5 ? "#ffffff" : "#000000";
1439
+ return ot(s, n) >= i ? Ft(s) : c < 0.5 ? "#ffffff" : "#000000";
1328
1440
  }
1329
- function $t(e) {
1441
+ function qt(e) {
1330
1442
  return e ? e.isVisible !== !1 && e.isFrozen !== !0 : !0;
1331
1443
  }
1332
- function Ue(e, t) {
1444
+ function Qe(e, t) {
1333
1445
  if (!e) return;
1334
- const r = t.foreground ?? "#ffffff", i = B(e.trueColor);
1446
+ const r = t.foreground ?? "#ffffff", i = F(e.trueColor);
1335
1447
  if (i) return i;
1336
- if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return U(e.trueColor, t.trueColorByteOrder ?? "rgb");
1337
- const s = B(e.color);
1448
+ if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return V(e.trueColor, t.trueColorByteOrder ?? "rgb");
1449
+ const s = F(e.color);
1338
1450
  if (s) return s;
1339
- if ($e(e.colorIndex)) return N(e.colorIndex, r, r);
1451
+ if (er(e.colorIndex)) return E(e.colorIndex, r, r);
1340
1452
  if (typeof e.color == "number") {
1341
1453
  const n = Number(e.color);
1342
- return Math.abs(n) <= 257 ? N(n, r, r) : U(n, t.trueColorByteOrder ?? "rgb");
1454
+ return Math.abs(n) <= 257 ? E(n, r, r) : V(n, t.trueColorByteOrder ?? "rgb");
1343
1455
  }
1344
- if (typeof e.colorIndex == "number") return N(e.colorIndex, r, r);
1456
+ if (typeof e.colorIndex == "number") return E(e.colorIndex, r, r);
1345
1457
  }
1346
- function Ve(e) {
1347
- return Gt(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
1458
+ function tr(e) {
1459
+ return Jt(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
1348
1460
  }
1349
- function jt(e, t, r, i = {}) {
1350
- if (!Ve(e)) return e;
1351
- const s = F(t, r, i);
1461
+ function Kt(e, t, r, i = {}) {
1462
+ if (!tr(e)) return e;
1463
+ const s = D(t, r, i);
1352
1464
  return { ...e, color: s, trueColor: void 0, colorIndex: void 0, colorNumber: void 0 };
1353
1465
  }
1354
- function $e(e) {
1466
+ function er(e) {
1355
1467
  return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
1356
1468
  }
1357
- function je(e, t) {
1469
+ function rr(e, t) {
1358
1470
  if (!(!e || !t))
1359
1471
  return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((r) => r.name.toLowerCase() === t.toLowerCase());
1360
1472
  }
1361
- function Gt(...e) {
1473
+ function Jt(...e) {
1362
1474
  for (const t of e)
1363
1475
  if (typeof t == "number" && Number.isFinite(t)) return t;
1364
1476
  }
1365
- function Ge(e, t) {
1477
+ function ir(e, t) {
1366
1478
  const r = e;
1367
1479
  for (const i of t) {
1368
1480
  const s = r[i];
1369
1481
  if (typeof s == "number" && Number.isFinite(s)) return s;
1370
1482
  }
1371
1483
  }
1372
- function it(e) {
1484
+ function nt(e) {
1373
1485
  const t = e.trim().toLowerCase();
1374
1486
  if (/^#[0-9a-f]{3}$/i.test(t))
1375
1487
  return {
@@ -1399,7 +1511,7 @@ function it(e) {
1399
1511
  }
1400
1512
  }
1401
1513
  }
1402
- function It(e, t) {
1514
+ function Bt(e, t) {
1403
1515
  const r = e.a + t.a * (1 - e.a);
1404
1516
  return r <= 0 ? { r: 0, g: 0, b: 0, a: 0 } : {
1405
1517
  r: (e.r * e.a + t.r * t.a * (1 - e.a)) / r,
@@ -1408,7 +1520,7 @@ function It(e, t) {
1408
1520
  a: r
1409
1521
  };
1410
1522
  }
1411
- function Ze(e, t, r) {
1523
+ function sr(e, t, r) {
1412
1524
  const i = Math.max(0, Math.min(1, r));
1413
1525
  return {
1414
1526
  r: e.r + (t.r - e.r) * i,
@@ -1417,28 +1529,28 @@ function Ze(e, t, r) {
1417
1529
  a: e.a
1418
1530
  };
1419
1531
  }
1420
- function dt(e) {
1532
+ function pt(e) {
1421
1533
  const t = [e.r, e.g, e.b].map((r) => {
1422
1534
  const i = r / 255;
1423
1535
  return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
1424
1536
  });
1425
1537
  return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
1426
1538
  }
1427
- function st(e, t) {
1428
- const r = dt(e), i = dt(t), s = Math.max(r, i), n = Math.min(r, i);
1539
+ function ot(e, t) {
1540
+ const r = pt(e), i = pt(t), s = Math.max(r, i), n = Math.min(r, i);
1429
1541
  return (s + 0.05) / (n + 0.05);
1430
1542
  }
1431
- function Tt(e) {
1543
+ function Ft(e) {
1432
1544
  const t = W(e.r), r = W(e.g), i = W(e.b);
1433
- return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${ut(e.a)})` : `rgb(${t}, ${r}, ${i})`;
1545
+ return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${gt(e.a)})` : `rgb(${t}, ${r}, ${i})`;
1434
1546
  }
1435
1547
  function W(e) {
1436
1548
  return Math.max(0, Math.min(255, Math.round(e)));
1437
1549
  }
1438
- function ut(e) {
1550
+ function gt(e) {
1439
1551
  return Math.round(e * 1e3) / 1e3;
1440
1552
  }
1441
- function nt(e, t) {
1553
+ function at(e, t) {
1442
1554
  return {
1443
1555
  a: e.a * t.a + e.c * t.b,
1444
1556
  b: e.b * t.a + e.d * t.b,
@@ -1448,14 +1560,14 @@ function nt(e, t) {
1448
1560
  f: e.b * t.e + e.d * t.f + e.f
1449
1561
  };
1450
1562
  }
1451
- function Lt(e, t) {
1563
+ function Dt(e, t) {
1452
1564
  return { a: 1, b: 0, c: 0, d: 1, e, f: t };
1453
1565
  }
1454
- function qe(e) {
1566
+ function nr(e) {
1455
1567
  const t = Math.cos(e), r = Math.sin(e);
1456
1568
  return { a: t, b: r, c: -r, d: t, e: 0, f: 0 };
1457
1569
  }
1458
- function Ke(e, t = e) {
1570
+ function or(e, t = e) {
1459
1571
  return { a: e, b: 0, c: 0, d: t, e: 0, f: 0 };
1460
1572
  }
1461
1573
  function k(e, t) {
@@ -1465,33 +1577,33 @@ function k(e, t) {
1465
1577
  z: "z" in e ? e.z : void 0
1466
1578
  };
1467
1579
  }
1468
- function At(e, t) {
1580
+ function Wt(e, t) {
1469
1581
  if (e)
1470
1582
  return e.map((r) => ({ cmd: r.cmd, points: r.points.map((i) => k(i, t)) }));
1471
1583
  }
1472
- function Q(e, t = { x: 0, y: 0 }) {
1584
+ function tt(e, t = { x: 0, y: 0 }) {
1473
1585
  const r = e.insertionPoint ?? { x: 0, y: 0 }, i = e.scale, s = Number(typeof i == "object" && i ? i.x ?? 1 : e.scaleX ?? 1), n = Number(typeof i == "object" && i ? i.y ?? s : e.scaleY ?? s), o = Number(e.rotation ?? 0);
1474
- let a = Lt(r.x, r.y);
1475
- return a = nt(a, qe(Number.isFinite(o) ? o : 0)), a = nt(a, Ke(Number.isFinite(s) ? s : 1, Number.isFinite(n) ? n : 1)), a = nt(a, Lt(-t.x, -t.y)), a;
1586
+ let a = Dt(r.x, r.y);
1587
+ return a = at(a, nr(Number.isFinite(o) ? o : 0)), a = at(a, or(Number.isFinite(s) ? s : 1, Number.isFinite(n) ? n : 1)), a = at(a, Dt(-t.x, -t.y)), a;
1476
1588
  }
1477
- function tt(e, t) {
1589
+ function et(e, t) {
1478
1590
  const r = { ...e, raw: e.raw ?? e };
1479
1591
  if (e.startPoint && (r.startPoint = k(e.startPoint, t)), e.endPoint && (r.endPoint = k(e.endPoint, t)), e.center && (r.center = k(e.center, t)), e.insertionPoint && (r.insertionPoint = k(e.insertionPoint, t)), e.majorAxisEndPoint) {
1480
1592
  const s = k({ x: 0, y: 0 }, t), n = k(e.majorAxisEndPoint, t);
1481
1593
  r.majorAxisEndPoint = { x: n.x - s.x, y: n.y - s.y, z: n.z };
1482
1594
  }
1483
- e.vertices && (r.vertices = e.vertices.map((s) => ({ ...k(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => k(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => k(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => k(s, t))), e.commands && (r.commands = At(e.commands, t)), e.loops && (r.loops = e.loops.map((s) => {
1595
+ e.vertices && (r.vertices = e.vertices.map((s) => ({ ...k(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => k(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => k(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => k(s, t))), e.commands && (r.commands = Wt(e.commands, t)), e.loops && (r.loops = e.loops.map((s) => {
1484
1596
  var n;
1485
1597
  return {
1486
1598
  ...s,
1487
1599
  vertices: (n = s.vertices) == null ? void 0 : n.map((o) => k(o, t)),
1488
- commands: At(s.commands, t)
1600
+ commands: Wt(s.commands, t)
1489
1601
  };
1490
1602
  }));
1491
1603
  const i = Math.sqrt(Math.abs(t.a * t.d - t.b * t.c));
1492
1604
  return typeof e.radius == "number" && Number.isFinite(i) && (r.radius = e.radius * i), r;
1493
1605
  }
1494
- const Je = {
1606
+ const ar = {
1495
1607
  background: "#0b1020",
1496
1608
  foreground: "#ffffff",
1497
1609
  showUnsupportedMarkers: !1,
@@ -1514,13 +1626,13 @@ const Je = {
1514
1626
  preserveDrawingBuffer: !1,
1515
1627
  enableSpatialIndex: !0
1516
1628
  };
1517
- class Bt {
1629
+ class Rt {
1518
1630
  constructor(t, r = {}) {
1519
1631
  d(this, "canvas");
1520
1632
  d(this, "ctx");
1521
1633
  d(this, "opts");
1522
1634
  d(this, "document");
1523
- d(this, "bounds", M());
1635
+ d(this, "bounds", N());
1524
1636
  d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
1525
1637
  d(this, "fitScale", 1);
1526
1638
  d(this, "dpr", 1);
@@ -1533,14 +1645,14 @@ class Bt {
1533
1645
  d(this, "onViewChange");
1534
1646
  const i = t.getContext("2d");
1535
1647
  if (!i) throw new Error("Canvas 2D context is not available.");
1536
- this.canvas = t, this.ctx = i, this.opts = { ...Je, ...r }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
1648
+ this.canvas = t, this.ctx = i, this.opts = { ...ar, ...r }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
1537
1649
  }
1538
1650
  destroy() {
1539
1651
  var t;
1540
1652
  (t = this.resizeObserver) == null || t.disconnect();
1541
1653
  }
1542
1654
  clear() {
1543
- this.document = void 0, this.bounds = M(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1655
+ this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1544
1656
  }
1545
1657
  setDocument(t) {
1546
1658
  this.document = t, this.bounds = this.computeBounds(t), this.fitToView();
@@ -1555,7 +1667,7 @@ class Bt {
1555
1667
  return { ...this.opts };
1556
1668
  }
1557
1669
  fitToView(t = 0.92) {
1558
- if (!D(this.bounds)) {
1670
+ if (!O(this.bounds)) {
1559
1671
  this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
1560
1672
  return;
1561
1673
  }
@@ -1598,7 +1710,7 @@ class Bt {
1598
1710
  return { ...this.bounds };
1599
1711
  }
1600
1712
  getStats() {
1601
- return Qe(this.stats);
1713
+ return cr(this.stats);
1602
1714
  }
1603
1715
  getZoomRatio() {
1604
1716
  return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
@@ -1666,7 +1778,7 @@ class Bt {
1666
1778
  const i = String(t.type ?? "UNKNOWN").toUpperCase();
1667
1779
  this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
1668
1780
  const s = this.lookupLayer(t.layer);
1669
- if (t.isVisible === !1 || !$t(s)) {
1781
+ if (t.isVisible === !1 || !qt(s)) {
1670
1782
  this.stats.skipped++;
1671
1783
  return;
1672
1784
  }
@@ -1709,8 +1821,8 @@ class Bt {
1709
1821
  beginStyledPath(t, r = !1) {
1710
1822
  const i = this.ctx;
1711
1823
  i.save(), i.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
1712
- const s = F(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), n = ft(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
1713
- i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha = T(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
1824
+ const s = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), n = mt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
1825
+ i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha = A(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
1714
1826
  const o = typeof t.lineweight == "number" && t.lineweight > 0 ? t.lineweight : 0;
1715
1827
  i.lineWidth = Math.max(1, Math.min(12, o > 0 ? o / 30 : 1)), i.beginPath();
1716
1828
  }
@@ -1735,7 +1847,7 @@ class Bt {
1735
1847
  drawArc(t) {
1736
1848
  const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
1737
1849
  if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
1738
- this.strokeWorldPolyline(t, q(x(r), i, s, n, !0), !1);
1850
+ this.strokeWorldPolyline(t, K(w(r), i, s, n, !0), !1);
1739
1851
  }
1740
1852
  drawPolyline(t) {
1741
1853
  const r = t.vertices ?? t.points;
@@ -1744,15 +1856,15 @@ class Bt {
1744
1856
  for (let o = 0; o < n; o++) {
1745
1857
  const a = r[o], c = r[(o + 1) % r.length];
1746
1858
  if (!m(a) || !m(c)) continue;
1747
- const h = Xt(a, c, Number(a.bulge ?? 0));
1748
- s.length > 0 && h.shift(), s.push(...h);
1859
+ const l = $t(a, c, Number(a.bulge ?? 0));
1860
+ s.length > 0 && l.shift(), s.push(...l);
1749
1861
  }
1750
1862
  this.strokeWorldPolyline(t, s, i);
1751
1863
  }
1752
1864
  drawEllipse(t) {
1753
1865
  const r = t.center, i = t.majorAxisEndPoint, s = Number(t.axisRatio ?? 1);
1754
1866
  if (!m(r) || !m(i)) return this.markSkipped("ELLIPSE");
1755
- const n = K(r, i, s, Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2)), o = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
1867
+ const n = J(r, i, s, Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2)), o = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
1756
1868
  this.strokeWorldPolyline(t, n, o);
1757
1869
  }
1758
1870
  drawPoint(t) {
@@ -1762,17 +1874,17 @@ class Bt {
1762
1874
  this.beginStyledPath(t), this.ctx.moveTo(i.x - 3, i.y), this.ctx.lineTo(i.x + 3, i.y), this.ctx.moveTo(i.x, i.y - 3), this.ctx.lineTo(i.x, i.y + 3), this.finishStroke();
1763
1875
  }
1764
1876
  drawText(t) {
1765
- const r = t.insertionPoint ?? t.startPoint ?? t.center, i = _t(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
1877
+ const r = t.insertionPoint ?? t.startPoint ?? t.center, i = jt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
1766
1878
  if (!m(r) || !i) return this.markSkipped(String(t.type));
1767
1879
  this.drawTextAt(t, r, i, s, Number(t.rotation ?? 0));
1768
1880
  }
1769
1881
  drawInsert(t, r) {
1770
1882
  const i = this.lookupBlock(t.blockName ?? t.name);
1771
1883
  if (i && r < this.opts.maxInsertDepth) {
1772
- const a = Q(t, i.basePoint ?? { x: 0, y: 0 });
1884
+ const a = tt(t, i.basePoint ?? { x: 0, y: 0 });
1773
1885
  for (const c of i.entities) {
1774
- const h = jt(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast });
1775
- this.drawEntityTracked(tt(h, a), r + 1);
1886
+ const l = Kt(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast });
1887
+ this.drawEntityTracked(et(l, a), r + 1);
1776
1888
  }
1777
1889
  return;
1778
1890
  }
@@ -1812,7 +1924,7 @@ class Bt {
1812
1924
  }
1813
1925
  this.ctx.closePath();
1814
1926
  }
1815
- this.finishFillStroke(!!ft(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
1927
+ this.finishFillStroke(!!mt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
1816
1928
  }
1817
1929
  drawSpline(t) {
1818
1930
  var i;
@@ -1844,17 +1956,17 @@ class Bt {
1844
1956
  drawImage(t) {
1845
1957
  const r = t.insertionPoint;
1846
1958
  if (!m(r)) return this.markSkipped(String(t.type));
1847
- const i = Number(t.width ?? 32), s = Number(t.height ?? 32), n = this.worldToScreen(r), o = this.worldToScreen({ x: r.x + i, y: r.y - s }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), h = Math.abs(o.x - n.x), l = Math.abs(o.y - n.y), f = t.imageDataUrl;
1959
+ const i = Number(t.width ?? 32), s = Number(t.height ?? 32), n = this.worldToScreen(r), o = this.worldToScreen({ x: r.x + i, y: r.y - s }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), l = Math.abs(o.x - n.x), h = Math.abs(o.y - n.y), f = t.imageDataUrl;
1848
1960
  if (f) {
1849
1961
  const u = this.getImage(f);
1850
1962
  if (u.complete && u.naturalWidth > 0) {
1851
- this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(u, a, c, h, l), this.ctx.restore(), this.stats.drawn++;
1963
+ this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(u, a, c, l, h), this.ctx.restore(), this.stats.drawn++;
1852
1964
  return;
1853
1965
  }
1854
1966
  u.onload = () => this.render();
1855
1967
  }
1856
1968
  if (!this.opts.showImagePlaceholders) return this.markSkipped(String(t.type));
1857
- this.beginStyledPath(t), this.ctx.rect(a, c, h, l), this.ctx.moveTo(a, c), this.ctx.lineTo(a + h, c + l), this.ctx.moveTo(a + h, c), this.ctx.lineTo(a, c + l), this.finishStroke();
1969
+ this.beginStyledPath(t), this.ctx.rect(a, c, l, h), this.ctx.moveTo(a, c), this.ctx.lineTo(a + l, c + h), this.ctx.moveTo(a + l, c), this.ctx.lineTo(a, c + h), this.finishStroke();
1858
1970
  }
1859
1971
  getImage(t) {
1860
1972
  let r = this.imageCache.get(t);
@@ -1870,8 +1982,8 @@ class Bt {
1870
1982
  const o = this.ctx, a = this.worldToScreen(r);
1871
1983
  o.save(), o.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), o.translate(a.x, a.y), o.rotate(-n);
1872
1984
  const c = Math.max(4, Math.min(256, Math.abs(s) * this.view.scale));
1873
- o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = F(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o.globalAlpha = T(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
1874
- for (const [h, l] of i.split(/\r?\n/g).entries()) o.fillText(l, 0, h * c * 1.22);
1985
+ o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o.globalAlpha = A(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
1986
+ for (const [l, h] of i.split(/\r?\n/g).entries()) o.fillText(h, 0, l * c * 1.22);
1875
1987
  o.restore(), this.stats.drawn++;
1876
1988
  }
1877
1989
  strokeWorldPolyline(t, r, i) {
@@ -1892,41 +2004,41 @@ class Bt {
1892
2004
  entityAnchor(t) {
1893
2005
  for (const r of ["startPoint", "insertionPoint", "center", "point", "location"]) {
1894
2006
  const i = t[r];
1895
- if (m(i)) return x(i);
2007
+ if (m(i)) return w(i);
1896
2008
  }
1897
- if (Array.isArray(t.vertices) && m(t.vertices[0])) return x(t.vertices[0]);
2009
+ if (Array.isArray(t.vertices) && m(t.vertices[0])) return w(t.vertices[0]);
1898
2010
  if (Array.isArray(t.commands) && t.commands.length) {
1899
2011
  const r = t.commands.find((i) => i.points.length > 0);
1900
- if (r) return x(r.points[0]);
2012
+ if (r) return w(r.points[0]);
1901
2013
  }
1902
2014
  }
1903
2015
  computeBounds(t) {
1904
2016
  var i;
1905
- const r = M();
2017
+ const r = N();
1906
2018
  if ((i = t.pages) != null && i.length)
1907
2019
  for (const s of t.pages)
1908
2020
  v(r, { x: 0, y: 0 }), v(r, { x: s.width, y: s.height });
1909
2021
  for (const s of t.entities) this.includeEntityBounds(r, s, 0);
1910
- return Ht(r);
2022
+ return Vt(r);
1911
2023
  }
1912
2024
  includeEntityBounds(t, r, i) {
1913
2025
  const s = String(r.type ?? "").toUpperCase(), n = r.kind ?? R(s);
1914
2026
  if (n === "insert") {
1915
2027
  const o = this.lookupBlock(r.blockName ?? r.name);
1916
2028
  if (o && i < this.opts.maxInsertDepth) {
1917
- const a = Q(r, o.basePoint ?? { x: 0, y: 0 });
1918
- for (const c of o.entities) this.includeEntityBounds(t, tt(c, a), i + 1);
2029
+ const a = tt(r, o.basePoint ?? { x: 0, y: 0 });
2030
+ for (const c of o.entities) this.includeEntityBounds(t, et(c, a), i + 1);
1919
2031
  return;
1920
2032
  }
1921
2033
  }
1922
2034
  if (n === "line")
1923
2035
  m(r.startPoint) && v(t, r.startPoint), m(r.endPoint) && v(t, r.endPoint);
1924
2036
  else if (n === "circle" || n === "arc")
1925
- m(r.center) && Number.isFinite(r.radius) && Yt(t, r.center, Number(r.radius));
2037
+ m(r.center) && Number.isFinite(r.radius) && Ut(t, r.center, Number(r.radius));
1926
2038
  else if (n === "polyline" || n === "solid" || n === "spline")
1927
2039
  for (const o of [...r.vertices ?? [], ...r.points ?? [], ...r.controlPoints ?? [], ...r.fitPoints ?? []]) m(o) && v(t, o);
1928
2040
  else if (n === "ellipse")
1929
- m(r.center) && m(r.majorAxisEndPoint) && K(r.center, r.majorAxisEndPoint, Number(r.axisRatio ?? 1), Number(r.startAngle ?? 0), Number(r.endAngle ?? Math.PI * 2)).forEach((o) => v(t, o));
2041
+ m(r.center) && m(r.majorAxisEndPoint) && J(r.center, r.majorAxisEndPoint, Number(r.axisRatio ?? 1), Number(r.startAngle ?? 0), Number(r.endAngle ?? Math.PI * 2)).forEach((o) => v(t, o));
1930
2042
  else if (n === "path")
1931
2043
  for (const o of r.commands ?? []) for (const a of o.points) v(t, a);
1932
2044
  else if (n === "hatch")
@@ -1961,7 +2073,7 @@ class Bt {
1961
2073
  });
1962
2074
  }
1963
2075
  }
1964
- function Qe(e) {
2076
+ function cr(e) {
1965
2077
  return {
1966
2078
  total: e.total,
1967
2079
  drawn: e.drawn,
@@ -1977,7 +2089,7 @@ function Qe(e) {
1977
2089
  buildElapsedMs: e.buildElapsedMs
1978
2090
  };
1979
2091
  }
1980
- const tr = {
2092
+ const lr = {
1981
2093
  background: "#0b1020",
1982
2094
  foreground: "#ffffff",
1983
2095
  showUnsupportedMarkers: !1,
@@ -2000,7 +2112,7 @@ const tr = {
2000
2112
  preserveDrawingBuffer: !1,
2001
2113
  enableSpatialIndex: !0
2002
2114
  };
2003
- class Ft {
2115
+ class Ot {
2004
2116
  constructor(t, r = {}) {
2005
2117
  d(this, "canvas");
2006
2118
  d(this, "backend", "webgl");
@@ -2010,7 +2122,7 @@ class Ft {
2010
2122
  d(this, "imageCache", /* @__PURE__ */ new Map());
2011
2123
  d(this, "opts");
2012
2124
  d(this, "document");
2013
- d(this, "bounds", M());
2125
+ d(this, "bounds", N());
2014
2126
  d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
2015
2127
  d(this, "fitScale", 1);
2016
2128
  d(this, "dpr", 1);
@@ -2024,30 +2136,30 @@ class Ft {
2024
2136
  d(this, "rafHandle", 0);
2025
2137
  d(this, "onStats");
2026
2138
  d(this, "onViewChange");
2027
- const i = er(t, r);
2139
+ const i = hr(t, r);
2028
2140
  if (!i) throw new Error('WebGL is not available. Use renderer: "canvas2d" to force the Canvas2D fallback.');
2029
- this.canvas = t, this.gl = i, this.program = rr(i), this.opts = { ...tr, ...r }, this.canvas.classList.add("cad-viewer-canvas", "cad-viewer-webgl-canvas"), this.createOverlayCanvas(), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
2141
+ this.canvas = t, this.gl = i, this.program = fr(i), this.opts = { ...lr, ...r }, this.canvas.classList.add("cad-viewer-canvas", "cad-viewer-webgl-canvas"), this.createOverlayCanvas(), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
2030
2142
  }
2031
2143
  static isSupported() {
2032
- return Zt();
2144
+ return Qt();
2033
2145
  }
2034
2146
  destroy() {
2035
2147
  var t, r;
2036
2148
  this.eventController.abort(), (t = this.resizeObserver) == null || t.disconnect(), this.cancelScheduledRender(), this.disposeScene(), (r = this.overlayCanvas) == null || r.remove();
2037
2149
  }
2038
2150
  clear() {
2039
- this.document = void 0, this.bounds = M(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
2151
+ this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
2040
2152
  }
2041
2153
  setDocument(t) {
2042
- this.document = t, this.bounds = cr(t, this.opts), this.disposeScene();
2043
- const r = sr(t, this.opts, this.bounds);
2044
- this.scene = ir(this.gl, r), this.stats = fr(this.scene, 0), this.fitToView();
2154
+ this.document = t, this.bounds = br(t, this.opts), this.disposeScene();
2155
+ const r = ur(t, this.opts, this.bounds);
2156
+ this.scene = dr(this.gl, r), this.stats = wr(this.scene, 0), this.fitToView();
2045
2157
  }
2046
2158
  getDocument() {
2047
2159
  return this.document;
2048
2160
  }
2049
2161
  setOptions(t) {
2050
- const r = lr(this.opts, t);
2162
+ const r = yr(this.opts, t);
2051
2163
  if (this.opts = { ...this.opts, ...t }, r && this.document) {
2052
2164
  this.setDocument(this.document);
2053
2165
  return;
@@ -2058,7 +2170,7 @@ class Ft {
2058
2170
  return { ...this.opts };
2059
2171
  }
2060
2172
  fitToView(t = 0.92) {
2061
- if (!D(this.bounds)) {
2173
+ if (!O(this.bounds)) {
2062
2174
  this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
2063
2175
  return;
2064
2176
  }
@@ -2101,7 +2213,7 @@ class Ft {
2101
2213
  return { ...this.bounds };
2102
2214
  }
2103
2215
  getStats() {
2104
- return dr(this.stats);
2216
+ return xr(this.stats);
2105
2217
  }
2106
2218
  getZoomRatio() {
2107
2219
  return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
@@ -2125,17 +2237,17 @@ class Ft {
2125
2237
  return this.cancelScheduledRender(), this.renderNow();
2126
2238
  }
2127
2239
  renderNow() {
2128
- var h;
2240
+ var l;
2129
2241
  const t = performance.now(), r = this.gl;
2130
2242
  r.viewport(0, 0, this.canvas.width, this.canvas.height);
2131
- const i = mt(this.opts.background, [11, 16, 32, 255]);
2243
+ const i = bt(this.opts.background, [11, 16, 32, 255]);
2132
2244
  r.clearColor(i[0] / 255, i[1] / 255, i[2] / 255, i[3] / 255), r.clear(r.COLOR_BUFFER_BIT), r.disable(r.DEPTH_TEST), r.enable(r.BLEND), r.blendFunc(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA);
2133
2245
  let s = 0, n = 0;
2134
2246
  const o = this.scene, a = this.visibleWorldBounds();
2135
2247
  if (o) {
2136
2248
  r.useProgram(this.program.program), r.uniform2f(this.program.uViewCenter, this.view.centerX - o.origin.x, this.view.centerY - o.origin.y), r.uniform1f(this.program.uScale, this.view.scale * this.dpr), r.uniform2f(this.program.uViewport, this.canvas.width, this.canvas.height), r.uniform1f(this.program.uPointSize, Math.max(2, Math.min(12, 4 * this.dpr)));
2137
- const l = this.drawBatches(o.lineBatches, r.LINES, a);
2138
- s += l.visible, n += l.culled;
2249
+ const h = this.drawBatches(o.lineBatches, r.LINES, a);
2250
+ s += h.visible, n += h.culled;
2139
2251
  const f = this.drawBatches(o.triangleBatches, r.TRIANGLES, a);
2140
2252
  s += f.visible, n += f.culled;
2141
2253
  const u = this.drawBatches(o.pointBatches, r.POINTS, a);
@@ -2143,13 +2255,13 @@ class Ft {
2143
2255
  }
2144
2256
  this.renderOverlay(a);
2145
2257
  const c = performance.now() - t;
2146
- return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount: s, culledPrimitiveCount: n, gpuMemoryBytes: o.gpuMemoryBytes, buildElapsedMs: o.buildElapsedMs } : { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: c, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 }, (h = this.onStats) == null || h.call(this, this.getStats()), this.getStats();
2258
+ return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount: s, culledPrimitiveCount: n, gpuMemoryBytes: o.gpuMemoryBytes, buildElapsedMs: o.buildElapsedMs } : { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: c, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 }, (l = this.onStats) == null || l.call(this, this.getStats()), this.getStats();
2147
2259
  }
2148
2260
  drawBatches(t, r, i) {
2149
2261
  const s = this.gl;
2150
2262
  let n = 0, o = 0;
2151
2263
  for (const a of t) {
2152
- if (!ct(a.bounds, i)) {
2264
+ if (!ht(a.bounds, i)) {
2153
2265
  o += a.primitiveCount;
2154
2266
  continue;
2155
2267
  }
@@ -2186,32 +2298,32 @@ class Ft {
2186
2298
  let n = 0;
2187
2299
  for (const o of r) {
2188
2300
  if (n >= s) break;
2189
- if (!ct(o.bounds, i)) continue;
2301
+ if (!ht(o.bounds, i)) continue;
2190
2302
  const a = Math.abs(o.height) * this.view.scale;
2191
2303
  if (a < this.opts.textMinPixelHeight) continue;
2192
2304
  const c = this.worldToScreen(o.point);
2193
2305
  if (c.x < -512 || c.y < -512 || c.x > this.cssWidth + 512 || c.y > this.cssHeight + 512) continue;
2194
2306
  t.save(), t.translate(c.x, c.y), t.rotate(-o.rotation);
2195
- const h = Math.max(4, Math.min(256, a));
2196
- t.font = `${h}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, t.fillStyle = o.color, t.globalAlpha = o.opacity, t.textBaseline = "alphabetic";
2197
- for (const [l, f] of o.text.split(/\r?\n/g).entries()) t.fillText(f, 0, l * h * 1.22);
2307
+ const l = Math.max(4, Math.min(256, a));
2308
+ t.font = `${l}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, t.fillStyle = o.color, t.globalAlpha = o.opacity, t.textBaseline = "alphabetic";
2309
+ for (const [h, f] of o.text.split(/\r?\n/g).entries()) t.fillText(f, 0, h * l * 1.22);
2198
2310
  t.restore(), n++;
2199
2311
  }
2200
2312
  }
2201
2313
  drawImagesOverlay(t, r, i) {
2202
2314
  for (const s of r) {
2203
- if (!ct(s.bounds, i)) continue;
2204
- const n = this.worldToScreen(s.point), o = this.worldToScreen({ x: s.point.x + s.width, y: s.point.y - s.height }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), h = Math.abs(o.x - n.x), l = Math.abs(o.y - n.y);
2205
- if (!(h < 1 || l < 1)) {
2315
+ if (!ht(s.bounds, i)) continue;
2316
+ const n = this.worldToScreen(s.point), o = this.worldToScreen({ x: s.point.x + s.width, y: s.point.y - s.height }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), l = Math.abs(o.x - n.x), h = Math.abs(o.y - n.y);
2317
+ if (!(l < 1 || h < 1)) {
2206
2318
  if (s.source) {
2207
2319
  const f = this.getImage(s.source);
2208
2320
  if (f.complete && f.naturalWidth > 0) {
2209
- t.save(), t.globalAlpha = s.opacity, t.drawImage(f, a, c, h, l), t.restore();
2321
+ t.save(), t.globalAlpha = s.opacity, t.drawImage(f, a, c, l, h), t.restore();
2210
2322
  continue;
2211
2323
  }
2212
2324
  f.onload = () => this.scheduleRender();
2213
2325
  }
2214
- this.opts.showImagePlaceholders && (t.save(), t.strokeStyle = s.color, t.globalAlpha = s.opacity, t.lineWidth = 1, t.strokeRect(a, c, h, l), t.beginPath(), t.moveTo(a, c), t.lineTo(a + h, c + l), t.moveTo(a + h, c), t.lineTo(a, c + l), t.stroke(), t.restore());
2326
+ this.opts.showImagePlaceholders && (t.save(), t.strokeStyle = s.color, t.globalAlpha = s.opacity, t.lineWidth = 1, t.strokeRect(a, c, l, h), t.beginPath(), t.moveTo(a, c), t.lineTo(a + l, c + h), t.moveTo(a + l, c), t.lineTo(a, c + h), t.stroke(), t.restore());
2215
2327
  }
2216
2328
  }
2217
2329
  }
@@ -2285,12 +2397,12 @@ class Ft {
2285
2397
  });
2286
2398
  }
2287
2399
  }
2288
- function Zt() {
2400
+ function Qt() {
2289
2401
  if (typeof document > "u") return !1;
2290
2402
  const e = document.createElement("canvas");
2291
2403
  return !!(e.getContext("webgl2") ?? e.getContext("webgl") ?? e.getContext("experimental-webgl"));
2292
2404
  }
2293
- function er(e, t) {
2405
+ function hr(e, t) {
2294
2406
  const r = {
2295
2407
  alpha: !1,
2296
2408
  antialias: t.antialias ?? !0,
@@ -2301,7 +2413,7 @@ function er(e, t) {
2301
2413
  };
2302
2414
  return e.getContext("webgl2", r) ?? e.getContext("webgl", r) ?? e.getContext("experimental-webgl", r) ?? void 0;
2303
2415
  }
2304
- function rr(e) {
2416
+ function fr(e) {
2305
2417
  const t = `
2306
2418
  attribute vec2 a_position;
2307
2419
  attribute vec4 a_color;
@@ -2326,15 +2438,15 @@ function rr(e) {
2326
2438
  void main() {
2327
2439
  gl_FragColor = v_color;
2328
2440
  }
2329
- `, i = Wt(e, e.VERTEX_SHADER, t), s = Wt(e, e.FRAGMENT_SHADER, r), n = e.createProgram();
2441
+ `, i = zt(e, e.VERTEX_SHADER, t), s = zt(e, e.FRAGMENT_SHADER, r), n = e.createProgram();
2330
2442
  if (!n) throw new Error("Failed to create WebGL program.");
2331
2443
  if (e.attachShader(n, i), e.attachShader(n, s), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
2332
- const l = e.getProgramInfoLog(n) ?? "Unknown WebGL program link error.";
2333
- throw e.deleteProgram(n), new Error(l);
2444
+ const h = e.getProgramInfoLog(n) ?? "Unknown WebGL program link error.";
2445
+ throw e.deleteProgram(n), new Error(h);
2334
2446
  }
2335
2447
  e.deleteShader(i), e.deleteShader(s);
2336
- const o = e.getUniformLocation(n, "u_viewCenter"), a = e.getUniformLocation(n, "u_scale"), c = e.getUniformLocation(n, "u_viewport"), h = e.getUniformLocation(n, "u_pointSize");
2337
- if (!o || !a || !c || !h) throw new Error("Failed to resolve WebGL shader uniforms.");
2448
+ const o = e.getUniformLocation(n, "u_viewCenter"), a = e.getUniformLocation(n, "u_scale"), c = e.getUniformLocation(n, "u_viewport"), l = e.getUniformLocation(n, "u_pointSize");
2449
+ if (!o || !a || !c || !l) throw new Error("Failed to resolve WebGL shader uniforms.");
2338
2450
  return {
2339
2451
  program: n,
2340
2452
  aPosition: e.getAttribLocation(n, "a_position"),
@@ -2342,10 +2454,10 @@ function rr(e) {
2342
2454
  uViewCenter: o,
2343
2455
  uScale: a,
2344
2456
  uViewport: c,
2345
- uPointSize: h
2457
+ uPointSize: l
2346
2458
  };
2347
2459
  }
2348
- function Wt(e, t, r) {
2460
+ function zt(e, t, r) {
2349
2461
  const i = e.createShader(t);
2350
2462
  if (!i) throw new Error("Failed to create WebGL shader.");
2351
2463
  if (e.shaderSource(i, r), e.compileShader(i), !e.getShaderParameter(i, e.COMPILE_STATUS)) {
@@ -2354,13 +2466,13 @@ function Wt(e, t, r) {
2354
2466
  }
2355
2467
  return i;
2356
2468
  }
2357
- function ir(e, t) {
2469
+ function dr(e, t) {
2358
2470
  let r = 0;
2359
2471
  const i = (a) => a.map((c) => {
2360
- const h = Rt(e, c.positions), l = Rt(e, c.colors), f = c.positions.byteLength + c.colors.byteLength;
2472
+ const l = _t(e, c.positions), h = _t(e, c.colors), f = c.positions.byteLength + c.colors.byteLength;
2361
2473
  return r += f, {
2362
- positionBuffer: h,
2363
- colorBuffer: l,
2474
+ positionBuffer: l,
2475
+ colorBuffer: h,
2364
2476
  vertexCount: c.positions.length / 2,
2365
2477
  primitiveCount: c.primitiveCount,
2366
2478
  bounds: c.bounds,
@@ -2380,18 +2492,18 @@ function ir(e, t) {
2380
2492
  buildElapsedMs: t.buildElapsedMs
2381
2493
  };
2382
2494
  }
2383
- function Rt(e, t) {
2495
+ function _t(e, t) {
2384
2496
  const r = e.createBuffer();
2385
2497
  if (!r) throw new Error("Failed to create WebGL buffer.");
2386
2498
  return e.bindBuffer(e.ARRAY_BUFFER, r), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), r;
2387
2499
  }
2388
- function sr(e, t, r) {
2389
- const i = performance.now(), s = D(r) ? { x: (r.minX + r.maxX) / 2, y: (r.minY + r.maxY) / 2 } : { x: 0, y: 0 }, n = new nr(e, t, r, s);
2500
+ function ur(e, t, r) {
2501
+ const i = performance.now(), s = O(r) ? { x: (r.minX + r.maxX) / 2, y: (r.minY + r.maxY) / 2 } : { x: 0, y: 0 }, n = new mr(e, t, r, s);
2390
2502
  for (const a of e.entities) n.addEntityTracked(a, 0);
2391
2503
  const o = n.finalize();
2392
2504
  return o.buildElapsedMs = performance.now() - i, o;
2393
2505
  }
2394
- class nr {
2506
+ class mr {
2395
2507
  constructor(t, r, i, s) {
2396
2508
  d(this, "lineBuckets", /* @__PURE__ */ new Map());
2397
2509
  d(this, "triangleBuckets", /* @__PURE__ */ new Map());
@@ -2403,7 +2515,7 @@ class nr {
2403
2515
  d(this, "maxVerticesPerBatch");
2404
2516
  d(this, "primitiveCount", 0);
2405
2517
  this.document = t, this.opts = r, this.bounds = i, this.origin = s;
2406
- const n = D(i) ? Math.max(i.maxX - i.minX, i.maxY - i.minY, 1e-9) : 1;
2518
+ const n = O(i) ? Math.max(i.maxX - i.minX, i.maxY - i.minY, 1e-9) : 1;
2407
2519
  this.tileSize = r.enableSpatialIndex ? n / Math.max(8, r.spatialIndexCellCount) : Number.POSITIVE_INFINITY, this.maxVerticesPerBatch = Math.max(4096, Math.floor(r.maxVerticesPerBatch));
2408
2520
  }
2409
2521
  addEntityTracked(t, r) {
@@ -2411,14 +2523,14 @@ class nr {
2411
2523
  const i = String(t.type ?? "UNKNOWN").toUpperCase();
2412
2524
  this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
2413
2525
  const s = this.lookupLayer(t.layer);
2414
- if (t.isVisible === !1 || !$t(s)) {
2526
+ if (t.isVisible === !1 || !qt(s)) {
2415
2527
  this.stats.skipped++;
2416
2528
  return;
2417
2529
  }
2418
2530
  this.addEntity(t, i, r);
2419
2531
  }
2420
2532
  finalize() {
2421
- const t = ot(this.lineBuckets, this.maxVerticesPerBatch), r = ot(this.triangleBuckets, this.maxVerticesPerBatch), i = ot(this.pointBuckets, this.maxVerticesPerBatch);
2533
+ const t = ct(this.lineBuckets, this.maxVerticesPerBatch), r = ct(this.triangleBuckets, this.maxVerticesPerBatch), i = ct(this.pointBuckets, this.maxVerticesPerBatch);
2422
2534
  return this.stats.primitiveCount = this.primitiveCount, {
2423
2535
  origin: this.origin,
2424
2536
  lineBatches: t,
@@ -2472,13 +2584,13 @@ class nr {
2472
2584
  addCircleEntity(t) {
2473
2585
  const r = t.center, i = Number(t.radius);
2474
2586
  if (!m(r) || !Number.isFinite(i)) return this.markSkipped("CIRCLE");
2475
- const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n = q(r, i, 0, Math.PI * 2, !0, s);
2587
+ const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n = K(r, i, 0, Math.PI * 2, !0, s);
2476
2588
  this.addPolyline(n, !0, this.strokeBytes(t)), this.stats.drawn++;
2477
2589
  }
2478
2590
  addArcEntity(t) {
2479
2591
  const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
2480
2592
  if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
2481
- this.addPolyline(q(r, i, s, n, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t)), this.stats.drawn++;
2593
+ this.addPolyline(K(r, i, s, n, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t)), this.stats.drawn++;
2482
2594
  }
2483
2595
  addPolylineEntity(t) {
2484
2596
  const r = t.vertices ?? t.points;
@@ -2487,28 +2599,28 @@ class nr {
2487
2599
  for (let o = 0; o < n; o++) {
2488
2600
  const a = r[o], c = r[(o + 1) % r.length];
2489
2601
  if (!m(a) || !m(c)) continue;
2490
- const h = Xt(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
2491
- s.length > 0 && h.shift(), s.push(...h);
2602
+ const l = $t(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
2603
+ s.length > 0 && l.shift(), s.push(...l);
2492
2604
  }
2493
2605
  if (s.length < 2) return this.markSkipped(String(t.type));
2494
2606
  this.addPolyline(s, i, this.strokeBytes(t)), this.stats.drawn++;
2495
2607
  }
2496
2608
  addEllipseEntity(t) {
2497
2609
  if (!m(t.center) || !m(t.majorAxisEndPoint)) return this.markSkipped("ELLIPSE");
2498
- const r = K(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), i = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
2610
+ const r = J(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), i = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
2499
2611
  this.addPolyline(r, i, this.strokeBytes(t)), this.stats.drawn++;
2500
2612
  }
2501
2613
  addTextEntity(t) {
2502
- const r = t.insertionPoint ?? t.startPoint ?? t.center, i = _t(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
2614
+ const r = t.insertionPoint ?? t.startPoint ?? t.center, i = jt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
2503
2615
  if (!m(r) || !i || !Number.isFinite(s)) return this.markSkipped(String(t.type));
2504
- const n = x(r), o = Math.max(1, i.split(/\r?\n/g).reduce((c, h) => Math.max(c, h.length), 0)) * Math.abs(s) * 0.62, a = Math.max(1, i.split(/\r?\n/g).length) * Math.abs(s) * 1.22;
2616
+ const n = w(r), o = Math.max(1, i.split(/\r?\n/g).reduce((c, l) => Math.max(c, l.length), 0)) * Math.abs(s) * 0.62, a = Math.max(1, i.split(/\r?\n/g).length) * Math.abs(s) * 1.22;
2505
2617
  this.textItems.push({
2506
2618
  point: n,
2507
2619
  text: i,
2508
2620
  height: s,
2509
2621
  rotation: Number(t.rotation ?? 0),
2510
- color: F(t, this.document, this.colorOptions()),
2511
- opacity: T(Number(t.opacity ?? 1), 0, 1),
2622
+ color: D(t, this.document, this.colorOptions()),
2623
+ opacity: A(Number(t.opacity ?? 1), 0, 1),
2512
2624
  bounds: { minX: n.x - o * 0.1, minY: n.y - a, maxX: n.x + o, maxY: n.y + a }
2513
2625
  }), this.stats.drawn++;
2514
2626
  }
@@ -2520,10 +2632,10 @@ class nr {
2520
2632
  addInsertEntity(t, r) {
2521
2633
  const i = this.lookupBlock(t.blockName ?? t.name);
2522
2634
  if (i && r < this.opts.maxInsertDepth) {
2523
- const n = Q(t, i.basePoint ?? { x: 0, y: 0 });
2635
+ const n = tt(t, i.basePoint ?? { x: 0, y: 0 });
2524
2636
  for (const o of i.entities) {
2525
- const a = jt(o, t, this.document, this.colorOptions());
2526
- this.addEntityTracked(tt(a, n), r + 1);
2637
+ const a = Kt(o, t, this.document, this.colorOptions());
2638
+ this.addEntityTracked(et(a, n), r + 1);
2527
2639
  }
2528
2640
  return;
2529
2641
  }
@@ -2535,7 +2647,7 @@ class nr {
2535
2647
  addSolidEntity(t) {
2536
2648
  const r = t.vertices ?? t.points;
2537
2649
  if (!Array.isArray(r) || r.length < 3) return this.markSkipped(String(t.type));
2538
- const i = r.filter(m).map(x);
2650
+ const i = r.filter(m).map(w);
2539
2651
  if (i.length < 3) return this.markSkipped(String(t.type));
2540
2652
  const s = this.fillBytes(t) ?? this.strokeBytes(t);
2541
2653
  this.addTriangleFan(i, s), this.addPolyline(i, !0, this.strokeBytes(t)), this.stats.drawn++;
@@ -2547,7 +2659,7 @@ class nr {
2547
2659
  const i = this.strokeBytes(t), s = this.fillBytes(t);
2548
2660
  let n = !1;
2549
2661
  for (const a of r) {
2550
- const c = (o = a.commands) != null && o.length ? Dt(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(m).map(x);
2662
+ const c = (o = a.commands) != null && o.length ? Ht(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(m).map(w);
2551
2663
  c.length < 2 || (this.addPolyline(c, !0, i), s && c.length >= 3 && this.addTriangleFan(c, s), n = !0);
2552
2664
  }
2553
2665
  if (!n) return this.markSkipped("HATCH");
@@ -2557,12 +2669,12 @@ class nr {
2557
2669
  var i;
2558
2670
  const r = (i = t.fitPoints) != null && i.length ? t.fitPoints : t.controlPoints;
2559
2671
  if (!r || r.length < 2) return this.markSkipped("SPLINE");
2560
- this.addPolyline(r.filter(m).map(x), !!t.isClosed, this.strokeBytes(t)), this.stats.drawn++;
2672
+ this.addPolyline(r.filter(m).map(w), !!t.isClosed, this.strokeBytes(t)), this.stats.drawn++;
2561
2673
  }
2562
2674
  addPathEntity(t) {
2563
2675
  var s;
2564
2676
  if (!((s = t.commands) != null && s.length)) return this.markSkipped(String(t.type));
2565
- const r = Dt(t.commands, this.opts.maxCurveSegments);
2677
+ const r = Ht(t.commands, this.opts.maxCurveSegments);
2566
2678
  if (r.length < 2) return this.markSkipped(String(t.type));
2567
2679
  this.addPolyline(r, !1, this.strokeBytes(t));
2568
2680
  const i = this.fillBytes(t);
@@ -2573,15 +2685,15 @@ class nr {
2573
2685
  if (!m(r)) return this.markSkipped(String(t.type));
2574
2686
  const i = Number(t.width ?? 32), s = Number(t.height ?? 32);
2575
2687
  if (!Number.isFinite(i) || !Number.isFinite(s)) return this.markSkipped(String(t.type));
2576
- const n = x(r), o = at([n, { x: n.x + i, y: n.y - s }]);
2577
- this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color: F(t, this.document, this.colorOptions()), opacity: T(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
2688
+ const n = w(r), o = lt([n, { x: n.x + i, y: n.y - s }]);
2689
+ this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color: D(t, this.document, this.colorOptions()), opacity: A(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
2578
2690
  }
2579
2691
  addUnsupportedMarker(t) {
2580
- const r = qt(t);
2692
+ const r = te(t);
2581
2693
  r && this.addPoint(r, this.strokeBytes(t));
2582
2694
  }
2583
2695
  addPolyline(t, r, i) {
2584
- const s = t.filter(m).map(x);
2696
+ const s = t.filter(m).map(w);
2585
2697
  if (!(s.length < 2)) {
2586
2698
  for (let n = 0; n < s.length - 1; n++) this.addSegment(s[n], s[n + 1], i);
2587
2699
  r && this.addSegment(s[s.length - 1], s[0], i);
@@ -2589,24 +2701,24 @@ class nr {
2589
2701
  }
2590
2702
  addSegment(t, r, i) {
2591
2703
  if (!m(t) || !m(r) || Math.hypot(t.x - r.x, t.y - r.y) <= 1e-14) return;
2592
- const s = this.batchFor(this.lineBuckets, at([t, r]));
2593
- I(s, t, i, this.origin), I(s, r, i, this.origin), s.primitiveCount++, this.primitiveCount++;
2704
+ const s = this.batchFor(this.lineBuckets, lt([t, r]));
2705
+ T(s, t, i, this.origin), T(s, r, i, this.origin), s.primitiveCount++, this.primitiveCount++;
2594
2706
  }
2595
2707
  addPoint(t, r) {
2596
- const i = this.batchFor(this.pointBuckets, hr(t));
2597
- I(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
2708
+ const i = this.batchFor(this.pointBuckets, vr(t));
2709
+ T(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
2598
2710
  }
2599
2711
  addTriangleFan(t, r) {
2600
- const i = t.filter(m).map(x);
2712
+ const i = t.filter(m).map(w);
2601
2713
  if (i.length < 3) return;
2602
- const s = at(i), n = this.batchFor(this.triangleBuckets, s);
2714
+ const s = lt(i), n = this.batchFor(this.triangleBuckets, s);
2603
2715
  for (let o = 1; o < i.length - 1; o++)
2604
- I(n, i[0], r, this.origin), I(n, i[o], r, this.origin), I(n, i[o + 1], r, this.origin), n.primitiveCount++, this.primitiveCount++;
2716
+ T(n, i[0], r, this.origin), T(n, i[o], r, this.origin), T(n, i[o + 1], r, this.origin), n.primitiveCount++, this.primitiveCount++;
2605
2717
  }
2606
2718
  batchFor(t, r) {
2607
2719
  const i = this.bucketKey(r);
2608
2720
  let s = t.get(i);
2609
- return s || (s = or(), t.set(i, s)), v(s.bounds, { x: r.minX, y: r.minY }), v(s.bounds, { x: r.maxX, y: r.maxY }), s;
2721
+ return s || (s = pr(), t.set(i, s)), v(s.bounds, { x: r.minX, y: r.minY }), v(s.bounds, { x: r.maxX, y: r.maxY }), s;
2610
2722
  }
2611
2723
  bucketKey(t) {
2612
2724
  if (!Number.isFinite(this.tileSize)) return "all";
@@ -2614,11 +2726,11 @@ class nr {
2614
2726
  return `${s}:${n}`;
2615
2727
  }
2616
2728
  strokeBytes(t) {
2617
- return mt(F(t, this.document, this.colorOptions()), [255, 255, 255, 255], T(Number(t.opacity ?? 1), 0, 1));
2729
+ return bt(D(t, this.document, this.colorOptions()), [255, 255, 255, 255], A(Number(t.opacity ?? 1), 0, 1));
2618
2730
  }
2619
2731
  fillBytes(t) {
2620
- const r = ft(t, this.document, this.colorOptions());
2621
- return r ? mt(r, [255, 255, 255, 255], T(Number(t.opacity ?? 1), 0, 1)) : void 0;
2732
+ const r = mt(t, this.document, this.colorOptions());
2733
+ return r ? bt(r, [255, 255, 255, 255], A(Number(t.opacity ?? 1), 0, 1)) : void 0;
2622
2734
  }
2623
2735
  colorOptions() {
2624
2736
  return { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast };
@@ -2635,37 +2747,37 @@ class nr {
2635
2747
  return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((r) => r.name.toLowerCase() === t.toLowerCase());
2636
2748
  }
2637
2749
  }
2638
- function or() {
2639
- return { positions: [], colors: [], bounds: M(), primitiveCount: 0 };
2750
+ function pr() {
2751
+ return { positions: [], colors: [], bounds: N(), primitiveCount: 0 };
2640
2752
  }
2641
- function I(e, t, r, i) {
2753
+ function T(e, t, r, i) {
2642
2754
  e.positions.push(t.x - i.x, t.y - i.y), e.colors.push(r[0], r[1], r[2], r[3]);
2643
2755
  }
2644
- function ot(e, t) {
2756
+ function ct(e, t) {
2645
2757
  const r = [];
2646
2758
  for (const i of e.values()) {
2647
2759
  const s = i.positions.length / 2;
2648
- if (s <= 0 || !D(i.bounds)) continue;
2760
+ if (s <= 0 || !O(i.bounds)) continue;
2649
2761
  if (s <= t) {
2650
2762
  r.push({ positions: new Float32Array(i.positions), colors: new Uint8Array(i.colors), bounds: { ...i.bounds }, primitiveCount: i.primitiveCount });
2651
2763
  continue;
2652
2764
  }
2653
- const n = ar(i), o = Math.max(n, Math.floor(t / n) * n);
2765
+ const n = gr(i), o = Math.max(n, Math.floor(t / n) * n);
2654
2766
  for (let a = 0; a < s; a += o) {
2655
- const c = Math.min(s, a + o), h = i.positions.slice(a * 2, c * 2), l = i.colors.slice(a * 4, c * 4), f = M();
2656
- for (let u = 0; u < h.length; u += 2) v(f, { x: h[u], y: h[u + 1] });
2657
- r.push({ positions: new Float32Array(h), colors: new Uint8Array(l), bounds: { ...i.bounds }, primitiveCount: Math.floor((c - a) / n) });
2767
+ const c = Math.min(s, a + o), l = i.positions.slice(a * 2, c * 2), h = i.colors.slice(a * 4, c * 4), f = N();
2768
+ for (let u = 0; u < l.length; u += 2) v(f, { x: l[u], y: l[u + 1] });
2769
+ r.push({ positions: new Float32Array(l), colors: new Uint8Array(h), bounds: { ...i.bounds }, primitiveCount: Math.floor((c - a) / n) });
2658
2770
  }
2659
2771
  }
2660
2772
  return r;
2661
2773
  }
2662
- function ar(e) {
2774
+ function gr(e) {
2663
2775
  const t = e.positions.length / 2;
2664
2776
  return t === e.primitiveCount ? 1 : t === e.primitiveCount * 3 ? 3 : 2;
2665
2777
  }
2666
- function cr(e, t) {
2778
+ function br(e, t) {
2667
2779
  var n;
2668
- const r = M();
2780
+ const r = N();
2669
2781
  if ((n = e.pages) != null && n.length)
2670
2782
  for (const o of e.pages)
2671
2783
  v(r, { x: 0, y: 0 }), v(r, { x: o.width, y: o.height });
@@ -2673,96 +2785,96 @@ function cr(e, t) {
2673
2785
  if (o)
2674
2786
  return e.blocks[o] ?? e.blocks[o.toLowerCase()] ?? Object.values(e.blocks).find((a) => a.name.toLowerCase() === o.toLowerCase());
2675
2787
  }, s = (o, a) => {
2676
- const c = String(o.type ?? "").toUpperCase(), h = o.kind ?? R(c);
2677
- if (h === "insert") {
2678
- const l = i(o.blockName ?? o.name);
2679
- if (l && a < t.maxInsertDepth) {
2680
- const f = Q(o, l.basePoint ?? { x: 0, y: 0 });
2681
- for (const u of l.entities) s(tt(u, f), a + 1);
2788
+ const c = String(o.type ?? "").toUpperCase(), l = o.kind ?? R(c);
2789
+ if (l === "insert") {
2790
+ const h = i(o.blockName ?? o.name);
2791
+ if (h && a < t.maxInsertDepth) {
2792
+ const f = tt(o, h.basePoint ?? { x: 0, y: 0 });
2793
+ for (const u of h.entities) s(et(u, f), a + 1);
2682
2794
  return;
2683
2795
  }
2684
2796
  }
2685
- if (h === "line")
2797
+ if (l === "line")
2686
2798
  m(o.startPoint) && v(r, o.startPoint), m(o.endPoint) && v(r, o.endPoint);
2687
- else if (h === "circle" || h === "arc")
2688
- m(o.center) && Number.isFinite(o.radius) && Yt(r, o.center, Number(o.radius));
2689
- else if (h === "polyline" || h === "solid" || h === "spline")
2690
- for (const l of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(l) && v(r, l);
2691
- else if (h === "ellipse")
2692
- m(o.center) && m(o.majorAxisEndPoint) && K(o.center, o.majorAxisEndPoint, Number(o.axisRatio ?? 1), Number(o.startAngle ?? 0), Number(o.endAngle ?? Math.PI * 2), t.maxCurveSegments).forEach((l) => v(r, l));
2693
- else if (h === "path")
2694
- for (const l of o.commands ?? []) for (const f of l.points) v(r, f);
2695
- else if (h === "hatch")
2696
- for (const l of o.loops ?? []) {
2697
- for (const f of l.vertices ?? []) v(r, f);
2698
- for (const f of l.commands ?? []) for (const u of f.points) v(r, u);
2799
+ else if (l === "circle" || l === "arc")
2800
+ m(o.center) && Number.isFinite(o.radius) && Ut(r, o.center, Number(o.radius));
2801
+ else if (l === "polyline" || l === "solid" || l === "spline")
2802
+ for (const h of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(h) && v(r, h);
2803
+ else if (l === "ellipse")
2804
+ m(o.center) && m(o.majorAxisEndPoint) && J(o.center, o.majorAxisEndPoint, Number(o.axisRatio ?? 1), Number(o.startAngle ?? 0), Number(o.endAngle ?? Math.PI * 2), t.maxCurveSegments).forEach((h) => v(r, h));
2805
+ else if (l === "path")
2806
+ for (const h of o.commands ?? []) for (const f of h.points) v(r, f);
2807
+ else if (l === "hatch")
2808
+ for (const h of o.loops ?? []) {
2809
+ for (const f of h.vertices ?? []) v(r, f);
2810
+ for (const f of h.commands ?? []) for (const u of f.points) v(r, u);
2699
2811
  }
2700
2812
  else {
2701
- const l = qt(o);
2702
- l && v(r, l);
2813
+ const h = te(o);
2814
+ h && v(r, h);
2703
2815
  }
2704
2816
  };
2705
2817
  for (const o of e.entities) s(o, 0);
2706
- return Ht(r);
2818
+ return Vt(r);
2707
2819
  }
2708
- function Dt(e, t) {
2820
+ function Ht(e, t) {
2709
2821
  const r = [];
2710
2822
  let i, s;
2711
2823
  const n = (o) => {
2712
- (!r.length || Math.hypot(r[r.length - 1].x - o.x, r[r.length - 1].y - o.y) > 1e-12) && r.push(x(o)), i = x(o);
2824
+ (!r.length || Math.hypot(r[r.length - 1].x - o.x, r[r.length - 1].y - o.y) > 1e-12) && r.push(w(o)), i = w(o);
2713
2825
  };
2714
2826
  for (const o of e)
2715
2827
  if (o.cmd === "M")
2716
- i = x(o.points[0]), s = i, n(i);
2828
+ i = w(o.points[0]), s = i, n(i);
2717
2829
  else if (o.cmd === "L")
2718
2830
  n(o.points[0]);
2719
2831
  else if (o.cmd === "Q" && i && o.points.length >= 2) {
2720
- const a = i, [c, h] = o.points, l = Math.max(4, Math.min(t, 24));
2721
- for (let f = 1; f <= l; f++) {
2722
- const u = f / l, p = 1 - u;
2723
- n({ x: p * p * a.x + 2 * p * u * c.x + u * u * h.x, y: p * p * a.y + 2 * p * u * c.y + u * u * h.y });
2832
+ const a = i, [c, l] = o.points, h = Math.max(4, Math.min(t, 24));
2833
+ for (let f = 1; f <= h; f++) {
2834
+ const u = f / h, p = 1 - u;
2835
+ n({ x: p * p * a.x + 2 * p * u * c.x + u * u * l.x, y: p * p * a.y + 2 * p * u * c.y + u * u * l.y });
2724
2836
  }
2725
2837
  } else if (o.cmd === "C" && i && o.points.length >= 3) {
2726
- const a = i, [c, h, l] = o.points, f = Math.max(6, Math.min(t, 32));
2838
+ const a = i, [c, l, h] = o.points, f = Math.max(6, Math.min(t, 32));
2727
2839
  for (let u = 1; u <= f; u++) {
2728
2840
  const p = u / f, g = 1 - p;
2729
2841
  n({
2730
- x: g ** 3 * a.x + 3 * g * g * p * c.x + 3 * g * p * p * h.x + p ** 3 * l.x,
2731
- y: g ** 3 * a.y + 3 * g * g * p * c.y + 3 * g * p * p * h.y + p ** 3 * l.y
2842
+ x: g ** 3 * a.x + 3 * g * g * p * c.x + 3 * g * p * p * l.x + p ** 3 * h.x,
2843
+ y: g ** 3 * a.y + 3 * g * g * p * c.y + 3 * g * p * p * l.y + p ** 3 * h.y
2732
2844
  });
2733
2845
  }
2734
2846
  } else o.cmd === "Z" && s && n(s);
2735
2847
  return r;
2736
2848
  }
2737
- function qt(e) {
2849
+ function te(e) {
2738
2850
  for (const t of ["startPoint", "insertionPoint", "center", "point", "location"]) {
2739
2851
  const r = e[t];
2740
- if (m(r)) return x(r);
2852
+ if (m(r)) return w(r);
2741
2853
  }
2742
- if (Array.isArray(e.vertices) && m(e.vertices[0])) return x(e.vertices[0]);
2854
+ if (Array.isArray(e.vertices) && m(e.vertices[0])) return w(e.vertices[0]);
2743
2855
  if (Array.isArray(e.commands) && e.commands.length) {
2744
2856
  const t = e.commands.find((r) => r.points.length > 0);
2745
- if (t) return x(t.points[0]);
2857
+ if (t) return w(t.points[0]);
2746
2858
  }
2747
2859
  }
2748
- function at(e) {
2749
- const t = M();
2860
+ function lt(e) {
2861
+ const t = N();
2750
2862
  for (const r of e) v(t, r);
2751
2863
  return t;
2752
2864
  }
2753
- function hr(e) {
2865
+ function vr(e) {
2754
2866
  return { minX: e.x, minY: e.y, maxX: e.x, maxY: e.y };
2755
2867
  }
2756
- function ct(e, t) {
2868
+ function ht(e, t) {
2757
2869
  return e.minX <= t.maxX && e.maxX >= t.minX && e.minY <= t.maxY && e.maxY >= t.minY;
2758
2870
  }
2759
- function lr(e, t) {
2871
+ function yr(e, t) {
2760
2872
  return t.trueColorByteOrder !== void 0 && t.trueColorByteOrder !== e.trueColorByteOrder || t.contrastMode !== void 0 && t.contrastMode !== e.contrastMode || t.minColorContrast !== void 0 && t.minColorContrast !== e.minColorContrast || t.foreground !== void 0 && t.foreground !== e.foreground || t.background !== void 0 && t.background !== e.background || t.maxInsertDepth !== void 0 && t.maxInsertDepth !== e.maxInsertDepth || t.maxCurveSegments !== void 0 && t.maxCurveSegments !== e.maxCurveSegments || t.spatialIndexCellCount !== void 0 && t.spatialIndexCellCount !== e.spatialIndexCellCount || t.maxVerticesPerBatch !== void 0 && t.maxVerticesPerBatch !== e.maxVerticesPerBatch || t.enableSpatialIndex !== void 0 && t.enableSpatialIndex !== e.enableSpatialIndex;
2761
2873
  }
2762
- function fr(e, t) {
2874
+ function wr(e, t) {
2763
2875
  return { ...e.stats, renderElapsedMs: t, backend: "webgl", primitiveCount: e.primitiveCount, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: e.gpuMemoryBytes, buildElapsedMs: e.buildElapsedMs };
2764
2876
  }
2765
- function dr(e) {
2877
+ function xr(e) {
2766
2878
  return {
2767
2879
  total: e.total,
2768
2880
  drawn: e.drawn,
@@ -2778,7 +2890,7 @@ function dr(e) {
2778
2890
  buildElapsedMs: e.buildElapsedMs
2779
2891
  };
2780
2892
  }
2781
- function mt(e, t, r = 1) {
2893
+ function bt(e, t, r = 1) {
2782
2894
  const i = e.trim().toLowerCase();
2783
2895
  let s;
2784
2896
  if (/^#[0-9a-f]{3}$/i.test(i))
@@ -2788,8 +2900,8 @@ function mt(e, t, r = 1) {
2788
2900
  else {
2789
2901
  const o = i.match(/^rgba?\(([^)]+)\)$/i);
2790
2902
  if (o) {
2791
- const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((l) => l.includes("%")), h = a.map((l) => Number(l.replace("%", "")));
2792
- h.length >= 3 && h.slice(0, 3).every(Number.isFinite) && (s = [X(c ? h[0] * 2.55 : h[0]), X(c ? h[1] * 2.55 : h[1]), X(c ? h[2] * 2.55 : h[2]), X((Number.isFinite(h[3]) ? h[3] : 1) * 255)]);
2903
+ const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((h) => h.includes("%")), l = a.map((h) => Number(h.replace("%", "")));
2904
+ l.length >= 3 && l.slice(0, 3).every(Number.isFinite) && (s = [X(c ? l[0] * 2.55 : l[0]), X(c ? l[1] * 2.55 : l[1]), X(c ? l[2] * 2.55 : l[2]), X((Number.isFinite(l[3]) ? l[3] : 1) * 255)]);
2793
2905
  }
2794
2906
  }
2795
2907
  const n = s ?? t;
@@ -2798,7 +2910,7 @@ function mt(e, t, r = 1) {
2798
2910
  function X(e) {
2799
2911
  return Math.max(0, Math.min(255, Math.round(e)));
2800
2912
  }
2801
- class ur {
2913
+ class Cr {
2802
2914
  constructor(t = {}) {
2803
2915
  d(this, "canvas");
2804
2916
  d(this, "renderer");
@@ -2808,7 +2920,7 @@ class ur {
2808
2920
  d(this, "lastResult");
2809
2921
  d(this, "activeNativeLoader");
2810
2922
  var r;
2811
- if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? ze(t), t.loaders) for (const i of t.loaders) this.registry.register(i);
2923
+ if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? Ge(t), t.loaders) for (const i of t.loaders) this.registry.register(i);
2812
2924
  if (this.canvas = t.canvas ?? document.createElement("canvas"), this.canvas.classList.add("cad-viewer-canvas"), t.container)
2813
2925
  t.container.classList.add("cad-viewer-container"), t.canvas || (this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", t.container.appendChild(this.canvas)), this.nativeHost = t.nativeHost ?? document.createElement("div"), this.nativeHost.classList.add("cad-viewer-native-host"), t.nativeHost || t.container.appendChild(this.nativeHost);
2814
2926
  else if (t.nativeHost)
@@ -2818,7 +2930,7 @@ class ur {
2818
2930
  const i = document.createElement("div");
2819
2931
  i.classList.add("cad-viewer-native-host"), t.canvas.parentElement.appendChild(i), this.nativeHost = i;
2820
2932
  }
2821
- this.renderer = pr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (i) => {
2933
+ this.renderer = kr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (i) => {
2822
2934
  var s, n;
2823
2935
  return (n = (s = this.options).onRenderStats) == null ? void 0 : n.call(s, i);
2824
2936
  }, this.renderer.onViewChange = (i) => {
@@ -2851,7 +2963,7 @@ class ur {
2851
2963
  elapsedMs: 0,
2852
2964
  format: t.format,
2853
2965
  warnings: t.warnings,
2854
- summary: j(t),
2966
+ summary: G(t),
2855
2967
  fileName: r
2856
2968
  };
2857
2969
  return this.renderer.setDocument(t), this.options.autoFit || this.renderer.render(), this.lastResult = i, (n = (s = this.options).onLoad) == null || n.call(s, i), i;
@@ -2913,14 +3025,14 @@ class ur {
2913
3025
  var s, n;
2914
3026
  try {
2915
3027
  const o = this.mergeLoadOptions(r);
2916
- ht(o.signal);
3028
+ ft(o.signal);
2917
3029
  const a = await this.registry.detect(t), c = { ...t, buffer: a.bytes };
2918
- if (Ye(a.loader))
3030
+ if (Ze(a.loader))
2919
3031
  return await this.applyNativeLoadResult(a.loader, c, o, i);
2920
- const h = await a.loader.load(c, o);
2921
- return this.applyLoadResult(h, i);
3032
+ const l = await a.loader.load(c, o);
3033
+ return this.applyLoadResult(l, i);
2922
3034
  } catch (o) {
2923
- const a = mr(o);
3035
+ const a = Pr(o);
2924
3036
  throw (n = (s = this.options).onError) == null || n.call(s, a), a;
2925
3037
  }
2926
3038
  }
@@ -2930,7 +3042,7 @@ class ur {
2930
3042
  const i = {
2931
3043
  ...t,
2932
3044
  fileName: r,
2933
- summary: j(t.document)
3045
+ summary: G(t.document)
2934
3046
  };
2935
3047
  return this.lastResult = i, (a = (o = this.options).onLoad) == null || a.call(o, i), i;
2936
3048
  }
@@ -2938,16 +3050,16 @@ class ur {
2938
3050
  var n, o, a;
2939
3051
  if (!this.nativeHost)
2940
3052
  throw new Error("Native DWF rendering requires CadViewerOptions.container, nativeHost, or a canvas parent element.");
2941
- ht(i.signal), this.renderer.clear(), (n = this.activeNativeLoader) == null || n.unmount(), this.activeNativeLoader = t, this.canvas.style.display = "none", this.nativeHost.classList.add("is-active");
3053
+ ft(i.signal), this.renderer.clear(), (n = this.activeNativeLoader) == null || n.unmount(), this.activeNativeLoader = t, this.canvas.style.display = "none", this.nativeHost.classList.add("is-active");
2942
3054
  try {
2943
3055
  const c = await t.mount(r, this.nativeHost, i);
2944
- ht(i.signal);
2945
- const h = {
3056
+ ft(i.signal);
3057
+ const l = {
2946
3058
  ...c,
2947
3059
  fileName: s,
2948
- summary: j(c.document)
3060
+ summary: G(c.document)
2949
3061
  };
2950
- return this.lastResult = h, this.emitNativeRenderStats(c), (a = (o = this.options).onLoad) == null || a.call(o, h), h;
3062
+ return this.lastResult = l, this.emitNativeRenderStats(c), (a = (o = this.options).onLoad) == null || a.call(o, l), l;
2951
3063
  } catch (c) {
2952
3064
  throw this.deactivateNativeRenderer(), c;
2953
3065
  }
@@ -2961,13 +3073,13 @@ class ur {
2961
3073
  (r = this.activeNativeLoader) == null || r.unmount(), this.activeNativeLoader = void 0, this.nativeHost && (this.nativeHost.classList.remove("is-active"), this.nativeHost.replaceChildren()), this.canvas.style.display = "";
2962
3074
  }
2963
3075
  emitNativeRenderStats(t) {
2964
- var o, a, c, h;
3076
+ var o, a, c, l;
2965
3077
  const r = t.document.metadata, i = Number(((o = r.nativeRenderStats) == null ? void 0 : o.commands) ?? t.document.entities.length ?? 0), n = String(((a = r.nativeRenderStats) == null ? void 0 : a.backend) ?? "webgl").includes("webgl") ? "webgl" : "canvas2d";
2966
- (h = (c = this.options).onRenderStats) == null || h.call(c, {
3078
+ (l = (c = this.options).onRenderStats) == null || l.call(c, {
2967
3079
  total: i,
2968
3080
  drawn: i,
2969
3081
  skipped: 0,
2970
- byType: j(t.document).byType,
3082
+ byType: G(t.document).byType,
2971
3083
  unsupported: {},
2972
3084
  renderElapsedMs: t.elapsedMs,
2973
3085
  backend: n,
@@ -2990,48 +3102,48 @@ class ur {
2990
3102
  };
2991
3103
  }
2992
3104
  }
2993
- function vr(e = {}) {
2994
- return new ur(e);
3105
+ function Mr(e = {}) {
3106
+ return new Cr(e);
2995
3107
  }
2996
- function mr(e) {
3108
+ function Pr(e) {
2997
3109
  return e instanceof Error ? e : new Error(String(e));
2998
3110
  }
2999
- function ht(e) {
3111
+ function ft(e) {
3000
3112
  if (e != null && e.aborted)
3001
3113
  throw new DOMException("Loading cancelled.", "AbortError");
3002
3114
  }
3003
- function pr(e, t, r = {}) {
3004
- if (e === "canvas2d") return new Bt(t, r);
3005
- if (e === "webgl") return new Ft(t, r);
3006
- if (Zt())
3115
+ function kr(e, t, r = {}) {
3116
+ if (e === "canvas2d") return new Rt(t, r);
3117
+ if (e === "webgl") return new Ot(t, r);
3118
+ if (Qt())
3007
3119
  try {
3008
- return new Ft(t, r);
3120
+ return new Ot(t, r);
3009
3121
  } catch {
3010
3122
  }
3011
- return new Bt(t, r);
3123
+ return new Rt(t, r);
3012
3124
  }
3013
3125
  export {
3014
- Bt as CadCanvasRenderer,
3015
- re as CadLoaderRegistry,
3016
- ur as CadViewer,
3017
- Ft as CadWebGLRenderer,
3018
- Ee as DwfLoader,
3019
- ce as DwgLoader,
3020
- ie as DwgWorkerClient,
3021
- me as DxfLoader,
3022
- N as colorFromAci,
3023
- U as colorFromTrueColor,
3024
- zt as createCadDocument,
3025
- vr as createCadViewer,
3026
- ze as createDefaultLoaderRegistry,
3027
- A as detectCadFormat,
3126
+ Rt as CadCanvasRenderer,
3127
+ oe as CadLoaderRegistry,
3128
+ Cr as CadViewer,
3129
+ Ot as CadWebGLRenderer,
3130
+ Re as DwfLoader,
3131
+ de as DwgLoader,
3132
+ ae as DwgWorkerClient,
3133
+ ve as DxfLoader,
3134
+ E as colorFromAci,
3135
+ V as colorFromTrueColor,
3136
+ Xt as createCadDocument,
3137
+ Mr as createCadViewer,
3138
+ Ge as createDefaultLoaderRegistry,
3139
+ B as detectCadFormat,
3028
3140
  R as inferEntityKind,
3029
- Ye as isCadNativeRenderableLoader,
3030
- Zt as isWebGLAvailable,
3031
- fe as normalizeCadEntity,
3032
- _ as readInputBytes,
3033
- F as resolveCadColor,
3034
- j as summarizeCadDocument,
3035
- lt as supportsDwgWorker
3141
+ Ze as isCadNativeRenderableLoader,
3142
+ Qt as isWebGLAvailable,
3143
+ pe as normalizeCadEntity,
3144
+ U as readInputBytes,
3145
+ D as resolveCadColor,
3146
+ G as summarizeCadDocument,
3147
+ dt as supportsDwgWorker
3036
3148
  };
3037
3149
  //# sourceMappingURL=cad-viewer.es.js.map