@bpinternal/integration-hub 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1120 +1,1297 @@
1
- import { jsx as v, jsxs as K } from "react/jsx-runtime";
2
- import { Loader2 as It } from "lucide-react";
3
- import { useState as P, useRef as ut, useEffect as ct, useMemo as L, useCallback as J } from "react";
4
- import { I as Gt, c as lt, a as Zt, b as Jt, d as Xt, e as Yt, f as mt, g as tn, h as nn, i as en, j as on, k as an } from "../chunks/index.js";
5
- import { StaticZuiForm as sn } from "@bpinternal/static-zui-form";
6
- import { useQueryClient as At, useQuery as St, useMutation as j } from "@tanstack/react-query";
1
+ import { jsx as I, jsxs as $ } from "react/jsx-runtime";
2
+ import { Loader2 as Lt } from "lucide-react";
3
+ import { useState as x, useRef as G, useEffect as Z, useMemo as F, useCallback as N } from "react";
4
+ import { I as ue, c as bt, u as fe, a as ge, b as pe, d as he, e as be, f as ve, g as Ce, h as ye, i as Ie, j as we, k as Se, l as Ae } from "../chunks/index.js";
5
+ import { StaticZuiForm as Me } from "@bpinternal/static-zui-form";
6
+ import { useQueryClient as kt, useQuery as Et, useMutation as Q } from "@tanstack/react-query";
7
7
  import "framer-motion";
8
8
  import "clsx";
9
9
  import "tailwind-merge";
10
10
  import "@base-ui/react/menu";
