@burdenoff/microfe-mybodyshield 2026.720.3 → 2026.731.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/mybodyshield/hooks/useMyBodyShieldApi.d.ts +28 -1
  2. package/dist/mybodyshield/hooks/useMyBodyShieldApi.d.ts.map +1 -1
  3. package/dist/mybodyshield/hooks/useMyBodyShieldApi.js +79 -40
  4. package/dist/mybodyshield/hooks/useMyBodyShieldApi.js.map +1 -1
  5. package/dist/mybodyshield/lib/offlineSessionQueue.d.ts +76 -0
  6. package/dist/mybodyshield/lib/offlineSessionQueue.d.ts.map +1 -0
  7. package/dist/mybodyshield/lib/offlineSessionQueue.js +77 -0
  8. package/dist/mybodyshield/lib/offlineSessionQueue.js.map +1 -0
  9. package/dist/mybodyshield/lib/useOfflineSessionSync.d.ts +30 -0
  10. package/dist/mybodyshield/lib/useOfflineSessionSync.d.ts.map +1 -0
  11. package/dist/mybodyshield/lib/useOfflineSessionSync.js +80 -0
  12. package/dist/mybodyshield/lib/useOfflineSessionSync.js.map +1 -0
  13. package/dist/mybodyshield/pages/DashboardPage.d.ts.map +1 -1
  14. package/dist/mybodyshield/pages/DashboardPage.js +247 -170
  15. package/dist/mybodyshield/pages/DashboardPage.js.map +1 -1
  16. package/dist/mybodyshield/pages/nutrition/NutritionPage.d.ts.map +1 -1
  17. package/dist/mybodyshield/pages/nutrition/NutritionPage.js +540 -441
  18. package/dist/mybodyshield/pages/nutrition/NutritionPage.js.map +1 -1
  19. package/dist/mybodyshield/pages/train/SessionDetailPage.d.ts.map +1 -1
  20. package/dist/mybodyshield/pages/train/SessionDetailPage.js +242 -173
  21. package/dist/mybodyshield/pages/train/SessionDetailPage.js.map +1 -1
  22. package/dist/mybodyshield/types/index.d.ts +46 -0
  23. package/dist/mybodyshield/types/index.d.ts.map +1 -1
  24. package/package.json +4 -4
@@ -14,14 +14,38 @@ import "../../components/index.js";
14
14
  import { motion as s } from "../../../node_modules/framer-motion/dist/es/render/components/motion/proxy.js";
15
15
  import { useReducedMotion as me } from "../../../node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.js";
16
16
  import { IconChip as c } from "../_shared/visuals.js";
17
- import { useEffect as he, useMemo as l, useState as u } from "react";
18
- import { AlertTriangle as ge, ArrowLeft as _e, CheckCircle2 as ve, ChevronLeft as ye, ChevronRight as be, Dumbbell as d, Flame as xe, Gauge as Se, ListChecks as Ce, Plus as f, Ruler as we, Timer as p, Trophy as Te, Weight as Ee, X as De } from "lucide-react";
19
- import { useParams as Oe } from "react-router-dom";
20
- import { Fragment as ke, jsx as m, jsxs as h } from "react/jsx-runtime";
21
- import { Button as g, GlassCard as _, Input as v, Label as y, ResponsiveDialog as Ae, ResponsiveDialogContent as je, ResponsiveDialogDescription as Me, ResponsiveDialogFooter as Ne, ResponsiveDialogHeader as Pe, ResponsiveDialogTitle as Fe, Switch as Ie, Textarea as Le } from "@burdenoff/fe-libs/ui";
17
+ import { listPendingActionsForSession as he } from "../../lib/offlineSessionQueue.js";
18
+ import { useOfflineSessionSync as ge } from "../../lib/useOfflineSessionSync.js";
19
+ import { useCallback as _e, useEffect as ve, useMemo as l, useState as u } from "react";
20
+ import { AlertTriangle as ye, ArrowLeft as be, CheckCircle2 as xe, ChevronLeft as Se, ChevronRight as Ce, Dumbbell as d, Flame as we, Gauge as Te, ListChecks as Ee, Plus as f, Ruler as De, Timer as p, Trophy as Oe, Weight as ke, WifiOff as Ae, X as je } from "lucide-react";
21
+ import { useParams as Me } from "react-router-dom";
22
+ import { Fragment as Ne, jsx as m, jsxs as h } from "react/jsx-runtime";
23
+ import { Button as g, GlassCard as _, Input as v, Label as y, ResponsiveDialog as Pe, ResponsiveDialogContent as Fe, ResponsiveDialogDescription as Ie, ResponsiveDialogFooter as Le, ResponsiveDialogHeader as Re, ResponsiveDialogTitle as ze, Switch as Be, Textarea as Ve } from "@burdenoff/fe-libs/ui";
22
24
  //#region src/mybodyshield/pages/train/SessionDetailPage.tsx
