@wso2/am-core-ui 0.0.18 → 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 (48) hide show
  1. package/dist/APIKeysManager-C0phJriD.js +241 -0
  2. package/dist/CatalogKindListing-DvUuZEpc.js +137 -0
  3. package/dist/CodeBlock-B2Ecl916.js +21736 -0
  4. package/dist/EnvironmentCard-CIXhDhlZ.js +319 -0
  5. package/dist/EnvironmentSelector-D8S6nO9u.js +48 -0
  6. package/dist/IsolationTierIndicator-cf90kgjL.js +81 -0
  7. package/dist/LabelChips-7rA7_yre.js +139 -0
  8. package/dist/MCPLogo-D9IJzzl7.js +30 -0
  9. package/dist/PolicyListSection-D6aVSKwP.js +1143 -0
  10. package/dist/ResourceListShell-DFisKftq.js +463 -0
  11. package/dist/SwaggerSpecViewer-DzjR6U6W.js +106 -0
  12. package/dist/clipboard-YAzStmkw.js +23 -0
  13. package/dist/debounce-D17ObVdG.js +208 -0
  14. package/dist/format-wlHhWjGo.js +29 -0
  15. package/dist/formatDistanceToNow-DyjnT7l9.js +100 -0
  16. package/dist/gatewayScripts-D4ZDEDPS.js +72 -0
  17. package/dist/highlight-BsUzxSR3.js +454 -0
  18. package/dist/{index-CnXsN5I3.js → index-3K-zqdp-.js} +34 -33
  19. package/dist/index-6liAPSDn.js +1564 -0
  20. package/dist/index-B3ASENUJ.js +1290 -0
  21. package/dist/index-B7Pf4oPq.js +3069 -0
  22. package/dist/index-BNO3FhZK.js +2304 -0
  23. package/dist/index-BUZSfCl5.js +335 -0
  24. package/dist/index-BXiG1r_o.js +1409 -0
  25. package/dist/index-BYy7Iaam.js +459 -0
  26. package/dist/index-BbB_yx4V.js +1397 -0
  27. package/dist/index-BjWJ95lH.js +2728 -0
  28. package/dist/index-ByEInFlf.js +26408 -0
  29. package/dist/index-C8WIhzyz.js +123 -0
  30. package/dist/index-CnzvaT6b.js +2368 -0
  31. package/dist/index-CrnCf-hJ.js +763 -0
  32. package/dist/index-Cvsho9xg.js +2346 -0
  33. package/dist/index-CxnAo1_c.js +119 -0
  34. package/dist/{index-DYV1jEai.js → index-Cz7-AZwE.js} +22 -20
  35. package/dist/index-DBdRFjxm.js +1264 -0
  36. package/dist/index-DFsSvmMZ.js +7981 -0
  37. package/dist/index-DslzOSGN.js +2549 -0
  38. package/dist/index-DvpYvchM.js +2341 -0
  39. package/dist/index-PWsNvJB-.js +546 -0
  40. package/dist/index.d.ts +1398 -481
  41. package/dist/index.js +539 -438
  42. package/dist/js-yaml-CvhD-clg.js +1335 -0
  43. package/dist/llmProviderPayload-BPzWDy7n.js +332 -0
  44. package/dist/schemas-DFScWdSL.js +2969 -0
  45. package/package.json +1 -1
  46. package/dist/index-B47EJCom.js +0 -236
  47. package/dist/index-Bl1Y7Sro.js +0 -3037
  48. package/dist/index-DlS9Lybj.js +0 -80691
