@alfadocs/ui-kit 1.66.0 → 1.67.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 (143) hide show
  1. package/dist/_chunks/ai-credits-exhausted-notice-DfAgfZDF.js +287 -0
  2. package/dist/_chunks/ai-credits-exhausted-notice.agent-DgTSTgez.js +43 -0
  3. package/dist/_chunks/ai-credits-notice-DQ-r3iQU.js +191 -0
  4. package/dist/_chunks/{ai-permission-notice-DpRmZ9Q3.js → ai-permission-notice-qsdm4Sx4.js} +2 -2
  5. package/dist/_chunks/{alert-DdDpOi-P.js → alert-DjsJMGRE.js} +3 -2
  6. package/dist/_chunks/{anamnesis-summary-rows-BIfw890v.js → anamnesis-summary-rows-BQ_EokKz.js} +2 -2
  7. package/dist/_chunks/{audio-recorder-DR-u1qbl.js → audio-recorder-B11RR-rC.js} +2 -2
  8. package/dist/_chunks/{auth-form-parts-Cmb41LSQ.js → auth-form-parts-DwUTH6YN.js} +2 -2
  9. package/dist/_chunks/{booking-DkjatiXc.js → booking-tTVxKPQY.js} +2 -2
  10. package/dist/_chunks/{calendar-workspace-Cp8yTZ1g.js → calendar-workspace-MRrzcxAy.js} +6 -6
  11. package/dist/_chunks/{document-preview-B1dQm292.js → document-preview-VyQOjFVL.js} +2 -2
  12. package/dist/_chunks/{document-scanner-CVPVLK7z.js → document-scanner-CXH_GYh4.js} +2 -2
  13. package/dist/_chunks/{entity-summary-BQ9_KA8S.js → entity-summary-Bj-Wxq7Y.js} +2 -2
  14. package/dist/_chunks/{error-summary-DrUfuKu1.js → error-summary-PUE5Zxp9.js} +2 -2
  15. package/dist/_chunks/{forgot-password-form-CgZkEvZy.js → forgot-password-form-CPOfRE0C.js} +4 -4
  16. package/dist/_chunks/{freemium-paywall-DKJHRFpp.js → freemium-paywall-6DO7noHX.js} +2 -2
  17. package/dist/_chunks/help-me-write-templates-Bw3Q58x-.js +687 -0
  18. package/dist/_chunks/hourglass-BEAzW1wE.js +26 -0
  19. package/dist/_chunks/{login-dev-card-PnADNcI9.js → login-dev-card-A-CL3mjt.js} +3 -3
  20. package/dist/_chunks/{marketplace-app-shell-C-2e4eCD.js → marketplace-app-shell-DtSX8sYb.js} +2 -2
  21. package/dist/_chunks/{notes-panel-uEGIL7mi.js → notes-panel-IdsmqRFC.js} +3 -3
  22. package/dist/_chunks/{patient-details-4P1vA9Ls.js → patient-details-C-EWQTms.js} +2 -2
  23. package/dist/_chunks/{patient-field-row-CBXhlfGD.js → patient-field-row-lY-Tb5Mo.js} +155 -176
  24. package/dist/_chunks/{patient-search-DOnDUVsl.js → patient-search-DpAKidZ5.js} +2 -2
  25. package/dist/_chunks/{patient-summary-card-CuDLo8MP.js → patient-summary-card-Bpto_VCD.js} +2 -2
  26. package/dist/_chunks/{payment-automation-upsell-C8MEu0t6.js → payment-automation-upsell-BQ307qEX.js} +2 -2
  27. package/dist/_chunks/{payment-form-C3dGY7v4.js → payment-form-XKtinW8r.js} +2 -2
  28. package/dist/_chunks/{pdf-viewer-DJ9VN7cu.js → pdf-viewer-BvoVMjH4.js} +2 -2
  29. package/dist/_chunks/{practice-results-8h2Utpt3.js → practice-results-BrUDDMXC.js} +2 -2
  30. package/dist/_chunks/{registration-form-BQyT_kBX.js → registration-form-BxwqUZzk.js} +3 -3
  31. package/dist/_chunks/{rich-text-editor-M2gT_E7f.js → rich-text-editor-aCIoptbg.js} +1653 -1743
  32. package/dist/_chunks/{sign-document-CY7xTXbm.js → sign-document-D1P1nUQA.js} +2 -2
  33. package/dist/_chunks/{signature-request-BMCHy2ZO.js → signature-request-3u6TvRt2.js} +2 -2
  34. package/dist/_chunks/{task-editor-CifOznfq.js → task-editor-Bb5MMcid.js} +2 -2
  35. package/dist/_chunks/{tasks-panel-8nLwBw6P.js → tasks-panel-BOb57Ysw.js} +2 -2
  36. package/dist/_chunks/{use-appointment-details-read-B-FEWbQM.js → use-appointment-details-read-CVSPoP5j.js} +4 -4
  37. package/dist/_chunks/voice-control-panel-BJIEbDq6.js +1148 -0
  38. package/dist/_chunks/{warning-stack-HYWAytZV.js → warning-stack-BdY-0bd3.js} +2 -2
  39. package/dist/_chunks/{workflow-map-C2B2qIr1.js → workflow-map-CYbRD9ek.js} +2 -2
  40. package/dist/agent-catalog.json +50 -3
  41. package/dist/agent-i18n/en.json +7 -4
  42. package/dist/components/ai-credits-notice/ai-credits-exhausted-notice.agent.d.ts +4 -0
  43. package/dist/components/ai-credits-notice/ai-credits-exhausted-notice.d.ts +96 -0
  44. package/dist/components/ai-credits-notice/ai-credits-notice.d.ts +30 -4
  45. package/dist/components/ai-credits-notice/index.d.ts +3 -0
  46. package/dist/components/ai-credits-notice/index.js +10 -4
  47. package/dist/components/ai-permission-notice/index.js +1 -1
  48. package/dist/components/alert/index.js +1 -1
  49. package/dist/components/appointment-details-panel/index.js +1 -1
  50. package/dist/components/audio-recorder/index.js +1 -1
  51. package/dist/components/booking/index.js +1 -1
  52. package/dist/components/document-preview/index.js +1 -1
  53. package/dist/components/document-scanner/index.js +1 -1
  54. package/dist/components/entity-summary/index.js +1 -1
  55. package/dist/components/error-summary/index.js +1 -1
  56. package/dist/components/freemium-paywall/index.js +1 -1
  57. package/dist/components/notes-panel/index.js +1 -1
  58. package/dist/components/patient-details/index.js +1 -1
  59. package/dist/components/patient-search/index.js +1 -1
  60. package/dist/components/patient-summary-card/index.js +1 -1
  61. package/dist/components/payment-form/index.js +1 -1
  62. package/dist/components/pdf-viewer/index.js +1 -1
  63. package/dist/components/practice-results/index.js +1 -1
  64. package/dist/components/rich-text-editor/index.js +1 -1
  65. package/dist/components/sign-document/index.js +1 -1
  66. package/dist/components/task-editor/index.js +1 -1
  67. package/dist/components/tasks-panel/index.js +1 -1
  68. package/dist/components/voice-control-panel/index.d.ts +2 -1
  69. package/dist/components/voice-control-panel/index.js +1 -1
  70. package/dist/components/voice-control-panel/voice-control-panel.d.ts +43 -3
  71. package/dist/components/warning-stack/index.js +1 -1
  72. package/dist/components/workflow/index.js +1 -1
  73. package/dist/i18n/locales/ar.d.ts +27 -12
  74. package/dist/i18n/locales/ar.js +27 -12
  75. package/dist/i18n/locales/de.d.ts +27 -12
  76. package/dist/i18n/locales/de.js +27 -12
  77. package/dist/i18n/locales/el.d.ts +27 -12
  78. package/dist/i18n/locales/el.js +27 -12
  79. package/dist/i18n/locales/en.d.ts +27 -12
  80. package/dist/i18n/locales/en.js +27 -12
  81. package/dist/i18n/locales/es.d.ts +27 -12
  82. package/dist/i18n/locales/es.js +27 -12
  83. package/dist/i18n/locales/fr.d.ts +27 -12
  84. package/dist/i18n/locales/fr.js +27 -12
  85. package/dist/i18n/locales/hi.d.ts +27 -12
  86. package/dist/i18n/locales/hi.js +27 -12
  87. package/dist/i18n/locales/it.d.ts +27 -12
  88. package/dist/i18n/locales/it.js +27 -12
  89. package/dist/i18n/locales/ja.d.ts +27 -12
  90. package/dist/i18n/locales/ja.js +27 -12
  91. package/dist/i18n/locales/nl.d.ts +27 -12
  92. package/dist/i18n/locales/nl.js +27 -12
  93. package/dist/i18n/locales/pl.d.ts +27 -12
  94. package/dist/i18n/locales/pl.js +27 -12
  95. package/dist/i18n/locales/pt.d.ts +27 -12
  96. package/dist/i18n/locales/pt.js +27 -12
  97. package/dist/i18n/locales/ro.d.ts +27 -12
  98. package/dist/i18n/locales/ro.js +27 -12
  99. package/dist/i18n/locales/ru.d.ts +27 -12
  100. package/dist/i18n/locales/ru.js +27 -12
  101. package/dist/i18n/locales/sq.d.ts +27 -12
  102. package/dist/i18n/locales/sq.js +27 -12
  103. package/dist/i18n/locales/sv.d.ts +27 -12
  104. package/dist/i18n/locales/sv.js +27 -12
  105. package/dist/i18n/locales/tr.d.ts +27 -12
  106. package/dist/i18n/locales/tr.js +27 -12
  107. package/dist/i18n/locales/zh.d.ts +27 -12
  108. package/dist/i18n/locales/zh.js +27 -12
  109. package/dist/index.js +814 -809
  110. package/dist/locales/ar.json +27 -12
  111. package/dist/locales/de.json +27 -12
  112. package/dist/locales/el.json +27 -12
  113. package/dist/locales/en.json +27 -12
  114. package/dist/locales/es.json +27 -12
  115. package/dist/locales/fr.json +27 -12
  116. package/dist/locales/hi.json +27 -12
  117. package/dist/locales/it.json +27 -12
  118. package/dist/locales/ja.json +27 -12
  119. package/dist/locales/nl.json +27 -12
  120. package/dist/locales/pl.json +27 -12
  121. package/dist/locales/pt.json +27 -12
  122. package/dist/locales/ro.json +27 -12
  123. package/dist/locales/ru.json +27 -12
  124. package/dist/locales/sq.json +27 -12
  125. package/dist/locales/sv.json +27 -12
  126. package/dist/locales/tr.json +27 -12
  127. package/dist/locales/zh.json +27 -12
  128. package/dist/patterns/anamnesis/index.js +1 -1
  129. package/dist/patterns/calendar/index.js +1 -1
  130. package/dist/patterns/forgot-password-form/index.js +1 -1
  131. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +6 -23
  132. package/dist/patterns/help-me-write-templates/index.js +8 -7
  133. package/dist/patterns/login-form/index.js +1 -1
  134. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  135. package/dist/patterns/payment-automation-upsell/index.js +1 -1
  136. package/dist/patterns/registration-form/index.js +1 -1
  137. package/dist/patterns/signature-request/index.js +1 -1
  138. package/dist/tokens.css +1 -1
  139. package/package.json +1 -1
  140. package/dist/_chunks/ai-credits-notice-pK9BOmEz.js +0 -90
  141. package/dist/_chunks/ai-credits-notice.agent-C9L7orrP.js +0 -17
  142. package/dist/_chunks/help-me-write-templates-DFmqnsAa.js +0 -747
  143. package/dist/_chunks/voice-control-panel-C0BfY23Y.js +0 -1009
