@solid-labs/fab-one-widget 1.0.0 → 1.0.2

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,16 +1,16 @@
1
- import { jsxs as k, jsx as i, Fragment as Oe } from "react/jsx-runtime";
2
- import { createContext as no, Component as oo, useCallback as te, useMemo as H, useState as W, memo as ro, useEffect as U, useRef as le, forwardRef as io, createElement as nn } from "react";
3
- import { useFrame as fn, useThree as un, Canvas as so } from "@react-three/fiber";
4
- import { Html as Xe, Line as fe, OrbitControls as pn } from "@react-three/drei";
1
+ import { jsxs as k, jsx as i, Fragment as He } from "react/jsx-runtime";
2
+ import { createContext as oo, Component as ro, useCallback as J, useMemo as H, useState as B, memo as io, useEffect as Q, useRef as le, forwardRef as so, createElement as sn } from "react";
3
+ import { useFrame as hn, useThree as gn, Canvas as lo } from "@react-three/fiber";
4
+ import { Html as Ze, Line as de, OrbitControls as mn } from "@react-three/drei";
5
5
  import * as O from "three";
6
- import { Plane as ht, Vector3 as C, Box3 as hn, Line3 as gn, Raycaster as lo } from "three";
7
- import { create as ao } from "zustand";
8
- import { OBJLoader as mn } from "three/examples/jsm/loaders/OBJLoader.js";
9
- import { STLLoader as co } from "three/examples/jsm/loaders/STLLoader.js";
10
- import { MeshBVH as gt } from "three-mesh-bvh";
11
- let kr, ft, gr, An;
6
+ import { Plane as yt, Vector3 as C, Box3 as xn, Line3 as bn, Raycaster as ao } from "three";
7
+ import { create as co } from "zustand";
8
+ import { OBJLoader as yn } from "three/examples/jsm/loaders/OBJLoader.js";
9
+ import { STLLoader as fo } from "three/examples/jsm/loaders/STLLoader.js";
10
+ import { MeshBVH as wt } from "three-mesh-bvh";
11
+ let Ar, mt, mr, Ln;
12
12
  let __tla = (async () => {
13
- const fo = {
13
+ const uo = {
14
14
  showDragDrop: true,
15
15
  showStartOver: true,
16
16
  showDebug: true,
@@ -19,7 +19,7 @@ let __tla = (async () => {
19
19
  showNavigation: true,
20
20
  showToolbar: false,
21
21
  showSaveButton: true
22
- }, uo = {
22
+ }, po = {
23
23
  showDragDrop: false,
24
24
  showStartOver: false,
25
25
  showDebug: false,
@@ -28,7 +28,7 @@ let __tla = (async () => {
28
28
  showNavigation: false,
29
29
  showToolbar: false,
30
30
  showSaveButton: false
31
- }, po = no(fo), Et = ao((e, r) => ({
31
+ }, ho = oo(uo), Ht = co((e, r) => ({
32
32
  landmarkPoints: [],
33
33
  isAligned: false,
34
34
  isCut: false,
@@ -64,13 +64,13 @@ let __tla = (async () => {
64
64
  isAligned: false,
65
65
  isCut: false
66
66
  })
67
- })), ho = 0.45, mt = 3, Bt = 1e-3, ut = 25.4, go = [
67
+ })), go = 0.45, St = 3, $t = 1e-3, xt = 25.4, mo = [
68
68
  0.25,
69
69
  -0.25,
70
70
  0.5,
71
71
  -0.5
72
72
  ];
73
- function mo(e) {
73
+ function xo(e) {
74
74
  var _a;
75
75
  const r = e.match(/^v\s+\S+\s+\S+\s+\S+(.*)$/m);
76
76
  if (!r || !((_a = r[1]) == null ? void 0 : _a.trim().includes(" "))) return null;
@@ -90,68 +90,68 @@ let __tla = (async () => {
90
90
  colors: new Float32Array(l)
91
91
  } : null;
92
92
  }
93
- function xo(e, r, t, o) {
93
+ function bo(e, r, t, o) {
94
94
  const l = e.getAttribute("position"), s = l.count, c = new Float32Array(s * 3), a = r.length / 3;
95
95
  let n = 1 / 0, m = 1 / 0, d = 1 / 0, f = -1 / 0, u = -1 / 0, x = -1 / 0;
96
96
  for (let _ = 0; _ < a; _++) {
97
- const E = r[_ * 3] * o, V = r[_ * 3 + 1] * o, N = r[_ * 3 + 2] * o;
98
- E < n && (n = E), E > f && (f = E), V < m && (m = V), V > u && (u = V), N < d && (d = N), N > x && (x = N);
97
+ const E = r[_ * 3] * o, V = r[_ * 3 + 1] * o, Y = r[_ * 3 + 2] * o;
98
+ E < n && (n = E), E > f && (f = E), V < m && (m = V), V > u && (u = V), Y < d && (d = Y), Y > x && (x = Y);
99
99
  }
100
- const S = (n + f) * 0.5, p = (m + u) * 0.5, g = (d + x) * 0.5, b = f - n + 1e-6, A = u - m + 1e-6, L = x - d + 1e-6, z = b * 0.5, P = A * 0.5, y = L * 0.5, M = Math.min(128, Math.max(16, Math.round(Math.cbrt(a)))), h = b / M, v = A / M, F = L / M, I = /* @__PURE__ */ new Map();
100
+ const S = (n + f) * 0.5, p = (m + u) * 0.5, g = (d + x) * 0.5, b = f - n + 1e-6, A = u - m + 1e-6, L = x - d + 1e-6, z = b * 0.5, P = A * 0.5, w = L * 0.5, M = Math.min(128, Math.max(16, Math.round(Math.cbrt(a)))), h = b / M, v = A / M, F = L / M, I = /* @__PURE__ */ new Map();
101
101
  for (let _ = 0; _ < a; _++) {
102
- const E = r[_ * 3] * o - S, V = r[_ * 3 + 1] * o - p, N = r[_ * 3 + 2] * o - g, J = Math.min(M - 1, Math.max(0, Math.floor((E + z) / h))), ye = Math.min(M - 1, Math.max(0, Math.floor((V + P) / v))), ae = Math.min(M - 1, Math.max(0, Math.floor((N + y) / F))), ue = J * M * M + ye * M + ae;
103
- let ie = I.get(ue);
104
- ie || (ie = [], I.set(ue, ie)), ie.push(_);
102
+ const E = r[_ * 3] * o - S, V = r[_ * 3 + 1] * o - p, Y = r[_ * 3 + 2] * o - g, q = Math.min(M - 1, Math.max(0, Math.floor((E + z) / h))), ye = Math.min(M - 1, Math.max(0, Math.floor((V + P) / v))), ae = Math.min(M - 1, Math.max(0, Math.floor((Y + w) / F))), fe = q * M * M + ye * M + ae;
103
+ let ie = I.get(fe);
104
+ ie || (ie = [], I.set(fe, ie)), ie.push(_);
105
105
  }
106
106
  for (let _ = 0; _ < s; _++) {
107
- const E = l.getX(_), V = l.getY(_), N = l.getZ(_), J = Math.min(M - 1, Math.max(0, Math.floor((E + z) / h))), ye = Math.min(M - 1, Math.max(0, Math.floor((V + P) / v))), ae = Math.min(M - 1, Math.max(0, Math.floor((N + y) / F)));
108
- let ue = 1 / 0, ie = 0;
109
- for (let Q = 0; Q <= M && ue > 0; Q++) {
110
- for (let Y = -Q; Y <= Q; Y++) for (let he = -Q; he <= Q; he++) for (let Z = -Q; Z <= Q; Z++) {
111
- if (Q > 0 && Math.abs(Y) < Q && Math.abs(he) < Q && Math.abs(Z) < Q) continue;
112
- const ge = J + Y, me = ye + he, pe = ae + Z;
113
- if (ge < 0 || ge >= M || me < 0 || me >= M || pe < 0 || pe >= M) continue;
114
- const $ = I.get(ge * M * M + me * M + pe);
107
+ const E = l.getX(_), V = l.getY(_), Y = l.getZ(_), q = Math.min(M - 1, Math.max(0, Math.floor((E + z) / h))), ye = Math.min(M - 1, Math.max(0, Math.floor((V + P) / v))), ae = Math.min(M - 1, Math.max(0, Math.floor((Y + w) / F)));
108
+ let fe = 1 / 0, ie = 0;
109
+ for (let ee = 0; ee <= M && fe > 0; ee++) {
110
+ for (let X = -ee; X <= ee; X++) for (let ue = -ee; ue <= ee; ue++) for (let Z = -ee; Z <= ee; Z++) {
111
+ if (ee > 0 && Math.abs(X) < ee && Math.abs(ue) < ee && Math.abs(Z) < ee) continue;
112
+ const pe = q + X, me = ye + ue, he = ae + Z;
113
+ if (pe < 0 || pe >= M || me < 0 || me >= M || he < 0 || he >= M) continue;
114
+ const $ = I.get(pe * M * M + me * M + he);
115
115
  if ($) for (const ne of $) {
116
- const xe = r[ne * 3] * o - S, Me = r[ne * 3 + 1] * o - p, we = r[ne * 3 + 2] * o - g, re = (E - xe) ** 2 + (V - Me) ** 2 + (N - we) ** 2;
117
- re < ue && (ue = re, ie = ne);
116
+ const xe = r[ne * 3] * o - S, Se = r[ne * 3 + 1] * o - p, we = r[ne * 3 + 2] * o - g, re = (E - xe) ** 2 + (V - Se) ** 2 + (Y - we) ** 2;
117
+ re < fe && (fe = re, ie = ne);
118
118
  }
119
119
  }
120
- if (ue < 1 / 0) break;
120
+ if (fe < 1 / 0) break;
121
121
  }
122
122
  c[_ * 3] = t[ie * 3], c[_ * 3 + 1] = t[ie * 3 + 1], c[_ * 3 + 2] = t[ie * 3 + 2];
123
123
  }
124
124
  e.setAttribute("color", new O.Float32BufferAttribute(c, 3));
125
125
  }
126
- const on = {
126
+ const ln = {
127
127
  debug: 0,
128
128
  info: 1,
129
129
  warn: 2,
130
130
  error: 3
131
131
  };
132
- let xn = "warn", bn = null;
133
- const de = {
132
+ let wn = "warn", Sn = null;
133
+ const ce = {
134
134
  setLevel(e) {
135
- xn = e;
135
+ wn = e;
136
136
  },
137
137
  setHandler(e) {
138
- bn = e;
138
+ Sn = e;
139
139
  },
140
140
  debug(e, r, t) {
141
- ct("debug", e, r, t);
141
+ ht("debug", e, r, t);
142
142
  },
143
143
  info(e, r, t) {
144
- ct("info", e, r, t);
144
+ ht("info", e, r, t);
145
145
  },
146
146
  warn(e, r, t) {
147
- ct("warn", e, r, t);
147
+ ht("warn", e, r, t);
148
148
  },
149
149
  error(e, r, t) {
150
- ct("error", e, r, t);
150
+ ht("error", e, r, t);
151
151
  }
152
152
  };
153
- function ct(e, r, t, o) {
154
- if (on[e] < on[xn]) return;
153
+ function ht(e, r, t, o) {
154
+ if (ln[e] < ln[wn]) return;
155
155
  const l = `[${r}]`, s = o !== void 0 ? [
156
156
  l,
157
157
  t,
@@ -174,9 +174,9 @@ let __tla = (async () => {
174
174
  console.error(...s);
175
175
  break;
176
176
  }
177
- bn == null ? void 0 : bn(e, r, t, o);
177
+ Sn == null ? void 0 : Sn(e, r, t, o);
178
178
  }
179
- function pt(e) {
179
+ function bt(e) {
180
180
  const r = e.getAttribute("position"), t = new Float32Array(r.array), o = e.getIndex();
181
181
  if (o) return {
182
182
  positions: t,
@@ -189,32 +189,32 @@ let __tla = (async () => {
189
189
  indices: s
190
190
  };
191
191
  }
192
- function yn(e, r) {
192
+ function vn(e, r) {
193
193
  const t = new O.BufferGeometry();
194
194
  return t.setAttribute("position", new O.Float32BufferAttribute(e, 3)), t.setIndex(new O.BufferAttribute(r, 1)), t.computeVertexNormals(), t;
195
195
  }
196
- async function bo(e, r, t) {
196
+ async function yo(e, r, t) {
197
197
  try {
198
- const o = mo(e);
198
+ const o = xo(e);
199
199
  t == null ? void 0 : t("Parsing mesh...");
200
- const s = new mn().parse(e);
200
+ const s = new yn().parse(e);
201
201
  let c = null;
202
202
  if (s.traverse((b) => {
203
203
  b.isMesh && !c && (c = b.geometry);
204
204
  }), !c) return null;
205
- const { positions: a, indices: n } = pt(c);
206
- if (a.length < 9 || n.length < 3) return de.warn("wasm", `Mesh too small: positions=${a.length} indices=${n.length}`), null;
207
- for (let b = 0; b < Math.min(a.length, 300); b++) if (!isFinite(a[b])) return de.error("wasm", `Invalid position data: NaN/Infinity at index ${b}`), null;
205
+ const { positions: a, indices: n } = bt(c);
206
+ if (a.length < 9 || n.length < 3) return ce.warn("wasm", `Mesh too small: positions=${a.length} indices=${n.length}`), null;
207
+ for (let b = 0; b < Math.min(a.length, 300); b++) if (!isFinite(a[b])) return ce.error("wasm", `Invalid position data: NaN/Infinity at index ${b}`), null;
208
208
  const m = a.length / 3;
209
- for (let b = 0; b < Math.min(n.length, 300); b++) if (n[b] >= m) return de.error("wasm", `Out-of-bounds index: ${n[b]} >= ${m}`), null;
209
+ for (let b = 0; b < Math.min(n.length, 300); b++) if (n[b] >= m) return ce.error("wasm", `Out-of-bounds index: ${n[b]} >= ${m}`), null;
210
210
  t == null ? void 0 : t("Processing mesh (WASM)...");
211
211
  const d = r.preprocess_mesh(a, n, 10, 1e-4, 500), f = d.positions(), u = d.indices(), x = d.unit_converted(), S = d.detected_unit(), p = d.log();
212
- if (de.debug("wasm", "preprocess result", p), f.length === 0) return null;
212
+ if (ce.debug("wasm", "preprocess result", p), f.length === 0) return null;
213
213
  t == null ? void 0 : t("Building geometry...");
214
- const g = yn(f, u);
214
+ const g = vn(f, u);
215
215
  if (o) {
216
216
  const b = x ? 1e3 : 1;
217
- xo(g, o.positions, o.colors, b);
217
+ bo(g, o.positions, o.colors, b);
218
218
  }
219
219
  return {
220
220
  geometry: g,
@@ -223,18 +223,18 @@ let __tla = (async () => {
223
223
  detectedUnit: S
224
224
  };
225
225
  } catch (o) {
226
- return de.error("wasm", "Processing failed", o), null;
226
+ return ce.error("wasm", "Processing failed", o), null;
227
227
  }
228
228
  }
229
- function yo(e) {
230
- const t = new mn().parse(e);
229
+ function wo(e) {
230
+ const t = new yn().parse(e);
231
231
  let o = null;
232
232
  return t.traverse((l) => {
233
233
  l.isMesh && !o && (o = l.geometry);
234
234
  }), o;
235
235
  }
236
- async function Rt(e) {
237
- const r = await e.arrayBuffer(), l = new co().parse(r).getAttribute("position");
236
+ async function Tt(e) {
237
+ const r = await e.arrayBuffer(), l = new fo().parse(r).getAttribute("position");
238
238
  if (!l || l.count === 0) throw new Error("Empty STL geometry");
239
239
  const s = [];
240
240
  for (let c = 0; c < l.count; c++) s.push(`v ${l.getX(c)} ${l.getY(c)} ${l.getZ(c)}`);
@@ -242,25 +242,25 @@ let __tla = (async () => {
242
242
  return s.join(`
243
243
  `);
244
244
  }
245
- function wo(e, r) {
245
+ function So(e, r) {
246
246
  const t = 1 / r;
247
247
  return `${Math.round(e.x * t)}_${Math.round(e.y * t)}_${Math.round(e.z * t)}`;
248
248
  }
249
- function So(e, r) {
249
+ function vo(e, r) {
250
250
  if (!e.length) return [];
251
251
  const t = [];
252
252
  for (const o of e) (t.length === 0 || t[t.length - 1].distanceTo(o) > r) && t.push(o.clone());
253
253
  return t.length > 2 && t[0].distanceTo(t[t.length - 1]) > r && t.push(t[0].clone()), t;
254
254
  }
255
- function Ke(e) {
255
+ function Ue(e) {
256
256
  let r = 0;
257
257
  for (let t = 0; t < e.length - 1; t++) r += e[t].distanceTo(e[t + 1]);
258
258
  return r;
259
259
  }
260
- function wn(e, r = 1e-3, t = false) {
260
+ function Cn(e, r = 1e-3, t = false) {
261
261
  if (!e.length) return [];
262
262
  const o = /* @__PURE__ */ new Map(), l = (f) => {
263
- const u = wo(f, r);
263
+ const u = So(f, r);
264
264
  let x = o.get(u);
265
265
  return x || (x = f.clone(), o.set(u, x)), x;
266
266
  }, s = e.map((f) => ({
@@ -285,13 +285,13 @@ let __tla = (async () => {
285
285
  s.splice(p, 1), x = true;
286
286
  }
287
287
  }
288
- const S = So(u, r);
288
+ const S = vo(u, r);
289
289
  S.length > 1 && c.push(S);
290
290
  }
291
291
  if (!c.length) return [];
292
292
  if (t) {
293
- c.sort((x, S) => Ke(S) - Ke(x));
294
- const f = Ke(c[0]), u = c.filter((x) => Ke(x) >= f * 0.3);
293
+ c.sort((x, S) => Ue(S) - Ue(x));
294
+ const f = Ue(c[0]), u = c.filter((x) => Ue(x) >= f * 0.3);
295
295
  return u[u.length - 1] ?? c[0];
296
296
  }
297
297
  const a = c.filter((f) => f.length >= 3 && f[0].distanceTo(f[f.length - 1]) < r * 10), n = a.length > 0 ? a : c;
@@ -306,8 +306,8 @@ let __tla = (async () => {
306
306
  }
307
307
  return m;
308
308
  }
309
- function rn(e, r, t, o = false) {
310
- const l = new ht(new C(0, 1, 0), -t), s = [], c = new hn();
309
+ function an(e, r, t, o = false) {
310
+ const l = new yt(new C(0, 1, 0), -t), s = [], c = new xn();
311
311
  c.setFromBufferAttribute(r.getAttribute("position"));
312
312
  const a = {
313
313
  linePoints: [],
@@ -315,7 +315,7 @@ let __tla = (async () => {
315
315
  rightmostPoint: new C(0, t, 0)
316
316
  };
317
317
  if (!l.intersectsBox(c)) return a;
318
- const n = new gn(), m = new C();
318
+ const n = new bn(), m = new C();
319
319
  e.shapecast({
320
320
  intersectsBounds: (p) => l.intersectsBox(p),
321
321
  intersectsTriangle: (p) => {
@@ -326,12 +326,12 @@ let __tla = (async () => {
326
326
  });
327
327
  }
328
328
  });
329
- const d = wn(s, Bt, o);
329
+ const d = Cn(s, $t, o);
330
330
  if (d.length < 2) return a;
331
- const f = Ke(d);
331
+ const f = Ue(d);
332
332
  let u = -1 / 0, x = new C(0, t, 0);
333
333
  for (const p of d) p.x > u && (u = p.x, x = p.clone());
334
- const S = d.length > 2 && d[0].distanceTo(d[d.length - 1]) < Bt * 10;
334
+ const S = d.length > 2 && d[0].distanceTo(d[d.length - 1]) < $t * 10;
335
335
  return {
336
336
  linePoints: d,
337
337
  lineLength: f,
@@ -339,22 +339,22 @@ let __tla = (async () => {
339
339
  isClosed: S
340
340
  };
341
341
  }
342
- function Ye(e, r, t, o = false) {
343
- const l = rn(e, r, t, o);
342
+ function Ge(e, r, t, o = false) {
343
+ const l = an(e, r, t, o);
344
344
  if (l.isClosed && l.linePoints.length >= 3) return l;
345
- de.debug("slice", `y=${t.toFixed(2)} failed (pts=${l.linePoints.length}, closed=${l.isClosed}), retrying...`);
345
+ ce.debug("slice", `y=${t.toFixed(2)} failed (pts=${l.linePoints.length}, closed=${l.isClosed}), retrying...`);
346
346
  let s = l;
347
- for (const c of go) {
348
- const a = rn(e, r, t + c, o);
349
- if (a.isClosed && a.linePoints.length >= 3) return de.debug("slice", `y=${t.toFixed(2)} recovered with offset ${c > 0 ? "+" : ""}${c}mm (pts=${a.linePoints.length}, len=${a.lineLength.toFixed(1)}mm)`), a;
347
+ for (const c of mo) {
348
+ const a = an(e, r, t + c, o);
349
+ if (a.isClosed && a.linePoints.length >= 3) return ce.debug("slice", `y=${t.toFixed(2)} recovered with offset ${c > 0 ? "+" : ""}${c}mm (pts=${a.linePoints.length}, len=${a.lineLength.toFixed(1)}mm)`), a;
350
350
  a.linePoints.length > s.linePoints.length && (s = a);
351
351
  }
352
- return de.warn("slice", `y=${t.toFixed(2)} all retries exhausted (pts=${s.linePoints.length}, closed=${s.isClosed})`), s;
352
+ return ce.warn("slice", `y=${t.toFixed(2)} all retries exhausted (pts=${s.linePoints.length}, closed=${s.isClosed})`), s;
353
353
  }
354
- function vo(e, r, t, o) {
355
- const l = new ht().setFromNormalAndCoplanarPoint(o.clone().normalize(), t), s = new hn();
354
+ function Co(e, r, t, o) {
355
+ const l = new yt().setFromNormalAndCoplanarPoint(o.clone().normalize(), t), s = new xn();
356
356
  if (s.setFromBufferAttribute(r.getAttribute("position")), !l.intersectsBox(s)) return 0;
357
- const c = [], a = new gn(), n = new C();
357
+ const c = [], a = new bn(), n = new C();
358
358
  e.shapecast({
359
359
  intersectsBounds: (d) => l.intersectsBox(d),
360
360
  intersectsTriangle: (d) => {
@@ -365,15 +365,15 @@ let __tla = (async () => {
365
365
  });
366
366
  }
367
367
  });
368
- const m = wn(c, Bt);
369
- return Ke(m);
368
+ const m = Cn(c, $t);
369
+ return Ue(m);
370
370
  }
371
- function Sn(e) {
372
- return new gt(e, {
373
- maxLeafTris: mt
371
+ function Mn(e) {
372
+ return new wt(e, {
373
+ maxLeafTris: St
374
374
  });
375
375
  }
376
- function Co(e, r, t, o) {
376
+ function Mo(e, r, t, o) {
377
377
  const l = e.getIndex(), s = l ? l.count / 3 : 0;
378
378
  if (s < 10) return {
379
379
  valid: false,
@@ -388,9 +388,9 @@ let __tla = (async () => {
388
388
  valid: false,
389
389
  reason: `Height too large (${c.toFixed(1)}mm > 1000mm)`
390
390
  };
391
- const a = new gt(e, {
392
- maxLeafTris: mt
393
- }), n = Ye(a, e, r);
391
+ const a = new wt(e, {
392
+ maxLeafTris: St
393
+ }), n = Ge(a, e, r);
394
394
  if (n.lineLength === 0) return {
395
395
  valid: false,
396
396
  reason: "No circumference at green point \u2014 mesh may be empty at that height"
@@ -400,7 +400,7 @@ let __tla = (async () => {
400
400
  valid: true,
401
401
  reason: ""
402
402
  };
403
- const d = Ye(a, e, m);
403
+ const d = Ge(a, e, m);
404
404
  if (n.lineLength > 0 && d.lineLength > 0) {
405
405
  const u = n.lineLength / d.lineLength;
406
406
  if (u < 0.5) return {
@@ -410,7 +410,7 @@ let __tla = (async () => {
410
410
  }
411
411
  const f = r - o * 2;
412
412
  if (f > t) {
413
- const u = Ye(a, e, f);
413
+ const u = Ge(a, e, f);
414
414
  if (d.lineLength > 0 && u.lineLength > 0) {
415
415
  const x = d.lineLength / u.lineLength;
416
416
  if (x < 0.5) return {
@@ -424,8 +424,8 @@ let __tla = (async () => {
424
424
  reason: ""
425
425
  };
426
426
  }
427
- const Pe = "pipeline";
428
- function Mo(e, r, t, o) {
427
+ const Le = "pipeline";
428
+ function zo(e, r, t, o) {
429
429
  var _a, _b, _c, _d;
430
430
  const l = e.geometry.clone(), s = r.map((a) => ({
431
431
  ...a
@@ -434,19 +434,19 @@ let __tla = (async () => {
434
434
  let a = e.geometry, n = s.map(($) => new C($.position.x, $.position.y, $.position.z));
435
435
  const m = n[0], d = n[1];
436
436
  if (!c) {
437
- o.onStatus("Aligning mesh (JS fallback)..."), de.warn(Pe, "WASM not available, using JS fallback alignment");
438
- const $ = new C(0, 1, 0), ne = new C().subVectors(d, m).normalize(), xe = ne.dot($), Me = new C().crossVectors(ne, $);
439
- if (Me.length() > 1e-4) {
440
- Me.normalize();
441
- const X = new O.Quaternion().setFromAxisAngle(Me, Math.acos(Math.min(1, Math.max(-1, xe))));
442
- a.applyMatrix4(new O.Matrix4().makeRotationFromQuaternion(X)), n = n.map((Le) => Le.clone().applyQuaternion(X));
437
+ o.onStatus("Aligning mesh (JS fallback)..."), ce.warn(Le, "WASM not available, using JS fallback alignment");
438
+ const $ = new C(0, 1, 0), ne = new C().subVectors(d, m).normalize(), xe = ne.dot($), Se = new C().crossVectors(ne, $);
439
+ if (Se.length() > 1e-4) {
440
+ Se.normalize();
441
+ const N = new O.Quaternion().setFromAxisAngle(Se, Math.acos(Math.min(1, Math.max(-1, xe))));
442
+ a.applyMatrix4(new O.Matrix4().makeRotationFromQuaternion(N)), n = n.map((Ie) => Ie.clone().applyQuaternion(N));
443
443
  }
444
444
  if (n[0].y > n[1].y) {
445
- const X = new O.Quaternion().setFromAxisAngle(new C(1, 0, 0), Math.PI);
446
- a.applyMatrix4(new O.Matrix4().makeRotationFromQuaternion(X)), n = n.map((Le) => Le.clone().applyQuaternion(X));
445
+ const N = new O.Quaternion().setFromAxisAngle(new C(1, 0, 0), Math.PI);
446
+ a.applyMatrix4(new O.Matrix4().makeRotationFromQuaternion(N)), n = n.map((Ie) => Ie.clone().applyQuaternion(N));
447
447
  }
448
448
  const we = n[0].clone();
449
- a.translate(-we.x, -we.y, -we.z), n = n.map((X) => new C(X.x - we.x, X.y - we.y, X.z - we.z)), a.computeVertexNormals(), a.computeBoundingBox();
449
+ a.translate(-we.x, -we.y, -we.z), n = n.map((N) => new C(N.x - we.x, N.y - we.y, N.z - we.z)), a.computeVertexNormals(), a.computeBoundingBox();
450
450
  const re = new C(n[0].x, n[0].y, n[0].z);
451
451
  n.push(re), o.addLandmarkPoint({
452
452
  faceIndex: -1,
@@ -465,16 +465,16 @@ let __tla = (async () => {
465
465
  v: 0.33,
466
466
  w: 0.34
467
467
  }
468
- }), o.updateLandmarkPositions(n.map((X) => ({
469
- x: X.x,
470
- y: X.y,
471
- z: X.z
472
- }))), o.setAligned(true), o.setCut(true), o.setAdjustedStartY(null), o.setAdjustedEndY(null), o.setOriginalEndY(n[1].y + 2 * ut);
468
+ }), o.updateLandmarkPositions(n.map((N) => ({
469
+ x: N.x,
470
+ y: N.y,
471
+ z: N.z
472
+ }))), o.setAligned(true), o.setCut(true), o.setAdjustedStartY(null), o.setAdjustedEndY(null), o.setOriginalEndY(n[1].y + 2 * xt);
473
473
  const j = new C();
474
474
  a.computeBoundingBox(), a.boundingBox.getSize(j), o.setModelSize(Math.max(j.x, j.y, j.z)), l.dispose();
475
475
  return;
476
476
  }
477
- const { positions: f, indices: u } = pt(a), x = new Float32Array([
477
+ const { positions: f, indices: u } = bt(a), x = new Float32Array([
478
478
  m.x,
479
479
  m.y,
480
480
  m.z
@@ -485,21 +485,21 @@ let __tla = (async () => {
485
485
  ]);
486
486
  o.onStatus("Detecting shell type...");
487
487
  const p = c.detect_shell(f, u, S, 40), g = p.is_double_shell(), b = p.surface_normal();
488
- de.info(Pe, `Shell: ${g ? "DOUBLE" : "SINGLE"}`, p.details()), (_a = o.setDoubleShell) == null ? void 0 : _a.call(o, g), o.onStatus("Finding cross-section plane...");
488
+ ce.info(Le, `Shell: ${g ? "DOUBLE" : "SINGLE"}`, p.details()), (_a = o.setDoubleShell) == null ? void 0 : _a.call(o, g), o.onStatus("Finding cross-section plane...");
489
489
  const A = new Float32Array([
490
490
  b[0],
491
491
  b[1],
492
492
  b[2]
493
493
  ]), L = c.find_min_cross_section(f, u, S, A, 10), z = L.plane_normal();
494
- de.info(Pe, "Cross-section found", L.details()), o.onStatus("Aligning mesh...");
494
+ ce.info(Le, "Cross-section found", L.details()), o.onStatus("Aligning mesh...");
495
495
  const P = new Float32Array([
496
496
  z[0],
497
497
  z[1],
498
498
  z[2]
499
- ]), y = c.align_to_origin(f, x, S, P);
500
- let M = y.positions(), h = y.mpt(), v = y.origin();
501
- const F = y.transform();
502
- de.info(Pe, "Alignment complete", y.details());
499
+ ]), w = c.align_to_origin(f, x, S, P);
500
+ let M = w.positions(), h = w.mpt(), v = w.origin();
501
+ const F = w.transform();
502
+ ce.info(Le, "Alignment complete", w.details());
503
503
  const I = [
504
504
  F[3],
505
505
  F[4],
@@ -517,34 +517,34 @@ let __tla = (async () => {
517
517
  ]);
518
518
  o.onStatus("Generating measurement points...");
519
519
  const E = c.subdivide_origin_to_plane(new Float32Array(v), new Float32Array(h), _);
520
- de.debug(Pe, `Subdivide: ${E.count()} pts, spacing=${E.spacing().toFixed(1)}mm`);
521
- const V = E.points(), N = E.count(), J = 2, ye = 1, ae = [];
522
- for (let $ = J; $ < N - ye; $++) ae.push(V[$ * 3 + 1]);
520
+ ce.debug(Le, `Subdivide: ${E.count()} pts, spacing=${E.spacing().toFixed(1)}mm`);
521
+ const V = E.points(), Y = E.count(), q = 2, ye = 1, ae = [];
522
+ for (let $ = q; $ < Y - ye; $++) ae.push(V[$ * 3 + 1]);
523
523
  o.onStatus("Computing cross-sections...");
524
- let ue = [];
524
+ let fe = [];
525
525
  if (ae.length >= 2) {
526
526
  const ne = (g ? c.batch_cross_sections_y_inner.bind(c) : c.batch_cross_sections_y.bind(c))(M, u, new Float32Array(ae), 10);
527
- de.debug(Pe, "Batch (subdivision)", ne.details());
528
- const xe = ne.all_loop_points(), Me = ne.offsets(), we = ne.circumferences();
529
- for (let re = 0; re < Me.length - 1; re++) {
530
- const j = Me[re], X = Me[re + 1];
531
- if (X <= j || we[re] <= 0) continue;
532
- const Le = (X - j) / 3;
533
- if (Le < 3) continue;
534
- let Ie = 0, Ge = 0, se = 0;
535
- for (let Ae = j; Ae < X; Ae += 3) Ie += xe[Ae], Ge += xe[Ae + 1], se += xe[Ae + 2];
536
- ue.push(Ie / Le, Ge / Le, se / Le);
527
+ ce.debug(Le, "Batch (subdivision)", ne.details());
528
+ const xe = ne.all_loop_points(), Se = ne.offsets(), we = ne.circumferences();
529
+ for (let re = 0; re < Se.length - 1; re++) {
530
+ const j = Se[re], N = Se[re + 1];
531
+ if (N <= j || we[re] <= 0) continue;
532
+ const Ie = (N - j) / 3;
533
+ if (Ie < 3) continue;
534
+ let Pe = 0, Ke = 0, se = 0;
535
+ for (let Ae = j; Ae < N; Ae += 3) Pe += xe[Ae], Ke += xe[Ae + 1], se += xe[Ae + 2];
536
+ fe.push(Pe / Ie, Ke / Ie, se / Ie);
537
537
  }
538
538
  }
539
- if (ue.length >= 6) {
539
+ if (fe.length >= 6) {
540
540
  o.onStatus("Refining alignment...");
541
- const $ = c.refine_alignment(new Float32Array(ue), M, new Float32Array(v), new Float32Array(h));
542
- de.info(Pe, "Refinement complete", $.details()), M = $.positions(), h = $.mpt(), v = $.origin();
541
+ const $ = c.refine_alignment(new Float32Array(fe), M, new Float32Array(v), new Float32Array(h));
542
+ ce.info(Le, "Refinement complete", $.details()), M = $.positions(), h = $.mpt(), v = $.origin();
543
543
  }
544
- const ie = a.getAttribute("color"), Q = yn(M, u);
545
- ie && Q.setAttribute("color", ie), a.dispose(), a = Q, e.geometry = a, a.computeVertexNormals(), a.computeBoundingBox(), n[0] = new C(v[0], v[1], v[2]), n[1] = new C(h[0], h[1], h[2]), o.onStatus("Setting blue point...");
546
- const Y = new C(n[0].x, n[0].y, n[0].z);
547
- n.push(Y), o.addLandmarkPoint({
544
+ const ie = a.getAttribute("color"), ee = vn(M, u);
545
+ ie && ee.setAttribute("color", ie), a.dispose(), a = ee, e.geometry = a, a.computeVertexNormals(), a.computeBoundingBox(), n[0] = new C(v[0], v[1], v[2]), n[1] = new C(h[0], h[1], h[2]), o.onStatus("Setting blue point...");
546
+ const X = new C(n[0].x, n[0].y, n[0].z);
547
+ n.push(X), o.addLandmarkPoint({
548
548
  faceIndex: -1,
549
549
  vertexIndices: [
550
550
  0,
@@ -552,9 +552,9 @@ let __tla = (async () => {
552
552
  2
553
553
  ],
554
554
  position: {
555
- x: Y.x,
556
- y: Y.y,
557
- z: Y.z
555
+ x: X.x,
556
+ y: X.y,
557
+ z: X.z
558
558
  },
559
559
  barycentricCoords: {
560
560
  u: 0.33,
@@ -566,41 +566,41 @@ let __tla = (async () => {
566
566
  y: $.y,
567
567
  z: $.z
568
568
  }))), o.setAligned(true);
569
- const he = a.boundingBox, Z = new C();
570
- he.getSize(Z), o.setModelSize(Math.max(Z.x, Z.y, Z.z)), o.setCut(true), o.setAdjustedStartY(null), o.setAdjustedEndY(null), o.setOriginalEndY(n[1].y + 2 * ut), o.onStatus("Computing final measurements...");
569
+ const ue = a.boundingBox, Z = new C();
570
+ ue.getSize(Z), o.setModelSize(Math.max(Z.x, Z.y, Z.z)), o.setCut(true), o.setAdjustedStartY(null), o.setAdjustedEndY(null), o.setOriginalEndY(n[1].y + 2 * xt), o.onStatus("Computing final measurements...");
571
571
  {
572
- const $ = pt(a), ne = n[1].y, xe = n[0].y;
573
- let Me = 1 / 0, we = -1 / 0;
572
+ const $ = bt(a), ne = n[1].y, xe = n[0].y;
573
+ let Se = 1 / 0, we = -1 / 0;
574
574
  const re = $.positions;
575
- for (let se = 1; se < re.length; se += 3) re[se] < Me && (Me = re[se]), re[se] > we && (we = re[se]);
576
- const j = 25.4, X = [];
577
- X.push(ne);
575
+ for (let se = 1; se < re.length; se += 3) re[se] < Se && (Se = re[se]), re[se] > we && (we = re[se]);
576
+ const j = 25.4, N = [];
577
+ N.push(ne);
578
578
  for (let se = 1; se <= 2; se++) {
579
579
  const Ae = ne + se * j;
580
- Ae < we - 1 && X.push(Ae);
580
+ Ae < we - 1 && N.push(Ae);
581
581
  }
582
- for (let se = ne - j; se > xe; se -= j) X.push(se);
583
- X.sort((se, Ae) => se - Ae), de.info(Pe, `Horizontal slices: ${X.length} Y planes, range ${(_b = X[0]) == null ? void 0 : _b.toFixed(1)} \u2192 ${(_c = X[X.length - 1]) == null ? void 0 : _c.toFixed(1)} mm`);
584
- const Ie = (g ? c.batch_cross_sections_y_inner.bind(c) : c.batch_cross_sections_y.bind(c))($.positions, $.indices, new Float32Array(X), 10);
585
- de.info(Pe, `Horizontal slices (${g ? "inner" : "outer"}): ${Ie.count()}/${X.length} valid`), de.debug(Pe, "Slice details", Ie.details());
586
- const Ge = {
587
- yValues: X,
588
- circumferences: Array.from(Ie.circumferences()),
589
- allLoopPoints: new Float32Array(Ie.all_loop_points()),
590
- offsets: new Uint32Array(Ie.offsets()),
582
+ for (let se = ne - j; se > xe; se -= j) N.push(se);
583
+ N.sort((se, Ae) => se - Ae), ce.info(Le, `Horizontal slices: ${N.length} Y planes, range ${(_b = N[0]) == null ? void 0 : _b.toFixed(1)} \u2192 ${(_c = N[N.length - 1]) == null ? void 0 : _c.toFixed(1)} mm`);
584
+ const Pe = (g ? c.batch_cross_sections_y_inner.bind(c) : c.batch_cross_sections_y.bind(c))($.positions, $.indices, new Float32Array(N), 10);
585
+ ce.info(Le, `Horizontal slices (${g ? "inner" : "outer"}): ${Pe.count()}/${N.length} valid`), ce.debug(Le, "Slice details", Pe.details());
586
+ const Ke = {
587
+ yValues: N,
588
+ circumferences: Array.from(Pe.circumferences()),
589
+ allLoopPoints: new Float32Array(Pe.all_loop_points()),
590
+ offsets: new Uint32Array(Pe.offsets()),
591
591
  mptY: ne,
592
592
  originY: xe
593
593
  };
594
- (_d = o.setWasmSlices) == null ? void 0 : _d.call(o, Ge);
594
+ (_d = o.setWasmSlices) == null ? void 0 : _d.call(o, Ke);
595
595
  }
596
596
  o.onStatus("Validating results...");
597
- const ge = n[1].y, me = n[0].y, pe = Co(a, ge, me, t);
598
- pe.valid || de.warn(Pe, `Validation: ${pe.reason}`), o.setClippedReferenceGeometry ? (l.computeVertexNormals(), o.setClippedReferenceGeometry(l)) : l.dispose();
597
+ const pe = n[1].y, me = n[0].y, he = Mo(a, pe, me, t);
598
+ he.valid || ce.warn(Le, `Validation: ${he.reason}`), o.setClippedReferenceGeometry ? (l.computeVertexNormals(), o.setClippedReferenceGeometry(l)) : l.dispose();
599
599
  } catch (a) {
600
- de.error(Pe, "Processing failed", a), o.setError(a instanceof Error ? a.message : "Failed to process mesh."), l.dispose();
600
+ ce.error(Le, "Processing failed", a), o.setError(a instanceof Error ? a.message : "Failed to process mesh."), l.dispose();
601
601
  }
602
602
  }
603
- class zo extends oo {
603
+ class ko extends ro {
604
604
  constructor() {
605
605
  super(...arguments), this.state = {
606
606
  error: null
@@ -667,7 +667,7 @@ let __tla = (async () => {
667
667
  }) : this.props.children;
668
668
  }
669
669
  }
670
- const ko = ({ message: e, onDismiss: r }) => k("div", {
670
+ const Ao = ({ message: e, onDismiss: r }) => k("div", {
671
671
  style: {
672
672
  position: "absolute",
673
673
  top: 16,
@@ -720,7 +720,7 @@ let __tla = (async () => {
720
720
  children: "x"
721
721
  })
722
722
  ]
723
- }), sn = ({ message: e }) => k("div", {
723
+ }), cn = ({ message: e }) => k("div", {
724
724
  style: {
725
725
  position: "absolute",
726
726
  top: 0,
@@ -758,7 +758,7 @@ let __tla = (async () => {
758
758
  })
759
759
  ]
760
760
  });
761
- function Ao(e, r, t, o) {
761
+ function Fo(e, r, t, o) {
762
762
  const l = new C().subVectors(t, r), s = new C().subVectors(o, r), c = new C().subVectors(e, r), a = l.dot(l), n = l.dot(s), m = l.dot(c), d = s.dot(s), f = s.dot(c), u = 1 / (a * d - n * n), x = (d * m - n * f) * u, S = (a * f - n * m) * u;
763
763
  return {
764
764
  u: 1 - x - S,
@@ -766,8 +766,8 @@ let __tla = (async () => {
766
766
  w: S
767
767
  };
768
768
  }
769
- const Fo = ({ mesh: e, maxPoints: r = 2, meshColor: t = "#c8c8c8", meshOpacity: o = 1, frontFaceOnly: l = false, doubleShellTransparency: s = false }) => {
770
- const { addLandmarkPoint: c, landmarkPoints: a } = Et(), n = te((x) => {
769
+ const Po = ({ mesh: e, maxPoints: r = 2, meshColor: t = "#c8c8c8", meshOpacity: o = 1, frontFaceOnly: l = false, doubleShellTransparency: s = false }) => {
770
+ const { addLandmarkPoint: c, landmarkPoints: a } = Ht(), n = J((x) => {
771
771
  if (a.length >= r) return;
772
772
  x.stopPropagation();
773
773
  const S = x.intersections[0], p = S == null ? void 0 : S.faceIndex;
@@ -783,9 +783,9 @@ let __tla = (async () => {
783
783
  p * 3 + 1,
784
784
  p * 3 + 2
785
785
  ];
786
- const L = g.getAttribute("position"), z = new C().fromBufferAttribute(L, A[0]), P = new C().fromBufferAttribute(L, A[1]), y = new C().fromBufferAttribute(L, A[2]);
787
- z.applyMatrix4(e.matrixWorld), P.applyMatrix4(e.matrixWorld), y.applyMatrix4(e.matrixWorld);
788
- const M = S.point, h = Ao(M, z, P, y), v = {
786
+ const L = g.getAttribute("position"), z = new C().fromBufferAttribute(L, A[0]), P = new C().fromBufferAttribute(L, A[1]), w = new C().fromBufferAttribute(L, A[2]);
787
+ z.applyMatrix4(e.matrixWorld), P.applyMatrix4(e.matrixWorld), w.applyMatrix4(e.matrixWorld);
788
+ const M = S.point, h = Fo(M, z, P, w), v = {
789
789
  faceIndex: p,
790
790
  vertexIndices: A,
791
791
  position: {
@@ -826,8 +826,8 @@ let __tla = (async () => {
826
826
  material: u,
827
827
  renderOrder: s ? 0 : void 0
828
828
  });
829
- }, Po = ({ point: e, index: r, markerSize: t, color: o, label: l }) => {
830
- const [s, c] = W(false);
829
+ }, Lo = ({ point: e, index: r, markerSize: t, color: o, label: l }) => {
830
+ const [s, c] = B(false);
831
831
  return k("mesh", {
832
832
  position: [
833
833
  e.position.x,
@@ -847,7 +847,7 @@ let __tla = (async () => {
847
847
  i("meshBasicMaterial", {
848
848
  color: o
849
849
  }),
850
- s && i(Xe, {
850
+ s && i(Ze, {
851
851
  center: true,
852
852
  style: {
853
853
  pointerEvents: "none"
@@ -868,8 +868,8 @@ let __tla = (async () => {
868
868
  })
869
869
  ]
870
870
  }, r);
871
- }, Lo = ({ modelSize: e, labels: r }) => {
872
- const { landmarkPoints: t } = Et(), o = e * 0.02, l = [
871
+ }, Io = ({ modelSize: e, labels: r }) => {
872
+ const { landmarkPoints: t } = Ht(), o = e * 0.02, l = [
873
873
  "#44ff44",
874
874
  "#ff4444",
875
875
  "#4444ff"
@@ -878,8 +878,8 @@ let __tla = (async () => {
878
878
  "Origin",
879
879
  "Cut Plane"
880
880
  ];
881
- return i(Oe, {
882
- children: t.map((a, n) => i(Po, {
881
+ return i(He, {
882
+ children: t.map((a, n) => i(Lo, {
883
883
  point: a,
884
884
  index: n,
885
885
  markerSize: o,
@@ -888,28 +888,28 @@ let __tla = (async () => {
888
888
  }, n))
889
889
  });
890
890
  };
891
- function vn(e) {
892
- return H(() => e ? new gt(e, {
893
- maxLeafTris: mt
891
+ function zn(e) {
892
+ return H(() => e ? new wt(e, {
893
+ maxLeafTris: St
894
894
  }) : null, [
895
895
  e
896
896
  ]);
897
897
  }
898
- const ln = (e, r) => {
898
+ const dn = (e, r) => {
899
899
  const t = Math.abs(e - r);
900
900
  return t <= 7 ? "#8BC34A" : t <= 20 ? "#FFC107" : "#FF5722";
901
- }, an = new O.Color("#8BC34A"), cn = new O.Color("#FFC107"), Io = new O.Color("#FF5722"), Do = (e) => {
902
- if (e <= 7) return an.clone();
901
+ }, fn = new O.Color("#8BC34A"), un = new O.Color("#FFC107"), Do = new O.Color("#FF5722"), _o = (e) => {
902
+ if (e <= 7) return fn.clone();
903
903
  if (e <= 20) {
904
904
  const t = (e - 7) / 13;
905
- return an.clone().lerp(cn, t);
905
+ return fn.clone().lerp(un, t);
906
906
  }
907
907
  const r = Math.min((e - 20) / 20, 1);
908
- return cn.clone().lerp(Io, r);
909
- }, _o = (e, r) => {
908
+ return un.clone().lerp(Do, r);
909
+ }, Ro = (e, r) => {
910
910
  const t = e.length, o = new Float32Array(t * 2 * 3), l = new Float32Array(t * 2 * 3), s = [];
911
911
  for (let n = 0; n < t; n++) {
912
- const m = e[n], d = r[n], f = m.distanceTo(d), u = Do(f);
912
+ const m = e[n], d = r[n], f = m.distanceTo(d), u = _o(f);
913
913
  if (o[n * 6] = m.x, o[n * 6 + 1] = m.y, o[n * 6 + 2] = m.z, l[n * 6] = u.r, l[n * 6 + 1] = u.g, l[n * 6 + 2] = u.b, o[n * 6 + 3] = d.x, o[n * 6 + 4] = d.y, o[n * 6 + 5] = d.z, l[n * 6 + 3] = u.r, l[n * 6 + 4] = u.g, l[n * 6 + 5] = u.b, n < t - 1) {
914
914
  const x = n * 2, S = x + 1, p = (n + 1) * 2, g = p + 1;
915
915
  s.push(x, S, p, S, g, p);
@@ -926,8 +926,8 @@ let __tla = (async () => {
926
926
  depthWrite: false
927
927
  });
928
928
  return new O.Mesh(c, a);
929
- }, Ro = ({ bvh: e, geometry: r, yPosition: t, color: o = "#00ff00", labelX: l, onDataChange: s, displayUnit: c = "mm", useInnerSurface: a = false, formValue: n, lineWidth: m = 1.5, wasmLoopPoints: d, wasmCircumference: f }) => {
930
- const u = H(() => d && f != null ? null : Ye(e, r, t, a), [
929
+ }, Wo = ({ bvh: e, geometry: r, yPosition: t, color: o = "#00ff00", labelX: l, onDataChange: s, displayUnit: c = "mm", useInnerSurface: a = false, formValue: n, lineWidth: m = 1.5, wasmLoopPoints: d, wasmCircumference: f }) => {
930
+ const u = H(() => d && f != null ? null : Ge(e, r, t, a), [
931
931
  e,
932
932
  r,
933
933
  t,
@@ -936,17 +936,17 @@ let __tla = (async () => {
936
936
  f
937
937
  ]), x = d ?? (u == null ? void 0 : u.linePoints) ?? [], S = f ?? (u == null ? void 0 : u.lineLength) ?? 0, p = H(() => {
938
938
  if (n == null || n === 0 || S <= 0 || x.length < 2) return null;
939
- const L = n / S, z = x.reduce((y, M) => y + M.x, 0) / x.length, P = x.reduce((y, M) => y + M.z, 0) / x.length;
940
- return x.map((y) => new C(z + (y.x - z) * L, y.y, P + (y.z - P) * L));
939
+ const L = n / S, z = x.reduce((w, M) => w + M.x, 0) / x.length, P = x.reduce((w, M) => w + M.z, 0) / x.length;
940
+ return x.map((w) => new C(z + (w.x - z) * L, w.y, P + (w.z - P) * L));
941
941
  }, [
942
942
  x,
943
943
  S,
944
944
  n
945
- ]), g = H(() => !p || x.length < 2 ? null : _o(x, p), [
945
+ ]), g = H(() => !p || x.length < 2 ? null : Ro(x, p), [
946
946
  x,
947
947
  p
948
948
  ]);
949
- U(() => () => {
949
+ Q(() => () => {
950
950
  g && (g.geometry.dispose(), g.material.dispose());
951
951
  }, [
952
952
  g
@@ -962,11 +962,11 @@ let __tla = (async () => {
962
962
  });
963
963
  return new O.Line(L, z);
964
964
  }, []);
965
- return U(() => () => {
965
+ return Q(() => () => {
966
966
  A.geometry.dispose(), A.material.dispose();
967
967
  }, [
968
968
  A
969
- ]), U(() => {
969
+ ]), Q(() => {
970
970
  S > 0 && (s == null ? void 0 : s({
971
971
  yPosition: t,
972
972
  originalValue: S,
@@ -976,27 +976,27 @@ let __tla = (async () => {
976
976
  S,
977
977
  t,
978
978
  s
979
- ]), fn(({ camera: L }) => {
979
+ ]), hn(({ camera: L }) => {
980
980
  if (!b.current || x.length < 2) return;
981
981
  const z = new C();
982
982
  L.getWorldDirection(z);
983
983
  const P = new C(z.x, 0, z.z);
984
984
  if (P.lengthSq() < 1e-8) return;
985
985
  P.normalize();
986
- const y = new C().crossVectors(P, new C(0, 1, 0)).normalize();
986
+ const w = new C().crossVectors(P, new C(0, 1, 0)).normalize();
987
987
  let M = -1 / 0, h = x[0];
988
988
  for (const _ of x) {
989
- const E = y.x * _.x + y.z * _.z;
989
+ const E = w.x * _.x + w.z * _.z;
990
990
  E > M && (M = E, h = _);
991
991
  }
992
- const v = l * 0.35, F = new C(h.x + y.x * v, t, h.z + y.z * v);
992
+ const v = l * 0.35, F = new C(h.x + w.x * v, t, h.z + w.z * v);
993
993
  b.current.position.copy(F);
994
994
  const I = A.geometry.getAttribute("position");
995
995
  I.setXYZ(0, h.x, h.y, h.z), I.setXYZ(1, F.x, F.y, F.z), I.needsUpdate = true;
996
996
  }), x.length < 2 ? null : k("group", {
997
997
  renderOrder: 10,
998
998
  children: [
999
- i(fe, {
999
+ i(de, {
1000
1000
  points: x,
1001
1001
  color: o,
1002
1002
  lineWidth: m,
@@ -1009,9 +1009,9 @@ let __tla = (async () => {
1009
1009
  object: g,
1010
1010
  renderOrder: 10
1011
1011
  }),
1012
- p && n != null && n !== 0 && i(fe, {
1012
+ p && n != null && n !== 0 && i(de, {
1013
1013
  points: p,
1014
- color: ln(S, n),
1014
+ color: dn(S, n),
1015
1015
  lineWidth: 2.5,
1016
1016
  dashed: true,
1017
1017
  dashSize: 2,
@@ -1028,7 +1028,7 @@ let __tla = (async () => {
1028
1028
  }),
1029
1029
  i("group", {
1030
1030
  ref: b,
1031
- children: i(Xe, {
1031
+ children: i(Ze, {
1032
1032
  zIndexRange: [
1033
1033
  100,
1034
1034
  0
@@ -1078,7 +1078,7 @@ let __tla = (async () => {
1078
1078
  ]
1079
1079
  }),
1080
1080
  n != null && n !== 0 && S > 0 && (() => {
1081
- const L = S - n, z = L > 0.5 ? "\u25B2" : L < -0.5 ? "\u25BC" : "", P = ln(S, n);
1081
+ const L = S - n, z = L > 0.5 ? "\u25B2" : L < -0.5 ? "\u25BC" : "", P = dn(S, n);
1082
1082
  return k("div", {
1083
1083
  style: {
1084
1084
  display: "flex",
@@ -1130,8 +1130,8 @@ let __tla = (async () => {
1130
1130
  })
1131
1131
  ]
1132
1132
  });
1133
- }, Wo = ro(Ro), Bo = ({ mesh: e, startY: r, endY: t, spacing: o, modelSize: l, onMeasurementsChange: s, reverseOrder: c = false, displayUnit: a = "mm", useInnerSurface: n = false, formMeasurements: m, originY: d, wasmSlices: f }) => {
1134
- const u = le(/* @__PURE__ */ new Map()), x = e.geometry, S = vn(x), p = H(() => {
1133
+ }, Bo = io(Wo), Eo = ({ mesh: e, startY: r, endY: t, spacing: o, modelSize: l, onMeasurementsChange: s, reverseOrder: c = false, displayUnit: a = "mm", useInnerSurface: n = false, formMeasurements: m, originY: d, wasmSlices: f }) => {
1134
+ const u = le(/* @__PURE__ */ new Map()), x = e.geometry, S = zn(x), p = H(() => {
1135
1135
  if (f) {
1136
1136
  let M = [
1137
1137
  ...f.yValues
@@ -1146,8 +1146,8 @@ let __tla = (async () => {
1146
1146
  return c ? M.sort((h, v) => v - h) : M.sort((h, v) => h - v), M;
1147
1147
  }
1148
1148
  const P = [];
1149
- if (c) for (let y = t; y >= r; y -= o) P.push(y);
1150
- else for (let y = r; y <= t; y += o) P.push(y);
1149
+ if (c) for (let w = t; w >= r; w -= o) P.push(w);
1150
+ else for (let w = r; w <= t; w += o) P.push(w);
1151
1151
  return P;
1152
1152
  }, [
1153
1153
  r,
@@ -1157,12 +1157,12 @@ let __tla = (async () => {
1157
1157
  f
1158
1158
  ]), g = H(() => {
1159
1159
  if (!f) return null;
1160
- const P = /* @__PURE__ */ new Map(), { allLoopPoints: y, offsets: M, yValues: h } = f;
1160
+ const P = /* @__PURE__ */ new Map(), { allLoopPoints: w, offsets: M, yValues: h } = f;
1161
1161
  for (let v = 0; v < M.length - 1; v++) {
1162
1162
  const F = M[v], I = M[v + 1];
1163
1163
  if (I <= F) continue;
1164
1164
  const _ = [];
1165
- for (let E = F; E < I; E += 3) _.push(new C(y[E], y[E + 1], y[E + 2]));
1165
+ for (let E = F; E < I; E += 3) _.push(new C(w[E], w[E + 1], w[E + 2]));
1166
1166
  _.length >= 3 && P.set(h[v], _);
1167
1167
  }
1168
1168
  return P;
@@ -1171,20 +1171,20 @@ let __tla = (async () => {
1171
1171
  ]), b = H(() => {
1172
1172
  if (!f) return null;
1173
1173
  const P = /* @__PURE__ */ new Map();
1174
- for (let y = 0; y < f.yValues.length; y++) P.set(f.yValues[y], f.circumferences[y]);
1174
+ for (let w = 0; w < f.yValues.length; w++) P.set(f.yValues[w], f.circumferences[w]);
1175
1175
  return P;
1176
1176
  }, [
1177
1177
  f
1178
1178
  ]);
1179
- U(() => {
1179
+ Q(() => {
1180
1180
  u.current.clear();
1181
1181
  }, [
1182
1182
  p
1183
- ]), U(() => {
1183
+ ]), Q(() => {
1184
1184
  if (!b || !s) return;
1185
- const P = p.filter((y) => (b.get(y) ?? 0) > 0).map((y) => ({
1186
- yPosition: y,
1187
- originalValue: b.get(y) ?? 0,
1185
+ const P = p.filter((w) => (b.get(w) ?? 0) > 0).map((w) => ({
1186
+ yPosition: w,
1187
+ originalValue: b.get(w) ?? 0,
1188
1188
  modifiedValue: null
1189
1189
  }));
1190
1190
  s(P);
@@ -1195,57 +1195,57 @@ let __tla = (async () => {
1195
1195
  ]);
1196
1196
  const A = [
1197
1197
  "#5B9BD5"
1198
- ], L = l * ho, z = te((P) => {
1198
+ ], L = l * go, z = J((P) => {
1199
1199
  if (b) return;
1200
1200
  u.current.set(P.yPosition, P);
1201
- const y = Array.from(u.current.values()).sort((M, h) => c ? h.yPosition - M.yPosition : M.yPosition - h.yPosition);
1202
- s == null ? void 0 : s(y);
1201
+ const w = Array.from(u.current.values()).sort((M, h) => c ? h.yPosition - M.yPosition : M.yPosition - h.yPosition);
1202
+ s == null ? void 0 : s(w);
1203
1203
  }, [
1204
1204
  s,
1205
1205
  c,
1206
1206
  b
1207
1207
  ]);
1208
- return S ? i(Oe, {
1209
- children: p.map((P, y) => i(Wo, {
1208
+ return S ? i(He, {
1209
+ children: p.map((P, w) => i(Bo, {
1210
1210
  bvh: S,
1211
1211
  geometry: x,
1212
1212
  yPosition: P,
1213
- color: d != null && Math.abs(P - d) < o * 0.5 ? "#44ff44" : A[y % A.length],
1213
+ color: d != null && Math.abs(P - d) < o * 0.5 ? "#44ff44" : A[w % A.length],
1214
1214
  labelX: L,
1215
1215
  onDataChange: z,
1216
1216
  displayUnit: a,
1217
1217
  useInnerSurface: n,
1218
- formValue: m == null ? void 0 : m[y],
1218
+ formValue: m == null ? void 0 : m[w],
1219
1219
  lineWidth: d != null && Math.abs(P - d) < o * 0.5 ? 4 : 1.5,
1220
1220
  wasmLoopPoints: g == null ? void 0 : g.get(P),
1221
1221
  wasmCircumference: b == null ? void 0 : b.get(P)
1222
1222
  }, P))
1223
1223
  }) : null;
1224
- }, Eo = (e, r) => {
1224
+ }, To = (e, r) => {
1225
1225
  const t = Math.abs(e - r);
1226
1226
  return t <= 7 ? "#4caf50" : t <= 15 ? "#ff9800" : "#f44336";
1227
- }, To = ({ mesh: e, greenY: r, modelSize: t, displayUnit: o = "mm", bottomY: l, formHeight: s }) => {
1227
+ }, Oo = ({ mesh: e, greenY: r, modelSize: t, displayUnit: o = "mm", bottomY: l, formHeight: s }) => {
1228
1228
  var _a;
1229
1229
  const c = e.geometry;
1230
1230
  c.computeBoundingBox();
1231
1231
  const a = l ?? ((_a = c.boundingBox) == null ? void 0 : _a.min.y) ?? 0, n = r - a, m = t * 0.4, d = t * 0.03, f = le(null);
1232
- fn(({ camera: y }) => {
1232
+ hn(({ camera: w }) => {
1233
1233
  if (!f.current) return;
1234
1234
  const M = new C();
1235
- y.getWorldDirection(M);
1235
+ w.getWorldDirection(M);
1236
1236
  const h = new C(M.x, 0, M.z);
1237
1237
  if (h.lengthSq() < 1e-8) return;
1238
1238
  h.normalize();
1239
1239
  const v = new C().crossVectors(new C(0, 1, 0), h).normalize();
1240
1240
  f.current.position.set(v.x * m, 0, v.z * m);
1241
- const F = y.position.x - f.current.position.x, I = y.position.z - f.current.position.z;
1241
+ const F = w.position.x - f.current.position.x, I = w.position.z - f.current.position.z;
1242
1242
  f.current.rotation.y = Math.atan2(F, I);
1243
1243
  });
1244
- const u = new C(0, r, 0), x = new C(0, a, 0), S = new C(0, (r + a) / 2, 0), p = new C(-d, r, 0), g = new C(d, r, 0), b = new C(-d, a, 0), A = new C(d, a, 0), L = s != null && s > 0, z = L ? n - s : 0, P = L ? Eo(n, s) : "#fff";
1244
+ const u = new C(0, r, 0), x = new C(0, a, 0), S = new C(0, (r + a) / 2, 0), p = new C(-d, r, 0), g = new C(d, r, 0), b = new C(-d, a, 0), A = new C(d, a, 0), L = s != null && s > 0, z = L ? n - s : 0, P = L ? To(n, s) : "#fff";
1245
1245
  return k("group", {
1246
1246
  ref: f,
1247
1247
  children: [
1248
- i(fe, {
1248
+ i(de, {
1249
1249
  points: [
1250
1250
  u,
1251
1251
  x
@@ -1253,7 +1253,7 @@ let __tla = (async () => {
1253
1253
  color: "#888888",
1254
1254
  lineWidth: 1.5
1255
1255
  }),
1256
- i(fe, {
1256
+ i(de, {
1257
1257
  points: [
1258
1258
  p,
1259
1259
  g
@@ -1261,7 +1261,7 @@ let __tla = (async () => {
1261
1261
  color: "#888888",
1262
1262
  lineWidth: 1.5
1263
1263
  }),
1264
- i(fe, {
1264
+ i(de, {
1265
1265
  points: [
1266
1266
  b,
1267
1267
  A
@@ -1271,7 +1271,7 @@ let __tla = (async () => {
1271
1271
  }),
1272
1272
  i("mesh", {
1273
1273
  position: S,
1274
- children: i(Xe, {
1274
+ children: i(Ze, {
1275
1275
  center: true,
1276
1276
  style: {
1277
1277
  pointerEvents: "none"
@@ -1360,8 +1360,8 @@ let __tla = (async () => {
1360
1360
  })
1361
1361
  ]
1362
1362
  });
1363
- }, Oo = ({ modelSize: e, isAligned: r, isCut: t, mesh: o, viewMode: l, sliceY: s, landmarkCount: c = 0, measurementGeometry: a, resetCameraToFrontRef: n }) => {
1364
- const { set: m, size: d, camera: f, invalidate: u } = un(), x = le(false), S = le(l), p = le(new C()), g = le(null), b = le(c), A = le(r), L = le(t), z = le(a), P = le(0), y = te(() => {
1363
+ }, $o = ({ modelSize: e, isAligned: r, isCut: t, mesh: o, viewMode: l, sliceY: s, landmarkCount: c = 0, measurementGeometry: a, resetCameraToFrontRef: n }) => {
1364
+ const { set: m, size: d, camera: f, invalidate: u } = gn(), x = le(false), S = le(l), p = le(new C()), g = le(null), b = le(c), A = le(r), L = le(t), z = le(a), P = le(0), w = J(() => {
1365
1365
  if (!o || e <= 0) return null;
1366
1366
  const h = a ?? o.geometry;
1367
1367
  h.computeBoundingBox();
@@ -1369,19 +1369,19 @@ let __tla = (async () => {
1369
1369
  v.getCenter(F);
1370
1370
  const I = new C();
1371
1371
  v.getSize(I), p.current.copy(I);
1372
- const _ = d.width / d.height, E = Math.max(I.y, I.x / _) * 1.6, V = E * _, N = F.y - I.y * 0.05;
1373
- P.current = N;
1374
- const J = new O.OrthographicCamera(-V / 2, V / 2, E / 2, -E / 2, 0.1, e * 10);
1375
- return J.position.set(0, N, e * 2), J.lookAt(0, N, 0), J;
1372
+ const _ = d.width / d.height, E = Math.max(I.y, I.x / _) * 1.6, V = E * _, Y = F.y - I.y * 0.05;
1373
+ P.current = Y;
1374
+ const q = new O.OrthographicCamera(-V / 2, V / 2, E / 2, -E / 2, 0.1, e * 10);
1375
+ return q.position.set(0, Y, e * 2), q.lookAt(0, Y, 0), q;
1376
1376
  }, [
1377
1377
  o,
1378
1378
  e,
1379
1379
  d,
1380
1380
  a
1381
1381
  ]);
1382
- U(() => {
1382
+ Q(() => {
1383
1383
  if (n) return n.current = () => {
1384
- const h = y();
1384
+ const h = w();
1385
1385
  h && (m({
1386
1386
  camera: h
1387
1387
  }), u());
@@ -1390,17 +1390,17 @@ let __tla = (async () => {
1390
1390
  };
1391
1391
  }, [
1392
1392
  n,
1393
- y,
1393
+ w,
1394
1394
  m,
1395
1395
  u
1396
1396
  ]);
1397
- const M = te((h) => {
1397
+ const M = J((h) => {
1398
1398
  const v = h.position.clone(), F = v.length(), I = Math.atan2(v.x, v.z), _ = Math.acos(v.y / F), V = I + 0.02;
1399
1399
  h.position.set(F * Math.sin(_) * Math.sin(V), F * Math.cos(_), F * Math.sin(_) * Math.cos(V)), h.lookAt(0, 0, 0), h.updateMatrixWorld(true), u();
1400
1400
  }, [
1401
1401
  u
1402
1402
  ]);
1403
- return U(() => {
1403
+ return Q(() => {
1404
1404
  if (e > 0 && !x.current && !r) {
1405
1405
  x.current = true;
1406
1406
  const h = new O.PerspectiveCamera(50, d.width / d.height, 0.1, e * 10);
@@ -1414,7 +1414,7 @@ let __tla = (async () => {
1414
1414
  m,
1415
1415
  r,
1416
1416
  M
1417
- ]), U(() => {
1417
+ ]), Q(() => {
1418
1418
  const h = b.current;
1419
1419
  b.current = c, h === 0 && c === 1 && !r && requestAnimationFrame(() => M(f));
1420
1420
  }, [
@@ -1422,10 +1422,10 @@ let __tla = (async () => {
1422
1422
  r,
1423
1423
  f,
1424
1424
  M
1425
- ]), U(() => {
1425
+ ]), Q(() => {
1426
1426
  const h = A.current !== r, v = L.current !== t, F = !z.current && !!a;
1427
1427
  if (A.current = r, L.current = t, z.current = a, !h && !v && !F || !r || l !== "3D") return;
1428
- const I = y();
1428
+ const I = w();
1429
1429
  I && m({
1430
1430
  camera: I
1431
1431
  });
@@ -1434,37 +1434,37 @@ let __tla = (async () => {
1434
1434
  t,
1435
1435
  l,
1436
1436
  a,
1437
- y,
1437
+ w,
1438
1438
  m
1439
- ]), U(() => {
1439
+ ]), Q(() => {
1440
1440
  if (S.current === l) return;
1441
1441
  const h = S.current;
1442
1442
  if (S.current = l, !(!r || !o || e <= 0)) {
1443
1443
  if (l === "2D" && s != null) {
1444
1444
  g.current = f;
1445
1445
  const v = o.geometry, F = v.getAttribute("position"), I = F.array, _ = e * 0.15;
1446
- let E = 1 / 0, V = -1 / 0, N = 1 / 0, J = -1 / 0, ye = false;
1447
- for (let pe = 0; pe < F.count; pe++) if (Math.abs(I[pe * 3 + 1] - s) < _) {
1448
- const $ = I[pe * 3], ne = I[pe * 3 + 2];
1449
- $ < E && (E = $), $ > V && (V = $), ne < N && (N = ne), ne > J && (J = ne), ye = true;
1446
+ let E = 1 / 0, V = -1 / 0, Y = 1 / 0, q = -1 / 0, ye = false;
1447
+ for (let he = 0; he < F.count; he++) if (Math.abs(I[he * 3 + 1] - s) < _) {
1448
+ const $ = I[he * 3], ne = I[he * 3 + 2];
1449
+ $ < E && (E = $), $ > V && (V = $), ne < Y && (Y = ne), ne > q && (q = ne), ye = true;
1450
1450
  }
1451
1451
  if (!ye) {
1452
1452
  v.computeBoundingBox();
1453
- const pe = v.boundingBox;
1454
- E = pe.min.x, V = pe.max.x, N = pe.min.z, J = pe.max.z;
1453
+ const he = v.boundingBox;
1454
+ E = he.min.x, V = he.max.x, Y = he.min.z, q = he.max.z;
1455
1455
  }
1456
- const ae = (E + V) / 2, ue = (N + J) / 2, ie = d.width / d.height, Q = 1.4, Y = (V - E) * Q, he = (J - N) * Q;
1457
- let Z, ge;
1458
- Y / he > ie ? (Z = Y, ge = Y / ie) : (ge = he, Z = he * ie);
1459
- const me = new O.OrthographicCamera(-Z / 2, Z / 2, ge / 2, -ge / 2, 0.1, e * 10);
1460
- me.position.set(ae, s + e * 2, ue), me.up.set(0, 0, -1), me.lookAt(ae, s, ue), m({
1456
+ const ae = (E + V) / 2, fe = (Y + q) / 2, ie = d.width / d.height, ee = 1.4, X = (V - E) * ee, ue = (q - Y) * ee;
1457
+ let Z, pe;
1458
+ X / ue > ie ? (Z = X, pe = X / ie) : (pe = ue, Z = ue * ie);
1459
+ const me = new O.OrthographicCamera(-Z / 2, Z / 2, pe / 2, -pe / 2, 0.1, e * 10);
1460
+ me.position.set(ae, s + e * 2, fe), me.up.set(0, 0, -1), me.lookAt(ae, s, fe), m({
1461
1461
  camera: me
1462
1462
  });
1463
1463
  } else if (h === "2D") if (g.current) m({
1464
1464
  camera: g.current
1465
1465
  }), g.current = null;
1466
1466
  else {
1467
- const v = y();
1467
+ const v = w();
1468
1468
  v && m({
1469
1469
  camera: v
1470
1470
  });
@@ -1479,26 +1479,26 @@ let __tla = (async () => {
1479
1479
  d,
1480
1480
  m,
1481
1481
  f,
1482
- y
1483
- ]), U(() => {
1482
+ w
1483
+ ]), Q(() => {
1484
1484
  if (!r || !f || !f.isOrthographicCamera) return;
1485
1485
  const h = f;
1486
1486
  if (l === "2D") {
1487
1487
  if (!o || s == null) return;
1488
1488
  const v = o.geometry, F = v.getAttribute("position"), I = F.array, _ = e * 0.15;
1489
- let E = 1 / 0, V = -1 / 0, N = 1 / 0, J = -1 / 0, ye = false;
1489
+ let E = 1 / 0, V = -1 / 0, Y = 1 / 0, q = -1 / 0, ye = false;
1490
1490
  for (let Z = 0; Z < F.count; Z++) if (Math.abs(I[Z * 3 + 1] - s) < _) {
1491
- const ge = I[Z * 3], me = I[Z * 3 + 2];
1492
- ge < E && (E = ge), ge > V && (V = ge), me < N && (N = me), me > J && (J = me), ye = true;
1491
+ const pe = I[Z * 3], me = I[Z * 3 + 2];
1492
+ pe < E && (E = pe), pe > V && (V = pe), me < Y && (Y = me), me > q && (q = me), ye = true;
1493
1493
  }
1494
1494
  if (!ye) {
1495
1495
  v.computeBoundingBox();
1496
1496
  const Z = v.boundingBox;
1497
- E = Z.min.x, V = Z.max.x, N = Z.min.z, J = Z.max.z;
1497
+ E = Z.min.x, V = Z.max.x, Y = Z.min.z, q = Z.max.z;
1498
1498
  }
1499
- const ae = d.width / d.height, ue = 1.4, ie = (V - E) * ue, Q = (J - N) * ue;
1500
- let Y, he;
1501
- ie / Q > ae ? (Y = ie, he = ie / ae) : (he = Q, Y = Q * ae), h.left = -Y / 2, h.right = Y / 2, h.top = he / 2, h.bottom = -he / 2;
1499
+ const ae = d.width / d.height, fe = 1.4, ie = (V - E) * fe, ee = (q - Y) * fe;
1500
+ let X, ue;
1501
+ ie / ee > ae ? (X = ie, ue = ie / ae) : (ue = ee, X = ee * ae), h.left = -X / 2, h.right = X / 2, h.top = ue / 2, h.bottom = -ue / 2;
1502
1502
  } else {
1503
1503
  const v = p.current, F = d.width / d.height, I = Math.max(v.y, v.x / F) * 1.6, _ = I * F;
1504
1504
  h.left = -_ / 2, h.right = _ / 2, h.top = I / 2, h.bottom = -I / 2;
@@ -1512,12 +1512,12 @@ let __tla = (async () => {
1512
1512
  l,
1513
1513
  o
1514
1514
  ]), null;
1515
- }, $o = ({ mesh: e, isDragging: r }) => {
1515
+ }, Ho = ({ mesh: e, isDragging: r }) => {
1516
1516
  var _a;
1517
1517
  const t = e.geometry;
1518
1518
  t.computeBoundingBox();
1519
1519
  const o = new C();
1520
- return (_a = t.boundingBox) == null ? void 0 : _a.getCenter(o), i(pn, {
1520
+ return (_a = t.boundingBox) == null ? void 0 : _a.getCenter(o), i(mn, {
1521
1521
  enableDamping: false,
1522
1522
  enablePan: false,
1523
1523
  minPolarAngle: Math.PI * 0.15,
@@ -1531,7 +1531,7 @@ let __tla = (async () => {
1531
1531
  o.z
1532
1532
  ]
1533
1533
  });
1534
- }, Ho = ({ wasAutoScaled: e, onDismiss: r }) => k("div", {
1534
+ }, Vo = ({ wasAutoScaled: e, onDismiss: r }) => k("div", {
1535
1535
  style: {
1536
1536
  position: "absolute",
1537
1537
  bottom: 16,
@@ -1572,7 +1572,7 @@ let __tla = (async () => {
1572
1572
  children: "X"
1573
1573
  })
1574
1574
  ]
1575
- }), Vo = ({ isDoubleShell: e, onDismiss: r }) => k("div", {
1575
+ }), jo = ({ isDoubleShell: e, onDismiss: r }) => k("div", {
1576
1576
  style: {
1577
1577
  position: "absolute",
1578
1578
  bottom: 68,
@@ -1613,7 +1613,7 @@ let __tla = (async () => {
1613
1613
  children: "X"
1614
1614
  })
1615
1615
  ]
1616
- }), jo = ({ steps: e, currentStep: r, accentColor: t = "rgb(12, 67, 173)" }) => i("div", {
1616
+ }), No = ({ steps: e, currentStep: r, accentColor: t = "rgb(12, 67, 173)" }) => i("div", {
1617
1617
  style: {
1618
1618
  backgroundColor: "#fff",
1619
1619
  borderBottom: "1px solid #e0e0e0",
@@ -1677,27 +1677,27 @@ let __tla = (async () => {
1677
1677
  ]
1678
1678
  }, o.number);
1679
1679
  })
1680
- }), No = ({ mesh: e, upperY: r, originY: t, modelSize: o, meshColor: l = "#c8c8c8", displayUnit: s = "mm" }) => {
1681
- const c = e.geometry, a = H(() => new gt(c, {
1682
- maxLeafTris: mt
1680
+ }), Yo = ({ mesh: e, upperY: r, originY: t, modelSize: o, meshColor: l = "#c8c8c8", displayUnit: s = "mm" }) => {
1681
+ const c = e.geometry, a = H(() => new wt(c, {
1682
+ maxLeafTris: St
1683
1683
  }), [
1684
1684
  c
1685
- ]), n = H(() => Ye(a, c, t), [
1685
+ ]), n = H(() => Ge(a, c, t), [
1686
1686
  a,
1687
1687
  c,
1688
1688
  t
1689
- ]), m = H(() => new ht(new C(0, -1, 0), r), [
1689
+ ]), m = H(() => new yt(new C(0, -1, 0), r), [
1690
1690
  r
1691
1691
  ]), { mlLine: d, apLine: f, mlWidth: u, apWidth: x } = H(() => {
1692
1692
  let g = null, b = null, A = 0, L = 0;
1693
1693
  if (n.linePoints.length >= 2) {
1694
- let z = n.linePoints[0], P = n.linePoints[0], y = n.linePoints[0], M = n.linePoints[0];
1695
- for (const h of n.linePoints) h.x < z.x && (z = h), h.x > P.x && (P = h), h.z < y.z && (y = h), h.z > M.z && (M = h);
1694
+ let z = n.linePoints[0], P = n.linePoints[0], w = n.linePoints[0], M = n.linePoints[0];
1695
+ for (const h of n.linePoints) h.x < z.x && (z = h), h.x > P.x && (P = h), h.z < w.z && (w = h), h.z > M.z && (M = h);
1696
1696
  g = [
1697
1697
  new C(z.x, t, z.z),
1698
1698
  new C(P.x, t, P.z)
1699
1699
  ], b = [
1700
- new C(y.x, t, y.z),
1700
+ new C(w.x, t, w.z),
1701
1701
  new C(M.x, t, M.z)
1702
1702
  ], A = g[0].distanceTo(g[1]), L = b[0].distanceTo(b[1]);
1703
1703
  }
@@ -1711,7 +1711,7 @@ let __tla = (async () => {
1711
1711
  n,
1712
1712
  t
1713
1713
  ]), S = (g) => s === "inch" ? (g / 25.4).toFixed(2) : g.toFixed(1), p = s === "inch" ? "in" : "mm";
1714
- return k(Oe, {
1714
+ return k(He, {
1715
1715
  children: [
1716
1716
  i("mesh", {
1717
1717
  geometry: e.geometry,
@@ -1726,7 +1726,7 @@ let __tla = (async () => {
1726
1726
  ]
1727
1727
  })
1728
1728
  }),
1729
- n.linePoints.length >= 2 && i(fe, {
1729
+ n.linePoints.length >= 2 && i(de, {
1730
1730
  points: n.linePoints,
1731
1731
  color: "#00ff00",
1732
1732
  lineWidth: 3,
@@ -1734,9 +1734,9 @@ let __tla = (async () => {
1734
1734
  depthWrite: false,
1735
1735
  transparent: true
1736
1736
  }),
1737
- d && k(Oe, {
1737
+ d && k(He, {
1738
1738
  children: [
1739
- i(fe, {
1739
+ i(de, {
1740
1740
  points: d,
1741
1741
  color: "#ff8800",
1742
1742
  lineWidth: 2,
@@ -1744,7 +1744,7 @@ let __tla = (async () => {
1744
1744
  depthWrite: false,
1745
1745
  transparent: true
1746
1746
  }),
1747
- i(Xe, {
1747
+ i(Ze, {
1748
1748
  position: [
1749
1749
  d[0].x,
1750
1750
  t,
@@ -1778,9 +1778,9 @@ let __tla = (async () => {
1778
1778
  })
1779
1779
  ]
1780
1780
  }),
1781
- f && k(Oe, {
1781
+ f && k(He, {
1782
1782
  children: [
1783
- i(fe, {
1783
+ i(de, {
1784
1784
  points: f,
1785
1785
  color: "#ff00ff",
1786
1786
  lineWidth: 2,
@@ -1788,7 +1788,7 @@ let __tla = (async () => {
1788
1788
  depthWrite: false,
1789
1789
  transparent: true
1790
1790
  }),
1791
- i(Xe, {
1791
+ i(Ze, {
1792
1792
  position: [
1793
1793
  Math.max(f[0].x, f[1].x) + o * 0.02,
1794
1794
  t,
@@ -1824,8 +1824,8 @@ let __tla = (async () => {
1824
1824
  })
1825
1825
  ]
1826
1826
  });
1827
- }, Yo = ({ mesh: e, yPosition: r, onYChange: t, minY: o, maxY: l, modelSize: s, color: c, hoverColor: a, dragColor: n, label: m, onDragStart: d, onDragEnd: f }) => {
1828
- const [u, x] = W(false), [S, p] = W(false), { camera: g, gl: b } = un(), A = le(0), L = e.geometry, z = vn(L), P = H(() => z ? Ye(z, L, r) : {
1827
+ }, Xo = ({ mesh: e, yPosition: r, onYChange: t, minY: o, maxY: l, modelSize: s, color: c, hoverColor: a, dragColor: n, label: m, onDragStart: d, onDragEnd: f }) => {
1828
+ const [u, x] = B(false), [S, p] = B(false), { camera: g, gl: b } = gn(), A = le(0), L = e.geometry, z = zn(L), P = H(() => z ? Ge(z, L, r) : {
1829
1829
  linePoints: [],
1830
1830
  lineLength: 0,
1831
1831
  rightmostPoint: new C()
@@ -1833,33 +1833,33 @@ let __tla = (async () => {
1833
1833
  z,
1834
1834
  L,
1835
1835
  r
1836
- ]), y = te((I, _) => {
1837
- const E = b.domElement.getBoundingClientRect(), V = (I - E.left) / E.width * 2 - 1, N = -((_ - E.top) / E.height) * 2 + 1, J = new lo();
1838
- J.setFromCamera(new O.Vector2(V, N), g);
1839
- const ye = new ht(new C(0, 0, 1), 0), ae = new C();
1840
- return J.ray.intersectPlane(ye, ae), ae ? ae.y : r;
1836
+ ]), w = J((I, _) => {
1837
+ const E = b.domElement.getBoundingClientRect(), V = (I - E.left) / E.width * 2 - 1, Y = -((_ - E.top) / E.height) * 2 + 1, q = new ao();
1838
+ q.setFromCamera(new O.Vector2(V, Y), g);
1839
+ const ye = new yt(new C(0, 0, 1), 0), ae = new C();
1840
+ return q.ray.intersectPlane(ye, ae), ae ? ae.y : r;
1841
1841
  }, [
1842
1842
  g,
1843
1843
  b,
1844
1844
  r
1845
- ]), M = te((I) => {
1846
- I.stopPropagation(), x(true), b.domElement.style.cursor = "ns-resize", A.current = r - y(I.clientX, I.clientY), I.target.setPointerCapture(I.pointerId), d == null ? void 0 : d();
1845
+ ]), M = J((I) => {
1846
+ I.stopPropagation(), x(true), b.domElement.style.cursor = "ns-resize", A.current = r - w(I.clientX, I.clientY), I.target.setPointerCapture(I.pointerId), d == null ? void 0 : d();
1847
1847
  }, [
1848
1848
  r,
1849
1849
  b,
1850
- y,
1850
+ w,
1851
1851
  d
1852
- ]), h = te((I) => {
1852
+ ]), h = J((I) => {
1853
1853
  if (!u) return;
1854
- let _ = y(I.clientX, I.clientY) + A.current;
1854
+ let _ = w(I.clientX, I.clientY) + A.current;
1855
1855
  _ = Math.max(o, Math.min(l, _)), t(_);
1856
1856
  }, [
1857
1857
  u,
1858
- y,
1858
+ w,
1859
1859
  t,
1860
1860
  o,
1861
1861
  l
1862
- ]), v = te((I) => {
1862
+ ]), v = J((I) => {
1863
1863
  x(false), b.domElement.style.cursor = "auto", I.target.releasePointerCapture(I.pointerId), f == null ? void 0 : f();
1864
1864
  }, [
1865
1865
  b,
@@ -1870,7 +1870,7 @@ let __tla = (async () => {
1870
1870
  return k("group", {
1871
1871
  renderOrder: 10,
1872
1872
  children: [
1873
- i(fe, {
1873
+ i(de, {
1874
1874
  points: P.linePoints,
1875
1875
  color: F,
1876
1876
  lineWidth: u ? 6 : S ? 5 : 4,
@@ -1894,7 +1894,7 @@ let __tla = (async () => {
1894
1894
  r,
1895
1895
  0
1896
1896
  ],
1897
- children: i(Xe, {
1897
+ children: i(Ze, {
1898
1898
  center: true,
1899
1899
  children: i("div", {
1900
1900
  style: {
@@ -1913,17 +1913,17 @@ let __tla = (async () => {
1913
1913
  ]
1914
1914
  });
1915
1915
  };
1916
- function Xo(e, r) {
1916
+ function Go(e, r) {
1917
1917
  if (e == null) return {};
1918
1918
  var t = {}, o = Object.keys(e), l, s;
1919
1919
  for (s = 0; s < o.length; s++) l = o[s], !(r.indexOf(l) >= 0) && (t[l] = e[l]);
1920
1920
  return t;
1921
1921
  }
1922
- var Go = [
1922
+ var Zo = [
1923
1923
  "color"
1924
- ], Zo = io(function(e, r) {
1925
- var t = e.color, o = t === void 0 ? "currentColor" : t, l = Xo(e, Go);
1926
- return nn("svg", Object.assign({
1924
+ ], Ko = so(function(e, r) {
1925
+ var t = e.color, o = t === void 0 ? "currentColor" : t, l = Go(e, Zo);
1926
+ return sn("svg", Object.assign({
1927
1927
  width: "15",
1928
1928
  height: "15",
1929
1929
  viewBox: "0 0 15 15",
@@ -1931,20 +1931,20 @@ let __tla = (async () => {
1931
1931
  xmlns: "http://www.w3.org/2000/svg"
1932
1932
  }, l, {
1933
1933
  ref: r
1934
- }), nn("path", {
1934
+ }), sn("path", {
1935
1935
  d: "M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",
1936
1936
  fill: o,
1937
1937
  fillRule: "evenodd",
1938
1938
  clipRule: "evenodd"
1939
1939
  }));
1940
1940
  });
1941
- const Ko = [
1941
+ const Uo = [
1942
1942
  "Scan doesn't load properly",
1943
1943
  "Takes too long",
1944
1944
  "I don't want to",
1945
1945
  "I want a second opinion",
1946
1946
  "I measured from IT"
1947
- ], dt = {
1947
+ ], gt = {
1948
1948
  padding: "8px 20px",
1949
1949
  borderRadius: 4,
1950
1950
  fontSize: 14,
@@ -1953,7 +1953,7 @@ let __tla = (async () => {
1953
1953
  fontFamily: "system-ui, sans-serif",
1954
1954
  letterSpacing: "0.4px",
1955
1955
  lineHeight: "36px"
1956
- }, Uo = {
1956
+ }, Jo = {
1957
1957
  width: "100%",
1958
1958
  padding: "10px 12px",
1959
1959
  fontSize: 15,
@@ -1962,15 +1962,15 @@ let __tla = (async () => {
1962
1962
  outline: "none",
1963
1963
  boxSizing: "border-box",
1964
1964
  fontFamily: "system-ui, sans-serif"
1965
- }, Cn = ({ onSkip: e, onCancel: r }) => {
1966
- const [t, o] = W("confirm"), [l, s] = W(null), [c, a] = W(""), n = te(() => {
1965
+ }, kn = ({ onSkip: e, onCancel: r }) => {
1966
+ const [t, o] = B("confirm"), [l, s] = B(null), [c, a] = B(""), n = J(() => {
1967
1967
  o("reasons");
1968
- }, []), m = te(() => {
1968
+ }, []), m = J(() => {
1969
1969
  t === "reasons" ? (o("confirm"), s(null), a("")) : r();
1970
1970
  }, [
1971
1971
  t,
1972
1972
  r
1973
- ]), d = l != null && (l !== "Other" || c.trim() !== ""), f = te(() => {
1973
+ ]), d = l != null && (l !== "Other" || c.trim() !== ""), f = J(() => {
1974
1974
  !d || !l || e(l === "Other" ? `Other: ${c.trim()}` : l);
1975
1975
  }, [
1976
1976
  d,
@@ -2031,7 +2031,7 @@ let __tla = (async () => {
2031
2031
  },
2032
2032
  children: [
2033
2033
  [
2034
- ...Ko,
2034
+ ...Uo,
2035
2035
  "Other"
2036
2036
  ].map((u) => k("label", {
2037
2037
  style: {
@@ -2078,7 +2078,7 @@ let __tla = (async () => {
2078
2078
  u.key === "Enter" && f();
2079
2079
  },
2080
2080
  style: {
2081
- ...Uo,
2081
+ ...Jo,
2082
2082
  marginTop: 8,
2083
2083
  marginLeft: 40,
2084
2084
  width: "calc(100% - 40px)",
@@ -2099,7 +2099,7 @@ let __tla = (async () => {
2099
2099
  i("button", {
2100
2100
  onClick: m,
2101
2101
  style: {
2102
- ...dt,
2102
+ ...gt,
2103
2103
  backgroundColor: "#fff",
2104
2104
  border: "1px solid #ddd",
2105
2105
  color: "#666"
@@ -2110,7 +2110,7 @@ let __tla = (async () => {
2110
2110
  onClick: f,
2111
2111
  disabled: !d,
2112
2112
  style: {
2113
- ...dt,
2113
+ ...gt,
2114
2114
  backgroundColor: d ? "rgb(12, 67, 173)" : "#e0e0e0",
2115
2115
  border: "none",
2116
2116
  color: d ? "#fff" : "#9e9e9e",
@@ -2171,7 +2171,7 @@ let __tla = (async () => {
2171
2171
  i("button", {
2172
2172
  onClick: r,
2173
2173
  style: {
2174
- ...dt,
2174
+ ...gt,
2175
2175
  backgroundColor: "#fff",
2176
2176
  border: "1px solid #bdbdbd",
2177
2177
  color: "#333"
@@ -2181,7 +2181,7 @@ let __tla = (async () => {
2181
2181
  i("button", {
2182
2182
  onClick: n,
2183
2183
  style: {
2184
- ...dt,
2184
+ ...gt,
2185
2185
  backgroundColor: "rgb(12, 67, 173)",
2186
2186
  border: "none",
2187
2187
  color: "#fff"
@@ -2193,7 +2193,7 @@ let __tla = (async () => {
2193
2193
  ]
2194
2194
  })
2195
2195
  });
2196
- }, Wt = {
2196
+ }, Ot = {
2197
2197
  padding: "8px 20px",
2198
2198
  borderRadius: 4,
2199
2199
  fontSize: 14,
@@ -2202,7 +2202,7 @@ let __tla = (async () => {
2202
2202
  fontFamily: "system-ui, sans-serif",
2203
2203
  letterSpacing: "0.4px",
2204
2204
  lineHeight: "36px"
2205
- }, dn = {
2205
+ }, pn = {
2206
2206
  width: "100%",
2207
2207
  padding: "10px 12px",
2208
2208
  fontSize: 15,
@@ -2211,7 +2211,7 @@ let __tla = (async () => {
2211
2211
  outline: "none",
2212
2212
  boxSizing: "border-box",
2213
2213
  fontFamily: "system-ui, sans-serif"
2214
- }, Jo = ({ amputationType: e, spacingInches: r, scanMeasurements: t, scanFrontalHeight: o, onSave: l, onSkip: s, onFormChange: c, onHeightChange: a, initialValues: n, initialFrontalHeight: m }) => {
2214
+ }, Qo = ({ amputationType: e, spacingInches: r, scanMeasurements: t, scanFrontalHeight: o, onSave: l, onSkip: s, onFormChange: c, onHeightChange: a, initialValues: n, initialFrontalHeight: m }) => {
2215
2215
  const d = e === "AK" ? "IT" : "MPT", f = r, u = e === "AK" ? 18 : 9, x = H(() => {
2216
2216
  const h = [];
2217
2217
  for (let v = 2; v >= 1; v -= f) h.push(`${v}\u2033 above ${d}`);
@@ -2222,25 +2222,25 @@ let __tla = (async () => {
2222
2222
  f,
2223
2223
  d,
2224
2224
  u
2225
- ]), [S, p] = W(() => {
2225
+ ]), [S, p] = B(() => {
2226
2226
  if (!n) return {};
2227
2227
  const h = {};
2228
2228
  return x.forEach((v, F) => {
2229
2229
  n[F] != null && n[F] !== 0 && (h[v] = n[F].toFixed(1));
2230
2230
  }), h;
2231
- }), [g, b] = W(m && m > 0 ? m.toFixed(1) : ""), [A, L] = W(false), z = H(() => x.map((h) => {
2231
+ }), [g, b] = B(m && m > 0 ? m.toFixed(1) : ""), [A, L] = B(false), z = H(() => x.map((h) => {
2232
2232
  const v = S[h];
2233
2233
  return v != null && v !== "" && !isNaN(parseFloat(v)) ? parseFloat(v) : 0;
2234
2234
  }), [
2235
2235
  x,
2236
2236
  S
2237
2237
  ]);
2238
- U(() => {
2238
+ Q(() => {
2239
2239
  c == null ? void 0 : c(z);
2240
2240
  }, [
2241
2241
  z,
2242
2242
  c
2243
- ]), U(() => {
2243
+ ]), Q(() => {
2244
2244
  const h = g !== "" && !isNaN(parseFloat(g)) ? parseFloat(g) : void 0;
2245
2245
  a == null ? void 0 : a(h);
2246
2246
  }, [
@@ -2253,7 +2253,7 @@ let __tla = (async () => {
2253
2253
  }, [
2254
2254
  z,
2255
2255
  g
2256
- ]), y = te(() => {
2256
+ ]), w = J(() => {
2257
2257
  if (!P) return;
2258
2258
  const h = g !== "" && !isNaN(parseFloat(g)) ? parseFloat(g) : 0;
2259
2259
  l({
@@ -2265,7 +2265,7 @@ let __tla = (async () => {
2265
2265
  z,
2266
2266
  g,
2267
2267
  l
2268
- ]), M = te(() => {
2268
+ ]), M = J(() => {
2269
2269
  const h = {};
2270
2270
  x.forEach((v, F) => {
2271
2271
  const I = t[F];
@@ -2288,7 +2288,7 @@ let __tla = (async () => {
2288
2288
  fontFamily: "system-ui, sans-serif"
2289
2289
  },
2290
2290
  children: [
2291
- A && i(Cn, {
2291
+ A && i(kn, {
2292
2292
  onSkip: s,
2293
2293
  onCancel: () => L(false)
2294
2294
  }),
@@ -2327,7 +2327,7 @@ let __tla = (async () => {
2327
2327
  i("button", {
2328
2328
  onClick: M,
2329
2329
  style: {
2330
- ...Wt,
2330
+ ...Ot,
2331
2331
  backgroundColor: "#fff",
2332
2332
  border: "2px solid rgb(12, 67, 173)",
2333
2333
  color: "rgb(12, 67, 173)",
@@ -2345,7 +2345,7 @@ let __tla = (async () => {
2345
2345
  gap: 4
2346
2346
  },
2347
2347
  children: [
2348
- i(Zo, {
2348
+ i(Ko, {
2349
2349
  style: {
2350
2350
  width: 14,
2351
2351
  height: 14
@@ -2408,7 +2408,7 @@ let __tla = (async () => {
2408
2408
  [h]: F.target.value
2409
2409
  })),
2410
2410
  style: {
2411
- ...dn,
2411
+ ...pn,
2412
2412
  padding: "6px 8px",
2413
2413
  fontSize: 13,
2414
2414
  borderColor: S[h] ? "rgb(12, 67, 173)" : "#ccc",
@@ -2451,7 +2451,7 @@ let __tla = (async () => {
2451
2451
  value: g,
2452
2452
  onChange: (h) => b(h.target.value),
2453
2453
  style: {
2454
- ...dn,
2454
+ ...pn,
2455
2455
  padding: "6px 8px",
2456
2456
  fontSize: 13,
2457
2457
  borderColor: g ? "rgb(12, 67, 173)" : "#ccc",
@@ -2475,10 +2475,10 @@ let __tla = (async () => {
2475
2475
  },
2476
2476
  children: [
2477
2477
  i("button", {
2478
- onClick: y,
2478
+ onClick: w,
2479
2479
  disabled: !P,
2480
2480
  style: {
2481
- ...Wt,
2481
+ ...Ot,
2482
2482
  backgroundColor: P ? "rgb(12, 67, 173)" : "#e0e0e0",
2483
2483
  border: "none",
2484
2484
  color: P ? "#fff" : "#9e9e9e",
@@ -2492,7 +2492,7 @@ let __tla = (async () => {
2492
2492
  i("button", {
2493
2493
  onClick: () => L(true),
2494
2494
  style: {
2495
- ...Wt,
2495
+ ...Ot,
2496
2496
  backgroundColor: "#fff",
2497
2497
  border: "1px solid #bdbdbd",
2498
2498
  color: "#666",
@@ -2507,18 +2507,18 @@ let __tla = (async () => {
2507
2507
  ]
2508
2508
  });
2509
2509
  };
2510
- function Mn(e, r, t) {
2510
+ function An(e, r, t) {
2511
2511
  const o = e.getAttribute("position"), l = t - r;
2512
2512
  if (l < 1) return null;
2513
2513
  const s = 30, c = l / s, a = [];
2514
2514
  for (let g = 0; g < s; g++) {
2515
2515
  const b = r + g * c, A = r + (g + 1) * c;
2516
- let L = 0, z = 0, P = 0, y = 0;
2516
+ let L = 0, z = 0, P = 0, w = 0;
2517
2517
  for (let M = 0; M < o.count; M++) {
2518
2518
  const h = o.getY(M);
2519
- h >= b && h < A && (L += o.getX(M), z += h, P += o.getZ(M), y++);
2519
+ h >= b && h < A && (L += o.getX(M), z += h, P += o.getZ(M), w++);
2520
2520
  }
2521
- y > 20 && a.push(new C(L / y, z / y, P / y));
2521
+ w > 20 && a.push(new C(L / w, z / w, P / w));
2522
2522
  }
2523
2523
  if (a.length < 5) return null;
2524
2524
  const n = new C();
@@ -2537,7 +2537,7 @@ let __tla = (async () => {
2537
2537
  }
2538
2538
  return p.y < 0 && p.negate(), p;
2539
2539
  }
2540
- const Qo = {
2540
+ const qo = {
2541
2541
  pcaAxes: true,
2542
2542
  obb: true,
2543
2543
  obbAxis: true,
@@ -2547,12 +2547,12 @@ let __tla = (async () => {
2547
2547
  landmarkAxis: true,
2548
2548
  iterativePCA: false,
2549
2549
  fullRegionPCA: true
2550
- }, qo = [
2550
+ }, er = [
2551
2551
  "#ff4444",
2552
2552
  "#44cc44",
2553
2553
  "#4488ff"
2554
2554
  ];
2555
- function zn(e) {
2555
+ function Fn(e) {
2556
2556
  const r = e.getAttribute("position"), t = r.count, o = new C();
2557
2557
  for (let p = 0; p < t; p++) o.x += r.getX(p), o.y += r.getY(p), o.z += r.getZ(p);
2558
2558
  o.divideScalar(t);
@@ -2582,13 +2582,13 @@ let __tla = (async () => {
2582
2582
  for (let p = 0; p < 3; p++) {
2583
2583
  let g = new C(1 + p * 0.1, 1 - p * 0.1, 0.5 + p * 0.3).normalize(), b = 0;
2584
2584
  for (let A = 0; A < 100; A++) {
2585
- const L = u[0][0] * g.x + u[0][1] * g.y + u[0][2] * g.z, z = u[1][0] * g.x + u[1][1] * g.y + u[1][2] * g.z, P = u[2][0] * g.x + u[2][1] * g.y + u[2][2] * g.z, y = new C(L, z, P);
2586
- if (b = y.length(), b < 1e-12) break;
2587
- if (y.divideScalar(b), g.distanceTo(y) < 1e-10) {
2588
- g = y;
2585
+ const L = u[0][0] * g.x + u[0][1] * g.y + u[0][2] * g.z, z = u[1][0] * g.x + u[1][1] * g.y + u[1][2] * g.z, P = u[2][0] * g.x + u[2][1] * g.y + u[2][2] * g.z, w = new C(L, z, P);
2586
+ if (b = w.length(), b < 1e-12) break;
2587
+ if (w.divideScalar(b), g.distanceTo(w) < 1e-10) {
2588
+ g = w;
2589
2589
  break;
2590
2590
  }
2591
- g = y;
2591
+ g = w;
2592
2592
  }
2593
2593
  d.push(g.clone()), f.push(b);
2594
2594
  for (let A = 0; A < 3; A++) for (let L = 0; L < 3; L++) {
@@ -2616,7 +2616,7 @@ let __tla = (async () => {
2616
2616
  let g = 1 / 0, b = -1 / 0;
2617
2617
  const A = d[p];
2618
2618
  for (let L = 0; L < t; L++) {
2619
- const z = r.getX(L) - x.x, P = r.getY(L) - x.y, y = r.getZ(L) - x.z, M = z * A.x + P * A.y + y * A.z;
2619
+ const z = r.getX(L) - x.x, P = r.getY(L) - x.y, w = r.getZ(L) - x.z, M = z * A.x + P * A.y + w * A.z;
2620
2620
  M < g && (g = M), M > b && (b = M);
2621
2621
  }
2622
2622
  S[p] = (b - g) / 2;
@@ -2628,22 +2628,22 @@ let __tla = (async () => {
2628
2628
  halfExtents: S
2629
2629
  };
2630
2630
  }
2631
- function er({ pca: e }) {
2631
+ function tr({ pca: e }) {
2632
2632
  return i("group", {
2633
2633
  children: e.axes.map((r, t) => {
2634
2634
  const o = e.center.clone().addScaledVector(r, e.halfExtents[t]), l = e.center.clone().addScaledVector(r, -e.halfExtents[t]);
2635
- return i(fe, {
2635
+ return i(de, {
2636
2636
  points: [
2637
2637
  l,
2638
2638
  o
2639
2639
  ],
2640
- color: qo[t],
2640
+ color: er[t],
2641
2641
  lineWidth: 2
2642
2642
  }, t);
2643
2643
  })
2644
2644
  });
2645
2645
  }
2646
- function tr({ pca: e }) {
2646
+ function nr({ pca: e }) {
2647
2647
  const r = H(() => {
2648
2648
  const { center: t, axes: o, halfExtents: l } = e, s = [];
2649
2649
  for (let a = -1; a <= 1; a += 2) for (let n = -1; n <= 1; n += 2) for (let m = -1; m <= 1; m += 2) s.push(t.clone().addScaledVector(o[0], a * l[0]).addScaledVector(o[1], n * l[1]).addScaledVector(o[2], m * l[2]));
@@ -2704,7 +2704,7 @@ let __tla = (async () => {
2704
2704
  e
2705
2705
  ]);
2706
2706
  return i("group", {
2707
- children: r.map((t, o) => i(fe, {
2707
+ children: r.map((t, o) => i(de, {
2708
2708
  points: t,
2709
2709
  color: "#ffaa00",
2710
2710
  lineWidth: 1,
@@ -2713,7 +2713,7 @@ let __tla = (async () => {
2713
2713
  }, o))
2714
2714
  });
2715
2715
  }
2716
- function nr({ redPoint: e, greenPoint: r }) {
2716
+ function or({ redPoint: e, greenPoint: r }) {
2717
2717
  const t = H(() => new C().subVectors(r, e).normalize(), [
2718
2718
  e,
2719
2719
  r
@@ -2725,7 +2725,7 @@ let __tla = (async () => {
2725
2725
  ]), l = o < 1 ? "#44ff44" : o < 5 ? "#ffcc00" : "#ff4444";
2726
2726
  return k("group", {
2727
2727
  children: [
2728
- i(fe, {
2728
+ i(de, {
2729
2729
  points: [
2730
2730
  e,
2731
2731
  r
@@ -2766,13 +2766,13 @@ let __tla = (async () => {
2766
2766
  ]
2767
2767
  });
2768
2768
  }
2769
- function or({ geometry: e, redY: r, greenY: t, modelSize: o }) {
2769
+ function rr({ geometry: e, redY: r, greenY: t, modelSize: o }) {
2770
2770
  const s = o * 0.15, c = H(() => {
2771
2771
  const a = [];
2772
2772
  let n = t - 10;
2773
2773
  const m = new C(0, 1, 0);
2774
2774
  for (; n > r; ) {
2775
- const d = Math.min(n, t), f = Math.max(n, t), u = Mn(e, d, f);
2775
+ const d = Math.min(n, t), f = Math.max(n, t), u = An(e, d, f);
2776
2776
  if (u) {
2777
2777
  const x = u.dot(m), S = Math.acos(Math.min(1, Math.abs(x))) * 180 / Math.PI;
2778
2778
  a.push({
@@ -2795,7 +2795,7 @@ let __tla = (async () => {
2795
2795
  const m = (a.regionMin + a.regionMax) / 2, d = new C(0, m, 0), f = d.clone().addScaledVector(a.axis, s), u = d.clone().addScaledVector(a.axis, -s), x = n / Math.max(1, c.length - 1), S = a.angleDeg < 0.5 ? `hsl(${120 - x * 120}, 80%, 60%)` : `hsl(${40 - a.angleDeg * 2}, 90%, 55%)`;
2796
2796
  return k("group", {
2797
2797
  children: [
2798
- i(fe, {
2798
+ i(de, {
2799
2799
  points: [
2800
2800
  u,
2801
2801
  f
@@ -2805,7 +2805,7 @@ let __tla = (async () => {
2805
2805
  transparent: true,
2806
2806
  opacity: 0.7
2807
2807
  }),
2808
- i(fe, {
2808
+ i(de, {
2809
2809
  points: [
2810
2810
  new C(-s * 0.3, a.regionMin, 0),
2811
2811
  new C(s * 0.3, a.regionMin, 0)
@@ -2820,9 +2820,9 @@ let __tla = (async () => {
2820
2820
  })
2821
2821
  });
2822
2822
  }
2823
- function rr({ geometry: e, redY: r, greenY: t, modelSize: o }) {
2823
+ function ir({ geometry: e, redY: r, greenY: t, modelSize: o }) {
2824
2824
  const l = H(() => {
2825
- const f = Mn(e, r, t);
2825
+ const f = An(e, r, t);
2826
2826
  if (!f) return null;
2827
2827
  const u = f.dot(new C(0, 1, 0)), x = Math.acos(Math.min(1, Math.abs(u))) * 180 / Math.PI;
2828
2828
  return {
@@ -2837,7 +2837,7 @@ let __tla = (async () => {
2837
2837
  if (!l) return null;
2838
2838
  const s = (r + t) / 2, c = new C(0, s, 0), a = o * 0.4, n = c.clone().addScaledVector(l.axis, a), m = c.clone().addScaledVector(l.axis, -a), d = l.angleDeg < 0.5 ? "#00ffff" : l.angleDeg < 2 ? "#ffcc00" : "#ff6600";
2839
2839
  return i("group", {
2840
- children: i(fe, {
2840
+ children: i(de, {
2841
2841
  points: [
2842
2842
  m,
2843
2843
  n
@@ -2850,9 +2850,9 @@ let __tla = (async () => {
2850
2850
  })
2851
2851
  });
2852
2852
  }
2853
- function ir({ pca: e, modelSize: r }) {
2853
+ function sr({ pca: e, modelSize: r }) {
2854
2854
  const t = e.axes[0], o = r * 0.6, l = e.center.clone().addScaledVector(t, o), s = e.center.clone().addScaledVector(t, -o);
2855
- return i(fe, {
2855
+ return i(de, {
2856
2856
  points: [
2857
2857
  s,
2858
2858
  l
@@ -2864,11 +2864,11 @@ let __tla = (async () => {
2864
2864
  gapSize: 2
2865
2865
  });
2866
2866
  }
2867
- function sr({ geometry: e, redY: r, greenY: t, modelSize: o, measurementGeometry: l }) {
2867
+ function lr({ geometry: e, redY: r, greenY: t, modelSize: o, measurementGeometry: l }) {
2868
2868
  const s = H(() => {
2869
- const d = l ?? e, f = Sn(d), u = new C(0, 1, 0), x = 5, p = t + 3 * 25.4, g = [];
2869
+ const d = l ?? e, f = Mn(d), u = new C(0, 1, 0), x = 5, p = t + 3 * 25.4, g = [];
2870
2870
  for (let h = r + x; h < p; h += x) {
2871
- const v = vo(f, d, new C(0, h, 0), u);
2871
+ const v = Co(f, d, new C(0, h, 0), u);
2872
2872
  v > 0 && g.push({
2873
2873
  y: h,
2874
2874
  circ: v
@@ -2877,10 +2877,10 @@ let __tla = (async () => {
2877
2877
  if (g.length < 5) return null;
2878
2878
  const b = t - r, A = r + b * 0.3, L = r + b * 0.7, z = g.filter((h) => h.y >= A && h.y <= L);
2879
2879
  if (z.length < 3) return null;
2880
- const P = z.map((h) => h.circ).sort((h, v) => h - v), y = P[Math.floor(P.length / 2)], M = Math.max(...g.map((h) => h.circ));
2880
+ const P = z.map((h) => h.circ).sort((h, v) => h - v), w = P[Math.floor(P.length / 2)], M = Math.max(...g.map((h) => h.circ));
2881
2881
  return {
2882
2882
  circumferences: g,
2883
- baseline: y,
2883
+ baseline: w,
2884
2884
  maxCirc: M
2885
2885
  };
2886
2886
  }, [
@@ -2894,7 +2894,7 @@ let __tla = (async () => {
2894
2894
  children: [
2895
2895
  c.map(({ y: d, circ: f }, u) => {
2896
2896
  const x = f / a, S = x > 1.6 ? "#ff4444" : x > 1.3 ? "#ffcc00" : "#22cc66", p = f * m;
2897
- return i(fe, {
2897
+ return i(de, {
2898
2898
  points: [
2899
2899
  new C(-p, d, 0),
2900
2900
  new C(p, d, 0)
@@ -2907,9 +2907,9 @@ let __tla = (async () => {
2907
2907
  }),
2908
2908
  (() => {
2909
2909
  const d = a * 1.6 * m, f = c[0].y, u = c[c.length - 1].y;
2910
- return k(Oe, {
2910
+ return k(He, {
2911
2911
  children: [
2912
- i(fe, {
2912
+ i(de, {
2913
2913
  points: [
2914
2914
  new C(-d, f, 0),
2915
2915
  new C(-d, u, 0)
@@ -2922,7 +2922,7 @@ let __tla = (async () => {
2922
2922
  transparent: true,
2923
2923
  opacity: 0.4
2924
2924
  }),
2925
- i(fe, {
2925
+ i(de, {
2926
2926
  points: [
2927
2927
  new C(d, f, 0),
2928
2928
  new C(d, u, 0)
@@ -2941,7 +2941,7 @@ let __tla = (async () => {
2941
2941
  ]
2942
2942
  });
2943
2943
  }
2944
- function lr({ componentDebug: e }) {
2944
+ function ar({ componentDebug: e }) {
2945
2945
  return i("group", {
2946
2946
  children: e.geometries.map((r, t) => {
2947
2947
  const o = e.colors[t] ?? "#888888", l = t === e.innerIdx;
@@ -2975,7 +2975,7 @@ let __tla = (async () => {
2975
2975
  }),
2976
2976
  i("group", {
2977
2977
  position: s,
2978
- children: i(Xe, {
2978
+ children: i(Ze, {
2979
2979
  center: true,
2980
2980
  style: {
2981
2981
  pointerEvents: "none"
@@ -3005,7 +3005,7 @@ let __tla = (async () => {
3005
3005
  })
3006
3006
  });
3007
3007
  }
3008
- function ar({ geometry: e, aoData: r }) {
3008
+ function cr({ geometry: e, aoData: r }) {
3009
3009
  const t = H(() => {
3010
3010
  const o = e.toNonIndexed(), l = o.getAttribute("position"), s = r.length, c = l.count, a = new Float32Array(c * 3);
3011
3011
  for (let n = 0; n < s && n * 3 + 2 < c; n++) {
@@ -3034,8 +3034,8 @@ let __tla = (async () => {
3034
3034
  })
3035
3035
  });
3036
3036
  }
3037
- function cr({ mesh: e, layers: r, landmarkPoints: t, componentDebug: o, aoData: l, aoGeometry: s, measurementGeometry: c }) {
3038
- const a = e.geometry, n = H(() => a.getAttribute("position") ? zn(a) : null, [
3037
+ function dr({ mesh: e, layers: r, landmarkPoints: t, componentDebug: o, aoData: l, aoGeometry: s, measurementGeometry: c }) {
3038
+ const a = e.geometry, n = H(() => a.getAttribute("position") ? Fn(a) : null, [
3039
3039
  a
3040
3040
  ]), m = H(() => !t || t.length < 2 ? null : {
3041
3041
  red: new C(t[1].position.x, t[1].position.y, t[1].position.z),
@@ -3045,24 +3045,24 @@ let __tla = (async () => {
3045
3045
  ]);
3046
3046
  return k("group", {
3047
3047
  children: [
3048
- r.pcaAxes && n && i(er, {
3048
+ r.pcaAxes && n && i(tr, {
3049
3049
  pca: n
3050
3050
  }),
3051
- r.obb && n && i(tr, {
3051
+ r.obb && n && i(nr, {
3052
3052
  pca: n
3053
3053
  }),
3054
- r.obbAxis && n && i(ir, {
3054
+ r.obbAxis && n && i(sr, {
3055
3055
  pca: n,
3056
3056
  modelSize: n.halfExtents[0] ? Math.max(...n.halfExtents) * 2 : 100
3057
3057
  }),
3058
- r.shellComponents && o && i(lr, {
3058
+ r.shellComponents && o && i(ar, {
3059
3059
  componentDebug: o
3060
3060
  }),
3061
- r.ambientOcclusion && l && l.length > 0 && i(ar, {
3061
+ r.ambientOcclusion && l && l.length > 0 && i(cr, {
3062
3062
  geometry: s ?? a,
3063
3063
  aoData: l
3064
3064
  }),
3065
- r.circumferenceScan && m && i(sr, {
3065
+ r.circumferenceScan && m && i(lr, {
3066
3066
  geometry: a,
3067
3067
  redY: m.red.y,
3068
3068
  greenY: m.green.y,
@@ -3080,17 +3080,17 @@ let __tla = (async () => {
3080
3080
  depthWrite: false
3081
3081
  })
3082
3082
  }),
3083
- r.landmarkAxis && m && i(nr, {
3083
+ r.landmarkAxis && m && i(or, {
3084
3084
  redPoint: m.red,
3085
3085
  greenPoint: m.green
3086
3086
  }),
3087
- r.iterativePCA && m && i(or, {
3087
+ r.iterativePCA && m && i(rr, {
3088
3088
  geometry: a,
3089
3089
  redY: m.red.y,
3090
3090
  greenY: m.green.y,
3091
3091
  modelSize: (n == null ? void 0 : n.halfExtents[0]) ? Math.max(...n.halfExtents) * 2 : 100
3092
3092
  }),
3093
- r.fullRegionPCA && m && i(rr, {
3093
+ r.fullRegionPCA && m && i(ir, {
3094
3094
  geometry: a,
3095
3095
  redY: m.red.y,
3096
3096
  greenY: m.green.y,
@@ -3099,10 +3099,10 @@ let __tla = (async () => {
3099
3099
  ]
3100
3100
  });
3101
3101
  }
3102
- function dr({ mesh: e }) {
3102
+ function fr({ mesh: e }) {
3103
3103
  const r = e.geometry, t = H(() => {
3104
3104
  if (!r.getAttribute("position")) return null;
3105
- const s = zn(r), c = s.axes[0], a = s.halfExtents[0] * 1.3;
3105
+ const s = Fn(r), c = s.axes[0], a = s.halfExtents[0] * 1.3;
3106
3106
  return {
3107
3107
  axis: c,
3108
3108
  center: s.center,
@@ -3113,7 +3113,7 @@ let __tla = (async () => {
3113
3113
  ]);
3114
3114
  if (!t) return null;
3115
3115
  const o = t.center.clone().addScaledVector(t.axis, t.halfLen), l = t.center.clone().addScaledVector(t.axis, -t.halfLen);
3116
- return i(fe, {
3116
+ return i(de, {
3117
3117
  points: [
3118
3118
  l,
3119
3119
  o
@@ -3129,7 +3129,7 @@ let __tla = (async () => {
3129
3129
  renderOrder: 999
3130
3130
  });
3131
3131
  }
3132
- const kn = [
3132
+ const Pn = [
3133
3133
  {
3134
3134
  key: "pcaAxes",
3135
3135
  label: "PCA Axes (full mesh)",
@@ -3185,10 +3185,10 @@ let __tla = (async () => {
3185
3185
  color: "#00ffff",
3186
3186
  group: "Alignment"
3187
3187
  }
3188
- ], fr = [
3189
- ...new Set(kn.map((e) => e.group))
3188
+ ], ur = [
3189
+ ...new Set(Pn.map((e) => e.group))
3190
3190
  ];
3191
- function ur({ layers: e, onToggleLayer: r, isDoubleShell: t }) {
3191
+ function pr({ layers: e, onToggleLayer: r, isDoubleShell: t }) {
3192
3192
  return k("div", {
3193
3193
  style: {
3194
3194
  position: "absolute",
@@ -3217,8 +3217,8 @@ let __tla = (async () => {
3217
3217
  },
3218
3218
  children: "Debug Layers"
3219
3219
  }),
3220
- fr.map((o) => {
3221
- const l = kn.filter((s) => s.group === o && !(s.hideWhenDoubleShell && t));
3220
+ ur.map((o) => {
3221
+ const l = Pn.filter((s) => s.group === o && !(s.hideWhenDoubleShell && t));
3222
3222
  return l.length === 0 ? null : k("div", {
3223
3223
  children: [
3224
3224
  i("div", {
@@ -3278,179 +3278,179 @@ let __tla = (async () => {
3278
3278
  ]
3279
3279
  });
3280
3280
  }
3281
- const pr = ({ config: e, spacingType: r, scanUrl: t, formMeasurements: o, onComplete: l, isDebugUser: s = false, onAnalyticsEvent: c, wasmModule: a }) => {
3282
- const [n, m] = W(null), [d, f] = W(0), [u, x] = W(false), [S, p] = W(false), [g, b] = W(""), [A, L] = W("3D"), [z, P] = W(r === "AK" ? 2 : 1), [y, M] = W(false), [h, v] = W(null), [F, I] = W(r ?? null), [_, E] = W("mm"), [V, N] = W(false), [J, ye] = W(""), [ae, ue] = W(false), [ie, Q] = W(false), [Y, he] = W(false), [Z, ge] = W(false), [me, pe] = W(null), [$, ne] = W(null), [xe, Me] = W(null), [we, re] = W(false), [j, X] = W([]), [Le, Ie] = W(null), [Ge, se] = W(null), [Ae, Tt] = W(null), [xt, Fn] = W(null), [Pn, Ot] = W(false), [bt, Ln] = W(null), [yt, De] = W(null), [We, In] = W(false), [$t, Dn] = W(Qo), [$e, Ht] = W("obj"), [Se, wt] = W(o), [Ue, Vt] = W(true), [He, St] = W(false), [vt, _n] = W(false), [ze, rt] = W(false), [Rn, Ct] = W(false), [Je, Wn] = W(null), [Bn, En] = W(void 0), [Tn, On] = W(void 0), [jt] = W("#c8c8c8"), [$n] = W(1), [Ze, Hn] = W(false), [Mt, Nt] = W([]), it = le(null), Ve = le(null), zt = le(false), Vn = le(null), kt = le(null), At = le(null), Qe = te(async () => {
3283
- if (At.current) try {
3284
- const w = (await import("./html2canvas.esm-Dmi1NfiH.js")).default, D = At.current, B = 2, R = async (K = false) => {
3285
- const oe = await w(D, {
3281
+ const hr = ({ config: e, spacingType: r, scanUrl: t, formMeasurements: o, onComplete: l, isDebugUser: s = false, onAnalyticsEvent: c, wasmModule: a }) => {
3282
+ const [n, m] = B(null), [d, f] = B(0), [u, x] = B(false), [S, p] = B(false), [g, b] = B(""), [A, L] = B("3D"), [z, P] = B(r === "AK" ? 2 : 1), [w, M] = B(false), [h, v] = B(null), [F, I] = B(r ?? null), [_, E] = B("mm"), [V, Y] = B(false), [q, ye] = B(""), [ae, fe] = B(false), [ie, ee] = B(false), [X, ue] = B(false), [Z, pe] = B(false), [me, he] = B(null), [$, ne] = B(null), [xe, Se] = B(null), [we, re] = B(false), [j, N] = B([]), [Ie, Pe] = B(null), [Ke, se] = B(null), [Ae, vt] = B(null), [Ct, Vt] = B(null), [In, jt] = B(false), [Mt, Nt] = B(null), [zt, De] = B(null), [We, Dn] = B(false), [Yt, _n] = B(qo), [Ve, Xt] = B("obj"), [ve, kt] = B(o), [Je, At] = B(true), [je, rt] = B(false), [it, Gt] = B(false), [ze, st] = B(false), [Rn, Ft] = B(false), [Qe, Wn] = B(null), [Bn, En] = B(void 0), [Tn, On] = B(void 0), [Zt] = B("#c8c8c8"), [$n] = B(1), [Te, Hn] = B(false), [Pt, Kt] = B([]), lt = le(null), Ne = le(null), at = le(false), Vn = le(null), Lt = le(null), It = le(null), qe = J(async () => {
3283
+ if (It.current) try {
3284
+ const y = (await import("./html2canvas.esm-Dmi1NfiH.js")).default, D = It.current, R = 2, W = async (U = false) => {
3285
+ const oe = await y(D, {
3286
3286
  backgroundColor: null,
3287
3287
  useCORS: true,
3288
- scale: B,
3288
+ scale: R,
3289
3289
  ignoreElements: (nt) => {
3290
3290
  var _a, _b;
3291
3291
  return ((_a = nt.style) == null ? void 0 : _a.zIndex) === "10" || ((_b = nt.hasAttribute) == null ? void 0 : _b.call(nt, "data-finalizing-overlay"));
3292
3292
  }
3293
- }), ee = D.getBoundingClientRect(), Fe = ee.width, Be = ee.height;
3294
- let Ce, ke, be, Te;
3295
- if (K) {
3293
+ }), te = D.getBoundingClientRect(), Fe = te.width, Be = te.height;
3294
+ let Me, ke, be, $e;
3295
+ if (U) {
3296
3296
  const _e = oe.getContext("2d").getImageData(0, 0, oe.width, oe.height).data;
3297
- let Re = oe.width, Ee = oe.height, ot = 0, at = 0;
3298
- for (let je = 0; je < oe.height; je++) for (let Ne = 0; Ne < oe.width; Ne++) {
3299
- const to = (je * oe.width + Ne) * 4;
3300
- _e[to + 3] > 20 && (Ne < Re && (Re = Ne), Ne > ot && (ot = Ne), je < Ee && (Ee = je), je > at && (at = je));
3297
+ let Re = oe.width, Ee = oe.height, ot = 0, pt = 0;
3298
+ for (let Ye = 0; Ye < oe.height; Ye++) for (let Xe = 0; Xe < oe.width; Xe++) {
3299
+ const no = (Ye * oe.width + Xe) * 4;
3300
+ _e[no + 3] > 20 && (Xe < Re && (Re = Xe), Xe > ot && (ot = Xe), Ye < Ee && (Ee = Ye), Ye > pt && (pt = Ye));
3301
3301
  }
3302
- ot <= Re && (Re = 0, Ee = 0, ot = oe.width, at = oe.height), Ce = Re / B, ke = Ee / B, be = ot / B, Te = at / B;
3302
+ ot <= Re && (Re = 0, Ee = 0, ot = oe.width, pt = oe.height), Me = Re / R, ke = Ee / R, be = ot / R, $e = pt / R;
3303
3303
  } else {
3304
3304
  const nt = D.querySelectorAll("[style*='pointer-events: none']");
3305
- Ce = 1 / 0, ke = 1 / 0, be = -1 / 0, Te = -1 / 0, nt.forEach((_t) => {
3306
- const _e = _t.getBoundingClientRect();
3305
+ Me = 1 / 0, ke = 1 / 0, be = -1 / 0, $e = -1 / 0, nt.forEach((Et) => {
3306
+ const _e = Et.getBoundingClientRect();
3307
3307
  if (_e.width === 0 || _e.height === 0) return;
3308
- const Re = _e.left - ee.left, Ee = _e.top - ee.top;
3309
- Re < Ce && (Ce = Re), Ee < ke && (ke = Ee), Re + _e.width > be && (be = Re + _e.width), Ee + _e.height > Te && (Te = Ee + _e.height);
3310
- }), Ce === 1 / 0 && (Ce = 0, ke = 0, be = Fe, Te = Be);
3308
+ const Re = _e.left - te.left, Ee = _e.top - te.top;
3309
+ Re < Me && (Me = Re), Ee < ke && (ke = Ee), Re + _e.width > be && (be = Re + _e.width), Ee + _e.height > $e && ($e = Ee + _e.height);
3310
+ }), Me === 1 / 0 && (Me = 0, ke = 0, be = Fe, $e = Be);
3311
3311
  }
3312
- const en = Math.max(Fe, Be) * 0.03, tn = Math.max(Fe, Be) * 0.06;
3313
- Ce = Math.max(0, Ce - en), ke = Math.max(0, ke - tn), be = Math.min(Fe, be + en), Te = Math.min(Be, Te + tn);
3314
- const It = (be - Ce) * B, Dt = (Te - ke) * B, qn = Math.max(0, Ce * B), eo = Math.max(0, ke * B), lt = document.createElement("canvas");
3315
- return lt.width = Math.round(It), lt.height = Math.round(Dt), lt.getContext("2d").drawImage(oe, Math.round(qn), Math.round(eo), Math.round(It), Math.round(Dt), 0, 0, Math.round(It), Math.round(Dt)), lt.toDataURL("image/png");
3312
+ const on = Math.max(Fe, Be) * 0.03, rn = Math.max(Fe, Be) * 0.06;
3313
+ Me = Math.max(0, Me - on), ke = Math.max(0, ke - rn), be = Math.min(Fe, be + on), $e = Math.min(Be, $e + rn);
3314
+ const Wt = (be - Me) * R, Bt = ($e - ke) * R, eo = Math.max(0, Me * R), to = Math.max(0, ke * R), ut = document.createElement("canvas");
3315
+ return ut.width = Math.round(Wt), ut.height = Math.round(Bt), ut.getContext("2d").drawImage(oe, Math.round(eo), Math.round(to), Math.round(Wt), Math.round(Bt), 0, 0, Math.round(Wt), Math.round(Bt)), ut.toDataURL("image/png");
3316
3316
  };
3317
- kt.current && kt.current(), await new Promise((K) => setTimeout(K, 100)), await new Promise((K) => requestAnimationFrame(() => requestAnimationFrame(K)));
3318
- const ce = await R();
3319
- L("2D"), await new Promise((K) => setTimeout(K, 200)), await new Promise((K) => requestAnimationFrame(() => requestAnimationFrame(K)));
3320
- const G = await R(true);
3317
+ Lt.current && Lt.current(), await new Promise((U) => setTimeout(U, 100)), await new Promise((U) => requestAnimationFrame(() => requestAnimationFrame(U)));
3318
+ const ge = await W();
3319
+ L("2D"), await new Promise((U) => setTimeout(U, 200)), await new Promise((U) => requestAnimationFrame(() => requestAnimationFrame(U)));
3320
+ const G = await W(true);
3321
3321
  return L("3D"), {
3322
- frontal_view_png: ce,
3322
+ frontal_view_png: ge,
3323
3323
  side_view_png: G
3324
3324
  };
3325
3325
  } catch {
3326
3326
  return;
3327
3327
  }
3328
- }, []), ve = te((w) => {
3329
- const D = /* @__PURE__ */ new Date(), B = `${String(D.getHours()).padStart(2, "0")}:${String(D.getMinutes()).padStart(2, "0")}:${String(D.getSeconds()).padStart(2, "0")}.${String(D.getMilliseconds()).padStart(3, "0")}`;
3330
- Nt((R) => [
3331
- ...R.slice(-200),
3332
- `[${B}] ${w}`
3328
+ }, []), Ce = J((y) => {
3329
+ const D = /* @__PURE__ */ new Date(), R = `${String(D.getHours()).padStart(2, "0")}:${String(D.getMinutes()).padStart(2, "0")}:${String(D.getSeconds()).padStart(2, "0")}.${String(D.getMilliseconds()).padStart(3, "0")}`;
3330
+ Kt((W) => [
3331
+ ...W.slice(-200),
3332
+ `[${R}] ${y}`
3333
3333
  ]);
3334
- }, []), { landmarkPoints: T, clearLandmarkPoints: jn, addLandmarkPoint: Yt, removeLandmarkPoint: Xt, updateLandmarkPositions: Gt, setAligned: Zt, isAligned: q, setCut: Kt, isCut: Ft, reset: Ut } = Et();
3335
- U(() => {
3336
- Ut();
3334
+ }, []), { landmarkPoints: T, clearLandmarkPoints: jn, addLandmarkPoint: Ut, removeLandmarkPoint: Jt, updateLandmarkPositions: Qt, setAligned: qt, isAligned: K, setCut: en, isCut: Dt, reset: ct } = Ht();
3335
+ Q(() => {
3336
+ ct();
3337
3337
  }, [
3338
- Ut
3338
+ ct
3339
3339
  ]);
3340
- const st = z * ut;
3341
- U(() => {
3340
+ const dt = z * xt;
3341
+ Q(() => {
3342
3342
  if (!s || T.length === 0) return;
3343
- const w = T[T.length - 1];
3344
- ve(`LANDMARK[${T.length - 1}]: placed at (${w.position.x.toFixed(1)}, ${w.position.y.toFixed(1)}, ${w.position.z.toFixed(1)}) face=${w.faceIndex}`);
3343
+ const y = T[T.length - 1];
3344
+ Ce(`LANDMARK[${T.length - 1}]: placed at (${y.position.x.toFixed(1)}, ${y.position.y.toFixed(1)}, ${y.position.z.toFixed(1)}) face=${y.faceIndex}`);
3345
3345
  }, [
3346
3346
  T.length,
3347
3347
  s,
3348
- ve
3349
- ]), U(() => {
3350
- s && q && ve("STATE: mesh aligned");
3348
+ Ce
3349
+ ]), Q(() => {
3350
+ s && K && Ce("STATE: mesh aligned");
3351
3351
  }, [
3352
- q,
3352
+ K,
3353
3353
  s,
3354
- ve
3355
- ]), U(() => {
3356
- s && Ft && ve("STATE: mesh cut");
3354
+ Ce
3355
+ ]), Q(() => {
3356
+ s && Dt && Ce("STATE: mesh cut");
3357
3357
  }, [
3358
- Ft,
3358
+ Dt,
3359
3359
  s,
3360
- ve
3361
- ]), U(() => {
3362
- it.current && (it.current.scrollTop = it.current.scrollHeight);
3360
+ Ce
3361
+ ]), Q(() => {
3362
+ lt.current && (lt.current.scrollTop = lt.current.scrollHeight);
3363
3363
  }, [
3364
- Mt
3364
+ Pt
3365
3365
  ]);
3366
- const Jt = H(() => xe ? new O.Mesh(xe) : null, [
3366
+ const tn = H(() => xe ? new O.Mesh(xe) : null, [
3367
3367
  xe
3368
3368
  ]);
3369
- U(() => {
3370
- o && wt(o);
3369
+ Q(() => {
3370
+ o && kt(o);
3371
3371
  }, [
3372
3372
  o
3373
- ]), U(() => {
3374
- o || wt(void 0);
3373
+ ]), Q(() => {
3374
+ o || kt(void 0);
3375
3375
  }, [
3376
3376
  z
3377
3377
  ]);
3378
- const Pt = le(false);
3379
- U(() => {
3380
- if (!q || j.length === 0 || Pt.current || !c) return;
3381
- Pt.current = true;
3382
- const w = T.length >= 3 ? Math.abs(T[2].position.y - T[0].position.y) : null;
3378
+ const ft = le(false);
3379
+ Q(() => {
3380
+ if (!K || j.length === 0 || ft.current || !c) return;
3381
+ ft.current = true;
3382
+ const y = T.length >= 3 ? Math.abs(T[2].position.y - T[0].position.y) : null;
3383
3383
  c("dimensions_calculated", {
3384
3384
  spacing_type: F,
3385
3385
  source_unit: "mm",
3386
- file_format: $e,
3386
+ file_format: Ve,
3387
3387
  measurement_source: "scan_derived",
3388
- is_double_wall: Y,
3388
+ is_double_wall: X,
3389
3389
  is_unit_converted: false,
3390
- form_measurements: (Se == null ? void 0 : Se.filter((D) => D != null)) ?? null,
3390
+ form_measurements: (ve == null ? void 0 : ve.filter((D) => D != null)) ?? null,
3391
3391
  scan_measurements: j.map((D) => +(D.modifiedValue ?? D.originalValue).toFixed(1)),
3392
- measurement_variance: Se ? j.map((D, B) => {
3393
- const R = Se[B];
3394
- return R == null ? null : +((D.modifiedValue ?? D.originalValue) - R).toFixed(1);
3392
+ measurement_variance: ve ? j.map((D, R) => {
3393
+ const W = ve[R];
3394
+ return W == null ? null : +((D.modifiedValue ?? D.originalValue) - W).toFixed(1);
3395
3395
  }) : null,
3396
- frontal_height: w !== null ? +w.toFixed(1) : null
3396
+ frontal_height: y !== null ? +y.toFixed(1) : null
3397
3397
  });
3398
3398
  }, [
3399
- q,
3399
+ K,
3400
3400
  j
3401
- ]), U(() => {
3402
- a !== void 0 && (Ve.current = a), Hn(true);
3401
+ ]), Q(() => {
3402
+ a !== void 0 && (Ne.current = a), Hn(true);
3403
3403
  }, [
3404
3404
  a
3405
3405
  ]);
3406
- const qe = te((w, D) => {
3407
- w.computeBoundingBox();
3408
- const B = w.boundingBox, R = new C();
3409
- B.getCenter(R), w.translate(-R.x, -R.y, -R.z), w.computeBoundingBox();
3410
- const ce = w.boundingBox, G = new C();
3411
- ce.getSize(G), f(Math.max(G.x, G.y, G.z));
3412
- const K = new O.Mesh(w, new O.MeshStandardMaterial({
3406
+ const et = J((y, D) => {
3407
+ y.computeBoundingBox();
3408
+ const R = y.boundingBox, W = new C();
3409
+ R.getCenter(W), y.translate(-W.x, -W.y, -W.z), y.computeBoundingBox();
3410
+ const ge = y.boundingBox, G = new C();
3411
+ ge.getSize(G), f(Math.max(G.x, G.y, G.z));
3412
+ const U = new O.Mesh(y, new O.MeshStandardMaterial({
3413
3413
  color: 8947848,
3414
3414
  side: O.DoubleSide
3415
3415
  }));
3416
- m(K), ue(D), Q(true), ge(false), zt.current = false;
3417
- }, []), et = te(async (w, D) => {
3416
+ m(U), fe(D), ee(true), pe(false), at.current = false;
3417
+ }, []), Oe = J(async (y, D) => {
3418
3418
  De(null);
3419
- const B = D.toLowerCase(), R = B.endsWith(".stl");
3420
- if (!B.endsWith(".obj") && !R) {
3419
+ const R = D.toLowerCase(), W = R.endsWith(".stl");
3420
+ if (!R.endsWith(".obj") && !W) {
3421
3421
  De("Unsupported file format. Please use OBJ or STL.");
3422
3422
  return;
3423
3423
  }
3424
- Ht(R ? "stl" : "obj"), p(true), b("Processing file..."), ve(`FILE_LOAD: ${D} (${R ? "STL" : "OBJ"})`);
3424
+ Xt(W ? "stl" : "obj"), p(true), b("Processing file..."), Ce(`FILE_LOAD: ${D} (${W ? "STL" : "OBJ"})`);
3425
3425
  try {
3426
3426
  let G;
3427
- if (R) if (b("Converting STL..."), w instanceof ArrayBuffer) {
3428
- const ee = new Blob([
3429
- w
3427
+ if (W) if (b("Converting STL..."), y instanceof ArrayBuffer) {
3428
+ const te = new Blob([
3429
+ y
3430
3430
  ]), Fe = new File([
3431
- ee
3431
+ te
3432
3432
  ], D);
3433
- G = await Rt(Fe);
3433
+ G = await Tt(Fe);
3434
3434
  } else {
3435
- const ee = new Blob([
3436
- w
3435
+ const te = new Blob([
3436
+ y
3437
3437
  ]), Fe = new File([
3438
- ee
3438
+ te
3439
3439
  ], D);
3440
- G = await Rt(Fe);
3440
+ G = await Tt(Fe);
3441
3441
  }
3442
- else G = typeof w == "string" ? w : new TextDecoder().decode(w);
3443
- const K = performance.now(), oe = Ve.current ? await bo(G, Ve.current, (ee) => {
3444
- b(ee), ve(`PREPROCESS: ${ee}`);
3442
+ else G = typeof y == "string" ? y : new TextDecoder().decode(y);
3443
+ const U = performance.now(), oe = Ne.current ? await yo(G, Ne.current, (te) => {
3444
+ b(te), Ce(`PREPROCESS: ${te}`);
3445
3445
  }) : null;
3446
- if (oe) ve(`PREPROCESS: done in ${(performance.now() - K).toFixed(0)}ms \u2014 unit=${oe.detectedUnit}, scaled=${oe.wasScaled}`), e.showAmputationModal && !r ? (v(oe), M(true)) : qe(oe.geometry, oe.wasScaled);
3446
+ if (oe) Ce(`PREPROCESS: done in ${(performance.now() - U).toFixed(0)}ms \u2014 unit=${oe.detectedUnit}, scaled=${oe.wasScaled}`), e.showAmputationModal && !r ? (v(oe), M(true)) : et(oe.geometry, oe.wasScaled);
3447
3447
  else {
3448
3448
  b("Using fallback loader...");
3449
- const ee = yo(G);
3450
- ee ? e.showAmputationModal && !r ? (v({
3451
- geometry: ee,
3449
+ const te = wo(G);
3450
+ te ? e.showAmputationModal && !r ? (v({
3451
+ geometry: te,
3452
3452
  wasScaled: false
3453
- }), M(true)) : qe(ee, false) : De("Failed to parse the mesh.");
3453
+ }), M(true)) : et(te, false) : De("Failed to parse the mesh.");
3454
3454
  }
3455
3455
  } catch (G) {
3456
3456
  De(G instanceof Error ? G.message : "Failed to process the mesh file.");
@@ -3458,25 +3458,25 @@ let __tla = (async () => {
3458
3458
  p(false), b("");
3459
3459
  }
3460
3460
  }, [
3461
- Ze,
3461
+ Te,
3462
3462
  e.showAmputationModal,
3463
3463
  r,
3464
- qe
3464
+ et
3465
3465
  ]);
3466
- U(() => {
3467
- if (!t || !Ze) return;
3466
+ Q(() => {
3467
+ if (!t || !Te) return;
3468
3468
  (async () => {
3469
3469
  p(true), b("Loading scan...");
3470
3470
  try {
3471
3471
  const D = await fetch(t);
3472
3472
  if (!D.ok) throw new Error(`Failed to download scan: ${D.status}`);
3473
- const R = new URL(t).pathname.split("/").pop() || "scan.obj";
3474
- if (R.toLowerCase().endsWith(".stl")) {
3473
+ const W = new URL(t).pathname.split("/").pop() || "scan.obj";
3474
+ if (W.toLowerCase().endsWith(".stl")) {
3475
3475
  const G = await D.arrayBuffer();
3476
- await et(G, R);
3476
+ await Oe(G, W);
3477
3477
  } else {
3478
3478
  const G = await D.text();
3479
- await et(G, R);
3479
+ await Oe(G, W);
3480
3480
  }
3481
3481
  } catch (D) {
3482
3482
  De(D instanceof Error ? D.message : "Failed to load scan from URL."), p(false), b("");
@@ -3484,219 +3484,234 @@ let __tla = (async () => {
3484
3484
  })();
3485
3485
  }, [
3486
3486
  t,
3487
- Ze
3487
+ Te
3488
3488
  ]);
3489
- const Nn = te((w) => {
3490
- w.preventDefault(), x(true);
3491
- }, []), Yn = te((w) => {
3492
- w.preventDefault(), x(false);
3493
- }, []), Xn = te(async (w) => {
3494
- if (w.preventDefault(), x(false), !Ze) {
3489
+ const Nn = J((y) => {
3490
+ y.preventDefault(), x(true);
3491
+ }, []), Yn = J((y) => {
3492
+ y.preventDefault(), x(false);
3493
+ }, []), Xn = J(async (y) => {
3494
+ if (y.preventDefault(), x(false), !Te) {
3495
3495
  De("WASM module is still loading. Please wait.");
3496
3496
  return;
3497
3497
  }
3498
- const D = w.dataTransfer.files[0];
3498
+ const D = y.dataTransfer.files[0];
3499
3499
  if (!D) return;
3500
- const B = D.name.toLowerCase();
3501
- if (!B.endsWith(".obj") && !B.endsWith(".stl")) {
3500
+ const R = D.name.toLowerCase();
3501
+ if (!R.endsWith(".obj") && !R.endsWith(".stl")) {
3502
3502
  De("Please drop an OBJ or STL file.");
3503
3503
  return;
3504
3504
  }
3505
- if (B.endsWith(".stl")) {
3506
- Ht("stl"), p(true), b("Converting STL...");
3505
+ if (R.endsWith(".stl")) {
3506
+ Xt("stl"), p(true), b("Converting STL...");
3507
3507
  try {
3508
- const R = await Rt(D);
3509
- await et(R, D.name.replace(/\.stl$/i, ".obj"));
3510
- } catch (R) {
3511
- De(R instanceof Error ? R.message : "Failed to process STL file."), p(false), b("");
3508
+ const W = await Tt(D);
3509
+ await Oe(W, D.name.replace(/\.stl$/i, ".obj"));
3510
+ } catch (W) {
3511
+ De(W instanceof Error ? W.message : "Failed to process STL file."), p(false), b("");
3512
3512
  }
3513
3513
  } else {
3514
- const R = await D.text();
3515
- await et(R, D.name);
3514
+ const W = await D.text();
3515
+ await Oe(W, D.name);
3516
3516
  }
3517
3517
  }, [
3518
- Ze,
3519
- et
3520
- ]), Gn = te((w) => {
3521
- I(w), P(w === "AK" ? 2 : 1), M(false), h && (qe(h.geometry, h.wasScaled), v(null)), c == null ? void 0 : c("file_loaded", {
3522
- spacing_type: w,
3523
- file_format: $e,
3518
+ Te,
3519
+ Oe
3520
+ ]), Gn = J((y) => {
3521
+ I(y), P(y === "AK" ? 2 : 1), M(false), h && (et(h.geometry, h.wasScaled), v(null)), c == null ? void 0 : c("file_loaded", {
3522
+ spacing_type: y,
3523
+ file_format: Ve,
3524
3524
  is_double_wall: false
3525
3525
  });
3526
3526
  }, [
3527
3527
  h,
3528
- qe,
3528
+ et,
3529
3529
  c,
3530
- $e
3530
+ Ve
3531
3531
  ]);
3532
- U(() => {
3533
- if (!n || T.length !== 1 || !Ve.current || zt.current) return;
3534
- zt.current = true;
3535
- const w = T[0], D = Ve.current, B = n.geometry, { positions: R, indices: ce } = pt(B), G = new Float32Array([
3536
- w.position.x,
3537
- w.position.y,
3538
- w.position.z
3539
- ]), K = D.detect_shell(R, ce, G, 40), oe = K.details(), ee = K.is_double_shell();
3540
- ve(`SHELL_DETECT: ${ee ? "DOUBLE" : "SINGLE"} \u2014 ${oe}`), ee && (he(true), re(true), ve(`SHELL_DETECT: double shell, thickness=${K.thickness().toFixed(1)}mm`));
3532
+ Q(() => {
3533
+ if (!n || T.length !== 1 || !Ne.current || at.current) return;
3534
+ at.current = true;
3535
+ const y = T[0], D = Ne.current, R = n.geometry, { positions: W, indices: ge } = bt(R), G = new Float32Array([
3536
+ y.position.x,
3537
+ y.position.y,
3538
+ y.position.z
3539
+ ]), U = D.detect_shell(W, ge, G, 40), oe = U.details(), te = U.is_double_shell();
3540
+ Ce(`SHELL_DETECT: ${te ? "DOUBLE" : "SINGLE"} \u2014 ${oe}`), te && (ue(true), re(true), Ce(`SHELL_DETECT: double shell, thickness=${U.thickness().toFixed(1)}mm`));
3541
3541
  }, [
3542
3542
  n,
3543
3543
  T,
3544
- ve
3544
+ Ce
3545
3545
  ]);
3546
- const Zn = te(() => {
3546
+ const Zn = J(() => {
3547
3547
  if (!n || T.length < 2) return;
3548
- N(true), ye("Please wait..."), ve("PIPELINE: starting processing pipeline...");
3549
- const w = performance.now();
3548
+ Y(true), ye("Please wait..."), Ce("PIPELINE: starting processing pipeline...");
3549
+ const y = performance.now();
3550
3550
  setTimeout(() => {
3551
3551
  const D = [
3552
3552
  T[1],
3553
3553
  T[0],
3554
3554
  ...T.slice(2)
3555
3555
  ];
3556
- Mo(n, D, ut, {
3557
- onStatus: (B) => {
3558
- ye(B), ve(`PIPELINE: ${B}`);
3556
+ zo(n, D, xt, {
3557
+ onStatus: (R) => {
3558
+ ye(R), Ce(`PIPELINE: ${R}`);
3559
3559
  },
3560
- addLandmarkPoint: Yt,
3561
- removeLandmarkPoint: Xt,
3562
- updateLandmarkPositions: (B) => {
3563
- const R = [
3564
- B[1],
3565
- B[0],
3566
- ...B.slice(2)
3560
+ addLandmarkPoint: Ut,
3561
+ removeLandmarkPoint: Jt,
3562
+ updateLandmarkPositions: (R) => {
3563
+ const W = [
3564
+ R[1],
3565
+ R[0],
3566
+ ...R.slice(2)
3567
3567
  ];
3568
- Gt(R);
3568
+ Qt(W);
3569
3569
  },
3570
- setAligned: Zt,
3571
- setCut: Kt,
3570
+ setAligned: qt,
3571
+ setCut: en,
3572
3572
  setModelSize: f,
3573
- setOriginalEndY: Fn,
3573
+ setOriginalEndY: Vt,
3574
3574
  setAdjustedStartY: se,
3575
- setAdjustedEndY: Tt,
3575
+ setAdjustedEndY: vt,
3576
3576
  setError: De,
3577
- setDoubleShell: (B) => {
3578
- he(B), re(true);
3577
+ setDoubleShell: (R) => {
3578
+ ue(R), re(true);
3579
3579
  },
3580
- setAoData: (B, R) => {
3581
- pe(B), ne(R ?? null);
3580
+ setAoData: (R, W) => {
3581
+ he(R), ne(W ?? null);
3582
3582
  },
3583
- setInnerShellExtracted: ge,
3584
- setMeasurementGeometry: Me,
3585
- setWasmSlices: Ie,
3586
- wasmModule: Ve.current ?? void 0
3587
- }), ve(`PIPELINE: completed in ${(performance.now() - w).toFixed(0)}ms`), Pt.current = false, N(false);
3583
+ setInnerShellExtracted: pe,
3584
+ setMeasurementGeometry: Se,
3585
+ setWasmSlices: Pe,
3586
+ wasmModule: Ne.current ?? void 0
3587
+ }), Ce(`PIPELINE: completed in ${(performance.now() - y).toFixed(0)}ms`), ft.current = false, Y(false);
3588
3588
  }, 50);
3589
3589
  }, [
3590
3590
  n,
3591
3591
  T,
3592
- Gt,
3593
- Zt,
3594
- Yt,
3595
- Xt,
3596
- Kt,
3592
+ Qt,
3593
+ qt,
3594
+ Ut,
3595
+ Jt,
3596
+ en,
3597
3597
  Z
3598
- ]), Qt = le(false);
3599
- U(() => {
3600
- q && j.length > 0 && !Qt.current && (Qt.current = true, St(true));
3598
+ ]), _t = le(false), Kn = J(async () => {
3599
+ if (ct(), N([]), Pe(null), Se(null), se(null), vt(null), Nt(null), Vt(null), rt(false), Gt(false), At(true), ue(false), pe(false), at.current = false, _t.current = false, ft.current = false, L("3D"), t && Te) {
3600
+ m(null);
3601
+ try {
3602
+ const y = await fetch(t);
3603
+ if (!y.ok) throw new Error(`Failed to download scan: ${y.status}`);
3604
+ const R = new URL(t).pathname.split("/").pop() || "scan.obj";
3605
+ R.toLowerCase().endsWith(".stl") ? await Oe(await y.arrayBuffer(), R) : await Oe(await y.text(), R);
3606
+ } catch (y) {
3607
+ De(y instanceof Error ? y.message : "Failed to reload scan.");
3608
+ }
3609
+ }
3610
+ }, [
3611
+ t,
3612
+ Te,
3613
+ Oe,
3614
+ ct
3615
+ ]);
3616
+ Q(() => {
3617
+ K && j.length > 0 && !_t.current && (_t.current = true, rt(true));
3601
3618
  }, [
3602
- q,
3619
+ K,
3603
3620
  j.length
3604
3621
  ]);
3605
3622
  const tt = H(() => {
3606
3623
  var _a;
3607
3624
  if (!n || T.length < 3) return 0;
3608
- if (Y) return Math.abs(T[0].position.y - T[2].position.y);
3609
- const w = n.geometry;
3610
- w.computeBoundingBox();
3611
- const D = ((_a = w.boundingBox) == null ? void 0 : _a.min.y) ?? 0;
3625
+ if (X) return Math.abs(T[0].position.y - T[2].position.y);
3626
+ const y = n.geometry;
3627
+ y.computeBoundingBox();
3628
+ const D = ((_a = y.boundingBox) == null ? void 0 : _a.min.y) ?? 0;
3612
3629
  return Math.abs(T[0].position.y - D);
3613
3630
  }, [
3614
3631
  n,
3615
3632
  T,
3616
- Y
3617
- ]), Kn = te((w) => {
3618
- Wn(w), wt(w.circumferences), Vt(true), _n(true);
3619
- }, []), qt = te(async (w) => {
3620
- if (l) {
3621
- St(false), Ct(false), rt(true);
3622
- try {
3623
- const D = n ? await Promise.race([
3624
- Qe(),
3625
- new Promise((B) => setTimeout(() => B(void 0), 8e3))
3626
- ]) : void 0;
3627
- l({
3628
- spacingType: F ?? "BK",
3629
- sourceUnit: "mm",
3630
- fileFormat: $e,
3631
- measurementSource: "form_provided",
3632
- isDoubleWall: Y,
3633
- isUnitConverted: false,
3634
- formMeasurements: Se,
3635
- scanMeasurements: j,
3636
- frontalHeight: tt,
3637
- transverseML: 0,
3638
- transverseAP: 0,
3639
- scanUrl: t,
3640
- decision: "skip",
3641
- skipReason: w,
3642
- screenshots: D
3643
- });
3644
- } finally {
3645
- rt(false);
3646
- }
3633
+ X
3634
+ ]), Un = J((y) => {
3635
+ Wn(y), kt(y.circumferences), At(true), Gt(true);
3636
+ }, []), nn = J(async (y) => {
3637
+ if (!l) return;
3638
+ const D = n ? await Promise.race([
3639
+ qe(),
3640
+ new Promise((R) => setTimeout(() => R(void 0), 8e3))
3641
+ ]) : void 0;
3642
+ rt(false), Ft(false), st(true);
3643
+ try {
3644
+ l({
3645
+ spacingType: F ?? "BK",
3646
+ sourceUnit: "mm",
3647
+ fileFormat: Ve,
3648
+ measurementSource: "form_provided",
3649
+ isDoubleWall: X,
3650
+ isUnitConverted: false,
3651
+ formMeasurements: ve,
3652
+ scanMeasurements: j,
3653
+ frontalHeight: tt,
3654
+ transverseML: 0,
3655
+ transverseAP: 0,
3656
+ scanUrl: t,
3657
+ decision: "skip",
3658
+ skipReason: y,
3659
+ screenshots: D
3660
+ });
3661
+ } finally {
3662
+ st(false);
3647
3663
  }
3648
3664
  }, [
3649
3665
  l,
3650
3666
  n,
3651
3667
  F,
3652
- $e,
3653
- Y,
3654
- Se,
3668
+ Ve,
3669
+ X,
3670
+ ve,
3655
3671
  j,
3656
3672
  tt,
3657
3673
  t,
3658
- Qe
3659
- ]), Lt = te(async (w) => {
3660
- if (!(!l || !n || j.length === 0 || !F)) {
3661
- rt(true);
3662
- try {
3663
- let D = 0, B = 0;
3664
- if (T.length >= 2) {
3665
- const ce = n.geometry, K = T[0].position.y;
3666
- try {
3667
- const oe = Sn(ce), ee = Ye(oe, ce, K);
3668
- if (ee.linePoints.length >= 2) {
3669
- let Fe = ee.linePoints[0], Be = ee.linePoints[0], Ce = ee.linePoints[0], ke = ee.linePoints[0];
3670
- for (const be of ee.linePoints) be.x < Fe.x && (Fe = be), be.x > Be.x && (Be = be), be.z < Ce.z && (Ce = be), be.z > ke.z && (ke = be);
3671
- D = new C(Fe.x, K, Fe.z).distanceTo(new C(Be.x, K, Be.z)), B = new C(Ce.x, K, Ce.z).distanceTo(new C(ke.x, K, ke.z));
3672
- }
3673
- } catch {
3674
+ qe
3675
+ ]), Rt = J(async (y) => {
3676
+ if (!l || !n || j.length === 0 || !F) return;
3677
+ const D = await Promise.race([
3678
+ qe(),
3679
+ new Promise((R) => setTimeout(() => R(void 0), 8e3))
3680
+ ]);
3681
+ st(true);
3682
+ try {
3683
+ let R = 0, W = 0;
3684
+ if (T.length >= 2) {
3685
+ const ge = n.geometry, U = T[0].position.y;
3686
+ try {
3687
+ const oe = Mn(ge), te = Ge(oe, ge, U);
3688
+ if (te.linePoints.length >= 2) {
3689
+ let Fe = te.linePoints[0], Be = te.linePoints[0], Me = te.linePoints[0], ke = te.linePoints[0];
3690
+ for (const be of te.linePoints) be.x < Fe.x && (Fe = be), be.x > Be.x && (Be = be), be.z < Me.z && (Me = be), be.z > ke.z && (ke = be);
3691
+ R = new C(Fe.x, U, Fe.z).distanceTo(new C(Be.x, U, Be.z)), W = new C(Me.x, U, Me.z).distanceTo(new C(ke.x, U, ke.z));
3674
3692
  }
3693
+ } catch {
3675
3694
  }
3676
- const R = await Promise.race([
3677
- Qe(),
3678
- new Promise((ce) => setTimeout(() => ce(void 0), 8e3))
3679
- ]);
3680
- l({
3681
- spacingType: F,
3682
- sourceUnit: "mm",
3683
- fileFormat: $e,
3684
- measurementSource: w === "use_form_measurements" ? "form_provided" : "scan_derived",
3685
- isDoubleWall: Y,
3686
- isUnitConverted: false,
3687
- formMeasurements: Se,
3688
- scanMeasurements: j,
3689
- frontalHeight: (Je == null ? void 0 : Je.frontalHeight) ?? tt,
3690
- transverseML: D,
3691
- transverseAP: B,
3692
- scanUrl: t,
3693
- decision: w,
3694
- userEnteredMeasurements: Je ?? void 0,
3695
- screenshots: R
3696
- });
3697
- } finally {
3698
- rt(false);
3699
3695
  }
3696
+ l({
3697
+ spacingType: F,
3698
+ sourceUnit: "mm",
3699
+ fileFormat: Ve,
3700
+ measurementSource: y === "use_form_measurements" ? "form_provided" : "scan_derived",
3701
+ isDoubleWall: X,
3702
+ isUnitConverted: false,
3703
+ formMeasurements: ve,
3704
+ scanMeasurements: j,
3705
+ frontalHeight: (Qe == null ? void 0 : Qe.frontalHeight) ?? tt,
3706
+ transverseML: R,
3707
+ transverseAP: W,
3708
+ scanUrl: t,
3709
+ decision: y,
3710
+ userEnteredMeasurements: Qe ?? void 0,
3711
+ screenshots: D
3712
+ });
3713
+ } finally {
3714
+ st(false);
3700
3715
  }
3701
3716
  }, [
3702
3717
  l,
@@ -3704,28 +3719,28 @@ let __tla = (async () => {
3704
3719
  j,
3705
3720
  F,
3706
3721
  T,
3707
- $e,
3708
- Y,
3709
- Se,
3722
+ Ve,
3723
+ X,
3724
+ ve,
3710
3725
  t,
3711
- Je,
3726
+ Qe,
3712
3727
  tt,
3713
- Qe
3714
- ]), Un = H(() => {
3715
- if (!Se || j.length === 0) return false;
3716
- const w = Math.min(Se.length, j.length);
3717
- if (w === 0) return false;
3718
- for (let D = 0; D < w; D++) {
3719
- const B = Se[D], R = j[D];
3720
- if (!R || B == null || B === 0) continue;
3721
- const ce = R.modifiedValue ?? R.originalValue;
3722
- if (Math.abs(ce - B) > 7) return false;
3728
+ qe
3729
+ ]), Jn = H(() => {
3730
+ if (!ve || j.length === 0) return false;
3731
+ const y = Math.min(ve.length, j.length);
3732
+ if (y === 0) return false;
3733
+ for (let D = 0; D < y; D++) {
3734
+ const R = ve[D], W = j[D];
3735
+ if (!W || R == null || R === 0) continue;
3736
+ const ge = W.modifiedValue ?? W.originalValue;
3737
+ if (Math.abs(ge - R) > 7) return false;
3723
3738
  }
3724
3739
  return true;
3725
3740
  }, [
3726
- Se,
3741
+ ve,
3727
3742
  j
3728
- ]), Jn = vt ? 5 : q && He || q ? 4 : n ? T.length === 0 ? 2 : 3 : 1, Qn = [
3743
+ ]), Qn = it ? 5 : K && je || K ? 4 : n ? T.length === 0 ? 2 : 3 : 1, qn = [
3729
3744
  {
3730
3745
  label: "Load File",
3731
3746
  number: 1
@@ -3747,7 +3762,7 @@ let __tla = (async () => {
3747
3762
  number: 5
3748
3763
  }
3749
3764
  ];
3750
- return k(po.Provider, {
3765
+ return k(ho.Provider, {
3751
3766
  value: e,
3752
3767
  children: [
3753
3768
  k("div", {
@@ -3779,9 +3794,9 @@ let __tla = (async () => {
3779
3794
  }
3780
3795
  })
3781
3796
  }),
3782
- i(jo, {
3783
- steps: Qn,
3784
- currentStep: Jn
3797
+ i(No, {
3798
+ steps: qn,
3799
+ currentStep: Qn
3785
3800
  }),
3786
3801
  k("div", {
3787
3802
  style: {
@@ -3799,28 +3814,28 @@ let __tla = (async () => {
3799
3814
  minHeight: 0
3800
3815
  },
3801
3816
  children: [
3802
- q && He && F && i("div", {
3817
+ K && je && F && i("div", {
3803
3818
  style: {
3804
3819
  width: 340,
3805
3820
  flexShrink: 0,
3806
3821
  borderRight: "1px solid #e0e0e0",
3807
3822
  overflow: "hidden"
3808
3823
  },
3809
- children: i(Jo, {
3824
+ children: i(Qo, {
3810
3825
  amputationType: F,
3811
3826
  spacingInches: z,
3812
3827
  scanMeasurements: j,
3813
3828
  scanFrontalHeight: tt,
3814
- onSave: Kn,
3815
- onSkip: qt,
3829
+ onSave: Un,
3830
+ onSkip: nn,
3816
3831
  onFormChange: En,
3817
3832
  onHeightChange: On,
3818
- initialValues: Se,
3819
- initialFrontalHeight: Je == null ? void 0 : Je.frontalHeight
3833
+ initialValues: ve,
3834
+ initialFrontalHeight: Qe == null ? void 0 : Qe.frontalHeight
3820
3835
  })
3821
3836
  }),
3822
3837
  k("div", {
3823
- ref: At,
3838
+ ref: It,
3824
3839
  style: {
3825
3840
  flex: 1,
3826
3841
  position: "relative",
@@ -3842,7 +3857,7 @@ let __tla = (async () => {
3842
3857
  justifyContent: "center",
3843
3858
  pointerEvents: "none"
3844
3859
  },
3845
- children: Ze ? i("div", {
3860
+ children: Te ? i("div", {
3846
3861
  style: {
3847
3862
  fontSize: 18,
3848
3863
  color: "#aaa",
@@ -3880,7 +3895,7 @@ let __tla = (async () => {
3880
3895
  ]
3881
3896
  })
3882
3897
  }),
3883
- !e.showDragDrop && !n && !S && !yt && i("div", {
3898
+ !e.showDragDrop && !n && !S && !zt && i("div", {
3884
3899
  style: {
3885
3900
  position: "absolute",
3886
3901
  inset: 0,
@@ -3918,7 +3933,7 @@ let __tla = (async () => {
3918
3933
  ]
3919
3934
  })
3920
3935
  }),
3921
- n && !q && T.length === 0 && k("div", {
3936
+ n && !K && T.length === 0 && k("div", {
3922
3937
  style: {
3923
3938
  position: "absolute",
3924
3939
  top: 16,
@@ -3950,7 +3965,7 @@ let __tla = (async () => {
3950
3965
  F === "AK" ? "IT" : "MPT"
3951
3966
  ]
3952
3967
  }),
3953
- n && !q && T.length === 1 && k("div", {
3968
+ n && !K && T.length === 1 && k("div", {
3954
3969
  style: {
3955
3970
  position: "absolute",
3956
3971
  top: 16,
@@ -3981,17 +3996,17 @@ let __tla = (async () => {
3981
3996
  "Click mesh to set Origin"
3982
3997
  ]
3983
3998
  }),
3984
- S && i(sn, {
3999
+ S && i(cn, {
3985
4000
  message: g || "Processing mesh..."
3986
4001
  }),
3987
- V && i(sn, {
3988
- message: J
4002
+ V && i(cn, {
4003
+ message: q
3989
4004
  }),
3990
- yt && i(ko, {
3991
- message: yt,
4005
+ zt && i(Ao, {
4006
+ message: zt,
3992
4007
  onDismiss: () => De(null)
3993
4008
  }),
3994
- e.showAmputationModal && y && i("div", {
4009
+ e.showAmputationModal && w && i("div", {
3995
4010
  style: {
3996
4011
  position: "absolute",
3997
4012
  inset: 0,
@@ -4042,8 +4057,8 @@ let __tla = (async () => {
4042
4057
  children: [
4043
4058
  "AK",
4044
4059
  "BK"
4045
- ].map((w) => k("label", {
4046
- onClick: () => I(w),
4060
+ ].map((y) => k("label", {
4061
+ onClick: () => I(y),
4047
4062
  style: {
4048
4063
  flex: 1,
4049
4064
  display: "flex",
@@ -4052,16 +4067,16 @@ let __tla = (async () => {
4052
4067
  border: "2px solid",
4053
4068
  borderRadius: 4,
4054
4069
  cursor: "pointer",
4055
- borderColor: F === w ? "rgb(12, 67, 173)" : "#e0e0e0",
4056
- backgroundColor: F === w ? "rgba(12, 67, 173, 0.04)" : "#fff",
4070
+ borderColor: F === y ? "rgb(12, 67, 173)" : "#e0e0e0",
4071
+ backgroundColor: F === y ? "rgba(12, 67, 173, 0.04)" : "#fff",
4057
4072
  transition: "border-color 0.15s, background-color 0.15s"
4058
4073
  },
4059
4074
  children: [
4060
4075
  i("input", {
4061
4076
  type: "radio",
4062
4077
  name: "ampType",
4063
- checked: F === w,
4064
- onChange: () => I(w),
4078
+ checked: F === y,
4079
+ onChange: () => I(y),
4065
4080
  style: {
4066
4081
  accentColor: "rgb(12, 67, 173)",
4067
4082
  marginBottom: 12,
@@ -4076,7 +4091,7 @@ let __tla = (async () => {
4076
4091
  color: "rgba(0,0,0,0.87)",
4077
4092
  marginBottom: 4
4078
4093
  },
4079
- children: w
4094
+ children: y
4080
4095
  }),
4081
4096
  k("span", {
4082
4097
  style: {
@@ -4084,12 +4099,12 @@ let __tla = (async () => {
4084
4099
  color: "rgba(0,0,0,0.54)"
4085
4100
  },
4086
4101
  children: [
4087
- w === "AK" ? "2" : "1",
4102
+ y === "AK" ? "2" : "1",
4088
4103
  "-inch measurement spacing"
4089
4104
  ]
4090
4105
  })
4091
4106
  ]
4092
- }, w))
4107
+ }, y))
4093
4108
  })
4094
4109
  ]
4095
4110
  }),
@@ -4154,8 +4169,8 @@ let __tla = (async () => {
4154
4169
  zIndex: 10
4155
4170
  }
4156
4171
  }),
4157
- i(zo, {
4158
- children: k(so, {
4172
+ i(ko, {
4173
+ children: k(lo, {
4159
4174
  camera: {
4160
4175
  position: [
4161
4176
  0,
@@ -4202,15 +4217,15 @@ let __tla = (async () => {
4202
4217
  ],
4203
4218
  intensity: 0.2
4204
4219
  }),
4205
- n && A === "3D" && i(Fo, {
4220
+ n && A === "3D" && i(Po, {
4206
4221
  mesh: n,
4207
4222
  maxPoints: 2,
4208
- meshColor: jt,
4223
+ meshColor: Zt,
4209
4224
  meshOpacity: We ? 0.3 : $n,
4210
4225
  frontFaceOnly: Z,
4211
- doubleShellTransparency: Y && q
4226
+ doubleShellTransparency: X && K
4212
4227
  }),
4213
- n && A === "3D" && i(Lo, {
4228
+ n && A === "3D" && i(Io, {
4214
4229
  modelSize: d,
4215
4230
  labels: [
4216
4231
  F === "AK" ? "IT" : "MPT",
@@ -4218,94 +4233,94 @@ let __tla = (async () => {
4218
4233
  "Cut Plane"
4219
4234
  ]
4220
4235
  }),
4221
- i(Oo, {
4236
+ i($o, {
4222
4237
  modelSize: d,
4223
- isAligned: q,
4224
- isCut: Ft,
4238
+ isAligned: K,
4239
+ isCut: Dt,
4225
4240
  mesh: n,
4226
4241
  viewMode: A,
4227
- sliceY: q && T.length >= 2 ? Ae ?? xt ?? T[0].position.y : void 0,
4242
+ sliceY: K && T.length >= 2 ? Ae ?? Ct ?? T[0].position.y : void 0,
4228
4243
  landmarkCount: T.length,
4229
4244
  measurementGeometry: xe,
4230
- resetCameraToFrontRef: kt
4245
+ resetCameraToFrontRef: Lt
4231
4246
  }),
4232
- !q && i(pn, {
4247
+ !K && i(mn, {
4233
4248
  enableDamping: false
4234
4249
  }),
4235
- q && j.length > 0 && n && A === "3D" && i($o, {
4250
+ K && j.length > 0 && n && A === "3D" && i(Ho, {
4236
4251
  mesh: n,
4237
- isDragging: Pn
4252
+ isDragging: In
4238
4253
  }),
4239
- n && q && T.length >= 3 && (() => {
4254
+ n && K && T.length >= 3 && (() => {
4240
4255
  const D = n.geometry.getIndex();
4241
4256
  if (!D || D.count < 30) return null;
4242
- const B = T[2], R = T[0], ce = Ge ?? B.position.y, G = Ae ?? xt ?? R.position.y;
4243
- return A === "2D" ? i(No, {
4244
- mesh: Jt ?? n,
4257
+ const R = T[2], W = T[0], ge = Ke ?? R.position.y, G = Ae ?? Ct ?? W.position.y;
4258
+ return A === "2D" ? i(Yo, {
4259
+ mesh: tn ?? n,
4245
4260
  upperY: G,
4246
- originY: R.position.y,
4261
+ originY: W.position.y,
4247
4262
  modelSize: d,
4248
- meshColor: jt,
4263
+ meshColor: Zt,
4249
4264
  displayUnit: _
4250
- }) : k(Oe, {
4265
+ }) : k(He, {
4251
4266
  children: [
4252
- i(Bo, {
4253
- mesh: Jt ?? n,
4254
- startY: ce,
4267
+ i(Eo, {
4268
+ mesh: tn ?? n,
4269
+ startY: ge,
4255
4270
  endY: G,
4256
- spacing: st,
4271
+ spacing: dt,
4257
4272
  modelSize: d,
4258
- onMeasurementsChange: X,
4273
+ onMeasurementsChange: N,
4259
4274
  reverseOrder: true,
4260
4275
  displayUnit: _,
4261
- useInnerSurface: Y && !Z,
4262
- formMeasurements: He ? Bn ?? Se : Ue ? Se : void 0,
4263
- originY: bt ?? R.position.y,
4264
- wasmSlices: Le
4276
+ useInnerSurface: X && !Z,
4277
+ formMeasurements: je ? Bn ?? ve : Je ? ve : void 0,
4278
+ originY: Mt ?? W.position.y,
4279
+ wasmSlices: Ie
4265
4280
  }),
4266
- i(To, {
4281
+ i(Oo, {
4267
4282
  mesh: n,
4268
- greenY: bt ?? R.position.y,
4283
+ greenY: Mt ?? W.position.y,
4269
4284
  modelSize: d,
4270
4285
  displayUnit: _,
4271
- bottomY: Y ? B.position.y : void 0,
4272
- formHeight: He ? Tn : Ue ? Je == null ? void 0 : Je.frontalHeight : void 0
4286
+ bottomY: X ? R.position.y : void 0,
4287
+ formHeight: je ? Tn : Je ? Qe == null ? void 0 : Qe.frontalHeight : void 0
4273
4288
  }),
4274
- i(Yo, {
4289
+ i(Xo, {
4275
4290
  mesh: n,
4276
- yPosition: bt ?? R.position.y,
4277
- onYChange: (K) => {
4278
- Ln(K), Ie(null);
4279
- const oe = K - R.position.y;
4280
- Tt((xt ?? R.position.y + st * 2) + oe);
4291
+ yPosition: Mt ?? W.position.y,
4292
+ onYChange: (U) => {
4293
+ Nt(U), Pe(null);
4294
+ const oe = U - W.position.y;
4295
+ vt((Ct ?? W.position.y + dt * 2) + oe);
4281
4296
  },
4282
- minY: R.position.y - st,
4283
- maxY: R.position.y + st,
4297
+ minY: W.position.y - dt,
4298
+ maxY: W.position.y + dt,
4284
4299
  modelSize: d,
4285
4300
  color: "#44ff44",
4286
4301
  hoverColor: "#88ff88",
4287
4302
  dragColor: "#ffffff",
4288
4303
  label: F === "AK" ? "IT" : "MPT",
4289
- onDragStart: () => Ot(true),
4290
- onDragEnd: () => Ot(false)
4304
+ onDragStart: () => jt(true),
4305
+ onDragEnd: () => jt(false)
4291
4306
  })
4292
4307
  ]
4293
4308
  });
4294
4309
  })(),
4295
- n && q && A === "3D" && We && i(dr, {
4310
+ n && K && A === "3D" && We && i(fr, {
4296
4311
  mesh: n
4297
4312
  }),
4298
- n && e.showDebug && We && A === "3D" && i(cr, {
4313
+ n && e.showDebug && We && A === "3D" && i(dr, {
4299
4314
  mesh: n,
4300
4315
  modelSize: d,
4301
- layers: $t,
4316
+ layers: Yt,
4302
4317
  landmarkPoints: T,
4303
4318
  componentDebug: null,
4304
4319
  aoData: me,
4305
4320
  aoGeometry: $,
4306
4321
  measurementGeometry: xe
4307
4322
  }),
4308
- i(hr, {
4323
+ i(gr, {
4309
4324
  screenshotFnRef: Vn,
4310
4325
  mesh: n,
4311
4326
  modelSize: d,
@@ -4341,7 +4356,7 @@ let __tla = (async () => {
4341
4356
  },
4342
4357
  children: "Start Over"
4343
4358
  }),
4344
- !q && T.length >= 1 && i("button", {
4359
+ !K && T.length >= 1 && i("button", {
4345
4360
  onClick: jn,
4346
4361
  style: {
4347
4362
  padding: "6px 16px",
@@ -4357,18 +4372,35 @@ let __tla = (async () => {
4357
4372
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
4358
4373
  },
4359
4374
  children: "Reset Points"
4375
+ }),
4376
+ K && !it && i("button", {
4377
+ onClick: Kn,
4378
+ style: {
4379
+ padding: "6px 16px",
4380
+ borderRadius: 4,
4381
+ fontSize: 13,
4382
+ fontWeight: 500,
4383
+ backgroundColor: "#fff",
4384
+ border: "1px solid #e53935",
4385
+ color: "#e53935",
4386
+ cursor: "pointer",
4387
+ fontFamily: "system-ui, sans-serif",
4388
+ letterSpacing: "0.4px",
4389
+ boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
4390
+ },
4391
+ children: "Reset Points"
4360
4392
  })
4361
4393
  ]
4362
4394
  }),
4363
- e.showDebug && We && n && A === "3D" && i(ur, {
4364
- layers: $t,
4365
- onToggleLayer: (w) => Dn((D) => ({
4395
+ e.showDebug && We && n && A === "3D" && i(pr, {
4396
+ layers: Yt,
4397
+ onToggleLayer: (y) => _n((D) => ({
4366
4398
  ...D,
4367
- [w]: !D[w]
4399
+ [y]: !D[y]
4368
4400
  })),
4369
- isDoubleShell: Y
4401
+ isDoubleShell: X
4370
4402
  }),
4371
- q && j.length > 0 && k("div", {
4403
+ K && j.length > 0 && k("div", {
4372
4404
  style: {
4373
4405
  position: "absolute",
4374
4406
  top: 16,
@@ -4498,7 +4530,7 @@ let __tla = (async () => {
4498
4530
  })
4499
4531
  ]
4500
4532
  }),
4501
- A === "3D" && Se && i("div", {
4533
+ A === "3D" && ve && i("div", {
4502
4534
  style: {
4503
4535
  display: "flex",
4504
4536
  borderRadius: 6,
@@ -4507,13 +4539,13 @@ let __tla = (async () => {
4507
4539
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
4508
4540
  },
4509
4541
  children: i("button", {
4510
- onClick: () => Vt((w) => !w),
4542
+ onClick: () => At((y) => !y),
4511
4543
  style: {
4512
4544
  padding: "6px 14px",
4513
4545
  fontSize: 13,
4514
- fontWeight: Ue ? 600 : 400,
4515
- backgroundColor: Ue ? "rgb(12, 67, 173)" : "#fff",
4516
- color: Ue ? "#fff" : "#666",
4546
+ fontWeight: Je ? 600 : 400,
4547
+ backgroundColor: Je ? "rgb(12, 67, 173)" : "#fff",
4548
+ color: Je ? "#fff" : "#666",
4517
4549
  border: "none",
4518
4550
  cursor: "pointer",
4519
4551
  fontFamily: "system-ui, sans-serif"
@@ -4531,13 +4563,13 @@ let __tla = (async () => {
4531
4563
  },
4532
4564
  children: i("button", {
4533
4565
  onClick: async () => {
4534
- const w = await Qe();
4535
- if (!w) return;
4536
- const D = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), B = (R, ce) => {
4566
+ const y = await qe();
4567
+ if (!y) return;
4568
+ const D = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), R = (W, ge) => {
4537
4569
  const G = document.createElement("a");
4538
- G.href = R, G.download = ce, G.click();
4570
+ G.href = W, G.download = ge, G.click();
4539
4571
  };
4540
- B(w.frontal_view_png, `measurements_front_${D}.png`), await new Promise((R) => setTimeout(R, 300)), B(w.side_view_png, `measurements_transverse_${D}.png`);
4572
+ R(y.frontal_view_png, `measurements_front_${D}.png`), await new Promise((W) => setTimeout(W, 300)), R(y.side_view_png, `measurements_transverse_${D}.png`);
4541
4573
  },
4542
4574
  style: {
4543
4575
  padding: "6px 14px",
@@ -4561,7 +4593,7 @@ let __tla = (async () => {
4561
4593
  boxShadow: "0 2px 8px rgba(0,0,0,0.1)"
4562
4594
  },
4563
4595
  children: i("button", {
4564
- onClick: () => In((w) => !w),
4596
+ onClick: () => Dn((y) => !y),
4565
4597
  style: {
4566
4598
  padding: "6px 14px",
4567
4599
  fontSize: 13,
@@ -4577,12 +4609,12 @@ let __tla = (async () => {
4577
4609
  })
4578
4610
  ]
4579
4611
  }),
4580
- n && ie && i(Ho, {
4612
+ n && ie && i(Vo, {
4581
4613
  wasAutoScaled: ae,
4582
- onDismiss: () => Q(false)
4614
+ onDismiss: () => ee(false)
4583
4615
  }),
4584
- n && we && q && i(Vo, {
4585
- isDoubleShell: Y,
4616
+ n && we && K && i(jo, {
4617
+ isDoubleShell: X,
4586
4618
  onDismiss: () => re(false)
4587
4619
  })
4588
4620
  ]
@@ -4638,9 +4670,9 @@ let __tla = (async () => {
4638
4670
  flexShrink: 0
4639
4671
  },
4640
4672
  children: [
4641
- !He && l && i("button", {
4673
+ !je && l && i("button", {
4642
4674
  disabled: ze,
4643
- onClick: () => Ct(true),
4675
+ onClick: () => Ft(true),
4644
4676
  style: {
4645
4677
  padding: "6px 16px",
4646
4678
  borderRadius: 4,
@@ -4656,14 +4688,14 @@ let __tla = (async () => {
4656
4688
  },
4657
4689
  children: "Have Galileo Check My Measurements"
4658
4690
  }),
4659
- He && i("div", {}),
4691
+ je && i("div", {}),
4660
4692
  k("div", {
4661
4693
  style: {
4662
4694
  display: "flex",
4663
4695
  gap: 8
4664
4696
  },
4665
4697
  children: [
4666
- n && !q && T.length >= 2 && i("button", {
4698
+ n && !K && T.length >= 2 && i("button", {
4667
4699
  onClick: Zn,
4668
4700
  style: {
4669
4701
  padding: "6px 16px",
@@ -4680,8 +4712,8 @@ let __tla = (async () => {
4680
4712
  },
4681
4713
  children: "Next \xBB"
4682
4714
  }),
4683
- q && vt && !He && i("button", {
4684
- onClick: () => St(true),
4715
+ K && it && !je && i("button", {
4716
+ onClick: () => rt(true),
4685
4717
  style: {
4686
4718
  padding: "6px 16px",
4687
4719
  borderRadius: 4,
@@ -4697,9 +4729,9 @@ let __tla = (async () => {
4697
4729
  },
4698
4730
  children: "Edit Measurements"
4699
4731
  }),
4700
- q && vt && (Un ? i("button", {
4732
+ K && it && (Jn ? i("button", {
4701
4733
  disabled: ze,
4702
- onClick: () => Lt("continue"),
4734
+ onClick: () => Rt("continue"),
4703
4735
  style: {
4704
4736
  padding: "6px 16px",
4705
4737
  borderRadius: 4,
@@ -4714,11 +4746,11 @@ let __tla = (async () => {
4714
4746
  lineHeight: "36px"
4715
4747
  },
4716
4748
  children: "Continue"
4717
- }) : k(Oe, {
4749
+ }) : k(He, {
4718
4750
  children: [
4719
4751
  i("button", {
4720
4752
  disabled: ze,
4721
- onClick: () => Lt("use_form_measurements"),
4753
+ onClick: () => Rt("use_form_measurements"),
4722
4754
  style: {
4723
4755
  padding: "6px 16px",
4724
4756
  borderRadius: 4,
@@ -4736,7 +4768,7 @@ let __tla = (async () => {
4736
4768
  }),
4737
4769
  i("button", {
4738
4770
  disabled: ze,
4739
- onClick: () => Lt("use_scan"),
4771
+ onClick: () => Rt("use_scan"),
4740
4772
  style: {
4741
4773
  padding: "6px 16px",
4742
4774
  borderRadius: 4,
@@ -4760,7 +4792,7 @@ let __tla = (async () => {
4760
4792
  })
4761
4793
  ]
4762
4794
  }),
4763
- s && Mt.length > 0 && k("div", {
4795
+ s && Pt.length > 0 && k("div", {
4764
4796
  style: {
4765
4797
  height: 120,
4766
4798
  flexShrink: 0,
@@ -4807,18 +4839,18 @@ let __tla = (async () => {
4807
4839
  },
4808
4840
  children: [
4809
4841
  "WASM ",
4810
- Ve.current ? "v2" : "N/A",
4842
+ Ne.current ? "v2" : "N/A",
4811
4843
  " | ",
4812
4844
  T.length,
4813
4845
  " pts | ",
4814
- q ? "aligned" : "unaligned",
4846
+ K ? "aligned" : "unaligned",
4815
4847
  " | ",
4816
4848
  j.length,
4817
4849
  " slices"
4818
4850
  ]
4819
4851
  }),
4820
4852
  i("button", {
4821
- onClick: () => Nt([]),
4853
+ onClick: () => Kt([]),
4822
4854
  style: {
4823
4855
  background: "none",
4824
4856
  border: "1px solid #30363d",
@@ -4835,21 +4867,21 @@ let __tla = (async () => {
4835
4867
  ]
4836
4868
  }),
4837
4869
  i("div", {
4838
- ref: it,
4870
+ ref: lt,
4839
4871
  style: {
4840
4872
  flex: 1,
4841
4873
  overflowY: "auto",
4842
4874
  padding: "4px 10px",
4843
4875
  lineHeight: 1.6
4844
4876
  },
4845
- children: Mt.map((w, D) => {
4846
- const B = w.includes("ERROR") || w.includes("failed"), R = w.includes("warning") || w.includes("WARN"), ce = w.includes("PIPELINE:"), G = w.includes("STATE:");
4877
+ children: Pt.map((y, D) => {
4878
+ const R = y.includes("ERROR") || y.includes("failed"), W = y.includes("warning") || y.includes("WARN"), ge = y.includes("PIPELINE:"), G = y.includes("STATE:");
4847
4879
  return i("div", {
4848
4880
  style: {
4849
- color: B ? "#f85149" : R ? "#d29922" : ce ? "#58a6ff" : G ? "#3fb950" : "#8b949e",
4881
+ color: R ? "#f85149" : W ? "#d29922" : ge ? "#58a6ff" : G ? "#3fb950" : "#8b949e",
4850
4882
  whiteSpace: "pre"
4851
4883
  },
4852
- children: w
4884
+ children: y
4853
4885
  }, D);
4854
4886
  })
4855
4887
  })
@@ -4857,21 +4889,21 @@ let __tla = (async () => {
4857
4889
  })
4858
4890
  ]
4859
4891
  }),
4860
- Rn && i(Cn, {
4861
- onSkip: qt,
4862
- onCancel: () => Ct(false)
4892
+ Rn && i(kn, {
4893
+ onSkip: nn,
4894
+ onCancel: () => Ft(false)
4863
4895
  })
4864
4896
  ]
4865
4897
  });
4866
4898
  };
4867
- function hr({ screenshotFnRef: e }) {
4868
- return U(() => {
4899
+ function gr({ screenshotFnRef: e }) {
4900
+ return Q(() => {
4869
4901
  e.current = null;
4870
4902
  }, [
4871
4903
  e
4872
4904
  ]), null;
4873
4905
  }
4874
- An = function(e) {
4906
+ Ln = function(e) {
4875
4907
  const r = e === "AK" ? 2 : 1, t = [];
4876
4908
  for (let o = 2; o >= 1; o -= r) t.push(`${o}_above`);
4877
4909
  t.push("at_ref");
@@ -4890,40 +4922,40 @@ let __tla = (async () => {
4890
4922
  ]) t.push(`${o}_below`);
4891
4923
  return t;
4892
4924
  };
4893
- ft = function(e, r) {
4894
- const t = An(r), o = {};
4925
+ mt = function(e, r) {
4926
+ const t = Ln(r), o = {};
4895
4927
  for (let l = 0; l < Math.min(e.length, t.length); l++) {
4896
4928
  const s = e[l];
4897
4929
  s != null && !isNaN(s) && (o[t[l]] = s);
4898
4930
  }
4899
4931
  return o;
4900
4932
  };
4901
- gr = function(e, r) {
4933
+ mr = function(e, r) {
4902
4934
  if (!e) return;
4903
- const o = An(r).map((l) => {
4935
+ const o = Ln(r).map((l) => {
4904
4936
  const s = e[l];
4905
4937
  return s ?? void 0;
4906
4938
  });
4907
4939
  if (!o.every((l) => l == null)) return o;
4908
4940
  };
4909
- kr = ({ request: e, onComplete: r, wasmModule: t }) => {
4910
- const o = H(() => gr(e.form_measurements, e.spacing_type), [
4941
+ Ar = ({ request: e, onComplete: r, wasmModule: t }) => {
4942
+ const o = H(() => mr(e.form_measurements, e.spacing_type), [
4911
4943
  e.form_measurements,
4912
4944
  e.spacing_type
4913
4945
  ]), l = (s) => {
4914
4946
  var _a, _b;
4915
- const c = s.scanMeasurements.map((p) => +(p.modifiedValue ?? p.originalValue).toFixed(1)), a = ft(c, e.spacing_type);
4947
+ const c = s.scanMeasurements.map((p) => +(p.modifiedValue ?? p.originalValue).toFixed(1)), a = mt(c, e.spacing_type);
4916
4948
  let n, m;
4917
4949
  if (s.formMeasurements) {
4918
- n = ft(s.formMeasurements, e.spacing_type);
4950
+ n = mt(s.formMeasurements, e.spacing_type);
4919
4951
  const p = s.scanMeasurements.map((g, b) => {
4920
4952
  var _a2;
4921
4953
  const A = (_a2 = s.formMeasurements) == null ? void 0 : _a2[b];
4922
4954
  return A == null || isNaN(A) ? null : +((g.modifiedValue ?? g.originalValue) - A).toFixed(1);
4923
4955
  });
4924
- m = ft(p, e.spacing_type);
4956
+ m = mt(p, e.spacing_type);
4925
4957
  }
4926
- const d = s.userEnteredMeasurements ? ft(s.userEnteredMeasurements.circumferences, e.spacing_type) : void 0, f = s.decision === "use_scan" || s.decision === "continue", u = f ? a : d ?? n ?? a, x = f ? +s.frontalHeight.toFixed(1) : +(((_a = s.userEnteredMeasurements) == null ? void 0 : _a.frontalHeight) ?? s.frontalHeight).toFixed(1), S = {
4958
+ const d = s.userEnteredMeasurements ? mt(s.userEnteredMeasurements.circumferences, e.spacing_type) : void 0, f = s.decision === "use_scan" || s.decision === "continue", u = f ? a : d ?? n ?? a, x = f ? +s.frontalHeight.toFixed(1) : +(((_a = s.userEnteredMeasurements) == null ? void 0 : _a.frontalHeight) ?? s.frontalHeight).toFixed(1), S = {
4927
4959
  spacing_type: e.spacing_type,
4928
4960
  source_unit: "mm",
4929
4961
  file_format: s.fileFormat,
@@ -4955,8 +4987,8 @@ let __tla = (async () => {
4955
4987
  height: "100%",
4956
4988
  display: "flex"
4957
4989
  },
4958
- children: i(pr, {
4959
- config: uo,
4990
+ children: i(hr, {
4991
+ config: po,
4960
4992
  spacingType: e.spacing_type,
4961
4993
  scanUrl: e.scan_url,
4962
4994
  formMeasurements: o,
@@ -4967,9 +4999,9 @@ let __tla = (async () => {
4967
4999
  };
4968
5000
  })();
4969
5001
  export {
4970
- kr as G,
5002
+ Ar as G,
4971
5003
  __tla,
4972
- ft as a,
4973
- gr as c,
4974
- An as g
5004
+ mt as a,
5005
+ mr as c,
5006
+ Ln as g
4975
5007
  };