23
- var Re = 90, ze = [];
24
- function Be(e, t, n) {
25
+ function He(e) {
26
+ if (typeof navigator < "u" && !navigator.onLine || e instanceof TypeError) return !0;
27
+ let t = e instanceof Error ? e.message.toLowerCase() : "";
28
+ return t.includes("failed to fetch") || t.includes("load failed") || t.includes("network");
29
+ }
30
+ function Ue(e, t) {
31
+ let n = e.input;
32
+ return {
33
+ id: `pending-${e.clientActionId}`,
34
+ workspaceId: "",
35
+ sessionId: t,
36
+ exerciseName: n.exerciseName,
37
+ setNumber: n.setNumber ?? 1,
38
+ reps: n.reps ?? 0,
39
+ weight: n.weight ?? 0,
40
+ distanceM: n.distanceM ?? 0,
41
+ durationSec: n.durationSec ?? 0,
42
+ isPersonalRecord: !!n.isPersonalRecord,
43
+ createdAt: e.capturedAt,
44
+ updatedAt: e.capturedAt
45
+ };
46
+ }
47
+ var We = 90, Ge = [];
48
+ function Ke(e, t, n) {
25
49
  return n ? e > n.weight || e === n.weight && t > n.reps : !1;
26
50
  }
27
51
  var b = [
@@ -29,7 +53,7 @@ var b = [
29
53
  1,
30
54
  .3,
31
55
  1
32
- ], Ve = {
56
+ ], qe = {
33
57
  hidden: {},
34
58
  show: { transition: { staggerChildren: .06 } }
35
59
  }, x = {
@@ -60,17 +84,23 @@ var C = {
60
84
  distanceM: "",
61
85
  durationSec: "",
62
86
  isPersonalRecord: !1
63
- }, He = {
87
+ }, Je = {
64
88
  caloriesBurned: "",
65
89
  perceivedExertion: "",
66
90
  notes: ""
67
91
  };
68
92
  function w() {
69
- let { navigateTo: w, workspaceId: Ue } = e(), T = me(), { id: E } = Oe();
93
+ let { navigateTo: w, workspaceId: Ye } = e(), T = me(), { id: E } = Me();
70
94
  fe();
71
- let D = ue(E), O = le(), k = se(), We = de(D.data?.workoutId ?? void 0), [Ge, A] = u(!1), [j, M] = u(C), [Ke, N] = u(null), [qe, P] = u(!1), [Je, F] = u(!1), [I, L] = u(He), [Ye, R] = u(null), [Xe, z] = u(null), [Ze, Qe] = u(D.data?.workoutId), [B, V] = u(null), [$e, H] = u(0), U = ce(j.exerciseName), W = D.data, G = l(() => W?.sets ?? [], [W?.sets]), K = l(() => {
95
+ let D = ue(E), O = le(), k = se(), Xe = de(D.data?.workoutId ?? void 0), A = ge((e) => O.mutateAsync(e), (e) => k.mutateAsync(e), () => D.refetch()), [j, Ze] = u([]), M = _e(() => {
96
+ E && he(E).then(Ze);
97
+ }, [E]);
98
+ ve(() => {
99
+ M();
100
+ }, [M, A.pendingCount]);
101
+ let Qe = l(() => E ? j.filter((e) => e.type === "LOG_SET").map((e) => Ue(e, E)) : [], [j, E]), $e = j.some((e) => e.type === "COMPLETE_SESSION"), [et, N] = u(!1), [P, F] = u(C), [tt, I] = u(null), [nt, L] = u(!1), [rt, R] = u(!1), [z, B] = u(Je), [it, V] = u(null), [at, H] = u(null), [ot, st] = u(D.data?.workoutId), [ct, U] = u(null), [lt, W] = u(0), G = ce(P.exerciseName), K = D.data, q = l(() => [...K?.sets ?? [], ...Qe], [K?.sets, Qe]), J = l(() => {
72
102
  let e = /* @__PURE__ */ new Map();
73
- for (let t of G) {
103
+ for (let t of q) {
74
104
  let n = e.get(t.exerciseName) ?? [];
75
105
  n.push(t), e.set(t.exerciseName, n);
76
106
  }
@@ -78,28 +108,28 @@ function w() {
78
108
  name: e,
79
109
  sets: t.slice().sort((e, t) => e.setNumber - t.setNumber)
80
110
  }));
81
- }, [G]), et = l(() => G.reduce((e, t) => e + t.reps * t.weight, 0), [G]), q = W?.startedAt, tt = W?.completedAt, nt = l(() => {
82
- if (!q || !tt) return;
83
- let e = new Date(q).getTime(), t = new Date(tt).getTime();
111
+ }, [q]), ut = l(() => q.reduce((e, t) => e + t.reps * t.weight, 0), [q]), dt = K?.startedAt, ft = K?.completedAt, pt = l(() => {
112
+ if (!dt || !ft) return;
113
+ let e = new Date(dt).getTime(), t = new Date(ft).getTime();
84
114
  if (!(!Number.isFinite(e) || !Number.isFinite(t) || t < e)) return (t - e) / 1e3;
85
- }, [q, tt]), J = We.data ?? ze, Y = l(() => {
115
+ }, [dt, ft]), Y = Xe.data ?? Ge, X = l(() => {
86
116
  let e = /* @__PURE__ */ new Map();
87
- for (let t of K) e.set(t.name, t.sets.length);
117
+ for (let t of J) e.set(t.name, t.sets.length);
88
118
  return e;
89
- }, [K]), rt = l(() => {
90
- if (J.length === 0) return 0;
91
- let e = J.findIndex((e) => (Y.get(e.name) ?? 0) < Math.max(e.sets, 1));
92
- return e === -1 ? J.length - 1 : e;
93
- }, [J, Y]), X = Math.min(Xe ?? rt, Math.max(J.length - 1, 0)), Z = J[X], it = J.length > 0 && J.every((e) => (Y.get(e.name) ?? 0) >= Math.max(e.sets, 1));
94
- D.data?.workoutId !== Ze && (Qe(D.data?.workoutId), z(null)), he(() => {
95
- if (B == null) return;
119
+ }, [J]), mt = l(() => {
120
+ if (Y.length === 0) return 0;
121
+ let e = Y.findIndex((e) => (X.get(e.name) ?? 0) < Math.max(e.sets, 1));
122
+ return e === -1 ? Y.length - 1 : e;
123
+ }, [Y, X]), Z = Math.min(at ?? mt, Math.max(Y.length - 1, 0)), Q = Y[Z], ht = Y.length > 0 && Y.every((e) => (X.get(e.name) ?? 0) >= Math.max(e.sets, 1));
124
+ D.data?.workoutId !== ot && (st(D.data?.workoutId), H(null)), ve(() => {
125
+ if (ct == null) return;
96
126
  let e = window.setInterval(() => {
97
- let e = Math.max(0, Math.ceil((B - Date.now()) / 1e3));
98
- H(e), e <= 0 && V(null);
127
+ let e = Math.max(0, Math.ceil((ct - Date.now()) / 1e3));
128
+ W(e), e <= 0 && U(null);
99
129
  }, 1e3);
100
130
  return () => window.clearInterval(e);
101
- }, [B]);
102
- let at = S(j.weight) ?? 0, ot = S(j.reps) ?? 0, st = j.exerciseName.trim().length > 0 && Be(at, ot, U.data), ct = qe ? j.isPersonalRecord : st;
131
+ }, [ct]);
132
+ let gt = S(P.weight) ?? 0, _t = S(P.reps) ?? 0, vt = P.exerciseName.trim().length > 0 && Ke(gt, _t, G.data), yt = nt ? P.isPersonalRecord : vt;
103
133
  if (!E) return /* @__PURE__ */ m(t, {
104
134
  title: "Workout session",
105
135
  children: /* @__PURE__ */ m(ae, {
@@ -111,7 +141,7 @@ function w() {
111
141
  title: "Workout session",
112
142
  children: /* @__PURE__ */ m(oe, { label: "Loading session…" })
113
143
  });
114
- if (D.isError || !W) return /* @__PURE__ */ m(t, {
144
+ if (D.isError || !K) return /* @__PURE__ */ m(t, {
115
145
  title: "Workout session",
116
146
  children: /* @__PURE__ */ m(ae, {
117
147
  title: "Session not found",
@@ -119,37 +149,55 @@ function w() {
119
149
  onRetry: () => D.refetch()
120
150
  })
121
151
  });
122
- let Q = W.status === "IN_PROGRESS", lt = W.completedAt ? `Completed ${a(W.completedAt)}` : W.startedAt ? `Started ${a(W.startedAt)}` : W.scheduledFor ? `Scheduled ${a(W.scheduledFor)}` : `Created ${a(W.createdAt)}`, $ = () => {
123
- M(C), N(null), P(!1), A(!0);
124
- }, ut = (e) => {
125
- let t = Y.get(e.name) ?? 0;
126
- M({
152
+ let $ = K.status === "IN_PROGRESS", bt = K.completedAt ? `Completed ${a(K.completedAt)}` : K.startedAt ? `Started ${a(K.startedAt)}` : K.scheduledFor ? `Scheduled ${a(K.scheduledFor)}` : `Created ${a(K.createdAt)}`, xt = () => {
153
+ F(C), I(null), L(!1), N(!0);
154
+ }, St = (e) => {
155
+ let t = X.get(e.name) ?? 0;
156
+ F({
127
157
  ...C,
128
158
  exerciseName: e.name,
129
159
  setNumber: String(t + 1),
130
160
  reps: e.reps > 0 ? String(e.reps) : "",
131
161
  weight: e.targetWeight > 0 ? String(e.targetWeight) : ""
132
- }), N(null), P(!1), A(!0);
162
+ }), I(null), L(!1), N(!0);
133
163
  };
134
164
  return /* @__PURE__ */ h(t, {
135
165
  title: "Workout session",
136
- description: lt,
137
- actions: Q ? /* @__PURE__ */ h(ke, { children: [/* @__PURE__ */ h(g, {
166
+ description: bt,
167
+ actions: $ ? /* @__PURE__ */ h(Ne, { children: [/* @__PURE__ */ h(g, {
138
168
  variant: "outline",
139
- onClick: $,
169
+ onClick: xt,
140
170
  children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), " Log set"]
141
171
  }), /* @__PURE__ */ h(g, {
142
172
  onClick: () => {
143
- L(He), R(null), F(!0);
173
+ B(Je), V(null), R(!0);
144
174
  },
145
- children: [/* @__PURE__ */ m(ve, { className: "h-4 w-4" }), " Complete"]
175
+ disabled: $e,
176
+ children: [
177
+ /* @__PURE__ */ m(xe, { className: "h-4 w-4" }),
178
+ " ",
179
+ $e ? "Pending sync…" : "Complete"
180
+ ]
146
181
  })] }) : void 0,
147
182
  children: [
148
183
  /* @__PURE__ */ h("button", {
149
184
  type: "button",
150
185
  onClick: () => w("train"),
151
186
  className: "mb-4 inline-flex items-center gap-1.5 text-sm font-medium text-text-secondary hover:text-text-primary",
152
- children: [/* @__PURE__ */ m(_e, { className: "h-4 w-4" }), " Back to sessions"]
187
+ children: [/* @__PURE__ */ m(be, { className: "h-4 w-4" }), " Back to sessions"]
188
+ }),
189
+ (!A.isOnline || j.length > 0) && /* @__PURE__ */ h("div", {
190
+ className: "mb-4 flex items-center gap-2 rounded-xl border border-status-warning-text/40 bg-status-warning-bg-subtle px-4 py-2.5 text-sm text-text-primary",
191
+ children: [
192
+ /* @__PURE__ */ m(Ae, { className: "h-4 w-4 shrink-0 text-status-warning-text" }),
193
+ /* @__PURE__ */ m("span", { children: A.isOnline ? `Syncing ${j.length} queued ${j.length === 1 ? "action" : "actions"}…` : `You're offline — logged sets and completion will sync automatically once you're back online${j.length > 0 ? ` (${j.length} queued)` : ""}.` }),
194
+ A.isOnline && j.length > 0 && /* @__PURE__ */ m(g, {
195
+ variant: "ghost",
196
+ onClick: A.syncNow,
197
+ className: "ml-auto h-7 px-2 text-xs",
198
+ children: "Retry now"
199
+ })
200
+ ]
153
201
  }),
154
202
  /* @__PURE__ */ m(s.div, {
155
203
  initial: T ? !1 : {
@@ -166,7 +214,7 @@ function w() {
166
214
  },
167
215
  children: /* @__PURE__ */ h(_, {
168
216
  treatment: "glass",
169
- glow: Q,
217
+ glow: $,
170
218
  className: "p-6",
171
219
  children: [
172
220
  /* @__PURE__ */ m("div", {
@@ -174,71 +222,71 @@ function w() {
174
222
  children: /* @__PURE__ */ h("div", {
175
223
  className: "flex items-center gap-3",
176
224
  children: [/* @__PURE__ */ m(c, {
177
- icon: m(Q ? xe : d, { className: "h-5 w-5" }),
178
- tint: Q ? "var(--color-accent-teal)" : "var(--color-accent-primary)"
225
+ icon: m($ ? we : d, { className: "h-5 w-5" }),
226
+ tint: $ ? "var(--color-accent-teal)" : "var(--color-accent-primary)"
179
227
  }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("div", {
180
228
  className: "flex items-center gap-2",
181
- children: /* @__PURE__ */ m(re, { status: W.status })
229
+ children: /* @__PURE__ */ m(re, { status: K.status })
182
230
  }), /* @__PURE__ */ m("p", {
183
231
  className: "mt-1 text-sm text-text-secondary",
184
- children: lt
232
+ children: bt
185
233
  })] })]
186
234
  })
187
235
  }),
188
236
  /* @__PURE__ */ h("div", {
189
237
  className: "mt-5 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",
190
238
  children: [
191
- W.scheduledFor && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
239
+ K.scheduledFor && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
192
240
  className: "text-xs text-text-tertiary",
193
241
  children: "Scheduled for"
194
242
  }), /* @__PURE__ */ m("p", {
195
243
  className: "mt-0.5 text-sm font-medium text-text-primary",
196
- children: ee(W.scheduledFor)
244
+ children: ee(K.scheduledFor)
197
245
  })] }),
198
- W.startedAt && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
246
+ K.startedAt && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
199
247
  className: "text-xs text-text-tertiary",
200
248
  children: "Started"
201
249
  }), /* @__PURE__ */ m("p", {
202
250
  className: "mt-0.5 text-sm font-medium text-text-primary",
203
- children: ee(W.startedAt)
251
+ children: ee(K.startedAt)
204
252
  })] }),
205
- W.completedAt && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
253
+ K.completedAt && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
206
254
  className: "text-xs text-text-tertiary",
207
255
  children: "Completed"
208
256
  }), /* @__PURE__ */ m("p", {
209
257
  className: "mt-0.5 text-sm font-medium text-text-primary",
210
- children: ee(W.completedAt)
258
+ children: ee(K.completedAt)
211
259
  })] }),
212
- W.perceivedExertion != null && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
260
+ K.perceivedExertion != null && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
213
261
  className: "text-xs text-text-tertiary",
214
262
  children: "Perceived exertion"
215
263
  }), /* @__PURE__ */ h("p", {
216
264
  className: "mt-0.5 text-sm font-medium tabular-nums text-text-primary",
217
- children: [W.perceivedExertion, "/10 RPE"]
265
+ children: [K.perceivedExertion, "/10 RPE"]
218
266
  })] }),
219
- W.caloriesBurned > 0 && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
267
+ K.caloriesBurned > 0 && /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
220
268
  className: "text-xs text-text-tertiary",
221
269
  children: "Calories burned"
222
270
  }), /* @__PURE__ */ m("p", {
223
271
  className: "mt-0.5 text-sm font-medium tabular-nums text-text-primary",
224
- children: ne(W.caloriesBurned)
272
+ children: ne(K.caloriesBurned)
225
273
  })] })
