@epam/ai-dial-toolset-editor 1.2.0-dev.3 → 1.2.0-dev.303

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.
package/index.js CHANGED
@@ -1,59 +1,83 @@
1
- import { AvatarPickerModal as e, DeploymentCreationFieldErrorCode as t, DeploymentCreationForm as n, EditorLayout as r, EditorSection as i, validateDeploymentCreationFields as a } from "@epam/ai-dial-builder-form";
2
- import { ToolsetAuthTypes as o, ToolsetCredentialsLevel as s, WithLogin as c, dialFileToAttachment as l, getApiErrorDetails as u } from "@epam/ai-dial-chat-hooks";
3
- import { ConfirmationPopup as d, ConfirmationPopupVariant as f, DIAL_ICON_SIZE as p, DIAL_KIT_ICON_STROKE as m, Input as h, NeutralButton as g, PasswordInput as _, PrimaryButton as v, Radio as y, RadioGroup as b, SegmentedControl as ee, Select as x, TagInput as S } from "@epam/ai-dial-ui-kit";
4
- import { memo as C, useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as O } from "react";
5
- import { IconBrandOauth as k, IconKey as A, IconLockOff as j, IconLogin as te, IconLogout as M } from "@tabler/icons-react";
6
- import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
7
- import { CopyButton as I, TAG_INPUT_TAG_CLASS_NAME as L, mergeClasses as R, useCodeCopy as z } from "@epam/ai-dial-chat-shared";
8
- //#region src/constants/toolsets.ts
9
- var B = /* @__PURE__ */ function(e) {
1
+ import { DeploymentCreationFieldErrorCode as e, EntityEditor as t, MetadataField as n, MetadataForm as r, SEMVER_VERSION_PATTERN as i, useMetadataForm as a, validateDeploymentCreationFields as o } from "@epam/ai-dial-builder-form";
2
+ import { ToolsetAuthTypes as s, ToolsetCredentialsLevel as c, WithLogin as l, dialFileToAttachment as u, getApiErrorDetails as d } from "@epam/ai-dial-chat-hooks";
3
+ import { CopyButton as f, ENTITY_DESCRIPTION_MAX_LENGTH as p, ENTITY_NAME_MAX_LENGTH as m, TAG_INPUT_TAG_CLASS_NAME as h, TextRefinementField as g, mergeClasses as _, useCodeCopy as v, useTextRefinement as y } from "@epam/ai-dial-chat-shared";
4
+ import { memo as b, useCallback as x, useEffect as S, useMemo as C, useRef as ee, useState as w } from "react";
5
+ import { IconBrandOauth as T, IconKey as te, IconLockOff as ne, IconLogin as E, IconLogout as re } from "@tabler/icons-react";
6
+ import { jsx as D, jsxs as O } from "react/jsx-runtime";
7
+ import { ConfirmationPopup as ie, ConfirmationPopupVariant as ae, DIAL_ICON_SIZE as k, DIAL_KIT_ICON_STROKE as A, Input as j, NeutralButton as M, PasswordInput as N, Radio as P, RadioGroup as F, SegmentedControl as I, Select as L, TagInput as oe } from "@epam/ai-dial-ui-kit";
8
+ //#region src/constants/public-class-names.ts
9
+ var se = {
10
+ metadataSection: "dial-toolset-editor-metadata-section",
11
+ setupSection: "dial-toolset-editor-setup-section"
12
+ }, R = /* @__PURE__ */ function(e) {
10
13
  return e.Http = "HTTP", e.Sse = "SSE", e;
11
- }({}), V = "New toolset", H = "0.0.1", U = {
12
- [o.OAuth]: k,
13
- [o.ApiKey]: A,
14
- [o.None]: j
15
- }, W = ({ defaultName: e = V, existingNames: t }) => {
14
+ }({}), z = "New toolset", B = "1.0.0", ce = { validateVersionPattern: i }, V = {
15
+ [s.OAuth]: T,
16
+ [s.ApiKey]: te,
17
+ [s.None]: ne
18
+ }, H = ({ defaultName: e = z, existingNames: t }) => {
16
19
  let n = new Set(t);
17
20
  if (!n.has(e)) return e;
18
21
  let r = 1;
19
22
  for (; n.has(`${e} ${r}`);) r += 1;
20
23
  return `${e} ${r}`;
21
- }, G = () => ({
22
- authenticationType: o.None,
23
- withLogin: c.WithoutLogin,
24
+ }, le = () => ({
25
+ authenticationType: s.None,
26
+ withLogin: l.WithoutLogin,
24
27
  isLoggedIn: !1
25
- }), K = (e = []) => ({
26
- name: W({ existingNames: e }),
27
- version: H,
28
+ }), U = (e = []) => ({
29
+ name: H({ existingNames: e }),
30
+ version: B,
28
31
  iconUrl: "",
29
32
  description: "",
30
33
  topics: [],
31
34
  otherLocales: [],
32
35
  endpoint: "",
33
- protocol: B.Http,
36
+ protocol: R.Http,
34
37
  allowedTools: [],
35
- auth: G()
36
- }), q = (e) => {
38
+ auth: le()
39
+ }), W = (e) => {
37
40
  if (!/^https?:\/\//.test(e) || e.endsWith(".") || e.endsWith("//")) return !1;
38
41
  try {
39
42
  return !!new URL(e);
40
43
  } catch {
41
44
  return !1;
42
45
  }
43
- }, J = (e) => q(e.trim()), Y = (e) => e.replace(/^(https?):\/([^/])/, "$1://$2"), X = (e) => {
46
+ }, G = (e) => W(e.trim()), K = (e) => e.replace(/^(https?):\/([^/])/, "$1://$2"), q = (e) => {
44
47
  let t = e?.trim() ?? "";
45
- if (!t || q(t)) return t;
48
+ if (!t || W(t)) return t;
46
49
  let n = [t];
47
50
  try {
48
51
  let e = decodeURIComponent(t);
49
52
  e !== t && n.push(e);
50
53
  } catch {}
51
54
  for (let e of n) {
52
- let t = Y(e);
53
- if (q(t)) return t;
55
+ let t = K(e);
56
+ if (W(t)) return t;
54
57
  }
55
58
  return t;
56
- }, ne = (e) => !e?.trim() || J(e), Z = (e, t = !1) => e.isLoggedIn ? !0 : e.authenticationType === o.ApiKey ? e.keyHeader?.trim() ? e.withLogin === c.WithoutLogin ? !0 : !!(e.keyHeader?.trim() && e.apiKey?.trim()) : !1 : e.authenticationType === o.OAuth && e.withLogin === c.WithConfig ? !!e.clientId?.trim() && (t || !!e.clientSecret?.trim()) && ne(e.authorizationEndpoint) && ne(e.tokenEndpoint) : !0, re = (e, t = !1) => Object.keys(a(e, { validateVersionPattern: !0 })).length === 0 && J(e.endpoint) && Z(e.auth, t), ie = {
59
+ }, J = (e) => !e?.trim() || G(e), Y = (e, t = !1) => e.isLoggedIn ? !0 : e.authenticationType === s.ApiKey ? e.keyHeader?.trim() ? e.withLogin === l.WithoutLogin ? !0 : !!(e.keyHeader?.trim() && e.apiKey?.trim()) : !1 : e.authenticationType === s.OAuth && e.withLogin === l.WithConfig ? !!e.clientId?.trim() && (t || !!e.clientSecret?.trim()) && J(e.authorizationEndpoint) && J(e.tokenEndpoint) : !0, ue = (e, t = !1) => Object.keys(o(e, ce)).length === 0 && G(e.endpoint) && Y(e.auth, t), de = new Set([
60
+ "name",
61
+ "description",
62
+ "iconUrl",
63
+ "version",
64
+ "topics",
65
+ "otherLocales"
66
+ ]), fe = (e) => ({
67
+ name: e.name,
68
+ description: e.description,
69
+ iconUrl: e.iconUrl,
70
+ version: e.version,
71
+ topics: e.topics,
72
+ otherLocales: e.otherLocales
73
+ }), pe = (e) => {
74
+ let t = {}, n = {};
75
+ for (let [r, i] of Object.entries(e)) (de.has(r) ? t : n)[r] = i;
76
+ return {
77
+ metadata: t,
78
+ setup: n
79
+ };
80
+ }, X = {
57
81
  name: {
58
82
  label: "Name",
59
83
  placeholder: "Enter name"
@@ -92,381 +116,356 @@ var B = /* @__PURE__ */ function(e) {
92
116
  saveLabel: "Save"
93
117
  },
94
118
  ariaLabel: "General"
95
- }, Q = {
96
- title: "Add avatar",
97
- attachLabel: "Attach",
98
- emptyTitle: "This folder is empty",
99
- emptyDescription: "",
100
- errorMessage: "Failed to load files",
101
- retryLabel: "Retry",
102
- hiddenFilesLabel: "Hidden files",
103
- showHiddenFilesLabel: "Show hidden files",
104
- hideHiddenFilesLabel: "Hide hidden files",
105
- getSelectionLabel: (e) => e === 1 ? `${e} item selected` : `${e} items selected`,
106
- uploadFilesLabel: "Upload files",
107
- newFolderLabel: "New folder",
108
- downloadLabel: "Download",
109
- downloadingLabel: "Preparing download…",
110
- deleteLabel: "Delete",
111
- deletingLabel: "Deleting…",
112
- deleteConfirmTitleSingle: "Confirm deleting",
113
- deleteConfirmTitleMultiple: "Confirm deleting items",
114
- deleteConfirmSingleText: "Are you sure you want to delete",
115
- deleteConfirmMultipleText: "Do you want to delete following",
116
- deleteConfirmItemsLabel: "items?",
117
- deleteConfirmLabel: "Delete",
118
- deleteCancelLabel: "Cancel",
119
- uploadProgressTitle: "Uploading files",
120
- cancelLabel: "Cancel"
121
- }, ae = ({ form: t, errors: r, bucket: i, FileManagerModal: a, resolveIconUrl: o, allowedMimeTypes: s, maxFileSizeBytes: c, availableLocaleOptions: u, onChange: d, onNameBlur: f, onVersionBlur: p, labels: m }) => {
122
- let [h, g] = O(!1), _ = m?.form ?? ie, v = m?.avatarPicker ?? Q, y = E(() => o(t.iconUrl), [t.iconUrl, o]);
123
- return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(n, {
124
- values: {
125
- name: t.name,
126
- description: t.description,
127
- iconUrl: t.iconUrl,
128
- version: t.version,
129
- topics: t.topics,
130
- otherLocales: t.otherLocales
131
- },
132
- errors: r,
133
- onChange: d,
134
- onNameBlur: f,
135
- onVersionBlur: p,
136
- iconPreviewUrl: y,
137
- onAddAvatarClick: () => g(!0),
138
- labels: _,
139
- availableLocaleOptions: u
140
- }), /* @__PURE__ */ P(e, {
141
- isOpen: h,
142
- onClose: () => g(!1),
143
- onAttach: (e) => {
144
- let [t] = e.files, n = t ? l(t, i, { resolvePreviewUrl: o }) : null;
145
- n?.url && d({ iconUrl: n.url }), g(!1);
146
- },
147
- bucket: i,
148
- FileManagerModal: a,
149
- allowedMimeTypes: s,
150
- maxFileSizeBytes: c,
151
- labels: v
152
- })] });
153
- }, $ = /* @__PURE__ */ function(e) {
119
+ }, me = ({ form: e, errors: t, bucket: n, FileManagerModal: i, resolveIconUrl: a, allowedMimeTypes: o, maxFileSizeBytes: s, availableLocaleOptions: c, onChange: l, onNameBlur: d, onVersionBlur: f, renderDescription: p, labels: m }) => {
120
+ let h = x((e) => {
121
+ let [t] = e.files;
122
+ return (t ? u(t, n, { resolvePreviewUrl: a }) : null)?.url;
123
+ }, [n, a]);
124
+ return /* @__PURE__ */ D(r, {
125
+ values: e,
126
+ errors: t,
127
+ onChange: l,
128
+ onNameBlur: d,
129
+ onVersionBlur: f,
130
+ avatarPicker: C(() => ({
131
+ bucket: n,
132
+ FileManagerModal: i,
133
+ resolveIconUrl: a,
134
+ resolveAttachedIconUrl: h,
135
+ allowedMimeTypes: o,
136
+ maxFileSizeBytes: s
137
+ }), [
138
+ n,
139
+ i,
140
+ a,
141
+ h,
142
+ o,
143
+ s
144
+ ]),
145
+ availableLocaleOptions: c,
146
+ renderDescription: p,
147
+ labels: C(() => ({
148
+ form: m?.form ?? X,
149
+ avatarPicker: m?.avatarPicker
150
+ }), [m?.form, m?.avatarPicker])
151
+ });
152
+ }, Z = /* @__PURE__ */ function(e) {
154
153
  return e.Success = "success", e.Cancelled = "cancelled", e.PopupBlocked = "popup-blocked", e.InvalidConfig = "invalid-config", e.Failed = "failed", e;
155
- }({}), oe = (e, t) => e === o.None ? c.WithoutLogin : e === o.OAuth && !t ? c.WithConfig : c.WithLogin, se = (e, t) => e === o.None ? t?.typeNone ?? "Open access" : e === o.OAuth ? t?.typeOAuth ?? "OAuth" : t?.typeApiKey ?? "API Key", ce = ({ auth: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, endpoint: a, authActions: l, onOAuthLogin: v, onNotifySuccess: b, onNotifyError: x, onAuthChange: C, onEnsureSaved: w, labels: T }) => {
156
- let [E, D] = O(!1), [k, A] = O(!1), j = e.isLoggedIn || n || E, N = J(a) && Z(e, i) && !j, I = (t) => {
157
- j || t === e.authenticationType || C({
154
+ }({}), Q = (e) => e === s.None ? l.WithoutLogin : l.WithLogin, he = (e, t) => e === s.None ? t?.typeNone ?? "Open access" : e === s.OAuth ? t?.typeOAuth ?? "OAuth" : t?.typeApiKey ?? "API Key", ge = ({ auth: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, endpoint: a, authActions: o, onOAuthLogin: u, onNotifySuccess: f, onNotifyError: p, onAuthChange: m, onEnsureSaved: g, labels: _ }) => {
155
+ let [v, y] = w(!1), [b, x] = w(!1), S = e.isLoggedIn || n || v, C = G(a) && Y(e, i) && !S, ee = (t) => {
156
+ S || t === e.authenticationType || m({
158
157
  authenticationType: t,
159
- withLogin: oe(t, !!e.clientId?.trim())
158
+ withLogin: Q(t)
160
159
  });
161
- }, R = (e) => {
162
- C({ withLogin: e });
163
- }, z = (e) => {
164
- switch (e.auth != null && C(e.auth), e.status) {
165
- case $.Success:
166
- C({ isLoggedIn: !0 }), b(T?.loginSuccessMessage ?? "Successfully logged in.");
160
+ }, T = (e) => {
161
+ m({ withLogin: e });
162
+ }, te = (e) => {
163
+ switch (e.auth != null && m(e.auth), e.status) {
164
+ case Z.Success:
165
+ m({ isLoggedIn: !0 }), f(_?.loginSuccessMessage ?? "Successfully logged in.");
167
166
  return;
168
- case $.PopupBlocked:
169
- x(T?.errorPopupBlocked ?? "The login popup was blocked by your browser. Please allow popups for this site and try again.");
167
+ case Z.PopupBlocked:
168
+ p(_?.errorPopupBlocked ?? "The login popup was blocked by your browser. Please allow popups for this site and try again.");
170
169
  return;
171
- case $.InvalidConfig:
172
- x(T?.errorOAuthConfigMissing ?? "The OAuth provider did not return a valid client configuration. Please check the endpoint or contact your administrator.");
170
+ case Z.InvalidConfig:
171
+ p(_?.errorOAuthConfigMissing ?? "The OAuth provider did not return a valid client configuration. Please check the endpoint or contact your administrator.");
173
172
  return;
174
- case $.Failed:
175
- x(T?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", e.traceId);
173
+ case Z.Failed:
174
+ p(_?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", e.traceId);
176
175
  return;
177
- case $.Cancelled: return;
176
+ case Z.Cancelled: return;
178
177
  }
179
- }, B = async () => {
180
- if (!N) return;
181
- if (e.authenticationType === o.OAuth) {
182
- D(!0);
178
+ }, ne = async () => {
179
+ if (!C) return;
180
+ if (e.authenticationType === s.OAuth) {
181
+ y(!0);
183
182
  try {
184
- z(await v({
183
+ te(await u({
185
184
  auth: e,
186
- ensureSaved: w
185
+ ensureSaved: g
187
186
  }));
188
187
  } finally {
189
- D(!1);
188
+ y(!1);
190
189
  }
191
190
  return;
192
191
  }
193
- let t = await w();
192
+ let t = await g();
194
193
  if (t) {
195
- D(!0);
194
+ y(!0);
196
195
  try {
197
196
  let n = {
198
197
  url: t,
199
- credentialsLevel: s.User,
198
+ credentialsLevel: c.User,
200
199
  authenticationType: e.authenticationType,
201
200
  apiKey: e.apiKey?.trim()
202
201
  };
203
- await l.login(t, n), C({ isLoggedIn: !0 }), b(T?.loginSuccessMessage ?? "Successfully logged in.");
202
+ await o.login(t, n), m({ isLoggedIn: !0 }), f(_?.loginSuccessMessage ?? "Successfully logged in.");
204
203
  } catch (e) {
205
- let { traceId: t } = await u(e);
206
- x(T?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
204
+ let { traceId: t } = await d(e);
205
+ p(_?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
207
206
  } finally {
208
- D(!1);
207
+ y(!1);
209
208
  }
210
209
  }
211
- }, V = async () => {
212
- D(!0);
210
+ }, F = async () => {
211
+ y(!0);
213
212
  try {
214
213
  let t = {
215
214
  url: r,
216
- credentialsLevel: s.User,
215
+ credentialsLevel: c.User,
217
216
  authenticationType: e.authenticationType
218
217
  };
219
- await l.logout(r, t), C({ isLoggedIn: !1 }), A(!1), b(T?.logoutSuccessMessage ?? "Successfully logged out.");
218
+ await o.logout(r, t), m({ isLoggedIn: !1 }), x(!1), f(_?.logoutSuccessMessage ?? "Successfully logged out.");
220
219
  } catch (e) {
221
- let { traceId: t } = await u(e);
222
- x(T?.errorLogoutFailed ?? "Failed to log out. Please try again.", t);
220
+ let { traceId: t } = await d(e);
221
+ p(_?.errorLogoutFailed ?? "Failed to log out. Please try again.", t);
223
222
  } finally {
224
- D(!1);
223
+ y(!1);
225
224
  }
226
- }, H = () => e.isLoggedIn ? /* @__PURE__ */ P("div", {
225
+ }, L = () => e.isLoggedIn ? /* @__PURE__ */ D("div", {
227
226
  className: "flex",
228
- children: /* @__PURE__ */ P(g, {
229
- label: T?.logOutLabel ?? "Log out",
230
- iconBefore: /* @__PURE__ */ P(M, {
231
- size: p.MD,
232
- stroke: m
227
+ children: /* @__PURE__ */ D(M, {
228
+ label: _?.logOutLabel ?? "Log out",
229
+ iconBefore: /* @__PURE__ */ D(re, {
230
+ size: k.MD,
231
+ stroke: A
233
232
  }),
234
- onClick: () => A(!0),
235
- disabled: n || E
233
+ onClick: () => x(!0),
234
+ disabled: n || v
236
235
  })
237
- }) : /* @__PURE__ */ P("div", {
236
+ }) : /* @__PURE__ */ D("div", {
238
237
  className: "flex",
239
- children: /* @__PURE__ */ P(g, {
240
- label: T?.logInLabel ?? "Log in",
241
- iconBefore: /* @__PURE__ */ P(te, {
242
- size: p.MD,
243
- stroke: m
238
+ children: /* @__PURE__ */ D(M, {
239
+ label: _?.logInLabel ?? "Log in",
240
+ iconBefore: /* @__PURE__ */ D(E, {
241
+ size: k.MD,
242
+ stroke: A
244
243
  }),
245
- onClick: B,
246
- disabled: !N
244
+ onClick: ne,
245
+ disabled: !C
247
246
  })
248
247
  });
249
- return /* @__PURE__ */ F("section", {
248
+ return /* @__PURE__ */ O("section", {
250
249
  className: "flex flex-col gap-2",
251
250
  children: [
252
- /* @__PURE__ */ P("h3", {
251
+ /* @__PURE__ */ D("h3", {
253
252
  className: "dial-h3-text",
254
- children: T?.sectionTitle ?? "Authentication"
253
+ children: _?.sectionTitle ?? "Authentication"
255
254
  }),
256
- /* @__PURE__ */ P(ee, {
257
- "aria-label": T?.sectionTitle ?? "Authentication",
255
+ /* @__PURE__ */ D(I, {
256
+ "aria-label": _?.sectionTitle ?? "Authentication",
258
257
  value: e.authenticationType,
259
- onChange: (e) => I(e),
258
+ onChange: (e) => ee(e),
260
259
  segmentClassName: "px-2",
261
260
  items: [
262
- o.None,
263
- o.OAuth,
264
- o.ApiKey
261
+ s.None,
262
+ s.OAuth,
263
+ s.ApiKey
265
264
  ].map((t) => {
266
- let n = U[t];
265
+ let n = V[t];
267
266
  return {
268
267
  value: t,
269
- label: /* @__PURE__ */ F("div", {
268
+ label: /* @__PURE__ */ O("div", {
270
269
  className: "flex items-center gap-2",
271
- children: [/* @__PURE__ */ P(n, {
270
+ children: [/* @__PURE__ */ D(n, {
272
271
  className: "shrink-0",
273
- size: p.SM,
274
- stroke: m,
272
+ size: k.SM,
273
+ stroke: A,
275
274
  "aria-hidden": !0
276
- }), /* @__PURE__ */ P("span", {
275
+ }), /* @__PURE__ */ D("span", {
277
276
  className: "sr-only desktop:not-sr-only",
278
- children: se(t, T)
277
+ children: he(t, _)
279
278
  })]
280
279
  }),
281
- disabled: j && e.authenticationType !== t
280
+ disabled: S && e.authenticationType !== t
282
281
  };
283
282
  })
284
283
  }),
285
- e.authenticationType === o.None && /* @__PURE__ */ P("p", {
284
+ e.authenticationType === s.None && /* @__PURE__ */ D("p", {
286
285
  className: "dial-small-text pt-2 text-secondary",
287
- children: T?.openAccessDescription ?? "Open endpoint, no credentials"
286
+ children: _?.openAccessDescription ?? "Open endpoint, no credentials"
288
287
  }),
289
- e.authenticationType === o.OAuth && /* @__PURE__ */ F("div", {
288
+ e.authenticationType === s.OAuth && /* @__PURE__ */ O("div", {
290
289
  className: "flex flex-col gap-3 pt-2",
291
290
  children: [
292
- /* @__PURE__ */ F("div", {
291
+ /* @__PURE__ */ O("div", {
293
292
  className: "flex flex-col gap-2",
294
- children: [/* @__PURE__ */ P(y, {
293
+ children: [/* @__PURE__ */ D(P, {
295
294
  name: "oauth-login-mode",
296
295
  id: "oauth-with-login",
297
- value: c.WithLogin,
298
- labelProps: { label: T?.withLoginOAuthLabel ?? "Standard login" },
299
- isSelected: e.withLogin === c.WithLogin,
300
- disabled: j,
301
- onChange: R
302
- }), /* @__PURE__ */ P(y, {
296
+ value: l.WithLogin,
297
+ labelProps: { label: _?.withLoginOAuthLabel ?? "Standard login" },
298
+ isSelected: e.withLogin === l.WithLogin,
299
+ disabled: S,
300
+ onChange: T
301
+ }), /* @__PURE__ */ D(P, {
303
302
  name: "oauth-login-mode",
304
303
  id: "oauth-with-config",
305
- value: c.WithConfig,
306
- labelProps: { label: T?.withConfigOAuthLabel ?? "Custom login" },
307
- isSelected: e.withLogin === c.WithConfig,
308
- disabled: j,
309
- onChange: R
304
+ value: l.WithConfig,
305
+ labelProps: { label: _?.withConfigOAuthLabel ?? "Custom login" },
306
+ isSelected: e.withLogin === l.WithConfig,
307
+ disabled: S,
308
+ onChange: T
310
309
  })]
311
310
  }),
312
- e.withLogin === c.WithConfig && /* @__PURE__ */ F("div", {
311
+ e.withLogin === l.WithConfig && /* @__PURE__ */ O("div", {
313
312
  className: "flex flex-col gap-3",
314
313
  children: [
315
- /* @__PURE__ */ P(h, {
314
+ /* @__PURE__ */ D(j, {
316
315
  id: "toolset-client-id",
317
316
  value: e.clientId ?? "",
318
- onChange: (e) => C({ clientId: e ?? "" }),
317
+ onChange: (e) => m({ clientId: e ?? "" }),
319
318
  labelProps: {
320
- label: T?.clientIdLabel ?? "Client ID",
319
+ label: _?.clientIdLabel ?? "Client ID",
321
320
  required: !0
322
321
  },
323
- placeholder: T?.clientIdPlaceholder ?? "Enter client ID",
322
+ placeholder: _?.clientIdPlaceholder ?? "Enter client ID",
324
323
  error: t.clientId || void 0,
325
324
  invalid: !!t.clientId,
326
- disabled: j
325
+ disabled: S
327
326
  }),
328
- /* @__PURE__ */ P(_, {
327
+ /* @__PURE__ */ D(N, {
329
328
  id: "toolset-client-secret",
330
329
  value: e.clientSecret ?? "",
331
- onChange: (e) => C({ clientSecret: e ?? "" }),
330
+ onChange: (e) => m({ clientSecret: e ?? "" }),
332
331
  labelProps: {
333
- label: T?.clientSecretLabel ?? "Client secret",
332
+ label: _?.clientSecretLabel ?? "Client secret",
334
333
  required: !i
335
334
  },
336
- placeholder: T?.clientSecretPlaceholder ?? "Enter client secret",
337
- showPasswordLabel: T?.showClientSecretLabel ?? "Show client secret",
338
- hidePasswordLabel: T?.hideClientSecretLabel ?? "Hide client secret",
335
+ placeholder: _?.clientSecretPlaceholder ?? "Enter client secret",
336
+ showPasswordLabel: _?.showClientSecretLabel ?? "Show client secret",
337
+ hidePasswordLabel: _?.hideClientSecretLabel ?? "Hide client secret",
339
338
  error: t.clientSecret || void 0,
340
339
  invalid: !!t.clientSecret,
341
- disabled: j
340
+ disabled: S
342
341
  }),
343
- /* @__PURE__ */ P(h, {
342
+ /* @__PURE__ */ D(j, {
344
343
  id: "toolset-authorization-endpoint",
345
344
  value: e.authorizationEndpoint ?? "",
346
- onChange: (e) => C({ authorizationEndpoint: e ?? "" }),
347
- labelProps: { label: T?.authorizationEndpointLabel ?? "Authorization endpoint" },
348
- placeholder: T?.authorizationEndpointPlaceholder ?? "Enter authorization endpoint",
345
+ onChange: (e) => m({ authorizationEndpoint: e ?? "" }),
346
+ labelProps: { label: _?.authorizationEndpointLabel ?? "Authorization endpoint" },
347
+ placeholder: _?.authorizationEndpointPlaceholder ?? "Enter authorization endpoint",
349
348
  error: t.authorizationEndpoint || void 0,
350
349
  invalid: !!t.authorizationEndpoint,
351
- disabled: j
350
+ disabled: S
352
351
  }),
353
- /* @__PURE__ */ P(h, {
352
+ /* @__PURE__ */ D(j, {
354
353
  id: "toolset-token-endpoint",
355
354
  value: e.tokenEndpoint ?? "",
356
- onChange: (e) => C({ tokenEndpoint: e ?? "" }),
357
- labelProps: { label: T?.tokenEndpointLabel ?? "Token endpoint" },
358
- placeholder: T?.tokenEndpointPlaceholder ?? "Enter token endpoint",
355
+ onChange: (e) => m({ tokenEndpoint: e ?? "" }),
356
+ labelProps: { label: _?.tokenEndpointLabel ?? "Token endpoint" },
357
+ placeholder: _?.tokenEndpointPlaceholder ?? "Enter token endpoint",
359
358
  error: t.tokenEndpoint || void 0,
360
359
  invalid: !!t.tokenEndpoint,
361
- disabled: j
360
+ disabled: S
362
361
  }),
363
- /* @__PURE__ */ P(S, {
362
+ /* @__PURE__ */ D(oe, {
364
363
  id: "toolset-scopes",
365
- labelProps: { label: T?.scopesLabel ?? "Scopes" },
366
- placeholder: T?.scopesPlaceholder ?? "Enter scopes",
364
+ labelProps: { label: _?.scopesLabel ?? "Scopes" },
365
+ placeholder: _?.scopesPlaceholder ?? "Enter scopes",
367
366
  value: e.scopes ?? [],
368
- onChange: (e) => C({ scopes: e }),
369
- disabled: j,
370
- tagClassName: L
367
+ onChange: (e) => m({ scopes: e }),
368
+ disabled: S,
369
+ tagClassName: h
371
370
  })
372
371
  ]
373
372
  }),
374
- H()
373
+ L()
375
374
  ]
376
375
  }),
377
- e.authenticationType === o.ApiKey && /* @__PURE__ */ F("div", {
376
+ e.authenticationType === s.ApiKey && /* @__PURE__ */ O("div", {
378
377
  className: "flex flex-col gap-3 pt-2",
379
378
  children: [
380
- /* @__PURE__ */ F("div", {
379
+ /* @__PURE__ */ O("div", {
381
380
  className: "flex flex-col gap-2",
382
- children: [/* @__PURE__ */ P(y, {
381
+ children: [/* @__PURE__ */ D(P, {
383
382
  name: "apikey-login-mode",
384
383
  id: "apikey-with-login",
385
- value: c.WithLogin,
386
- labelProps: { label: T?.withLoginLabel ?? "With login" },
387
- isSelected: e.withLogin === c.WithLogin,
388
- disabled: j,
389
- onChange: R
390
- }), /* @__PURE__ */ P(y, {
384
+ value: l.WithLogin,
385
+ labelProps: { label: _?.withLoginLabel ?? "With login" },
386
+ isSelected: e.withLogin === l.WithLogin,
387
+ disabled: S,
388
+ onChange: T
389
+ }), /* @__PURE__ */ D(P, {
391
390
  name: "apikey-login-mode",
392
391
  id: "apikey-without-login",
393
- value: c.WithoutLogin,
394
- labelProps: { label: T?.withoutLoginLabel ?? "Without login" },
395
- isSelected: e.withLogin === c.WithoutLogin,
396
- disabled: j,
397
- onChange: R
392
+ value: l.WithoutLogin,
393
+ labelProps: { label: _?.withoutLoginLabel ?? "Without login" },
394
+ isSelected: e.withLogin === l.WithoutLogin,
395
+ disabled: S,
396
+ onChange: T
398
397
  })]
399
398
  }),
400
- /* @__PURE__ */ F("div", {
399
+ /* @__PURE__ */ O("div", {
401
400
  className: "flex flex-col gap-3",
402
- children: [/* @__PURE__ */ P(h, {
401
+ children: [/* @__PURE__ */ D(j, {
403
402
  id: "toolset-key-header",
404
403
  value: e.keyHeader ?? "",
405
- onChange: (e) => C({ keyHeader: e ?? "" }),
404
+ onChange: (e) => m({ keyHeader: e ?? "" }),
406
405
  labelProps: {
407
- label: T?.keyHeaderLabel ?? "API Key parameter name",
406
+ label: _?.keyHeaderLabel ?? "API Key parameter name",
408
407
  required: !0
409
408
  },
410
- placeholder: T?.keyHeaderPlaceholder ?? "Enter API key parameter name",
409
+ placeholder: _?.keyHeaderPlaceholder ?? "Enter API key parameter name",
411
410
  error: t.keyHeader || void 0,
412
411
  invalid: !!t.keyHeader,
413
- disabled: j
414
- }), e.withLogin === c.WithLogin && /* @__PURE__ */ P(_, {
412
+ disabled: S
413
+ }), e.withLogin === l.WithLogin && /* @__PURE__ */ D(N, {
415
414
  id: "toolset-api-key",
416
415
  value: e.apiKey ?? "",
417
- onChange: (e) => C({ apiKey: e ?? "" }),
416
+ onChange: (e) => m({ apiKey: e ?? "" }),
418
417
  labelProps: {
419
- label: T?.apiKeyLabel ?? "API key",
418
+ label: _?.apiKeyLabel ?? "API key",
420
419
  required: !0
421
420
  },
422
- placeholder: T?.apiKeyPlaceholder ?? "Enter API key",
423
- showPasswordLabel: T?.showApiKeyLabel ?? "Show API key",
424
- hidePasswordLabel: T?.hideApiKeyLabel ?? "Hide API key",
421
+ placeholder: _?.apiKeyPlaceholder ?? "Enter API key",
422
+ showPasswordLabel: _?.showApiKeyLabel ?? "Show API key",
423
+ hidePasswordLabel: _?.hideApiKeyLabel ?? "Hide API key",
425
424
  error: t.apiKey || void 0,
426
425
  invalid: !!t.apiKey,
427
- disabled: j
426
+ disabled: S
428
427
  })]
429
428
  }),
430
- e.withLogin !== c.WithoutLogin && H()
429
+ e.withLogin !== l.WithoutLogin && L()
431
430
  ]
432
431
  }),
433
- k && /* @__PURE__ */ P(d, {
434
- open: k,
435
- header: T?.logoutConfirmTitle ?? "Log out?",
436
- description: T?.logoutConfirmDescription ?? "Are you sure you want to log out? You will need to re-enter your credentials to use this toolset again.",
437
- confirmLabel: T?.logOutLabel ?? "Log out",
438
- cancelLabel: T?.cancelLabel ?? "Cancel",
439
- variant: f.Danger,
440
- isLoading: E,
441
- disableConfirmButton: E,
442
- onConfirm: V,
443
- onCancel: () => A(!1),
444
- onClose: () => A(!1)
432
+ b && /* @__PURE__ */ D(ie, {
433
+ open: b,
434
+ header: _?.logoutConfirmTitle ?? "Log out?",
435
+ description: _?.logoutConfirmDescription ?? "Are you sure you want to log out? You will need to re-enter your credentials to use this toolset again.",
436
+ confirmLabel: _?.logOutLabel ?? "Log out",
437
+ cancelLabel: _?.cancelLabel ?? "Cancel",
438
+ variant: ae.Danger,
439
+ isLoading: v,
440
+ disableConfirmButton: v,
441
+ onConfirm: F,
442
+ onCancel: () => x(!1),
443
+ onClose: () => x(!1)
445
444
  })
446
445
  ]
447
446
  });
448
- }, le = C(({ url: e, className: t, labels: n }) => {
449
- let { isCopied: r, copy: i } = z(e), a = n?.copiedLabel ?? "Copied!";
450
- return /* @__PURE__ */ F("div", {
451
- className: R("flex flex-col gap-3", t),
447
+ }, _e = b(({ url: e, className: t, labels: n }) => {
448
+ let { isCopied: r, copy: i } = v(e), a = n?.copiedLabel ?? "Copied!";
449
+ return /* @__PURE__ */ O("div", {
450
+ className: _("flex flex-col gap-3", t),
452
451
  children: [
453
- /* @__PURE__ */ F("div", {
452
+ /* @__PURE__ */ O("div", {
454
453
  className: "flex flex-col gap-1",
455
- children: [/* @__PURE__ */ P("p", {
454
+ children: [/* @__PURE__ */ D("p", {
456
455
  className: "dial-body-semi-text text-start text-primary",
457
456
  children: n?.title ?? "Connect toolset"
458
- }), /* @__PURE__ */ P("p", {
457
+ }), /* @__PURE__ */ D("p", {
459
458
  className: "dial-small-text text-start text-secondary",
460
459
  children: n?.description ?? "Copy endpoint URL to easily integrate toolset into your workflows"
461
460
  })]
462
461
  }),
463
- /* @__PURE__ */ P("div", { children: /* @__PURE__ */ P(I, {
462
+ /* @__PURE__ */ D("div", { children: /* @__PURE__ */ D(f, {
464
463
  copiedLabel: a,
465
464
  copyLabel: n?.copyLabel ?? "Copy URL",
466
465
  isCopied: r,
467
466
  onClick: i
468
467
  }) }),
469
- /* @__PURE__ */ P("span", {
468
+ /* @__PURE__ */ D("span", {
470
469
  role: "status",
471
470
  "aria-live": "polite",
472
471
  className: "sr-only",
@@ -474,16 +473,16 @@ var B = /* @__PURE__ */ function(e) {
474
473
  })
475
474
  ]
476
475
  });
477
- }), ue = ({ form: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, connectUrl: a, listToolNames: o, authActions: s, onOAuthLogin: c, onNotifySuccess: l, onNotifyError: u, onChange: d, onAuthChange: f, onEnsureSaved: p, labels: m }) => {
478
- let [g, _] = O(null), v = !!a && !!r, y = E(() => [{
479
- value: B.Http,
476
+ }), ve = ({ form: e, errors: t, isSaving: n, toolsetId: r, isEditMode: i, connectUrl: a, listToolNames: o, authActions: s, onOAuthLogin: c, onNotifySuccess: l, onNotifyError: u, onChange: d, onAuthChange: f, onEnsureSaved: p, labels: m }) => {
477
+ let [g, _] = w(null), v = !!a && !!r, y = C(() => [{
478
+ value: R.Http,
480
479
  label: "HTTP"
481
480
  }, {
482
- value: B.Sse,
481
+ value: R.Sse,
483
482
  label: "SSE"
484
483
  }], []);
485
- return T(() => {
486
- if (!r || !o || !Z(e.auth, i)) {
484
+ return S(() => {
485
+ if (!r || !o || !Y(e.auth, i)) {
487
486
  _(null);
488
487
  return;
489
488
  }
@@ -504,10 +503,10 @@ var B = /* @__PURE__ */ function(e) {
504
503
  e.auth,
505
504
  e.endpoint,
506
505
  o
507
- ]), /* @__PURE__ */ F("div", {
506
+ ]), /* @__PURE__ */ O("div", {
508
507
  className: "flex max-w-[1060px] flex-col gap-4",
509
508
  children: [
510
- /* @__PURE__ */ P(h, {
509
+ /* @__PURE__ */ D(j, {
511
510
  id: "toolset-endpoint",
512
511
  value: e.endpoint,
513
512
  onChange: (e) => d({ endpoint: e ?? "" }),
@@ -520,7 +519,7 @@ var B = /* @__PURE__ */ function(e) {
520
519
  error: t.endpoint || void 0,
521
520
  invalid: !!t.endpoint
522
521
  }),
523
- /* @__PURE__ */ P(b, {
522
+ /* @__PURE__ */ D(F, {
524
523
  labelProps: {
525
524
  label: m?.protocolLabel ?? "Protocol",
526
525
  required: !0
@@ -532,7 +531,7 @@ var B = /* @__PURE__ */ function(e) {
532
531
  d({ protocol: e });
533
532
  }
534
533
  }),
535
- g ? /* @__PURE__ */ P(x, {
534
+ g ? /* @__PURE__ */ D(L, {
536
535
  id: "toolset-allowed-tools",
537
536
  multiple: !0,
538
537
  searchable: !0,
@@ -545,15 +544,15 @@ var B = /* @__PURE__ */ function(e) {
545
544
  })),
546
545
  value: e.allowedTools,
547
546
  onChange: (e) => d({ allowedTools: e })
548
- }) : /* @__PURE__ */ P(S, {
547
+ }) : /* @__PURE__ */ D(oe, {
549
548
  id: "toolset-allowed-tools",
550
549
  labelProps: { label: m?.allowedToolsLabel ?? "Allowed tools" },
551
550
  placeholder: m?.allowedToolsPlaceholder ?? "Add tools, comma separated",
552
551
  value: e.allowedTools,
553
552
  onChange: (e) => d({ allowedTools: e }),
554
- tagClassName: L
553
+ tagClassName: h
555
554
  }),
556
- /* @__PURE__ */ P(ce, {
555
+ /* @__PURE__ */ D(ge, {
557
556
  auth: e.auth,
558
557
  errors: t,
559
558
  isSaving: n,
@@ -568,178 +567,202 @@ var B = /* @__PURE__ */ function(e) {
568
567
  onEnsureSaved: p,
569
568
  labels: m?.auth
570
569
  }),
571
- v && /* @__PURE__ */ P(le, {
570
+ v && /* @__PURE__ */ D(_e, {
572
571
  url: a ?? "",
573
572
  labels: m?.connect,
574
573
  className: "border-t border-tertiary pt-4"
575
574
  })
576
575
  ]
577
576
  });
578
- }, de = [
577
+ }, ye = [
579
578
  "keyHeader",
580
579
  "apiKey",
581
580
  "clientId",
582
581
  "clientSecret",
583
582
  "authorizationEndpoint",
584
583
  "tokenEndpoint"
585
- ], fe = [
586
- "name",
587
- "version",
588
- "endpoint",
589
- ...de
590
- ], pe = new Set(fe), me = (e) => {
584
+ ], be = ["endpoint", ...ye], $ = new Set(be), xe = (e) => {
591
585
  let t = {};
592
- for (let n of Object.keys(e)) pe.has(n) && (t[n] = !0);
586
+ for (let n of Object.keys(e)) $.has(n) && (t[n] = !0);
593
587
  return t;
594
- }, he = ({ initialForm: e, toolsetId: n, onPersist: s, onPostSaveLogin: l, onToolsetsChanged: d, onSaveSuccess: f, onSaveComplete: p, onBack: m, buildMcpUrl: h, listToolNames: _, authActions: y, onOAuthLogin: b, onNotifySuccess: ee, onNotifyError: x, bucket: S, FileManagerModal: C, resolveIconUrl: k, allowedMimeTypes: A, maxFileSizeBytes: j, availableLocaleOptions: te, labels: M }) => {
595
- let I = !!n, [L, R] = O(""), z = n || L, [B, V] = O(e), [H, U] = O(!1), [W, G] = O({}), [K, q] = O({}), Y = D(null);
596
- T(() => {
597
- V(e), Y.current = e, G({}), q({}), R("");
598
- }, [e]);
599
- let X = w((e) => {
600
- V((t) => ({
601
- ...t,
602
- ...e
603
- })), q((t) => ({
604
- ...t,
605
- ...me(e)
606
- })), G((t) => {
607
- let n = { ...t };
608
- for (let t of Object.keys(e)) delete n[t];
609
- return n;
610
- });
611
- }, []), ne = w((e) => {
612
- V((t) => ({
588
+ }, Se = ({ initialForm: r, toolsetId: i, onPersist: o, onPostSaveLogin: c, onToolsetsChanged: u, onSaveSuccess: f, onSaveComplete: h, onBack: _, buildMcpUrl: v, listToolNames: b, authActions: T, onOAuthLogin: te, onNotifySuccess: ne, onNotifyError: E, bucket: re, FileManagerModal: O, resolveIconUrl: ie, allowedMimeTypes: ae, maxFileSizeBytes: k, availableLocaleOptions: A, onRefineDescription: j, labels: M }) => {
589
+ let N = !!i, [P, F] = w(""), I = i || P, [L, oe] = w({
590
+ initialForm: r,
591
+ key: 0
592
+ });
593
+ L.initialForm !== r && oe({
594
+ initialForm: r,
595
+ key: L.key + 1
596
+ });
597
+ let { values: R, setValues: z, markTouched: B, visibleErrorCodes: V, attemptSubmit: H } = a({
598
+ initialValues: C(() => fe(r), [r]),
599
+ validationOptions: ce,
600
+ reseedKey: L.key
601
+ }), [le, U] = w(r), W = C(() => ({
602
+ ...le,
603
+ ...R
604
+ }), [le, R]), [K, q] = w(!1), [J, Y] = w({}), [de, X] = w({}), Z = ee(null);
605
+ S(() => {
606
+ U(r), Z.current = r, Y({}), X({}), F("");
607
+ }, [r]);
608
+ let Q = x((e) => {
609
+ let { metadata: t, setup: r } = pe(e);
610
+ Object.keys(t).length > 0 && (z(t), "name" in t && B(n.Name), "version" in t && B(n.Version)), Object.keys(r).length !== 0 && (U((e) => ({
611
+ ...e,
612
+ ...r
613
+ })), X((e) => ({
614
+ ...e,
615
+ ...xe(r)
616
+ })), Y((e) => {
617
+ let t = { ...e };
618
+ for (let e of Object.keys(r)) delete t[e];
619
+ return t;
620
+ }));
621
+ }, [z, B]), he = x((e) => {
622
+ U((t) => ({
613
623
  ...t,
614
624
  auth: {
615
625
  ...t.auth,
616
626
  ...e
617
627
  }
618
- })), q((t) => ({
628
+ })), X((t) => ({
619
629
  ...t,
620
- ...me(e)
621
- })), G((t) => {
630
+ ...xe(e)
631
+ })), Y((t) => {
622
632
  let n = { ...t };
623
- if ("authenticationType" in e || "withLogin" in e || "isLoggedIn" in e) for (let e of de) delete n[e];
633
+ if ("authenticationType" in e || "withLogin" in e || "isLoggedIn" in e) for (let e of ye) delete n[e];
624
634
  else for (let t of Object.keys(e)) delete n[t];
625
635
  return n;
626
- }), "isLoggedIn" in e && d();
627
- }, [d]), Z = w(async () => {
628
- if (z && Y.current != null && JSON.stringify(Y.current) === JSON.stringify(B)) return z;
629
- U(!0);
636
+ }), "isLoggedIn" in e && u();
637
+ }, [u]), ge = x(async () => {
638
+ if (I && Z.current != null && JSON.stringify(Z.current) === JSON.stringify(W)) return I;
639
+ q(!0);
630
640
  try {
631
- let e = await s(B, z);
632
- return e ? (z || R(e), Y.current = B, await d(), e) : null;
641
+ let e = await o(W, I);
642
+ return e ? (I || F(e), Z.current = W, await u(), e) : null;
633
643
  } catch {
634
644
  return null;
635
645
  } finally {
636
- U(!1);
646
+ q(!1);
637
647
  }
638
648
  }, [
639
- B,
640
- z,
641
- s,
642
- d
643
- ]), ie = w(async () => await Z() ?? !1, [Z]), Q = w((e) => {
644
- let n = M?.validation, r = {}, i = a(e, { validateVersionPattern: !0 });
645
- return i.name === t.Required && (r.name = n?.nameRequired ?? "Name is required"), i.version === t.InvalidFormat && (r.version = n?.versionInvalid ?? "Version may only contain letters, digits, dots, underscores, and dashes"), e.endpoint.trim() ? J(e.endpoint) || (r.endpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL") : r.endpoint = n?.endpointRequired ?? "Endpoint is required", e.auth.isLoggedIn || (e.auth.authenticationType === o.ApiKey && (e.auth.keyHeader?.trim() || (r.keyHeader = n?.keyHeaderRequired ?? "Key name is required"), e.auth.withLogin === c.WithLogin && !e.auth.apiKey?.trim() && (r.apiKey = n?.apiKeyRequired ?? "API key is required")), e.auth.authenticationType === o.OAuth && e.auth.withLogin === c.WithConfig && (e.auth.clientId?.trim() || (r.clientId = n?.clientIdRequired ?? "Client ID is required"), !I && !e.auth.clientSecret?.trim() && (r.clientSecret = n?.clientSecretRequired ?? "Client secret is required"), e.auth.authorizationEndpoint?.trim() && !J(e.auth.authorizationEndpoint) && (r.authorizationEndpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL"), e.auth.tokenEndpoint?.trim() && !J(e.auth.tokenEndpoint) && (r.tokenEndpoint = n?.endpointInvalid ?? "Enter a valid http(s) URL"))), r;
646
- }, [M, I]), $ = w(async () => {
647
- let e = Q(B);
648
- if (Object.keys(e).length > 0) {
649
- G(e);
649
+ W,
650
+ I,
651
+ o,
652
+ u
653
+ ]), _e = x(async () => await ge() ?? !1, [ge]), $ = x((e) => {
654
+ let t = M?.validation, n = {};
655
+ return e.endpoint.trim() ? G(e.endpoint) || (n.endpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL") : n.endpoint = t?.endpointRequired ?? "Endpoint is required", e.auth.isLoggedIn || (e.auth.authenticationType === s.ApiKey && (e.auth.keyHeader?.trim() || (n.keyHeader = t?.keyHeaderRequired ?? "Key name is required"), e.auth.withLogin === l.WithLogin && !e.auth.apiKey?.trim() && (n.apiKey = t?.apiKeyRequired ?? "API key is required")), e.auth.authenticationType === s.OAuth && e.auth.withLogin === l.WithConfig && (e.auth.clientId?.trim() || (n.clientId = t?.clientIdRequired ?? "Client ID is required"), !N && !e.auth.clientSecret?.trim() && (n.clientSecret = t?.clientSecretRequired ?? "Client secret is required"), e.auth.authorizationEndpoint?.trim() && !G(e.auth.authorizationEndpoint) && (n.authorizationEndpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL"), e.auth.tokenEndpoint?.trim() && !G(e.auth.tokenEndpoint) && (n.tokenEndpoint = t?.endpointInvalid ?? "Enter a valid http(s) URL"))), n;
656
+ }, [M, N]), Se = x(async () => {
657
+ let e = H(), t = $(W);
658
+ if (!e || Object.keys(t).length > 0) {
659
+ Y(t);
650
660
  return;
651
661
  }
652
- G({}), U(!0);
662
+ Y({}), q(!0);
653
663
  try {
654
- let e = await s(B, z);
664
+ let e = await o(W, I);
655
665
  if (!e) return;
656
- await d(), f(B);
666
+ await u(), f(W);
657
667
  try {
658
- await l(e, B.auth), p();
668
+ await c(e, W.auth), h();
659
669
  } catch (e) {
660
- let { traceId: t } = await u(e);
661
- x(M?.settings?.auth?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
670
+ let { traceId: t } = await d(e);
671
+ E(M?.settings?.auth?.errorLoginFailed ?? "Failed to log in. Please check your credentials and try again.", t);
662
672
  }
663
673
  } catch {} finally {
664
- U(!1);
674
+ q(!1);
665
675
  }
666
676
  }, [
667
- B,
668
- Q,
669
- z,
670
- s,
671
- d,
677
+ H,
678
+ W,
679
+ $,
680
+ I,
681
+ o,
682
+ u,
672
683
  f,
673
- p,
674
- l,
675
- x,
684
+ h,
685
+ c,
686
+ E,
676
687
  M
677
- ]), oe = E(() => !re(B, I), [B, I]), se = E(() => {
678
- let e = Q(B), t = { ...W };
679
- for (let n of fe) {
680
- if (!K[n]) continue;
681
- let r = e[n];
682
- r ? t[n] = r : delete t[n];
688
+ ]), Ce = y({
689
+ value: R.description,
690
+ onChange: (e) => Q({ description: e }),
691
+ onRefine: j,
692
+ disabled: K,
693
+ resetKey: L.key
694
+ }), we = j ? (e, t) => /* @__PURE__ */ D(g, {
695
+ isEnabled: !0,
696
+ fieldId: t,
697
+ label: M?.general?.form?.description.label ?? "Description",
698
+ labels: M?.refinement,
699
+ refinement: Ce,
700
+ disabled: Ce.isPending || K,
701
+ children: e
702
+ }) : void 0, Te = C(() => !ue(W, N), [W, N]), Ee = C(() => {
703
+ let t = M?.validation, n = $(W), r = { ...J };
704
+ for (let e of be) {
705
+ if (!de[e]) continue;
706
+ let t = n[e];
707
+ t ? r[e] = t : delete r[e];
683
708
  }
684
- return t;
709
+ return V.name === e.Required ? r.name = t?.nameRequired ?? "Name is required" : V.name === e.TooLong ? r.name = t?.nameTooLong ?? `Use ${m} characters or fewer.` : V.name === e.ControlCharacters && (r.name = t?.nameControlCharacters ?? "Remove line breaks, tabs and other control characters."), V.description === e.TooLong && (r.description = t?.descriptionTooLong ?? `Use ${p} characters or fewer.`), V.version === e.InvalidFormat && (r.version = t?.versionInvalid ?? "Version must follow semantic versioning (e.g., 1.0.0)"), r;
685
710
  }, [
686
- K,
711
+ de,
712
+ J,
687
713
  W,
688
- B,
689
- Q
690
- ]), ce = h && z ? h(z) : void 0;
691
- return /* @__PURE__ */ P(r, {
692
- title: I ? M?.layout?.editTitle ?? "Edit toolset" : M?.layout?.createTitle ?? "Create toolset",
693
- onBack: m,
694
- backAriaLabel: M?.layout?.backAriaLabel ?? "Back to catalog",
695
- isSaving: H,
696
- labels: { savingStatusLabel: M?.layout?.savingStatusLabel ?? "Saving" },
697
- actions: /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(g, {
698
- label: M?.layout?.cancelLabel ?? "Cancel",
699
- onClick: m
700
- }), /* @__PURE__ */ P(v, {
701
- label: I ? M?.layout?.saveLabel ?? "Save" : M?.layout?.createLabel ?? "Create",
702
- disabled: oe,
703
- onClick: $
704
- })] }),
705
- leftContent: /* @__PURE__ */ P(i, {
706
- title: M?.layout?.metadataSectionTitle ?? "Metadata",
707
- className: "border-0 p-4 desktop:p-6",
708
- children: /* @__PURE__ */ P(ae, {
709
- form: B,
710
- errors: se,
711
- bucket: S,
712
- FileManagerModal: C,
713
- resolveIconUrl: k,
714
- allowedMimeTypes: A,
715
- maxFileSizeBytes: j,
716
- availableLocaleOptions: te,
717
- onChange: X,
718
- labels: M?.general
719
- })
714
+ M,
715
+ V,
716
+ $
717
+ ]), De = v && I ? v(I) : void 0;
718
+ return /* @__PURE__ */ D(t, {
719
+ title: N ? M?.layout?.editTitle ?? "Edit toolset" : M?.layout?.createTitle ?? "Create toolset",
720
+ onBack: _,
721
+ onCancel: _,
722
+ onSubmit: Se,
723
+ submitLabel: N ? M?.layout?.saveLabel ?? "Save" : M?.layout?.createLabel ?? "Create",
724
+ isSubmitting: K,
725
+ isSubmitDisabled: Te || Ce.isPending,
726
+ metadataSectionClassName: se.metadataSection,
727
+ setupSectionClassName: se.setupSection,
728
+ labels: {
729
+ backAriaLabel: M?.layout?.backAriaLabel ?? "Back to catalog",
730
+ savingStatusLabel: M?.layout?.savingStatusLabel ?? "Saving",
731
+ metadataTitle: M?.layout?.metadataSectionTitle ?? "Metadata",
732
+ setupTitle: M?.layout?.setupSectionTitle ?? "Setup",
733
+ cancelLabel: M?.layout?.cancelLabel ?? "Cancel"
734
+ },
735
+ metadata: /* @__PURE__ */ D(me, {
736
+ form: W,
737
+ errors: Ee,
738
+ bucket: re,
739
+ FileManagerModal: O,
740
+ resolveIconUrl: ie,
741
+ allowedMimeTypes: ae,
742
+ maxFileSizeBytes: k,
743
+ availableLocaleOptions: A,
744
+ onChange: Q,
745
+ renderDescription: we,
746
+ labels: M?.general
720
747
  }),
721
- rightContent: /* @__PURE__ */ P(i, {
722
- title: M?.layout?.setupSectionTitle ?? "Setup",
723
- className: "border-0 p-4 desktop:p-6",
724
- children: /* @__PURE__ */ P(ue, {
725
- form: B,
726
- errors: se,
727
- isSaving: H,
728
- toolsetId: z,
729
- isEditMode: I,
730
- connectUrl: ce,
731
- listToolNames: _,
732
- authActions: y,
733
- onOAuthLogin: b,
734
- onNotifySuccess: ee,
735
- onNotifyError: x,
736
- onChange: X,
737
- onAuthChange: ne,
738
- onEnsureSaved: ie,
739
- labels: M?.settings
740
- })
748
+ setup: /* @__PURE__ */ D(ve, {
749
+ form: W,
750
+ errors: Ee,
751
+ isSaving: K,
752
+ toolsetId: I,
753
+ isEditMode: N,
754
+ connectUrl: De,
755
+ listToolNames: b,
756
+ authActions: T,
757
+ onOAuthLogin: te,
758
+ onNotifySuccess: ne,
759
+ onNotifyError: E,
760
+ onChange: Q,
761
+ onAuthChange: he,
762
+ onEnsureSaved: _e,
763
+ labels: M?.settings
741
764
  })
742
765
  });
743
766
  };
744
767
  //#endregion
745
- export { U as AUTH_TYPE_ICONS, V as DEFAULT_TOOLSET_NAME, H as DEFAULT_TOOLSET_VERSION, ae as GeneralForm, he as ToolsetEditor, $ as ToolsetOAuthLoginStatus, B as ToolsetTransportType, K as getDefaultToolsetForm, W as getStorageSafeUniqueToolsetName, Z as isToolsetAuthValid, re as isToolsetFormValid, J as isValidEndpointUrl, X as normalizeReturnedEndpointUrl };
768
+ export { V as AUTH_TYPE_ICONS, z as DEFAULT_TOOLSET_NAME, B as DEFAULT_TOOLSET_VERSION, me as GeneralForm, se as TOOLSET_EDITOR_CLASS, Se as ToolsetEditor, Z as ToolsetOAuthLoginStatus, R as ToolsetTransportType, U as getDefaultToolsetForm, H as getStorageSafeUniqueToolsetName, Y as isToolsetAuthValid, ue as isToolsetFormValid, G as isValidEndpointUrl, q as normalizeReturnedEndpointUrl };