@cristiancosano/pallet-builder 0.1.4 → 0.1.5

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