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

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