226
274
  ]
227
275
  }),
228
- W.notes && /* @__PURE__ */ h("div", {
276
+ K.notes && /* @__PURE__ */ h("div", {
229
277
  className: "mt-5 rounded-xl bg-bg-sunken/60 p-4",
230
278
  children: [/* @__PURE__ */ m("p", {
231
279
  className: "text-xs text-text-tertiary",
232
280
  children: "Notes"
233
281
  }), /* @__PURE__ */ m("p", {
234
282
  className: "mt-1 whitespace-pre-wrap text-sm text-text-secondary",
235
- children: W.notes
283
+ children: K.notes
236
284
  })]
237
285
  })
238
286
  ]
239
287
  })
240
288
  }),
241
- Q && $e > 0 && /* @__PURE__ */ m(s.div, {
289
+ $ && lt > 0 && /* @__PURE__ */ m(s.div, {
242
290
  initial: T ? !1 : {
243
291
  opacity: 0,
244
292
  y: -6
@@ -265,7 +313,7 @@ function w() {
265
313
  children: "Resting"
266
314
  }), /* @__PURE__ */ h("p", {
267
315
  className: "text-xs tabular-nums text-text-secondary",
268
- children: [r($e), " remaining"]
316
+ children: [r(lt), " remaining"]
269
317
  })] })]
