@alfadocs/ui-kit 1.43.0 → 1.45.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 (113) hide show
  1. package/dist/_chunks/ai-sparkle-DXeP_6a0.js +52 -0
  2. package/dist/_chunks/{calendar-ChJQzRw-.js → calendar-U6N0F99w.js} +383 -359
  3. package/dist/_chunks/calendar-workspace-B7KvZ1_D.js +12161 -0
  4. package/dist/_chunks/{face-scheme-Dg6ZyLKb.js → face-scheme-Bm6pe7R8.js} +265 -275
  5. package/dist/_chunks/help-me-write-templates-GUeEn3Ff.js +741 -0
  6. package/dist/_chunks/{notes-panel-CRAovkjx.js → notes-panel-Dkk9QPPX.js} +159 -152
  7. package/dist/_chunks/{panel-subview-PMBRPFOa.js → panel-subview-CYnuX-KR.js} +61 -40
  8. package/dist/_chunks/rich-text-editor-BrAvNajV.js +3779 -0
  9. package/dist/_chunks/undo-2-CYNAzclj.js +26 -0
  10. package/dist/_chunks/use-ai-sparkle-CyQSRTCe.js +103 -0
  11. package/dist/_chunks/variables-menu-vXUaSBj4.js +401 -0
  12. package/dist/agent-catalog.json +84 -3
  13. package/dist/agent-i18n/en.json +14 -3
  14. package/dist/components/ai-sparkle/ai-sparkle.d.ts +24 -0
  15. package/dist/components/ai-sparkle/index.d.ts +3 -0
  16. package/dist/components/ai-sparkle/index.js +5 -0
  17. package/dist/components/calendar/calendar.d.ts +6 -0
  18. package/dist/components/calendar/index.js +1 -1
  19. package/dist/components/face-scheme/index.js +1 -1
  20. package/dist/components/index.d.ts +4 -2
  21. package/dist/components/notes-panel/index.js +1 -1
  22. package/dist/components/notes-panel/notes-panel.d.ts +4 -0
  23. package/dist/components/panel-subview/index.js +1 -1
  24. package/dist/components/panel-subview/panel-subview.d.ts +6 -0
  25. package/dist/components/rich-text-editor/editor-toolbar.d.ts +35 -3
  26. package/dist/components/rich-text-editor/index.d.ts +1 -1
  27. package/dist/components/rich-text-editor/index.js +1 -1
  28. package/dist/components/rich-text-editor/rich-text-editor.d.ts +98 -15
  29. package/dist/components/variables-menu/index.d.ts +4 -0
  30. package/dist/components/variables-menu/index.js +6 -0
  31. package/dist/components/variables-menu/variables-menu.agent.d.ts +10 -0
  32. package/dist/components/variables-menu/variables-menu.d.ts +53 -0
  33. package/dist/hooks/index.d.ts +1 -0
  34. package/dist/hooks/index.js +64 -56
  35. package/dist/hooks/use-ai-sparkle.d.ts +109 -0
  36. package/dist/host-compat.css +5 -5
  37. package/dist/i18n/locales/ar.d.ts +77 -6
  38. package/dist/i18n/locales/ar.js +78 -7
  39. package/dist/i18n/locales/de.d.ts +77 -6
  40. package/dist/i18n/locales/de.js +78 -7
  41. package/dist/i18n/locales/el.d.ts +77 -6
  42. package/dist/i18n/locales/el.js +78 -7
  43. package/dist/i18n/locales/en.d.ts +77 -6
  44. package/dist/i18n/locales/en.js +85 -7
  45. package/dist/i18n/locales/es.d.ts +77 -6
  46. package/dist/i18n/locales/es.js +78 -7
  47. package/dist/i18n/locales/fr.d.ts +77 -6
  48. package/dist/i18n/locales/fr.js +78 -7
  49. package/dist/i18n/locales/hi.d.ts +77 -6
  50. package/dist/i18n/locales/hi.js +78 -7
  51. package/dist/i18n/locales/it.d.ts +77 -6
  52. package/dist/i18n/locales/it.js +78 -7
  53. package/dist/i18n/locales/ja.d.ts +77 -6
  54. package/dist/i18n/locales/ja.js +78 -7
  55. package/dist/i18n/locales/nl.d.ts +77 -6
  56. package/dist/i18n/locales/nl.js +78 -7
  57. package/dist/i18n/locales/pl.d.ts +77 -6
  58. package/dist/i18n/locales/pl.js +78 -7
  59. package/dist/i18n/locales/pt.d.ts +77 -6
  60. package/dist/i18n/locales/pt.js +78 -7
  61. package/dist/i18n/locales/ro.d.ts +77 -6
  62. package/dist/i18n/locales/ro.js +78 -7
  63. package/dist/i18n/locales/ru.d.ts +77 -6
  64. package/dist/i18n/locales/ru.js +78 -7
  65. package/dist/i18n/locales/sq.d.ts +77 -6
  66. package/dist/i18n/locales/sq.js +78 -7
  67. package/dist/i18n/locales/sv.d.ts +77 -6
  68. package/dist/i18n/locales/sv.js +78 -7
  69. package/dist/i18n/locales/tr.d.ts +77 -6
  70. package/dist/i18n/locales/tr.js +78 -7
  71. package/dist/i18n/locales/zh.d.ts +77 -6
  72. package/dist/i18n/locales/zh.js +78 -7
  73. package/dist/index.js +1106 -1099
  74. package/dist/locales/ar.json +78 -7
  75. package/dist/locales/de.json +78 -7
  76. package/dist/locales/el.json +78 -7
  77. package/dist/locales/en.json +78 -7
  78. package/dist/locales/es.json +78 -7
  79. package/dist/locales/fr.json +78 -7
  80. package/dist/locales/hi.json +78 -7
  81. package/dist/locales/it.json +78 -7
  82. package/dist/locales/ja.json +78 -7
  83. package/dist/locales/nl.json +78 -7
  84. package/dist/locales/pl.json +78 -7
  85. package/dist/locales/pt.json +78 -7
  86. package/dist/locales/ro.json +78 -7
  87. package/dist/locales/ru.json +78 -7
  88. package/dist/locales/sq.json +78 -7
  89. package/dist/locales/sv.json +78 -7
  90. package/dist/locales/tr.json +78 -7
  91. package/dist/locales/zh.json +78 -7
  92. package/dist/patterns/calendar/calendar-bookings-panel.d.ts +8 -3
  93. package/dist/patterns/calendar/calendar-care-rules.d.ts +49 -0
  94. package/dist/patterns/calendar/calendar-task-editor.d.ts +31 -0
  95. package/dist/patterns/calendar/calendar-workspace.d.ts +8 -1
  96. package/dist/patterns/calendar/calendar-workspace.model.d.ts +39 -12
  97. package/dist/patterns/calendar/calendar.data.d.ts +9 -0
  98. package/dist/patterns/calendar/calendar.journey.d.ts +35 -3
  99. package/dist/patterns/calendar/calendar.model.d.ts +23 -1
  100. package/dist/patterns/calendar/calendar.sheets.d.ts +21 -3
  101. package/dist/patterns/calendar/calendar.surface.d.ts +6 -1
  102. package/dist/patterns/calendar/calendar.types.d.ts +32 -1
  103. package/dist/patterns/calendar/index.js +1 -1
  104. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +58 -26
  105. package/dist/patterns/help-me-write-templates/index.d.ts +1 -1
  106. package/dist/patterns/help-me-write-templates/index.js +1 -1
  107. package/dist/tokens.css +6 -6
  108. package/package.json +5 -1
  109. package/dist/_chunks/calendar-workspace-DhXqqu-D.js +0 -11392
  110. package/dist/_chunks/help-me-write-templates-B-m7zgJa.js +0 -775
  111. package/dist/_chunks/highlighter-DSkckT2Q.js +0 -15
  112. package/dist/_chunks/rich-text-editor-DUMeifwc.js +0 -3176
  113. package/dist/_chunks/wand-sparkles-DAjKyhz7.js +0 -27
