eddyter 1.4.18 → 1.4.19

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 (60) hide show
  1. package/dist/AIChatPlugin-BUWq8ixX.js +1042 -0
  2. package/dist/{CombinedAutocompletGrammarPlugin-BXOz6IRb.js → CombinedAutocompletGrammarPlugin-Dq25w8tq.js} +388 -337
  3. package/dist/{CommentBubblePlugin-kiMehQkL.js → CommentBubblePlugin-B77d3Qq6.js} +4 -4
  4. package/dist/CommentPlugin-BJQyKmrN.js +212 -0
  5. package/dist/{NotePanelPlugin-FirMseLu.js → NotePanelPlugin-BqOdcg07.js} +3 -3
  6. package/dist/{TextEnhancePlugin-oXbL_F1i.js → TextEnhancePlugin-BnmdRgUu.js} +2 -2
  7. package/dist/assets/style.css +1 -1
  8. package/dist/components/AnimatedPlaceholderText.d.ts +2 -0
  9. package/dist/components/DividerPicker/DividerPicker.d.ts +17 -0
  10. package/dist/components/EditorialDivider/EditorialDividerView.d.ts +23 -0
  11. package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +1 -1
  12. package/dist/components/LockedFeature/LockedFeature.d.ts +4 -0
  13. package/dist/components/Toolbar/styles.d.ts +19 -1
  14. package/dist/components/UnifiedColorPicker/UnifiedColorPicker.d.ts +1 -0
  15. package/dist/components/ui/button.d.ts +1 -1
  16. package/dist/components/ui/separator.d.ts +4 -1
  17. package/dist/constants.d.ts +12 -1
  18. package/dist/editorConfig.d.ts +7 -0
  19. package/dist/{generateDocxThumbnail-RE7yNAXP.js → generateDocxThumbnail-DBMxjZ83.js} +1 -1
  20. package/dist/{generatePdfThumbnail-CnldK2yE.js → generatePdfThumbnail-Cv2-ZCzh.js} +4 -4
  21. package/dist/{generateXlsxThumbnail-BpBB4ePK.js → generateXlsxThumbnail-UHmNc7Fa.js} +1 -1
  22. package/dist/hooks/useEditorToolbar.d.ts +1 -1
  23. package/dist/{index-CL0adQ5R.js → index-BaWQzoL2.js} +11 -11
  24. package/dist/{index-CXyZgoBl.js → index-Bex3G_eE.js} +18704 -15777
  25. package/dist/index-C_mjLQUF.js +796 -0
  26. package/dist/{index-C8ZUqYRj.js → index-ChSepytp.js} +26 -26
  27. package/dist/index-Cl_A9eof.js +1508 -0
  28. package/dist/{index-B4W_mfNI.js → index-DcHU8PlQ.js} +120 -123
  29. package/dist/{index-CKRp6axU.js → index-q_TW8dU1.js} +19 -19
  30. package/dist/index.js +7 -7
  31. package/dist/nodes/AsterismNode.d.ts +22 -0
  32. package/dist/nodes/ButtonNode.d.ts +37 -0
  33. package/dist/nodes/ColumnNode.d.ts +44 -0
  34. package/dist/nodes/ColumnsNode.d.ts +45 -0
  35. package/dist/nodes/EditorialFieldNode.d.ts +32 -0
  36. package/dist/nodes/FaqNode.d.ts +28 -0
  37. package/dist/nodes/ImagePlaceholderNode.d.ts +15 -0
  38. package/dist/nodes/LabeledRuleNode.d.ts +33 -0
  39. package/dist/nodes/OrnamentDividerNode.d.ts +22 -0
  40. package/dist/nodes/PullQuoteRulesNode.d.ts +32 -0
  41. package/dist/nodes/SectionNumberHeadingNode.d.ts +42 -0
  42. package/dist/plugins/BlockLayoutPlugin.d.ts +29 -0
  43. package/dist/plugins/ColumnAddButtonPlugin.d.ts +12 -0
  44. package/dist/plugins/CommentPlugin.commands.d.ts +1 -0
  45. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +12 -2
  46. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +2 -1
  47. package/dist/plugins/CustomHorizontalRulePlugin/styles.d.ts +38 -0
  48. package/dist/plugins/EditorialFloatingToolbarPlugin.d.ts +8 -0
  49. package/dist/plugins/EditorialTypographyPlugin.d.ts +18 -0
  50. package/dist/plugins/PatternsPlugin.d.ts +12 -0
  51. package/dist/{sparkles-CTAYmQOE.js → sparkles-C-XoMho5.js} +1 -1
  52. package/dist/types.d.ts +11 -0
  53. package/dist/ui/Icons.d.ts +34 -9
  54. package/dist/{useVoiceToText-U0yKgS5Q.js → useVoiceToText-BzaLSbRi.js} +17 -17
  55. package/package.json +1 -1
  56. package/dist/AIChatPlugin-DsUPycjT.js +0 -872
  57. package/dist/CommentPlugin-DIuM-Jao.js +0 -154
  58. package/dist/index-DZAvLKar.js +0 -1431
  59. package/dist/index-F2-F96Nx.js +0 -720
  60. package/dist/square-CupR-YWR.js +0 -7