270
318
  }), /* @__PURE__ */ h("div", {
271
319
  className: "flex items-center gap-2",
@@ -273,21 +321,21 @@ function w() {
273
321
  variant: "outline",
274
322
  size: "sm",
275
323
  onClick: () => {
276
- V((e) => e && e + 15e3), H((e) => e + 15);
324
+ U((e) => e && e + 15e3), W((e) => e + 15);
277
325
  },
278
326
  children: "+15s"
279
327
  }), /* @__PURE__ */ h(g, {
280
328
  variant: "ghost",
281
329
  size: "sm",
282
330
  onClick: () => {
283
- V(null), H(0);
331
+ U(null), W(0);
284
332
  },
285
- children: [/* @__PURE__ */ m(De, { className: "h-4 w-4" }), " Skip"]
333
+ children: [/* @__PURE__ */ m(je, { className: "h-4 w-4" }), " Skip"]
286
334
  })]
287
335
  })]
288
336
  })
289
337
  }),
290
- Q && J.length > 0 && /* @__PURE__ */ m(s.div, {
338
+ $ && Y.length > 0 && /* @__PURE__ */ m(s.div, {
291
339
  initial: T ? !1 : {
292
340
  opacity: 0,
293
341
  y: 10
@@ -309,65 +357,65 @@ function w() {
309
357
  className: "mb-3 flex items-center justify-between gap-2",
310
358
  children: [/* @__PURE__ */ h("div", {
311
359
  className: "flex items-center gap-2.5",
312
- children: [/* @__PURE__ */ m(c, { icon: /* @__PURE__ */ m(Ce, { className: "h-4 w-4" }) }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("h3", {
360
+ children: [/* @__PURE__ */ m(c, { icon: /* @__PURE__ */ m(Ee, { className: "h-4 w-4" }) }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("h3", {
313
361
  className: "text-sm font-semibold text-text-primary",
314
362
  children: "Guided workout"
315
363
  }), /* @__PURE__ */ m("p", {
316
364
  className: "text-xs text-text-secondary",
317
- children: it ? "All planned exercises logged — nice work." : `Exercise ${X + 1} of ${J.length}`
365
+ children: ht ? "All planned exercises logged — nice work." : `Exercise ${Z + 1} of ${Y.length}`
318
366
  })] })]
319
367
  }), /* @__PURE__ */ h("div", {
320
368
  className: "flex items-center gap-1.5",
321
369
  children: [/* @__PURE__ */ m(g, {
322
370
  variant: "outline",
323
371
  size: "sm",
324
- onClick: () => z(Math.max(X - 1, 0)),
325
- disabled: X === 0,
372
+ onClick: () => H(Math.max(Z - 1, 0)),
373
+ disabled: Z === 0,
326
374
  "aria-label": "Previous exercise",
327
- children: /* @__PURE__ */ m(ye, { className: "h-4 w-4" })
375
+ children: /* @__PURE__ */ m(Se, { className: "h-4 w-4" })
328
376
  }), /* @__PURE__ */ m(g, {
329
377
  variant: "outline",
330
378
  size: "sm",
331
- onClick: () => z(Math.min(X + 1, J.length - 1)),
332
- disabled: X >= J.length - 1,
379
+ onClick: () => H(Math.min(Z + 1, Y.length - 1)),
380
+ disabled: Z >= Y.length - 1,
333
381
  "aria-label": "Next exercise",
334
- children: /* @__PURE__ */ m(be, { className: "h-4 w-4" })
382
+ children: /* @__PURE__ */ m(Ce, { className: "h-4 w-4" })
335
383
  })]
336
384
  })]
337
- }), Z && /* @__PURE__ */ h("div", {
385
+ }), Q && /* @__PURE__ */ h("div", {
338
386
  className: "flex flex-wrap items-center justify-between gap-3 rounded-xl bg-bg-sunken/60 p-3",
339
387
  children: [/* @__PURE__ */ h("div", { children: [
340
388
  /* @__PURE__ */ m("p", {
341
389
  className: "text-sm font-semibold text-text-primary",
342
- children: Z.name
390
+ children: Q.name
343
391
  }),
344
392
  /* @__PURE__ */ h("p", {
345
393
  className: "mt-0.5 text-xs text-text-secondary",
346
394
  children: [
347
- te(Z.muscleGroup),
395
+ te(Q.muscleGroup),
348
396
  " · ",
349
- Z.sets,
397
+ Q.sets,
350
398
  " ×",
351
399
  " ",
352
- Z.reps,
400
+ Q.reps,
353
401
  " reps",
354
- Z.targetWeight > 0 ? ` @ ${o(Z.targetWeight)}` : "",
355
- Z.restSeconds > 0 ? ` · ${r(Z.restSeconds)} rest` : ""
402
+ Q.targetWeight > 0 ? ` @ ${o(Q.targetWeight)}` : "",
403
+ Q.restSeconds > 0 ? ` · ${r(Q.restSeconds)} rest` : ""
356
404
  ]
357
405
  }),
358
406
  /* @__PURE__ */ h("p", {
359
407
  className: "mt-0.5 text-xs tabular-nums text-text-tertiary",
360
408
  children: [
361
- Y.get(Z.name) ?? 0,
409
+ X.get(Q.name) ?? 0,
362
410
  " of",
363
411
  " ",
364
- Math.max(Z.sets, 1),
412
+ Math.max(Q.sets, 1),
365
413
  " sets logged"
366
414
  ]
367
415
  })
368
416
  ] }), /* @__PURE__ */ h(g, {
369
417
  size: "sm",
370
- onClick: () => ut(Z),
418
+ onClick: () => St(Q),
371
419
  children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), " Log this exercise"]
372
420
  })]
373
421
  })]
@@ -375,7 +423,7 @@ function w() {
375
423
  }),
376
424
  /* @__PURE__ */ h(s.div, {
377
425
  className: "mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
378
- variants: T ? void 0 : Ve,
426
+ variants: T ? void 0 : qe,
379
427
  initial: T ? !1 : "hidden",
380
428
  animate: "show",
381
429
  children: [
@@ -386,7 +434,7 @@ function w() {
386
434
  className: "text-action-primary-bg",
387
435
  children: /* @__PURE__ */ m(d, { className: "h-5 w-5" })
388
436
  }),
389
- value: i(G.length),
437
+ value: i(q.length),
390
438
  label: "Total sets"
391
439
  })
392
440
  }),
