@alfadocs/ui-kit 1.69.0 → 1.70.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.
Files changed (63) hide show
  1. package/dist/_chunks/workflow-webhook-action-D6K7Jgc2.js +832 -0
  2. package/dist/agent-catalog.json +12 -2
  3. package/dist/agent-i18n/en.json +2 -1
  4. package/dist/i18n/locales/ar.d.ts +13 -1
  5. package/dist/i18n/locales/ar.js +13 -1
  6. package/dist/i18n/locales/de.d.ts +13 -1
  7. package/dist/i18n/locales/de.js +13 -1
  8. package/dist/i18n/locales/el.d.ts +13 -1
  9. package/dist/i18n/locales/el.js +13 -1
  10. package/dist/i18n/locales/en.d.ts +13 -1
  11. package/dist/i18n/locales/en.js +13 -1
  12. package/dist/i18n/locales/es.d.ts +13 -1
  13. package/dist/i18n/locales/es.js +13 -1
  14. package/dist/i18n/locales/fr.d.ts +13 -1
  15. package/dist/i18n/locales/fr.js +13 -1
  16. package/dist/i18n/locales/hi.d.ts +13 -1
  17. package/dist/i18n/locales/hi.js +13 -1
  18. package/dist/i18n/locales/it.d.ts +13 -1
  19. package/dist/i18n/locales/it.js +13 -1
  20. package/dist/i18n/locales/ja.d.ts +13 -1
  21. package/dist/i18n/locales/ja.js +13 -1
  22. package/dist/i18n/locales/nl.d.ts +13 -1
  23. package/dist/i18n/locales/nl.js +13 -1
  24. package/dist/i18n/locales/pl.d.ts +13 -1
  25. package/dist/i18n/locales/pl.js +13 -1
  26. package/dist/i18n/locales/pt.d.ts +13 -1
  27. package/dist/i18n/locales/pt.js +13 -1
  28. package/dist/i18n/locales/ro.d.ts +13 -1
  29. package/dist/i18n/locales/ro.js +13 -1
  30. package/dist/i18n/locales/ru.d.ts +13 -1
  31. package/dist/i18n/locales/ru.js +13 -1
  32. package/dist/i18n/locales/sq.d.ts +13 -1
  33. package/dist/i18n/locales/sq.js +13 -1
  34. package/dist/i18n/locales/sv.d.ts +13 -1
  35. package/dist/i18n/locales/sv.js +13 -1
  36. package/dist/i18n/locales/tr.d.ts +13 -1
  37. package/dist/i18n/locales/tr.js +13 -1
  38. package/dist/i18n/locales/zh.d.ts +13 -1
  39. package/dist/i18n/locales/zh.js +13 -1
  40. package/dist/index.js +1 -1
  41. package/dist/locales/ar.json +13 -1
  42. package/dist/locales/de.json +13 -1
  43. package/dist/locales/el.json +13 -1
  44. package/dist/locales/en.json +13 -1
  45. package/dist/locales/es.json +13 -1
  46. package/dist/locales/fr.json +13 -1
  47. package/dist/locales/hi.json +13 -1
  48. package/dist/locales/it.json +13 -1
  49. package/dist/locales/ja.json +13 -1
  50. package/dist/locales/nl.json +13 -1
  51. package/dist/locales/pl.json +13 -1
  52. package/dist/locales/pt.json +13 -1
  53. package/dist/locales/ro.json +13 -1
  54. package/dist/locales/ru.json +13 -1
  55. package/dist/locales/sq.json +13 -1
  56. package/dist/locales/sv.json +13 -1
  57. package/dist/locales/tr.json +13 -1
  58. package/dist/locales/zh.json +13 -1
  59. package/dist/patterns/workflow-webhook-action/index.d.ts +1 -1
  60. package/dist/patterns/workflow-webhook-action/index.js +1 -1
  61. package/dist/patterns/workflow-webhook-action/workflow-webhook-action.d.ts +29 -3
  62. package/package.json +1 -1
  63. package/dist/_chunks/workflow-webhook-action-Ct8tFYi7.js +0 -691
