@wso2/am-core-ui 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/CatalogKindListing-DvUuZEpc.js +137 -0
  2. package/dist/{CodeBlock-mB_Loq7I.js → CodeBlock-B2Ecl916.js} +1 -1
  3. package/dist/EnvironmentCard-CIXhDhlZ.js +319 -0
  4. package/dist/{EnvironmentSelector-B7Bl93s2.js → EnvironmentSelector-D8S6nO9u.js} +1 -1
  5. package/dist/IsolationTierIndicator-cf90kgjL.js +81 -0
  6. package/dist/LabelChips-7rA7_yre.js +139 -0
  7. package/dist/PolicyListSection-D6aVSKwP.js +1143 -0
  8. package/dist/{ResourceListShell-Cx6mdeqv.js → ResourceListShell-DFisKftq.js} +1 -1
  9. package/dist/{SwaggerSpecViewer-BvkhoKsi.js → SwaggerSpecViewer-DzjR6U6W.js} +1 -1
  10. package/dist/{debounce-BV83M53b.js → debounce-D17ObVdG.js} +1 -1
  11. package/dist/{format-BEZZRyE2.js → format-wlHhWjGo.js} +1 -1
  12. package/dist/{formatDistanceToNow-TErllcH8.js → formatDistanceToNow-DyjnT7l9.js} +11 -11
  13. package/dist/{gatewayScripts-D8O45W8u.js → gatewayScripts-D4ZDEDPS.js} +1 -1
  14. package/dist/{index-sr-mWz4T.js → index-3K-zqdp-.js} +32 -32
  15. package/dist/{index-KRsV2L4V.js → index-6liAPSDn.js} +160 -160
  16. package/dist/{index-B52h3RHg.js → index-B3ASENUJ.js} +109 -109
  17. package/dist/index-B7Pf4oPq.js +3069 -0
  18. package/dist/index-BNO3FhZK.js +2304 -0
  19. package/dist/index-BUZSfCl5.js +335 -0
  20. package/dist/index-BXiG1r_o.js +1409 -0
  21. package/dist/{index-_0Pj_ZtW.js → index-BYy7Iaam.js} +40 -40
  22. package/dist/{index-BfjzUWDa.js → index-BbB_yx4V.js} +103 -103
  23. package/dist/index-BjWJ95lH.js +2728 -0
  24. package/dist/{index-B_Z0MwXk.js → index-ByEInFlf.js} +10916 -9520
  25. package/dist/index-C8WIhzyz.js +123 -0
  26. package/dist/index-CnzvaT6b.js +2368 -0
  27. package/dist/index-CrnCf-hJ.js +763 -0
  28. package/dist/{index-CgCWbWzN.js → index-Cvsho9xg.js} +381 -377
  29. package/dist/{index-UqDmyMSA.js → index-CxnAo1_c.js} +21 -21
  30. package/dist/{index-BnV-PkwM.js → index-Cz7-AZwE.js} +2 -2
  31. package/dist/{index-BP5drcF2.js → index-DBdRFjxm.js} +232 -233
  32. package/dist/{index-BZ4vxviI.js → index-DFsSvmMZ.js} +5 -5
  33. package/dist/index-DslzOSGN.js +2549 -0
  34. package/dist/{index-DD4qF7gq.js → index-DvpYvchM.js} +101 -100
  35. package/dist/index.d.ts +784 -163
  36. package/dist/index.js +532 -454
  37. package/dist/js-yaml-CvhD-clg.js +1335 -0
  38. package/dist/{llmProviderPayload-CzihkdNa.js → llmProviderPayload-BPzWDy7n.js} +2 -2
  39. package/package.json +1 -1
  40. package/dist/CatalogKindListing-DtFI2YMG.js +0 -118
  41. package/dist/EnvironmentCard-09h1XRxx.js +0 -310
  42. package/dist/PolicyListSection-o4k9e8XO.js +0 -2475
  43. package/dist/index-CGDYgUCH.js +0 -711
  44. package/dist/index-COt7nJIf.js +0 -2286
  45. package/dist/index-CWZjOy1h.js +0 -2247
  46. package/dist/index-CezvogTQ.js +0 -116
  47. package/dist/index-CjCkcuuI.js +0 -322
  48. package/dist/index-CjXvuf9m.js +0 -1354
  49. package/dist/index-DeQ-9KTC.js +0 -737
  50. package/dist/index-Df6OBy4E.js +0 -3041
  51. package/dist/index-PUuASE1F.js +0 -2507