@@ -395,9 +443,9 @@ function w() {
395
443
  children: /* @__PURE__ */ m(n, {
396
444
  icon: /* @__PURE__ */ m("span", {
397
445
  className: "text-action-primary-bg",
398
- children: /* @__PURE__ */ m(Ee, { className: "h-5 w-5" })
446
+ children: /* @__PURE__ */ m(ke, { className: "h-5 w-5" })
399
447
  }),
400
- value: `${i(et)} kg`,
448
+ value: `${i(ut)} kg`,
401
449
  label: "Total volume"
402
450
  })
403
451
  }),
@@ -408,7 +456,7 @@ function w() {
408
456
  className: "text-action-primary-bg",
409
457
  children: /* @__PURE__ */ m(p, { className: "h-5 w-5" })
410
458
  }),
411
- value: nt == null ? "—" : r(nt),
459
+ value: pt == null ? "—" : r(pt),
412
460
  label: "Duration"
413
461
  })
414
462
  }),
@@ -417,9 +465,9 @@ function w() {
417
465
  children: /* @__PURE__ */ m(n, {
418
466
  icon: /* @__PURE__ */ m("span", {
419
467
  className: "text-action-primary-bg",
420
- children: /* @__PURE__ */ m(xe, { className: "h-5 w-5" })
468
+ children: /* @__PURE__ */ m(we, { className: "h-5 w-5" })
421
469
  }),
422
- value: W.caloriesBurned > 0 ? ne(W.caloriesBurned) : "—",
470
+ value: K.caloriesBurned > 0 ? ne(K.caloriesBurned) : "—",
423
471
  label: "Calories burned"
424
472
  })
425
473
  })
