quantum-component-library 1.4.51-dev.1 → 1.4.51-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,48 @@
1
1
  import { j as e } from "./react-jsx-runtime-vendor-OVHDjVDe.js";
2
- import { Flex as ye, InputGroup as rt, InputLeftElement as $t, Icon as xt, Input as we, FormLabel as jt, Box as re, TableContainer as ft, Table as bt, Thead as yt, Tr as We, Th as be, Tbody as vt, Td as Ce, ButtonGroup as Le, Tooltip as et, Button as ee, RangeSlider as Dt, RangeSliderMark as Ve, Text as b, RangeSliderTrack as Et, RangeSliderFilledTrack as _t, RangeSliderThumb as ot, Select as it, NumberInput as at, NumberInputField as lt, HStack as oe, Tag as Re, Image as Gt, useToast as Ct, VStack as le, FormControl as X, RadioGroup as wt, Radio as Qe, Alert as qe, AlertIcon as Ke, Spinner as St, useDisclosure as zt, Modal as Bt, ModalOverlay as Ut, ModalContent as Wt, ModalHeader as Qt, ModalCloseButton as qt, ModalBody as Kt, ModalFooter as Yt, Badge as Lt, IconButton as Ht, Tabs as Jt, TabList as Xt, Tab as ct, TabPanels as Zt, TabPanel as dt, Textarea as Ee } from "@chakra-ui/react";
3
2
  import "./moment-vendor-DMLRxgRE.js";
4
- import { useMemo as T, useState as z, useCallback as $, useRef as Vt, useEffect as ce, createContext as en, useContext as tn, memo as Je } from "react";
5
- import { c as Ne } from "./utils-cn-CgdSr4hO.js";
3
+ import { Flex as we, InputGroup as at, InputLeftElement as $t, Icon as bt, Input as Le, FormLabel as Xe, ButtonGroup as Me, Tooltip as tt, Button as se, Box as te, RangeSlider as Ft, RangeSliderMark as et, Text as C, RangeSliderTrack as Dt, RangeSliderFilledTrack as Gt, RangeSliderThumb as it, Select as lt, NumberInput as ct, NumberInputField as dt, HStack as re, Tag as Ne, FormControl as X, TableContainer as Pt, Table as Et, Thead as _t, Tr as ut, Th as Re, Tbody as zt, Td as _e, Image as Bt, useToast as yt, VStack as le, RadioGroup as vt, Radio as Ye, Alert as He, AlertIcon as Je, Spinner as Ct, useDisclosure as Wt, Modal as Ut, ModalOverlay as Qt, ModalContent as qt, ModalHeader as Kt, ModalCloseButton as Yt, ModalBody as Ht, ModalFooter as Jt, Badge as wt, IconButton as Xt, Tabs as Zt, TabList as Vt, Tab as mt, TabPanels as en, TabPanel as ht, Textarea as ze } from "@chakra-ui/react";
4
+ import { useMemo as k, useState as B, useEffect as ie, useCallback as P, createContext as tn, useContext as nn, memo as Se, useRef as sn } from "react";
5
+ import { getFragmentData as L } from "./generated.js";
6
+ import { G as nt, M as je, a as be, b as St, c as rn, C as st, d as Lt, e as It, R as Ze, f as $e, T as Ie, A as ve, g as on, h as Mt, U as Ot, i as Qe, j as At, k as an, l as ln, m as cn, n as dn, o as un, p as mn } from "./graphql-B-0IK2pU.js";
7
+ import { c as qe } from "./utils-cn-CgdSr4hO.js";
6
8
  import "./lodash-vendor-B-xpwrnm.js";
7
- import { useQuery as je, useMutation as me, useClient as nn } from "urql";
8
- import { useUiLabelContext as xe, useAllPartParameters as sn } from "./hooks.js";
9
- import { u as rn } from "./ufuzzy-vendor-Dl0ZI6Av.js";
10
- import { F as on, a as an, b as ln, c as cn } from "./react-icons-vendor-CMsTQrA0.js";
11
- import { s as ge } from "./react-select-vendor-_26lPW2Z.js";
12
- import { getFragmentData as R } from "./generated.js";
13
- import { G as Mt, a as dn, C as tt, b as It, R as nt, M as ke, c as Ye, T as Se, A as fe, d as He, e as Ot, f as un, g as At, U as Tt, h as Be, i as Nt, j as hn, k as mn, l as pn, m as gn, n as xn, o as jn, p as fn } from "./graphql-BIKiRJ8I.js";
9
+ import { useClient as rt, useQuery as Ce, useMutation as fe } from "urql";
10
+ import { useUiLabelContext as pe, useAllPartParameters as hn } from "./hooks.js";
11
+ import { u as pn } from "./ufuzzy-vendor-Dl0ZI6Av.js";
12
+ import { s as ue } from "./react-select-vendor-_26lPW2Z.js";
13
+ import { F as gn, a as xn, b as fn, c as jn } from "./react-icons-vendor-CMsTQrA0.js";
14
14
  import { D as bn, H as yn, u as vn, a as Cn } from "./react-dnd-vendor-BYAS_HOo.js";
