quantum-component-library 0.0.1 → 1.0.0-alpha.0

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 (119) hide show
  1. package/README.md +115 -69
  2. package/dist/babel-vendor-BOM86iTb.js +221 -0
  3. package/dist/babel-vendor-cKvSpnBp.cjs +3 -0
  4. package/dist/components/activity-list/index.d.ts +19 -0
  5. package/dist/components/copy-activity-form/index.d.ts +30 -0
  6. package/dist/components/copy-activity-form/index.stories.d.ts +6 -0
  7. package/dist/components/copy-module-form/index.d.ts +30 -0
  8. package/dist/components/copy-module-form/index.stories.d.ts +6 -0
  9. package/dist/components/index.d.ts +8 -0
  10. package/dist/components/module-form/index.d.ts +15 -0
  11. package/dist/components/parameter-edit-list/index.d.ts +13 -0
  12. package/dist/components/parameter-edit-select/index.d.ts +16 -0
  13. package/dist/components/test-filter-panel/index.d.ts +7 -0
  14. package/dist/components/ui/form/index.d.ts +4 -0
  15. package/dist/components/ui/form/label/index.d.ts +4 -0
  16. package/dist/components/ui/form/list-order-input/index.d.ts +14 -0
  17. package/dist/components/ui/form/radio-buttons/index.d.ts +16 -0
  18. package/dist/components/ui/form/range-slider-input/index.d.ts +17 -0
  19. package/dist/components/ui/index.d.ts +2 -1
  20. package/dist/components/ui/tag-group/index.d.ts +7 -0
  21. package/dist/components/upsert-activity-form/index.d.ts +18 -0
  22. package/dist/components/upsert-activity-form/index.stories.d.ts +6 -0
  23. package/dist/components/upsert-module-form/index.d.ts +17 -0
  24. package/dist/components/upsert-module-form/index.stories.d.ts +6 -0
  25. package/dist/components.cjs +13 -0
  26. package/dist/components.js +2078 -0
  27. package/dist/dnd-core-vendor-bgjKfDi6.cjs +1 -0
  28. package/dist/dnd-core-vendor-q7mfiuVu.js +750 -0
  29. package/dist/generated/fragment-masking.d.ts +19 -0
  30. package/dist/generated/gql.d.ts +271 -0
  31. package/dist/generated/graphql.d.ts +2326 -0
  32. package/dist/generated/index.d.ts +2 -0
  33. package/dist/generated-ChsGaiYd.cjs +1 -0
  34. package/dist/generated-GfcSQz21.js +65 -0
  35. package/dist/graphql/fragments/actions.d.ts +1 -0
  36. package/dist/graphql/fragments/analysis.d.ts +12 -0
  37. package/dist/graphql/fragments/groups.d.ts +1 -0
  38. package/dist/graphql/fragments/index.d.ts +6 -0
  39. package/dist/graphql/fragments/modules.d.ts +3 -0
  40. package/dist/graphql/fragments/playback.d.ts +11 -0
  41. package/dist/graphql/fragments/session.d.ts +3 -0
  42. package/dist/graphql/index.d.ts +3 -0
  43. package/dist/graphql/mutations/actions.d.ts +7 -0
  44. package/dist/graphql/mutations/index.d.ts +2 -0
  45. package/dist/graphql/mutations/modules.d.ts +13 -0
  46. package/dist/graphql/queries/actions.d.ts +19 -0
  47. package/dist/graphql/queries/groups.d.ts +9 -0
  48. package/dist/graphql/queries/index.d.ts +3 -0
  49. package/dist/graphql/queries/modules.d.ts +9 -0
  50. package/dist/graphql-CqPvuCvr.cjs +679 -0
  51. package/dist/graphql-DiUes2Np.js +735 -0
  52. package/dist/graphql-vendor-JsvuUrRs.cjs +14 -0
  53. package/dist/graphql-vendor-YnA_qhJA.js +669 -0
  54. package/dist/hooks.cjs +1 -0
  55. package/dist/hooks.js +84 -0
  56. package/dist/index.cjs +1 -0
  57. package/dist/index.d.ts +6 -1
  58. package/dist/index.js +132 -3159
  59. package/dist/lib/hooks/index.d.ts +7 -0
  60. package/dist/lib/hooks/use-graphql-client.d.ts +5 -0
  61. package/dist/lib/hooks/use-joints-for-limb-ids.d.ts +2 -0
  62. package/dist/lib/hooks/use-joints-for-sensor-locations.d.ts +2 -0
  63. package/dist/lib/hooks/use-limbs-for-sensor-locations.d.ts +2 -0
  64. package/dist/lib/hooks/use-part-options-for-joints.d.ts +3 -0
  65. package/dist/lib/hooks/use-part-options-for-limbs.d.ts +3 -0
  66. package/dist/lib/hooks/use-part-options-for-sensor-locations.d.ts +3 -0
  67. package/dist/lib/services/human.d.ts +69 -0
  68. package/dist/lib/services/index.d.ts +1 -0
  69. package/dist/lib/services/rom.json.d.ts +226 -0
  70. package/dist/lib/types/activity.d.ts +19 -0
  71. package/dist/lib/types/analysis.d.ts +115 -0
  72. package/dist/lib/types/athlete.d.ts +8 -0
  73. package/dist/lib/types/catalog.d.ts +35 -0
  74. package/dist/lib/types/error.d.ts +4 -0
  75. package/dist/lib/types/human-part.d.ts +23 -0
  76. package/dist/lib/types/human.d.ts +147 -0
  77. package/dist/lib/types/index.d.ts +14 -0
  78. package/dist/lib/types/parameters.d.ts +10 -0
  79. package/dist/lib/types/playback.d.ts +20 -0
  80. package/dist/lib/types/recording.d.ts +5 -0
  81. package/dist/lib/types/sensor-info.d.ts +105 -0
  82. package/dist/lib/types/threshold.d.ts +30 -0
  83. package/dist/lib/types/tracking.d.ts +82 -0
  84. package/dist/lib/types/upload.d.ts +28 -0
  85. package/dist/lib/utils/conversion.d.ts +27 -0
  86. package/dist/lib/utils/index.d.ts +6 -0
  87. package/dist/lib/utils/memo.d.ts +7 -0
  88. package/dist/lib/utils/parameters.d.ts +6 -0
  89. package/dist/lib/utils/text.d.ts +2 -0
  90. package/dist/lodash-vendor-D5A6v3mw.cjs +1 -0
  91. package/dist/lodash-vendor-Dz4vW7Gd.js +1120 -0
  92. package/dist/other-CmpBz5tg.js +15 -0
  93. package/dist/other-TR0ap-t4.cjs +1 -0
  94. package/dist/providers/index.d.ts +1 -0
  95. package/dist/providers/quantum-library-provider.d.ts +8 -0
  96. package/dist/providers.cjs +1 -0
  97. package/dist/providers.js +11 -0
  98. package/dist/quantum-component-library.css +1 -0
  99. package/dist/react-dnd-vendor-BWqlt2EC.cjs +2 -0
  100. package/dist/react-dnd-vendor-BZs2igAJ.js +1375 -0
  101. package/dist/react-icons-vendor-D2s8zw9h.cjs +1 -0
  102. package/dist/react-icons-vendor-TETORdU9.js +119 -0
  103. package/dist/react-select-vendor-By3h6JjH.cjs +4 -0
  104. package/dist/react-select-vendor-eBH7yy3O.js +2801 -0
  105. package/dist/services.cjs +1 -0
  106. package/dist/services.js +810 -0
  107. package/dist/styled-components-vendor-Bvwhddj9.js +1154 -0
  108. package/dist/styled-components-vendor-D09ATioU.cjs +60 -0
  109. package/dist/types.cjs +1 -0
  110. package/dist/types.js +316 -0
  111. package/dist/utils.cjs +1 -0
  112. package/dist/utils.js +128 -0
  113. package/dist/vendor-BeqUcSbw.cjs +45 -0
  114. package/dist/vendor-DvX9OX-j.js +7876 -0
  115. package/package.json +118 -60
  116. package/dist/components/ui/button.d.ts +0 -10
  117. package/dist/index.css +0 -1
  118. package/dist/index.umd.cjs +0 -22
  119. package/dist/lib/utils.d.ts +0 -2