@@ -435,28 +483,28 @@ function w() {
435
483
  }), /* @__PURE__ */ m("p", {
436
484
  className: "mt-0.5 text-sm text-text-secondary",
437
485
  children: "Every set recorded during this session, grouped by exercise."
438
- })] }), Q && /* @__PURE__ */ h(g, {
486
+ })] }), $ && /* @__PURE__ */ h(g, {
439
487
  variant: "outline",
440
488
  size: "sm",
441
- onClick: $,
489
+ onClick: xt,
442
490
  className: "shrink-0",
443
491
  children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), " Log set"]
444
492
  })]
445
- }), K.length === 0 ? /* @__PURE__ */ m(ie, {
493
+ }), J.length === 0 ? /* @__PURE__ */ m(ie, {
446
494
  illustration: "empty-data",
447
495
  icon: /* @__PURE__ */ m(d, { className: "h-10 w-10" }),
448
496
  title: "No sets logged yet",
449
- description: Q ? "Log your first set to start tracking this workout." : "No sets were recorded for this session.",
450
- action: Q ? /* @__PURE__ */ h(g, {
451
- onClick: $,
497
+ description: $ ? "Log your first set to start tracking this workout." : "No sets were recorded for this session.",
498
+ action: $ ? /* @__PURE__ */ h(g, {
499
+ onClick: xt,
452
500
  children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), " Log set"]
453
501
  }) : void 0
454
502
  }) : /* @__PURE__ */ m(s.div, {
455
503
  className: "space-y-4",
456
- variants: T ? void 0 : Ve,
504
+ variants: T ? void 0 : qe,
457
505
  initial: T ? !1 : "hidden",
458
506
  animate: "show",
459
- children: K.map((e) => {
507
+ children: J.map((e) => {
460
508
  let t = e.sets.filter((e) => e.isPersonalRecord).length;
461
509
  return /* @__PURE__ */ m(s.div, {
462
510
  variants: T ? void 0 : x,
@@ -521,7 +569,7 @@ function w() {
521
569
  }), t && e.distanceM > 0 && /* @__PURE__ */ h("span", {
522
570
  className: "inline-flex items-center gap-1 tabular-nums",
523
571
  children: [
524
- /* @__PURE__ */ m(we, { className: "h-3.5 w-3.5 text-accent" }),
572
+ /* @__PURE__ */ m(De, { className: "h-3.5 w-3.5 text-accent" }),
525
573
  i(e.distanceM),
526
574
  " m"
527
575
  ]
@@ -539,16 +587,16 @@ function w() {
539
587
  className: "mt-8",
540
588
  children: /* @__PURE__ */ m(pe, {
541
589
  entityType: "mybodyshield-session",
542
- entityId: W.id,
590
+ entityId: K.id,
543
591
  title: "Coach feedback",
544
592
  description: "Discuss form, cues and this session's results with your coach and team."
545
593
  })
546
594
  }),
547
- /* @__PURE__ */ m(Ae, {
548
- open: Ge,
549
- onOpenChange: A,
550
- children: /* @__PURE__ */ h(je, { children: [
551
- /* @__PURE__ */ h(Pe, { children: [/* @__PURE__ */ m(Fe, { children: "Log a set" }), /* @__PURE__ */ m(Me, { children: "Record reps and load for strength work, or duration and distance for cardio. The dialog stays open so you can log sets back-to-back." })] }),
595
+ /* @__PURE__ */ m(Pe, {
596
+ open: et,
597
+ onOpenChange: N,
598
+ children: /* @__PURE__ */ h(Fe, { children: [
599
+ /* @__PURE__ */ h(Re, { children: [/* @__PURE__ */ m(ze, { children: "Log a set" }), /* @__PURE__ */ m(Ie, { children: "Record reps and load for strength work, or duration and distance for cardio. The dialog stays open so you can log sets back-to-back." })] }),
552
600
  /* @__PURE__ */ h("div", {
553
601
  className: "space-y-4 px-1",
554
602
  children: [
@@ -559,13 +607,13 @@ function w() {
559
607
  children: "Exercise"
560
608
  }), /* @__PURE__ */ m(v, {
561
609
  id: "myb-set-exercise",
562
- value: j.exerciseName,
610
+ value: P.exerciseName,
563
611
  onChange: (e) => {
564
612
  let t = e.target.value;
565
- M((e) => ({
613
+ F((e) => ({
566
614
  ...e,
567
615
  exerciseName: t
568
- })), P(!1);
616
+ })), L(!1);
569
617
  },
570
618
  placeholder: "e.g. Back Squat"
571
619
  })]
@@ -583,8 +631,8 @@ function w() {
583
631
  type: "number",
584
632
  inputMode: "numeric",
585
633
  min: 1,
586
- value: j.setNumber,
587
- onChange: (e) => M((t) => ({
634
+ value: P.setNumber,
635
+ onChange: (e) => F((t) => ({
588
636
  ...t,
589
637
  setNumber: e.target.value
590
638
  })),
@@ -601,8 +649,8 @@ function w() {
601
649
  type: "number",
602
650
  inputMode: "numeric",
603
651
  min: 0,
604
- value: j.reps,
605
- onChange: (e) => M((t) => ({
652
+ value: P.reps,
653
+ onChange: (e) => F((t) => ({
606
654
  ...t,
607
655
  reps: e.target.value
608
656
  })),
@@ -620,8 +668,8 @@ function w() {
620
668
  inputMode: "decimal",
621
669
  min: 0,
622
670
  step: "0.5",
623
- value: j.weight,
624
- onChange: (e) => M((t) => ({
671
+ value: P.weight,
672
+ onChange: (e) => F((t) => ({
625
673
  ...t,
626
674
  weight: e.target.value
627
675
  })),
@@ -638,8 +686,8 @@ function w() {
638
686
  type: "number",
639
687
  inputMode: "numeric",
640
688
  min: 0,
641
- value: j.distanceM,
642
- onChange: (e) => M((t) => ({
689
+ value: P.distanceM,
690
+ onChange: (e) => F((t) => ({
643
691
  ...t,
644
692
  distanceM: e.target.value
645
693
  })),
@@ -656,8 +704,8 @@ function w() {
656
704
  type: "number",
657
705
  inputMode: "numeric",
658
706
  min: 0,
659
- value: j.durationSec,
660
- onChange: (e) => M((t) => ({
707
+ value: P.durationSec,
708
+ onChange: (e) => F((t) => ({
661
709
  ...t,
662
710
  durationSec: e.target.value
663
711
  })),
@@ -670,63 +718,75 @@ function w() {
670
718
  className: "flex items-center justify-between gap-3 rounded-xl bg-bg-sunken/60 p-3",
671
719
  children: [/* @__PURE__ */ h("div", {
672
720
  className: "flex items-center gap-2",
673
- children: [ct ? /* @__PURE__ */ m(Te, { className: "h-4 w-4 text-status-success-text" }) : /* @__PURE__ */ m(Se, { className: "h-4 w-4 text-accent" }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m(y, {
721
+ children: [yt ? /* @__PURE__ */ m(Oe, { className: "h-4 w-4 text-status-success-text" }) : /* @__PURE__ */ m(Te, { className: "h-4 w-4 text-accent" }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m(y, {
674
722
  htmlFor: "myb-set-pr",
675
723
  className: "cursor-pointer",
676
724
  children: "Personal record"
677
725
  }), /* @__PURE__ */ m("p", {
678
726
  className: "text-xs text-text-tertiary",
679
- children: U.data ? `Auto-detected against your best: ${i(U.data.reps)} × ${o(U.data.weight)}.` : j.exerciseName.trim() ? "First time logging this exercise — nothing to compare yet." : "Flag this set as a new PR."
727
+ children: G.data ? `Auto-detected against your best: ${i(G.data.reps)} × ${o(G.data.weight)}.` : P.exerciseName.trim() ? "First time logging this exercise — nothing to compare yet." : "Flag this set as a new PR."
680
728
  })] })]
681
- }), /* @__PURE__ */ m(Ie, {
729
+ }), /* @__PURE__ */ m(Be, {
682
730
  id: "myb-set-pr",
683
- checked: ct,
731
+ checked: yt,
684
732
  onCheckedChange: (e) => {
685
- P(!0), M((t) => ({
733
+ L(!0), F((t) => ({
686
734
  ...t,
687
735
  isPersonalRecord: e
688
736
  }));
689
737
  }
690
738
  })]
691
739
  }),
692
- Ke && /* @__PURE__ */ m("p", {
740
+ tt && /* @__PURE__ */ m("p", {
693
741
  className: "text-sm text-status-error-text",
694
- children: Ke
742
+ children: tt
695
743
  })
696
744
  ]
697
745
  }),
698
- /* @__PURE__ */ h(Ne, { children: [/* @__PURE__ */ m(g, {
746
+ /* @__PURE__ */ h(Le, { children: [/* @__PURE__ */ m(g, {
699
747
  variant: "outline",
700
- onClick: () => A(!1),
748
+ onClick: () => N(!1),
701
749
  children: "Done"
702
750
  }), /* @__PURE__ */ m(g, {
703
751
  onClick: async () => {
704
- N(null);
705
- let e = j.exerciseName.trim();
752
+ I(null);
753
+ let e = P.exerciseName.trim();
706
754
  if (!e) {
707
- N("Exercise name is required.");
755
+ I("Exercise name is required.");
708
756
  return;
709
757
  }
710
- try {
711
- let t = await O.mutateAsync({
712
- sessionId: E,
713
- exerciseName: e,
714
- setNumber: S(j.setNumber),
715
- reps: S(j.reps),
716
- weight: S(j.weight),
717
- distanceM: S(j.distanceM),
718
- durationSec: S(j.durationSec),
719
- isPersonalRecord: ct
720
- });
721
- M({
758
+ let t = {
759
+ exerciseName: e,
760
+ setNumber: S(P.setNumber),
761
+ reps: S(P.reps),
762
+ weight: S(P.weight),
763
+ distanceM: S(P.distanceM),
764
+ durationSec: S(P.durationSec),
765
+ isPersonalRecord: yt
766
+ }, n = (t) => {
767
+ F({
722
768
  ...C,
723
769
  exerciseName: e,
724
- setNumber: String(t.setNumber + 1)
725
- }), P(!1);
726
- let n = Z && Z.name === e && Z.restSeconds > 0 ? Z.restSeconds : Re;
727
- V(Date.now() + n * 1e3), H(n);
770
+ setNumber: String(t)
771
+ }), L(!1);
772
+ let n = Q && Q.name === e && Q.restSeconds > 0 ? Q.restSeconds : We;
773
+ U(Date.now() + n * 1e3), W(n);
774
+ };
775
+ if (!A.isOnline) {
776
+ await A.enqueueLogSet(E, t), M(), n((S(P.setNumber) ?? q.length) + 1);
777
+ return;
778
+ }
779
+ try {
780
+ n((await O.mutateAsync({
781
+ sessionId: E,
782
+ ...t
783
+ })).setNumber + 1);
728
784
  } catch (e) {
729
- N(e instanceof Error ? e.message : "Failed to log the set.");
785
+ if (He(e)) {
786
+ await A.enqueueLogSet(E, t), M(), n((S(P.setNumber) ?? q.length) + 1);
787
+ return;
788
+ }
789
+ I(e instanceof Error ? e.message : "Failed to log the set.");
730
790
  }
731
791
  },
732
792
  disabled: O.isPending,
@@ -734,17 +794,17 @@ function w() {
734
794
  })] })
735
795
  ] })
736
796
  }),
737
- /* @__PURE__ */ m(Ae, {
738
- open: Je,
739
- onOpenChange: F,
740
- children: /* @__PURE__ */ h(je, { children: [
741
- /* @__PURE__ */ h(Pe, { children: [/* @__PURE__ */ m(Fe, { children: "Complete session" }), /* @__PURE__ */ m(Me, { children: "Wrap up this workout and record how it went." })] }),
797
+ /* @__PURE__ */ m(Pe, {
798
+ open: rt,
799
+ onOpenChange: R,
800
+ children: /* @__PURE__ */ h(Fe, { children: [
801
+ /* @__PURE__ */ h(Re, { children: [/* @__PURE__ */ m(ze, { children: "Complete session" }), /* @__PURE__ */ m(Ie, { children: "Wrap up this workout and record how it went." })] }),
742
802
  /* @__PURE__ */ h("div", {
743
803
  className: "space-y-4 px-1",
744
804
  children: [
745
- G.length === 0 && /* @__PURE__ */ h("div", {
805
+ q.length === 0 && /* @__PURE__ */ h("div", {
746
806
  className: "flex items-start gap-2.5 rounded-xl border border-status-warning-text/40 bg-status-warning-bg-subtle p-3",
747
- children: [/* @__PURE__ */ m(ge, { className: "mt-0.5 h-4 w-4 shrink-0 text-status-warning-text" }), /* @__PURE__ */ h("p", {
807
+ children: [/* @__PURE__ */ m(ye, { className: "mt-0.5 h-4 w-4 shrink-0 text-status-warning-text" }), /* @__PURE__ */ h("p", {
748
808
  className: "text-sm text-text-secondary",
749
809
  children: [/* @__PURE__ */ m("span", {
750
810
  className: "font-medium text-text-primary",
@@ -764,8 +824,8 @@ function w() {
764
824
  type: "number",
765
825
  inputMode: "numeric",
766
826
  min: 0,
767
- value: I.caloriesBurned,
768
- onChange: (e) => L((t) => ({
827
+ value: z.caloriesBurned,
828
+ onChange: (e) => B((t) => ({
769
829
  ...t,
770
830
  caloriesBurned: e.target.value
771
831
  })),
@@ -782,8 +842,8 @@ function w() {
782
842
  inputMode: "numeric",
783
843
  min: 1,
784
844
  max: 10,
785
- value: I.perceivedExertion,
786
- onChange: (e) => L((t) => ({
845
+ value: z.perceivedExertion,
846
+ onChange: (e) => B((t) => ({
787
847
  ...t,
788
848
  perceivedExertion: e.target.value
789
849
  })),
@@ -796,41 +856,50 @@ function w() {
796
856
  children: [/* @__PURE__ */ m(y, {
797
857
  htmlFor: "myb-complete-notes",
798
858
  children: "Notes"
799
- }), /* @__PURE__ */ m(Le, {
859
+ }), /* @__PURE__ */ m(Ve, {
800
860
  id: "myb-complete-notes",
801
861
  rows: 3,
802
- value: I.notes,
803
- onChange: (e) => L((t) => ({
862
+ value: z.notes,
863
+ onChange: (e) => B((t) => ({
804
864
  ...t,
805
865
  notes: e.target.value
806
866
  })),
807
867
  placeholder: "How did the session feel?"
808
868
  })]
809
869
  }),
810
- Ye && /* @__PURE__ */ m("p", {
870
+ it && /* @__PURE__ */ m("p", {
811
871
  className: "text-sm text-status-error-text",
812
- children: Ye
872
+ children: it
813
873
  })
814
874
  ]
815
875
  }),
816
- /* @__PURE__ */ h(Ne, { children: [/* @__PURE__ */ m(g, {
876
+ /* @__PURE__ */ h(Le, { children: [/* @__PURE__ */ m(g, {
817
877
  variant: "outline",
818
- onClick: () => F(!1),
878
+ onClick: () => R(!1),
819
879
  children: "Cancel"
820
880
  }), /* @__PURE__ */ m(g, {
821
881
  onClick: async () => {
822
- R(null);
882
+ V(null);
883
+ let e = {
884
+ caloriesBurned: S(z.caloriesBurned),
885
+ perceivedExertion: S(z.perceivedExertion),
886
+ notes: z.notes.trim() ? z.notes.trim() : void 0
887
+ };
888
+ if (!A.isOnline) {
889
+ await A.enqueueCompleteSession(E, e), M(), R(!1);
890
+ return;
891
+ }
823
892
  try {
824
893
  await k.mutateAsync({
825
894
  id: E,
826
- input: {
827
- caloriesBurned: S(I.caloriesBurned),
828
- perceivedExertion: S(I.perceivedExertion),
829
- notes: I.notes.trim() ? I.notes.trim() : void 0
830
- }
831
- }), F(!1);
832
- } catch (e) {
833
- R(e instanceof Error ? e.message : "Failed to complete the session.");
895
+ input: e
896
+ }), R(!1);
897
+ } catch (t) {
898
+ if (He(t)) {
899
+ await A.enqueueCompleteSession(E, e), M(), R(!1);
900
+ return;
901
+ }
902
+ V(t instanceof Error ? t.message : "Failed to complete the session.");
834
903
  }
835
904
  },
836
905
  disabled: k.isPending,