@@ -0,0 +1,687 @@
1
+ import { jsxs as g, Fragment as _, jsx as e } from "react/jsx-runtime";
2
+ import { useState as h, useEffect as j, useId as ee, useRef as q, useCallback as P, useMemo as K } from "react";
3
+ import { useTranslation as U } from "react-i18next";
4
+ import { c as ce } from "./index-D2ZczOXr.js";
5
+ import { A as Z } from "./alert-DjsJMGRE.js";
6
+ import { A as de } from "./ai-credits-exhausted-notice-DfAgfZDF.js";
7
+ import { B as I } from "./button-D-MQxsA_.js";
8
+ import { I as L } from "./icon-button-C_1TgRiK.js";
9
+ import { D as W } from "./dialog-D6fkpRc4.js";
10
+ import { E as me } from "./editor-overlay-CpVO1-Kk.js";
11
+ import { E as pe } from "./empty-state-pL1qum99.js";
12
+ import { F as X } from "./form-field-Ani72sVY.js";
13
+ import { S as ue } from "./spinner-CoflYlEx.js";
14
+ import { T as se } from "./text-area-COMVJ1yE.js";
15
+ import { S as re } from "./state-backed-text-input-Cgh4ms3p.js";
16
+ import { SafeHtml as fe } from "../safe-html/index.js";
17
+ import { P as ge } from "./pencil-B1sKKyuT.js";
18
+ import { T as he } from "./trash-2-uumy3fy1.js";
19
+ import { P as be } from "./plus-DzMQ_c6b.js";
20
+ import { X as te } from "./x-B5YnXwCz.js";
21
+ import { R as ve } from "./rotate-ccw-BBQnIVTr.js";
22
+ import { S as Te } from "./square-DASBRZ0U.js";
23
+ import { M as Me } from "./mic-CUklMZGF.js";
24
+ import { S as Ce } from "./send-C5kDJ-Mz.js";
25
+ import { G as We } from "./grip-vertical-onSb1JXO.js";
26
+ class ae extends Error {
27
+ constructor(m = "AI credits exhausted") {
28
+ super(m), this.name = "AiCreditsExhaustedError";
29
+ }
30
+ }
31
+ const B = "ds:!size-[var(--min-target-size)]", we = `${B} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`, ye = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", J = "ds:m-0 ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", Ne = "type-eyebrow ds:m-0 ds:text-[color:var(--muted-foreground)]", xe = [
32
+ "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
33
+ "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
34
+ "ds:p-[var(--spacing-sm)] ds:[max-block-size:14rem] ds:overflow-y-auto",
35
+ "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]",
36
+ "ds:[&_ul]:list-disc ds:[&_ul]:ps-[var(--spacing-md)]",
37
+ "ds:[&_h3]:font-medium ds:[&_h3]:[margin-block-start:var(--spacing-xs)]",
38
+ "ds:[&_p]:[margin-block-end:var(--spacing-xs)]",
39
+ "ds:[&>:first-child]:[margin-block-start:0]"
40
+ ].join(" ");
41
+ function ne(r, m) {
42
+ return m ? r ? /\s$/.test(r) ? `${r}${m}` : `${r} ${m}` : m : r;
43
+ }
44
+ function ke(r) {
45
+ return typeof r == "object" && r !== null && "name" in r && r.name === "AbortError";
46
+ }
47
+ function De({
48
+ context: r,
49
+ onGenerate: m,
50
+ onApplied: v,
51
+ credits: u,
52
+ enableDictation: N = !0,
53
+ suspendClose: w = !1
54
+ }) {
55
+ const { t: n } = U("ui"), { open: t } = r, x = ee(), s = ee(), [d, k] = h(""), [y, D] = h(!1), [E, i] = h(!1), [p, l] = h(!1), [T, R] = h(null), o = q(null), f = N ? r.onDictate : void 0, [M, S] = h(!1), [A, H] = h(""), [V, a] = h(""), C = q(null), z = P(() => {
56
+ var c;
57
+ return (c = C.current) == null ? void 0 : c.abort();
58
+ }, []), ie = P(() => {
59
+ if (M) {
60
+ z();
61
+ return;
62
+ }
63
+ if (!f) return;
64
+ const c = new AbortController();
65
+ C.current = c, S(!0), a(n("helpMeWriteTemplates.bar.listening")), f({
66
+ signal: c.signal,
67
+ onPartialTranscript: (b) => {
68
+ c.signal.aborted || H(b);
69
+ },
70
+ onFinalTranscript: (b) => {
71
+ if (c.signal.aborted) return;
72
+ H("");
73
+ const F = b.trim();
74
+ F && (k((O) => ne(O, F)), a(F));
75
+ }
76
+ }).catch((b) => {
77
+ b instanceof ae && l(!0);
78
+ }).finally(() => {
79
+ H(""), C.current === c && (C.current = null, S(!1), a(""));
80
+ });
81
+ }, [M, f, z, n]);
82
+ j(() => {
83
+ var c, b;
84
+ t ? (k(""), D(!1), i(!1), l(r.creditsExhausted), R(null)) : ((c = o.current) == null || c.abort(), (b = C.current) == null || b.abort());
85
+ }, [t]), j(
86
+ () => () => {
87
+ var c, b;
88
+ (c = o.current) == null || c.abort(), (b = C.current) == null || b.abort();
89
+ },
90
+ []
91
+ );
92
+ const Q = P(() => {
93
+ var F;
94
+ if (y || !d.trim()) return;
95
+ z(), (F = o.current) == null || F.abort();
96
+ const c = new AbortController();
97
+ o.current = c, i(!1), D(!0);
98
+ const b = r.scope === "selection";
99
+ m({
100
+ prompt: d.trim(),
101
+ sourceText: b ? r.selectionText : r.getText(),
102
+ scope: b ? "selection" : "document",
103
+ signal: c.signal
104
+ }).then((O) => {
105
+ c.signal.aborted || (R(O), D(!1));
106
+ }).catch((O) => {
107
+ c.signal.aborted || ke(O) || (O instanceof ae ? l(!0) : i(!0), D(!1));
108
+ });
109
+ }, [y, d, m, z]), { onClose: G } = r, le = P(() => {
110
+ w || G();
111
+ }, [w, G]), oe = () => {
112
+ if (T === null) return;
113
+ const c = r.getHTML();
114
+ r.insertAtSelection(T), r.onClose();
115
+ const { setContent: b } = r;
116
+ v == null || v({
117
+ mode: r.scope === "selection" ? "replace" : "insert",
118
+ previousHtml: c,
119
+ undo: () => b(c)
120
+ });
121
+ };
122
+ let $;
123
+ if (p)
124
+ $ = /* @__PURE__ */ e(
125
+ de,
126
+ {
127
+ credits: u,
128
+ onBack: () => l(!1),
129
+ footnote: n("helpMeWriteTemplates.credits.kept")
130
+ }
131
+ );
132
+ else if (T !== null)
133
+ $ = /* @__PURE__ */ g(_, { children: [
134
+ /* @__PURE__ */ g(
135
+ "section",
136
+ {
137
+ "aria-labelledby": x,
138
+ className: "ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]",
139
+ children: [
140
+ /* @__PURE__ */ e("h2", { id: x, className: Ne, children: n("helpMeWriteTemplates.bar.after") }),
141
+ /* @__PURE__ */ e(
142
+ fe,
143
+ {
144
+ html: T,
145
+ profile: "rich-text",
146
+ className: xe,
147
+ tabIndex: 0
148
+ }
149
+ )
150
+ ]
151
+ }
152
+ ),
153
+ /* @__PURE__ */ g("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
154
+ /* @__PURE__ */ e(I, { intent: "ghost", startIcon: /* @__PURE__ */ e(te, {}), onClick: r.onClose, children: n("helpMeWriteTemplates.bar.discard") }),
155
+ /* @__PURE__ */ e(
156
+ I,
157
+ {
158
+ intent: "ghost",
159
+ startIcon: /* @__PURE__ */ e(ve, {}),
160
+ onClick: () => {
161
+ R(null), Q();
162
+ },
163
+ children: n("helpMeWriteTemplates.bar.retry")
164
+ }
165
+ ),
166
+ /* @__PURE__ */ e("span", { className: "ds:flex-1", "aria-hidden": "true" }),
167
+ /* @__PURE__ */ e(I, { intent: "primary", onClick: oe, children: r.scope === "selection" ? n("helpMeWriteTemplates.bar.replace") : n("helpMeWriteTemplates.bar.insert") })
168
+ ] })
169
+ ] });
170
+ else {
171
+ const c = M ? ne(d, A) : d;
172
+ $ = /* @__PURE__ */ g(_, { children: [
173
+ /* @__PURE__ */ g("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
174
+ /* @__PURE__ */ e(
175
+ L,
176
+ {
177
+ size: "md",
178
+ intent: "outline",
179
+ className: B,
180
+ icon: /* @__PURE__ */ e(te, {}),
181
+ "aria-label": n("helpMeWriteTemplates.bar.close"),
182
+ onClick: r.onClose
183
+ }
184
+ ),
185
+ /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ e(
186
+ se,
187
+ {
188
+ size: "md",
189
+ value: c,
190
+ onChange: (b) => k(b.target.value),
191
+ placeholder: n("editor.ai.promptPlaceholder"),
192
+ "aria-label": n("editor.ai.promptLabel"),
193
+ autoResize: !0,
194
+ minRows: 1,
195
+ maxRows: 3,
196
+ readOnly: y || M,
197
+ tone: E ? "error" : "default",
198
+ "aria-describedby": E ? s : void 0
199
+ }
200
+ ) }),
201
+ f ? /* @__PURE__ */ e(
202
+ L,
203
+ {
204
+ size: "md",
205
+ intent: "outline",
206
+ className: M ? `${B} ${ye}` : B,
207
+ icon: M ? /* @__PURE__ */ e(Te, { className: "ds:fill-current" }) : /* @__PURE__ */ e(Me, {}),
208
+ "aria-pressed": M,
209
+ "aria-label": n(M ? "helpMeWriteTemplates.bar.dictateStop" : "helpMeWriteTemplates.bar.dictateStart"),
210
+ disabled: y,
211
+ onClick: ie
212
+ }
213
+ ) : null,
214
+ /* @__PURE__ */ e(
215
+ L,
216
+ {
217
+ size: "md",
218
+ intent: "primary",
219
+ className: we,
220
+ icon: y ? /* @__PURE__ */ e(ue, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ e(Ce, {}),
221
+ disabled: y || !d.trim(),
222
+ "aria-busy": y || void 0,
223
+ "aria-label": n("helpMeWriteTemplates.bar.write"),
224
+ onClick: Q
225
+ }
226
+ )
227
+ ] }),
228
+ f ? /* @__PURE__ */ e("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: V }) : null,
229
+ E ? /* @__PURE__ */ e("p", { id: s, role: "alert", className: J, children: n("helpMeWriteTemplates.bar.error") }) : null,
230
+ /* @__PURE__ */ g("p", { className: J, children: [
231
+ r.scope === "selection" ? n("helpMeWriteTemplates.bar.contextSelection") : n("helpMeWriteTemplates.bar.contextDocument"),
232
+ " ",
233
+ r.privacyNotice
234
+ ] })
235
+ ] });
236
+ }
237
+ return /* @__PURE__ */ e(
238
+ me,
239
+ {
240
+ open: t,
241
+ onClose: le,
242
+ ariaLabel: n("editor.ai.helpMeWrite"),
243
+ children: /* @__PURE__ */ e("div", { className: "ds:contents", "data-component": "help-me-write-templates-bar", children: $ })
244
+ }
245
+ );
246
+ }
247
+ const Ee = ce("", {
248
+ variants: {
249
+ dragging: { true: "ds:opacity-60", false: "" },
250
+ dropTarget: {
251
+ true: "ds:outline-[length:var(--focus-ring-width)] ds:outline-dashed ds:outline-[var(--primary)] ds:outline-offset-[-2px]",
252
+ false: ""
253
+ }
254
+ },
255
+ defaultVariants: { dragging: !1, dropTarget: !1 }
256
+ });
257
+ function Re(r, m) {
258
+ const { t: v } = U("ui"), [u, N] = h(null), [w, n] = h(null), [t, x] = h(""), s = q(!1), d = (i, p) => {
259
+ const l = Math.max(0, Math.min(r.length - 1, p));
260
+ if (!m || l === i) return;
261
+ const T = r.map((f) => f.id), [R] = T.splice(i, 1);
262
+ T.splice(l, 0, R), m(T), s.current = !s.current;
263
+ const o = v("helpMeWriteTemplates.manager.reorderAnnounce", {
264
+ label: r[i].name,
265
+ to: l + 1,
266
+ total: r.length
267
+ });
268
+ x(s.current ? o : `${o}​`);
269
+ };
270
+ return { rowProps: (i) => m ? {
271
+ draggable: !0,
272
+ onDragStart: (p) => {
273
+ N(i), p.dataTransfer.effectAllowed = "move", p.dataTransfer.setData("text/plain", String(i));
274
+ },
275
+ onDragEnd: () => {
276
+ N(null), n(null);
277
+ },
278
+ onDragOver: (p) => {
279
+ u !== null && (p.preventDefault(), p.dataTransfer.dropEffect = "move", n(i));
280
+ },
281
+ onDragLeave: () => n(null),
282
+ onDrop: (p) => {
283
+ p.preventDefault();
284
+ const l = u;
285
+ N(null), n(null), l !== null && d(l, i);
286
+ }
287
+ } : {}, rowClass: (i) => Ee({
288
+ dragging: u === i,
289
+ dropTarget: w === i && u !== i
290
+ }), handle: (i, p) => /* @__PURE__ */ e(
291
+ L,
292
+ {
293
+ size: "sm",
294
+ intent: "ghost",
295
+ icon: /* @__PURE__ */ e(We, { "aria-hidden": "true" }),
296
+ "aria-label": v("helpMeWriteTemplates.manager.reorderHandle", {
297
+ label: p
298
+ }),
299
+ className: "ds:cursor-grab ds:active:cursor-grabbing",
300
+ onKeyDown: (l) => {
301
+ if (!l.altKey) return;
302
+ const T = l.key === "ArrowUp" ? i - 1 : l.key === "ArrowDown" ? i + 1 : l.key === "Home" ? 0 : l.key === "End" ? r.length - 1 : null;
303
+ T !== null && (l.preventDefault(), d(i, T));
304
+ }
305
+ }
306
+ ), liveRegion: /* @__PURE__ */ e("span", { role: "status", "aria-live": "polite", className: "ds:sr-only", children: t }) };
307
+ }
308
+ const Y = {
309
+ name: "",
310
+ description: "",
311
+ prompt: "",
312
+ submitted: !1
313
+ };
314
+ function ze({
315
+ open: r,
316
+ onOpenChange: m,
317
+ initialMode: v = "list",
318
+ templates: u,
319
+ onSaveTemplate: N,
320
+ onDeleteTemplate: w,
321
+ onReorderTemplates: n
322
+ }) {
323
+ const { t } = U("ui"), x = Re(u, n), [s, d] = h(null), [k, y] = h(!1), [D, E] = h(!1), [i, p] = h(null), [l, T] = h(!1), [R, o] = h(!1), f = async () => {
324
+ if (!(!i || l)) {
325
+ T(!0), o(!1);
326
+ try {
327
+ await (w == null ? void 0 : w(i.id)), p(null);
328
+ } catch {
329
+ o(!0);
330
+ } finally {
331
+ T(!1);
332
+ }
333
+ }
334
+ };
335
+ j(() => {
336
+ r && (E(!1), d(v === "create" ? { ...Y } : null));
337
+ }, [r]);
338
+ const M = (a, C) => u.some(
339
+ (z) => z.id !== C && z.name.toLowerCase() === a.toLowerCase()
340
+ ), S = (() => {
341
+ if (!(s != null && s.submitted)) return;
342
+ const a = s.name.trim();
343
+ return a ? M(a, s.id) ? t("helpMeWriteTemplates.manager.nameTaken") : void 0 : t("helpMeWriteTemplates.manager.nameRequired");
344
+ })(), A = s != null && s.submitted && !s.prompt.trim() ? t("helpMeWriteTemplates.manager.promptRequired") : void 0, H = async () => {
345
+ if (!s || k) return;
346
+ const a = { ...s, submitted: !0 };
347
+ d(a);
348
+ const C = a.name.trim(), z = a.prompt.trim();
349
+ if (!(!C || !z || M(C, a.id))) {
350
+ y(!0), E(!1);
351
+ try {
352
+ await N({
353
+ id: a.id,
354
+ name: C,
355
+ description: a.description.trim() || void 0,
356
+ prompt: z
357
+ }), d(null);
358
+ } catch {
359
+ E(!0);
360
+ } finally {
361
+ y(!1);
362
+ }
363
+ }
364
+ }, V = s ? s.id ? t("helpMeWriteTemplates.manager.formEdit") : t("helpMeWriteTemplates.manager.formNew") : t("helpMeWriteTemplates.manager.title");
365
+ return /* @__PURE__ */ g(_, { children: [
366
+ /* @__PURE__ */ e(W, { open: r, onOpenChange: m, children: /* @__PURE__ */ e(W.Content, { size: "lg", children: /* @__PURE__ */ g("div", { className: "ds:contents", "data-component": "ai-template-manager", children: [
367
+ /* @__PURE__ */ g(W.Header, { children: [
368
+ /* @__PURE__ */ e(W.Title, { children: V }),
369
+ /* @__PURE__ */ e(W.Description, { children: t("helpMeWriteTemplates.manager.description") })
370
+ ] }),
371
+ /* @__PURE__ */ g(W.Body, { children: [
372
+ s ? /* @__PURE__ */ g("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
373
+ D ? /* @__PURE__ */ e(Z, { variant: "error", children: t("helpMeWriteTemplates.manager.saveError") }) : null,
374
+ /* @__PURE__ */ e(
375
+ X,
376
+ {
377
+ label: t("helpMeWriteTemplates.manager.name"),
378
+ error: S,
379
+ required: !0,
380
+ children: /* @__PURE__ */ e(
381
+ re,
382
+ {
383
+ value: s.name,
384
+ maxLength: 100,
385
+ placeholder: t(
386
+ "helpMeWriteTemplates.manager.namePlaceholder"
387
+ ),
388
+ onChange: (a) => d({ ...s, name: a.target.value })
389
+ }
390
+ )
391
+ }
392
+ ),
393
+ /* @__PURE__ */ e(
394
+ X,
395
+ {
396
+ label: t("helpMeWriteTemplates.manager.descLabel"),
397
+ description: t("helpMeWriteTemplates.manager.descHint"),
398
+ optional: !0,
399
+ children: /* @__PURE__ */ e(
400
+ re,
401
+ {
402
+ value: s.description,
403
+ maxLength: 120,
404
+ onChange: (a) => d({ ...s, description: a.target.value })
405
+ }
406
+ )
407
+ }
408
+ ),
409
+ /* @__PURE__ */ e(
410
+ X,
411
+ {
412
+ label: t("helpMeWriteTemplates.manager.prompt"),
413
+ description: t(
414
+ "helpMeWriteTemplates.manager.promptDescription"
415
+ ),
416
+ error: A,
417
+ required: !0,
418
+ children: /* @__PURE__ */ e(
419
+ se,
420
+ {
421
+ value: s.prompt,
422
+ maxLength: 4e3,
423
+ autoResize: !0,
424
+ minRows: 4,
425
+ maxRows: 10,
426
+ onChange: (a) => d({ ...s, prompt: a.target.value })
427
+ }
428
+ )
429
+ }
430
+ )
431
+ ] }) : u.length === 0 ? /* @__PURE__ */ e(
432
+ pe,
433
+ {
434
+ variant: "first-use",
435
+ size: "sm",
436
+ title: t("helpMeWriteTemplates.manager.emptyTitle"),
437
+ description: t(
438
+ "helpMeWriteTemplates.manager.emptyDescription"
439
+ ),
440
+ primaryAction: {
441
+ label: t("helpMeWriteTemplates.manager.new"),
442
+ onClick: () => d({ ...Y })
443
+ }
444
+ }
445
+ ) : /* @__PURE__ */ e(
446
+ "ul",
447
+ {
448
+ "aria-label": t("helpMeWriteTemplates.manager.listLabel"),
449
+ className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0",
450
+ children: u.map((a, C) => /* @__PURE__ */ g(
451
+ "li",
452
+ {
453
+ ...x.rowProps(C),
454
+ className: `ds:flex ds:items-start ds:gap-[var(--spacing-sm)] ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)] ds:p-[var(--spacing-sm)] ${x.rowClass(C)}`,
455
+ children: [
456
+ n ? x.handle(C, a.name) : null,
457
+ /* @__PURE__ */ g("div", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
458
+ /* @__PURE__ */ e("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", children: /* @__PURE__ */ e("span", { className: "type-title-item ds:text-[color:var(--foreground)]", children: a.name }) }),
459
+ /* @__PURE__ */ e("p", { className: `${J} ds:line-clamp-2`, children: a.description || a.prompt })
460
+ ] }),
461
+ /* @__PURE__ */ e(
462
+ L,
463
+ {
464
+ size: "sm",
465
+ intent: "ghost",
466
+ icon: /* @__PURE__ */ e(ge, {}),
467
+ "aria-label": t("helpMeWriteTemplates.manager.edit", {
468
+ name: a.name
469
+ }),
470
+ onClick: () => d({
471
+ id: a.id,
472
+ name: a.name,
473
+ description: a.description ?? "",
474
+ prompt: a.prompt,
475
+ submitted: !1
476
+ })
477
+ }
478
+ ),
479
+ w ? /* @__PURE__ */ e(
480
+ L,
481
+ {
482
+ size: "sm",
483
+ intent: "ghost",
484
+ icon: /* @__PURE__ */ e(he, {}),
485
+ "aria-label": t("helpMeWriteTemplates.manager.delete", {
486
+ name: a.name
487
+ }),
488
+ onClick: () => p(a)
489
+ }
490
+ ) : null
491
+ ]
492
+ },
493
+ a.id
494
+ ))
495
+ }
496
+ ),
497
+ x.liveRegion
498
+ ] }),
499
+ /* @__PURE__ */ e(W.Footer, { children: s ? /* @__PURE__ */ g(_, { children: [
500
+ /* @__PURE__ */ e(I, { intent: "secondary", onClick: () => d(null), children: t("helpMeWriteTemplates.manager.cancel") }),
501
+ /* @__PURE__ */ e(
502
+ I,
503
+ {
504
+ intent: "primary",
505
+ loading: k,
506
+ onClick: () => void H(),
507
+ children: t("helpMeWriteTemplates.manager.save")
508
+ }
509
+ )
510
+ ] }) : /* @__PURE__ */ g(_, { children: [
511
+ u.length > 0 ? /* @__PURE__ */ e(
512
+ I,
513
+ {
514
+ intent: "outline",
515
+ startIcon: /* @__PURE__ */ e(be, {}),
516
+ onClick: () => d({ ...Y }),
517
+ children: t("helpMeWriteTemplates.manager.new")
518
+ }
519
+ ) : null,
520
+ /* @__PURE__ */ e(W.Close, { asChild: !0, children: /* @__PURE__ */ e(I, { intent: "primary", children: t("helpMeWriteTemplates.manager.done") }) })
521
+ ] }) })
522
+ ] }) }) }),
523
+ /* @__PURE__ */ e(
524
+ W,
525
+ {
526
+ open: i != null,
527
+ onOpenChange: (a) => {
528
+ !a && !l && (p(null), o(!1));
529
+ },
530
+ children: /* @__PURE__ */ g(W.Content, { size: "sm", variant: "alert", children: [
531
+ /* @__PURE__ */ g(W.Header, { children: [
532
+ /* @__PURE__ */ e(W.Title, { children: t("helpMeWriteTemplates.manager.deleteTitle", {
533
+ name: (i == null ? void 0 : i.name) ?? ""
534
+ }) }),
535
+ /* @__PURE__ */ e(W.Description, { children: t("helpMeWriteTemplates.manager.deleteDescription") })
536
+ ] }),
537
+ R ? /* @__PURE__ */ e(W.Body, { children: /* @__PURE__ */ e(Z, { variant: "error", children: t("helpMeWriteTemplates.manager.deleteError") }) }) : null,
538
+ /* @__PURE__ */ g(W.Footer, { children: [
539
+ /* @__PURE__ */ e(W.Close, { asChild: !0, children: /* @__PURE__ */ e(I, { intent: "secondary", disabled: l, children: t("helpMeWriteTemplates.manager.cancel") }) }),
540
+ /* @__PURE__ */ e(
541
+ I,
542
+ {
543
+ intent: "destructive",
544
+ loading: l,
545
+ onClick: () => void f(),
546
+ children: t("helpMeWriteTemplates.manager.deleteConfirm")
547
+ }
548
+ )
549
+ ] })
550
+ ] })
551
+ }
552
+ )
553
+ ] });
554
+ }
555
+ function Ie({
556
+ applied: r,
557
+ onUndo: m,
558
+ onDismiss: v
559
+ }) {
560
+ const { t: u } = U("ui"), N = q(null);
561
+ if (j(() => {
562
+ var n;
563
+ r && ((n = N.current) == null || n.focus());
564
+ }, [r]), !(r != null && r.template)) return null;
565
+ const w = r.template.name;
566
+ return /* @__PURE__ */ e(
567
+ Z,
568
+ {
569
+ variant: "success",
570
+ dismissible: !0,
571
+ onOpenChange: (n) => {
572
+ n || v();
573
+ },
574
+ "data-component": "help-me-write-undo-notice",
575
+ children: /* @__PURE__ */ g("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
576
+ /* @__PURE__ */ e("span", { children: r.mode === "below" ? u("helpMeWriteTemplates.undo.addedBelow", { name: w }) : u("helpMeWriteTemplates.undo.replaced", { name: w }) }),
577
+ /* @__PURE__ */ e(I, { ref: N, intent: "outline", size: "sm", onClick: m, children: u("helpMeWriteTemplates.undo.undo") })
578
+ ] })
579
+ }
580
+ );
581
+ }
582
+ function nr({
583
+ templates: r,
584
+ onGenerate: m,
585
+ onSaveTemplate: v,
586
+ onDeleteTemplate: u,
587
+ onReorderTemplates: N,
588
+ credits: w,
589
+ enableDictation: n,
590
+ onApplied: t,
591
+ creditsNotice: x
592
+ }) {
593
+ const [s, d] = h({ open: !1, mode: "list" }), [k, y] = h(null), D = P(
594
+ (o = "list") => d({ open: !0, mode: o }),
595
+ []
596
+ ), E = P(
597
+ (o) => /* @__PURE__ */ e(
598
+ De,
599
+ {
600
+ context: o,
601
+ onGenerate: m,
602
+ credits: w,
603
+ enableDictation: n,
604
+ suspendClose: s.open,
605
+ onApplied: t
606
+ }
607
+ ),
608
+ [m, w, n, s.open, t]
609
+ ), i = K(() => {
610
+ const o = new Map(r.map((f) => [f.id, f]));
611
+ return {
612
+ templates: r,
613
+ onRun: ({ template: f, text: M, scope: S, signal: A }) => {
614
+ const H = o.get(f.id);
615
+ return H ? m({
616
+ template: H,
617
+ prompt: "",
618
+ sourceText: M,
619
+ scope: S,
620
+ signal: A
621
+ }) : Promise.reject(new Error("Unknown template"));
622
+ },
623
+ onManage: v ? D : void 0
624
+ };
625
+ }, [r, m, v, D]), p = P(
626
+ (o) => {
627
+ if (o.action !== "template" || !o.template) return;
628
+ const f = r.find((S) => {
629
+ var A;
630
+ return S.id === ((A = o.template) == null ? void 0 : A.id);
631
+ }), M = {
632
+ mode: "replace",
633
+ template: f,
634
+ previousHtml: o.previousHtml,
635
+ undo: o.undo
636
+ };
637
+ y(f ? M : null), t == null || t(M);
638
+ },
639
+ [r, t]
640
+ ), l = K(
641
+ () => v ? /* @__PURE__ */ e(
642
+ ze,
643
+ {
644
+ open: s.open,
645
+ initialMode: s.mode,
646
+ onOpenChange: (o) => d((f) => ({ ...f, open: o })),
647
+ templates: r,
648
+ onSaveTemplate: v,
649
+ onDeleteTemplate: u,
650
+ onReorderTemplates: N
651
+ }
652
+ ) : null,
653
+ [s, r, v, u, N]
654
+ ), T = /* @__PURE__ */ e(
655
+ Ie,
656
+ {
657
+ applied: k,
658
+ onUndo: () => {
659
+ k == null || k.undo(), y(null);
660
+ },
661
+ onDismiss: () => y(null)
662
+ }
663
+ ), R = K(
664
+ () => ({
665
+ renderHelpMeWrite: E,
666
+ aiTemplates: i,
667
+ onAiApplied: p,
668
+ aiCreditsNotice: x
669
+ }),
670
+ [E, i, p, x]
671
+ );
672
+ return {
673
+ ...R,
674
+ editorProps: R,
675
+ manager: l,
676
+ undoNotice: T,
677
+ openManager: D
678
+ };
679
+ }
680
+ export {
681
+ ae as A,
682
+ De as H,
683
+ ze as a,
684
+ Ie as b,
685
+ nr as u
686
+ };
687
+ //# sourceMappingURL=help-me-write-templates-Bw3Q58x-.js.map