@@ -0,0 +1,2078 @@
1
+ import { j as e, u as ls } from "./vendor-DvX9OX-j.js";
2
+ import { Flex as le, InputGroup as Pe, InputLeftElement as as, Icon as We, Input as ye, FormLabel as $e, Box as B, TableContainer as Qe, Table as qe, Thead as He, Tr as Ce, Th as ie, Tbody as Ye, Td as re, ButtonGroup as ce, Tooltip as Je, Button as $, RangeSlider as cs, RangeSliderMark as Ae, Text as M, RangeSliderTrack as ds, RangeSliderFilledTrack as us, RangeSliderThumb as _e, Select as ze, NumberInput as Ue, NumberInputField as Ge, HStack as K, Tag as de, Checkbox as hs, useToast as Ke, VStack as V, FormControl as G, Alert as be, AlertIcon as ve, Spinner as Xe, useDisclosure as ms, Modal as gs, ModalOverlay as ps, ModalContent as xs, ModalHeader as fs, ModalCloseButton as js, ModalBody as bs, ModalFooter as vs, IconButton as ys, Textarea as Ie } from "@chakra-ui/react";
3
+ import { useMemo as D, useState as F, useCallback as O, useRef as Cs, useEffect as Y, memo as Se } from "react";
4
+ import { d as Ze } from "./styled-components-vendor-Bvwhddj9.js";
5
+ import { s as se, y as Ss } from "./react-select-vendor-eBH7yy3O.js";
6
+ import { F as ws, a as Ms } from "./react-icons-vendor-TETORdU9.js";
7
+ import { useQuery as ee, useMutation as oe, useClient as As } from "urql";
8
+ import { g as W, T as je, S as k, A as ge, a as Te } from "./generated-GfcSQz21.js";
9
+ import { G as Ve, a as Is, C as De, A as ae, b as es, c as Ts, d as ss, e as Re, M as ts, f as Le, U as Ns, g as Os, S as Rs, h as Ls, i as Fs, j as Ds, k as ks, l as Es, m as Ps } from "./graphql-DiUes2Np.js";
10
+ import { D as _s, H as zs, u as Us, a as Gs } from "./react-dnd-vendor-BZs2igAJ.js";
11
+ import { getSegmentNameWithPlane as ns, getJointNameWithPlane as is, getJointAngleDirectionName as Bs, getSegmentAngleDirectionName as Ws, getNormativeJointRange as $s } from "./services.js";
12
+ import { availablePlanes as Be, getAnalysisPartIdNoSide as pe } from "./types.js";
13
+ import { thresholdsToParameters as Qs, parametersToThresholds as Ne, cn as qs } from "./utils.js";
14
+ import { usePartOptionsForSensorLocations as Hs } from "./hooks.js";
15
+ const Ys = ({
16
+ setSearch: t,
17
+ actions: s,
18
+ updateUseCases: o
19
+ }) => {
20
+ const u = D(
21
+ () => s?.flatMap((l) => l.useCases).filter((l, a, m) => m.findIndex((f) => f.id === l.id) === a).map((l) => ({
22
+ label: l.name,
23
+ value: l.id
24
+ })) || [],
25
+ [s]
26
+ );
27
+ return /* @__PURE__ */ e.jsxs(le, { width: "100%", alignContent: "space-evenly", gap: 4, children: [
28
+ /* @__PURE__ */ e.jsxs(Pe, { size: "md", children: [
29
+ /* @__PURE__ */ e.jsx(as, { children: /* @__PURE__ */ e.jsx(We, { as: ws, color: "gray.300" }) }),
30
+ /* @__PURE__ */ e.jsx(
31
+ ye,
32
+ {
33
+ placeholder: "Search by name...",
34
+ maxW: "30rem",
35
+ onChange: (l) => t(l.target.value)
36
+ }
37
+ )
38
+ ] }),
39
+ /* @__PURE__ */ e.jsx(Pe, { size: "md", children: /* @__PURE__ */ e.jsx(
40
+ se,
41
+ {
42
+ size: "md",
43
+ chakraStyles: {
44
+ container: (l) => ({
45
+ ...l,
46
+ width: "100%"
47
+ })
48
+ },
49
+ menuPortalTarget: document.body,
50
+ placeholder: "Filter use case",
51
+ isMulti: !0,
52
+ options: u,
53
+ onChange: (l) => o(l.map((a) => a.value))
54
+ }
55
+ ) })
56
+ ] });
57
+ }, te = ({
58
+ children: t
59
+ }) => /* @__PURE__ */ e.jsx($e, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: t }), Js = ({ value: t, onChange: s }) => {
60
+ const o = F(
61
+ () => Math.random().toString(36).substring(2, 15)
62
+ )[0], u = O(
63
+ (l, a) => {
64
+ s((m) => {
65
+ const f = [...m], [j] = f.splice(l, 1);
66
+ return f.splice(a, 0, j), f;
67
+ });
68
+ },
69
+ [s]
70
+ );
71
+ return /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(_s, { backend: zs, children: /* @__PURE__ */ e.jsx(Qe, { children: /* @__PURE__ */ e.jsxs(qe, { variant: "simple", size: "md", children: [
72
+ /* @__PURE__ */ e.jsx(He, { children: /* @__PURE__ */ e.jsxs(Ce, { children: [
73
+ /* @__PURE__ */ e.jsx(ie, { children: "Order" }),
74
+ /* @__PURE__ */ e.jsx(ie, { children: "Name" })
75
+ ] }) }),
76
+ /* @__PURE__ */ e.jsx(Ye, { children: t.map((l, a) => /* @__PURE__ */ e.jsx(
77
+ Ks,
78
+ {
79
+ listKey: o,
80
+ index: a,
81
+ id: l.id,
82
+ name: l.name,
83
+ move: u
84
+ },
85
+ l.id
86
+ )) })
87
+ ] }) }) }) });
88
+ }, Ks = ({ listKey: t, index: s, id: o, name: u, move: l }) => {
89
+ const a = Cs(null), [{ handlerId: m }, f] = Us({
90
+ accept: t,
91
+ collect: (x) => ({
92
+ handlerId: x.getHandlerId()?.toString() ?? ""
93
+ }),
94
+ hover: (x, A) => {
95
+ if (!a.current)
96
+ return;
97
+ const d = x.index, r = s;
98
+ if (d === r)
99
+ return;
100
+ const S = a.current?.getBoundingClientRect(), b = (S.bottom - S.top) / 2, h = A.getClientOffset().y - S.top;
101
+ d < r && h < b || d > r && h > b || (l(d, r), x.index = r);
102
+ }
103
+ }), [{ isDragging: j }, C] = Gs({
104
+ type: t,
105
+ item: () => ({ id: o, index: s }),
106
+ collect: (x) => ({
107
+ isDragging: x.isDragging()
108
+ })
109
+ }), I = j ? 0.6 : 1, p = j ? "grabbing" : "grab";
110
+ return C(f(a)), /* @__PURE__ */ e.jsxs(Ce, { ref: a, style: { opacity: I, cursor: p }, "data-handler-id": m, children: [
111
+ /* @__PURE__ */ e.jsx(re, { children: s + 1 }),
112
+ /* @__PURE__ */ e.jsx(re, { children: u })
113
+ ] });
114
+ }, Fe = ({
115
+ items: t,
116
+ onChange: s,
117
+ selectedItem: o,
118
+ isDisabled: u,
119
+ selectedProps: l,
120
+ buttonProps: a
121
+ }) => {
122
+ const m = (j) => j === o || j.value === o, f = (j) => m(j) ? { ...a, ...l } : a;
123
+ return /* @__PURE__ */ e.jsx(ce, { isAttached: !0, isDisabled: u, children: t.map((j, C) => /* @__PURE__ */ e.jsx(
124
+ Je,
125
+ {
126
+ label: j.tooltip,
127
+ openDelay: 50,
128
+ closeDelay: 200,
129
+ placement: "top",
130
+ visibility: j.tooltip ? "visible" : "hidden",
131
+ hasArrow: !0,
132
+ children: /* @__PURE__ */ e.jsx(
133
+ $,
134
+ {
135
+ onClick: () => m(j) ? null : s(j, C),
136
+ isDisabled: j.disabled,
137
+ ...f(j),
138
+ children: j.label
139
+ }
140
+ )
141
+ },
142
+ C
143
+ )) });
144
+ }, xe = (t, s) => s < 0 ? -1 * Math.abs(t) : Math.abs(t), Xs = ({
145
+ isReversed: t,
146
+ min: s,
147
+ max: o,
148
+ value: u,
149
+ onChange: l,
150
+ inputProps: a,
151
+ size: m,
152
+ zeroMarker: f,
153
+ formatValue: j,
154
+ valueLabel: C,
155
+ positiveNegativeLabels: I,
156
+ isDisabled: p,
157
+ ...x
158
+ }) => {
159
+ const [A, d] = F([void 0, void 0]), r = A[0], S = A[1], b = f && s < -5 && o > 5, v = Number(u?.[0] ?? S ?? s) > 0 ? 1 : -1, h = Number(u?.[1] ?? S ?? o) < 0 ? -1 : 1, g = I?.[0] === I?.[1], w = u?.[0], P = u?.[1];
160
+ Y(() => {
161
+ w !== void 0 && P !== void 0 && d([w.toFixed(0), P.toFixed(0)]);
162
+ }, [w, P, d]);
163
+ const T = O(
164
+ ([i, y]) => {
165
+ i < y && d([i.toFixed(0), y.toFixed(0)]);
166
+ },
167
+ [d]
168
+ ), q = O(
169
+ ([i, y]) => {
170
+ i < y && l([i, y]);
171
+ },
172
+ [l]
173
+ ), R = O(() => {
174
+ d(([i, y]) => {
175
+ const L = isNaN(Number(i)) ? s : Number(i), _ = isNaN(Number(y)) ? o : Number(y), H = xe(Number(L), v), E = xe(Number(_), h), J = v < 0 ? Math.max(H, s) : Math.min(H, o), z = h < 0 ? Math.max(E, s) : Math.min(E, o);
176
+ return J > z ? (l([z, J]), [z.toFixed(0), J.toFixed(0)]) : (l([J, z]), [J.toFixed(0), z.toFixed(0)]);
177
+ });
178
+ }, [l, d, v, h, s, o]), Q = O(
179
+ (i) => {
180
+ const y = i === "" || isNaN(Number(i)) ? i : xe(Number(i), v);
181
+ d(([L, _]) => [y.toString(), _]);
182
+ },
183
+ [d, v]
184
+ ), U = O(
185
+ (i) => {
186
+ const y = i === "" || isNaN(Number(i)) ? i : xe(Number(i), h);
187
+ d(([L, _]) => [L, y.toString()]);
188
+ },
189
+ [d, h]
190
+ ), c = D(
191
+ () => m === "xs" ? "0.75rem" : void 0,
192
+ [m]
193
+ ), n = O(
194
+ (i, y) => {
195
+ const L = Number(y.target.value);
196
+ if (!r || !S || ![-1, 1].includes(L))
197
+ return;
198
+ const _ = (J) => L < 0 ? -1 * Math.abs(J) : Math.abs(J), H = i ? _(Number(r)) : Number(r), E = i ? Number(S) : _(Number(S));
199
+ H > E ? l([E, H]) : l([H, E]);
200
+ },
201
+ [r, S, l]
202
+ );
203
+ return /* @__PURE__ */ e.jsxs(le, { direction: "column", ...x, children: [
204
+ /* @__PURE__ */ e.jsx(B, { pt: "1em", mb: "-0.5em", children: /* @__PURE__ */ e.jsxs(
205
+ cs,
206
+ {
207
+ "aria-label": ["min", "max"],
208
+ isReversed: t,
209
+ value: [Number(r ?? s), Number(S ?? o)],
210
+ max: o,
211
+ min: s,
212
+ minStepsBetweenThumbs: 3,
213
+ step: 1,
214
+ onChange: T,
215
+ onChangeEnd: q,
216
+ isDisabled: p,
217
+ children: [
218
+ /* @__PURE__ */ e.jsx(Ae, { value: s, top: "-1em", children: /* @__PURE__ */ e.jsx(
219
+ M,
220
+ {
221
+ fontSize: m ?? "sm",
222
+ fontWeight: "semibold",
223
+ whiteSpace: "nowrap",
224
+ children: j ? j?.(s) : s
225
+ }
226
+ ) }),
227
+ /* @__PURE__ */ e.jsx(Ae, { value: o, top: "-1em", children: /* @__PURE__ */ e.jsx(
228
+ M,
229
+ {
230
+ fontSize: m ?? "sm",
231
+ fontWeight: "semibold",
232
+ style: { transform: "translateX(-100%)" },
233
+ whiteSpace: "nowrap",
234
+ children: j ? j(o) : o
235
+ }
236
+ ) }),
237
+ b && /* @__PURE__ */ e.jsxs(Ae, { value: 0, top: "-1em", pos: "relative", children: [
238
+ /* @__PURE__ */ e.jsx(M, { fontSize: m, fontWeight: "semibold", children: j?.(0) ?? "0" }),
239
+ /* @__PURE__ */ e.jsx(Zs, {})
240
+ ] }),
241
+ /* @__PURE__ */ e.jsx(ds, { children: /* @__PURE__ */ e.jsx(us, {}) }),
242
+ /* @__PURE__ */ e.jsx(_e, { index: 0, w: c, h: c }),
243
+ /* @__PURE__ */ e.jsx(_e, { index: 1, w: c, h: c })
244
+ ]
245
+ }
246
+ ) }),
247
+ C && /* @__PURE__ */ e.jsxs(
248
+ le,
249
+ {
250
+ direction: t ? "row-reverse" : "row",
251
+ justifyContent: "space-between",
252
+ children: [
253
+ /* @__PURE__ */ e.jsx(
254
+ M,
255
+ {
256
+ fontSize: m ?? "sm",
257
+ fontWeight: "semibold",
258
+ whiteSpace: "nowrap",
259
+ children: C(s)
260
+ }
261
+ ),
262
+ /* @__PURE__ */ e.jsx(
263
+ M,
264
+ {
265
+ fontSize: m ?? "sm",
266
+ fontWeight: "semibold",
267
+ whiteSpace: "nowrap",
268
+ children: C(o)
269
+ }
270
+ )
271
+ ]
272
+ }
273
+ ),
274
+ /* @__PURE__ */ e.jsxs(
275
+ le,
276
+ {
277
+ direction: t ? "row-reverse" : "row",
278
+ justifyContent: "center",
279
+ alignItems: "center",
280
+ gap: "0.125em",
281
+ children: [
282
+ I && /* @__PURE__ */ e.jsxs(
283
+ ze,
284
+ {
285
+ width: "auto",
286
+ size: m,
287
+ fontWeight: "bold",
288
+ value: v,
289
+ onChange: (i) => n(!0, i),
290
+ isDisabled: g || p,
291
+ children: [
292
+ /* @__PURE__ */ e.jsx("option", { value: -1, children: I[0] }),
293
+ /* @__PURE__ */ e.jsx("option", { value: 1, children: I[1] })
294
+ ]
295
+ }
296
+ ),
297
+ /* @__PURE__ */ e.jsx(
298
+ Ue,
299
+ {
300
+ precision: 0,
301
+ size: m ?? "sm",
302
+ min: 0,
303
+ max: v < 0 ? Math.abs(s) : P ?? o,
304
+ value: r === "" ? "" : Math.abs(Number(r ?? s)),
305
+ onChange: Q,
306
+ onBlur: R,
307
+ borderWidth: 1,
308
+ borderRadius: 3,
309
+ borderColor: "#ccc",
310
+ isDisabled: p,
311
+ ...a,
312
+ children: /* @__PURE__ */ e.jsx(
313
+ Ge,
314
+ {
315
+ backgroundColor: "#fff",
316
+ paddingRight: 0,
317
+ width: "4em"
318
+ }
319
+ )
320
+ }
321
+ ),
322
+ /* @__PURE__ */ e.jsx(
323
+ Ue,
324
+ {
325
+ size: m ?? "sm",
326
+ min: 0,
327
+ max: h < 0 ? Math.abs(w ?? s) : o,
328
+ precision: 0,
329
+ value: S === "" ? "" : Math.abs(Number(S ?? o)),
330
+ onChange: U,
331
+ onBlur: R,
332
+ borderWidth: 1,
333
+ borderRadius: 3,
334
+ borderColor: "#ccc",
335
+ isDisabled: p,
336
+ ...a,
337
+ children: /* @__PURE__ */ e.jsx(
338
+ Ge,
339
+ {
340
+ backgroundColor: "#fff",
341
+ paddingRight: 0,
342
+ width: "4em"
343
+ }
344
+ )
345
+ }
346
+ ),
347
+ I && /* @__PURE__ */ e.jsxs(
348
+ ze,
349
+ {
350
+ width: "auto",
351
+ size: m,
352
+ fontWeight: "bold",
353
+ value: h,
354
+ onChange: (i) => n(!1, i),
355
+ isDisabled: g || p,
356
+ children: [
357
+ /* @__PURE__ */ e.jsx("option", { value: -1, children: I[0] }),
358
+ /* @__PURE__ */ e.jsx("option", { value: 1, children: I[1] })
359
+ ]
360
+ }
361
+ )
362
+ ]
363
+ }
364
+ )
365
+ ] });
366
+ }, Zs = Ze(B)`
367
+ position: absolute;
368
+ width: 2px;
369
+ height: 1em;
370
+ top: 90%;
371
+ left: 20%;
372
+ background-color: var(--chakra-colors-gray-300);
373
+ `, Vs = ({ tags: t, containerProps: s, ...o }) => /* @__PURE__ */ e.jsx(K, { ...s, children: t.map((u, l) => /* @__PURE__ */ e.jsx(de, { ...o, children: u }, l)) }), et = new ls({}), st = (t, s) => {
374
+ if (!s || !s.trim().length)
375
+ return t;
376
+ const o = t.map((l) => l.name ?? "");
377
+ return et.filter(o, s)?.map((l) => t[l]) ?? [];
378
+ }, tt = (t, s) => !s || s.length == 0 ? t : t.filter(
379
+ (o) => o.useCases.some((u) => s.includes(u.id))
380
+ ), nt = ({
381
+ actions: t,
382
+ totalActions: s,
383
+ onCreate: o,
384
+ onDelete: u,
385
+ onEdit: l,
386
+ onSelected: a,
387
+ onDuplicate: m,
388
+ disableMultiSelect: f,
389
+ disableDelete: j,
390
+ disableEdit: C,
391
+ disableCreate: I,
392
+ tableProps: p,
393
+ ...x
394
+ }) => {
395
+ const [A, d] = F(""), [r, S] = F(), b = D(() => {
396
+ if (!t)
397
+ return;
398
+ const g = st(t, A);
399
+ return tt(g, r).sort((P, T) => P.name.localeCompare(T.name));
400
+ }, [t, A, r]), v = O(() => {
401
+ if (!u)
402
+ return;
403
+ const g = t.filter((w) => w.selected).map((w) => w.id);
404
+ u(g);
405
+ }, [t, u]), h = O(() => {
406
+ if (!m)
407
+ return;
408
+ const g = t.filter((w) => w.selected);
409
+ m(g.map((w) => w.id)), a && g.forEach((w) => a(w, !1));
410
+ }, [t, m, a]);
411
+ return /* @__PURE__ */ e.jsxs(B, { ...x, children: [
412
+ /* @__PURE__ */ e.jsxs(le, { alignContent: "space-between", gap: 4, children: [
413
+ (o || u || m) && /* @__PURE__ */ e.jsxs(ce, { mb: "1rem", gap: 4, children: [
414
+ o && /* @__PURE__ */ e.jsx(
415
+ $,
416
+ {
417
+ isDisabled: !o || I,
418
+ colorScheme: "blackAlpha",
419
+ backgroundColor: "gray.700",
420
+ onClick: o,
421
+ children: "Create New Activity"
422
+ }
423
+ ),
424
+ u && !f && /* @__PURE__ */ e.jsx(
425
+ $,
426
+ {
427
+ colorScheme: "gray",
428
+ isDisabled: t.length <= 0 || !u || j,
429
+ onClick: v,
430
+ children: "Delete Selected"
431
+ }
432
+ ),
433
+ m && !f && /* @__PURE__ */ e.jsx(
434
+ $,
435
+ {
436
+ colorScheme: "gray",
437
+ isDisabled: t.length <= 0,
438
+ onClick: h,
439
+ children: "Duplicate Selected"
440
+ }
441
+ )
442
+ ] }),
443
+ /* @__PURE__ */ e.jsx(
444
+ Ys,
445
+ {
446
+ setSearch: d,
447
+ actions: t,
448
+ updateUseCases: S
449
+ }
450
+ )
451
+ ] }),
452
+ /* @__PURE__ */ e.jsx(Qe, { mr: "2rem", overflowX: "hidden", ...p, children: /* @__PURE__ */ e.jsxs(qe, { size: "md", variant: "simple", children: [
453
+ /* @__PURE__ */ e.jsx(He, { position: "sticky", top: 0, bg: "white", zIndex: 1, children: /* @__PURE__ */ e.jsxs(Ce, { children: [
454
+ /* @__PURE__ */ e.jsxs(ie, { fontWeight: "normal", children: [
455
+ "(showing ",
456
+ b?.length ?? 0,
457
+ " of",
458
+ " ",
459
+ s ?? t.length,
460
+ ")"
461
+ ] }),
462
+ /* @__PURE__ */ e.jsx(ie, { children: "Name" }),
463
+ /* @__PURE__ */ e.jsx(ie, { children: "Sensor Count" }),
464
+ /* @__PURE__ */ e.jsx(ie, { children: "Use Case" }),
465
+ /* @__PURE__ */ e.jsx(ie, {})
466
+ ] }) }),
467
+ /* @__PURE__ */ e.jsx(Ye, { children: b?.map((g) => /* @__PURE__ */ e.jsxs(
468
+ it,
469
+ {
470
+ disableMultiSelect: f,
471
+ selected: g.selected,
472
+ title: f && g.selected ? "This activity is selected. Click it again to deselect." : void 0,
473
+ bg: f && g.selected ? "gray.200" : void 0,
474
+ onClick: () => f ? a?.(g, !g.selected) : void 0,
475
+ children: [
476
+ /* @__PURE__ */ e.jsx(re, { children: /* @__PURE__ */ e.jsxs(le, { children: [
477
+ a && !f && /* @__PURE__ */ e.jsx(
478
+ hs,
479
+ {
480
+ isChecked: g.selected,
481
+ onChange: (w) => a(g, w.target.checked)
482
+ }
483
+ ),
484
+ l && /* @__PURE__ */ e.jsx(
485
+ $,
486
+ {
487
+ disabled: C,
488
+ ml: "1em",
489
+ size: "sm",
490
+ variant: "link",
491
+ colorScheme: "blue",
492
+ onClick: () => l(g.id),
493
+ children: "edit"
494
+ }
495
+ )
496
+ ] }) }),
497
+ /* @__PURE__ */ e.jsx(re, { whiteSpace: "break-spaces", children: g.name }),
498
+ /* @__PURE__ */ e.jsx(re, { maxW: "20rem", children: g.sensorLocations.length }),
499
+ /* @__PURE__ */ e.jsx(re, { maxW: "20rem", children: /* @__PURE__ */ e.jsx(
500
+ Vs,
501
+ {
502
+ containerProps: { flexWrap: "wrap" },
503
+ tags: g.useCases?.map((w) => w.name) ?? []
504
+ }
505
+ ) })
506
+ ]
507
+ },
508
+ g.id
509
+ )) })
510
+ ] }) })
511
+ ] });
512
+ }, it = Ze(Ce)`
513
+ &:hover {
514
+ background-color: ${(t) => t.disableMultiSelect && !t.selected ? "#f7f7f7" : void 0};
515
+ }
516
+ cursor: ${(t) => t.disableMultiSelect ? "pointer" : "default"};
517
+ `, Ot = ({
518
+ onSave: t,
519
+ onCancel: s,
520
+ onError: o,
521
+ hideButtons: u = !1,
522
+ setButtonDisabled: l,
523
+ setButtonOnClick: a,
524
+ quantumOwned: m
525
+ }) => {
526
+ const f = Ke(), [j, C] = F(""), [I, p] = F([]), [x, A] = F(!1), [d] = ee({
527
+ query: Ve
528
+ }), [r] = ee({
529
+ query: Is,
530
+ variables: { groupId: j },
531
+ pause: !j
532
+ // Only run when group is selected
533
+ }), [, S] = oe(De), b = D(() => d.data?.groups ? d.data.groups.map(
534
+ (c) => W(es, c)
535
+ ) : [], [d.data]), v = D(() => r.data ? r.data.actions.map(
536
+ (n) => W(ae, n)
537
+ ) : [], [r.data]), h = D(() => v.filter(
538
+ (c) => I.includes(c.id)
539
+ ), [v, I]), g = O(
540
+ (c) => {
541
+ const n = c?.value || "";
542
+ C(n), p([]);
543
+ },
544
+ []
545
+ ), w = O(
546
+ (c) => {
547
+ const n = c.map((i) => i.value);
548
+ p(n);
549
+ },
550
+ []
551
+ ), P = O(async () => {
552
+ if (A(!0), !h.length) {
553
+ const c = new Error("No activities selected for copying");
554
+ o?.(c), A(!1);
555
+ return;
556
+ }
557
+ try {
558
+ const c = [];
559
+ let n = 0;
560
+ for (const i of h)
561
+ try {
562
+ const y = {
563
+ ...i,
564
+ name: `${i.name} (Copy)`,
565
+ // Add "(Copy)" suffix to distinguish
566
+ description: i.description || void 0,
567
+ instructionsPointOfInterest: i.instructionsPointOfInterest || void 0,
568
+ instructionsMovementReport: i.instructionsMovementReport || void 0,
569
+ laterality: i.laterality,
570
+ activityKind: i.activityKind,
571
+ sensorLocations: i.sensorLocations,
572
+ thresholds: i.thresholds.map((_) => ({
573
+ ..._,
574
+ id: void 0
575
+ })),
576
+ quantumOwned: m,
577
+ id: void 0
578
+ }, L = await S({ fields: y });
579
+ if (L.error)
580
+ throw new Error(L.error.message);
581
+ if (L.data?.createAction) {
582
+ const _ = W(
583
+ ae,
584
+ L.data.createAction
585
+ );
586
+ c.push(_);
587
+ }
588
+ } catch (y) {
589
+ console.error(
590
+ `Failed to copy activity "${i.name}":`,
591
+ y
592
+ ), n++;
593
+ }
594
+ if (c.length > 0) {
595
+ const i = c.length, y = h.length;
596
+ f({
597
+ title: n > 0 ? "Partial copy completed" : "Activities copied successfully",
598
+ description: n > 0 ? `${i} of ${y} activities copied successfully` : `${i} activit${i > 1 ? "ies" : "y"} copied successfully`,
599
+ status: n > 0 ? "warning" : "success",
600
+ duration: 3e3,
601
+ isClosable: !0
602
+ }), t?.(), C(""), p([]);
603
+ } else
604
+ throw new Error("Failed to copy any activities");
605
+ } catch (c) {
606
+ const n = c instanceof Error ? c.message : "Failed to copy activities";
607
+ f({
608
+ title: "Copy failed",
609
+ description: n,
610
+ status: "error",
611
+ duration: 5e3,
612
+ isClosable: !0
613
+ }), o?.(c instanceof Error ? c : new Error(n));
614
+ } finally {
615
+ A(!1);
616
+ }
617
+ }, [h, S, f, t, o, m]), T = O(() => {
618
+ C(""), p([]), s?.();
619
+ }, [s]);
620
+ Y(() => {
621
+ l && l({
622
+ cancelButton: !1,
623
+ saveButton: h.length === 0 || x
624
+ });
625
+ }, [h.length, x, l]), Y(() => {
626
+ a && a({
627
+ cancelButton: T,
628
+ saveButton: P
629
+ });
630
+ }, [a, T, P]);
631
+ const q = D(() => b.map((c) => ({
632
+ value: c.id,
633
+ label: c.name
634
+ })), [b]), R = D(() => v.map((c) => ({
635
+ value: c.id,
636
+ label: c.name,
637
+ // Add custom data to identify quantum-owned actions
638
+ isQuantumOwned: c.quantumOwned
639
+ })), [v]), Q = d.fetching, U = r.fetching;
640
+ return /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsxs(V, { spacing: 6, align: "stretch", children: [
641
+ /* @__PURE__ */ e.jsxs(G, { children: [
642
+ /* @__PURE__ */ e.jsx(te, { children: "Select Source Group" }),
643
+ /* @__PURE__ */ e.jsx(
644
+ se,
645
+ {
646
+ placeholder: "Choose a group...",
647
+ options: q,
648
+ value: q.find((c) => c.value === j) || null,
649
+ onChange: g,
650
+ isLoading: Q,
651
+ isDisabled: Q,
652
+ isClearable: !0
653
+ }
654
+ ),
655
+ d.error && /* @__PURE__ */ e.jsxs(be, { status: "error", mt: 2, children: [
656
+ /* @__PURE__ */ e.jsx(ve, {}),
657
+ /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", children: [
658
+ "Failed to load groups: ",
659
+ d.error.message
660
+ ] })
661
+ ] })
662
+ ] }),
663
+ j && /* @__PURE__ */ e.jsxs(G, { children: [
664
+ /* @__PURE__ */ e.jsx(te, { children: "Select Activities to Copy" }),
665
+ U ? /* @__PURE__ */ e.jsxs(K, { children: [
666
+ /* @__PURE__ */ e.jsx(Xe, { size: "sm" }),
667
+ /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.600", children: "Loading activities..." })
668
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
669
+ /* @__PURE__ */ e.jsx(
670
+ se,
671
+ {
672
+ placeholder: "Choose activities to copy...",
673
+ options: R,
674
+ value: R.filter(
675
+ (c) => I.includes(c.value)
676
+ ),
677
+ onChange: w,
678
+ isDisabled: R.length === 0,
679
+ isClearable: !0,
680
+ isMulti: !0,
681
+ closeMenuOnSelect: !1,
682
+ formatOptionLabel: (c, { context: n }) => /* @__PURE__ */ e.jsxs(K, { justify: "space-between", w: "100%", children: [
683
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
684
+ /* @__PURE__ */ e.jsx(M, { children: c.label }),
685
+ n === "value" && c.isQuantumOwned && /* @__PURE__ */ e.jsx(M, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
686
+ ] }),
687
+ c.isQuantumOwned && n === "menu" && /* @__PURE__ */ e.jsx(de, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
688
+ ] })
689
+ }
690
+ ),
691
+ R.length === 0 && /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.500", mt: 2, children: "No activities found" })
692
+ ] }),
693
+ r.error && /* @__PURE__ */ e.jsxs(be, { status: "error", mt: 2, children: [
694
+ /* @__PURE__ */ e.jsx(ve, {}),
695
+ /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", children: [
696
+ "Failed to load activities: ",
697
+ r.error.message
698
+ ] })
699
+ ] })
700
+ ] }),
701
+ h.length > 0 && /* @__PURE__ */ e.jsxs(B, { p: 4, bg: "gray.50", borderRadius: "md", children: [
702
+ /* @__PURE__ */ e.jsx(M, { fontWeight: "semibold", mb: 3, children: h.length === 1 ? "Activity to Copy:" : `${h.length} Activities to Copy:` }),
703
+ /* @__PURE__ */ e.jsxs(V, { align: "start", spacing: 3, children: [
704
+ h.map((c, n) => /* @__PURE__ */ e.jsxs(
705
+ B,
706
+ {
707
+ w: "100%",
708
+ p: 3,
709
+ bg: "white",
710
+ borderRadius: "md",
711
+ border: "1px solid",
712
+ borderColor: "gray.200",
713
+ children: [
714
+ /* @__PURE__ */ e.jsxs(K, { justify: "space-between", align: "start", mb: 2, children: [
715
+ /* @__PURE__ */ e.jsxs(M, { fontWeight: "medium", fontSize: "sm", children: [
716
+ n + 1,
717
+ ". ",
718
+ c.name
719
+ ] }),
720
+ c.quantumOwned && /* @__PURE__ */ e.jsx(de, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
721
+ ] }),
722
+ /* @__PURE__ */ e.jsxs(
723
+ V,
724
+ {
725
+ align: "start",
726
+ spacing: 1,
727
+ fontSize: "sm",
728
+ color: "gray.600",
729
+ children: [
730
+ c.description && /* @__PURE__ */ e.jsxs(M, { children: [
731
+ /* @__PURE__ */ e.jsx("strong", { children: "Description:" }),
732
+ " ",
733
+ c.description
734
+ ] }),
735
+ /* @__PURE__ */ e.jsxs(M, { children: [
736
+ /* @__PURE__ */ e.jsx("strong", { children: "Type:" }),
737
+ " ",
738
+ c.activityKind
739
+ ] }),
740
+ /* @__PURE__ */ e.jsxs(M, { children: [
741
+ /* @__PURE__ */ e.jsx("strong", { children: "Laterality:" }),
742
+ " ",
743
+ c.laterality
744
+ ] }),
745
+ /* @__PURE__ */ e.jsxs(M, { children: [
746
+ /* @__PURE__ */ e.jsx("strong", { children: "Sensor Locations:" }),
747
+ " ",
748
+ c.sensorLocations.length
749
+ ] }),
750
+ /* @__PURE__ */ e.jsxs(M, { children: [
751
+ /* @__PURE__ */ e.jsx("strong", { children: "Thresholds:" }),
752
+ " ",
753
+ c.thresholds.length
754
+ ] }),
755
+ /* @__PURE__ */ e.jsxs(M, { children: [
756
+ /* @__PURE__ */ e.jsx("strong", { children: "Use Cases:" }),
757
+ " ",
758
+ c.useCases.map((i) => i.name).join(", ") || "None"
759
+ ] })
760
+ ]
761
+ }
762
+ )
763
+ ]
764
+ },
765
+ c.id
766
+ )),
767
+ h.length > 1 && /* @__PURE__ */ e.jsx(
768
+ B,
769
+ {
770
+ w: "100%",
771
+ p: 2,
772
+ bg: "blue.50",
773
+ borderRadius: "md",
774
+ border: "1px solid",
775
+ borderColor: "blue.200",
776
+ children: /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
777
+ "Total: ",
778
+ h.length,
779
+ " activities will be copied"
780
+ ] })
781
+ }
782
+ )
783
+ ] })
784
+ ] }),
785
+ !u && /* @__PURE__ */ e.jsxs(ce, { spacing: 4, justifyContent: "flex-end", children: [
786
+ /* @__PURE__ */ e.jsx(
787
+ $,
788
+ {
789
+ variant: "outline",
790
+ onClick: T,
791
+ isDisabled: x,
792
+ children: "Cancel"
793
+ }
794
+ ),
795
+ /* @__PURE__ */ e.jsxs(
796
+ $,
797
+ {
798
+ colorScheme: "blue",
799
+ onClick: P,
800
+ isDisabled: h.length === 0 || x,
801
+ isLoading: x,
802
+ loadingText: "Copying...",
803
+ children: [
804
+ "Copy",
805
+ " ",
806
+ h.length === 1 ? "Activity" : `${h.length} Activities`
807
+ ]
808
+ }
809
+ )
810
+ ] })
811
+ ] }) });
812
+ }, Rt = ({
813
+ onSave: t,
814
+ onCancel: s,
815
+ onError: o,
816
+ hideButtons: u = !1,
817
+ setButtonDisabled: l,
818
+ setButtonOnClick: a,
819
+ quantumOwned: m
820
+ }) => {
821
+ const f = Ke(), [j, C] = F(""), [I, p] = F([]), [x, A] = F(!1), [d] = ee({
822
+ query: Ve
823
+ }), [r] = ee({
824
+ query: Ts,
825
+ variables: { groupId: j },
826
+ pause: !j
827
+ // Only run when group is selected
828
+ }), [, S] = oe(ss), [, b] = oe(De), v = D(() => d.data?.groups ? d.data.groups.map(
829
+ (n) => W(es, n)
830
+ ) : [], [d.data]), h = D(() => r.data?.modules ? W(
831
+ Re,
832
+ r.data?.modules
833
+ ).map((i) => {
834
+ const y = W(
835
+ ts,
836
+ i.moduleActions
837
+ );
838
+ return {
839
+ ...i,
840
+ moduleActions: y.map((L) => ({
841
+ ...L,
842
+ action: W(ae, L.action)
843
+ })),
844
+ categories: W(
845
+ Le,
846
+ i.categories
847
+ )
848
+ };
849
+ }) : [], [r.data]), g = D(() => h.filter(
850
+ (n) => I.includes(n.id)
851
+ ), [h, I]), w = O(
852
+ (n) => {
853
+ const i = n?.value || "";
854
+ C(i), p([]);
855
+ },
856
+ []
857
+ ), P = O(
858
+ (n) => {
859
+ const i = n.map((y) => y.value);
860
+ p(i);
861
+ },
862
+ []
863
+ ), T = O(async () => {
864
+ if (A(!0), !g.length) {
865
+ A(!1);
866
+ const n = new Error("No modules selected for copying");
867
+ o?.(n);
868
+ return;
869
+ }
870
+ try {
871
+ const n = [];
872
+ let i = 0;
873
+ for (const y of g)
874
+ try {
875
+ let L = y.moduleActions.map((E) => E.actionId);
876
+ if (m) {
877
+ const E = y.moduleActions.map((z) => z.action);
878
+ L = (await Promise.all(
879
+ E.map(async (z) => {
880
+ if (z.quantumOwned)
881
+ return Promise.resolve(z);
882
+ const ue = {
883
+ ...z,
884
+ quantumOwned: m,
885
+ thresholds: z.thresholds.map((X) => ({
886
+ ...X,
887
+ id: void 0
888
+ })),
889
+ id: void 0
890
+ };
891
+ return await b({ fields: ue }).then(
892
+ (X) => X.error || !X.data?.createAction ? null : W(
893
+ ae,
894
+ X.data.createAction
895
+ )
896
+ );
897
+ })
898
+ )).filter((z) => !!z).map((z) => z.id);
899
+ }
900
+ const _ = {
901
+ name: `${y.name} (Copy)`,
902
+ // Add "(Copy)" suffix to distinguish
903
+ description: y.description || void 0,
904
+ actions: L,
905
+ categories: y.categories.map((E) => E.id),
906
+ quantumOwned: m
907
+ }, H = await S({ input: _ });
908
+ if (H.error)
909
+ throw new Error(H.error.message);
910
+ if (H.data?.createModule) {
911
+ const E = W(
912
+ Re,
913
+ H.data.createModule
914
+ );
915
+ n.push(E);
916
+ }
917
+ } catch (L) {
918
+ console.error(`Failed to copy module "${y.name}":`, L), i++;
919
+ }
920
+ if (n.length > 0) {
921
+ const y = n.length, L = g.length;
922
+ f({
923
+ title: i > 0 ? "Partial copy completed" : "Modules copied successfully",
924
+ description: i > 0 ? `${y} of ${L} modules copied successfully` : `${y} module${y > 1 ? "s" : ""} copied successfully`,
925
+ status: i > 0 ? "warning" : "success",
926
+ duration: 3e3,
927
+ isClosable: !0
928
+ }), n.length > 0 && t?.(), C(""), p([]);
929
+ } else
930
+ throw new Error("Failed to copy any modules");
931
+ } catch (n) {
932
+ const i = n instanceof Error ? n.message : "Failed to copy modules";
933
+ f({
934
+ title: "Copy failed",
935
+ description: i,
936
+ status: "error",
937
+ duration: 5e3,
938
+ isClosable: !0
939
+ }), o?.(n instanceof Error ? n : new Error(i));
940
+ } finally {
941
+ A(!1);
942
+ }
943
+ }, [
944
+ g,
945
+ S,
946
+ f,
947
+ t,
948
+ o,
949
+ m,
950
+ b
951
+ ]), q = O(() => {
952
+ C(""), p([]), s?.();
953
+ }, [s]);
954
+ Y(() => {
955
+ l && l({
956
+ cancelButton: !1,
957
+ saveButton: g.length === 0 || x
958
+ });
959
+ }, [g.length, x, l]), Y(() => {
960
+ a && a({
961
+ cancelButton: q,
962
+ saveButton: T
963
+ });
964
+ }, [a, q, T]);
965
+ const R = D(() => v.map((n) => ({
966
+ value: n.id,
967
+ label: n.name
968
+ })), [v]), Q = D(() => h.map((n) => ({
969
+ value: n.id,
970
+ label: n.name,
971
+ // Add custom data to identify quantum-owned modules
972
+ isQuantumOwned: n.quantumOwned
973
+ })), [h]), U = d.fetching, c = r.fetching;
974
+ return /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsxs(V, { spacing: 6, align: "stretch", children: [
975
+ /* @__PURE__ */ e.jsxs(G, { children: [
976
+ /* @__PURE__ */ e.jsx(te, { children: "Select Source Group" }),
977
+ /* @__PURE__ */ e.jsx(
978
+ se,
979
+ {
980
+ placeholder: "Choose a group...",
981
+ options: R,
982
+ value: R.find((n) => n.value === j) || null,
983
+ onChange: w,
984
+ isLoading: U,
985
+ isDisabled: U,
986
+ isClearable: !0
987
+ }
988
+ ),
989
+ d.error && /* @__PURE__ */ e.jsxs(be, { status: "error", mt: 2, children: [
990
+ /* @__PURE__ */ e.jsx(ve, {}),
991
+ /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", children: [
992
+ "Failed to load groups: ",
993
+ d.error.message
994
+ ] })
995
+ ] })
996
+ ] }),
997
+ j && /* @__PURE__ */ e.jsxs(G, { children: [
998
+ /* @__PURE__ */ e.jsx(te, { children: "Select Module to Copy" }),
999
+ c ? /* @__PURE__ */ e.jsxs(K, { children: [
1000
+ /* @__PURE__ */ e.jsx(Xe, { size: "sm" }),
1001
+ /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.600", children: "Loading modules..." })
1002
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1003
+ /* @__PURE__ */ e.jsx(
1004
+ se,
1005
+ {
1006
+ placeholder: "Choose modules to copy...",
1007
+ options: Q,
1008
+ value: Q.filter(
1009
+ (n) => I.includes(n.value)
1010
+ ),
1011
+ onChange: P,
1012
+ isDisabled: Q.length === 0,
1013
+ isClearable: !0,
1014
+ isMulti: !0,
1015
+ closeMenuOnSelect: !1,
1016
+ formatOptionLabel: (n, { context: i }) => /* @__PURE__ */ e.jsxs(K, { justify: "space-between", w: "100%", children: [
1017
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1018
+ /* @__PURE__ */ e.jsx(M, { children: n.label }),
1019
+ i === "value" && n.isQuantumOwned && /* @__PURE__ */ e.jsx(M, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
1020
+ ] }),
1021
+ n.isQuantumOwned && i === "menu" && /* @__PURE__ */ e.jsx(de, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1022
+ ] })
1023
+ }
1024
+ ),
1025
+ Q.length === 0 && /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.500", mt: 2, children: "No modules found in this group" })
1026
+ ] }),
1027
+ r.error && /* @__PURE__ */ e.jsxs(be, { status: "error", mt: 2, children: [
1028
+ /* @__PURE__ */ e.jsx(ve, {}),
1029
+ /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", children: [
1030
+ "Failed to load modules: ",
1031
+ r.error.message
1032
+ ] })
1033
+ ] })
1034
+ ] }),
1035
+ g.length > 0 && /* @__PURE__ */ e.jsxs(B, { p: 4, bg: "gray.50", borderRadius: "md", children: [
1036
+ /* @__PURE__ */ e.jsx(M, { fontWeight: "semibold", mb: 3, children: g.length === 1 ? "Module to Copy:" : `${g.length} Modules to Copy:` }),
1037
+ /* @__PURE__ */ e.jsxs(V, { align: "start", spacing: 3, children: [
1038
+ g.map((n, i) => /* @__PURE__ */ e.jsxs(
1039
+ B,
1040
+ {
1041
+ w: "100%",
1042
+ p: 3,
1043
+ bg: "white",
1044
+ borderRadius: "md",
1045
+ border: "1px solid",
1046
+ borderColor: "gray.200",
1047
+ children: [
1048
+ /* @__PURE__ */ e.jsxs(K, { justify: "space-between", align: "start", mb: 2, children: [
1049
+ /* @__PURE__ */ e.jsxs(M, { fontWeight: "medium", fontSize: "sm", children: [
1050
+ i + 1,
1051
+ ". ",
1052
+ n.name
1053
+ ] }),
1054
+ n.quantumOwned && /* @__PURE__ */ e.jsx(de, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1055
+ ] }),
1056
+ /* @__PURE__ */ e.jsxs(
1057
+ V,
1058
+ {
1059
+ align: "start",
1060
+ spacing: 1,
1061
+ fontSize: "sm",
1062
+ color: "gray.600",
1063
+ children: [
1064
+ n.description && /* @__PURE__ */ e.jsxs(M, { children: [
1065
+ /* @__PURE__ */ e.jsx("strong", { children: "Description:" }),
1066
+ " ",
1067
+ n.description
1068
+ ] }),
1069
+ /* @__PURE__ */ e.jsxs(M, { children: [
1070
+ /* @__PURE__ */ e.jsx("strong", { children: "Actions:" }),
1071
+ " ",
1072
+ n.moduleActions.length
1073
+ ] }),
1074
+ /* @__PURE__ */ e.jsxs(M, { children: [
1075
+ /* @__PURE__ */ e.jsx("strong", { children: "Categories:" }),
1076
+ " ",
1077
+ n.categories.map((y) => y.name).join(", ") || "None"
1078
+ ] })
1079
+ ]
1080
+ }
1081
+ )
1082
+ ]
1083
+ },
1084
+ n.id
1085
+ )),
1086
+ g.length > 1 && /* @__PURE__ */ e.jsx(
1087
+ B,
1088
+ {
1089
+ w: "100%",
1090
+ p: 2,
1091
+ bg: "blue.50",
1092
+ borderRadius: "md",
1093
+ border: "1px solid",
1094
+ borderColor: "blue.200",
1095
+ children: /* @__PURE__ */ e.jsxs(M, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
1096
+ "Total: ",
1097
+ g.length,
1098
+ " modules will be copied"
1099
+ ] })
1100
+ }
1101
+ ),
1102
+ m && g.filter((n) => n.moduleActions.some((i) => !i.action.quantumOwned)).length > 0 && /* @__PURE__ */ e.jsx(
1103
+ B,
1104
+ {
1105
+ p: 2,
1106
+ bg: "yellow.50",
1107
+ borderRadius: "md",
1108
+ border: "1px solid",
1109
+ borderColor: "yellow.200",
1110
+ children: /* @__PURE__ */ e.jsx(M, { fontSize: "sm", fontWeight: "medium", color: "yellow.800", children: "Copying Modules with Non QM-Owned Actions will create corresponding QM-Owned Actions" })
1111
+ }
1112
+ )
1113
+ ] })
1114
+ ] }),
1115
+ !u && /* @__PURE__ */ e.jsxs(ce, { spacing: 4, justifyContent: "flex-end", children: [
1116
+ /* @__PURE__ */ e.jsx(
1117
+ $,
1118
+ {
1119
+ variant: "outline",
1120
+ onClick: q,
1121
+ isDisabled: x,
1122
+ children: "Cancel"
1123
+ }
1124
+ ),
1125
+ /* @__PURE__ */ e.jsxs(
1126
+ $,
1127
+ {
1128
+ colorScheme: "blue",
1129
+ onClick: T,
1130
+ isDisabled: g.length === 0 || x,
1131
+ isLoading: x,
1132
+ loadingText: "Copying...",
1133
+ children: [
1134
+ "Copy",
1135
+ " ",
1136
+ g.length === 1 ? "Module" : `${g.length} Modules`
1137
+ ]
1138
+ }
1139
+ )
1140
+ ] })
1141
+ ] }) });
1142
+ }, ot = ({
1143
+ name: t,
1144
+ setName: s,
1145
+ actions: o,
1146
+ selectedActionIds: u,
1147
+ setSelectedActionIds: l,
1148
+ availableCategories: a,
1149
+ selectedCategoryIds: m,
1150
+ setSelectedCategoryIds: f,
1151
+ description: j,
1152
+ setDescription: C,
1153
+ ...I
1154
+ }) => {
1155
+ const p = ms(), x = D(() => o.map((v) => ({
1156
+ ...v,
1157
+ selected: u.includes(v.id)
1158
+ })), [o, u]), A = D(() => o.reduce((v, h) => (v[h.id] = h, v), {}), [o]), d = D(
1159
+ () => u.map((v) => A[v]),
1160
+ [x, u]
1161
+ ), r = O(
1162
+ (v, h) => {
1163
+ l(h ? [...u, v.id] : u.filter((g) => g !== v.id));
1164
+ },
1165
+ [u, l]
1166
+ ), S = O(
1167
+ (v) => {
1168
+ s(v.target.value);
1169
+ },
1170
+ [s]
1171
+ ), b = O(
1172
+ (v) => {
1173
+ C?.(v.target.value);
1174
+ },
1175
+ [C]
1176
+ );
1177
+ return /* @__PURE__ */ e.jsxs(B, { ...I, children: [
1178
+ /* @__PURE__ */ e.jsxs(K, { gap: "2rem", children: [
1179
+ /* @__PURE__ */ e.jsx(rt, { name: t ?? "", onInputChange: S }),
1180
+ /* @__PURE__ */ e.jsx(
1181
+ lt,
1182
+ {
1183
+ availableCategories: a,
1184
+ value: m,
1185
+ onChange: f
1186
+ }
1187
+ )
1188
+ ] }),
1189
+ /* @__PURE__ */ e.jsx(
1190
+ at,
1191
+ {
1192
+ description: j ?? "",
1193
+ onInputChange: b
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ e.jsx(
1197
+ ct,
1198
+ {
1199
+ value: d,
1200
+ onChange: l,
1201
+ onAdjustActivities: () => p.onOpen()
1202
+ }
1203
+ ),
1204
+ /* @__PURE__ */ e.jsxs(
1205
+ gs,
1206
+ {
1207
+ isOpen: p.isOpen,
1208
+ onClose: p.onClose,
1209
+ size: "6xl",
1210
+ children: [
1211
+ /* @__PURE__ */ e.jsx(ps, {}),
1212
+ /* @__PURE__ */ e.jsxs(xs, { children: [
1213
+ /* @__PURE__ */ e.jsx(fs, { children: "Select Activities" }),
1214
+ /* @__PURE__ */ e.jsx(js, {}),
1215
+ /* @__PURE__ */ e.jsx(bs, { children: /* @__PURE__ */ e.jsx(
1216
+ nt,
1217
+ {
1218
+ actions: x,
1219
+ onSelected: r,
1220
+ disableCreate: !0,
1221
+ disableDelete: !0,
1222
+ tableProps: {
1223
+ height: "28rem",
1224
+ overflowY: "auto"
1225
+ }
1226
+ }
1227
+ ) }),
1228
+ /* @__PURE__ */ e.jsx(vs, { children: /* @__PURE__ */ e.jsx(
1229
+ $,
1230
+ {
1231
+ colorScheme: "blue",
1232
+ onClick: p.onClose,
1233
+ isDisabled: u.length === 0,
1234
+ children: "Done"
1235
+ }
1236
+ ) })
1237
+ ] })
1238
+ ]
1239
+ }
1240
+ )
1241
+ ] });
1242
+ }, rt = Se(
1243
+ ({
1244
+ name: t,
1245
+ onInputChange: s
1246
+ }) => /* @__PURE__ */ e.jsxs(G, { mb: 4, children: [
1247
+ /* @__PURE__ */ e.jsx(te, { children: "Module Name" }),
1248
+ /* @__PURE__ */ e.jsx(
1249
+ ye,
1250
+ {
1251
+ placeholder: "i.e. ACL RTP Test Battery",
1252
+ value: t,
1253
+ onChange: s,
1254
+ isRequired: !0
1255
+ }
1256
+ )
1257
+ ] })
1258
+ ), lt = Se(
1259
+ ({
1260
+ availableCategories: t,
1261
+ value: s,
1262
+ onChange: o
1263
+ }) => {
1264
+ const u = D(() => [
1265
+ ...t,
1266
+ {
1267
+ id: "other",
1268
+ name: "Other"
1269
+ }
1270
+ ], [t]), l = D(() => u.map((a) => ({
1271
+ value: a.id,
1272
+ label: a.name
1273
+ })), [u]);
1274
+ return /* @__PURE__ */ e.jsxs(G, { mb: 4, children: [
1275
+ /* @__PURE__ */ e.jsx(te, { children: "Module Category" }),
1276
+ /* @__PURE__ */ e.jsx(
1277
+ se,
1278
+ {
1279
+ isDisabled: t.length === 0,
1280
+ isClearable: !0,
1281
+ options: l,
1282
+ value: u.filter((a) => s.includes(a.id)).map((a) => ({
1283
+ value: a.id,
1284
+ label: a.name
1285
+ })),
1286
+ onChange: (a) => o(a ? [a.value] : []),
1287
+ placeholder: "Select category"
1288
+ }
1289
+ )
1290
+ ] });
1291
+ }
1292
+ ), at = Se(
1293
+ ({
1294
+ description: t,
1295
+ onInputChange: s
1296
+ }) => /* @__PURE__ */ e.jsxs(G, { mb: 4, children: [
1297
+ /* @__PURE__ */ e.jsx(te, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1298
+ "Description",
1299
+ /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.500", children: "Briefly describe the objective of this module. Max 40 words." })
1300
+ ] }) }),
1301
+ /* @__PURE__ */ e.jsx(
1302
+ ye,
1303
+ {
1304
+ placeholder: "i.e. Assess readiness to return to play post-ACL reconstruction",
1305
+ value: t,
1306
+ onChange: s
1307
+ }
1308
+ )
1309
+ ] })
1310
+ ), ct = Se(
1311
+ ({
1312
+ value: t,
1313
+ onChange: s,
1314
+ onAdjustActivities: o
1315
+ }) => {
1316
+ const u = D(
1317
+ () => t.map((l) => ({
1318
+ id: l.id,
1319
+ name: l.name
1320
+ })),
1321
+ [t]
1322
+ );
1323
+ return /* @__PURE__ */ e.jsxs(G, { mb: 4, children: [
1324
+ /* @__PURE__ */ e.jsxs(K, { justifyContent: "space-between", children: [
1325
+ /* @__PURE__ */ e.jsx(te, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1326
+ "Activities",
1327
+ /* @__PURE__ */ e.jsx(M, { fontSize: "sm", color: "gray.500", children: "Drag and drop to reorder the activities in this module." })
1328
+ ] }) }),
1329
+ /* @__PURE__ */ e.jsx(
1330
+ $,
1331
+ {
1332
+ size: "sm",
1333
+ variant: "solid",
1334
+ colorScheme: "blue",
1335
+ onClick: o,
1336
+ children: "Add / Remove Activities"
1337
+ }
1338
+ )
1339
+ ] }),
1340
+ u.length === 0 ? /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsxs(M, { color: "gray.500", fontSize: "lg", mb: "4rem", mt: "4rem", children: [
1341
+ "No activities selected for this module.",
1342
+ /* @__PURE__ */ e.jsx(
1343
+ $,
1344
+ {
1345
+ ml: "0.5em",
1346
+ size: "sm",
1347
+ variant: "link",
1348
+ colorScheme: "blue",
1349
+ onClick: o,
1350
+ children: "Add activities."
1351
+ }
1352
+ )
1353
+ ] }) }) : /* @__PURE__ */ e.jsx(
1354
+ Js,
1355
+ {
1356
+ value: u,
1357
+ onChange: (l) => {
1358
+ const a = l(u);
1359
+ s(a.map((m) => m.id));
1360
+ }
1361
+ }
1362
+ )
1363
+ ] });
1364
+ }
1365
+ ), dt = ({
1366
+ value: t,
1367
+ onChange: s,
1368
+ forceKind: o,
1369
+ disableRemove: u,
1370
+ disableKind: l,
1371
+ lockRanges: a,
1372
+ ...m
1373
+ }) => {
1374
+ const f = D(() => [...t].sort((p, x) => {
1375
+ const A = Be.indexOf(p.plane), d = Be.indexOf(x.plane);
1376
+ return A - d;
1377
+ }), [t]), j = O((p) => "segment" in p.id ? ns(p.id.segment, p.plane, !0) ?? "Unknown" : is(p.id.joint, p.plane, !0) ?? "Unknown", []), C = O(
1378
+ (p, x) => {
1379
+ const A = f.findIndex(
1380
+ (r) => r.id === x.id && r.plane === x.plane
1381
+ );
1382
+ let d = [...f];
1383
+ o && (x = { ...x, kind: o }), d[A] = x, a && (d = d.map((r) => ({
1384
+ ...r,
1385
+ min: x.min,
1386
+ max: x.max
1387
+ }))), s(d);
1388
+ },
1389
+ [s, f, o, a]
1390
+ ), I = O(
1391
+ (p) => {
1392
+ const x = f.filter(
1393
+ (A) => A.id !== p.id || A.plane !== p.plane
1394
+ );
1395
+ s(x);
1396
+ },
1397
+ [s, f]
1398
+ );
1399
+ return /* @__PURE__ */ e.jsx(V, { alignItems: "flex-start", overflowY: "auto", ...m, children: f.map((p, x) => /* @__PURE__ */ e.jsx(
1400
+ ut,
1401
+ {
1402
+ label: j(p),
1403
+ parameter: p,
1404
+ onChange: (A) => C(x, A),
1405
+ onRemove: u ? void 0 : () => I(p),
1406
+ forceKind: o,
1407
+ disableKind: l
1408
+ },
1409
+ `${JSON.stringify(p.id)}-${p.plane}`
1410
+ )) });
1411
+ }, ut = ({
1412
+ label: t,
1413
+ parameter: s,
1414
+ onChange: o,
1415
+ onRemove: u,
1416
+ forceKind: l,
1417
+ disableKind: a
1418
+ }) => {
1419
+ const m = O(
1420
+ (C) => "joint" in s.id ? Bs(
1421
+ s.id.joint,
1422
+ s.plane,
1423
+ C < 0 ? -1 : 1
1424
+ ) : Ws(
1425
+ s.id.segment,
1426
+ s.plane,
1427
+ C < 0 ? -1 : 1
1428
+ ),
1429
+ [s]
1430
+ ), { min: f, max: j } = "joint" in s.id ? $s(s.id.joint, s.plane) : { min: -180, max: 180 };
1431
+ return /* @__PURE__ */ e.jsxs(
1432
+ V,
1433
+ {
1434
+ borderRadius: "md",
1435
+ p: 2,
1436
+ px: 4,
1437
+ bg: "gray.100",
1438
+ w: "100%",
1439
+ overflow: "hidden",
1440
+ flexShrink: "0",
1441
+ children: [
1442
+ /* @__PURE__ */ e.jsxs(K, { w: "100%", children: [
1443
+ /* @__PURE__ */ e.jsx(
1444
+ M,
1445
+ {
1446
+ fontSize: "sm",
1447
+ flex: 1,
1448
+ textTransform: "capitalize",
1449
+ fontWeight: "semibold",
1450
+ children: t
1451
+ }
1452
+ ),
1453
+ u && /* @__PURE__ */ e.jsx(
1454
+ ys,
1455
+ {
1456
+ size: "xs",
1457
+ variant: "ghost",
1458
+ "aria-label": "delete",
1459
+ icon: /* @__PURE__ */ e.jsx(We, { as: Ms }),
1460
+ onClick: u
1461
+ }
1462
+ ),
1463
+ !l && /* @__PURE__ */ e.jsx(
1464
+ Fe,
1465
+ {
1466
+ selectedItem: s?.kind ?? je.Limit,
1467
+ onChange: ({ value: C }) => o({ ...s, kind: C }),
1468
+ isDisabled: a,
1469
+ buttonProps: {
1470
+ size: "sm",
1471
+ variant: "outline",
1472
+ colorScheme: "gray"
1473
+ },
1474
+ selectedProps: {
1475
+ variant: "solid",
1476
+ colorScheme: "teal"
1477
+ },
1478
+ items: [
1479
+ { value: je.Limit, label: "limit" },
1480
+ { value: je.Target, label: "target" }
1481
+ ]
1482
+ }
1483
+ )
1484
+ ] }),
1485
+ /* @__PURE__ */ e.jsx(
1486
+ Xs,
1487
+ {
1488
+ w: "100%",
1489
+ size: "xs",
1490
+ min: f,
1491
+ max: j,
1492
+ zeroMarker: !0,
1493
+ value: [s.min, s.max],
1494
+ onChange: (C) => o({ ...s, min: C[0], max: C[1] }),
1495
+ formatValue: (C) => `${Math.abs(C)}°`,
1496
+ valueLabel: (C) => m(C) ?? "",
1497
+ positiveNegativeLabels: m(0) ? [m(-1) ?? "", m(1) ?? ""] : void 0
1498
+ }
1499
+ )
1500
+ ]
1501
+ }
1502
+ );
1503
+ }, fe = (t, s) => "segment" in t && "segment" in s && t.segment === s.segment || "joint" in t && "joint" in s && t.joint === s.joint, ht = ({
1504
+ options: t,
1505
+ value: s,
1506
+ onChange: o,
1507
+ forceKind: u,
1508
+ singleValue: l,
1509
+ singleValueSideless: a,
1510
+ editOnly: m,
1511
+ disableKind: f,
1512
+ maxParameters: j,
1513
+ ...C
1514
+ }) => {
1515
+ const I = a ? 2 : j, p = D(
1516
+ () => t.map((r) => ({
1517
+ label: "segment" in r.id ? ns(r.id.segment, r.plane, !0) ?? "Unknown" : is(r.id.joint, r.plane, !0) ?? "Unknown",
1518
+ value: r.id,
1519
+ plane: r.plane
1520
+ })),
1521
+ [t]
1522
+ ), x = D(() => {
1523
+ if (!a || s.length === 0)
1524
+ return p;
1525
+ const r = s[0];
1526
+ return p.filter(
1527
+ (S) => pe(S.value) === pe(r.id) && S.plane === r.plane
1528
+ );
1529
+ }, [p, s, a]), A = D(
1530
+ () => p.filter(
1531
+ (r) => s.some((S) => fe(S.id, r.value) && S.plane === r.plane)
1532
+ ),
1533
+ [p, s]
1534
+ ), d = O(
1535
+ (r) => {
1536
+ const S = r.map((b) => {
1537
+ const v = s.find(
1538
+ (T) => fe(T.id, b.value) && T.plane === b.plane
1539
+ ), h = t.find(
1540
+ (T) => fe(T.id, b.value) && T.plane === b.plane
1541
+ ), g = a ? s.find(
1542
+ (T) => pe(T.id) === pe(b.value) && T.plane === b.plane
1543
+ ) : void 0, w = g && !v ? g.min : h && h.min ? h.min : 0, P = g && !v ? g.max : h && h.max ? h.max : 0;
1544
+ return v ?? {
1545
+ id: b.value,
1546
+ plane: b.plane,
1547
+ min: w,
1548
+ max: P,
1549
+ kind: u ?? je.Limit
1550
+ };
1551
+ });
1552
+ o(S);
1553
+ },
1554
+ [o, s, t, u, a]
1555
+ );
1556
+ return Y(() => {
1557
+ const r = s.filter(
1558
+ (S) => t.some((b) => fe(b.id, S.id) && b.plane === S.plane)
1559
+ );
1560
+ r.length !== s.length && o(r);
1561
+ }, [t, o]), /* @__PURE__ */ e.jsxs(B, { ...C, children: [
1562
+ /* @__PURE__ */ e.jsx(
1563
+ se,
1564
+ {
1565
+ isMulti: !l,
1566
+ placeholder: s.length ? `${s.length} selected` : "Search...",
1567
+ value: A,
1568
+ isDisabled: m || A.length >= (I ?? 1 / 0),
1569
+ onChange: (r) => Array.isArray(r) ? d([...r]) : d(r !== null ? [r] : []),
1570
+ options: x,
1571
+ controlShouldRenderValue: !1
1572
+ }
1573
+ ),
1574
+ /* @__PURE__ */ e.jsx(
1575
+ dt,
1576
+ {
1577
+ marginTop: 2,
1578
+ maxH: "28rem",
1579
+ value: s,
1580
+ onChange: o,
1581
+ forceKind: u,
1582
+ disableKind: f,
1583
+ lockRanges: a
1584
+ }
1585
+ )
1586
+ ] });
1587
+ }, os = (t) => {
1588
+ switch (t) {
1589
+ case k.Thorax:
1590
+ return "Thorax";
1591
+ case k.CenterBack:
1592
+ return "Center Back";
1593
+ case k.Pelvis:
1594
+ return "Pelvis";
1595
+ case k.LeftThigh:
1596
+ return "Left Thigh";
1597
+ case k.RightThigh:
1598
+ return "Right Thigh";
1599
+ case k.LeftShank:
1600
+ return "Left Shank";
1601
+ case k.RightShank:
1602
+ return "Right Shank";
1603
+ case k.LeftFoot:
1604
+ return "Left Foot";
1605
+ case k.RightFoot:
1606
+ return "Right Foot";
1607
+ case k.LeftUpperArm:
1608
+ return "Left Upper Arm";
1609
+ case k.RightUpperArm:
1610
+ return "Right Upper Arm";
1611
+ case k.LeftForearm:
1612
+ return "Left Forearm";
1613
+ case k.RightForearm:
1614
+ return "Right Forearm";
1615
+ case k.Head:
1616
+ return "Head";
1617
+ }
1618
+ return console.warn(`Unknown sensor location: ${t}`), "Unknown";
1619
+ }, mt = 6, gt = [
1620
+ k.LeftFoot,
1621
+ k.LeftShank,
1622
+ k.LeftThigh,
1623
+ k.Pelvis,
1624
+ k.RightFoot,
1625
+ k.RightShank,
1626
+ k.RightThigh,
1627
+ k.Thorax,
1628
+ k.CenterBack,
1629
+ k.Head
1630
+ ], pt = gt.map((t) => ({
1631
+ label: os(t),
1632
+ value: t
1633
+ })), Oe = (t) => t.map(
1634
+ (s) => s.__isNew__ ? { name: s.label } : { id: s.value, name: s.label }
1635
+ ), Lt = ({
1636
+ id: t,
1637
+ onError: s,
1638
+ onCancel: o,
1639
+ onSave: u,
1640
+ hideButtons: l,
1641
+ setButtonOnClick: a,
1642
+ setButtonDisabled: m,
1643
+ quantumOwned: f
1644
+ }) => {
1645
+ const j = As(), [{ fetching: C }, I] = oe(De), [{ fetching: p }, x] = oe(Ns), [{ data: A }] = ee({
1646
+ query: Os,
1647
+ variables: { id: t ?? "" },
1648
+ pause: !t
1649
+ }), d = W(
1650
+ ae,
1651
+ A?.getActionById
1652
+ ), r = C || p, S = !!d && !!t, [b, v] = F(""), [h, g] = F(""), [w, P] = F(""), [T, q] = F(""), [R, Q] = F(
1653
+ ge.Either
1654
+ ), [U, c] = F(
1655
+ Te.Action
1656
+ ), [n, i] = F([]), [y, L] = F([]), _ = D(
1657
+ () => n.map((N) => N.value),
1658
+ [n]
1659
+ ), H = Hs(_), [E, J] = F([]), [z, ue] = F(!1), X = b.length && R;
1660
+ Y(() => {
1661
+ d && (v(d.name), c(d.activityKind), g(d.description || ""), Q(d.laterality), L(
1662
+ d.useCases.map((N) => ({
1663
+ id: N.id,
1664
+ value: N.id,
1665
+ label: N.name,
1666
+ __isNew__: !1
1667
+ }))
1668
+ ), P(d.instructionsPointOfInterest || ""), q(d.instructionsMovementReport || ""), i(
1669
+ d.sensorLocations.map((N) => ({
1670
+ label: os(N),
1671
+ value: N
1672
+ }))
1673
+ ), J(Qs(d.thresholds)));
1674
+ }, [d]);
1675
+ const rs = O(
1676
+ async (N) => (await j.query(
1677
+ f ? Rs : Ls,
1678
+ {
1679
+ query: N,
1680
+ limit: 10
1681
+ }
1682
+ ).then((ne) => {
1683
+ const me = ne.data;
1684
+ return me ? me?.quantumOwnedUseCases ? me.quantumOwnedUseCases : me.useCases : [];
1685
+ }) ?? []).map((ne) => ({
1686
+ label: ne.name,
1687
+ value: ne.id
1688
+ })),
1689
+ [j, f]
1690
+ ), [ke, Ee] = F({});
1691
+ Y(() => {
1692
+ Ee({
1693
+ name: b,
1694
+ laterality: R,
1695
+ description: h,
1696
+ instructionsPointOfInterest: w,
1697
+ instructionsMovementReport: T,
1698
+ sensorLocations: _,
1699
+ thresholds: Ne(E),
1700
+ useCases: Oe(y),
1701
+ activityKind: U
1702
+ });
1703
+ }, [Ee, d]);
1704
+ const we = D(
1705
+ () => JSON.stringify(ke) !== JSON.stringify({
1706
+ name: b,
1707
+ laterality: R,
1708
+ description: h,
1709
+ instructionsPointOfInterest: w,
1710
+ instructionsMovementReport: T,
1711
+ sensorLocations: _,
1712
+ thresholds: Ne(E),
1713
+ useCases: Oe(y),
1714
+ activityKind: U
1715
+ }),
1716
+ [
1717
+ ke,
1718
+ b,
1719
+ R,
1720
+ _,
1721
+ h,
1722
+ T,
1723
+ w,
1724
+ E,
1725
+ y,
1726
+ U
1727
+ ]
1728
+ ), Me = O(() => {
1729
+ const N = {
1730
+ name: b,
1731
+ laterality: R,
1732
+ description: h,
1733
+ instructionsPointOfInterest: w,
1734
+ instructionsMovementReport: T,
1735
+ sensorLocations: _,
1736
+ thresholds: Ne(E),
1737
+ useCases: Oe(y),
1738
+ activityKind: U,
1739
+ quantumOwned: f
1740
+ };
1741
+ let he;
1742
+ S && t ? he = x({
1743
+ id: t,
1744
+ fields: N
1745
+ }) : he = I({
1746
+ fields: N
1747
+ }), he.then(({ error: ne }) => {
1748
+ ne ? s(ne) : u();
1749
+ });
1750
+ }, [
1751
+ f,
1752
+ I,
1753
+ x,
1754
+ t,
1755
+ b,
1756
+ R,
1757
+ _,
1758
+ u,
1759
+ h,
1760
+ T,
1761
+ w,
1762
+ S,
1763
+ E,
1764
+ y,
1765
+ U,
1766
+ s
1767
+ ]);
1768
+ return Y(() => {
1769
+ m && m({
1770
+ cancelButton: r,
1771
+ saveButton: r || !X || !we
1772
+ });
1773
+ }, [r, m, X, we]), Y(() => {
1774
+ a && a({
1775
+ cancelButton: o,
1776
+ saveButton: Me
1777
+ });
1778
+ }, [a, o, Me]), /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-4 w-full", children: [
1779
+ /* @__PURE__ */ e.jsxs("div", { className: "col-span-2 lg:col-span-1 flex flex-col gap-8", children: [
1780
+ /* @__PURE__ */ e.jsxs(G, { children: [
1781
+ /* @__PURE__ */ e.jsx(Z, { children: "Name" }),
1782
+ /* @__PURE__ */ e.jsx(
1783
+ ye,
1784
+ {
1785
+ value: b,
1786
+ onChange: (N) => v(N.target.value),
1787
+ type: "text",
1788
+ placeholder: "i.e. Lunge & Return"
1789
+ }
1790
+ )
1791
+ ] }),
1792
+ /* @__PURE__ */ e.jsxs(K, { m: "0", p: "0", w: "100%", justifyItems: "space-between", children: [
1793
+ /* @__PURE__ */ e.jsxs(G, { children: [
1794
+ /* @__PURE__ */ e.jsx(Z, { children: "Activity Type" }),
1795
+ /* @__PURE__ */ e.jsx(
1796
+ Fe,
1797
+ {
1798
+ selectedItem: U,
1799
+ onChange: (N) => c(N.value),
1800
+ buttonProps: {
1801
+ size: "sm",
1802
+ variant: "outline",
1803
+ colorScheme: "gray"
1804
+ },
1805
+ selectedProps: {
1806
+ variant: "solid",
1807
+ colorScheme: "teal"
1808
+ },
1809
+ items: [
1810
+ { value: Te.Action, label: "Action" },
1811
+ { value: Te.Movement, label: "Movement" }
1812
+ ]
1813
+ }
1814
+ )
1815
+ ] }),
1816
+ /* @__PURE__ */ e.jsxs(G, { children: [
1817
+ /* @__PURE__ */ e.jsx(Z, { children: "Laterality" }),
1818
+ /* @__PURE__ */ e.jsx(
1819
+ Fe,
1820
+ {
1821
+ selectedItem: R,
1822
+ onChange: (N) => Q(N.value),
1823
+ buttonProps: {
1824
+ size: "sm",
1825
+ variant: "outline",
1826
+ colorScheme: "gray"
1827
+ },
1828
+ selectedProps: {
1829
+ variant: "solid",
1830
+ colorScheme: "teal"
1831
+ },
1832
+ items: [
1833
+ {
1834
+ value: ge.Unilateral,
1835
+ label: "unilateral"
1836
+ },
1837
+ {
1838
+ value: ge.Bilateral,
1839
+ label: "bilateral"
1840
+ },
1841
+ {
1842
+ value: ge.Either,
1843
+ label: "either / or"
1844
+ }
1845
+ ]
1846
+ }
1847
+ )
1848
+ ] })
1849
+ ] }),
1850
+ /* @__PURE__ */ e.jsxs(G, { children: [
1851
+ /* @__PURE__ */ e.jsx(Z, { children: "Use Cases" }),
1852
+ /* @__PURE__ */ e.jsx(
1853
+ Je,
1854
+ {
1855
+ isOpen: z,
1856
+ label: "Type to search for existing use cases",
1857
+ placement: "top-end",
1858
+ children: /* @__PURE__ */ e.jsx(B, { children: /* @__PURE__ */ e.jsx(
1859
+ Ss,
1860
+ {
1861
+ value: y,
1862
+ onChange: (N) => L([...N]),
1863
+ isMulti: !0,
1864
+ cacheOptions: !0,
1865
+ defaultOptions: !0,
1866
+ onFocus: () => ue(!0),
1867
+ onBlur: () => ue(!1),
1868
+ loadOptions: rs,
1869
+ placeholder: "(optional) Search for & select use cases…"
1870
+ }
1871
+ ) })
1872
+ }
1873
+ )
1874
+ ] }),
1875
+ /* @__PURE__ */ e.jsxs(G, { children: [
1876
+ /* @__PURE__ */ e.jsx(Z, { children: "Description" }),
1877
+ /* @__PURE__ */ e.jsx(
1878
+ Ie,
1879
+ {
1880
+ value: h,
1881
+ onChange: (N) => g(N.target.value),
1882
+ rows: 2,
1883
+ placeholder: "(optional) Describe how to perform the test or exercise"
1884
+ }
1885
+ )
1886
+ ] }),
1887
+ /* @__PURE__ */ e.jsxs(G, { children: [
1888
+ /* @__PURE__ */ e.jsx(Z, { children: "Instructions for General Movement Report" }),
1889
+ /* @__PURE__ */ e.jsx(
1890
+ Ie,
1891
+ {
1892
+ value: T,
1893
+ onChange: (N) => q(N.target.value),
1894
+ rows: 2,
1895
+ placeholder: "(optional) Describe how to setup or generate the movement report"
1896
+ }
1897
+ )
1898
+ ] }),
1899
+ /* @__PURE__ */ e.jsxs(G, { children: [
1900
+ /* @__PURE__ */ e.jsx(Z, { children: "Instructions for Point of Interest Report" }),
1901
+ /* @__PURE__ */ e.jsx(
1902
+ Ie,
1903
+ {
1904
+ value: w,
1905
+ onChange: (N) => P(N.target.value),
1906
+ rows: 2,
1907
+ placeholder: "(optional) Describe how to setup or generate the point of interest report"
1908
+ }
1909
+ )
1910
+ ] })
1911
+ ] }),
1912
+ /* @__PURE__ */ e.jsxs("div", { className: "col-span-2 lg:col-span-1 flex flex-col gap-8", children: [
1913
+ /* @__PURE__ */ e.jsxs(G, { children: [
1914
+ /* @__PURE__ */ e.jsx(Z, { children: "Sensor Locations" }),
1915
+ /* @__PURE__ */ e.jsx(
1916
+ se,
1917
+ {
1918
+ isMulti: !0,
1919
+ value: n,
1920
+ onChange: (N) => i([...N]),
1921
+ options: pt,
1922
+ isOptionDisabled: () => n.length >= mt
1923
+ }
1924
+ )
1925
+ ] }),
1926
+ /* @__PURE__ */ e.jsxs(G, { children: [
1927
+ /* @__PURE__ */ e.jsx(Z, { children: "Default Parameters" }),
1928
+ /* @__PURE__ */ e.jsx(
1929
+ ht,
1930
+ {
1931
+ options: H,
1932
+ value: E,
1933
+ onChange: J
1934
+ }
1935
+ )
1936
+ ] })
1937
+ ] }),
1938
+ /* @__PURE__ */ e.jsx(
1939
+ "div",
1940
+ {
1941
+ className: qs("col-span-2 flex justify-end", l && "hidden"),
1942
+ children: /* @__PURE__ */ e.jsxs(ce, { mt: 16, gap: 4, children: [
1943
+ /* @__PURE__ */ e.jsx($, { colorScheme: "gray", isDisabled: r, onClick: o, children: "Cancel" }),
1944
+ /* @__PURE__ */ e.jsx(
1945
+ $,
1946
+ {
1947
+ colorScheme: "blue",
1948
+ isDisabled: r || !X || !we,
1949
+ isLoading: r,
1950
+ onClick: Me,
1951
+ children: "Save changes"
1952
+ }
1953
+ )
1954
+ ] })
1955
+ }
1956
+ )
1957
+ ] });
1958
+ }, Z = ({ children: t }) => /* @__PURE__ */ e.jsx($e, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: t }), Ft = ({
1959
+ id: t,
1960
+ onCancel: s,
1961
+ onSave: o,
1962
+ onError: u,
1963
+ hideButtons: l,
1964
+ quantumOwned: a,
1965
+ setButtonOnClick: m,
1966
+ setButtonDisabled: f
1967
+ }) => {
1968
+ const [{ data: j }] = ee({
1969
+ query: a ? Fs : Ds
1970
+ }), [{ data: C }] = ee({
1971
+ query: ks,
1972
+ variables: { id: t },
1973
+ pause: !t
1974
+ }), [{ data: I }] = ee({
1975
+ query: Es
1976
+ }), p = W(
1977
+ Le,
1978
+ I?.moduleCategories
1979
+ ), [{ fetching: x }, A] = oe(Ps), [{ fetching: d }, r] = oe(ss), S = W(
1980
+ ae,
1981
+ a ? j?.quantumOwnedActions : j?.actions
1982
+ ) ?? [], b = W(Re, C?.module), v = W(ts, b?.moduleActions) ?? [], [h, g] = F([
1983
+ ...v.map((c) => c.actionId) ?? []
1984
+ ]), [w, P] = F(b?.name ?? ""), [T, q] = F([]), [R, Q] = F(b?.description ?? "");
1985
+ Y(() => {
1986
+ b && (g(v.map((c) => c.actionId)), P(b.name), Q(b.description ?? ""), q(
1987
+ b.categories.map(
1988
+ (c) => W(Le, c).id
1989
+ ) ?? []
1990
+ ));
1991
+ }, [b, v]);
1992
+ const U = O(() => {
1993
+ let c;
1994
+ const n = {
1995
+ actions: h,
1996
+ name: w,
1997
+ categories: T.filter((i) => i !== "other"),
1998
+ description: R,
1999
+ quantumOwned: a
2000
+ };
2001
+ b ? c = A({
2002
+ id: b.id,
2003
+ input: n
2004
+ }) : c = r({
2005
+ input: n
2006
+ }), c.then(({ error: i }) => {
2007
+ i ? u(i) : o();
2008
+ });
2009
+ }, [
2010
+ r,
2011
+ A,
2012
+ h,
2013
+ w,
2014
+ R,
2015
+ T,
2016
+ b,
2017
+ o,
2018
+ u
2019
+ ]);
2020
+ return Y(() => {
2021
+ f && f({
2022
+ cancelButton: x || d,
2023
+ saveButton: x || d || !w || R.trim().split(/\s+/).filter(Boolean).length > 40
2024
+ });
2025
+ }, [f, x, d, h, w, R]), Y(() => {
2026
+ m && m({
2027
+ cancelButton: s,
2028
+ saveButton: U
2029
+ });
2030
+ }, [m, s, U]), /* @__PURE__ */ e.jsxs(B, { width: "100%", children: [
2031
+ /* @__PURE__ */ e.jsx(
2032
+ ot,
2033
+ {
2034
+ name: w,
2035
+ setName: P,
2036
+ actions: S,
2037
+ selectedActionIds: h,
2038
+ setSelectedActionIds: g,
2039
+ availableCategories: p ?? [],
2040
+ selectedCategoryIds: T,
2041
+ setSelectedCategoryIds: q,
2042
+ description: R,
2043
+ setDescription: Q
2044
+ }
2045
+ ),
2046
+ !l && /* @__PURE__ */ e.jsx(K, { justifyContent: "flex-start", children: /* @__PURE__ */ e.jsxs(ce, { mt: 16, gap: 4, children: [
2047
+ /* @__PURE__ */ e.jsx(
2048
+ $,
2049
+ {
2050
+ colorScheme: "gray",
2051
+ isDisabled: x || d,
2052
+ onClick: s,
2053
+ children: "Cancel"
2054
+ }
2055
+ ),
2056
+ /* @__PURE__ */ e.jsx(
2057
+ $,
2058
+ {
2059
+ colorScheme: "blue",
2060
+ isDisabled: x || d || !w || R.trim().split(/\s+/).filter(Boolean).length > 40,
2061
+ isLoading: x || d,
2062
+ onClick: U,
2063
+ children: "Save"
2064
+ }
2065
+ )
2066
+ ] }) })
2067
+ ] });
2068
+ };
2069
+ export {
2070
+ nt as ActivityList,
2071
+ Ot as CopyActivityForm,
2072
+ Rt as CopyModuleForm,
2073
+ ot as ModuleForm,
2074
+ dt as ParameterEditList,
2075
+ ht as ParameterEditSelect,
2076
+ Lt as UpsertActivityForm,
2077
+ Ft as UpsertModuleForm
2078
+ };