@burdenoff/microfe-movethewheels 2026.830.5 → 2026.918.1

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.
@@ -14,9 +14,9 @@ import { Zap as f } from "../node_modules/lucide-react/dist/esm/icons/zap.js";
14
14
  import { joinPath as p } from "../utils/navigation.js";
15
15
  import { useMoveTheWheels as m } from "../providers/MoveTheWheelsProvider.js";
16
16
  import { useFleet as h } from "../hooks/useFleet.js";
17
- import { useRoute as g, useRoutes as _ } from "../hooks/useRoutes.js";
18
- import { Badge as v, Button as y, Card as b, CardContent as x, CardHeader as S, CardTitle as C, Input as w, Label as T, Select as E, SelectContent as D, SelectItem as O, SelectTrigger as k, SelectValue as A } from "../components/ui.js";
19
- import { ErrorState as j, LoadingState as M, PageLayout as ee } from "../components/PageLayout.js";
17
+ import { useRoute as ee, useRoutes as g } from "../hooks/useRoutes.js";
18
+ import { Badge as _, Button as v, Card as y, CardContent as b, CardHeader as x, CardTitle as S, Input as C, Label as w, Select as T, SelectContent as E, SelectItem as D, SelectTrigger as O, SelectValue as k } from "../components/ui.js";
19
+ import { ErrorState as A, LoadingState as j, PageLayout as M } from "../components/PageLayout.js";
20
20
  import { RouteMap as N } from "../components/maps/RouteMap.js";
21
21
  import "../components/maps/index.js";
22
22
  import { ROUTE_STATUS_COLORS as P } from "../constants/index.js";
@@ -24,11 +24,14 @@ import { StatusBadge as F } from "../components/StatusBadge.js";
24
24
  import { FormError as I } from "../components/FormError.js";
25
25
  import { Notice as L, useNotice as R } from "../components/Notice.js";
26
26
  import { formatAddress as z, formatCurrency as B, formatDate as V } from "../utils/formatters.js";
27
- import { firstRealLatLng as H } from "../utils/mapMarkers.js";
28
- import { useEffect as U, useState as W } from "react";
29
- import { useLocation as G, useParams as K } from "react-router";
30
- import { jsx as q, jsxs as J } from "react/jsx-runtime";
31
- import { EmphasisPanel as Y, NextSteps as X, PagePurpose as Z } from "@burdenoff/fe-libs/ui";
27
+ import { firstRealLatLng as te } from "../utils/mapMarkers.js";
28
+ import { useAssignmentSuggestions as H } from "../hooks/useFleetIntelligence.js";
29
+ import { AssignmentSuggestions as U } from "../components/AssignmentSuggestions.js";
30
+ import { useEffect as W, useState as G } from "react";
31
+ import { useLocation as K, useParams as q } from "react-router";
32
+ import { jsx as J, jsxs as Y } from "react/jsx-runtime";
33
+ import { useI18n as ne } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
34
+ import { EmphasisPanel as X, NextSteps as re, PagePurpose as Z } from "@burdenoff/fe-libs/ui";
32
35
  //#region src/movethewheels/pages/RouteDetailsPage.tsx