@@ -0,0 +1,2368 @@
1
+ import { c as me } from "react/compiler-runtime";
2
+ import { jsx as e, jsxs as i, Fragment as O } from "react/jsx-runtime";
3
+ import { Link as Qe, useNavigate as se, useParams as q, generatePath as B, useLocation as Ln, matchPath as En, Routes as Ke, Route as U, Navigate as Je } from "react-router-dom";
4
+ import { aw as Ye, cl as Ze, G as kn, g as X, n as Dn, cr as De, j as Gn, k as zn, o as On, E as Bn, cs as en, ct as Fn, L as nn, y as tn, H as rn, cu as Wn, cv as Mn, cw as jn, cx as $n, cy as Hn, cz as Vn, cA as Un, cB as Xn, cC as an, cD as _n, cE as qn, cF as Qn, cG as Kn, cH as Jn, cI as Yn, P as on, cJ as Me } from "./index-ByEInFlf.js";
5
+ import { useState as D, useMemo as S, useEffect as Ge, useCallback as Ce, createElement as sn, useRef as Zn } from "react";
6
+ import { Button as _, Form as T, Stack as E, Avatar as ye, Typography as P, Box as F, Skeleton as z, ListingTable as t, SearchBar as et, Alert as M, Tooltip as ee, IconButton as ae, Grid as ue, Card as Ie, InputAdornment as nt, Chip as pe, Tabs as ze, Tab as ce, TablePagination as ln, TextField as Z, Collapse as cn, Autocomplete as ve, CircularProgress as Te, List as je, ListSubheader as tt, Divider as rt, ListItemButton as it, ListItemIcon as at, ListItemText as ot } from "@wso2/oxygen-ui";
7
+ import { ArrowLeft as st, AlertTriangle as Ae, KeyRound as $e, Search as dn, Copy as hn, Users as pn, Plus as we, Folder as Le, Trash as oe, Shield as Ee, LayoutGrid as lt, CheckCircle as ct } from "@wso2/oxygen-ui-icons-react";
8
+ import "@tanstack/react-query";
9
+ import { c as gn } from "./clipboard-YAzStmkw.js";
10
+ import { o as dt, s as He } from "./schemas-DFScWdSL.js";
11
+ const ge = (r) => {
12
+ const n = me(5), {
13
+ to: o,
14
+ label: a
15
+ } = r;
16
+ let l, c;
17
+ n[0] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ e(st, { size: 16 }), c = {
18
+ mb: 2
19
+ }, n[0] = l, n[1] = c) : (l = n[0], c = n[1]);
20
+ let h;
21
+ return n[2] !== a || n[3] !== o ? (h = /* @__PURE__ */ e(_, { component: Qe, to: o, variant: "text", startIcon: l, sx: c, children: a }), n[2] = a, n[3] = o, n[4] = h) : h = n[4], h;
22
+ }, ht = {
23
+ width: 48,
24
+ height: 48,
25
+ fontSize: 20
26
+ }, pt = {
27
+ flex: 1,
28
+ minWidth: 0
29
+ }, gt = {
30
+ fontFamily: "monospace"
31
+ }, Oe = (r) => {
32
+ const n = me(19), {
33
+ fallback: o,
34
+ name: a,
35
+ subtitle: l,
36
+ id: c,
37
+ badge: h
38
+ } = r;
39
+ let p;
40
+ n[0] !== o || n[1] !== a ? (p = a.charAt(0).toUpperCase() || o, n[0] = o, n[1] = a, n[2] = p) : p = n[2];
41
+ let y;
42
+ n[3] !== p ? (y = /* @__PURE__ */ e(ye, { sx: ht, children: p }), n[3] = p, n[4] = y) : y = n[4];
43
+ let g;
44
+ n[5] !== h || n[6] !== a ? (g = h ? /* @__PURE__ */ i(E, { direction: "row", alignItems: "center", spacing: 1, children: [
45
+ /* @__PURE__ */ e(P, { variant: "h6", noWrap: !0, children: a }),
46
+ h
47
+ ] }) : /* @__PURE__ */ e(P, { variant: "h6", noWrap: !0, children: a }), n[5] = h, n[6] = a, n[7] = g) : g = n[7];
48
+ let u;
49
+ n[8] !== l ? (u = l && /* @__PURE__ */ e(P, { variant: "body2", color: "text.secondary", noWrap: !0, children: l }), n[8] = l, n[9] = u) : u = n[9];
50
+ let I;
51
+ n[10] !== c ? (I = /* @__PURE__ */ e(P, { variant: "caption", color: "text.disabled", sx: gt, children: c }), n[10] = c, n[11] = I) : I = n[11];
52
+ let m;
53
+ n[12] !== g || n[13] !== u || n[14] !== I ? (m = /* @__PURE__ */ i(F, { sx: pt, children: [
54
+ g,
55
+ u,
56
+ I
57
+ ] }), n[12] = g, n[13] = u, n[14] = I, n[15] = m) : m = n[15];
58
+ let b;
59
+ return n[16] !== y || n[17] !== m ? (b = /* @__PURE__ */ e(T.Section, { children: /* @__PURE__ */ i(E, { direction: "row", alignItems: "center", spacing: 2, children: [
60
+ y,
61
+ m
62
+ ] }) }), n[16] = y, n[17] = m, n[18] = b) : b = n[18], b;
63
+ }, Be = (r) => {
64
+ const n = me(9), {
65
+ tabs: o
66
+ } = r, a = o === void 0 ? 2 : o;
67
+ let l;
68
+ n[0] === Symbol.for("react.memo_cache_sentinel") ? (l = {
69
+ borderBottom: 1,
70
+ borderColor: "divider",
71
+ pb: 1.5
72
+ }, n[0] = l) : l = n[0];
73
+ let c;
74
+ n[1] !== a ? (c = /* @__PURE__ */ e(E, { direction: "row", spacing: 3, sx: l, children: Array.from({
75
+ length: a
76
+ }).map(mt) }), n[1] = a, n[2] = c) : c = n[2];
77
+ let h, p, y;
78
+ n[3] === Symbol.for("react.memo_cache_sentinel") ? (h = /* @__PURE__ */ e(z, { variant: "text", width: "30%", height: 28 }), p = /* @__PURE__ */ e(z, { variant: "text", width: "55%" }), y = /* @__PURE__ */ e(z, { variant: "rounded", height: 40 }), n[3] = h, n[4] = p, n[5] = y) : (h = n[3], p = n[4], y = n[5]);
79
+ let g;
80
+ n[6] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ i(E, { spacing: 1, children: [
81
+ /* @__PURE__ */ e(z, { variant: "rounded", height: 56 }),
82
+ /* @__PURE__ */ e(z, { variant: "rounded", height: 56 }),
83
+ /* @__PURE__ */ e(z, { variant: "rounded", height: 56 })
84
+ ] }), n[6] = g) : g = n[6];
85
+ let u;
86
+ return n[7] !== c ? (u = /* @__PURE__ */ i(T.Section, { children: [
87
+ c,
88
+ h,
89
+ p,
90
+ y,
91
+ g
92
+ ] }), n[7] = c, n[8] = u) : u = n[8], u;
93
+ };
94
+ function mt(r, n) {
95
+ return /* @__PURE__ */ e(z, { variant: "text", width: 72 }, n);
96
+ }
97
+ const mn = (r) => {
98
+ const n = me(5), {
99
+ rows: o,
100
+ columns: a
101
+ } = r, l = o === void 0 ? 5 : o, c = a === void 0 ? 2 : a;
102
+ let h;
103
+ n[0] !== l ? (h = Array.from({
104
+ length: l
105
+ }), n[0] = l, n[1] = h) : h = n[1];
106
+ let p;
107
+ return n[2] !== c || n[3] !== h ? (p = /* @__PURE__ */ e(O, { children: h.map((y, g) => /* @__PURE__ */ i(t.Row, { variant: "table", children: [
108
+ /* @__PURE__ */ e(t.Cell, { children: /* @__PURE__ */ i(E, { direction: "row", alignItems: "center", spacing: 2, children: [
109
+ /* @__PURE__ */ e(z, { variant: "circular", width: 28, height: 28 }),
110
+ /* @__PURE__ */ e(z, { variant: "text", width: "40%" })
111
+ ] }) }),
112
+ c > 1 && /* @__PURE__ */ e(t.Cell, { children: /* @__PURE__ */ e(z, { variant: "text", width: "70%" }) }),
113
+ /* @__PURE__ */ e(t.Cell, { align: "center", width: "80px" })
114
+ ] }, g)) }), n[2] = c, n[3] = h, n[4] = p) : p = n[4], p;
115
+ }, un = "ThunderID", Ve = {
116
+ fontFamily: "monospace",
117
+ color: "text.secondary",
118
+ overflow: "hidden",
119
+ textOverflow: "ellipsis",
120
+ whiteSpace: "nowrap",
121
+ display: "block"
122
+ }, ut = (r, n) => [un, r.title, r.instance.envName, r.instance.issuerUrl, r.instance.tokenUrl].join(" ").toLowerCase().includes(n);
123
+ function vt() {
124
+ const r = se(), {
125
+ orgId: n
126
+ } = q(), {
127
+ pushSnackBar: o
128
+ } = Ye(), [a, l] = D(""), {
129
+ data: c,
130
+ isLoading: h,
131
+ error: p
132
+ } = Ze({
133
+ orgName: n
134
+ }), {
135
+ data: y,
136
+ isLoading: g
137
+ } = kn({
138
+ orgName: n
139
+ }), u = h || g, I = p, m = S(() => c?.thunderInstances ?? [], [c]), b = S(() => {
140
+ const A = new Map(m.map((s) => [s.envName, s])), w = [], L = /* @__PURE__ */ new Set();
141
+ for (const s of y ?? []) {
142
+ L.add(s.name);
143
+ const v = A.get(s.name);
144
+ v && w.push({
145
+ title: s.displayName || s.name,
146
+ instance: v
147
+ });
148
+ }
149
+ for (const s of m)
150
+ L.has(s.envName) || w.push({
151
+ title: s.displayName || s.envName,
152
+ instance: s
153
+ });
154
+ const x = a.trim().toLowerCase();
155
+ return x ? w.filter((s) => ut(s, x)) : w;
156
+ }, [y, m, a]), C = (A, w) => {
157
+ A.stopPropagation(), gn(w).then((L) => {
158
+ o(L ? {
159
+ message: "Token endpoint copied to clipboard",
160
+ type: "success"
161
+ } : {
162
+ message: "Failed to copy token endpoint",
163
+ type: "error"
164
+ });
165
+ });
166
+ }, f = (A) => {
167
+ r(B(X.children.org.children.thunderInstances.children.view.path, {
168
+ orgId: n ?? "",
169
+ envName: A.envName
170
+ }));
171
+ }, R = e(et, {
172
+ placeholder: "Search identity providers...",
173
+ size: "small",
174
+ fullWidth: !0,
175
+ value: a,
176
+ onChange: (A) => l(A.target.value),
177
+ disabled: u
178
+ });
179
+ return u ? e(t.Container, {
180
+ disablePaper: !0,
181
+ children: e(E, {
182
+ spacing: 1,
183
+ mt: 1,
184
+ children: Array.from({
185
+ length: 3
186
+ }).map((A, w) => i(E, {
187
+ direction: "row",
188
+ alignItems: "center",
189
+ spacing: 2,
190
+ sx: {
191
+ px: 2,
192
+ py: 1.5,
193
+ borderRadius: 1,
194
+ border: "1px solid",
195
+ borderColor: "divider",
196
+ bgcolor: "background.paper"
197
+ },
198
+ children: [e(z, {
199
+ variant: "circular",
200
+ width: 36,
201
+ height: 36
202
+ }), e(z, {
203
+ variant: "text",
204
+ width: 160,
205
+ height: 20,
206
+ sx: {
207
+ flex: 1
208
+ }
209
+ }), e(z, {
210
+ variant: "rounded",
211
+ width: 96,
212
+ height: 24
213
+ }), e(z, {
214
+ variant: "rounded",
215
+ width: 24,
216
+ height: 24
217
+ })]
218
+ }, w))
219
+ })
220
+ }) : I ? e(M, {
221
+ severity: "error",
222
+ icon: e(Ae, {
223
+ size: 18
224
+ }),
225
+ children: "Failed to load identity providers. Please try again."
226
+ }) : m.length === 0 ? e(t.Container, {
227
+ children: e(t.EmptyState, {
228
+ illustration: e($e, {
229
+ size: 64
230
+ }),
231
+ title: "No identity providers",
232
+ description: "Add an environment first. Each environment automatically gets a Thunder identity provider."
233
+ })
234
+ }) : i(E, {
235
+ spacing: 1,
236
+ children: [R, b.length === 0 ? e(t.Container, {
237
+ children: e(t.EmptyState, {
238
+ illustration: e(dn, {
239
+ size: 64
240
+ }),
241
+ title: "No identity providers found",
242
+ description: "Try a different keyword or clear the search filter."
243
+ })
244
+ }) : e(E, {
245
+ pt: 3,
246
+ children: e(t.Container, {
247
+ disablePaper: !0,
248
+ children: i(t, {
249
+ variant: "card",
250
+ children: [e(t.Head, {
251
+ children: i(t.Row, {
252
+ children: [e(t.Cell, {
253
+ width: "240px",
254
+ children: "Environment"
255
+ }), e(t.Cell, {
256
+ children: "Issuer"
257
+ }), e(t.Cell, {
258
+ children: "Token Endpoint"
259
+ })]
260
+ })
261
+ }), e(t.Body, {
262
+ children: b.map(({
263
+ title: A,
264
+ instance: w
265
+ }) => i(t.Row, {
266
+ variant: "card",
267
+ hover: !0,
268
+ clickable: !0,
269
+ onClick: () => f(w),
270
+ children: [e(t.Cell, {
271
+ children: e(t.CellIcon, {
272
+ icon: e(ye, {
273
+ sx: {
274
+ width: 28,
275
+ height: 28,
276
+ bgcolor: "primary.main",
277
+ color: "primary.contrastText"
278
+ },
279
+ children: e($e, {
280
+ size: 16
281
+ })
282
+ }),
283
+ primary: A,
284
+ secondary: un
285
+ })
286
+ }), e(t.Cell, {
287
+ children: e(P, {
288
+ variant: "caption",
289
+ sx: {
290
+ ...Ve,
291
+ maxWidth: 280
292
+ },
293
+ children: w.issuerUrl
294
+ })
295
+ }), e(t.Cell, {
296
+ children: i(E, {
297
+ direction: "row",
298
+ alignItems: "center",
299
+ spacing: 1,
300
+ children: [e(P, {
301
+ variant: "caption",
302
+ sx: {
303
+ ...Ve,
304
+ maxWidth: 320
305
+ },
306
+ children: w.tokenUrl
307
+ }), e(ee, {
308
+ title: "Copy token endpoint",
309
+ children: e(ae, {
310
+ size: "small",
311
+ onClick: (L) => C(L, w.tokenUrl),
312
+ children: e(hn, {
313
+ size: 14
314
+ })
315
+ })
316
+ })]
317
+ })
318
+ })]
319
+ }, w.envName))
320
+ })]
321
+ })
322
+ })
323
+ })]
324
+ });
325
+ }
326
+ function Ue({
327
+ label: r,
328
+ value: n,
329
+ monospace: o = !1
330
+ }) {
331
+ return e(Ie, {
332
+ variant: "outlined",
333
+ sx: {
334
+ p: 2,
335
+ height: "100%"
336
+ },
337
+ children: i(E, {
338
+ spacing: 0.5,
339
+ children: [e(P, {
340
+ variant: "caption",
341
+ color: "text.secondary",
342
+ sx: {
343
+ fontWeight: 500
344
+ },
345
+ children: r
346
+ }), e(P, {
347
+ variant: "body2",
348
+ sx: {
349
+ fontFamily: o ? "monospace" : void 0,
350
+ wordBreak: "break-all"
351
+ },
352
+ children: n
353
+ })]
354
+ })
355
+ });
356
+ }
357
+ function Ne({
358
+ label: r,
359
+ value: n,
360
+ onCopy: o
361
+ }) {
362
+ return e(Dn, {
363
+ label: r,
364
+ value: n,
365
+ size: "small",
366
+ fullWidth: !0,
367
+ slotProps: {
368
+ input: {
369
+ readOnly: !0,
370
+ sx: {
371
+ fontFamily: "monospace",
372
+ fontSize: "0.8125rem"
373
+ },
374
+ endAdornment: e(nt, {
375
+ position: "end",
376
+ children: e(ee, {
377
+ title: `Copy ${r}`,
378
+ children: e(ae, {
379
+ size: "small",
380
+ "aria-label": `Copy ${r}`,
381
+ onClick: () => o(n, r),
382
+ children: e(hn, {
383
+ size: 14
384
+ })
385
+ })
386
+ })
387
+ })
388
+ }
389
+ }
390
+ });
391
+ }
392
+ function yt({
393
+ instance: r,
394
+ onCopy: n
395
+ }) {
396
+ return i(E, {
397
+ spacing: 3,
398
+ children: [i(E, {
399
+ spacing: 1.5,
400
+ children: [e(P, {
401
+ variant: "subtitle2",
402
+ fontWeight: 600,
403
+ children: "Infrastructure"
404
+ }), i(ue, {
405
+ container: !0,
406
+ spacing: 2,
407
+ children: [e(ue, {
408
+ size: {
409
+ xs: 12,
410
+ sm: 6
411
+ },
412
+ children: e(Ue, {
413
+ label: "Kubernetes Namespace",
414
+ value: r.namespace,
415
+ monospace: !0
416
+ })
417
+ }), e(ue, {
418
+ size: {
419
+ xs: 12,
420
+ sm: 6
421
+ },
422
+ children: e(Ue, {
423
+ label: "Environment",
424
+ value: r.envName,
425
+ monospace: !0
426
+ })
427
+ })]
428
+ })]
429
+ }), i(E, {
430
+ spacing: 1.5,
431
+ children: [e(P, {
432
+ variant: "subtitle2",
433
+ fontWeight: 600,
434
+ children: "OAuth2 Endpoints"
435
+ }), i(E, {
436
+ spacing: 2,
437
+ children: [e(Ne, {
438
+ label: "Token Endpoint",
439
+ value: r.tokenUrl,
440
+ onCopy: n
441
+ }), e(Ne, {
442
+ label: "JWKS Endpoint",
443
+ value: r.jwksUrl,
444
+ onCopy: n
445
+ }), e(Ne, {
446
+ label: "Issuer URL",
447
+ value: r.issuerUrl,
448
+ onCopy: n
449
+ })]
450
+ })]
451
+ })]
452
+ });
453
+ }
454
+ const ft = {
455
+ width: 28,
456
+ height: 28,
457
+ fontSize: 12
458
+ }, bt = {
459
+ fontFamily: "monospace"
460
+ }, Ct = {
461
+ completed: "success",
462
+ in_progress: "info",
463
+ pending: "warning",
464
+ failed: "error"
465
+ }, It = (r, n) => [r.agentName, r.projectName, r.status, r.thunderAgentId ?? ""].join(" ").toLowerCase().includes(n), At = () => {
466
+ const {
467
+ orgId: r,
468
+ envName: n
469
+ } = q(), o = se(), [a, l] = D(""), {
470
+ data: c,
471
+ isLoading: h,
472
+ error: p
473
+ } = De({
474
+ orgName: r,
475
+ envName: n ?? ""
476
+ }), y = S(() => c?.agents ?? [], [c]), g = X.children.org.children.thunderInstances.children.view.children.agents, u = (m) => r && n ? B(g.children.detail.path, {
477
+ orgId: r,
478
+ envName: n,
479
+ projectName: m.projectName,
480
+ agentName: m.agentName
481
+ }) : "#", I = S(() => {
482
+ const m = a.trim().toLowerCase();
483
+ return m ? y.filter((b) => It(b, m)) : y;
484
+ }, [y, a]);
485
+ return p != null ? e(M, {
486
+ severity: "error",
487
+ icon: e(Ae, {
488
+ size: 18
489
+ }),
490
+ children: "Failed to load agents. Please try again."
491
+ }) : e(t.Provider, {
492
+ searchValue: a,
493
+ onSearchChange: l,
494
+ children: i(t.Container, {
495
+ children: [e(t.Toolbar, {
496
+ showSearch: !0,
497
+ searchPlaceholder: "Search agents..."
498
+ }), !h && y.length === 0 ? e(t.EmptyState, {
499
+ illustration: e(pn, {
500
+ size: 64
501
+ }),
502
+ title: "No agents yet",
503
+ description: "Agents provisioned in this environment will appear here."
504
+ }) : !h && I.length === 0 ? e(t.EmptyState, {
505
+ illustration: e(dn, {
506
+ size: 64
507
+ }),
508
+ title: "No agents found",
509
+ description: `No agents match "${a}". Try a different search term.`
510
+ }) : i(t, {
511
+ variant: "table",
512
+ children: [e(t.Head, {
513
+ children: i(t.Row, {
514
+ children: [e(t.Cell, {
515
+ children: "Agent"
516
+ }), e(t.Cell, {
517
+ children: "Project"
518
+ }), e(t.Cell, {
519
+ children: "Status"
520
+ }), e(t.Cell, {
521
+ children: "Thunder Agent ID"
522
+ })]
523
+ })
524
+ }), i(t.Body, {
525
+ children: [h && Array.from({
526
+ length: 5
527
+ }).map((m, b) => i(t.Row, {
528
+ variant: "table",
529
+ children: [e(t.Cell, {
530
+ children: i(E, {
531
+ direction: "row",
532
+ alignItems: "center",
533
+ spacing: 2,
534
+ children: [e(z, {
535
+ variant: "circular",
536
+ width: 28,
537
+ height: 28
538
+ }), e(z, {
539
+ variant: "text",
540
+ width: "40%"
541
+ })]
542
+ })
543
+ }), e(t.Cell, {
544
+ children: e(z, {
545
+ variant: "text",
546
+ width: "60%"
547
+ })
548
+ }), e(t.Cell, {
549
+ children: e(z, {
550
+ variant: "rounded",
551
+ width: 80,
552
+ height: 24
553
+ })
554
+ }), e(t.Cell, {
555
+ children: e(z, {
556
+ variant: "text",
557
+ width: "70%"
558
+ })
559
+ })]
560
+ }, b)), !h && I.map((m) => i(t.Row, {
561
+ variant: "table",
562
+ hover: !0,
563
+ clickable: !0,
564
+ onClick: () => o(u(m)),
565
+ children: [e(t.Cell, {
566
+ children: e(t.CellIcon, {
567
+ icon: e(ye, {
568
+ sx: ft,
569
+ children: m.agentName.charAt(0).toUpperCase() || "A"
570
+ }),
571
+ primary: m.agentName
572
+ })
573
+ }), e(t.Cell, {
574
+ children: m.projectName
575
+ }), e(t.Cell, {
576
+ children: e(pe, {
577
+ label: m.status,
578
+ size: "small",
579
+ color: Ct[m.status] ?? "default",
580
+ variant: "outlined"
581
+ })
582
+ }), e(t.Cell, {
583
+ children: e(P, {
584
+ variant: "caption",
585
+ color: "text.secondary",
586
+ sx: bt,
587
+ children: m.thunderAgentId ?? "-"
588
+ })
589
+ })]
590
+ }, `${m.projectName}/${m.agentName}`))]
591
+ })]
592
+ })]
593
+ })
594
+ });
595
+ };
596
+ function Xe({
597
+ header: r,
598
+ description: n,
599
+ items: o,
600
+ emptyText: a
601
+ }) {
602
+ return i(O, {
603
+ children: [e(T.Header, {
604
+ children: r
605
+ }), e(P, {
606
+ variant: "body2",
607
+ color: "text.secondary",
608
+ children: n
609
+ }), e(F, {
610
+ sx: {
611
+ mt: 1
612
+ },
613
+ children: o.length === 0 ? e(P, {
614
+ variant: "body2",
615
+ color: "text.secondary",
616
+ children: a
617
+ }) : e(E, {
618
+ direction: "row",
619
+ flexWrap: "wrap",
620
+ gap: 1,
621
+ children: o.map((l) => e(pe, {
622
+ label: l.name,
623
+ size: "small"
624
+ }, l.id))
625
+ })
626
+ })]
627
+ });
628
+ }
629
+ const wt = () => {
630
+ const {
631
+ orgId: r,
632
+ envName: n,
633
+ projectName: o,
634
+ agentName: a
635
+ } = q(), [l, c] = D("roles"), {
636
+ data: h,
637
+ isLoading: p,
638
+ error: y
639
+ } = Gn({
640
+ orgName: r,
641
+ projName: o,
642
+ agentName: a
643
+ }, {
644
+ environment: n ?? ""
645
+ }), {
646
+ data: g,
647
+ isLoading: u,
648
+ error: I
649
+ } = zn({
650
+ orgName: r,
651
+ projName: o,
652
+ agentName: a
653
+ }, {
654
+ environment: n ?? ""
655
+ }), {
656
+ data: m,
657
+ isLoading: b
658
+ } = On({
659
+ orgName: r,
660
+ projName: o,
661
+ agentName: a
662
+ }), {
663
+ data: C,
664
+ isLoading: f
665
+ } = Bn({
666
+ orgName: r,
667
+ projName: o
668
+ }), R = S(() => h?.roles ?? [], [h]), A = S(() => g?.groups ?? [], [g]), w = X.children.org.children.thunderInstances.children.view.children.agents, L = r && n ? B(w.path, {
669
+ orgId: r,
670
+ envName: n
671
+ }) : "#";
672
+ return p || u || b || f ? i(O, {
673
+ children: [e(ge, {
674
+ to: L,
675
+ label: "Agents"
676
+ }), e(Be, {
677
+ tabs: 2
678
+ })]
679
+ }) : i(O, {
680
+ children: [e(ge, {
681
+ to: L,
682
+ label: "Agents"
683
+ }), i(E, {
684
+ spacing: 3,
685
+ children: [e(Oe, {
686
+ fallback: "A",
687
+ name: m?.displayName || a || "",
688
+ subtitle: C?.displayName || o,
689
+ id: a ?? ""
690
+ }), (y != null || I != null) && e(M, {
691
+ severity: "error",
692
+ children: "Failed to load this agent's roles/groups. Please try again."
693
+ }), i(T.Section, {
694
+ children: [i(ze, {
695
+ value: l,
696
+ onChange: (s, v) => c(v),
697
+ sx: {
698
+ borderBottom: 1,
699
+ borderColor: "divider"
700
+ },
701
+ children: [e(ce, {
702
+ label: "Roles",
703
+ value: "roles"
704
+ }), e(ce, {
705
+ label: "Groups",
706
+ value: "groups"
707
+ })]
708
+ }), l === "roles" && e(Xe, {
709
+ header: "Assigned Roles",
710
+ description: i(O, {
711
+ children: ["Roles assigned to this agent's identity in ", n, ". To modify role assignments, use the Roles page."]
712
+ }),
713
+ items: R,
714
+ emptyText: "No roles assigned to this agent."
715
+ }), l === "groups" && e(Xe, {
716
+ header: "Group Memberships",
717
+ description: i(O, {
718
+ children: ["Groups this agent's identity belongs to in ", n, ". To modify group memberships, use the Groups page."]
719
+ }),
720
+ items: A,
721
+ emptyText: "This agent is not a member of any groups."
722
+ })]
723
+ })]
724
+ })]
725
+ });
726
+ }, St = {
727
+ width: 28,
728
+ height: 28,
729
+ fontSize: 12
730
+ }, xt = () => {
731
+ const {
732
+ orgId: r,
733
+ envName: n
734
+ } = q(), o = se(), [a, l] = D(0), [c, h] = D(10), [p, y] = D(""), {
735
+ data: g,
736
+ isLoading: u,
737
+ error: I
738
+ } = en({
739
+ orgName: r,
740
+ envName: n ?? ""
741
+ }, {
742
+ offset: a * c,
743
+ limit: c
744
+ }), {
745
+ mutateAsync: m
746
+ } = Fn(), {
747
+ addConfirmation: b
748
+ } = nn(), C = S(() => g?.groups ?? [], [g]), f = g?.total ?? 0;
749
+ Ge(() => {
750
+ if (C.length === 0 && f > 0) {
751
+ const s = Math.max(0, Math.ceil(f / c) - 1);
752
+ a !== s && l(s);
753
+ }
754
+ }, [C.length, f, a, c]);
755
+ const R = X.children.org.children.thunderInstances.children.view.children.groups, A = r && n ? B(R.children.create.path, {
756
+ orgId: r,
757
+ envName: n
758
+ }) : "#", w = (s) => r && n ? B(R.children.detail.path, {
759
+ orgId: r,
760
+ envName: n,
761
+ groupId: s
762
+ }) : "#", L = S(() => {
763
+ if (!p) return C;
764
+ const s = p.toLowerCase();
765
+ return C.filter((v) => v.name.toLowerCase().includes(s) || (v.description ?? "").toLowerCase().includes(s));
766
+ }, [C, p]), x = (s) => {
767
+ b({
768
+ title: "Delete Group",
769
+ description: `Are you sure you want to delete "${s.name}"? This action cannot be undone.`,
770
+ confirmButtonText: "Delete",
771
+ confirmButtonColor: "error",
772
+ confirmButtonIcon: e(oe, {
773
+ size: 16
774
+ }),
775
+ onConfirm: () => m({
776
+ orgName: r,
777
+ envName: n ?? "",
778
+ groupId: s.id
779
+ })
780
+ });
781
+ };
782
+ return i(O, {
783
+ children: [I != null && e(M, {
784
+ severity: "error",
785
+ sx: {
786
+ mb: 2
787
+ },
788
+ children: "Failed to load groups"
789
+ }), e(t.Provider, {
790
+ searchValue: p,
791
+ onSearchChange: y,
792
+ children: i(t.Container, {
793
+ children: [e(t.Toolbar, {
794
+ showSearch: !0,
795
+ searchPlaceholder: "Search groups...",
796
+ actions: e(_, {
797
+ variant: "contained",
798
+ startIcon: e(we, {}),
799
+ onClick: () => o(A),
800
+ children: "Create Group"
801
+ })
802
+ }), !u && f === 0 ? e(t.EmptyState, {
803
+ illustration: e(Le, {
804
+ size: 64
805
+ }),
806
+ title: "No groups yet",
807
+ description: 'Click "Create Group" to add one.'
808
+ }) : !u && L.length === 0 ? e(t.EmptyState, {
809
+ illustration: e(Le, {
810
+ size: 64
811
+ }),
812
+ title: "No groups found",
813
+ description: `No groups match "${p}". Try a different search term.`
814
+ }) : i(t, {
815
+ variant: "table",
816
+ children: [e(t.Head, {
817
+ children: i(t.Row, {
818
+ children: [e(t.Cell, {
819
+ children: "Name"
820
+ }), e(t.Cell, {
821
+ align: "center",
822
+ width: "80px"
823
+ })]
824
+ })
825
+ }), i(t.Body, {
826
+ children: [u && e(mn, {
827
+ rows: Math.ceil(c / 2),
828
+ columns: 1
829
+ }), !u && L.map((s) => i(t.Row, {
830
+ variant: "table",
831
+ hover: !0,
832
+ clickable: !0,
833
+ onClick: () => o(w(s.id)),
834
+ children: [e(t.Cell, {
835
+ children: e(t.CellIcon, {
836
+ icon: e(ye, {
837
+ sx: St,
838
+ children: s.name.charAt(0).toUpperCase() || "G"
839
+ }),
840
+ primary: s.name,
841
+ secondary: s.description ?? void 0
842
+ })
843
+ }), e(t.Cell, {
844
+ align: "center",
845
+ children: e(t.RowActions, {
846
+ visibility: "hover",
847
+ children: e(ee, {
848
+ title: "Delete group",
849
+ children: e(ae, {
850
+ size: "small",
851
+ color: "error",
852
+ onClick: (v) => {
853
+ v.stopPropagation(), x(s);
854
+ },
855
+ children: e(oe, {
856
+ size: 16
857
+ })
858
+ })
859
+ })
860
+ })
861
+ })]
862
+ }, s.id))]
863
+ })]
864
+ }), !u && f >= 5 && e(ln, {
865
+ component: "div",
866
+ count: f,
867
+ page: a,
868
+ rowsPerPage: c,
869
+ onPageChange: (s, v) => l(v),
870
+ onRowsPerPageChange: (s) => {
871
+ h(parseInt(s.target.value, 10)), l(0);
872
+ },
873
+ rowsPerPageOptions: [5, 10, 25, 50]
874
+ })]
875
+ })
876
+ })]
877
+ });
878
+ }, vn = dt({
879
+ name: He().trim().min(1, "Name is required").max(50, "Name must be at most 50 characters"),
880
+ description: He().trim().optional()
881
+ }), Nt = vn, Rt = vn, Pt = () => {
882
+ const {
883
+ orgId: r,
884
+ envName: n
885
+ } = q(), o = se(), [a, l] = D({
886
+ name: "",
887
+ description: ""
888
+ }), {
889
+ errors: c,
890
+ validateField: h,
891
+ validateForm: p,
892
+ clearErrors: y,
893
+ setFieldError: g
894
+ } = tn(Nt), {
895
+ checkDirty: u,
896
+ resetDirty: I
897
+ } = rn(a), [m, b] = D({}), {
898
+ mutateAsync: C,
899
+ isPending: f,
900
+ error: R
901
+ } = Wn(), A = X.children.org.children.thunderInstances.children.view.children.groups, w = r && n ? B(A.path, {
902
+ orgId: r,
903
+ envName: n
904
+ }) : "#", L = Ce((v, $) => {
905
+ const J = {
906
+ ...a,
907
+ [v]: $
908
+ };
909
+ l(J), u(J), g(v, h(v, $));
910
+ }, [a, u, h, g]), x = Ce(async () => {
911
+ if (!p(a)) {
912
+ b(c);
913
+ return;
914
+ }
915
+ b({});
916
+ try {
917
+ const v = await C({
918
+ params: {
919
+ orgName: r,
920
+ envName: n ?? ""
921
+ },
922
+ body: {
923
+ name: a.name.trim(),
924
+ description: a.description?.trim() || void 0
925
+ }
926
+ });
927
+ I(), y(), o(B(A.children.detail.path, {
928
+ orgId: r,
929
+ envName: n,
930
+ groupId: v.id
931
+ }));
932
+ } catch {
933
+ }
934
+ }, [a, p, c, C, r, n, I, y, o, A]), s = Object.values(m);
935
+ return e(O, {
936
+ children: i(F, {
937
+ display: "flex",
938
+ flexDirection: "column",
939
+ gap: 2,
940
+ children: [R != null && e(M, {
941
+ severity: "error",
942
+ children: R?.message ?? "Failed to create group"
943
+ }), e(T.Stack, {
944
+ spacing: 3,
945
+ children: i(T.Section, {
946
+ children: [e(T.Subheader, {
947
+ children: "Group Details"
948
+ }), i(T.Stack, {
949
+ spacing: 2,
950
+ children: [e(T.ElementWrapper, {
951
+ label: "Name",
952
+ name: "name",
953
+ children: e(Z, {
954
+ id: "name",
955
+ value: a.name,
956
+ onChange: (v) => L("name", v.target.value),
957
+ placeholder: "on-call-agents",
958
+ autoComplete: "off",
959
+ error: !!c.name,
960
+ helperText: c.name,
961
+ fullWidth: !0
962
+ })
963
+ }), e(T.ElementWrapper, {
964
+ label: "Description (optional)",
965
+ name: "description",
966
+ children: e(Z, {
967
+ id: "description",
968
+ value: a.description,
969
+ onChange: (v) => L("description", v.target.value),
970
+ placeholder: "Describe the group's purpose",
971
+ multiline: !0,
972
+ minRows: 2,
973
+ maxRows: 6,
974
+ error: !!c.description,
975
+ helperText: c.description,
976
+ fullWidth: !0
977
+ })
978
+ })]
979
+ })]
980
+ })
981
+ }), i(F, {
982
+ display: "flex",
983
+ flexDirection: "column",
984
+ gap: 3,
985
+ children: [e(cn, {
986
+ in: s.length > 0,
987
+ timeout: "auto",
988
+ unmountOnExit: !0,
989
+ children: e(M, {
990
+ severity: "error",
991
+ children: s.map((v, $) => e(F, {
992
+ children: v
993
+ }, $))
994
+ })
995
+ }), i(F, {
996
+ display: "flex",
997
+ flexDirection: "row",
998
+ gap: 1,
999
+ alignItems: "center",
1000
+ children: [e(_, {
1001
+ variant: "outlined",
1002
+ color: "primary",
1003
+ onClick: () => o(w),
1004
+ children: "Cancel"
1005
+ }), e(_, {
1006
+ variant: "contained",
1007
+ color: "primary",
1008
+ startIcon: e(we, {
1009
+ size: 16
1010
+ }),
1011
+ onClick: x,
1012
+ disabled: f || !a.name.trim(),
1013
+ children: "Create Group"
1014
+ })]
1015
+ })]
1016
+ })]
1017
+ })
1018
+ });
1019
+ };
1020
+ function yn(r) {
1021
+ const n = S(() => r.filter((l) => !!l.thunderAgentId), [r]), o = S(() => new Map(n.map((l) => [l.thunderAgentId, l])), [n]);
1022
+ return {
1023
+ agents: n,
1024
+ agentsByThunderId: o,
1025
+ displayName: (l) => o.get(l)?.agentName ?? l
1026
+ };
1027
+ }
1028
+ function ke(r, n) {
1029
+ const [o, a] = D([]), [l, c] = D(/* @__PURE__ */ new Set()), h = S(() => r.filter((b) => !l.has(b)), [r, l]), p = S(() => o.map(n), [o, n]), y = S(() => /* @__PURE__ */ new Set([...h, ...p]), [h, p]), g = (b, C) => {
1030
+ if (!C) return;
1031
+ const f = n(C);
1032
+ l.has(f) ? c((R) => {
1033
+ const A = new Set(R);
1034
+ return A.delete(f), A;
1035
+ }) : a((R) => [...R, C]);
1036
+ }, u = (b) => {
1037
+ o.some((C) => n(C) === b) ? a((C) => C.filter((f) => n(f) !== b)) : c((C) => /* @__PURE__ */ new Set([...C, b]));
1038
+ }, I = () => {
1039
+ a([]), c(/* @__PURE__ */ new Set());
1040
+ }, m = o.length > 0 || l.size > 0;
1041
+ return {
1042
+ pendingAdds: o,
1043
+ removedIds: l,
1044
+ activeIds: h,
1045
+ pendingAddIds: p,
1046
+ excludedIds: y,
1047
+ handleAdd: g,
1048
+ handleRemove: u,
1049
+ reset: I,
1050
+ isDirty: m
1051
+ };
1052
+ }
1053
+ const Re = 100, Tt = () => {
1054
+ const {
1055
+ orgId: r,
1056
+ envName: n,
1057
+ groupId: o
1058
+ } = q(), a = se(), [l, c] = D("agents"), h = {
1059
+ orgName: r,
1060
+ envName: n ?? "",
1061
+ groupId: o ?? ""
1062
+ }, {
1063
+ data: p,
1064
+ isLoading: y
1065
+ } = Mn(h), {
1066
+ data: g,
1067
+ isLoading: u
1068
+ } = jn(h, {
1069
+ offset: 0,
1070
+ limit: Re
1071
+ }), {
1072
+ data: I,
1073
+ isLoading: m,
1074
+ isError: b
1075
+ } = $n(h), {
1076
+ data: C,
1077
+ isLoading: f
1078
+ } = De({
1079
+ orgName: r,
1080
+ envName: n ?? ""
1081
+ }), {
1082
+ mutateAsync: R
1083
+ } = Hn(), {
1084
+ mutateAsync: A
1085
+ } = Vn(), {
1086
+ agents: w,
1087
+ displayName: L
1088
+ } = yn(C?.agents ?? []), x = S(() => (g?.members ?? []).map((N) => N.id), [g]), s = S(() => I?.roles ?? [], [I]), v = ke(x, (N) => N.thunderAgentId), {
1089
+ pendingAdds: $,
1090
+ removedIds: J
1091
+ } = v, [Y, k] = D(!1), [W, Q] = D(), [de, ne] = D(!1), Se = X.children.org.children.thunderInstances.children.view.children.groups, te = r && n ? B(Se.path, {
1092
+ orgId: r,
1093
+ envName: n
1094
+ }) : "#", re = v.activeIds, H = S(() => w.filter((N) => !v.excludedIds.has(N.thunderAgentId)), [w, v.excludedIds]), xe = v.handleAdd, j = v.handleRemove, K = async () => {
1095
+ if (!(!r || !n || !o)) {
1096
+ Q(void 0), ne(!1), k(!0);
1097
+ try {
1098
+ const N = $.map((he) => he.thunderAgentId).filter((he) => !x.includes(he)), ie = [...J];
1099
+ await Promise.all([N.length > 0 ? R({
1100
+ params: h,
1101
+ body: {
1102
+ agentIds: N
1103
+ }
1104
+ }) : null, ie.length > 0 ? A({
1105
+ params: h,
1106
+ body: {
1107
+ agentIds: ie
1108
+ }
1109
+ }) : null]), ne(!0), v.reset();
1110
+ } catch {
1111
+ Q("Failed to update group members. Please try again.");
1112
+ } finally {
1113
+ k(!1);
1114
+ }
1115
+ }
1116
+ };
1117
+ if (y || u || f)
1118
+ return i(O, {
1119
+ children: [e(ge, {
1120
+ to: te,
1121
+ label: "Groups"
1122
+ }), e(Be, {
1123
+ tabs: 2
1124
+ })]
1125
+ });
1126
+ const le = v.isDirty;
1127
+ return i(O, {
1128
+ children: [e(ge, {
1129
+ to: te,
1130
+ label: "Groups"
1131
+ }), i(E, {
1132
+ spacing: 3,
1133
+ children: [e(Oe, {
1134
+ fallback: "G",
1135
+ name: p?.name ?? "",
1136
+ subtitle: p?.description,
1137
+ id: o ?? ""
1138
+ }), W != null && e(M, {
1139
+ severity: "error",
1140
+ children: W
1141
+ }), de && e(M, {
1142
+ severity: "success",
1143
+ children: "Group updated successfully."
1144
+ }), i(T.Section, {
1145
+ children: [i(ze, {
1146
+ value: l,
1147
+ onChange: (N, ie) => c(ie),
1148
+ sx: {
1149
+ borderBottom: 1,
1150
+ borderColor: "divider"
1151
+ },
1152
+ children: [e(ce, {
1153
+ label: "Agents",
1154
+ value: "agents"
1155
+ }), e(ce, {
1156
+ label: "Roles",
1157
+ value: "roles"
1158
+ })]
1159
+ }), l === "agents" && i(O, {
1160
+ children: [e(T.Header, {
1161
+ children: "Agents"
1162
+ }), e(P, {
1163
+ variant: "body2",
1164
+ color: "text.secondary",
1165
+ children: "Search and add agents to this group."
1166
+ }), (g?.total ?? 0) > Re && i(M, {
1167
+ severity: "warning",
1168
+ sx: {
1169
+ mt: 1
1170
+ },
1171
+ children: ["Showing the first ", Re, " of ", g?.total, " members. The add-agent picker below only excludes agents from this page."]
1172
+ }), e(F, {
1173
+ sx: {
1174
+ mt: 1
1175
+ },
1176
+ children: e(T.ElementWrapper, {
1177
+ label: "Add Agent",
1178
+ name: "addAgent",
1179
+ children: e(ve, {
1180
+ id: "addAgent",
1181
+ options: H,
1182
+ getOptionLabel: (N) => N.agentName,
1183
+ onChange: xe,
1184
+ value: null,
1185
+ renderInput: (N) => e(Z, {
1186
+ ...N,
1187
+ placeholder: "Search agents..."
1188
+ }),
1189
+ noOptionsText: "No agents available"
1190
+ })
1191
+ })
1192
+ }), $.length > 0 && i(F, {
1193
+ mb: 2,
1194
+ children: [e(P, {
1195
+ variant: "body2",
1196
+ fontWeight: 500,
1197
+ mb: 1,
1198
+ children: "Pending additions (unsaved)"
1199
+ }), e(t.Container, {
1200
+ children: i(t, {
1201
+ children: [e(t.Head, {
1202
+ children: i(t.Row, {
1203
+ children: [e(t.Cell, {
1204
+ children: "Agent"
1205
+ }), e(t.Cell, {
1206
+ children: "Project"
1207
+ }), e(t.Cell, {})]
1208
+ })
1209
+ }), e(t.Body, {
1210
+ children: $.map((N) => i(t.Row, {
1211
+ children: [e(t.Cell, {
1212
+ children: N.agentName
1213
+ }), e(t.Cell, {
1214
+ children: N.projectName
1215
+ }), e(t.Cell, {
1216
+ align: "right",
1217
+ children: e(ee, {
1218
+ title: "Remove from group",
1219
+ children: e(ae, {
1220
+ size: "small",
1221
+ onClick: () => j(N.thunderAgentId),
1222
+ children: e(oe, {
1223
+ size: 16
1224
+ })
1225
+ })
1226
+ })
1227
+ })]
1228
+ }, N.thunderAgentId))
1229
+ })]
1230
+ })
1231
+ })]
1232
+ }), re.length === 0 && $.length === 0 ? e(P, {
1233
+ variant: "body2",
1234
+ color: "text.secondary",
1235
+ children: "No members yet. Search and add agents above."
1236
+ }) : re.length > 0 ? e(t.Container, {
1237
+ children: i(t, {
1238
+ children: [e(t.Head, {
1239
+ children: i(t.Row, {
1240
+ children: [e(t.Cell, {
1241
+ children: "Agent"
1242
+ }), e(t.Cell, {
1243
+ children: "Thunder Agent ID"
1244
+ }), e(t.Cell, {})]
1245
+ })
1246
+ }), e(t.Body, {
1247
+ children: re.map((N) => i(t.Row, {
1248
+ children: [e(t.Cell, {
1249
+ children: L(N)
1250
+ }), e(t.Cell, {
1251
+ children: N
1252
+ }), e(t.Cell, {
1253
+ align: "right",
1254
+ children: e(ee, {
1255
+ title: "Remove from group",
1256
+ children: e(ae, {
1257
+ size: "small",
1258
+ onClick: () => j(N),
1259
+ children: e(oe, {
1260
+ size: 16
1261
+ })
1262
+ })
1263
+ })
1264
+ })]
1265
+ }, N))
1266
+ })]
1267
+ })
1268
+ }) : null]
1269
+ }), l === "roles" && i(O, {
1270
+ children: [e(T.Header, {
1271
+ children: "Assigned Roles"
1272
+ }), e(P, {
1273
+ variant: "body2",
1274
+ color: "text.secondary",
1275
+ children: "Roles currently assigned to this group. Manage role assignments from the Roles page."
1276
+ }), e(F, {
1277
+ sx: {
1278
+ mt: 1
1279
+ },
1280
+ children: m ? e(Te, {
1281
+ size: 20
1282
+ }) : b ? e(P, {
1283
+ variant: "body2",
1284
+ color: "error",
1285
+ children: "Failed to load roles. Please try again."
1286
+ }) : s.length === 0 ? e(P, {
1287
+ variant: "body2",
1288
+ color: "text.secondary",
1289
+ children: "No roles assigned to this group."
1290
+ }) : e(t.Container, {
1291
+ children: i(t, {
1292
+ children: [e(t.Head, {
1293
+ children: i(t.Row, {
1294
+ children: [e(t.Cell, {
1295
+ children: "Name"
1296
+ }), e(t.Cell, {
1297
+ children: "Description"
1298
+ })]
1299
+ })
1300
+ }), e(t.Body, {
1301
+ children: s.map((N) => i(t.Row, {
1302
+ children: [e(t.Cell, {
1303
+ children: N.name
1304
+ }), e(t.Cell, {
1305
+ children: N.description ?? "-"
1306
+ })]
1307
+ }, N.id))
1308
+ })]
1309
+ })
1310
+ })
1311
+ })]
1312
+ })]
1313
+ }), le && i(E, {
1314
+ direction: "row",
1315
+ spacing: 1,
1316
+ children: [e(_, {
1317
+ variant: "outlined",
1318
+ onClick: () => a(te),
1319
+ disabled: Y,
1320
+ children: "Cancel"
1321
+ }), e(_, {
1322
+ variant: "contained",
1323
+ onClick: K,
1324
+ disabled: Y,
1325
+ children: Y ? "Saving..." : "Save Changes"
1326
+ })]
1327
+ })]
1328
+ })]
1329
+ });
1330
+ }, Lt = {
1331
+ width: 28,
1332
+ height: 28,
1333
+ fontSize: 12
1334
+ }, Et = () => {
1335
+ const {
1336
+ orgId: r,
1337
+ envName: n
1338
+ } = q(), o = se(), [a, l] = D(0), [c, h] = D(10), [p, y] = D(""), {
1339
+ data: g,
1340
+ isLoading: u,
1341
+ error: I
1342
+ } = Un({
1343
+ orgName: r,
1344
+ envName: n ?? ""
1345
+ }, {
1346
+ offset: a * c,
1347
+ limit: c
1348
+ }), {
1349
+ mutateAsync: m
1350
+ } = Xn(), {
1351
+ addConfirmation: b
1352
+ } = nn(), C = S(() => g?.roles ?? [], [g]), f = g?.total ?? 0;
1353
+ Ge(() => {
1354
+ if (C.length === 0 && f > 0) {
1355
+ const s = Math.max(0, Math.ceil(f / c) - 1);
1356
+ a !== s && l(s);
1357
+ }
1358
+ }, [C.length, f, a, c]);
1359
+ const R = X.children.org.children.thunderInstances.children.view.children.roles, A = r && n ? B(R.children.create.path, {
1360
+ orgId: r,
1361
+ envName: n
1362
+ }) : "#", w = (s) => r && n ? B(R.children.detail.path, {
1363
+ orgId: r,
1364
+ envName: n,
1365
+ roleId: s
1366
+ }) : "#", L = S(() => {
1367
+ if (!p) return C;
1368
+ const s = p.toLowerCase();
1369
+ return C.filter((v) => v.name.toLowerCase().includes(s) || (v.description ?? "").toLowerCase().includes(s));
1370
+ }, [C, p]), x = (s) => {
1371
+ b({
1372
+ title: "Delete Role",
1373
+ description: `Are you sure you want to delete "${s.name}"? This action cannot be undone.`,
1374
+ confirmButtonText: "Delete",
1375
+ confirmButtonColor: "error",
1376
+ confirmButtonIcon: e(oe, {
1377
+ size: 16
1378
+ }),
1379
+ onConfirm: () => m({
1380
+ orgName: r,
1381
+ envName: n ?? "",
1382
+ roleId: s.id
1383
+ })
1384
+ });
1385
+ };
1386
+ return i(O, {
1387
+ children: [I != null && e(M, {
1388
+ severity: "error",
1389
+ sx: {
1390
+ mb: 2
1391
+ },
1392
+ children: "Failed to load roles"
1393
+ }), e(t.Provider, {
1394
+ searchValue: p,
1395
+ onSearchChange: y,
1396
+ children: i(t.Container, {
1397
+ children: [e(t.Toolbar, {
1398
+ showSearch: !0,
1399
+ searchPlaceholder: "Search roles...",
1400
+ actions: e(_, {
1401
+ variant: "contained",
1402
+ startIcon: e(we, {}),
1403
+ onClick: () => o(A),
1404
+ children: "Create Role"
1405
+ })
1406
+ }), !u && f === 0 ? e(t.EmptyState, {
1407
+ illustration: e(Ee, {
1408
+ size: 64
1409
+ }),
1410
+ title: "No roles yet",
1411
+ description: 'Click "Create Role" to add one.'
1412
+ }) : !u && L.length === 0 ? e(t.EmptyState, {
1413
+ illustration: e(Ee, {
1414
+ size: 64
1415
+ }),
1416
+ title: "No roles found",
1417
+ description: `No roles match "${p}". Try a different search term.`
1418
+ }) : i(t, {
1419
+ variant: "table",
1420
+ children: [e(t.Head, {
1421
+ children: i(t.Row, {
1422
+ children: [e(t.Cell, {
1423
+ children: "Name"
1424
+ }), e(t.Cell, {
1425
+ align: "center",
1426
+ width: "80px"
1427
+ })]
1428
+ })
1429
+ }), i(t.Body, {
1430
+ children: [u && e(mn, {
1431
+ rows: Math.ceil(c / 2),
1432
+ columns: 1
1433
+ }), !u && L.map((s) => i(t.Row, {
1434
+ variant: "table",
1435
+ hover: !0,
1436
+ clickable: !0,
1437
+ onClick: () => o(w(s.id)),
1438
+ children: [e(t.Cell, {
1439
+ children: e(t.CellIcon, {
1440
+ icon: e(ye, {
1441
+ sx: Lt,
1442
+ children: s.name.charAt(0).toUpperCase() || "R"
1443
+ }),
1444
+ primary: s.name,
1445
+ secondary: s.description ?? void 0
1446
+ })
1447
+ }), e(t.Cell, {
1448
+ align: "center",
1449
+ children: e(t.RowActions, {
1450
+ visibility: "hover",
1451
+ children: !s.isReadOnly && e(ee, {
1452
+ title: "Delete role",
1453
+ children: e(ae, {
1454
+ size: "small",
1455
+ color: "error",
1456
+ onClick: (v) => {
1457
+ v.stopPropagation(), x(s);
1458
+ },
1459
+ children: e(oe, {
1460
+ size: 16
1461
+ })
1462
+ })
1463
+ })
1464
+ })
1465
+ })]
1466
+ }, s.id))]
1467
+ })]
1468
+ }), !u && f >= 5 && e(ln, {
1469
+ component: "div",
1470
+ count: f,
1471
+ page: a,
1472
+ rowsPerPage: c,
1473
+ onPageChange: (s, v) => l(v),
1474
+ onRowsPerPageChange: (s) => {
1475
+ h(parseInt(s.target.value, 10)), l(0);
1476
+ },
1477
+ rowsPerPageOptions: [5, 10, 25, 50]
1478
+ })]
1479
+ })
1480
+ })]
1481
+ });
1482
+ }, kt = () => {
1483
+ const {
1484
+ orgId: r,
1485
+ envName: n
1486
+ } = q(), o = se(), [a, l] = D({
1487
+ name: "",
1488
+ description: ""
1489
+ }), [c, h] = D([]), {
1490
+ data: p
1491
+ } = an({
1492
+ orgName: r,
1493
+ envName: n ?? ""
1494
+ }), y = p?.scopes ?? [], {
1495
+ errors: g,
1496
+ validateField: u,
1497
+ validateForm: I,
1498
+ clearErrors: m,
1499
+ setFieldError: b
1500
+ } = tn(Rt), {
1501
+ checkDirty: C,
1502
+ resetDirty: f
1503
+ } = rn(a), [R, A] = D({}), {
1504
+ mutateAsync: w,
1505
+ isPending: L,
1506
+ error: x
1507
+ } = _n(), s = X.children.org.children.thunderInstances.children.view.children.roles, v = r && n ? B(s.path, {
1508
+ orgId: r,
1509
+ envName: n
1510
+ }) : "#", $ = Ce((k, W) => {
1511
+ const Q = {
1512
+ ...a,
1513
+ [k]: W
1514
+ };
1515
+ l(Q), C(Q), b(k, u(k, W));
1516
+ }, [a, C, u, b]), J = Ce(async () => {
1517
+ if (!I(a)) {
1518
+ A(g);
1519
+ return;
1520
+ }
1521
+ A({});
1522
+ try {
1523
+ const k = await w({
1524
+ params: {
1525
+ orgName: r,
1526
+ envName: n ?? ""
1527
+ },
1528
+ body: {
1529
+ name: a.name.trim(),
1530
+ description: a.description?.trim() || void 0,
1531
+ scopes: c.map((W) => W.scope)
1532
+ }
1533
+ });
1534
+ f(), m(), o(B(s.children.detail.path, {
1535
+ orgId: r,
1536
+ envName: n,
1537
+ roleId: k.id
1538
+ }));
1539
+ } catch {
1540
+ }
1541
+ }, [a, I, g, w, r, n, c, f, m, o, s]), Y = Object.values(R);
1542
+ return e(O, {
1543
+ children: i(F, {
1544
+ display: "flex",
1545
+ flexDirection: "column",
1546
+ gap: 2,
1547
+ children: [x != null && e(M, {
1548
+ severity: "error",
1549
+ children: x?.message ?? "Failed to create role"
1550
+ }), e(T.Stack, {
1551
+ spacing: 3,
1552
+ children: i(T.Section, {
1553
+ children: [e(T.Subheader, {
1554
+ children: "Role Details"
1555
+ }), i(T.Stack, {
1556
+ spacing: 2,
1557
+ children: [e(T.ElementWrapper, {
1558
+ label: "Name",
1559
+ name: "name",
1560
+ children: e(Z, {
1561
+ id: "name",
1562
+ value: a.name,
1563
+ onChange: (k) => $("name", k.target.value),
1564
+ placeholder: "agent-admin",
1565
+ autoComplete: "off",
1566
+ error: !!g.name,
1567
+ helperText: g.name,
1568
+ fullWidth: !0
1569
+ })
1570
+ }), e(T.ElementWrapper, {
1571
+ label: "Description (optional)",
1572
+ name: "description",
1573
+ children: e(Z, {
1574
+ id: "description",
1575
+ value: a.description,
1576
+ onChange: (k) => $("description", k.target.value),
1577
+ placeholder: "Describe the role's purpose and permissions",
1578
+ multiline: !0,
1579
+ minRows: 2,
1580
+ maxRows: 6,
1581
+ error: !!g.description,
1582
+ helperText: g.description,
1583
+ fullWidth: !0
1584
+ })
1585
+ }), e(T.ElementWrapper, {
1586
+ label: "Scopes (optional)",
1587
+ name: "scopes",
1588
+ children: e(ve, {
1589
+ id: "scopes",
1590
+ multiple: !0,
1591
+ disableCloseOnSelect: !0,
1592
+ options: y,
1593
+ value: c,
1594
+ onChange: (k, W) => h(W),
1595
+ getOptionLabel: (k) => k.scope,
1596
+ isOptionEqualToValue: (k, W) => k.scope === W.scope,
1597
+ renderTags: (k, W) => k.map((Q, de) => sn(pe, {
1598
+ ...W({
1599
+ index: de
1600
+ }),
1601
+ key: Q.scope,
1602
+ label: Q.scope,
1603
+ size: "small"
1604
+ })),
1605
+ renderInput: (k) => e(Z, {
1606
+ ...k,
1607
+ placeholder: "Search scopes..."
1608
+ }),
1609
+ noOptionsText: "No scopes in the catalog"
1610
+ })
1611
+ })]
1612
+ })]
1613
+ })
1614
+ }), i(F, {
1615
+ display: "flex",
1616
+ flexDirection: "column",
1617
+ gap: 3,
1618
+ children: [e(cn, {
1619
+ in: Y.length > 0,
1620
+ timeout: "auto",
1621
+ unmountOnExit: !0,
1622
+ children: e(M, {
1623
+ severity: "error",
1624
+ children: Y.map((k, W) => e(F, {
1625
+ children: k
1626
+ }, W))
1627
+ })
1628
+ }), i(F, {
1629
+ display: "flex",
1630
+ flexDirection: "row",
1631
+ gap: 1,
1632
+ alignItems: "center",
1633
+ children: [e(_, {
1634
+ variant: "outlined",
1635
+ color: "primary",
1636
+ onClick: () => o(v),
1637
+ children: "Cancel"
1638
+ }), e(_, {
1639
+ variant: "contained",
1640
+ color: "primary",
1641
+ startIcon: e(we, {
1642
+ size: 16
1643
+ }),
1644
+ onClick: J,
1645
+ disabled: L || !a.name.trim(),
1646
+ children: "Create Role"
1647
+ })]
1648
+ })]
1649
+ })]
1650
+ })
1651
+ });
1652
+ }, Pe = 100, Dt = () => {
1653
+ const {
1654
+ orgId: r,
1655
+ envName: n,
1656
+ roleId: o
1657
+ } = q(), a = se(), [l, c] = D("permissions"), [h, p] = D(!1), [y, g] = D(), [u, I] = D(!1), m = {
1658
+ orgName: r,
1659
+ envName: n ?? "",
1660
+ roleId: o ?? ""
1661
+ }, {
1662
+ data: b,
1663
+ isLoading: C
1664
+ } = qn(m), f = b?.isReadOnly ?? !1, {
1665
+ data: R,
1666
+ isLoading: A
1667
+ } = Qn(m), {
1668
+ data: w,
1669
+ isLoading: L
1670
+ } = De({
1671
+ orgName: r,
1672
+ envName: n ?? ""
1673
+ }), {
1674
+ data: x,
1675
+ isLoading: s
1676
+ } = en({
1677
+ orgName: r,
1678
+ envName: n ?? ""
1679
+ }, {
1680
+ offset: 0,
1681
+ limit: Pe
1682
+ }), {
1683
+ data: v,
1684
+ isLoading: $
1685
+ } = an({
1686
+ orgName: r,
1687
+ envName: n ?? ""
1688
+ }), {
1689
+ mutateAsync: J
1690
+ } = Kn(), {
1691
+ mutateAsync: Y
1692
+ } = Jn(), {
1693
+ mutateAsync: k
1694
+ } = Yn(), {
1695
+ agents: W,
1696
+ displayName: Q
1697
+ } = yn(w?.agents ?? []), de = S(() => x?.groups ?? [], [x]), ne = S(() => v?.scopes ?? [], [v]), Se = S(() => (R?.agents ?? []).map((d) => d.id), [R]), te = S(() => R?.groups ?? [], [R]), re = S(() => b?.permissions?.flatMap((d) => d.permissions) ?? [], [b]), H = ke(Se, (d) => d.thunderAgentId), xe = S(() => te.map((d) => d.id), [te]), j = ke(xe, (d) => d.id), [K, fe] = D([]), le = Zn(!1);
1698
+ Ge(() => {
1699
+ if (!le.current && ne.length > 0) {
1700
+ const d = new Map(ne.map((G) => [G.scope, G]));
1701
+ fe(re.map((G) => d.get(G) ?? {
1702
+ scope: G
1703
+ }));
1704
+ }
1705
+ }, [re, ne]);
1706
+ const N = X.children.org.children.thunderInstances.children.view.children.roles, ie = r && n ? B(N.path, {
1707
+ orgId: r,
1708
+ envName: n
1709
+ }) : "#", he = S(() => [...H.activeIds, ...H.pendingAddIds], [H.activeIds, H.pendingAddIds]), Fe = S(() => [...te.filter((d) => !j.removedIds.has(d.id)), ...j.pendingAdds], [te, j.removedIds, j.pendingAdds]), fn = S(() => W.filter((d) => !H.excludedIds.has(d.thunderAgentId)), [W, H.excludedIds]), bn = S(() => de.filter((d) => !j.excludedIds.has(d.id)), [de, j.excludedIds]), Cn = S(() => new Set(K.map((d) => d.scope)), [K]), In = H.handleAdd, An = H.handleRemove, wn = j.handleAdd, Sn = j.handleRemove, xn = (d, G) => {
1710
+ le.current = !0, fe(G);
1711
+ }, Nn = (d) => {
1712
+ le.current = !0, fe((G) => G.filter((be) => be.scope !== d));
1713
+ }, Rn = async () => {
1714
+ if (!(!r || !n || !o)) {
1715
+ g(void 0), I(!1), p(!0);
1716
+ try {
1717
+ const d = H.pendingAdds.map((V) => V.thunderAgentId), G = [...H.removedIds], be = j.pendingAdds.map((V) => V.id), We = [...j.removedIds];
1718
+ await Promise.all([
1719
+ d.length > 0 ? J({
1720
+ params: m,
1721
+ body: {
1722
+ assignments: d.map((V) => ({
1723
+ id: V,
1724
+ type: "agent"
1725
+ }))
1726
+ }
1727
+ }) : null,
1728
+ G.length > 0 ? Y({
1729
+ params: m,
1730
+ body: {
1731
+ assignments: G.map((V) => ({
1732
+ id: V,
1733
+ type: "agent"
1734
+ }))
1735
+ }
1736
+ }) : null,
1737
+ be.length > 0 ? J({
1738
+ params: m,
1739
+ body: {
1740
+ assignments: be.map((V) => ({
1741
+ id: V,
1742
+ type: "group"
1743
+ }))
1744
+ }
1745
+ }) : null,
1746
+ We.length > 0 ? Y({
1747
+ params: m,
1748
+ body: {
1749
+ assignments: We.map((V) => ({
1750
+ id: V,
1751
+ type: "group"
1752
+ }))
1753
+ }
1754
+ }) : null,
1755
+ // The backend reconciles add/remove scope permissions server-side from
1756
+ // the full desired set, so a single update call is enough here.
1757
+ le.current && !f && b ? k({
1758
+ params: m,
1759
+ body: {
1760
+ name: b.name,
1761
+ description: b.description,
1762
+ scopes: K.map((V) => V.scope)
1763
+ }
1764
+ }) : null
1765
+ ]), I(!0), H.reset(), j.reset(), le.current = !1;
1766
+ } catch {
1767
+ g("Failed to update role. Please try again.");
1768
+ } finally {
1769
+ p(!1);
1770
+ }
1771
+ }
1772
+ }, Pn = C || A || $, Tn = S(() => {
1773
+ if (f) return !1;
1774
+ const d = new Set(re);
1775
+ return d.size !== K.length || K.some((G) => !d.has(G.scope));
1776
+ }, [f, re, K]) || H.isDirty || j.isDirty;
1777
+ return Pn ? i(O, {
1778
+ children: [e(ge, {
1779
+ to: ie,
1780
+ label: "Roles"
1781
+ }), e(Be, {
1782
+ tabs: 3
1783
+ })]
1784
+ }) : i(O, {
1785
+ children: [e(ge, {
1786
+ to: ie,
1787
+ label: "Roles"
1788
+ }), i(E, {
1789
+ spacing: 3,
1790
+ children: [e(Oe, {
1791
+ fallback: "R",
1792
+ name: b?.name ?? "",
1793
+ subtitle: b?.description,
1794
+ id: o ?? "",
1795
+ badge: f ? e(pe, {
1796
+ label: "Read-only",
1797
+ size: "small"
1798
+ }) : void 0
1799
+ }), y != null && e(M, {
1800
+ severity: "error",
1801
+ children: y
1802
+ }), u && e(M, {
1803
+ severity: "success",
1804
+ children: "Role updated successfully."
1805
+ }), i(T.Section, {
1806
+ children: [i(ze, {
1807
+ value: l,
1808
+ onChange: (d, G) => c(G),
1809
+ sx: {
1810
+ borderBottom: 1,
1811
+ borderColor: "divider"
1812
+ },
1813
+ children: [e(ce, {
1814
+ label: "Permissions",
1815
+ value: "permissions"
1816
+ }), e(ce, {
1817
+ label: "Agents",
1818
+ value: "agents"
1819
+ }), e(ce, {
1820
+ label: "Groups",
1821
+ value: "groups"
1822
+ })]
1823
+ }), l === "permissions" && i(O, {
1824
+ children: [e(T.Header, {
1825
+ children: "Permissions"
1826
+ }), e(P, {
1827
+ variant: "body2",
1828
+ color: "text.secondary",
1829
+ children: f ? "Permissions for predefined roles cannot be modified." : "Search and select scopes to assign to this role."
1830
+ }), i(F, {
1831
+ sx: {
1832
+ mt: 1
1833
+ },
1834
+ children: [!f && e(T.ElementWrapper, {
1835
+ label: "Add scopes",
1836
+ name: "addScopes",
1837
+ children: e(ve, {
1838
+ id: "addScopes",
1839
+ multiple: !0,
1840
+ disableCloseOnSelect: !0,
1841
+ options: ne,
1842
+ value: K,
1843
+ onChange: xn,
1844
+ getOptionLabel: (d) => d.scope,
1845
+ isOptionEqualToValue: (d, G) => d.scope === G.scope,
1846
+ renderTags: () => null,
1847
+ renderOption: (d, G) => sn("li", {
1848
+ ...d,
1849
+ key: G.scope
1850
+ }, i(F, {
1851
+ children: [e(P, {
1852
+ variant: "body2",
1853
+ children: G.scope
1854
+ }), G.description && e(P, {
1855
+ variant: "caption",
1856
+ color: "text.secondary",
1857
+ children: G.description
1858
+ })]
1859
+ })),
1860
+ renderInput: (d) => e(Z, {
1861
+ ...d,
1862
+ placeholder: "Search scopes..."
1863
+ }),
1864
+ noOptionsText: "No scopes in the catalog",
1865
+ sx: {
1866
+ mb: 3
1867
+ }
1868
+ })
1869
+ }), K.length === 0 ? e(P, {
1870
+ variant: "body2",
1871
+ color: "text.secondary",
1872
+ children: "No scopes assigned yet."
1873
+ }) : e(E, {
1874
+ direction: "row",
1875
+ flexWrap: "wrap",
1876
+ gap: 1,
1877
+ children: ne.filter((d) => Cn.has(d.scope)).map((d) => e(pe, {
1878
+ label: d.scope,
1879
+ size: "small",
1880
+ onDelete: f ? void 0 : () => Nn(d.scope)
1881
+ }, d.scope))
1882
+ })]
1883
+ })]
1884
+ }), l === "agents" && i(O, {
1885
+ children: [e(T.Header, {
1886
+ children: "Assigned Agents"
1887
+ }), L ? e(Te, {
1888
+ size: 20
1889
+ }) : i(O, {
1890
+ children: [e(P, {
1891
+ variant: "body2",
1892
+ color: "text.secondary",
1893
+ children: "Search and add agents to this role."
1894
+ }), e(F, {
1895
+ sx: {
1896
+ mt: 1,
1897
+ mb: 2
1898
+ },
1899
+ children: e(T.ElementWrapper, {
1900
+ label: "Add Agent",
1901
+ name: "addAgent",
1902
+ children: e(ve, {
1903
+ id: "addAgent",
1904
+ options: fn,
1905
+ getOptionLabel: (d) => d.agentName,
1906
+ onChange: In,
1907
+ value: null,
1908
+ renderInput: (d) => e(Z, {
1909
+ ...d,
1910
+ placeholder: "Search agents..."
1911
+ }),
1912
+ noOptionsText: "No agents available"
1913
+ })
1914
+ })
1915
+ }), he.length === 0 ? e(P, {
1916
+ variant: "body2",
1917
+ color: "text.secondary",
1918
+ children: "No agents assigned yet. Search and add agents above."
1919
+ }) : e(t.Container, {
1920
+ children: i(t, {
1921
+ children: [e(t.Head, {
1922
+ children: i(t.Row, {
1923
+ children: [e(t.Cell, {
1924
+ children: "Agent"
1925
+ }), e(t.Cell, {
1926
+ children: "Thunder Agent ID"
1927
+ }), e(t.Cell, {})]
1928
+ })
1929
+ }), e(t.Body, {
1930
+ children: he.map((d) => i(t.Row, {
1931
+ children: [e(t.Cell, {
1932
+ children: Q(d)
1933
+ }), e(t.Cell, {
1934
+ children: d
1935
+ }), e(t.Cell, {
1936
+ align: "right",
1937
+ children: e(ee, {
1938
+ title: "Remove from role",
1939
+ children: e(ae, {
1940
+ size: "small",
1941
+ onClick: () => An(d),
1942
+ children: e(oe, {
1943
+ size: 16
1944
+ })
1945
+ })
1946
+ })
1947
+ })]
1948
+ }, d))
1949
+ })]
1950
+ })
1951
+ })]
1952
+ })]
1953
+ }), l === "groups" && i(O, {
1954
+ children: [e(T.Header, {
1955
+ children: "Assigned Groups"
1956
+ }), s ? e(Te, {
1957
+ size: 20
1958
+ }) : i(O, {
1959
+ children: [e(P, {
1960
+ variant: "body2",
1961
+ color: "text.secondary",
1962
+ children: "Search and add groups to this role."
1963
+ }), (x?.total ?? 0) > Pe && i(M, {
1964
+ severity: "warning",
1965
+ sx: {
1966
+ mt: 1
1967
+ },
1968
+ children: ["Showing the first ", Pe, " of ", x?.total, " groups in this environment. The add-group picker below only excludes groups from this page."]
1969
+ }), e(F, {
1970
+ sx: {
1971
+ mt: 1,
1972
+ mb: 2
1973
+ },
1974
+ children: e(T.ElementWrapper, {
1975
+ label: "Add Group",
1976
+ name: "addGroup",
1977
+ children: e(ve, {
1978
+ id: "addGroup",
1979
+ options: bn,
1980
+ getOptionLabel: (d) => d.name,
1981
+ onChange: wn,
1982
+ value: null,
1983
+ renderInput: (d) => e(Z, {
1984
+ ...d,
1985
+ placeholder: "Search groups..."
1986
+ }),
1987
+ noOptionsText: "No groups available"
1988
+ })
1989
+ })
1990
+ }), Fe.length === 0 ? e(P, {
1991
+ variant: "body2",
1992
+ color: "text.secondary",
1993
+ children: "No groups assigned yet. Search and add groups above."
1994
+ }) : e(t.Container, {
1995
+ children: i(t, {
1996
+ children: [e(t.Head, {
1997
+ children: i(t.Row, {
1998
+ children: [e(t.Cell, {
1999
+ children: "Name"
2000
+ }), e(t.Cell, {
2001
+ children: "Description"
2002
+ }), e(t.Cell, {})]
2003
+ })
2004
+ }), e(t.Body, {
2005
+ children: Fe.map((d) => i(t.Row, {
2006
+ children: [e(t.Cell, {
2007
+ children: d.name
2008
+ }), e(t.Cell, {
2009
+ children: d.description ?? "-"
2010
+ }), e(t.Cell, {
2011
+ align: "right",
2012
+ children: e(ee, {
2013
+ title: "Remove from role",
2014
+ children: e(ae, {
2015
+ size: "small",
2016
+ onClick: () => Sn(d.id),
2017
+ children: e(oe, {
2018
+ size: 16
2019
+ })
2020
+ })
2021
+ })
2022
+ })]
2023
+ }, d.id))
2024
+ })]
2025
+ })
2026
+ })]
2027
+ })]
2028
+ })]
2029
+ }), Tn && i(E, {
2030
+ direction: "row",
2031
+ spacing: 1,
2032
+ children: [e(_, {
2033
+ variant: "outlined",
2034
+ onClick: () => a(ie),
2035
+ disabled: h,
2036
+ children: "Cancel"
2037
+ }), e(_, {
2038
+ variant: "contained",
2039
+ onClick: Rn,
2040
+ disabled: h,
2041
+ children: h ? "Saving..." : "Save Changes"
2042
+ })]
2043
+ })]
2044
+ })]
2045
+ });
2046
+ }, Gt = {
2047
+ minWidth: 36,
2048
+ color: "primary.main"
2049
+ }, zt = {
2050
+ minWidth: 36,
2051
+ color: "inherit"
2052
+ }, Ot = {
2053
+ color: "text.secondary"
2054
+ }, Bt = {
2055
+ color: "inherit"
2056
+ };
2057
+ function _e({
2058
+ tab: r,
2059
+ isActive: n
2060
+ }) {
2061
+ return e(Qe, {
2062
+ to: r.href,
2063
+ style: {
2064
+ textDecoration: "none",
2065
+ color: "inherit"
2066
+ },
2067
+ children: i(it, {
2068
+ selected: n,
2069
+ children: [e(at, {
2070
+ sx: n ? Gt : zt,
2071
+ children: r.icon
2072
+ }), e(ot, {
2073
+ primary: r.label,
2074
+ sx: n ? Ot : Bt
2075
+ })]
2076
+ })
2077
+ });
2078
+ }
2079
+ const Ft = () => {
2080
+ const r = me(12), {
2081
+ orgId: n,
2082
+ envName: o
2083
+ } = q(), {
2084
+ pathname: a
2085
+ } = Ln(), {
2086
+ pushSnackBar: l
2087
+ } = Ye();
2088
+ let c;
2089
+ r[0] !== n ? (c = {
2090
+ orgName: n
2091
+ }, r[0] = n, r[1] = c) : c = r[1];
2092
+ const {
2093
+ data: h,
2094
+ isLoading: p,
2095
+ error: y
2096
+ } = Ze(c);
2097
+ let g;
2098
+ if (r[2] !== h?.thunderInstances || r[3] !== o || r[4] !== y || r[5] !== p || r[6] !== n || r[7] !== a || r[8] !== l) {
2099
+ const u = h?.thunderInstances.find((x) => x.envName === o);
2100
+ let I;
2101
+ r[10] !== l ? (I = (x, s) => {
2102
+ gn(x).then((v) => {
2103
+ l(v ? {
2104
+ message: `${s} copied to clipboard`,
2105
+ type: "success"
2106
+ } : {
2107
+ message: `Failed to copy ${s}`,
2108
+ type: "error"
2109
+ });
2110
+ });
2111
+ }, r[10] = l, r[11] = I) : I = r[11];
2112
+ const m = I, b = u?.displayName || u?.envName || o || "", C = B(X.children.org.children.thunderInstances.path, {
2113
+ orgId: n ?? ""
2114
+ }), f = X.children.org.children.thunderInstances.children.view, R = B(f.path, {
2115
+ orgId: n ?? "",
2116
+ envName: o ?? ""
2117
+ }), A = {
2118
+ label: "Overview",
2119
+ icon: e(lt, {
2120
+ size: 18
2121
+ }),
2122
+ href: R
2123
+ }, w = [{
2124
+ label: "Agents",
2125
+ icon: e(pn, {
2126
+ size: 18
2127
+ }),
2128
+ href: B(f.children.agents.path, {
2129
+ orgId: n ?? "",
2130
+ envName: o ?? ""
2131
+ }),
2132
+ wildPath: f.children.agents.wildPath
2133
+ }, {
2134
+ label: "Roles",
2135
+ icon: e(Ee, {
2136
+ size: 18
2137
+ }),
2138
+ href: B(f.children.roles.path, {
2139
+ orgId: n ?? "",
2140
+ envName: o ?? ""
2141
+ }),
2142
+ wildPath: f.children.roles.wildPath
2143
+ }, {
2144
+ label: "Groups",
2145
+ icon: e(Le, {
2146
+ size: 18
2147
+ }),
2148
+ href: B(f.children.groups.path, {
2149
+ orgId: n ?? "",
2150
+ envName: o ?? ""
2151
+ }),
2152
+ wildPath: f.children.groups.wildPath
2153
+ }], L = a === R;
2154
+ g = e(O, {
2155
+ children: i(on, {
2156
+ title: b,
2157
+ backHref: C,
2158
+ backLabel: "Back to Identity Providers",
2159
+ description: `The system identity provider used to manage agents, users, roles, and groups for the ${o} environment.`,
2160
+ disableIcon: !0,
2161
+ isLoading: p,
2162
+ titleTail: u && !y ? e(ee, {
2163
+ title: "Thunder identity provider is active for this environment",
2164
+ children: e(pe, {
2165
+ icon: e(ct, {
2166
+ size: 14
2167
+ }),
2168
+ label: "Active",
2169
+ size: "small",
2170
+ color: "success",
2171
+ variant: "outlined"
2172
+ })
2173
+ }) : void 0,
2174
+ children: [p && i(E, {
2175
+ spacing: 3,
2176
+ children: [e(ue, {
2177
+ container: !0,
2178
+ spacing: 2,
2179
+ children: [0, 1, 2, 3].map(Wt)
2180
+ }), e(Ie, {
2181
+ variant: "outlined",
2182
+ sx: {
2183
+ p: 3
2184
+ },
2185
+ children: i(E, {
2186
+ spacing: 2,
2187
+ children: [e(z, {
2188
+ variant: "text",
2189
+ width: 140,
2190
+ height: 24
2191
+ }), e(z, {
2192
+ variant: "rounded",
2193
+ height: 80
2194
+ })]
2195
+ })
2196
+ })]
2197
+ }), !!y && e(M, {
2198
+ severity: "error",
2199
+ icon: e(Ae, {
2200
+ size: 18
2201
+ }),
2202
+ children: "Failed to load identity provider. Please try again."
2203
+ }), !p && !y && !u && i(M, {
2204
+ severity: "warning",
2205
+ icon: e(Ae, {
2206
+ size: 18
2207
+ }),
2208
+ children: ['Identity provider for environment "', o, '" was not found.']
2209
+ }), u && !y && i(Ie, {
2210
+ variant: "outlined",
2211
+ sx: {
2212
+ display: "flex",
2213
+ overflow: "hidden",
2214
+ minHeight: "calc(70vh - 64px)"
2215
+ },
2216
+ children: [i(F, {
2217
+ component: "nav",
2218
+ sx: {
2219
+ width: 200,
2220
+ flexShrink: 0,
2221
+ overflowY: "auto",
2222
+ p: 2
2223
+ },
2224
+ children: [e(je, {
2225
+ children: e(_e, {
2226
+ tab: A,
2227
+ isActive: L
2228
+ })
2229
+ }), e(je, {
2230
+ subheader: e(tt, {
2231
+ disableGutters: !0,
2232
+ disableSticky: !0,
2233
+ children: e(P, {
2234
+ variant: "overline",
2235
+ children: "Identity Management"
2236
+ })
2237
+ }),
2238
+ children: w.map((x) => e(_e, {
2239
+ tab: x,
2240
+ isActive: !!x.wildPath && !!En(x.wildPath, a)
2241
+ }, x.label))
2242
+ })]
2243
+ }), e(rt, {
2244
+ orientation: "vertical",
2245
+ flexItem: !0
2246
+ }), e(F, {
2247
+ sx: {
2248
+ flex: 1,
2249
+ minWidth: 0,
2250
+ overflowY: "auto",
2251
+ p: 3
2252
+ },
2253
+ children: i(Ke, {
2254
+ children: [e(U, {
2255
+ index: !0,
2256
+ element: e(yt, {
2257
+ instance: u,
2258
+ onCopy: m
2259
+ })
2260
+ }), e(U, {
2261
+ path: "agents",
2262
+ element: e(At, {})
2263
+ }), e(U, {
2264
+ path: "agents/:projectName/:agentName",
2265
+ element: e(wt, {})
2266
+ }), e(U, {
2267
+ path: "groups",
2268
+ element: e(xt, {})
2269
+ }), e(U, {
2270
+ path: "groups/create",
2271
+ element: e(Pt, {})
2272
+ }), e(U, {
2273
+ path: "groups/:groupId",
2274
+ element: e(Tt, {})
2275
+ }), e(U, {
2276
+ path: "roles",
2277
+ element: e(Et, {})
2278
+ }), e(U, {
2279
+ path: "roles/create",
2280
+ element: e(kt, {})
2281
+ }), e(U, {
2282
+ path: "roles/:roleId",
2283
+ element: e(Dt, {})
2284
+ }), e(U, {
2285
+ path: "*",
2286
+ element: e(Je, {
2287
+ to: ".",
2288
+ replace: !0
2289
+ })
2290
+ })]
2291
+ })
2292
+ })]
2293
+ })]
2294
+ })
2295
+ }), r[2] = h?.thunderInstances, r[3] = o, r[4] = y, r[5] = p, r[6] = n, r[7] = a, r[8] = l, r[9] = g;
2296
+ } else
2297
+ g = r[9];
2298
+ return g;
2299
+ };
2300
+ function Wt(r) {
2301
+ return e(ue, {
2302
+ size: {
2303
+ xs: 12,
2304
+ sm: 6,
2305
+ md: 3
2306
+ },
2307
+ children: e(Ie, {
2308
+ variant: "outlined",
2309
+ sx: {
2310
+ p: 2,
2311
+ height: "100%"
2312
+ },
2313
+ children: i(E, {
2314
+ spacing: 0.5,
2315
+ children: [e(z, {
2316
+ variant: "text",
2317
+ width: "40%",
2318
+ height: 14
2319
+ }), e(z, {
2320
+ variant: "text",
2321
+ width: "85%",
2322
+ height: 20
2323
+ })]
2324
+ })
2325
+ })
2326
+ }, r);
2327
+ }
2328
+ const qe = () => {
2329
+ const r = me(2), {
2330
+ orgId: n
2331
+ } = q();
2332
+ let o;
2333
+ return r[0] !== n ? (o = i(Ke, {
2334
+ children: [e(U, {
2335
+ index: !0,
2336
+ element: e(on, {
2337
+ title: "Identity Providers",
2338
+ description: "Environment-scoped identity providers for agent authentication",
2339
+ disableIcon: !0,
2340
+ children: e(vt, {})
2341
+ })
2342
+ }), e(U, {
2343
+ path: "view/:envName/*",
2344
+ element: e(Ft, {})
2345
+ }), e(U, {
2346
+ path: "*",
2347
+ element: e(Je, {
2348
+ to: B(X.children.org.children.thunderInstances.path, {
2349
+ orgId: n
2350
+ })
2351
+ })
2352
+ })]
2353
+ }), r[0] = n, r[1] = o) : o = r[1], o;
2354
+ }, Jt = {
2355
+ title: Me.title,
2356
+ description: "Environment-scoped agent identity providers for agent authentication",
2357
+ icon: Me.icon,
2358
+ path: "/thunder-instances",
2359
+ component: qe,
2360
+ levels: {
2361
+ organization: qe
2362
+ }
2363
+ };
2364
+ export {
2365
+ qe as ThunderInstancesOrganization,
2366
+ Jt as thunderInstancesMetaData,
2367
+ Me as thunderInstancesMetadata
2368
+ };