@@ -1,775 +0,0 @@
1
- import { jsxs as i, jsx as e, Fragment as E } from "react/jsx-runtime";
2
- import { useState as h, useEffect as U, useId as ie, useRef as te, useCallback as O, useMemo as Ne } from "react";
3
- import { useTranslation as V } from "react-i18next";
4
- import { A as R } from "./alert-CiQ5Pa3Q.js";
5
- import { B as fe } from "./badge-BudgzTe_.js";
6
- import { B as g } from "./button-CaUe1uyd.js";
7
- import { I as H } from "./icon-button-CehAeZoP.js";
8
- import { D as f } from "./dialog-BJiLqhx6.js";
9
- import { D as z } from "./dropdown-menu-DU-Hrf33.js";
10
- import { E as we } from "./editor-overlay-DwNKaI22.js";
11
- import { E as ke } from "./empty-state-BUN_UAWf.js";
12
- import { F as Q } from "./form-field-CahJzTxp.js";
13
- import { P as De } from "./progress-CK8otcQ-.js";
14
- import { S as le } from "./spinner-hbwuKwMf.js";
15
- import { S as Ie } from "./switch-OILsBLWo.js";
16
- import { T as ge } from "./text-area-Bt3p7Pt0.js";
17
- import { T as oe } from "./text-input-CUvCb6ST.js";
18
- import { SafeHtml as Se } from "../safe-html/index.js";
19
- import { T as ze } from "./trending-up-C_luYBzS.js";
20
- import { A as Ee } from "./astroid-BN4f5VXU.js";
21
- import { A as Re } from "./arrow-left-BfaGqVam.js";
22
- import { P as $e } from "./pencil-B1sKKyuT.js";
23
- import { T as Ae } from "./trash-2-uumy3fy1.js";
24
- import { P as be } from "./plus-DzMQ_c6b.js";
25
- import { X as de } from "./x-B5YnXwCz.js";
26
- import { R as Be } from "./rotate-ccw-BBQnIVTr.js";
27
- import { S as Oe } from "./square-DASBRZ0U.js";
28
- import { M as Fe } from "./mic-CUklMZGF.js";
29
- import { C as Le } from "./chevron-down-DWE7GSq9.js";
30
- import { W as ce } from "./wand-sparkles-DAjKyhz7.js";
31
- import { S as _e } from "./settings-d25ju_6L.js";
32
- import { S as He } from "./send-C5kDJ-Mz.js";
33
- class me extends Error {
34
- constructor(c = "AI credits exhausted") {
35
- super(c), this.name = "AiCreditsExhaustedError";
36
- }
37
- }
38
- const q = "ds:!size-[var(--min-target-size)]", Pe = "ds:!h-[var(--min-target-size)] ds:shrink-0", je = `${q} ds:bg-[image:var(--gradient-brand)] ds:rounded-full`, qe = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", G = "ds:m-0 ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", pe = "type-eyebrow ds:m-0 ds:text-[color:var(--muted-foreground)]", ee = [
39
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
40
- "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
41
- "ds:p-[var(--spacing-sm)] ds:[max-block-size:14rem] ds:overflow-y-auto",
42
- "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]",
43
- "ds:[&_ul]:list-disc ds:[&_ul]:ps-[var(--spacing-md)]",
44
- "ds:[&_h3]:font-medium ds:[&_h3]:[margin-block-start:var(--spacing-xs)]",
45
- "ds:[&_p]:[margin-block-end:var(--spacing-xs)]",
46
- "ds:[&>:first-child]:[margin-block-start:0]"
47
- ].join(" "), ue = "ds:[block-size:14rem]";
48
- function ve(r) {
49
- return [...r].sort(
50
- (c, o) => Number(o.isDefault) - Number(c.isDefault)
51
- );
52
- }
53
- function he(r, c) {
54
- return c ? r ? /\s$/.test(r) ? `${r}${c}` : `${r} ${c}` : c : r;
55
- }
56
- function Ue(r) {
57
- return typeof r == "object" && r !== null && "name" in r && r.name === "AbortError";
58
- }
59
- function Ge({
60
- credits: r,
61
- onBack: c
62
- }) {
63
- const { t: o, i18n: p } = V(), u = r == null ? void 0 : r.limit, b = (r == null ? void 0 : r.remaining) ?? 0, t = u !== void 0 ? o("helpMeWriteTemplates.credits.remaining", { remaining: b, limit: u }) : void 0, n = r != null && r.resetsOn ? new Intl.DateTimeFormat(p.language, {
64
- day: "numeric",
65
- month: "long"
66
- }).format(r.resetsOn) : void 0;
67
- return /* @__PURE__ */ i(
68
- "div",
69
- {
70
- className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
71
- "data-component": "ai-credits-exhausted-notice",
72
- children: [
73
- /* @__PURE__ */ i(R, { variant: "promo", icon: /* @__PURE__ */ e(Ee, { "aria-hidden": "true" }), children: [
74
- /* @__PURE__ */ e(R.Title, { as: "h2", children: o("helpMeWriteTemplates.credits.title") }),
75
- /* @__PURE__ */ e(R.Description, { children: r != null && r.onBuyCredits ? n ? o("helpMeWriteTemplates.credits.bodyResets", { date: n }) : o("helpMeWriteTemplates.credits.body") : n ? o("helpMeWriteTemplates.credits.bodyWaitResets", {
76
- date: n
77
- }) : o("helpMeWriteTemplates.credits.bodyWait") }),
78
- u !== void 0 && t ? /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)] ds:[margin-block-start:var(--spacing-sm)]", children: [
79
- /* @__PURE__ */ i("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
80
- /* @__PURE__ */ e("span", { className: "type-label", children: o("helpMeWriteTemplates.credits.meterLabel") }),
81
- /* @__PURE__ */ e("span", { className: "type-label ds:ms-auto ds:tabular-nums", children: t })
82
- ] }),
83
- /* @__PURE__ */ e(
84
- De,
85
- {
86
- value: Math.max(0, u - b),
87
- max: u,
88
- size: "sm",
89
- ariaLabel: o("helpMeWriteTemplates.credits.meterLabel"),
90
- ariaValueText: t
91
- }
92
- )
93
- ] }) : null,
94
- r != null && r.onBuyCredits || r != null && r.onSeeCosts ? /* @__PURE__ */ i(R.Action, { children: [
95
- r.onBuyCredits ? /* @__PURE__ */ e(
96
- g,
97
- {
98
- intent: "tonal",
99
- size: "sm",
100
- startIcon: /* @__PURE__ */ e(ze, { "aria-hidden": "true" }),
101
- onClick: r.onBuyCredits,
102
- children: o("helpMeWriteTemplates.credits.cta")
103
- }
104
- ) : null,
105
- r.onSeeCosts ? /* @__PURE__ */ e(g, { intent: "link", size: "sm", onClick: r.onSeeCosts, children: o("helpMeWriteTemplates.credits.secondary") }) : null
106
- ] }) : null
107
- ] }),
108
- /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
109
- c ? /* @__PURE__ */ e(g, { intent: "ghost", startIcon: /* @__PURE__ */ e(Re, {}), onClick: c, children: o("helpMeWriteTemplates.credits.back") }) : null,
110
- /* @__PURE__ */ e("p", { className: G, children: o("helpMeWriteTemplates.credits.kept") })
111
- ] })
112
- ]
113
- }
114
- );
115
- }
116
- function Ve({
117
- context: r,
118
- templates: c,
119
- onGenerate: o,
120
- onManageTemplates: p,
121
- onApplied: u,
122
- credits: b,
123
- enableDictation: t = !0,
124
- suspendClose: n = !1
125
- }) {
126
- const { t: a } = V(), { open: N } = r, M = ie(), S = ie(), [C, x] = h(""), [I, v] = h(null), [y, F] = h(!1), [L, $] = h(!1), [w, _] = h(null), [k, X] = h({
127
- kind: "document",
128
- words: 0,
129
- text: ""
130
- }), A = te(null), s = I !== null, D = t ? r.onDictate : void 0, [T, se] = h(!1), [Te, Y] = h(""), [Me, Z] = h(""), B = te(null), P = O(() => {
131
- var l;
132
- return (l = B.current) == null ? void 0 : l.abort();
133
- }, []), We = O(() => {
134
- if (T) {
135
- P();
136
- return;
137
- }
138
- if (!D) return;
139
- const l = new AbortController();
140
- B.current = l, se(!0), Z(a("helpMeWriteTemplates.bar.listening")), D({
141
- signal: l.signal,
142
- onPartialTranscript: (d) => {
143
- l.signal.aborted || Y(d);
144
- },
145
- onFinalTranscript: (d) => {
146
- if (l.signal.aborted) return;
147
- Y("");
148
- const W = d.trim();
149
- W && (x((m) => he(m, W)), Z(W));
150
- }
151
- }).catch((d) => {
152
- d instanceof me && $(!0);
153
- }).finally(() => {
154
- Y(""), B.current === l && (B.current = null, se(!1), Z(""));
155
- });
156
- }, [T, D, P, a]);
157
- U(() => {
158
- var l, d;
159
- if (N) {
160
- x(""), v(null), F(!1), $(r.creditsExhausted), _(null);
161
- const W = r.selectionText.trim(), m = W || r.getText();
162
- X({
163
- kind: W ? "selection" : "document",
164
- words: m.split(/\s+/).filter(Boolean).length,
165
- text: m
166
- });
167
- } else
168
- (l = A.current) == null || l.abort(), (d = B.current) == null || d.abort();
169
- }, [N]), U(
170
- () => () => {
171
- var l, d;
172
- (l = A.current) == null || l.abort(), (d = B.current) == null || d.abort();
173
- },
174
- []
175
- );
176
- const J = O(
177
- (l) => {
178
- var W;
179
- if (s || (l ? k.words === 0 : !C.trim())) return;
180
- P(), (W = A.current) == null || W.abort();
181
- const d = new AbortController();
182
- A.current = d, F(!1), v(l), o({
183
- template: l,
184
- prompt: C.trim(),
185
- sourceText: l ? k.text : "",
186
- signal: d.signal
187
- }).then((m) => {
188
- d.signal.aborted || (_({ draft: m, template: l }), v(null));
189
- }).catch((m) => {
190
- d.signal.aborted || Ue(m) || (m instanceof me ? $(!0) : F(!0), v(null));
191
- });
192
- },
193
- [s, k, C, o, P]
194
- ), { onClose: ae } = r, Ce = O(() => {
195
- n || ae();
196
- }, [n, ae]), K = (l) => {
197
- if (!w) return;
198
- const { draft: d, template: W } = w, m = r.getHTML(), ne = k.kind === "selection";
199
- l === "insert" ? r.insertAtSelection(d) : l === "replace" ? ne ? r.insertAtSelection(d) : r.setContent(d) : ne ? r.insertAfterSelection(d) : r.setContent(`${m}${d}`), r.onClose();
200
- const { setContent: ye } = r;
201
- u == null || u({
202
- mode: l,
203
- template: W,
204
- previousHtml: m,
205
- undo: () => ye(m)
206
- });
207
- }, xe = k.words === 0 ? a("helpMeWriteTemplates.bar.sourceEmpty") : k.kind === "selection" ? a("helpMeWriteTemplates.bar.sourceSelection") : a("helpMeWriteTemplates.bar.sourceDocument");
208
- let j;
209
- if (L)
210
- j = /* @__PURE__ */ e(
211
- Ge,
212
- {
213
- credits: b,
214
- onBack: () => $(!1)
215
- }
216
- );
217
- else if (w) {
218
- const l = !!w.template;
219
- j = /* @__PURE__ */ i(E, { children: [
220
- /* @__PURE__ */ i(
221
- "div",
222
- {
223
- className: l ? "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:lg:grid-cols-2" : "ds:grid ds:grid-cols-1",
224
- children: [
225
- l ? /* @__PURE__ */ i(
226
- "section",
227
- {
228
- "aria-labelledby": `${M}-before`,
229
- className: "ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]",
230
- children: [
231
- /* @__PURE__ */ e("h2", { id: `${M}-before`, className: pe, children: k.kind === "selection" ? a("helpMeWriteTemplates.bar.beforeSelection") : a("helpMeWriteTemplates.bar.beforeDocument") }),
232
- /* @__PURE__ */ e(
233
- "p",
234
- {
235
- className: `${ee} ${ue} ds:text-[color:var(--muted-foreground)]`,
236
- tabIndex: 0,
237
- children: k.text
238
- }
239
- )
240
- ]
241
- }
242
- ) : null,
243
- /* @__PURE__ */ i(
244
- "section",
245
- {
246
- "aria-labelledby": `${M}-after`,
247
- className: "ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-2xs)]",
248
- children: [
249
- /* @__PURE__ */ e("h2", { id: `${M}-after`, className: pe, children: w.template ? `${a("helpMeWriteTemplates.bar.after")} · ${w.template.name}` : a("helpMeWriteTemplates.bar.after") }),
250
- /* @__PURE__ */ e(
251
- Se,
252
- {
253
- html: w.draft,
254
- profile: "rich-text",
255
- className: l ? `${ee} ${ue}` : ee,
256
- tabIndex: 0
257
- }
258
- )
259
- ]
260
- }
261
- )
262
- ]
263
- }
264
- ),
265
- /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
266
- /* @__PURE__ */ e(g, { intent: "ghost", startIcon: /* @__PURE__ */ e(de, {}), onClick: r.onClose, children: a("helpMeWriteTemplates.bar.discard") }),
267
- /* @__PURE__ */ e(
268
- g,
269
- {
270
- intent: "ghost",
271
- startIcon: /* @__PURE__ */ e(Be, {}),
272
- onClick: () => {
273
- _(null), J(w.template);
274
- },
275
- children: a("helpMeWriteTemplates.bar.retry")
276
- }
277
- ),
278
- /* @__PURE__ */ e("span", { className: "ds:flex-1", "aria-hidden": "true" }),
279
- l ? /* @__PURE__ */ i(E, { children: [
280
- /* @__PURE__ */ e(g, { intent: "outline", onClick: () => K("below"), children: a("helpMeWriteTemplates.bar.insertBelow") }),
281
- /* @__PURE__ */ e(g, { intent: "primary", onClick: () => K("replace"), children: a("helpMeWriteTemplates.bar.replace") })
282
- ] }) : /* @__PURE__ */ e(g, { intent: "primary", onClick: () => K("insert"), children: a("helpMeWriteTemplates.bar.insert") })
283
- ] })
284
- ] });
285
- } else {
286
- const l = ve(c), d = T ? he(C, Te) : C, W = c.length > 0 || p;
287
- j = /* @__PURE__ */ i(E, { children: [
288
- /* @__PURE__ */ i("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
289
- /* @__PURE__ */ e(
290
- H,
291
- {
292
- size: "md",
293
- intent: "outline",
294
- className: q,
295
- icon: /* @__PURE__ */ e(de, {}),
296
- "aria-label": a("helpMeWriteTemplates.bar.close"),
297
- onClick: r.onClose
298
- }
299
- ),
300
- /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ e(
301
- ge,
302
- {
303
- size: "md",
304
- value: d,
305
- onChange: (m) => x(m.target.value),
306
- placeholder: a("helpMeWriteTemplates.bar.prompt"),
307
- "aria-label": a("helpMeWriteTemplates.bar.prompt"),
308
- autoResize: !0,
309
- minRows: 1,
310
- maxRows: 3,
311
- readOnly: s || T,
312
- tone: y ? "error" : "default",
313
- "aria-describedby": y ? S : void 0
314
- }
315
- ) }),
316
- D ? /* @__PURE__ */ e(
317
- H,
318
- {
319
- size: "md",
320
- intent: "outline",
321
- className: T ? `${q} ${qe}` : q,
322
- icon: T ? /* @__PURE__ */ e(Oe, { className: "ds:fill-current" }) : /* @__PURE__ */ e(Fe, {}),
323
- "aria-pressed": T,
324
- "aria-label": a(T ? "helpMeWriteTemplates.bar.dictateStop" : "helpMeWriteTemplates.bar.dictateStart"),
325
- disabled: s,
326
- onClick: We
327
- }
328
- ) : null,
329
- W ? /* @__PURE__ */ i(z.Root, { children: [
330
- /* @__PURE__ */ e(z.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
331
- g,
332
- {
333
- intent: "outline",
334
- size: "md",
335
- className: Pe,
336
- startIcon: I ? /* @__PURE__ */ e(le, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ e(ce, { "aria-hidden": "true" }),
337
- endIcon: /* @__PURE__ */ e(Le, { "aria-hidden": "true" }),
338
- "aria-haspopup": "menu",
339
- "aria-busy": I ? !0 : void 0,
340
- disabled: s,
341
- "aria-describedby": M,
342
- children: a("helpMeWriteTemplates.bar.templatesMenu")
343
- }
344
- ) }),
345
- /* @__PURE__ */ i(z.Content, { side: "top", align: "end", sideOffset: 8, children: [
346
- /* @__PURE__ */ e(z.Label, { children: a("helpMeWriteTemplates.bar.templatesGroup") }),
347
- l.map((m) => /* @__PURE__ */ e(
348
- z.Item,
349
- {
350
- startIcon: /* @__PURE__ */ e(ce, {}),
351
- description: m.description || void 0,
352
- disabled: s || k.words === 0,
353
- onSelect: () => J(m),
354
- children: /* @__PURE__ */ i("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
355
- m.name,
356
- m.isDefault ? /* @__PURE__ */ e(fe, { variant: "brand", size: "sm", children: a("helpMeWriteTemplates.bar.defaultBadge") }) : null
357
- ] })
358
- },
359
- m.id
360
- )),
361
- p && c.length === 0 ? /* @__PURE__ */ e(
362
- z.Item,
363
- {
364
- startIcon: /* @__PURE__ */ e(be, {}),
365
- onSelect: () => p("create"),
366
- children: a("helpMeWriteTemplates.bar.createFirst")
367
- }
368
- ) : null,
369
- p && c.length > 0 ? /* @__PURE__ */ i(E, { children: [
370
- /* @__PURE__ */ e(z.Separator, {}),
371
- /* @__PURE__ */ e(
372
- z.Item,
373
- {
374
- startIcon: /* @__PURE__ */ e(_e, {}),
375
- onSelect: () => p("list"),
376
- children: a("helpMeWriteTemplates.bar.manage")
377
- }
378
- )
379
- ] }) : null
380
- ] })
381
- ] }) : null,
382
- /* @__PURE__ */ e(
383
- H,
384
- {
385
- size: "md",
386
- intent: "primary",
387
- className: je,
388
- icon: I === void 0 ? /* @__PURE__ */ e(le, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ e(He, {}),
389
- disabled: s || !C.trim(),
390
- "aria-busy": I === void 0 || void 0,
391
- "aria-label": a("helpMeWriteTemplates.bar.write"),
392
- onClick: () => J(void 0)
393
- }
394
- )
395
- ] }),
396
- D ? /* @__PURE__ */ e("p", { className: "ds:sr-only", role: "status", "aria-live": "polite", children: Me }) : null,
397
- y ? /* @__PURE__ */ e("p", { id: S, role: "alert", className: G, children: a("helpMeWriteTemplates.bar.error") }) : null,
398
- /* @__PURE__ */ i("p", { id: M, className: G, children: [
399
- xe,
400
- " ",
401
- r.privacyNotice
402
- ] })
403
- ] });
404
- }
405
- return /* @__PURE__ */ e(
406
- we,
407
- {
408
- open: N,
409
- onClose: Ce,
410
- ariaLabel: a("editor.ai.helpMeWrite"),
411
- children: /* @__PURE__ */ e("div", { className: "ds:contents", "data-component": "help-me-write-templates-bar", children: j })
412
- }
413
- );
414
- }
415
- const re = {
416
- name: "",
417
- description: "",
418
- prompt: "",
419
- isDefault: !1,
420
- submitted: !1
421
- };
422
- function Xe({
423
- open: r,
424
- onOpenChange: c,
425
- initialMode: o = "list",
426
- templates: p,
427
- onSaveTemplate: u,
428
- onDeleteTemplate: b
429
- }) {
430
- const { t } = V(), [n, a] = h(null), [N, M] = h(!1), [S, C] = h(!1), [x, I] = h(null), [v, y] = h(!1), [F, L] = h(!1), $ = async () => {
431
- if (!(!x || v)) {
432
- y(!0), L(!1);
433
- try {
434
- await (b == null ? void 0 : b(x.id)), I(null);
435
- } catch {
436
- L(!0);
437
- } finally {
438
- y(!1);
439
- }
440
- }
441
- };
442
- U(() => {
443
- r && (C(!1), a(
444
- o === "create" ? { ...re, isDefault: p.length === 0 } : null
445
- ));
446
- }, [r]);
447
- const w = (s, D) => p.some(
448
- (T) => T.id !== D && T.name.toLowerCase() === s.toLowerCase()
449
- ), _ = (() => {
450
- if (!(n != null && n.submitted)) return;
451
- const s = n.name.trim();
452
- return s ? w(s, n.id) ? t("helpMeWriteTemplates.manager.nameTaken") : void 0 : t("helpMeWriteTemplates.manager.nameRequired");
453
- })(), k = n != null && n.submitted && !n.prompt.trim() ? t("helpMeWriteTemplates.manager.promptRequired") : void 0, X = async () => {
454
- if (!n || N) return;
455
- const s = { ...n, submitted: !0 };
456
- a(s);
457
- const D = s.name.trim(), T = s.prompt.trim();
458
- if (!(!D || !T || w(D, s.id))) {
459
- M(!0), C(!1);
460
- try {
461
- await u({
462
- id: s.id,
463
- name: D,
464
- description: s.description.trim() || void 0,
465
- prompt: T,
466
- isDefault: s.isDefault
467
- }), a(null);
468
- } catch {
469
- C(!0);
470
- } finally {
471
- M(!1);
472
- }
473
- }
474
- }, A = n ? n.id ? t("helpMeWriteTemplates.manager.formEdit") : t("helpMeWriteTemplates.manager.formNew") : t("helpMeWriteTemplates.manager.title");
475
- return /* @__PURE__ */ i(E, { children: [
476
- /* @__PURE__ */ e(f, { open: r, onOpenChange: c, children: /* @__PURE__ */ e(f.Content, { size: "lg", children: /* @__PURE__ */ i("div", { className: "ds:contents", "data-component": "ai-template-manager", children: [
477
- /* @__PURE__ */ i(f.Header, { children: [
478
- /* @__PURE__ */ e(f.Title, { children: A }),
479
- /* @__PURE__ */ e(f.Description, { children: t("helpMeWriteTemplates.manager.description") })
480
- ] }),
481
- /* @__PURE__ */ e(f.Body, { children: n ? /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
482
- S ? /* @__PURE__ */ e(R, { variant: "error", children: t("helpMeWriteTemplates.manager.saveError") }) : null,
483
- /* @__PURE__ */ e(
484
- Q,
485
- {
486
- label: t("helpMeWriteTemplates.manager.name"),
487
- error: _,
488
- required: !0,
489
- children: /* @__PURE__ */ e(
490
- oe,
491
- {
492
- value: n.name,
493
- maxLength: 100,
494
- placeholder: t(
495
- "helpMeWriteTemplates.manager.namePlaceholder"
496
- ),
497
- onChange: (s) => a({ ...n, name: s.target.value })
498
- }
499
- )
500
- }
501
- ),
502
- /* @__PURE__ */ e(
503
- Q,
504
- {
505
- label: t("helpMeWriteTemplates.manager.descLabel"),
506
- description: t("helpMeWriteTemplates.manager.descHint"),
507
- optional: !0,
508
- children: /* @__PURE__ */ e(
509
- oe,
510
- {
511
- value: n.description,
512
- maxLength: 120,
513
- onChange: (s) => a({ ...n, description: s.target.value })
514
- }
515
- )
516
- }
517
- ),
518
- /* @__PURE__ */ e(
519
- Q,
520
- {
521
- label: t("helpMeWriteTemplates.manager.prompt"),
522
- description: t(
523
- "helpMeWriteTemplates.manager.promptDescription"
524
- ),
525
- error: k,
526
- required: !0,
527
- children: /* @__PURE__ */ e(
528
- ge,
529
- {
530
- value: n.prompt,
531
- maxLength: 4e3,
532
- autoResize: !0,
533
- minRows: 4,
534
- maxRows: 10,
535
- onChange: (s) => a({ ...n, prompt: s.target.value })
536
- }
537
- )
538
- }
539
- ),
540
- /* @__PURE__ */ e(
541
- Ie,
542
- {
543
- label: t("helpMeWriteTemplates.manager.isDefault"),
544
- checked: n.isDefault,
545
- onCheckedChange: (s) => a({ ...n, isDefault: s })
546
- }
547
- )
548
- ] }) : p.length === 0 ? /* @__PURE__ */ e(
549
- ke,
550
- {
551
- variant: "first-use",
552
- size: "sm",
553
- title: t("helpMeWriteTemplates.manager.emptyTitle"),
554
- description: t(
555
- "helpMeWriteTemplates.manager.emptyDescription"
556
- ),
557
- primaryAction: {
558
- label: t("helpMeWriteTemplates.manager.new"),
559
- onClick: () => a({ ...re, isDefault: !0 })
560
- }
561
- }
562
- ) : /* @__PURE__ */ e(
563
- "ul",
564
- {
565
- "aria-label": t("helpMeWriteTemplates.manager.listLabel"),
566
- className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0",
567
- children: ve(p).map((s) => /* @__PURE__ */ i(
568
- "li",
569
- {
570
- 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)]",
571
- children: [
572
- /* @__PURE__ */ i("div", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-2xs)]", children: [
573
- /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]", children: [
574
- /* @__PURE__ */ e("span", { className: "type-title-item ds:text-[color:var(--foreground)]", children: s.name }),
575
- s.isDefault ? /* @__PURE__ */ e(fe, { variant: "brand", size: "sm", children: t("helpMeWriteTemplates.bar.defaultBadge") }) : null
576
- ] }),
577
- /* @__PURE__ */ e("p", { className: `${G} ds:line-clamp-2`, children: s.description || s.prompt })
578
- ] }),
579
- /* @__PURE__ */ e(
580
- H,
581
- {
582
- size: "sm",
583
- intent: "ghost",
584
- icon: /* @__PURE__ */ e($e, {}),
585
- "aria-label": t("helpMeWriteTemplates.manager.edit", {
586
- name: s.name
587
- }),
588
- onClick: () => a({
589
- id: s.id,
590
- name: s.name,
591
- description: s.description ?? "",
592
- prompt: s.prompt,
593
- isDefault: s.isDefault,
594
- submitted: !1
595
- })
596
- }
597
- ),
598
- b ? /* @__PURE__ */ e(
599
- H,
600
- {
601
- size: "sm",
602
- intent: "ghost",
603
- icon: /* @__PURE__ */ e(Ae, {}),
604
- "aria-label": t("helpMeWriteTemplates.manager.delete", {
605
- name: s.name
606
- }),
607
- onClick: () => I(s)
608
- }
609
- ) : null
610
- ]
611
- },
612
- s.id
613
- ))
614
- }
615
- ) }),
616
- /* @__PURE__ */ e(f.Footer, { children: n ? /* @__PURE__ */ i(E, { children: [
617
- /* @__PURE__ */ e(g, { intent: "secondary", onClick: () => a(null), children: t("helpMeWriteTemplates.manager.cancel") }),
618
- /* @__PURE__ */ e(
619
- g,
620
- {
621
- intent: "primary",
622
- loading: N,
623
- onClick: () => void X(),
624
- children: t("helpMeWriteTemplates.manager.save")
625
- }
626
- )
627
- ] }) : /* @__PURE__ */ i(E, { children: [
628
- p.length > 0 ? /* @__PURE__ */ e(
629
- g,
630
- {
631
- intent: "outline",
632
- startIcon: /* @__PURE__ */ e(be, {}),
633
- onClick: () => a({ ...re }),
634
- children: t("helpMeWriteTemplates.manager.new")
635
- }
636
- ) : null,
637
- /* @__PURE__ */ e(f.Close, { asChild: !0, children: /* @__PURE__ */ e(g, { intent: "primary", children: t("helpMeWriteTemplates.manager.done") }) })
638
- ] }) })
639
- ] }) }) }),
640
- /* @__PURE__ */ e(
641
- f,
642
- {
643
- open: x != null,
644
- onOpenChange: (s) => {
645
- !s && !v && (I(null), L(!1));
646
- },
647
- children: /* @__PURE__ */ i(f.Content, { size: "sm", variant: "alert", children: [
648
- /* @__PURE__ */ i(f.Header, { children: [
649
- /* @__PURE__ */ e(f.Title, { children: t("helpMeWriteTemplates.manager.deleteTitle", {
650
- name: (x == null ? void 0 : x.name) ?? ""
651
- }) }),
652
- /* @__PURE__ */ e(f.Description, { children: t("helpMeWriteTemplates.manager.deleteDescription") })
653
- ] }),
654
- F ? /* @__PURE__ */ e(f.Body, { children: /* @__PURE__ */ e(R, { variant: "error", children: t("helpMeWriteTemplates.manager.deleteError") }) }) : null,
655
- /* @__PURE__ */ i(f.Footer, { children: [
656
- /* @__PURE__ */ e(f.Close, { asChild: !0, children: /* @__PURE__ */ e(g, { intent: "secondary", disabled: v, children: t("helpMeWriteTemplates.manager.cancel") }) }),
657
- /* @__PURE__ */ e(
658
- g,
659
- {
660
- intent: "destructive",
661
- loading: v,
662
- onClick: () => void $(),
663
- children: t("helpMeWriteTemplates.manager.deleteConfirm")
664
- }
665
- )
666
- ] })
667
- ] })
668
- }
669
- )
670
- ] });
671
- }
672
- function Ye({
673
- applied: r,
674
- onUndo: c,
675
- onDismiss: o
676
- }) {
677
- const { t: p } = V(), u = te(null);
678
- if (U(() => {
679
- var t;
680
- r && ((t = u.current) == null || t.focus());
681
- }, [r]), !(r != null && r.template)) return null;
682
- const b = r.template.name;
683
- return /* @__PURE__ */ e(
684
- R,
685
- {
686
- variant: "success",
687
- dismissible: !0,
688
- onOpenChange: (t) => {
689
- t || o();
690
- },
691
- "data-component": "help-me-write-undo-notice",
692
- children: /* @__PURE__ */ i("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]", children: [
693
- /* @__PURE__ */ e("span", { children: r.mode === "below" ? p("helpMeWriteTemplates.undo.addedBelow", { name: b }) : p("helpMeWriteTemplates.undo.replaced", { name: b }) }),
694
- /* @__PURE__ */ e(g, { ref: u, intent: "outline", size: "sm", onClick: c, children: p("helpMeWriteTemplates.undo.undo") })
695
- ] })
696
- }
697
- );
698
- }
699
- function Dr({
700
- templates: r,
701
- onGenerate: c,
702
- onSaveTemplate: o,
703
- onDeleteTemplate: p,
704
- credits: u,
705
- enableDictation: b,
706
- onApplied: t
707
- }) {
708
- const [n, a] = h({ open: !1, mode: "list" }), [N, M] = h(null), S = O(
709
- (v = "list") => a({ open: !0, mode: v }),
710
- []
711
- ), C = O(
712
- (v) => /* @__PURE__ */ e(
713
- Ve,
714
- {
715
- context: v,
716
- templates: r,
717
- onGenerate: c,
718
- onManageTemplates: o ? S : void 0,
719
- credits: u,
720
- enableDictation: b,
721
- suspendClose: n.open,
722
- onApplied: (y) => {
723
- M(y.template ? y : null), t == null || t(y);
724
- }
725
- }
726
- ),
727
- [
728
- r,
729
- c,
730
- o,
731
- S,
732
- u,
733
- b,
734
- n.open,
735
- t
736
- ]
737
- ), x = Ne(
738
- () => o ? /* @__PURE__ */ e(
739
- Xe,
740
- {
741
- open: n.open,
742
- initialMode: n.mode,
743
- onOpenChange: (v) => a((y) => ({ ...y, open: v })),
744
- templates: r,
745
- onSaveTemplate: o,
746
- onDeleteTemplate: p
747
- }
748
- ) : null,
749
- [n, r, o, p]
750
- );
751
- return {
752
- renderHelpMeWrite: C,
753
- manager: x,
754
- undoNotice: /* @__PURE__ */ e(
755
- Ye,
756
- {
757
- applied: N,
758
- onUndo: () => {
759
- N == null || N.undo(), M(null);
760
- },
761
- onDismiss: () => M(null)
762
- }
763
- ),
764
- openManager: S
765
- };
766
- }
767
- export {
768
- me as A,
769
- Ve as H,
770
- Ge as a,
771
- Xe as b,
772
- Ye as c,
773
- Dr as u
774
- };
775
- //# sourceMappingURL=help-me-write-templates-B-m7zgJa.js.map