11
- const rn = "width=650,height=800,popup=true", cn = 500, ln = 5 * 60 * 1e3, dn = (n) => {
12
- if (!n)
11
+ const Te = "width=650,height=800,popup=true", Oe = 500, Pe = 5 * 60 * 1e3, Be = (t) => {
12
+ if (!t)
13
13
  return null;
14
14
  try {
15
- return new URL(n).pathname.split("/").filter(Boolean).at(-1) ?? null;
15
+ return new URL(t).pathname.split("/").filter(Boolean).at(-1) ?? null;
16
16
  } catch {
17
- return n.split("/").filter(Boolean).at(-1) ?? null;
17
+ return t.split("/").filter(Boolean).at(-1) ?? null;
18
18
  }
19
- }, un = async ({
20
- client: n,
21
- linkTemplateScript: t,
22
- data: e
19
+ }, Ue = async ({
20
+ client: t,
21
+ linkTemplateScript: e,
22
+ data: i
23
23
  }) => {
24
- const { result: i } = await n.runVrl({
25
- script: t,
26
- data: e ?? {}
24
+ const { result: n } = await t.runVrl({
25
+ script: e,
26
+ data: i ?? {}
27
27
  });
28
- if (typeof i != "string")
28
+ if (typeof n != "string")
29
29
  throw new Error("Authorization URL is not a string");
30
- return i;
31
- }, pn = async ({
32
- authorizationUrl: n,
33
- onClose: t,
34
- popupFeatures: e = rn,
35
- pollIntervalMs: i = cn,
36
- timeoutMs: o = ln
30
+ return n;
31
+ }, xe = async ({
32
+ authorizationUrl: t,
33
+ onClose: e,
34
+ popupFeatures: i = Te,
35
+ pollIntervalMs: n = Oe,
36
+ timeoutMs: o = Pe
37
37
  }) => {
38
- const a = window.open(n, "OAuth", e);
38
+ const a = window.open(t, "OAuth", i);
39
39
  if (!a)
40
40
  return "blocked";
41
41
  if (!await new Promise((c) => {
42
- const s = window.setInterval(() => {
42
+ const r = window.setInterval(() => {
43
43
  try {
44
44
  if (!a.closed)
45
45
  return;
46
- window.clearInterval(s), window.clearTimeout(d), c(!0);
46
+ window.clearInterval(r), window.clearTimeout(l), c(!0);
47
47
  } catch {
48
- window.clearInterval(s), window.clearTimeout(d), c(!1);
48
+ window.clearInterval(r), window.clearTimeout(l), c(!1);
49
49
  }
50
- }, i), d = window.setTimeout(() => {
51
- window.clearInterval(s), a.closed || a.close(), c(!1);
50
+ }, n), l = window.setTimeout(() => {
51
+ window.clearInterval(r), a.closed || a.close(), c(!1);
52
52
  }, o);
53
53
  }))
54
54
  return "timeout";
55
55
  try {
56
- return await (t == null ? void 0 : t()), "completed";
56
+ return await (e == null ? void 0 : e()), "completed";
57
57
  } catch {
58
58
  return "failed";
59
59
  }
60
- }, fn = (n) => n instanceof Error ? n : new Error("OAuth authorization failed"), gn = ({
61
- client: n,
62
- integrationName: t,
63
- linkTemplateScript: e,
64
- webhookId: i,
60
+ }, De = (t) => t instanceof Error ? t : new Error("OAuth authorization failed"), Le = ({
61
+ client: t,
62
+ integrationName: e,
63
+ linkTemplateScript: i,
64
+ webhookId: n,
65
65
  webhookUrl: o,
66
66
  oauthTemplateData: a,
67
- isAuthorized: l = !1,
67
+ isAuthorized: d = !1,
68
68
  disabled: c = !1,
69
- onAuthorized: s,
70
- onError: d
69
+ onAuthorized: r,
70
+ onError: l
71
71
  }) => {
72
- const [u, C] = P(null), [b, I] = P(!1), [O, x] = P(!1), M = i ?? dn(o), h = !!(i || o), p = ut(d);
73
- ct(() => {
74
- p.current = d;
75
- }, [d]);
76
- const S = L(() => {
72
+ const [u, v] = x(null), [C, S] = x(!1), [T, O] = x(!1), B = n ?? Be(o), h = !!(n || o), g = G(l);
73
+ Z(() => {
74
+ g.current = l;
75
+ }, [l]);
76
+ const M = F(() => {
77
77
  try {
78
78
  return JSON.stringify(a ?? {});
79
79
  } catch {
80
80
  return "{}";
81
81
  }
82
82
  }, [a]);
83
- ct(() => {
83
+ Z(() => {
84
84
  if (!h) {
85
- C(null), I(!1);
85
+ v(null), S(!1);
86
86
  return;
87
87
  }
88
- let f = !1;
88
+ let p = !1;
89
89
  return (async () => {
90
- var y;
90
+ var P;
91
91
  let k = {};
92
92
  try {
93
- k = JSON.parse(S);
93
+ k = JSON.parse(M);
94
94
  } catch {
95
95
  k = {};
96
96
  }
97
- const E = {
97
+ const y = {
98
98
  webhookUrl: o ?? null,
99
- webhookId: M,
99
+ webhookId: B,
100
100
  ...k
101
101
  };
102
- I(!0);
102
+ S(!0);
103
103
  try {
104
- const N = await un({
105
- client: n,
106
- linkTemplateScript: e,
107
- data: E
104
+ const V = await Ue({
105
+ client: t,
106
+ linkTemplateScript: i,
107
+ data: y
108
108
  });
109
- f || C(N);
110
- } catch (N) {
111
- f || (C(null), (y = p.current) == null || y.call(p, fn(N)));
109
+ p || v(V);
110
+ } catch (V) {
111
+ p || (v(null), (P = g.current) == null || P.call(g, De(V)));
112
112
  } finally {
113
- f || I(!1);
113
+ p || S(!1);
114
114
  }
115
115
  })(), () => {
116
- f = !0;
116
+ p = !0;
117
117
  };
118
- }, [n, h, e, S, o, M]);
119
- const _ = h && !!u && !b && !c, H = async () => {
120
- var f, A, k;
121
- if (!(!u || O)) {
122
- x(!0);
118
+ }, [t, h, i, M, o, B]);
119
+ const j = h && !!u && !C && !c, _ = async () => {
120
+ var p, A, k;
121
+ if (!(!u || T)) {
122
+ O(!0);
123
123
  try {
124
- const E = await pn({
124
+ const y = await xe({
125
125
  authorizationUrl: u,
126
- onClose: s
126
+ onClose: r
127
127
  });
128
- if (E === "completed")
128
+ if (y === "completed")
129
129
  return;
130
- if (E === "blocked") {
131
- (f = p.current) == null || f.call(p, new Error("Please allow browser popups to authorize this integration."));
130
+ if (y === "blocked") {
131
+ (p = g.current) == null || p.call(g, new Error("Please allow browser popups to authorize this integration."));
132
132
  return;
133
133
  }
134
- if (E === "timeout") {
135
- (A = p.current) == null || A.call(p, new Error("OAuth popup did not close in time. Please close it and try again."));
134
+ if (y === "timeout") {
135
+ (A = g.current) == null || A.call(g, new Error("OAuth popup did not close in time. Please close it and try again."));
136
136
  return;
137
137
  }
138
- (k = p.current) == null || k.call(p, new Error("OAuth authorization finished but refresh failed."));
138
+ (k = g.current) == null || k.call(g, new Error("OAuth authorization finished but refresh failed."));
139
139
  } finally {
140
- x(!1);
140
+ O(!1);
141
141
  }
142
142
  }
143
143
  };
144
- return /* @__PURE__ */ v(
145
- Gt,
144
+ return /* @__PURE__ */ I(
145
+ ue,
146
146
  {
147
- integrationName: t,
148
- canAuthorize: _,
149
- isAuthorizing: O,
150
- isAuthorized: l,
147
+ integrationName: e,
148
+ canAuthorize: j,
149
+ isAuthorizing: T,
150
+ isAuthorized: d,
151
151
  disabled: c,
152
152
  showInstallHint: !h,
153
153
  onClick: () => {
154
- H();
154
+ _();
155
155
  }
156
156
  }
157
157
  );
158
- }, Tt = ({
159
- definition: n,
160
- selectedConnectionMethod: t
158
+ }, Nt = ({
159
+ definition: t,
160
+ selectedConnectionMethod: e
161
161
  }) => {
162
- var i, o, a;
163
- const e = t != null ? (o = (i = n.configurations) == null ? void 0 : i[t]) == null ? void 0 : o.schema : (a = n.configuration) == null ? void 0 : a.schema;
164
- return !e || typeof e != "object" ? null : e;
165
- }, Ot = (n) => {
166
- if (!n || typeof n != "object")
162
+ var n, o, a;
163
+ const i = e != null ? (o = (n = t.configurations) == null ? void 0 : n[e]) == null ? void 0 : o.schema : (a = t.configuration) == null ? void 0 : a.schema;
164
+ return !i || typeof i != "object" ? null : i;
165
+ }, Vt = (t) => {
166
+ if (!t || typeof t != "object")
167
167
  return [];
168
- const t = n.properties;
169
- return !t || typeof t != "object" ? [] : Object.keys(t);
170
- }, at = (n) => !n || typeof n != "object" || Array.isArray(n) ? {} : n, yt = (n, t) => {
171
- if (t.length === 0)
168
+ const e = t.properties;
169
+ return !e || typeof e != "object" ? [] : Object.keys(e);
170
+ }, gt = (t) => !t || typeof t != "object" || Array.isArray(t) ? {} : t, Ut = (t, e) => {
171
+ if (e.length === 0)
172
172
  return {};
173
- const e = t.filter((i) => Object.prototype.hasOwnProperty.call(n, i)).map((i) => [i, n[i]]);
174
- return Object.fromEntries(e);
175
- }, Z = (n) => !!n && typeof n == "object" && !Array.isArray(n), dt = (n, t) => {
176
- if (Object.is(n, t))
173
+ const i = e.filter((n) => Object.prototype.hasOwnProperty.call(t, n)).map((n) => [n, t[n]]);
174
+ return Object.fromEntries(i);
175
+ }, it = (t) => !!t && typeof t == "object" && !Array.isArray(t), vt = (t, e) => {
176
+ if (Object.is(t, e))
177
177
  return !0;
178
- if (Array.isArray(n) || Array.isArray(t))
179
- return !Array.isArray(n) || !Array.isArray(t) || n.length !== t.length ? !1 : n.every((e, i) => dt(e, t[i]));
180
- if (Z(n) || Z(t)) {
181
- if (!Z(n) || !Z(t))
178
+ if (Array.isArray(t) || Array.isArray(e))
179
+ return !Array.isArray(t) || !Array.isArray(e) || t.length !== e.length ? !1 : t.every((i, n) => vt(i, e[n]));
180
+ if (it(t) || it(e)) {
181
+ if (!it(t) || !it(e))
182
182
  return !1;
183
- const e = Object.keys(n), i = Object.keys(t);
184
- return e.length !== i.length ? !1 : e.every(
185
- (o) => Object.prototype.hasOwnProperty.call(t, o) && dt(n[o], t[o])
183
+ const i = Object.keys(t), n = Object.keys(e);
184
+ return i.length !== n.length ? !1 : i.every(
185
+ (o) => Object.prototype.hasOwnProperty.call(e, o) && vt(t[o], e[o])
186
186
  );
187
187
  }
188
188
  return !1;
189
- }, hn = ({
190
- definition: n,
191
- installedState: t,
192
- selectedConnectionMethod: e,
193
- onSave: i,
189
+ }, ke = ({
190
+ definition: t,
191
+ installedState: e,
192
+ selectedConnectionMethod: i,
193
+ onSave: n,
194
194
  isSaving: o,
195
195
  disabled: a = !1
196
196
  }) => {
197
- const l = L(
198
- () => Tt({ definition: n, selectedConnectionMethod: e }),
199
- [n, e]
200
- ), c = L(() => Ot(l), [l]), s = L(
201
- () => yt(at(t == null ? void 0 : t.configuration), c),
202
- [t == null ? void 0 : t.configuration, c]
203
- ), d = L(() => c.join("\0"), [c]), [u, C] = P({}), [b, I] = P(null), [O, x] = P(0), M = ut(null);
204
- return ct(() => {
197
+ const d = F(
198
+ () => Nt({ definition: t, selectedConnectionMethod: i }),
199
+ [t, i]
200
+ ), c = F(() => Vt(d), [d]), r = F(
201
+ () => Ut(gt(e == null ? void 0 : e.configuration), c),
202
+ [e == null ? void 0 : e.configuration, c]
203
+ ), l = F(() => c.join("\0"), [c]), [u, v] = x({}), [C, S] = x(null), [T, O] = x(0), B = G(null);
204
+ return Z(() => {
205
205
  const h = {
206
- integrationAlias: (t == null ? void 0 : t.integrationAlias) ?? null,
207
- configurationType: (t == null ? void 0 : t.configurationType) ?? null,
208
- schemaKeySignature: d,
209
- configuration: s
210
- }, p = M.current;
211
- p && p.integrationAlias === h.integrationAlias && p.configurationType === h.configurationType && p.schemaKeySignature === h.schemaKeySignature && dt(p.configuration, h.configuration) || (M.current = h, C(s), I(null), x((S) => S + 1));
212
- }, [s, t == null ? void 0 : t.integrationAlias, t == null ? void 0 : t.configurationType, d]), !l || c.length === 0 ? null : /* @__PURE__ */ K("div", { className: "flex flex-col gap-3", children: [
213
- /* @__PURE__ */ v(
214
- sn,
206
+ integrationAlias: (e == null ? void 0 : e.integrationAlias) ?? null,
207
+ configurationType: (e == null ? void 0 : e.configurationType) ?? null,
208
+ schemaKeySignature: l,
209
+ configuration: r
210
+ }, g = B.current;
211
+ g && g.integrationAlias === h.integrationAlias && g.configurationType === h.configurationType && g.schemaKeySignature === h.schemaKeySignature && vt(g.configuration, h.configuration) || (B.current = h, v(r), S(null), O((M) => M + 1));
212
+ }, [r, e == null ? void 0 : e.integrationAlias, e == null ? void 0 : e.configurationType, l]), !d || c.length === 0 ? null : /* @__PURE__ */ $("div", { className: "flex flex-col gap-3", children: [
213
+ /* @__PURE__ */ I(
214
+ Me,
215
215
  {
216
- schema: l,
216
+ schema: d,
217
217
  value: u,
218
218
  onChange: (h) => {
219
- const p = yt(at(h), c);
220
- C(p);
219
+ const g = Ut(gt(h), c);
220
+ v(g);
221
221
  },
222
222
  onValidation: ({ formValid: h }) => {
223
- I(h);
223
+ S(h);
224
224
  }
225
225
  },
226
- O
226
+ T
227
227
  ),
228
- /* @__PURE__ */ K(
228
+ /* @__PURE__ */ $(
229
229
  "button",
230
230
  {
231
231
  type: "button",
232
- disabled: a || o || b !== !0,
232
+ disabled: a || o || C !== !0,
233
233
  onClick: () => {
234
- const h = at(t == null ? void 0 : t.configuration);
235
- i({
234
+ const h = gt(e == null ? void 0 : e.configuration);
235
+ n({
236
236
  ...h,
237
237
  ...u
238
238
  });
239
239
  },
240
- className: lt(
240
+ className: bt(
241
241
  "relative self-end rounded-lg bg-[var(--gray-12)] px-6 py-2 text-sm text-[var(--gray-1)] hover:opacity-90 cursor-pointer",
242
242
  "disabled:opacity-50 disabled:cursor-not-allowed"
243
243
  ),
244
244
  children: [
245
- /* @__PURE__ */ v("span", { className: o ? "invisible" : "", children: "Save Configuration" }),
246
- o && /* @__PURE__ */ v(It, { className: "absolute inset-0 m-auto h-4 w-4 animate-spin" })
245
+ /* @__PURE__ */ I("span", { className: o ? "invisible" : "", children: "Save Configuration" }),
246
+ o && /* @__PURE__ */ I(Lt, { className: "absolute inset-0 m-auto h-4 w-4 animate-spin" })
247
247
  ]
248
248
  }
249
249
  )
250
250
  ] });
251
- }, Mt = "Other", bn = "team-cloud-services", st = "sandbox", rt = (n) => n.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[_.:/-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (t) => t.toUpperCase()), vn = (n) => n == null ? void 0 : n.replace(/\.$/, ""), Pt = (n) => {
252
- var t;
253
- return n && "meta" in n ? ((t = n.meta) == null ? void 0 : t.installs) ?? null : null;
254
- }, pt = (n) => n instanceof Error ? n : new Error("An unknown error occurred while loading integrations"), xt = (n) => n === bn, Bt = (n, t) => {
251
+ }, Ft = "Other", Ee = "team-cloud-services", pt = "sandbox", ht = (t) => t.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[_.:/-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase()), Ne = (t) => t == null ? void 0 : t.replace(/\.$/, ""), jt = (t) => {
252
+ var e;
253
+ return t && "meta" in t ? ((e = t.meta) == null ? void 0 : e.installs) ?? null : null;
254
+ }, Ct = (t) => t instanceof Error ? t : new Error("An unknown error occurred while loading integrations"), _t = (t) => t === Ee, Kt = (t, e) => {
255
255
  var o;
256
- const e = t == null ? void 0 : t(n);
257
- if (e)
258
- return e;
259
- const i = (o = n.attributes) == null ? void 0 : o.category;
260
- return typeof i == "string" && i.length > 0 ? i : Mt;
261
- }, X = (n) => n ? Object.entries(n).map(([t, e]) => {
262
- const i = e;
256
+ const i = e == null ? void 0 : e(t);
257
+ if (i)
258
+ return i;
259
+ const n = (o = t.attributes) == null ? void 0 : o.category;
260
+ return typeof n == "string" && n.length > 0 ? n : Ft;
261
+ }, ot = (t) => t ? Object.entries(t).map(([e, i]) => {
262
+ const n = i;
263
263
  return {
264
- ...i,
265
- id: typeof i.id == "string" && i.id.length > 0 ? i.id : t,
266
- name: typeof i.name == "string" && i.name.length > 0 ? i.name : t,
267
- integrationAlias: t
264
+ ...n,
265
+ id: typeof n.id == "string" && n.id.length > 0 ? n.id : e,
266
+ name: typeof n.name == "string" && n.name.length > 0 ? n.name : e,
267
+ integrationAlias: e
268
268
  };
269
- }) : [], ft = ({
270
- installedIntegrations: n,
271
- integrationId: t,
272
- integrationName: e
273
- }) => n.find((i) => i.id === t) ?? n.find((i) => i.integrationAlias === t) ?? (e ? n.find((i) => i.name === e) : void 0), Cn = ({
274
- summary: n,
275
- installedByName: t,
276
- categoryResolver: e
269
+ }) : [], yt = ({
270
+ installedIntegrations: t,
271
+ integrationId: e,
272
+ integrationName: i
273
+ }) => t.find((n) => n.id === e) ?? t.find((n) => n.integrationAlias === e) ?? (i ? t.find((n) => n.name === i) : void 0), Ve = ({
274
+ summary: t,
275
+ installedByName: e,
276
+ categoryResolver: i
277
277
  }) => {
278
- var s, d, u;
279
- const i = t.get(n.name), o = xt((s = n.ownerWorkspace) == null ? void 0 : s.handle), a = (i == null ? void 0 : i.version) ?? null, l = n.version ?? null, c = a && l ? a !== l : !1;
278
+ var r, l, u;
279
+ const n = e.get(t.name), o = _t((r = t.ownerWorkspace) == null ? void 0 : r.handle), a = (n == null ? void 0 : n.version) ?? null, d = t.version ?? null, c = a && d ? a !== d : !1;
280
280
  return {
281
- id: n.id,
282
- installedId: i == null ? void 0 : i.id,
283
- name: n.name,
284
- title: n.title,
285
- description: n.description,
286
- iconUrl: n.iconUrl,
287
- attributes: { category: Bt(n, e) },
281
+ id: t.id,
282
+ installedId: n == null ? void 0 : n.id,
283
+ name: t.name,
284
+ title: t.title,
285
+ description: t.description,
286
+ iconUrl: t.iconUrl,
287
+ attributes: { category: Kt(t, i) },
288
288
  meta: {
289
- installs: Pt(n)
289
+ installs: jt(t)
290
290
  },
291
- installed: !!i,
292
- enabled: i == null ? void 0 : i.enabled,
291
+ installed: !!n,
292
+ enabled: n == null ? void 0 : n.enabled,
293
293
  hasUpdate: c,
294
- deprecated: (i == null ? void 0 : i.lifecycleStatus) === "deprecated" || n.lifecycleStatus === "deprecated",
295
- author: ((d = n.ownerWorkspace) == null ? void 0 : d.handle) ?? ((u = n.ownerWorkspace) == null ? void 0 : u.name) ?? null,
294
+ deprecated: (n == null ? void 0 : n.lifecycleStatus) === "deprecated" || t.lifecycleStatus === "deprecated",
295
+ author: ((l = t.ownerWorkspace) == null ? void 0 : l.handle) ?? ((u = t.ownerWorkspace) == null ? void 0 : u.name) ?? null,
296
296
  isOfficial: o,
297
- isVerified: n.verificationStatus === "approved",
298
- isPrivate: n.visibility === "private",
299
- visibility: n.visibility,
300
- verificationStatus: n.verificationStatus,
301
- ownerWorkspace: n.ownerWorkspace,
302
- version: n.version,
303
- updatedAt: n.updatedAt
297
+ isVerified: t.verificationStatus === "approved",
298
+ isPrivate: t.visibility === "private",
299
+ visibility: t.visibility,
300
+ verificationStatus: t.verificationStatus,
301
+ ownerWorkspace: t.ownerWorkspace,
302
+ version: t.version,
303
+ updatedAt: t.updatedAt
304
304
  };
305
- }, wn = ({
306
- installedIntegration: n,
307
- summary: t,
308
- categoryResolver: e
305
+ }, Fe = ({
306
+ installedIntegration: t,
307
+ summary: e,
308
+ categoryResolver: i
309
309
  }) => {
310
- var a, l, c;
311
- const i = xt((a = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : a.handle), o = n.version && (t != null && t.version) ? n.version !== (t == null ? void 0 : t.version) : !1;
310
+ var a, d, c;
311
+ const n = _t((a = e == null ? void 0 : e.ownerWorkspace) == null ? void 0 : a.handle), o = t.version && (e != null && e.version) ? t.version !== (e == null ? void 0 : e.version) : !1;
312
312
  return {
313
- id: (t == null ? void 0 : t.id) ?? n.id,
314
- installedId: n.id,
315
- name: (t == null ? void 0 : t.name) ?? n.name,
316
- title: (t == null ? void 0 : t.title) ?? n.name,
317
- description: (t == null ? void 0 : t.description) ?? null,
318
- iconUrl: t == null ? void 0 : t.iconUrl,
313
+ id: (e == null ? void 0 : e.id) ?? t.id,
314
+ installedId: t.id,
315
+ name: (e == null ? void 0 : e.name) ?? t.name,
316
+ title: (e == null ? void 0 : e.title) ?? t.name,
317
+ description: (e == null ? void 0 : e.description) ?? null,
318
+ iconUrl: e == null ? void 0 : e.iconUrl,
319
319
  attributes: {
320
- category: t ? Bt(t, e) : Mt
320
+ category: e ? Kt(e, i) : Ft
321
321
  },
322
322
  meta: {
323
- installs: Pt(t)
323
+ installs: jt(e)
324
324
  },
325
325
  installed: !0,
326
- enabled: n.enabled,
326
+ enabled: t.enabled,
327
327
  hasUpdate: o,
328
- deprecated: n.lifecycleStatus === "deprecated",
329
- author: ((l = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : l.handle) ?? ((c = t == null ? void 0 : t.ownerWorkspace) == null ? void 0 : c.name) ?? null,
330
- isOfficial: i,
331
- isVerified: (t == null ? void 0 : t.verificationStatus) === "approved",
332
- isPrivate: (t == null ? void 0 : t.visibility) === "private",
333
- visibility: t == null ? void 0 : t.visibility,
334
- verificationStatus: t == null ? void 0 : t.verificationStatus,
335
- ownerWorkspace: t == null ? void 0 : t.ownerWorkspace,
336
- version: (t == null ? void 0 : t.version) ?? n.version,
337
- updatedAt: t == null ? void 0 : t.updatedAt
328
+ deprecated: t.lifecycleStatus === "deprecated",
329
+ author: ((d = e == null ? void 0 : e.ownerWorkspace) == null ? void 0 : d.handle) ?? ((c = e == null ? void 0 : e.ownerWorkspace) == null ? void 0 : c.name) ?? null,
330
+ isOfficial: n,
331
+ isVerified: (e == null ? void 0 : e.verificationStatus) === "approved",
332
+ isPrivate: (e == null ? void 0 : e.visibility) === "private",
333
+ visibility: e == null ? void 0 : e.visibility,
334
+ verificationStatus: e == null ? void 0 : e.verificationStatus,
335
+ ownerWorkspace: e == null ? void 0 : e.ownerWorkspace,
336
+ version: (e == null ? void 0 : e.version) ?? t.version,
337
+ updatedAt: e == null ? void 0 : e.updatedAt
338
338
  };
339
- }, yn = (n) => {
340
- if (!n)
339
+ }, je = (t) => {
340
+ if (!t)
341
341
  return {
342
342
  actionCards: [],
343
343
  eventCards: [],
344
344
  channelCards: []
345
345
  };
346
- const t = Object.entries(n.actions ?? {}).filter(([, o]) => {
346
+ const e = Object.entries(t.actions ?? {}).filter(([, o]) => {
347
347
  var a;
348
348
  return ((a = o.attributes) == null ? void 0 : a.bpActionHiddenInStudio) !== "true";
349
349
  }).map(([o, a]) => {
350
- var l;
350
+ var d;
351
351
  return {
352
352
  key: o,
353
- name: rt(o),
353
+ name: ht(o),
354
354
  description: a.description ?? "",
355
355
  type: "action",
356
- billable: ((l = a.attributes) == null ? void 0 : l.billable) === "true"
356
+ billable: ((d = a.attributes) == null ? void 0 : d.billable) === "true"
357
357
  };
358
- }), e = Object.entries(n.events ?? {}).map(([o, a]) => ({
358
+ }), i = Object.entries(t.events ?? {}).map(([o, a]) => ({
359
359
  key: o,
360
- name: rt(o),
360
+ name: ht(o),
361
361
  description: a.description ?? "",
362
362
  type: "event",
363
363
  enabled: !0
364
- })), i = Object.keys(n.channels ?? {}).map((o) => ({
364
+ })), n = Object.keys(t.channels ?? {}).map((o) => ({
365
365
  key: o,
366
- name: rt(o),
366
+ name: ht(o),
367
367
  description: "Channel communication support",
368
368
  type: "channel",
369
369
  enabled: !0
370
370
  }));
371
371
  return {
372
- actionCards: t,
373
- eventCards: e,
374
- channelCards: i
372
+ actionCards: e,
373
+ eventCards: i,
374
+ channelCards: n
375
375
  };
376
- }, In = (n) => {
377
- var a, l, c, s;
378
- if (!n)
376
+ }, _e = (t) => {
377
+ var a, d, c, r;
378
+ if (!t)
379
379
  return [];
380
- const e = [
380
+ const i = [
381
381
  {
382
382
  value: null,
383
- label: !!((l = (a = n.configuration) == null ? void 0 : a.identifier) != null && l.linkTemplateScript) ? "Connect with OAuth" : "Default configuration"
383
+ label: !!((d = (a = t.configuration) == null ? void 0 : a.identifier) != null && d.linkTemplateScript) ? "Connect with OAuth" : "Default configuration"
384
384
  }
385
385
  ];
386
- for (const [d, u] of Object.entries(n.configurations ?? {}))
387
- d !== st && e.push({
388
- value: d,
389
- label: vn(u.description) || u.title || d
386
+ for (const [l, u] of Object.entries(t.configurations ?? {}))
387
+ l !== pt && i.push({
388
+ value: l,
389
+ label: Ne(u.description) || u.title || l
390
390
  });
391
- return !!((c = n.sandbox) == null ? void 0 : c.identifierExtractScript) && !!((s = n.configurations) != null && s[st]) && e.push({ value: st, label: "Connect to a Playground" }), e;
392
- }, An = ({
393
- installedState: n,
394
- connectionMethods: t
391
+ return !!((c = t.sandbox) == null ? void 0 : c.identifierExtractScript) && !!((r = t.configurations) != null && r[pt]) && i.push({ value: pt, label: "Connect to a Playground" }), i;
392
+ }, Ke = ({
393
+ installedState: t,
394
+ connectionMethods: e
395
395
  }) => {
396
- var i;
397
- const e = (n == null ? void 0 : n.configurationType) ?? null;
398
- return t.some((o) => o.value === e) ? e : ((i = t[0]) == null ? void 0 : i.value) ?? null;
399
- }, Sn = ({
400
- integrations: n,
401
- searchTerm: t,
402
- visibility: e,
403
- verification: i,
396
+ var n;
397
+ const i = (t == null ? void 0 : t.configurationType) ?? null;
398
+ return e.some((o) => o.value === i) ? i : ((n = e[0]) == null ? void 0 : n.value) ?? null;
399
+ }, He = ({
400
+ integrations: t,
401
+ searchTerm: e,
402
+ visibility: i,
403
+ verification: n,
404
404
  sortMethod: o
405
405
  }) => {
406
- const a = t.trim().toLowerCase(), l = i ?? [];
407
- let c = n;
408
- if (a && (c = c.filter((u) => (u.title || u.name).toLowerCase().includes(a))), e && e !== "all" && (c = c.filter((u) => e === "private" ? u.isPrivate : !u.isPrivate)), l.length > 0 && (c = c.filter((u) => {
409
- const C = l.includes("official") && u.isOfficial, b = l.includes("verified") && u.isVerified;
410
- return C || b;
406
+ const a = e.trim().toLowerCase(), d = n ?? [];
407
+ let c = t;
408
+ if (a && (c = c.filter((u) => (u.title || u.name).toLowerCase().includes(a))), i && i !== "all" && (c = c.filter((u) => i === "private" ? u.isPrivate : !u.isPrivate)), d.length > 0 && (c = c.filter((u) => {
409
+ const v = d.includes("official") && u.isOfficial, C = d.includes("verified") && u.isVerified;
410
+ return v || C;
411
411
  })), !o)
412
412
  return c;
413
- const s = (u) => (u.title || u.name).toLowerCase(), d = (u) => u.updatedAt ? new Date(u.updatedAt).getTime() : 0;
414
- return [...c].sort((u, C) => o === "asc" ? s(u).localeCompare(s(C), void 0, { sensitivity: "base" }) : o === "desc" ? s(C).localeCompare(s(u), void 0, { sensitivity: "base" }) : o === "newest" ? d(C) - d(u) : d(u) - d(C));
415
- }, Yn = (n) => {
416
- const t = /* @__PURE__ */ new Map();
417
- for (const e of n)
418
- t.set(e.id, e);
419
- return [...t.values()];
420
- }, Ut = ({
421
- client: n,
422
- botId: t,
423
- transformIntegrationPatch: e
424
- }) => async (i, o) => {
425
- const a = e == null ? void 0 : e[i], l = a ? await a(o) : o;
426
- await n.updateBot({ id: t, integrations: l });
427
- }, Tn = (n, t) => ["integration-hub", n, t], On = (n) => {
428
- var e;
429
- if (!n || typeof n != "object")
413
+ const r = (u) => (u.title || u.name).toLowerCase(), l = (u) => u.updatedAt ? new Date(u.updatedAt).getTime() : 0;
414
+ return [...c].sort((u, v) => o === "asc" ? r(u).localeCompare(r(v), void 0, { sensitivity: "base" }) : o === "desc" ? r(v).localeCompare(r(u), void 0, { sensitivity: "base" }) : o === "newest" ? l(v) - l(u) : l(u) - l(v));
415
+ }, wn = (t) => {
416
+ const e = /* @__PURE__ */ new Map();
417
+ for (const i of t)
418
+ e.set(i.id, i);
419
+ return [...e.values()];
420
+ }, Ht = ({
421
+ client: t,
422
+ botId: e,
423
+ transformIntegrationPatch: i
424
+ }) => async (n, o) => {
425
+ const a = i == null ? void 0 : i[n], d = a ? await a(o) : o;
426
+ await t.updateBot({ id: e, integrations: d });
427
+ }, ze = (t, e) => ["integration-hub", t, e], Re = (t) => {
428
+ var i;
429
+ if (!t || typeof t != "object")
430
430
  return !1;
431
- const t = n;
432
- return t.status === 404 || t.statusCode === 404 || ((e = t.response) == null ? void 0 : e.status) === 404;
433
- }, Mn = async ({
434
- client: n,
435
- integrationId: t
431
+ const e = t;
432
+ return e.status === 404 || e.statusCode === 404 || ((i = e.response) == null ? void 0 : i.status) === 404;
433
+ }, qe = async ({
434
+ client: t,
435
+ integrationId: e
436
436
  }) => {
437
437
  try {
438
- return (await n.getPublicIntegrationById({ id: t })).integration;
439
- } catch (e) {
440
- if (!On(e))
441
- throw e;
442
- return (await n.getIntegration({ id: t })).integration;
438
+ return (await t.getPublicIntegrationById({ id: e })).integration;
439
+ } catch (i) {
440
+ if (!Re(i))
441
+ throw i;
442
+ return (await t.getIntegration({ id: e })).integration;
443
443
  }
444
- }, Pn = ({
445
- installedIntegrations: n,
446
- integrationId: t,
447
- integrationName: e
448
- }) => ft({
449
- installedIntegrations: n,
450
- integrationId: t,
451
- integrationName: e
452
- }) ?? null, xn = async ({ client: n, botId: t, integrationId: e }) => {
453
- if (!e)
444
+ }, Qe = ({
445
+ installedIntegrations: t,
446
+ integrationId: e,
447
+ integrationName: i
448
+ }) => yt({
449
+ installedIntegrations: t,
450
+ integrationId: e,
451
+ integrationName: i
452
+ }) ?? null, We = async ({ client: t, botId: e, integrationId: i }) => {
453
+ if (!i)
454
454
  return null;
455
- const [i, o] = await Promise.all([
456
- Mn({ client: n, integrationId: e }),
457
- n.getBot({ id: t })
458
- ]), a = X(o.bot.integrations), l = Pn({
455
+ const [n, o] = await Promise.all([
456
+ qe({ client: t, integrationId: i }),
457
+ t.getBot({ id: e })
458
+ ]), a = ot(o.bot.integrations), d = Qe({
459
459
  installedIntegrations: a,
460
- integrationId: e,
461
- integrationName: i.name
462
- }), c = In(i);
460
+ integrationId: i,
461
+ integrationName: n.name
462
+ }), c = _e(n);
463
463
  return {
464
- definition: i,
465
- installedState: l,
466
- capabilities: yn(i),
464
+ definition: n,
465
+ installedState: d,
466
+ capabilities: je(n),
467
467
  connectionMethods: c,
468
- selectedConnectionMethod: An({ installedState: l, connectionMethods: c })
468
+ selectedConnectionMethod: Ke({ installedState: d, connectionMethods: c })
469
469
  };
470
- }, kt = ({
471
- client: n,
472
- workspaceId: t,
473
- botId: e,
474
- integrationId: i,
470
+ }, zt = ({
471
+ client: t,
472
+ workspaceId: e,
473
+ botId: i,
474
+ integrationId: n,
475
475
  enabled: o = !0,
476
476
  transformIntegrationPatch: a
477
477
  }) => {
478
- const l = At(), c = L(() => Tn(t, e), [t, e]), { data: s, isLoading: d, error: u, refetch: C } = St({
479
- queryKey: [...c, "details", i],
480
- enabled: o && !!i,
481
- queryFn: () => xn({ client: n, workspaceId: t, botId: e, integrationId: i, enabled: o })
482
- }), b = J(async () => {
483
- await l.invalidateQueries({ queryKey: c });
484
- }, [l, c]), I = () => {
485
- if (!(s != null && s.installedState))
478
+ const d = kt(), c = F(() => ze(e, i), [e, i]), { data: r, isLoading: l, error: u, refetch: v } = Et({
479
+ queryKey: [...c, "details", n],
480
+ enabled: o && !!n,
481
+ queryFn: () => We({ client: t, workspaceId: e, botId: i, integrationId: n, enabled: o })
482
+ }), C = N(async () => {
483
+ await d.invalidateQueries({ queryKey: c });
484
+ }, [d, c]), S = () => {
485
+ if (!(r != null && r.installedState))
486
486
  throw new Error("Integration is not installed on this bot");
487
- return s.installedState;
488
- }, O = Ut({ client: n, botId: e, transformIntegrationPatch: a }), x = j({
489
- mutationFn: async (p) => {
490
- const S = I();
491
- await O("configure", {
492
- [S.integrationAlias]: {
493
- configuration: p,
494
- configurationType: S.configurationType ?? null
487
+ return r.installedState;
488
+ }, T = Ht({ client: t, botId: i, transformIntegrationPatch: a }), O = Q({
489
+ mutationFn: async (g) => {
490
+ const M = S();
491
+ await T("configure", {
492
+ [M.integrationAlias]: {
493
+ configuration: g,
494
+ configurationType: M.configurationType ?? null
495
495
  }
496
496
  });
497
497
  },
498
- onSuccess: b
499
- }), M = j({
498
+ onSuccess: C
499
+ }), B = Q({
500
500
  mutationFn: async () => {
501
- const p = I(), S = p.enabled ? "disable" : "enable";
502
- await O(S, {
503
- [p.integrationAlias]: {
504
- enabled: !p.enabled
501
+ const g = S(), M = g.enabled ? "disable" : "enable";
502
+ await T(M, {
503
+ [g.integrationAlias]: {
504
+ enabled: !g.enabled
505
505
  }
506
506
  });
507
507
  },
508
- onSuccess: b
509
- }), h = j({
510
- mutationFn: async (p) => {
511
- const S = I();
512
- await O("configure", {
513
- [S.integrationAlias]: {
514
- configurationType: p
508
+ onSuccess: C
509
+ }), h = Q({
510
+ mutationFn: async (g) => {
511
+ const M = S();
512
+ await T("configure", {
513
+ [M.integrationAlias]: {
514
+ configurationType: g
515
515
  }
516
516
  });
517
517
  },
518
- onSuccess: b
518
+ onSuccess: C
519
519
  });
520
520
  return {
521
- definition: (s == null ? void 0 : s.definition) ?? null,
522
- installedState: (s == null ? void 0 : s.installedState) ?? null,
523
- selectedConnectionMethod: (s == null ? void 0 : s.selectedConnectionMethod) ?? null,
524
- capabilities: (s == null ? void 0 : s.capabilities) ?? {
521
+ definition: (r == null ? void 0 : r.definition) ?? null,
522
+ installedState: (r == null ? void 0 : r.installedState) ?? null,
523
+ selectedConnectionMethod: (r == null ? void 0 : r.selectedConnectionMethod) ?? null,
524
+ capabilities: (r == null ? void 0 : r.capabilities) ?? {
525
525
  actionCards: [],
526
526
  eventCards: [],
527
527
  channelCards: []
528
528
  },
529
- connectionMethods: (s == null ? void 0 : s.connectionMethods) ?? [],
530
- isLoading: d,
531
- error: u ? pt(u) : null,
532
- saveConfig: x.mutateAsync,
533
- toggleEnabled: M.mutateAsync,
529
+ connectionMethods: (r == null ? void 0 : r.connectionMethods) ?? [],
530
+ isLoading: l,
531
+ error: u ? Ct(u) : null,
532
+ saveConfig: O.mutateAsync,
533
+ toggleEnabled: B.mutateAsync,
534
534
  setConnectionMethod: h.mutateAsync,
535
535
  refresh: () => {
536
- C();
536
+ v();
537
537
  },
538
- isSavingConfig: x.isPending,
539
- isTogglingEnabled: M.isPending,
538
+ isSavingConfig: O.isPending,
539
+ isTogglingEnabled: B.isPending,
540
540
  isSettingConnectionMethod: h.isPending
541
541
  };
542
- }, mn = kt, Et = 100, Lt = 200, Bn = (n, t) => ["integration-hub", n, t], Un = ({
543
- publicIntegrations: n,
544
- privateIntegrations: t
542
+ }, Sn = zt, Rt = 100, qt = 200, $e = (t, e) => ["integration-hub", t, e], Ge = ({
543
+ publicIntegrations: t,
544
+ privateIntegrations: e
545
545
  }) => {
546
- const e = /* @__PURE__ */ new Map();
547
- for (const i of n)
548
- e.has(i.id) || e.set(i.id, i);
549
- for (const i of t)
550
- e.set(i.id, i);
551
- return [...e.values()];
552
- }, kn = async ({ client: n }) => {
553
- const t = [];
554
- let e, i = 0;
546
+ const i = /* @__PURE__ */ new Map();
547
+ for (const n of t)
548
+ i.has(n.id) || i.set(n.id, n);
549
+ for (const n of e)
550
+ i.set(n.id, n);
551
+ return [...i.values()];
552
+ }, Je = async ({ client: t }) => {
553
+ const e = [];
554
+ let i, n = 0;
555
555
  do {
556
- const o = e, a = await n.listPublicIntegrations({
557
- limit: Et,
556
+ const o = i, a = await t.listPublicIntegrations({
557
+ limit: Rt,
558
558
  version: "latest",
559
- nextToken: e
559
+ nextToken: i
560
560
  });
561
- if (t.push(...a.integrations), e = a.meta.nextToken, i += 1, i >= Lt)
561
+ if (e.push(...a.integrations), i = a.meta.nextToken, n += 1, n >= qt)
562
562
  throw new Error("Public integration pagination exceeded safety limit");
563
- if (e && e === o)
563
+ if (i && i === o)
564
564
  break;
565
- } while (e);
566
- return t;
567
- }, En = async ({ client: n }) => {
568
- const t = [];
569
- let e, i = 0;
565
+ } while (i);
566
+ return e;
567
+ }, Ze = async ({ client: t }) => {
568
+ const e = [];
569
+ let i, n = 0;
570
570
  do {
571
- const o = e, a = await n.listIntegrations({
572
- limit: Et,
571
+ const o = i, a = await t.listIntegrations({
572
+ limit: Rt,
573
573
  version: "latest",
574
574
  visibility: "private",
575
- nextToken: e
575
+ nextToken: i
576
576
  });
577
- if (t.push(...a.integrations), e = a.meta.nextToken, i += 1, i >= Lt)
577
+ if (e.push(...a.integrations), i = a.meta.nextToken, n += 1, n >= qt)
578
578
  throw new Error("Private integration pagination exceeded safety limit");
579
- if (e && e === o)
579
+ if (i && i === o)
580
580
  break;
581
- } while (e);
582
- return t;
583
- }, Ln = async ({
584
- client: n,
585
- integrationId: t
581
+ } while (i);
582
+ return e;
583
+ }, Xe = async ({
584
+ client: t,
585
+ integrationId: e
586
586
  }) => {
587
587
  try {
588
- return (await n.getPublicIntegrationById({ id: t })).integration.name;
588
+ return (await t.getPublicIntegrationById({ id: e })).integration.name;
589
589
  } catch {
590
590
  try {
591
- return (await n.getIntegration({ id: t })).integration.name;
591
+ return (await t.getIntegration({ id: e })).integration.name;
592
592
  } catch {
593
593
  return;
594
594
  }
595
595
  }
596
- }, Nn = ({
597
- integrationId: n,
598
- installedIntegrations: t
596
+ }, Ye = ({
597
+ integrationId: t,
598
+ installedIntegrations: e
599
599
  }) => {
600
- const e = ft({ installedIntegrations: t, integrationId: n });
601
- return (e == null ? void 0 : e.integrationAlias) ?? n;
602
- }, Fn = async ({ client: n, botId: t, categoryResolver: e }) => {
603
- const [i, o, a] = await Promise.all([
604
- kn({ client: n }),
605
- En({ client: n }),
606
- n.getBot({ id: t })
607
- ]), l = X(a.bot.integrations), c = Un({ publicIntegrations: i, privateIntegrations: o }), s = new Map(l.map((b) => [b.name, b])), d = new Map(c.map((b) => [b.name, b])), u = c.map(
608
- (b) => Cn({
609
- summary: b,
610
- installedByName: s,
611
- categoryResolver: e
600
+ const i = yt({ installedIntegrations: e, integrationId: t });
601
+ return (i == null ? void 0 : i.integrationAlias) ?? t;
602
+ }, me = async ({ client: t, botId: e, categoryResolver: i }) => {
603
+ const [n, o, a] = await Promise.all([
604
+ Je({ client: t }),
605
+ Ze({ client: t }),
606
+ t.getBot({ id: e })
607
+ ]), d = ot(a.bot.integrations), c = Ge({ publicIntegrations: n, privateIntegrations: o }), r = new Map(d.map((C) => [C.name, C])), l = new Map(c.map((C) => [C.name, C])), u = c.map(
608
+ (C) => Ve({
609
+ summary: C,
610
+ installedByName: r,
611
+ categoryResolver: i
612
612
  })
613
- ), C = l.map(
614
- (b) => wn({
615
- installedIntegration: b,
616
- summary: d.get(b.name),
617
- categoryResolver: e
613
+ ), v = d.map(
614
+ (C) => Fe({
615
+ installedIntegration: C,
616
+ summary: l.get(C.name),
617
+ categoryResolver: i
618
618
  })
619
619
  );
620
620
  return {
621
621
  integrations: u,
622
- installedIntegrations: C
622
+ installedIntegrations: v
623
623
  };
624
- }, Nt = ({
625
- client: n,
626
- workspaceId: t,
627
- botId: e,
628
- categoryResolver: i,
624
+ }, Qt = ({
625
+ client: t,
626
+ workspaceId: e,
627
+ botId: i,
628
+ categoryResolver: n,
629
629
  enabled: o = !0,
630
630
  transformIntegrationPatch: a
631
631
  }) => {
632
- const l = At(), c = L(() => Bn(t, e), [t, e]), s = ut(Promise.resolve()), { data: d, isLoading: u, error: C, refetch: b } = St({
632
+ const d = kt(), c = F(() => $e(e, i), [e, i]), r = G(Promise.resolve()), { data: l, isLoading: u, error: v, refetch: C } = Et({
633
633
  queryKey: [...c, "catalog"],
634
634
  enabled: o,
635
- queryFn: () => Fn({ client: n, workspaceId: t, botId: e, categoryResolver: i })
636
- }), I = J(async () => {
637
- await l.invalidateQueries({ queryKey: c });
638
- }, [l, c]), O = J(async (f) => {
639
- const A = s.current.then(f, f);
640
- return s.current = A.then(
635
+ queryFn: () => me({ client: t, workspaceId: e, botId: i, categoryResolver: n })
636
+ }), S = N(async () => {
637
+ await d.invalidateQueries({ queryKey: c });
638
+ }, [d, c]), T = N(async (p) => {
639
+ const A = r.current.then(p, p);
640
+ return r.current = A.then(
641
641
  () => {
642
642
  },
643
643
  () => {
644
644
  }
645
645
  ), A;
646
- }, []), x = Ut({ client: n, botId: e, transformIntegrationPatch: a }), M = async (f) => {
647
- const { bot: A } = await n.getBot({ id: e }), k = X(A.integrations);
648
- return Nn({ integrationId: f, installedIntegrations: k });
649
- }, h = j({
650
- mutationFn: async (f) => {
651
- await O(async () => {
652
- await x("install", { [f]: { enabled: !0 } });
646
+ }, []), O = Ht({ client: t, botId: i, transformIntegrationPatch: a }), B = async (p) => {
647
+ const { bot: A } = await t.getBot({ id: i }), k = ot(A.integrations);
648
+ return Ye({ integrationId: p, installedIntegrations: k });
649
+ }, h = Q({
650
+ mutationFn: async (p) => {
651
+ await T(async () => {
652
+ await O("install", { [p]: { enabled: !0 } });
653
653
  });
654
654
  },
655
- onSuccess: I
656
- }), p = j({
657
- mutationFn: async (f) => {
658
- await O(async () => {
659
- const A = await M(f);
660
- await x("uninstall", { [A]: null });
655
+ onSuccess: S
656
+ }), g = Q({
657
+ mutationFn: async (p) => {
658
+ await T(async () => {
659
+ const A = await B(p);
660
+ await O("uninstall", { [A]: null });
661
661
  });
662
662
  },
663
- onSuccess: I
664
- }), S = j({
665
- mutationFn: async (f) => {
666
- await O(async () => {
667
- const A = await M(f);
668
- await x("enable", { [A]: { enabled: !0 } });
663
+ onSuccess: S
664
+ }), M = Q({
665
+ mutationFn: async (p) => {
666
+ await T(async () => {
667
+ const A = await B(p);
668
+ await O("enable", { [A]: { enabled: !0 } });
669
669
  });
670
670
  },
671
- onSuccess: I
672
- }), _ = j({
673
- mutationFn: async (f) => {
674
- await O(async () => {
675
- const A = await M(f);
676
- await x("disable", { [A]: { enabled: !1 } });
671
+ onSuccess: S
672
+ }), j = Q({
673
+ mutationFn: async (p) => {
674
+ await T(async () => {
675
+ const A = await B(p);
676
+ await O("disable", { [A]: { enabled: !1 } });
677
677
  });
678
678
  },
679
- onSuccess: I
680
- }), H = j({
681
- mutationFn: async (f) => {
682
- await O(async () => {
683
- const { bot: A } = await n.getBot({ id: e }), k = X(A.integrations), E = await Ln({ client: n, integrationId: f }), y = ft({
679
+ onSuccess: S
680
+ }), _ = Q({
681
+ mutationFn: async (p) => {
682
+ await T(async () => {
683
+ const { bot: A } = await t.getBot({ id: i }), k = ot(A.integrations), y = await Xe({ client: t, integrationId: p }), P = yt({
684
684
  installedIntegrations: k,
685
- integrationId: f,
686
- integrationName: E
687
- }), N = {
688
- enabled: (y == null ? void 0 : y.enabled) ?? !0,
689
- configuration: (y == null ? void 0 : y.configuration) ?? {},
690
- configurationType: (y == null ? void 0 : y.configurationType) ?? null
691
- }, V = {
692
- [f]: N
685
+ integrationId: p,
686
+ integrationName: y
687
+ }), V = {
688
+ enabled: (P == null ? void 0 : P.enabled) ?? !0,
689
+ configuration: (P == null ? void 0 : P.configuration) ?? {},
690
+ configurationType: (P == null ? void 0 : P.configurationType) ?? null
691
+ }, J = {
692
+ [p]: V
693
693
  };
694
- y && y.integrationAlias !== f && (V[y.integrationAlias] = null), await x("upgrade", V);
694
+ P && P.integrationAlias !== p && (J[P.integrationAlias] = null), await O("upgrade", J);
695
695
  });
696
696
  },
697
- onSuccess: I
697
+ onSuccess: S
698
698
  });
699
699
  return {
700
- integrations: (d == null ? void 0 : d.integrations) ?? [],
701
- installedIntegrations: (d == null ? void 0 : d.installedIntegrations) ?? [],
700
+ integrations: (l == null ? void 0 : l.integrations) ?? [],
701
+ installedIntegrations: (l == null ? void 0 : l.installedIntegrations) ?? [],
702
702
  isLoading: u,
703
- error: C ? pt(C) : null,
703
+ error: v ? Ct(v) : null,
704
704
  install: h.mutateAsync,
705
- uninstall: p.mutateAsync,
706
- enable: S.mutateAsync,
707
- disable: _.mutateAsync,
708
- upgrade: H.mutateAsync,
705
+ uninstall: g.mutateAsync,
706
+ enable: M.mutateAsync,
707
+ disable: j.mutateAsync,
708
+ upgrade: _.mutateAsync,
709
709
  refresh: () => {
710
- b();
710
+ C();
711
711
  },
712
712
  isInstalling: h.isPending,
713
- isUninstalling: p.isPending,
714
- isEnabling: S.isPending,
715
- isDisabling: _.isPending,
716
- isUpgrading: H.isPending
713
+ isUninstalling: g.isPending,
714
+ isEnabling: M.isPending,
715
+ isDisabling: j.isPending,
716
+ isUpgrading: _.isPending
717
717
  };
718
- }, te = Nt, Dn = ["official", "verified"], jn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ v(It, { className: "h-6 w-6 animate-spin text-[var(--gray-9)]" }) }), Vn = () => /* @__PURE__ */ v("div", { className: "flex items-center justify-center py-16 text-sm text-[var(--gray-11)]", children: "Integration details are unavailable for this selection." }), _n = (n) => n ? {
719
- key: n.key,
720
- type: n.type
721
- } : null, Hn = ({
722
- definition: n,
723
- selectedConnectionMethod: t
724
- }) => {
725
- var e, i, o, a, l;
726
- return t ? ((o = (i = (e = n.configurations) == null ? void 0 : e[t]) == null ? void 0 : i.identifier) == null ? void 0 : o.linkTemplateScript) ?? null : ((l = (a = n.configuration) == null ? void 0 : a.identifier) == null ? void 0 : l.linkTemplateScript) ?? null;
727
- }, zn = ({
728
- client: n,
718
+ }, An = Qt, tn = ["hub", "installed"], en = (t, e) => `integration-hub:nav:${t}:${e}`, xt = (t) => {
719
+ try {
720
+ const e = sessionStorage.getItem(t);
721
+ if (!e)
722
+ return null;
723
+ const i = JSON.parse(e);
724
+ if (typeof i != "object" || i === null)
725
+ return null;
726
+ const n = i, o = {};
727
+ return typeof n.view == "string" && tn.includes(n.view) && (o.view = n.view), (typeof n.selectedIntegrationId == "string" || n.selectedIntegrationId === null) && (o.selectedIntegrationId = n.selectedIntegrationId), (typeof n.selectedDefinitionId == "string" || n.selectedDefinitionId === null) && (o.selectedDefinitionId = n.selectedDefinitionId), typeof n.searchInput == "string" && (o.searchInput = n.searchInput), typeof n.visibility == "string" ? o.visibility = n.visibility : "visibility" in n && (o.visibility = void 0), Array.isArray(n.verification) && n.verification.every((a) => typeof a == "string") ? o.verification = n.verification : "verification" in n && (o.verification = void 0), typeof n.sortMethod == "string" ? o.sortMethod = n.sortMethod : "sortMethod" in n && (o.sortMethod = void 0), typeof n.selectedCategory == "string" ? o.selectedCategory = n.selectedCategory : "selectedCategory" in n && (o.selectedCategory = void 0), o;
728
+ } catch {
729
+ return null;
730
+ }
731
+ }, nn = (t, e) => {
732
+ try {
733
+ sessionStorage.setItem(
734
+ t,
735
+ JSON.stringify(e, (i, n) => n === void 0 ? null : n)
736
+ );
737
+ } catch {
738
+ }
739
+ }, Dt = (t, e) => ({
740
+ view: (t == null ? void 0 : t.view) ?? e.initialView,
741
+ selectedIntegrationId: (t == null ? void 0 : t.selectedIntegrationId) ?? null,
742
+ selectedDefinitionId: (t == null ? void 0 : t.selectedDefinitionId) ?? null,
743
+ searchInput: (t == null ? void 0 : t.searchInput) ?? "",
744
+ visibility: t && "visibility" in t ? t.visibility : e.defaultVisibility,
745
+ verification: t && "verification" in t ? t.verification ? [...t.verification] : void 0 : e.defaultVerification,
746
+ sortMethod: t && "sortMethod" in t ? t.sortMethod : e.defaultSortMethod,
747
+ selectedCategory: t == null ? void 0 : t.selectedCategory
748
+ }), on = ({
729
749
  workspaceId: t,
730
750
  botId: e,
731
- initialView: i = "hub",
751
+ enabled: i,
752
+ defaults: n
753
+ }) => {
754
+ const o = en(t, e), a = G(null);
755
+ if (a.current === null) {
756
+ const f = i ? xt(o) : null;
757
+ a.current = Dt(f, n);
758
+ }
759
+ const [d, c] = x(a.current.view), [r, l] = x(
760
+ a.current.selectedIntegrationId
761
+ ), [u, v] = x(
762
+ a.current.selectedDefinitionId
763
+ ), [C, S] = x(a.current.searchInput), [T, O] = x(a.current.visibility), [B, h] = x(a.current.verification), [g, M] = x(a.current.sortMethod), [j, _] = x(
764
+ a.current.selectedCategory
765
+ ), p = G(a.current), A = G(i);
766
+ A.current = i;
767
+ const k = G(o);
768
+ Z(() => {
769
+ if (o === k.current)
770
+ return;
771
+ k.current = o;
772
+ const f = i ? xt(o) : null, E = Dt(f, n);
773
+ p.current = E, c(E.view), l(E.selectedIntegrationId), v(E.selectedDefinitionId), S(E.searchInput), O(E.visibility), h(E.verification), M(E.sortMethod), _(E.selectedCategory);
774
+ }, [o, i, n]);
775
+ const y = N((f) => {
776
+ f.verification !== void 0 && (f = { ...f, verification: f.verification ? [...f.verification] : void 0 }), Object.assign(p.current, f), A.current && nn(k.current, p.current);
777
+ }, []), P = N(
778
+ (f) => {
779
+ c(f), y({ view: f });
780
+ },
781
+ [y]
782
+ ), V = N(
783
+ (f) => {
784
+ l(f), y({ selectedIntegrationId: f });
785
+ },
786
+ [y]
787
+ ), J = N(
788
+ (f) => {
789
+ v(f), y({ selectedDefinitionId: f });
790
+ },
791
+ [y]
792
+ ), at = N(
793
+ (f) => {
794
+ S(f), y({ searchInput: f });
795
+ },
796
+ [y]
797
+ ), X = N(
798
+ (f) => {
799
+ O(f), y({ visibility: f });
800
+ },
801
+ [y]
802
+ ), Y = N(
803
+ (f) => {
804
+ h(f), y({ verification: f });
805
+ },
806
+ [y]
807
+ ), K = N(
808
+ (f) => {
809
+ M(f), y({ sortMethod: f });
810
+ },
811
+ [y]
812
+ ), H = N(
813
+ (f) => {
814
+ _(f), y({ selectedCategory: f });
815
+ },
816
+ [y]
817
+ );
818
+ return {
819
+ view: d,
820
+ setView: P,
821
+ selectedIntegrationId: r,
822
+ setSelectedIntegrationId: V,
823
+ selectedDefinitionId: u,
824
+ setSelectedDefinitionId: J,
825
+ searchInput: C,
826
+ setSearchInput: at,
827
+ visibility: T,
828
+ setVisibility: X,
829
+ verification: B,
830
+ setVerification: Y,
831
+ sortMethod: g,
832
+ setSortMethod: K,
833
+ selectedCategory: j,
834
+ setSelectedCategory: H
835
+ };
836
+ }, an = ["official", "verified"], sn = () => /* @__PURE__ */ I("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ I(Lt, { className: "h-6 w-6 animate-spin text-[var(--gray-9)]" }) }), rn = () => /* @__PURE__ */ I("div", { className: "flex items-center justify-center py-16 text-sm text-[var(--gray-11)]", children: "Integration details are unavailable for this selection." }), cn = (t) => t ? {
837
+ key: t.key,
838
+ type: t.type
839
+ } : null, ln = ({
840
+ definition: t,
841
+ selectedConnectionMethod: e
842
+ }) => {
843
+ var i, n, o, a, d;
844
+ return e ? ((o = (n = (i = t.configurations) == null ? void 0 : i[e]) == null ? void 0 : n.identifier) == null ? void 0 : o.linkTemplateScript) ?? null : ((d = (a = t.configuration) == null ? void 0 : a.identifier) == null ? void 0 : d.linkTemplateScript) ?? null;
845
+ }, dn = ({
846
+ client: t,
847
+ workspaceId: e,
848
+ botId: i,
849
+ initialView: n,
732
850
  categories: o,
733
851
  bannerSlides: a,
734
- bannerIconUrl: l,
852
+ bannerIconUrl: d,
735
853
  noResultsDocumentationLink: c,
736
- disableInstallation: s = !1,
737
- hasWriteAccess: d = !0,
854
+ disableInstallation: r = !1,
855
+ hasWriteAccess: l = !0,
738
856
  transformIntegrationPatch: u,
739
- categoryResolver: C,
740
- filterMenuLabels: b,
741
- defaultVisibility: I,
742
- defaultVerification: O,
743
- defaultSortMethod: x,
744
- renderConfigurationForm: M,
857
+ categoryResolver: v,
858
+ filterMenuLabels: C,
859
+ defaultVisibility: S,
860
+ defaultVerification: T,
861
+ defaultSortMethod: O,
862
+ renderConfigurationForm: B,
745
863
  renderConnectionsContent: h,
746
- oauthTemplateData: p,
747
- renderDetailPanel: S,
748
- onInstall: _,
749
- onUninstall: H,
750
- onEnable: f,
751
- onDisable: A,
752
- onUpgrade: k,
753
- onError: E
864
+ oauthTemplateData: g,
865
+ renderDetailPanel: M,
866
+ renderNotifications: j,
867
+ onShare: _,
868
+ onInstall: p,
869
+ onUninstall: A,
870
+ onEnable: k,
871
+ onDisable: y,
872
+ onUpgrade: P,
873
+ onError: V,
874
+ persistNavigationState: J = !1
754
875
  }) => {
755
- const [y, N] = P(i), [V, Ft] = P(""), [z, Q] = P(null), [gt, W] = P(null), [Y, q] = P(null), [m, Dt] = P(I), [tt, jt] = P(
756
- O ?? [...Dn]
757
- ), [nt, Vt] = P(x), [_t, et] = P("connections"), [Ht, it] = P("connections"), w = Nt({
758
- client: n,
759
- workspaceId: t,
760
- botId: e,
761
- categoryResolver: C,
876
+ var It;
877
+ const at = F(
878
+ () => ({
879
+ initialView: n ?? "hub",
880
+ defaultVisibility: S,
881
+ defaultVerification: T ?? [...an],
882
+ defaultSortMethod: O
883
+ }),
884
+ [n, S, T, O]
885
+ ), {
886
+ view: X,
887
+ setView: Y,
888
+ selectedIntegrationId: K,
889
+ setSelectedIntegrationId: H,
890
+ selectedDefinitionId: f,
891
+ setSelectedDefinitionId: E,
892
+ searchInput: m,
893
+ setSearchInput: Wt,
894
+ visibility: st,
895
+ setVisibility: $t,
896
+ verification: rt,
897
+ setVerification: Gt,
898
+ sortMethod: ct,
899
+ setSortMethod: Jt,
900
+ selectedCategory: Zt,
901
+ setSelectedCategory: Xt
902
+ } = on({
903
+ workspaceId: e,
904
+ botId: i,
905
+ enabled: J,
906
+ defaults: at
907
+ }), [lt, z] = x(null), [Yt, W] = x(!1), [mt, dt] = x("connections"), [te, ut] = x("connections"), w = Qt({
908
+ client: t,
909
+ workspaceId: e,
910
+ botId: i,
911
+ categoryResolver: v,
762
912
  enabled: !0,
763
913
  transformIntegrationPatch: u
764
- }), zt = L(
765
- () => Sn({
914
+ }), ee = F(
915
+ () => He({
766
916
  integrations: w.integrations,
767
- searchTerm: V,
768
- visibility: m,
769
- verification: tt,
770
- sortMethod: nt
917
+ searchTerm: m,
918
+ visibility: st,
919
+ verification: rt,
920
+ sortMethod: ct
771
921
  }),
772
- [w.integrations, V, m, tt, nt]
773
- ), U = L(
922
+ [w.integrations, m, st, rt, ct]
923
+ ), D = F(
774
924
  () => [...w.integrations, ...w.installedIntegrations].find(
775
- (g) => g.id === z
925
+ (b) => b.id === K
776
926
  ) ?? null,
777
- [w.integrations, w.installedIntegrations, z]
778
- ), r = kt({
779
- client: n,
780
- workspaceId: t,
781
- botId: e,
782
- integrationId: gt,
783
- enabled: !!gt,
927
+ [w.integrations, w.installedIntegrations, K]
928
+ );
929
+ Z(() => {
930
+ K && !w.isLoading && !D && (H(null), E(null));
931
+ }, [K, D, w.isLoading, H, E]);
932
+ const s = zt({
933
+ client: t,
934
+ workspaceId: e,
935
+ botId: i,
936
+ integrationId: f,
937
+ enabled: !!f,
784
938
  transformIntegrationPatch: u
785
- }), Kt = L(
786
- () => (o == null ? void 0 : o.filter((g) => g.name !== "Popular").map((g) => g.name)) ?? [],
939
+ }), ne = F(
940
+ () => (o == null ? void 0 : o.filter((b) => b.name !== "Popular").map((b) => b.name)) ?? [],
787
941
  [o]
788
- ), R = J(
789
- (g) => {
790
- const B = pt(g);
791
- E == null || E(B);
942
+ ), { readme: ie, isLoading: oe } = fe((It = s.definition) == null ? void 0 : It.readmeUrl);
943
+ Z(() => {
944
+ W(!1), z(null);
945
+ }, [f]);
946
+ const tt = N(
947
+ (b) => {
948
+ const U = Ct(b);
949
+ V == null || V(U);
792
950
  },
793
- [E]
794
- ), $ = async ({
795
- operation: g,
796
- onSuccess: B,
797
- integration: F
951
+ [V]
952
+ ), et = async ({
953
+ operation: b,
954
+ onSuccess: U,
955
+ integration: R
798
956
  }) => {
799
- const D = F ?? U;
800
- if (D)
957
+ const q = R ?? D;
958
+ if (q)
801
959
  try {
802
- await g(), B == null || B(D);
803
- } catch (ot) {
804
- R(ot);
960
+ await b(), U == null || U(q);
961
+ } catch (ft) {
962
+ tt(ft);
805
963
  }
806
- }, qt = (g) => {
807
- var bt, vt, Ct, wt;
808
- if (!z || g !== z)
964
+ }, ae = (b) => {
965
+ var Tt, Ot, Pt, Bt;
966
+ if (!K || b !== K)
809
967
  return null;
810
- if (r.isLoading)
811
- return jn();
812
- if (!r.definition || !U)
813
- return Vn();
814
- const B = !!r.installedState, F = Hn({
815
- definition: r.definition,
816
- selectedConnectionMethod: r.selectedConnectionMethod
817
- }), D = r.connectionMethods.length > 1 || !!F, ot = Tt({
818
- definition: r.definition,
819
- selectedConnectionMethod: r.selectedConnectionMethod
820
- }), Qt = Ot(ot).length > 0, Wt = !!M || Qt, ht = async (T) => {
968
+ if (s.isLoading)
969
+ return sn();
970
+ if (!s.definition || !D)
971
+ return rn();
972
+ const U = !!s.installedState, R = ln({
973
+ definition: s.definition,
974
+ selectedConnectionMethod: s.selectedConnectionMethod
975
+ }), q = s.connectionMethods.length > 1 || !!R, ft = Nt({
976
+ definition: s.definition,
977
+ selectedConnectionMethod: s.selectedConnectionMethod
978
+ }), se = Vt(ft).length > 0, re = !!B || se, wt = !U || Yt, St = {
979
+ integration: D,
980
+ definition: s.definition,
981
+ installedState: s.installedState,
982
+ workspaceId: e,
983
+ botId: i
984
+ }, At = async (L) => {
821
985
  try {
822
- await r.saveConfig(T);
823
- } catch (G) {
824
- R(G);
986
+ await s.saveConfig(L);
987
+ } catch (nt) {
988
+ tt(nt);
825
989
  }
826
- }, Rt = h ? h({
827
- definition: r.definition,
828
- installedState: r.installedState,
829
- connectionMethods: r.connectionMethods,
830
- selectedConnectionMethod: r.selectedConnectionMethod,
831
- onConnectionMethodChange: r.setConnectionMethod,
832
- isSettingConnectionMethod: r.isSettingConnectionMethod
833
- }) : /* @__PURE__ */ K("div", { className: "flex flex-col gap-4", children: [
834
- /* @__PURE__ */ v("div", { className: "self-end", children: /* @__PURE__ */ v(
835
- mt,
990
+ }, ce = h ? h({
991
+ definition: s.definition,
992
+ installedState: s.installedState,
993
+ connectionMethods: s.connectionMethods,
994
+ selectedConnectionMethod: s.selectedConnectionMethod,
995
+ onConnectionMethodChange: s.setConnectionMethod,
996
+ isSettingConnectionMethod: s.isSettingConnectionMethod
997
+ }) : /* @__PURE__ */ $("div", { className: "flex flex-col gap-4", children: [
998
+ /* @__PURE__ */ I("div", { className: "self-end", children: /* @__PURE__ */ I(
999
+ ve,
836
1000
  {
837
- options: r.connectionMethods,
838
- value: r.selectedConnectionMethod,
839
- disabled: !d,
840
- onChange: (T) => {
841
- d && r.setConnectionMethod(T).catch(R);
1001
+ options: s.connectionMethods,
1002
+ value: s.selectedConnectionMethod,
1003
+ disabled: !l,
1004
+ onChange: (L) => {
1005
+ l && s.setConnectionMethod(L).catch(tt);
842
1006
  }
843
1007
  }
844
1008
  ) }),
845
- F ? /* @__PURE__ */ v(
846
- gn,
1009
+ R ? /* @__PURE__ */ I(
1010
+ Le,
847
1011
  {
848
- client: n,
849
- integrationName: r.definition.title ?? r.definition.name,
850
- linkTemplateScript: F,
851
- webhookUrl: (bt = r.installedState) == null ? void 0 : bt.webhookUrl,
852
- oauthTemplateData: p,
853
- isAuthorized: !!((vt = r.installedState) != null && vt.identifier),
854
- disabled: !d,
1012
+ client: t,
1013
+ integrationName: s.definition.title ?? s.definition.name,
1014
+ linkTemplateScript: R,
1015
+ webhookUrl: (Tt = s.installedState) == null ? void 0 : Tt.webhookUrl,
1016
+ oauthTemplateData: g,
1017
+ isAuthorized: !!((Ot = s.installedState) != null && Ot.identifier),
1018
+ disabled: !l,
855
1019
  onAuthorized: async () => {
856
- r.refresh(), w.refresh();
1020
+ s.refresh(), w.refresh();
857
1021
  },
858
- onError: R
1022
+ onError: tt
859
1023
  }
860
- ) : /* @__PURE__ */ K("p", { className: "text-sm text-[var(--gray-11)]", children: [
1024
+ ) : /* @__PURE__ */ $("p", { className: "text-sm text-[var(--gray-11)]", children: [
861
1025
  "No custom connection UI was provided. Use ",
862
- /* @__PURE__ */ v("code", { children: "renderConnectionsContent" }),
1026
+ /* @__PURE__ */ I("code", { children: "renderConnectionsContent" }),
863
1027
  " to plug your OAuth/manual connection flow."
864
1028
  ] })
865
- ] }), $t = /* @__PURE__ */ v(
866
- tn,
1029
+ ] }), le = /* @__PURE__ */ I(
1030
+ Ce,
867
1031
  {
868
- webhookUrl: (Ct = r.installedState) == null ? void 0 : Ct.webhookUrl,
869
- isBlocked: !r.installedState,
870
- children: M ? M({
871
- definition: r.definition,
872
- installedState: r.installedState,
873
- selectedConnectionMethod: r.selectedConnectionMethod,
874
- onSave: ht,
875
- isSaving: r.isSavingConfig
876
- }) : /* @__PURE__ */ v(
877
- hn,
1032
+ webhookUrl: (Pt = s.installedState) == null ? void 0 : Pt.webhookUrl,
1033
+ isBlocked: !s.installedState,
1034
+ children: B ? B({
1035
+ definition: s.definition,
1036
+ installedState: s.installedState,
1037
+ selectedConnectionMethod: s.selectedConnectionMethod,
1038
+ onSave: At,
1039
+ isSaving: s.isSavingConfig
1040
+ }) : /* @__PURE__ */ I(
1041
+ ke,
878
1042
  {
879
- definition: r.definition,
880
- installedState: r.installedState,
881
- selectedConnectionMethod: r.selectedConnectionMethod,
882
- onSave: ht,
883
- isSaving: r.isSavingConfig,
884
- disabled: !d || !r.installedState
1043
+ definition: s.definition,
1044
+ installedState: s.installedState,
1045
+ selectedConnectionMethod: s.selectedConnectionMethod,
1046
+ onSave: At,
1047
+ isSaving: s.isSavingConfig,
1048
+ disabled: !l || !s.installedState
885
1049
  }
886
1050
  )
887
1051
  }
1052
+ ), Mt = /* @__PURE__ */ I(
1053
+ ye,
1054
+ {
1055
+ actionCards: s.capabilities.actionCards,
1056
+ eventCards: s.capabilities.eventCards,
1057
+ channelCards: s.capabilities.channelCards,
1058
+ selectedCard: lt,
1059
+ onCardSelect: (L) => {
1060
+ z(
1061
+ cn(
1062
+ L ? {
1063
+ key: L.key,
1064
+ type: L.type
1065
+ } : null
1066
+ )
1067
+ );
1068
+ }
1069
+ }
1070
+ ), de = /* @__PURE__ */ I(
1071
+ Ie,
1072
+ {
1073
+ version: s.definition.version,
1074
+ githubUrl: s.definition.url,
1075
+ aboutLabel: "About Integration",
1076
+ onAboutClick: U ? () => W(!0) : void 0
1077
+ }
888
1078
  );
889
- return /* @__PURE__ */ v(
890
- nn,
1079
+ return /* @__PURE__ */ I(
1080
+ we,
891
1081
  {
892
- title: r.definition.title ?? r.definition.name,
893
- iconUrl: r.definition.iconUrl,
894
- contributorName: U.author,
895
- isOfficial: U.isOfficial,
896
- isVerified: U.isVerified,
897
- isPrivate: U.isPrivate,
1082
+ title: s.definition.title ?? s.definition.name,
1083
+ iconUrl: s.definition.iconUrl,
1084
+ contributorName: D.author,
1085
+ isOfficial: D.isOfficial,
1086
+ isVerified: D.isVerified,
1087
+ isPrivate: D.isPrivate,
898
1088
  onBack: () => {
899
- Q(null), W(null), q(null);
1089
+ H(null), E(null), z(null), W(!1);
900
1090
  },
901
- onInstall: B || s || !d ? void 0 : () => {
902
- $({
903
- operation: () => w.install(U.id),
904
- onSuccess: _,
905
- integration: U
1091
+ onInstall: U || r || !l ? void 0 : () => {
1092
+ et({
1093
+ operation: () => w.install(D.id),
1094
+ onSuccess: p,
1095
+ integration: D
906
1096
  });
907
1097
  },
908
- onToggleEnabled: !B || !d ? void 0 : () => {
909
- const T = r.installedState, G = !!(T != null && T.enabled);
910
- $({
1098
+ onToggleEnabled: !U || !l ? void 0 : () => {
1099
+ const L = s.installedState, nt = !!(L != null && L.enabled);
1100
+ et({
911
1101
  operation: async () => {
912
- if (!T)
1102
+ if (!L)
913
1103
  throw new Error("Integration is not installed");
914
- if (G) {
915
- await w.disable(T.id);
1104
+ if (nt) {
1105
+ await w.disable(L.id);
916
1106
  return;
917
1107
  }
918
- await w.enable(T.id);
1108
+ await w.enable(L.id);
919
1109
  },
920
- onSuccess: G ? A : f,
921
- integration: U
1110
+ onSuccess: nt ? y : k,
1111
+ integration: D
922
1112
  });
923
1113
  },
924
- onUninstall: !B || !d ? void 0 : () => {
925
- const T = r.installedState;
926
- $({
1114
+ onUninstall: !U || !l ? void 0 : () => {
1115
+ const L = s.installedState;
1116
+ et({
927
1117
  operation: async () => {
928
- if (!T)
1118
+ if (!L)
929
1119
  throw new Error("Integration is not installed");
930
- await w.uninstall(T.id);
1120
+ await w.uninstall(L.id);
931
1121
  },
932
- onSuccess: H,
933
- integration: U
1122
+ onSuccess: A,
1123
+ integration: D
934
1124
  });
935
1125
  },
936
- onUpgrade: !U.hasUpdate || !d ? void 0 : () => {
937
- $({
938
- operation: () => w.upgrade(U.id),
939
- onSuccess: k,
940
- integration: U
1126
+ onUpgrade: !D.hasUpdate || !l ? void 0 : () => {
1127
+ et({
1128
+ operation: () => w.upgrade(D.id),
1129
+ onSuccess: P,
1130
+ integration: D
941
1131
  });
942
1132
  },
943
- isInstalled: B,
944
- disableInstallation: s,
945
- hasWriteAccess: d,
1133
+ isInstalled: U,
1134
+ disableInstallation: r,
1135
+ hasWriteAccess: l,
946
1136
  isInstalling: w.isInstalling,
947
1137
  isUninstalling: w.isUninstalling,
948
1138
  isTogglingEnabled: w.isEnabling || w.isDisabling,
949
- hasUpdate: U.hasUpdate,
1139
+ hasUpdate: D.hasUpdate,
950
1140
  isUpgrading: w.isUpgrading,
951
- toggleButtonLabel: (wt = r.installedState) != null && wt.enabled ? "Disable" : "Enable",
952
- selectedDetailPanel: Y && S ? S({
953
- definition: r.definition,
954
- selectedCard: Y,
955
- onClose: () => q(null)
1141
+ toggleButtonLabel: (Bt = s.installedState) != null && Bt.enabled ? "Disable" : "Enable",
1142
+ onShare: _ ? () => _(St) : void 0,
1143
+ showBackToSetup: U && wt,
1144
+ onBackToSetup: () => W(!1),
1145
+ notifications: j == null ? void 0 : j(St),
1146
+ selectedDetailPanel: lt && M ? M({
1147
+ definition: s.definition,
1148
+ selectedCard: lt,
1149
+ onClose: () => z(null)
956
1150
  }) : void 0,
957
- onDismissSelectedDetailPanel: () => q(null),
958
- children: /* @__PURE__ */ v(
959
- en,
1151
+ onDismissSelectedDetailPanel: () => z(null),
1152
+ children: wt ? /* @__PURE__ */ $("div", { className: "flex flex-col gap-6 mt-6", children: [
1153
+ /* @__PURE__ */ I(Se, { readme: ie, isLoading: oe }),
1154
+ Mt
1155
+ ] }) : /* @__PURE__ */ I(
1156
+ Ae,
960
1157
  {
961
- integrationTitle: r.definition.title ?? r.definition.name,
962
- isFullyConfigured: B,
963
- hasConnectionStep: D,
964
- hasConfigurationStep: Wt,
965
- configuredTab: _t,
966
- onConfiguredTabChange: et,
967
- setupTab: Ht,
968
- onSetupTabChange: it,
1158
+ integrationTitle: s.definition.title ?? s.definition.name,
1159
+ isFullyConfigured: U,
1160
+ hasConnectionStep: q,
1161
+ hasConfigurationStep: re,
1162
+ configuredTab: mt,
1163
+ onConfiguredTabChange: dt,
1164
+ setupTab: te,
1165
+ onSetupTabChange: ut,
969
1166
  onCancelSetup: () => {
970
- Q(null), W(null), q(null);
1167
+ H(null), E(null), z(null), W(!1);
971
1168
  },
972
- metadata: /* @__PURE__ */ v(
973
- on,
974
- {
975
- version: r.definition.version,
976
- githubUrl: r.definition.url,
977
- aboutLabel: "About Integration"
978
- }
979
- ),
980
- connectionsContent: Rt,
981
- configurationContent: $t,
982
- capabilitiesContent: /* @__PURE__ */ v(
983
- an,
984
- {
985
- actionCards: r.capabilities.actionCards,
986
- eventCards: r.capabilities.eventCards,
987
- channelCards: r.capabilities.channelCards,
988
- selectedCard: Y,
989
- onCardSelect: (T) => {
990
- q(
991
- _n(
992
- T ? {
993
- key: T.key,
994
- type: T.type
995
- } : null
996
- )
997
- );
998
- }
999
- }
1000
- )
1169
+ metadata: de,
1170
+ connectionsContent: ce,
1171
+ configurationContent: le,
1172
+ capabilitiesContent: Mt
1001
1173
  }
1002
1174
  )
1003
1175
  }
1004
1176
  );
1005
1177
  };
1006
- return /* @__PURE__ */ K("div", { className: "flex h-full min-h-0 flex-col", children: [
1007
- !z && /* @__PURE__ */ v("div", { className: "flex justify-end px-6 pt-4", children: /* @__PURE__ */ K("div", { className: "flex rounded-lg bg-[var(--gray-a3)] p-1", children: [
1008
- /* @__PURE__ */ v(
1178
+ return /* @__PURE__ */ $("div", { className: "flex h-full min-h-0 flex-col", children: [
1179
+ !K && /* @__PURE__ */ I("div", { className: "flex justify-end px-6 pt-4", children: /* @__PURE__ */ $("div", { className: "flex rounded-lg bg-[var(--gray-a3)] p-1", children: [
1180
+ /* @__PURE__ */ I(
1009
1181
  "button",
1010
1182
  {
1011
1183
  type: "button",
1012
- onClick: () => N("hub"),
1013
- className: lt(
1184
+ onClick: () => Y("hub"),
1185
+ className: bt(
1014
1186
  "cursor-pointer rounded-md px-3 py-1.5 text-sm text-[var(--gray-11)] transition-colors",
1015
- y === "hub" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1187
+ X === "hub" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1016
1188
  ),
1017
1189
  children: "Integration Hub"
1018
1190
  }
1019
1191
  ),
1020
- /* @__PURE__ */ v(
1192
+ /* @__PURE__ */ I(
1021
1193
  "button",
1022
1194
  {
1023
1195
  type: "button",
1024
- onClick: () => N("installed"),
1025
- className: lt(
1196
+ onClick: () => Y("installed"),
1197
+ className: bt(
1026
1198
  "cursor-pointer rounded-md px-3 py-1.5 text-sm text-[var(--gray-11)] transition-colors",
1027
- y === "installed" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1199
+ X === "installed" && "bg-[var(--gray-1)] text-[var(--gray-12)] shadow-sm"
1028
1200
  ),
1029
1201
  children: "Installed Integrations"
1030
1202
  }
1031
1203
  )
1032
1204
  ] }) }),
1033
- /* @__PURE__ */ v(
1034
- Zt,
1205
+ /* @__PURE__ */ I(
1206
+ ge,
1035
1207
  {
1036
- view: y,
1037
- searchInput: V,
1038
- searchTerm: V,
1039
- onSearchInputChange: Ft,
1040
- selectedIntegrationId: z,
1041
- hubIntegrations: zt,
1208
+ view: X,
1209
+ searchInput: m,
1210
+ searchTerm: m,
1211
+ onSearchInputChange: Wt,
1212
+ selectedCategory: Zt,
1213
+ onSelectedCategoryChange: Xt,
1214
+ selectedIntegrationId: K,
1215
+ hubIntegrations: ee,
1042
1216
  sidebarIntegrations: w.integrations,
1043
1217
  installedIntegrations: w.installedIntegrations,
1044
1218
  isHubLoading: w.isLoading,
1045
1219
  isInstalledLoading: w.isLoading,
1046
- filterMenu: /* @__PURE__ */ v(
1047
- Jt,
1220
+ filterMenu: /* @__PURE__ */ I(
1221
+ pe,
1048
1222
  {
1049
- visibility: m,
1050
- verification: tt,
1051
- sortMethod: nt,
1052
- labels: b,
1053
- onVisibilityChange: Dt,
1054
- onVerificationChange: jt,
1055
- onSortMethodChange: Vt
1223
+ visibility: st,
1224
+ verification: rt,
1225
+ sortMethod: ct,
1226
+ labels: C,
1227
+ onVisibilityChange: $t,
1228
+ onVerificationChange: Gt,
1229
+ onSortMethodChange: Jt
1056
1230
  }
1057
1231
  ),
1058
1232
  categories: o,
1059
1233
  bannerSlides: a,
1060
- bannerIconUrl: l,
1234
+ bannerIconUrl: d,
1061
1235
  noResultsDocumentationLink: c,
1062
- renderIntegrationCard: (g, { onEscape: B }) => /* @__PURE__ */ v(
1063
- Xt,
1236
+ renderIntegrationCard: (b, { onEscape: U }) => /* @__PURE__ */ I(
1237
+ he,
1064
1238
  {
1065
- name: g.title ?? g.name,
1066
- description: g.description,
1067
- author: g.author,
1068
- installed: g.installed,
1069
- updateAvailable: g.hasUpdate,
1070
- verified: g.isVerified,
1071
- official: g.isOfficial,
1072
- private: g.isPrivate,
1073
- iconUrl: g.iconUrl,
1239
+ name: b.title ?? b.name,
1240
+ description: b.description,
1241
+ author: b.author,
1242
+ installed: b.installed,
1243
+ updateAvailable: b.hasUpdate,
1244
+ verified: b.isVerified,
1245
+ official: b.isOfficial,
1246
+ private: b.isPrivate,
1247
+ iconUrl: b.iconUrl,
1074
1248
  onClick: () => {
1075
- Q(g.id), W(g.installedId ?? g.id), et("connections"), it("connections");
1249
+ H(b.id), E(b.installedId ?? b.id), dt("connections"), ut("connections"), W(!1), z(null);
1076
1250
  },
1077
- onEscape: B
1251
+ onEscape: U
1078
1252
  }
1079
1253
  ),
1080
- renderInstalledIntegrations: ({ integrations: g, searchTerm: B, categoryOrder: F }) => /* @__PURE__ */ v(
1081
- Yt,
1254
+ renderInstalledIntegrations: ({ integrations: b, searchTerm: U, categoryOrder: R }) => /* @__PURE__ */ I(
1255
+ be,
1082
1256
  {
1083
- integrations: g,
1084
- searchTerm: B,
1085
- categoryOrder: F.length > 0 ? F : Kt,
1086
- onSelectIntegration: (D) => {
1087
- Q(D.id), W(D.installedId ?? D.id), et("connections"), it("connections");
1257
+ integrations: b,
1258
+ searchTerm: U,
1259
+ categoryOrder: R.length > 0 ? R : ne,
1260
+ onSelectIntegration: (q) => {
1261
+ H(q.id), E(q.installedId ?? q.id), dt("connections"), ut("connections"), W(!1), z(null);
1088
1262
  }
1089
1263
  }
1090
1264
  ),
1091
- renderIntegrationDetails: qt
1265
+ renderIntegrationDetails: ae
1092
1266
  }
1093
1267
  )
1094
1268
  ] });
1095
- }, ne = zn;
1269
+ }, Mn = dn;
1096
1270
  export {
1097
- ne as BotpressIntegrationHub,
1098
- zn as BotpressIntegrationHubScreen,
1099
- gn as IntegrationOAuthButton,
1100
- hn as IntegrationStaticZuiConfigurationForm,
1101
- Yn as dedupeById,
1102
- un as fetchOAuthAuthorizationUrl,
1103
- Sn as filterAndSortIntegrations,
1104
- ft as findInstalledIntegration,
1105
- X as getInstalledIntegrations,
1106
- An as getSelectedConnectionMethod,
1107
- dn as getWebhookIdFromUrl,
1108
- xt as isOfficialWorkspace,
1109
- pn as openOAuthPopup,
1110
- Bt as resolveCategory,
1111
- yn as toCapabilityCards,
1112
- In as toConnectionMethods,
1113
- pt as toError,
1114
- Cn as toHubItem,
1115
- wn as toInstalledItem,
1116
- kt as useBotpressIntegrationDetails,
1117
- Nt as useBotpressIntegrationHub,
1118
- mn as useIntegrationDetails,
1119
- te as useIntegrationHub
1271
+ Mn as BotpressIntegrationHub,
1272
+ dn as BotpressIntegrationHubScreen,
1273
+ Le as IntegrationOAuthButton,
1274
+ Se as IntegrationReadmeContent,
1275
+ ke as IntegrationStaticZuiConfigurationForm,
1276
+ wn as dedupeById,
1277
+ Ue as fetchOAuthAuthorizationUrl,
1278
+ He as filterAndSortIntegrations,
1279
+ yt as findInstalledIntegration,
1280
+ ot as getInstalledIntegrations,
1281
+ Ke as getSelectedConnectionMethod,
1282
+ Be as getWebhookIdFromUrl,
1283
+ _t as isOfficialWorkspace,
1284
+ xe as openOAuthPopup,
1285
+ Kt as resolveCategory,
1286
+ je as toCapabilityCards,
1287
+ _e as toConnectionMethods,
1288
+ Ct as toError,
1289
+ Ve as toHubItem,
1290
+ Fe as toInstalledItem,
1291
+ zt as useBotpressIntegrationDetails,
1292
+ Qt as useBotpressIntegrationHub,
1293
+ Sn as useIntegrationDetails,
1294
+ An as useIntegrationHub,
1295
+ fe as useIntegrationReadme,
1296
+ on as usePersistedNavigationState
1120
1297
  };