@@ -0,0 +1,832 @@
1
+ import { jsxs as d, jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as Ht, useId as N, useRef as i, useState as u, useEffect as C, useCallback as $t } from "react";
3
+ import { useTranslation as Qe } from "react-i18next";
4
+ import { c as h } from "./index-D2ZczOXr.js";
5
+ import { C as Ge } from "./code-block-RSKdF3E-.js";
6
+ import { A as k } from "./accordion-Ch3xp0mX.js";
7
+ import { A as U } from "./alert-9kEwDza3.js";
8
+ import { B as Kt } from "./badge-BUk4RjTS.js";
9
+ import { B as ue } from "./button-D-MQxsA_.js";
10
+ import { I as Xt } from "./icon-button-C_1TgRiK.js";
11
+ import { C as Je } from "./card-BA4Ig_kn.js";
12
+ import { C as zt } from "./checkbox-BjDv-r3o.js";
13
+ import { F as Ut } from "./field-array-BJYc1xSu.js";
14
+ import { F as G } from "./form-field-Ani72sVY.js";
15
+ import { P as Gt } from "./password-input-BokZ_rnT.js";
16
+ import { T as me } from "./text-input-CaG9ApoE.js";
17
+ import { T as Jt } from "./token-insert-menu-CQvV4u1m.js";
18
+ import { u as Ze } from "./use-copy-to-clipboard-Cyfc_dlv.js";
19
+ import { u as Yt } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
20
+ import { c as Qt } from "./createLucideIcon-DhHxpK9K.js";
21
+ import { C as Ve } from "./check-DrFSN__t.js";
22
+ import { C as he } from "./circle-alert-rGDZ73Wh.js";
23
+ import { C as et } from "./copy-vRpqqHtY.js";
24
+ import { S as Zt } from "./send-C5kDJ-Mz.js";
25
+ /**
26
+ * @license lucide-react v1.22.0 - ISC
27
+ *
28
+ * This source code is licensed under the ISC license.
29
+ * See the LICENSE file in the root directory of this source tree.
30
+ */
31
+ const Vt = [
32
+ [
33
+ "path",
34
+ {
35
+ d: "M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",
36
+ key: "1s6t7t"
37
+ }
38
+ ],
39
+ ["circle", { cx: "16.5", cy: "7.5", r: ".5", fill: "currentColor", key: "w0ekpg" }]
40
+ ], eo = Qt("key-round", Vt), qo = [
41
+ "url",
42
+ "secret",
43
+ "legalBasisConfirmed",
44
+ "parameters"
45
+ ], to = h(
46
+ "ds:flex ds:w-full ds:flex-col ds:gap-[var(--spacing-lg)] ds:text-start ds:text-[var(--foreground)]"
47
+ ), oo = h(
48
+ "ds:m-0 ds:grid ds:gap-x-[var(--spacing-xl)] ds:gap-y-[var(--spacing-md)]",
49
+ {
50
+ variants: {
51
+ columns: {
52
+ 1: "ds:grid-cols-1",
53
+ 2: "ds:grid-cols-2",
54
+ 3: "ds:grid-cols-3"
55
+ }
56
+ },
57
+ defaultVariants: { columns: 1 }
58
+ }
59
+ ), fe = h(
60
+ "ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-sm)]"
61
+ ), pe = h("type-title-item ds:text-foreground"), no = h(
62
+ "ds:min-w-0 ds:rounded-[var(--radius-sm)] ds:bg-[var(--muted)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:font-mono type-body-sm ds:text-foreground ds:[overflow-wrap:anywhere]"
63
+ ), x = h("type-body-sm ds:text-muted-foreground"), ro = h(
64
+ "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-body-sm ds:text-destructive"
65
+ ), so = h(
66
+ "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:sm:grid-cols-2"
67
+ ), ao = "https://", co = 2048, lo = 720, ke = {
68
+ salutation: "[[TITOLO]]",
69
+ firstName: "[[NOME]]",
70
+ lastName: "[[COGNOME]]"
71
+ }, tt = "wf12-e345-a67", io = {
72
+ sentAt: "2026-10-12T09:00:00+02:00",
73
+ idempotencyKey: tt,
74
+ practiceId: 1234,
75
+ workflowId: 12,
76
+ workflowActionId: 67,
77
+ workflowEnrollmentId: 345,
78
+ patientId: 5678
79
+ }, uo = [
80
+ "Content-Type: application/json",
81
+ `X-AlfaDocs-Idempotency-Key: ${tt}`,
82
+ "X-AlfaDocs-Request-Timestamp: 1791788400000",
83
+ "X-AlfaDocs-Signature: sha256=9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
84
+ ].join(`
85
+ `), ot = (s) => s === null ? "" : String(s), we = (s) => s.original !== void 0 && s.name === s.original.name && s.value === ot(s.original.value), mo = (s) => s.flatMap((a) => a.original !== void 0 && we(a) ? [[a.original.name, a.original.value]] : a.name.trim() === "" ? [] : [[a.name, a.value]]), fo = (s) => s.length === 0 ? "" : `{${s.map(
86
+ ([a, w]) => `${JSON.stringify(a)}:${JSON.stringify(w)}`
87
+ ).join(",")}}`, po = () => {
88
+ const s = new Uint8Array(32);
89
+ return globalThis.crypto.getRandomValues(s), Array.from(s, (a) => a.toString(16).padStart(2, "0")).join(
90
+ ""
91
+ );
92
+ }, Ye = (s) => s != null && s.url ? { kind: "url" } : s != null && s.secret ? { kind: "secret" } : s != null && s.legalBasisConfirmed ? { kind: "legal" } : s != null && s.parameters ? { kind: "parametersError" } : null;
93
+ function ko({ name: s, description: a, onCopied: w }) {
94
+ const { t: l } = Qe("ui"), p = N(), { status: L, copy: I } = Ze(), y = L === "copied", D = L === "error";
95
+ return /* @__PURE__ */ d("div", { className: "ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
96
+ /* @__PURE__ */ d("dt", { className: "ds:flex ds:min-w-0 ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", children: [
97
+ /* @__PURE__ */ n("code", { dir: "ltr", className: no(), children: s }),
98
+ /* @__PURE__ */ n(
99
+ Xt,
100
+ {
101
+ icon: y ? /* @__PURE__ */ n(Ve, {}) : D ? /* @__PURE__ */ n(he, {}) : /* @__PURE__ */ n(et, {}),
102
+ size: "sm",
103
+ intent: "ghost",
104
+ "aria-label": l("keyValuePair.copy", { label: s }),
105
+ "aria-describedby": p,
106
+ "data-action": "copy-field",
107
+ "data-copied": y ? "true" : void 0,
108
+ onClick: () => void I(s).then(w)
109
+ }
110
+ ),
111
+ y ? /* @__PURE__ */ n("span", { "aria-hidden": "true", className: "type-body-sm ds:text-success", children: l("copyField.copied") }) : D ? /* @__PURE__ */ n("span", { "aria-hidden": "true", className: "type-body-sm ds:text-destructive", children: l("copyField.copyFailed") }) : null
112
+ ] }),
113
+ /* @__PURE__ */ n(
114
+ "dd",
115
+ {
116
+ id: p,
117
+ className: "ds:m-0 type-body-sm ds:text-muted-foreground",
118
+ children: a
119
+ }
120
+ )
121
+ ] });
122
+ }
123
+ const ho = Ht(
124
+ ({
125
+ children: s,
126
+ initialValues: a,
127
+ hasSavedSecret: w = !1,
128
+ errors: l,
129
+ fieldNames: p,
130
+ placeholders: L,
131
+ onSendTest: I,
132
+ onValueChange: y,
133
+ layout: D = "two-column",
134
+ className: nt,
135
+ ...rt
136
+ }, E) => {
137
+ const { t: o } = Qe("ui"), st = [
138
+ ["patientId", o("workflowWebhookAction.sent.patientId")],
139
+ ["practiceId", o("workflowWebhookAction.sent.practiceId")],
140
+ ["workflowId", o("workflowWebhookAction.sent.workflowId")],
141
+ ["workflowActionId", o("workflowWebhookAction.sent.workflowActionId")],
142
+ [
143
+ "workflowEnrollmentId",
144
+ o("workflowWebhookAction.sent.workflowEnrollmentId")
145
+ ],
146
+ ["sentAt", o("workflowWebhookAction.sent.sentAt")],
147
+ ["idempotencyKey", o("workflowWebhookAction.sent.idempotencyKey")],
148
+ ["parameters", o("workflowWebhookAction.sent.parameters")]
149
+ ], at = [
150
+ ["X-AlfaDocs-Signature", o("workflowWebhookAction.headers.signature")],
151
+ [
152
+ "X-AlfaDocs-Request-Timestamp",
153
+ o("workflowWebhookAction.headers.timestamp")
154
+ ],
155
+ [
156
+ "X-AlfaDocs-Idempotency-Key",
157
+ o("workflowWebhookAction.headers.idempotency")
158
+ ]
159
+ ], be = N(), ge = N(), ve = N(), ye = N(), Ae = N(), T = L ?? [
160
+ {
161
+ value: ke.salutation,
162
+ label: o("workflowWebhookAction.variableSalutation")
163
+ },
164
+ {
165
+ value: ke.firstName,
166
+ label: o("workflowWebhookAction.variableFirstName")
167
+ },
168
+ {
169
+ value: ke.lastName,
170
+ label: o("workflowWebhookAction.variableLastName")
171
+ }
172
+ ], M = i(0), ct = () => (M.current += 1, `parameter-${M.current}`), [A, lt] = u(() => (a == null ? void 0 : a.url) ?? ""), [f, We] = u(""), [it, Ce] = u(!1), [b, J] = u(
173
+ () => Object.entries((a == null ? void 0 : a.parameters) ?? {}).map(([e, t]) => (M.current += 1, {
174
+ key: `parameter-${M.current}`,
175
+ name: e,
176
+ value: ot(t),
177
+ original: { name: e, value: t }
178
+ }))
179
+ ), [R, dt] = u(
180
+ () => (a == null ? void 0 : a.legalBasisConfirmed) ?? !1
181
+ ), [ut, Y] = u(
182
+ () => Object.keys((a == null ? void 0 : a.parameters) ?? {}).length > 0 || !!(l != null && l.parameters)
183
+ ), [mt, ft] = u({}), [Q, pt] = u(!1), [O, xe] = u(() => l ?? {}), [kt, Ne] = u(""), [ht, wt] = u(!1), [bt, gt] = u(
184
+ () => Object.values(l ?? {}).some(Boolean)
185
+ ), Ie = i(l);
186
+ C(() => {
187
+ l !== Ie.current && (Ie.current = l, xe(l ?? {}), l != null && l.parameters && Y(!0), gt(Object.values(l ?? {}).some(Boolean)), g(Ye(l)));
188
+ }, [l]);
189
+ const B = (e) => ft(
190
+ (t) => t[e] ? t : { ...t, [e]: !0 }
191
+ ), W = (e) => xe(
192
+ (t) => t[e] ? { ...t, [e]: void 0 } : t
193
+ ), P = i(null), Ee = i(null), _ = i(null), Te = i(null), Re = i(null), Oe = i(null), Be = i(null), Fe = i(null), Z = i(/* @__PURE__ */ new Map()), j = i(/* @__PURE__ */ new Map()), V = i(/* @__PURE__ */ new Set()), ee = i(null);
194
+ C(() => {
195
+ var t;
196
+ const e = ee.current;
197
+ e && (ee.current = null, (t = j.current.get(e.key)) == null || t.setSelectionRange(e.position, e.position));
198
+ });
199
+ const [vt, yt] = u(!1);
200
+ Yt(() => {
201
+ const e = P.current;
202
+ if (!e) return;
203
+ const t = () => yt(
204
+ e.getBoundingClientRect().width >= lo
205
+ );
206
+ if (t(), typeof ResizeObserver > "u") return;
207
+ const r = new ResizeObserver(t);
208
+ return r.observe(e), () => r.disconnect();
209
+ }, []);
210
+ const te = D === "two-column" && vt, At = $t(
211
+ (e) => {
212
+ P.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
213
+ },
214
+ [E]
215
+ ), F = (e) => {
216
+ Ne("");
217
+ let t = 0;
218
+ const r = () => {
219
+ var m;
220
+ if (((m = Fe.current) == null ? void 0 : m.closest('[aria-hidden="true"]')) && t < 60) {
221
+ t += 1, window.requestAnimationFrame(r);
222
+ return;
223
+ }
224
+ Ne(e);
225
+ };
226
+ window.requestAnimationFrame(r);
227
+ }, oe = () => {
228
+ const e = A.trim();
229
+ if (e === "") return o("workflowWebhookAction.urlRequired");
230
+ let t;
231
+ try {
232
+ t = new URL(e);
233
+ } catch {
234
+ return o("workflowWebhookAction.urlInvalid");
235
+ }
236
+ if (!e.startsWith(ao)) return o("workflowWebhookAction.urlHttps");
237
+ if (t.hostname === "") return o("workflowWebhookAction.urlInvalid");
238
+ if (t.username !== "" || t.password !== "")
239
+ return o("workflowWebhookAction.urlCredentials");
240
+ }, ne = () => f.trim() === "" && !w ? o("workflowWebhookAction.secretRequired") : void 0, Wt = () => {
241
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
242
+ for (const r of b) {
243
+ const c = we(r) ? r.name : r.name.trim() === "" ? null : r.name;
244
+ c !== null && t.set(c, (t.get(c) ?? 0) + 1);
245
+ }
246
+ for (const r of b)
247
+ if (!we(r)) {
248
+ if (r.name.trim() === "") {
249
+ r.value !== "" && e.set(
250
+ r.key,
251
+ o("workflowWebhookAction.parameterNameRequired")
252
+ );
253
+ continue;
254
+ }
255
+ (t.get(r.name) ?? 0) > 1 && e.set(
256
+ r.key,
257
+ o("workflowWebhookAction.parameterNameDuplicate")
258
+ );
259
+ }
260
+ return e;
261
+ }, Se = () => R ? void 0 : o("workflowWebhookAction.legalBasisRequired"), re = (e) => Q || mt[e] === !0, Le = Wt(), Ct = O.url ?? (re("url") ? oe() : void 0), xt = O.secret ?? (re("secret") ? ne() : void 0), q = O.legalBasisConfirmed ?? (Q ? Se() : void 0), Nt = (e) => re(`parameter:${e}`) ? Le.get(e) : void 0, H = !Q && !bt && !ht, De = () => {
262
+ if (oe()) return { kind: "url" };
263
+ if (ne()) return { kind: "secret" };
264
+ if (Se()) return { kind: "legal" };
265
+ const e = b.find((t) => Le.has(t.key));
266
+ return e ? { kind: "parameter", key: e.key } : void 0;
267
+ }, Me = i(De);
268
+ Me.current = De;
269
+ const [$, g] = u(
270
+ () => Ye(l)
271
+ );
272
+ C(() => {
273
+ if (!$) return;
274
+ const e = (() => {
275
+ var t;
276
+ switch ($.kind) {
277
+ case "url":
278
+ return Ee.current;
279
+ case "secret":
280
+ return _.current;
281
+ case "legal":
282
+ return Be.current;
283
+ case "sendTest":
284
+ return Re.current;
285
+ case "copy":
286
+ return Te.current;
287
+ case "parametersError":
288
+ return Oe.current;
289
+ case "add":
290
+ return (t = P.current) == null ? void 0 : t.querySelector(
291
+ '[data-slot="parameters"] [data-component="field-array"] > button'
292
+ );
293
+ case "parameter":
294
+ return Z.current.get($.key);
295
+ }
296
+ })();
297
+ e == null || e.focus();
298
+ }, [$]), C(() => {
299
+ var r;
300
+ const e = (r = P.current) == null ? void 0 : r.closest("form");
301
+ if (!e) return;
302
+ const t = (c) => {
303
+ const m = Me.current();
304
+ m && (c.preventDefault(), pt(!0), m.kind === "parameter" && Y(!0), g({ ...m }));
305
+ };
306
+ return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
307
+ }, []);
308
+ const v = mo(b), se = fo(v), K = i(y);
309
+ K.current = y;
310
+ const Pe = i(v);
311
+ Pe.current = v;
312
+ const _e = i(!1);
313
+ C(() => {
314
+ var e;
315
+ if (!_e.current) {
316
+ _e.current = !0;
317
+ return;
318
+ }
319
+ (e = K.current) == null || e.call(K, {
320
+ url: A,
321
+ secret: f,
322
+ parameters: Object.fromEntries(Pe.current),
323
+ legalBasisConfirmed: R
324
+ });
325
+ }, [A, f, se, R]);
326
+ const {
327
+ status: je,
328
+ copiedValue: It,
329
+ copy: Et,
330
+ reset: qe
331
+ } = Ze(), ae = je === "copied" && It === f, He = je === "error", Tt = () => {
332
+ qe(), We(po()), Ce(!0), W("secret"), F(o("workflowWebhookAction.secretGenerated")), g({ kind: "copy" });
333
+ }, [$e, ce] = u({ kind: "idle" }), S = i(0), Rt = async () => {
334
+ var r;
335
+ if (!I) return;
336
+ const e = oe() ? "url" : ne() ? "secret" : null;
337
+ if (e) {
338
+ B("url"), B("secret"), wt(!0), g({ kind: e });
339
+ return;
340
+ }
341
+ S.current += 1;
342
+ const t = S.current;
343
+ ce({ kind: "sending" });
344
+ try {
345
+ const c = await I({
346
+ url: A.trim(),
347
+ secret: ((r = _.current) == null ? void 0 : r.value) ?? f,
348
+ parameters: Object.fromEntries(v),
349
+ legalBasisConfirmed: R
350
+ });
351
+ t === S.current && Ke({ kind: "done", result: c });
352
+ } catch {
353
+ t === S.current && Ke({ kind: "failed" });
354
+ }
355
+ }, Ke = (e) => {
356
+ ce(e);
357
+ const t = ze(e);
358
+ t && F(t.text);
359
+ const r = document.activeElement;
360
+ (!r || r === document.body) && g({ kind: "sendTest" });
361
+ }, X = `${A}
362
+ ${f}
363
+ ${se}`, Xe = i(X);
364
+ C(() => {
365
+ X !== Xe.current && (Xe.current = X, S.current += 1, ce(
366
+ (e) => e.kind === "idle" ? e : { kind: "idle" }
367
+ ));
368
+ }, [X]);
369
+ const ze = (e) => {
370
+ if (e.kind === "failed")
371
+ return { ok: !1, text: o("workflowWebhookAction.testFailed") };
372
+ if (e.kind !== "done") return null;
373
+ const { result: t } = e, r = t.outcome === "answered" && t.status >= 200 && t.status < 300;
374
+ return t.message ? { ok: r, text: t.message } : t.outcome === "unreachable" ? { ok: r, text: o("workflowWebhookAction.testUnreachable") } : r ? {
375
+ ok: r,
376
+ text: o("workflowWebhookAction.testSent", { status: t.status })
377
+ } : {
378
+ ok: r,
379
+ text: t.status === 401 || t.status === 403 ? o("workflowWebhookAction.testCheckSecret", {
380
+ status: t.status
381
+ }) : o("workflowWebhookAction.testRejected", {
382
+ status: t.status
383
+ })
384
+ };
385
+ }, Ot = async () => {
386
+ var t;
387
+ const e = await Et(((t = _.current) == null ? void 0 : t.value) ?? f);
388
+ F(o(e ? "copyField.copySuccess" : "copyField.copyFailed"));
389
+ }, le = (e, t) => {
390
+ J(
391
+ (r) => r.map((c) => c.key === e ? { ...c, ...t } : c)
392
+ ), W("parameters");
393
+ }, Bt = () => {
394
+ const e = ct();
395
+ J((t) => [...t, { key: e, name: "", value: "" }]), g({ kind: "parameter", key: e });
396
+ }, Ft = (e) => {
397
+ const t = b.filter((m, de) => de !== e), r = b[e];
398
+ r && (Z.current.delete(r.key), j.current.delete(r.key), V.current.delete(r.key)), J(t), W("parameters");
399
+ const c = t[e] ?? t[e - 1];
400
+ g(
401
+ c ? { kind: "parameter", key: c.key } : { kind: "add" }
402
+ );
403
+ }, St = (e, t) => {
404
+ var Ue;
405
+ const r = j.current.get(e.key), c = r !== void 0 && V.current.has(e.key), m = c ? r.selectionStart ?? e.value.length : e.value.length, de = c ? r.selectionEnd ?? m : m, _t = e.value.slice(0, m) + t + e.value.slice(de);
406
+ ee.current = { key: e.key, position: m + t.length }, le(e.key, { value: _t });
407
+ const jt = (Ue = T.find((qt) => qt.value === t)) == null ? void 0 : Ue.label;
408
+ F(
409
+ o("workflowWebhookAction.placeholderInserted", {
410
+ detail: jt ?? t
411
+ })
412
+ );
413
+ }, Lt = (e) => F(o(e ? "copyField.copySuccess" : "copyField.copyFailed")), ie = (e, t, r = 2) => /* @__PURE__ */ n(
414
+ "dl",
415
+ {
416
+ "aria-labelledby": e,
417
+ className: oo({
418
+ columns: te ? r : 1
419
+ }),
420
+ children: t.map(([c, m]) => /* @__PURE__ */ n(
421
+ ko,
422
+ {
423
+ name: c,
424
+ description: m,
425
+ onCopied: Lt
426
+ },
427
+ c
428
+ ))
429
+ }
430
+ ), Dt = JSON.stringify(
431
+ { ...io, parameters: Object.fromEntries(v) },
432
+ null,
433
+ 2
434
+ ), Mt = /* @__PURE__ */ d(
435
+ "div",
436
+ {
437
+ "data-columns": te ? 2 : 1,
438
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xl)]",
439
+ children: [
440
+ /* @__PURE__ */ d("div", { className: fe(), children: [
441
+ /* @__PURE__ */ n("h4", { id: ge, className: pe(), children: o("workflowWebhookAction.bodyHeading") }),
442
+ /* @__PURE__ */ n("p", { className: x(), children: o("workflowWebhookAction.sentDescription") }),
443
+ /* @__PURE__ */ n(
444
+ Ge,
445
+ {
446
+ language: "json",
447
+ code: Dt,
448
+ copyLabel: o("workflowWebhookAction.copyBody")
449
+ }
450
+ ),
451
+ ie(ge, st)
452
+ ] }),
453
+ /* @__PURE__ */ d("div", { className: fe(), children: [
454
+ /* @__PURE__ */ n("h4", { id: ve, className: pe(), children: o("workflowWebhookAction.headersHeading") }),
455
+ /* @__PURE__ */ n("p", { className: x(), children: o("workflowWebhookAction.headersDescription") }),
456
+ /* @__PURE__ */ n(
457
+ Ge,
458
+ {
459
+ language: "http",
460
+ code: uo,
461
+ copyLabel: o("workflowWebhookAction.copyHeaders")
462
+ }
463
+ ),
464
+ ie(ve, at)
465
+ ] })
466
+ ]
467
+ }
468
+ ), z = p !== void 0, Pt = o(it ? "workflowWebhookAction.generatedNotice" : w ? "workflowWebhookAction.secretSavedDescription" : "workflowWebhookAction.secretDescription");
469
+ return /* @__PURE__ */ d(
470
+ "div",
471
+ {
472
+ ref: At,
473
+ ...rt,
474
+ "data-component": "workflow-webhook-action",
475
+ "data-layout": te ? "two-column" : "one-column",
476
+ className: to({ className: nt }),
477
+ children: [
478
+ s ? /* @__PURE__ */ n(
479
+ "div",
480
+ {
481
+ "data-slot": "host-content",
482
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]",
483
+ children: s
484
+ }
485
+ ) : null,
486
+ /* @__PURE__ */ n("p", { className: x(), children: o("workflowWebhookAction.intro") }),
487
+ /* @__PURE__ */ n(
488
+ G,
489
+ {
490
+ label: o("workflowWebhookAction.url"),
491
+ description: o("workflowWebhookAction.urlDescription"),
492
+ required: !0,
493
+ error: Ct,
494
+ announceError: H,
495
+ "data-field": "url",
496
+ children: /* @__PURE__ */ n(
497
+ me,
498
+ {
499
+ ref: Ee,
500
+ name: z ? p.url : void 0,
501
+ dir: "ltr",
502
+ inputMode: "url",
503
+ autoComplete: "off",
504
+ spellCheck: !1,
505
+ maxLength: co,
506
+ placeholder: "https://",
507
+ value: A,
508
+ onChange: (e) => {
509
+ lt(e.target.value), W("url");
510
+ },
511
+ onBlur: (e) => {
512
+ e.target.value !== "" && B("url");
513
+ }
514
+ }
515
+ )
516
+ }
517
+ ),
518
+ /* @__PURE__ */ d(
519
+ "div",
520
+ {
521
+ "data-field": "secret",
522
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
523
+ children: [
524
+ /* @__PURE__ */ n(
525
+ G,
526
+ {
527
+ label: o("workflowWebhookAction.secret"),
528
+ description: Pt,
529
+ ...w ? { optional: !0 } : { required: !0 },
530
+ error: xt,
531
+ announceError: H,
532
+ children: /* @__PURE__ */ n(
533
+ Gt,
534
+ {
535
+ ref: _,
536
+ name: z ? p.secret : "",
537
+ dir: "ltr",
538
+ autoComplete: "new-password",
539
+ spellCheck: !1,
540
+ value: f,
541
+ onChange: (e) => {
542
+ We(e.target.value), Ce(!1), qe(), W("secret");
543
+ },
544
+ onBlur: (e) => {
545
+ e.target.value !== "" && B("secret");
546
+ }
547
+ }
548
+ )
549
+ }
550
+ ),
551
+ /* @__PURE__ */ d("div", { className: "ds:flex ds:flex-wrap ds:gap-[var(--spacing-xs)]", children: [
552
+ /* @__PURE__ */ n(
553
+ ue,
554
+ {
555
+ type: "button",
556
+ intent: "outline",
557
+ size: "sm",
558
+ startIcon: /* @__PURE__ */ n(eo, {}),
559
+ "data-action": "generate-secret",
560
+ onClick: Tt,
561
+ children: o("workflowWebhookAction.generate")
562
+ }
563
+ ),
564
+ /* @__PURE__ */ n(
565
+ ue,
566
+ {
567
+ ref: Te,
568
+ type: "button",
569
+ intent: "outline",
570
+ size: "sm",
571
+ disabled: f === "",
572
+ startIcon: ae ? /* @__PURE__ */ n(Ve, {}) : He ? /* @__PURE__ */ n(he, {}) : /* @__PURE__ */ n(et, {}),
573
+ "data-action": "copy-secret",
574
+ "data-copied": ae ? "true" : void 0,
575
+ onClick: () => void Ot(),
576
+ children: o(ae ? "copyField.copied" : He ? "copyField.copyFailed" : "workflowWebhookAction.copySecret")
577
+ }
578
+ )
579
+ ] })
580
+ ]
581
+ }
582
+ ),
583
+ I ? /* @__PURE__ */ d(
584
+ "div",
585
+ {
586
+ "data-slot": "send-test",
587
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
588
+ children: [
589
+ /* @__PURE__ */ n("p", { id: Ae, className: x(), children: o("workflowWebhookAction.testDescription") }),
590
+ /* @__PURE__ */ n(
591
+ ue,
592
+ {
593
+ ref: Re,
594
+ type: "button",
595
+ intent: "outline",
596
+ size: "sm",
597
+ startIcon: /* @__PURE__ */ n(Zt, {}),
598
+ loading: $e.kind === "sending",
599
+ "aria-describedby": Ae,
600
+ className: "ds:self-start",
601
+ "data-action": "send-test",
602
+ onClick: () => void Rt(),
603
+ children: o("workflowWebhookAction.sendTest")
604
+ }
605
+ ),
606
+ (() => {
607
+ const e = ze($e);
608
+ return e ? /* @__PURE__ */ n(
609
+ U,
610
+ {
611
+ variant: e.ok ? "success" : "error",
612
+ announce: "off",
613
+ "data-slot": "test-result",
614
+ "data-test-ok": e.ok ? "true" : "false",
615
+ children: /* @__PURE__ */ n(U.Description, { children: e.text })
616
+ }
617
+ ) : null;
618
+ })()
619
+ ]
620
+ }
621
+ ) : null,
622
+ /* @__PURE__ */ d(
623
+ "div",
624
+ {
625
+ "data-field": "legalBasisConfirmed",
626
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
627
+ children: [
628
+ /* @__PURE__ */ n(
629
+ zt,
630
+ {
631
+ ref: Be,
632
+ name: z ? p.legalBasisConfirmed : void 0,
633
+ value: "1",
634
+ checked: R,
635
+ onCheckedChange: (e) => {
636
+ dt(e === !0), W("legalBasisConfirmed");
637
+ },
638
+ "aria-required": "true",
639
+ "aria-invalid": q ? !0 : void 0,
640
+ "aria-describedby": q ? be : void 0,
641
+ label: o("workflowWebhookAction.legalBasis")
642
+ }
643
+ ),
644
+ q ? /* @__PURE__ */ d(
645
+ "p",
646
+ {
647
+ id: be,
648
+ role: H ? "alert" : void 0,
649
+ "data-slot": "error",
650
+ className: ro(),
651
+ children: [
652
+ /* @__PURE__ */ n(
653
+ he,
654
+ {
655
+ "aria-hidden": "true",
656
+ className: "ds:size-4 ds:shrink-0"
657
+ }
658
+ ),
659
+ /* @__PURE__ */ n("span", { children: q })
660
+ ]
661
+ }
662
+ ) : null
663
+ ]
664
+ }
665
+ ),
666
+ z ? /* @__PURE__ */ n(
667
+ "input",
668
+ {
669
+ type: "hidden",
670
+ name: p.parameters,
671
+ value: se
672
+ }
673
+ ) : null,
674
+ /* @__PURE__ */ n("div", { "data-field": "parameters", "data-slot": "parameters", children: /* @__PURE__ */ n(Je, { variant: "elevated", children: /* @__PURE__ */ n(
675
+ k,
676
+ {
677
+ type: "single",
678
+ collapsible: !0,
679
+ value: ut ? "advanced" : "",
680
+ onValueChange: (e) => Y(e === "advanced"),
681
+ children: /* @__PURE__ */ d(k.Item, { value: "advanced", children: [
682
+ /* @__PURE__ */ n(k.Trigger, { "data-action": "toggle-advanced", children: /* @__PURE__ */ d("span", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", children: [
683
+ /* @__PURE__ */ n("span", { children: o("workflowWebhookAction.advanced") }),
684
+ v.length > 0 ? /* @__PURE__ */ n(Kt, { variant: "neutral", size: "md", children: o("workflowWebhookAction.parameterCount", {
685
+ total: v.length
686
+ }) }) : null
687
+ ] }) }),
688
+ /* @__PURE__ */ n(k.Content, { children: /* @__PURE__ */ d("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", children: [
689
+ /* @__PURE__ */ n("p", { className: x(), children: o("workflowWebhookAction.advancedDescription") }),
690
+ O.parameters ? /* @__PURE__ */ n(
691
+ "div",
692
+ {
693
+ ref: Oe,
694
+ tabIndex: -1,
695
+ "data-slot": "error",
696
+ className: "ds:outline-none",
697
+ children: /* @__PURE__ */ n(U, { variant: "error", announce: "off", children: /* @__PURE__ */ n(U.Description, { children: O.parameters }) })
698
+ }
699
+ ) : null,
700
+ /* @__PURE__ */ n(
701
+ Ut,
702
+ {
703
+ legend: o("workflowWebhookAction.parametersLegend"),
704
+ items: b,
705
+ addLabel: o("workflowWebhookAction.addParameter"),
706
+ removeItemLabel: (e) => o("workflowWebhookAction.removeParameter", {
707
+ number: e + 1
708
+ }),
709
+ onAdd: Bt,
710
+ onRemove: Ft,
711
+ renderItem: (e, t) => /* @__PURE__ */ d(
712
+ "div",
713
+ {
714
+ "data-parameter-id": e.key,
715
+ className: so(),
716
+ children: [
717
+ /* @__PURE__ */ n(
718
+ G,
719
+ {
720
+ label: o("workflowWebhookAction.parameterName"),
721
+ error: Nt(e.key),
722
+ announceError: H,
723
+ children: /* @__PURE__ */ n(
724
+ me,
725
+ {
726
+ ref: (r) => {
727
+ r && Z.current.set(e.key, r);
728
+ },
729
+ "aria-label": o(
730
+ "workflowWebhookAction.parameterNameOf",
731
+ { number: t + 1 }
732
+ ),
733
+ dir: "auto",
734
+ autoComplete: "off",
735
+ spellCheck: !1,
736
+ value: e.name,
737
+ onChange: (r) => le(e.key, { name: r.target.value }),
738
+ onBlur: () => B(`parameter:${e.key}`)
739
+ }
740
+ )
741
+ }
742
+ ),
743
+ /* @__PURE__ */ n(
744
+ G,
745
+ {
746
+ label: o("workflowWebhookAction.parameterValue"),
747
+ children: /* @__PURE__ */ n(
748
+ me,
749
+ {
750
+ ref: (r) => {
751
+ r && j.current.set(e.key, r);
752
+ },
753
+ "aria-label": o(
754
+ "workflowWebhookAction.parameterValueOf",
755
+ { number: t + 1 }
756
+ ),
757
+ dir: "auto",
758
+ autoComplete: "off",
759
+ value: e.value,
760
+ onChange: (r) => le(e.key, {
761
+ value: r.target.value
762
+ }),
763
+ onFocus: () => V.current.add(e.key)
764
+ }
765
+ )
766
+ }
767
+ ),
768
+ T.length > 0 ? /* @__PURE__ */ n("div", { className: "ds:sm:col-span-2", children: /* @__PURE__ */ n(
769
+ Jt,
770
+ {
771
+ tokens: T.map((r) => ({
772
+ value: r.value,
773
+ label: r.label
774
+ })),
775
+ triggerLabel: o(
776
+ "workflowWebhookAction.insertDetail"
777
+ ),
778
+ onInsert: (r) => St(e, r)
779
+ }
780
+ ) }) : null
781
+ ]
782
+ }
783
+ )
784
+ }
785
+ ),
786
+ T.length > 0 ? /* @__PURE__ */ d("div", { className: fe(), children: [
787
+ /* @__PURE__ */ n(
788
+ "h4",
789
+ {
790
+ id: ye,
791
+ className: pe(),
792
+ children: o("workflowWebhookAction.variablesHeading")
793
+ }
794
+ ),
795
+ /* @__PURE__ */ n("p", { className: x(), children: o("workflowWebhookAction.variablesDescription") }),
796
+ ie(
797
+ ye,
798
+ T.map(
799
+ (e) => [e.value, e.label]
800
+ ),
801
+ 3
802
+ )
803
+ ] }) : null
804
+ ] }) })
805
+ ] })
806
+ }
807
+ ) }) }),
808
+ /* @__PURE__ */ n("div", { "data-slot": "reference", children: /* @__PURE__ */ n(Je, { variant: "elevated", children: /* @__PURE__ */ n(k, { type: "single", collapsible: !0, children: /* @__PURE__ */ d(k.Item, { value: "reference", children: [
809
+ /* @__PURE__ */ n(k.Trigger, { "data-action": "toggle-reference", children: /* @__PURE__ */ n("span", { children: o("workflowWebhookAction.sentHeading") }) }),
810
+ /* @__PURE__ */ n(k.Content, { children: Mt })
811
+ ] }) }) }) }),
812
+ /* @__PURE__ */ n(
813
+ "span",
814
+ {
815
+ ref: Fe,
816
+ role: "status",
817
+ "aria-live": "polite",
818
+ className: "ds:sr-only",
819
+ children: kt
820
+ }
821
+ )
822
+ ]
823
+ }
824
+ );
825
+ }
826
+ );
827
+ ho.displayName = "WorkflowWebhookAction";
828
+ export {
829
+ qo as W,
830
+ ho as a
831
+ };
832
+ //# sourceMappingURL=workflow-webhook-action-D6K7Jgc2.js.map