@@ -0,0 +1,1042 @@
1
+ import { jsxs as e, Fragment as tt, jsx as t } from "react/jsx-runtime";
2
+ import { c as xt, T as Vt, w as Bt, x as Tt, y as Pt, D as yt, a as Nt, b as wt, d as kt, z as Ut, G as Mt, H as Rt, J as zt, K as Lt, M as U, L as Wt, O as Yt, Q as Ft, U as Jt, B as at, V as Qt, W as Xt, X as Zt, Y as te, Z as ee, _ as $t, e as re, g as oe, a0 as ht, a1 as ie, a2 as Dt, t as pt } from "./index-Bex3G_eE.js";
3
+ import { useLexicalComposerContext as de } from "@lexical/react/LexicalComposerContext";
4
+ import { $getSelection as ct, COMMAND_PRIORITY_LOW as Ct, $isRangeSelection as St } from "lexical";
5
+ import { useState as d, useRef as W, useCallback as K, useEffect as $, useMemo as Et } from "react";
6
+ import { u as ce, M as ne } from "./useVoiceToText-BzaLSbRi.js";
7
+ import { S as Ot } from "./sparkles-C-XoMho5.js";
8
+ const lt = xt("ArrowUpRight", [
9
+ ["path", { d: "M7 7h10v10", key: "1tivn9" }],
10
+ ["path", { d: "M7 17 17 7", key: "1vkiza" }]
11
+ ]);
12
+ const se = xt("Send", [
13
+ ["path", { d: "m22 2-7 20-4-9-9-4Z", key: "1q3vgg" }],
14
+ ["path", { d: "M22 2 11 13", key: "nzbqef" }]
15
+ ]);
16
+ const It = xt("Square", [
17
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
18
+ ]);
19
+ function At(c) {
20
+ if (!c) return "just now";
21
+ try {
22
+ const b = new Date(c);
23
+ if (isNaN(b.getTime())) return "just now";
24
+ const x = Math.floor(((/* @__PURE__ */ new Date()).getTime() - b.getTime()) / 1e3);
25
+ if (x < 10) return "just now";
26
+ if (x < 60) return `${x}s ago`;
27
+ const k = Math.floor(x / 60);
28
+ if (k < 60) return `${k}m ago`;
29
+ const P = Math.floor(k / 60);
30
+ return P < 24 ? `${P}h ago` : `${Math.floor(P / 24)}d ago`;
31
+ } catch {
32
+ return "just now";
33
+ }
34
+ }
35
+ function ae({
36
+ open: c,
37
+ onOpenChange: b,
38
+ editor: et,
39
+ apiKey: x,
40
+ initialText: k,
41
+ onShowInEditor: P,
42
+ onStreamStart: q,
43
+ onStreamEnd: D,
44
+ selectedTextForInline: rt,
45
+ savedSelection: R
46
+ }) {
47
+ const [l, v] = d(""), [i, y] = d(""), [n, z] = d(!1), [C, L] = d(null), [A, S] = d("chatgpt"), [O, F] = d(0), [T, V] = d(0), [G, _] = d(!1), [B, N] = d(!0), [g, m] = d("idle"), [j, E] = d(!1), [u, J] = d([]), [nt, Q] = d(!1), [ot, st] = d(!1), X = W(R ?? null), Y = W(null), o = Tt(), M = o?.isByokPlan ?? !1, h = o?.byokApiKeys, s = Et(() => {
48
+ if (!M || !h)
49
+ return ["chatgpt", "claude", "grok", "gemini"];
50
+ const r = [];
51
+ return h.hasOpenaiKey && r.push("chatgpt"), h.hasAnthropicKey && r.push("claude"), h.hasGrokKey && r.push("grok"), h.hasGeminiKey && r.push("gemini"), r;
52
+ }, [M, h]), a = M && s.length === 0, Z = M && !h?.hasAssemblyaiKey;
53
+ $(() => {
54
+ X.current = R ?? null;
55
+ }, [R]), $(() => {
56
+ M && s.length > 0 && !s.includes(A) && S(s[0]);
57
+ }, [M, s, A]), $(() => {
58
+ c && k ? (y(k), v("")) : c || (y(""), v("")), c && x && (st(!0), Pt(x).then(J).catch(() => {
59
+ }).finally(() => st(!1)));
60
+ }, [c, k, x]);
61
+ const {
62
+ isRecording: w,
63
+ isPaused: H,
64
+ isLoading: I,
65
+ error: mt,
66
+ elapsedTime: Gt,
67
+ toggleRecording: ft,
68
+ pauseRecording: _t,
69
+ resumeRecording: jt
70
+ } = ce({
71
+ onTranscriptUpdate: (r) => {
72
+ v(r);
73
+ },
74
+ apiKey: x
75
+ }), Ht = (r) => {
76
+ const p = Math.floor(r / 60), f = r % 60;
77
+ return `${p.toString().padStart(2, "0")}:${f.toString().padStart(2, "0")}`;
78
+ };
79
+ $(() => {
80
+ let r = !0;
81
+ return (async () => {
82
+ try {
83
+ const f = await ie({ apiKey: x });
84
+ r && f && (_(!!f.unlimited), F(Number(f.remainingCredits ?? 0)), V(Number(f.purchasedCredits ?? 0)));
85
+ } catch {
86
+ r && (_(!1), F(0), V(0));
87
+ } finally {
88
+ r && N(!1);
89
+ }
90
+ })(), () => {
91
+ r = !1;
92
+ };
93
+ }, [x]);
94
+ const bt = (r) => {
95
+ const p = r.toLowerCase();
96
+ return [
97
+ "generate image",
98
+ "generate an image",
99
+ "create image",
100
+ "create an image",
101
+ "make image",
102
+ "make an image",
103
+ "draw",
104
+ "illustration",
105
+ "picture of",
106
+ "image of",
107
+ "photo of",
108
+ "generate picture",
109
+ "create picture",
110
+ "visualize",
111
+ "render image",
112
+ "design image",
113
+ "produce image"
114
+ ].some((dt) => p.includes(dt));
115
+ }, Kt = K(() => {
116
+ Y.current && (Y.current.abort(), Y.current = null);
117
+ }, []), vt = async () => {
118
+ if (!l.trim() || n) return;
119
+ const r = i && i.trim() !== "";
120
+ let p;
121
+ const f = bt(l) || i && bt(i);
122
+ f ? p = r ? `${l}: ${i}` : l : r ? p = `${l}
123
+ IMPORTANT: Return ONLY the modified/transformed text. Do NOT include any labels, prefixes, explanations, or formatting like "Simplified:", "Result:", "Here is", etc. Just return the pure result text.
124
+ Text to transform:
125
+ "${i}"
126
+ ` : p = l;
127
+ const dt = new AbortController();
128
+ Y.current = dt, await Dt({
129
+ editor: et,
130
+ query: p,
131
+ model: A,
132
+ apiKey: x || "",
133
+ originalPrompt: l,
134
+ savedSelection: X.current,
135
+ abortSignal: dt.signal,
136
+ onStatusChange: (gt) => m(gt),
137
+ onLoadingChange: z,
138
+ onStreamStart: () => {
139
+ b(!1), q && q(dt, A, !!f);
140
+ },
141
+ onInputClear: () => {
142
+ v(""), y("");
143
+ },
144
+ onError: (gt) => {
145
+ pt.error(gt), E(!0), z(!1), D && D(), it(!0);
146
+ },
147
+ onSuccess: () => {
148
+ E(!0), z(!1), D && D(), it(!0);
149
+ }
150
+ });
151
+ }, it = (r) => {
152
+ if (n && !r) {
153
+ Kt();
154
+ return;
155
+ }
156
+ Y.current = null, v(""), y(""), L(null), b(!1);
157
+ }, qt = (r) => {
158
+ switch (r) {
159
+ case "chatgpt":
160
+ return "OpenAI ChatGPT";
161
+ case "claude":
162
+ return "Anthropic Claude";
163
+ case "grok":
164
+ return "xAI Grok";
165
+ case "gemini":
166
+ return "Google Gemini";
167
+ default:
168
+ return "OpenAI ChatGPT";
169
+ }
170
+ }, ut = W(null);
171
+ return $(() => {
172
+ if (ut.current) {
173
+ const r = ut.current;
174
+ r.style.height = "auto", r.style.height = `${r.scrollHeight}px`;
175
+ }
176
+ }, [l]), /* @__PURE__ */ t(tt, { children: /* @__PURE__ */ t(yt, { open: c, onOpenChange: () => it(), children: /* @__PURE__ */ e(Nt, { className: "sm:cteditor-max-w-[60rem] cteditor-max-w-[calc(100%-2rem)] !cteditor-max-h-[90vh] !cteditor-flex !cteditor-flex-col cteditor-overflow-hidden cteditor-rounded-lg [&>.closeDialog]:cteditor-top-1.5 [&>.closeDialog]:cteditor-right-1.5 !cteditor-gap-0 !cteditor-p-0 md:cteditor-gap-0", children: [
177
+ /* @__PURE__ */ t(wt, { children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-px-4 cteditor-py-4 cteditor-border-b cteditor-border-foreground/10", children: [
178
+ /* @__PURE__ */ e(kt, { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xl cteditor-mb-1 !cteditor-font-medium", children: [
179
+ /* @__PURE__ */ t(Ut, {}),
180
+ /* @__PURE__ */ e("div", { className: "max-md:cteditor-text-left", children: [
181
+ /* @__PURE__ */ t("span", { children: "Ask AI" }),
182
+ /* @__PURE__ */ t("div", { className: "cteditor-text-xs cteditor-pt-1 cteditor-text-foreground/50", children: "Quick assistance for improving, translating, or explaining your content." })
183
+ ] })
184
+ ] }),
185
+ /* @__PURE__ */ t("div", {})
186
+ ] }) }),
187
+ /* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-overflow-y-auto", children: [
188
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-gap-3 cteditor-justify-between cteditor-items-center md:cteditor-hidden cteditor-flex-wrap cteditor-p-4", children: [
189
+ /* @__PURE__ */ e("div", { className: "max-xs:cteditor-w-full", children: [
190
+ /* @__PURE__ */ t("label", { className: "cteditor-block cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-1 cteditor-font-medium", children: "Choose AI Provider" }),
191
+ /* @__PURE__ */ t("div", { className: "cteditor-min-w-[160px] max-xs:cteditor-min-w-0 max-xs:cteditor-w-full", children: /* @__PURE__ */ t("div", { className: "cteditor-relative", children: /* @__PURE__ */ e(
192
+ Mt,
193
+ {
194
+ value: s.includes(A) ? A : s[0] ?? "chatgpt",
195
+ onValueChange: (r) => S(r),
196
+ disabled: a,
197
+ children: [
198
+ /* @__PURE__ */ t(Rt, { className: "cteditor-w-full cteditor-text-xs !cteditor-py-1 !cteditor-h-8", children: /* @__PURE__ */ t(zt, { placeholder: "Select provider" }) }),
199
+ /* @__PURE__ */ e(Lt, { children: [
200
+ s.includes("chatgpt") && /* @__PURE__ */ t(U, { value: "chatgpt", children: "OpenAI ChatGPT" }),
201
+ s.includes("claude") && /* @__PURE__ */ t(U, { value: "claude", children: "Anthropic Claude" }),
202
+ s.includes("grok") && /* @__PURE__ */ t(U, { value: "grok", children: "xAI Grok" }),
203
+ s.includes("gemini") && /* @__PURE__ */ t(U, { value: "gemini", children: "Google Gemini" })
204
+ ] })
205
+ ]
206
+ }
207
+ ) }) })
208
+ ] }),
209
+ /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5 cteditor-text-xs max-xs:cteditor-w-full", children: B ? /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-accent cteditor-rounded-md cteditor-px-3 cteditor-py-1.5 cteditor-animate-pulse cteditor-min-w-[90px] max-xs:cteditor-flex-1", children: [
210
+ /* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-16 cteditor-bg-foreground/15 cteditor-rounded cteditor-mb-1" }),
211
+ /* @__PURE__ */ t("div", { className: "cteditor-h-4 cteditor-w-12 cteditor-bg-foreground/15 cteditor-rounded" })
212
+ ] }) : G ? /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-rounded-md cteditor-bg-green-500/10 cteditor-px-3 cteditor-py-1.5 cteditor-min-h-11 max-xs:cteditor-flex-1", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-leading-none cteditor-gap-0.5", children: [
213
+ /* @__PURE__ */ t("span", { className: "cteditor-font-medium cteditor-text-green-600 cteditor-text-[11px]", children: "Your API Key" }),
214
+ /* @__PURE__ */ t("span", { className: "cteditor-text-muted-foreground cteditor-text-[10px]", children: "No credit usage" })
215
+ ] }) }) : /* @__PURE__ */ e(tt, { children: [
216
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-accent/80 cteditor-rounded-md cteditor-px-3 cteditor-py-1.5 cteditor-min-w-[90px] cteditor-justify-center max-xs:cteditor-flex-1", children: [
217
+ /* @__PURE__ */ t("span", { className: "cteditor-text-[11px] cteditor-font-medium cteditor-text-muted-foreground cteditor-mb-0.5", children: "Credits Left" }),
218
+ /* @__PURE__ */ t("span", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground cteditor-leading-none", children: O + T })
219
+ ] }),
220
+ T > 0 && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-green-500/10 cteditor-border-l-2 cteditor-border-green-600 cteditor-rounded-r-md cteditor-rounded-l-sm cteditor-px-3 cteditor-py-1.5 cteditor-min-w-[90px] cteditor-justify-center max-xs:cteditor-flex-1", children: [
221
+ /* @__PURE__ */ t("span", { className: "cteditor-text-[11px] cteditor-font-medium cteditor-text-muted-foreground cteditor-mb-0.5", children: "Purchased" }),
222
+ /* @__PURE__ */ t("span", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-green-500 cteditor-leading-none", children: T })
223
+ ] })
224
+ ] }) })
225
+ ] }),
226
+ a && /* @__PURE__ */ t("div", { className: "cteditor-rounded-md cteditor-bg-amber-500/10 cteditor-border cteditor-border-amber-500/30 cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-text-amber-800 dark:cteditor-text-amber-200", children: "Add at least one AI provider key in License Section > Manage API Keys to use AI Chat." }),
227
+ /* @__PURE__ */ e("div", { className: "cteditor-grid md:cteditor-grid-cols-12 cteditor-gap-4 cteditor-flex-1 ", children: [
228
+ /* @__PURE__ */ e("div", { className: "cteditor-space-y-4 md:cteditor-col-span-8 cteditor-p-6 cteditor-border-r cteditor-border-foreground/5 dark:cteditor-bg-black/10 ", children: [
229
+ /* @__PURE__ */ e("div", { children: [
230
+ /* @__PURE__ */ t(
231
+ Wt,
232
+ {
233
+ htmlFor: "ai-prompt",
234
+ className: "cteditor-text-sm cteditor-font-medium cteditor-block cteditor-mb-2",
235
+ children: i && i.trim() !== "" ? "Your Instruction" : "Your Question"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ t("div", { className: "cteditor-relative cteditor-mb-2 ", children: /* @__PURE__ */ e("div", { className: `cteditor-border cteditor-border-foreground/15 dark:cteditor-bg-black/10 cteditor-bg-black/5 cteditor-rounded-md cteditor-pb-[55px]
239
+ ${w && !H ? "!cteditor-border-rose-400" : ""}
240
+ ${H ? "!cteditor-border-amber-400" : ""}
241
+ `, children: [
242
+ /* @__PURE__ */ t(
243
+ "textarea",
244
+ {
245
+ ref: ut,
246
+ id: "ai-prompt",
247
+ placeholder: I ? "Initializing microphone..." : w ? H ? "Paused..." : "Listening..." : i && i.trim() !== "" ? "e.g., Improve this, translate to Spanish, summarize, fix grammar..." : "e.g., Write a paragraph about..., Generate an image of...",
248
+ value: l,
249
+ onChange: (r) => v(r.target.value),
250
+ disabled: n || w || I || a,
251
+ rows: 1,
252
+ onInput: (r) => {
253
+ if (r.currentTarget.value === "") return;
254
+ const p = r.currentTarget;
255
+ p.style.height = "auto", p.style.height = `${p.scrollHeight}px`;
256
+ },
257
+ onKeyDown: (r) => {
258
+ r.key === "Enter" && !r.shiftKey && !n && l.trim() && (r.preventDefault(), vt());
259
+ },
260
+ className: `cteditor-w-full cteditor-block cteditor-transition-all cteditor-border-none cteditor-bg-transparent cteditor-resize-none cteditor-outline-none cteditor-p-2 cteditor-min-h-52 cteditor-text-xs cteditor-overflow-clip ${w ? "" : "cteditor-max-h-[47vh] cteditor-overflow-y-auto"}`
261
+ }
262
+ ),
263
+ /* @__PURE__ */ t("div", { className: "cteditor-w-full cteditor-h-[1px] cteditor-bg-foreground/10" }),
264
+ /* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-right-3 cteditor-bottom-3 cteditor-gap-2 cteditor-flex", children: [
265
+ /* @__PURE__ */ t(Yt, { delayDuration: 200, children: /* @__PURE__ */ e(Ft, { children: [
266
+ /* @__PURE__ */ t(Jt, { asChild: !0, children: /* @__PURE__ */ e(
267
+ at,
268
+ {
269
+ variant: "link",
270
+ onClick: () => {
271
+ P && (P(A, rt), it());
272
+ },
273
+ disabled: n,
274
+ className: "md:cteditor-mr-auto [&>svg]:!cteditor-size-3 !cteditor-p-1 cteditor-text-xs !cteditor-h-8 cteditor-no-underline max-xs:cteditor-size-8",
275
+ children: [
276
+ /* @__PURE__ */ t("span", { className: "max-xs:cteditor-hidden ", children: "Show in Editor" }),
277
+ /* @__PURE__ */ t(lt, {})
278
+ ]
279
+ }
280
+ ) }),
281
+ /* @__PURE__ */ t(Qt, { children: /* @__PURE__ */ t("p", { children: "Show AI prompt in the editor text area" }) })
282
+ ] }) }),
283
+ /* @__PURE__ */ t(
284
+ at,
285
+ {
286
+ variant: "outline",
287
+ onClick: () => it(),
288
+ disabled: n,
289
+ className: "[&>svg]:!cteditor-size-3 !cteditor-px-3 cteditor-text-xs !cteditor-h-8",
290
+ children: "Cancel"
291
+ }
292
+ ),
293
+ /* @__PURE__ */ e(
294
+ at,
295
+ {
296
+ onClick: vt,
297
+ disabled: !l.trim() || a,
298
+ className: "[&>svg]:!cteditor-size-3 !cteditor-px-3 cteditor-text-xs !cteditor-h-8 !gap-1",
299
+ children: [
300
+ /* @__PURE__ */ t(Ot, {}),
301
+ "Ask AI"
302
+ ]
303
+ }
304
+ )
305
+ ] }),
306
+ !w && /* @__PURE__ */ t("div", { className: "cteditor-absolute cteditor-left-3 cteditor-bottom-3 ", children: /* @__PURE__ */ t(
307
+ "button",
308
+ {
309
+ type: "button",
310
+ onClick: ft,
311
+ disabled: n || I || Z,
312
+ className: `cteditor-rounded-lg cteditor-transition-all cteditor-size-8 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center cteditor-border cteditor-border-foreground/10 ${!I && !Z && ""} ${Z ? "cteditor-opacity-60 cteditor-cursor-not-allowed" : I ? "cteditor-text-gray-500 dark:cteditor-text-gray-400 cteditor-cursor-not-allowed" : w ? "cteditor-text-rose-600 dark:cteditor-text-rose-400 hover:cteditor-bg-rose-100 dark:hover:cteditor-bg-rose-900/30 " + (H ? "" : "cteditor-animate-pulse") : "cteditor-text-foreground hover:cteditor-bg-foreground hover:cteditor-text-background"}`,
313
+ title: Z ? "Add your AssemblyAI key in License Section > Manage API Keys to use voice input." : I ? "Initializing microphone..." : w ? "Stop recording" : "Start voice input",
314
+ children: I ? /* @__PURE__ */ e(
315
+ "svg",
316
+ {
317
+ className: "cteditor-w-4 cteditor-h-4 cteditor-animate-spin",
318
+ fill: "none",
319
+ viewBox: "0 0 24 24",
320
+ children: [
321
+ /* @__PURE__ */ t(
322
+ "circle",
323
+ {
324
+ className: "cteditor-opacity-25",
325
+ cx: "12",
326
+ cy: "12",
327
+ r: "10",
328
+ stroke: "currentColor",
329
+ strokeWidth: "4"
330
+ }
331
+ ),
332
+ /* @__PURE__ */ t(
333
+ "path",
334
+ {
335
+ className: "cteditor-opacity-75",
336
+ fill: "currentColor",
337
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
338
+ }
339
+ )
340
+ ]
341
+ }
342
+ ) : w ? null : /* @__PURE__ */ t(ne, { size: 16 })
343
+ }
344
+ ) }),
345
+ w && /* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-left-4 cteditor-bottom-4 cteditor-flex cteditor-gap-1 cteditor-justify-end cteditor-items-center", children: [
346
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1", children: [
347
+ w && /* @__PURE__ */ t(
348
+ "button",
349
+ {
350
+ type: "button",
351
+ onClick: H ? jt : _t,
352
+ disabled: n || I,
353
+ className: ` cteditor-rounded-full cteditor-transition-all cteditor-size-6 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center [&>svg]:cteditor-w-full [&>svg]:cteditor-h-full ${H ? "cteditor-text-amber-600 dark:cteditor-text-amber-400 hover:cteditor-bg-amber-100 dark:hover:cteditor-bg-amber-900/30" : "cteditor-text-gray-600 dark:cteditor-text-gray-400 hover:cteditor-bg-gray-200 dark:hover:cteditor-bg-gray-800"}`,
354
+ title: H ? "Resume recording" : "Pause recording",
355
+ children: H ? /* @__PURE__ */ t(Xt, {}) : /* @__PURE__ */ t(Zt, {})
356
+ }
357
+ ),
358
+ w && !I && /* @__PURE__ */ t(
359
+ "button",
360
+ {
361
+ type: "button",
362
+ onClick: ft,
363
+ disabled: n || I,
364
+ className: `cteditor-rounded-full cteditor-transition-all cteditor-size-6 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center [&>svg]:cteditor-w-full [&>svg]:cteditor-h-full
365
+ ${I ? "cteditor-text-gray-500 dark:cteditor-text-gray-400 cteditor-cursor-not-allowed" : w ? "cteditor-text-rose-600 dark:cteditor-text-rose-400 hover:cteditor-bg-rose-100 dark:hover:cteditor-bg-rose-900/30 " + (H ? "" : "cteditor-animate-pulse") : "cteditor-text-foreground hover:cteditor-bg-foreground hover:cteditor-text-background"}`,
366
+ title: I ? "Initializing microphone..." : w ? "Stop recording" : "Start voice input",
367
+ children: /* @__PURE__ */ t(te, {})
368
+ }
369
+ )
370
+ ] }),
371
+ /* @__PURE__ */ t("span", { className: "cteditor-text-xs", children: Ht(Gt) })
372
+ ] })
373
+ ] }) }),
374
+ !w && !mt && !I && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xs cteditor-text-muted-foreground", children: [
375
+ /* @__PURE__ */ t(
376
+ "svg",
377
+ {
378
+ className: "cteditor-w-4 cteditor-h-4 cteditor-opacity-60",
379
+ fill: "none",
380
+ stroke: "currentColor",
381
+ viewBox: "0 0 24 24",
382
+ children: /* @__PURE__ */ t(
383
+ "path",
384
+ {
385
+ strokeLinecap: "round",
386
+ strokeLinejoin: "round",
387
+ strokeWidth: 2,
388
+ d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
389
+ }
390
+ )
391
+ }
392
+ ),
393
+ /* @__PURE__ */ t("span", { children: i && i.trim() !== "" ? "Enter what you want to do with the selected text, or use voice input" : "Type your question or click the microphone icon to use voice input" })
394
+ ] }),
395
+ !w && !n && (!i || i.trim() === "") && /* @__PURE__ */ e(tt, { children: [
396
+ ot && /* @__PURE__ */ t("div", { className: "cteditor-mt-3 cteditor-rounded-lg cteditor-border cteditor-border-foreground/10 cteditor-bg-accent/30 cteditor-p-3 cteditor-animate-pulse", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-3", children: [
397
+ /* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-space-y-1.5", children: [
398
+ /* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-full cteditor-bg-foreground/10 cteditor-rounded" }),
399
+ /* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-2/3 cteditor-bg-foreground/10 cteditor-rounded" })
400
+ ] }),
401
+ /* @__PURE__ */ t("div", { className: "cteditor-h-7 cteditor-w-20 cteditor-bg-foreground/10 cteditor-rounded-md" })
402
+ ] }) }),
403
+ !ot && u.length > 0 && /* @__PURE__ */ e("div", { className: "cteditor-mt-4 cteditor-flex cteditor-flex-col cteditor-gap-2", children: [
404
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-justify-between", children: [
405
+ /* @__PURE__ */ e("div", { className: "cteditor-text-[10px] cteditor-font-semibold cteditor-tracking-[0.12em] cteditor-uppercase cteditor-text-[#8c8c8c]", children: [
406
+ "Recent prompts",
407
+ /* @__PURE__ */ e("span", { className: "cteditor-font-mono cteditor-text-[10px] cteditor-text-[#525252] cteditor-ml-2 cteditor-tracking-normal cteditor-normal-case cteditor-font-normal", children: [
408
+ "1 / ",
409
+ u.length
410
+ ] })
411
+ ] }),
412
+ u.length > 1 && /* @__PURE__ */ e(
413
+ "button",
414
+ {
415
+ type: "button",
416
+ onClick: () => Q(!0),
417
+ className: "cteditor-inline-flex cteditor-items-center cteditor-gap-1 cteditor-bg-transparent cteditor-border-none cteditor-text-foreground/55 cteditor-cursor-pointer cteditor-text-xs hover:cteditor-text-foreground/80",
418
+ children: [
419
+ "Show ",
420
+ u.length - 1,
421
+ " more",
422
+ /* @__PURE__ */ t(ee, { size: 11 })
423
+ ]
424
+ }
425
+ )
426
+ ] }),
427
+ /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-1.5", children: u.slice(0, 1).map((r) => {
428
+ const p = r.createdAt ? At(r.createdAt) : "just now";
429
+ return /* @__PURE__ */ e(
430
+ "div",
431
+ {
432
+ className: "cteditor-flex cteditor-items-stretch cteditor-gap-3.5 cteditor-p-3.5 cteditor-rounded-xl cteditor-border dark:cteditor-bg-[#19191c] cteditor-bg-foreground/10 cteditor-border-white/5",
433
+ children: [
434
+ /* @__PURE__ */ t("div", { className: "cteditor-w-[3px] cteditor-rounded-[2px] cteditor-bg-gradient-to-b cteditor-from-[#6352e8] cteditor-to-[#4d3fc4]" }),
435
+ /* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
436
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-baseline cteditor-gap-2 cteditor-text-xs cteditor-font-semibold dark:cteditor-text-white cteditor-text-foreground", children: [
437
+ "Last prompt",
438
+ /* @__PURE__ */ t("span", { className: "cteditor-font-mono cteditor-text-[10px] cteditor-text-[#8c8c8c] cteditor-font-normal", children: p })
439
+ ] }),
440
+ /* @__PURE__ */ t("div", { className: "cteditor-text-xs dark:cteditor-text-[#d1d5dc] cteditor-text-foreground cteditor-leading-relaxed cteditor-mt-1 cteditor-break-words cteditor-line-clamp-2", children: r.prompt })
441
+ ] }),
442
+ /* @__PURE__ */ e(
443
+ "button",
444
+ {
445
+ type: "button",
446
+ onClick: () => v(r.prompt),
447
+ className: "cteditor-inline-flex cteditor-items-center cteditor-gap-1.5 cteditor-h-7 cteditor-px-3 cteditor-rounded-md cteditor-cursor-pointer cteditor-text-xs cteditor-font-normal cteditor-self-center cteditor-shrink-0 cteditor-transition-all cteditor-bg-indigo-600/18 dark:cteditor-text-white cteditor-text-foreground cteditor-border cteditor-border-indigo-600/50 hover:cteditor-bg-indigo-600/25",
448
+ children: [
449
+ "Use prompt",
450
+ /* @__PURE__ */ t(lt, { className: "cteditor-h-[11px] cteditor-w-[11px]" })
451
+ ]
452
+ }
453
+ )
454
+ ]
455
+ },
456
+ r.id
457
+ );
458
+ }) }),
459
+ /* @__PURE__ */ t(yt, { open: nt, onOpenChange: Q, children: /* @__PURE__ */ e(Nt, { className: "sm:cteditor-max-w-[40rem] cteditor-max-w-[calc(100%-2rem)] !cteditor-max-h-[80vh] !cteditor-flex !cteditor-flex-col cteditor-overflow-hidden cteditor-rounded-lg [&>.closeDialog]:cteditor-top-3 [&>.closeDialog]:cteditor-right-3 !cteditor-gap-0 !cteditor-p-0", children: [
460
+ /* @__PURE__ */ e(wt, { className: "cteditor-px-5 cteditor-py-4 cteditor-border-b cteditor-border-foreground/10", children: [
461
+ /* @__PURE__ */ e(kt, { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-lg !cteditor-font-medium", children: [
462
+ /* @__PURE__ */ t($t, { size: 18, className: "cteditor-text-[#8c8c8c]" }),
463
+ /* @__PURE__ */ t("span", { children: "Recent Prompts History" })
464
+ ] }),
465
+ /* @__PURE__ */ t(re, { className: "cteditor-text-xs cteditor-text-foreground/50", children: "Choose a prompt from your history to use it in the chat." })
466
+ ] }),
467
+ /* @__PURE__ */ t("div", { className: "cteditor-flex-1 cteditor-overflow-y-auto cteditor-p-5 cteditor-flex cteditor-flex-col cteditor-gap-3 dark:cteditor-bg-black/10", children: u.map((r, p) => {
468
+ const f = r.createdAt ? At(r.createdAt) : "just now";
469
+ return /* @__PURE__ */ e(
470
+ "div",
471
+ {
472
+ className: "cteditor-flex cteditor-items-stretch cteditor-gap-3.5 cteditor-p-3.5 cteditor-rounded-xl cteditor-border dark:cteditor-bg-white/[0.015] cteditor-bg-foreground/10 cteditor-border-foreground/5 hover:cteditor-border-foreground/15 cteditor-transition-all",
473
+ children: [
474
+ /* @__PURE__ */ t("div", { className: "cteditor-w-[3px] cteditor-rounded-[2px] cteditor-bg-foreground/10" }),
475
+ /* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
476
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-baseline cteditor-gap-2 cteditor-text-xs cteditor-font-semibold dark:cteditor-text-[#aeaeae] cteditor-text-foreground", children: [
477
+ /* @__PURE__ */ e("span", { children: [
478
+ "Prompt #",
479
+ u.length - p
480
+ ] }),
481
+ /* @__PURE__ */ t("span", { className: "cteditor-font-mono cteditor-text-[10px] cteditor-text-[#8c8c8c] cteditor-font-normal", children: f })
482
+ ] }),
483
+ /* @__PURE__ */ t("div", { className: "cteditor-text-xs dark:cteditor-text-[#d1d5dc] cteditor-text-foreground cteditor-leading-relaxed cteditor-mt-1 cteditor-break-words", children: r.prompt })
484
+ ] }),
485
+ /* @__PURE__ */ e(
486
+ "button",
487
+ {
488
+ type: "button",
489
+ onClick: () => {
490
+ v(r.prompt), Q(!1);
491
+ },
492
+ className: "cteditor-inline-flex cteditor-items-center cteditor-gap-1.5 cteditor-h-7 cteditor-px-3 cteditor-rounded-md cteditor-cursor-pointer cteditor-text-xs cteditor-font-normal cteditor-self-center cteditor-shrink-0 cteditor-transition-all cteditor-bg-transparent cteditor-text-foreground cteditor-border dark:cteditor-border-white/5 cteditor-border-foreground/30 hover:cteditor-bg-white/5",
493
+ children: [
494
+ "Use prompt",
495
+ /* @__PURE__ */ t(lt, { className: "cteditor-h-[11px] cteditor-w-[11px]" })
496
+ ]
497
+ }
498
+ )
499
+ ]
500
+ },
501
+ r.id
502
+ );
503
+ }) }),
504
+ /* @__PURE__ */ t(oe, { className: "cteditor-px-5 cteditor-py-3 cteditor-border-t cteditor-border-foreground/10 cteditor-flex cteditor-justify-end", children: /* @__PURE__ */ t(
505
+ at,
506
+ {
507
+ variant: "outline",
508
+ onClick: () => Q(!1),
509
+ className: "cteditor-text-xs !cteditor-h-8",
510
+ children: "Close"
511
+ }
512
+ ) })
513
+ ] }) })
514
+ ] })
515
+ ] }),
516
+ i && i.trim() !== "" && /* @__PURE__ */ e("div", { className: "cteditor-space-y-2 cteditor-mt-2", children: [
517
+ /* @__PURE__ */ e("div", { className: "cteditor-p-3 cteditor-rounded-md cteditor-bg-accent/50 cteditor-relative cteditor-max-h-24 cteditor-overflow-y-auto cteditor-pr-12", children: [
518
+ /* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground cteditor-truncate", children: "Selected Text" }),
519
+ /* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-foreground/60 cteditor-flex-1 cteditor-leading-relaxed cteditor-line-clamp-1", children: i.length > 300 ? i.substring(0, 300) + "..." : i }),
520
+ /* @__PURE__ */ t(
521
+ "button",
522
+ {
523
+ type: "button",
524
+ onClick: () => y(""),
525
+ className: "cteditor-right-2 cteditor-top-1/2 cteditor--translate-y-1/2 cteditor-p-1 cteditor-text-xs cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-absolute ",
526
+ title: "Clear selected text",
527
+ children: /* @__PURE__ */ t(ht, { size: 14 })
528
+ }
529
+ )
530
+ ] }),
531
+ /* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: "Your prompt will be applied to this selected text" })
532
+ ] })
533
+ ] }),
534
+ I && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-gray-100 dark:cteditor-bg-gray-900/50 cteditor-border cteditor-border-gray-300 dark:cteditor-border-gray-700", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
535
+ /* @__PURE__ */ e(
536
+ "svg",
537
+ {
538
+ className: "cteditor-w-4 cteditor-h-4 cteditor-animate-spin cteditor-text-gray-600 dark:cteditor-text-gray-400",
539
+ fill: "none",
540
+ viewBox: "0 0 24 24",
541
+ children: [
542
+ /* @__PURE__ */ t(
543
+ "circle",
544
+ {
545
+ className: "cteditor-opacity-25",
546
+ cx: "12",
547
+ cy: "12",
548
+ r: "10",
549
+ stroke: "currentColor",
550
+ strokeWidth: "4"
551
+ }
552
+ ),
553
+ /* @__PURE__ */ t(
554
+ "path",
555
+ {
556
+ className: "cteditor-opacity-75",
557
+ fill: "currentColor",
558
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
559
+ }
560
+ )
561
+ ]
562
+ }
563
+ ),
564
+ /* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-gray-700 dark:cteditor-text-gray-300", children: "Initializing microphone... Please allow microphone access." })
565
+ ] }) }),
566
+ mt && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-red-50 dark:cteditor-bg-red-950/20 cteditor-border cteditor-border-red-200 dark:cteditor-border-red-800", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
567
+ /* @__PURE__ */ t("span", { className: "cteditor-text-red-600 dark:cteditor-text-red-400", children: "⚠️" }),
568
+ /* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-red-700 dark:cteditor-text-red-300", children: mt })
569
+ ] }) }),
570
+ C && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-destructive/10 cteditor-border cteditor-border-destructive/20", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
571
+ /* @__PURE__ */ t("span", { className: "cteditor-text-destructive", children: "⚠️" }),
572
+ /* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-destructive", children: C })
573
+ ] }) }),
574
+ n && /* @__PURE__ */ t("div", { className: "cteditor-p-4 cteditor-rounded-lg cteditor-bg-gray-100 dark:cteditor-bg-gray-900/50 cteditor-border cteditor-border-gray-300 dark:cteditor-border-gray-700", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-3", children: [
575
+ /* @__PURE__ */ t("div", { className: "cteditor-h-5 cteditor-w-5 cteditor-animate-spin cteditor-rounded-full cteditor-border-2 cteditor-border-gray-700 dark:cteditor-border-gray-300 cteditor-border-t-transparent" }),
576
+ /* @__PURE__ */ e("div", { children: [
577
+ /* @__PURE__ */ e("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-text-gray-900 dark:cteditor-text-gray-100", children: [
578
+ qt(A),
579
+ " is thinking..."
580
+ ] }),
581
+ /* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-gray-600 dark:cteditor-text-gray-400 cteditor-mt-1", children: "This may take a few seconds. Please wait." })
582
+ ] })
583
+ ] }) })
584
+ ] }),
585
+ /* @__PURE__ */ t("div", { className: "md:cteditor-col-span-4 cteditor-py-6 cteditor-px-3 max-md:cteditor-hidden", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-gap-4 cteditor-flex-col", children: [
586
+ /* @__PURE__ */ e("div", { children: [
587
+ /* @__PURE__ */ t("label", { className: "cteditor-block cteditor-text-[10px] cteditor-font-medium cteditor-tracking-[0.12em] cteditor-uppercase cteditor-text-[#8c8c8c] cteditor-mb-2", children: "AI Provider" }),
588
+ /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-1", children: [
589
+ { id: "chatgpt", name: "OpenAI ChatGPT", model: "gpt-4o", classes: "cteditor-bg-[#10a37f] cteditor-shadow-[0_0_0_2px_#10a37f22]" },
590
+ { id: "claude", name: "Anthropic Claude", model: "sonnet-3.5", classes: "cteditor-bg-[#d97757] cteditor-shadow-[0_0_0_2px_#d9775722]" },
591
+ { id: "grok", name: "xAI Grok", model: "grok-2", classes: "cteditor-bg-[#ffffff] cteditor-shadow-[0_0_0_2px_#ffffff22]" },
592
+ { id: "gemini", name: "Google Gemini", model: "1.5-pro", classes: "cteditor-bg-[#4285f4] cteditor-shadow-[0_0_0_2px_#4285f422]" }
593
+ ].map((r) => {
594
+ if (!s.includes(r.id)) return null;
595
+ const f = A === r.id;
596
+ return /* @__PURE__ */ e(
597
+ "button",
598
+ {
599
+ type: "button",
600
+ onClick: () => !a && S(r.id),
601
+ disabled: a,
602
+ className: `cteditor-flex cteditor-items-center cteditor-gap-2.5 cteditor-w-full cteditor-py-2 cteditor-px-2.5 cteditor-rounded-lg cteditor-border cteditor-transition-all cteditor-text-left ${f ? "cteditor-bg-indigo-600/10 cteditor-border-indigo-600/30" : "cteditor-bg-transparent cteditor-border-transparent hover:cteditor-bg-foreground/5"}`,
603
+ children: [
604
+ /* @__PURE__ */ t("span", { className: `cteditor-inline-block cteditor-w-[10px] cteditor-h-[10px] cteditor-rounded-[2px] cteditor-shrink-0 cteditor-border cteditor-border-foreground/10 ${r.classes}` }),
605
+ /* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-min-w-0", children: [
606
+ /* @__PURE__ */ t("div", { className: "cteditor-font-medium cteditor-text-xs cteditor-text-foreground cteditor-leading-tight", children: r.name }),
607
+ /* @__PURE__ */ t("div", { className: "cteditor-font-mono cteditor-text-[10px] cteditor-text-[#8c8c8c] cteditor-leading-none cteditor-mt-0.5", children: r.model })
608
+ ] }),
609
+ f && /* @__PURE__ */ t("span", { className: "cteditor-text-indigo-600 dark:cteditor-text-indigo-400 cteditor-shrink-0", children: /* @__PURE__ */ t("svg", { width: "8", height: "8", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M12 3l8 9-8 9-8-9z" }) }) })
610
+ ]
611
+ },
612
+ r.id
613
+ );
614
+ }) })
615
+ ] }),
616
+ /* @__PURE__ */ e("div", { className: "cteditor-p-3.5 cteditor-rounded-xl dark:cteditor-bg-black/10 cteditor-bg-black/5 cteditor-border cteditor-border-foreground/10 cteditor-flex cteditor-flex-col cteditor-gap-2.5 cteditor-w-full", children: [
617
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-justify-between", children: [
618
+ /* @__PURE__ */ t("span", { className: "cteditor-text-[10px] cteditor-font-semibold cteditor-tracking-[0.12em] cteditor-uppercase cteditor-text-foreground/60", children: "Credits" }),
619
+ !G && !B && /* @__PURE__ */ e(
620
+ "button",
621
+ {
622
+ type: "button",
623
+ onClick: () => {
624
+ window.location.href = "/user/license-key";
625
+ },
626
+ className: "cteditor-inline-flex cteditor-items-center cteditor-gap-0.5 cteditor-h-[22px] cteditor-px-2 cteditor-rounded-[5px] cteditor-bg-green-500/10 cteditor-text-green-500 cteditor-border cteditor-border-green-500/20 hover:cteditor-bg-green-500/20 cteditor-cursor-pointer cteditor-text-[10px] cteditor-font-semibold cteditor-transition-colors",
627
+ children: [
628
+ "Top up",
629
+ /* @__PURE__ */ t(lt, { className: "cteditor-h-2.5 cteditor-w-2.5 cteditor-shrink-0 cteditor-ml-0.5" })
630
+ ]
631
+ }
632
+ )
633
+ ] }),
634
+ B ? /* @__PURE__ */ e("div", { className: "cteditor-animate-pulse cteditor-space-y-2", children: [
635
+ /* @__PURE__ */ t("div", { className: "cteditor-h-6 cteditor-w-24 cteditor-bg-white/10 cteditor-rounded" }),
636
+ /* @__PURE__ */ t("div", { className: "cteditor-h-1 cteditor-w-full cteditor-bg-white/5 cteditor-rounded" })
637
+ ] }) : G ? /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-1", children: [
638
+ /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-items-baseline cteditor-gap-1.5", children: /* @__PURE__ */ t("span", { className: "cteditor-text-base cteditor-font-semibold cteditor-text-green-500", children: "Unlimited" }) }),
639
+ /* @__PURE__ */ t("span", { className: "cteditor-text-[10px] cteditor-text-[#8c8c8c] cteditor-font-medium", children: "Using your own API Key" })
640
+ ] }) : /* @__PURE__ */ e(tt, { children: [
641
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-baseline cteditor-gap-1.5", children: [
642
+ /* @__PURE__ */ t("span", { className: "cteditor-font-mono cteditor-text-3xl cteditor-font-semibold cteditor-text-foreground leading-none", children: (O + T).toLocaleString() }),
643
+ /* @__PURE__ */ t("span", { className: "cteditor-text-[10px] cteditor-text-[#8c8c8c] leading-none", children: "remaining" })
644
+ ] }),
645
+ /* @__PURE__ */ t("div", { className: "cteditor-w-full cteditor-h-1 cteditor-rounded-full cteditor-bg-white/5 cteditor-overflow-hidden", children: /* @__PURE__ */ t(
646
+ "div",
647
+ {
648
+ className: "cteditor-h-full cteditor-bg-gradient-to-r cteditor-from-foreground cteditor-to-[#6352e8]",
649
+ style: {
650
+ width: `${Math.min(100, (O + T || 0) / 1e3 * 100)}%`
651
+ }
652
+ }
653
+ ) }),
654
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-wrap cteditor-gap-3 cteditor-mt-0.5", children: [
655
+ /* @__PURE__ */ e("span", { className: "cteditor-inline-flex cteditor-items-center cteditor-gap-1.5 cteditor-text-[10px] cteditor-text-foreground/60", children: [
656
+ /* @__PURE__ */ t("span", { className: "cteditor-w-1.5 cteditor-h-1.5 cteditor-rounded-full cteditor-bg-foreground" }),
657
+ "Plan",
658
+ /* @__PURE__ */ t("span", { className: "cteditor-font-mono cteditor-text-foreground cteditor-ml-0.5", children: O })
659
+ ] }),
660
+ T > 0 && /* @__PURE__ */ e("span", { className: "cteditor-inline-flex cteditor-items-center cteditor-gap-1.5 cteditor-text-[10px] cteditor-text-foreground/60", children: [
661
+ /* @__PURE__ */ t("span", { className: "cteditor-w-1.5 cteditor-h-1.5 cteditor-rounded-full cteditor-bg-[#1fbf75]" }),
662
+ "Top-up",
663
+ /* @__PURE__ */ e("span", { className: "cteditor-font-mono cteditor-text-[#1fbf75] cteditor-ml-0.5", children: [
664
+ "+",
665
+ T
666
+ ] })
667
+ ] })
668
+ ] })
669
+ ] })
670
+ ] })
671
+ ] }) })
672
+ ] })
673
+ ] })
674
+ ] }) }) });
675
+ }
676
+ function le({
677
+ editor: c,
678
+ apiKey: b,
679
+ initialProvider: et,
680
+ selectedText: x,
681
+ onClose: k,
682
+ anchorElem: P,
683
+ isStreamingFromModal: q = !1,
684
+ isImageStreaming: D = !1,
685
+ onStopStreaming: rt,
686
+ onReopenModal: R
687
+ }) {
688
+ const [l, v] = d(et), [i, y] = d(""), [n, z] = d(!1), [C, L] = d("idle"), [A, S] = d(!0), [O, F] = d([]), [T, V] = d(!1), G = W(null), _ = W(null), B = Tt(), N = B?.isByokPlan ?? !1, g = B?.byokApiKeys, m = Et(() => {
689
+ if (!N || !g)
690
+ return ["chatgpt", "claude", "grok", "gemini"];
691
+ const o = [];
692
+ return g.hasOpenaiKey && o.push("chatgpt"), g.hasAnthropicKey && o.push("claude"), g.hasGrokKey && o.push("grok"), g.hasGeminiKey && o.push("gemini"), o;
693
+ }, [N, g]), j = N && m.length === 0;
694
+ $(() => {
695
+ N && m.length > 0 && !m.includes(l) && v(m[0]);
696
+ }, [N, m, l]);
697
+ const E = W(null), [u, J] = d(x);
698
+ $(() => {
699
+ c.getEditorState().read(() => {
700
+ const o = ct();
701
+ o && (E.current = o.clone());
702
+ });
703
+ }, [c]), $(() => {
704
+ const o = c.registerUpdateListener(({ editorState: M }) => {
705
+ M.read(() => {
706
+ const h = ct();
707
+ if (h && St(h) && h.getTextContent().trim()) {
708
+ const s = h.getTextContent();
709
+ s.trim() !== "" && (J(s), E.current = h.clone(), L("idle"), S(!0));
710
+ }
711
+ });
712
+ });
713
+ return () => {
714
+ o();
715
+ };
716
+ }, [c]), $(() => {
717
+ G.current && G.current.focus(), b && Pt(b).then(F).catch(() => {
718
+ });
719
+ }, [b]), $(() => {
720
+ if (!T) return;
721
+ const o = () => V(!1);
722
+ return document.addEventListener("click", o), () => document.removeEventListener("click", o);
723
+ }, [T]);
724
+ const nt = (o) => {
725
+ const M = o.toLowerCase();
726
+ return [
727
+ "generate image",
728
+ "generate an image",
729
+ "create image",
730
+ "create an image",
731
+ "make image",
732
+ "make an image",
733
+ "draw",
734
+ "illustration",
735
+ "picture of",
736
+ "image of",
737
+ "photo of",
738
+ "generate picture",
739
+ "create picture",
740
+ "visualize",
741
+ "render image",
742
+ "design image",
743
+ "produce image"
744
+ ].some((s) => M.includes(s));
745
+ }, Q = K(() => {
746
+ _.current && (_.current.abort(), _.current = null);
747
+ }, []), ot = async () => {
748
+ if (!i.trim() || n) return;
749
+ c.getEditorState().read(() => {
750
+ const a = ct();
751
+ a && St(a) && (E.current = a.clone());
752
+ });
753
+ const o = new AbortController();
754
+ _.current = o, z(!0);
755
+ const M = nt(i) || u && nt(u), h = u && u.trim() !== "";
756
+ i.length + (h ? u.length : 0);
757
+ let s;
758
+ M ? h ? s = `${i}: ${u}` : s = i : h ? s = `${i}
759
+
760
+ IMPORTANT: Return ONLY the modified/transformed text. Do NOT include any labels, prefixes, explanations, or formatting like "Simplified:", "Result:", "Here is", etc. Just return the pure result text.
761
+
762
+ Text to transform:
763
+ "${u}"` : s = i;
764
+ try {
765
+ await Dt({
766
+ editor: c,
767
+ query: s,
768
+ model: l === "chatgpt" ? "chatgpt" : l,
769
+ apiKey: b || "",
770
+ type: "general",
771
+ savedSelection: E.current,
772
+ originalPrompt: i,
773
+ abortSignal: o.signal,
774
+ onStreamStart: () => {
775
+ },
776
+ onInputClear: () => {
777
+ y(""), J("");
778
+ },
779
+ onStatusChange: (a) => {
780
+ a !== "loading" && (L(a), S(!0));
781
+ },
782
+ onLoadingChange: (a) => {
783
+ z(a);
784
+ },
785
+ onSuccess: () => {
786
+ y(""), J(""), L("success"), S(!0), z(!1), c.focus();
787
+ },
788
+ onError: (a) => {
789
+ pt.error(a), L("error"), S(!0), z(!1);
790
+ }
791
+ });
792
+ } catch (a) {
793
+ console.error("Error processing AI action:", a);
794
+ const Z = a instanceof Error ? a.message : "Error processing your request. Please try again.";
795
+ pt.error(Z), L("error"), S(!0), z(!1);
796
+ }
797
+ }, st = (o) => {
798
+ o.key === "Enter" && !o.shiftKey && !n && i.trim() && (o.preventDefault(), ot()), o.key === "Escape" && k();
799
+ }, X = u && u.trim() !== "", Y = X ? u.length > 50 ? u.substring(0, 50) + "..." : u : "";
800
+ return /* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-bottom-1 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-flex cteditor-flex-col cteditor-gap-2 cteditor-bg-main-background cteditor-px-2 cteditor-py-2 cteditor-rounded-md cteditor-border cteditor-border-border cteditor-shadow-lg cteditor-z-10 cteditor-max-w-[550px] cteditor-w-full", children: [
801
+ q && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-2 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-bg-blue-500/10 cteditor-border cteditor-border-blue-500/20", children: [
802
+ /* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-3 cteditor-rounded-full cteditor-bg-blue-500 cteditor-animate-pulse cteditor-shrink-0" }),
803
+ /* @__PURE__ */ t("span", { className: "cteditor-text-blue-600 dark:cteditor-text-blue-300 cteditor-flex-1", children: D ? "AI is generating image..." : "AI is writing content..." }),
804
+ !D && /* @__PURE__ */ e(
805
+ "button",
806
+ {
807
+ type: "button",
808
+ onClick: rt,
809
+ className: "cteditor-h-6 cteditor-px-2 cteditor-bg-red-600 cteditor-text-white cteditor-rounded cteditor-text-xs cteditor-flex cteditor-items-center cteditor-gap-1 cteditor-shrink-0 cteditor-cursor-pointer hover:cteditor-bg-red-700 cteditor-transition-colors",
810
+ title: "Stop generating",
811
+ children: [
812
+ /* @__PURE__ */ t(It, { size: 10 }),
813
+ "Stop"
814
+ ]
815
+ }
816
+ )
817
+ ] }),
818
+ A && !q && /* @__PURE__ */ e(
819
+ "div",
820
+ {
821
+ className: `cteditor-relative cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-6 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-text-muted-foreground ${C === "success" ? "cteditor-bg-green-500/10 cteditor-border cteditor-border-green-500/20" : C === "error" ? "cteditor-bg-red-500/10 cteditor-border cteditor-border-red-500/20" : "cteditor-bg-muted"}`,
822
+ children: [
823
+ C === "success" ? /* @__PURE__ */ t("span", { className: "cteditor-text-green-600 dark:cteditor-text-green-400", children: "✓ Content inserted! Select new text or enter another prompt" }) : C === "error" ? /* @__PURE__ */ t("span", { className: "cteditor-text-red-600 dark:cteditor-text-red-400", children: "✗ Request failed. Try again or select different text" }) : X ? /* @__PURE__ */ e(tt, { children: [
824
+ /* @__PURE__ */ t("span", { className: "cteditor-text-muted-foreground/60", children: "Selected:" }),
825
+ /* @__PURE__ */ e("span", { className: "cteditor-text-foreground cteditor-italic", children: [
826
+ '"',
827
+ Y,
828
+ '"'
829
+ ] })
830
+ ] }) : /* @__PURE__ */ t("span", { className: "cteditor-text-foreground", children: "Ask AI anything or select text to transform" }),
831
+ /* @__PURE__ */ t(
832
+ "button",
833
+ {
834
+ type: "button",
835
+ onClick: () => {
836
+ S(!1), J("");
837
+ },
838
+ className: "cteditor-absolute cteditor-right-1 cteditor-top-1/2 cteditor--translate-y-1/2 cteditor-size-4 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-duration-200 cteditor-cursor-pointer",
839
+ title: "Close message",
840
+ children: /* @__PURE__ */ t(ht, { size: 12 })
841
+ }
842
+ )
843
+ ]
844
+ }
845
+ ),
846
+ /* @__PURE__ */ e("div", { className: "cteditor-flex md:cteditor-items-center cteditor-gap-1.5 max-xs:cteditor-flex-col", children: [
847
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5 max-xs:cteditor-w-full", children: [
848
+ /* @__PURE__ */ e(
849
+ Mt,
850
+ {
851
+ value: m.includes(l) ? l : m[0] ?? "chatgpt",
852
+ onValueChange: (o) => v(o),
853
+ disabled: j,
854
+ children: [
855
+ /* @__PURE__ */ t(Rt, { className: "sm:cteditor-max-w-[90px] !cteditor-h-8 cteditor-text-xs cteditor-font-medium cteditor-border-border cteditor-bg-muted cteditor-text-foreground !cteditor-px-2 !cteditor-py-1 max-xs:cteditor-w-full", children: /* @__PURE__ */ t(zt, { placeholder: "Select provider" }) }),
856
+ /* @__PURE__ */ e(Lt, { children: [
857
+ m.includes("chatgpt") && /* @__PURE__ */ t(U, { value: "chatgpt", children: "ChatGPT" }),
858
+ m.includes("claude") && /* @__PURE__ */ t(U, { value: "claude", children: "Claude" }),
859
+ m.includes("grok") && /* @__PURE__ */ t(U, { value: "grok", children: "Grok" }),
860
+ m.includes("gemini") && /* @__PURE__ */ t(U, { value: "gemini", children: "Gemini" })
861
+ ] })
862
+ ]
863
+ }
864
+ ),
865
+ O.length > 0 && /* @__PURE__ */ e("div", { className: "cteditor-relative", onClick: (o) => o.stopPropagation(), children: [
866
+ /* @__PURE__ */ t(
867
+ "button",
868
+ {
869
+ type: "button",
870
+ onClick: () => V((o) => !o),
871
+ className: "cteditor-h-8 cteditor-w-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-border cteditor-border-border cteditor-bg-muted cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-shrink-0",
872
+ title: "Recent prompts",
873
+ children: /* @__PURE__ */ t($t, { size: 14 })
874
+ }
875
+ ),
876
+ T && /* @__PURE__ */ t("div", { className: "cteditor-absolute cteditor-bottom-full sm:cteditor-left-0 max-sm:cteditor-right-0 cteditor-mb-1 cteditor-bg-popover cteditor-border cteditor-border-border cteditor-rounded-md cteditor-shadow-lg cteditor-z-20 sm:cteditor-min-w-[200px] sm:cteditor-max-w-[300px] max-sm:cteditor-w-[95vw]", children: O.map((o) => /* @__PURE__ */ t(
877
+ "button",
878
+ {
879
+ type: "button",
880
+ className: "cteditor-w-full cteditor-text-left cteditor-px-3 cteditor-py-2 cteditor-text-xs cteditor-text-foreground hover:cteditor-bg-muted cteditor-transition-colors cteditor-truncate cteditor-border-b cteditor-border-border last:cteditor-border-b-0",
881
+ onClick: () => {
882
+ y(o.prompt), V(!1), C !== "idle" && L("idle"), S(!0);
883
+ },
884
+ title: o.prompt,
885
+ children: o.prompt.length > 50 ? o.prompt.substring(0, 50) + "..." : o.prompt
886
+ },
887
+ o.id
888
+ )) })
889
+ ] })
890
+ ] }),
891
+ /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5 cteditor-w-full", children: [
892
+ /* @__PURE__ */ t(
893
+ "input",
894
+ {
895
+ ref: G,
896
+ type: "text",
897
+ value: i,
898
+ onChange: (o) => {
899
+ y(o.target.value), C !== "idle" && L("idle");
900
+ },
901
+ onKeyDown: st,
902
+ placeholder: j ? "Add API keys in License > Manage API Keys to use AI..." : X ? "What do you want to do with this text?" : "Ask AI anything...",
903
+ disabled: n || j,
904
+ className: "cteditor-h-8 cteditor-px-2 cteditor-text-xs cteditor-flex-1 cteditor-min-w-0 cteditor-border cteditor-border-border cteditor-rounded-md cteditor-outline-none cteditor-bg-muted cteditor-text-foreground"
905
+ }
906
+ ),
907
+ n ? /* @__PURE__ */ t(
908
+ "button",
909
+ {
910
+ type: "button",
911
+ onClick: Q,
912
+ className: "cteditor-h-8 cteditor-w-8 cteditor-bg-red-600 cteditor-text-white cteditor-rounded-md cteditor-border-none cteditor-flex cteditor-items-center cteditor-justify-center cteditor-shrink-0 cteditor-cursor-pointer cteditor-transition-colors cteditor-duration-200 hover:cteditor-bg-red-700",
913
+ title: "Stop generating",
914
+ children: /* @__PURE__ */ t(It, { size: 14 })
915
+ }
916
+ ) : /* @__PURE__ */ t(
917
+ "button",
918
+ {
919
+ type: "button",
920
+ onClick: ot,
921
+ disabled: !i.trim() || j,
922
+ className: `cteditor-h-8 cteditor-w-8 cteditor-bg-primary cteditor-text-primary-foreground cteditor-rounded-md cteditor-border-none cteditor-flex cteditor-items-center cteditor-justify-center cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 ${!i.trim() || j ? "cteditor-cursor-not-allowed cteditor-opacity-50" : "cteditor-cursor-pointer cteditor-opacity-100"}`,
923
+ children: /* @__PURE__ */ t(se, { size: 16 })
924
+ }
925
+ ),
926
+ R && /* @__PURE__ */ t(
927
+ "button",
928
+ {
929
+ type: "button",
930
+ onClick: R,
931
+ className: "cteditor-h-8 cteditor-w-8 cteditor-bg-muted cteditor-text-muted-foreground cteditor-flex cteditor-items-center cteditor-justify-center cteditor-cursor-pointer cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 hover:cteditor-text-foreground cteditor-rounded-md cteditor-border cteditor-border-border",
932
+ title: "Open AI Chat",
933
+ children: /* @__PURE__ */ t(Ot, { size: 14 })
934
+ }
935
+ )
936
+ ] }),
937
+ /* @__PURE__ */ t(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ onClick: k,
942
+ className: "cteditor-h-8 cteditor-w-8 cteditor-bg-muted cteditor-text-muted-foreground cteditor-flex cteditor-items-center cteditor-justify-center cteditor-cursor-pointer cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 hover:cteditor-text-foreground cteditor-rounded-md cteditor-border cteditor-border-border max-xs:cteditor-absolute max-xs:cteditor-right-1 max-xs:cteditor-bottom-full max-xs:cteditor-mb-1.5",
943
+ title: "Close (Esc)",
944
+ children: /* @__PURE__ */ t(ht, { size: 16 })
945
+ }
946
+ )
947
+ ] })
948
+ ] });
949
+ }
950
+ function me(c, b, et) {
951
+ const [x, k] = d(!1), [P, q] = d(
952
+ void 0
953
+ ), D = W(null), [rt, R] = d(!1), [l, v] = d("chatgpt"), [i, y] = d(""), n = W(null), [z, C] = d(!1), [L, A] = d(!1), S = K(
954
+ (N) => {
955
+ c.getEditorState().read(() => {
956
+ const g = ct();
957
+ g && (D.current = g.clone());
958
+ }), q(N), k((g) => !g);
959
+ },
960
+ [c]
961
+ ), O = K(
962
+ (N, g) => {
963
+ v(N), y(g || P || ""), R(!0);
964
+ },
965
+ [P]
966
+ ), F = K(
967
+ (N, g, m) => {
968
+ n.current = N, C(!0), A(m ?? !1), v(g), y(""), R(!0);
969
+ },
970
+ []
971
+ ), T = K(() => {
972
+ n.current = null, C(!1);
973
+ }, []), V = K(() => {
974
+ n.current && (n.current.abort(), n.current = null), C(!1);
975
+ }, []), G = K(() => {
976
+ k(!0);
977
+ }, []), _ = K(() => {
978
+ n.current && (n.current.abort(), n.current = null), C(!1), R(!1), y("");
979
+ }, []);
980
+ $(() => {
981
+ const N = c.registerCommand(
982
+ Vt,
983
+ (m) => (S(m), !0),
984
+ Ct
985
+ ), g = c.registerCommand(
986
+ Bt,
987
+ (m) => {
988
+ let j = "";
989
+ return c.getEditorState().read(() => {
990
+ const E = ct();
991
+ E && (j = E.getTextContent());
992
+ }), v(m?.provider || "chatgpt"), y(m?.initialText || j), R(!0), !0;
993
+ },
994
+ Ct
995
+ );
996
+ return () => {
997
+ N(), g();
998
+ };
999
+ }, [c, S]);
1000
+ const B = c.getRootElement();
1001
+ return /* @__PURE__ */ e(tt, { children: [
1002
+ x && /* @__PURE__ */ t(
1003
+ ae,
1004
+ {
1005
+ open: x,
1006
+ onOpenChange: k,
1007
+ editor: c,
1008
+ apiKey: b,
1009
+ initialText: P,
1010
+ savedSelection: D.current,
1011
+ onShowInEditor: O,
1012
+ onStreamStart: F,
1013
+ onStreamEnd: T,
1014
+ selectedTextForInline: P
1015
+ }
1016
+ ),
1017
+ rt && /* @__PURE__ */ t(
1018
+ le,
1019
+ {
1020
+ editor: c,
1021
+ apiKey: b,
1022
+ initialProvider: l,
1023
+ selectedText: i,
1024
+ onClose: _,
1025
+ anchorElem: B,
1026
+ isStreamingFromModal: z,
1027
+ isImageStreaming: L,
1028
+ onStopStreaming: V,
1029
+ onReopenModal: G
1030
+ }
1031
+ )
1032
+ ] });
1033
+ }
1034
+ function ve({
1035
+ apiKey: c
1036
+ }) {
1037
+ const [b] = de();
1038
+ return me(b, c);
1039
+ }
1040
+ export {
1041
+ ve as default
1042
+ };