@cristiancosano/pallet-builder 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import De, { createContext as Ge, useContext as Ve, useMemo as k, useCallback as H, memo as V, useRef as Ee, useEffect as fe, useState as ae } from "react";
2
- import { Html as ke, OrbitControls as Xe } from "@react-three/drei";
3
- import * as $ from "three";
1
+ import Le, { createContext as Ge, useContext as Ve, useMemo as k, useCallback as q, memo as V, useRef as _e, useEffect as fe, useState as ae } from "react";
2
+ import { Edges as Xe, Html as ke, OrbitControls as Ze } from "@react-three/drei";
3
+ import * as B from "three";
4
4
  import { useThree as Ae, Canvas as pe } from "@react-three/fiber";
5
- const L = {
5
+ const N = {
6
6
  WOOD: "WOOD",
7
7
  PLASTIC: "PLASTIC",
8
8
  METAL: "METAL",
@@ -21,7 +21,7 @@ const L = {
21
21
  /** Palet EUR/EPAL — Estándar europeo (1200×800×144mm, ISO 6780) */
22
22
  EUR: {
23
23
  dimensions: { width: 1200, height: 144, depth: 800 },
24
- material: L.WOOD,
24
+ material: N.WOOD,
25
25
  maxWeight: 1e3,
26
26
  maxStackHeight: 2200,
27
27
  weight: 25
@@ -29,7 +29,7 @@ const L = {
29
29
  /** Palet GMA/Americano — Estándar norteamericano (1219×1016×145mm, 48"×40") */
30
30
  GMA: {
31
31
  dimensions: { width: 1219, height: 145, depth: 1016 },
32
- material: L.WOOD,
32
+ material: N.WOOD,
33
33
  maxWeight: 1200,
34
34
  maxStackHeight: 2200,
35
35
  weight: 30
@@ -37,7 +37,7 @@ const L = {
37
37
  /** Palet UK Standard — Reino Unido (1200×1000×150mm) */
38
38
  UK: {
39
39
  dimensions: { width: 1200, height: 150, depth: 1e3 },
40
- material: L.WOOD,
40
+ material: N.WOOD,
41
41
  maxWeight: 1e3,
42
42
  maxStackHeight: 2200,
43
43
  weight: 28
@@ -45,7 +45,7 @@ const L = {
45
45
  /** Palet asiático estándar — Asia Pallet (1100×1100×150mm, ISO 6780) */
46
46
  ASIA: {
47
47
  dimensions: { width: 1100, height: 150, depth: 1100 },
48
- material: L.WOOD,
48
+ material: N.WOOD,
49
49
  maxWeight: 1e3,
50
50
  maxStackHeight: 2200,
51
51
  weight: 28
@@ -53,7 +53,7 @@ const L = {
53
53
  /** Palet australiano estándar — Australia (1165×1165×150mm) */
54
54
  AUSTRALIAN: {
55
55
  dimensions: { width: 1165, height: 150, depth: 1165 },
56
- material: L.WOOD,
56
+ material: N.WOOD,
57
57
  maxWeight: 1e3,
58
58
  maxStackHeight: 2200,
59
59
  weight: 29
@@ -61,7 +61,7 @@ const L = {
61
61
  /** Medio palet EUR — Half European Pallet (800×600×144mm) */
62
62
  HALF_EUR: {
63
63
  dimensions: { width: 800, height: 144, depth: 600 },
64
- material: L.WOOD,
64
+ material: N.WOOD,
65
65
  maxWeight: 500,
66
66
  maxStackHeight: 2200,
67
67
  weight: 12
@@ -69,7 +69,7 @@ const L = {
69
69
  /** Cuarto de palet EUR — Quarter European Pallet (600×400×144mm) */
70
70
  QUARTER_EUR: {
71
71
  dimensions: { width: 600, height: 144, depth: 400 },
72
- material: L.WOOD,
72
+ material: N.WOOD,
73
73
  maxWeight: 250,
74
74
  maxStackHeight: 2200,
75
75
  weight: 6
@@ -77,7 +77,7 @@ const L = {
77
77
  /** Palet ISO 1 — ISO 6780 (1200×1000×150mm) */
78
78
  ISO_1: {
79
79
  dimensions: { width: 1200, height: 150, depth: 1e3 },
80
- material: L.WOOD,
80
+ material: N.WOOD,
81
81
  maxWeight: 1e3,
82
82
  maxStackHeight: 2200,
83
83
  weight: 28
@@ -85,14 +85,14 @@ const L = {
85
85
  /** Palet ISO 2 — ISO 6780 (1200×800×144mm, equivalente a EUR) */
86
86
  ISO_2: {
87
87
  dimensions: { width: 1200, height: 144, depth: 800 },
88
- material: L.WOOD,
88
+ material: N.WOOD,
89
89
  maxWeight: 1e3,
90
90
  maxStackHeight: 2200,
91
91
  weight: 25
92
92
  }
93
93
  };
94
94
  ue.GMA;
95
- const Ze = {
95
+ const De = {
96
96
  [ie.BOX]: {
97
97
  dimensions: { width: 2480, height: 2700, depth: 13600 },
98
98
  maxWeight: 24e3
@@ -109,15 +109,15 @@ const Ze = {
109
109
  dimensions: { width: 2480, height: 2700, depth: 13600 },
110
110
  maxWeight: 24e3
111
111
  }
112
- }, At = {
112
+ }, Ot = {
113
113
  thickness: 10,
114
114
  // mm
115
115
  weight: 2
116
116
  // kg
117
- }, Y = {
117
+ }, U = {
118
118
  MM_TO_M: 1e-3,
119
119
  M_TO_MM: 1e3
120
- }, Ne = 1, Me = 0.6, Oe = 0.9, Le = {
120
+ }, Ne = 1, ze = 0.6, Ie = 0.9, Ue = {
121
121
  id: "unstyled",
122
122
  name: "Sin estilo",
123
123
  box: {
@@ -162,7 +162,7 @@ const Ze = {
162
162
  chassisColor: "#2a2a2a",
163
163
  wheelColor: "#1a1a1a"
164
164
  }
165
- }, Ie = {
165
+ }, Oe = {
166
166
  id: "industrial",
167
167
  name: "Industrial",
168
168
  box: {
@@ -207,195 +207,195 @@ const Ze = {
207
207
  chassisColor: "#1e1e1e",
208
208
  wheelColor: "#111111"
209
209
  }
210
- }, Ye = {
211
- unstyled: Le,
212
- industrial: Ie
213
- }, xe = Ie;
214
- var re = { exports: {} }, ee = {};
215
- var Pe;
216
- function Ue() {
217
- if (Pe) return ee;
218
- Pe = 1;
219
- var o = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
220
- function t(i, n, r) {
210
+ }, He = {
211
+ unstyled: Ue,
212
+ industrial: Oe
213
+ }, xe = Oe;
214
+ var re = { exports: {} }, te = {};
215
+ var Ce;
216
+ function Ye() {
217
+ if (Ce) return te;
218
+ Ce = 1;
219
+ var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
220
+ function t(o, s, n) {
221
221
  var a = null;
222
- if (r !== void 0 && (a = "" + r), n.key !== void 0 && (a = "" + n.key), "key" in n) {
223
- r = {};
224
- for (var f in n)
225
- f !== "key" && (r[f] = n[f]);
226
- } else r = n;
227
- return n = r.ref, {
228
- $$typeof: o,
229
- type: i,
222
+ if (n !== void 0 && (a = "" + n), s.key !== void 0 && (a = "" + s.key), "key" in s) {
223
+ n = {};
224
+ for (var c in s)
225
+ c !== "key" && (n[c] = s[c]);
226
+ } else n = s;
227
+ return s = n.ref, {
228
+ $$typeof: i,
229
+ type: o,
230
230
  key: a,
231
- ref: n !== void 0 ? n : null,
232
- props: r
231
+ ref: s !== void 0 ? s : null,
232
+ props: n
233
233
  };
234
234
  }
235
- return ee.Fragment = e, ee.jsx = t, ee.jsxs = t, ee;
235
+ return te.Fragment = e, te.jsx = t, te.jsxs = t, te;
236
236
  }
237
- var te = {};
238
- var Re;
237
+ var oe = {};
238
+ var Pe;
239
239
  function Fe() {
240
- return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
241
- function o(m) {
242
- if (m == null) return null;
243
- if (typeof m == "function")
244
- return m.$$typeof === R ? null : m.displayName || m.name || null;
245
- if (typeof m == "string") return m;
246
- switch (m) {
247
- case h:
240
+ return Pe || (Pe = 1, process.env.NODE_ENV !== "production" && (function() {
241
+ function i(p) {
242
+ if (p == null) return null;
243
+ if (typeof p == "function")
244
+ return p.$$typeof === T ? null : p.displayName || p.name || null;
245
+ if (typeof p == "string") return p;
246
+ switch (p) {
247
+ case d:
248
248
  return "Fragment";
249
- case T:
250
- return "Profiler";
251
249
  case j:
250
+ return "Profiler";
251
+ case b:
252
252
  return "StrictMode";
253
- case _:
253
+ case z:
254
254
  return "Suspense";
255
255
  case y:
256
256
  return "SuspenseList";
257
- case E:
257
+ case _:
258
258
  return "Activity";
259
259
  }
260
- if (typeof m == "object")
261
- switch (typeof m.tag == "number" && console.error(
260
+ if (typeof p == "object")
261
+ switch (typeof p.tag == "number" && console.error(
262
262
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
263
- ), m.$$typeof) {
264
- case d:
263
+ ), p.$$typeof) {
264
+ case u:
265
265
  return "Portal";
266
- case b:
267
- return m.displayName || "Context";
268
- case z:
269
- return (m._context.displayName || "Context") + ".Consumer";
270
- case M:
271
- var C = m.render;
272
- return m = m.displayName, m || (m = C.displayName || C.name || "", m = m !== "" ? "ForwardRef(" + m + ")" : "ForwardRef"), m;
273
- case w:
274
- return C = m.displayName || null, C !== null ? C : o(m.type) || "Memo";
275
266
  case S:
276
- C = m._payload, m = m._init;
267
+ return p.displayName || "Context";
268
+ case E:
269
+ return (p._context.displayName || "Context") + ".Consumer";
270
+ case C:
271
+ var P = p.render;
272
+ return p = p.displayName, p || (p = P.displayName || P.name || "", p = p !== "" ? "ForwardRef(" + p + ")" : "ForwardRef"), p;
273
+ case v:
274
+ return P = p.displayName || null, P !== null ? P : i(p.type) || "Memo";
275
+ case M:
276
+ P = p._payload, p = p._init;
277
277
  try {
278
- return o(m(C));
278
+ return i(p(P));
279
279
  } catch {
280
280
  }
281
281
  }
282
282
  return null;
283
283
  }
284
- function e(m) {
285
- return "" + m;
284
+ function e(p) {
285
+ return "" + p;
286
286
  }
287
- function t(m) {
287
+ function t(p) {
288
288
  try {
289
- e(m);
290
- var C = !1;
289
+ e(p);
290
+ var P = !1;
291
291
  } catch {
292
- C = !0;
292
+ P = !0;
293
293
  }
294
- if (C) {
295
- C = console;
296
- var I = C.error, W = typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object";
297
- return I.call(
298
- C,
294
+ if (P) {
295
+ P = console;
296
+ var O = P.error, W = typeof Symbol == "function" && Symbol.toStringTag && p[Symbol.toStringTag] || p.constructor.name || "Object";
297
+ return O.call(
298
+ P,
299
299
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
300
300
  W
301
- ), e(m);
301
+ ), e(p);
302
302
  }
303
303
  }
304
- function i(m) {
305
- if (m === h) return "<>";
306
- if (typeof m == "object" && m !== null && m.$$typeof === S)
304
+ function o(p) {
305
+ if (p === d) return "<>";
306
+ if (typeof p == "object" && p !== null && p.$$typeof === M)
307
307
  return "<...>";
308
308
  try {
309
- var C = o(m);
310
- return C ? "<" + C + ">" : "<...>";
309
+ var P = i(p);
310
+ return P ? "<" + P + ">" : "<...>";
311
311
  } catch {
312
312
  return "<...>";
313
313
  }
314
314
  }
315
- function n() {
316
- var m = O.A;
317
- return m === null ? null : m.getOwner();
315
+ function s() {
316
+ var p = I.A;
317
+ return p === null ? null : p.getOwner();
318
318
  }
319
- function r() {
319
+ function n() {
320
320
  return Error("react-stack-top-frame");
321
321
  }
322
- function a(m) {
323
- if (P.call(m, "key")) {
324
- var C = Object.getOwnPropertyDescriptor(m, "key").get;
325
- if (C && C.isReactWarning) return !1;
322
+ function a(p) {
323
+ if (R.call(p, "key")) {
324
+ var P = Object.getOwnPropertyDescriptor(p, "key").get;
325
+ if (P && P.isReactWarning) return !1;
326
326
  }
327
- return m.key !== void 0;
327
+ return p.key !== void 0;
328
328
  }
329
- function f(m, C) {
330
- function I() {
331
- N || (N = !0, console.error(
329
+ function c(p, P) {
330
+ function O() {
331
+ D || (D = !0, console.error(
332
332
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
333
- C
333
+ P
334
334
  ));
335
335
  }
336
- I.isReactWarning = !0, Object.defineProperty(m, "key", {
337
- get: I,
336
+ O.isReactWarning = !0, Object.defineProperty(p, "key", {
337
+ get: O,
338
338
  configurable: !0
339
339
  });
340
340
  }
341
- function g() {
342
- var m = o(this.type);
343
- return U[m] || (U[m] = !0, console.error(
341
+ function l() {
342
+ var p = i(this.type);
343
+ return H[p] || (H[p] = !0, console.error(
344
344
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
345
- )), m = this.props.ref, m !== void 0 ? m : null;
345
+ )), p = this.props.ref, p !== void 0 ? p : null;
346
346
  }
347
- function v(m, C, I, W, ne, de) {
348
- var B = I.ref;
349
- return m = {
350
- $$typeof: l,
351
- type: m,
352
- key: C,
353
- props: I,
347
+ function f(p, P, O, W, ne, de) {
348
+ var $ = O.ref;
349
+ return p = {
350
+ $$typeof: x,
351
+ type: p,
352
+ key: P,
353
+ props: O,
354
354
  _owner: W
355
- }, (B !== void 0 ? B : null) !== null ? Object.defineProperty(m, "ref", {
355
+ }, ($ !== void 0 ? $ : null) !== null ? Object.defineProperty(p, "ref", {
356
356
  enumerable: !1,
357
- get: g
358
- }) : Object.defineProperty(m, "ref", { enumerable: !1, value: null }), m._store = {}, Object.defineProperty(m._store, "validated", {
357
+ get: l
358
+ }) : Object.defineProperty(p, "ref", { enumerable: !1, value: null }), p._store = {}, Object.defineProperty(p._store, "validated", {
359
359
  configurable: !1,
360
360
  enumerable: !1,
361
361
  writable: !0,
362
362
  value: 0
363
- }), Object.defineProperty(m, "_debugInfo", {
363
+ }), Object.defineProperty(p, "_debugInfo", {
364
364
  configurable: !1,
365
365
  enumerable: !1,
366
366
  writable: !0,
367
367
  value: null
368
- }), Object.defineProperty(m, "_debugStack", {
368
+ }), Object.defineProperty(p, "_debugStack", {
369
369
  configurable: !1,
370
370
  enumerable: !1,
371
371
  writable: !0,
372
372
  value: ne
373
- }), Object.defineProperty(m, "_debugTask", {
373
+ }), Object.defineProperty(p, "_debugTask", {
374
374
  configurable: !1,
375
375
  enumerable: !1,
376
376
  writable: !0,
377
377
  value: de
378
- }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
378
+ }), Object.freeze && (Object.freeze(p.props), Object.freeze(p)), p;
379
379
  }
380
- function u(m, C, I, W, ne, de) {
381
- var B = C.children;
382
- if (B !== void 0)
380
+ function h(p, P, O, W, ne, de) {
381
+ var $ = P.children;
382
+ if ($ !== void 0)
383
383
  if (W)
384
- if (A(B)) {
385
- for (W = 0; W < B.length; W++)
386
- x(B[W]);
387
- Object.freeze && Object.freeze(B);
384
+ if (A($)) {
385
+ for (W = 0; W < $.length; W++)
386
+ g($[W]);
387
+ Object.freeze && Object.freeze($);
388
388
  } else
389
389
  console.error(
390
390
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
391
391
  );
392
- else x(B);
393
- if (P.call(C, "key")) {
394
- B = o(m);
395
- var Q = Object.keys(C).filter(function(Be) {
396
- return Be !== "key";
392
+ else g($);
393
+ if (R.call(P, "key")) {
394
+ $ = i(p);
395
+ var Q = Object.keys(P).filter(function($e) {
396
+ return $e !== "key";
397
397
  });
398
- W = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", J[B + W] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
398
+ W = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", J[$ + W] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
399
399
  `A props object containing a "key" prop is being spread into JSX:
400
400
  let props = %s;
401
401
  <%s {...props} />
@@ -403,568 +403,568 @@ React keys must be passed directly to JSX without using spread:
403
403
  let props = %s;
404
404
  <%s key={someKey} {...props} />`,
405
405
  W,
406
- B,
406
+ $,
407
407
  Q,
408
- B
409
- ), J[B + W] = !0);
408
+ $
409
+ ), J[$ + W] = !0);
410
410
  }
411
- if (B = null, I !== void 0 && (t(I), B = "" + I), a(C) && (t(C.key), B = "" + C.key), "key" in C) {
412
- I = {};
413
- for (var he in C)
414
- he !== "key" && (I[he] = C[he]);
415
- } else I = C;
416
- return B && f(
417
- I,
418
- typeof m == "function" ? m.displayName || m.name || "Unknown" : m
419
- ), v(
420
- m,
421
- B,
422
- I,
423
- n(),
411
+ if ($ = null, O !== void 0 && (t(O), $ = "" + O), a(P) && (t(P.key), $ = "" + P.key), "key" in P) {
412
+ O = {};
413
+ for (var he in P)
414
+ he !== "key" && (O[he] = P[he]);
415
+ } else O = P;
416
+ return $ && c(
417
+ O,
418
+ typeof p == "function" ? p.displayName || p.name || "Unknown" : p
419
+ ), f(
420
+ p,
421
+ $,
422
+ O,
423
+ s(),
424
424
  ne,
425
425
  de
426
426
  );
427
427
  }
428
- function x(m) {
429
- p(m) ? m._store && (m._store.validated = 1) : typeof m == "object" && m !== null && m.$$typeof === S && (m._payload.status === "fulfilled" ? p(m._payload.value) && m._payload.value._store && (m._payload.value._store.validated = 1) : m._store && (m._store.validated = 1));
428
+ function g(p) {
429
+ w(p) ? p._store && (p._store.validated = 1) : typeof p == "object" && p !== null && p.$$typeof === M && (p._payload.status === "fulfilled" ? w(p._payload.value) && p._payload.value._store && (p._payload.value._store.validated = 1) : p._store && (p._store.validated = 1));
430
430
  }
431
- function p(m) {
432
- return typeof m == "object" && m !== null && m.$$typeof === l;
431
+ function w(p) {
432
+ return typeof p == "object" && p !== null && p.$$typeof === x;
433
433
  }
434
- var c = De, l = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), j = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), b = /* @__PURE__ */ Symbol.for("react.context"), M = /* @__PURE__ */ Symbol.for("react.forward_ref"), _ = /* @__PURE__ */ Symbol.for("react.suspense"), y = /* @__PURE__ */ Symbol.for("react.suspense_list"), w = /* @__PURE__ */ Symbol.for("react.memo"), S = /* @__PURE__ */ Symbol.for("react.lazy"), E = /* @__PURE__ */ Symbol.for("react.activity"), R = /* @__PURE__ */ Symbol.for("react.client.reference"), O = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, A = Array.isArray, G = console.createTask ? console.createTask : function() {
434
+ var m = Le, x = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), b = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), E = /* @__PURE__ */ Symbol.for("react.consumer"), S = /* @__PURE__ */ Symbol.for("react.context"), C = /* @__PURE__ */ Symbol.for("react.forward_ref"), z = /* @__PURE__ */ Symbol.for("react.suspense"), y = /* @__PURE__ */ Symbol.for("react.suspense_list"), v = /* @__PURE__ */ Symbol.for("react.memo"), M = /* @__PURE__ */ Symbol.for("react.lazy"), _ = /* @__PURE__ */ Symbol.for("react.activity"), T = /* @__PURE__ */ Symbol.for("react.client.reference"), I = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, A = Array.isArray, G = console.createTask ? console.createTask : function() {
435
435
  return null;
436
436
  };
437
- c = {
438
- react_stack_bottom_frame: function(m) {
439
- return m();
437
+ m = {
438
+ react_stack_bottom_frame: function(p) {
439
+ return p();
440
440
  }
441
441
  };
442
- var N, U = {}, F = c.react_stack_bottom_frame.bind(
443
- c,
444
- r
445
- )(), X = G(i(r)), J = {};
446
- te.Fragment = h, te.jsx = function(m, C, I) {
447
- var W = 1e4 > O.recentlyCreatedOwnerStacks++;
448
- return u(
449
- m,
450
- C,
451
- I,
442
+ var D, H = {}, F = m.react_stack_bottom_frame.bind(
443
+ m,
444
+ n
445
+ )(), X = G(o(n)), J = {};
446
+ oe.Fragment = d, oe.jsx = function(p, P, O) {
447
+ var W = 1e4 > I.recentlyCreatedOwnerStacks++;
448
+ return h(
449
+ p,
450
+ P,
451
+ O,
452
452
  !1,
453
453
  W ? Error("react-stack-top-frame") : F,
454
- W ? G(i(m)) : X
454
+ W ? G(o(p)) : X
455
455
  );
456
- }, te.jsxs = function(m, C, I) {
457
- var W = 1e4 > O.recentlyCreatedOwnerStacks++;
458
- return u(
459
- m,
460
- C,
461
- I,
456
+ }, oe.jsxs = function(p, P, O) {
457
+ var W = 1e4 > I.recentlyCreatedOwnerStacks++;
458
+ return h(
459
+ p,
460
+ P,
461
+ O,
462
462
  !0,
463
463
  W ? Error("react-stack-top-frame") : F,
464
- W ? G(i(m)) : X
464
+ W ? G(o(p)) : X
465
465
  );
466
466
  };
467
- })()), te;
467
+ })()), oe;
468
468
  }
469
- var _e;
470
- function He() {
471
- return _e || (_e = 1, process.env.NODE_ENV === "production" ? re.exports = Ue() : re.exports = Fe()), re.exports;
469
+ var Re;
470
+ function qe() {
471
+ return Re || (Re = 1, process.env.NODE_ENV === "production" ? re.exports = Ye() : re.exports = Fe()), re.exports;
472
472
  }
473
- var s = He();
474
- const $e = Ge(xe);
475
- function ve({ preset: o, children: e }) {
476
- const t = k(() => o ? typeof o == "string" ? Ye[o] ?? xe : o : xe, [o]);
477
- return /* @__PURE__ */ s.jsx($e.Provider, { value: t, children: e });
473
+ var r = qe();
474
+ const Be = Ge(xe);
475
+ function we({ preset: i, children: e }) {
476
+ const t = k(() => i ? typeof i == "string" ? He[i] ?? xe : i : xe, [i]);
477
+ return /* @__PURE__ */ r.jsx(Be.Provider, { value: t, children: e });
478
478
  }
479
479
  function ce() {
480
- return Ve($e);
480
+ return Ve(Be);
481
481
  }
482
- function le(o) {
482
+ function le(i) {
483
483
  let e = 0;
484
- for (const t of o.floors) {
484
+ for (const t of i.floors) {
485
485
  e += t.pallet.dimensions.height;
486
- const i = t.boxes.reduce((n, r) => {
487
- const a = r.position.y + r.box.dimensions.height;
488
- return Math.max(n, a);
486
+ const o = t.boxes.reduce((s, n) => {
487
+ const a = n.position.y + n.box.dimensions.height;
488
+ return Math.max(s, a);
489
489
  }, 0);
490
- e += i, t.separatorAbove && (e += t.separatorAbove.dimensions.height);
490
+ e += o, t.separatorAbove && (e += t.separatorAbove.dimensions.height);
491
491
  }
492
492
  return e;
493
493
  }
494
- function we(o) {
494
+ function ye(i) {
495
495
  let e = 0;
496
- for (const t of o.floors)
497
- e += t.pallet.weight, e += t.boxes.reduce((i, n) => i + n.box.weight, 0), t.separatorAbove && (e += t.separatorAbove.weight);
496
+ for (const t of i.floors)
497
+ e += t.pallet.weight, e += t.boxes.reduce((o, s) => o + s.box.weight, 0), t.separatorAbove && (e += t.separatorAbove.weight);
498
498
  return e;
499
499
  }
500
- function qe(o, e) {
501
- const t = e || o.id, i = o.floors.map((n, r) => {
502
- const a = n.boxes.map((f, g) => {
503
- const v = `${t}:f${r}:b${g}`, u = (x) => x.map((p) => {
504
- const c = n.boxes.findIndex((l) => l.id === p);
505
- return c >= 0 ? `${t}:f${r}:b${c}` : p;
500
+ function Je(i, e) {
501
+ const t = e || i.id, o = i.floors.map((s, n) => {
502
+ const a = s.boxes.map((c, l) => {
503
+ const f = `${t}:f${n}:b${l}`, h = (g) => g.map((w) => {
504
+ const m = s.boxes.findIndex((x) => x.id === w);
505
+ return m >= 0 ? `${t}:f${n}:b${m}` : w;
506
506
  });
507
507
  return {
508
- ...f,
509
- id: v,
510
- supportedBy: u(f.supportedBy),
511
- supporting: u(f.supporting)
508
+ ...c,
509
+ id: f,
510
+ supportedBy: h(c.supportedBy),
511
+ supporting: h(c.supporting)
512
512
  };
513
513
  });
514
514
  return {
515
- ...n,
515
+ ...s,
516
516
  boxes: a
517
517
  };
518
518
  });
519
519
  return {
520
- ...o,
521
- floors: i
520
+ ...i,
521
+ floors: o
522
522
  };
523
523
  }
524
- function D(o) {
525
- let e = o.box.dimensions.width, t = o.box.dimensions.depth;
526
- const i = o.box.dimensions.height;
527
- return (o.rotation.y === 90 || o.rotation.y === 270) && ([e, t] = [t, e]), {
528
- minX: o.position.x,
529
- maxX: o.position.x + e,
530
- minY: o.position.y,
531
- maxY: o.position.y + i,
532
- minZ: o.position.z,
533
- maxZ: o.position.z + t
524
+ function L(i) {
525
+ let e = i.box.dimensions.width, t = i.box.dimensions.depth;
526
+ const o = i.box.dimensions.height;
527
+ return (i.rotation.y === 90 || i.rotation.y === 270) && ([e, t] = [t, e]), {
528
+ minX: i.position.x,
529
+ maxX: i.position.x + e,
530
+ minY: i.position.y,
531
+ maxY: i.position.y + o,
532
+ minZ: i.position.z,
533
+ maxZ: i.position.z + t
534
534
  };
535
535
  }
536
- function oe(o) {
537
- const e = o.stackedPallet, t = e.floors[0].pallet, i = t.dimensions.width, n = t.dimensions.depth, r = le(e), a = o.yRotation * Math.PI / 180, f = Math.cos(a), g = Math.sin(a), u = [
536
+ function se(i) {
537
+ const e = i.stackedPallet, t = e.floors[0].pallet, o = t.dimensions.width, s = t.dimensions.depth, n = le(e), a = i.yRotation * Math.PI / 180, c = Math.cos(a), l = Math.sin(a), h = [
538
538
  { x: 0, z: 0 },
539
- { x: i, z: 0 },
540
- { x: i, z: n },
541
- { x: 0, z: n }
542
- ].map((d) => ({
543
- x: o.position.x + d.x * f + d.z * g,
544
- z: o.position.z - d.x * g + d.z * f
545
- })), x = Math.min(...u.map((d) => d.x)), p = Math.max(...u.map((d) => d.x)), c = Math.min(...u.map((d) => d.z)), l = Math.max(...u.map((d) => d.z));
539
+ { x: o, z: 0 },
540
+ { x: o, z: s },
541
+ { x: 0, z: s }
542
+ ].map((u) => ({
543
+ x: i.position.x + u.x * c + u.z * l,
544
+ z: i.position.z - u.x * l + u.z * c
545
+ })), g = Math.min(...h.map((u) => u.x)), w = Math.max(...h.map((u) => u.x)), m = Math.min(...h.map((u) => u.z)), x = Math.max(...h.map((u) => u.z));
546
546
  return {
547
- minX: x,
548
- maxX: p,
549
- minY: o.position.y,
550
- maxY: o.position.y + r,
551
- minZ: c,
552
- maxZ: l
547
+ minX: g,
548
+ maxX: w,
549
+ minY: i.position.y,
550
+ maxY: i.position.y + n,
551
+ minZ: m,
552
+ maxZ: x
553
553
  };
554
554
  }
555
- function ye(o, e, t = Ne) {
556
- return o.minX < e.maxX - t && o.maxX > e.minX + t && o.minY < e.maxY - t && o.maxY > e.minY + t && o.minZ < e.maxZ - t && o.maxZ > e.minZ + t;
555
+ function ve(i, e, t = Ne) {
556
+ return i.minX < e.maxX - t && i.maxX > e.minX + t && i.minY < e.maxY - t && i.maxY > e.minY + t && i.minZ < e.maxZ - t && i.maxZ > e.minZ + t;
557
557
  }
558
- function Je(o) {
558
+ function Qe(i) {
559
559
  const e = [];
560
- for (let t = 0; t < o.length; t++)
561
- for (let i = t + 1; i < o.length; i++) {
562
- const n = D(o[t]), r = D(o[i]);
563
- ye(n, r) && e.push({
560
+ for (let t = 0; t < i.length; t++)
561
+ for (let o = t + 1; o < i.length; o++) {
562
+ const s = L(i[t]), n = L(i[o]);
563
+ ve(s, n) && e.push({
564
564
  code: "BR-002",
565
565
  severity: "error",
566
- message: `Colisión entre cajas ${o[t].id} y ${o[i].id}`,
567
- involvedIds: [o[t].id, o[i].id]
566
+ message: `Colisión entre cajas ${i[t].id} y ${i[o].id}`,
567
+ involvedIds: [i[t].id, i[o].id]
568
568
  });
569
569
  }
570
570
  return { isValid: e.length === 0, violations: e };
571
571
  }
572
- function Qe(o) {
572
+ function Ke(i) {
573
573
  const e = [];
574
- for (let t = 0; t < o.length; t++)
575
- for (let i = t + 1; i < o.length; i++) {
576
- const n = oe(o[t]), r = oe(o[i]);
577
- ye(n, r) && e.push({
574
+ for (let t = 0; t < i.length; t++)
575
+ for (let o = t + 1; o < i.length; o++) {
576
+ const s = se(i[t]), n = se(i[o]);
577
+ ve(s, n) && e.push({
578
578
  code: "BR-003",
579
579
  severity: "error",
580
- message: `Colisión entre palets ${o[t].id} y ${o[i].id}`,
581
- involvedIds: [o[t].id, o[i].id]
580
+ message: `Colisión entre palets ${i[t].id} y ${i[o].id}`,
581
+ involvedIds: [i[t].id, i[o].id]
582
582
  });
583
583
  }
584
584
  return { isValid: e.length === 0, violations: e };
585
585
  }
586
- function Ke(o, e) {
587
- const t = [], i = D(o);
588
- return (i.minX < 0 || i.maxX > e.dimensions.width) && t.push({
586
+ function et(i, e) {
587
+ const t = [], o = L(i);
588
+ return (o.minX < 0 || o.maxX > e.dimensions.width) && t.push({
589
589
  code: "BR-001",
590
590
  severity: "error",
591
- message: `Caja ${o.id} sobresale por el eje X del palet`,
592
- involvedIds: [o.id, e.id]
593
- }), (i.minZ < 0 || i.maxZ > e.dimensions.depth) && t.push({
591
+ message: `Caja ${i.id} sobresale por el eje X del palet`,
592
+ involvedIds: [i.id, e.id]
593
+ }), (o.minZ < 0 || o.maxZ > e.dimensions.depth) && t.push({
594
594
  code: "BR-001",
595
595
  severity: "error",
596
- message: `Caja ${o.id} sobresale por el eje Z del palet`,
597
- involvedIds: [o.id, e.id]
598
- }), i.maxY > e.maxStackHeight && t.push({
596
+ message: `Caja ${i.id} sobresale por el eje Z del palet`,
597
+ involvedIds: [i.id, e.id]
598
+ }), o.maxY > e.maxStackHeight && t.push({
599
599
  code: "BR-001",
600
600
  severity: "error",
601
- message: `Caja ${o.id} excede la altura máxima de apilamiento del palet`,
602
- involvedIds: [o.id, e.id]
601
+ message: `Caja ${i.id} excede la altura máxima de apilamiento del palet`,
602
+ involvedIds: [i.id, e.id]
603
603
  }), { isValid: t.length === 0, violations: t };
604
604
  }
605
- function et(o, e) {
605
+ function tt(i, e) {
606
606
  const t = [];
607
- for (const i of o) {
608
- const n = Ke(i, e);
609
- t.push(...n.violations);
607
+ for (const o of i) {
608
+ const s = et(o, e);
609
+ t.push(...s.violations);
610
610
  }
611
611
  return { isValid: t.length === 0, violations: t };
612
612
  }
613
- function tt(o, e) {
614
- const t = [], i = oe(o), n = e.dimensions;
615
- return (i.minX < 0 || i.maxX > n.width) && t.push({
613
+ function ot(i, e) {
614
+ const t = [], o = se(i), s = e.dimensions;
615
+ return (o.minX < 0 || o.maxX > s.width) && t.push({
616
616
  code: "BR-402",
617
617
  severity: "error",
618
- message: `Palet ${o.id} sobresale por el ancho del camión`,
619
- involvedIds: [o.id, e.id]
620
- }), (i.minZ < 0 || i.maxZ > n.depth) && t.push({
618
+ message: `Palet ${i.id} sobresale por el ancho del camión`,
619
+ involvedIds: [i.id, e.id]
620
+ }), (o.minZ < 0 || o.maxZ > s.depth) && t.push({
621
621
  code: "BR-402",
622
622
  severity: "error",
623
- message: `Palet ${o.id} sobresale por la profundidad del camión`,
624
- involvedIds: [o.id, e.id]
625
- }), i.maxY > n.height && t.push({
623
+ message: `Palet ${i.id} sobresale por la profundidad del camión`,
624
+ involvedIds: [i.id, e.id]
625
+ }), o.maxY > s.height && t.push({
626
626
  code: "BR-404",
627
627
  severity: "error",
628
- message: `Palet ${o.id} excede la altura del camión`,
629
- involvedIds: [o.id, e.id]
628
+ message: `Palet ${i.id} excede la altura del camión`,
629
+ involvedIds: [i.id, e.id]
630
630
  }), { isValid: t.length === 0, violations: t };
631
631
  }
632
- function Ot(o, e) {
633
- const t = [], i = oe(o);
634
- return i.maxY > e && t.push({
632
+ function Bt(i, e) {
633
+ const t = [], o = se(i);
634
+ return o.maxY > e && t.push({
635
635
  code: "BR-403",
636
636
  severity: "error",
637
- message: `Palet ${o.id} excede el techo de la estancia (${i.maxY}mm > ${e}mm)`,
638
- involvedIds: [o.id]
637
+ message: `Palet ${i.id} excede el techo de la estancia (${o.maxY}mm > ${e}mm)`,
638
+ involvedIds: [i.id]
639
639
  }), { isValid: t.length === 0, violations: t };
640
640
  }
641
- function it(o) {
642
- const e = [], t = o.boxes.reduce((n, r) => n + r.box.weight, 0), i = o.pallet.maxWeight;
643
- return t > i ? e.push({
641
+ function it(i) {
642
+ const e = [], t = i.boxes.reduce((s, n) => s + n.box.weight, 0), o = i.pallet.maxWeight;
643
+ return t > o ? e.push({
644
644
  code: "BR-101",
645
645
  severity: "error",
646
- message: `Peso de cajas (${t.toFixed(1)}kg) excede el máximo del palet (${i}kg)`,
647
- involvedIds: [o.pallet.id]
648
- }) : t > i * Oe && e.push({
646
+ message: `Peso de cajas (${t.toFixed(1)}kg) excede el máximo del palet (${o}kg)`,
647
+ involvedIds: [i.pallet.id]
648
+ }) : t > o * Ie && e.push({
649
649
  code: "BR-101",
650
650
  severity: "warning",
651
- message: `Peso de cajas (${t.toFixed(1)}kg) supera el 90% del máximo del palet (${i}kg)`,
652
- involvedIds: [o.pallet.id]
653
- }), { isValid: e.filter((n) => n.severity === "error").length === 0, violations: e };
651
+ message: `Peso de cajas (${t.toFixed(1)}kg) supera el 90% del máximo del palet (${o}kg)`,
652
+ involvedIds: [i.pallet.id]
653
+ }), { isValid: e.filter((s) => s.severity === "error").length === 0, violations: e };
654
654
  }
655
- function It(o) {
656
- const e = [], t = o.pallets.reduce(
657
- (i, n) => i + we(n.stackedPallet),
655
+ function Wt(i) {
656
+ const e = [], t = i.pallets.reduce(
657
+ (o, s) => o + ye(s.stackedPallet),
658
658
  0
659
659
  );
660
- return t > o.maxWeight ? e.push({
660
+ return t > i.maxWeight ? e.push({
661
661
  code: "BR-102",
662
662
  severity: "error",
663
- message: `Peso total (${t.toFixed(1)}kg) excede el máximo del camión (${o.maxWeight}kg)`,
664
- involvedIds: [o.id]
665
- }) : t > o.maxWeight * Oe && e.push({
663
+ message: `Peso total (${t.toFixed(1)}kg) excede el máximo del camión (${i.maxWeight}kg)`,
664
+ involvedIds: [i.id]
665
+ }) : t > i.maxWeight * Ie && e.push({
666
666
  code: "BR-102",
667
667
  severity: "warning",
668
- message: `Peso total (${t.toFixed(1)}kg) supera el 90% del máximo del camión (${o.maxWeight}kg)`,
669
- involvedIds: [o.id]
670
- }), { isValid: e.filter((i) => i.severity === "error").length === 0, violations: e };
668
+ message: `Peso total (${t.toFixed(1)}kg) supera el 90% del máximo del camión (${i.maxWeight}kg)`,
669
+ involvedIds: [i.id]
670
+ }), { isValid: e.filter((o) => o.severity === "error").length === 0, violations: e };
671
671
  }
672
- function ot(o) {
672
+ function st(i) {
673
673
  const e = [];
674
- for (const t of o) {
674
+ for (const t of i) {
675
675
  if (!t.box.fragile) continue;
676
- const i = t.box.fragilityMaxWeight ?? 0, n = st(t, o);
677
- n > i && e.push({
676
+ const o = t.box.fragilityMaxWeight ?? 0, s = nt(t, i);
677
+ s > o && e.push({
678
678
  code: "BR-103",
679
679
  severity: "error",
680
- message: `Caja frágil ${t.id} soporta ${n.toFixed(1)}kg (máx: ${i}kg)`,
680
+ message: `Caja frágil ${t.id} soporta ${s.toFixed(1)}kg (máx: ${o}kg)`,
681
681
  involvedIds: [t.id]
682
682
  });
683
683
  }
684
684
  return { isValid: e.length === 0, violations: e };
685
685
  }
686
- function st(o, e) {
687
- const t = D(o);
688
- let i = 0;
689
- for (const n of e) {
690
- if (n.id === o.id) continue;
691
- const r = D(n);
692
- r.minY >= t.maxY - 1 && r.minX < t.maxX && r.maxX > t.minX && r.minZ < t.maxZ && r.maxZ > t.minZ && (i += n.box.weight);
693
- }
694
- return i;
686
+ function nt(i, e) {
687
+ const t = L(i);
688
+ let o = 0;
689
+ for (const s of e) {
690
+ if (s.id === i.id) continue;
691
+ const n = L(s);
692
+ n.minY >= t.maxY - 1 && n.minX < t.maxX && n.maxX > t.minX && n.minZ < t.maxZ && n.maxZ > t.minZ && (o += s.box.weight);
693
+ }
694
+ return o;
695
695
  }
696
- function nt(o, e) {
696
+ function rt(i, e) {
697
697
  const t = [];
698
698
  if (e.length === 0) return { isValid: !0, violations: t };
699
- const i = e.reduce((g, v) => g + v.box.weight, 0);
700
- if (i === 0) return { isValid: !0, violations: t };
701
- let n = 0, r = 0;
702
- for (const g of e) {
703
- const v = D(g), u = (v.minX + v.maxX) / 2, x = (v.minZ + v.maxZ) / 2;
704
- n += u * g.box.weight, r += x * g.box.weight;
705
- }
706
- n /= i, r /= i;
707
- const a = o.dimensions.width / 2, f = o.dimensions.depth / 2;
708
- return (Math.abs(n - a) > o.dimensions.width / 6 || Math.abs(r - f) > o.dimensions.depth / 6) && t.push({
699
+ const o = e.reduce((l, f) => l + f.box.weight, 0);
700
+ if (o === 0) return { isValid: !0, violations: t };
701
+ let s = 0, n = 0;
702
+ for (const l of e) {
703
+ const f = L(l), h = (f.minX + f.maxX) / 2, g = (f.minZ + f.maxZ) / 2;
704
+ s += h * l.box.weight, n += g * l.box.weight;
705
+ }
706
+ s /= o, n /= o;
707
+ const a = i.dimensions.width / 2, c = i.dimensions.depth / 2;
708
+ return (Math.abs(s - a) > i.dimensions.width / 6 || Math.abs(n - c) > i.dimensions.depth / 6) && t.push({
709
709
  code: "BR-104",
710
710
  severity: "warning",
711
- message: `Centro de gravedad descentrado (${n.toFixed(0)}, ${r.toFixed(0)}) respecto al centro del palet`,
712
- involvedIds: [o.id]
711
+ message: `Centro de gravedad descentrado (${s.toFixed(0)}, ${n.toFixed(0)}) respecto al centro del palet`,
712
+ involvedIds: [i.id]
713
713
  }), { isValid: !0, violations: t };
714
714
  }
715
- function rt(o) {
715
+ function at(i) {
716
716
  const e = [];
717
- for (const t of o) {
717
+ for (const t of i) {
718
718
  if (t.box.stackable) continue;
719
- const i = D(t);
720
- for (const n of o) {
721
- if (n.id === t.id) continue;
722
- const r = D(n);
723
- r.minY >= i.maxY - 1 && r.minX < i.maxX && r.maxX > i.minX && r.minZ < i.maxZ && r.maxZ > i.minZ && e.push({
719
+ const o = L(t);
720
+ for (const s of i) {
721
+ if (s.id === t.id) continue;
722
+ const n = L(s);
723
+ n.minY >= o.maxY - 1 && n.minX < o.maxX && n.maxX > o.minX && n.minZ < o.maxZ && n.maxZ > o.minZ && e.push({
724
724
  code: "BR-201",
725
725
  severity: "error",
726
- message: `Caja ${n.id} apilada sobre caja no apilable ${t.id}`,
727
- involvedIds: [t.id, n.id]
726
+ message: `Caja ${s.id} apilada sobre caja no apilable ${t.id}`,
727
+ involvedIds: [t.id, s.id]
728
728
  });
729
729
  }
730
730
  }
731
731
  return { isValid: e.length === 0, violations: e };
732
732
  }
733
- function at(o) {
733
+ function ct(i) {
734
734
  const e = [];
735
- for (const t of o) {
736
- const i = D(t), n = (i.maxX - i.minX) * (i.maxZ - i.minZ);
737
- for (const r of o) {
738
- if (r.id === t.id) continue;
739
- const a = D(r);
740
- if (a.minY < i.maxY - 1 || a.minX >= i.maxX || a.maxX <= i.minX || a.minZ >= i.maxZ || a.maxZ <= i.minZ) continue;
741
- const f = (a.maxX - a.minX) * (a.maxZ - a.minZ);
742
- r.box.weight > t.box.weight * 1.5 && f > n * 1.2 && e.push({
735
+ for (const t of i) {
736
+ const o = L(t), s = (o.maxX - o.minX) * (o.maxZ - o.minZ);
737
+ for (const n of i) {
738
+ if (n.id === t.id) continue;
739
+ const a = L(n);
740
+ if (a.minY < o.maxY - 1 || a.minX >= o.maxX || a.maxX <= o.minX || a.minZ >= o.maxZ || a.maxZ <= o.minZ) continue;
741
+ const c = (a.maxX - a.minX) * (a.maxZ - a.minZ);
742
+ n.box.weight > t.box.weight * 1.5 && c > s * 1.2 && e.push({
743
743
  code: "BR-203",
744
744
  severity: "warning",
745
- message: `Pirámide invertida: caja ${r.id} (${r.box.weight}kg) sobre caja ${t.id} (${t.box.weight}kg)`,
746
- involvedIds: [t.id, r.id]
745
+ message: `Pirámide invertida: caja ${n.id} (${n.box.weight}kg) sobre caja ${t.id} (${t.box.weight}kg)`,
746
+ involvedIds: [t.id, n.id]
747
747
  });
748
748
  }
749
749
  }
750
750
  return { isValid: !0, violations: e };
751
751
  }
752
- function $t(o) {
752
+ function $t(i) {
753
753
  const e = [];
754
- if (o.floors.length <= 1) return { isValid: !0, violations: e };
755
- const t = o.floors[0].pallet;
756
- for (let i = 1; i < o.floors.length; i++) {
757
- const n = o.floors[i].pallet;
758
- (n.dimensions.width !== t.dimensions.width || n.dimensions.depth !== t.dimensions.depth) && e.push({
754
+ if (i.floors.length <= 1) return { isValid: !0, violations: e };
755
+ const t = i.floors[0].pallet;
756
+ for (let o = 1; o < i.floors.length; o++) {
757
+ const s = i.floors[o].pallet;
758
+ (s.dimensions.width !== t.dimensions.width || s.dimensions.depth !== t.dimensions.depth) && e.push({
759
759
  code: "BR-301",
760
760
  severity: "error",
761
- message: `Piso ${i}: dimensiones (${n.dimensions.width}×${n.dimensions.depth}) distintas a la base (${t.dimensions.width}×${t.dimensions.depth})`,
762
- involvedIds: [t.id, n.id]
761
+ message: `Piso ${o}: dimensiones (${s.dimensions.width}×${s.dimensions.depth}) distintas a la base (${t.dimensions.width}×${t.dimensions.depth})`,
762
+ involvedIds: [t.id, s.id]
763
763
  });
764
764
  }
765
765
  return { isValid: e.length === 0, violations: e };
766
766
  }
767
- function Wt(o) {
767
+ function Lt(i) {
768
768
  const e = [];
769
- for (let t = 0; t < o.floors.length - 1; t++)
770
- o.floors[t].separatorAbove || e.push({
769
+ for (let t = 0; t < i.floors.length - 1; t++)
770
+ i.floors[t].separatorAbove || e.push({
771
771
  code: "BR-302",
772
772
  severity: "error",
773
773
  message: `Falta separador entre piso ${t} y piso ${t + 1}`,
774
- involvedIds: [o.id]
774
+ involvedIds: [i.id]
775
775
  });
776
776
  return { isValid: e.length === 0, violations: e };
777
777
  }
778
- function Bt(o, e) {
779
- const t = [], i = le(o);
780
- return i > e && t.push({
778
+ function Gt(i, e) {
779
+ const t = [], o = le(i);
780
+ return o > e && t.push({
781
781
  code: "BR-303",
782
782
  severity: "error",
783
- message: `Altura del stack (${i}mm) excede la del contenedor (${e}mm)`,
784
- involvedIds: [o.id]
783
+ message: `Altura del stack (${o}mm) excede la del contenedor (${e}mm)`,
784
+ involvedIds: [i.id]
785
785
  }), { isValid: t.length === 0, violations: t };
786
786
  }
787
- function Dt(o) {
788
- const e = [], t = we(o), i = o.floors[0].pallet.maxWeight, n = t - o.floors[0].pallet.weight;
789
- return n > i && e.push({
787
+ function Vt(i) {
788
+ const e = [], t = ye(i), o = i.floors[0].pallet.maxWeight, s = t - i.floors[0].pallet.weight;
789
+ return s > o && e.push({
790
790
  code: "BR-304",
791
791
  severity: "error",
792
- message: `Peso de carga del stack (${n.toFixed(1)}kg) excede la capacidad del palet base (${i}kg)`,
793
- involvedIds: [o.id]
792
+ message: `Peso de carga del stack (${s.toFixed(1)}kg) excede la capacidad del palet base (${o}kg)`,
793
+ involvedIds: [i.id]
794
794
  }), { isValid: e.length === 0, violations: e };
795
795
  }
796
- function ct(o) {
796
+ function lt(i) {
797
797
  const e = [];
798
- for (const t of o) {
799
- const i = D(t);
800
- if (i.minY <= 1) continue;
801
- const n = (i.maxX - i.minX) * (i.maxZ - i.minZ);
802
- let r = 0;
803
- for (const a of o) {
798
+ for (const t of i) {
799
+ const o = L(t);
800
+ if (o.minY <= 1) continue;
801
+ const s = (o.maxX - o.minX) * (o.maxZ - o.minZ);
802
+ let n = 0;
803
+ for (const a of i) {
804
804
  if (a.id === t.id) continue;
805
- const f = D(a);
806
- if (Math.abs(f.maxY - i.minY) > 2) continue;
807
- const g = Math.max(0, Math.min(i.maxX, f.maxX) - Math.max(i.minX, f.minX)), v = Math.max(0, Math.min(i.maxZ, f.maxZ) - Math.max(i.minZ, f.minZ));
808
- r += g * v;
805
+ const c = L(a);
806
+ if (Math.abs(c.maxY - o.minY) > 2) continue;
807
+ const l = Math.max(0, Math.min(o.maxX, c.maxX) - Math.max(o.minX, c.minX)), f = Math.max(0, Math.min(o.maxZ, c.maxZ) - Math.max(o.minZ, c.minZ));
808
+ n += l * f;
809
809
  }
810
- n > 0 && r / n < Me && e.push({
810
+ s > 0 && n / s < ze && e.push({
811
811
  code: "BR-004",
812
812
  severity: "error",
813
- message: `Caja ${t.id} sin soporte suficiente (${(r / n * 100).toFixed(0)}% < ${Me * 100}%)`,
813
+ message: `Caja ${t.id} sin soporte suficiente (${(n / s * 100).toFixed(0)}% < ${ze * 100}%)`,
814
814
  involvedIds: [t.id]
815
815
  });
816
816
  }
817
817
  return { isValid: e.length === 0, violations: e };
818
818
  }
819
- function q(o) {
820
- if (o.length === 0) return { x: 0, y: 0, z: 0 };
821
- let e = 0, t = 0, i = 0, n = 0;
822
- for (const r of o) {
823
- const a = D(r), f = (a.minX + a.maxX) / 2, g = (a.minY + a.maxY) / 2, v = (a.minZ + a.maxZ) / 2, u = r.box.weight;
824
- t += f * u, i += g * u, n += v * u, e += u;
819
+ function Y(i) {
820
+ if (i.length === 0) return { x: 0, y: 0, z: 0 };
821
+ let e = 0, t = 0, o = 0, s = 0;
822
+ for (const n of i) {
823
+ const a = L(n), c = (a.minX + a.maxX) / 2, l = (a.minY + a.maxY) / 2, f = (a.minZ + a.maxZ) / 2, h = n.box.weight;
824
+ t += c * h, o += l * h, s += f * h, e += h;
825
825
  }
826
826
  return e === 0 ? { x: 0, y: 0, z: 0 } : {
827
827
  x: t / e,
828
- y: i / e,
829
- z: n / e
828
+ y: o / e,
829
+ z: s / e
830
830
  };
831
831
  }
832
- function se(o, e) {
832
+ function ee(i, e) {
833
833
  if (e.length === 0) return 100;
834
- const t = q(e), i = o.dimensions.width / 2, n = o.dimensions.depth / 2, r = Math.abs(t.x - i) / (o.dimensions.width / 2), a = Math.abs(t.z - n) / (o.dimensions.depth / 2), f = Math.max(0, 100 - (r + a) * 50), g = e.reduce((x, p) => {
835
- const c = D(p);
836
- return Math.max(x, c.maxY);
837
- }, 0), v = g > 0 ? t.y / g : 0, u = Math.max(0, 100 - Math.max(0, v - 0.5) * 100);
838
- return Math.round(f * 0.7 + u * 0.3);
834
+ const t = Y(e), o = i.dimensions.width / 2, s = i.dimensions.depth / 2, n = Math.abs(t.x - o) / (i.dimensions.width / 2), a = Math.abs(t.z - s) / (i.dimensions.depth / 2), c = Math.max(0, 100 - (n + a) * 50), l = e.reduce((g, w) => {
835
+ const m = L(w);
836
+ return Math.max(g, m.maxY);
837
+ }, 0), f = l > 0 ? t.y / l : 0, h = Math.max(0, 100 - Math.max(0, f - 0.5) * 100);
838
+ return Math.round(c * 0.7 + h * 0.3);
839
839
  }
840
- function lt(o, e) {
840
+ function dt(i, e) {
841
841
  const t = [];
842
842
  if (e.length === 0) return { isValid: !0, violations: t };
843
- const i = q(e);
844
- return (i.x < 0 || i.x > o.dimensions.width || i.z < 0 || i.z > o.dimensions.depth) && t.push({
843
+ const o = Y(e);
844
+ return (o.x < 0 || o.x > i.dimensions.width || o.z < 0 || o.z > i.dimensions.depth) && t.push({
845
845
  code: "BR-502",
846
846
  severity: "error",
847
- message: `Centro de gravedad (${i.x.toFixed(0)}, ${i.z.toFixed(0)}) fuera del palet`,
848
- involvedIds: [o.id]
847
+ message: `Centro de gravedad (${o.x.toFixed(0)}, ${o.z.toFixed(0)}) fuera del palet`,
848
+ involvedIds: [i.id]
849
849
  }), { isValid: t.length === 0, violations: t };
850
850
  }
851
- function dt(o, e) {
851
+ function ht(i, e) {
852
852
  const t = [];
853
853
  if (e.length === 0) return { isValid: !0, violations: t };
854
- const i = se(o, e);
855
- i < 50 ? t.push({
854
+ const o = ee(i, e);
855
+ o < 50 ? t.push({
856
856
  code: "BR-501",
857
857
  severity: "error",
858
- message: `Score de estabilidad bajo (${i}/100, mínimo: 50)`,
859
- involvedIds: [o.id]
860
- }) : i < 70 && t.push({
858
+ message: `Score de estabilidad bajo (${o}/100, mínimo: 50)`,
859
+ involvedIds: [i.id]
860
+ }) : o < 70 && t.push({
861
861
  code: "BR-501",
862
862
  severity: "warning",
863
- message: `Score de estabilidad mejorable (${i}/100, recomendado: ≥70)`,
864
- involvedIds: [o.id]
863
+ message: `Score de estabilidad mejorable (${o}/100, recomendado: ≥70)`,
864
+ involvedIds: [i.id]
865
865
  });
866
- const n = q(e), r = e.reduce((a, f) => Math.max(a, D(f).maxY), 0);
867
- return r > 0 && n.y > r * 0.6 && t.push({
866
+ const s = Y(e), n = e.reduce((a, c) => Math.max(a, L(c).maxY), 0);
867
+ return n > 0 && s.y > n * 0.6 && t.push({
868
868
  code: "BR-503",
869
869
  severity: "warning",
870
- message: `Centro de gravedad alto (${n.y.toFixed(0)}mm, ${(n.y / r * 100).toFixed(0)}% de la altura)`,
871
- involvedIds: [o.id]
870
+ message: `Centro de gravedad alto (${s.y.toFixed(0)}mm, ${(s.y / n * 100).toFixed(0)}% de la altura)`,
871
+ involvedIds: [i.id]
872
872
  }), { isValid: t.filter((a) => a.severity === "error").length === 0, violations: t };
873
873
  }
874
- function ht(o, e) {
874
+ function mt(i, e) {
875
875
  let t = !1;
876
- const i = e.length;
877
- for (let n = 0, r = i - 1; n < i; r = n++) {
878
- const a = e[n].x, f = e[n].z, g = e[r].x, v = e[r].z;
879
- f > o.z != v > o.z && o.x < (g - a) * (o.z - f) / (v - f) + a && (t = !t);
876
+ const o = e.length;
877
+ for (let s = 0, n = o - 1; s < o; n = s++) {
878
+ const a = e[s].x, c = e[s].z, l = e[n].x, f = e[n].z;
879
+ c > i.z != f > i.z && i.x < (l - a) * (i.z - c) / (f - c) + a && (t = !t);
880
880
  }
881
881
  return t;
882
882
  }
883
- function We(o, e) {
884
- const t = [], i = oe(o), n = [
885
- { x: i.minX, z: i.minZ },
886
- { x: i.maxX, z: i.minZ },
887
- { x: i.maxX, z: i.maxZ },
888
- { x: i.minX, z: i.maxZ }
883
+ function We(i, e) {
884
+ const t = [], o = se(i), s = [
885
+ { x: o.minX, z: o.minZ },
886
+ { x: o.maxX, z: o.minZ },
887
+ { x: o.maxX, z: o.maxZ },
888
+ { x: o.minX, z: o.maxZ }
889
889
  ];
890
- for (const r of n)
891
- if (!ht(r, e.floorPolygon)) {
890
+ for (const n of s)
891
+ if (!mt(n, e.floorPolygon)) {
892
892
  t.push({
893
893
  code: "BR-401",
894
894
  severity: "error",
895
- message: `Palet ${o.id} fuera de la estancia ${e.name} en (${r.x}, ${r.z})`,
896
- involvedIds: [o.id, e.id]
895
+ message: `Palet ${i.id} fuera de la estancia ${e.name} en (${n.x}, ${n.z})`,
896
+ involvedIds: [i.id, e.id]
897
897
  });
898
898
  break;
899
899
  }
900
- return i.maxY > e.ceilingHeight && t.push({
900
+ return o.maxY > e.ceilingHeight && t.push({
901
901
  code: "BR-403",
902
902
  severity: "error",
903
- message: `Palet ${o.id} excede el techo de la estancia ${e.name}`,
904
- involvedIds: [o.id, e.id]
903
+ message: `Palet ${i.id} excede el techo de la estancia ${e.name}`,
904
+ involvedIds: [i.id, e.id]
905
905
  }), { isValid: t.length === 0, violations: t };
906
906
  }
907
- class mt {
907
+ class ut {
908
908
  id = "column";
909
909
  name = "Columnas por tipo";
910
910
  pack(e, t) {
911
- const i = [], n = [], r = /* @__PURE__ */ new Map();
912
- for (const c of e) {
913
- const l = c.type ?? c.sku ?? "default";
914
- r.has(l) || r.set(l, []), r.get(l).push(c);
911
+ const o = [], s = [], n = /* @__PURE__ */ new Map();
912
+ for (const m of e) {
913
+ const x = m.type ?? m.sku ?? "default";
914
+ n.has(x) || n.set(x, []), n.get(x).push(m);
915
915
  }
916
- let a = 0, f = 0;
917
- for (const [, c] of r) {
918
- if (c.length === 0) continue;
919
- const l = c[0], d = l.dimensions.width, h = l.dimensions.depth, j = l.dimensions.height;
920
- if (a + d > t.dimensions.width) {
921
- n.push(...c);
916
+ let a = 0, c = 0;
917
+ for (const [, m] of n) {
918
+ if (m.length === 0) continue;
919
+ const x = m[0], u = x.dimensions.width, d = x.dimensions.depth, b = x.dimensions.height;
920
+ if (a + u > t.dimensions.width) {
921
+ s.push(...m);
922
922
  continue;
923
923
  }
924
- let T = 0, z = 0, b = 0;
925
- for (; b < c.length; ) {
926
- const M = c[b];
927
- if (T + h > t.dimensions.depth) {
928
- if (T = 0, z += j, z + j > t.maxStackHeight) {
929
- n.push(...c.slice(b));
924
+ let j = 0, E = 0, S = 0;
925
+ for (; S < m.length; ) {
926
+ const C = m[S];
927
+ if (j + d > t.dimensions.depth) {
928
+ if (j = 0, E += b, E + b > t.maxStackHeight) {
929
+ s.push(...m.slice(S));
930
930
  break;
931
931
  }
932
932
  continue;
933
933
  }
934
- i.push({
935
- id: `placed-${++f}`,
936
- box: M,
937
- position: { x: a, y: z, z: T },
934
+ o.push({
935
+ id: `placed-${++c}`,
936
+ box: C,
937
+ position: { x: a, y: E, z: j },
938
938
  rotation: { x: 0, y: 0, z: 0 },
939
939
  supportedBy: [],
940
940
  supporting: []
941
- }), T += h, b++;
941
+ }), j += d, S++;
942
942
  }
943
- a += d;
943
+ a += u;
944
944
  }
945
- const g = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, v = i.reduce((c, l) => {
946
- const d = l.box.dimensions;
947
- return c + d.width * d.height * d.depth;
948
- }, 0), u = i.reduce((c, l) => c + l.box.weight, 0), x = q(i), p = se(t, i);
945
+ const l = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, f = o.reduce((m, x) => {
946
+ const u = x.box.dimensions;
947
+ return m + u.width * u.height * u.depth;
948
+ }, 0), h = o.reduce((m, x) => m + x.box.weight, 0), g = Y(o), w = ee(t, o);
949
949
  return {
950
- placements: i,
950
+ placements: o,
951
951
  metrics: {
952
- volumeUtilization: g > 0 ? v / g : 0,
953
- weightUtilization: t.maxWeight > 0 ? u / t.maxWeight : 0,
954
- centerOfGravity: x,
955
- stabilityScore: p
952
+ volumeUtilization: l > 0 ? f / l : 0,
953
+ weightUtilization: t.maxWeight > 0 ? h / t.maxWeight : 0,
954
+ centerOfGravity: g,
955
+ stabilityScore: w
956
956
  },
957
- unplacedBoxes: n
957
+ unplacedBoxes: s
958
958
  };
959
959
  }
960
960
  }
961
- class ut {
961
+ class xt {
962
962
  id = "bin-packing-3d";
963
963
  name = "Bin Packing 3D (FFD Height)";
964
964
  pack(e, t) {
965
- const i = [], n = [], r = [...e].sort((x, p) => {
966
- const c = x.dimensions.width * x.dimensions.height * x.dimensions.depth;
967
- return p.dimensions.width * p.dimensions.height * p.dimensions.depth - c;
965
+ const o = [], s = [], n = [...e].sort((g, w) => {
966
+ const m = g.dimensions.width * g.dimensions.height * g.dimensions.depth;
967
+ return w.dimensions.width * w.dimensions.height * w.dimensions.depth - m;
968
968
  }), a = [
969
969
  {
970
970
  x: 0,
@@ -975,124 +975,646 @@ class ut {
975
975
  depth: t.dimensions.depth
976
976
  }
977
977
  ];
978
- let f = 0;
979
- for (const x of r) {
980
- let p = !1;
981
- const c = [
982
- { w: x.dimensions.width, h: x.dimensions.height, d: x.dimensions.depth, rot: 0 },
983
- { w: x.dimensions.depth, h: x.dimensions.height, d: x.dimensions.width, rot: 90 }
978
+ let c = 0;
979
+ for (const g of n) {
980
+ let w = !1;
981
+ const m = [
982
+ { w: g.dimensions.width, h: g.dimensions.height, d: g.dimensions.depth, rot: 0 },
983
+ { w: g.dimensions.depth, h: g.dimensions.height, d: g.dimensions.width, rot: 90 }
984
984
  ];
985
- for (let l = 0; l < a.length && !p; l++) {
986
- const d = a[l];
987
- for (const h of c)
988
- if (h.w <= d.width && h.h <= d.height && h.d <= d.depth) {
989
- const j = {
990
- id: `placed-${++f}`,
991
- box: x,
992
- position: { x: d.x, y: d.y, z: d.z },
993
- rotation: { x: 0, y: h.rot, z: 0 },
985
+ for (let x = 0; x < a.length && !w; x++) {
986
+ const u = a[x];
987
+ for (const d of m)
988
+ if (d.w <= u.width && d.h <= u.height && d.d <= u.depth) {
989
+ const b = {
990
+ id: `placed-${++c}`,
991
+ box: g,
992
+ position: { x: u.x, y: u.y, z: u.z },
993
+ rotation: { x: 0, y: d.rot, z: 0 },
994
994
  supportedBy: [],
995
995
  supporting: []
996
- }, T = D(j);
997
- if (!i.some(
998
- (b) => ye(D(b), T)
996
+ }, j = L(b);
997
+ if (!o.some(
998
+ (S) => ve(L(S), j)
999
999
  )) {
1000
- i.push(j), p = !0, a.splice(l, 1), d.width - h.w > 0 && a.push({
1001
- x: d.x + h.w,
1002
- y: d.y,
1003
- z: d.z,
1004
- width: d.width - h.w,
1005
- height: d.height,
1006
- depth: d.depth
1007
- }), d.height - h.h > 0 && a.push({
1008
- x: d.x,
1009
- y: d.y + h.h,
1010
- z: d.z,
1011
- width: h.w,
1012
- height: d.height - h.h,
1013
- depth: h.d
1014
- }), d.depth - h.d > 0 && a.push({
1015
- x: d.x,
1016
- y: d.y,
1017
- z: d.z + h.d,
1018
- width: h.w,
1019
- height: d.height,
1020
- depth: d.depth - h.d
1021
- }), a.sort((b, M) => b.y - M.y || b.x - M.x || b.z - M.z);
1000
+ o.push(b), w = !0, a.splice(x, 1), u.width - d.w > 0 && a.push({
1001
+ x: u.x + d.w,
1002
+ y: u.y,
1003
+ z: u.z,
1004
+ width: u.width - d.w,
1005
+ height: u.height,
1006
+ depth: u.depth
1007
+ }), u.height - d.h > 0 && a.push({
1008
+ x: u.x,
1009
+ y: u.y + d.h,
1010
+ z: u.z,
1011
+ width: d.w,
1012
+ height: u.height - d.h,
1013
+ depth: d.d
1014
+ }), u.depth - d.d > 0 && a.push({
1015
+ x: u.x,
1016
+ y: u.y,
1017
+ z: u.z + d.d,
1018
+ width: d.w,
1019
+ height: u.height,
1020
+ depth: u.depth - d.d
1021
+ }), a.sort((S, C) => S.y - C.y || S.x - C.x || S.z - C.z);
1022
1022
  break;
1023
1023
  }
1024
1024
  }
1025
1025
  }
1026
- p || n.push(x);
1026
+ w || s.push(g);
1027
1027
  }
1028
- const g = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, v = i.reduce((x, p) => {
1029
- const c = p.box.dimensions;
1030
- return x + c.width * c.height * c.depth;
1031
- }, 0), u = i.reduce((x, p) => x + p.box.weight, 0);
1028
+ const l = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, f = o.reduce((g, w) => {
1029
+ const m = w.box.dimensions;
1030
+ return g + m.width * m.height * m.depth;
1031
+ }, 0), h = o.reduce((g, w) => g + w.box.weight, 0);
1032
1032
  return {
1033
- placements: i,
1033
+ placements: o,
1034
1034
  metrics: {
1035
- volumeUtilization: g > 0 ? v / g : 0,
1036
- weightUtilization: t.maxWeight > 0 ? u / t.maxWeight : 0,
1037
- centerOfGravity: q(i),
1038
- stabilityScore: se(t, i)
1035
+ volumeUtilization: l > 0 ? f / l : 0,
1036
+ weightUtilization: t.maxWeight > 0 ? h / t.maxWeight : 0,
1037
+ centerOfGravity: Y(o),
1038
+ stabilityScore: ee(t, o)
1039
1039
  },
1040
- unplacedBoxes: n
1040
+ unplacedBoxes: s
1041
1041
  };
1042
1042
  }
1043
1043
  }
1044
- class xt {
1044
+ class gt {
1045
1045
  id = "type-group";
1046
1046
  name = "Agrupación por tipo";
1047
1047
  pack(e, t) {
1048
- const i = [], n = [], r = [...e].sort((l, d) => {
1049
- const h = l.type ?? l.sku ?? "z", j = d.type ?? d.sku ?? "z";
1050
- return h !== j ? h.localeCompare(j) : l.fragile !== d.fragile ? l.fragile ? 1 : -1 : d.weight - l.weight;
1048
+ const o = [], s = [], n = [...e].sort((x, u) => {
1049
+ const d = x.type ?? x.sku ?? "z", b = u.type ?? u.sku ?? "z";
1050
+ return d !== b ? d.localeCompare(b) : x.fragile !== u.fragile ? x.fragile ? 1 : -1 : u.weight - x.weight;
1051
1051
  });
1052
- let a = 0, f = 0, g = 0, v = 0, u = 0;
1053
- for (const l of r) {
1054
- const d = l.dimensions.width, h = l.dimensions.height, j = l.dimensions.depth;
1055
- if (a + d > t.dimensions.width && (a = 0, f += v > 0 ? j : 0), f + j > t.dimensions.depth && (a = 0, f = 0, g += v, v = 0), g + h > t.maxStackHeight) {
1056
- n.push(l);
1052
+ let a = 0, c = 0, l = 0, f = 0, h = 0;
1053
+ for (const x of n) {
1054
+ const u = x.dimensions.width, d = x.dimensions.height, b = x.dimensions.depth;
1055
+ if (a + u > t.dimensions.width && (a = 0, c += f > 0 ? b : 0), c + b > t.dimensions.depth && (a = 0, c = 0, l += f, f = 0), l + d > t.maxStackHeight) {
1056
+ s.push(x);
1057
1057
  continue;
1058
1058
  }
1059
- if (a + d > t.dimensions.width) {
1060
- n.push(l);
1059
+ if (a + u > t.dimensions.width) {
1060
+ s.push(x);
1061
1061
  continue;
1062
1062
  }
1063
- if (f + j > t.dimensions.depth) {
1064
- n.push(l);
1063
+ if (c + b > t.dimensions.depth) {
1064
+ s.push(x);
1065
1065
  continue;
1066
1066
  }
1067
- i.push({
1068
- id: `placed-${++u}`,
1069
- box: l,
1070
- position: { x: a, y: g, z: f },
1067
+ o.push({
1068
+ id: `placed-${++h}`,
1069
+ box: x,
1070
+ position: { x: a, y: l, z: c },
1071
1071
  rotation: { x: 0, y: 0, z: 0 },
1072
1072
  supportedBy: [],
1073
1073
  supporting: []
1074
- }), a += d, v = Math.max(v, h);
1074
+ }), a += u, f = Math.max(f, d);
1075
1075
  }
1076
- const x = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, p = i.reduce((l, d) => {
1077
- const h = d.box.dimensions;
1078
- return l + h.width * h.height * h.depth;
1079
- }, 0), c = i.reduce((l, d) => l + d.box.weight, 0);
1076
+ const g = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, w = o.reduce((x, u) => {
1077
+ const d = u.box.dimensions;
1078
+ return x + d.width * d.height * d.depth;
1079
+ }, 0), m = o.reduce((x, u) => x + u.box.weight, 0);
1080
1080
  return {
1081
- placements: i,
1081
+ placements: o,
1082
1082
  metrics: {
1083
- volumeUtilization: x > 0 ? p / x : 0,
1084
- weightUtilization: t.maxWeight > 0 ? c / t.maxWeight : 0,
1085
- centerOfGravity: q(i),
1086
- stabilityScore: se(t, i)
1083
+ volumeUtilization: g > 0 ? w / g : 0,
1084
+ weightUtilization: t.maxWeight > 0 ? m / t.maxWeight : 0,
1085
+ centerOfGravity: Y(o),
1086
+ stabilityScore: ee(t, o)
1087
1087
  },
1088
- unplacedBoxes: n
1088
+ unplacedBoxes: s
1089
1089
  };
1090
1090
  }
1091
1091
  }
1092
- class gt {
1092
+ class ft {
1093
+ id = "material-grouping";
1094
+ name = "Material & Product Grouping";
1095
+ /**
1096
+ * Packs boxes into a pallet using layer-based approach with material ordering
1097
+ *
1098
+ * @param boxes - Boxes to pack
1099
+ * @param pallet - Target pallet
1100
+ * @returns Packing result with placements and metrics
1101
+ */
1102
+ pack(e, t) {
1103
+ if (e.length === 0)
1104
+ return this.emptyResult();
1105
+ const o = this.sortBoxes(e), s = this.groupByMaterialWeight(o), a = this.buildLayers(s, t).flatMap((f) => f.placements), c = e.filter(
1106
+ (f) => !a.some((h) => h.box.id === f.id)
1107
+ ), l = this.calculateMetrics(a, t);
1108
+ return {
1109
+ placements: a,
1110
+ metrics: l,
1111
+ unplacedBoxes: c
1112
+ };
1113
+ }
1114
+ // ─── Phase 1: Sorting ──────────────────────────────────────────────
1115
+ /**
1116
+ * Sorts boxes by multiple criteria:
1117
+ * 1. Material weight (descending) - more resistant boxes first
1118
+ * 2. Product (alphabetical) - group same products together
1119
+ * 3. Base area (descending) - larger boxes first for stable base
1120
+ * 4. Height (descending) - taller boxes first for better layer filling
1121
+ *
1122
+ * @param boxes - Boxes to sort
1123
+ * @returns Sorted boxes array
1124
+ */
1125
+ sortBoxes(e) {
1126
+ return [...e].sort((t, o) => {
1127
+ const s = t.materialWeight ?? 5, n = o.materialWeight ?? 5;
1128
+ if (s !== n)
1129
+ return n - s;
1130
+ const a = t.product ?? "", c = o.product ?? "";
1131
+ if (a !== c)
1132
+ return a.localeCompare(c);
1133
+ const l = t.dimensions.width * t.dimensions.depth, f = o.dimensions.width * o.dimensions.depth;
1134
+ return l !== f ? f - l : o.dimensions.height - t.dimensions.height;
1135
+ });
1136
+ }
1137
+ /**
1138
+ * Groups boxes by material weight for layer construction
1139
+ *
1140
+ * @param boxes - Sorted boxes
1141
+ * @returns Map of material weight → boxes with that weight
1142
+ */
1143
+ groupByMaterialWeight(e) {
1144
+ const t = /* @__PURE__ */ new Map();
1145
+ for (const o of e) {
1146
+ const s = o.materialWeight ?? 5;
1147
+ t.has(s) || t.set(s, []), t.get(s).push(o);
1148
+ }
1149
+ return new Map([...t.entries()].sort((o, s) => s[0] - o[0]));
1150
+ }
1151
+ // ─── Phase 2: Layer Construction ──────────────────────────────────
1152
+ /**
1153
+ * Builds layers from bottom to top, processing each material weight group
1154
+ *
1155
+ * @param materialGroups - Boxes grouped by material weight
1156
+ * @param pallet - Target pallet
1157
+ * @returns Array of layers
1158
+ */
1159
+ buildLayers(e, t) {
1160
+ const o = [], s = /* @__PURE__ */ new Map(), n = [];
1161
+ let a = 0;
1162
+ for (const [, c] of e) {
1163
+ let l = [...c];
1164
+ for (; l.length > 0; ) {
1165
+ const f = this.buildNextLayer(
1166
+ l,
1167
+ t,
1168
+ a,
1169
+ s,
1170
+ n
1171
+ );
1172
+ if (f.placements.length === 0)
1173
+ break;
1174
+ o.push(f), n.push(...f.placements), a += f.height;
1175
+ const h = new Set(f.placements.map((g) => g.box.id));
1176
+ if (l = l.filter((g) => !h.has(g.id)), a >= t.maxStackHeight)
1177
+ break;
1178
+ }
1179
+ }
1180
+ return o;
1181
+ }
1182
+ /**
1183
+ * Builds the next layer using available boxes
1184
+ *
1185
+ * Strategy:
1186
+ * 1. Try uniform height layer with 100% coverage
1187
+ * 2. If not possible, try mixed height layer
1188
+ * 3. If still not possible, use partial coverage (last resort)
1189
+ *
1190
+ * @param availableBoxes - Boxes available for this layer
1191
+ * @param pallet - Target pallet
1192
+ * @param currentY - Current vertical position
1193
+ * @param occupiedColumns - Track which (x,z) positions have which product
1194
+ * @param allPreviousPlacements - All placements from previous layers (for support calculation)
1195
+ * @returns Constructed layer
1196
+ */
1197
+ buildNextLayer(e, t, o, s, n) {
1198
+ const a = this.tryUniformHeightLayer(
1199
+ e,
1200
+ t,
1201
+ o,
1202
+ s,
1203
+ n
1204
+ );
1205
+ if (a && a.coverage >= 95)
1206
+ return a;
1207
+ const c = this.tryMixedHeightLayer(
1208
+ e,
1209
+ t,
1210
+ o,
1211
+ s,
1212
+ n
1213
+ );
1214
+ return c && c.coverage >= 95 ? c : ((a?.coverage ?? 0) > (c?.coverage ?? 0) ? a : c) ?? this.emptyLayer(o);
1215
+ }
1216
+ /**
1217
+ * Attempts to create a layer with boxes of uniform height
1218
+ *
1219
+ * @param boxes - Available boxes
1220
+ * @param pallet - Target pallet
1221
+ * @param currentY - Current vertical position
1222
+ * @param occupiedColumns - Occupied column tracker
1223
+ * @param allPreviousPlacements - All placements from previous layers
1224
+ * @returns Layer or null if not possible
1225
+ */
1226
+ tryUniformHeightLayer(e, t, o, s, n) {
1227
+ const a = /* @__PURE__ */ new Map();
1228
+ for (const l of e) {
1229
+ const f = l.dimensions.height;
1230
+ a.has(f) || a.set(f, []), a.get(f).push(l);
1231
+ }
1232
+ const c = [...a.entries()].sort(
1233
+ (l, f) => f[1].length - l[1].length
1234
+ );
1235
+ for (const [l, f] of c) {
1236
+ if (o + l > t.maxStackHeight)
1237
+ continue;
1238
+ const h = this.placeBoxesInLayer(
1239
+ f,
1240
+ t,
1241
+ o,
1242
+ l,
1243
+ s,
1244
+ n
1245
+ );
1246
+ if (h.coverage >= 95)
1247
+ return h;
1248
+ }
1249
+ return null;
1250
+ }
1251
+ /**
1252
+ * Attempts to create a layer with boxes of mixed heights
1253
+ *
1254
+ * @param boxes - Available boxes
1255
+ * @param pallet - Target pallet
1256
+ * @param currentY - Current vertical position
1257
+ * @param occupiedColumns - Occupied column tracker
1258
+ * @param allPreviousPlacements - All placements from previous layers
1259
+ * @returns Layer or null if not possible
1260
+ */
1261
+ tryMixedHeightLayer(e, t, o, s, n) {
1262
+ return this.placeBoxesInLayer(
1263
+ e,
1264
+ t,
1265
+ o,
1266
+ null,
1267
+ s,
1268
+ n
1269
+ );
1270
+ }
1271
+ // ─── Phase 3: Maximal Rectangles 2D Packing ───────────────────────
1272
+ /**
1273
+ * Places boxes in a layer using Maximal Rectangles algorithm
1274
+ *
1275
+ * @param boxes - Boxes to place
1276
+ * @param pallet - Target pallet
1277
+ * @param currentY - Y coordinate of this layer
1278
+ * @param targetHeight - If specified, only use boxes of this height
1279
+ * @param occupiedColumns - Track product columns
1280
+ * @param allPreviousPlacements - All placements from previous layers (for support calculation)
1281
+ * @returns Constructed layer
1282
+ */
1283
+ placeBoxesInLayer(e, t, o, s, n, a) {
1284
+ const c = [
1285
+ {
1286
+ x: 0,
1287
+ z: 0,
1288
+ width: t.dimensions.width,
1289
+ depth: t.dimensions.depth
1290
+ }
1291
+ ], l = [], h = [...this.groupByProduct(e).entries()].sort(
1292
+ (u, d) => d[1].length - u[1].length
1293
+ );
1294
+ let g = 0;
1295
+ for (const [u, d] of h) {
1296
+ const b = s ? d.filter((j) => j.dimensions.height === s) : d;
1297
+ for (const j of b) {
1298
+ if (o + j.dimensions.height > t.maxStackHeight)
1299
+ continue;
1300
+ const E = [
1301
+ {
1302
+ width: j.dimensions.width,
1303
+ depth: j.dimensions.depth,
1304
+ rotation: 0
1305
+ },
1306
+ {
1307
+ width: j.dimensions.depth,
1308
+ depth: j.dimensions.width,
1309
+ rotation: 90
1310
+ }
1311
+ ];
1312
+ for (const S of E) {
1313
+ const C = [
1314
+ ...a,
1315
+ ...l
1316
+ ], z = this.findBestRectangle(
1317
+ S,
1318
+ c,
1319
+ n,
1320
+ u,
1321
+ o,
1322
+ C
1323
+ );
1324
+ if (z) {
1325
+ const y = {
1326
+ id: `placed-${++g}`,
1327
+ box: j,
1328
+ position: { x: z.x, y: o, z: z.z },
1329
+ rotation: { x: 0, y: S.rotation, z: 0 },
1330
+ supportedBy: [],
1331
+ supporting: []
1332
+ };
1333
+ l.push(y), this.updateOccupiedColumns(
1334
+ n,
1335
+ z.x,
1336
+ z.z,
1337
+ u
1338
+ ), this.updateFreeRectangles(
1339
+ c,
1340
+ z,
1341
+ S.width,
1342
+ S.depth
1343
+ );
1344
+ break;
1345
+ }
1346
+ }
1347
+ }
1348
+ }
1349
+ const w = t.dimensions.width * t.dimensions.depth, m = l.reduce((u, d) => {
1350
+ const b = d.rotation.y === 90 ? d.box.dimensions.depth : d.box.dimensions.width, j = d.rotation.y === 90 ? d.box.dimensions.width : d.box.dimensions.depth;
1351
+ return u + b * j;
1352
+ }, 0), x = l.length > 0 ? Math.max(...l.map((u) => u.box.dimensions.height)) : 0;
1353
+ return {
1354
+ y: o,
1355
+ height: x,
1356
+ placements: l,
1357
+ coverage: m / w * 100
1358
+ };
1359
+ }
1360
+ /**
1361
+ * Finds the best free rectangle for a box using scoring
1362
+ *
1363
+ * @param boxDims - Box dimensions (with rotation applied)
1364
+ * @param freeRectangles - Available free spaces
1365
+ * @param occupiedColumns - Product column tracker
1366
+ * @param product - Product identifier
1367
+ * @param currentY - Current layer Y position
1368
+ * @param existingPlacements - Already placed boxes in this layer and below
1369
+ * @param pallet - Pallet dimensions
1370
+ * @returns Best rectangle or null if none fit
1371
+ */
1372
+ findBestRectangle(e, t, o, s, n, a) {
1373
+ let c = null, l = -1 / 0;
1374
+ for (const f of t)
1375
+ if (e.width <= f.width && e.depth <= f.depth) {
1376
+ const h = this.calculateSupportArea(
1377
+ f.x,
1378
+ f.z,
1379
+ e.width,
1380
+ e.depth,
1381
+ n,
1382
+ a
1383
+ ), g = e.width * e.depth;
1384
+ if (h / g < 0.7 || this.boxExtendsBeyondLowerLayer(
1385
+ f.x,
1386
+ f.z,
1387
+ e.width,
1388
+ e.depth,
1389
+ n,
1390
+ a
1391
+ ))
1392
+ continue;
1393
+ const m = this.scoreRectangle(
1394
+ f,
1395
+ e,
1396
+ o,
1397
+ s
1398
+ );
1399
+ m > l && (l = m, c = f);
1400
+ }
1401
+ return c;
1402
+ }
1403
+ /**
1404
+ * Calculates the area of support a box would have at a given position
1405
+ *
1406
+ * @param x - X position of box
1407
+ * @param z - Z position of box
1408
+ * @param width - Width of box
1409
+ * @param depth - Depth of box
1410
+ * @param currentY - Y position where box will be placed
1411
+ * @param existingPlacements - Boxes already placed in current and previous layers
1412
+ * @param pallet - Pallet dimensions
1413
+ * @returns Supported area in mm²
1414
+ */
1415
+ calculateSupportArea(e, t, o, s, n, a) {
1416
+ let c = 0;
1417
+ if (n === 0)
1418
+ return o * s;
1419
+ for (const l of a) {
1420
+ const f = l.rotation.y === 90 ? l.box.dimensions.depth : l.box.dimensions.width, h = l.rotation.y === 90 ? l.box.dimensions.width : l.box.dimensions.depth, g = l.position.y + l.box.dimensions.height;
1421
+ if (Math.abs(g - n) > 1)
1422
+ continue;
1423
+ const m = this.calculateRectangleIntersection(
1424
+ e,
1425
+ t,
1426
+ o,
1427
+ s,
1428
+ l.position.x,
1429
+ l.position.z,
1430
+ f,
1431
+ h
1432
+ );
1433
+ c += m;
1434
+ }
1435
+ return c;
1436
+ }
1437
+ /**
1438
+ * Calculates intersection area between two rectangles
1439
+ *
1440
+ * @returns Intersection area in mm²
1441
+ */
1442
+ calculateRectangleIntersection(e, t, o, s, n, a, c, l) {
1443
+ const f = Math.max(0, Math.min(e + o, n + c) - Math.max(e, n)), h = Math.max(0, Math.min(t + s, a + l) - Math.max(t, a));
1444
+ return f * h;
1445
+ }
1446
+ /**
1447
+ * Checks if a box would extend beyond the footprint of boxes in the layer directly below
1448
+ *
1449
+ * This ensures that boxes in upper layers are always stacked on top of lower boxes,
1450
+ * preventing boxes from "hanging" over edges when there's available space in the lower layer.
1451
+ *
1452
+ * @param x - X position of box
1453
+ * @param z - Z position of box
1454
+ * @param width - Width of box
1455
+ * @param depth - Depth of box
1456
+ * @param currentY - Y position where box will be placed
1457
+ * @param existingPlacements - Boxes already placed in current and previous layers
1458
+ * @returns true if box extends beyond lower layer footprint
1459
+ */
1460
+ boxExtendsBeyondLowerLayer(e, t, o, s, n, a) {
1461
+ if (n === 0)
1462
+ return !1;
1463
+ const c = a.filter((d) => {
1464
+ const b = d.position.y + d.box.dimensions.height;
1465
+ return Math.abs(b - n) <= 1;
1466
+ });
1467
+ if (c.length === 0)
1468
+ return !0;
1469
+ let l = 1 / 0, f = -1 / 0, h = 1 / 0, g = -1 / 0;
1470
+ for (const d of c) {
1471
+ const b = d.rotation.y === 90 ? d.box.dimensions.depth : d.box.dimensions.width, j = d.rotation.y === 90 ? d.box.dimensions.width : d.box.dimensions.depth;
1472
+ l = Math.min(l, d.position.x), f = Math.max(f, d.position.x + b), h = Math.min(h, d.position.z), g = Math.max(g, d.position.z + j);
1473
+ }
1474
+ const w = e + o, m = t + s, x = 1;
1475
+ return e < l - x || w > f + x || t < h - x || m > g + x;
1476
+ }
1477
+ /**
1478
+ * Scores a rectangle position based on multiple criteria
1479
+ *
1480
+ * Higher score = better position
1481
+ *
1482
+ * @param rect - Free rectangle
1483
+ * @param boxDims - Box dimensions
1484
+ * @param occupiedColumns - Product column tracker
1485
+ * @param product - Product identifier
1486
+ * @returns Score value
1487
+ */
1488
+ scoreRectangle(e, t, o, s) {
1489
+ let n = 0;
1490
+ const a = `${e.x},${e.z}`;
1491
+ o.get(a) === s && (n += 100), o.has(a) && o.get(a) !== s && (n -= 50);
1492
+ const c = e.width * e.depth - t.width * t.depth;
1493
+ return n += 50 / (1 + c / 1e4), n += 30 / (1 + e.x / 1e3 + e.z / 1e3), n;
1494
+ }
1495
+ /**
1496
+ * Updates free rectangles after placing a box (Maximal Rectangles algorithm)
1497
+ *
1498
+ * @param freeRects - Current free rectangles
1499
+ * @param usedRect - Rectangle being used by the new box
1500
+ * @param boxWidth - Width of placed box
1501
+ * @param boxDepth - Depth of placed box
1502
+ */
1503
+ updateFreeRectangles(e, t, o, s) {
1504
+ const n = [];
1505
+ for (let a = e.length - 1; a >= 0; a--) {
1506
+ const c = e[a];
1507
+ this.rectanglesIntersect(c, t, o, s) && (e.splice(a, 1), t.x > c.x && n.push({
1508
+ x: c.x,
1509
+ z: c.z,
1510
+ width: t.x - c.x,
1511
+ depth: c.depth
1512
+ }), t.x + o < c.x + c.width && n.push({
1513
+ x: t.x + o,
1514
+ z: c.z,
1515
+ width: c.x + c.width - (t.x + o),
1516
+ depth: c.depth
1517
+ }), t.z > c.z && n.push({
1518
+ x: c.x,
1519
+ z: c.z,
1520
+ width: c.width,
1521
+ depth: t.z - c.z
1522
+ }), t.z + s < c.z + c.depth && n.push({
1523
+ x: c.x,
1524
+ z: t.z + s,
1525
+ width: c.width,
1526
+ depth: c.z + c.depth - (t.z + s)
1527
+ }));
1528
+ }
1529
+ e.push(...n), this.removeContainedRectangles(e);
1530
+ }
1531
+ /**
1532
+ * Checks if two rectangles intersect
1533
+ */
1534
+ rectanglesIntersect(e, t, o, s) {
1535
+ return !(t.x + o <= e.x || t.x >= e.x + e.width || t.z + s <= e.z || t.z >= e.z + e.depth);
1536
+ }
1537
+ /**
1538
+ * Removes rectangles that are fully contained within other rectangles
1539
+ */
1540
+ removeContainedRectangles(e) {
1541
+ for (let t = e.length - 1; t >= 0; t--) {
1542
+ const o = e[t];
1543
+ for (let s = 0; s < e.length; s++) {
1544
+ if (t === s) continue;
1545
+ const n = e[s];
1546
+ if (o.x >= n.x && o.z >= n.z && o.x + o.width <= n.x + n.width && o.z + o.depth <= n.z + n.depth) {
1547
+ e.splice(t, 1);
1548
+ break;
1549
+ }
1550
+ }
1551
+ }
1552
+ }
1553
+ /**
1554
+ * Updates the occupied columns map after placing a box
1555
+ */
1556
+ updateOccupiedColumns(e, t, o, s) {
1557
+ const n = `${t},${o}`;
1558
+ e.has(n) || e.set(n, s);
1559
+ }
1560
+ // ─── Utility Methods ───────────────────────────────────────────────
1561
+ /**
1562
+ * Groups boxes by product identifier
1563
+ */
1564
+ groupByProduct(e) {
1565
+ const t = /* @__PURE__ */ new Map();
1566
+ for (const o of e) {
1567
+ const s = o.product ?? "default";
1568
+ t.has(s) || t.set(s, []), t.get(s).push(o);
1569
+ }
1570
+ return t;
1571
+ }
1572
+ /**
1573
+ * Creates an empty layer
1574
+ */
1575
+ emptyLayer(e) {
1576
+ return {
1577
+ y: e,
1578
+ height: 0,
1579
+ placements: [],
1580
+ coverage: 0
1581
+ };
1582
+ }
1583
+ /**
1584
+ * Creates an empty packing result
1585
+ */
1586
+ emptyResult() {
1587
+ return {
1588
+ placements: [],
1589
+ metrics: {
1590
+ volumeUtilization: 0,
1591
+ weightUtilization: 0,
1592
+ centerOfGravity: { x: 0, y: 0, z: 0 },
1593
+ stabilityScore: 100
1594
+ },
1595
+ unplacedBoxes: []
1596
+ };
1597
+ }
1598
+ /**
1599
+ * Calculates packing metrics
1600
+ */
1601
+ calculateMetrics(e, t) {
1602
+ const o = t.dimensions.width * t.maxStackHeight * t.dimensions.depth, s = e.reduce((a, c) => {
1603
+ const l = c.box.dimensions;
1604
+ return a + l.width * l.height * l.depth;
1605
+ }, 0), n = e.reduce((a, c) => a + c.box.weight, 0);
1606
+ return {
1607
+ volumeUtilization: o > 0 ? s / o : 0,
1608
+ weightUtilization: t.maxWeight > 0 ? n / t.maxWeight : 0,
1609
+ centerOfGravity: Y(e),
1610
+ stabilityScore: ee(t, e)
1611
+ };
1612
+ }
1613
+ }
1614
+ class pt {
1093
1615
  strategies = /* @__PURE__ */ new Map();
1094
1616
  constructor() {
1095
- this.register(new mt()), this.register(new ut()), this.register(new xt());
1617
+ this.register(new ut()), this.register(new xt()), this.register(new gt()), this.register(new ft());
1096
1618
  }
1097
1619
  register(e) {
1098
1620
  this.strategies.set(e.id, e);
@@ -1113,10 +1635,10 @@ class gt {
1113
1635
  return this.strategies.has(e);
1114
1636
  }
1115
1637
  }
1116
- const ft = new gt();
1117
- let pt = 0;
1638
+ const wt = new pt();
1639
+ let yt = 0;
1118
1640
  function Te() {
1119
- return `pallet-${++pt}`;
1641
+ return `pallet-${++yt}`;
1120
1642
  }
1121
1643
  class Z {
1122
1644
  // ═══ Palets estándar internacionales ═══════════════════════════
@@ -1167,16 +1689,16 @@ class Z {
1167
1689
  * @param overrides - Propiedades a sobrescribir
1168
1690
  */
1169
1691
  static fromPreset(e, t) {
1170
- const i = ue[e];
1171
- if (!i)
1692
+ const o = ue[e];
1693
+ if (!o)
1172
1694
  throw new Error(`Unknown pallet preset: ${e}`);
1173
1695
  return {
1174
1696
  id: Te(),
1175
- dimensions: { ...i.dimensions },
1176
- material: i.material,
1177
- maxWeight: i.maxWeight,
1178
- maxStackHeight: i.maxStackHeight,
1179
- weight: i.weight,
1697
+ dimensions: { ...o.dimensions },
1698
+ material: o.material,
1699
+ maxWeight: o.maxWeight,
1700
+ maxStackHeight: o.maxStackHeight,
1701
+ weight: o.weight,
1180
1702
  metadata: { preset: e },
1181
1703
  ...t
1182
1704
  };
@@ -1187,7 +1709,7 @@ class Z {
1187
1709
  return {
1188
1710
  id: Te(),
1189
1711
  dimensions: { ...e },
1190
- material: L.WOOD,
1712
+ material: N.WOOD,
1191
1713
  maxWeight: 1e3,
1192
1714
  maxStackHeight: 2200,
1193
1715
  weight: 25,
@@ -1209,107 +1731,153 @@ class Z {
1209
1731
  }
1210
1732
  }
1211
1733
  let vt = 0;
1212
- function ze() {
1734
+ function Ee() {
1213
1735
  return `truck-${++vt}`;
1214
1736
  }
1215
- class Gt {
1737
+ class Xt {
1216
1738
  /** Crea un camión a partir de un preset de tipo */
1217
1739
  static fromPreset(e, t) {
1218
- const i = Ze[e];
1740
+ const o = De[e];
1219
1741
  return {
1220
- id: ze(),
1742
+ id: Ee(),
1221
1743
  name: `Camión ${e}`,
1222
1744
  truckType: e,
1223
- dimensions: { ...i.dimensions },
1224
- maxWeight: i.maxWeight,
1745
+ dimensions: { ...o.dimensions },
1746
+ maxWeight: o.maxWeight,
1225
1747
  pallets: [],
1226
1748
  metadata: {},
1227
1749
  ...t
1228
1750
  };
1229
1751
  }
1230
1752
  /** Crea un camión custom con dimensiones y peso arbitrarios */
1231
- static custom(e, t, i) {
1753
+ static custom(e, t, o) {
1232
1754
  return {
1233
- id: ze(),
1755
+ id: Ee(),
1234
1756
  name: "Camión Custom",
1235
1757
  truckType: ie.CUSTOM,
1236
1758
  dimensions: { ...e },
1237
1759
  maxWeight: t,
1238
1760
  pallets: [],
1239
1761
  metadata: {},
1240
- ...i
1762
+ ...o
1241
1763
  };
1242
1764
  }
1243
1765
  }
1244
- let wt = 0;
1245
- function yt() {
1246
- return `box-${++wt}`;
1766
+ let bt = 0;
1767
+ function St() {
1768
+ return `box-${++bt}`;
1247
1769
  }
1248
1770
  class ge {
1249
- /** Crea una caja con valores por defecto razonables */
1771
+ /**
1772
+ * Creates a box with default values
1773
+ *
1774
+ * @param dims - Box dimensions in millimeters
1775
+ * @param opts - Optional overrides for any Box property
1776
+ * @returns A new Box instance with defaults applied
1777
+ *
1778
+ * @example
1779
+ * const box = BoxFactory.create(
1780
+ * { width: 600, height: 400, depth: 400 },
1781
+ * { product: 'PROD-A', materialWeight: 6 }
1782
+ * )
1783
+ */
1250
1784
  static create(e, t) {
1251
1785
  return {
1252
- id: yt(),
1786
+ id: St(),
1253
1787
  dimensions: { ...e },
1254
1788
  weight: 5,
1789
+ materialWeight: 5,
1790
+ // Default: medium resistance
1255
1791
  fragile: !1,
1256
1792
  stackable: !0,
1257
1793
  metadata: {},
1258
1794
  ...t
1259
1795
  };
1260
1796
  }
1261
- /** Caja frágil con peso máximo encima */
1262
- static fragile(e, t, i) {
1797
+ /**
1798
+ * Creates a fragile box with maximum weight limit
1799
+ *
1800
+ * @param dims - Box dimensions in millimeters
1801
+ * @param fragilityMaxWeight - Maximum weight (kg) this box can support on top
1802
+ * @param opts - Optional overrides
1803
+ * @returns A fragile Box instance
1804
+ *
1805
+ * @example
1806
+ * const fragileBox = BoxFactory.fragile(
1807
+ * { width: 400, height: 300, depth: 300 },
1808
+ * 10, // Can support max 10kg on top
1809
+ * { materialWeight: 0, product: 'PROD-FRAGILE' }
1810
+ * )
1811
+ */
1812
+ static fragile(e, t, o) {
1263
1813
  return ge.create(e, {
1264
1814
  fragile: !0,
1265
1815
  fragilityMaxWeight: t,
1266
- ...i
1816
+ materialWeight: 0,
1817
+ // Fragile boxes go on top
1818
+ ...o
1267
1819
  });
1268
1820
  }
1269
- /** Caja pesada y no apilable */
1270
- static heavy(e, t, i) {
1821
+ /**
1822
+ * Creates a heavy, non-stackable box
1823
+ *
1824
+ * @param dims - Box dimensions in millimeters
1825
+ * @param weight - Box weight in kilograms
1826
+ * @param opts - Optional overrides
1827
+ * @returns A heavy Box instance
1828
+ *
1829
+ * @example
1830
+ * const heavyBox = BoxFactory.heavy(
1831
+ * { width: 800, height: 600, depth: 600 },
1832
+ * 50, // 50kg
1833
+ * { materialWeight: 8, product: 'PROD-HEAVY' }
1834
+ * )
1835
+ */
1836
+ static heavy(e, t, o) {
1271
1837
  return ge.create(e, {
1272
1838
  weight: t,
1273
1839
  stackable: !1,
1274
- ...i
1840
+ materialWeight: 8,
1841
+ // Heavy boxes have high resistance
1842
+ ...o
1275
1843
  });
1276
1844
  }
1277
1845
  }
1278
- function Vt(o, e) {
1846
+ function Zt(i, e) {
1279
1847
  return k(() => {
1280
- const t = Je(o), i = et(o, e), r = it({ pallet: e, boxes: o }), a = ct(o), f = rt(o), g = at(o), v = dt(e, o), u = lt(e, o), x = ot(o), p = nt(e, o), c = [...f.violations, ...g.violations], l = [...v.violations, ...u.violations], d = [
1848
+ const t = Qe(i), o = tt(i, e), n = it({ pallet: e, boxes: i }), a = lt(i), c = at(i), l = ct(i), f = ht(e, i), h = dt(e, i), g = st(i), w = rt(e, i), m = [...c.violations, ...l.violations], x = [...f.violations, ...h.violations], u = [
1281
1849
  ...t.violations,
1282
- ...i.violations,
1283
- ...r.violations,
1850
+ ...o.violations,
1851
+ ...n.violations,
1284
1852
  ...a.violations,
1285
- ...c,
1286
- ...l,
1287
- ...x.violations,
1288
- ...p.violations
1853
+ ...m,
1854
+ ...x,
1855
+ ...g.violations,
1856
+ ...w.violations
1289
1857
  ];
1290
1858
  return {
1291
- isValid: d.filter((h) => h.severity === "error").length === 0,
1292
- violations: d,
1859
+ isValid: u.filter((d) => d.severity === "error").length === 0,
1860
+ violations: u,
1293
1861
  collisions: t,
1294
- bounds: i,
1295
- weight: r,
1862
+ bounds: o,
1863
+ weight: n,
1296
1864
  gravity: a,
1297
1865
  stacking: {
1298
- isValid: f.isValid,
1299
- violations: c
1866
+ isValid: c.isValid,
1867
+ violations: m
1300
1868
  },
1301
1869
  stability: {
1302
- isValid: v.isValid && u.isValid,
1303
- violations: l
1870
+ isValid: f.isValid && h.isValid,
1871
+ violations: x
1304
1872
  },
1305
- fragile: x,
1306
- distribution: p
1873
+ fragile: g,
1874
+ distribution: w
1307
1875
  };
1308
- }, [o, e]);
1876
+ }, [i, e]);
1309
1877
  }
1310
- function Xt(o) {
1878
+ function Dt(i) {
1311
1879
  return k(() => {
1312
- if (!o || o.floors.length === 0)
1880
+ if (!i || i.floors.length === 0)
1313
1881
  return {
1314
1882
  volumeUtilization: 0,
1315
1883
  weightUtilization: 0,
@@ -1320,140 +1888,150 @@ function Xt(o) {
1320
1888
  boxCount: 0,
1321
1889
  floorCount: 0
1322
1890
  };
1323
- const e = le(o), t = we(o), i = o.floors[0].pallet, n = o.floors.flatMap((x) => x.boxes), r = n.length, a = o.floors.length, f = i.dimensions.width * i.maxStackHeight * i.dimensions.depth, g = n.reduce((x, p) => {
1324
- const c = p.box.dimensions;
1325
- return x + c.width * c.height * c.depth;
1326
- }, 0), v = q(n), u = se(i, n);
1891
+ const e = le(i), t = ye(i), o = i.floors[0].pallet, s = i.floors.flatMap((g) => g.boxes), n = s.length, a = i.floors.length, c = o.dimensions.width * o.maxStackHeight * o.dimensions.depth, l = s.reduce((g, w) => {
1892
+ const m = w.box.dimensions;
1893
+ return g + m.width * m.height * m.depth;
1894
+ }, 0), f = Y(s), h = ee(o, s);
1327
1895
  return {
1328
- volumeUtilization: f > 0 ? g / f : 0,
1329
- weightUtilization: i.maxWeight > 0 ? t / i.maxWeight : 0,
1330
- centerOfGravity: v,
1331
- stabilityScore: u,
1896
+ volumeUtilization: c > 0 ? l / c : 0,
1897
+ weightUtilization: o.maxWeight > 0 ? t / o.maxWeight : 0,
1898
+ centerOfGravity: f,
1899
+ stabilityScore: h,
1332
1900
  totalHeight: e,
1333
1901
  totalWeight: t,
1334
- boxCount: r,
1902
+ boxCount: n,
1335
1903
  floorCount: a
1336
1904
  };
1337
- }, [o]);
1905
+ }, [i]);
1338
1906
  }
1339
- function Zt(o, e = ft) {
1907
+ function Nt(i, e = wt) {
1340
1908
  const t = k(
1341
- () => e.list().map((n) => ({ id: n.id, name: n.name })),
1909
+ () => e.list().map((s) => ({ id: s.id, name: s.name })),
1342
1910
  [e]
1343
- ), i = H(
1344
- (n, r) => e.get(o).pack(n, r),
1345
- [o, e]
1911
+ ), o = q(
1912
+ (s, n) => e.get(i).pack(s, n),
1913
+ [i, e]
1346
1914
  );
1347
- return { availableStrategies: t, pack: i };
1915
+ return { availableStrategies: t, pack: o };
1348
1916
  }
1349
- function Nt(o) {
1917
+ function Ut(i) {
1350
1918
  return k(() => {
1351
1919
  const e = [];
1352
- for (const n of o.pallets) {
1353
- const r = We(n, o);
1354
- e.push(...r.violations);
1920
+ for (const s of i.pallets) {
1921
+ const n = We(s, i);
1922
+ e.push(...n.violations);
1355
1923
  }
1356
- const t = Qe(o.pallets), i = [
1924
+ const t = Ke(i.pallets), o = [
1357
1925
  ...e,
1358
1926
  ...t.violations
1359
1927
  ];
1360
1928
  return {
1361
- isValid: i.filter((n) => n.severity === "error").length === 0,
1362
- violations: i,
1929
+ isValid: o.filter((s) => s.severity === "error").length === 0,
1930
+ violations: o,
1363
1931
  palletInRoom: {
1364
1932
  isValid: e.length === 0,
1365
1933
  violations: e
1366
1934
  },
1367
1935
  palletCollisions: t
1368
1936
  };
1369
- }, [o]);
1937
+ }, [i]);
1370
1938
  }
1371
- const bt = V(function({
1939
+ const jt = V(function({
1372
1940
  placedBox: e,
1373
1941
  selected: t = !1,
1374
- highlighted: i = !1,
1375
- showLabel: n = !1,
1376
- color: r,
1942
+ highlighted: o = !1,
1943
+ showLabel: s = !1,
1944
+ color: n,
1377
1945
  opacity: a,
1378
- selectedColor: f,
1379
- highlightedColor: g,
1380
- onClick: v,
1381
- onHover: u
1946
+ selectedColor: c,
1947
+ highlightedColor: l,
1948
+ onClick: f,
1949
+ onHover: h
1382
1950
  }) {
1383
- const x = Ee(null), p = ce(), { box: c, position: l, rotation: d } = e, h = Y.MM_TO_M, j = r ?? c.color ?? p.box.color, T = a ?? p.box.opacity, z = f ?? p.selection.selectedColor, b = g ?? p.selection.highlightedColor;
1384
- let M = c.dimensions.width, _ = c.dimensions.depth;
1385
- (d.y === 90 || d.y === 270) && ([M, _] = [_, M]);
1951
+ const g = _e(null), w = ce(), { box: m, position: x, rotation: u } = e, d = U.MM_TO_M, b = n ?? m.color ?? w.box.color, j = a ?? w.box.opacity, E = c ?? w.selection.selectedColor, S = l ?? w.selection.highlightedColor;
1952
+ let C = m.dimensions.width, z = m.dimensions.depth;
1953
+ (u.y === 90 || u.y === 270) && ([C, z] = [z, C]);
1386
1954
  const y = k(
1387
- () => [M * h, c.dimensions.height * h, _ * h],
1388
- [M, _, c.dimensions.height, h]
1389
- ), w = k(
1390
- () => new $.Vector3(
1391
- l.x * h + y[0] / 2,
1392
- l.y * h + y[1] / 2,
1393
- l.z * h + y[2] / 2
1955
+ () => [C * d, m.dimensions.height * d, z * d],
1956
+ [C, z, m.dimensions.height, d]
1957
+ ), v = k(
1958
+ () => new B.Vector3(
1959
+ x.x * d + y[0] / 2,
1960
+ x.y * d + y[1] / 2,
1961
+ x.z * d + y[2] / 2
1394
1962
  ),
1395
- [l, y, h]
1396
- ), S = t ? z : i ? b : null, E = H(
1397
- (P) => {
1398
- P.stopPropagation(), v?.(e.id);
1963
+ [x, y, d]
1964
+ ), M = t ? E : o ? S : null, _ = q(
1965
+ (R) => {
1966
+ R.stopPropagation(), f?.(e.id);
1399
1967
  },
1400
- [v, e.id]
1401
- ), R = H(
1402
- (P) => {
1403
- P.stopPropagation(), u?.(e.id);
1968
+ [f, e.id]
1969
+ ), T = q(
1970
+ (R) => {
1971
+ R.stopPropagation(), h?.(e.id);
1404
1972
  },
1405
- [u, e.id]
1406
- ), O = H(() => {
1407
- u?.(null);
1408
- }, [u]);
1409
- return /* @__PURE__ */ s.jsxs("group", { children: [
1410
- /* @__PURE__ */ s.jsxs(
1973
+ [h, e.id]
1974
+ ), I = q(() => {
1975
+ h?.(null);
1976
+ }, [h]);
1977
+ return /* @__PURE__ */ r.jsxs("group", { children: [
1978
+ /* @__PURE__ */ r.jsxs(
1411
1979
  "mesh",
1412
1980
  {
1413
- ref: x,
1414
- position: w,
1415
- onClick: E,
1416
- onPointerOver: R,
1417
- onPointerOut: O,
1981
+ ref: g,
1982
+ position: v,
1983
+ onClick: _,
1984
+ onPointerOver: T,
1985
+ onPointerOut: I,
1418
1986
  castShadow: !0,
1419
1987
  receiveShadow: !0,
1420
1988
  children: [
1421
- /* @__PURE__ */ s.jsx("boxGeometry", { args: y }),
1422
- /* @__PURE__ */ s.jsx(
1989
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: y }),
1990
+ /* @__PURE__ */ r.jsx(
1423
1991
  "meshStandardMaterial",
1424
1992
  {
1425
- color: j,
1426
- transparent: T < 1,
1427
- opacity: T,
1428
- roughness: p.box.roughness,
1429
- metalness: p.box.metalness
1993
+ color: b,
1994
+ transparent: j < 1,
1995
+ opacity: j,
1996
+ roughness: w.box.roughness,
1997
+ metalness: w.box.metalness,
1998
+ polygonOffset: !0,
1999
+ polygonOffsetFactor: 1,
2000
+ polygonOffsetUnits: 1
2001
+ }
2002
+ ),
2003
+ /* @__PURE__ */ r.jsx(
2004
+ Xe,
2005
+ {
2006
+ linewidth: 2,
2007
+ scale: 1.001,
2008
+ threshold: 15,
2009
+ color: M ?? "#000000",
2010
+ opacity: M ? 1 : 0.6,
2011
+ transparent: !0
1430
2012
  }
1431
2013
  )
1432
2014
  ]
1433
2015
  }
1434
2016
  ),
1435
- S && /* @__PURE__ */ s.jsxs("mesh", { position: w, children: [
1436
- /* @__PURE__ */ s.jsx("boxGeometry", { args: y }),
1437
- /* @__PURE__ */ s.jsx(
2017
+ M && /* @__PURE__ */ r.jsxs("mesh", { position: v, children: [
2018
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: y }),
2019
+ /* @__PURE__ */ r.jsx(
1438
2020
  "meshBasicMaterial",
1439
2021
  {
1440
- color: S,
2022
+ color: M,
1441
2023
  wireframe: !0,
1442
- wireframeLinewidth: 1,
2024
+ wireframeLinewidth: 2,
1443
2025
  transparent: !0,
1444
2026
  opacity: 0.9,
1445
2027
  depthTest: !1
1446
2028
  }
1447
2029
  )
1448
2030
  ] }),
1449
- S && /* @__PURE__ */ s.jsxs("lineSegments", { position: w, renderOrder: 999, children: [
1450
- /* @__PURE__ */ s.jsx("edgesGeometry", { args: [new $.BoxGeometry(...y)] }),
1451
- /* @__PURE__ */ s.jsx("lineBasicMaterial", { color: S })
1452
- ] }),
1453
- n && /* @__PURE__ */ s.jsx(
2031
+ s && /* @__PURE__ */ r.jsx(
1454
2032
  ke,
1455
2033
  {
1456
- position: [w.x, w.y + y[1] / 2 + 0.05, w.z],
2034
+ position: [v.x, v.y + y[1] / 2 + 0.05, v.z],
1457
2035
  center: !0,
1458
2036
  style: {
1459
2037
  background: "rgba(0,0,0,0.75)",
@@ -1464,38 +2042,38 @@ const bt = V(function({
1464
2042
  whiteSpace: "nowrap",
1465
2043
  pointerEvents: "none"
1466
2044
  },
1467
- children: c.sku ?? c.type ?? c.id
2045
+ children: m.sku ?? m.type ?? m.id
1468
2046
  }
1469
2047
  )
1470
2048
  ] });
1471
- }), jt = V(function({
2049
+ }), Mt = V(function({
1472
2050
  pallet: e,
1473
2051
  position: t = { x: 0, y: 0, z: 0 },
1474
- color: i,
1475
- edgeColor: n
2052
+ color: o,
2053
+ edgeColor: s
1476
2054
  }) {
1477
- const r = ce(), a = i ?? r.pallet.color, f = n ?? r.pallet.edgeColor, g = Y.MM_TO_M, v = e.dimensions, u = k(
1478
- () => [v.width * g, v.height * g, v.depth * g],
1479
- [v, g]
1480
- ), x = k(
1481
- () => new $.Vector3(
1482
- t.x * g + u[0] / 2,
1483
- t.y * g + u[1] / 2,
1484
- t.z * g + u[2] / 2
2055
+ const n = ce(), a = o ?? n.pallet.color, c = s ?? n.pallet.edgeColor, l = U.MM_TO_M, f = e.dimensions, h = k(
2056
+ () => [f.width * l, f.height * l, f.depth * l],
2057
+ [f, l]
2058
+ ), g = k(
2059
+ () => new B.Vector3(
2060
+ t.x * l + h[0] / 2,
2061
+ t.y * l + h[1] / 2,
2062
+ t.z * l + h[2] / 2
1485
2063
  ),
1486
- [t, u, g]
2064
+ [t, h, l]
1487
2065
  );
1488
- return /* @__PURE__ */ s.jsxs("group", { children: [
1489
- /* @__PURE__ */ s.jsxs("mesh", { position: x, castShadow: !0, receiveShadow: !0, children: [
1490
- /* @__PURE__ */ s.jsx("boxGeometry", { args: u }),
1491
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: a, roughness: r.pallet.roughness, metalness: r.pallet.metalness })
2066
+ return /* @__PURE__ */ r.jsxs("group", { children: [
2067
+ /* @__PURE__ */ r.jsxs("mesh", { position: g, castShadow: !0, receiveShadow: !0, children: [
2068
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: h }),
2069
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: a, roughness: n.pallet.roughness, metalness: n.pallet.metalness })
1492
2070
  ] }),
1493
- /* @__PURE__ */ s.jsxs("lineSegments", { position: x, children: [
1494
- /* @__PURE__ */ s.jsx("edgesGeometry", { args: [new $.BoxGeometry(...u)] }),
1495
- /* @__PURE__ */ s.jsx("lineBasicMaterial", { color: f })
2071
+ /* @__PURE__ */ r.jsxs("lineSegments", { position: g, children: [
2072
+ /* @__PURE__ */ r.jsx("edgesGeometry", { args: [new B.BoxGeometry(...h)] }),
2073
+ /* @__PURE__ */ r.jsx("lineBasicMaterial", { color: c })
1496
2074
  ] })
1497
2075
  ] });
1498
- }), St = {
2076
+ }), zt = {
1499
2077
  [me.CARDBOARD]: "#b5926b",
1500
2078
  [me.WOOD]: "#c4a26e",
1501
2079
  [me.PLASTIC]: "#90a4ae"
@@ -1503,23 +2081,23 @@ const bt = V(function({
1503
2081
  separator: e,
1504
2082
  position: t = { x: 0, y: 0, z: 0 }
1505
2083
  }) {
1506
- const i = Y.MM_TO_M, n = e.dimensions, r = k(
1507
- () => [n.width * i, n.height * i, n.depth * i],
1508
- [n, i]
2084
+ const o = U.MM_TO_M, s = e.dimensions, n = k(
2085
+ () => [s.width * o, s.height * o, s.depth * o],
2086
+ [s, o]
1509
2087
  ), a = k(
1510
- () => new $.Vector3(
1511
- t.x * i + r[0] / 2,
1512
- t.y * i + r[1] / 2,
1513
- t.z * i + r[2] / 2
2088
+ () => new B.Vector3(
2089
+ t.x * o + n[0] / 2,
2090
+ t.y * o + n[1] / 2,
2091
+ t.z * o + n[2] / 2
1514
2092
  ),
1515
- [t, r, i]
1516
- ), f = St[e.material];
1517
- return /* @__PURE__ */ s.jsxs("mesh", { position: a, receiveShadow: !0, children: [
1518
- /* @__PURE__ */ s.jsx("boxGeometry", { args: r }),
1519
- /* @__PURE__ */ s.jsx(
2093
+ [t, n, o]
2094
+ ), c = zt[e.material];
2095
+ return /* @__PURE__ */ r.jsxs("mesh", { position: a, receiveShadow: !0, children: [
2096
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: n }),
2097
+ /* @__PURE__ */ r.jsx(
1520
2098
  "meshStandardMaterial",
1521
2099
  {
1522
- color: f,
2100
+ color: c,
1523
2101
  roughness: 0.9,
1524
2102
  metalness: 0,
1525
2103
  transparent: !0,
@@ -1531,108 +2109,108 @@ const bt = V(function({
1531
2109
  function({
1532
2110
  stackedPallet: e,
1533
2111
  position: t = { x: 0, y: 0, z: 0 },
1534
- yRotation: i = 0,
1535
- palletId: n,
1536
- selectedBoxId: r,
2112
+ yRotation: o = 0,
2113
+ palletId: s,
2114
+ selectedBoxId: n,
1537
2115
  highlightedBoxId: a,
1538
- selectedColor: f,
1539
- highlightedColor: g,
1540
- showLabels: v = !1,
1541
- onBoxClick: u,
1542
- onBoxHover: x
2116
+ selectedColor: c,
2117
+ highlightedColor: l,
2118
+ showLabels: f = !1,
2119
+ onBoxClick: h,
2120
+ onBoxHover: g
1543
2121
  }) {
1544
- const p = k(
1545
- () => qe(e, n),
1546
- [e, n]
1547
- ), c = Y.MM_TO_M, l = k(() => i * Math.PI / 180, [i]), d = k(() => {
1548
- const h = [];
1549
- let j = 0;
1550
- for (const T of p.floors) {
1551
- h.push(j), j += T.pallet.dimensions.height;
1552
- const z = T.boxes.reduce(
1553
- (b, M) => Math.max(b, M.position.y + M.box.dimensions.height),
2122
+ const w = k(
2123
+ () => Je(e, s),
2124
+ [e, s]
2125
+ ), m = U.MM_TO_M, x = k(() => o * Math.PI / 180, [o]), u = k(() => {
2126
+ const d = [];
2127
+ let b = 0;
2128
+ for (const j of w.floors) {
2129
+ d.push(b), b += j.pallet.dimensions.height;
2130
+ const E = j.boxes.reduce(
2131
+ (S, C) => Math.max(S, C.position.y + C.box.dimensions.height),
1554
2132
  0
1555
2133
  );
1556
- j += z, T.separatorAbove && (j += T.separatorAbove.dimensions.height);
2134
+ b += E, j.separatorAbove && (b += j.separatorAbove.dimensions.height);
1557
2135
  }
1558
- return h;
1559
- }, [p]);
1560
- return /* @__PURE__ */ s.jsx(
2136
+ return d;
2137
+ }, [w]);
2138
+ return /* @__PURE__ */ r.jsx(
1561
2139
  "group",
1562
2140
  {
1563
- position: [t.x * c, t.y * c, t.z * c],
1564
- rotation: [0, l, 0],
1565
- children: p.floors.map((h, j) => {
1566
- const T = d[j], z = T + h.pallet.dimensions.height;
1567
- return /* @__PURE__ */ s.jsxs("group", { children: [
1568
- /* @__PURE__ */ s.jsx(
1569
- jt,
2141
+ position: [t.x * m, t.y * m, t.z * m],
2142
+ rotation: [0, x, 0],
2143
+ children: w.floors.map((d, b) => {
2144
+ const j = u[b], E = j + d.pallet.dimensions.height;
2145
+ return /* @__PURE__ */ r.jsxs("group", { children: [
2146
+ /* @__PURE__ */ r.jsx(
2147
+ Mt,
1570
2148
  {
1571
- pallet: h.pallet,
1572
- position: { x: 0, y: T, z: 0 }
2149
+ pallet: d.pallet,
2150
+ position: { x: 0, y: j, z: 0 }
1573
2151
  }
1574
2152
  ),
1575
- h.boxes.map((b) => /* @__PURE__ */ s.jsx(
1576
- bt,
2153
+ d.boxes.map((S) => /* @__PURE__ */ r.jsx(
2154
+ jt,
1577
2155
  {
1578
2156
  placedBox: {
1579
- ...b,
2157
+ ...S,
1580
2158
  position: {
1581
- x: b.position.x,
1582
- y: b.position.y + z,
1583
- z: b.position.z
2159
+ x: S.position.x,
2160
+ y: S.position.y + E,
2161
+ z: S.position.z
1584
2162
  }
1585
2163
  },
1586
- selected: r === b.id,
1587
- highlighted: a === b.id,
1588
- selectedColor: f,
1589
- highlightedColor: g,
1590
- showLabel: v,
1591
- onClick: u,
1592
- onHover: x
2164
+ selected: n === S.id,
2165
+ highlighted: a === S.id,
2166
+ selectedColor: c,
2167
+ highlightedColor: l,
2168
+ showLabel: f,
2169
+ onClick: h,
2170
+ onHover: g
1593
2171
  },
1594
- b.id
2172
+ S.id
1595
2173
  )),
1596
- h.separatorAbove && /* @__PURE__ */ s.jsx(
2174
+ d.separatorAbove && /* @__PURE__ */ r.jsx(
1597
2175
  Ct,
1598
2176
  {
1599
- separator: h.separatorAbove,
2177
+ separator: d.separatorAbove,
1600
2178
  position: {
1601
2179
  x: 0,
1602
- y: z + h.boxes.reduce(
1603
- (b, M) => Math.max(b, M.position.y + M.box.dimensions.height),
2180
+ y: E + d.boxes.reduce(
2181
+ (S, C) => Math.max(S, C.position.y + C.box.dimensions.height),
1604
2182
  0
1605
2183
  ),
1606
2184
  z: 0
1607
2185
  }
1608
2186
  }
1609
2187
  )
1610
- ] }, `floor-${j}`);
2188
+ ] }, `floor-${b}`);
1611
2189
  })
1612
2190
  }
1613
2191
  );
1614
2192
  }
1615
- ), Lt = V(function({
2193
+ ), Ht = V(function({
1616
2194
  text: e,
1617
2195
  position: t,
1618
- visible: i = !0,
1619
- fontSize: n = 12,
1620
- color: r = "white",
2196
+ visible: o = !0,
2197
+ fontSize: s = 12,
2198
+ color: n = "white",
1621
2199
  background: a = "rgba(0,0,0,0.75)"
1622
2200
  }) {
1623
- if (!i) return null;
1624
- const f = Y.MM_TO_M;
1625
- return /* @__PURE__ */ s.jsx(
2201
+ if (!o) return null;
2202
+ const c = U.MM_TO_M;
2203
+ return /* @__PURE__ */ r.jsx(
1626
2204
  ke,
1627
2205
  {
1628
- position: [t.x * f, t.y * f, t.z * f],
2206
+ position: [t.x * c, t.y * c, t.z * c],
1629
2207
  center: !0,
1630
2208
  style: {
1631
2209
  background: a,
1632
- color: r,
2210
+ color: n,
1633
2211
  padding: "2px 8px",
1634
2212
  borderRadius: "4px",
1635
- fontSize: `${n}px`,
2213
+ fontSize: `${s}px`,
1636
2214
  whiteSpace: "nowrap",
1637
2215
  pointerEvents: "none",
1638
2216
  userSelect: "none"
@@ -1640,42 +2218,42 @@ const bt = V(function({
1640
2218
  children: e
1641
2219
  }
1642
2220
  );
1643
- }), Mt = V(
2221
+ }), Pt = V(
1644
2222
  function({
1645
2223
  room: e,
1646
2224
  floorColor: t,
1647
- wallColor: i,
1648
- showGrid: n,
1649
- children: r
2225
+ wallColor: o,
2226
+ showGrid: s,
2227
+ children: n
1650
2228
  }) {
1651
- const a = ce(), f = t ?? a.warehouse.floorColor, g = i ?? a.warehouse.wallColor, v = n ?? a.warehouse.showGrid, u = Y.MM_TO_M, x = e.ceilingHeight * u, { shape: p, minX: c, maxX: l, minZ: d, maxZ: h } = k(() => {
2229
+ const a = ce(), c = t ?? a.warehouse.floorColor, l = o ?? a.warehouse.wallColor, f = s ?? a.warehouse.showGrid, h = U.MM_TO_M, g = e.ceilingHeight * h, { shape: w, minX: m, maxX: x, minZ: u, maxZ: d } = k(() => {
1652
2230
  const y = e.floorPolygon;
1653
- let w = 1 / 0, S = -1 / 0, E = 1 / 0, R = -1 / 0;
1654
- for (const P of y)
1655
- w = Math.min(w, P.x * u), S = Math.max(S, P.x * u), E = Math.min(E, P.z * u), R = Math.max(R, P.z * u);
1656
- const O = new $.Shape();
1657
- O.moveTo(y[0].x * u, -y[0].z * u);
1658
- for (let P = 1; P < y.length; P++)
1659
- O.lineTo(y[P].x * u, -y[P].z * u);
1660
- return O.closePath(), { shape: O, minX: w, maxX: S, minZ: E, maxZ: R };
1661
- }, [e.floorPolygon, u]), j = k(() => {
1662
- const y = e.floorPolygon, w = [], S = [];
1663
- for (let R = 0; R < y.length; R++) {
1664
- const O = y[R], P = y[(R + 1) % y.length], A = R * 4;
1665
- w.push(
1666
- O.x * u,
2231
+ let v = 1 / 0, M = -1 / 0, _ = 1 / 0, T = -1 / 0;
2232
+ for (const R of y)
2233
+ v = Math.min(v, R.x * h), M = Math.max(M, R.x * h), _ = Math.min(_, R.z * h), T = Math.max(T, R.z * h);
2234
+ const I = new B.Shape();
2235
+ I.moveTo(y[0].x * h, -y[0].z * h);
2236
+ for (let R = 1; R < y.length; R++)
2237
+ I.lineTo(y[R].x * h, -y[R].z * h);
2238
+ return I.closePath(), { shape: I, minX: v, maxX: M, minZ: _, maxZ: T };
2239
+ }, [e.floorPolygon, h]), b = k(() => {
2240
+ const y = e.floorPolygon, v = [], M = [];
2241
+ for (let T = 0; T < y.length; T++) {
2242
+ const I = y[T], R = y[(T + 1) % y.length], A = T * 4;
2243
+ v.push(
2244
+ I.x * h,
1667
2245
  0,
1668
- O.z * u,
1669
- P.x * u,
2246
+ I.z * h,
2247
+ R.x * h,
1670
2248
  0,
1671
- P.z * u,
1672
- P.x * u,
1673
- x,
1674
- P.z * u,
1675
- O.x * u,
1676
- x,
1677
- O.z * u
1678
- ), S.push(
2249
+ R.z * h,
2250
+ R.x * h,
2251
+ g,
2252
+ R.z * h,
2253
+ I.x * h,
2254
+ g,
2255
+ I.z * h
2256
+ ), M.push(
1679
2257
  A,
1680
2258
  A + 1,
1681
2259
  A + 2,
@@ -1684,41 +2262,41 @@ const bt = V(function({
1684
2262
  A + 3
1685
2263
  );
1686
2264
  }
1687
- const E = new $.BufferGeometry();
1688
- return E.setAttribute("position", new $.Float32BufferAttribute(w, 3)), E.setIndex(S), E.computeVertexNormals(), E;
1689
- }, [e.floorPolygon, x, u]), T = l - c, z = h - d, b = (c + l) / 2, M = (d + h) / 2, _ = k(() => {
1690
- if (!v) return null;
1691
- const y = 0.5, w = 0.01, S = [];
1692
- for (let R = c; R <= l; R += y)
1693
- S.push(R, w, d, R, w, h);
1694
- for (let R = d; R <= h; R += y)
1695
- S.push(c, w, R, l, w, R);
1696
- const E = new $.BufferGeometry();
1697
- return E.setAttribute("position", new $.Float32BufferAttribute(S, 3)), E;
1698
- }, [v, c, l, d, h]);
1699
- return /* @__PURE__ */ s.jsxs("group", { children: [
1700
- /* @__PURE__ */ s.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, -5e-3, 0], receiveShadow: !0, children: [
1701
- /* @__PURE__ */ s.jsx("shapeGeometry", { args: [p] }),
1702
- /* @__PURE__ */ s.jsx(
2265
+ const _ = new B.BufferGeometry();
2266
+ return _.setAttribute("position", new B.Float32BufferAttribute(v, 3)), _.setIndex(M), _.computeVertexNormals(), _;
2267
+ }, [e.floorPolygon, g, h]), j = x - m, E = d - u, S = (m + x) / 2, C = (u + d) / 2, z = k(() => {
2268
+ if (!f) return null;
2269
+ const y = 0.5, v = 0.01, M = [];
2270
+ for (let T = m; T <= x; T += y)
2271
+ M.push(T, v, u, T, v, d);
2272
+ for (let T = u; T <= d; T += y)
2273
+ M.push(m, v, T, x, v, T);
2274
+ const _ = new B.BufferGeometry();
2275
+ return _.setAttribute("position", new B.Float32BufferAttribute(M, 3)), _;
2276
+ }, [f, m, x, u, d]);
2277
+ return /* @__PURE__ */ r.jsxs("group", { children: [
2278
+ /* @__PURE__ */ r.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, -5e-3, 0], receiveShadow: !0, children: [
2279
+ /* @__PURE__ */ r.jsx("shapeGeometry", { args: [w] }),
2280
+ /* @__PURE__ */ r.jsx(
1703
2281
  "meshStandardMaterial",
1704
2282
  {
1705
- color: f,
1706
- side: $.DoubleSide,
2283
+ color: c,
2284
+ side: B.DoubleSide,
1707
2285
  roughness: a.warehouse.floorRoughness
1708
2286
  }
1709
2287
  )
1710
2288
  ] }),
1711
- /* @__PURE__ */ s.jsx("mesh", { geometry: j, position: [0, 0, 0], receiveShadow: !0, children: /* @__PURE__ */ s.jsx(
2289
+ /* @__PURE__ */ r.jsx("mesh", { geometry: b, position: [0, 0, 0], receiveShadow: !0, children: /* @__PURE__ */ r.jsx(
1712
2290
  "meshStandardMaterial",
1713
2291
  {
1714
- color: g,
1715
- side: $.DoubleSide,
2292
+ color: l,
2293
+ side: B.DoubleSide,
1716
2294
  roughness: 0.7,
1717
2295
  transparent: !0,
1718
2296
  opacity: a.warehouse.wallOpacity
1719
2297
  }
1720
2298
  ) }),
1721
- v && _ && /* @__PURE__ */ s.jsx("lineSegments", { geometry: _, children: /* @__PURE__ */ s.jsx(
2299
+ f && z && /* @__PURE__ */ r.jsx("lineSegments", { geometry: z, children: /* @__PURE__ */ r.jsx(
1722
2300
  "lineBasicMaterial",
1723
2301
  {
1724
2302
  color: a.warehouse.gridColor,
@@ -1727,144 +2305,144 @@ const bt = V(function({
1727
2305
  depthWrite: !1
1728
2306
  }
1729
2307
  ) }),
1730
- /* @__PURE__ */ s.jsx("ambientLight", { intensity: a.warehouse.ambientIntensity }),
1731
- /* @__PURE__ */ s.jsx(
2308
+ /* @__PURE__ */ r.jsx("ambientLight", { intensity: a.warehouse.ambientIntensity }),
2309
+ /* @__PURE__ */ r.jsx(
1732
2310
  "directionalLight",
1733
2311
  {
1734
- position: [b + T, x * 0.8, M + z],
2312
+ position: [S + j, g * 0.8, C + E],
1735
2313
  intensity: a.warehouse.directionalIntensity,
1736
2314
  castShadow: !0,
1737
2315
  "shadow-mapSize-width": 1024,
1738
2316
  "shadow-mapSize-height": 1024
1739
2317
  }
1740
2318
  ),
1741
- /* @__PURE__ */ s.jsx(
2319
+ /* @__PURE__ */ r.jsx(
1742
2320
  "pointLight",
1743
2321
  {
1744
- position: [b, x * 0.9, M],
2322
+ position: [S, g * 0.9, C],
1745
2323
  intensity: 0.5,
1746
- distance: Math.max(T, z) * 2
2324
+ distance: Math.max(j, E) * 2
1747
2325
  }
1748
2326
  ),
1749
- r
2327
+ n
1750
2328
  ] });
1751
2329
  }
1752
- ), K = V(function({ position: e, radius: t, width: i, color: n }) {
1753
- return /* @__PURE__ */ s.jsxs("group", { position: e, children: [
1754
- /* @__PURE__ */ s.jsxs("mesh", { rotation: [0, 0, Math.PI / 2], castShadow: !0, children: [
1755
- /* @__PURE__ */ s.jsx("cylinderGeometry", { args: [t, t, i, 24] }),
1756
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: n, roughness: 0.9, metalness: 0.1 })
2330
+ ), K = V(function({ position: e, radius: t, width: o, color: s }) {
2331
+ return /* @__PURE__ */ r.jsxs("group", { position: e, children: [
2332
+ /* @__PURE__ */ r.jsxs("mesh", { rotation: [0, 0, Math.PI / 2], castShadow: !0, children: [
2333
+ /* @__PURE__ */ r.jsx("cylinderGeometry", { args: [t, t, o, 24] }),
2334
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: s, roughness: 0.9, metalness: 0.1 })
1757
2335
  ] }),
1758
- /* @__PURE__ */ s.jsxs("mesh", { rotation: [0, 0, Math.PI / 2], children: [
1759
- /* @__PURE__ */ s.jsx("cylinderGeometry", { args: [t * 0.55, t * 0.55, i + 5e-3, 16] }),
1760
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#888888", roughness: 0.3, metalness: 0.7 })
2336
+ /* @__PURE__ */ r.jsxs("mesh", { rotation: [0, 0, Math.PI / 2], children: [
2337
+ /* @__PURE__ */ r.jsx("cylinderGeometry", { args: [t * 0.55, t * 0.55, o + 5e-3, 16] }),
2338
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#888888", roughness: 0.3, metalness: 0.7 })
1761
2339
  ] })
1762
2340
  ] });
1763
- }), Pt = V(function({
2341
+ }), Rt = V(function({
1764
2342
  truck: e,
1765
2343
  showGrid: t,
1766
- wallOpacity: i = 0.3,
1767
- showRoof: n = !1,
1768
- showSideWalls: r = !0,
2344
+ wallOpacity: o = 0.3,
2345
+ showRoof: s = !1,
2346
+ showSideWalls: n = !0,
1769
2347
  children: a
1770
2348
  }) {
1771
- const g = ce().truck, v = t ?? g.showGrid, u = Y.MM_TO_M, x = e.dimensions.width * u, p = e.dimensions.height * u, c = e.dimensions.depth * u, l = 0.05, d = 0.08, h = 0.28, j = 0.18, T = 0.15, z = 0.25, b = h + T, M = b + h + 0.1, _ = M + z / 2 + d / 2, y = x + l * 2, w = x * 0.65, S = p * 0.85, E = 0.15, R = c + l + E, O = _, P = k(() => {
1772
- if (!v) return null;
1773
- const G = 0.5, N = _ + 2e-3, U = [];
1774
- for (let X = 0; X <= x; X += G)
1775
- U.push(X, N, 0, X, N, c);
1776
- for (let X = 0; X <= c; X += G)
1777
- U.push(0, N, X, x, N, X);
1778
- const F = new $.BufferGeometry();
1779
- return F.setAttribute("position", new $.Float32BufferAttribute(U, 3)), F;
1780
- }, [v, x, c, _]), A = k(
1781
- () => /* @__PURE__ */ s.jsx(
2349
+ const l = ce().truck, f = t ?? l.showGrid, h = U.MM_TO_M, g = e.dimensions.width * h, w = e.dimensions.height * h, m = e.dimensions.depth * h, x = 0.05, u = 0.08, d = 0.28, b = 0.18, j = 0.15, E = 0.25, S = d + j, C = S + d + 0.1, z = C + E / 2 + u / 2, y = g + x * 2, v = g * 0.65, M = w * 0.85, _ = 0.15, T = m + x + _, I = z, R = k(() => {
2350
+ if (!f) return null;
2351
+ const G = 0.5, D = z + 2e-3, H = [];
2352
+ for (let X = 0; X <= g; X += G)
2353
+ H.push(X, D, 0, X, D, m);
2354
+ for (let X = 0; X <= m; X += G)
2355
+ H.push(0, D, X, g, D, X);
2356
+ const F = new B.BufferGeometry();
2357
+ return F.setAttribute("position", new B.Float32BufferAttribute(H, 3)), F;
2358
+ }, [f, g, m, z]), A = k(
2359
+ () => /* @__PURE__ */ r.jsx(
1782
2360
  "meshStandardMaterial",
1783
2361
  {
1784
- color: g.wallColor,
2362
+ color: l.wallColor,
1785
2363
  roughness: 0.5,
1786
2364
  metalness: 0.3,
1787
- transparent: i < 1,
1788
- opacity: i,
1789
- side: $.DoubleSide,
1790
- depthWrite: i >= 0.95
2365
+ transparent: o < 1,
2366
+ opacity: o,
2367
+ side: B.DoubleSide,
2368
+ depthWrite: o >= 0.95
1791
2369
  }
1792
2370
  ),
1793
- [g.wallColor, i]
2371
+ [l.wallColor, o]
1794
2372
  );
1795
- return /* @__PURE__ */ s.jsxs("group", { children: [
1796
- /* @__PURE__ */ s.jsxs(
2373
+ return /* @__PURE__ */ r.jsxs("group", { children: [
2374
+ /* @__PURE__ */ r.jsxs(
1797
2375
  "mesh",
1798
2376
  {
1799
- position: [x / 2, _, c / 2],
2377
+ position: [g / 2, z, m / 2],
1800
2378
  rotation: [-Math.PI / 2, 0, 0],
1801
2379
  receiveShadow: !0,
1802
2380
  children: [
1803
- /* @__PURE__ */ s.jsx("planeGeometry", { args: [x, c] }),
1804
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.floorColor, roughness: 0.85 })
2381
+ /* @__PURE__ */ r.jsx("planeGeometry", { args: [g, m] }),
2382
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.floorColor, roughness: 0.85 })
1805
2383
  ]
1806
2384
  }
1807
2385
  ),
1808
- /* @__PURE__ */ s.jsxs("mesh", { position: [x / 2, _ - d / 2, c / 2], castShadow: !0, receiveShadow: !0, children: [
1809
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [x + l * 2, d, c + l] }),
1810
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.floorColor, roughness: 0.85, metalness: 0.1 })
2386
+ /* @__PURE__ */ r.jsxs("mesh", { position: [g / 2, z - u / 2, m / 2], castShadow: !0, receiveShadow: !0, children: [
2387
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [g + x * 2, u, m + x] }),
2388
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.floorColor, roughness: 0.85, metalness: 0.1 })
1811
2389
  ] }),
1812
- r && /* @__PURE__ */ s.jsxs("mesh", { position: [-l / 2, _ + p / 2, c / 2], castShadow: !0, children: [
1813
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [l, p, c + l] }),
2390
+ n && /* @__PURE__ */ r.jsxs("mesh", { position: [-x / 2, z + w / 2, m / 2], castShadow: !0, children: [
2391
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [x, w, m + x] }),
1814
2392
  A
1815
2393
  ] }),
1816
- r && /* @__PURE__ */ s.jsxs("mesh", { position: [x + l / 2, _ + p / 2, c / 2], castShadow: !0, children: [
1817
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [l, p, c + l] }),
2394
+ n && /* @__PURE__ */ r.jsxs("mesh", { position: [g + x / 2, z + w / 2, m / 2], castShadow: !0, children: [
2395
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [x, w, m + x] }),
1818
2396
  A
1819
2397
  ] }),
1820
- /* @__PURE__ */ s.jsxs("mesh", { position: [x / 2, _ + p / 2, c + l / 2], castShadow: !0, children: [
1821
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [x + l * 2, p, l] }),
2398
+ /* @__PURE__ */ r.jsxs("mesh", { position: [g / 2, z + w / 2, m + x / 2], castShadow: !0, children: [
2399
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [g + x * 2, w, x] }),
1822
2400
  A
1823
2401
  ] }),
1824
- n && /* @__PURE__ */ s.jsxs("mesh", { position: [x / 2, _ + p, c / 2], castShadow: !0, children: [
1825
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [x + l * 2, l, c + l] }),
2402
+ s && /* @__PURE__ */ r.jsxs("mesh", { position: [g / 2, z + w, m / 2], castShadow: !0, children: [
2403
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [g + x * 2, x, m + x] }),
1826
2404
  A
1827
2405
  ] }),
1828
- v && P && /* @__PURE__ */ s.jsx("lineSegments", { geometry: P, children: /* @__PURE__ */ s.jsx(
2406
+ f && R && /* @__PURE__ */ r.jsx("lineSegments", { geometry: R, children: /* @__PURE__ */ r.jsx(
1829
2407
  "lineBasicMaterial",
1830
2408
  {
1831
- color: g.gridColor,
2409
+ color: l.gridColor,
1832
2410
  opacity: 0.5,
1833
2411
  transparent: !0,
1834
2412
  depthWrite: !1
1835
2413
  }
1836
2414
  ) }),
1837
- /* @__PURE__ */ s.jsxs("mesh", { position: [x * 0.25, M, (c + w + E) / 2], castShadow: !0, children: [
1838
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [0.12, z, c + w + E] }),
1839
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.chassisColor, roughness: 0.7, metalness: 0.5 })
2415
+ /* @__PURE__ */ r.jsxs("mesh", { position: [g * 0.25, C, (m + v + _) / 2], castShadow: !0, children: [
2416
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [0.12, E, m + v + _] }),
2417
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.chassisColor, roughness: 0.7, metalness: 0.5 })
1840
2418
  ] }),
1841
- /* @__PURE__ */ s.jsxs("mesh", { position: [x * 0.75, M, (c + w + E) / 2], castShadow: !0, children: [
1842
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [0.12, z, c + w + E] }),
1843
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.chassisColor, roughness: 0.7, metalness: 0.5 })
2419
+ /* @__PURE__ */ r.jsxs("mesh", { position: [g * 0.75, C, (m + v + _) / 2], castShadow: !0, children: [
2420
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [0.12, E, m + v + _] }),
2421
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.chassisColor, roughness: 0.7, metalness: 0.5 })
1844
2422
  ] }),
1845
- [0.15, 0.35, 0.55, 0.75, 0.95].map((G) => /* @__PURE__ */ s.jsxs("mesh", { position: [x / 2, M, c * G], castShadow: !0, children: [
1846
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [x * 0.6, 0.06, 0.06] }),
1847
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.chassisColor, roughness: 0.7, metalness: 0.5 })
2423
+ [0.15, 0.35, 0.55, 0.75, 0.95].map((G) => /* @__PURE__ */ r.jsxs("mesh", { position: [g / 2, C, m * G], castShadow: !0, children: [
2424
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [g * 0.6, 0.06, 0.06] }),
2425
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.chassisColor, roughness: 0.7, metalness: 0.5 })
1848
2426
  ] }, G)),
1849
- /* @__PURE__ */ s.jsx(K, { position: [-j / 2 - l, b, c * 0.12], radius: h, width: j, color: g.wheelColor }),
1850
- /* @__PURE__ */ s.jsx(K, { position: [x + j / 2 + l, b, c * 0.12], radius: h, width: j, color: g.wheelColor }),
1851
- /* @__PURE__ */ s.jsx(K, { position: [-j / 2 - l, b, c * 0.22], radius: h, width: j, color: g.wheelColor }),
1852
- /* @__PURE__ */ s.jsx(K, { position: [x + j / 2 + l, b, c * 0.22], radius: h, width: j, color: g.wheelColor }),
1853
- /* @__PURE__ */ s.jsx(K, { position: [-j / 2 - l, b, R + w * 0.5], radius: h, width: j, color: g.wheelColor }),
1854
- /* @__PURE__ */ s.jsx(K, { position: [x + j / 2 + l, b, R + w * 0.5], radius: h, width: j, color: g.wheelColor }),
1855
- /* @__PURE__ */ s.jsxs("group", { position: [x / 2, O, R], children: [
1856
- /* @__PURE__ */ s.jsxs("mesh", { position: [0, S / 2, w / 2], castShadow: !0, receiveShadow: !0, children: [
1857
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y, S, w] }),
1858
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.cabColor, roughness: 0.4, metalness: 0.3 })
2427
+ /* @__PURE__ */ r.jsx(K, { position: [-b / 2 - x, S, m * 0.12], radius: d, width: b, color: l.wheelColor }),
2428
+ /* @__PURE__ */ r.jsx(K, { position: [g + b / 2 + x, S, m * 0.12], radius: d, width: b, color: l.wheelColor }),
2429
+ /* @__PURE__ */ r.jsx(K, { position: [-b / 2 - x, S, m * 0.22], radius: d, width: b, color: l.wheelColor }),
2430
+ /* @__PURE__ */ r.jsx(K, { position: [g + b / 2 + x, S, m * 0.22], radius: d, width: b, color: l.wheelColor }),
2431
+ /* @__PURE__ */ r.jsx(K, { position: [-b / 2 - x, S, T + v * 0.5], radius: d, width: b, color: l.wheelColor }),
2432
+ /* @__PURE__ */ r.jsx(K, { position: [g + b / 2 + x, S, T + v * 0.5], radius: d, width: b, color: l.wheelColor }),
2433
+ /* @__PURE__ */ r.jsxs("group", { position: [g / 2, I, T], children: [
2434
+ /* @__PURE__ */ r.jsxs("mesh", { position: [0, M / 2, v / 2], castShadow: !0, receiveShadow: !0, children: [
2435
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y, M, v] }),
2436
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.cabColor, roughness: 0.4, metalness: 0.3 })
1859
2437
  ] }),
1860
- /* @__PURE__ */ s.jsxs(
2438
+ /* @__PURE__ */ r.jsxs(
1861
2439
  "mesh",
1862
2440
  {
1863
- position: [0, S * 0.6, w + 0.01],
2441
+ position: [0, M * 0.6, v + 0.01],
1864
2442
  castShadow: !0,
1865
2443
  children: [
1866
- /* @__PURE__ */ s.jsx("planeGeometry", { args: [y * 0.75, S * 0.4] }),
1867
- /* @__PURE__ */ s.jsx(
2444
+ /* @__PURE__ */ r.jsx("planeGeometry", { args: [y * 0.75, M * 0.4] }),
2445
+ /* @__PURE__ */ r.jsx(
1868
2446
  "meshStandardMaterial",
1869
2447
  {
1870
2448
  color: "#88bbdd",
@@ -1872,15 +2450,15 @@ const bt = V(function({
1872
2450
  opacity: 0.5,
1873
2451
  roughness: 0.1,
1874
2452
  metalness: 0.6,
1875
- side: $.DoubleSide
2453
+ side: B.DoubleSide
1876
2454
  }
1877
2455
  )
1878
2456
  ]
1879
2457
  }
1880
2458
  ),
1881
- /* @__PURE__ */ s.jsxs("mesh", { position: [-y / 2 - 0.01, S * 0.6, w * 0.55], rotation: [0, Math.PI / 2, 0], children: [
1882
- /* @__PURE__ */ s.jsx("planeGeometry", { args: [w * 0.5, S * 0.3] }),
1883
- /* @__PURE__ */ s.jsx(
2459
+ /* @__PURE__ */ r.jsxs("mesh", { position: [-y / 2 - 0.01, M * 0.6, v * 0.55], rotation: [0, Math.PI / 2, 0], children: [
2460
+ /* @__PURE__ */ r.jsx("planeGeometry", { args: [v * 0.5, M * 0.3] }),
2461
+ /* @__PURE__ */ r.jsx(
1884
2462
  "meshStandardMaterial",
1885
2463
  {
1886
2464
  color: "#88bbdd",
@@ -1888,13 +2466,13 @@ const bt = V(function({
1888
2466
  opacity: 0.4,
1889
2467
  roughness: 0.1,
1890
2468
  metalness: 0.6,
1891
- side: $.DoubleSide
2469
+ side: B.DoubleSide
1892
2470
  }
1893
2471
  )
1894
2472
  ] }),
1895
- /* @__PURE__ */ s.jsxs("mesh", { position: [y / 2 + 0.01, S * 0.6, w * 0.55], rotation: [0, -Math.PI / 2, 0], children: [
1896
- /* @__PURE__ */ s.jsx("planeGeometry", { args: [w * 0.5, S * 0.3] }),
1897
- /* @__PURE__ */ s.jsx(
2473
+ /* @__PURE__ */ r.jsxs("mesh", { position: [y / 2 + 0.01, M * 0.6, v * 0.55], rotation: [0, -Math.PI / 2, 0], children: [
2474
+ /* @__PURE__ */ r.jsx("planeGeometry", { args: [v * 0.5, M * 0.3] }),
2475
+ /* @__PURE__ */ r.jsx(
1898
2476
  "meshStandardMaterial",
1899
2477
  {
1900
2478
  color: "#88bbdd",
@@ -1902,72 +2480,72 @@ const bt = V(function({
1902
2480
  opacity: 0.4,
1903
2481
  roughness: 0.1,
1904
2482
  metalness: 0.6,
1905
- side: $.DoubleSide
2483
+ side: B.DoubleSide
1906
2484
  }
1907
2485
  )
1908
2486
  ] }),
1909
- /* @__PURE__ */ s.jsxs("mesh", { position: [0, S + 0.04, w / 2], children: [
1910
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y * 0.95, 0.08, w * 0.9] }),
1911
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.cabColor, roughness: 0.4, metalness: 0.3 })
2487
+ /* @__PURE__ */ r.jsxs("mesh", { position: [0, M + 0.04, v / 2], children: [
2488
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y * 0.95, 0.08, v * 0.9] }),
2489
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.cabColor, roughness: 0.4, metalness: 0.3 })
1912
2490
  ] }),
1913
- /* @__PURE__ */ s.jsxs("mesh", { position: [0, S + 0.25, w * 0.1], rotation: [-0.3, 0, 0], children: [
1914
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y * 0.9, 0.04, w * 0.5] }),
1915
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.cabColor, roughness: 0.4, metalness: 0.3 })
2491
+ /* @__PURE__ */ r.jsxs("mesh", { position: [0, M + 0.25, v * 0.1], rotation: [-0.3, 0, 0], children: [
2492
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y * 0.9, 0.04, v * 0.5] }),
2493
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.cabColor, roughness: 0.4, metalness: 0.3 })
1916
2494
  ] }),
1917
- /* @__PURE__ */ s.jsxs("mesh", { position: [-y * 0.35, S * 0.2, w + 0.02], children: [
1918
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y * 0.15, 0.08, 0.02] }),
1919
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#ffffcc", emissive: "#ffffaa", emissiveIntensity: 0.3 })
2495
+ /* @__PURE__ */ r.jsxs("mesh", { position: [-y * 0.35, M * 0.2, v + 0.02], children: [
2496
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y * 0.15, 0.08, 0.02] }),
2497
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#ffffcc", emissive: "#ffffaa", emissiveIntensity: 0.3 })
1920
2498
  ] }),
1921
- /* @__PURE__ */ s.jsxs("mesh", { position: [y * 0.35, S * 0.2, w + 0.02], children: [
1922
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y * 0.15, 0.08, 0.02] }),
1923
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#ffffcc", emissive: "#ffffaa", emissiveIntensity: 0.3 })
2499
+ /* @__PURE__ */ r.jsxs("mesh", { position: [y * 0.35, M * 0.2, v + 0.02], children: [
2500
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y * 0.15, 0.08, 0.02] }),
2501
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#ffffcc", emissive: "#ffffaa", emissiveIntensity: 0.3 })
1924
2502
  ] }),
1925
- /* @__PURE__ */ s.jsxs("mesh", { position: [0, 0.06, w + 0.04], castShadow: !0, children: [
1926
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [y * 1.02, 0.12, 0.06] }),
1927
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.chassisColor, roughness: 0.5, metalness: 0.6 })
2503
+ /* @__PURE__ */ r.jsxs("mesh", { position: [0, 0.06, v + 0.04], castShadow: !0, children: [
2504
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [y * 1.02, 0.12, 0.06] }),
2505
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.chassisColor, roughness: 0.5, metalness: 0.6 })
1928
2506
  ] })
1929
2507
  ] }),
1930
- [-1, 1].map((G) => /* @__PURE__ */ s.jsxs(
2508
+ [-1, 1].map((G) => /* @__PURE__ */ r.jsxs(
1931
2509
  "mesh",
1932
2510
  {
1933
2511
  position: [
1934
- G === -1 ? -l - j * 0.5 : x + l + j * 0.5,
1935
- b + h * 0.6,
1936
- c * 0.17
2512
+ G === -1 ? -x - b * 0.5 : g + x + b * 0.5,
2513
+ S + d * 0.6,
2514
+ m * 0.17
1937
2515
  ],
1938
2516
  castShadow: !0,
1939
2517
  children: [
1940
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [j + 0.04, 0.04, h * 2.5] }),
1941
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: g.chassisColor, roughness: 0.6, metalness: 0.4 })
2518
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [b + 0.04, 0.04, d * 2.5] }),
2519
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: l.chassisColor, roughness: 0.6, metalness: 0.4 })
1942
2520
  ]
1943
2521
  },
1944
2522
  `fender-rear-${G}`
1945
2523
  )),
1946
- /* @__PURE__ */ s.jsxs("mesh", { position: [-l / 2 + 0.01, _ + p * 0.3, -0.01], children: [
1947
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [0.08, 0.12, 0.02] }),
1948
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#ff3333", emissive: "#ff0000", emissiveIntensity: 0.3 })
2524
+ /* @__PURE__ */ r.jsxs("mesh", { position: [-x / 2 + 0.01, z + w * 0.3, -0.01], children: [
2525
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [0.08, 0.12, 0.02] }),
2526
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#ff3333", emissive: "#ff0000", emissiveIntensity: 0.3 })
1949
2527
  ] }),
1950
- /* @__PURE__ */ s.jsxs("mesh", { position: [x + l / 2 - 0.01, _ + p * 0.3, -0.01], children: [
1951
- /* @__PURE__ */ s.jsx("boxGeometry", { args: [0.08, 0.12, 0.02] }),
1952
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#ff3333", emissive: "#ff0000", emissiveIntensity: 0.3 })
2528
+ /* @__PURE__ */ r.jsxs("mesh", { position: [g + x / 2 - 0.01, z + w * 0.3, -0.01], children: [
2529
+ /* @__PURE__ */ r.jsx("boxGeometry", { args: [0.08, 0.12, 0.02] }),
2530
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#ff3333", emissive: "#ff0000", emissiveIntensity: 0.3 })
1953
2531
  ] }),
1954
- /* @__PURE__ */ s.jsx("ambientLight", { intensity: 0.45 }),
1955
- /* @__PURE__ */ s.jsx(
2532
+ /* @__PURE__ */ r.jsx("ambientLight", { intensity: 0.45 }),
2533
+ /* @__PURE__ */ r.jsx(
1956
2534
  "directionalLight",
1957
2535
  {
1958
- position: [x / 2, _ + p * 1.5, c * 0.8],
2536
+ position: [g / 2, z + w * 1.5, m * 0.8],
1959
2537
  intensity: 0.75,
1960
2538
  castShadow: !0,
1961
2539
  "shadow-mapSize-width": 1024,
1962
2540
  "shadow-mapSize-height": 1024
1963
2541
  }
1964
2542
  ),
1965
- /* @__PURE__ */ s.jsx("pointLight", { position: [x / 2, _ + p * 0.7, c / 2], intensity: 0.35 }),
1966
- /* @__PURE__ */ s.jsx("pointLight", { position: [x / 2, _ + p * 0.9, c * 0.3], intensity: 0.25 }),
1967
- /* @__PURE__ */ s.jsx("group", { position: [0, _, 0], children: a })
2543
+ /* @__PURE__ */ r.jsx("pointLight", { position: [g / 2, z + w * 0.7, m / 2], intensity: 0.35 }),
2544
+ /* @__PURE__ */ r.jsx("pointLight", { position: [g / 2, z + w * 0.9, m * 0.3], intensity: 0.25 }),
2545
+ /* @__PURE__ */ r.jsx("group", { position: [0, z, 0], children: a })
1968
2546
  ] });
1969
2547
  });
1970
- function Rt(o, e, t) {
2548
+ function Tt(i, e, t) {
1971
2549
  if (!t)
1972
2550
  return {
1973
2551
  perspective: [3, 3, 3],
@@ -1975,58 +2553,58 @@ function Rt(o, e, t) {
1975
2553
  top: [0, 5, 0],
1976
2554
  front: [0, 1.5, 5],
1977
2555
  side: [5, 1.5, 0]
1978
- }[o];
1979
- const { width: i, height: n, depth: r } = t, [a, f, g] = e, u = Math.sqrt(i ** 2 + n ** 2 + r ** 2) * 3;
1980
- switch (o) {
2556
+ }[i];
2557
+ const { width: o, height: s, depth: n } = t, [a, c, l] = e, h = Math.sqrt(o ** 2 + s ** 2 + n ** 2) * 3;
2558
+ switch (i) {
1981
2559
  case "perspective":
1982
2560
  return [
1983
- a + u * 0.6,
1984
- f + u * 0.5,
1985
- g + u * 0.6
2561
+ a + h * 0.6,
2562
+ c + h * 0.5,
2563
+ l + h * 0.6
1986
2564
  ];
1987
2565
  case "isometric":
1988
2566
  return [
1989
- a + u * 0.577,
1990
- f + u * 0.577,
1991
- g + u * 0.577
2567
+ a + h * 0.577,
2568
+ c + h * 0.577,
2569
+ l + h * 0.577
1992
2570
  ];
1993
2571
  case "top":
1994
- return [a, f + Math.max(u, n * 2), g];
2572
+ return [a, c + Math.max(h, s * 2), l];
1995
2573
  case "front":
1996
- return [a, f + n * 0.5, g + Math.max(u, r * 1.5)];
2574
+ return [a, c + s * 0.5, l + Math.max(h, n * 1.5)];
1997
2575
  case "side":
1998
- return [a + Math.max(u, i * 1.5), f + n * 0.5, g];
2576
+ return [a + Math.max(h, o * 1.5), c + s * 0.5, l];
1999
2577
  }
2000
2578
  }
2001
- const je = V(function({
2579
+ const Se = V(function({
2002
2580
  preset: e = "perspective",
2003
2581
  autoRotate: t = !1,
2004
- enablePan: i = !0,
2005
- enableZoom: n = !0,
2006
- target: r = [0, 0, 0],
2582
+ enablePan: o = !0,
2583
+ enableZoom: s = !0,
2584
+ target: n = [0, 0, 0],
2007
2585
  minDistance: a = 0.5,
2008
- maxDistance: f = 50,
2009
- sceneSize: g
2586
+ maxDistance: c = 50,
2587
+ sceneSize: l
2010
2588
  }) {
2011
- const { camera: v } = Ae(), u = Ee(null);
2589
+ const { camera: f } = Ae(), h = _e(null);
2012
2590
  return fe(() => {
2013
- const x = Rt(e, r, g), p = new $.Vector3(x[0], x[1], x[2]), c = new $.Vector3(...r), l = v.position.clone(), d = 1e3, h = Date.now(), j = () => {
2014
- const T = Date.now() - h, z = Math.min(T / d, 1), b = 1 - Math.pow(1 - z, 3);
2015
- v.position.lerpVectors(l, p, b), u.current && (u.current.target.lerp(c, b), u.current.update()), z < 1 && requestAnimationFrame(j);
2591
+ const g = Tt(e, n, l), w = new B.Vector3(g[0], g[1], g[2]), m = new B.Vector3(...n), x = f.position.clone(), u = 1e3, d = Date.now(), b = () => {
2592
+ const j = Date.now() - d, E = Math.min(j / u, 1), S = 1 - Math.pow(1 - E, 3);
2593
+ f.position.lerpVectors(x, w, S), h.current && (h.current.target.lerp(m, S), h.current.update()), E < 1 && requestAnimationFrame(b);
2016
2594
  };
2017
- j();
2018
- }, [e, g, v, r]), /* @__PURE__ */ s.jsx(
2019
- Xe,
2595
+ b();
2596
+ }, [e, l, f, n]), /* @__PURE__ */ r.jsx(
2597
+ Ze,
2020
2598
  {
2021
- ref: u,
2022
- target: r,
2599
+ ref: h,
2600
+ target: n,
2023
2601
  autoRotate: t,
2024
2602
  autoRotateSpeed: 0.5,
2025
- enablePan: i,
2026
- enableZoom: n,
2603
+ enablePan: o,
2604
+ enableZoom: s,
2027
2605
  enableRotate: !0,
2028
2606
  minDistance: a,
2029
- maxDistance: f,
2607
+ maxDistance: c,
2030
2608
  enableDamping: !0,
2031
2609
  dampingFactor: 0.05,
2032
2610
  rotateSpeed: 0.5,
@@ -2035,7 +2613,7 @@ const je = V(function({
2035
2613
  makeDefault: !0
2036
2614
  }
2037
2615
  );
2038
- }), _t = {
2616
+ }), Et = {
2039
2617
  perspective: { label: "Perspectiva", icon: "📐" },
2040
2618
  isometric: { label: "Isométrica", icon: "🔲" },
2041
2619
  top: { label: "Superior", icon: "⬇️" },
@@ -2045,58 +2623,58 @@ const je = V(function({
2045
2623
  V(function({
2046
2624
  currentPreset: e,
2047
2625
  onPresetChange: t,
2048
- position: i = "top-right"
2626
+ position: o = "top-right"
2049
2627
  }) {
2050
- const n = ["perspective", "isometric", "top", "front", "side"];
2051
- return /* @__PURE__ */ s.jsxs("div", { className: `view-controls view-controls--${i}`, children: [
2052
- /* @__PURE__ */ s.jsx("div", { className: "view-controls__title", children: "Vista" }),
2053
- /* @__PURE__ */ s.jsx("div", { className: "view-controls__buttons", children: n.map((r) => {
2054
- const { label: a, icon: f } = _t[r], g = e === r;
2055
- return /* @__PURE__ */ s.jsxs(
2628
+ const s = ["perspective", "isometric", "top", "front", "side"];
2629
+ return /* @__PURE__ */ r.jsxs("div", { className: `view-controls view-controls--${o}`, children: [
2630
+ /* @__PURE__ */ r.jsx("div", { className: "view-controls__title", children: "Vista" }),
2631
+ /* @__PURE__ */ r.jsx("div", { className: "view-controls__buttons", children: s.map((n) => {
2632
+ const { label: a, icon: c } = Et[n], l = e === n;
2633
+ return /* @__PURE__ */ r.jsxs(
2056
2634
  "button",
2057
2635
  {
2058
- className: `view-controls__button ${g ? "view-controls__button--active" : ""}`,
2059
- onClick: () => t(r),
2636
+ className: `view-controls__button ${l ? "view-controls__button--active" : ""}`,
2637
+ onClick: () => t(n),
2060
2638
  title: a,
2061
2639
  "aria-label": a,
2062
2640
  children: [
2063
- /* @__PURE__ */ s.jsx("span", { className: "view-controls__icon", role: "img", "aria-hidden": "true", children: f }),
2064
- /* @__PURE__ */ s.jsx("span", { className: "view-controls__label", children: a })
2641
+ /* @__PURE__ */ r.jsx("span", { className: "view-controls__icon", role: "img", "aria-hidden": "true", children: c }),
2642
+ /* @__PURE__ */ r.jsx("span", { className: "view-controls__label", children: a })
2065
2643
  ]
2066
2644
  },
2067
- r
2645
+ n
2068
2646
  );
2069
2647
  }) })
2070
2648
  ] });
2071
2649
  });
2072
- const Se = V(function({
2650
+ const je = V(function({
2073
2651
  sceneWidth: e,
2074
2652
  sceneDepth: t,
2075
- sceneType: i,
2076
- floorPolygon: n,
2077
- cameraPosition: r,
2653
+ sceneType: o,
2654
+ floorPolygon: s,
2655
+ cameraPosition: n,
2078
2656
  targetPosition: a,
2079
- position: f = "bottom-left"
2657
+ position: c = "bottom-left"
2080
2658
  }) {
2081
- const u = k(() => 130 / Math.max(e, t), [e, t]), x = (h, j) => ({
2082
- x: 10 + h * u,
2083
- y: 10 + j * u
2084
- }), p = k(() => i !== "warehouse" || !n || n.length === 0 ? "" : `M ${n.map((j) => {
2085
- const T = x(j.x, j.z);
2086
- return `${T.x},${T.y}`;
2087
- }).join(" L ")} Z`, [i, n, u]), c = k(() => {
2088
- if (i !== "truck") return null;
2089
- const h = x(0, 0);
2659
+ const h = k(() => 130 / Math.max(e, t), [e, t]), g = (d, b) => ({
2660
+ x: 10 + d * h,
2661
+ y: 10 + b * h
2662
+ }), w = k(() => o !== "warehouse" || !s || s.length === 0 ? "" : `M ${s.map((b) => {
2663
+ const j = g(b.x, b.z);
2664
+ return `${j.x},${j.y}`;
2665
+ }).join(" L ")} Z`, [o, s, h]), m = k(() => {
2666
+ if (o !== "truck") return null;
2667
+ const d = g(0, 0);
2090
2668
  return {
2091
- x: h.x,
2092
- y: h.y,
2093
- width: e * u,
2094
- height: t * u
2669
+ x: d.x,
2670
+ y: d.y,
2671
+ width: e * h,
2672
+ height: t * h
2095
2673
  };
2096
- }, [i, e, t, u]), l = r ? x(r.x, r.z) : null, d = a ? x(a.x, a.z) : null;
2097
- return /* @__PURE__ */ s.jsxs("div", { className: `minimap minimap--${f}`, children: [
2098
- /* @__PURE__ */ s.jsx("div", { className: "minimap__title", children: "Mapa" }),
2099
- /* @__PURE__ */ s.jsxs(
2674
+ }, [o, e, t, h]), x = n ? g(n.x, n.z) : null, u = a ? g(a.x, a.z) : null;
2675
+ return /* @__PURE__ */ r.jsxs("div", { className: `minimap minimap--${c}`, children: [
2676
+ /* @__PURE__ */ r.jsx("div", { className: "minimap__title", children: "Mapa" }),
2677
+ /* @__PURE__ */ r.jsxs(
2100
2678
  "svg",
2101
2679
  {
2102
2680
  className: "minimap__canvas",
@@ -2105,31 +2683,31 @@ const Se = V(function({
2105
2683
  viewBox: "0 0 150 150",
2106
2684
  xmlns: "http://www.w3.org/2000/svg",
2107
2685
  children: [
2108
- /* @__PURE__ */ s.jsx("rect", { width: 150, height: 150, fill: "#1a1a2e" }),
2109
- i === "warehouse" && p && /* @__PURE__ */ s.jsx("path", { d: p, fill: "rgba(96, 165, 250, 0.15)", stroke: "#60a5fa", strokeWidth: "2" }),
2110
- i === "truck" && c && /* @__PURE__ */ s.jsx(
2686
+ /* @__PURE__ */ r.jsx("rect", { width: 150, height: 150, fill: "#1a1a2e" }),
2687
+ o === "warehouse" && w && /* @__PURE__ */ r.jsx("path", { d: w, fill: "rgba(96, 165, 250, 0.15)", stroke: "#60a5fa", strokeWidth: "2" }),
2688
+ o === "truck" && m && /* @__PURE__ */ r.jsx(
2111
2689
  "rect",
2112
2690
  {
2113
- x: c.x,
2114
- y: c.y,
2115
- width: c.width,
2116
- height: c.height,
2691
+ x: m.x,
2692
+ y: m.y,
2693
+ width: m.width,
2694
+ height: m.height,
2117
2695
  fill: "rgba(96, 165, 250, 0.15)",
2118
2696
  stroke: "#60a5fa",
2119
2697
  strokeWidth: "2"
2120
2698
  }
2121
2699
  ),
2122
- /* @__PURE__ */ s.jsx("defs", { children: /* @__PURE__ */ s.jsx(
2700
+ /* @__PURE__ */ r.jsx("defs", { children: /* @__PURE__ */ r.jsx(
2123
2701
  "pattern",
2124
2702
  {
2125
2703
  id: "minimap-grid",
2126
- width: u,
2127
- height: u,
2704
+ width: h,
2705
+ height: h,
2128
2706
  patternUnits: "userSpaceOnUse",
2129
- children: /* @__PURE__ */ s.jsx(
2707
+ children: /* @__PURE__ */ r.jsx(
2130
2708
  "path",
2131
2709
  {
2132
- d: `M ${u} 0 L 0 0 0 ${u}`,
2710
+ d: `M ${h} 0 L 0 0 0 ${h}`,
2133
2711
  fill: "none",
2134
2712
  stroke: "rgba(255, 255, 255, 0.08)",
2135
2713
  strokeWidth: "0.5"
@@ -2137,29 +2715,29 @@ const Se = V(function({
2137
2715
  )
2138
2716
  }
2139
2717
  ) }),
2140
- i === "truck" && c && /* @__PURE__ */ s.jsx(
2718
+ o === "truck" && m && /* @__PURE__ */ r.jsx(
2141
2719
  "rect",
2142
2720
  {
2143
- x: c.x,
2144
- y: c.y,
2145
- width: c.width,
2146
- height: c.height,
2721
+ x: m.x,
2722
+ y: m.y,
2723
+ width: m.width,
2724
+ height: m.height,
2147
2725
  fill: "url(#minimap-grid)"
2148
2726
  }
2149
2727
  ),
2150
- d && /* @__PURE__ */ s.jsxs("g", { children: [
2151
- /* @__PURE__ */ s.jsx("circle", { cx: d.x, cy: d.y, r: "3", fill: "#f87171", opacity: "0.6" }),
2152
- /* @__PURE__ */ s.jsx("circle", { cx: d.x, cy: d.y, r: "5", fill: "none", stroke: "#f87171", strokeWidth: "1.5" })
2728
+ u && /* @__PURE__ */ r.jsxs("g", { children: [
2729
+ /* @__PURE__ */ r.jsx("circle", { cx: u.x, cy: u.y, r: "3", fill: "#f87171", opacity: "0.6" }),
2730
+ /* @__PURE__ */ r.jsx("circle", { cx: u.x, cy: u.y, r: "5", fill: "none", stroke: "#f87171", strokeWidth: "1.5" })
2153
2731
  ] }),
2154
- l && /* @__PURE__ */ s.jsxs("g", { children: [
2155
- /* @__PURE__ */ s.jsx("circle", { cx: l.x, cy: l.y, r: "4", fill: "#60a5fa" }),
2156
- d && /* @__PURE__ */ s.jsx(
2732
+ x && /* @__PURE__ */ r.jsxs("g", { children: [
2733
+ /* @__PURE__ */ r.jsx("circle", { cx: x.x, cy: x.y, r: "4", fill: "#60a5fa" }),
2734
+ u && /* @__PURE__ */ r.jsx(
2157
2735
  "line",
2158
2736
  {
2159
- x1: l.x,
2160
- y1: l.y,
2161
- x2: d.x,
2162
- y2: d.y,
2737
+ x1: x.x,
2738
+ y1: x.y,
2739
+ x2: u.x,
2740
+ y2: u.y,
2163
2741
  stroke: "#60a5fa",
2164
2742
  strokeWidth: "1",
2165
2743
  strokeDasharray: "2,2",
@@ -2170,103 +2748,103 @@ const Se = V(function({
2170
2748
  ]
2171
2749
  }
2172
2750
  ),
2173
- /* @__PURE__ */ s.jsxs("div", { className: "minimap__legend", children: [
2174
- /* @__PURE__ */ s.jsxs("div", { className: "minimap__legend-item", children: [
2175
- /* @__PURE__ */ s.jsx("span", { className: "minimap__legend-dot minimap__legend-dot--camera" }),
2176
- /* @__PURE__ */ s.jsx("span", { className: "minimap__legend-text", children: "Cámara" })
2751
+ /* @__PURE__ */ r.jsxs("div", { className: "minimap__legend", children: [
2752
+ /* @__PURE__ */ r.jsxs("div", { className: "minimap__legend-item", children: [
2753
+ /* @__PURE__ */ r.jsx("span", { className: "minimap__legend-dot minimap__legend-dot--camera" }),
2754
+ /* @__PURE__ */ r.jsx("span", { className: "minimap__legend-text", children: "Cámara" })
2177
2755
  ] }),
2178
- /* @__PURE__ */ s.jsxs("div", { className: "minimap__legend-item", children: [
2179
- /* @__PURE__ */ s.jsx("span", { className: "minimap__legend-dot minimap__legend-dot--target" }),
2180
- /* @__PURE__ */ s.jsx("span", { className: "minimap__legend-text", children: "Objetivo" })
2756
+ /* @__PURE__ */ r.jsxs("div", { className: "minimap__legend-item", children: [
2757
+ /* @__PURE__ */ r.jsx("span", { className: "minimap__legend-dot minimap__legend-dot--target" }),
2758
+ /* @__PURE__ */ r.jsx("span", { className: "minimap__legend-text", children: "Objetivo" })
2181
2759
  ] })
2182
2760
  ] })
2183
2761
  ] });
2184
2762
  });
2185
- function Tt() {
2186
- const { camera: o } = Ae(), [e, t] = ae({
2187
- x: o.position.x,
2188
- y: o.position.y,
2189
- z: o.position.z
2763
+ function _t() {
2764
+ const { camera: i } = Ae(), [e, t] = ae({
2765
+ x: i.position.x,
2766
+ y: i.position.y,
2767
+ z: i.position.z
2190
2768
  });
2191
2769
  return fe(() => {
2192
- let i;
2193
- const n = () => {
2770
+ let o;
2771
+ const s = () => {
2194
2772
  t({
2195
- x: o.position.x,
2196
- y: o.position.y,
2197
- z: o.position.z
2198
- }), i = requestAnimationFrame(n);
2773
+ x: i.position.x,
2774
+ y: i.position.y,
2775
+ z: i.position.z
2776
+ }), o = requestAnimationFrame(s);
2199
2777
  };
2200
- return i = requestAnimationFrame(n), () => {
2201
- i && cancelAnimationFrame(i);
2778
+ return o = requestAnimationFrame(s), () => {
2779
+ o && cancelAnimationFrame(o);
2202
2780
  };
2203
- }, [o]), e;
2781
+ }, [i]), e;
2204
2782
  }
2205
- function Ce({ onPositionChange: o }) {
2206
- const e = Tt();
2783
+ function Me({ onPositionChange: i }) {
2784
+ const e = _t();
2207
2785
  return fe(() => {
2208
- o(e);
2209
- }, [e, o]), null;
2786
+ i(e);
2787
+ }, [e, i]), null;
2210
2788
  }
2211
2789
  const Yt = V(function({
2212
2790
  stackedPallet: e,
2213
2791
  preset: t,
2214
- selectedBoxId: i,
2215
- highlightedBoxId: n,
2216
- selectedColor: r,
2792
+ selectedBoxId: o,
2793
+ highlightedBoxId: s,
2794
+ selectedColor: n,
2217
2795
  highlightedColor: a,
2218
- showLabels: f = !1,
2219
- cameraPreset: g = "perspective",
2220
- showGrid: v = !0,
2221
- showMiniMap: u = !1,
2222
- onBoxClick: x,
2223
- onBoxHover: p,
2224
- children: c,
2225
- style: l
2796
+ showLabels: c = !1,
2797
+ cameraPreset: l = "perspective",
2798
+ showGrid: f = !0,
2799
+ showMiniMap: h = !1,
2800
+ onBoxClick: g,
2801
+ onBoxHover: w,
2802
+ children: m,
2803
+ style: x
2226
2804
  }) {
2227
- const d = Y.MM_TO_M, h = e.floors[0]?.pallet, [j, T] = ae({ x: 0, z: 0 }), z = H((w) => {
2228
- T({ x: w.x, z: w.z });
2229
- }, []), b = k(() => h ? {
2230
- width: h.dimensions.width * d,
2231
- height: le(e) * d,
2232
- depth: h.dimensions.depth * d
2233
- } : { width: 1.2, height: 1, depth: 0.8 }, [h, e, d]), M = k(() => {
2234
- const w = h ? h.dimensions.width * d / 2 : 0, S = h ? h.dimensions.depth * d / 2 : 0, E = b.height / 2;
2235
- return [w, E, S];
2236
- }, [h, d, b.height]), _ = k(() => {
2237
- const S = Math.sqrt(
2238
- b.width ** 2 + b.height ** 2 + b.depth ** 2
2805
+ const u = U.MM_TO_M, d = e.floors[0]?.pallet, [b, j] = ae({ x: 0, z: 0 }), E = q((v) => {
2806
+ j({ x: v.x, z: v.z });
2807
+ }, []), S = k(() => d ? {
2808
+ width: d.dimensions.width * u,
2809
+ height: le(e) * u,
2810
+ depth: d.dimensions.depth * u
2811
+ } : { width: 1.2, height: 1, depth: 0.8 }, [d, e, u]), C = k(() => {
2812
+ const v = d ? d.dimensions.width * u / 2 : 0, M = d ? d.dimensions.depth * u / 2 : 0, _ = S.height / 2;
2813
+ return [v, _, M];
2814
+ }, [d, u, S.height]), z = k(() => {
2815
+ const M = Math.sqrt(
2816
+ S.width ** 2 + S.height ** 2 + S.depth ** 2
2239
2817
  ) * 3.5;
2240
2818
  return [
2241
- M[0] + S * 0.7,
2242
- M[1] + S * 0.6,
2243
- M[2] + S * 0.7
2819
+ C[0] + M * 0.7,
2820
+ C[1] + M * 0.6,
2821
+ C[2] + M * 0.7
2244
2822
  ];
2245
- }, [M, b]), y = k(() => {
2246
- if (!v || !h) return null;
2247
- const w = h.dimensions.width * d, S = h.dimensions.depth * d, E = 0.2, R = 1e-3, O = [];
2248
- for (let A = 0; A <= w; A += E)
2249
- O.push(A, R, 0, A, R, S);
2250
- for (let A = 0; A <= S; A += E)
2251
- O.push(0, R, A, w, R, A);
2252
- const P = new $.BufferGeometry();
2253
- return P.setAttribute("position", new $.Float32BufferAttribute(O, 3)), P;
2254
- }, [v, h, d]);
2255
- return /* @__PURE__ */ s.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
2256
- /* @__PURE__ */ s.jsx(
2823
+ }, [C, S]), y = k(() => {
2824
+ if (!f || !d) return null;
2825
+ const v = d.dimensions.width * u, M = d.dimensions.depth * u, _ = 0.2, T = 1e-3, I = [];
2826
+ for (let A = 0; A <= v; A += _)
2827
+ I.push(A, T, 0, A, T, M);
2828
+ for (let A = 0; A <= M; A += _)
2829
+ I.push(0, T, A, v, T, A);
2830
+ const R = new B.BufferGeometry();
2831
+ return R.setAttribute("position", new B.Float32BufferAttribute(I, 3)), R;
2832
+ }, [f, d, u]);
2833
+ return /* @__PURE__ */ r.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
2834
+ /* @__PURE__ */ r.jsx(
2257
2835
  pe,
2258
2836
  {
2259
2837
  shadows: !0,
2260
2838
  camera: {
2261
- position: _,
2839
+ position: z,
2262
2840
  fov: 45,
2263
2841
  near: 0.01,
2264
2842
  far: 100
2265
2843
  },
2266
- style: { width: "100%", height: "100%", ...l },
2267
- children: /* @__PURE__ */ s.jsxs(ve, { preset: t, children: [
2268
- /* @__PURE__ */ s.jsx("ambientLight", { intensity: 0.4 }),
2269
- /* @__PURE__ */ s.jsx(
2844
+ style: { width: "100%", height: "100%", ...x },
2845
+ children: /* @__PURE__ */ r.jsxs(we, { preset: t, children: [
2846
+ /* @__PURE__ */ r.jsx("ambientLight", { intensity: 0.4 }),
2847
+ /* @__PURE__ */ r.jsx(
2270
2848
  "directionalLight",
2271
2849
  {
2272
2850
  position: [5, 8, 5],
@@ -2276,26 +2854,26 @@ const Yt = V(function({
2276
2854
  "shadow-mapSize-height": 1024
2277
2855
  }
2278
2856
  ),
2279
- /* @__PURE__ */ s.jsx("hemisphereLight", { intensity: 0.3, color: "#ffffff", groundColor: "#444444" }),
2280
- /* @__PURE__ */ s.jsx(
2281
- je,
2857
+ /* @__PURE__ */ r.jsx("hemisphereLight", { intensity: 0.3, color: "#ffffff", groundColor: "#444444" }),
2858
+ /* @__PURE__ */ r.jsx(
2859
+ Se,
2282
2860
  {
2283
- preset: g,
2284
- target: M,
2285
- sceneSize: b,
2861
+ preset: l,
2862
+ target: C,
2863
+ sceneSize: S,
2286
2864
  minDistance: 0.3,
2287
- maxDistance: Math.max(b.width, b.height, b.depth) * 4
2865
+ maxDistance: Math.max(S.width, S.height, S.depth) * 4
2288
2866
  }
2289
2867
  ),
2290
- /* @__PURE__ */ s.jsx(Ce, { onPositionChange: z }),
2291
- /* @__PURE__ */ s.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [M[0], -2e-3, M[2]], receiveShadow: !0, children: [
2292
- /* @__PURE__ */ s.jsx("planeGeometry", { args: [
2293
- h ? h.dimensions.width * d * 1.5 : 3,
2294
- h ? h.dimensions.depth * d * 1.5 : 3
2868
+ /* @__PURE__ */ r.jsx(Me, { onPositionChange: E }),
2869
+ /* @__PURE__ */ r.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [C[0], -2e-3, C[2]], receiveShadow: !0, children: [
2870
+ /* @__PURE__ */ r.jsx("planeGeometry", { args: [
2871
+ d ? d.dimensions.width * u * 1.5 : 3,
2872
+ d ? d.dimensions.depth * u * 1.5 : 3
2295
2873
  ] }),
2296
- /* @__PURE__ */ s.jsx("meshStandardMaterial", { color: "#e0e0e0", roughness: 0.9 })
2874
+ /* @__PURE__ */ r.jsx("meshStandardMaterial", { color: "#e0e0e0", roughness: 0.9 })
2297
2875
  ] }),
2298
- v && y && /* @__PURE__ */ s.jsx("lineSegments", { geometry: y, children: /* @__PURE__ */ s.jsx(
2876
+ f && y && /* @__PURE__ */ r.jsx("lineSegments", { geometry: y, children: /* @__PURE__ */ r.jsx(
2299
2877
  "lineBasicMaterial",
2300
2878
  {
2301
2879
  color: "#aaaaaa",
@@ -2304,308 +2882,308 @@ const Yt = V(function({
2304
2882
  depthWrite: !1
2305
2883
  }
2306
2884
  ) }),
2307
- /* @__PURE__ */ s.jsx(
2885
+ /* @__PURE__ */ r.jsx(
2308
2886
  be,
2309
2887
  {
2310
2888
  stackedPallet: e,
2311
- selectedBoxId: i,
2312
- highlightedBoxId: n,
2313
- selectedColor: r,
2889
+ selectedBoxId: o,
2890
+ highlightedBoxId: s,
2891
+ selectedColor: n,
2314
2892
  highlightedColor: a,
2315
- showLabels: f,
2316
- onBoxClick: x,
2317
- onBoxHover: p
2893
+ showLabels: c,
2894
+ onBoxClick: g,
2895
+ onBoxHover: w
2318
2896
  }
2319
2897
  ),
2320
- c
2898
+ m
2321
2899
  ] })
2322
2900
  }
2323
2901
  ),
2324
- u && h && /* @__PURE__ */ s.jsx(
2325
- Se,
2902
+ h && d && /* @__PURE__ */ r.jsx(
2903
+ je,
2326
2904
  {
2327
- sceneWidth: b.width,
2328
- sceneDepth: b.depth,
2905
+ sceneWidth: S.width,
2906
+ sceneDepth: S.depth,
2329
2907
  sceneType: "truck",
2330
- cameraPosition: j,
2331
- targetPosition: { x: M[0], z: M[2] },
2908
+ cameraPosition: b,
2909
+ targetPosition: { x: C[0], z: C[2] },
2332
2910
  position: "bottom-left"
2333
2911
  }
2334
2912
  )
2335
2913
  ] });
2336
- }), Ut = V(function({
2914
+ }), Ft = V(function({
2337
2915
  truck: e,
2338
2916
  preset: t,
2339
- selectedBoxId: i,
2340
- highlightedBoxId: n,
2341
- selectedColor: r,
2917
+ selectedBoxId: o,
2918
+ highlightedBoxId: s,
2919
+ selectedColor: n,
2342
2920
  highlightedColor: a,
2343
- showLabels: f = !1,
2344
- showGrid: g,
2345
- wallOpacity: v = 0.3,
2346
- showRoof: u = !1,
2347
- showSideWalls: x = !0,
2348
- cameraPreset: p = "perspective",
2349
- showMiniMap: c = !1,
2350
- onBoxClick: l,
2351
- onBoxHover: d,
2352
- children: h,
2353
- style: j
2921
+ showLabels: c = !1,
2922
+ showGrid: l,
2923
+ wallOpacity: f = 0.3,
2924
+ showRoof: h = !1,
2925
+ showSideWalls: g = !0,
2926
+ cameraPreset: w = "perspective",
2927
+ showMiniMap: m = !1,
2928
+ onBoxClick: x,
2929
+ onBoxHover: u,
2930
+ children: d,
2931
+ style: b
2354
2932
  }) {
2355
- const [T, z] = ae({ x: 0, z: 0 }), b = H((P) => {
2356
- z({ x: P.x, z: P.z });
2357
- }, []), M = Y.MM_TO_M, _ = e.dimensions.width * M, y = e.dimensions.height * M, w = e.dimensions.depth * M, S = k(
2358
- () => [_ / 2, y / 2, w / 2],
2359
- [_, y, w]
2360
- ), E = k(
2361
- () => ({ width: _, height: y, depth: w }),
2362
- [_, y, w]
2363
- ), R = k(() => [_ * 0.8, y * 1.2, w * 0.4], [_, y, w]), O = k(() => e.pallets.filter((P) => {
2364
- const A = tt(P, e);
2933
+ const [j, E] = ae({ x: 0, z: 0 }), S = q((R) => {
2934
+ E({ x: R.x, z: R.z });
2935
+ }, []), C = U.MM_TO_M, z = e.dimensions.width * C, y = e.dimensions.height * C, v = e.dimensions.depth * C, M = k(
2936
+ () => [z / 2, y / 2, v / 2],
2937
+ [z, y, v]
2938
+ ), _ = k(
2939
+ () => ({ width: z, height: y, depth: v }),
2940
+ [z, y, v]
2941
+ ), T = k(() => [z * 0.8, y * 1.2, v * 0.4], [z, y, v]), I = k(() => e.pallets.filter((R) => {
2942
+ const A = ot(R, e);
2365
2943
  return A.isValid ? !0 : (console.error(
2366
- `[TruckScene] Palet "${P.id}" fuera de los límites del camión.`,
2944
+ `[TruckScene] Palet "${R.id}" fuera de los límites del camión.`,
2367
2945
  "Violaciones:",
2368
2946
  A.violations
2369
2947
  ), !1);
2370
2948
  }), [e]);
2371
- return /* @__PURE__ */ s.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
2372
- /* @__PURE__ */ s.jsx(
2949
+ return /* @__PURE__ */ r.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
2950
+ /* @__PURE__ */ r.jsx(
2373
2951
  pe,
2374
2952
  {
2375
2953
  shadows: !0,
2376
2954
  camera: {
2377
- position: R,
2955
+ position: T,
2378
2956
  fov: 45,
2379
2957
  near: 0.01,
2380
2958
  far: 200
2381
2959
  },
2382
- style: { width: "100%", height: "100%", ...j },
2383
- children: /* @__PURE__ */ s.jsxs(ve, { preset: t, children: [
2384
- /* @__PURE__ */ s.jsx(
2385
- je,
2960
+ style: { width: "100%", height: "100%", ...b },
2961
+ children: /* @__PURE__ */ r.jsxs(we, { preset: t, children: [
2962
+ /* @__PURE__ */ r.jsx(
2963
+ Se,
2386
2964
  {
2387
- preset: p,
2388
- target: S,
2389
- sceneSize: E,
2390
- maxDistance: Math.max(_, y, w) * 3,
2965
+ preset: w,
2966
+ target: M,
2967
+ sceneSize: _,
2968
+ maxDistance: Math.max(z, y, v) * 3,
2391
2969
  minDistance: 0.5
2392
2970
  }
2393
2971
  ),
2394
- /* @__PURE__ */ s.jsx(Ce, { onPositionChange: b }),
2395
- /* @__PURE__ */ s.jsxs(
2396
- Pt,
2972
+ /* @__PURE__ */ r.jsx(Me, { onPositionChange: S }),
2973
+ /* @__PURE__ */ r.jsxs(
2974
+ Rt,
2397
2975
  {
2398
2976
  truck: e,
2399
- showGrid: g,
2400
- wallOpacity: v,
2401
- showRoof: u,
2402
- showSideWalls: x,
2977
+ showGrid: l,
2978
+ wallOpacity: f,
2979
+ showRoof: h,
2980
+ showSideWalls: g,
2403
2981
  children: [
2404
- O.map((P) => /* @__PURE__ */ s.jsx(
2982
+ I.map((R) => /* @__PURE__ */ r.jsx(
2405
2983
  be,
2406
2984
  {
2407
- stackedPallet: P.stackedPallet,
2408
- position: P.position,
2409
- yRotation: P.yRotation,
2410
- palletId: P.id,
2411
- selectedBoxId: i,
2412
- highlightedBoxId: n,
2413
- selectedColor: r,
2985
+ stackedPallet: R.stackedPallet,
2986
+ position: R.position,
2987
+ yRotation: R.yRotation,
2988
+ palletId: R.id,
2989
+ selectedBoxId: o,
2990
+ highlightedBoxId: s,
2991
+ selectedColor: n,
2414
2992
  highlightedColor: a,
2415
- showLabels: f,
2416
- onBoxClick: l,
2417
- onBoxHover: d
2993
+ showLabels: c,
2994
+ onBoxClick: x,
2995
+ onBoxHover: u
2418
2996
  },
2419
- P.id
2997
+ R.id
2420
2998
  )),
2421
- h
2999
+ d
2422
3000
  ]
2423
3001
  }
2424
3002
  )
2425
3003
  ] })
2426
3004
  }
2427
3005
  ),
2428
- c && /* @__PURE__ */ s.jsx(
2429
- Se,
3006
+ m && /* @__PURE__ */ r.jsx(
3007
+ je,
2430
3008
  {
2431
- sceneWidth: _,
2432
- sceneDepth: w,
3009
+ sceneWidth: z,
3010
+ sceneDepth: v,
2433
3011
  sceneType: "truck",
2434
- cameraPosition: T,
2435
- targetPosition: { x: S[0], z: S[2] },
3012
+ cameraPosition: j,
3013
+ targetPosition: { x: M[0], z: M[2] },
2436
3014
  position: "bottom-left"
2437
3015
  }
2438
3016
  )
2439
3017
  ] });
2440
- }), Ft = V(function({
3018
+ }), qt = V(function({
2441
3019
  room: e,
2442
3020
  preset: t,
2443
- selectedBoxId: i,
2444
- highlightedBoxId: n,
2445
- selectedColor: r,
3021
+ selectedBoxId: o,
3022
+ highlightedBoxId: s,
3023
+ selectedColor: n,
2446
3024
  highlightedColor: a,
2447
- showLabels: f = !1,
2448
- cameraPreset: g = "perspective",
2449
- showMiniMap: v = !1,
2450
- onBoxClick: u,
2451
- onBoxHover: x,
2452
- children: p,
2453
- style: c
3025
+ showLabels: c = !1,
3026
+ cameraPreset: l = "perspective",
3027
+ showMiniMap: f = !1,
3028
+ onBoxClick: h,
3029
+ onBoxHover: g,
3030
+ children: w,
3031
+ style: m
2454
3032
  }) {
2455
- const l = Y.MM_TO_M, [d, h] = ae({ x: 0, z: 0 }), j = H((y) => {
2456
- h({ x: y.x, z: y.z });
2457
- }, []), { target: T, sceneSize: z, initialCameraPosition: b } = k(() => {
3033
+ const x = U.MM_TO_M, [u, d] = ae({ x: 0, z: 0 }), b = q((y) => {
3034
+ d({ x: y.x, z: y.z });
3035
+ }, []), { target: j, sceneSize: E, initialCameraPosition: S } = k(() => {
2458
3036
  const y = e.floorPolygon;
2459
- let w = 1 / 0, S = -1 / 0, E = 1 / 0, R = -1 / 0;
2460
- for (const C of y)
2461
- w = Math.min(w, C.x * l), S = Math.max(S, C.x * l), E = Math.min(E, C.z * l), R = Math.max(R, C.z * l);
2462
- const O = S - w, P = R - E, A = e.ceilingHeight * l, G = (w + S) / 2, N = (E + R) / 2, U = [G, A / 2, N], F = { width: O, height: A, depth: P }, J = Math.sqrt(O ** 2 + A ** 2 + P ** 2) * 0.8, m = [
3037
+ let v = 1 / 0, M = -1 / 0, _ = 1 / 0, T = -1 / 0;
3038
+ for (const P of y)
3039
+ v = Math.min(v, P.x * x), M = Math.max(M, P.x * x), _ = Math.min(_, P.z * x), T = Math.max(T, P.z * x);
3040
+ const I = M - v, R = T - _, A = e.ceilingHeight * x, G = (v + M) / 2, D = (_ + T) / 2, H = [G, A / 2, D], F = { width: I, height: A, depth: R }, J = Math.sqrt(I ** 2 + A ** 2 + R ** 2) * 0.8, p = [
2463
3041
  G + J * 0.6,
2464
3042
  A + J * 0.5,
2465
- N + J * 0.6
3043
+ D + J * 0.6
2466
3044
  ];
2467
3045
  return {
2468
- target: U,
3046
+ target: H,
2469
3047
  sceneSize: F,
2470
- initialCameraPosition: m
3048
+ initialCameraPosition: p
2471
3049
  };
2472
- }, [e.floorPolygon, e.ceilingHeight, l]), M = k(() => e.floorPolygon.map((y) => ({ x: y.x * l, z: y.z * l })), [e.floorPolygon, l]), _ = k(() => e.pallets.filter((y) => {
2473
- const w = We(y, e);
2474
- return w.isValid ? !0 : (console.error(
3050
+ }, [e.floorPolygon, e.ceilingHeight, x]), C = k(() => e.floorPolygon.map((y) => ({ x: y.x * x, z: y.z * x })), [e.floorPolygon, x]), z = k(() => e.pallets.filter((y) => {
3051
+ const v = We(y, e);
3052
+ return v.isValid ? !0 : (console.error(
2475
3053
  `[WarehouseScene] Palet "${y.id}" fuera de los límites de la estancia "${e.name}".`,
2476
3054
  "Violaciones:",
2477
- w.violations
3055
+ v.violations
2478
3056
  ), !1);
2479
3057
  }), [e]);
2480
- return /* @__PURE__ */ s.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
2481
- /* @__PURE__ */ s.jsx(
3058
+ return /* @__PURE__ */ r.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
3059
+ /* @__PURE__ */ r.jsx(
2482
3060
  pe,
2483
3061
  {
2484
3062
  shadows: !0,
2485
3063
  camera: {
2486
- position: b,
3064
+ position: S,
2487
3065
  fov: 45,
2488
3066
  near: 0.01,
2489
3067
  far: 300
2490
3068
  },
2491
- style: { width: "100%", height: "100%", ...c },
2492
- children: /* @__PURE__ */ s.jsxs(ve, { preset: t, children: [
2493
- /* @__PURE__ */ s.jsx(
2494
- je,
3069
+ style: { width: "100%", height: "100%", ...m },
3070
+ children: /* @__PURE__ */ r.jsxs(we, { preset: t, children: [
3071
+ /* @__PURE__ */ r.jsx(
3072
+ Se,
2495
3073
  {
2496
- preset: g,
2497
- target: T,
2498
- sceneSize: z,
2499
- maxDistance: Math.max(z.width, z.height, z.depth) * 4,
3074
+ preset: l,
3075
+ target: j,
3076
+ sceneSize: E,
3077
+ maxDistance: Math.max(E.width, E.height, E.depth) * 4,
2500
3078
  minDistance: 0.5
2501
3079
  }
2502
3080
  ),
2503
- /* @__PURE__ */ s.jsx(Ce, { onPositionChange: j }),
2504
- /* @__PURE__ */ s.jsxs(Mt, { room: e, children: [
2505
- _.map((y) => /* @__PURE__ */ s.jsx(
3081
+ /* @__PURE__ */ r.jsx(Me, { onPositionChange: b }),
3082
+ /* @__PURE__ */ r.jsxs(Pt, { room: e, children: [
3083
+ z.map((y) => /* @__PURE__ */ r.jsx(
2506
3084
  be,
2507
3085
  {
2508
3086
  stackedPallet: y.stackedPallet,
2509
3087
  position: y.position,
2510
3088
  yRotation: y.yRotation,
2511
3089
  palletId: y.id,
2512
- selectedBoxId: i,
2513
- highlightedBoxId: n,
2514
- selectedColor: r,
3090
+ selectedBoxId: o,
3091
+ highlightedBoxId: s,
3092
+ selectedColor: n,
2515
3093
  highlightedColor: a,
2516
- showLabels: f,
2517
- onBoxClick: u,
2518
- onBoxHover: x
3094
+ showLabels: c,
3095
+ onBoxClick: h,
3096
+ onBoxHover: g
2519
3097
  },
2520
3098
  y.id
2521
3099
  )),
2522
- p
3100
+ w
2523
3101
  ] })
2524
3102
  ] })
2525
3103
  }
2526
3104
  ),
2527
- v && /* @__PURE__ */ s.jsx(
2528
- Se,
3105
+ f && /* @__PURE__ */ r.jsx(
3106
+ je,
2529
3107
  {
2530
- sceneWidth: z.width,
2531
- sceneDepth: z.depth,
3108
+ sceneWidth: E.width,
3109
+ sceneDepth: E.depth,
2532
3110
  sceneType: "warehouse",
2533
- floorPolygon: M,
2534
- cameraPosition: d,
2535
- targetPosition: { x: T[0], z: T[2] },
3111
+ floorPolygon: C,
3112
+ cameraPosition: u,
3113
+ targetPosition: { x: j[0], z: j[2] },
2536
3114
  position: "bottom-left"
2537
3115
  }
2538
3116
  )
2539
3117
  ] });
2540
3118
  });
2541
3119
  export {
2542
- ut as BinPacking3DStrategy,
2543
- bt as BoxComponent,
3120
+ xt as BinPacking3DStrategy,
3121
+ jt as BoxComponent,
2544
3122
  ge as BoxFactory,
2545
3123
  Ne as COLLISION_TOLERANCE,
2546
- je as CameraControlsComponent,
2547
- mt as ColumnStrategy,
3124
+ Se as CameraControlsComponent,
3125
+ ut as ColumnStrategy,
2548
3126
  xe as DEFAULT_PRESET,
2549
- Lt as Label,
2550
- Me as MIN_SUPPORT_PERCENTAGE,
2551
- Ie as PRESET_INDUSTRIAL,
2552
- Le as PRESET_UNSTYLED,
2553
- gt as PackingRegistry,
2554
- jt as PalletComponent,
3127
+ Ht as Label,
3128
+ ze as MIN_SUPPORT_PERCENTAGE,
3129
+ Oe as PRESET_INDUSTRIAL,
3130
+ Ue as PRESET_UNSTYLED,
3131
+ pt as PackingRegistry,
3132
+ Mt as PalletComponent,
2555
3133
  Z as PalletFactory,
2556
- L as PalletMaterial,
3134
+ N as PalletMaterial,
2557
3135
  Yt as PalletScene,
2558
- ve as PresetProvider,
2559
- Ye as SCENE_PRESETS,
2560
- At as SEPARATOR_DEFAULTS,
3136
+ we as PresetProvider,
3137
+ He as SCENE_PRESETS,
3138
+ Ot as SEPARATOR_DEFAULTS,
2561
3139
  ue as STANDARD_PALLETS,
2562
3140
  Ct as SeparatorComponent,
2563
3141
  me as SeparatorMaterial,
2564
3142
  be as StackedPalletComponent,
2565
- Ze as TRUCK_PRESETS,
2566
- Pt as TruckEnvironment,
2567
- Gt as TruckFactory,
2568
- Ut as TruckScene,
3143
+ De as TRUCK_PRESETS,
3144
+ Rt as TruckEnvironment,
3145
+ Xt as TruckFactory,
3146
+ Ft as TruckScene,
2569
3147
  ie as TruckType,
2570
- xt as TypeGroupStrategy,
2571
- Y as UNITS,
2572
- Oe as WEIGHT_WARNING_THRESHOLD,
2573
- Mt as WarehouseEnvironment,
2574
- Ft as WarehouseScene,
2575
- ye as aabbIntersects,
2576
- q as calculateCenterOfGravity,
2577
- se as calculateStabilityScore,
2578
- ft as defaultRegistry,
2579
- qe as ensureUniqueBoxIds,
2580
- D as getBoxBoundingBox,
2581
- oe as getPalletBoundingBox,
3148
+ gt as TypeGroupStrategy,
3149
+ U as UNITS,
3150
+ Ie as WEIGHT_WARNING_THRESHOLD,
3151
+ Pt as WarehouseEnvironment,
3152
+ qt as WarehouseScene,
3153
+ ve as aabbIntersects,
3154
+ Y as calculateCenterOfGravity,
3155
+ ee as calculateStabilityScore,
3156
+ wt as defaultRegistry,
3157
+ Je as ensureUniqueBoxIds,
3158
+ L as getBoxBoundingBox,
3159
+ se as getPalletBoundingBox,
2582
3160
  le as getStackedPalletTotalHeight,
2583
- we as getStackedPalletTotalWeight,
2584
- ht as pointInPolygon,
2585
- Zt as usePackingStrategy,
2586
- Xt as usePalletMetrics,
2587
- Vt as usePhysicsValidation,
3161
+ ye as getStackedPalletTotalWeight,
3162
+ mt as pointInPolygon,
3163
+ Nt as usePackingStrategy,
3164
+ Dt as usePalletMetrics,
3165
+ Zt as usePhysicsValidation,
2588
3166
  ce as usePreset,
2589
- Nt as useWarehouseValidation,
2590
- et as validateAllBoxesInPalletBounds,
2591
- Ke as validateBoxInPalletBounds,
2592
- rt as validateBoxStackability,
2593
- lt as validateCogInsideSupport,
2594
- ot as validateFragileLoad,
2595
- at as validateInvertedPyramid,
2596
- Je as validateNoBoxCollisions,
2597
- Qe as validateNoPalletCollisions,
2598
- Ot as validatePalletHeight,
3167
+ Ut as useWarehouseValidation,
3168
+ tt as validateAllBoxesInPalletBounds,
3169
+ et as validateBoxInPalletBounds,
3170
+ at as validateBoxStackability,
3171
+ dt as validateCogInsideSupport,
3172
+ st as validateFragileLoad,
3173
+ ct as validateInvertedPyramid,
3174
+ Qe as validateNoBoxCollisions,
3175
+ Ke as validateNoPalletCollisions,
3176
+ Bt as validatePalletHeight,
2599
3177
  We as validatePalletInRoom,
2600
- tt as validatePalletInTruck,
3178
+ ot as validatePalletInTruck,
2601
3179
  it as validatePalletWeight,
2602
- Wt as validateSeparators,
2603
- dt as validateStability,
3180
+ Lt as validateSeparators,
3181
+ ht as validateStability,
2604
3182
  $t as validateStackDimensions,
2605
- Bt as validateStackHeight,
2606
- Dt as validateStackWeight,
2607
- ct as validateSupport,
2608
- It as validateTruckWeight,
2609
- nt as validateWeightDistribution
3183
+ Gt as validateStackHeight,
3184
+ Vt as validateStackWeight,
3185
+ lt as validateSupport,
3186
+ Wt as validateTruckWeight,
3187
+ rt as validateWeightDistribution
2610
3188
  };
2611
3189
  //# sourceMappingURL=pallet-builder.js.map