33
36
  var Q = [
34
37
  {
@@ -48,8 +51,8 @@ var Q = [
48
51
  label: "Cancelled"
49
52
  }
50
53
  ];
51
- function $({ editId: r }) {
52
- let { basePath: i, navigate: a } = m(), { createRoute: o, updateRoute: u } = _(), { route: f } = g(r), { vehicles: v, drivers: j } = h(), M = !!r, [N, P] = W({
54
+ function ie({ editId: r }) {
55
+ let { basePath: i, navigate: a } = m(), { createRoute: o, updateRoute: u } = g(), { route: f } = ee(r), { vehicles: _, drivers: A } = h(), j = !!r, [N, P] = G({
53
56
  name: "",
54
57
  status: "planned",
55
58
  vehicleId: "",
@@ -58,8 +61,8 @@ function $({ editId: r }) {
58
61
  address: "",
59
62
  type: "delivery"
60
63
  }]
61
- }), [F, L] = W(!1), [R, B] = W(null);
62
- U(() => {
64
+ }), [F, L] = G(!1), [R, B] = G(null);
65
+ W(() => {
63
66
  !r || !f || P({
64
67
  name: f.name || "",
65
68
  status: f.status,
@@ -74,22 +77,22 @@ function $({ editId: r }) {
74
77
  }]
75
78
  });
76
79
  }, [r, f]);
77
- let V = () => a?.(p(i, "routes")), H = () => P((e) => ({
80
+ let V = () => a?.(p(i, "routes")), te = () => P((e) => ({
78
81
  ...e,
79
82
  stops: [...e.stops, {
80
83
  address: "",
81
84
  type: "delivery"
82
85
  }]
83
- })), G = (e) => P((t) => ({
86
+ })), H = (e) => P((t) => ({
84
87
  ...t,
85
88
  stops: t.stops.filter((t, n) => n !== e)
86
- })), K = (e, t, n) => P((r) => ({
89
+ })), U = (e, t, n) => P((r) => ({
87
90
  ...r,
88
91
  stops: r.stops.map((r, i) => i === e ? {
89
92
  ...r,
90
93
  [t]: n
91
94
  } : r)
92
- })), X = (e, t) => P((n) => {
95
+ })), K = (e, t) => P((n) => {
93
96
  let r = e + t;
94
97
  if (r < 0 || r >= n.stops.length) return n;
95
98
  let i = [...n.stops];
@@ -97,7 +100,7 @@ function $({ editId: r }) {
97
100
  ...n,
98
101
  stops: i
99
102
  };
100
- }), $ = async (e) => {
103
+ }), q = async (e) => {
101
104
  if (e.preventDefault(), !N.name.trim()) {
102
105
  B("Route name is required.");
103
106
  return;
@@ -125,7 +128,7 @@ function $({ editId: r }) {
125
128
  duration: 0,
126
129
  status: "pending"
127
130
  }));
128
- if (M) {
131
+ if (j) {
129
132
  let t = await u(r, {
130
133
  name: N.name.trim(),
131
134
  status: N.status,
@@ -148,51 +151,51 @@ function $({ editId: r }) {
148
151
  console.error("Failed to create route:", e), B(e instanceof Error ? e.message : "Failed to create route. Please try again."), L(!1);
149
152
  }
150
153
  };
151
- return /* @__PURE__ */ J(ee, {
152
- title: M ? "Edit Route" : "Create Route",
154
+ return /* @__PURE__ */ Y(M, {
155
+ title: j ? "Edit Route" : "Create Route",
153
156
  subtitle: "Plan a new delivery route",
154
- icon: /* @__PURE__ */ q(s, { size: 24 }),
155
- headerActions: /* @__PURE__ */ J("div", {
157
+ icon: /* @__PURE__ */ J(s, { size: 24 }),
158
+ headerActions: /* @__PURE__ */ Y("div", {
156
159
  className: "flex gap-2",
157
- children: [/* @__PURE__ */ J(y, {
160
+ children: [/* @__PURE__ */ Y(v, {
158
161
  variant: "outline",
159
162
  onClick: V,
160
163
  disabled: F,
161
- children: [/* @__PURE__ */ q(t, { size: 16 }), " Cancel"]
162
- }), /* @__PURE__ */ J(y, {
163
- onClick: $,
164
+ children: [/* @__PURE__ */ J(t, { size: 16 }), " Cancel"]
165
+ }), /* @__PURE__ */ Y(v, {
166
+ onClick: q,
164
167
  disabled: F,
165
168
  children: [
166
- /* @__PURE__ */ q(l, { size: 16 }),
169
+ /* @__PURE__ */ J(l, { size: 16 }),
167
170
  " ",
168
- M ? F ? "Saving..." : "Save Changes" : F ? "Saving..." : "Create Route"
171
+ j ? F ? "Saving..." : "Save Changes" : F ? "Saving..." : "Create Route"
169
172
  ]
170
173
  })]
171
174
  }),
172
- children: [/* @__PURE__ */ q(Z, {
173
- icon: /* @__PURE__ */ q(s, { size: 18 }),
175
+ children: [/* @__PURE__ */ J(Z, {
176
+ icon: /* @__PURE__ */ J(s, { size: 18 }),
174
177
  children: "Plan a new delivery route — name it, list the stops to visit, and optionally assign a vehicle and driver. Once created you can optimize it to sequence the stops into the shortest run."
175
- }), /* @__PURE__ */ J("form", {
176
- onSubmit: $,
178
+ }), /* @__PURE__ */ Y("form", {
179
+ onSubmit: q,
177
180
  className: "max-w-3xl space-y-6",
178
181
  children: [
179
- /* @__PURE__ */ q(I, { message: R }),
180
- /* @__PURE__ */ J(Y, { children: [/* @__PURE__ */ q("h2", {
182
+ /* @__PURE__ */ J(I, { message: R }),
183
+ /* @__PURE__ */ Y(X, { children: [/* @__PURE__ */ J("h2", {
181
184
  className: "text-base font-semibold text-text-primary mb-4",
182
185
  children: "Route Details"
183
- }), /* @__PURE__ */ J("div", {
186
+ }), /* @__PURE__ */ Y("div", {
184
187
  className: "space-y-4",
185
- children: [/* @__PURE__ */ J("div", {
188
+ children: [/* @__PURE__ */ Y("div", {
186
189
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
187
- children: [/* @__PURE__ */ J("div", {
190
+ children: [/* @__PURE__ */ Y("div", {
188
191
  className: "space-y-2",
189
- children: [/* @__PURE__ */ J(T, {
192
+ children: [/* @__PURE__ */ Y(w, {
190
193
  htmlFor: "name",
191
- children: ["Route Name ", /* @__PURE__ */ q("span", {
194
+ children: ["Route Name ", /* @__PURE__ */ J("span", {
192
195
  className: "text-status-error-text",
193
196
  children: "*"
194
197
  })]
195
- }), /* @__PURE__ */ q(w, {
198
+ }), /* @__PURE__ */ J(C, {
196
199
  id: "name",
197
200
  value: N.name,
198
201
  onChange: (e) => P((t) => ({
@@ -202,43 +205,43 @@ function $({ editId: r }) {
202
205
  placeholder: "Downtown morning run",
203
206
  required: !0
204
207
  })]
205
- }), /* @__PURE__ */ J("div", {
208
+ }), /* @__PURE__ */ Y("div", {
206
209
  className: "space-y-2",
207
- children: [/* @__PURE__ */ q(T, {
210
+ children: [/* @__PURE__ */ J(w, {
208
211
  htmlFor: "status",
209
212
  children: "Status"
210
- }), /* @__PURE__ */ J(E, {
213
+ }), /* @__PURE__ */ Y(T, {
211
214
  value: N.status,
212
215
  onValueChange: (e) => P((t) => ({
213
216
  ...t,
214
217
  status: e
215
218
  })),
216
- children: [/* @__PURE__ */ q(k, {
219
+ children: [/* @__PURE__ */ J(O, {
217
220
  id: "status",
218
- children: /* @__PURE__ */ q(A, {})
219
- }), /* @__PURE__ */ q(D, { children: Q.map((e) => /* @__PURE__ */ q(O, {
221
+ children: /* @__PURE__ */ J(k, {})
222
+ }), /* @__PURE__ */ J(E, { children: Q.map((e) => /* @__PURE__ */ J(D, {
220
223
  value: e.value,
221
224
  children: e.label
222
225
  }, e.value)) })]
223
226
  })]
224
227
  })]
225
- }), /* @__PURE__ */ J("div", {
228
+ }), /* @__PURE__ */ Y("div", {
226
229
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
227
- children: [/* @__PURE__ */ J("div", {
230
+ children: [/* @__PURE__ */ Y("div", {
228
231
  className: "space-y-2",
229
- children: [/* @__PURE__ */ q(T, {
232
+ children: [/* @__PURE__ */ J(w, {
230
233
  htmlFor: "vehicle",
231
234
  children: "Vehicle (optional)"
232
- }), /* @__PURE__ */ J(E, {
235
+ }), /* @__PURE__ */ Y(T, {
233
236
  value: N.vehicleId,
234
237
  onValueChange: (e) => P((t) => ({
235
238
  ...t,
236
239
  vehicleId: e
237
240
  })),
238
- children: [/* @__PURE__ */ q(k, {
241
+ children: [/* @__PURE__ */ J(O, {
239
242
  id: "vehicle",
240
- children: /* @__PURE__ */ q(A, { placeholder: "Assign later" })
241
- }), /* @__PURE__ */ q(D, { children: v.map((e) => /* @__PURE__ */ J(O, {
243
+ children: /* @__PURE__ */ J(k, { placeholder: "Assign later" })
244
+ }), /* @__PURE__ */ J(E, { children: _.map((e) => /* @__PURE__ */ Y(D, {
242
245
  value: e.id,
243
246
  children: [
244
247
  e.vehicleNumber,
@@ -248,21 +251,21 @@ function $({ editId: r }) {
248
251
  ]
249
252
  }, e.id)) })]
250
253
  })]
251
- }), /* @__PURE__ */ J("div", {
254
+ }), /* @__PURE__ */ Y("div", {
252
255
  className: "space-y-2",
253
- children: [/* @__PURE__ */ q(T, {
256
+ children: [/* @__PURE__ */ J(w, {
254
257
  htmlFor: "driver",
255
258
  children: "Driver (optional)"
256
- }), /* @__PURE__ */ J(E, {
259
+ }), /* @__PURE__ */ Y(T, {
257
260
  value: N.driverId,
258
261
  onValueChange: (e) => P((t) => ({
259
262
  ...t,
260
263
  driverId: e
261
264
  })),
262
- children: [/* @__PURE__ */ q(k, {
265
+ children: [/* @__PURE__ */ J(O, {
263
266
  id: "driver",
264
- children: /* @__PURE__ */ q(A, { placeholder: "Assign later" })
265
- }), /* @__PURE__ */ q(D, { children: j.map((e) => /* @__PURE__ */ J(O, {
267
+ children: /* @__PURE__ */ J(k, { placeholder: "Assign later" })
268
+ }), /* @__PURE__ */ J(E, { children: A.map((e) => /* @__PURE__ */ Y(D, {
266
269
  value: e.id,
267
270
  children: [
268
271
  e.fullName,
@@ -275,89 +278,89 @@ function $({ editId: r }) {
275
278
  })]
276
279
  })]
277
280
  })] }),
278
- /* @__PURE__ */ J(b, { children: [/* @__PURE__ */ J(S, {
281
+ /* @__PURE__ */ Y(y, { children: [/* @__PURE__ */ Y(x, {
279
282
  className: "flex flex-row items-center justify-between",
280
- children: [/* @__PURE__ */ J(C, { children: ["Stops ", /* @__PURE__ */ q("span", {
283
+ children: [/* @__PURE__ */ Y(S, { children: ["Stops ", /* @__PURE__ */ J("span", {
281
284
  className: "text-status-error-text",
282
285
  children: "*"
283
- })] }), /* @__PURE__ */ J(y, {
286
+ })] }), /* @__PURE__ */ Y(v, {
284
287
  type: "button",
285
288
  variant: "outline",
286
289
  size: "sm",
287
- onClick: H,
288
- children: [/* @__PURE__ */ q(c, { size: 16 }), " Add Stop"]
290
+ onClick: te,
291
+ children: [/* @__PURE__ */ J(c, { size: 16 }), " Add Stop"]
289
292
  })]
290
- }), /* @__PURE__ */ q(x, {
293
+ }), /* @__PURE__ */ J(b, {
291
294
  className: "space-y-4",
292
- children: N.stops.map((t, r) => /* @__PURE__ */ J("div", {
295
+ children: N.stops.map((t, r) => /* @__PURE__ */ Y("div", {
293
296
  className: "grid grid-cols-1 md:grid-cols-12 gap-3 items-end",
294
297
  children: [
295
- /* @__PURE__ */ J("div", {
298
+ /* @__PURE__ */ Y("div", {
296
299
  className: "md:col-span-7 space-y-2",
297
- children: [/* @__PURE__ */ J(T, {
300
+ children: [/* @__PURE__ */ Y(w, {
298
301
  htmlFor: `stop-address-${r}`,
299
302
  children: [
300
303
  "Stop ",
301
304
  r + 1,
302
305
  " address"
303
306
  ]
304
- }), /* @__PURE__ */ q(w, {
307
+ }), /* @__PURE__ */ J(C, {
305
308
  id: `stop-address-${r}`,
306
309
  value: t.address,
307
- onChange: (e) => K(r, "address", e.target.value),
310
+ onChange: (e) => U(r, "address", e.target.value),
308
311
  placeholder: "123 Main St, San Francisco, CA"
309
312
  })]
310
313
  }),
311
- /* @__PURE__ */ J("div", {
314
+ /* @__PURE__ */ Y("div", {
312
315
  className: "md:col-span-4 space-y-2",
313
- children: [/* @__PURE__ */ q(T, {
316
+ children: [/* @__PURE__ */ J(w, {
314
317
  htmlFor: `stop-type-${r}`,
315
318
  children: "Type"
316
- }), /* @__PURE__ */ J(E, {
319
+ }), /* @__PURE__ */ Y(T, {
317
320
  value: t.type,
318
- onValueChange: (e) => K(r, "type", e),
319
- children: [/* @__PURE__ */ q(k, {
321
+ onValueChange: (e) => U(r, "type", e),
322
+ children: [/* @__PURE__ */ J(O, {
320
323
  id: `stop-type-${r}`,
321
- children: /* @__PURE__ */ q(A, {})
322
- }), /* @__PURE__ */ J(D, { children: [/* @__PURE__ */ q(O, {
324
+ children: /* @__PURE__ */ J(k, {})
325
+ }), /* @__PURE__ */ Y(E, { children: [/* @__PURE__ */ J(D, {
323
326
  value: "pickup",
324
327
  children: "Pickup"
325
- }), /* @__PURE__ */ q(O, {
328
+ }), /* @__PURE__ */ J(D, {
326
329
  value: "delivery",
327
330
  children: "Delivery"
328
331
  })] })]
329
332
  })]
330
333
  }),
331
- /* @__PURE__ */ J("div", {
334
+ /* @__PURE__ */ Y("div", {
332
335
  className: "md:col-span-1 flex justify-end gap-1",
333
336
  children: [
334
- /* @__PURE__ */ q(y, {
337
+ /* @__PURE__ */ J(v, {
335
338
  type: "button",
336
339
  variant: "ghost",
337
340
  size: "icon",
338
- onClick: () => X(r, -1),
341
+ onClick: () => K(r, -1),
339
342
  disabled: r === 0,
340
343
  "aria-label": `Move stop ${r + 1} up`,
341
- children: /* @__PURE__ */ q(n, { size: 16 })
344
+ children: /* @__PURE__ */ J(n, { size: 16 })
342
345
  }),
343
- /* @__PURE__ */ q(y, {
346
+ /* @__PURE__ */ J(v, {
344
347
  type: "button",
345
348
  variant: "ghost",
346
349
  size: "icon",
347
- onClick: () => X(r, 1),
350
+ onClick: () => K(r, 1),
348
351
  disabled: r === N.stops.length - 1,
349
352
  "aria-label": `Move stop ${r + 1} down`,
350
- children: /* @__PURE__ */ q(e, { size: 16 })
353
+ children: /* @__PURE__ */ J(e, { size: 16 })
351
354
  }),
352
- /* @__PURE__ */ q(y, {
355
+ /* @__PURE__ */ J(v, {
353
356
  type: "button",
354
357
  variant: "ghost",
355
358
  size: "icon",
356
359
  className: "text-status-error-text",
357
- onClick: () => G(r),
360
+ onClick: () => H(r),
358
361
  disabled: N.stops.length === 1,
359
362
  "aria-label": `Remove stop ${r + 1}`,
360
- children: /* @__PURE__ */ q(d, { size: 16 })
363
+ children: /* @__PURE__ */ J(d, { size: 16 })
361
364
  })
362
365
  ]
363
366
  })
@@ -368,28 +371,33 @@ function $({ editId: r }) {
368
371
  })]
369
372
  });
370
373
  }
371
- function te() {
372
- let { routeId: e } = K(), n = G().pathname.endsWith("/edit"), { basePath: c, navigate: l } = m(), { route: d, isLoading: h, error: w, refetch: T } = g(e), { optimizeRoute: E } = _(), { message: D, notify: O } = R(), [k, A] = W(null), [U, Q] = W(!1), te = () => l?.(p(c, "routes")), ne = (e) => l?.(p(c, e)), re = async () => {
374
+ function $() {
375
+ let { routeId: e } = q(), n = K().pathname.endsWith("/edit"), { basePath: c, navigate: l } = m(), { route: d, isLoading: h, error: C, refetch: w } = ee(e), { optimizeRoute: T, updateRoute: E } = g(), D = H(e), { t: O } = ne(), k = (e, t) => {
376
+ let n = O(e);
377
+ return n === e ? t : n;
378
+ }, { message: W, notify: Q } = R(), [$, ae] = G(null), [oe, se] = G(!1), ce = () => l?.(p(c, "routes")), le = (e) => l?.(p(c, e)), ue = async () => {
373
379
  if (e) {
374
- Q(!0), A(null);
380
+ se(!0), ae(null);
375
381
  try {
376
- await E(e), O("Route optimized — stops resequenced for the shortest run."), T();
382
+ await T(e), Q("Route optimized — stops resequenced for the shortest run."), w();
377
383
  } catch (e) {
378
- A(e instanceof Error ? e.message : "Failed to optimize route.");
384
+ ae(e instanceof Error ? e.message : "Failed to optimize route.");
379
385
  } finally {
380
- Q(!1);
386
+ se(!1);
381
387
  }
382
388
  }
389
+ }, de = async (t) => {
390
+ e && (await E(e, t), Q(k("movethewheels.routes.suggest.done", "Assignment saved.")), w(), D.refetch());
383
391
  };
384
- if (!e) return /* @__PURE__ */ q($, {});
385
- if (n) return /* @__PURE__ */ q($, { editId: e });
386
- if (h) return /* @__PURE__ */ q(M, { message: "Loading route details..." });
387
- if (w || !d) return /* @__PURE__ */ q(j, {
392
+ if (!e) return /* @__PURE__ */ J(ie, {});
393
+ if (n) return /* @__PURE__ */ J(ie, { editId: e });
394
+ if (h) return /* @__PURE__ */ J(j, { message: "Loading route details..." });
395
+ if (C || !d) return /* @__PURE__ */ J(A, {
388
396
  title: "Route not found",
389
- onRetry: T
397
+ onRetry: w
390
398
  });
391
- let ie = d.stops.map((e) => {
392
- let t = H(e.address);
399
+ let fe = d.stops.map((e) => {
400
+ let t = te(e.address);
393
401
  return t ? {
394
402
  lat: t.lat,
395
403
  lng: t.lng,
@@ -397,152 +405,152 @@ function te() {
397
405
  label: z(e.address) || `Order #${e.orderId || e.sequence}`
398
406
  } : null;
399
407
  }).filter((e) => e !== null);
400
- return /* @__PURE__ */ J(ee, {
408
+ return /* @__PURE__ */ Y(M, {
401
409
  title: d.name,
402
410
  subtitle: `${d.stops.length} stops - ${d.distance.toFixed(1)} km`,
403
- icon: /* @__PURE__ */ q(s, { size: 24 }),
404
- headerActions: /* @__PURE__ */ J("div", {
411
+ icon: /* @__PURE__ */ J(s, { size: 24 }),
412
+ headerActions: /* @__PURE__ */ Y("div", {
405
413
  className: "flex gap-2",
406
414
  children: [
407
- /* @__PURE__ */ J(y, {
415
+ /* @__PURE__ */ Y(v, {
408
416
  variant: "outline",
409
- onClick: te,
410
- children: [/* @__PURE__ */ q(t, { size: 16 }), " Back"]
417
+ onClick: ce,
418
+ children: [/* @__PURE__ */ J(t, { size: 16 }), " Back"]
411
419
  }),
412
- !d.optimized && /* @__PURE__ */ J(y, {
420
+ !d.optimized && /* @__PURE__ */ Y(v, {
413
421
  variant: "outline",
414
- onClick: re,
415
- disabled: U,
422
+ onClick: ue,
423
+ disabled: oe,
416
424
  children: [
417
- /* @__PURE__ */ q(f, { size: 16 }),
425
+ /* @__PURE__ */ J(f, { size: 16 }),
418
426
  " ",
419
- U ? "Optimizing…" : "Optimize"
427
+ oe ? "Optimizing…" : "Optimize"
420
428
  ]
421
429
  }),
422
- /* @__PURE__ */ J(y, {
430
+ /* @__PURE__ */ Y(v, {
423
431
  onClick: () => l?.(p(c, `routes/${e}/edit`)),
424
- children: [/* @__PURE__ */ q(u, { size: 16 }), " Edit"]
432
+ children: [/* @__PURE__ */ J(u, { size: 16 }), " Edit"]
425
433
  })
426
434
  ]
427
435
  }),
428
- headerContent: /* @__PURE__ */ J("div", {
436
+ headerContent: /* @__PURE__ */ Y("div", {
429
437
  className: "flex gap-2",
430
- children: [/* @__PURE__ */ q(F, {
438
+ children: [/* @__PURE__ */ J(F, {
431
439
  status: d.status,
432
440
  customColors: P[d.status]
433
- }), /* @__PURE__ */ q(v, {
441
+ }), /* @__PURE__ */ J(_, {
434
442
  variant: d.optimized ? "default" : "secondary",
435
443
  children: d.optimized ? "Optimized" : "Not Optimized"
436
444
  })]
437
445
  }),
438
446
  children: [
439
- /* @__PURE__ */ q(Z, {
440
- icon: /* @__PURE__ */ q(s, { size: 18 }),
447
+ /* @__PURE__ */ J(Z, {
448
+ icon: /* @__PURE__ */ J(s, { size: 18 }),
441
449
  children: "A single optimized driving plan that chains together this route's stops. Review the sequence, distance and timing here, re-optimize if traffic or stops change, then hand the itinerary to a driver."
442
450
  }),
443
- /* @__PURE__ */ q(X, {
451
+ /* @__PURE__ */ J(re, {
444
452
  storageKey: "movethewheels-route-details",
445
453
  steps: [
446
454
  ...d.optimized ? [] : [{
447
455
  id: "optimize",
448
456
  label: "Optimize this route",
449
457
  description: "Reorder stops to cut distance and driving time.",
450
- icon: /* @__PURE__ */ q(f, { size: 16 }),
451
- onClick: re
458
+ icon: /* @__PURE__ */ J(f, { size: 16 }),
459
+ onClick: ue
452
460
  }],
453
461
  {
454
462
  id: "edit",
455
463
  label: "Adjust stops",
456
464
  description: "Add, remove or reorder the delivery stops.",
457
- icon: /* @__PURE__ */ q(u, { size: 16 }),
465
+ icon: /* @__PURE__ */ J(u, { size: 16 }),
458
466
  onClick: () => {}
459
467
  },
460
468
  {
461
469
  id: "orders",
462
470
  label: "Review the orders on this route",
463
471
  description: "Check the deliveries bundled into this run.",
464
- icon: /* @__PURE__ */ q(o, { size: 16 }),
465
- onClick: () => ne("orders")
472
+ icon: /* @__PURE__ */ J(o, { size: 16 }),
473
+ onClick: () => le("orders")
466
474
  }
467
475
  ]
468
476
  }),
469
- k && /* @__PURE__ */ q("div", {
477
+ $ && /* @__PURE__ */ J("div", {
470
478
  className: "mb-2",
471
- children: /* @__PURE__ */ q(I, { message: k })
479
+ children: /* @__PURE__ */ J(I, { message: $ })
472
480
  }),
473
- D && /* @__PURE__ */ q("div", {
481
+ W && /* @__PURE__ */ J("div", {
474
482
  className: "mb-2",
475
- children: /* @__PURE__ */ q(L, { message: D })
483
+ children: /* @__PURE__ */ J(L, { message: W })
476
484
  }),
477
- /* @__PURE__ */ J("div", {
485
+ /* @__PURE__ */ Y("div", {
478
486
  className: "grid grid-cols-1 lg:grid-cols-3 gap-6",
479
- children: [/* @__PURE__ */ J("div", {
487
+ children: [/* @__PURE__ */ Y("div", {
480
488
  className: "lg:col-span-2 space-y-6",
481
- children: [/* @__PURE__ */ J(b, { children: [/* @__PURE__ */ q(S, { children: /* @__PURE__ */ q(C, { children: "Route Map" }) }), /* @__PURE__ */ q(x, { children: ie.length > 0 ? /* @__PURE__ */ q(N, {
489
+ children: [/* @__PURE__ */ Y(y, { children: [/* @__PURE__ */ J(x, { children: /* @__PURE__ */ J(S, { children: "Route Map" }) }), /* @__PURE__ */ J(b, { children: fe.length > 0 ? /* @__PURE__ */ J(N, {
482
490
  className: "overflow-hidden rounded-lg border border-border-seam",
483
491
  height: 360,
484
- stops: ie
485
- }) : /* @__PURE__ */ J("div", {
492
+ stops: fe
493
+ }) : /* @__PURE__ */ Y("div", {
486
494
  className: "rounded-lg border border-border-seam bg-bg-sunken/40 p-4",
487
- children: [/* @__PURE__ */ q("p", {
495
+ children: [/* @__PURE__ */ J("p", {
488
496
  className: "mb-3 text-sm text-text-secondary",
489
497
  children: "These stops don't have map coordinates yet — showing the planned sequence instead."
490
- }), /* @__PURE__ */ q("ol", {
498
+ }), /* @__PURE__ */ J("ol", {
491
499
  className: "space-y-2",
492
- children: d.stops.map((e) => /* @__PURE__ */ J("li", {
500
+ children: d.stops.map((e) => /* @__PURE__ */ Y("li", {
493
501
  className: "flex items-start gap-3",
494
- children: [/* @__PURE__ */ q("span", {
502
+ children: [/* @__PURE__ */ J("span", {
495
503
  className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/10 text-xs font-semibold text-primary",
496
504
  children: e.sequence
497
- }), /* @__PURE__ */ q("span", {
505
+ }), /* @__PURE__ */ J("span", {
498
506
  className: "text-sm",
499
507
  children: z(e.address) || `Order #${e.orderId || e.sequence}`
500
508
  })]
501
509
  }, e.id))
502
510
  })]
503
- }) })] }), /* @__PURE__ */ J(b, { children: [/* @__PURE__ */ q(S, { children: /* @__PURE__ */ J(C, { children: [
511
+ }) })] }), /* @__PURE__ */ Y(y, { children: [/* @__PURE__ */ J(x, { children: /* @__PURE__ */ Y(S, { children: [
504
512
  "Stops (",
505
513
  d.stops.length,
506
514
  ")"
507
- ] }) }), /* @__PURE__ */ q(x, { children: /* @__PURE__ */ q("div", {
515
+ ] }) }), /* @__PURE__ */ J(b, { children: /* @__PURE__ */ J("div", {
508
516
  className: "space-y-4",
509
- children: d.stops.map((e, t) => /* @__PURE__ */ J("div", {
517
+ children: d.stops.map((e, t) => /* @__PURE__ */ Y("div", {
510
518
  className: "flex gap-4",
511
- children: [/* @__PURE__ */ J("div", {
519
+ children: [/* @__PURE__ */ Y("div", {
512
520
  className: "relative",
513
- children: [/* @__PURE__ */ q("div", {
521
+ children: [/* @__PURE__ */ J("div", {
514
522
  className: `w-8 h-8 rounded-full flex items-center justify-center ${e.status === "completed" ? "bg-status-success-text text-text-inverse" : "bg-bg-sunken"}`,
515
- children: e.status === "completed" ? /* @__PURE__ */ q(r, { size: 16 }) : e.sequence
516
- }), t < d.stops.length - 1 && /* @__PURE__ */ q("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
517
- }), /* @__PURE__ */ q("div", {
523
+ children: e.status === "completed" ? /* @__PURE__ */ J(r, { size: 16 }) : e.sequence
524
+ }), t < d.stops.length - 1 && /* @__PURE__ */ J("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
525
+ }), /* @__PURE__ */ J("div", {
518
526
  className: "flex-1 pb-4",
519
- children: /* @__PURE__ */ J("div", {
527
+ children: /* @__PURE__ */ Y("div", {
520
528
  className: "flex items-center justify-between",
521
- children: [/* @__PURE__ */ J("div", { children: [/* @__PURE__ */ J("div", {
529
+ children: [/* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ Y("div", {
522
530
  className: "flex items-center gap-2",
523
- children: [/* @__PURE__ */ q(v, {
531
+ children: [/* @__PURE__ */ J(_, {
524
532
  variant: e.type === "pickup" ? "secondary" : "default",
525
533
  className: "capitalize",
526
534
  children: e.type
527
- }), /* @__PURE__ */ J("span", {
535
+ }), /* @__PURE__ */ Y("span", {
528
536
  className: "font-medium",
529
537
  children: ["Order #", e.orderId]
530
538
  })]
531
- }), /* @__PURE__ */ q("p", {
539
+ }), /* @__PURE__ */ J("p", {
532
540
  className: "text-sm text-text-secondary mt-1",
533
541
  children: z(e.address)
534
- })] }), /* @__PURE__ */ J("div", {
542
+ })] }), /* @__PURE__ */ Y("div", {
535
543
  className: "text-right",
536
544
  children: [
537
- /* @__PURE__ */ J("p", {
545
+ /* @__PURE__ */ Y("p", {
538
546
  className: "text-sm",
539
547
  children: ["Scheduled: ", V(e.scheduledTime, "time")]
540
548
  }),
541
- e.actualTime && /* @__PURE__ */ J("p", {
549
+ e.actualTime && /* @__PURE__ */ Y("p", {
542
550
  className: "text-sm text-status-success-text",
543
551
  children: ["Actual: ", V(e.actualTime, "time")]
544
552
  }),
545
- /* @__PURE__ */ J("p", {
553
+ /* @__PURE__ */ Y("p", {
546
554
  className: "text-xs text-text-secondary",
547
555
  children: [e.duration, " min stop"]
548
556
  })
@@ -552,81 +560,91 @@ function te() {
552
560
  })]
553
561
  }, e.id))
554
562
  }) })] })]
555
- }), /* @__PURE__ */ J("div", {
563
+ }), /* @__PURE__ */ Y("div", {
556
564
  className: "space-y-6",
557
565
  children: [
558
- /* @__PURE__ */ J(Y, {
566
+ (d.status === "planned" || d.status === "in_progress") && /* @__PURE__ */ J(U, {
567
+ suggestions: D.data,
568
+ isLoading: D.isLoading,
569
+ error: D.error,
570
+ onRetry: D.refetch,
571
+ assignedVehicleId: d.vehicleId || void 0,
572
+ assignedDriverId: d.driverId || void 0,
573
+ onAssign: de,
574
+ t: k
575
+ }),
576
+ /* @__PURE__ */ Y(X, {
559
577
  className: "space-y-4",
560
578
  children: [
561
- /* @__PURE__ */ q("h2", {
579
+ /* @__PURE__ */ J("h2", {
562
580
  className: "text-base font-semibold text-text-primary",
563
581
  children: "Route Info"
564
582
  }),
565
- /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
583
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
566
584
  className: "text-sm text-text-secondary",
567
585
  children: "Total Distance"
568
- }), /* @__PURE__ */ J("p", {
586
+ }), /* @__PURE__ */ Y("p", {
569
587
  className: "text-2xl font-bold",
570
- children: [d.distance.toFixed(1), /* @__PURE__ */ q("span", {
588
+ children: [d.distance.toFixed(1), /* @__PURE__ */ J("span", {
571
589
  className: "text-sm font-normal",
572
590
  children: " km"
573
591
  })]
574
592
  })] }),
575
- /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
593
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
576
594
  className: "text-sm text-text-secondary",
577
595
  children: "Est. Duration"
578
- }), /* @__PURE__ */ J("p", {
596
+ }), /* @__PURE__ */ Y("p", {
579
597
  className: "text-2xl font-bold",
580
- children: [d.estimatedDuration, /* @__PURE__ */ q("span", {
598
+ children: [d.estimatedDuration, /* @__PURE__ */ J("span", {
581
599
  className: "text-sm font-normal",
582
600
  children: " min"
583
601
  })]
584
602
  })] }),
585
- d.fuelCost !== void 0 && /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ J("p", {
603
+ d.fuelCost !== void 0 && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ Y("p", {
586
604
  className: "text-sm text-text-secondary flex items-center gap-1",
587
- children: [/* @__PURE__ */ q(a, { size: 14 }), " Est. Fuel Cost"]
588
- }), /* @__PURE__ */ q("p", {
605
+ children: [/* @__PURE__ */ J(a, { size: 14 }), " Est. Fuel Cost"]
606
+ }), /* @__PURE__ */ J("p", {
589
607
  className: "text-2xl font-bold",
590
608
  children: B(d.fuelCost)
591
609
  })] }),
592
- d.actualDuration && /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
610
+ d.actualDuration && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
593
611
  className: "text-sm text-text-secondary",
594
612
  children: "Actual Duration"
595
- }), /* @__PURE__ */ J("p", {
613
+ }), /* @__PURE__ */ Y("p", {
596
614
  className: "text-2xl font-bold",
597
- children: [d.actualDuration, /* @__PURE__ */ q("span", {
615
+ children: [d.actualDuration, /* @__PURE__ */ J("span", {
598
616
  className: "text-sm font-normal",
599
617
  children: " min"
600
618
  })]
601
619
  })] })
602
620
  ]
603
621
  }),
604
- /* @__PURE__ */ J(b, { children: [/* @__PURE__ */ q(S, { children: /* @__PURE__ */ J(C, {
622
+ /* @__PURE__ */ Y(y, { children: [/* @__PURE__ */ J(x, { children: /* @__PURE__ */ Y(S, {
605
623
  className: "flex items-center gap-2",
606
- children: [/* @__PURE__ */ q(i, { size: 18 }), " Timeline"]
607
- }) }), /* @__PURE__ */ J(x, {
624
+ children: [/* @__PURE__ */ J(i, { size: 18 }), " Timeline"]
625
+ }) }), /* @__PURE__ */ Y(b, {
608
626
  className: "space-y-3",
609
627
  children: [
610
- d.startTime && /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
628
+ d.startTime && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
611
629
  className: "text-sm text-text-secondary",
612
630
  children: "Started"
613
- }), /* @__PURE__ */ q("p", { children: V(d.startTime, "full") })] }),
614
- d.endTime && /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
631
+ }), /* @__PURE__ */ J("p", { children: V(d.startTime, "full") })] }),
632
+ d.endTime && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
615
633
  className: "text-sm text-text-secondary",
616
634
  children: "Completed"
617
- }), /* @__PURE__ */ q("p", { children: V(d.endTime, "full") })] }),
618
- /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("p", {
635
+ }), /* @__PURE__ */ J("p", { children: V(d.endTime, "full") })] }),
636
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
619
637
  className: "text-sm text-text-secondary",
620
638
  children: "Created"
621
- }), /* @__PURE__ */ q("p", { children: V(d.createdAt, "full") })] })
639
+ }), /* @__PURE__ */ J("p", { children: V(d.createdAt, "full") })] })
622
640
  ]
623
641
  })] }),
624
- d.trafficConditions.length > 0 && /* @__PURE__ */ J(b, { children: [/* @__PURE__ */ q(S, { children: /* @__PURE__ */ q(C, { children: "Traffic Conditions" }) }), /* @__PURE__ */ q(x, { children: d.trafficConditions.map((e, t) => /* @__PURE__ */ J("div", {
642
+ d.trafficConditions.length > 0 && /* @__PURE__ */ Y(y, { children: [/* @__PURE__ */ J(x, { children: /* @__PURE__ */ J(S, { children: "Traffic Conditions" }) }), /* @__PURE__ */ J(b, { children: d.trafficConditions.map((e, t) => /* @__PURE__ */ Y("div", {
625
643
  className: `p-2 rounded mb-2 ${e.condition === "severe" ? "bg-status-error-bg-subtle" : (e.condition, "bg-status-warning-bg-subtle")}`,
626
- children: [/* @__PURE__ */ J("p", {
644
+ children: [/* @__PURE__ */ Y("p", {
627
645
  className: "text-sm font-medium capitalize",
628
646
  children: [e.condition, " traffic"]
629
- }), /* @__PURE__ */ J("p", {
647
+ }), /* @__PURE__ */ Y("p", {
630
648
  className: "text-xs text-text-secondary",
631
649
  children: [
632
650
  e.location,
@@ -643,4 +661,4 @@ function te() {
643
661
  });
644
662
  }
645
663
  //#endregion
646
- export { te as default };
664
+ export { $ as default };