15
- import { g as Rt, a as kt, b as wn, c as Sn, d as Ln, e as ut, f as ht } from "./services-human-BIz3wOu_.js";
16
- import { ThresholdKind as Ue, ReportKind as se, ActionLaterality as Mn, SensorLocation as ae } from "./generated-graphql.js";
17
- import { availablePlanes as mt, getAnalysisPartIdNoSide as _e } from "./types.js";
18
- const In = ({
19
- setSearch: n,
20
- actions: t,
21
- updateUseCases: o,
22
- hideUseCaseFilter: h = !1
15
+ import { g as kt, a as Tt, b as wn, c as Sn, d as Ln, e as pt, f as gt } from "./services-human-BIz3wOu_.js";
16
+ import { ThresholdKind as Ke, ReportKind as ae, ActionLaterality as In, SensorLocation as ce } from "./generated-graphql.js";
17
+ import { availablePlanes as xt, getAnalysisPartIdNoSide as Be } from "./types.js";
18
+ const Mn = ({
19
+ setSearch: r,
20
+ actions: n,
21
+ updateUseCases: a,
22
+ hideUseCaseFilter: p = !1
23
23
  }) => {
24
- const g = T(
25
- () => t?.flatMap((d) => d.useCases).filter((d, u, C) => C.findIndex((s) => s.id === d.id) === u).map((d) => ({
24
+ const x = k(
25
+ () => n?.flatMap((d) => d.useCases).filter((d, u, h) => h.findIndex((s) => s.id === d.id) === u).map((d) => ({
26
26
  label: d.name,
27
27
  value: d.id
28
28
  })) || [],
29
- [t]
29
+ [n]
30
30
  );
31
- return /* @__PURE__ */ e.jsxs(ye, { width: "100%", alignContent: "space-evenly", gap: 4, children: [
32
- /* @__PURE__ */ e.jsxs(rt, { size: "md", flex: 1, children: [
33
- /* @__PURE__ */ e.jsx($t, { children: /* @__PURE__ */ e.jsx(xt, { as: on, color: "gray.300" }) }),
31
+ return /* @__PURE__ */ e.jsxs(we, { width: "100%", alignContent: "space-evenly", gap: 4, children: [
32
+ /* @__PURE__ */ e.jsxs(at, { size: "md", flex: 1, children: [
33
+ /* @__PURE__ */ e.jsx($t, { children: /* @__PURE__ */ e.jsx(bt, { as: gn, color: "gray.300" }) }),
34
34
  /* @__PURE__ */ e.jsx(
35
- we,
35
+ Le,
36
36
  {
37
37
  placeholder: "Search by name...",
38
38
  width: "100%",
39
- maxW: h ? void 0 : "30rem",
40
- onChange: (d) => n(d.target.value)
39
+ maxW: p ? void 0 : "30rem",
40
+ onChange: (d) => r(d.target.value)
41
41
  }
42
42
  )
43
43
  ] }),
44
- !h && /* @__PURE__ */ e.jsx(rt, { size: "md", children: /* @__PURE__ */ e.jsx(
45
- ge,
44
+ !p && /* @__PURE__ */ e.jsx(at, { size: "md", children: /* @__PURE__ */ e.jsx(
45
+ ue,
46
46
  {
47
47
  size: "md",
48
48
  chakraStyles: {
@@ -54,96 +54,24 @@ const In = ({
54
54
  menuPortalTarget: document.body,
55
55
  placeholder: "Filter use case",
56
56
  isMulti: !0,
57
- options: g,
58
- onChange: (d) => o(d.map((u) => u.value))
57
+ options: x,
58
+ onChange: (d) => a(d.map((u) => u.value))
59
59
  }
60
60
  ) })
61
61
  ] });
62
- }, pe = ({
63
- children: n
64
- }) => /* @__PURE__ */ e.jsx(jt, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: n }), On = ({ value: n, onChange: t, disabled: o }) => {
65
- const h = z(
66
- () => Math.random().toString(36).substring(2, 15)
67
- )[0], g = $(
68
- (d, u) => {
69
- o || t((C) => {
70
- const s = [...C], [c] = s.splice(d, 1);
71
- return s.splice(u, 0, c), s;
72
- });
73
- },
74
- [t, o]
75
- );
76
- return /* @__PURE__ */ e.jsx(re, { children: /* @__PURE__ */ e.jsx(bn, { backend: yn, children: /* @__PURE__ */ e.jsx(ft, { children: /* @__PURE__ */ e.jsxs(bt, { variant: "simple", size: "md", children: [
77
- /* @__PURE__ */ e.jsx(yt, { children: /* @__PURE__ */ e.jsxs(We, { children: [
78
- /* @__PURE__ */ e.jsx(be, { children: "Order" }),
79
- /* @__PURE__ */ e.jsx(be, { children: "Name" })
80
- ] }) }),
81
- /* @__PURE__ */ e.jsx(vt, { children: n.map((d, u) => /* @__PURE__ */ e.jsx(
82
- An,
83
- {
84
- listKey: h,
85
- index: u,
86
- id: d.id,
87
- name: d.name,
88
- move: g,
89
- className: Ne(o && "!cursor-default")
90
- },
91
- d.id
92
- )) })
93
- ] }) }) }) });
94
- }, An = ({
95
- listKey: n,
96
- index: t,
97
- id: o,
98
- name: h,
99
- move: g,
100
- className: d
101
- }) => {
102
- const u = Vt(null), [{ handlerId: C }, s] = vn({
103
- accept: n,
104
- collect: (y) => ({
105
- handlerId: y.getHandlerId()?.toString() ?? ""
106
- }),
107
- hover: (y, I) => {
108
- if (!u.current)
109
- return;
110
- const j = y.index, m = t;
111
- if (j === m)
112
- return;
113
- const l = u.current?.getBoundingClientRect(), a = (l.bottom - l.top) / 2, w = I.getClientOffset().y - l.top;
114
- j < m && w < a || j > m && w > a || (g(j, m), y.index = m);
115
- }
116
- }), [{ isDragging: c }, x] = Cn({
117
- type: n,
118
- item: () => ({ id: o, index: t }),
119
- collect: (y) => ({
120
- isDragging: y.isDragging()
121
- })
122
- }), F = c ? 0.6 : 1, L = c ? "grabbing" : "grab";
123
- return x(s(u)), /* @__PURE__ */ e.jsxs(
124
- We,
125
- {
126
- ref: u,
127
- style: { opacity: F, cursor: L },
128
- "data-handler-id": C,
129
- className: d,
130
- children: [
131
- /* @__PURE__ */ e.jsx(Ce, { children: t + 1 }),
132
- /* @__PURE__ */ e.jsx(Ce, { children: h })
133
- ]
134
- }
135
- );
136
- }, Tn = ({
137
- items: n,
138
- onChange: t,
139
- selectedItem: o,
140
- isDisabled: h,
141
- selectedProps: g,
62
+ }, he = ({
63
+ children: r
64
+ }) => /* @__PURE__ */ e.jsx(Xe, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: r }), On = ({
65
+ items: r,
66
+ onChange: n,
67
+ selectedItem: a,
68
+ isDisabled: p,
69
+ selectedProps: x,
142
70
  buttonProps: d
143
71
  }) => {
144
- const u = (s) => s === o || s.value === o, C = (s) => u(s) ? { ...d, ...g } : d;
145
- return /* @__PURE__ */ e.jsx(Le, { isAttached: !0, isDisabled: h, children: n.map((s, c) => /* @__PURE__ */ e.jsx(
146
- et,
72
+ const u = (s) => s === a || s.value === a, h = (s) => u(s) ? { ...d, ...x } : d;
73
+ return /* @__PURE__ */ e.jsx(Me, { isAttached: !0, isDisabled: p, children: r.map((s, i) => /* @__PURE__ */ e.jsx(
74
+ tt,
147
75
  {
148
76
  label: s.tooltip,
149
77
  openDelay: 50,
@@ -152,114 +80,114 @@ const In = ({
152
80
  visibility: s.tooltip ? "visible" : "hidden",
153
81
  hasArrow: !0,
154
82
  children: /* @__PURE__ */ e.jsx(
155
- ee,
83
+ se,
156
84
  {
157
- onClick: () => u(s) ? null : t(s, c),
85
+ onClick: () => u(s) ? null : n(s, i),
158
86
  isDisabled: s.disabled,
159
- ...C(s),
87
+ ...h(s),
160
88
  children: s.label
161
89
  }
162
90
  )
163
91
  },
164
- c
92
+ i
165
93
  )) });
166
- }, Ge = (n, t) => t < 0 ? -1 * Math.abs(n) : Math.abs(n), Nn = ({
167
- isReversed: n,
168
- min: t,
169
- max: o,
170
- value: h,
171
- onChange: g,
94
+ }, We = (r, n) => n < 0 ? -1 * Math.abs(r) : Math.abs(r), An = ({
95
+ isReversed: r,
96
+ min: n,
97
+ max: a,
98
+ value: p,
99
+ onChange: x,
172
100
  inputProps: d,
173
101
  size: u,
174
- zeroMarker: C,
102
+ zeroMarker: h,
175
103
  formatValue: s,
176
- valueLabel: c,
177
- positiveNegativeLabels: x,
178
- isDisabled: F,
179
- ...L
104
+ valueLabel: i,
105
+ positiveNegativeLabels: g,
106
+ isDisabled: w,
107
+ ...S
180
108
  }) => {
181
- const [y, I] = z([void 0, void 0]), j = y[0], m = y[1], l = C && t < -5 && o > 5, a = Number(h?.[0] ?? m ?? t) > 0 ? 1 : -1, v = Number(h?.[1] ?? m ?? o) < 0 ? -1 : 1, w = x?.[0] === x?.[1], _ = h?.[0], B = h?.[1];
182
- ce(() => {
183
- _ !== void 0 && B !== void 0 && I([_.toFixed(0), B.toFixed(0)]);
184
- }, [_, B, I]);
185
- const W = $(
186
- ([M, E]) => {
187
- M < E && I([M.toFixed(0), E.toFixed(0)]);
109
+ const [M, I] = B([void 0, void 0]), y = M[0], c = M[1], m = h && n < -5 && a > 5, v = Number(p?.[0] ?? c ?? n) > 0 ? 1 : -1, j = Number(p?.[1] ?? c ?? a) < 0 ? -1 : 1, A = g?.[0] === g?.[1], $ = p?.[0], F = p?.[1];
110
+ ie(() => {
111
+ $ !== void 0 && F !== void 0 && I([$.toFixed(0), F.toFixed(0)]);
112
+ }, [$, F, I]);
113
+ const O = P(
114
+ ([T, _]) => {
115
+ T < _ && I([T.toFixed(0), _.toFixed(0)]);
188
116
  },
189
117
  [I]
190
- ), N = $(
191
- ([M, E]) => {
192
- M < E && g([M, E]);
118
+ ), N = P(
119
+ ([T, _]) => {
120
+ T < _ && x([T, _]);
193
121
  },
194
- [g]
195
- ), Z = $(() => {
196
- I(([M, E]) => {
197
- const te = isNaN(Number(M)) ? t : Number(M), Q = isNaN(Number(E)) ? o : Number(E), ie = Ge(Number(te), a), i = Ge(Number(Q), v), r = a < 0 ? Math.max(ie, t) : Math.min(ie, o), f = v < 0 ? Math.max(i, t) : Math.min(i, o);
198
- return r > f ? (g([f, r]), [f.toFixed(0), r.toFixed(0)]) : (g([r, f]), [r.toFixed(0), f.toFixed(0)]);
122
+ [x]
123
+ ), H = P(() => {
124
+ I(([T, _]) => {
125
+ const J = isNaN(Number(T)) ? n : Number(T), W = isNaN(Number(_)) ? a : Number(_), K = We(Number(J), v), l = We(Number(W), j), t = v < 0 ? Math.max(K, n) : Math.min(K, a), o = j < 0 ? Math.max(l, n) : Math.min(l, a);
126
+ return t > o ? (x([o, t]), [o.toFixed(0), t.toFixed(0)]) : (x([t, o]), [t.toFixed(0), o.toFixed(0)]);
199
127
  });
200
- }, [g, I, a, v, t, o]), J = $(
201
- (M) => {
202
- const E = M === "" || isNaN(Number(M)) ? M : Ge(Number(M), a);
203
- I(([te, Q]) => [E.toString(), Q]);
204
- },
205
- [I, a]
206
- ), D = $(
207
- (M) => {
208
- const E = M === "" || isNaN(Number(M)) ? M : Ge(Number(M), v);
209
- I(([te, Q]) => [te, E.toString()]);
128
+ }, [x, I, v, j, n, a]), oe = P(
129
+ (T) => {
130
+ const _ = T === "" || isNaN(Number(T)) ? T : We(Number(T), v);
131
+ I(([J, W]) => [_.toString(), W]);
210
132
  },
211
133
  [I, v]
212
- ), S = T(
134
+ ), R = P(
135
+ (T) => {
136
+ const _ = T === "" || isNaN(Number(T)) ? T : We(Number(T), j);
137
+ I(([J, W]) => [J, _.toString()]);
138
+ },
139
+ [I, j]
140
+ ), Z = k(
213
141
  () => u === "xs" ? "0.75rem" : void 0,
214
142
  [u]
215
- ), O = $(
216
- (M, E) => {
217
- const te = Number(E.target.value);
218
- if (!j || !m || ![-1, 1].includes(te))
143
+ ), V = P(
144
+ (T, _) => {
145
+ const J = Number(_.target.value);
146
+ if (!y || !c || ![-1, 1].includes(J))
219
147
  return;
220
- const Q = (r) => te < 0 ? -1 * Math.abs(r) : Math.abs(r), ie = M ? Q(Number(j)) : Number(j), i = M ? Number(m) : Q(Number(m));
221
- ie > i ? g([i, ie]) : g([ie, i]);
148
+ const W = (t) => J < 0 ? -1 * Math.abs(t) : Math.abs(t), K = T ? W(Number(y)) : Number(y), l = T ? Number(c) : W(Number(c));
149
+ K > l ? x([l, K]) : x([K, l]);
222
150
  },
223
- [j, m, g]
151
+ [y, c, x]
224
152
  );
225
- return /* @__PURE__ */ e.jsxs(ye, { direction: "column", ...L, children: [
226
- /* @__PURE__ */ e.jsx(re, { pt: "1em", mb: "-0.5em", children: /* @__PURE__ */ e.jsxs(
227
- Dt,
153
+ return /* @__PURE__ */ e.jsxs(we, { direction: "column", ...S, children: [
154
+ /* @__PURE__ */ e.jsx(te, { pt: "1em", mb: "-0.5em", children: /* @__PURE__ */ e.jsxs(
155
+ Ft,
228
156
  {
229
157
  "aria-label": ["min", "max"],
230
- isReversed: n,
231
- value: [Number(j ?? t), Number(m ?? o)],
232
- max: o,
233
- min: t,
158
+ isReversed: r,
159
+ value: [Number(y ?? n), Number(c ?? a)],
160
+ max: a,
161
+ min: n,
234
162
  minStepsBetweenThumbs: 3,
235
163
  step: 1,
236
- onChange: W,
164
+ onChange: O,
237
165
  onChangeEnd: N,
238
- isDisabled: F,
166
+ isDisabled: w,
239
167
  children: [
240
- /* @__PURE__ */ e.jsx(Ve, { value: t, top: "-1em", children: /* @__PURE__ */ e.jsx(
241
- b,
168
+ /* @__PURE__ */ e.jsx(et, { value: n, top: "-1em", children: /* @__PURE__ */ e.jsx(
169
+ C,
242
170
  {
243
171
  fontSize: u ?? "sm",
244
172
  fontWeight: "semibold",
245
173
  whiteSpace: "nowrap",
246
- children: s ? s?.(t) : t
174
+ children: s ? s?.(n) : n
247
175
  }
248
176
  ) }),
249
- /* @__PURE__ */ e.jsx(Ve, { value: o, top: "-1em", children: /* @__PURE__ */ e.jsx(
250
- b,
177
+ /* @__PURE__ */ e.jsx(et, { value: a, top: "-1em", children: /* @__PURE__ */ e.jsx(
178
+ C,
251
179
  {
252
180
  fontSize: u ?? "sm",
253
181
  fontWeight: "semibold",
254
182
  style: { transform: "translateX(-100%)" },
255
183
  whiteSpace: "nowrap",
256
- children: s ? s(o) : o
184
+ children: s ? s(a) : a
257
185
  }
258
186
  ) }),
259
- l && /* @__PURE__ */ e.jsxs(Ve, { value: 0, top: "-1em", pos: "relative", children: [
260
- /* @__PURE__ */ e.jsx(b, { fontSize: u, fontWeight: "semibold", children: s?.(0) ?? "0" }),
187
+ m && /* @__PURE__ */ e.jsxs(et, { value: 0, top: "-1em", pos: "relative", children: [
188
+ /* @__PURE__ */ e.jsx(C, { fontSize: u, fontWeight: "semibold", children: s?.(0) ?? "0" }),
261
189
  /* @__PURE__ */ e.jsx(
262
- re,
190
+ te,
263
191
  {
264
192
  position: "absolute",
265
193
  width: "2px",
@@ -270,79 +198,79 @@ const In = ({
270
198
  }
271
199
  )
272
200
  ] }),
273
- /* @__PURE__ */ e.jsx(Et, { children: /* @__PURE__ */ e.jsx(_t, {}) }),
274
- /* @__PURE__ */ e.jsx(ot, { index: 0, w: S, h: S }),
275
- /* @__PURE__ */ e.jsx(ot, { index: 1, w: S, h: S })
201
+ /* @__PURE__ */ e.jsx(Dt, { children: /* @__PURE__ */ e.jsx(Gt, {}) }),
202
+ /* @__PURE__ */ e.jsx(it, { index: 0, w: Z, h: Z }),
203
+ /* @__PURE__ */ e.jsx(it, { index: 1, w: Z, h: Z })
276
204
  ]
277
205
  }
278
206
  ) }),
279
- c && /* @__PURE__ */ e.jsxs(
280
- ye,
207
+ i && /* @__PURE__ */ e.jsxs(
208
+ we,
281
209
  {
282
- direction: n ? "row-reverse" : "row",
210
+ direction: r ? "row-reverse" : "row",
283
211
  justifyContent: "space-between",
284
212
  children: [
285
213
  /* @__PURE__ */ e.jsx(
286
- b,
214
+ C,
287
215
  {
288
216
  fontSize: u ?? "sm",
289
217
  fontWeight: "semibold",
290
218
  whiteSpace: "nowrap",
291
- children: c(t)
219
+ children: i(n)
292
220
  }
293
221
  ),
294
222
  /* @__PURE__ */ e.jsx(
295
- b,
223
+ C,
296
224
  {
297
225
  fontSize: u ?? "sm",
298
226
  fontWeight: "semibold",
299
227
  whiteSpace: "nowrap",
300
- children: c(o)
228
+ children: i(a)
301
229
  }
302
230
  )
303
231
  ]
304
232
  }
305
233
  ),
306
234
  /* @__PURE__ */ e.jsxs(
307
- ye,
235
+ we,
308
236
  {
309
- direction: n ? "row-reverse" : "row",
237
+ direction: r ? "row-reverse" : "row",
310
238
  justifyContent: "center",
311
239
  alignItems: "center",
312
240
  gap: "0.125em",
313
241
  children: [
314
- x && /* @__PURE__ */ e.jsxs(
315
- it,
242
+ g && /* @__PURE__ */ e.jsxs(
243
+ lt,
316
244
  {
317
245
  width: "auto",
318
246
  size: u,
319
247
  fontWeight: "bold",
320
- value: a,
321
- onChange: (M) => O(!0, M),
322
- isDisabled: w || F,
248
+ value: v,
249
+ onChange: (T) => V(!0, T),
250
+ isDisabled: A || w,
323
251
  children: [
324
- /* @__PURE__ */ e.jsx("option", { value: -1, children: x[0] }),
325
- /* @__PURE__ */ e.jsx("option", { value: 1, children: x[1] })
252
+ /* @__PURE__ */ e.jsx("option", { value: -1, children: g[0] }),
253
+ /* @__PURE__ */ e.jsx("option", { value: 1, children: g[1] })
326
254
  ]
327
255
  }
328
256
  ),
329
257
  /* @__PURE__ */ e.jsx(
330
- at,
258
+ ct,
331
259
  {
332
260
  precision: 0,
333
261
  size: u ?? "sm",
334
262
  min: 0,
335
- max: a < 0 ? Math.abs(t) : B ?? o,
336
- value: j === "" ? "" : Math.abs(Number(j ?? t)),
337
- onChange: J,
338
- onBlur: Z,
263
+ max: v < 0 ? Math.abs(n) : F ?? a,
264
+ value: y === "" ? "" : Math.abs(Number(y ?? n)),
265
+ onChange: oe,
266
+ onBlur: H,
339
267
  borderWidth: 1,
340
268
  borderRadius: 3,
341
269
  borderColor: "#ccc",
342
- isDisabled: F,
270
+ isDisabled: w,
343
271
  ...d,
344
272
  children: /* @__PURE__ */ e.jsx(
345
- lt,
273
+ dt,
346
274
  {
347
275
  backgroundColor: "#fff",
348
276
  paddingRight: 0,
@@ -352,22 +280,22 @@ const In = ({
352
280
  }
353
281
  ),
354
282
  /* @__PURE__ */ e.jsx(
355
- at,
283
+ ct,
356
284
  {
357
285
  size: u ?? "sm",
358
286
  min: 0,
359
- max: v < 0 ? Math.abs(_ ?? t) : o,
287
+ max: j < 0 ? Math.abs($ ?? n) : a,
360
288
  precision: 0,
361
- value: m === "" ? "" : Math.abs(Number(m ?? o)),
362
- onChange: D,
363
- onBlur: Z,
289
+ value: c === "" ? "" : Math.abs(Number(c ?? a)),
290
+ onChange: R,
291
+ onBlur: H,
364
292
  borderWidth: 1,
365
293
  borderRadius: 3,
366
294
  borderColor: "#ccc",
367
- isDisabled: F,
295
+ isDisabled: w,
368
296
  ...d,
369
297
  children: /* @__PURE__ */ e.jsx(
370
- lt,
298
+ dt,
371
299
  {
372
300
  backgroundColor: "#fff",
373
301
  paddingRight: 0,
@@ -376,18 +304,18 @@ const In = ({
376
304
  )
377
305
  }
378
306
  ),
379
- x && /* @__PURE__ */ e.jsxs(
380
- it,
307
+ g && /* @__PURE__ */ e.jsxs(
308
+ lt,
381
309
  {
382
310
  width: "auto",
383
311
  size: u,
384
312
  fontWeight: "bold",
385
- value: v,
386
- onChange: (M) => O(!1, M),
387
- isDisabled: w || F,
313
+ value: j,
314
+ onChange: (T) => V(!1, T),
315
+ isDisabled: A || w,
388
316
  children: [
389
- /* @__PURE__ */ e.jsx("option", { value: -1, children: x[0] }),
390
- /* @__PURE__ */ e.jsx("option", { value: 1, children: x[1] })
317
+ /* @__PURE__ */ e.jsx("option", { value: -1, children: g[0] }),
318
+ /* @__PURE__ */ e.jsx("option", { value: 1, children: g[1] })
391
319
  ]
392
320
  }
393
321
  )
@@ -395,20 +323,20 @@ const In = ({
395
323
  }
396
324
  )
397
325
  ] });
398
- }, Rn = ({ tags: n, containerProps: t, ...o }) => /* @__PURE__ */ e.jsx(oe, { ...t, children: n.map((h, g) => /* @__PURE__ */ e.jsx(Re, { ...o, children: h }, g)) }), kn = new rn({}), Fn = ({
399
- action: n,
400
- quantumIconSrc: t
326
+ }, kn = ({ tags: r, containerProps: n, ...a }) => /* @__PURE__ */ e.jsx(re, { ...n, children: r.map((p, x) => /* @__PURE__ */ e.jsx(Ne, { ...a, children: p }, x)) }), Tn = new pn({}), Rn = ({
327
+ action: r,
328
+ quantumIconSrc: n
401
329
  }) => {
402
- const { getLabel: o } = xe(), h = T(() => ({
403
- actionLowerCase: o("action").toLocaleLowerCase()
404
- }), [o]);
405
- return n.quantumOwned ? /* @__PURE__ */ e.jsx(
406
- et,
330
+ const { getLabel: a } = pe(), p = k(() => ({
331
+ actionLowerCase: a("action").toLocaleLowerCase()
332
+ }), [a]);
333
+ return r.quantumOwned ? /* @__PURE__ */ e.jsx(
334
+ tt,
407
335
  {
408
- label: `This ${h.actionLowerCase} is owned by Quantum`,
336
+ label: `This ${p.actionLowerCase} is owned by Quantum`,
409
337
  "aria-label": "Quantum owned",
410
338
  children: /* @__PURE__ */ e.jsx(
411
- re,
339
+ te,
412
340
  {
413
341
  boxSize: "1.5em",
414
342
  borderRadius: "full",
@@ -417,425 +345,534 @@ const In = ({
417
345
  alignItems: "center",
418
346
  justifyContent: "center",
419
347
  children: /* @__PURE__ */ e.jsx(
420
- Gt,
348
+ Bt,
421
349
  {
422
- src: t,
350
+ src: n,
423
351
  boxSize: "1em",
424
- alt: `Quantum-owned ${h.actionLowerCase}`
352
+ alt: `Quantum-owned ${p.actionLowerCase}`
425
353
  }
426
354
  )
427
355
  }
428
356
  )
429
357
  }
430
358
  ) : null;
431
- }, Pn = (n, t) => {
432
- if (!t || !t.trim().length)
433
- return n;
434
- const o = n.map((g) => g.name ?? "");
435
- return kn.filter(o, t)?.map((g) => n[g]) ?? [];
436
- }, $n = (n) => !n || n.length === 0 ? "None" : n.map(
437
- (t) => (
359
+ }, Nn = (r, n) => {
360
+ if (!n || !n.trim().length)
361
+ return r;
362
+ const a = r.map((x) => x.name ?? "");
363
+ return Tn.filter(a, n)?.map((x) => r[x]) ?? [];
364
+ }, $n = (r) => !r || r.length === 0 ? "None" : r.map(
365
+ (n) => (
438
366
  // Convert camelCase to separate words (e.g., 'LeftFoot' -> 'Left Foot')
439
- t.replace(/([A-Z])/g, " $1").trim()
367
+ n.replace(/([A-Z])/g, " $1").trim()
440
368
  )
441
- ).join(", "), Dn = (n, t) => !t || t.length == 0 ? n : n.filter(
442
- (o) => o.useCases?.some((h) => t.includes(h.id)) ?? !1
443
- ), En = ({
444
- actions: n,
445
- totalActions: t,
446
- onCreate: o,
447
- onDelete: h,
448
- onEdit: g,
369
+ ).join(", "), Fn = (r, n) => !n || n.length == 0 ? r : r.filter(
370
+ (a) => a.useCases?.some((p) => n.includes(p.id)) ?? !1
371
+ ), Dn = (r, n, a) => !n || n.length === 0 ? r : r.filter((p) => {
372
+ const x = {};
373
+ return n.forEach((d) => {
374
+ for (const [u, h] of Object.entries(a || {}))
375
+ if (h.some((s) => s.id === d)) {
376
+ x[u] || (x[u] = []), x[u].push(d);
377
+ break;
378
+ }
379
+ }), Object.entries(x).every(
380
+ ([d, u]) => {
381
+ const h = p.metadataGroups?.find((w) => L(je, w).key === d);
382
+ if (!h)
383
+ return !1;
384
+ const s = L(
385
+ je,
386
+ h
387
+ ), g = L(
388
+ be,
389
+ s.data
390
+ ).map((w) => w.id);
391
+ return u.some(
392
+ (w) => g.includes(w)
393
+ );
394
+ }
395
+ );
396
+ }), Gn = ({
397
+ actions: r,
398
+ totalActions: n,
399
+ onCreate: a,
400
+ onDelete: p,
401
+ onEdit: x,
449
402
  onView: d,
450
403
  onSelected: u,
451
- onDuplicate: C,
404
+ onDuplicate: h,
452
405
  disableMultiSelect: s,
453
- disableDelete: c,
454
- disableEdit: x,
455
- disableCreate: F,
456
- hideUseCase: L = !0,
457
- tableProps: y,
458
- containerProps: I,
459
- quantumIconSrc: j = "/favicon.ico"
406
+ disableDelete: i,
407
+ disableEdit: g,
408
+ disableCreate: w,
409
+ hideUseCase: S = !0,
410
+ showMetadataFilters: M = !0,
411
+ tableProps: I,
412
+ containerProps: y,
413
+ quantumIconSrc: c = "/favicon.ico"
460
414
  }) => {
461
- const [m, l] = z(""), [a, v] = z(), { getLabel: w } = xe(), _ = T(() => ({
462
- action: w("action"),
463
- actionPlural: w("action_plural"),
464
- actionLowerCase: w("action").toLocaleLowerCase(),
465
- actionPluralLowerCase: w("action_plural").toLocaleLowerCase()
466
- }), [w]), B = T(() => {
467
- if (!n)
415
+ const [m, v] = B(""), [j, A] = B(), [$, F] = B([]), [O, N] = B({}), { getLabel: H } = pe(), oe = rt(), R = k(() => ({
416
+ action: H("action"),
417
+ actionPlural: H("action_plural"),
418
+ actionLowerCase: H("action").toLocaleLowerCase(),
419
+ actionPluralLowerCase: H("action_plural").toLocaleLowerCase()
420
+ }), [H]), Z = k(() => [
421
+ { key: "module_category", label: "Link Category", multi: !0 },
422
+ { key: "activity_type", label: `${R.action} Type`, multi: !0 },
423
+ { key: "session_type", label: "Session Type", multi: !0 },
424
+ { key: "body_region", label: "Body Region", multi: !0 },
425
+ { key: "sport", label: "Sport", multi: !0 }
426
+ ], [R.action]);
427
+ ie(() => {
428
+ if (!M)
468
429
  return;
469
- const S = Pn(n, m);
470
- return L ? S : Dn(S, a);
471
- }, [n, m, a, L]), W = $(() => {
472
- if (!h)
430
+ const t = Z.map(
431
+ (o) => oe.query(nt, { key: o.key })
432
+ );
433
+ Promise.all(t).then((o) => {
434
+ const b = {};
435
+ o.forEach((U) => {
436
+ if (U.error || !U.data) return;
437
+ const q = L(
438
+ je,
439
+ U.data.getMetadataByKey
440
+ ), E = L(
441
+ be,
442
+ q.data
443
+ );
444
+ b[q.key] = E.map((D) => ({
445
+ label: D.label || D.value,
446
+ value: D.value,
447
+ id: D.id
448
+ }));
449
+ }), N(b);
450
+ });
451
+ }, [oe, Z, M]);
452
+ const V = k(() => {
453
+ if (!r)
454
+ return;
455
+ const t = Nn(r, m), o = S ? t : Fn(t, j);
456
+ return M ? Dn(
457
+ o,
458
+ $,
459
+ O
460
+ ) : o;
461
+ }, [
462
+ r,
463
+ m,
464
+ j,
465
+ S,
466
+ M,
467
+ $,
468
+ O
469
+ ]), T = P(() => {
470
+ if (!p)
473
471
  return;
474
- const O = n.filter(
475
- (M) => M.selected && !M.quantumOwned
476
- ).map((M) => M.id);
477
- h(O);
478
- }, [n, h]), N = $(() => {
479
- if (!C)
472
+ const o = r.filter(
473
+ (b) => b.selected && !b.quantumOwned
474
+ ).map((b) => b.id);
475
+ p(o);
476
+ }, [r, p]), _ = P(() => {
477
+ if (!h)
480
478
  return;
481
- const S = n.filter((O) => O.selected);
482
- C(S.map((O) => O.id)), u && S.forEach((O) => u(O, !1));
483
- }, [n, C, u]), Z = T(() => n.some((S) => S.selected && !S.quantumOwned), [n]), J = T(() => n.some((S) => S.selected), [n]), D = T(() => n.some((S) => S.selected && S.quantumOwned), [n]);
484
- return /* @__PURE__ */ e.jsxs(re, { ...I, children: [
485
- /* @__PURE__ */ e.jsxs(ye, { alignContent: "space-between", gap: 4, children: [
486
- (o || h || C) && /* @__PURE__ */ e.jsxs(Le, { mb: "1rem", gap: 4, children: [
487
- o && /* @__PURE__ */ e.jsxs(
488
- ee,
479
+ const t = r.filter((o) => o.selected);
480
+ h(t.map((o) => o.id)), u && t.forEach((o) => u(o, !1));
481
+ }, [r, h, u]), J = k(() => r.some((t) => t.selected && !t.quantumOwned), [r]), W = k(() => r.some((t) => t.selected), [r]), K = k(() => r.some((t) => t.selected && t.quantumOwned), [r]), l = P(
482
+ (t, o) => {
483
+ const b = Z.find((q) => q.key === t);
484
+ if (!b) return;
485
+ const U = b.multi ? (o ?? []).map((q) => q.id) : o ? [o.id] : [];
486
+ F((q) => [...q.filter((D) => Object.values(O).flat().find((ge) => ge.id === D) && !Object.keys(O).find(
487
+ (ge) => O[ge]?.some(
488
+ (ye) => ye.id === D && ge === t
489
+ )
490
+ )), ...U]);
491
+ },
492
+ [Z, O]
493
+ );
494
+ return /* @__PURE__ */ e.jsxs(te, { ...y, children: [
495
+ /* @__PURE__ */ e.jsxs(we, { alignContent: "space-between", gap: 4, children: [
496
+ (a || p || h) && /* @__PURE__ */ e.jsxs(Me, { mb: "1rem", gap: 4, children: [
497
+ a && /* @__PURE__ */ e.jsxs(
498
+ se,
489
499
  {
490
- isDisabled: !o || F,
500
+ isDisabled: !a || w,
491
501
  colorScheme: "blackAlpha",
492
502
  backgroundColor: "gray.700",
493
- onClick: o,
503
+ onClick: a,
494
504
  children: [
495
505
  "Create New ",
496
- _.action
506
+ R.action
497
507
  ]
498
508
  }
499
509
  ),
500
- h && !s && /* @__PURE__ */ e.jsx(
501
- et,
510
+ p && !s && /* @__PURE__ */ e.jsx(
511
+ tt,
502
512
  {
503
- label: D ? Z ? `Quantum-owned ${_.actionPluralLowerCase} are selected and will be skipped` : `Selected ${_.actionPluralLowerCase} are quantum-owned and cannot be deleted` : void 0,
513
+ label: K ? J ? `Quantum-owned ${R.actionPluralLowerCase} are selected and will be skipped` : `Selected ${R.actionPluralLowerCase} are quantum-owned and cannot be deleted` : void 0,
504
514
  shouldWrapChildren: !0,
505
515
  children: /* @__PURE__ */ e.jsx(
506
- ee,
516
+ se,
507
517
  {
508
518
  colorScheme: "gray",
509
- isDisabled: !Z || !h || c,
510
- onClick: W,
519
+ isDisabled: !J || !p || i,
520
+ onClick: T,
511
521
  children: "Delete Selected"
512
522
  }
513
523
  )
514
524
  }
515
525
  ),
516
- C && !s && /* @__PURE__ */ e.jsx(
517
- ee,
526
+ h && !s && /* @__PURE__ */ e.jsx(
527
+ se,
518
528
  {
519
529
  colorScheme: "gray",
520
- isDisabled: !J,
521
- onClick: N,
530
+ isDisabled: !W,
531
+ onClick: _,
522
532
  children: "Duplicate Selected"
523
533
  }
524
534
  )
525
535
  ] }),
526
536
  /* @__PURE__ */ e.jsx(
527
- In,
537
+ Mn,
528
538
  {
529
- setSearch: l,
530
- actions: n,
531
- updateUseCases: v,
532
- hideUseCaseFilter: L
539
+ setSearch: v,
540
+ actions: r,
541
+ updateUseCases: A,
542
+ hideUseCaseFilter: S
533
543
  }
534
544
  )
535
545
  ] }),
536
- /* @__PURE__ */ e.jsx(ft, { mr: "2rem", overflowX: "hidden", ...y, children: /* @__PURE__ */ e.jsxs(bt, { size: "md", variant: "simple", children: [
537
- /* @__PURE__ */ e.jsx(yt, { position: "sticky", top: 0, bg: "white", zIndex: 1, children: /* @__PURE__ */ e.jsxs(We, { children: [
538
- /* @__PURE__ */ e.jsxs(be, { fontWeight: "normal", children: [
546
+ M && O && /* @__PURE__ */ e.jsx(te, { my: 4, children: /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4", children: Z.map((t) => /* @__PURE__ */ e.jsxs(X, { children: [
547
+ /* @__PURE__ */ e.jsx(Xe, { fontSize: "sm", children: t.label }),
548
+ /* @__PURE__ */ e.jsx(
549
+ ue,
550
+ {
551
+ chakraStyles: {
552
+ menu: (o) => ({
553
+ ...o,
554
+ zIndex: 2
555
+ })
556
+ },
557
+ isMulti: t.multi,
558
+ value: O[t.key]?.filter(
559
+ (o) => $.includes(o.id)
560
+ ),
561
+ onChange: (o) => {
562
+ l(
563
+ t.key,
564
+ o
565
+ );
566
+ },
567
+ options: O[t.key],
568
+ placeholder: `Select ${t.multi ? "one or more" : "one"} ${t.label.toLowerCase()}`,
569
+ isClearable: t.multi
570
+ }
571
+ )
572
+ ] }, t.key)) }) }),
573
+ /* @__PURE__ */ e.jsx(Pt, { mr: "2rem", overflowX: "hidden", ...I, children: /* @__PURE__ */ e.jsxs(Et, { size: "md", variant: "simple", children: [
574
+ /* @__PURE__ */ e.jsx(_t, { position: "sticky", top: 0, bg: "white", zIndex: 1, children: /* @__PURE__ */ e.jsxs(ut, { children: [
575
+ /* @__PURE__ */ e.jsxs(Re, { fontWeight: "normal", children: [
539
576
  "(showing ",
540
- B?.length ?? 0,
577
+ V?.length ?? 0,
541
578
  " of",
542
579
  " ",
543
- t ?? n.length,
580
+ n ?? r.length,
544
581
  ")"
545
582
  ] }),
546
- /* @__PURE__ */ e.jsx(be, { children: "Name" }),
547
- /* @__PURE__ */ e.jsx(be, { children: "Sensor Locations" }),
548
- !L && /* @__PURE__ */ e.jsx(be, { children: "Use Case" }),
549
- /* @__PURE__ */ e.jsx(be, {})
583
+ /* @__PURE__ */ e.jsx(Re, { children: "Name" }),
584
+ /* @__PURE__ */ e.jsx(Re, { children: "Sensor Locations" }),
585
+ !S && /* @__PURE__ */ e.jsx(Re, { children: "Use Case" }),
586
+ /* @__PURE__ */ e.jsx(Re, {})
550
587
  ] }) }),
551
- /* @__PURE__ */ e.jsx(vt, { children: B?.map((S) => /* @__PURE__ */ e.jsxs(
552
- We,
588
+ /* @__PURE__ */ e.jsx(zt, { children: V?.map((t) => /* @__PURE__ */ e.jsxs(
589
+ ut,
553
590
  {
554
- className: Ne(
591
+ className: qe(
555
592
  "hover:bg-[#f7f7f7]",
556
593
  !s && "cursor-pointer",
557
- S.selected && "bg-gray-200"
594
+ t.selected && "bg-gray-200"
558
595
  ),
559
596
  onClick: () => {
560
- s || u?.(S, !S.selected);
597
+ s || u?.(t, !t.selected);
561
598
  },
562
599
  children: [
563
- /* @__PURE__ */ e.jsx(Ce, { children: /* @__PURE__ */ e.jsxs(ye, { children: [
564
- !s && /* @__PURE__ */ e.jsx(e.Fragment, { children: S.selected ? /* @__PURE__ */ e.jsx(an, { className: "text-blue-500" }) : /* @__PURE__ */ e.jsx(ln, { className: "text-gray-400" }) }),
565
- (S.quantumOwned || !g) && d && /* @__PURE__ */ e.jsx(
566
- ee,
600
+ /* @__PURE__ */ e.jsx(_e, { children: /* @__PURE__ */ e.jsxs(we, { children: [
601
+ !s && /* @__PURE__ */ e.jsx(e.Fragment, { children: t.selected ? /* @__PURE__ */ e.jsx(xn, { className: "text-blue-500" }) : /* @__PURE__ */ e.jsx(fn, { className: "text-gray-400" }) }),
602
+ (t.quantumOwned || !x) && d && /* @__PURE__ */ e.jsx(
603
+ se,
567
604
  {
568
605
  ml: "1em",
569
606
  size: "sm",
570
607
  variant: "link",
571
608
  colorScheme: "blue",
572
- onClick: (O) => {
573
- O.stopPropagation(), d(S.id);
609
+ onClick: (o) => {
610
+ o.stopPropagation(), d(t.id);
574
611
  },
575
612
  children: "View"
576
613
  }
577
614
  ),
578
- !S.quantumOwned && g && /* @__PURE__ */ e.jsx(
579
- ee,
615
+ !t.quantumOwned && x && /* @__PURE__ */ e.jsx(
616
+ se,
580
617
  {
581
- isDisabled: x,
618
+ isDisabled: g,
582
619
  ml: "1em",
583
620
  size: "sm",
584
621
  variant: "link",
585
622
  colorScheme: "blue",
586
- onClick: (O) => {
587
- O.stopPropagation(), g(S.id);
623
+ onClick: (o) => {
624
+ o.stopPropagation(), x(t.id);
588
625
  },
589
626
  children: "Edit"
590
627
  }
591
628
  )
592
629
  ] }) }),
593
- /* @__PURE__ */ e.jsx(Ce, { whiteSpace: "break-spaces", children: /* @__PURE__ */ e.jsxs(ye, { align: "center", gap: 2, children: [
630
+ /* @__PURE__ */ e.jsx(_e, { whiteSpace: "break-spaces", children: /* @__PURE__ */ e.jsxs(we, { align: "center", gap: 2, children: [
594
631
  /* @__PURE__ */ e.jsx(
595
- Fn,
632
+ Rn,
596
633
  {
597
- action: S,
598
- quantumIconSrc: j
634
+ action: t,
635
+ quantumIconSrc: c
599
636
  }
600
637
  ),
601
- S.name
638
+ t.name
602
639
  ] }) }),
603
- /* @__PURE__ */ e.jsx(Ce, { maxW: "20rem", whiteSpace: "break-spaces", children: $n(S.sensorLocations) }),
604
- !L && /* @__PURE__ */ e.jsx(Ce, { maxW: "20rem", children: /* @__PURE__ */ e.jsx(
605
- Rn,
640
+ /* @__PURE__ */ e.jsx(_e, { maxW: "20rem", whiteSpace: "break-spaces", children: $n(t.sensorLocations) }),
641
+ !S && /* @__PURE__ */ e.jsx(_e, { maxW: "20rem", children: /* @__PURE__ */ e.jsx(
642
+ kn,
606
643
  {
607
644
  containerProps: { flexWrap: "wrap" },
608
- tags: S.useCases?.map((O) => O.name) ?? []
645
+ tags: t.useCases?.map((o) => o.name) ?? []
609
646
  }
610
647
  ) })
611
648
  ]
612
649
  },
613
- S.id
650
+ t.id
614
651
  )) })
615
652
  ] }) })
616
653
  ] });
617
- }, us = ({
618
- onSave: n,
619
- onCancel: t,
620
- onError: o,
621
- hideButtons: h = !1,
622
- setButtonDisabled: g,
654
+ }, hs = ({
655
+ onSave: r,
656
+ onCancel: n,
657
+ onError: a,
658
+ hideButtons: p = !1,
659
+ setButtonDisabled: x,
623
660
  setButtonOnClick: d,
624
661
  quantumOwned: u
625
662
  }) => {
626
- const C = Ct(), { getLabel: s } = xe(), c = T(() => ({
663
+ const h = yt(), { getLabel: s } = pe(), i = k(() => ({
627
664
  singular: s("action"),
628
665
  plural: s("action_plural"),
629
666
  pluralLowerCase: s("action_plural").toLowerCase(),
630
667
  singularLowerCase: s("action").toLowerCase()
631
- }), [s]), [x, F] = z("copy"), [L, y] = z(""), [I, j] = z([]), [m, l] = z(!1), [a] = je({
632
- query: Mt
633
- }), [v] = je({
634
- query: dn,
635
- variables: { groupId: L },
636
- pause: !L
668
+ }), [s]), [g, w] = B("copy"), [S, M] = B(""), [I, y] = B([]), [c, m] = B(!1), [v] = Ce({
669
+ query: St
670
+ }), [j] = Ce({
671
+ query: rn,
672
+ variables: { groupId: S },
673
+ pause: !S
637
674
  // Only run when group is selected
638
- }), [, w] = me(tt), [, _] = me(
639
- It
640
- ), B = T(() => a.data?.groups ? a.data.groups.map(
641
- (i) => R(Ot, i)
642
- ) : [], [a.data]), W = T(() => v.data ? v.data.actions.map((r) => {
643
- const f = R(fe, r), A = R(
644
- nt,
645
- f.reports
646
- ), U = R(
647
- ke,
648
- f.categories
649
- ), q = R(
650
- Ye,
651
- f.metadataGroups
652
- ).map((Y) => ({
653
- ...Y,
654
- data: Y.data.map((K) => R(He, K))
675
+ }), [, A] = fe(st), [, $] = fe(
676
+ Lt
677
+ ), F = k(() => v.data?.groups ? v.data.groups.map(
678
+ (l) => L(It, l)
679
+ ) : [], [v.data]), O = k(() => j.data ? j.data.actions.map((t) => {
680
+ const o = L(ve, t), b = L(
681
+ Ze,
682
+ o.reports
683
+ ), U = L(
684
+ $e,
685
+ o.categories
686
+ ), E = L(
687
+ je,
688
+ o.metadataGroups
689
+ ).map((D) => ({
690
+ ...D,
691
+ data: D.data.map((Y) => L(be, Y))
655
692
  }));
656
693
  return {
657
- ...f,
658
- thresholds: R(Se, f.thresholds),
659
- reports: A.map((Y) => ({
660
- ...Y,
661
- thresholds: R(Se, Y.thresholds)
694
+ ...o,
695
+ thresholds: L(Ie, o.thresholds),
696
+ reports: b.map((D) => ({
697
+ ...D,
698
+ thresholds: L(Ie, D.thresholds)
662
699
  })),
663
700
  categories: U,
664
- metadataGroups: q
701
+ metadataGroups: E
665
702
  };
666
- }) : [], [v.data]), N = T(() => W.filter(
667
- (i) => I.includes(i.id)
668
- ), [W, I]), Z = $(
669
- (i) => {
670
- const r = i?.value || "";
671
- y(r), j([]);
703
+ }) : [], [j.data]), N = k(() => O.filter(
704
+ (l) => I.includes(l.id)
705
+ ), [O, I]), H = P(
706
+ (l) => {
707
+ const t = l?.value || "";
708
+ M(t), y([]);
672
709
  },
673
710
  []
674
- ), J = $(
675
- (i) => {
676
- const r = i.map((f) => f.value);
677
- j(r);
711
+ ), oe = P(
712
+ (l) => {
713
+ const t = l.map((o) => o.value);
714
+ y(t);
678
715
  },
679
716
  []
680
- ), D = $(
681
- async (i) => {
682
- const r = {
683
- ...i,
684
- name: `${i.name} (Copy)`,
717
+ ), R = P(
718
+ async (l) => {
719
+ const t = {
720
+ ...l,
721
+ name: `${l.name} (Copy)`,
685
722
  // Add "(Copy)" suffix to distinguish
686
- description: i.description || void 0,
687
- instructionsPointOfInterest: i.instructionsPointOfInterest || void 0,
688
- instructionsMovementReport: i.instructionsMovementReport || void 0,
689
- laterality: i.laterality,
690
- activityKind: i.activityKind,
691
- sensorLocations: i.sensorLocations,
692
- thresholds: i.thresholds.map((A) => ({
693
- ...A,
723
+ description: l.description || void 0,
724
+ instructionsPointOfInterest: l.instructionsPointOfInterest || void 0,
725
+ instructionsMovementReport: l.instructionsMovementReport || void 0,
726
+ laterality: l.laterality,
727
+ activityKind: l.activityKind,
728
+ sensorLocations: l.sensorLocations,
729
+ thresholds: l.thresholds.map((b) => ({
730
+ ...b,
694
731
  id: void 0
695
732
  })),
696
- categories: i.categories.map((A) => A.id),
733
+ categories: l.categories.map((b) => b.id),
697
734
  quantumOwned: u,
698
- metadataItemIds: i.metadataGroups.flatMap((A) => A.data.map((U) => U.id)).filter((A) => A !== void 0),
699
- reports: i.reports.map((A) => ({
700
- ...A,
735
+ metadataItemIds: l.metadataGroups.flatMap((b) => b.data.map((U) => U.id)).filter((b) => b !== void 0),
736
+ reports: l.reports.map((b) => ({
737
+ ...b,
701
738
  id: void 0,
702
- thresholds: A.thresholds.map((U) => ({
739
+ thresholds: b.thresholds.map((U) => ({
703
740
  ...U,
704
741
  id: void 0
705
742
  }))
706
743
  })),
707
744
  id: void 0
708
- }, f = await w({ fields: r });
709
- if (f.error) throw new Error(f.error.message);
710
- if (f.data?.createAction)
711
- return R(fe, f.data.createAction);
745
+ }, o = await A({ fields: t });
746
+ if (o.error) throw new Error(o.error.message);
747
+ if (o.data?.createAction)
748
+ return L(ve, o.data.createAction);
712
749
  throw new Error("No action data returned");
713
750
  },
714
- [w, u]
715
- ), S = $(
716
- async (i) => {
717
- const r = await _({ id: i.id });
718
- if (r.error)
719
- throw new Error(r.error.message);
720
- if (r.data?.convertActionToQuantumOwned)
721
- return R(
722
- fe,
723
- r.data.convertActionToQuantumOwned
751
+ [A, u]
752
+ ), Z = P(
753
+ async (l) => {
754
+ const t = await $({ id: l.id });
755
+ if (t.error)
756
+ throw new Error(t.error.message);
757
+ if (t.data?.convertActionToQuantumOwned)
758
+ return L(
759
+ ve,
760
+ t.data.convertActionToQuantumOwned
724
761
  );
725
762
  throw new Error("No action data returned");
726
763
  },
727
- [_]
728
- ), O = $(async () => {
729
- if (l(!0), !N.length) {
730
- const i = new Error(
731
- `No ${c.pluralLowerCase} selected for ${x === "copy" ? "copying" : "converting"}`
764
+ [$]
765
+ ), V = P(async () => {
766
+ if (m(!0), !N.length) {
767
+ const l = new Error(
768
+ `No ${i.pluralLowerCase} selected for ${g === "copy" ? "copying" : "converting"}`
732
769
  );
733
- o?.(i), l(!1);
770
+ a?.(l), m(!1);
734
771
  return;
735
772
  }
736
773
  try {
737
- const i = [];
738
- let r = 0;
739
- const f = x === "copy" ? D : S, A = x === "copy" ? "copy" : "convert";
774
+ const l = [];
775
+ let t = 0;
776
+ const o = g === "copy" ? R : Z, b = g === "copy" ? "copy" : "convert";
740
777
  for (const U of N)
741
778
  try {
742
- const ne = await f(U);
743
- i.push(ne);
744
- } catch (ne) {
779
+ const q = await o(U);
780
+ l.push(q);
781
+ } catch (q) {
745
782
  console.error(
746
- `Failed to ${A} ${c.singularLowerCase} "${U.name}":`,
747
- ne
748
- ), r++;
783
+ `Failed to ${b} ${i.singularLowerCase} "${U.name}":`,
784
+ q
785
+ ), t++;
749
786
  }
750
- if (i.length > 0) {
751
- const U = i.length, ne = N.length, q = x === "copy" ? "copied" : "converted", Y = x === "copy" ? "copy" : "convert";
752
- C({
753
- title: r > 0 ? `Partial ${Y} completed` : `${c.plural} ${q} successfully`,
754
- description: r > 0 ? `${U} of ${ne} ${c.pluralLowerCase} ${q} successfully` : `${U} ${U > 1 ? c.pluralLowerCase : c.singularLowerCase} ${q} successfully`,
755
- status: r > 0 ? "warning" : "success",
787
+ if (l.length > 0) {
788
+ const U = l.length, q = N.length, E = g === "copy" ? "copied" : "converted", D = g === "copy" ? "copy" : "convert";
789
+ h({
790
+ title: t > 0 ? `Partial ${D} completed` : `${i.plural} ${E} successfully`,
791
+ description: t > 0 ? `${U} of ${q} ${i.pluralLowerCase} ${E} successfully` : `${U} ${U > 1 ? i.pluralLowerCase : i.singularLowerCase} ${E} successfully`,
792
+ status: t > 0 ? "warning" : "success",
756
793
  duration: 3e3,
757
794
  isClosable: !0
758
- }), n?.(), y(""), j([]);
795
+ }), r?.(), M(""), y([]);
759
796
  } else
760
797
  throw new Error(
761
- `Failed to ${A} any ${c.pluralLowerCase}`
798
+ `Failed to ${b} any ${i.pluralLowerCase}`
762
799
  );
763
- } catch (i) {
764
- const r = x === "copy" ? "copy" : "convert", f = i instanceof Error ? i.message : `Failed to ${r} ${c.pluralLowerCase}`;
765
- C({
766
- title: `${x === "copy" ? "Copy" : "Convert"} failed`,
767
- description: f,
800
+ } catch (l) {
801
+ const t = g === "copy" ? "copy" : "convert", o = l instanceof Error ? l.message : `Failed to ${t} ${i.pluralLowerCase}`;
802
+ h({
803
+ title: `${g === "copy" ? "Copy" : "Convert"} failed`,
804
+ description: o,
768
805
  status: "error",
769
806
  duration: 5e3,
770
807
  isClosable: !0
771
- }), o?.(i instanceof Error ? i : new Error(f));
808
+ }), a?.(l instanceof Error ? l : new Error(o));
772
809
  } finally {
773
- l(!1);
810
+ m(!1);
774
811
  }
775
812
  }, [
776
813
  N,
777
- x,
778
- D,
779
- S,
780
- C,
781
- n,
782
- o,
783
- c
784
- ]), M = $(() => {
785
- y(""), j([]), F("copy"), t?.();
786
- }, [t]);
787
- ce(() => {
788
- g && g({
814
+ g,
815
+ R,
816
+ Z,
817
+ h,
818
+ r,
819
+ a,
820
+ i
821
+ ]), T = P(() => {
822
+ M(""), y([]), w("copy"), n?.();
823
+ }, [n]);
824
+ ie(() => {
825
+ x && x({
789
826
  cancelButton: !1,
790
- saveButton: N.length === 0 || m
827
+ saveButton: N.length === 0 || c
791
828
  });
792
- }, [N.length, m, g]), ce(() => {
829
+ }, [N.length, c, x]), ie(() => {
793
830
  d && d({
794
- cancelButton: M,
795
- saveButton: O
831
+ cancelButton: T,
832
+ saveButton: V
796
833
  });
797
- }, [d, M, O]);
798
- const E = T(() => B.map((i) => ({
799
- value: i.id,
800
- label: i.name
801
- })), [B]), te = T(() => W.filter((i) => x === "copy" ? !0 : !i.quantumOwned).map((i) => ({
802
- value: i.id,
803
- label: i.name,
834
+ }, [d, T, V]);
835
+ const _ = k(() => F.map((l) => ({
836
+ value: l.id,
837
+ label: l.name
838
+ })), [F]), J = k(() => O.filter((l) => g === "copy" ? !0 : !l.quantumOwned).map((l) => ({
839
+ value: l.id,
840
+ label: l.name,
804
841
  // Add custom data to identify quantum-owned actions for UI display
805
- isQuantumOwned: i.quantumOwned
806
- })), [W, x]), Q = a.fetching, ie = v.fetching;
807
- return /* @__PURE__ */ e.jsx(re, { children: /* @__PURE__ */ e.jsxs(le, { spacing: 6, align: "stretch", children: [
842
+ isQuantumOwned: l.quantumOwned
843
+ })), [O, g]), W = v.fetching, K = j.fetching;
844
+ return /* @__PURE__ */ e.jsx(te, { children: /* @__PURE__ */ e.jsxs(le, { spacing: 6, align: "stretch", children: [
808
845
  u && /* @__PURE__ */ e.jsxs(X, { children: [
809
- /* @__PURE__ */ e.jsx(pe, { children: "Operation Mode" }),
846
+ /* @__PURE__ */ e.jsx(he, { children: "Operation Mode" }),
810
847
  /* @__PURE__ */ e.jsx(
811
- wt,
848
+ vt,
812
849
  {
813
- value: x,
814
- onChange: (i) => {
815
- F(i), j([]);
850
+ value: g,
851
+ onChange: (l) => {
852
+ w(l), y([]);
816
853
  },
817
- children: /* @__PURE__ */ e.jsxs(oe, { spacing: 6, children: [
818
- /* @__PURE__ */ e.jsx(Qe, { value: "copy", colorScheme: "blue", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
819
- /* @__PURE__ */ e.jsxs(b, { fontWeight: "medium", children: [
854
+ children: /* @__PURE__ */ e.jsxs(re, { spacing: 6, children: [
855
+ /* @__PURE__ */ e.jsx(Ye, { value: "copy", colorScheme: "blue", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
856
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "medium", children: [
820
857
  "Copy ",
821
- c.plural
858
+ i.plural
822
859
  ] }),
823
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
860
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
824
861
  "Create new ",
825
- c.plural.toLocaleLowerCase(),
862
+ i.plural.toLocaleLowerCase(),
826
863
  " ",
827
864
  "based on selected ones"
828
865
  ] })
829
866
  ] }) }),
830
- /* @__PURE__ */ e.jsx(Qe, { value: "convert", colorScheme: "green", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
831
- /* @__PURE__ */ e.jsxs(b, { fontWeight: "medium", children: [
867
+ /* @__PURE__ */ e.jsx(Ye, { value: "convert", colorScheme: "green", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
868
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "medium", children: [
832
869
  "Convert to Quantum Owned ",
833
- c.singular
870
+ i.singular
834
871
  ] }),
835
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
872
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
836
873
  "Convert existing",
837
874
  " ",
838
- c.plural.toLocaleLowerCase(),
875
+ i.plural.toLocaleLowerCase(),
839
876
  " to quantum-owned"
840
877
  ] })
841
878
  ] }) })
@@ -844,87 +881,87 @@ const In = ({
844
881
  )
845
882
  ] }),
846
883
  /* @__PURE__ */ e.jsxs(X, { children: [
847
- /* @__PURE__ */ e.jsx(pe, { children: "Select Source Group" }),
884
+ /* @__PURE__ */ e.jsx(he, { children: "Select Source Group" }),
848
885
  /* @__PURE__ */ e.jsx(
849
- ge,
886
+ ue,
850
887
  {
851
888
  placeholder: "Choose a group...",
852
- options: E,
853
- value: E.find((i) => i.value === L) || null,
854
- onChange: Z,
855
- isLoading: Q,
856
- isDisabled: Q,
889
+ options: _,
890
+ value: _.find((l) => l.value === S) || null,
891
+ onChange: H,
892
+ isLoading: W,
893
+ isDisabled: W,
857
894
  isClearable: !0
858
895
  }
859
896
  ),
860
- a.error && /* @__PURE__ */ e.jsxs(qe, { status: "error", mt: 2, children: [
861
- /* @__PURE__ */ e.jsx(Ke, {}),
862
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", children: [
897
+ v.error && /* @__PURE__ */ e.jsxs(He, { status: "error", mt: 2, children: [
898
+ /* @__PURE__ */ e.jsx(Je, {}),
899
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", children: [
863
900
  "Failed to load groups: ",
864
- a.error.message
901
+ v.error.message
865
902
  ] })
866
903
  ] })
867
904
  ] }),
868
- L && /* @__PURE__ */ e.jsxs(X, { children: [
869
- /* @__PURE__ */ e.jsxs(pe, { children: [
905
+ S && /* @__PURE__ */ e.jsxs(X, { children: [
906
+ /* @__PURE__ */ e.jsxs(he, { children: [
870
907
  "Select ",
871
- c.plural,
908
+ i.plural,
872
909
  " to",
873
910
  " ",
874
- x === "copy" ? "Copy" : "Convert"
911
+ g === "copy" ? "Copy" : "Convert"
875
912
  ] }),
876
- ie ? /* @__PURE__ */ e.jsxs(oe, { children: [
877
- /* @__PURE__ */ e.jsx(St, { size: "sm" }),
878
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
913
+ K ? /* @__PURE__ */ e.jsxs(re, { children: [
914
+ /* @__PURE__ */ e.jsx(Ct, { size: "sm" }),
915
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
879
916
  "Loading ",
880
- c.pluralLowerCase,
917
+ i.pluralLowerCase,
881
918
  "..."
882
919
  ] })
883
920
  ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
884
921
  /* @__PURE__ */ e.jsx(
885
- ge,
922
+ ue,
886
923
  {
887
- placeholder: `Choose ${c.pluralLowerCase} to ${x}...`,
888
- options: te,
889
- value: te.filter(
890
- (i) => I.includes(i.value)
924
+ placeholder: `Choose ${i.pluralLowerCase} to ${g}...`,
925
+ options: J,
926
+ value: J.filter(
927
+ (l) => I.includes(l.value)
891
928
  ),
892
- onChange: J,
893
- isDisabled: te.length === 0,
929
+ onChange: oe,
930
+ isDisabled: J.length === 0,
894
931
  isClearable: !0,
895
932
  isMulti: !0,
896
933
  closeMenuOnSelect: !1,
897
- formatOptionLabel: (i, { context: r }) => /* @__PURE__ */ e.jsxs(oe, { justify: "space-between", w: "100%", children: [
934
+ formatOptionLabel: (l, { context: t }) => /* @__PURE__ */ e.jsxs(re, { justify: "space-between", w: "100%", children: [
898
935
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
899
- /* @__PURE__ */ e.jsx(b, { children: i.label }),
900
- r === "value" && i.isQuantumOwned && /* @__PURE__ */ e.jsx(b, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
936
+ /* @__PURE__ */ e.jsx(C, { children: l.label }),
937
+ t === "value" && l.isQuantumOwned && /* @__PURE__ */ e.jsx(C, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
901
938
  ] }),
902
- i.isQuantumOwned && r === "menu" && /* @__PURE__ */ e.jsx(Re, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
939
+ l.isQuantumOwned && t === "menu" && /* @__PURE__ */ e.jsx(Ne, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
903
940
  ] })
904
941
  }
905
942
  ),
906
- te.length === 0 && /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.500", mt: 2, children: [
943
+ J.length === 0 && /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.500", mt: 2, children: [
907
944
  "No ",
908
- c.pluralLowerCase,
945
+ i.pluralLowerCase,
909
946
  " found"
910
947
  ] })
911
948
  ] }),
912
- v.error && /* @__PURE__ */ e.jsxs(qe, { status: "error", mt: 2, children: [
913
- /* @__PURE__ */ e.jsx(Ke, {}),
914
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", children: [
949
+ j.error && /* @__PURE__ */ e.jsxs(He, { status: "error", mt: 2, children: [
950
+ /* @__PURE__ */ e.jsx(Je, {}),
951
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", children: [
915
952
  "Failed to load ",
916
- c.pluralLowerCase,
953
+ i.pluralLowerCase,
917
954
  ":",
918
955
  " ",
919
- v.error.message
956
+ j.error.message
920
957
  ] })
921
958
  ] })
922
959
  ] }),
923
- N.length > 0 && /* @__PURE__ */ e.jsxs(re, { p: 4, bg: "gray.50", borderRadius: "md", children: [
924
- /* @__PURE__ */ e.jsx(b, { fontWeight: "semibold", mb: 3, children: N.length === 1 ? `${c.singular} to ${x === "copy" ? "Copy" : "Convert"}:` : `${N.length} ${c.plural} to ${x === "copy" ? "Copy" : "Convert"}:` }),
960
+ N.length > 0 && /* @__PURE__ */ e.jsxs(te, { p: 4, bg: "gray.50", borderRadius: "md", children: [
961
+ /* @__PURE__ */ e.jsx(C, { fontWeight: "semibold", mb: 3, children: N.length === 1 ? `${i.singular} to ${g === "copy" ? "Copy" : "Convert"}:` : `${N.length} ${i.plural} to ${g === "copy" ? "Copy" : "Convert"}:` }),
925
962
  /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 3, children: [
926
- N.map((i, r) => /* @__PURE__ */ e.jsxs(
927
- re,
963
+ N.map((l, t) => /* @__PURE__ */ e.jsxs(
964
+ te,
928
965
  {
929
966
  w: "100%",
930
967
  p: 3,
@@ -933,13 +970,13 @@ const In = ({
933
970
  border: "1px solid",
934
971
  borderColor: "gray.200",
935
972
  children: [
936
- /* @__PURE__ */ e.jsxs(oe, { justify: "space-between", align: "start", mb: 2, children: [
937
- /* @__PURE__ */ e.jsxs(b, { fontWeight: "medium", fontSize: "sm", children: [
938
- r + 1,
973
+ /* @__PURE__ */ e.jsxs(re, { justify: "space-between", align: "start", mb: 2, children: [
974
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "medium", fontSize: "sm", children: [
975
+ t + 1,
939
976
  ". ",
940
- i.name
977
+ l.name
941
978
  ] }),
942
- i.quantumOwned && /* @__PURE__ */ e.jsx(Re, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
979
+ l.quantumOwned && /* @__PURE__ */ e.jsx(Ne, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
943
980
  ] }),
944
981
  /* @__PURE__ */ e.jsxs(
945
982
  le,
@@ -949,45 +986,45 @@ const In = ({
949
986
  fontSize: "sm",
950
987
  color: "gray.600",
951
988
  children: [
952
- i.description && /* @__PURE__ */ e.jsxs(b, { children: [
989
+ l.description && /* @__PURE__ */ e.jsxs(C, { children: [
953
990
  /* @__PURE__ */ e.jsx("strong", { children: "Description:" }),
954
991
  " ",
955
- i.description
992
+ l.description
956
993
  ] }),
957
- /* @__PURE__ */ e.jsxs(b, { children: [
994
+ /* @__PURE__ */ e.jsxs(C, { children: [
958
995
  /* @__PURE__ */ e.jsx("strong", { children: "Type:" }),
959
996
  " ",
960
- i.activityKind
997
+ l.activityKind
961
998
  ] }),
962
- /* @__PURE__ */ e.jsxs(b, { children: [
999
+ /* @__PURE__ */ e.jsxs(C, { children: [
963
1000
  /* @__PURE__ */ e.jsx("strong", { children: "Laterality:" }),
964
1001
  " ",
965
- i.laterality
1002
+ l.laterality
966
1003
  ] }),
967
- /* @__PURE__ */ e.jsxs(b, { children: [
1004
+ /* @__PURE__ */ e.jsxs(C, { children: [
968
1005
  /* @__PURE__ */ e.jsx("strong", { children: "Sensor Locations:" }),
969
1006
  " ",
970
- i.sensorLocations.length
1007
+ l.sensorLocations.length
971
1008
  ] }),
972
- /* @__PURE__ */ e.jsxs(b, { children: [
1009
+ /* @__PURE__ */ e.jsxs(C, { children: [
973
1010
  /* @__PURE__ */ e.jsx("strong", { children: "Thresholds:" }),
974
1011
  " ",
975
- i.thresholds.length
1012
+ l.thresholds.length
976
1013
  ] }),
977
- /* @__PURE__ */ e.jsxs(b, { children: [
1014
+ /* @__PURE__ */ e.jsxs(C, { children: [
978
1015
  /* @__PURE__ */ e.jsx("strong", { children: "Use Cases:" }),
979
1016
  " ",
980
- i.useCases.map((f) => f.name).join(", ") || "None"
1017
+ l.useCases.map((o) => o.name).join(", ") || "None"
981
1018
  ] })
982
1019
  ]
983
1020
  }
984
1021
  )
985
1022
  ]
986
1023
  },
987
- i.id
1024
+ l.id
988
1025
  )),
989
1026
  N.length > 1 && /* @__PURE__ */ e.jsx(
990
- re,
1027
+ te,
991
1028
  {
992
1029
  w: "100%",
993
1030
  p: 2,
@@ -995,312 +1032,321 @@ const In = ({
995
1032
  borderRadius: "md",
996
1033
  border: "1px solid",
997
1034
  borderColor: "blue.200",
998
- children: /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
1035
+ children: /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
999
1036
  "Total: ",
1000
1037
  N.length,
1001
1038
  " ",
1002
- c.pluralLowerCase,
1039
+ i.pluralLowerCase,
1003
1040
  " will be",
1004
1041
  " ",
1005
- x === "copy" ? "copied" : "converted"
1042
+ g === "copy" ? "copied" : "converted"
1006
1043
  ] })
1007
1044
  }
1008
1045
  )
1009
1046
  ] })
1010
1047
  ] }),
1011
- !h && /* @__PURE__ */ e.jsxs(Le, { spacing: 4, justifyContent: "flex-end", children: [
1048
+ !p && /* @__PURE__ */ e.jsxs(Me, { spacing: 4, justifyContent: "flex-end", children: [
1012
1049
  /* @__PURE__ */ e.jsx(
1013
- ee,
1050
+ se,
1014
1051
  {
1015
1052
  variant: "outline",
1016
- onClick: M,
1017
- isDisabled: m,
1053
+ onClick: T,
1054
+ isDisabled: c,
1018
1055
  children: "Cancel"
1019
1056
  }
1020
1057
  ),
1021
1058
  /* @__PURE__ */ e.jsxs(
1022
- ee,
1059
+ se,
1023
1060
  {
1024
- colorScheme: x === "copy" ? "blue" : "green",
1025
- onClick: O,
1026
- isDisabled: N.length === 0 || m,
1027
- isLoading: m,
1028
- loadingText: `${x === "copy" ? "Copying" : "Converting"}...`,
1061
+ colorScheme: g === "copy" ? "blue" : "green",
1062
+ onClick: V,
1063
+ isDisabled: N.length === 0 || c,
1064
+ isLoading: c,
1065
+ loadingText: `${g === "copy" ? "Copying" : "Converting"}...`,
1029
1066
  children: [
1030
- x === "copy" ? "Copy" : "Convert",
1067
+ g === "copy" ? "Copy" : "Convert",
1031
1068
  " ",
1032
- N.length === 1 ? c.singular : `${N.length} ${c.plural}`
1069
+ N.length === 1 ? i.singular : `${N.length} ${i.plural}`
1033
1070
  ]
1034
1071
  }
1035
1072
  )
1036
1073
  ] })
1037
1074
  ] }) });
1038
- }, hs = ({
1039
- onSave: n,
1040
- onCancel: t,
1041
- onError: o,
1042
- hideButtons: h = !1,
1043
- setButtonDisabled: g,
1075
+ }, ps = ({
1076
+ onSave: r,
1077
+ onCancel: n,
1078
+ onError: a,
1079
+ hideButtons: p = !1,
1080
+ setButtonDisabled: x,
1044
1081
  setButtonOnClick: d,
1045
1082
  quantumOwned: u
1046
1083
  }) => {
1047
- const C = Ct(), { getLabel: s } = xe(), c = T(() => ({
1084
+ const h = yt(), { getLabel: s } = pe(), i = k(() => ({
1048
1085
  singular: s("module"),
1049
1086
  plural: s("module_plural"),
1050
1087
  pluralLowerCase: s("module_plural").toLowerCase(),
1051
1088
  singularLowerCase: s("module").toLowerCase()
1052
- }), [s]), x = T(() => ({
1089
+ }), [s]), g = k(() => ({
1053
1090
  singular: s("action"),
1054
1091
  plural: s("action_plural"),
1055
1092
  pluralLowerCase: s("action_plural").toLowerCase(),
1056
1093
  singularLowerCase: s("action").toLowerCase()
1057
- }), [s]), [F, L] = z(""), [y, I] = z([]), [j, m] = z(!1), [l, a] = z("copy"), [v] = je({
1058
- query: Mt
1059
- }), [w] = je({
1060
- query: un,
1061
- variables: { groupId: F },
1062
- pause: !F
1094
+ }), [s]), [w, S] = B(""), [M, I] = B([]), [y, c] = B(!1), [m, v] = B("copy"), [j] = Ce({
1095
+ query: St
1096
+ }), [A] = Ce({
1097
+ query: on,
1098
+ variables: { groupId: w },
1099
+ pause: !w
1063
1100
  // Only run when group is selected
1064
- }), [, _] = me(At), [, B] = me(Tt), [, W] = me(tt), [, N] = me(
1065
- It
1066
- ), Z = T(() => v.data?.groups ? v.data.groups.map(
1067
- (r) => R(Ot, r)
1068
- ) : [], [v.data]), J = T(() => w.data?.modules ? R(
1069
- Be,
1070
- w.data?.modules
1071
- ).map((f) => {
1072
- const A = R(
1073
- Nt,
1074
- f.moduleActions
1075
- );
1101
+ }), [, $] = fe(Mt), [, F] = fe(Ot), [, O] = fe(st), [, N] = fe(
1102
+ Lt
1103
+ ), H = k(() => j.data?.groups ? j.data.groups.map(
1104
+ (t) => L(It, t)
1105
+ ) : [], [j.data]), oe = k(() => A.data?.modules ? L(
1106
+ Qe,
1107
+ A.data?.modules
1108
+ ).map((o) => {
1109
+ const b = L(
1110
+ At,
1111
+ o.moduleActions
1112
+ ), q = L(
1113
+ je,
1114
+ o.metadataGroups
1115
+ ).map((E) => L(be, E.data)).flat();
1076
1116
  return {
1077
- ...f,
1078
- moduleActions: A.map((U) => ({
1079
- ...U,
1080
- action: R(fe, U.action)
1117
+ ...o,
1118
+ moduleActions: b.map((E) => ({
1119
+ ...E,
1120
+ action: L(ve, E.action)
1081
1121
  })),
1082
- categories: R(
1083
- ke,
1084
- f.categories
1085
- )
1122
+ categories: L(
1123
+ $e,
1124
+ o.categories
1125
+ ),
1126
+ metadataItems: q
1086
1127
  };
1087
- }) : [], [w.data]), D = T(() => J.filter(
1088
- (r) => y.includes(r.id)
1089
- ), [J, y]), S = $(
1090
- (r) => {
1091
- const f = r?.value || "";
1092
- L(f), I([]);
1128
+ }) : [], [A.data]), R = k(() => oe.filter(
1129
+ (t) => M.includes(t.id)
1130
+ ), [oe, M]), Z = P(
1131
+ (t) => {
1132
+ const o = t?.value || "";
1133
+ S(o), I([]);
1093
1134
  },
1094
1135
  []
1095
- ), O = $(
1096
- (r) => {
1097
- const f = r.map((A) => A.value);
1098
- I(f);
1136
+ ), V = P(
1137
+ (t) => {
1138
+ const o = t.map((b) => b.value);
1139
+ I(o);
1099
1140
  },
1100
1141
  []
1101
- ), M = $(async () => {
1102
- if (m(!0), !D.length) {
1103
- m(!1);
1104
- const r = new Error(
1105
- `No modules selected for ${l === "convert" ? "converting" : "copying"}`
1142
+ ), T = P(async () => {
1143
+ if (c(!0), !R.length) {
1144
+ c(!1);
1145
+ const t = new Error(
1146
+ `No modules selected for ${m === "convert" ? "converting" : "copying"}`
1106
1147
  );
1107
- o?.(r);
1148
+ a?.(t);
1108
1149
  return;
1109
1150
  }
1110
1151
  try {
1111
- const r = [];
1112
- let f = 0;
1113
- for (const A of D)
1152
+ const t = [];
1153
+ let o = 0;
1154
+ for (const b of R)
1114
1155
  try {
1115
- let U = A.moduleActions.map((ne) => ne.actionId);
1156
+ let U = b.moduleActions.map((q) => q.actionId);
1116
1157
  if (u) {
1117
- const ne = A.moduleActions.map((K) => K.action), q = async (K) => {
1118
- if (l === "copy") {
1119
- if (K.quantumOwned) return K;
1120
- const ve = R(
1121
- ke,
1122
- K.categories
1123
- ), Pe = R(
1124
- Ye,
1125
- K.metadataGroups
1126
- ).map((he) => R(
1127
- He,
1128
- he.data
1129
- ).map((Te) => Te.id)).flat(), Ie = R(
1130
- nt,
1131
- K.reports
1132
- ).map((he) => ({
1133
- ...he,
1158
+ const q = b.moduleActions.map((Y) => Y.action), E = async (Y) => {
1159
+ if (m === "copy") {
1160
+ if (Y.quantumOwned) return Y;
1161
+ const ye = L(
1162
+ $e,
1163
+ Y.categories
1164
+ ), Ge = L(
1165
+ je,
1166
+ Y.metadataGroups
1167
+ ).map((xe) => L(
1168
+ be,
1169
+ xe.data
1170
+ ).map((Te) => Te.id)).flat(), Oe = L(
1171
+ Ze,
1172
+ Y.reports
1173
+ ).map((xe) => ({
1174
+ ...xe,
1134
1175
  id: void 0,
1135
- thresholds: R(
1136
- Se,
1137
- he.thresholds
1176
+ thresholds: L(
1177
+ Ie,
1178
+ xe.thresholds
1138
1179
  ).map((Te) => ({
1139
1180
  ...Te,
1140
1181
  id: void 0
1141
1182
  }))
1142
- })), Oe = R(
1143
- Se,
1144
- K.thresholds
1145
- ).map((he) => ({
1146
- ...he,
1183
+ })), Ae = L(
1184
+ Ie,
1185
+ Y.thresholds
1186
+ ).map((xe) => ({
1187
+ ...xe,
1147
1188
  id: void 0
1148
- })), $e = {
1149
- ...K,
1189
+ })), Pe = {
1190
+ ...Y,
1150
1191
  quantumOwned: !0,
1151
- thresholds: Oe,
1152
- categories: ve?.map((he) => he.id),
1153
- reports: Ie,
1154
- metadataIds: Pe,
1192
+ thresholds: Ae,
1193
+ categories: ye?.map((xe) => xe.id),
1194
+ reports: Oe,
1195
+ metadataIds: Ge,
1155
1196
  id: void 0
1156
- }, Ae = await W({ fields: $e });
1157
- return Ae.error || !Ae.data?.createAction ? null : R(
1158
- fe,
1159
- Ae.data.createAction
1197
+ }, ke = await O({ fields: Pe });
1198
+ return ke.error || !ke.data?.createAction ? null : L(
1199
+ ve,
1200
+ ke.data.createAction
1160
1201
  );
1161
1202
  }
1162
- if (K.quantumOwned) return K;
1163
- const Me = await N({
1164
- id: K.id
1203
+ if (Y.quantumOwned) return Y;
1204
+ const ge = await N({
1205
+ id: Y.id
1165
1206
  });
1166
- return Me.error || !Me.data?.convertActionToQuantumOwned ? null : R(
1167
- fe,
1168
- Me.data.convertActionToQuantumOwned
1207
+ return ge.error || !ge.data?.convertActionToQuantumOwned ? null : L(
1208
+ ve,
1209
+ ge.data.convertActionToQuantumOwned
1169
1210
  );
1170
1211
  };
1171
1212
  U = (await Promise.all(
1172
- ne.map(q)
1173
- )).filter((K) => !!K).map((K) => K.id);
1213
+ q.map(E)
1214
+ )).filter((Y) => !!Y).map((Y) => Y.id);
1174
1215
  }
1175
- if (l === "convert") {
1176
- const ne = {
1177
- name: A.name,
1178
- description: A.description || void 0,
1216
+ if (m === "convert") {
1217
+ const q = {
1218
+ name: b.name,
1219
+ description: b.description || void 0,
1179
1220
  actions: U,
1180
- categories: A.categories.map((Y) => Y.id),
1221
+ categories: b.categories.map((D) => D.id),
1181
1222
  quantumOwned: !0
1182
- }, q = await B({
1183
- id: A.id,
1184
- input: ne
1223
+ }, E = await F({
1224
+ id: b.id,
1225
+ input: q
1185
1226
  });
1186
- if (q.error) throw new Error(q.error.message);
1187
- if (q.data?.updateModule) {
1188
- const Y = R(
1189
- Be,
1190
- q.data.updateModule
1227
+ if (E.error) throw new Error(E.error.message);
1228
+ if (E.data?.updateModule) {
1229
+ const D = L(
1230
+ Qe,
1231
+ E.data.updateModule
1191
1232
  );
1192
- r.push(Y);
1233
+ t.push(D);
1193
1234
  }
1194
1235
  } else {
1195
- const ne = {
1196
- name: `${A.name} (Copy)`,
1197
- description: A.description || void 0,
1236
+ const q = {
1237
+ name: `${b.name} (Copy)`,
1238
+ description: b.description || void 0,
1198
1239
  actions: U,
1199
- categories: A.categories.map((Y) => Y.id),
1200
- quantumOwned: u
1201
- }, q = await _({ input: ne });
1202
- if (q.error) throw new Error(q.error.message);
1203
- if (q.data?.createModule) {
1204
- const Y = R(
1205
- Be,
1206
- q.data.createModule
1240
+ categories: b.categories.map((D) => D.id),
1241
+ quantumOwned: u,
1242
+ metadataItemIds: b.metadataItems.map((D) => D.id),
1243
+ actionReports: b.moduleActions.filter((D) => !!D.reportId).map((D) => ({
1244
+ actionId: D.actionId,
1245
+ reportId: D.reportId
1246
+ }))
1247
+ }, E = await $({ input: q });
1248
+ if (E.error) throw new Error(E.error.message);
1249
+ if (E.data?.createModule) {
1250
+ const D = L(
1251
+ Qe,
1252
+ E.data.createModule
1207
1253
  );
1208
- r.push(Y);
1254
+ t.push(D);
1209
1255
  }
1210
1256
  }
1211
1257
  } catch (U) {
1212
1258
  console.error(
1213
- `Failed to ${l === "convert" ? "convert" : "copy"} module "${A.name}":`,
1259
+ `Failed to ${m === "convert" ? "convert" : "copy"} module "${b.name}":`,
1214
1260
  U
1215
- ), f++;
1261
+ ), o++;
1216
1262
  }
1217
- if (r.length > 0) {
1218
- const A = r.length, U = D.length;
1219
- C({
1220
- title: f > 0 ? `Partial ${l === "convert" ? "convert" : "copy"} completed` : `${c.plural} ${l === "convert" ? "converted" : "copied"} successfully`,
1221
- description: f > 0 ? `${A} of ${U} ${c.plural} ${l === "convert" ? "converted" : "copied"} successfully` : `${A} ${A > 1 ? c.plural : c.singular} ${l === "convert" ? "converted" : "copied"} successfully`,
1222
- status: f > 0 ? "warning" : "success",
1263
+ if (t.length > 0) {
1264
+ const b = t.length, U = R.length;
1265
+ h({
1266
+ title: o > 0 ? `Partial ${m === "convert" ? "convert" : "copy"} completed` : `${i.plural} ${m === "convert" ? "converted" : "copied"} successfully`,
1267
+ description: o > 0 ? `${b} of ${U} ${i.plural} ${m === "convert" ? "converted" : "copied"} successfully` : `${b} ${b > 1 ? i.plural : i.singular} ${m === "convert" ? "converted" : "copied"} successfully`,
1268
+ status: o > 0 ? "warning" : "success",
1223
1269
  duration: 3e3,
1224
1270
  isClosable: !0
1225
- }), r.length > 0 && n?.(), L(""), I([]);
1271
+ }), t.length > 0 && r?.(), S(""), I([]);
1226
1272
  } else
1227
1273
  throw new Error(
1228
- `Failed to ${l === "convert" ? "convert" : "copy"} any modules`
1274
+ `Failed to ${m === "convert" ? "convert" : "copy"} any modules`
1229
1275
  );
1230
- } catch (r) {
1231
- const f = r instanceof Error ? r.message : `Failed to ${l === "convert" ? "convert" : "copy"} modules`;
1232
- C({
1233
- title: l === "convert" ? "Convert failed" : "Copy failed",
1234
- description: f,
1276
+ } catch (t) {
1277
+ const o = t instanceof Error ? t.message : `Failed to ${m === "convert" ? "convert" : "copy"} modules`;
1278
+ h({
1279
+ title: m === "convert" ? "Convert failed" : "Copy failed",
1280
+ description: o,
1235
1281
  status: "error",
1236
1282
  duration: 5e3,
1237
1283
  isClosable: !0
1238
- }), o?.(r instanceof Error ? r : new Error(f));
1284
+ }), a?.(t instanceof Error ? t : new Error(o));
1239
1285
  } finally {
1240
- m(!1);
1286
+ c(!1);
1241
1287
  }
1242
1288
  }, [
1243
- D,
1244
- _,
1245
- B,
1246
- C,
1247
- n,
1248
- o,
1289
+ R,
1290
+ $,
1291
+ F,
1292
+ h,
1293
+ r,
1294
+ a,
1249
1295
  u,
1250
- W,
1296
+ O,
1251
1297
  N,
1252
- l,
1253
- c
1254
- ]), E = $(() => {
1255
- L(""), I([]), a("copy"), t?.();
1256
- }, [t]);
1257
- ce(() => {
1258
- g && g({
1298
+ m,
1299
+ i
1300
+ ]), _ = P(() => {
1301
+ S(""), I([]), v("copy"), n?.();
1302
+ }, [n]);
1303
+ ie(() => {
1304
+ x && x({
1259
1305
  cancelButton: !1,
1260
- saveButton: D.length === 0 || j
1306
+ saveButton: R.length === 0 || y
1261
1307
  });
1262
- }, [D.length, j, g]), ce(() => {
1308
+ }, [R.length, y, x]), ie(() => {
1263
1309
  d && d({
1264
- cancelButton: E,
1265
- saveButton: M
1310
+ cancelButton: _,
1311
+ saveButton: T
1266
1312
  });
1267
- }, [d, E, M]);
1268
- const te = T(() => Z.map((r) => ({
1269
- value: r.id,
1270
- label: r.name
1271
- })), [Z]), Q = T(() => J.filter((r) => l === "copy" ? !0 : !r.quantumOwned).map((r) => ({
1272
- value: r.id,
1273
- label: r.name,
1313
+ }, [d, _, T]);
1314
+ const J = k(() => H.map((t) => ({
1315
+ value: t.id,
1316
+ label: t.name
1317
+ })), [H]), W = k(() => oe.filter((t) => m === "copy" ? !0 : !t.quantumOwned).map((t) => ({
1318
+ value: t.id,
1319
+ label: t.name,
1274
1320
  // Add custom data to identify quantum-owned modules
1275
- isQuantumOwned: r.quantumOwned
1276
- })), [J, l]), ie = v.fetching, i = w.fetching;
1277
- return /* @__PURE__ */ e.jsx(re, { children: /* @__PURE__ */ e.jsxs(le, { spacing: 6, align: "stretch", children: [
1321
+ isQuantumOwned: t.quantumOwned
1322
+ })), [oe, m]), K = j.fetching, l = A.fetching;
1323
+ return /* @__PURE__ */ e.jsx(te, { children: /* @__PURE__ */ e.jsxs(le, { spacing: 6, align: "stretch", children: [
1278
1324
  u && /* @__PURE__ */ e.jsxs(X, { children: [
1279
- /* @__PURE__ */ e.jsx(pe, { children: "Operation Mode" }),
1325
+ /* @__PURE__ */ e.jsx(he, { children: "Operation Mode" }),
1280
1326
  /* @__PURE__ */ e.jsx(
1281
- wt,
1327
+ vt,
1282
1328
  {
1283
- value: l,
1284
- onChange: (r) => {
1285
- a(r), I([]);
1329
+ value: m,
1330
+ onChange: (t) => {
1331
+ v(t), I([]);
1286
1332
  },
1287
- children: /* @__PURE__ */ e.jsxs(oe, { spacing: 6, children: [
1288
- /* @__PURE__ */ e.jsx(Qe, { value: "copy", colorScheme: "blue", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
1289
- /* @__PURE__ */ e.jsxs(b, { fontWeight: "medium", children: [
1333
+ children: /* @__PURE__ */ e.jsxs(re, { spacing: 6, children: [
1334
+ /* @__PURE__ */ e.jsx(Ye, { value: "copy", colorScheme: "blue", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
1335
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "medium", children: [
1290
1336
  "Copy ",
1291
- c.plural
1337
+ i.plural
1292
1338
  ] }),
1293
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
1339
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
1294
1340
  "Create new ",
1295
- c.pluralLowerCase,
1341
+ i.pluralLowerCase,
1296
1342
  " based on selected ones"
1297
1343
  ] })
1298
1344
  ] }) }),
1299
- /* @__PURE__ */ e.jsx(Qe, { value: "convert", colorScheme: "green", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
1300
- /* @__PURE__ */ e.jsx(b, { fontWeight: "medium", children: "Convert to Quantum Owned" }),
1301
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
1345
+ /* @__PURE__ */ e.jsx(Ye, { value: "convert", colorScheme: "green", children: /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 1, children: [
1346
+ /* @__PURE__ */ e.jsx(C, { fontWeight: "medium", children: "Convert to Quantum Owned" }),
1347
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
1302
1348
  "Convert existing ",
1303
- c.pluralLowerCase,
1349
+ i.pluralLowerCase,
1304
1350
  " to quantum-owned"
1305
1351
  ] })
1306
1352
  ] }) })
@@ -1309,81 +1355,81 @@ const In = ({
1309
1355
  )
1310
1356
  ] }),
1311
1357
  /* @__PURE__ */ e.jsxs(X, { children: [
1312
- /* @__PURE__ */ e.jsx(pe, { children: "Select Source Group" }),
1358
+ /* @__PURE__ */ e.jsx(he, { children: "Select Source Group" }),
1313
1359
  /* @__PURE__ */ e.jsx(
1314
- ge,
1360
+ ue,
1315
1361
  {
1316
1362
  placeholder: "Choose a group...",
1317
- options: te,
1318
- value: te.find((r) => r.value === F) || null,
1319
- onChange: S,
1320
- isLoading: ie,
1321
- isDisabled: ie,
1363
+ options: J,
1364
+ value: J.find((t) => t.value === w) || null,
1365
+ onChange: Z,
1366
+ isLoading: K,
1367
+ isDisabled: K,
1322
1368
  isClearable: !0
1323
1369
  }
1324
1370
  ),
1325
- v.error && /* @__PURE__ */ e.jsxs(qe, { status: "error", mt: 2, children: [
1326
- /* @__PURE__ */ e.jsx(Ke, {}),
1327
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", children: [
1371
+ j.error && /* @__PURE__ */ e.jsxs(He, { status: "error", mt: 2, children: [
1372
+ /* @__PURE__ */ e.jsx(Je, {}),
1373
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", children: [
1328
1374
  "Failed to load groups: ",
1329
- v.error.message
1375
+ j.error.message
1330
1376
  ] })
1331
1377
  ] })
1332
1378
  ] }),
1333
- F && /* @__PURE__ */ e.jsxs(X, { children: [
1334
- /* @__PURE__ */ e.jsx(pe, { children: l === "convert" ? `Select ${c.plural} to Convert` : `Select ${c.plural} to Copy` }),
1335
- i ? /* @__PURE__ */ e.jsxs(oe, { children: [
1336
- /* @__PURE__ */ e.jsx(St, { size: "sm" }),
1337
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", children: [
1379
+ w && /* @__PURE__ */ e.jsxs(X, { children: [
1380
+ /* @__PURE__ */ e.jsx(he, { children: m === "convert" ? `Select ${i.plural} to Convert` : `Select ${i.plural} to Copy` }),
1381
+ l ? /* @__PURE__ */ e.jsxs(re, { children: [
1382
+ /* @__PURE__ */ e.jsx(Ct, { size: "sm" }),
1383
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
1338
1384
  "Loading ",
1339
- c.pluralLowerCase,
1385
+ i.pluralLowerCase,
1340
1386
  "..."
1341
1387
  ] })
1342
1388
  ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1343
1389
  /* @__PURE__ */ e.jsx(
1344
- ge,
1390
+ ue,
1345
1391
  {
1346
- placeholder: l === "convert" ? `Choose ${c.pluralLowerCase} to convert...` : `Choose ${c.pluralLowerCase} to copy...`,
1347
- options: Q,
1348
- value: Q.filter(
1349
- (r) => y.includes(r.value)
1392
+ placeholder: m === "convert" ? `Choose ${i.pluralLowerCase} to convert...` : `Choose ${i.pluralLowerCase} to copy...`,
1393
+ options: W,
1394
+ value: W.filter(
1395
+ (t) => M.includes(t.value)
1350
1396
  ),
1351
- onChange: O,
1352
- isDisabled: Q.length === 0,
1397
+ onChange: V,
1398
+ isDisabled: W.length === 0,
1353
1399
  isClearable: !0,
1354
1400
  isMulti: !0,
1355
1401
  closeMenuOnSelect: !1,
1356
- formatOptionLabel: (r, { context: f }) => /* @__PURE__ */ e.jsxs(oe, { justify: "space-between", w: "100%", children: [
1402
+ formatOptionLabel: (t, { context: o }) => /* @__PURE__ */ e.jsxs(re, { justify: "space-between", w: "100%", children: [
1357
1403
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1358
- /* @__PURE__ */ e.jsx(b, { children: r.label }),
1359
- f === "value" && r.isQuantumOwned && /* @__PURE__ */ e.jsx(b, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
1404
+ /* @__PURE__ */ e.jsx(C, { children: t.label }),
1405
+ o === "value" && t.isQuantumOwned && /* @__PURE__ */ e.jsx(C, { color: "blue", fontSize: "xs", children: "(Quantum Owned)" })
1360
1406
  ] }),
1361
- r.isQuantumOwned && f === "menu" && /* @__PURE__ */ e.jsx(Re, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1407
+ t.isQuantumOwned && o === "menu" && /* @__PURE__ */ e.jsx(Ne, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1362
1408
  ] })
1363
1409
  }
1364
1410
  ),
1365
- Q.length === 0 && /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.500", mt: 2, children: [
1411
+ W.length === 0 && /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.500", mt: 2, children: [
1366
1412
  "No ",
1367
- c.pluralLowerCase,
1413
+ i.pluralLowerCase,
1368
1414
  " found in this group"
1369
1415
  ] })
1370
1416
  ] }),
1371
- w.error && /* @__PURE__ */ e.jsxs(qe, { status: "error", mt: 2, children: [
1372
- /* @__PURE__ */ e.jsx(Ke, {}),
1373
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", children: [
1417
+ A.error && /* @__PURE__ */ e.jsxs(He, { status: "error", mt: 2, children: [
1418
+ /* @__PURE__ */ e.jsx(Je, {}),
1419
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", children: [
1374
1420
  "Failed to load ",
1375
- c.pluralLowerCase,
1421
+ i.pluralLowerCase,
1376
1422
  ":",
1377
1423
  " ",
1378
- w.error.message
1424
+ A.error.message
1379
1425
  ] })
1380
1426
  ] })
1381
1427
  ] }),
1382
- D.length > 0 && /* @__PURE__ */ e.jsxs(re, { p: 4, bg: "gray.50", borderRadius: "md", children: [
1383
- /* @__PURE__ */ e.jsx(b, { fontWeight: "semibold", mb: 3, children: D.length === 1 ? `${c.singular} to ${l === "copy" ? "Copy" : "Convert"}` : `${D.length} ${c.plural} to ${l === "copy" ? "Copy" : "Convert"}` }),
1428
+ R.length > 0 && /* @__PURE__ */ e.jsxs(te, { p: 4, bg: "gray.50", borderRadius: "md", children: [
1429
+ /* @__PURE__ */ e.jsx(C, { fontWeight: "semibold", mb: 3, children: R.length === 1 ? `${i.singular} to ${m === "copy" ? "Copy" : "Convert"}` : `${R.length} ${i.plural} to ${m === "copy" ? "Copy" : "Convert"}` }),
1384
1430
  /* @__PURE__ */ e.jsxs(le, { align: "start", spacing: 3, children: [
1385
- D.map((r, f) => /* @__PURE__ */ e.jsxs(
1386
- re,
1431
+ R.map((t, o) => /* @__PURE__ */ e.jsxs(
1432
+ te,
1387
1433
  {
1388
1434
  w: "100%",
1389
1435
  p: 3,
@@ -1392,13 +1438,13 @@ const In = ({
1392
1438
  border: "1px solid",
1393
1439
  borderColor: "gray.200",
1394
1440
  children: [
1395
- /* @__PURE__ */ e.jsxs(oe, { justify: "space-between", align: "start", mb: 2, children: [
1396
- /* @__PURE__ */ e.jsxs(b, { fontWeight: "medium", fontSize: "sm", children: [
1397
- f + 1,
1441
+ /* @__PURE__ */ e.jsxs(re, { justify: "space-between", align: "start", mb: 2, children: [
1442
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "medium", fontSize: "sm", children: [
1443
+ o + 1,
1398
1444
  ". ",
1399
- r.name
1445
+ t.name
1400
1446
  ] }),
1401
- r.quantumOwned && /* @__PURE__ */ e.jsx(Re, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1447
+ t.quantumOwned && /* @__PURE__ */ e.jsx(Ne, { size: "sm", colorScheme: "blue", variant: "solid", children: "Quantum Owned" })
1402
1448
  ] }),
1403
1449
  /* @__PURE__ */ e.jsxs(
1404
1450
  le,
@@ -1408,30 +1454,30 @@ const In = ({
1408
1454
  fontSize: "sm",
1409
1455
  color: "gray.600",
1410
1456
  children: [
1411
- r.description && /* @__PURE__ */ e.jsxs(b, { children: [
1457
+ t.description && /* @__PURE__ */ e.jsxs(C, { children: [
1412
1458
  /* @__PURE__ */ e.jsx("strong", { children: "Description:" }),
1413
1459
  " ",
1414
- r.description
1460
+ t.description
1415
1461
  ] }),
1416
- /* @__PURE__ */ e.jsxs(b, { children: [
1462
+ /* @__PURE__ */ e.jsxs(C, { children: [
1417
1463
  /* @__PURE__ */ e.jsx("strong", { children: "Activities:" }),
1418
1464
  " ",
1419
- r.moduleActions.length
1465
+ t.moduleActions.length
1420
1466
  ] }),
1421
- /* @__PURE__ */ e.jsxs(b, { children: [
1467
+ /* @__PURE__ */ e.jsxs(C, { children: [
1422
1468
  /* @__PURE__ */ e.jsx("strong", { children: "Categories:" }),
1423
1469
  " ",
1424
- r.categories.map((A) => A.name).join(", ") || "None"
1470
+ t.categories.map((b) => b.name).join(", ") || "None"
1425
1471
  ] })
1426
1472
  ]
1427
1473
  }
1428
1474
  )
1429
1475
  ]
1430
1476
  },
1431
- r.id
1477
+ t.id
1432
1478
  )),
1433
- D.length > 1 && /* @__PURE__ */ e.jsx(
1434
- re,
1479
+ R.length > 1 && /* @__PURE__ */ e.jsx(
1480
+ te,
1435
1481
  {
1436
1482
  w: "100%",
1437
1483
  p: 2,
@@ -1439,141 +1485,154 @@ const In = ({
1439
1485
  borderRadius: "md",
1440
1486
  border: "1px solid",
1441
1487
  borderColor: "blue.200",
1442
- children: /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
1488
+ children: /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", fontWeight: "medium", color: "blue.800", children: [
1443
1489
  "Total: ",
1444
- D.length,
1490
+ R.length,
1445
1491
  " ",
1446
- c.pluralLowerCase,
1492
+ i.pluralLowerCase,
1447
1493
  " will be",
1448
1494
  " ",
1449
- l === "copy" ? "copied" : "converted"
1495
+ m === "copy" ? "copied" : "converted"
1450
1496
  ] })
1451
1497
  }
1452
1498
  ),
1453
- u && D.filter((r) => r.moduleActions.some((f) => !f.action.quantumOwned)).length > 0 && /* @__PURE__ */ e.jsx(
1454
- re,
1499
+ u && R.filter((t) => t.moduleActions.some((o) => !o.action.quantumOwned)).length > 0 && /* @__PURE__ */ e.jsx(
1500
+ te,
1455
1501
  {
1456
1502
  p: 2,
1457
1503
  bg: "yellow.50",
1458
1504
  borderRadius: "md",
1459
1505
  border: "1px solid",
1460
1506
  borderColor: "yellow.200",
1461
- children: /* @__PURE__ */ e.jsx(b, { fontSize: "sm", fontWeight: "medium", color: "yellow.800", children: l === "convert" ? `Converting ${c.plural} will convert non QM-Owned ${x.plural} to QM-Owned ${x.plural}` : `Copying ${c.plural} with Non QM-Owned ${x.plural} will create corresponding QM-Owned ${x.plural}` })
1507
+ children: /* @__PURE__ */ e.jsx(C, { fontSize: "sm", fontWeight: "medium", color: "yellow.800", children: m === "convert" ? `Converting ${i.plural} will convert non QM-Owned ${g.plural} to QM-Owned ${g.plural}` : `Copying ${i.plural} with Non QM-Owned ${g.plural} will create corresponding QM-Owned ${g.plural}` })
1462
1508
  }
1463
1509
  )
1464
1510
  ] })
1465
1511
  ] }),
1466
- !h && /* @__PURE__ */ e.jsxs(Le, { spacing: 4, justifyContent: "flex-end", children: [
1512
+ !p && /* @__PURE__ */ e.jsxs(Me, { spacing: 4, justifyContent: "flex-end", children: [
1467
1513
  /* @__PURE__ */ e.jsx(
1468
- ee,
1514
+ se,
1469
1515
  {
1470
1516
  variant: "outline",
1471
- onClick: E,
1472
- isDisabled: j,
1517
+ onClick: _,
1518
+ isDisabled: y,
1473
1519
  children: "Cancel"
1474
1520
  }
1475
1521
  ),
1476
1522
  /* @__PURE__ */ e.jsxs(
1477
- ee,
1523
+ se,
1478
1524
  {
1479
- colorScheme: l === "copy" ? "blue" : "green",
1480
- onClick: M,
1481
- isDisabled: D.length === 0 || j,
1482
- isLoading: j,
1483
- loadingText: `${l === "copy" ? "Copying" : "Converting"}...`,
1525
+ colorScheme: m === "copy" ? "blue" : "green",
1526
+ onClick: T,
1527
+ isDisabled: R.length === 0 || y,
1528
+ isLoading: y,
1529
+ loadingText: `${m === "copy" ? "Copying" : "Converting"}...`,
1484
1530
  children: [
1485
- l === "copy" ? "Copy" : "Convert",
1531
+ m === "copy" ? "Copy" : "Convert",
1486
1532
  " ",
1487
- D.length === 1 ? c.singular : `${D.length} ${c.plural}`
1533
+ R.length === 1 ? i.singular : `${R.length} ${i.plural}`
1488
1534
  ]
1489
1535
  }
1490
1536
  )
1491
1537
  ] })
1492
1538
  ] }) });
1493
- }, Ft = en(void 0), Xe = () => {
1494
- const n = tn(Ft);
1495
- if (!n)
1539
+ }, Rt = tn(void 0), Fe = () => {
1540
+ const r = nn(Rt);
1541
+ if (!r)
1496
1542
  throw new Error(
1497
1543
  "useUpsertModuleFormContext must be used within a UpsertModuleFormProvider"
1498
1544
  );
1499
- return n;
1500
- }, _n = ({
1501
- name: n,
1502
- setName: t,
1503
- actions: o,
1504
- selectedActionIds: h,
1505
- setSelectedActionIds: g,
1545
+ return r;
1546
+ }, Pn = ({
1547
+ name: r,
1548
+ setName: n,
1549
+ actions: a,
1550
+ selectedActionIds: p,
1551
+ setSelectedActionIds: x,
1506
1552
  availableCategories: d,
1507
1553
  selectedCategoryIds: u,
1508
- setSelectedCategoryIds: C,
1554
+ setSelectedCategoryIds: h,
1509
1555
  description: s,
1510
- setDescription: c,
1511
- ...x
1556
+ setDescription: i,
1557
+ selectedMetadataIds: g,
1558
+ setSelectedMetadataIds: w,
1559
+ actionReportIds: S,
1560
+ setActionReportIds: M,
1561
+ ...I
1512
1562
  }) => {
1513
- const F = zt(), L = T(() => o.map((a) => ({
1514
- ...a,
1515
- selected: h.includes(a.id)
1516
- })), [o, h]), y = T(() => o.reduce((a, v) => (a[v.id] = v, a), {}), [o]), I = T(
1517
- () => h.map((a) => y[a]),
1518
- [h, y]
1519
- ), j = $(
1520
- (a, v) => {
1521
- g(v ? [...h, a.id] : h.filter((w) => w !== a.id));
1563
+ const y = Wt(), c = k(() => a.map((F) => ({
1564
+ ...F,
1565
+ selected: p.includes(F.id)
1566
+ })), [a, p]), m = k(() => a.reduce((F, O) => (F[O.id] = O, F), {}), [a]), v = k(
1567
+ () => p.map((F) => m[F]),
1568
+ [p, m]
1569
+ ), j = P(
1570
+ (F, O) => {
1571
+ x(O ? [...p, F.id] : p.filter((N) => N !== F.id));
1522
1572
  },
1523
- [h, g]
1524
- ), m = $(
1525
- (a) => {
1526
- t(a.target.value);
1573
+ [p, x]
1574
+ ), A = P(
1575
+ (F) => {
1576
+ n(F.target.value);
1527
1577
  },
1528
- [t]
1529
- ), l = $(
1530
- (a) => {
1531
- c?.(a.target.value);
1578
+ [n]
1579
+ ), $ = P(
1580
+ (F) => {
1581
+ i?.(F.target.value);
1532
1582
  },
1533
- [c]
1583
+ [i]
1534
1584
  );
1535
- return /* @__PURE__ */ e.jsxs(re, { ...x, children: [
1536
- /* @__PURE__ */ e.jsxs(oe, { gap: "2rem", children: [
1537
- /* @__PURE__ */ e.jsx(Gn, { name: n ?? "", onInputChange: m }),
1585
+ return /* @__PURE__ */ e.jsxs(te, { ...I, children: [
1586
+ /* @__PURE__ */ e.jsxs(re, { gap: "2rem", children: [
1587
+ /* @__PURE__ */ e.jsx(En, { name: r ?? "", onInputChange: A }),
1538
1588
  /* @__PURE__ */ e.jsx(
1539
- zn,
1589
+ _n,
1540
1590
  {
1541
1591
  availableCategories: d,
1542
1592
  value: u,
1543
- onChange: C
1593
+ onChange: h
1544
1594
  }
1545
1595
  )
1546
1596
  ] }),
1547
1597
  /* @__PURE__ */ e.jsx(
1548
- Bn,
1598
+ zn,
1549
1599
  {
1550
1600
  description: s ?? "",
1551
- onInputChange: l
1601
+ onInputChange: $
1552
1602
  }
1553
1603
  ),
1554
1604
  /* @__PURE__ */ e.jsx(
1555
- Un,
1605
+ Qn,
1556
1606
  {
1557
- value: I,
1558
- onChange: g,
1559
- onAdjustActivities: () => F.onOpen()
1607
+ selectedMetadataIds: g,
1608
+ setSelectedMetadataIds: w
1609
+ }
1610
+ ),
1611
+ /* @__PURE__ */ e.jsx(
1612
+ Bn,
1613
+ {
1614
+ value: v,
1615
+ onChange: x,
1616
+ onAdjustActivities: () => y.onOpen(),
1617
+ actionReportIds: S,
1618
+ setActionReportIds: M
1560
1619
  }
1561
1620
  ),
1562
1621
  /* @__PURE__ */ e.jsxs(
1563
- Bt,
1622
+ Ut,
1564
1623
  {
1565
- isOpen: F.isOpen,
1566
- onClose: F.onClose,
1624
+ isOpen: y.isOpen,
1625
+ onClose: y.onClose,
1567
1626
  size: "6xl",
1568
1627
  children: [
1569
- /* @__PURE__ */ e.jsx(Ut, {}),
1570
- /* @__PURE__ */ e.jsxs(Wt, { children: [
1571
- /* @__PURE__ */ e.jsx(Qt, { children: "Select Activities" }),
1572
- /* @__PURE__ */ e.jsx(qt, {}),
1573
- /* @__PURE__ */ e.jsx(Kt, { children: /* @__PURE__ */ e.jsx(
1574
- En,
1628
+ /* @__PURE__ */ e.jsx(Qt, {}),
1629
+ /* @__PURE__ */ e.jsxs(qt, { children: [
1630
+ /* @__PURE__ */ e.jsx(Kt, { children: "Select Activities" }),
1631
+ /* @__PURE__ */ e.jsx(Yt, {}),
1632
+ /* @__PURE__ */ e.jsx(Ht, { children: /* @__PURE__ */ e.jsx(
1633
+ Gn,
1575
1634
  {
1576
- actions: L,
1635
+ actions: c,
1577
1636
  onSelected: j,
1578
1637
  disableCreate: !0,
1579
1638
  disableDelete: !0,
@@ -1583,12 +1642,12 @@ const In = ({
1583
1642
  }
1584
1643
  }
1585
1644
  ) }),
1586
- /* @__PURE__ */ e.jsx(Yt, { children: /* @__PURE__ */ e.jsx(
1587
- ee,
1645
+ /* @__PURE__ */ e.jsx(Jt, { children: /* @__PURE__ */ e.jsx(
1646
+ se,
1588
1647
  {
1589
1648
  colorScheme: "blue",
1590
- onClick: F.onClose,
1591
- isDisabled: h.length === 0,
1649
+ onClick: y.onClose,
1650
+ isDisabled: p.length === 0,
1592
1651
  children: "Done"
1593
1652
  }
1594
1653
  ) })
@@ -1597,241 +1656,418 @@ const In = ({
1597
1656
  }
1598
1657
  )
1599
1658
  ] });
1600
- }, Gn = Je(
1659
+ }, En = Se(
1601
1660
  ({
1602
- name: n,
1603
- onInputChange: t
1661
+ name: r,
1662
+ onInputChange: n
1604
1663
  }) => {
1605
- const { getLabel: o } = xe(), h = o("module"), { isView: g } = Xe();
1664
+ const { getLabel: a } = pe(), p = a("module"), { isView: x } = Fe();
1606
1665
  return /* @__PURE__ */ e.jsxs(X, { mb: 4, children: [
1607
- /* @__PURE__ */ e.jsxs(pe, { children: [
1608
- h,
1666
+ /* @__PURE__ */ e.jsxs(he, { children: [
1667
+ p,
1609
1668
  " Name"
1610
1669
  ] }),
1611
1670
  /* @__PURE__ */ e.jsx(
1612
- we,
1671
+ Le,
1613
1672
  {
1614
1673
  placeholder: "i.e. ACL RTP Test Battery",
1615
- value: n,
1616
- onChange: t,
1674
+ value: r,
1675
+ onChange: n,
1617
1676
  isRequired: !0,
1618
- isDisabled: g
1677
+ isDisabled: x
1619
1678
  }
1620
1679
  )
1621
1680
  ] });
1622
1681
  }
1623
- ), zn = Je(
1682
+ ), _n = Se(
1624
1683
  ({
1625
- availableCategories: n,
1626
- value: t,
1627
- onChange: o
1684
+ availableCategories: r,
1685
+ value: n,
1686
+ onChange: a
1628
1687
  }) => {
1629
- const { getLabel: h } = xe(), g = h("module"), { isView: d } = Xe(), u = T(() => [
1630
- ...n,
1688
+ const { getLabel: p } = pe(), x = p("module"), { isView: d } = Fe(), u = k(() => [
1689
+ ...r,
1631
1690
  {
1632
1691
  id: "other",
1633
1692
  name: "Other"
1634
1693
  }
1635
- ], [n]), C = T(() => u.map((s) => ({
1694
+ ], [r]), h = k(() => u.map((s) => ({
1636
1695
  value: s.id,
1637
1696
  label: s.name
1638
1697
  })), [u]);
1639
1698
  return /* @__PURE__ */ e.jsxs(X, { mb: 4, children: [
1640
- /* @__PURE__ */ e.jsxs(pe, { children: [
1641
- g,
1699
+ /* @__PURE__ */ e.jsxs(he, { children: [
1700
+ x,
1642
1701
  " Category"
1643
1702
  ] }),
1644
1703
  /* @__PURE__ */ e.jsx(
1645
- ge,
1704
+ ue,
1646
1705
  {
1647
- isDisabled: n.length === 0 || d,
1648
- options: C,
1649
- value: t.length === 0 ? { value: "other", label: "Other" } : u.filter((s) => t.includes(s.id)).map((s) => ({
1706
+ isDisabled: r.length === 0 || d,
1707
+ options: h,
1708
+ value: n.length === 0 ? { value: "other", label: "Other" } : u.filter((s) => n.includes(s.id)).map((s) => ({
1650
1709
  value: s.id,
1651
1710
  label: s.name
1652
1711
  }))[0],
1653
- onChange: (s) => o(s ? [s.value] : []),
1712
+ onChange: (s) => a(s ? [s.value] : []),
1654
1713
  placeholder: "Select category"
1655
1714
  }
1656
1715
  )
1657
1716
  ] });
1658
1717
  }
1659
- ), Bn = Je(
1718
+ ), zn = Se(
1660
1719
  ({
1661
- description: n,
1662
- onInputChange: t
1720
+ description: r,
1721
+ onInputChange: n
1663
1722
  }) => {
1664
- const { getLabel: o } = xe(), h = o("module"), { isView: g } = Xe();
1723
+ const { getLabel: a } = pe(), p = a("module"), { isView: x } = Fe();
1665
1724
  return /* @__PURE__ */ e.jsxs(X, { mb: 4, children: [
1666
- /* @__PURE__ */ e.jsx(pe, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1725
+ /* @__PURE__ */ e.jsx(he, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1667
1726
  "Description",
1668
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.500", children: [
1727
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.500", children: [
1669
1728
  "Briefly describe the objective of this",
1670
1729
  " ",
1671
- h.toLocaleLowerCase(),
1730
+ p.toLocaleLowerCase(),
1672
1731
  ". Max 40 words."
1673
1732
  ] })
1674
1733
  ] }) }),
1675
1734
  /* @__PURE__ */ e.jsx(
1676
- we,
1735
+ Le,
1677
1736
  {
1678
1737
  placeholder: "i.e. Assess readiness to return to play post-ACL reconstruction",
1679
- value: n,
1680
- onChange: t,
1681
- isDisabled: g
1738
+ value: r,
1739
+ onChange: n,
1740
+ isDisabled: x
1682
1741
  }
1683
1742
  )
1684
1743
  ] });
1685
1744
  }
1686
- ), Un = Je(
1745
+ ), Bn = Se(
1687
1746
  ({
1688
- value: n,
1689
- onChange: t,
1690
- onAdjustActivities: o
1747
+ value: r,
1748
+ onChange: n,
1749
+ onAdjustActivities: a,
1750
+ actionReportIds: p,
1751
+ setActionReportIds: x
1691
1752
  }) => {
1692
- const { getLabel: h } = xe(), { isView: g } = Xe(), d = T(() => ({
1693
- module: h("module"),
1694
- moduleLowerCase: h("module").toLocaleLowerCase(),
1695
- action: h("action"),
1696
- actionPlural: h("action_plural"),
1697
- actionPluralLowerCase: h("action_plural").toLocaleLowerCase()
1698
- }), [h]), u = T(
1699
- () => n.map((C) => ({
1700
- id: C.id,
1701
- name: C.name
1753
+ const { getLabel: d } = pe(), { isView: u } = Fe(), h = k(() => ({
1754
+ module: d("module"),
1755
+ moduleLowerCase: d("module").toLocaleLowerCase(),
1756
+ action: d("action"),
1757
+ actionPlural: d("action_plural"),
1758
+ actionPluralLowerCase: d("action_plural").toLocaleLowerCase()
1759
+ }), [d]), s = k(
1760
+ () => r.map((i) => ({
1761
+ id: i.id,
1762
+ name: i.name,
1763
+ reports: L(Ze, i.reports) || [],
1764
+ selectedReportId: p[i.id] || null
1702
1765
  })),
1703
- [n]
1766
+ [r, p]
1704
1767
  );
1705
1768
  return /* @__PURE__ */ e.jsxs(X, { mb: 4, children: [
1706
- /* @__PURE__ */ e.jsxs(oe, { justifyContent: "space-between", children: [
1707
- /* @__PURE__ */ e.jsx(pe, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1708
- d.actionPlural,
1709
- /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.500", children: [
1769
+ /* @__PURE__ */ e.jsxs(re, { justifyContent: "space-between", children: [
1770
+ /* @__PURE__ */ e.jsx(he, { children: /* @__PURE__ */ e.jsxs("span", { children: [
1771
+ h.actionPlural,
1772
+ !u && /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.500", children: [
1710
1773
  "Drag and drop to reorder the ",
1711
- d.actionPluralLowerCase,
1712
- " in this ",
1713
- d.moduleLowerCase,
1774
+ h.actionPluralLowerCase,
1775
+ " ",
1776
+ "in this ",
1777
+ h.moduleLowerCase,
1714
1778
  "."
1715
1779
  ] })
1716
1780
  ] }) }),
1717
- !g && /* @__PURE__ */ e.jsxs(
1718
- ee,
1781
+ !u && /* @__PURE__ */ e.jsxs(
1782
+ se,
1719
1783
  {
1720
1784
  size: "sm",
1721
1785
  variant: "solid",
1722
1786
  colorScheme: "blue",
1723
- onClick: o,
1787
+ onClick: a,
1724
1788
  children: [
1725
1789
  "Add / Remove ",
1726
- d.actionPlural
1790
+ h.actionPlural
1727
1791
  ]
1728
1792
  }
1729
1793
  )
1730
1794
  ] }),
1731
- u.length === 0 ? /* @__PURE__ */ e.jsx(le, { children: /* @__PURE__ */ e.jsxs(b, { color: "gray.500", fontSize: "lg", mb: "4rem", mt: "4rem", children: [
1795
+ s.length === 0 ? /* @__PURE__ */ e.jsx(le, { children: /* @__PURE__ */ e.jsxs(C, { color: "gray.500", fontSize: "lg", mb: "4rem", mt: "4rem", children: [
1732
1796
  "No ",
1733
- d.actionPluralLowerCase,
1797
+ h.actionPluralLowerCase,
1734
1798
  " selected for this",
1735
1799
  " ",
1736
- d.moduleLowerCase,
1800
+ h.moduleLowerCase,
1737
1801
  ".",
1738
- !g && /* @__PURE__ */ e.jsxs(
1739
- ee,
1802
+ !u && /* @__PURE__ */ e.jsxs(
1803
+ se,
1740
1804
  {
1741
1805
  ml: "0.5em",
1742
1806
  size: "sm",
1743
1807
  variant: "link",
1744
1808
  colorScheme: "blue",
1745
- onClick: o,
1809
+ onClick: a,
1746
1810
  children: [
1747
1811
  "Add ",
1748
- d.actionPluralLowerCase,
1812
+ h.actionPluralLowerCase,
1749
1813
  "."
1750
1814
  ]
1751
1815
  }
1752
1816
  )
1753
1817
  ] }) }) : /* @__PURE__ */ e.jsx(
1754
- On,
1818
+ Wn,
1755
1819
  {
1756
- value: u,
1757
- onChange: (C) => {
1758
- const s = C(u);
1759
- t(s.map((c) => c.id));
1820
+ value: s,
1821
+ onChange: (i) => {
1822
+ const g = i(s);
1823
+ n(g.map((w) => w.id));
1760
1824
  },
1761
- disabled: g
1825
+ disabled: u,
1826
+ actionReportIds: p,
1827
+ setActionReportIds: x
1762
1828
  }
1763
1829
  )
1764
1830
  ] });
1765
1831
  }
1766
- ), Wn = ({
1767
- value: n,
1768
- onChange: t,
1769
- forceKind: o,
1770
- disableRemove: h,
1771
- disableKind: g,
1832
+ ), Wn = Se(
1833
+ ({
1834
+ value: r,
1835
+ onChange: n,
1836
+ disabled: a,
1837
+ actionReportIds: p,
1838
+ setActionReportIds: x
1839
+ }) => {
1840
+ const [d] = B(
1841
+ () => Math.random().toString(36).substring(2, 15)
1842
+ ), u = P(
1843
+ (h, s) => {
1844
+ a || n((i) => {
1845
+ const g = [...i], [w] = g.splice(h, 1);
1846
+ return g.splice(s, 0, w), g;
1847
+ });
1848
+ },
1849
+ [n, a]
1850
+ );
1851
+ return /* @__PURE__ */ e.jsx(te, { children: /* @__PURE__ */ e.jsx(bn, { backend: yn, children: /* @__PURE__ */ e.jsx(le, { spacing: 3, align: "stretch", children: r.map((h, s) => /* @__PURE__ */ e.jsx(
1852
+ Un,
1853
+ {
1854
+ listKey: d,
1855
+ item: h,
1856
+ index: s,
1857
+ disabled: !!a,
1858
+ move: u,
1859
+ onReportChange: (i) => {
1860
+ x({
1861
+ ...p,
1862
+ [h.id]: i
1863
+ });
1864
+ }
1865
+ },
1866
+ h.id
1867
+ )) }) }) });
1868
+ }
1869
+ ), Un = Se(
1870
+ ({
1871
+ listKey: r,
1872
+ item: n,
1873
+ index: a,
1874
+ disabled: p,
1875
+ move: x,
1876
+ onReportChange: d
1877
+ }) => {
1878
+ const u = sn(null), { getLabel: h } = pe(), s = h("action"), [{ handlerId: i }, g] = vn({
1879
+ accept: r,
1880
+ collect: (c) => ({
1881
+ handlerId: c.getHandlerId()?.toString() ?? ""
1882
+ }),
1883
+ hover: (c, m) => {
1884
+ if (!u.current)
1885
+ return;
1886
+ const v = c.index, j = a;
1887
+ if (v === j)
1888
+ return;
1889
+ const A = u.current?.getBoundingClientRect(), $ = (A.bottom - A.top) / 2, O = m.getClientOffset().y - A.top;
1890
+ v < j && O < $ || v > j && O > $ || (x(v, j), c.index = j);
1891
+ }
1892
+ }), [{ isDragging: w }, S] = Cn({
1893
+ type: r,
1894
+ item: () => ({ id: n.id, index: a }),
1895
+ collect: (c) => ({
1896
+ isDragging: c.isDragging()
1897
+ }),
1898
+ canDrag: !p
1899
+ }), M = k(() => [
1900
+ { value: null, label: "No Report" },
1901
+ ...n.reports.map((c) => ({
1902
+ value: c.id,
1903
+ label: c.reportKind || "Report"
1904
+ }))
1905
+ ], [n.reports]), I = w ? 0.6 : 1, y = p ? "default" : w ? "grabbing" : "grab";
1906
+ return S(g(u)), /* @__PURE__ */ e.jsx(
1907
+ te,
1908
+ {
1909
+ ref: u,
1910
+ p: 3,
1911
+ border: "1px solid",
1912
+ borderColor: "gray.200",
1913
+ borderRadius: "md",
1914
+ bg: "gray.50",
1915
+ style: { opacity: I, cursor: y },
1916
+ "data-handler-id": i,
1917
+ children: /* @__PURE__ */ e.jsxs(re, { justify: "space-between", align: "center", children: [
1918
+ /* @__PURE__ */ e.jsxs(re, { spacing: 3, children: [
1919
+ /* @__PURE__ */ e.jsxs(C, { fontWeight: "semibold", minW: "2rem", children: [
1920
+ a + 1,
1921
+ "."
1922
+ ] }),
1923
+ /* @__PURE__ */ e.jsx(C, { fontWeight: "medium", children: n.name })
1924
+ ] }),
1925
+ /* @__PURE__ */ e.jsxs(re, { spacing: 3, align: "center", children: [
1926
+ /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", children: [
1927
+ s,
1928
+ " Report:"
1929
+ ] }),
1930
+ /* @__PURE__ */ e.jsx(te, { width: "300px", children: /* @__PURE__ */ e.jsx(
1931
+ ue,
1932
+ {
1933
+ value: M.find(
1934
+ (c) => c.value === n.selectedReportId
1935
+ ),
1936
+ onChange: (c) => {
1937
+ d(c?.value || null);
1938
+ },
1939
+ options: M,
1940
+ placeholder: "Select report...",
1941
+ isDisabled: p
1942
+ }
1943
+ ) })
1944
+ ] })
1945
+ ] })
1946
+ }
1947
+ );
1948
+ }
1949
+ ), Qn = Se(
1950
+ ({
1951
+ selectedMetadataIds: r,
1952
+ setSelectedMetadataIds: n
1953
+ }) => {
1954
+ const { getLabel: a } = pe(), { isView: p, metadataOptions: x } = Fe(), d = k(() => [
1955
+ {
1956
+ key: "activity_type",
1957
+ label: `${a("action")} Type`,
1958
+ multi: !0
1959
+ },
1960
+ { key: "session_type", label: "Session Type", multi: !0 },
1961
+ { key: "body_region", label: "Body Region", multi: !0 },
1962
+ { key: "sport", label: "Sport", multi: !0 }
1963
+ ], [a]), u = P(
1964
+ (h, s) => {
1965
+ const i = d.find((w) => w.key === h);
1966
+ if (!i) return;
1967
+ const g = i.multi ? (s ?? []).map((w) => w.id) : s ? [s.id] : [];
1968
+ n((w) => [...w.filter((M) => Object.values(x || {}).flat().find((y) => y.id === M) && !Object.keys(x || {}).find(
1969
+ (y) => x?.[y]?.some(
1970
+ (c) => c.id === M && y === h
1971
+ )
1972
+ )), ...g]);
1973
+ },
1974
+ [d, x, n]
1975
+ );
1976
+ return x ? /* @__PURE__ */ e.jsxs(X, { mb: 4, children: [
1977
+ /* @__PURE__ */ e.jsx(he, { children: "Metadata Tags" }),
1978
+ /* @__PURE__ */ e.jsx(re, { gap: "1rem", align: "start", children: d.map((h) => /* @__PURE__ */ e.jsxs(X, { flex: "1", children: [
1979
+ /* @__PURE__ */ e.jsx(Xe, { fontSize: "sm", children: h.label }),
1980
+ /* @__PURE__ */ e.jsx(
1981
+ ue,
1982
+ {
1983
+ isMulti: h.multi,
1984
+ value: x[h.key]?.filter(
1985
+ (s) => r.includes(s.id)
1986
+ ),
1987
+ onChange: (s) => {
1988
+ u(
1989
+ h.key,
1990
+ s
1991
+ );
1992
+ },
1993
+ options: x[h.key],
1994
+ placeholder: `Select ${h.multi ? "one or more" : "one"} ${h.label.toLowerCase()}`,
1995
+ isDisabled: p,
1996
+ isClearable: h.multi
1997
+ }
1998
+ )
1999
+ ] }, h.key)) })
2000
+ ] }) : null;
2001
+ }
2002
+ ), qn = ({
2003
+ value: r,
2004
+ onChange: n,
2005
+ forceKind: a,
2006
+ disableRemove: p,
2007
+ disableKind: x,
1772
2008
  isDisabled: d,
1773
2009
  lockRanges: u,
1774
- ...C
2010
+ ...h
1775
2011
  }) => {
1776
- const s = T(() => [...n].sort((L, y) => {
1777
- const I = mt.indexOf(L.plane), j = mt.indexOf(y.plane);
1778
- return I - j;
1779
- }), [n]), c = $((L) => "segment" in L.id ? Rt(L.id.segment, L.plane, !0) ?? "Unknown" : kt(L.id.joint, L.plane, !0) ?? "Unknown", []), x = $(
1780
- (L, y) => {
2012
+ const s = k(() => [...r].sort((S, M) => {
2013
+ const I = xt.indexOf(S.plane), y = xt.indexOf(M.plane);
2014
+ return I - y;
2015
+ }), [r]), i = P((S) => "segment" in S.id ? kt(S.id.segment, S.plane, !0) ?? "Unknown" : Tt(S.id.joint, S.plane, !0) ?? "Unknown", []), g = P(
2016
+ (S, M) => {
1781
2017
  const I = s.findIndex(
1782
- (m) => m.id === y.id && m.plane === y.plane
2018
+ (c) => c.id === M.id && c.plane === M.plane
1783
2019
  );
1784
- let j = [...s];
1785
- o && (y = { ...y, kind: o }), j[I] = y, u && (j = j.map((m) => ({
1786
- ...m,
1787
- min: y.min,
1788
- max: y.max
1789
- }))), t(j);
2020
+ let y = [...s];
2021
+ a && (M = { ...M, kind: a }), y[I] = M, u && (y = y.map((c) => ({
2022
+ ...c,
2023
+ min: M.min,
2024
+ max: M.max
2025
+ }))), n(y);
1790
2026
  },
1791
- [t, s, o, u]
1792
- ), F = $(
1793
- (L) => {
1794
- const y = s.filter(
1795
- (I) => I.id !== L.id || I.plane !== L.plane
2027
+ [n, s, a, u]
2028
+ ), w = P(
2029
+ (S) => {
2030
+ const M = s.filter(
2031
+ (I) => I.id !== S.id || I.plane !== S.plane
1796
2032
  );
1797
- t(y);
2033
+ n(M);
1798
2034
  },
1799
- [t, s]
2035
+ [n, s]
1800
2036
  );
1801
- return /* @__PURE__ */ e.jsx(le, { alignItems: "flex-start", overflowY: "auto", ...C, children: s.map((L, y) => /* @__PURE__ */ e.jsx(
1802
- Qn,
2037
+ return /* @__PURE__ */ e.jsx(le, { alignItems: "flex-start", overflowY: "auto", ...h, children: s.map((S, M) => /* @__PURE__ */ e.jsx(
2038
+ Kn,
1803
2039
  {
1804
- label: c(L),
1805
- parameter: L,
1806
- onChange: (I) => x(y, I),
1807
- onRemove: h || d ? void 0 : () => F(L),
1808
- forceKind: o,
1809
- disableKind: g || d,
2040
+ label: i(S),
2041
+ parameter: S,
2042
+ onChange: (I) => g(M, I),
2043
+ onRemove: p || d ? void 0 : () => w(S),
2044
+ forceKind: a,
2045
+ disableKind: x || d,
1810
2046
  isDisabled: d
1811
2047
  },
1812
- `${JSON.stringify(L.id)}-${L.plane}`
2048
+ `${JSON.stringify(S.id)}-${S.plane}`
1813
2049
  )) });
1814
- }, Qn = ({
1815
- label: n,
1816
- parameter: t,
1817
- onChange: o,
1818
- onRemove: h,
1819
- forceKind: g,
2050
+ }, Kn = ({
2051
+ label: r,
2052
+ parameter: n,
2053
+ onChange: a,
2054
+ onRemove: p,
2055
+ forceKind: x,
1820
2056
  disableKind: d,
1821
2057
  isDisabled: u
1822
2058
  }) => {
1823
- const C = $(
1824
- (x) => "joint" in t.id ? wn(
1825
- t.id.joint,
1826
- t.plane,
1827
- x < 0 ? -1 : 1
2059
+ const h = P(
2060
+ (g) => "joint" in n.id ? wn(
2061
+ n.id.joint,
2062
+ n.plane,
2063
+ g < 0 ? -1 : 1
1828
2064
  ) : Sn(
1829
- t.id.segment,
1830
- t.plane,
1831
- x < 0 ? -1 : 1
2065
+ n.id.segment,
2066
+ n.plane,
2067
+ g < 0 ? -1 : 1
1832
2068
  ),
1833
- [t]
1834
- ), { min: s, max: c } = "joint" in t.id ? Ln(t.id.joint, t.plane) : { min: -180, max: 180 };
2069
+ [n]
2070
+ ), { min: s, max: i } = "joint" in n.id ? Ln(n.id.joint, n.plane) : { min: -180, max: 180 };
1835
2071
  return /* @__PURE__ */ e.jsxs(
1836
2072
  le,
1837
2073
  {
@@ -1843,33 +2079,33 @@ const In = ({
1843
2079
  overflow: "hidden",
1844
2080
  flexShrink: "0",
1845
2081
  children: [
1846
- /* @__PURE__ */ e.jsxs(oe, { w: "100%", children: [
2082
+ /* @__PURE__ */ e.jsxs(re, { w: "100%", children: [
1847
2083
  /* @__PURE__ */ e.jsx(
1848
- b,
2084
+ C,
1849
2085
  {
1850
2086
  fontSize: "sm",
1851
2087
  flex: 1,
1852
2088
  textTransform: "capitalize",
1853
2089
  fontWeight: "semibold",
1854
- children: n
2090
+ children: r
1855
2091
  }
1856
2092
  ),
1857
- t.sensorOnly && /* @__PURE__ */ e.jsx(Lt, { size: "sm", colorScheme: "orange", variant: "subtle", children: "Sensor Only" }),
1858
- h && !u && /* @__PURE__ */ e.jsx(
1859
- Ht,
2093
+ n.sensorOnly && /* @__PURE__ */ e.jsx(wt, { size: "sm", colorScheme: "orange", variant: "subtle", children: "Sensor Only" }),
2094
+ p && !u && /* @__PURE__ */ e.jsx(
2095
+ Xt,
1860
2096
  {
1861
2097
  size: "xs",
1862
2098
  variant: "ghost",
1863
2099
  "aria-label": "delete",
1864
- icon: /* @__PURE__ */ e.jsx(xt, { as: cn }),
1865
- onClick: h
2100
+ icon: /* @__PURE__ */ e.jsx(bt, { as: jn }),
2101
+ onClick: p
1866
2102
  }
1867
2103
  ),
1868
- !g && /* @__PURE__ */ e.jsx(
1869
- Tn,
2104
+ !x && /* @__PURE__ */ e.jsx(
2105
+ On,
1870
2106
  {
1871
- selectedItem: t?.kind ?? Ue.Limit,
1872
- onChange: ({ value: x }) => o({ ...t, kind: x }),
2107
+ selectedItem: n?.kind ?? Ke.Limit,
2108
+ onChange: ({ value: g }) => a({ ...n, kind: g }),
1873
2109
  isDisabled: d || u,
1874
2110
  buttonProps: {
1875
2111
  size: "sm",
@@ -1881,450 +2117,450 @@ const In = ({
1881
2117
  colorScheme: "teal"
1882
2118
  },
1883
2119
  items: [
1884
- { value: Ue.Limit, label: "limit" },
1885
- { value: Ue.Target, label: "target" }
2120
+ { value: Ke.Limit, label: "limit" },
2121
+ { value: Ke.Target, label: "target" }
1886
2122
  ]
1887
2123
  }
1888
2124
  )
1889
2125
  ] }),
1890
2126
  /* @__PURE__ */ e.jsx(
1891
- Nn,
2127
+ An,
1892
2128
  {
1893
2129
  w: "100%",
1894
2130
  size: "xs",
1895
2131
  min: s,
1896
- max: c,
2132
+ max: i,
1897
2133
  zeroMarker: !0,
1898
- value: [t.min, t.max],
1899
- onChange: (x) => o({ ...t, min: x[0], max: x[1] }),
1900
- formatValue: (x) => `${Math.abs(x)}°`,
1901
- valueLabel: (x) => C(x) ?? "",
1902
- positiveNegativeLabels: C(0) ? [C(-1) ?? "", C(1) ?? ""] : void 0,
2134
+ value: [n.min, n.max],
2135
+ onChange: (g) => a({ ...n, min: g[0], max: g[1] }),
2136
+ formatValue: (g) => `${Math.abs(g)}°`,
2137
+ valueLabel: (g) => h(g) ?? "",
2138
+ positiveNegativeLabels: h(0) ? [h(-1) ?? "", h(1) ?? ""] : void 0,
1903
2139
  isDisabled: u
1904
2140
  }
1905
2141
  )
1906
2142
  ]
1907
2143
  }
1908
2144
  );
1909
- }, ze = (n, t) => "segment" in n && "segment" in t && n.segment === t.segment || "joint" in n && "joint" in t && n.joint === t.joint, pt = ({
1910
- options: n,
1911
- value: t,
1912
- onChange: o,
1913
- forceKind: h,
1914
- singleValue: g,
2145
+ }, Ue = (r, n) => "segment" in r && "segment" in n && r.segment === n.segment || "joint" in r && "joint" in n && r.joint === n.joint, ft = ({
2146
+ options: r,
2147
+ value: n,
2148
+ onChange: a,
2149
+ forceKind: p,
2150
+ singleValue: x,
1915
2151
  singleValueSideless: d,
1916
2152
  editOnly: u,
1917
- disableKind: C,
2153
+ disableKind: h,
1918
2154
  maxParameters: s,
1919
- ...c
2155
+ ...i
1920
2156
  }) => {
1921
- const x = d ? 2 : s, F = T(() => {
1922
- const m = /* @__PURE__ */ new Map();
1923
- return n.forEach((l) => {
1924
- const a = "joint" in l.id;
1925
- let v, w;
1926
- if (a ? (v = kt(l.id.joint, l.plane, !0) ?? "Unknown", w = `joint:${l.id.joint}`) : (v = Rt(l.id.segment, l.plane, !0) ?? "Unknown", w = `segment:${l.id.segment}`), !m.has(w)) {
1927
- const W = a ? ut(l.id.joint) ?? "Unknown Joint" : ut(l.id.segment) ?? "Unknown Segment";
1928
- m.set(w, {
1929
- label: W,
2157
+ const g = d ? 2 : s, w = k(() => {
2158
+ const c = /* @__PURE__ */ new Map();
2159
+ return r.forEach((m) => {
2160
+ const v = "joint" in m.id;
2161
+ let j, A;
2162
+ if (v ? (j = Tt(m.id.joint, m.plane, !0) ?? "Unknown", A = `joint:${m.id.joint}`) : (j = kt(m.id.segment, m.plane, !0) ?? "Unknown", A = `segment:${m.id.segment}`), !c.has(A)) {
2163
+ const O = v ? pt(m.id.joint) ?? "Unknown Joint" : pt(m.id.segment) ?? "Unknown Segment";
2164
+ c.set(A, {
2165
+ label: O,
1930
2166
  options: []
1931
2167
  });
1932
2168
  }
1933
- const _ = m.get(w), B = [
1934
- v,
1935
- a ? l.id.joint : l.id.segment,
1936
- l.plane
1937
- ].filter(Boolean).map((W) => String(W).toLowerCase().replace(/\s+|_/g, ""));
1938
- _.options.push({
1939
- label: /* @__PURE__ */ e.jsxs(oe, { spacing: 2, justify: "space-between", w: "100%", pl: 3, children: [
1940
- /* @__PURE__ */ e.jsx(b, { children: v }),
1941
- l.sensorOnly && /* @__PURE__ */ e.jsx(Lt, { size: "sm", colorScheme: "orange", variant: "subtle", children: "Sensor Only" })
2169
+ const $ = c.get(A), F = [
2170
+ j,
2171
+ v ? m.id.joint : m.id.segment,
2172
+ m.plane
2173
+ ].filter(Boolean).map((O) => String(O).toLowerCase().replace(/\s+|_/g, ""));
2174
+ $.options.push({
2175
+ label: /* @__PURE__ */ e.jsxs(re, { spacing: 2, justify: "space-between", w: "100%", pl: 3, children: [
2176
+ /* @__PURE__ */ e.jsx(C, { children: j }),
2177
+ m.sensorOnly && /* @__PURE__ */ e.jsx(wt, { size: "sm", colorScheme: "orange", variant: "subtle", children: "Sensor Only" })
1942
2178
  ] }),
1943
- value: l.id,
1944
- plane: l.plane,
1945
- sensorOnly: l.sensorOnly,
1946
- searchTokens: B
2179
+ value: m.id,
2180
+ plane: m.plane,
2181
+ sensorOnly: m.sensorOnly,
2182
+ searchTokens: F
1947
2183
  });
1948
- }), Array.from(m.values());
1949
- }, [n]), L = T(() => {
1950
- if (!d || t.length === 0)
1951
- return F;
1952
- const m = t[0];
1953
- return F.map((l) => ({
1954
- ...l,
1955
- options: l.options.filter(
1956
- (a) => _e(a.value) === _e(m.id) && a.plane === m.plane
2184
+ }), Array.from(c.values());
2185
+ }, [r]), S = k(() => {
2186
+ if (!d || n.length === 0)
2187
+ return w;
2188
+ const c = n[0];
2189
+ return w.map((m) => ({
2190
+ ...m,
2191
+ options: m.options.filter(
2192
+ (v) => Be(v.value) === Be(c.id) && v.plane === c.plane
1957
2193
  )
1958
- })).filter((l) => l.options.length > 0);
1959
- }, [F, t, d]), y = T(() => F.flatMap((l) => l.options).filter(
1960
- (l) => t.some((a) => ze(a.id, l.value) && a.plane === l.plane)
1961
- ), [F, t]), I = $((m, l) => {
1962
- if (!l) return !0;
1963
- const a = l.toLowerCase().replace(/\s+|_/g, ""), v = m.data;
1964
- return !v || !v.searchTokens ? !1 : v.searchTokens.some(
1965
- (w) => w.includes(a)
2194
+ })).filter((m) => m.options.length > 0);
2195
+ }, [w, n, d]), M = k(() => w.flatMap((m) => m.options).filter(
2196
+ (m) => n.some((v) => Ue(v.id, m.value) && v.plane === m.plane)
2197
+ ), [w, n]), I = P((c, m) => {
2198
+ if (!m) return !0;
2199
+ const v = m.toLowerCase().replace(/\s+|_/g, ""), j = c.data;
2200
+ return !j || !j.searchTokens ? !1 : j.searchTokens.some(
2201
+ (A) => A.includes(v)
1966
2202
  );
1967
- }, []), j = $(
1968
- (m) => {
1969
- const l = m.map((a) => {
1970
- const v = t.find(
1971
- (N) => ze(N.id, a.value) && N.plane === a.plane
1972
- ), w = n.find(
1973
- (N) => ze(N.id, a.value) && N.plane === a.plane
1974
- ), _ = d ? t.find(
1975
- (N) => _e(N.id) === _e(a.value) && N.plane === a.plane
1976
- ) : void 0, B = _ && !v ? _.min : w && w.min ? w.min : 0, W = _ && !v ? _.max : w && w.max ? w.max : 0;
1977
- return v ?? {
1978
- id: a.value,
1979
- plane: a.plane,
1980
- min: B,
1981
- max: W,
1982
- sensorOnly: a.sensorOnly,
1983
- kind: h ?? Ue.Limit
2203
+ }, []), y = P(
2204
+ (c) => {
2205
+ const m = c.map((v) => {
2206
+ const j = n.find(
2207
+ (N) => Ue(N.id, v.value) && N.plane === v.plane
2208
+ ), A = r.find(
2209
+ (N) => Ue(N.id, v.value) && N.plane === v.plane
2210
+ ), $ = d ? n.find(
2211
+ (N) => Be(N.id) === Be(v.value) && N.plane === v.plane
2212
+ ) : void 0, F = $ && !j ? $.min : A && A.min ? A.min : 0, O = $ && !j ? $.max : A && A.max ? A.max : 0;
2213
+ return j ?? {
2214
+ id: v.value,
2215
+ plane: v.plane,
2216
+ min: F,
2217
+ max: O,
2218
+ sensorOnly: v.sensorOnly,
2219
+ kind: p ?? Ke.Limit
1984
2220
  };
1985
2221
  });
1986
- o(l);
2222
+ a(m);
1987
2223
  },
1988
- [o, t, n, h, d]
2224
+ [a, n, r, p, d]
1989
2225
  );
1990
- return ce(() => {
1991
- const m = t.filter(
1992
- (l) => n.some((a) => ze(a.id, l.id) && a.plane === l.plane)
2226
+ return ie(() => {
2227
+ const c = n.filter(
2228
+ (m) => r.some((v) => Ue(v.id, m.id) && v.plane === m.plane)
1993
2229
  );
1994
- m.length !== t.length && o(m);
1995
- }, [n, o, t]), /* @__PURE__ */ e.jsxs(re, { ...c, children: [
2230
+ c.length !== n.length && a(c);
2231
+ }, [r, a, n]), /* @__PURE__ */ e.jsxs(te, { ...i, children: [
1996
2232
  /* @__PURE__ */ e.jsx(
1997
- ge,
2233
+ ue,
1998
2234
  {
1999
- isMulti: !g,
2000
- placeholder: t.length ? `${t.length} selected` : "Search...",
2001
- value: y,
2002
- isDisabled: u || y.length >= (x ?? 1 / 0),
2003
- onChange: (m) => Array.isArray(m) ? j([...m]) : j(m !== null ? [m] : []),
2004
- options: L,
2235
+ isMulti: !x,
2236
+ placeholder: n.length ? `${n.length} selected` : "Search...",
2237
+ value: M,
2238
+ isDisabled: u || M.length >= (g ?? 1 / 0),
2239
+ onChange: (c) => Array.isArray(c) ? y([...c]) : y(c !== null ? [c] : []),
2240
+ options: S,
2005
2241
  controlShouldRenderValue: !1,
2006
- formatOptionLabel: (m) => m.label,
2242
+ formatOptionLabel: (c) => c.label,
2007
2243
  filterOption: I,
2008
2244
  isSearchable: !0
2009
2245
  }
2010
2246
  ),
2011
2247
  /* @__PURE__ */ e.jsx(
2012
- Wn,
2248
+ qn,
2013
2249
  {
2014
2250
  marginTop: 2,
2015
2251
  maxH: "28rem",
2016
- value: t,
2017
- onChange: o,
2018
- forceKind: h,
2019
- disableKind: C,
2252
+ value: n,
2253
+ onChange: a,
2254
+ forceKind: p,
2255
+ disableKind: h,
2020
2256
  isDisabled: u,
2021
2257
  lockRanges: d
2022
2258
  }
2023
2259
  )
2024
2260
  ] });
2025
- }, gt = (n) => {
2026
- switch (n) {
2027
- case ae.Thorax:
2261
+ }, jt = (r) => {
2262
+ switch (r) {
2263
+ case ce.Thorax:
2028
2264
  return "Thorax";
2029
- case ae.CenterBack:
2265
+ case ce.CenterBack:
2030
2266
  return "Center Back";
2031
- case ae.Pelvis:
2267
+ case ce.Pelvis:
2032
2268
  return "Pelvis";
2033
- case ae.LeftThigh:
2269
+ case ce.LeftThigh:
2034
2270
  return "Left Thigh";
2035
- case ae.RightThigh:
2271
+ case ce.RightThigh:
2036
2272
  return "Right Thigh";
2037
- case ae.LeftShank:
2273
+ case ce.LeftShank:
2038
2274
  return "Left Shank";
2039
- case ae.RightShank:
2275
+ case ce.RightShank:
2040
2276
  return "Right Shank";
2041
- case ae.LeftFoot:
2277
+ case ce.LeftFoot:
2042
2278
  return "Left Foot";
2043
- case ae.RightFoot:
2279
+ case ce.RightFoot:
2044
2280
  return "Right Foot";
2045
- case ae.LeftUpperArm:
2281
+ case ce.LeftUpperArm:
2046
2282
  return "Left Upper Arm";
2047
- case ae.RightUpperArm:
2283
+ case ce.RightUpperArm:
2048
2284
  return "Right Upper Arm";
2049
- case ae.LeftForearm:
2285
+ case ce.LeftForearm:
2050
2286
  return "Left Forearm";
2051
- case ae.RightForearm:
2287
+ case ce.RightForearm:
2052
2288
  return "Right Forearm";
2053
- case ae.Head:
2289
+ case ce.Head:
2054
2290
  return "Head";
2055
2291
  }
2056
- }, qn = (n) => {
2057
- switch (n) {
2058
- case se.GeneralActivity:
2292
+ }, Yn = (r) => {
2293
+ switch (r) {
2294
+ case ae.GeneralActivity:
2059
2295
  return "General Activity";
2060
- case se.MovementCoordination:
2296
+ case ae.MovementCoordination:
2061
2297
  return "Movement Coordination";
2062
- case se.PointOfInterest:
2298
+ case ae.PointOfInterest:
2063
2299
  return "Point of Interest";
2064
- case se.Range:
2300
+ case ae.Range:
2065
2301
  return "Range";
2066
- case se.StabilityBalance:
2302
+ case ae.StabilityBalance:
2067
2303
  return "Stability Balance";
2068
2304
  }
2069
- }, ms = ({
2070
- id: n,
2071
- onError: t,
2072
- onCancel: o,
2073
- onSave: h,
2074
- hideButtons: g,
2305
+ }, gs = ({
2306
+ id: r,
2307
+ onError: n,
2308
+ onCancel: a,
2309
+ onSave: p,
2310
+ hideButtons: x,
2075
2311
  setButtonOnClick: d,
2076
2312
  setButtonDisabled: u,
2077
- quantumOwned: C,
2313
+ quantumOwned: h,
2078
2314
  isView: s
2079
2315
  }) => {
2080
- const c = nn(), [{ fetching: x }, F] = me(tt), [{ fetching: L }, y] = me(hn), [{ data: I }] = je({
2081
- query: mn,
2082
- variables: { id: n ?? "" },
2083
- pause: !n
2084
- }), j = T(() => {
2085
- const p = R(
2086
- fe,
2316
+ const i = rt(), [{ fetching: g }, w] = fe(st), [{ fetching: S }, M] = fe(an), [{ data: I }] = Ce({
2317
+ query: ln,
2318
+ variables: { id: r ?? "" },
2319
+ pause: !r
2320
+ }), y = k(() => {
2321
+ const f = L(
2322
+ ve,
2087
2323
  I?.getActionById
2088
2324
  );
2089
- if (!p) return null;
2090
- const k = R(nt, p.reports).map((G) => ({
2091
- ...G,
2092
- thresholds: R(Se, G.thresholds)
2325
+ if (!f) return null;
2326
+ const G = L(Ze, f.reports).map((Q) => ({
2327
+ ...Q,
2328
+ thresholds: L(Ie, Q.thresholds)
2093
2329
  }));
2094
2330
  return {
2095
- ...p,
2096
- thresholds: R(Se, p.thresholds),
2097
- reports: k
2331
+ ...f,
2332
+ thresholds: L(Ie, f.thresholds),
2333
+ reports: G
2098
2334
  };
2099
- }, [I]), m = x || L, l = !!j && !!n, { getLabel: a } = xe(), v = T(() => ({
2100
- action: a("action")
2101
- }), [a]), w = T(() => [
2335
+ }, [I]), c = g || S, m = !!y && !!r, { getLabel: v } = pe(), j = k(() => ({
2336
+ action: v("action")
2337
+ }), [v]), A = k(() => [
2102
2338
  { key: "module_category", label: "Link Category", multi: !0 },
2103
- { key: "activity_type", label: `${v.action} Type`, multi: !1 },
2339
+ { key: "activity_type", label: `${j.action} Type`, multi: !1 },
2104
2340
  { key: "session_type", label: "Session Type", multi: !0 },
2105
2341
  { key: "body_region", label: "Body Region", multi: !0 },
2106
2342
  { key: "sport", label: "Sport", multi: !0 }
2107
- ], [v.action]), [_, B] = z(""), [W, N] = z(""), [Z, J] = z(""), [D, S] = z(""), [O, M] = z([]), [E, te] = z({}), [Q, ie] = z(null), [i, r] = z([]), [f, A] = z([]), [U, ne] = z(""), [q, Y] = z([]), K = sn(), Me = T(() => K.filter((p) => p.sensorOnly), [K]), ve = T(() => {
2108
- const p = [
2109
- { label: "General Activity", value: se.GeneralActivity },
2343
+ ], [j.action]), [$, F] = B(""), [O, N] = B(""), [H, oe] = B(""), [R, Z] = B(""), [V, T] = B([]), [_, J] = B({}), [W, K] = B(null), [l, t] = B([]), [o, b] = B([]), [U, q] = B(""), [E, D] = B([]), Y = hn(), ge = k(() => Y.filter((f) => f.sensorOnly), [Y]), ye = k(() => {
2344
+ const f = [
2345
+ { label: "General Activity", value: ae.GeneralActivity },
2110
2346
  {
2111
2347
  label: "Movement Coordination",
2112
- value: se.MovementCoordination
2348
+ value: ae.MovementCoordination
2113
2349
  },
2114
- { label: "Point of Interest", value: se.PointOfInterest },
2115
- { label: "Range", value: se.Range },
2116
- { label: "Stability Balance", value: se.StabilityBalance }
2117
- ], P = q.map((k) => k.kind);
2118
- return p.filter(
2119
- (k) => !P.includes(k.value)
2350
+ { label: "Point of Interest", value: ae.PointOfInterest },
2351
+ { label: "Range", value: ae.Range },
2352
+ { label: "Stability Balance", value: ae.StabilityBalance }
2353
+ ], z = E.map((G) => G.kind);
2354
+ return f.filter(
2355
+ (G) => !z.includes(G.value)
2120
2356
  );
2121
- }, [q]), Fe = _.length > 0, [Pe, st] = z({});
2122
- ce(() => {
2123
- const p = w.map(
2124
- (P) => c.query(pn, { key: P.key })
2357
+ }, [E]), De = $.length > 0, [Ge, ot] = B({});
2358
+ ie(() => {
2359
+ const f = A.map(
2360
+ (z) => i.query(nt, { key: z.key })
2125
2361
  );
2126
- Promise.all(p).then((P) => {
2127
- const k = {};
2128
- P.forEach((G) => {
2129
- if (G.error || !G.data) return;
2130
- const H = R(
2131
- Ye,
2132
- G.data.getMetadataByKey
2133
- ), V = R(
2134
- He,
2135
- H.data
2362
+ Promise.all(f).then((z) => {
2363
+ const G = {};
2364
+ z.forEach((Q) => {
2365
+ if (Q.error || !Q.data) return;
2366
+ const ee = L(
2367
+ je,
2368
+ Q.data.getMetadataByKey
2369
+ ), ne = L(
2370
+ be,
2371
+ ee.data
2136
2372
  );
2137
- k[H.key] = V.map((ue) => ({
2138
- label: ue.label || ue.value,
2139
- value: ue.value,
2140
- id: ue.id
2373
+ G[ee.key] = ne.map((me) => ({
2374
+ label: me.label || me.value,
2375
+ value: me.value,
2376
+ id: me.id
2141
2377
  }));
2142
- }), te(k);
2378
+ }), J(G);
2143
2379
  });
2144
- }, [c, w]), ce(() => {
2145
- if (j) {
2146
- const P = R(
2147
- Ye,
2148
- j.metadataGroups
2380
+ }, [i, A]), ie(() => {
2381
+ if (y) {
2382
+ const z = L(
2383
+ je,
2384
+ y.metadataGroups
2149
2385
  ).map(
2150
- (H) => H.data.map((V) => R(He, V).id)
2151
- ), k = j.reports.map((H) => ({
2152
- id: H.id,
2153
- instructions: H.instructions ?? "",
2154
- kind: H.reportKind,
2155
- parameters: H.thresholds.map((V) => ({
2386
+ (ee) => ee.data.map((ne) => L(be, ne).id)
2387
+ ), G = y.reports.map((ee) => ({
2388
+ id: ee.id,
2389
+ instructions: ee.instructions ?? "",
2390
+ kind: ee.reportKind,
2391
+ parameters: ee.thresholds.map((ne) => ({
2156
2392
  id: {
2157
- [V.partKind]: V.partId
2393
+ [ne.partKind]: ne.partId
2158
2394
  },
2159
- kind: V.kind,
2160
- min: V.min,
2161
- max: V.max,
2162
- plane: V.partDimension,
2163
- oldId: V.id,
2164
- sensorOnly: Me.some((ue) => {
2165
- const Ze = ue.id[V.partKind];
2166
- return Ze ? Ze === V.partId && ue.plane === V.partDimension : !1;
2395
+ kind: ne.kind,
2396
+ min: ne.min,
2397
+ max: ne.max,
2398
+ plane: ne.partDimension,
2399
+ oldId: ne.id,
2400
+ sensorOnly: ge.some((me) => {
2401
+ const Ve = me.id[ne.partKind];
2402
+ return Ve ? Ve === ne.partId && me.plane === ne.partDimension : !1;
2167
2403
  })
2168
2404
  })),
2169
- sensorLocations: H.sensorLocations
2170
- })), G = {
2171
- name: j.name,
2172
- description: j.description || "",
2173
- cameraPlacement: j.cameraPlacement || "",
2174
- videoLink: j.videoLink || "",
2175
- metadataIds: P.flat(),
2176
- reports: k
2405
+ sensorLocations: ee.sensorLocations
2406
+ })), Q = {
2407
+ name: y.name,
2408
+ description: y.description || "",
2409
+ cameraPlacement: y.cameraPlacement || "",
2410
+ videoLink: y.videoLink || "",
2411
+ metadataIds: z.flat(),
2412
+ reports: G
2177
2413
  };
2178
- B(G.name), N(G.description), J(G.cameraPlacement), S(G.videoLink), M(G.metadataIds), Y(k), st(G);
2414
+ F(Q.name), N(Q.description), oe(Q.cameraPlacement), Z(Q.videoLink), T(Q.metadataIds), D(G), ot(Q);
2179
2415
  }
2180
- }, [j]);
2181
- const Ie = T(
2182
- () => JSON.stringify(Pe) !== JSON.stringify({
2183
- name: _,
2184
- description: W,
2185
- cameraPlacement: Z,
2186
- videoLink: D,
2187
- metadataIds: O,
2188
- reports: q
2416
+ }, [y]);
2417
+ const Oe = k(
2418
+ () => JSON.stringify(Ge) !== JSON.stringify({
2419
+ name: $,
2420
+ description: O,
2421
+ cameraPlacement: H,
2422
+ videoLink: R,
2423
+ metadataIds: V,
2424
+ reports: E
2189
2425
  }),
2190
2426
  [
2191
- Pe,
2192
- _,
2193
- W,
2194
- Z,
2195
- D,
2427
+ Ge,
2428
+ $,
2196
2429
  O,
2197
- q
2430
+ H,
2431
+ R,
2432
+ V,
2433
+ E
2198
2434
  ]
2199
- ), Oe = $(() => {
2200
- const p = {
2201
- name: _,
2202
- description: W,
2203
- cameraPlacement: Z,
2204
- videoLink: D,
2205
- metadataItemIds: O,
2435
+ ), Ae = P(() => {
2436
+ const f = {
2437
+ name: $,
2438
+ description: O,
2439
+ cameraPlacement: H,
2440
+ videoLink: R,
2441
+ metadataItemIds: V,
2206
2442
  // Backend requires laterality; keep existing default since UI no longer edits it
2207
- laterality: Mn.Either,
2208
- quantumOwned: C,
2443
+ laterality: In.Either,
2444
+ quantumOwned: h,
2209
2445
  //Backend requires session type; keep existing default since UI no longer edits it
2210
2446
  sessionType: [],
2211
2447
  // Backend requires thresholds; use empty array since reports handle parameters now
2212
2448
  thresholds: [],
2213
2449
  // Include reports data
2214
- reports: q.map((k) => ({
2215
- id: k.isNew ? void 0 : k.id,
2216
- reportKind: k.kind,
2217
- sensorLocations: k.sensorLocations,
2218
- instructions: k.instructions,
2219
- thresholds: k.parameters.map((G) => ({
2220
- id: G.oldId,
2221
- kind: G.kind,
2222
- min: G.min,
2223
- max: G.max,
2224
- partKind: "joint" in G.id ? "joint" : "segment",
2225
- partId: "joint" in G.id ? G.id.joint : G.id.segment,
2226
- partDimension: G.plane
2450
+ reports: E.map((G) => ({
2451
+ id: G.isNew ? void 0 : G.id,
2452
+ reportKind: G.kind,
2453
+ sensorLocations: G.sensorLocations,
2454
+ instructions: G.instructions,
2455
+ thresholds: G.parameters.map((Q) => ({
2456
+ id: Q.oldId,
2457
+ kind: Q.kind,
2458
+ min: Q.min,
2459
+ max: Q.max,
2460
+ partKind: "joint" in Q.id ? "joint" : "segment",
2461
+ partId: "joint" in Q.id ? Q.id.joint : Q.id.segment,
2462
+ partDimension: Q.plane
2227
2463
  }))
2228
2464
  }))
2229
2465
  };
2230
- let P;
2231
- l && n ? P = y({
2232
- id: n,
2233
- fields: p
2234
- }) : P = F({
2235
- fields: p
2236
- }), P.then(({ error: k }) => {
2237
- k ? t(k) : h();
2466
+ let z;
2467
+ m && r ? z = M({
2468
+ id: r,
2469
+ fields: f
2470
+ }) : z = w({
2471
+ fields: f
2472
+ }), z.then(({ error: G }) => {
2473
+ G ? n(G) : p();
2238
2474
  });
2239
2475
  }, [
2240
- C,
2241
- F,
2242
- y,
2243
- n,
2244
- _,
2245
- W,
2246
- Z,
2247
- D,
2248
- O,
2249
- q,
2250
- l,
2251
2476
  h,
2252
- t
2477
+ w,
2478
+ M,
2479
+ r,
2480
+ $,
2481
+ O,
2482
+ H,
2483
+ R,
2484
+ V,
2485
+ E,
2486
+ m,
2487
+ p,
2488
+ n
2253
2489
  ]);
2254
- ce(() => {
2490
+ ie(() => {
2255
2491
  u && u({
2256
- cancelButton: m,
2257
- saveButton: s ? !0 : m || !Fe || !Ie
2492
+ cancelButton: c,
2493
+ saveButton: s ? !0 : c || !De || !Oe
2258
2494
  });
2259
- }, [m, u, Fe, Ie, s]), ce(() => {
2495
+ }, [c, u, De, Oe, s]), ie(() => {
2260
2496
  d && d({
2261
- cancelButton: o,
2497
+ cancelButton: a,
2262
2498
  saveButton: s ? () => {
2263
- } : Oe
2499
+ } : Ae
2264
2500
  });
2265
- }, [d, o, Oe, s]);
2266
- const $e = $(
2267
- (p) => {
2268
- const P = ht(
2269
- p.map(
2270
- (k) => "joint" in k.id ? k.id.joint : k.id.segment
2501
+ }, [d, a, Ae, s]);
2502
+ const Pe = P(
2503
+ (f) => {
2504
+ const z = gt(
2505
+ f.map(
2506
+ (G) => "joint" in G.id ? G.id.joint : G.id.segment
2271
2507
  )
2272
2508
  );
2273
- A(P);
2509
+ b(z);
2274
2510
  },
2275
2511
  []
2276
2512
  );
2277
- ce(() => {
2278
- $e(i);
2279
- }, [i, $e]);
2280
- const Ae = $(() => {
2281
- if (!Q)
2513
+ ie(() => {
2514
+ Pe(l);
2515
+ }, [l, Pe]);
2516
+ const ke = P(() => {
2517
+ if (!W)
2282
2518
  return;
2283
- const p = Q === se.PointOfInterest, P = {
2519
+ const f = W === ae.PointOfInterest, z = {
2284
2520
  id: Date.now().toString(),
2285
2521
  // Temporary ID
2286
- kind: Q,
2287
- parameters: p ? [] : i,
2288
- sensorLocations: p ? [] : f,
2289
- instructions: p ? U : "",
2522
+ kind: W,
2523
+ parameters: f ? [] : l,
2524
+ sensorLocations: f ? [] : o,
2525
+ instructions: f ? U : "",
2290
2526
  isNew: !0
2291
2527
  };
2292
- Y((k) => [...k, P]), ie(null), r([]), A([]), ne("");
2528
+ D((G) => [...G, z]), K(null), t([]), b([]), q("");
2293
2529
  }, [
2294
- Q,
2295
- i,
2296
- f,
2530
+ W,
2531
+ l,
2532
+ o,
2297
2533
  U
2298
- ]), he = $((p) => {
2299
- Y((P) => P.filter((k) => k.id !== p));
2300
- }, []), Te = (p, P) => {
2301
- const k = w.find((H) => H.key === p);
2302
- if (!k) return;
2303
- const G = k.multi ? (P ?? []).map(
2304
- (H) => H.id
2305
- ) : P ? [P.id] : [];
2306
- M((H) => [...H.filter((ue) => Object.values(E).flat().find((De) => De.id === ue) && !Object.keys(E).find(
2307
- (De) => E[De]?.some(
2308
- (Pt) => Pt.id === ue && De === p
2534
+ ]), xe = P((f) => {
2535
+ D((z) => z.filter((G) => G.id !== f));
2536
+ }, []), Te = (f, z) => {
2537
+ const G = A.find((ee) => ee.key === f);
2538
+ if (!G) return;
2539
+ const Q = G.multi ? (z ?? []).map(
2540
+ (ee) => ee.id
2541
+ ) : z ? [z.id] : [];
2542
+ T((ee) => [...ee.filter((me) => Object.values(_).flat().find((Ee) => Ee.id === me) && !Object.keys(_).find(
2543
+ (Ee) => _[Ee]?.some(
2544
+ (Nt) => Nt.id === me && Ee === f
2309
2545
  )
2310
- )), ...G]);
2546
+ )), ...Q]);
2311
2547
  };
2312
2548
  return /* @__PURE__ */ e.jsxs(le, { spacing: 4, w: "full", align: "stretch", children: [
2313
- /* @__PURE__ */ e.jsxs(Jt, { children: [
2314
- /* @__PURE__ */ e.jsxs(Xt, { children: [
2315
- /* @__PURE__ */ e.jsx(ct, { children: "Basic Information" }),
2316
- /* @__PURE__ */ e.jsx(ct, { children: "Reports" })
2549
+ /* @__PURE__ */ e.jsxs(Zt, { children: [
2550
+ /* @__PURE__ */ e.jsxs(Vt, { children: [
2551
+ /* @__PURE__ */ e.jsx(mt, { children: "Basic Information" }),
2552
+ /* @__PURE__ */ e.jsx(mt, { children: "Reports" })
2317
2553
  ] }),
2318
- /* @__PURE__ */ e.jsxs(Zt, { children: [
2319
- /* @__PURE__ */ e.jsx(dt, { px: 0, children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [
2554
+ /* @__PURE__ */ e.jsxs(en, { children: [
2555
+ /* @__PURE__ */ e.jsx(ht, { px: 0, children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [
2320
2556
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2321
2557
  /* @__PURE__ */ e.jsxs(X, { children: [
2322
2558
  /* @__PURE__ */ e.jsx(de, { children: "Name" }),
2323
2559
  /* @__PURE__ */ e.jsx(
2324
- we,
2560
+ Le,
2325
2561
  {
2326
- value: _,
2327
- onChange: (p) => B(p.target.value),
2562
+ value: $,
2563
+ onChange: (f) => F(f.target.value),
2328
2564
  type: "text",
2329
2565
  placeholder: "i.e. Lunge & Return",
2330
2566
  isDisabled: s
@@ -2334,10 +2570,10 @@ const In = ({
2334
2570
  /* @__PURE__ */ e.jsxs(X, { children: [
2335
2571
  /* @__PURE__ */ e.jsx(de, { children: "Camera Placement" }),
2336
2572
  /* @__PURE__ */ e.jsx(
2337
- Ee,
2573
+ ze,
2338
2574
  {
2339
- value: Z,
2340
- onChange: (p) => J(p.target.value),
2575
+ value: H,
2576
+ onChange: (f) => oe(f.target.value),
2341
2577
  rows: 2,
2342
2578
  placeholder: "(optional) Describe camera setup, placement, angles",
2343
2579
  isDisabled: s
@@ -2347,10 +2583,10 @@ const In = ({
2347
2583
  /* @__PURE__ */ e.jsxs(X, { children: [
2348
2584
  /* @__PURE__ */ e.jsx(de, { children: "Video Link" }),
2349
2585
  /* @__PURE__ */ e.jsx(
2350
- we,
2586
+ Le,
2351
2587
  {
2352
- value: D,
2353
- onChange: (p) => S(p.target.value),
2588
+ value: R,
2589
+ onChange: (f) => Z(f.target.value),
2354
2590
  type: "url",
2355
2591
  placeholder: "(optional) https://...",
2356
2592
  isDisabled: s
@@ -2360,10 +2596,10 @@ const In = ({
2360
2596
  /* @__PURE__ */ e.jsxs(X, { children: [
2361
2597
  /* @__PURE__ */ e.jsx(de, { children: "Description" }),
2362
2598
  /* @__PURE__ */ e.jsx(
2363
- Ee,
2599
+ ze,
2364
2600
  {
2365
- value: W,
2366
- onChange: (p) => N(p.target.value),
2601
+ value: O,
2602
+ onChange: (f) => N(f.target.value),
2367
2603
  rows: 2,
2368
2604
  placeholder: "(optional) Describe how to perform the test or exercise",
2369
2605
  isDisabled: s
@@ -2373,62 +2609,62 @@ const In = ({
2373
2609
  ] }),
2374
2610
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2375
2611
  /* @__PURE__ */ e.jsx(de, { children: "Metadata Tags" }),
2376
- w.map((p) => /* @__PURE__ */ e.jsxs(X, { children: [
2377
- /* @__PURE__ */ e.jsx(de, { children: p.label }),
2612
+ A.map((f) => /* @__PURE__ */ e.jsxs(X, { children: [
2613
+ /* @__PURE__ */ e.jsx(de, { children: f.label }),
2378
2614
  /* @__PURE__ */ e.jsx(
2379
- ge,
2615
+ ue,
2380
2616
  {
2381
- isMulti: p.multi,
2382
- value: E[p.key]?.filter(
2383
- (P) => O.includes(P.id)
2617
+ isMulti: f.multi,
2618
+ value: _[f.key]?.filter(
2619
+ (z) => V.includes(z.id)
2384
2620
  ),
2385
- onChange: (P) => {
2386
- Te(p.key, P);
2621
+ onChange: (z) => {
2622
+ Te(f.key, z);
2387
2623
  },
2388
- options: E[p.key],
2389
- placeholder: `Select ${p.multi ? "one or more" : "one"} ${p.label.toLowerCase()}`,
2624
+ options: _[f.key],
2625
+ placeholder: `Select ${f.multi ? "one or more" : "one"} ${f.label.toLowerCase()}`,
2390
2626
  isDisabled: s,
2391
- isClearable: p.multi
2627
+ isClearable: f.multi
2392
2628
  }
2393
2629
  )
2394
- ] }, p.key))
2630
+ ] }, f.key))
2395
2631
  ] })
2396
2632
  ] }) }),
2397
- /* @__PURE__ */ e.jsx(dt, { px: 0, children: /* @__PURE__ */ e.jsxs(
2633
+ /* @__PURE__ */ e.jsx(ht, { px: 0, children: /* @__PURE__ */ e.jsxs(
2398
2634
  "div",
2399
2635
  {
2400
- className: Ne(
2636
+ className: qe(
2401
2637
  "grid grid-cols-1 gap-6",
2402
2638
  !s && "md:grid-cols-2"
2403
2639
  ),
2404
2640
  children: [
2405
- /* @__PURE__ */ e.jsxs("div", { className: Ne("space-y-4", s && "hidden"), children: [
2641
+ /* @__PURE__ */ e.jsxs("div", { className: qe("space-y-4", s && "hidden"), children: [
2406
2642
  /* @__PURE__ */ e.jsx(de, { children: "Add New Report" }),
2407
2643
  /* @__PURE__ */ e.jsxs(X, { children: [
2408
2644
  /* @__PURE__ */ e.jsx(de, { children: "Report Kind" }),
2409
- ve.length === 0 ? /* @__PURE__ */ e.jsx(b, { fontSize: "sm", color: "gray.500", p: 2, children: "All report kinds have been used. Remove an existing report to add a new one." }) : /* @__PURE__ */ e.jsx(
2410
- ge,
2645
+ ye.length === 0 ? /* @__PURE__ */ e.jsx(C, { fontSize: "sm", color: "gray.500", p: 2, children: "All report kinds have been used. Remove an existing report to add a new one." }) : /* @__PURE__ */ e.jsx(
2646
+ ue,
2411
2647
  {
2412
- value: Q ? ve.find(
2413
- (p) => p.value === Q
2648
+ value: W ? ye.find(
2649
+ (f) => f.value === W
2414
2650
  ) : null,
2415
- onChange: (p) => ie(p?.value || null),
2416
- options: ve,
2651
+ onChange: (f) => K(f?.value || null),
2652
+ options: ye,
2417
2653
  placeholder: "Select report kind...",
2418
2654
  isDisabled: s,
2419
2655
  isClearable: !0
2420
2656
  }
2421
2657
  )
2422
2658
  ] }),
2423
- Q !== se.PointOfInterest && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2659
+ W !== ae.PointOfInterest && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2424
2660
  /* @__PURE__ */ e.jsxs(X, { children: [
2425
2661
  /* @__PURE__ */ e.jsx(de, { children: "Default Parameters" }),
2426
2662
  /* @__PURE__ */ e.jsx(
2427
- pt,
2663
+ ft,
2428
2664
  {
2429
- options: K,
2430
- value: i,
2431
- onChange: r,
2665
+ options: Y,
2666
+ value: l,
2667
+ onChange: t,
2432
2668
  editOnly: s
2433
2669
  }
2434
2670
  )
@@ -2436,10 +2672,10 @@ const In = ({
2436
2672
  /* @__PURE__ */ e.jsxs(X, { children: [
2437
2673
  /* @__PURE__ */ e.jsx(de, { children: "Suggested Sensor Locations" }),
2438
2674
  /* @__PURE__ */ e.jsx(
2439
- we,
2675
+ Le,
2440
2676
  {
2441
- value: f.map(
2442
- (p) => gt(p)
2677
+ value: o.map(
2678
+ (f) => jt(f)
2443
2679
  ).join(", "),
2444
2680
  placeholder: "Auto-filled based on parameters...",
2445
2681
  isDisabled: !0
@@ -2447,13 +2683,13 @@ const In = ({
2447
2683
  )
2448
2684
  ] })
2449
2685
  ] }),
2450
- Q === se.PointOfInterest && /* @__PURE__ */ e.jsxs(X, { children: [
2686
+ W === ae.PointOfInterest && /* @__PURE__ */ e.jsxs(X, { children: [
2451
2687
  /* @__PURE__ */ e.jsx(de, { children: "Instructions" }),
2452
2688
  /* @__PURE__ */ e.jsx(
2453
- Ee,
2689
+ ze,
2454
2690
  {
2455
2691
  value: U,
2456
- onChange: (p) => ne(p.target.value),
2692
+ onChange: (f) => q(f.target.value),
2457
2693
  rows: 3,
2458
2694
  placeholder: "Enter specific instructions for this report...",
2459
2695
  isDisabled: s
@@ -2461,44 +2697,44 @@ const In = ({
2461
2697
  )
2462
2698
  ] }),
2463
2699
  /* @__PURE__ */ e.jsx("div", { className: "w-full flex justify-end", children: /* @__PURE__ */ e.jsx(
2464
- ee,
2700
+ se,
2465
2701
  {
2466
2702
  colorScheme: "blue",
2467
- onClick: Ae,
2468
- isDisabled: !Q || s || ve.length === 0 || Q !== se.PointOfInterest && i.length === 0,
2703
+ onClick: ke,
2704
+ isDisabled: !W || s || ye.length === 0 || W !== ae.PointOfInterest && l.length === 0,
2469
2705
  children: "Add Report"
2470
2706
  }
2471
2707
  ) })
2472
2708
  ] }),
2473
2709
  /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
2474
2710
  /* @__PURE__ */ e.jsx(de, { children: "Configured Reports" }),
2475
- q.length === 0 ? /* @__PURE__ */ e.jsx(b, { fontSize: "sm", color: "gray.500", children: "No reports created yet" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-3", children: q.map((p) => /* @__PURE__ */ e.jsxs(
2711
+ E.length === 0 ? /* @__PURE__ */ e.jsx(C, { fontSize: "sm", color: "gray.500", children: "No reports created yet" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-3", children: E.map((f) => /* @__PURE__ */ e.jsxs(
2476
2712
  "div",
2477
2713
  {
2478
2714
  className: "p-3 border border-gray-200 rounded-md bg-gray-50",
2479
2715
  children: [
2480
2716
  /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-start mb-2", children: [
2481
- /* @__PURE__ */ e.jsx(b, { fontWeight: "semibold", children: qn(p.kind) }),
2717
+ /* @__PURE__ */ e.jsx(C, { fontWeight: "semibold", children: Yn(f.kind) }),
2482
2718
  !s && /* @__PURE__ */ e.jsx(
2483
- ee,
2719
+ se,
2484
2720
  {
2485
2721
  size: "xs",
2486
2722
  colorScheme: "red",
2487
2723
  variant: "ghost",
2488
- onClick: () => he(p.id),
2724
+ onClick: () => xe(f.id),
2489
2725
  children: "Remove"
2490
2726
  }
2491
2727
  )
2492
2728
  ] }),
2493
- p.kind === se.PointOfInterest && /* @__PURE__ */ e.jsxs(X, { children: [
2729
+ f.kind === ae.PointOfInterest && /* @__PURE__ */ e.jsxs(X, { children: [
2494
2730
  /* @__PURE__ */ e.jsx(de, { children: "Instructions" }),
2495
2731
  /* @__PURE__ */ e.jsx(
2496
- Ee,
2732
+ ze,
2497
2733
  {
2498
- value: p.instructions,
2499
- onChange: (P) => Y(
2500
- (k) => k.map(
2501
- (G) => G.id === p.id ? { ...G, instructions: P.target.value } : G
2734
+ value: f.instructions,
2735
+ onChange: (z) => D(
2736
+ (G) => G.map(
2737
+ (Q) => Q.id === f.id ? { ...Q, instructions: z.target.value } : Q
2502
2738
  )
2503
2739
  ),
2504
2740
  rows: 3,
@@ -2507,34 +2743,34 @@ const In = ({
2507
2743
  }
2508
2744
  )
2509
2745
  ] }),
2510
- p.kind !== se.PointOfInterest && /* @__PURE__ */ e.jsx(
2511
- pt,
2746
+ f.kind !== ae.PointOfInterest && /* @__PURE__ */ e.jsx(
2747
+ ft,
2512
2748
  {
2513
- options: K,
2514
- value: p.parameters,
2515
- onChange: (P) => {
2516
- const k = P.map(
2517
- (H) => H.id.joint ?? H.id.segment
2518
- ), G = ht(k);
2519
- Y(
2520
- (H) => H.map(
2521
- (V) => V.id === p.id ? { ...V, parameters: P, sensorLocations: G } : V
2749
+ options: Y,
2750
+ value: f.parameters,
2751
+ onChange: (z) => {
2752
+ const G = z.map(
2753
+ (ee) => ee.id.joint ?? ee.id.segment
2754
+ ), Q = gt(G);
2755
+ D(
2756
+ (ee) => ee.map(
2757
+ (ne) => ne.id === f.id ? { ...ne, parameters: z, sensorLocations: Q } : ne
2522
2758
  )
2523
2759
  );
2524
2760
  },
2525
2761
  editOnly: s
2526
2762
  }
2527
2763
  ),
2528
- p.kind !== se.PointOfInterest && /* @__PURE__ */ e.jsxs(b, { fontSize: "sm", color: "gray.600", mt: 2, children: [
2764
+ f.kind !== ae.PointOfInterest && /* @__PURE__ */ e.jsxs(C, { fontSize: "sm", color: "gray.600", mt: 2, children: [
2529
2765
  "Sensors:",
2530
2766
  " ",
2531
- p.sensorLocations.map(
2532
- (P) => gt(P)
2767
+ f.sensorLocations.map(
2768
+ (z) => jt(z)
2533
2769
  ).join(", ")
2534
2770
  ] })
2535
2771
  ]
2536
2772
  },
2537
- p.id
2773
+ f.id
2538
2774
  )) })
2539
2775
  ] })
2540
2776
  ]
@@ -2543,19 +2779,19 @@ const In = ({
2543
2779
  ] })
2544
2780
  ] }),
2545
2781
  /* @__PURE__ */ e.jsx(
2546
- oe,
2782
+ re,
2547
2783
  {
2548
2784
  justify: "end",
2549
- className: Ne((g || s) && "!hidden"),
2550
- children: /* @__PURE__ */ e.jsxs(Le, { gap: 4, children: [
2551
- /* @__PURE__ */ e.jsx(ee, { colorScheme: "gray", isDisabled: m, onClick: o, children: "Cancel" }),
2785
+ className: qe((x || s) && "!hidden"),
2786
+ children: /* @__PURE__ */ e.jsxs(Me, { gap: 4, children: [
2787
+ /* @__PURE__ */ e.jsx(se, { colorScheme: "gray", isDisabled: c, onClick: a, children: "Cancel" }),
2552
2788
  /* @__PURE__ */ e.jsx(
2553
- ee,
2789
+ se,
2554
2790
  {
2555
2791
  colorScheme: "blue",
2556
- isDisabled: m || !Fe || !Ie,
2557
- isLoading: m,
2558
- onClick: Oe,
2792
+ isDisabled: c || !De || !Oe,
2793
+ isLoading: c,
2794
+ onClick: Ae,
2559
2795
  children: "Save changes"
2560
2796
  }
2561
2797
  )
@@ -2563,129 +2799,189 @@ const In = ({
2563
2799
  }
2564
2800
  )
2565
2801
  ] });
2566
- }, de = ({ children: n }) => /* @__PURE__ */ e.jsx(jt, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: n }), Kn = ({
2567
- children: n,
2568
- isView: t
2569
- }) => /* @__PURE__ */ e.jsx(Ft.Provider, { value: { isView: t }, children: n }), ps = ({
2570
- id: n,
2571
- onCancel: t,
2572
- onSave: o,
2573
- onError: h,
2574
- hideButtons: g,
2802
+ }, de = ({ children: r }) => /* @__PURE__ */ e.jsx(Xe, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: r }), Hn = ({
2803
+ children: r,
2804
+ isView: n,
2805
+ metadataKeys: a
2806
+ }) => {
2807
+ const [p, x] = B({}), d = rt();
2808
+ return ie(() => {
2809
+ const u = (a ?? []).map(
2810
+ (h) => d.query(nt, { key: h })
2811
+ );
2812
+ Promise.all(u).then((h) => {
2813
+ const s = {};
2814
+ h.forEach((i) => {
2815
+ if (i.error || !i.data) return;
2816
+ const g = L(
2817
+ je,
2818
+ i.data.getMetadataByKey
2819
+ ), w = L(
2820
+ be,
2821
+ g.data
2822
+ );
2823
+ s[g.key] = w.map((S) => ({
2824
+ label: S.label || S.value,
2825
+ value: S.value,
2826
+ id: S.id
2827
+ }));
2828
+ }), x(s);
2829
+ });
2830
+ }, [d, a]), /* @__PURE__ */ e.jsx(Rt.Provider, { value: { isView: n, metadataOptions: p }, children: r });
2831
+ }, xs = ({
2832
+ id: r,
2833
+ onCancel: n,
2834
+ onSave: a,
2835
+ onError: p,
2836
+ hideButtons: x,
2575
2837
  quantumOwned: d,
2576
2838
  setButtonOnClick: u,
2577
- setButtonDisabled: C,
2839
+ setButtonDisabled: h,
2578
2840
  isView: s
2579
2841
  }) => {
2580
- const [{ data: c }] = je({
2581
- query: d ? gn : xn
2582
- }), [{ data: x }] = je({
2583
- query: jn,
2584
- variables: { id: n },
2585
- pause: !n
2586
- }), [{ data: F }] = je({
2587
- query: fn
2588
- }), L = R(
2589
- ke,
2590
- F?.moduleCategories
2591
- ), [{ fetching: y }, I] = me(Tt), [{ fetching: j }, m] = me(At), l = R(
2592
- fe,
2593
- d ? c?.quantumOwnedActions : c?.actions
2594
- ) ?? [], a = R(Be, x?.module), v = T(() => R(Nt, a?.moduleActions) ?? [], [a?.moduleActions]), [w, _] = z([
2595
- ...v.map((O) => O.actionId) ?? []
2596
- ]), [B, W] = z(a?.name ?? ""), [N, Z] = z([]), [J, D] = z(a?.description ?? "");
2597
- ce(() => {
2598
- a && (_(v.map((O) => O.actionId)), W(a.name), D(a.description ?? ""), Z(
2599
- a.categories.map(
2600
- (O) => R(ke, O).id
2601
- ) ?? []
2602
- ));
2603
- }, [a, v]);
2604
- const S = $(() => {
2605
- let O;
2606
- const M = {
2607
- actions: w,
2608
- name: B,
2609
- categories: N.filter((E) => E !== "other"),
2610
- description: J,
2611
- quantumOwned: d
2842
+ const [{ data: i, fetching: g }] = Ce({
2843
+ query: d ? cn : dn
2844
+ }), [{ data: w }] = Ce({
2845
+ query: un,
2846
+ variables: { id: r },
2847
+ pause: !r
2848
+ }), [{ data: S }] = Ce({
2849
+ query: mn
2850
+ }), M = L(
2851
+ $e,
2852
+ S?.moduleCategories
2853
+ ), [{ fetching: I }, y] = fe(Ot), [{ fetching: c }, m] = fe(Mt), v = k(() => !i || g ? [] : L(
2854
+ ve,
2855
+ d ? i?.quantumOwnedActions ?? [] : i?.actions ?? []
2856
+ ).filter((l) => !!l?.id), [i, d, g]), j = L(Qe, w?.module), A = k(() => L(At, j?.moduleActions) ?? [], [j?.moduleActions]), [$, F] = B([
2857
+ ...A.map((K) => K.actionId) ?? []
2858
+ ]), [O, N] = B(j?.name ?? ""), [H, oe] = B([]), [R, Z] = B(j?.description ?? ""), [V, T] = B([]), [_, J] = B({});
2859
+ ie(() => {
2860
+ if (j) {
2861
+ F(A.map((o) => o.actionId)), N(j.name), Z(j.description ?? ""), oe(
2862
+ j.categories.map(
2863
+ (o) => L($e, o).id
2864
+ ) ?? []
2865
+ );
2866
+ const l = L(
2867
+ je,
2868
+ j.metadataGroups
2869
+ ).map(
2870
+ (o) => o.data.map((b) => L(be, b).id)
2871
+ );
2872
+ T(l.flat());
2873
+ const t = {};
2874
+ A.forEach((o) => {
2875
+ t[o.actionId] = o.reportId || null;
2876
+ }), J(t);
2877
+ }
2878
+ }, [j, A]);
2879
+ const W = P(() => {
2880
+ let K;
2881
+ const l = Object.entries(_).map(([o, b]) => ({
2882
+ actionId: o,
2883
+ reportId: b
2884
+ })).filter(({ reportId: o }) => o !== null), t = {
2885
+ actions: $,
2886
+ name: O,
2887
+ categories: H.filter((o) => o !== "other"),
2888
+ description: R,
2889
+ quantumOwned: d,
2890
+ metadataItemIds: V,
2891
+ actionReports: l.filter(({ reportId: o }) => o !== null).map(({ actionId: o, reportId: b }) => ({
2892
+ actionId: o,
2893
+ reportId: b
2894
+ }))
2612
2895
  };
2613
- a ? O = I({
2614
- id: a.id,
2615
- input: M
2616
- }) : O = m({
2617
- input: M
2618
- }), O.then(({ error: E }) => {
2619
- E ? h(E) : o();
2896
+ j ? K = y({
2897
+ id: j.id,
2898
+ input: t
2899
+ }) : K = m({
2900
+ input: t
2901
+ }), K.then(({ error: o }) => {
2902
+ o ? p(o instanceof Error ? o : new Error(String(o))) : a();
2620
2903
  });
2621
2904
  }, [
2622
2905
  m,
2623
- I,
2624
- w,
2625
- B,
2626
- J,
2627
- N,
2906
+ y,
2907
+ $,
2908
+ O,
2909
+ R,
2910
+ H,
2911
+ V,
2912
+ _,
2913
+ j,
2628
2914
  a,
2629
- o,
2630
- h,
2915
+ p,
2631
2916
  d
2632
2917
  ]);
2633
- return ce(() => {
2634
- C && C({
2635
- cancelButton: y || j,
2636
- saveButton: y || j || !B || J.trim().split(/\s+/).filter(Boolean).length > 40
2918
+ return ie(() => {
2919
+ h && h({
2920
+ cancelButton: I || c,
2921
+ saveButton: I || c || !O || R.trim().split(/\s+/).filter(Boolean).length > 40
2637
2922
  });
2638
- }, [C, y, j, w, B, J]), ce(() => {
2923
+ }, [h, I, c, $, O, R]), ie(() => {
2639
2924
  u && u({
2640
- cancelButton: t,
2641
- saveButton: S
2925
+ cancelButton: n,
2926
+ saveButton: W
2642
2927
  });
2643
- }, [u, t, S]), /* @__PURE__ */ e.jsx(re, { width: "100%", children: /* @__PURE__ */ e.jsxs(Kn, { isView: s, children: [
2644
- /* @__PURE__ */ e.jsx(
2645
- _n,
2646
- {
2647
- name: B,
2648
- setName: W,
2649
- actions: l,
2650
- selectedActionIds: w,
2651
- setSelectedActionIds: _,
2652
- availableCategories: L ?? [],
2653
- selectedCategoryIds: N,
2654
- setSelectedCategoryIds: Z,
2655
- description: J,
2656
- setDescription: D
2657
- }
2658
- ),
2659
- !g && !s && /* @__PURE__ */ e.jsx(oe, { justifyContent: "flex-start", children: /* @__PURE__ */ e.jsxs(Le, { mt: 16, gap: 4, children: [
2660
- /* @__PURE__ */ e.jsx(
2661
- ee,
2662
- {
2663
- colorScheme: "gray",
2664
- isDisabled: y || j,
2665
- onClick: t,
2666
- children: "Cancel"
2667
- }
2668
- ),
2669
- /* @__PURE__ */ e.jsx(
2670
- ee,
2671
- {
2672
- colorScheme: "blue",
2673
- isDisabled: y || j || !B || J.trim().split(/\s+/).filter(Boolean).length > 40,
2674
- isLoading: y || j,
2675
- onClick: S,
2676
- children: "Save"
2677
- }
2678
- )
2679
- ] }) })
2680
- ] }) });
2928
+ }, [u, n, W]), /* @__PURE__ */ e.jsx(te, { width: "100%", children: /* @__PURE__ */ e.jsxs(
2929
+ Hn,
2930
+ {
2931
+ isView: s,
2932
+ metadataKeys: ["activity_type", "session_type", "body_region", "sport"],
2933
+ children: [
2934
+ /* @__PURE__ */ e.jsx(
2935
+ Pn,
2936
+ {
2937
+ name: O,
2938
+ setName: N,
2939
+ actions: v,
2940
+ selectedActionIds: $,
2941
+ setSelectedActionIds: F,
2942
+ availableCategories: M ?? [],
2943
+ selectedCategoryIds: H,
2944
+ setSelectedCategoryIds: oe,
2945
+ description: R,
2946
+ setDescription: Z,
2947
+ selectedMetadataIds: V,
2948
+ setSelectedMetadataIds: T,
2949
+ actionReportIds: _,
2950
+ setActionReportIds: J
2951
+ }
2952
+ ),
2953
+ !x && !s && /* @__PURE__ */ e.jsx(re, { justifyContent: "flex-start", children: /* @__PURE__ */ e.jsxs(Me, { mt: 16, gap: 4, children: [
2954
+ /* @__PURE__ */ e.jsx(
2955
+ se,
2956
+ {
2957
+ colorScheme: "gray",
2958
+ isDisabled: I || c,
2959
+ onClick: n,
2960
+ children: "Cancel"
2961
+ }
2962
+ ),
2963
+ /* @__PURE__ */ e.jsx(
2964
+ se,
2965
+ {
2966
+ colorScheme: "blue",
2967
+ isDisabled: I || c || !O || R.trim().split(/\s+/).filter(Boolean).length > 40,
2968
+ isLoading: I || c,
2969
+ onClick: W,
2970
+ children: "Save"
2971
+ }
2972
+ )
2973
+ ] }) })
2974
+ ]
2975
+ }
2976
+ ) });
2681
2977
  };
2682
2978
  export {
2683
- En as ActivityList,
2684
- us as CopyActivityForm,
2685
- hs as CopyModuleForm,
2686
- _n as ModuleForm,
2687
- Wn as ParameterEditList,
2688
- pt as ParameterEditSelect,
2689
- ms as UpsertActivityForm,
2690
- ps as UpsertModuleForm
2979
+ Gn as ActivityList,
2980
+ hs as CopyActivityForm,
2981
+ ps as CopyModuleForm,
2982
+ Pn as ModuleForm,
2983
+ qn as ParameterEditList,
2984
+ ft as ParameterEditSelect,
2985
+ gs as UpsertActivityForm,
2986
+ xs as UpsertModuleForm
2691
2987
  };