@@ -0,0 +1,2341 @@
1
+ import { jsxs as a, jsx as n, Fragment as qt } from "react/jsx-runtime";
2
+ import { c as Se } from "react/compiler-runtime";
3
+ import { useTheme as kt, Stack as E, Typography as $, Alert as ce, Card as Pe, Chip as ue, FormControl as ge, FormLabel as ve, TextField as Le, InputAdornment as ot, Tooltip as Ge, IconButton as Qe, Divider as $e, Box as se, Button as de, ListingTable as B, Avatar as Ot, TablePagination as ct, Skeleton as ee, Grid as D, Select as Xe, MenuItem as _e, Collapse as Ze, CircularProgress as Et, SearchBar as At, Accordion as je, AccordionSummary as Ue, AccordionDetails as Be, Tabs as Mt, Tab as at, ToggleButtonGroup as Wt, ToggleButton as yt, Paper as lt, Switch as _t } from "@wso2/oxygen-ui";
4
+ import { useState as N, useMemo as Q, useCallback as H, useEffect as oe, useRef as Ke, Suspense as Ft } from "react";
5
+ import { Copy as gt, Key as Gt, Trash as vt, ServerCog as bt, EyeOff as $t, Eye as jt, Users as Ut, ArrowRight as Bt, Plus as xt, ShieldAlert as Vt, Search as Kt, ChevronDown as Ve, Save as Ht, Download as Yt, FileCode as Jt, BrainCircuit as Qt } from "@wso2/oxygen-ui-icons-react";
6
+ import { useNavigate as dt, useParams as De, Link as Xt, generatePath as Ne, useSearchParams as Zt, Route as tt, Routes as Dt, Navigate as en } from "react-router-dom";
7
+ import { L as tn, b6 as nn, bk as rn, ab as ut, O as sn, g as ze, bl as on, bm as Nt, bn as an, bo as ln, bp as cn, bq as dn, w as zt, br as un, bs as hn, bt as mn, P as ht, M as Fe, b4 as pn } from "./index-ByEInFlf.js";
8
+ import "@tanstack/react-query";
9
+ import { f as fn } from "./format-wlHhWjGo.js";
10
+ import { R as yn, A as gn } from "./ResourceListShell-DFisKftq.js";
11
+ import { j as vn } from "./js-yaml-CvhD-clg.js";
12
+ import { i as bn, A as xn } from "./APIKeysManager-C0phJriD.js";
13
+ import { s as pe, o as Re, c as mt, r as Cn, e as wn, b as Rt, _ as Ct } from "./schemas-DFScWdSL.js";
14
+ import { a as Pn } from "./PolicyListSection-D6aVSKwP.js";
15
+ import { S as Ln } from "./SwaggerSpecViewer-DzjR6U6W.js";
16
+ import { m as Sn, b as In, A as kn } from "./llmProviderPayload-BPzWDy7n.js";
17
+ import { t as kr } from "./llmProviderPayload-BPzWDy7n.js";
18
+ const nt = "__unassigned__";
19
+ function wt(t) {
20
+ return navigator.clipboard.writeText(t);
21
+ }
22
+ function En({
23
+ endpoints: t,
24
+ onGenerateApiKey: e,
25
+ isGeneratingApiKey: r,
26
+ apiKeyError: o,
27
+ generatedApiKey: i,
28
+ onClearApiKeyError: l,
29
+ emptyMessage: c = "No invoke URLs available. Deploy to an AI gateway to see invoke URLs and generate API keys."
30
+ }) {
31
+ const y = kt(), [d, u] = N(null), [L, v] = N(!1), P = Q(() => {
32
+ const h = /* @__PURE__ */ new Map();
33
+ for (const b of t) {
34
+ const s = b.environment, f = s?.id || s?.name || nt, M = h.get(f);
35
+ M ? M.endpoints.push(b) : h.set(f, {
36
+ key: f,
37
+ environment: s,
38
+ endpoints: [b]
39
+ });
40
+ }
41
+ return Array.from(h.values()).sort((b, s) => {
42
+ if (b.key === nt) return 1;
43
+ if (s.key === nt) return -1;
44
+ const f = b.environment?.isProduction ? 0 : 1, M = s.environment?.isProduction ? 0 : 1;
45
+ if (f !== M) return f - M;
46
+ const w = b.environment?.displayName || b.environment?.name || "", x = s.environment?.displayName || s.environment?.name || "";
47
+ return w.localeCompare(x);
48
+ });
49
+ }, [t]), S = H(async (h) => {
50
+ if (h.url)
51
+ try {
52
+ await wt(h.url), u(h.gatewayId), setTimeout(() => u(null), 2e3);
53
+ } catch {
54
+ }
55
+ }, []), I = H(async () => {
56
+ if (i)
57
+ try {
58
+ await wt(i), v(!0), setTimeout(() => v(!1), 2e3);
59
+ } catch {
60
+ }
61
+ }, [i]), p = {
62
+ "& .MuiInputBase-input": {
63
+ fontFamily: "monospace",
64
+ fontSize: y.typography.body2?.fontSize,
65
+ wordBreak: "break-all"
66
+ }
67
+ };
68
+ return /* @__PURE__ */ a(E, { spacing: 2.5, sx: {
69
+ width: "100%"
70
+ }, children: [
71
+ /* @__PURE__ */ n($, { variant: "subtitle2", color: "text.secondary", sx: {
72
+ fontWeight: 600
73
+ }, children: "Invoke URL & API Key" }),
74
+ t.length === 0 ? /* @__PURE__ */ n(ce, { severity: "info", children: c }) : /* @__PURE__ */ a(E, { spacing: 2, children: [
75
+ P.map((h) => {
76
+ const b = h.environment?.displayName || h.environment?.name, s = b ? /environment/i.test(b) ? b : `${b} Environment` : "Unassigned";
77
+ return /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
78
+ p: 2
79
+ }, children: /* @__PURE__ */ a(E, { spacing: 1.5, children: [
80
+ /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", gap: 1, children: [
81
+ /* @__PURE__ */ n($, { variant: "body2", sx: {
82
+ fontWeight: 600
83
+ }, children: s }),
84
+ h.environment?.isProduction && /* @__PURE__ */ n(ue, { size: "small", variant: "outlined", color: "success", label: "Production" })
85
+ ] }),
86
+ h.endpoints.map((f) => /* @__PURE__ */ a(ge, { fullWidth: !0, size: "small", children: [
87
+ /* @__PURE__ */ n(ve, { sx: {
88
+ mb: 0.5
89
+ }, children: f.displayName || f.name || f.gatewayId }),
90
+ /* @__PURE__ */ n(Le, { size: "small", fullWidth: !0, value: f.url, slotProps: {
91
+ input: {
92
+ readOnly: !0,
93
+ endAdornment: /* @__PURE__ */ n(ot, { position: "end", children: /* @__PURE__ */ n(Ge, { title: d === f.gatewayId ? "Copied!" : "Copy", children: /* @__PURE__ */ n(Qe, { size: "small", onClick: () => S(f), "aria-label": "Copy Invoke URL", children: /* @__PURE__ */ n(gt, { size: 16 }) }) }) })
94
+ }
95
+ }, sx: p })
96
+ ] }, f.gatewayId))
97
+ ] }) }, h.key);
98
+ }),
99
+ /* @__PURE__ */ n($e, {}),
100
+ /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
101
+ p: 2
102
+ }, children: /* @__PURE__ */ a(E, { spacing: 1.5, children: [
103
+ /* @__PURE__ */ a(se, { children: [
104
+ /* @__PURE__ */ n($, { variant: "subtitle2", sx: {
105
+ fontWeight: 600
106
+ }, children: "Generate API Key" }),
107
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "One API key works across all environments above." })
108
+ ] }),
109
+ /* @__PURE__ */ n(se, { children: /* @__PURE__ */ n(de, { variant: "outlined", size: "medium", startIcon: /* @__PURE__ */ n(Gt, { size: 16 }), onClick: e, disabled: r, children: r ? "Generating..." : "Generate API Key" }) }),
110
+ o && /* @__PURE__ */ n(ce, { severity: "error", onClose: l, children: o }),
111
+ i && /* @__PURE__ */ a(ce, { severity: "success", sx: {
112
+ "& .MuiAlert-message": {
113
+ flexGrow: 1
114
+ }
115
+ }, children: [
116
+ /* @__PURE__ */ n($, { variant: "subtitle2", sx: {
117
+ mb: 0.5
118
+ }, children: "API Key Generated" }),
119
+ /* @__PURE__ */ n($, { variant: "body2", sx: {
120
+ mb: 1
121
+ }, children: "Copy this API key now. It will not be shown again." }),
122
+ /* @__PURE__ */ n(E, { direction: "row", spacing: 1, flexGrow: 1, alignItems: "center", children: /* @__PURE__ */ n(Le, { size: "small", fullWidth: !0, value: i, slotProps: {
123
+ input: {
124
+ readOnly: !0,
125
+ endAdornment: /* @__PURE__ */ n(ot, { position: "end", children: /* @__PURE__ */ n(Ge, { title: L ? "Copied!" : "Copy", children: /* @__PURE__ */ n(Qe, { size: "small", onClick: I, "aria-label": "Copy API Key", children: /* @__PURE__ */ n(gt, { size: 16 }) }) }) })
126
+ }
127
+ }, sx: p }) })
128
+ ] })
129
+ ] }) })
130
+ ] })
131
+ ] });
132
+ }
133
+ const Pt = () => {
134
+ const t = Se(1);
135
+ let e;
136
+ return t[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ a(se, { sx: {
137
+ p: 3
138
+ }, children: [
139
+ /* @__PURE__ */ n($, { variant: "h5", gutterBottom: !0, children: "Component-level LLM Provider management" }),
140
+ /* @__PURE__ */ n($, { variant: "body1", color: "text.secondary", children: "This is an empty placeholder view for managing LLM providers at the component level." })
141
+ ] }), t[0] = e) : e = t[0], e;
142
+ };
143
+ function An() {
144
+ const t = dt(), {
145
+ orgId: e
146
+ } = De(), [r, o] = N(""), [i, l] = N(0), [c, y] = N(5), [d, u] = N(null), {
147
+ addConfirmation: L
148
+ } = tn(), {
149
+ data: v,
150
+ isLoading: P,
151
+ error: S
152
+ } = nn({
153
+ orgName: e
154
+ }), {
155
+ mutate: I
156
+ } = rn(), {
157
+ data: p
158
+ } = ut({
159
+ orgName: e
160
+ }), h = Q(() => p?.templates ? p.templates.reduce((w, x) => {
161
+ const U = x.metadata?.logoUrl;
162
+ return U && (w[x.id] = U), w;
163
+ }, {}) : {}, [p]), b = Q(() => p?.templates ? p.templates.reduce((w, x) => (x.name && (w[x.id] = x.name), w), {}) : {}, [p]), s = Q(() => v?.providers ?? [], [v]), f = Q(() => {
164
+ const w = r.trim().toLowerCase();
165
+ return w ? s.filter((x) => {
166
+ const U = x.name ?? x.displayName ?? "", _ = b[x.template] ?? x.template;
167
+ return [U, x.name, x.displayName, x.id, x.template, _, x.status ?? ""].filter(Boolean).join(" ").toLowerCase().includes(w);
168
+ }) : s;
169
+ }, [s, r, b]);
170
+ oe(() => {
171
+ i !== 0 && i * c >= f.length && l(0);
172
+ }, [f.length, i, c]);
173
+ const M = f.slice(i * c, i * c + c);
174
+ return /* @__PURE__ */ a(yn, { searchValue: r, onSearchChange: o, searchPlaceholder: "Search providers...", addButton: {
175
+ label: "Add Service Provider",
176
+ component: Xt,
177
+ to: Ne(ze.children.org.children.llmProviders.children.add.path, {
178
+ orgId: e
179
+ })
180
+ }, error: S, isLoading: P, isEmpty: !s.length, isSearchEmpty: !f.length, emptyState: {
181
+ illustration: /* @__PURE__ */ n(bt, { size: 64 }),
182
+ title: "No LLM service providers yet",
183
+ description: "Add an LLM service provider to start routing AI traffic through the gateway."
184
+ }, searchEmptyState: {
185
+ illustration: /* @__PURE__ */ n(bt, { size: 64 }),
186
+ title: "No providers match your search",
187
+ description: "Try a different keyword or clear the search filter."
188
+ }, children: [
189
+ /* @__PURE__ */ n(E, { children: /* @__PURE__ */ a(B, { variant: "card", children: [
190
+ /* @__PURE__ */ n(B.Head, { children: /* @__PURE__ */ a(B.Row, { children: [
191
+ /* @__PURE__ */ n(B.Cell, { width: "300px", children: "Name" }),
192
+ /* @__PURE__ */ n(B.Cell, { align: "left", width: "120px", children: "Template" }),
193
+ /* @__PURE__ */ n(B.Cell, { width: "140px", align: "right", children: "Last Updated" })
194
+ ] }) }),
195
+ /* @__PURE__ */ n(B.Body, { children: M.map((w) => {
196
+ const x = w.name ?? w.displayName ?? w.uuid, U = b[w.template] ?? w.template;
197
+ return /* @__PURE__ */ a(B.Row, { variant: "card", hover: !0, clickable: !0, onClick: () => t(Ne(ze.children.org.children.llmProviders.children.view.path, {
198
+ orgId: e,
199
+ providerId: w.uuid
200
+ })), onMouseEnter: () => u(w.uuid), onMouseLeave: () => u(null), onFocus: () => u(w.uuid), onBlur: () => u(null), children: [
201
+ /* @__PURE__ */ n(B.Cell, { children: /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", spacing: 2, children: [
202
+ /* @__PURE__ */ n(Ot, { sx: {
203
+ bgcolor: "primary.main",
204
+ color: "primary.contrastText",
205
+ fontSize: 16,
206
+ height: 36,
207
+ width: 36,
208
+ flexShrink: 0
209
+ }, children: x.charAt(0).toUpperCase() }),
210
+ /* @__PURE__ */ n($, { variant: "body2", fontWeight: 500, children: x })
211
+ ] }) }),
212
+ /* @__PURE__ */ n(B.Cell, { align: "left", children: /* @__PURE__ */ n(ue, { label: U, size: "small", icon: h[w.template] ? /* @__PURE__ */ n(se, { component: "img", src: h[w.template], alt: w.template, sx: {
213
+ width: 14,
214
+ height: 14,
215
+ objectFit: "contain",
216
+ bgcolor: "grey.200",
217
+ flexShrink: 0,
218
+ borderRadius: 1
219
+ } }) : void 0, variant: "outlined", sx: {
220
+ maxWidth: 130
221
+ } }) }),
222
+ /* @__PURE__ */ n(B.Cell, { align: "right", onClick: (_) => _.stopPropagation(), children: /* @__PURE__ */ n(E, { direction: "row", alignItems: "center", spacing: 1, justifyContent: "flex-end", children: d === w.uuid ? /* @__PURE__ */ n(sn, { children: /* @__PURE__ */ n(Ge, { title: "Delete provider", children: /* @__PURE__ */ n(Qe, { color: "error", size: "small", onClick: () => L({
223
+ title: "Delete LLM Provider",
224
+ description: "Are you sure you want to delete this provider? This action cannot be undone.",
225
+ confirmButtonText: "Delete",
226
+ confirmButtonColor: "error",
227
+ confirmButtonIcon: /* @__PURE__ */ n(vt, { size: 16 }),
228
+ onConfirm: () => I({
229
+ orgName: e,
230
+ providerId: w.uuid
231
+ })
232
+ }), children: /* @__PURE__ */ n(vt, { size: 16 }) }) }) }) : w.createdAt ? /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", children: fn(w.createdAt) }) : null }) })
233
+ ] }, w.uuid);
234
+ }) })
235
+ ] }) }),
236
+ f.length > 5 && /* @__PURE__ */ n(ct, { component: "div", count: f.length, page: i, rowsPerPage: c, onPageChange: (w, x) => l(x), onRowsPerPageChange: (w) => {
237
+ y(parseInt(w.target.value, 10)), l(0);
238
+ }, rowsPerPageOptions: [5, 10, 25] })
239
+ ] });
240
+ }
241
+ const Lt = /* @__PURE__ */ new Map();
242
+ function pt(t, e) {
243
+ const r = Se(12), [o, i] = N(e ?? ""), [l, c] = N(!1), [y, d] = N(null);
244
+ let u, L;
245
+ r[0] !== e ? (u = () => {
246
+ i(e ?? "");
247
+ }, L = [e], r[0] = e, r[1] = u, r[2] = L) : (u = r[1], L = r[2]), oe(u, L);
248
+ let v, P;
249
+ r[3] !== e || r[4] !== t ? (v = () => {
250
+ if (!t || (e ?? "").trim())
251
+ return;
252
+ const h = Lt.get(t);
253
+ if (h) {
254
+ i(h);
255
+ return;
256
+ }
257
+ const b = new AbortController();
258
+ return c(!0), d(null), fetch(t, {
259
+ signal: b.signal
260
+ }).then(Mn).then((s) => {
261
+ Lt.set(t, s), i(s);
262
+ }).catch((s) => {
263
+ s?.name !== "AbortError" && d(s instanceof Error ? s : new Error(String(s)));
264
+ }).finally(() => c(!1)), () => b.abort();
265
+ }, P = [t, e], r[3] = e, r[4] = t, r[5] = v, r[6] = P) : (v = r[5], P = r[6]), oe(v, P);
266
+ let S;
267
+ r[7] === Symbol.for("react.memo_cache_sentinel") ? (S = (h) => {
268
+ i(h);
269
+ }, r[7] = S) : S = r[7];
270
+ const I = S;
271
+ let p;
272
+ return r[8] !== y || r[9] !== l || r[10] !== o ? (p = {
273
+ text: o,
274
+ setText: I,
275
+ isLoading: l,
276
+ error: y
277
+ }, r[8] = y, r[9] = l, r[10] = o, r[11] = p) : p = r[11], p;
278
+ }
279
+ function Mn(t) {
280
+ if (!t.ok)
281
+ throw new Error(`Failed to fetch: ${t.status} ${t.statusText}`);
282
+ return t.text();
283
+ }
284
+ const Kn = /* @__PURE__ */ new Set(["get", "post", "put", "delete", "patch", "head", "options", "trace"]);
285
+ function He(t) {
286
+ if (!t?.trim()) return null;
287
+ try {
288
+ const e = JSON.parse(t);
289
+ return e && typeof e == "object" ? e : null;
290
+ } catch {
291
+ try {
292
+ const e = vn.load(t);
293
+ return e && typeof e == "object" ? e : null;
294
+ } catch {
295
+ return null;
296
+ }
297
+ }
298
+ }
299
+ function ft(t) {
300
+ const e = t?.paths;
301
+ if (!e || typeof e != "object") return [];
302
+ const r = [];
303
+ for (const o of Object.keys(e)) {
304
+ const i = e[o];
305
+ if (!(!i || typeof i != "object"))
306
+ for (const l of Object.keys(i)) {
307
+ if (!Kn.has(l.toLowerCase())) continue;
308
+ const c = i[l] || {};
309
+ r.push({
310
+ method: l.toUpperCase(),
311
+ path: o,
312
+ summary: c?.summary || c?.description
313
+ });
314
+ }
315
+ }
316
+ return r.sort((o, i) => {
317
+ const l = o.path.localeCompare(i.path);
318
+ return l !== 0 ? l : o.method.localeCompare(i.method);
319
+ }), r;
320
+ }
321
+ function We(t, e = "::") {
322
+ return `${t.method}${e}${t.path}`;
323
+ }
324
+ function Tt(t) {
325
+ const e = t.toUpperCase();
326
+ return e === "GET" ? "info" : e === "POST" ? "success" : e === "DELETE" ? "error" : "default";
327
+ }
328
+ function Nn(t, e, r) {
329
+ const o = e.toLowerCase(), l = t.paths?.[r], c = l?.[o];
330
+ if (!c) return null;
331
+ const y = {
332
+ [o]: c
333
+ };
334
+ return ["parameters", "servers", "summary", "description"].forEach((u) => {
335
+ l?.[u] !== void 0 && (y[u] = l[u]);
336
+ }), {
337
+ ...t.openapi ? {
338
+ openapi: t.openapi
339
+ } : {},
340
+ ...t.swagger ? {
341
+ swagger: t.swagger
342
+ } : {},
343
+ ...t.info ? {
344
+ info: t.info
345
+ } : {},
346
+ ...t.servers ? {
347
+ servers: t.servers
348
+ } : {},
349
+ ...t.components ? {
350
+ components: t.components
351
+ } : {},
352
+ ...t.security ? {
353
+ security: t.security
354
+ } : {},
355
+ ...t.tags ? {
356
+ tags: t.tags
357
+ } : {},
358
+ ...t.basePath ? {
359
+ basePath: t.basePath
360
+ } : {},
361
+ ...t.host ? {
362
+ host: t.host
363
+ } : {},
364
+ ...t.schemes ? {
365
+ schemes: t.schemes
366
+ } : {},
367
+ ...t.consumes ? {
368
+ consumes: t.consumes
369
+ } : {},
370
+ ...t.produces ? {
371
+ produces: t.produces
372
+ } : {},
373
+ ...t.definitions ? {
374
+ definitions: t.definitions
375
+ } : {},
376
+ ...t.securityDefinitions ? {
377
+ securityDefinitions: t.securityDefinitions
378
+ } : {},
379
+ paths: {
380
+ [r]: y
381
+ }
382
+ };
383
+ }
384
+ function zn({
385
+ providerData: t,
386
+ openapiSpecUrl: e,
387
+ isLoading: r = !1,
388
+ onUpdate: o,
389
+ isUpdating: i
390
+ }) {
391
+ const l = Ke(null), [c, y] = N("allow"), [d, u] = N([]), L = t?.openapi?.trim() ?? "", {
392
+ text: v,
393
+ setText: P,
394
+ isLoading: S,
395
+ error: I
396
+ } = pt(e, L), [p, h] = N(null);
397
+ oe(() => {
398
+ I && h({
399
+ message: "Failed to load OpenAPI spec.",
400
+ severity: "error"
401
+ });
402
+ }, [I]), oe(() => {
403
+ if (!t) return;
404
+ const C = String(t.accessControl?.mode || "").toLowerCase().replace(/-/g, "_") === "deny_all" ? "deny" : "allow", g = t.openapi?.trim() ?? "", A = (t.accessControl?.exceptions || []).flatMap((T) => (T.methods ?? ["GET"]).map((Y) => ({
405
+ method: Y,
406
+ path: T.path ?? ""
407
+ }))).map((T) => We(T));
408
+ y(C), u(A), l.current = {
409
+ mode: C,
410
+ exceptionKeys: A,
411
+ openapi: g
412
+ };
413
+ }, [t]);
414
+ const b = H((K) => {
415
+ if (!K.trim()) return [];
416
+ const C = He(K);
417
+ return C ? ft(C) : [];
418
+ }, []), s = Q(() => b(v).map((C) => ({
419
+ ...C,
420
+ method: C.method.toUpperCase()
421
+ })), [v, b]), f = Q(() => He(v), [v]), M = Q(() => s.map((K) => {
422
+ const C = f ? Nn(f, K.method, K.path) : null;
423
+ return {
424
+ key: We(K),
425
+ method: K.method,
426
+ path: K.path,
427
+ summary: K.summary,
428
+ operationSpec: C
429
+ };
430
+ }), [s, f]), w = Q(() => {
431
+ const K = l.current;
432
+ if (!K) return !1;
433
+ const C = [...d].sort().join("\0"), g = [...K.exceptionKeys].sort().join("\0");
434
+ return c !== K.mode || C !== g || v !== K.openapi;
435
+ }, [c, d, v]), x = H(async () => {
436
+ if (!t) return;
437
+ const K = c === "allow" ? "allow_all" : "deny_all", C = /* @__PURE__ */ new Map();
438
+ s.forEach((W) => C.set(We(W), W));
439
+ const g = /* @__PURE__ */ new Map();
440
+ for (const W of d) {
441
+ const A = C.get(W);
442
+ if (!A) continue;
443
+ const T = A.path ?? "", Y = g.get(T) ?? [];
444
+ Y.includes(A.method) || Y.push(A.method), g.set(T, Y);
445
+ }
446
+ const F = Array.from(g.entries()).map(([W, A]) => ({
447
+ path: W,
448
+ methods: A
449
+ }));
450
+ try {
451
+ await o({
452
+ accessControl: {
453
+ mode: K,
454
+ exceptions: F
455
+ }
456
+ }), l.current = {
457
+ mode: c,
458
+ exceptionKeys: [...d],
459
+ openapi: v
460
+ }, h({
461
+ message: "Access control updated successfully.",
462
+ severity: "success"
463
+ });
464
+ } catch {
465
+ h({
466
+ message: "Failed to update access control.",
467
+ severity: "error"
468
+ });
469
+ }
470
+ }, [t, c, d, s, v, o]), U = H(async (K) => {
471
+ try {
472
+ const C = await K.text();
473
+ if (!b(C).length) {
474
+ h({
475
+ message: "No resources found in specification.",
476
+ severity: "error"
477
+ });
478
+ return;
479
+ }
480
+ P(C), h({
481
+ message: "Specification imported. Click Save to apply.",
482
+ severity: "success"
483
+ });
484
+ } catch {
485
+ h({
486
+ message: "Failed to import specification.",
487
+ severity: "error"
488
+ });
489
+ }
490
+ }, [b, P]), _ = H(() => {
491
+ const K = l.current;
492
+ if (K)
493
+ y(K.mode), u([...K.exceptionKeys]), P(K.openapi);
494
+ else if (t) {
495
+ const g = String(t.accessControl?.mode || "").toLowerCase().replace(/-/g, "_") === "deny_all" ? "deny" : "allow", W = (t.accessControl?.exceptions || []).flatMap((A) => (A.methods ?? ["GET"]).map((T) => ({
496
+ method: T,
497
+ path: A.path ?? ""
498
+ })));
499
+ y(g), u(W.map((A) => We(A))), P(t.openapi?.trim() ?? "");
500
+ }
501
+ h(null);
502
+ }, [t, P]);
503
+ return !r && !S && !t ? null : /* @__PURE__ */ n(gn, { items: M, mode: c, onModeChange: y, exceptionKeys: d, onExceptionKeysChange: u, isLoading: r || S, isSaving: i, isDirty: w, onSave: () => void x(), onDiscard: _, status: p, onClearStatus: () => h(null), showImportButton: !0, onImportSpec: U, availableEmptyTitle: "No available resources", availableEmptyDescription: "Import a specification or use a template with OpenAPI to see resources here." });
504
+ }
505
+ function Rn(t) {
506
+ const e = Se(24), {
507
+ providerData: r,
508
+ orgName: o,
509
+ providerId: i,
510
+ isLoading: l,
511
+ error: c
512
+ } = t, y = l === void 0 ? !1 : l, d = c === void 0 ? null : c, u = bn(r?.security), L = u ? o : void 0, v = u ? i : void 0;
513
+ let P;
514
+ e[0] !== L || e[1] !== v ? (P = {
515
+ orgName: L,
516
+ providerId: v
517
+ }, e[0] = L, e[1] = v, e[2] = P) : P = e[2];
518
+ const {
519
+ data: S,
520
+ isLoading: I,
521
+ isError: p
522
+ } = on(P), {
523
+ mutateAsync: h,
524
+ isPending: b
525
+ } = Nt(), {
526
+ mutate: s,
527
+ isPending: f
528
+ } = an();
529
+ let M;
530
+ e[3] !== h || e[4] !== o || e[5] !== r?.id || e[6] !== i ? (M = async (C) => {
531
+ const {
532
+ displayName: g,
533
+ expiresAt: F
534
+ } = C;
535
+ if (!o || !i)
536
+ return;
537
+ const W = Math.random().toString(36).slice(2, 10), A = `provider-${r?.id ?? i}-${W}`;
538
+ return (await h({
539
+ params: {
540
+ orgName: o,
541
+ providerId: i
542
+ },
543
+ body: {
544
+ name: A,
545
+ displayName: g,
546
+ expiresAt: F
547
+ }
548
+ })).apiKey;
549
+ }, e[3] = h, e[4] = o, e[5] = r?.id, e[6] = i, e[7] = M) : M = e[7];
550
+ const w = M;
551
+ let x;
552
+ e[8] !== o || e[9] !== i || e[10] !== s ? (x = (C) => {
553
+ !o || !i || s({
554
+ orgName: o,
555
+ providerId: i,
556
+ keyName: C
557
+ });
558
+ }, e[8] = o, e[9] = i, e[10] = s, e[11] = x) : x = e[11];
559
+ const U = x;
560
+ if (y) {
561
+ let C;
562
+ return e[12] === Symbol.for("react.memo_cache_sentinel") ? (C = /* @__PURE__ */ n(ee, { variant: "rectangular", width: "100%", height: 200 }), e[12] = C) : C = e[12], C;
563
+ }
564
+ if (d) {
565
+ const C = d.message || "Failed to load the LLM provider.";
566
+ let g;
567
+ return e[13] !== C ? (g = /* @__PURE__ */ n(ce, { severity: "error", children: C }), e[13] = C, e[14] = g) : g = e[14], g;
568
+ }
569
+ if (!r)
570
+ return null;
571
+ if (!u) {
572
+ let C;
573
+ return e[15] === Symbol.for("react.memo_cache_sentinel") ? (C = /* @__PURE__ */ n(ce, { severity: "info", children: "Enable API key authentication from the Security tab to manage API keys." }), e[15] = C) : C = e[15], C;
574
+ }
575
+ const _ = S?.keys;
576
+ let K;
577
+ return e[16] !== w || e[17] !== U || e[18] !== b || e[19] !== p || e[20] !== I || e[21] !== f || e[22] !== _ ? (K = /* @__PURE__ */ n(xn, { keys: _, isLoading: I, isError: p, isCreating: b, isRevoking: f, emptyDescription: "Create an API key to authenticate requests to this LLM provider.", onCreate: w, onRevoke: U }), e[16] = w, e[17] = U, e[18] = b, e[19] = p, e[20] = I, e[21] = f, e[22] = _, e[23] = K) : K = e[23], K;
578
+ }
579
+ const Te = "••••••••••••", Tn = pe().min(1, "Provider Endpoint is required").url("Please enter a valid URL"), Me = "api-key", qn = [{
580
+ value: "api-key",
581
+ label: "API Key"
582
+ }, {
583
+ value: "bearer",
584
+ label: "Bearer"
585
+ }, {
586
+ value: "basic",
587
+ label: "Basic"
588
+ }, {
589
+ value: "none",
590
+ label: "None"
591
+ }];
592
+ function On({
593
+ providerData: t,
594
+ valuePrefix: e = "",
595
+ isLoading: r = !1,
596
+ onUpdate: o,
597
+ isUpdating: i
598
+ }) {
599
+ const l = Ke(null), c = Ke(!1), [y, d] = N(""), [u, L] = N(Me), [v, P] = N(""), [S, I] = N(""), [p, h] = N(!1), [b, s] = N(!1), [f, M] = N(null), [w, x] = N(null);
600
+ oe(() => {
601
+ if (!t) return;
602
+ const g = t.uuid;
603
+ l.current !== g && (l.current = g, d(t.upstream?.main?.url ?? ""), L(t.upstream?.main?.auth?.type ?? Me), P(t.upstream?.main?.auth?.header ?? ""), I(Te), h(!0), x(null));
604
+ }, [t]);
605
+ const U = Q(() => {
606
+ if (!t) return !1;
607
+ const g = t.upstream?.main, F = (g?.url ?? "").trim(), W = g?.auth?.type ?? Me, A = (g?.auth?.header ?? "").trim();
608
+ return y.trim() !== F || (u || Me) !== W || v.trim() !== A || !p && S.trim() !== Te;
609
+ }, [t, y, u, v, S, p]), _ = H((g) => {
610
+ const F = Tn.safeParse(g.trim());
611
+ if (F.success)
612
+ return x(null), null;
613
+ const W = F.error.flatten().formErrors[0] ?? "Invalid URL";
614
+ return x(W), W;
615
+ }, []), K = H(() => {
616
+ t && (d(t.upstream?.main?.url ?? ""), L(t.upstream?.main?.auth?.type ?? Me), P(t.upstream?.main?.auth?.header ?? ""), I(Te), h(!0), x(null), M(null));
617
+ }, [t]), C = H(async () => {
618
+ if (!t) return;
619
+ const g = y.trim(), F = _(y);
620
+ if (F) {
621
+ M({
622
+ message: F,
623
+ severity: "error"
624
+ });
625
+ return;
626
+ }
627
+ let W = t.upstream?.main?.auth?.value ?? "";
628
+ if (!p && S.trim() !== Te)
629
+ if (S.trim() === "" && !c.current)
630
+ W = t.upstream?.main?.auth?.value ?? "";
631
+ else {
632
+ const T = S.trim();
633
+ W = e ? T.startsWith(e) ? T : `${e}${T}` : T;
634
+ }
635
+ const A = u === "none" ? {
636
+ type: "none",
637
+ header: "",
638
+ value: ""
639
+ } : {
640
+ type: u || Me,
641
+ header: v.trim() || "",
642
+ value: W
643
+ };
644
+ try {
645
+ await o({
646
+ upstream: {
647
+ main: {
648
+ url: g,
649
+ auth: A
650
+ }
651
+ }
652
+ }), M({
653
+ message: "Connection updated successfully.",
654
+ severity: "success"
655
+ }), !p && S.trim() !== Te && (I(Te), h(!0));
656
+ } catch {
657
+ M({
658
+ message: "Failed to update connection.",
659
+ severity: "error"
660
+ });
661
+ }
662
+ }, [t, y, u, v, S, e, p, o, _]);
663
+ return r ? /* @__PURE__ */ n(E, { spacing: 2, children: /* @__PURE__ */ n(E, { spacing: 2, children: [1, 2, 3, 4].map((g) => /* @__PURE__ */ a(E, { spacing: 0.5, children: [
664
+ /* @__PURE__ */ n(ee, { variant: "text", width: 120, height: 16 }),
665
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 40 })
666
+ ] }, g)) }) }) : t ? /* @__PURE__ */ n(qt, { children: /* @__PURE__ */ n(E, { spacing: 2, children: /* @__PURE__ */ a(D, { container: !0, spacing: 3, children: [
667
+ /* @__PURE__ */ n(D, { size: {
668
+ xs: 12
669
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, children: [
670
+ /* @__PURE__ */ n(ve, { children: "Provider Endpoint" }),
671
+ /* @__PURE__ */ n(Le, { size: "small", value: y, onChange: (g) => {
672
+ d(g.target.value), w && _(g.target.value);
673
+ }, onBlur: () => _(y), error: !!w, helperText: w, sx: {
674
+ "& .MuiInputBase-input": {
675
+ fontFamily: "monospace",
676
+ fontSize: "0.875rem"
677
+ }
678
+ } })
679
+ ] }) }),
680
+ /* @__PURE__ */ n(D, { size: {
681
+ xs: 12,
682
+ sm: 6
683
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, children: [
684
+ /* @__PURE__ */ n(ve, { children: "Authentication" }),
685
+ /* @__PURE__ */ n(Xe, { size: "small", value: u || Me, onChange: (g) => L(g.target.value), children: qn.map((g) => /* @__PURE__ */ n(_e, { value: g.value, children: g.label }, g.value)) })
686
+ ] }) }),
687
+ /* @__PURE__ */ n(D, { size: {
688
+ xs: 12,
689
+ sm: 6
690
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, children: [
691
+ /* @__PURE__ */ n(ve, { children: "Authentication Header" }),
692
+ /* @__PURE__ */ n(Le, { size: "small", value: v, onChange: (g) => P(g.target.value) })
693
+ ] }) }),
694
+ /* @__PURE__ */ n(D, { size: {
695
+ xs: 12
696
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, children: [
697
+ /* @__PURE__ */ n(ve, { children: "Credentials" }),
698
+ /* @__PURE__ */ n(Le, { size: "small", type: b ? "text" : "password", value: S, onFocus: () => {
699
+ p && (I(""), h(!1), c.current = !1);
700
+ }, onChange: (g) => {
701
+ c.current = !0, I(g.target.value);
702
+ }, slotProps: {
703
+ input: {
704
+ endAdornment: /* @__PURE__ */ n(ot, { position: "end", children: /* @__PURE__ */ n(Qe, { size: "small", onClick: () => s((g) => !g), "aria-label": b ? "Hide credentials" : "Show credentials", children: b ? /* @__PURE__ */ n($t, { size: 18 }) : /* @__PURE__ */ n(jt, { size: 18 }) }) })
705
+ }
706
+ }, sx: {
707
+ "& .MuiInputBase-input": {
708
+ fontFamily: "monospace"
709
+ }
710
+ } })
711
+ ] }) }),
712
+ /* @__PURE__ */ n(D, { size: {
713
+ xs: 12
714
+ }, children: /* @__PURE__ */ a(E, { spacing: 1.5, width: "100%", children: [
715
+ /* @__PURE__ */ n(Ze, { in: !!f, timeout: 300, children: f && /* @__PURE__ */ n(ce, { severity: f.severity, onClose: () => M(null), sx: {
716
+ width: "100%"
717
+ }, children: f.message }) }),
718
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1.5, justifyContent: "flex-end", children: [
719
+ /* @__PURE__ */ n(de, { variant: "outlined", onClick: K, disabled: !U || i, children: "Discard" }),
720
+ /* @__PURE__ */ n(de, { variant: "contained", onClick: () => void C(), disabled: i || !U || !!w, children: i ? "Saving..." : "Save" })
721
+ ] })
722
+ ] }) })
723
+ ] }) }) }) : null;
724
+ }
725
+ function Wn(t, e) {
726
+ if (e.consumerType === "agent")
727
+ return Ne(ze.children.org.children.projects.children.agents.children.configure.path, {
728
+ orgId: t,
729
+ projectId: e.projectName,
730
+ agentId: e.consumerName
731
+ });
732
+ }
733
+ const _n = (t) => {
734
+ const e = Se(19), {
735
+ orgName: r,
736
+ providerId: o
737
+ } = t, i = dt();
738
+ let l;
739
+ e[0] !== r || e[1] !== o ? (l = {
740
+ orgName: r,
741
+ providerId: o
742
+ }, e[0] = r, e[1] = o, e[2] = l) : l = e[2];
743
+ const {
744
+ data: c,
745
+ isLoading: y,
746
+ error: d
747
+ } = ln(l);
748
+ if (y) {
749
+ let p;
750
+ return e[3] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ n(se, { sx: {
751
+ display: "flex",
752
+ justifyContent: "center",
753
+ py: 6
754
+ }, children: /* @__PURE__ */ n(Et, {}) }), e[3] = p) : p = e[3], p;
755
+ }
756
+ if (d) {
757
+ let p;
758
+ return e[4] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ n(ce, { severity: "error", sx: {
759
+ mt: 2
760
+ }, children: "Failed to load consumers." }), e[4] = p) : p = e[4], p;
761
+ }
762
+ let u;
763
+ e[5] !== c?.consumers ? (u = c?.consumers ?? [], e[5] = c?.consumers, e[6] = u) : u = e[6];
764
+ const L = u;
765
+ if (L.length === 0) {
766
+ let p;
767
+ return e[7] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ n(B.Container, { children: /* @__PURE__ */ n(B.EmptyState, { illustration: /* @__PURE__ */ n(Ut, { size: 64 }), title: "No consumers yet", description: "Agents and monitors that use an LLM proxy pointing to this provider will appear here." }) }), e[7] = p) : p = e[7], p;
768
+ }
769
+ let v;
770
+ e[8] === Symbol.for("react.memo_cache_sentinel") ? (v = {
771
+ pt: 2
772
+ }, e[8] = v) : v = e[8];
773
+ let P;
774
+ e[9] === Symbol.for("react.memo_cache_sentinel") ? (P = /* @__PURE__ */ n(B.Head, { children: /* @__PURE__ */ a(B.Row, { children: [
775
+ /* @__PURE__ */ n(B.Cell, { children: "Name" }),
776
+ /* @__PURE__ */ n(B.Cell, { children: "Type" }),
777
+ /* @__PURE__ */ n(B.Cell, { children: "Project" }),
778
+ /* @__PURE__ */ n(B.Cell, { width: "140px" })
779
+ ] }) }), e[9] = P) : P = e[9];
780
+ let S;
781
+ if (e[10] !== L || e[11] !== i || e[12] !== r) {
782
+ let p;
783
+ e[14] !== i || e[15] !== r ? (p = (h, b) => {
784
+ const s = r ? Wn(r, h) : void 0;
785
+ return /* @__PURE__ */ a(B.Row, { hover: !0, sx: {
786
+ "& .row-action": {
787
+ visibility: "hidden"
788
+ },
789
+ "&:hover .row-action, &:focus-within .row-action": {
790
+ visibility: "visible"
791
+ }
792
+ }, children: [
793
+ /* @__PURE__ */ n(B.Cell, { children: /* @__PURE__ */ n($, { variant: "body2", sx: {
794
+ fontWeight: 500
795
+ }, children: h.consumerName }) }),
796
+ /* @__PURE__ */ n(B.Cell, { children: h.consumerType === "agent" ? /* @__PURE__ */ n(ue, { label: "Agent", size: "small", variant: "outlined", color: "primary" }) : /* @__PURE__ */ n(ue, { label: "Monitor", size: "small", variant: "outlined", color: "default" }) }),
797
+ /* @__PURE__ */ n(B.Cell, { children: /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: h.projectName }) }),
798
+ /* @__PURE__ */ n(B.Cell, { align: "right", padding: "none", sx: {
799
+ pr: 1.5
800
+ }, children: s && /* @__PURE__ */ n(de, { className: "row-action", variant: "outlined", size: "small", endIcon: /* @__PURE__ */ n(Bt, { size: 14 }), onClick: () => i(s), "aria-label": `Go to ${h.consumerType} ${h.consumerName}`, sx: {
801
+ minWidth: 120
802
+ }, children: `Go to ${h.consumerType}` }) })
803
+ ] }, b);
804
+ }, e[14] = i, e[15] = r, e[16] = p) : p = e[16], S = L.map(p), e[10] = L, e[11] = i, e[12] = r, e[13] = S;
805
+ } else
806
+ S = e[13];
807
+ let I;
808
+ return e[17] !== S ? (I = /* @__PURE__ */ n(se, { sx: v, children: /* @__PURE__ */ a(B, { children: [
809
+ P,
810
+ /* @__PURE__ */ n(B.Body, { children: S })
811
+ ] }) }), e[17] = S, e[18] = I) : I = e[18], I;
812
+ }, Fn = Re({
813
+ path: pe(),
814
+ methods: mt(pe()),
815
+ params: Cn(pe(), wn()).optional()
816
+ }), Gn = Re({
817
+ name: pe().min(1),
818
+ version: pe().min(1),
819
+ paths: mt(Fn).optional()
820
+ }), $n = Re({
821
+ policies: mt(Gn)
822
+ });
823
+ function rt(t) {
824
+ return t.path === "/*" && (t.methods?.includes("*") ?? !1);
825
+ }
826
+ function St(t, e, r) {
827
+ return t.path !== e ? !1 : (t.methods ?? []).some((i) => i.toUpperCase() === r.toUpperCase());
828
+ }
829
+ function jn(t, e) {
830
+ const r = [...e.methods ?? []].sort();
831
+ return t.some((o) => {
832
+ if (o.path !== e.path) return !1;
833
+ const i = [...o.methods ?? []].sort();
834
+ return i.length === r.length && i.every((l, c) => l === r[c]);
835
+ });
836
+ }
837
+ function Un({
838
+ providerData: t,
839
+ openapiSpecUrl: e,
840
+ isLoading: r = !1,
841
+ error: o = null,
842
+ onUpdate: i,
843
+ isUpdating: l
844
+ }) {
845
+ const {
846
+ data: c
847
+ } = cn(), y = Q(() => c?.data ?? [], [c]), [d, u] = N(null), L = t?.openapi?.trim() ?? "", {
848
+ text: v,
849
+ isLoading: P,
850
+ error: S
851
+ } = pt(e, L), [I, p] = N(!1), [h, b] = N(null), [s, f] = N(null), [M, w] = N(/* @__PURE__ */ new Set()), [x, U] = N(0), [_, K] = N(""), C = 10, g = Q(() => t?.policies ?? [], [t?.policies]), [F, W] = N([]), A = Ke(JSON.stringify(g));
852
+ oe(() => {
853
+ W(g), A.current = JSON.stringify(g);
854
+ }, [g]);
855
+ const T = F;
856
+ oe(() => {
857
+ S && u({
858
+ message: "Failed to load OpenAPI spec.",
859
+ severity: "error"
860
+ });
861
+ }, [S]);
862
+ const Y = Q(() => {
863
+ if (!v.trim()) return [];
864
+ const m = He(v);
865
+ return m ? ft(m) : [];
866
+ }, [v]);
867
+ oe(() => {
868
+ U(0);
869
+ }, [Y]), oe(() => {
870
+ U(0);
871
+ }, [_]);
872
+ const ae = Q(() => {
873
+ const m = [];
874
+ return T.forEach((G, k) => {
875
+ (G.paths ?? []).forEach((z, R) => {
876
+ rt(z) && m.push({
877
+ policyIndex: k,
878
+ pathIndex: R,
879
+ policy: G,
880
+ path: z
881
+ });
882
+ });
883
+ }), m;
884
+ }, [T]), q = H((m) => {
885
+ const G = [];
886
+ return T.forEach((k, z) => {
887
+ (k.paths ?? []).forEach((R, O) => {
888
+ St(R, m.path, m.method) && G.push({
889
+ policyIndex: z,
890
+ pathIndex: O,
891
+ policy: k,
892
+ path: R
893
+ });
894
+ });
895
+ }), G;
896
+ }, [T]), V = Q(() => A.current === null ? !1 : JSON.stringify(F) !== A.current, [F]), X = H(async () => {
897
+ const m = $n.safeParse({
898
+ policies: F
899
+ });
900
+ if (!m.success) {
901
+ const G = m.error.issues[0];
902
+ u({
903
+ message: G?.message ?? "Validation failed",
904
+ severity: "error"
905
+ });
906
+ return;
907
+ }
908
+ try {
909
+ const G = m.data.policies.map((k) => ({
910
+ ...k,
911
+ paths: k.paths ?? []
912
+ }));
913
+ await i({
914
+ policies: G
915
+ }), A.current = JSON.stringify(F), u({
916
+ message: "Guardrails saved successfully.",
917
+ severity: "success"
918
+ });
919
+ } catch {
920
+ u({
921
+ message: "Failed to save guardrails.",
922
+ severity: "error"
923
+ });
924
+ }
925
+ }, [F, i]), J = H(() => {
926
+ W(g), A.current = JSON.stringify(g), u(null);
927
+ }, [g]), he = H((m, G) => {
928
+ if (!h) return;
929
+ const k = G ?? {}, z = h.type === "global" ? {
930
+ path: "/*",
931
+ methods: ["*"],
932
+ params: k
933
+ } : {
934
+ path: h.path,
935
+ methods: [h.method],
936
+ params: k
937
+ }, R = T.find((j) => j.name === m.name && j.version === m.version);
938
+ let O;
939
+ if (R) {
940
+ const j = R.paths ?? [], Z = jn(j, z) ? j : [...j, z];
941
+ O = T.map((ie) => ie.name === m.name && ie.version === m.version ? {
942
+ ...ie,
943
+ paths: Z
944
+ } : ie);
945
+ } else
946
+ O = [...T, {
947
+ name: m.name,
948
+ version: m.version,
949
+ paths: [z]
950
+ }];
951
+ W(O);
952
+ }, [h, T]), ne = H((m, G) => {
953
+ const k = T[m];
954
+ if (!k) return;
955
+ const z = (k.paths ?? []).filter((O, j) => j !== G), R = z.length === 0 ? T.filter((O, j) => j !== m) : T.map((O, j) => j === m ? {
956
+ ...O,
957
+ paths: z
958
+ } : O);
959
+ W(R);
960
+ }, [T]), re = H((m, G) => {
961
+ if (!s) return;
962
+ const k = G ?? {}, z = T.map((R, O) => O !== s.policyIndex ? R : {
963
+ ...R,
964
+ paths: (R.paths ?? []).map((j, Z) => Z === s.pathIndex ? {
965
+ ...j,
966
+ params: k
967
+ } : j)
968
+ });
969
+ W(z);
970
+ }, [s, T]), xe = H((m) => {
971
+ b(m), f(null), p(!0);
972
+ }, []), le = H((m) => {
973
+ if (!y.find((R) => R.name === m.policy.name && R.version === m.policy.version)) return;
974
+ const k = m.path, z = rt(k) ? {
975
+ type: "global"
976
+ } : {
977
+ type: "resource",
978
+ method: k.methods[0] ?? "",
979
+ path: k.path
980
+ };
981
+ b(z), f({
982
+ policyIndex: m.policyIndex,
983
+ pathIndex: m.pathIndex,
984
+ guardrailName: m.policy.name,
985
+ guardrailVersion: m.policy.version,
986
+ params: k.params ?? {}
987
+ }), p(!0);
988
+ }, [y]), te = H(() => {
989
+ p(!1), b(null), f(null);
990
+ }, []), fe = H((m, G) => {
991
+ s ? re(m, G) : h && he(m, G), te();
992
+ }, [h, s, he, re, te]), be = H((m) => y.find((k) => k.name === m.name && k.version === m.version)?.displayName ?? m.name, [y]), me = Q(() => {
993
+ if (!_.trim()) return Y;
994
+ const m = _.toLowerCase();
995
+ return Y.filter((G) => G.path.toLowerCase().includes(m) || G.method.toLowerCase().includes(m) || (G.summary ?? "").toLowerCase().includes(m));
996
+ }, [Y, _]), Ie = Q(() => me.slice(x * C, (x + 1) * C), [me, x]);
997
+ return r ? /* @__PURE__ */ a(E, { spacing: 3, children: [
998
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 120 }),
999
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 200 })
1000
+ ] }) : !t && !o ? null : /* @__PURE__ */ a(se, { sx: {
1001
+ display: "flex",
1002
+ flexDirection: "column",
1003
+ height: "100%"
1004
+ }, children: [
1005
+ /* @__PURE__ */ n(se, { sx: {
1006
+ flex: 1,
1007
+ overflowY: "auto",
1008
+ pb: 2
1009
+ }, children: /* @__PURE__ */ a(E, { spacing: 3, children: [
1010
+ o && /* @__PURE__ */ n(ce, { severity: "error", sx: {
1011
+ width: "100%"
1012
+ }, children: o instanceof Error ? o.message : "Failed to load provider." }),
1013
+ /* @__PURE__ */ n(Ze, { in: !!d && (d.severity === "error" || !V), timeout: 300, children: d && /* @__PURE__ */ n(ce, { severity: d.severity, onClose: () => u(null), sx: {
1014
+ width: "100%"
1015
+ }, children: d.message }) }),
1016
+ /* @__PURE__ */ a(E, { spacing: 3, children: [
1017
+ /* @__PURE__ */ a(se, { children: [
1018
+ /* @__PURE__ */ n($, { variant: "h6", component: "h2", sx: {
1019
+ mb: 0.5
1020
+ }, children: "Global Guardrails" }),
1021
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", sx: {
1022
+ mb: 2
1023
+ }, children: "Applies for all resources" }),
1024
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1, flexWrap: "wrap", useFlexGap: !0, children: [
1025
+ ae.map((m) => /* @__PURE__ */ n(ue, { label: `${be(m.policy)} (v${m.policy.version})`, color: "warning", variant: "outlined", onClick: () => le(m), onDelete: () => ne(m.policyIndex, m.pathIndex), disabled: l, sx: {
1026
+ cursor: "pointer"
1027
+ } }, `${m.policyIndex}-${m.pathIndex}`)),
1028
+ /* @__PURE__ */ n(de, { variant: "contained", size: "small", startIcon: /* @__PURE__ */ n(xt, { size: 16 }), onClick: () => xe({
1029
+ type: "global"
1030
+ }), disabled: l, children: "Add Guardrail" })
1031
+ ] })
1032
+ ] }),
1033
+ /* @__PURE__ */ a(se, { children: [
1034
+ /* @__PURE__ */ n($, { variant: "h6", component: "h2", sx: {
1035
+ mb: 2
1036
+ }, children: "Resource-wise Guardrails" }),
1037
+ P ? /* @__PURE__ */ a(E, { direction: "row", spacing: 1, alignItems: "center", sx: {
1038
+ py: 2
1039
+ }, children: [
1040
+ /* @__PURE__ */ n(ee, { variant: "circular", width: 16, height: 16 }),
1041
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "Loading OpenAPI spec…" })
1042
+ ] }) : Y.length === 0 ? /* @__PURE__ */ n(B.Container, { children: /* @__PURE__ */ n(B.EmptyState, { illustration: /* @__PURE__ */ n(Vt, { size: 64 }), title: "No resources found", description: "Add an OpenAPI specification to define resources for resource-wise guardrails." }) }) : /* @__PURE__ */ a(se, { children: [
1043
+ /* @__PURE__ */ n(At, { placeholder: "Search resources…", value: _, onChange: (m) => K(m.target.value), sx: {
1044
+ mb: 1,
1045
+ width: "100%"
1046
+ } }),
1047
+ me.length === 0 ? /* @__PURE__ */ n(B.Container, { children: /* @__PURE__ */ n(B.EmptyState, { illustration: /* @__PURE__ */ n(Kt, { size: 64 }), title: "No resources match your search", description: "Try a different keyword or clear the search filter." }) }) : /* @__PURE__ */ n(E, { spacing: 0, children: Ie.map((m) => {
1048
+ const G = We(m), k = M.has(G), z = q(m);
1049
+ return /* @__PURE__ */ a(je, { expanded: k, onChange: (R, O) => w((j) => {
1050
+ const Z = new Set(j);
1051
+ return O ? Z.add(G) : Z.delete(G), Z;
1052
+ }), disableGutters: !0, children: [
1053
+ /* @__PURE__ */ n(Ue, { expandIcon: /* @__PURE__ */ n(Ve, { size: 18 }), children: /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", spacing: 1, children: [
1054
+ /* @__PURE__ */ n(ue, { label: m.method, size: "small", variant: "outlined", color: Tt(m.method), sx: {
1055
+ minWidth: 72,
1056
+ justifyContent: "center"
1057
+ } }),
1058
+ /* @__PURE__ */ n($, { variant: "body2", children: m.path })
1059
+ ] }) }),
1060
+ /* @__PURE__ */ a(Be, { children: [
1061
+ /* @__PURE__ */ n($, { variant: "subtitle2", sx: {
1062
+ mb: 1
1063
+ }, children: "Guardrails" }),
1064
+ /* @__PURE__ */ n(E, { direction: "row", spacing: 1, flexWrap: "wrap", useFlexGap: !0, sx: {
1065
+ mb: 1
1066
+ }, children: z.length === 0 ? /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "No guardrails added yet." }) : z.map((R) => /* @__PURE__ */ n(ue, { label: `${be(R.policy)} (v${R.policy.version})`, color: "warning", variant: "outlined", onClick: () => le(R), onDelete: () => ne(R.policyIndex, R.pathIndex), disabled: l, sx: {
1067
+ cursor: "pointer"
1068
+ } }, `${m.path}-${R.policyIndex}-${R.pathIndex}`)) }),
1069
+ /* @__PURE__ */ n(de, { variant: "outlined", size: "small", startIcon: /* @__PURE__ */ n(xt, { size: 16 }), onClick: () => xe({
1070
+ type: "resource",
1071
+ method: m.method,
1072
+ path: m.path
1073
+ }), disabled: l, children: "Add Guardrail" })
1074
+ ] })
1075
+ ] }, G);
1076
+ }) }),
1077
+ me.length > C && /* @__PURE__ */ n(ct, { component: "div", count: me.length, page: x, rowsPerPage: C, rowsPerPageOptions: [C], onPageChange: (m, G) => U(G) })
1078
+ ] })
1079
+ ] })
1080
+ ] })
1081
+ ] }) }),
1082
+ /* @__PURE__ */ n($e, {}),
1083
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1.5, justifyContent: "flex-end", sx: {
1084
+ pt: 2
1085
+ }, children: [
1086
+ /* @__PURE__ */ n(de, { variant: "outlined", onClick: J, disabled: !V || l, children: "Discard" }),
1087
+ /* @__PURE__ */ n(de, { variant: "contained", onClick: () => void X(), disabled: !V || l, children: l ? "Saving..." : "Save" })
1088
+ ] }),
1089
+ /* @__PURE__ */ n(Pn, { open: I, onClose: te, onSubmit: fe, policyNoun: "guardrail", loadingLabel: "Loading guardrails...", searchPlaceholder: "Search guardrails...", catalogErrorLabel: "Failed to load guardrails.", emptySearchTitle: "No guardrails match your search", emptyCatalogTitle: "No guardrails available", emptyCatalogDescription: "No guardrail policies are available in the catalog.", disabledPolicyKeys: s ? [] : T.filter((m) => h?.type === "global" ? (m.paths ?? []).some(rt) : h?.type === "resource" ? (m.paths ?? []).some((G) => St(G, h.path, h.method)) : !1).map((m) => `${m.name}@${m.version}`), existingSettings: s?.params, editPolicyKey: s ? `${s.guardrailName}@${s.guardrailVersion}` : void 0, title: s ? "Edit Guardrail" : "Guardrails", subtitle: s ? "Update the guardrail configuration." : "Choose a guardrail to configure advanced options.", minWidth: 600, maxWidth: 600 })
1090
+ ] });
1091
+ }
1092
+ function Bn(t, e) {
1093
+ const r = t.startsWith("http") ? t : `https://${t}`, o = e.startsWith("/") ? e : `/${e}`;
1094
+ return `${r.replace(/\/$/, "")}${o}`;
1095
+ }
1096
+ function Vn({
1097
+ providerData: t,
1098
+ openapiSpecUrl: e,
1099
+ orgName: r,
1100
+ providerId: o,
1101
+ isLoading: i = !1,
1102
+ error: l = null,
1103
+ onUpdate: c,
1104
+ isUpdating: y
1105
+ }) {
1106
+ const d = kt(), [u, L] = N(!1), [v, P] = N(null), S = t?.openapi?.trim() ?? e ?? "", [I, p] = N(S), [h, b] = N(null), s = Ke(!1);
1107
+ oe(() => {
1108
+ const q = (t?.openapi?.trim() ?? e ?? "").trim();
1109
+ I.trim() === q ? p(t?.openapi?.trim() ?? e ?? "") : !s.current && q && (p(t?.openapi?.trim() ?? e ?? ""), s.current = !0);
1110
+ }, [t?.openapi, e]);
1111
+ const f = H(async () => {
1112
+ b(null);
1113
+ try {
1114
+ await c({
1115
+ openapi: I.trim() || void 0
1116
+ });
1117
+ } catch (q) {
1118
+ b(q instanceof Error ? q.message : "Failed to save OpenAPI spec");
1119
+ }
1120
+ }, [I, c]), M = I.trim() !== (t?.openapi?.trim() ?? e ?? "").trim(), w = Q(() => {
1121
+ const q = I.trim();
1122
+ if (!q) return null;
1123
+ if (q.startsWith("http://") || q.startsWith("https://"))
1124
+ return {
1125
+ type: "url",
1126
+ value: q
1127
+ };
1128
+ const V = He(q);
1129
+ return V ? {
1130
+ type: "spec",
1131
+ value: V
1132
+ } : null;
1133
+ }, [I]), {
1134
+ data: x
1135
+ } = dn({
1136
+ orgName: r ?? "",
1137
+ providerId: o ?? ""
1138
+ }, {
1139
+ status: "DEPLOYED"
1140
+ }), {
1141
+ data: U
1142
+ } = zt({
1143
+ orgName: r ?? ""
1144
+ }, {
1145
+ limit: 500
1146
+ }), _ = Q(() => {
1147
+ if (!t?.context || !r || !o) return [];
1148
+ const q = Array.isArray(x) ? x : [], V = U?.gateways ?? [], X = new Set(q.map((J) => J.gatewayId).filter(Boolean));
1149
+ return V.filter((J) => X.has(J.uuid)).map((J) => ({
1150
+ gatewayId: J.uuid,
1151
+ url: Bn(J.vhost, t.context),
1152
+ displayName: J.displayName,
1153
+ name: J.name,
1154
+ environment: J.environments?.[0]
1155
+ }));
1156
+ }, [t?.context, x, U, r, o]), [K, C] = N(null), [g, F] = N(null), W = Nt(), A = un(), T = H((q) => {
1157
+ if (q && typeof q == "object") {
1158
+ if ((q.status ?? q.statusCode) === 409) return !0;
1159
+ const X = String(q.message ?? q.error ?? "").toLowerCase();
1160
+ if (X.includes("already exists") || X.includes("key exists") || X.includes("conflict"))
1161
+ return !0;
1162
+ }
1163
+ return !1;
1164
+ }, []), Y = H(async () => {
1165
+ if (!r || !o || _.length === 0) return;
1166
+ F(null), C(null);
1167
+ const q = Math.random().toString(36).slice(2, 10), V = `provider-${t?.id ?? "unknown"}-${q}`;
1168
+ try {
1169
+ const X = await W.mutateAsync({
1170
+ params: {
1171
+ orgName: r,
1172
+ providerId: o
1173
+ },
1174
+ body: {
1175
+ name: V,
1176
+ displayName: V
1177
+ }
1178
+ });
1179
+ X.apiKey && C(X.apiKey);
1180
+ } catch (X) {
1181
+ if (T(X))
1182
+ try {
1183
+ const J = await A.mutateAsync({
1184
+ params: {
1185
+ orgName: r,
1186
+ providerId: o,
1187
+ keyName: V
1188
+ },
1189
+ body: {}
1190
+ });
1191
+ J.apiKey && C(J.apiKey);
1192
+ } catch (J) {
1193
+ F(J instanceof Error ? J.message : "Failed to rotate API key");
1194
+ }
1195
+ else
1196
+ F(X instanceof Error ? X.message : "Failed to generate API key");
1197
+ }
1198
+ }, [r, o, _.length, W, A, T]), ae = H(async () => {
1199
+ const q = I.trim().startsWith("http") ? I.trim() : null;
1200
+ if (q) {
1201
+ L(!0), P(null);
1202
+ try {
1203
+ const V = await fetch(q);
1204
+ if (!V.ok)
1205
+ throw new Error(`Failed to download spec: ${V.status} ${V.statusText}`);
1206
+ const X = await V.text(), J = q.endsWith(".json") ? "json" : "yaml", he = new Blob([X], {
1207
+ type: J === "json" ? "application/json" : "text/yaml"
1208
+ }), ne = URL.createObjectURL(he), re = document.createElement("a");
1209
+ re.href = ne, re.download = `openapi-spec.${J}`, re.click(), URL.revokeObjectURL(ne);
1210
+ } catch (V) {
1211
+ P(V instanceof Error ? V.message : "Failed to download spec.");
1212
+ } finally {
1213
+ L(!1);
1214
+ }
1215
+ }
1216
+ }, [I]);
1217
+ return i ? /* @__PURE__ */ a(E, { spacing: 2, children: [
1218
+ /* @__PURE__ */ n(D, { container: !0, spacing: 2, children: [1, 2, 3, 4, 5].map((q) => /* @__PURE__ */ n(D, { size: {
1219
+ xs: 12,
1220
+ sm: 6,
1221
+ md: 4
1222
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1223
+ p: 2,
1224
+ height: "100%"
1225
+ }, children: /* @__PURE__ */ a(E, { spacing: 1, children: [
1226
+ /* @__PURE__ */ n(ee, { variant: "text", width: "40%", height: 16 }),
1227
+ /* @__PURE__ */ n(ee, { variant: "text", width: "80%", height: 20 })
1228
+ ] }) }) }, q)) }),
1229
+ /* @__PURE__ */ n($e, {}),
1230
+ /* @__PURE__ */ a(E, { spacing: 1.5, sx: {
1231
+ mt: 3
1232
+ }, children: [
1233
+ /* @__PURE__ */ n(ee, { variant: "text", width: 140, height: 20 }),
1234
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1, alignItems: "center", children: [
1235
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 40, sx: {
1236
+ flex: 1
1237
+ } }),
1238
+ /* @__PURE__ */ n(ee, { variant: "rounded", width: 120, height: 40 })
1239
+ ] }),
1240
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 400 })
1241
+ ] })
1242
+ ] }) : !t && !l ? null : l && !i ? /* @__PURE__ */ n(ce, { severity: "error", sx: {
1243
+ width: "100%"
1244
+ }, children: l instanceof Error ? l.message : "Failed to load provider." }) : t ? /* @__PURE__ */ a(E, { spacing: 3, children: [
1245
+ /* @__PURE__ */ a(D, { container: !0, spacing: 2, children: [
1246
+ t.context && /* @__PURE__ */ n(D, { size: {
1247
+ xs: 12,
1248
+ sm: 6,
1249
+ md: 4
1250
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1251
+ p: 2,
1252
+ height: "100%"
1253
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.5, children: [
1254
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", sx: {
1255
+ fontWeight: 500
1256
+ }, children: "Context" }),
1257
+ /* @__PURE__ */ n($, { variant: "body2", sx: {
1258
+ fontFamily: d.typography?.fontFamilyMonospace ?? "monospace"
1259
+ }, children: t.context })
1260
+ ] }) }) }),
1261
+ t.upstream?.main?.url && /* @__PURE__ */ n(D, { size: {
1262
+ xs: 12,
1263
+ sm: 6,
1264
+ md: 4
1265
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1266
+ p: 2,
1267
+ height: "100%"
1268
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.5, children: [
1269
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", sx: {
1270
+ fontWeight: 500
1271
+ }, children: "Upstream URL" }),
1272
+ /* @__PURE__ */ n($, { variant: "body2", sx: {
1273
+ fontFamily: d.typography?.fontFamilyMonospace ?? "monospace",
1274
+ wordBreak: "break-all"
1275
+ }, children: t.upstream.main.url })
1276
+ ] }) }) }),
1277
+ t.upstream?.main?.auth?.type && /* @__PURE__ */ n(D, { size: {
1278
+ xs: 12,
1279
+ sm: 6,
1280
+ md: 4
1281
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1282
+ p: 2,
1283
+ height: "100%"
1284
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.5, children: [
1285
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", sx: {
1286
+ fontWeight: 500
1287
+ }, children: "Auth Type" }),
1288
+ /* @__PURE__ */ n($, { variant: "body2", children: t.upstream.main.auth.type })
1289
+ ] }) }) }),
1290
+ t.accessControl?.mode && /* @__PURE__ */ n(D, { size: {
1291
+ xs: 12,
1292
+ sm: 6,
1293
+ md: 4
1294
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1295
+ p: 2,
1296
+ height: "100%"
1297
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.5, children: [
1298
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", sx: {
1299
+ fontWeight: 500
1300
+ }, children: "Access Control" }),
1301
+ /* @__PURE__ */ n(ue, { label: t.accessControl.mode, size: "small", variant: "outlined", sx: {
1302
+ width: "fit-content",
1303
+ textTransform: "capitalize"
1304
+ } })
1305
+ ] }) }) }),
1306
+ /* @__PURE__ */ n(D, { size: {
1307
+ xs: 12,
1308
+ sm: 6,
1309
+ md: 4
1310
+ }, children: /* @__PURE__ */ n(Pe, { variant: "outlined", sx: {
1311
+ p: 2,
1312
+ height: "100%"
1313
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.5, children: [
1314
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", sx: {
1315
+ fontWeight: 500
1316
+ }, children: "In Catalog" }),
1317
+ /* @__PURE__ */ n(ue, { label: t.inCatalog ? "Yes" : "No", size: "small", color: t.inCatalog ? "success" : "default", variant: "outlined", sx: {
1318
+ width: "fit-content"
1319
+ } })
1320
+ ] }) }) })
1321
+ ] }),
1322
+ r && o && /* @__PURE__ */ n(En, { endpoints: _, onGenerateApiKey: Y, isGeneratingApiKey: W.isPending || A.isPending, apiKeyError: g, generatedApiKey: K, onClearApiKeyError: () => F(null), emptyMessage: "No invoke URLs available. Deploy this provider to an AI gateway to see invoke URLs and generate API keys." }),
1323
+ /* @__PURE__ */ n($e, {}),
1324
+ /* @__PURE__ */ a(E, { spacing: 1.5, sx: {
1325
+ mt: 3
1326
+ }, children: [
1327
+ /* @__PURE__ */ n($, { variant: "subtitle2", color: "text.secondary", sx: {
1328
+ fontWeight: 600
1329
+ }, children: "OpenAPI Resources" }),
1330
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "Enter a URL and Click Save to persist changes to the provider." }),
1331
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1, alignItems: "flex-start", children: [
1332
+ /* @__PURE__ */ n(Le, { size: "small", fullWidth: !0, value: I, onChange: (q) => {
1333
+ p(q.target.value), b(null);
1334
+ }, placeholder: "https://example.com/openapi.json", sx: {
1335
+ "& .MuiInputBase-input": {
1336
+ fontFamily: d.typography?.fontFamilyMonospace ?? "monospace",
1337
+ fontSize: d.typography.body2?.fontSize
1338
+ }
1339
+ } }),
1340
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1, flexShrink: 0, children: [
1341
+ /* @__PURE__ */ n(de, { variant: "contained", size: "medium", startIcon: /* @__PURE__ */ n(Ht, { size: 16 }), onClick: f, disabled: !M || y || !r || !o, children: y ? "Saving..." : "Save" }),
1342
+ /* @__PURE__ */ n(de, { variant: "outlined", size: "medium", startIcon: /* @__PURE__ */ n(Yt, { size: 16 }), onClick: ae, disabled: u || !I.trim().startsWith("http"), children: u ? "Downloading..." : "Download" })
1343
+ ] })
1344
+ ] }),
1345
+ h && /* @__PURE__ */ n(ce, { severity: "error", onClose: () => b(null), children: h }),
1346
+ v && /* @__PURE__ */ n(ce, { severity: "error", onClose: () => P(null), children: v }),
1347
+ w ? /* @__PURE__ */ n(E, { spacing: 1, children: /* @__PURE__ */ a(je, { disableGutters: !0, children: [
1348
+ /* @__PURE__ */ n(Ue, { expandIcon: /* @__PURE__ */ n(Ve, { size: 18 }), children: /* @__PURE__ */ n($, { variant: "subtitle2", color: "text.secondary", children: "API Preview" }) }),
1349
+ /* @__PURE__ */ n(Be, { children: /* @__PURE__ */ n(Ft, { fallback: /* @__PURE__ */ a(E, { spacing: 1, sx: {
1350
+ py: 3
1351
+ }, children: [
1352
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 48 }),
1353
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 200 }),
1354
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 400 })
1355
+ ] }), children: /* @__PURE__ */ n(Ln, { ...w.type === "url" ? {
1356
+ url: w.value
1357
+ } : {
1358
+ spec: w.value
1359
+ }, docExpansion: "list", hideInfoSection: !0, hideServers: !0, hideAuthorizeButton: !0, hideOperationHeader: !0 }) }) })
1360
+ ] }) }) : /* @__PURE__ */ n(ce, { severity: "info", children: "Enter a URL or paste an OpenAPI spec above to preview it here." })
1361
+ ] })
1362
+ ] }) : null;
1363
+ }
1364
+ const Hn = [{
1365
+ value: "minute",
1366
+ label: "Minute(s)"
1367
+ }, {
1368
+ value: "hour",
1369
+ label: "Hour(s)"
1370
+ }, {
1371
+ value: "day",
1372
+ label: "Day(s)"
1373
+ }, {
1374
+ value: "week",
1375
+ label: "Week(s)"
1376
+ }, {
1377
+ value: "month",
1378
+ label: "Month(s)"
1379
+ }], It = Re({
1380
+ enabled: Rt(),
1381
+ quota: pe(),
1382
+ duration: pe(),
1383
+ unit: pe()
1384
+ }).refine((t) => {
1385
+ if (!t.enabled) return !0;
1386
+ const e = Number(t.quota);
1387
+ return !Number.isNaN(e) && e >= 1;
1388
+ }, {
1389
+ message: "Quota must be >= 1",
1390
+ path: ["quota"]
1391
+ }).refine((t) => {
1392
+ if (!t.enabled) return !0;
1393
+ const e = Number(t.duration);
1394
+ return !Number.isNaN(e) && Number.isInteger(e) && e >= 1;
1395
+ }, {
1396
+ message: "Duration must be a whole number >= 1",
1397
+ path: ["duration"]
1398
+ }), Yn = Re({
1399
+ enabled: Rt(),
1400
+ quota: pe(),
1401
+ duration: pe(),
1402
+ unit: pe()
1403
+ }).refine((t) => {
1404
+ if (!t.enabled) return !0;
1405
+ const e = Number(t.quota);
1406
+ return !Number.isNaN(e) && e > 0;
1407
+ }, {
1408
+ message: "Budget must be > 0",
1409
+ path: ["quota"]
1410
+ }).refine((t) => {
1411
+ if (!t.enabled) return !0;
1412
+ const e = Number(t.duration);
1413
+ return !Number.isNaN(e) && Number.isInteger(e) && e >= 1;
1414
+ }, {
1415
+ message: "Duration must be a whole number >= 1",
1416
+ path: ["duration"]
1417
+ }), Jn = Re({
1418
+ request: It,
1419
+ token: It,
1420
+ cost: Yn
1421
+ }), it = (t) => We(t, "-"), Ce = {
1422
+ request: {
1423
+ enabled: !1,
1424
+ quota: "",
1425
+ duration: "1",
1426
+ unit: "hour"
1427
+ },
1428
+ token: {
1429
+ enabled: !1,
1430
+ quota: "",
1431
+ duration: "1",
1432
+ unit: "hour"
1433
+ },
1434
+ cost: {
1435
+ enabled: !1,
1436
+ quota: "",
1437
+ duration: "1",
1438
+ unit: "day"
1439
+ }
1440
+ };
1441
+ function Ye(t) {
1442
+ const e = {
1443
+ ...Ce
1444
+ };
1445
+ return t && (t.request && (e.request = {
1446
+ enabled: t.request.enabled,
1447
+ quota: String(t.request.count ?? ""),
1448
+ duration: String(t.request.reset?.duration ?? 1),
1449
+ unit: t.request.reset?.unit ?? "hour"
1450
+ }), t.token && (e.token = {
1451
+ enabled: t.token.enabled,
1452
+ quota: String(t.token.count ?? ""),
1453
+ duration: String(t.token.reset?.duration ?? 1),
1454
+ unit: t.token.reset?.unit ?? "hour"
1455
+ }), t.cost && (e.cost = {
1456
+ enabled: t.cost.enabled,
1457
+ quota: String(t.cost.amount ?? ""),
1458
+ duration: String(t.cost.reset?.duration ?? 1),
1459
+ unit: t.cost.reset?.unit ?? "day"
1460
+ })), e;
1461
+ }
1462
+ function qe(t) {
1463
+ const e = Number(t);
1464
+ return Number.isFinite(e) ? e : void 0;
1465
+ }
1466
+ function Ee(t) {
1467
+ const e = {};
1468
+ if (t.request.enabled) {
1469
+ const r = qe(t.request.quota), o = qe(t.request.duration);
1470
+ r !== void 0 && o !== void 0 && (e.request = {
1471
+ enabled: !0,
1472
+ count: r,
1473
+ reset: {
1474
+ duration: o,
1475
+ unit: t.request.unit
1476
+ }
1477
+ });
1478
+ }
1479
+ if (t.token.enabled) {
1480
+ const r = qe(t.token.quota), o = qe(t.token.duration);
1481
+ r !== void 0 && o !== void 0 && (e.token = {
1482
+ enabled: !0,
1483
+ count: r,
1484
+ reset: {
1485
+ duration: o,
1486
+ unit: t.token.unit
1487
+ }
1488
+ });
1489
+ }
1490
+ if (t.cost.enabled) {
1491
+ const r = qe(t.cost.quota), o = qe(t.cost.duration);
1492
+ r !== void 0 && o !== void 0 && (e.cost = {
1493
+ enabled: !0,
1494
+ amount: r,
1495
+ reset: {
1496
+ duration: o,
1497
+ unit: t.cost.unit
1498
+ }
1499
+ });
1500
+ }
1501
+ return e;
1502
+ }
1503
+ function Qn(t) {
1504
+ const e = Jn.safeParse(t);
1505
+ if (e.success) return {};
1506
+ const r = {};
1507
+ for (const o of e.error.issues) {
1508
+ const i = o.path.join(".");
1509
+ r[i] || (r[i] = o.message);
1510
+ }
1511
+ return r;
1512
+ }
1513
+ function Oe(t) {
1514
+ return t.request.enabled && Number(t.request.quota) >= 1 || t.token.enabled && Number(t.token.quota) >= 1 || t.cost.enabled && Number(t.cost.quota) > 0;
1515
+ }
1516
+ function Xn(t) {
1517
+ return t.request.enabled || t.token.enabled || t.cost.enabled;
1518
+ }
1519
+ function st(t) {
1520
+ const e = Se(77), {
1521
+ label: r,
1522
+ quotaLabel: o,
1523
+ quotaPlaceholder: i,
1524
+ quotaMin: l,
1525
+ quotaStep: c,
1526
+ criterionKey: y,
1527
+ value: d,
1528
+ onChange: u,
1529
+ disabled: L,
1530
+ fieldErrors: v
1531
+ } = t, P = L === void 0 ? !1 : L, [S, I] = N(d.enabled);
1532
+ let p, h;
1533
+ e[0] !== d.enabled ? (p = () => {
1534
+ I(d.enabled);
1535
+ }, h = [d.enabled], e[0] = d.enabled, e[1] = p, e[2] = h) : (p = e[1], h = e[2]), oe(p, h);
1536
+ const b = `${y}.quota`, s = `${y}.duration`, f = P ? 0.6 : 1;
1537
+ let M;
1538
+ e[3] !== f ? (M = {
1539
+ borderRadius: 2,
1540
+ overflow: "hidden",
1541
+ opacity: f
1542
+ }, e[3] = f, e[4] = M) : M = e[4];
1543
+ let w;
1544
+ e[5] === Symbol.for("react.memo_cache_sentinel") ? (w = (we, et) => I(et), e[5] = w) : w = e[5];
1545
+ let x;
1546
+ e[6] === Symbol.for("react.memo_cache_sentinel") ? (x = {
1547
+ background: "transparent",
1548
+ "&:before": {
1549
+ display: "none"
1550
+ }
1551
+ }, e[6] = x) : x = e[6];
1552
+ let U, _;
1553
+ e[7] === Symbol.for("react.memo_cache_sentinel") ? (U = /* @__PURE__ */ n(Ve, { size: 18 }), _ = {
1554
+ px: 2,
1555
+ py: 1
1556
+ }, e[7] = U, e[8] = _) : (U = e[7], _ = e[8]);
1557
+ let K;
1558
+ e[9] !== r ? (K = /* @__PURE__ */ n($, { variant: "subtitle2", children: r }), e[9] = r, e[10] = K) : K = e[10];
1559
+ let C;
1560
+ e[11] !== d.enabled ? (C = d.enabled && /* @__PURE__ */ n(ue, { label: "Enabled", size: "small", color: "primary", variant: "outlined", sx: {
1561
+ height: 20,
1562
+ fontSize: "0.7rem"
1563
+ } }), e[11] = d.enabled, e[12] = C) : C = e[12];
1564
+ let g;
1565
+ e[13] !== K || e[14] !== C ? (g = /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", spacing: 1, children: [
1566
+ K,
1567
+ C
1568
+ ] }), e[13] = K, e[14] = C, e[15] = g) : g = e[15];
1569
+ let F;
1570
+ e[16] !== u ? (F = (we, et) => u({
1571
+ enabled: et
1572
+ }), e[16] = u, e[17] = F) : F = e[17];
1573
+ let W;
1574
+ e[18] !== P || e[19] !== F || e[20] !== d.enabled ? (W = /* @__PURE__ */ n(_t, { size: "small", checked: d.enabled, onChange: F, disabled: P, onClick: Dn }), e[18] = P, e[19] = F, e[20] = d.enabled, e[21] = W) : W = e[21];
1575
+ let A;
1576
+ e[22] !== g || e[23] !== W ? (A = /* @__PURE__ */ n(Ue, { expandIcon: U, sx: _, children: /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", justifyContent: "space-between", width: "100%", pr: 1, children: [
1577
+ g,
1578
+ W
1579
+ ] }) }), e[22] = g, e[23] = W, e[24] = A) : A = e[24];
1580
+ let T;
1581
+ e[25] === Symbol.for("react.memo_cache_sentinel") ? (T = {
1582
+ px: 2,
1583
+ pb: 2,
1584
+ pt: 0
1585
+ }, e[25] = T) : T = e[25];
1586
+ let Y;
1587
+ e[26] === Symbol.for("react.memo_cache_sentinel") ? (Y = {
1588
+ xs: 12,
1589
+ sm: 4
1590
+ }, e[26] = Y) : Y = e[26];
1591
+ let ae;
1592
+ e[27] !== o ? (ae = /* @__PURE__ */ n(ve, { children: o }), e[27] = o, e[28] = ae) : ae = e[28];
1593
+ let q;
1594
+ e[29] !== y || e[30] !== u ? (q = (we) => u({
1595
+ quota: y === "cost" ? we.target.value : we.target.value === "" ? "" : String(Math.trunc(Number(we.target.value)))
1596
+ }), e[29] = y, e[30] = u, e[31] = q) : q = e[31];
1597
+ const V = P || !d.enabled, X = !!v?.[b], J = v?.[b];
1598
+ let he;
1599
+ e[32] !== l || e[33] !== c ? (he = {
1600
+ input: {
1601
+ inputProps: {
1602
+ min: l,
1603
+ step: c
1604
+ }
1605
+ }
1606
+ }, e[32] = l, e[33] = c, e[34] = he) : he = e[34];
1607
+ let ne;
1608
+ e[35] !== i || e[36] !== q || e[37] !== V || e[38] !== X || e[39] !== J || e[40] !== he || e[41] !== d.quota ? (ne = /* @__PURE__ */ n(Le, { size: "small", type: "number", placeholder: i, value: d.quota, onChange: q, disabled: V, error: X, helperText: J, slotProps: he }), e[35] = i, e[36] = q, e[37] = V, e[38] = X, e[39] = J, e[40] = he, e[41] = d.quota, e[42] = ne) : ne = e[42];
1609
+ let re;
1610
+ e[43] !== ae || e[44] !== ne ? (re = /* @__PURE__ */ n(D, { size: Y, children: /* @__PURE__ */ a(ge, { fullWidth: !0, size: "small", children: [
1611
+ ae,
1612
+ ne
1613
+ ] }) }), e[43] = ae, e[44] = ne, e[45] = re) : re = e[45];
1614
+ let xe;
1615
+ e[46] === Symbol.for("react.memo_cache_sentinel") ? (xe = {
1616
+ xs: 12,
1617
+ sm: 4
1618
+ }, e[46] = xe) : xe = e[46];
1619
+ let le;
1620
+ e[47] === Symbol.for("react.memo_cache_sentinel") ? (le = /* @__PURE__ */ n(ve, { children: "Duration" }), e[47] = le) : le = e[47];
1621
+ let te;
1622
+ e[48] !== u ? (te = (we) => u({
1623
+ duration: we.target.value
1624
+ }), e[48] = u, e[49] = te) : te = e[49];
1625
+ const fe = P || !d.enabled, be = !!v?.[s], me = v?.[s];
1626
+ let Ie;
1627
+ e[50] === Symbol.for("react.memo_cache_sentinel") ? (Ie = {
1628
+ input: {
1629
+ inputProps: {
1630
+ min: 1,
1631
+ step: 1
1632
+ }
1633
+ }
1634
+ }, e[50] = Ie) : Ie = e[50];
1635
+ let m;
1636
+ e[51] !== te || e[52] !== fe || e[53] !== be || e[54] !== me || e[55] !== d.duration ? (m = /* @__PURE__ */ n(D, { size: xe, children: /* @__PURE__ */ a(ge, { fullWidth: !0, size: "small", children: [
1637
+ le,
1638
+ /* @__PURE__ */ n(Le, { size: "small", type: "number", placeholder: "e.g. 1", value: d.duration, onChange: te, disabled: fe, error: be, helperText: me, slotProps: Ie })
1639
+ ] }) }), e[51] = te, e[52] = fe, e[53] = be, e[54] = me, e[55] = d.duration, e[56] = m) : m = e[56];
1640
+ let G;
1641
+ e[57] === Symbol.for("react.memo_cache_sentinel") ? (G = {
1642
+ xs: 12,
1643
+ sm: 4
1644
+ }, e[57] = G) : G = e[57];
1645
+ let k;
1646
+ e[58] === Symbol.for("react.memo_cache_sentinel") ? (k = /* @__PURE__ */ n(ve, { children: "Unit" }), e[58] = k) : k = e[58];
1647
+ const z = d.unit;
1648
+ let R;
1649
+ e[59] !== u ? (R = (we) => u({
1650
+ unit: we.target.value
1651
+ }), e[59] = u, e[60] = R) : R = e[60];
1652
+ const O = P || !d.enabled;
1653
+ let j;
1654
+ e[61] === Symbol.for("react.memo_cache_sentinel") ? (j = Hn.map(Zn), e[61] = j) : j = e[61];
1655
+ let Z;
1656
+ e[62] !== R || e[63] !== O || e[64] !== d.unit ? (Z = /* @__PURE__ */ n(D, { size: G, children: /* @__PURE__ */ a(ge, { fullWidth: !0, size: "small", children: [
1657
+ k,
1658
+ /* @__PURE__ */ n(Xe, { size: "small", value: z, onChange: R, disabled: O, children: j })
1659
+ ] }) }), e[62] = R, e[63] = O, e[64] = d.unit, e[65] = Z) : Z = e[65];
1660
+ let ie;
1661
+ e[66] !== re || e[67] !== m || e[68] !== Z ? (ie = /* @__PURE__ */ n(Be, { sx: T, children: /* @__PURE__ */ a(D, { container: !0, spacing: 2, children: [
1662
+ re,
1663
+ m,
1664
+ Z
1665
+ ] }) }), e[66] = re, e[67] = m, e[68] = Z, e[69] = ie) : ie = e[69];
1666
+ let ye;
1667
+ e[70] !== S || e[71] !== A || e[72] !== ie ? (ye = /* @__PURE__ */ a(je, { expanded: S, onChange: w, disableGutters: !0, elevation: 0, sx: x, children: [
1668
+ A,
1669
+ ie
1670
+ ] }), e[70] = S, e[71] = A, e[72] = ie, e[73] = ye) : ye = e[73];
1671
+ let ke;
1672
+ return e[74] !== ye || e[75] !== M ? (ke = /* @__PURE__ */ n(lt, { variant: "outlined", sx: M, children: ye }), e[74] = ye, e[75] = M, e[76] = ke) : ke = e[76], ke;
1673
+ }
1674
+ function Zn(t) {
1675
+ return /* @__PURE__ */ n(_e, { value: t.value, children: t.label }, t.value);
1676
+ }
1677
+ function Dn(t) {
1678
+ return t.stopPropagation();
1679
+ }
1680
+ function Je(t) {
1681
+ const e = Se(27), {
1682
+ criteria: r,
1683
+ onChange: o,
1684
+ disabled: i,
1685
+ showCost: l,
1686
+ fieldErrors: c
1687
+ } = t, y = i === void 0 ? !1 : i, d = l === void 0 ? !0 : l;
1688
+ let u;
1689
+ e[0] !== r || e[1] !== o ? (u = (b, s) => {
1690
+ o({
1691
+ ...r,
1692
+ [b]: {
1693
+ ...r[b],
1694
+ ...s
1695
+ }
1696
+ });
1697
+ }, e[0] = r, e[1] = o, e[2] = u) : u = e[2];
1698
+ const L = u;
1699
+ let v;
1700
+ e[3] !== L ? (v = (b) => L("request", b), e[3] = L, e[4] = v) : v = e[4];
1701
+ let P;
1702
+ e[5] !== r.request || e[6] !== y || e[7] !== c || e[8] !== v ? (P = /* @__PURE__ */ n(st, { label: "Request Counts", quotaLabel: "Quota (requests)", quotaPlaceholder: "e.g. 1000", quotaMin: 1, quotaStep: 1, criterionKey: "request", value: r.request, onChange: v, disabled: y, fieldErrors: c }), e[5] = r.request, e[6] = y, e[7] = c, e[8] = v, e[9] = P) : P = e[9];
1703
+ let S;
1704
+ e[10] !== L ? (S = (b) => L("token", b), e[10] = L, e[11] = S) : S = e[11];
1705
+ let I;
1706
+ e[12] !== r.token || e[13] !== y || e[14] !== c || e[15] !== S ? (I = /* @__PURE__ */ n(st, { label: "Token Count", quotaLabel: "Quota (tokens)", quotaPlaceholder: "e.g. 500000", quotaMin: 1, quotaStep: 1, criterionKey: "token", value: r.token, onChange: S, disabled: y, fieldErrors: c }), e[12] = r.token, e[13] = y, e[14] = c, e[15] = S, e[16] = I) : I = e[16];
1707
+ let p;
1708
+ e[17] !== r.cost || e[18] !== y || e[19] !== c || e[20] !== d || e[21] !== L ? (p = d && /* @__PURE__ */ n(st, { label: "Cost", quotaLabel: "Budget (USD)", quotaPlaceholder: "e.g. 10.00", quotaMin: 1e-6, quotaStep: 1e-6, criterionKey: "cost", value: r.cost, onChange: (b) => L("cost", b), disabled: y, fieldErrors: c }), e[17] = r.cost, e[18] = y, e[19] = c, e[20] = d, e[21] = L, e[22] = p) : p = e[22];
1709
+ let h;
1710
+ return e[23] !== P || e[24] !== I || e[25] !== p ? (h = /* @__PURE__ */ a(E, { spacing: 1.5, children: [
1711
+ P,
1712
+ I,
1713
+ p
1714
+ ] }), e[23] = P, e[24] = I, e[25] = p, e[26] = h) : h = e[26], h;
1715
+ }
1716
+ function er({
1717
+ providerData: t,
1718
+ openapiSpecUrl: e,
1719
+ isLoading: r = !1,
1720
+ onUpdate: o,
1721
+ isUpdating: i
1722
+ }) {
1723
+ const [l, c] = Zt(), [y, d] = N(0), [u, L] = N(null), v = t?.openapi?.trim() ?? "", {
1724
+ text: P,
1725
+ isLoading: S,
1726
+ error: I
1727
+ } = pt(e, v);
1728
+ oe(() => {
1729
+ I && L({
1730
+ message: "Failed to load OpenAPI spec.",
1731
+ severity: "error"
1732
+ });
1733
+ }, [I]);
1734
+ const p = Q(() => {
1735
+ if (!P.trim()) return [];
1736
+ const k = He(P);
1737
+ return k ? ft(k) : [];
1738
+ }, [P]), h = l.get("mode"), b = h === "global" || h === "resourceWise" ? h : "global", [s, f] = N(b), [M, w] = N(Ce), [x, U] = N(Ce), [_, K] = N({}), [C, g] = N(""), [F, W] = N(/* @__PURE__ */ new Set()), [A, T] = N({}), [Y, ae] = N(Ce), q = Q(() => Oe(M), [M]), V = Q(() => Oe(x) ? !0 : Object.values(_).some(Oe), [x, _]), X = Ke(null), [J, he] = N(0), ne = H(() => {
1739
+ const k = Ee(M), z = Ee(x), R = Object.entries(_).filter(([, O]) => Oe(O)).map(([O, j]) => ({
1740
+ resource: O,
1741
+ limit: Ee(j)
1742
+ })).sort((O, j) => O.resource.localeCompare(j.resource));
1743
+ return JSON.stringify({
1744
+ global: k,
1745
+ resourceWise: {
1746
+ default: z,
1747
+ resources: R
1748
+ },
1749
+ consumerGlobal: Ee(Y)
1750
+ });
1751
+ }, [M, x, _, Y]), re = H(() => {
1752
+ if (!t) return;
1753
+ const k = l.get("mode"), z = t.rateLimiting?.providerLevel;
1754
+ let R = "global";
1755
+ if (z?.resourceWise) {
1756
+ R = "resourceWise", f("resourceWise"), w(Ce), U(Ye(z.resourceWise.default));
1757
+ const j = {};
1758
+ for (const Z of z.resourceWise.resources ?? [])
1759
+ j[Z.resource] = Ye(Z.limit);
1760
+ K(j);
1761
+ } else z?.global ? (R = "global", f("global"), w(Ye(z.global)), U(Ce), K({})) : (f("global"), w(Ce), U(Ce), K({}));
1762
+ k || c((j) => {
1763
+ const Z = new URLSearchParams(j);
1764
+ return Z.set("mode", R), Z;
1765
+ }, {
1766
+ replace: !0
1767
+ });
1768
+ const O = t.rateLimiting?.consumerLevel;
1769
+ O?.global ? ae(Ye(O.global)) : ae(Ce), he(Date.now());
1770
+ }, [t, l, c]);
1771
+ oe(() => {
1772
+ re();
1773
+ }, [re]), oe(() => {
1774
+ const k = l.get("mode");
1775
+ (k === "global" || k === "resourceWise") && f(k);
1776
+ }, [l]);
1777
+ const xe = Ke("");
1778
+ xe.current = ne(), oe(() => {
1779
+ J > 0 && t && (X.current = xe.current);
1780
+ }, [J, t]);
1781
+ const le = Q(() => !t || X.current === null ? !1 : ne() !== X.current, [t, ne]), te = Q(() => {
1782
+ if (!C.trim()) return p;
1783
+ const k = C.toLowerCase();
1784
+ return p.filter((z) => it(z).toLowerCase().includes(k) || z.path.toLowerCase().includes(k) || (z.summary ?? "").toLowerCase().includes(k));
1785
+ }, [p, C]), fe = 10, [be, me] = N(0);
1786
+ oe(() => {
1787
+ me(0);
1788
+ }, [te]);
1789
+ const Ie = Q(() => te.slice(be * fe, (be + 1) * fe), [te, be]), m = H(async () => {
1790
+ if (!t || r) return;
1791
+ if (s === "global" && V) {
1792
+ L({
1793
+ message: "Provider Level cannot have both Provider-wide and Per Resource values. Remove one side and try again.",
1794
+ severity: "error"
1795
+ });
1796
+ return;
1797
+ }
1798
+ if (s === "resourceWise" && q) {
1799
+ L({
1800
+ message: "Provider Level cannot have both Provider-wide and Per Resource values. Remove one side and try again.",
1801
+ severity: "error"
1802
+ });
1803
+ return;
1804
+ }
1805
+ const k = [];
1806
+ s === "global" ? k.push({
1807
+ c: M,
1808
+ blockKey: "global"
1809
+ }) : (k.push({
1810
+ c: x,
1811
+ blockKey: "resourceWise-default"
1812
+ }), Object.entries(_).forEach(([R, O]) => {
1813
+ Xn(O) && k.push({
1814
+ c: O,
1815
+ blockKey: `resourceWise-${R}`
1816
+ });
1817
+ })), k.push({
1818
+ c: Y,
1819
+ blockKey: "consumer-global"
1820
+ });
1821
+ for (const {
1822
+ c: R,
1823
+ blockKey: O
1824
+ } of k) {
1825
+ const j = Qn(R);
1826
+ if (Object.keys(j).length > 0) {
1827
+ if (T({
1828
+ [O]: j
1829
+ }), O === "consumer-global")
1830
+ d(1);
1831
+ else if (d(0), O.startsWith("resourceWise-") && O !== "resourceWise-default") {
1832
+ const Z = O.replace("resourceWise-", "");
1833
+ W((ye) => new Set(ye).add(Z));
1834
+ const ie = te.findIndex((ye) => it(ye) === Z);
1835
+ ie >= 0 && me(Math.floor(ie / fe));
1836
+ }
1837
+ return;
1838
+ }
1839
+ }
1840
+ T({});
1841
+ const z = () => {
1842
+ if (s === "global")
1843
+ return {
1844
+ global: Ee(M),
1845
+ resourceWise: void 0
1846
+ };
1847
+ const R = Object.entries(_).filter(([, O]) => Oe(O)).map(([O, j]) => ({
1848
+ resource: O,
1849
+ limit: Ee(j)
1850
+ }));
1851
+ return {
1852
+ global: void 0,
1853
+ resourceWise: {
1854
+ default: Ee(x),
1855
+ resources: R
1856
+ }
1857
+ };
1858
+ };
1859
+ try {
1860
+ await o({
1861
+ rateLimiting: {
1862
+ providerLevel: z(),
1863
+ consumerLevel: {
1864
+ global: Ee(Y),
1865
+ resourceWise: void 0
1866
+ }
1867
+ }
1868
+ }), L({
1869
+ message: "Rate limits updated successfully.",
1870
+ severity: "success"
1871
+ }), T({}), X.current = ne();
1872
+ } catch {
1873
+ L({
1874
+ message: "Failed to update rate limits.",
1875
+ severity: "error"
1876
+ });
1877
+ }
1878
+ }, [t, r, s, M, x, _, q, V, Y, o, ne, te]), G = H(() => {
1879
+ re(), L(null), T({});
1880
+ }, [re]);
1881
+ return r ? /* @__PURE__ */ a(E, { spacing: 3, children: [
1882
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 48 }),
1883
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 120 }),
1884
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 120 })
1885
+ ] }) : t ? /* @__PURE__ */ a(E, { spacing: 3, children: [
1886
+ /* @__PURE__ */ n(se, { sx: {
1887
+ borderBottom: 1,
1888
+ borderColor: "divider"
1889
+ }, children: /* @__PURE__ */ a(Mt, { value: y, onChange: (k, z) => d(z), children: [
1890
+ /* @__PURE__ */ n(at, { label: "Provider Level" }),
1891
+ /* @__PURE__ */ n(at, { label: "Consumer Level" })
1892
+ ] }) }),
1893
+ y === 0 && /* @__PURE__ */ a(E, { spacing: 2, children: [
1894
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "Aggregate limits enforced on the upstream LLM provider across all consumers." }),
1895
+ /* @__PURE__ */ a(ge, { children: [
1896
+ /* @__PURE__ */ n(ve, { sx: {
1897
+ mb: 1
1898
+ }, children: "Mode" }),
1899
+ /* @__PURE__ */ a(Wt, { value: s, exclusive: !0, color: "primary", onChange: (k, z) => {
1900
+ z && (f(z), c((R) => {
1901
+ const O = new URLSearchParams(R);
1902
+ return O.set("mode", z), O;
1903
+ }, {
1904
+ replace: !0
1905
+ }));
1906
+ }, size: "small", children: [
1907
+ /* @__PURE__ */ n(Ge, { title: s === "resourceWise" && (V || le) ? "Remove Per Resource values first to switch to Provider-wide." : "", children: /* @__PURE__ */ n(se, { component: "span", children: /* @__PURE__ */ n(yt, { value: "global", sx: {
1908
+ textTransform: "none"
1909
+ }, disabled: le || s === "resourceWise" && V, children: "Provider-wide" }) }) }),
1910
+ /* @__PURE__ */ n(Ge, { title: s === "global" && (q || le) ? "Remove Provider-wide values first to switch to Per Resource." : "", children: /* @__PURE__ */ n(se, { component: "span", children: /* @__PURE__ */ n(yt, { value: "resourceWise", sx: {
1911
+ textTransform: "none"
1912
+ }, disabled: le || s === "global" && q, children: "Per Resource" }) }) })
1913
+ ] })
1914
+ ] }),
1915
+ s === "global" && /* @__PURE__ */ n(Je, { criteria: M, onChange: w, fieldErrors: A.global }),
1916
+ s === "resourceWise" && /* @__PURE__ */ a(E, { spacing: 2, children: [
1917
+ /* @__PURE__ */ n(lt, { variant: "outlined", sx: {
1918
+ borderRadius: 2
1919
+ }, children: /* @__PURE__ */ a(je, { defaultExpanded: !0, disableGutters: !0, elevation: 0, sx: {
1920
+ background: "transparent",
1921
+ "&:before": {
1922
+ display: "none"
1923
+ }
1924
+ }, children: [
1925
+ /* @__PURE__ */ n(Ue, { expandIcon: /* @__PURE__ */ n(Ve, { size: 18 }), sx: {
1926
+ px: 2
1927
+ }, children: /* @__PURE__ */ a(E, { spacing: 0.25, children: [
1928
+ /* @__PURE__ */ n($, { variant: "subtitle2", children: "Default Resource Limit" }),
1929
+ /* @__PURE__ */ n($, { variant: "caption", color: "text.secondary", children: "Applied to any resource that has no specific override below." })
1930
+ ] }) }),
1931
+ /* @__PURE__ */ n(Be, { sx: {
1932
+ px: 2,
1933
+ pb: 2
1934
+ }, children: /* @__PURE__ */ n(Je, { criteria: x, onChange: U, fieldErrors: A["resourceWise-default"] }) })
1935
+ ] }) }),
1936
+ /* @__PURE__ */ n(At, { placeholder: "Search resources…", value: C, onChange: (k) => g(k.target.value) }),
1937
+ S ? /* @__PURE__ */ a(se, { sx: {
1938
+ display: "flex",
1939
+ alignItems: "center",
1940
+ gap: 1,
1941
+ py: 2
1942
+ }, children: [
1943
+ /* @__PURE__ */ n(Et, { size: 16 }),
1944
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "Loading OpenAPI spec…" })
1945
+ ] }) : te.length === 0 ? /* @__PURE__ */ n(B.Container, { children: /* @__PURE__ */ n(B.EmptyState, { illustration: C.trim() ? /* @__PURE__ */ n(Kt, { size: 64 }) : /* @__PURE__ */ n(Jt, { size: 64 }), title: C.trim() ? "No resources match your search" : "No resources found", description: C.trim() ? "Try a different keyword or clear the search filter." : "No resources are available from the OpenAPI spec. Add an OpenAPI specification to define resources." }) }) : /* @__PURE__ */ a(E, { spacing: 1, children: [
1946
+ Ie.map((k) => {
1947
+ const z = it(k), R = F.has(z), O = _[z] ?? Ce, j = Oe(O);
1948
+ return /* @__PURE__ */ n(lt, { variant: "outlined", sx: {
1949
+ borderRadius: 2,
1950
+ overflow: "hidden"
1951
+ }, children: /* @__PURE__ */ a(je, { expanded: R, onChange: (Z, ie) => W((ye) => {
1952
+ const ke = new Set(ye);
1953
+ return ie ? ke.add(z) : ke.delete(z), ke;
1954
+ }), disableGutters: !0, elevation: 0, sx: {
1955
+ background: "transparent",
1956
+ "&:before": {
1957
+ display: "none"
1958
+ }
1959
+ }, children: [
1960
+ /* @__PURE__ */ n(Ue, { expandIcon: /* @__PURE__ */ n(Ve, { size: 16 }), sx: {
1961
+ px: 2
1962
+ }, children: /* @__PURE__ */ a(E, { direction: "row", alignItems: "center", spacing: 1, children: [
1963
+ /* @__PURE__ */ n(ue, { label: k.method, size: "small", variant: "outlined", color: Tt(k.method), sx: {
1964
+ minWidth: 72,
1965
+ justifyContent: "center"
1966
+ } }),
1967
+ /* @__PURE__ */ n($, { variant: "body2", children: k.path }),
1968
+ j && /* @__PURE__ */ n(ue, { label: "Custom", size: "small", color: "primary", sx: {
1969
+ height: 18,
1970
+ fontSize: "0.65rem"
1971
+ } })
1972
+ ] }) }),
1973
+ R && /* @__PURE__ */ n(Be, { sx: {
1974
+ px: 2,
1975
+ pb: 2
1976
+ }, children: /* @__PURE__ */ n(Je, { criteria: O, onChange: (Z) => K((ie) => ({
1977
+ ...ie,
1978
+ [z]: Z
1979
+ })), fieldErrors: A[`resourceWise-${z}`] }) })
1980
+ ] }) }, z);
1981
+ }),
1982
+ te.length > fe && /* @__PURE__ */ n(ct, { component: "div", count: te.length, page: be, rowsPerPage: fe, rowsPerPageOptions: [fe], onPageChange: (k, z) => me(z) })
1983
+ ] })
1984
+ ] })
1985
+ ] }),
1986
+ y === 1 && /* @__PURE__ */ a(E, { spacing: 2, children: [
1987
+ /* @__PURE__ */ n($, { variant: "body2", color: "text.secondary", children: "Limits applied per agent (consumer). Each connected agent gets its own independent quota — enabling a criterion here prevents any single agent from exhausting the shared provider limit." }),
1988
+ /* @__PURE__ */ n(Je, { criteria: Y, onChange: ae, fieldErrors: A["consumer-global"] })
1989
+ ] }),
1990
+ /* @__PURE__ */ a(E, { spacing: 1.5, width: "100%", children: [
1991
+ /* @__PURE__ */ n(Ze, { in: !!u && (u.severity === "error" || !le), timeout: 300, children: u && /* @__PURE__ */ n(ce, { severity: u.severity, onClose: () => L(null), sx: {
1992
+ width: "100%"
1993
+ }, children: u.message }) }),
1994
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1.5, justifyContent: "flex-end", children: [
1995
+ /* @__PURE__ */ n(de, { variant: "outlined", onClick: G, disabled: !le || i, children: "Discard" }),
1996
+ /* @__PURE__ */ n(de, { variant: "contained", onClick: () => void m(), disabled: !le || i, children: i ? "Saving..." : "Save" })
1997
+ ] })
1998
+ ] })
1999
+ ] }) : null;
2000
+ }
2001
+ const tr = [{
2002
+ value: "header",
2003
+ label: "header"
2004
+ }, {
2005
+ value: "query",
2006
+ label: "query"
2007
+ }], nr = Re({
2008
+ authenticationType: Ct(["apiKey", ""]),
2009
+ keyValue: pe(),
2010
+ keyIn: Ct(["header", "query"])
2011
+ }).refine((t) => t.authenticationType === "apiKey" ? t.keyValue.trim().length > 0 : !0, {
2012
+ message: "API Key is required when using API Key authentication",
2013
+ path: ["keyValue"]
2014
+ });
2015
+ function rr({
2016
+ providerData: t,
2017
+ isLoading: e = !1,
2018
+ onUpdate: r,
2019
+ isUpdating: o
2020
+ }) {
2021
+ const [i, l] = N("apiKey"), [c, y] = N(""), [d, u] = N("header"), [L, v] = N(null), [P, S] = N({}), I = Q(() => {
2022
+ if (!t) return !1;
2023
+ const s = t.security?.apiKey, M = !!s && s.enabled !== !1 && !!(s.key ?? "").trim() ? "apiKey" : "", w = t.security?.apiKey?.key ?? "", x = t.security?.apiKey?.in ?? "header";
2024
+ return i !== M || c.trim() !== w || d !== x;
2025
+ }, [t, i, c, d]);
2026
+ oe(() => {
2027
+ if (!t) return;
2028
+ const s = t.security?.apiKey, f = !!s && s.enabled !== !1 && !!(s.key ?? "").trim();
2029
+ l(f ? "apiKey" : ""), y(t.security?.apiKey?.key ?? ""), u(t.security?.apiKey?.in ?? "header"), S({});
2030
+ }, [t]);
2031
+ const p = H(() => {
2032
+ if (!t) return;
2033
+ const s = t.security?.apiKey, f = !!s && s.enabled !== !1 && !!(s.key ?? "").trim();
2034
+ l(f ? "apiKey" : ""), y(t.security?.apiKey?.key ?? ""), u(t.security?.apiKey?.in ?? "header"), S({}), v(null);
2035
+ }, [t]), h = H(async () => {
2036
+ if (!t) return;
2037
+ const s = nr.safeParse({
2038
+ authenticationType: i || "",
2039
+ keyValue: c,
2040
+ keyIn: d
2041
+ });
2042
+ if (!s.success) {
2043
+ const w = s.error.flatten(), x = w.formErrors[0];
2044
+ S({
2045
+ keyValue: w.fieldErrors.keyValue?.[0]
2046
+ }), v({
2047
+ message: x ?? "Validation failed.",
2048
+ severity: "error"
2049
+ });
2050
+ return;
2051
+ }
2052
+ S({});
2053
+ const f = s.data.keyValue.trim(), M = s.data.keyIn;
2054
+ try {
2055
+ await r({
2056
+ security: {
2057
+ enabled: t.security?.enabled ?? !0,
2058
+ apiKey: {
2059
+ enabled: i === "apiKey",
2060
+ key: i === "apiKey" ? f : "",
2061
+ in: M
2062
+ }
2063
+ }
2064
+ }), S({}), v({
2065
+ message: "Updated security settings.",
2066
+ severity: "success"
2067
+ });
2068
+ } catch {
2069
+ v({
2070
+ message: "Failed to update security.",
2071
+ severity: "error"
2072
+ });
2073
+ }
2074
+ }, [t, i, c, d, r]), b = e || !t;
2075
+ return e ? /* @__PURE__ */ a(E, { spacing: 2, children: [
2076
+ /* @__PURE__ */ n($, { variant: "h6", children: "Authentication" }),
2077
+ /* @__PURE__ */ n(E, { spacing: 2, children: [1, 2, 3].map((s) => /* @__PURE__ */ a(E, { spacing: 0.5, children: [
2078
+ /* @__PURE__ */ n(ee, { variant: "text", width: 120, height: 16 }),
2079
+ /* @__PURE__ */ n(ee, { variant: "rounded", height: 40 })
2080
+ ] }, s)) })
2081
+ ] }) : t ? /* @__PURE__ */ a(E, { spacing: 2, children: [
2082
+ /* @__PURE__ */ n($, { variant: "h6", children: "Authentication" }),
2083
+ /* @__PURE__ */ n(D, { container: !0, spacing: 3, children: /* @__PURE__ */ n(D, { size: {
2084
+ xs: 12,
2085
+ md: 5
2086
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, disabled: b, children: [
2087
+ /* @__PURE__ */ n(ve, { children: "Method" }),
2088
+ /* @__PURE__ */ a(Xe, { size: "small", value: i || "", onChange: (s) => l(s.target.value || ""), children: [
2089
+ /* @__PURE__ */ n(_e, { value: "", children: "None" }),
2090
+ /* @__PURE__ */ n(_e, { value: "apiKey", children: "apiKey" })
2091
+ ] })
2092
+ ] }) }) }),
2093
+ i === "apiKey" && /* @__PURE__ */ a(D, { container: !0, spacing: 3, children: [
2094
+ /* @__PURE__ */ n(D, { size: {
2095
+ xs: 12,
2096
+ md: 5
2097
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, disabled: b, children: [
2098
+ /* @__PURE__ */ n(ve, { children: "Key Location" }),
2099
+ /* @__PURE__ */ n(Xe, { size: "small", value: d, onChange: (s) => u(s.target.value), children: tr.map((s) => /* @__PURE__ */ n(_e, { value: s.value, children: s.label }, s.value)) })
2100
+ ] }) }),
2101
+ /* @__PURE__ */ n(D, { size: {
2102
+ xs: 12,
2103
+ md: 5
2104
+ }, children: /* @__PURE__ */ a(ge, { fullWidth: !0, disabled: b, error: !!P.keyValue, children: [
2105
+ /* @__PURE__ */ n(ve, { children: d === "query" ? "Query Param Key" : "Header Key" }),
2106
+ /* @__PURE__ */ n(Le, { size: "small", value: c, onChange: (s) => {
2107
+ y(s.target.value), P.keyValue && S({});
2108
+ }, error: !!P.keyValue, helperText: P.keyValue, sx: {
2109
+ "& .MuiInputBase-input": {
2110
+ fontFamily: "monospace"
2111
+ }
2112
+ } })
2113
+ ] }) })
2114
+ ] }),
2115
+ /* @__PURE__ */ a(E, { spacing: 1.5, width: "100%", children: [
2116
+ /* @__PURE__ */ n(Ze, { in: !!L && !I, timeout: 300, children: L && /* @__PURE__ */ n(ce, { severity: L.severity, onClose: () => v(null), sx: {
2117
+ width: "100%",
2118
+ maxWidth: 480
2119
+ }, children: L.message }) }),
2120
+ /* @__PURE__ */ a(E, { direction: "row", spacing: 1.5, justifyContent: "flex-end", children: [
2121
+ /* @__PURE__ */ n(de, { variant: "outlined", onClick: p, disabled: !I || o, children: "Discard" }),
2122
+ /* @__PURE__ */ n(de, { variant: "contained", onClick: () => void h(), disabled: o || !I, children: o ? "Saving..." : "Save" })
2123
+ ] })
2124
+ ] })
2125
+ ] }) : null;
2126
+ }
2127
+ const ir = [
2128
+ "Overview",
2129
+ "Connection",
2130
+ "Access Control",
2131
+ "Security",
2132
+ "API Keys",
2133
+ "Rate Limiting",
2134
+ "Guardrails",
2135
+ "Consumers"
2136
+ // "Models",
2137
+ ];
2138
+ function Ae(t) {
2139
+ const e = Se(4), {
2140
+ value: r,
2141
+ index: o,
2142
+ children: i
2143
+ } = t, l = r !== o;
2144
+ let c;
2145
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (c = {
2146
+ pt: 2
2147
+ }, e[0] = c) : c = e[0];
2148
+ const y = r === o ? i : null;
2149
+ let d;
2150
+ return e[1] !== l || e[2] !== y ? (d = /* @__PURE__ */ n(se, { role: "tabpanel", hidden: l, sx: c, children: y }), e[1] = l, e[2] = y, e[3] = d) : d = e[3], d;
2151
+ }
2152
+ const sr = () => {
2153
+ const [t, e] = N(0), {
2154
+ providerId: r,
2155
+ orgId: o
2156
+ } = De(), {
2157
+ data: i,
2158
+ isLoading: l,
2159
+ error: c
2160
+ } = hn({
2161
+ orgName: o,
2162
+ providerId: r
2163
+ }), {
2164
+ mutateAsync: y,
2165
+ isPending: d
2166
+ } = mn(), u = H(async (f) => y({
2167
+ params: {
2168
+ orgName: o,
2169
+ providerId: r
2170
+ },
2171
+ body: {
2172
+ ...i,
2173
+ ...f
2174
+ }
2175
+ }), [o, r, i, y]), {
2176
+ data: L
2177
+ } = ut({
2178
+ orgName: o
2179
+ }), v = Q(() => {
2180
+ const f = i?.template;
2181
+ return !f || !L?.templates ? null : L.templates.find((M) => M.name === f || M.id === f) ?? null;
2182
+ }, [i?.template, L?.templates]), P = v?.metadata?.logoUrl, S = v?.name ?? i?.template ?? "", I = v?.metadata?.openapiSpecUrl, p = v?.metadata?.auth?.valuePrefix ?? "", h = i?.name ?? r ?? "", b = i?.version, s = i?.description?.trim();
2183
+ return /* @__PURE__ */ n(ht, { title: h, description: s, backHref: Ne(ze.children.org.children.llmProviders.path, {
2184
+ orgId: o ?? ""
2185
+ }), backLabel: "Back to LLM Providers", isLoading: l, titleTail: /* @__PURE__ */ a(E, { direction: "row", spacing: 1, alignItems: "center", sx: {
2186
+ ml: 1
2187
+ }, children: [
2188
+ S && /* @__PURE__ */ n(ue, { label: S, icon: P ? /* @__PURE__ */ n(se, { component: "img", src: P, alt: S, sx: {
2189
+ width: 14,
2190
+ height: 14
2191
+ } }) : void 0, size: "small" }),
2192
+ b && /* @__PURE__ */ n(ue, { label: b, size: "small", variant: "outlined" })
2193
+ ] }), children: /* @__PURE__ */ n(E, { spacing: 3, children: /* @__PURE__ */ a(Pe, { variant: "outlined", children: [
2194
+ /* @__PURE__ */ n(Mt, { value: t, onChange: (f, M) => e(M), variant: "scrollable", allowScrollButtonsMobile: !0, children: ir.map((f) => /* @__PURE__ */ n(at, { label: f }, f)) }),
2195
+ /* @__PURE__ */ n($e, {}),
2196
+ /* @__PURE__ */ a(se, { sx: {
2197
+ px: 3,
2198
+ pb: 3
2199
+ }, children: [
2200
+ /* @__PURE__ */ n(Ae, { value: t, index: 0, children: /* @__PURE__ */ n(Vn, { providerData: i, openapiSpecUrl: I, orgName: o, providerId: r, isLoading: l, error: c instanceof Error ? c : c ? new Error(Fe(c)) : null, onUpdate: u, isUpdating: d }) }),
2201
+ /* @__PURE__ */ n(Ae, { value: t, index: 1, children: /* @__PURE__ */ n(On, { providerData: i, valuePrefix: p, isLoading: l, onUpdate: u, isUpdating: d }) }),
2202
+ /* @__PURE__ */ n(Ae, { value: t, index: 2, children: /* @__PURE__ */ n(zn, { providerData: i, openapiSpecUrl: I, isLoading: l, onUpdate: u, isUpdating: d }) }),
2203
+ /* @__PURE__ */ n(Ae, { value: t, index: 3, children: /* @__PURE__ */ n(rr, { providerData: i, isLoading: l, onUpdate: u, isUpdating: d }) }),
2204
+ /* @__PURE__ */ n(Ae, { value: t, index: 4, children: /* @__PURE__ */ n(Rn, { providerData: i, orgName: o, providerId: r, isLoading: l, error: c instanceof Error ? c : c ? new Error(Fe(c)) : null }) }),
2205
+ /* @__PURE__ */ n(Ae, { value: t, index: 5, children: /* @__PURE__ */ n(er, { providerData: i, openapiSpecUrl: I, isLoading: l, onUpdate: u, isUpdating: d }) }),
2206
+ /* @__PURE__ */ n(Ae, { value: t, index: 6, children: /* @__PURE__ */ n(Un, { providerData: i, openapiSpecUrl: I, isLoading: l, error: c instanceof Error ? c : c ? new Error(Fe(c)) : null, onUpdate: u, isUpdating: d }) }),
2207
+ /* @__PURE__ */ n(Ae, { value: t, index: 7, children: /* @__PURE__ */ n(_n, { orgName: o, providerId: r }) })
2208
+ ] })
2209
+ ] }) }) });
2210
+ }, or = () => {
2211
+ const t = Se(6), {
2212
+ orgId: e
2213
+ } = De();
2214
+ let r;
2215
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ n(tt, { index: !0, element: /* @__PURE__ */ n(ht, { title: "LLM Service Providers", disableIcon: !0, children: /* @__PURE__ */ n(An, {}) }) }), t[0] = r) : r = t[0];
2216
+ let o;
2217
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ n(tt, { path: "view/:providerId", element: /* @__PURE__ */ n(sr, {}) }), t[1] = o) : o = t[1];
2218
+ let i;
2219
+ t[2] !== e ? (i = Ne(ze.children.org.children.llmProviders.path, {
2220
+ orgId: e
2221
+ }), t[2] = e, t[3] = i) : i = t[3];
2222
+ let l;
2223
+ return t[4] !== i ? (l = /* @__PURE__ */ a(Dt, { children: [
2224
+ r,
2225
+ o,
2226
+ /* @__PURE__ */ n(tt, { path: "*", element: /* @__PURE__ */ n(en, { to: i, replace: !0 }) })
2227
+ ] }), t[4] = i, t[5] = l) : l = t[5], l;
2228
+ }, ar = () => {
2229
+ const t = Se(33), {
2230
+ orgId: e
2231
+ } = De(), r = dt();
2232
+ let o;
2233
+ t[0] !== e ? (o = e ? Ne(ze.children.org.children.llmProviders.path, {
2234
+ orgId: e
2235
+ }) : "#", t[0] = e, t[1] = o) : o = t[1];
2236
+ const i = o, l = e ?? "";
2237
+ let c;
2238
+ t[2] !== l ? (c = {
2239
+ orgName: l
2240
+ }, t[2] = l, t[3] = c) : c = t[3];
2241
+ let y;
2242
+ t[4] === Symbol.for("react.memo_cache_sentinel") ? (y = {
2243
+ limit: 50,
2244
+ offset: 0
2245
+ }, t[4] = y) : y = t[4];
2246
+ const {
2247
+ data: d,
2248
+ isLoading: u,
2249
+ error: L
2250
+ } = ut(c, y), v = e ?? "";
2251
+ let P;
2252
+ t[5] !== v ? (P = {
2253
+ orgName: v
2254
+ }, t[5] = v, t[6] = P) : P = t[6];
2255
+ const {
2256
+ error: S
2257
+ } = zt(P), {
2258
+ mutate: I,
2259
+ isPending: p,
2260
+ error: h
2261
+ } = pn(), b = d?.templates;
2262
+ let s;
2263
+ t[7] !== b ? (s = Sn(b), t[7] = b, t[8] = s) : s = t[8];
2264
+ const f = s;
2265
+ let M;
2266
+ e: {
2267
+ if (!e) {
2268
+ M = "Organization is required to add an LLM provider.";
2269
+ break e;
2270
+ }
2271
+ M = null;
2272
+ }
2273
+ const w = M;
2274
+ let x;
2275
+ e: {
2276
+ if (L) {
2277
+ let A;
2278
+ t[9] !== L ? (A = Fe(L), t[9] = L, t[10] = A) : A = t[10], x = A;
2279
+ break e;
2280
+ }
2281
+ if (S) {
2282
+ let A;
2283
+ t[11] !== S ? (A = Fe(S), t[11] = S, t[12] = A) : A = t[12], x = A;
2284
+ break e;
2285
+ }
2286
+ if (h) {
2287
+ x = h?.message || "Failed to create LLM provider";
2288
+ break e;
2289
+ }
2290
+ x = null;
2291
+ }
2292
+ const U = x;
2293
+ let _;
2294
+ t[13] !== I || t[14] !== r || t[15] !== e || t[16] !== f ? (_ = (A, T) => {
2295
+ if (!e)
2296
+ return;
2297
+ const Y = In(A, T, f);
2298
+ I({
2299
+ params: {
2300
+ orgName: e
2301
+ },
2302
+ body: Y
2303
+ }, {
2304
+ onSuccess: (ae) => {
2305
+ const q = Ne(ze.children.org.children.llmProviders.children.view.path, {
2306
+ orgId: e,
2307
+ providerId: ae.uuid
2308
+ });
2309
+ r(q);
2310
+ }
2311
+ });
2312
+ }, t[13] = I, t[14] = r, t[15] = e, t[16] = f, t[17] = _) : _ = t[17];
2313
+ const K = _, C = e ?? "";
2314
+ let g;
2315
+ t[18] !== i || t[19] !== r ? (g = () => r(i), t[18] = i, t[19] = r, t[20] = g) : g = t[20];
2316
+ let F;
2317
+ t[21] !== U || t[22] !== K || t[23] !== p || t[24] !== u || t[25] !== w || t[26] !== C || t[27] !== g || t[28] !== f ? (F = /* @__PURE__ */ n(kn, { orgId: C, templates: f, isLoadingTemplates: u, missingParamsMessage: w, errorMessage: U, isSubmitting: p, onCancel: g, onSubmit: K }), t[21] = U, t[22] = K, t[23] = p, t[24] = u, t[25] = w, t[26] = C, t[27] = g, t[28] = f, t[29] = F) : F = t[29];
2318
+ let W;
2319
+ return t[30] !== i || t[31] !== F ? (W = /* @__PURE__ */ n(ht, { title: "Add LLM Service Provider", backHref: i, disableIcon: !0, backLabel: "Back to Providers List", children: F }), t[30] = i, t[31] = F, t[32] = W) : W = t[32], W;
2320
+ }, Lr = {
2321
+ title: "LLM Service Providers",
2322
+ description: "A page component for LLM Service Provider management",
2323
+ icon: Qt,
2324
+ path: "/llm-providers",
2325
+ component: Pt,
2326
+ levels: {
2327
+ component: Pt,
2328
+ organization: or,
2329
+ addLLMProvidersOrganization: ar
2330
+ }
2331
+ };
2332
+ export {
2333
+ kn as AddLLMProviderForm,
2334
+ ar as AddLLMProvidersOrganization,
2335
+ Pt as LLMProvidersComponent,
2336
+ or as LLMProvidersOrganization,
2337
+ In as buildCreateLLMProviderRequest,
2338
+ Sn as mapLLMProviderTemplatesToCards,
2339
+ Lr as metaData,
2340
+ kr as toProviderId
2341
+ };