@deepagents/react-input 7.8.2 → 7.10.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 (47) hide show
  1. package/COMPOSER_FEATURE_MATRIX.md +3 -2
  2. package/dist/browser.d.ts +4 -0
  3. package/dist/browser.d.ts.map +1 -1
  4. package/dist/browser.js +1238 -935
  5. package/dist/browser.js.map +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/lib/Composer.d.ts +8 -3
  8. package/dist/lib/Composer.d.ts.map +1 -1
  9. package/dist/lib/ComposerAttachments.d.ts +1 -1
  10. package/dist/lib/ComposerAttachments.d.ts.map +1 -1
  11. package/dist/lib/ComposerContext.d.ts +3 -3
  12. package/dist/lib/ComposerContext.d.ts.map +1 -1
  13. package/dist/lib/ComposerCore.d.ts +3 -8
  14. package/dist/lib/ComposerCore.d.ts.map +1 -1
  15. package/dist/lib/ComposerDraft.d.ts +1 -1
  16. package/dist/lib/ComposerDraft.d.ts.map +1 -1
  17. package/dist/lib/ComposerRegistry.d.ts +5 -5
  18. package/dist/lib/ComposerRegistry.d.ts.map +1 -1
  19. package/dist/lib/ComposerSlashCommands.d.ts +1 -1
  20. package/dist/lib/ComposerSlashCommands.d.ts.map +1 -1
  21. package/dist/lib/ComposerSuggestions.d.ts +1 -1
  22. package/dist/lib/ComposerSuggestions.d.ts.map +1 -1
  23. package/dist/lib/ComposerTokenText.d.ts +1 -1
  24. package/dist/lib/ComposerTokenText.d.ts.map +1 -1
  25. package/dist/lib/ComposerTriggers.d.ts.map +1 -1
  26. package/dist/lib/ComposerTypes.d.ts +1 -1
  27. package/dist/lib/ComposerTypes.d.ts.map +1 -1
  28. package/dist/lib/ComposerVisibility.d.ts +1 -1
  29. package/dist/lib/ComposerVisibility.d.ts.map +1 -1
  30. package/dist/lib/PersistedPromptText.d.ts.map +1 -1
  31. package/dist/lib/dictation/ComposerDictationContext.d.ts +34 -0
  32. package/dist/lib/dictation/ComposerDictationContext.d.ts.map +1 -0
  33. package/dist/lib/dictation/ComposerDictationParts.d.ts +14 -0
  34. package/dist/lib/dictation/ComposerDictationParts.d.ts.map +1 -0
  35. package/dist/lib/dictation/DictationError.d.ts +6 -0
  36. package/dist/lib/dictation/DictationError.d.ts.map +1 -0
  37. package/dist/lib/dictation/MicrophonePermission.d.ts +7 -0
  38. package/dist/lib/dictation/MicrophonePermission.d.ts.map +1 -0
  39. package/dist/lib/dictation/Recording.d.ts +23 -0
  40. package/dist/lib/dictation/Recording.d.ts.map +1 -0
  41. package/dist/lib/dictation/useDictationController.d.ts +12 -0
  42. package/dist/lib/dictation/useDictationController.d.ts.map +1 -0
  43. package/dist/lib/persisted-prompt-selection.d.ts.map +1 -1
  44. package/dist/lib/tiptap/ComposerTiptapDomain.d.ts +6 -9
  45. package/dist/lib/tiptap/ComposerTiptapDomain.d.ts.map +1 -1
  46. package/dist/persisted-prompt.d.ts.map +1 -1
  47. package/package.json +7 -5
package/dist/browser.js CHANGED
@@ -4,24 +4,23 @@ import { Button as a } from "@base-ui/react/button";
4
4
  import { EditorContent as o, useEditor as s } from "@tiptap/react";
5
5
  import { useClock as c } from "@zukhruf/ui";
6
6
  import { cn as l } from "cn";
7
- import { Children as u, Fragment as d, createContext as f, isValidElement as p, use as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
8
- import { Package as y, X as b } from "lucide-react";
9
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
10
- import { escapeRegExp as w } from "lodash-es";
11
- import { Extension as ee, Mark as T, Node as E, mergeAttributes as D } from "@tiptap/core";
12
- import te from "@tiptap/extension-link";
13
- import { Slice as O } from "@tiptap/pm/model";
14
- import { Plugin as ne, TextSelection as re } from "@tiptap/pm/state";
7
+ import { Children as u, Fragment as d, createContext as f, isValidElement as p, startTransition as m, use as h, useActionState as g, useEffect as _, useEffectEvent as v, useMemo as y, useRef as b, useState as x, useSyncExternalStore as ee } from "react";
8
+ import { Package as S, X as te } from "lucide-react";
9
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
10
+ import { Extension as E, Mark as D, Node as O, mergeAttributes as k } from "@tiptap/core";
11
+ import A from "@tiptap/extension-link";
12
+ import { Slice as ne } from "@tiptap/pm/model";
13
+ import { Plugin as re, TextSelection as j } from "@tiptap/pm/state";
15
14
  import ie from "@tiptap/starter-kit";
16
15
  //#region src/lib/ComposerContext.ts
17
16
  var ae = f(null);
18
- function k(e) {
19
- let t = m(ae);
17
+ function M(e) {
18
+ let t = h(ae);
20
19
  if (!t) throw Error(`${e} must be used inside Composer.Root.`);
21
20
  return t;
22
21
  }
23
- function oe(e) {
24
- let t = i(9), n = k(e === void 0 ? "useComposer" : e), r;
22
+ function N(e) {
23
+ let t = i(9), n = M(e === void 0 ? "useComposer" : e), r;
25
24
  t[0] !== n.activePopup || t[1] !== n.disabled || t[2] !== n.meta || t[3] !== n.suggestions ? (r = {
26
25
  ...n.meta,
27
26
  disabled: n.disabled,
@@ -37,10 +36,10 @@ function oe(e) {
37
36
  }
38
37
  //#endregion
39
38
  //#region src/lib/ComposerAttachments.tsx
40
- function se(e) {
39
+ function P(e) {
41
40
  let t = i(23), n, r;
42
41
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
43
- let { state: a, attachedImages: o } = k("Composer.Attachments"), s = a.imageAttachments, c, u, d, f, p, m;
42
+ let { state: a, attachedImages: o } = M("Composer.Attachments"), s = a.imageAttachments, c, u, d, f, p, m;
44
43
  if (t[3] !== o || t[4] !== n || t[5] !== r || t[6] !== a.imageAttachments) {
45
44
  m = Symbol.for("react.early_return_sentinel");
46
45
  bb0: {
@@ -51,13 +50,13 @@ function se(e) {
51
50
  m = null;
52
51
  break bb0;
53
52
  }
54
- c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(ce);
53
+ c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(F);
55
54
  }
56
55
  t[3] = o, t[4] = n, t[5] = r, t[6] = a.imageAttachments, t[7] = c, t[8] = u, t[9] = d, t[10] = f, t[11] = p, t[12] = m;
57
56
  } else c = t[7], u = t[8], d = t[9], f = t[10], p = t[11], m = t[12];
58
57
  if (m !== Symbol.for("react.early_return_sentinel")) return m;
59
58
  let h;
60
- return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */ S("div", {
59
+ return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */ w("div", {
61
60
  role: c,
62
61
  "aria-label": u,
63
62
  className: d,
@@ -65,35 +64,35 @@ function se(e) {
65
64
  children: p
66
65
  }), t[17] = c, t[18] = u, t[19] = d, t[20] = f, t[21] = p, t[22] = h) : h = t[22], h;
67
66
  }
68
- function ce(e) {
69
- return /* @__PURE__ */ S(A, { attachment: e }, e.id);
67
+ function F(e) {
68
+ return /* @__PURE__ */ w(I, { attachment: e }, e.id);
70
69
  }
71
- function A(e) {
72
- let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } = k("Composer.Attachments"), d;
70
+ function I(e) {
71
+ let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } = M("Composer.Attachments"), d;
73
72
  t[0] !== c || t[1] !== r ? (d = c.get(r), t[0] = c, t[1] = r, t[2] = d) : d = t[2];
74
73
  let f = d;
75
74
  if (!f) return null;
76
75
  let p;
77
- t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */ S(N, {
76
+ t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */ w(z, {
78
77
  placeholder: o,
79
78
  file: f
80
- }) : s === "audio" ? /* @__PURE__ */ S(F, {
79
+ }) : s === "audio" ? /* @__PURE__ */ w(V, {
81
80
  placeholder: o,
82
81
  file: f,
83
82
  glyph: "♪"
84
- }) : /* @__PURE__ */ S(M, {
83
+ }) : /* @__PURE__ */ w(R, {
85
84
  placeholder: o,
86
85
  file: f
87
86
  }), t[3] = f, t[4] = s, t[5] = o, t[6] = p) : p = t[6];
88
87
  let m = `Remove ${o}`, h;
89
88
  t[7] !== u || t[8] !== r ? (h = () => u.removeImageAttachment(r), t[7] = u, t[8] = r, t[9] = h) : h = t[9];
90
89
  let g;
91
- t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ S(b, {
90
+ t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ w(te, {
92
91
  "aria-hidden": !0,
93
92
  className: "size-3"
94
93
  }), t[10] = g) : g = t[10];
95
94
  let _;
96
- t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */ S(a, {
95
+ t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */ w(a, {
97
96
  type: "button",
98
97
  "aria-label": m,
99
98
  disabled: l,
@@ -102,26 +101,26 @@ function A(e) {
102
101
  children: g
103
102
  }), t[11] = l, t[12] = m, t[13] = h, t[14] = _) : _ = t[14];
104
103
  let v;
105
- return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */ C("div", {
104
+ return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */ T("div", {
106
105
  role: "listitem",
107
106
  className: "relative",
108
107
  children: [p, _]
109
108
  }), t[15] = p, t[16] = _, t[17] = v) : v = t[17], v;
110
109
  }
111
- function j(e) {
112
- let t = i(3), [n, r] = v(null), a, o;
110
+ function L(e) {
111
+ let t = i(3), [n, r] = x(null), a, o;
113
112
  return t[0] === e ? (a = t[1], o = t[2]) : (a = () => {
114
113
  let t = URL.createObjectURL(e);
115
114
  return r(t), () => URL.revokeObjectURL(t);
116
- }, o = [e], t[0] = e, t[1] = a, t[2] = o), h(a, o), n;
115
+ }, o = [e], t[0] = e, t[1] = a, t[2] = o), _(a, o), n;
117
116
  }
118
- function M(e) {
119
- let t = i(5), { placeholder: n, file: r } = e, a = j(r), [o, s] = v(null), c;
120
- return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */ S(F, {
117
+ function R(e) {
118
+ let t = i(5), { placeholder: n, file: r } = e, a = L(r), [o, s] = x(null), c;
119
+ return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */ w(V, {
121
120
  placeholder: n,
122
121
  file: r,
123
122
  glyph: "🖼"
124
- }) : /* @__PURE__ */ S("img", {
123
+ }) : /* @__PURE__ */ w("img", {
125
124
  src: a,
126
125
  alt: n,
127
126
  title: r.name,
@@ -129,11 +128,11 @@ function M(e) {
129
128
  onError: () => s(a)
130
129
  }), t[0] = o, t[1] = r, t[2] = a, t[3] = n, t[4] = c) : c = t[4], c;
131
130
  }
132
- function N(e) {
133
- let t = i(11), { placeholder: n, file: r } = e, a = j(r), [o, s] = v(null), c = a ?? void 0, l;
131
+ function z(e) {
132
+ let t = i(11), { placeholder: n, file: r } = e, a = L(r), [o, s] = x(null), c = a ?? void 0, l;
134
133
  t[0] === Symbol.for("react.memo_cache_sentinel") ? (l = (e) => s(e.currentTarget.duration), t[0] = l) : l = t[0];
135
134
  let u;
136
- t[1] === c ? u = t[2] : (u = /* @__PURE__ */ S("video", {
135
+ t[1] === c ? u = t[2] : (u = /* @__PURE__ */ w("video", {
137
136
  src: c,
138
137
  muted: !0,
139
138
  playsInline: !0,
@@ -142,18 +141,18 @@ function N(e) {
142
141
  onLoadedMetadata: l
143
142
  }), t[1] = c, t[2] = u);
144
143
  let d;
145
- t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ S("span", {
144
+ t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ w("span", {
146
145
  "aria-hidden": !0,
147
146
  className: "pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow",
148
147
  children: "▶"
149
148
  }), t[3] = d) : d = t[3];
150
149
  let f;
151
- t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */ S("span", {
150
+ t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */ w("span", {
152
151
  className: "absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white",
153
- children: P(o)
152
+ children: B(o)
154
153
  }) : null, t[4] = o, t[5] = f);
155
154
  let p;
156
- return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */ C("div", {
155
+ return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */ T("div", {
157
156
  role: "img",
158
157
  "aria-label": n,
159
158
  title: r.name,
@@ -165,28 +164,28 @@ function N(e) {
165
164
  ]
166
165
  }), t[6] = r.name, t[7] = n, t[8] = u, t[9] = f, t[10] = p) : p = t[10], p;
167
166
  }
168
- function P(e) {
167
+ function B(e) {
169
168
  let t = Math.round(e);
170
169
  return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
171
170
  }
172
- function F(e) {
171
+ function V(e) {
173
172
  let t = i(12), { placeholder: n, file: r, glyph: a } = e, o;
174
- t[0] === a ? o = t[1] : (o = /* @__PURE__ */ C("span", {
173
+ t[0] === a ? o = t[1] : (o = /* @__PURE__ */ T("span", {
175
174
  "aria-hidden": !0,
176
175
  children: [a, " "]
177
176
  }), t[0] = a, t[1] = o);
178
177
  let s = r.name || n, c;
179
- t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */ C("span", {
178
+ t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */ T("span", {
180
179
  className: "text-foreground truncate",
181
180
  children: [o, s]
182
181
  }), t[2] = o, t[3] = s, t[4] = c) : c = t[4];
183
182
  let l = r.type || "file", u;
184
- t[5] === l ? u = t[6] : (u = /* @__PURE__ */ S("span", {
183
+ t[5] === l ? u = t[6] : (u = /* @__PURE__ */ w("span", {
185
184
  className: "truncate",
186
185
  children: l
187
186
  }), t[5] = l, t[6] = u);
188
187
  let d;
189
- return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */ C("div", {
188
+ return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */ T("div", {
190
189
  role: "img",
191
190
  "aria-label": n,
192
191
  title: r.name,
@@ -196,15 +195,15 @@ function F(e) {
196
195
  }
197
196
  //#endregion
198
197
  //#region src/lib/ComposerVisibility.ts
199
- function I(e, t) {
198
+ function H(e, t) {
200
199
  return e === "hidden" ? !1 : e === "before-interaction" ? !t : e !== "after-interaction" || t;
201
200
  }
202
201
  //#endregion
203
202
  //#region src/lib/ComposerSlashCommands.ts
204
- function L(e, t, n) {
205
- let r = z(e), i = t.filter((e) => le(e) && I(e.visibility, n));
203
+ function oe(e, t, n) {
204
+ let r = W(e), i = t.filter((e) => G(e) && H(e.visibility, n));
206
205
  return r ? i.map((e, t) => {
207
- let n = ue(r, e);
206
+ let n = ce(r, e);
208
207
  return n === null ? null : {
209
208
  command: e,
210
209
  rank: n,
@@ -212,52 +211,52 @@ function L(e, t, n) {
212
211
  };
213
212
  }).filter((e) => !!e).sort((e, t) => e.rank - t.rank || e.index - t.index).map((e) => e.command).slice(0, 10) : i.slice(0, 10);
214
213
  }
215
- function R(e, t) {
214
+ function U(e, t) {
216
215
  let n = e.toLowerCase();
217
- return t.find((e) => le(e) && (e.value.toLowerCase() === n || B(e).some((e) => e === n)));
216
+ return t.find((e) => G(e) && (e.value.toLowerCase() === n || se(e).some((e) => e === n)));
218
217
  }
219
- function z(e) {
218
+ function W(e) {
220
219
  return e.slice(1).toLowerCase();
221
220
  }
222
- function le(e) {
221
+ function G(e) {
223
222
  return e.availability !== "disabled";
224
223
  }
225
- function B(e) {
224
+ function se(e) {
226
225
  return (e.aliases ?? []).map((e) => e.toLowerCase());
227
226
  }
228
- function ue(e, t) {
229
- let n = t.value.toLowerCase(), r = B(t), i = [t.label.toLowerCase(), ...(t.searchTerms ?? []).map((e) => e.toLowerCase())];
227
+ function ce(e, t) {
228
+ let n = t.value.toLowerCase(), r = se(t), i = [t.label.toLowerCase(), ...(t.searchTerms ?? []).map((e) => e.toLowerCase())];
230
229
  return n === e ? 0 : r.some((t) => t === e) ? 1 : n.startsWith(e) ? 2 : r.some((t) => t.startsWith(e)) ? 3 : i.some((t) => t.startsWith(e)) ? 4 : null;
231
230
  }
232
231
  //#endregion
233
232
  //#region src/lib/ComposerTriggers.ts
234
- function V(e) {
235
- return e.map(w).join("|");
233
+ function le(e) {
234
+ return e.map(RegExp.escape).join("|");
236
235
  }
237
- function de(e) {
238
- return `(?:${V(e)})[A-Za-z0-9_:-]+`;
236
+ function ue(e) {
237
+ return `(?:${le(e)})[A-Za-z0-9_:-]+`;
239
238
  }
240
- function fe(e) {
241
- return `(?:${V(e)})[^\\s]+`;
239
+ function de(e) {
240
+ return `(?:${le(e)})[^\\s]+`;
242
241
  }
243
- function pe(e, t) {
242
+ function fe(e, t) {
244
243
  let n = [];
245
- return t.length > 0 && n.push(fe(t)), e.length > 0 && n.push(de(e)), n.length > 0 ? new RegExp(n.join("|"), "g") : null;
244
+ return t.length > 0 && n.push(de(t)), e.length > 0 && n.push(ue(e)), n.length > 0 ? new RegExp(n.join("|"), "g") : null;
246
245
  }
247
- function H(e, t) {
246
+ function pe(e, t) {
248
247
  return t.some((t) => e.startsWith(t));
249
248
  }
250
- function U(e) {
249
+ function K(e) {
251
250
  return `${e.trigger}${e.value}`;
252
251
  }
253
252
  //#endregion
254
253
  //#region src/lib/ComposerCore.ts
255
- function W({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandidates: r = [], commandTriggers: i = [], remoteImageUrls: a = [], isTaskRunning: o = !1, queueSubmissions: s = !1 } = {}) {
254
+ function q({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandidates: r = [], commandTriggers: i = [], remoteImageUrls: a = [], isTaskRunning: o = !1, queueSubmissions: s = !1 } = {}) {
256
255
  let c = e?.text ?? t, l = r.flatMap((e) => {
257
- let t = Pe("mention", U(e), c, { detail: e.detail });
256
+ let t = Pe("mention", K(e), c, { detail: e.detail });
258
257
  return t ? [t] : [];
259
258
  }), u = l.flatMap((e) => {
260
- let t = r.find((t) => U(t) === e.label);
259
+ let t = r.find((t) => K(t) === e.label);
261
260
  return t ? [{
262
261
  id: e.id,
263
262
  trigger: t.trigger,
@@ -266,13 +265,13 @@ function W({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandid
266
265
  persistsAs: t.persistsAs
267
266
  }] : [];
268
267
  }), d = e?.remoteImages ?? (e?.remoteImageUrls ?? a).map((e, t) => ({
269
- id: Z("remote-image", e, t),
268
+ id: $("remote-image", e, t),
270
269
  url: e
271
270
  }));
272
271
  return {
273
272
  text: c,
274
273
  cursor: c.length,
275
- elements: q(e?.elements ?? [...G(c, n, i), ...l]),
274
+ elements: X(e?.elements ?? [...ve(c, n, i), ...l]),
276
275
  mentionBindings: e?.mentionBindings ?? u,
277
276
  imageAttachments: [],
278
277
  remoteImages: d,
@@ -292,43 +291,43 @@ function me(e) {
292
291
  return e.text.length === 0 && e.imageAttachments.length === 0 && e.remoteImages.length === 0 && e.pendingPastes.length === 0;
293
292
  }
294
293
  function he(e, t, n) {
295
- return ve(e, t, n);
294
+ return J(e, t, n);
296
295
  }
297
296
  function ge(e, t) {
298
297
  if (!t || t < 1) return null;
299
- let n = ze(e.prompt);
298
+ let n = Z(e.prompt);
300
299
  return n <= t ? null : `Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`;
301
300
  }
302
301
  function _e(e, t, n) {
303
302
  let r = Oe(e.elements, e.text);
304
- r = [...r.filter((e) => e.kind !== "slash-command"), ...G(e.text, t, n)];
303
+ r = [...r.filter((e) => e.kind !== "slash-command"), ...ve(e.text, t, n)];
305
304
  let i = e.mentionBindings.filter((e) => r.some((t) => t.id === e.id)), a = e.imageAttachments.filter((e) => r.some((t) => t.kind === "image" && t.label === e.placeholder)), o = e.pendingPastes.filter((e) => r.some((t) => t.kind === "paste" && t.label === e.placeholder));
306
305
  return {
307
306
  ...e,
308
- elements: q(r),
307
+ elements: X(r),
309
308
  mentionBindings: i,
310
- imageAttachments: Le(a, e.remoteImages.length),
309
+ imageAttachments: ze(a, e.remoteImages.length),
311
310
  pendingPastes: o
312
311
  };
313
312
  }
314
- function ve(e, t, n) {
315
- let r = e.text.trim(), i = we(e.text, r, e.elements), a = Se(e.text, e.elements, e.pendingPastes), o = a.text, s = o.trim(), c = we(o, s, a.elements), l = e.imageAttachments.filter((t) => e.text.includes(t.placeholder)), u = Te(r, i), d = Ge({
313
+ function J(e, t, n) {
314
+ let r = e.text.trim(), i = we(e.text, r, e.elements), a = Se(e.text, e.elements, e.pendingPastes), o = a.text, s = o.trim(), c = we(o, s, a.elements), l = e.imageAttachments.filter((t) => e.text.includes(t.placeholder)), u = Te(r, i), d = Ke({
316
315
  text: u.text,
317
316
  elements: u.elements,
318
317
  mentionBindings: e.mentionBindings
319
- }), f = Ge({
318
+ }), f = Ke({
320
319
  text: s,
321
320
  elements: c,
322
321
  mentionBindings: e.mentionBindings
323
322
  });
324
323
  if (!s && l.length === 0 && e.remoteImages.length === 0) return null;
325
- let p = H(o, n) ? ye(s, c, t, n) : null, m = p?.prompt === void 0 ? null : p.args ? `${p.prompt}\n\n${Ge({
324
+ let p = pe(o, n) ? ye(s, c, t, n) : null, m = p?.prompt === void 0 ? null : p.args ? `${p.prompt}\n\n${Ke({
326
325
  text: p.args,
327
326
  elements: p.argsElements,
328
327
  mentionBindings: e.mentionBindings
329
328
  })}` : p.prompt, h = p?.prompt === void 0 ? null : p.args ? (() => {
330
329
  let t = Te(p.args, p.argsElements);
331
- return `${p.prompt}\n\n${Ge({
330
+ return `${p.prompt}\n\n${Ke({
332
331
  text: t.text,
333
332
  elements: t.elements,
334
333
  mentionBindings: e.mentionBindings
@@ -377,16 +376,16 @@ function ve(e, t, n) {
377
376
  mentionBindings: e.mentionBindings
378
377
  };
379
378
  }
380
- function G(e, t, n) {
379
+ function ve(e, t, n) {
381
380
  let r = [];
382
381
  if (n.length === 0) return r;
383
- let i = e.matchAll(RegExp(`(^|\\s)((?:${V(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`, "g"));
382
+ let i = e.matchAll(RegExp(`(^|\\s)((?:${le(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`, "g"));
384
383
  for (let e of i) {
385
- let n = R(e[3], t);
384
+ let n = U(e[3], t);
386
385
  if (!n) continue;
387
386
  let i = e[2], a = e.index + e[1].length;
388
387
  r.push({
389
- id: Z("slash-command", i, a),
388
+ id: $("slash-command", i, a),
390
389
  kind: "slash-command",
391
390
  label: i,
392
391
  range: {
@@ -399,9 +398,9 @@ function G(e, t, n) {
399
398
  return r;
400
399
  }
401
400
  function ye(e, t, n, r) {
402
- let i = e.match(RegExp(`^(?:${V(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));
401
+ let i = e.match(RegExp(`^(?:${le(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));
403
402
  if (!i) return null;
404
- let a = R(i[1], n);
403
+ let a = U(i[1], n);
405
404
  if (!a) return null;
406
405
  let o = i[2] ?? "";
407
406
  if (!o.trim()) return {
@@ -419,10 +418,10 @@ function ye(e, t, n, r) {
419
418
  }
420
419
  function be(e, t, n) {
421
420
  if (n.length === 0) return null;
422
- let r = e.match(RegExp(`^(?:${V(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));
423
- return !r || R(r[1], t) || K(r[1]) ? null : r[1];
421
+ let r = e.match(RegExp(`^(?:${le(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));
422
+ return !r || U(r[1], t) || xe(r[1]) ? null : r[1];
424
423
  }
425
- var xe = /* @__PURE__ */ new Set([
424
+ var Y = /* @__PURE__ */ new Set([
426
425
  "Applications",
427
426
  "Library",
428
427
  "System",
@@ -441,8 +440,8 @@ var xe = /* @__PURE__ */ new Set([
441
440
  "var",
442
441
  "workspace"
443
442
  ]);
444
- function K(e) {
445
- return xe.has(e);
443
+ function xe(e) {
444
+ return Y.has(e);
446
445
  }
447
446
  function Se(e, t, n) {
448
447
  if (n.length === 0 || t.length === 0) return {
@@ -455,7 +454,7 @@ function Se(e, t, n) {
455
454
  t.push(e.content), r.set(e.placeholder, t);
456
455
  }
457
456
  let i = "", a = [], o = 0;
458
- for (let n of q(t)) {
457
+ for (let n of X(t)) {
459
458
  let t = Math.min(n.range.start, e.length), s = Math.min(n.range.end, e.length);
460
459
  if (t > s) continue;
461
460
  t > o && (i += e.slice(o, t));
@@ -498,12 +497,12 @@ function we(e, t, n) {
498
497
  }));
499
498
  }
500
499
  function Te(e, t) {
501
- let n = q(t.filter((e) => e.kind === "image"));
500
+ let n = X(t.filter((e) => e.kind === "image"));
502
501
  for (let t of n.toReversed()) e = De(e, t.range, "");
503
502
  let r = (e) => n.reduce((t, n) => t + Math.max(0, Math.min(e, n.range.end) - n.range.start), 0);
504
503
  return {
505
504
  text: e,
506
- elements: q(t.filter((e) => e.kind !== "image")).map((e) => ({
505
+ elements: X(t.filter((e) => e.kind !== "image")).map((e) => ({
507
506
  ...e,
508
507
  range: {
509
508
  start: e.range.start - r(e.range.start),
@@ -520,7 +519,7 @@ function De(e, t, n) {
520
519
  }
521
520
  function Oe(e, t) {
522
521
  let n = /* @__PURE__ */ new Map();
523
- return q(e).map((e) => {
522
+ return X(e).map((e) => {
524
523
  let r = ke(t, e.label);
525
524
  if (r.length === 0) return null;
526
525
  let i = `${e.kind}:${e.label}`, a = n.get(i) ?? [], o = Ae(r, e, a) ?? je(r, e, a) ?? Me(r, e);
@@ -554,7 +553,7 @@ function Ne(e, t) {
554
553
  function Pe(e, t, n, r = {}) {
555
554
  let i = n.indexOf(t);
556
555
  return i === -1 ? null : {
557
- id: Z(e, t, i),
556
+ id: $(e, t, i),
558
557
  kind: e,
559
558
  label: t,
560
559
  range: {
@@ -564,7 +563,7 @@ function Pe(e, t, n, r = {}) {
564
563
  detail: r.detail
565
564
  };
566
565
  }
567
- function q(e) {
566
+ function X(e) {
568
567
  return [...e].sort((e, t) => e.range.start - t.range.start);
569
568
  }
570
569
  var Fe = {
@@ -572,87 +571,87 @@ var Fe = {
572
571
  video: "Video",
573
572
  audio: "Audio"
574
573
  };
575
- function J(e) {
574
+ function Ie(e) {
576
575
  let t = e.type.split("/")[0];
577
576
  return t === "image" || t === "video" || t === "audio" ? t : null;
578
577
  }
579
- function Y(e) {
578
+ function Le(e) {
580
579
  return e === "video" || e === "audio" ? e : "image";
581
580
  }
582
- function Ie(e, t) {
581
+ function Re(e, t) {
583
582
  return `[${Fe[e]} #${t}]`;
584
583
  }
585
- function Le(e, t) {
584
+ function ze(e, t) {
586
585
  return e.map((e, n) => ({
587
586
  ...e,
588
- placeholder: Ie(e.media, t + n + 1)
587
+ placeholder: Re(e.media, t + n + 1)
589
588
  }));
590
589
  }
591
- function Re(e, t) {
590
+ function Be(e, t) {
592
591
  if (!t) return null;
593
592
  let n = e.remoteImages.findIndex((e) => e.id === t);
594
593
  return n === -1 ? null : n;
595
594
  }
596
- function ze(e) {
595
+ function Z(e) {
597
596
  return Array.from(e).length;
598
597
  }
599
- function Be(e) {
598
+ function Ve(e) {
600
599
  let t = Te(e.text, e.elements);
601
600
  return {
602
601
  text: t.text,
603
- elements: et(t.elements),
604
- mentionBindings: tt(e.mentionBindings),
602
+ elements: tt(t.elements),
603
+ mentionBindings: nt(e.mentionBindings),
605
604
  remoteImages: e.remoteImages.map((e) => ({ ...e })),
606
- pendingPastes: nt(e.pendingPastes)
605
+ pendingPastes: rt(e.pendingPastes)
607
606
  };
608
607
  }
609
- function Ve(e, t) {
608
+ function He(e, t) {
610
609
  return {
611
610
  persistedPrompt: t,
612
611
  remoteImages: e.remoteImages.map((e) => ({ ...e })),
613
- pendingPastes: nt(e.pendingPastes)
612
+ pendingPastes: rt(e.pendingPastes)
614
613
  };
615
614
  }
616
- function He(e, t) {
617
- let n = Ve(e, t);
615
+ function Ue(e, t) {
616
+ let n = He(e, t);
618
617
  return !n.persistedPrompt.trim() && n.remoteImages.length === 0 && n.pendingPastes.length === 0 ? e.history : [n, ...e.history].slice(0, 8);
619
618
  }
620
- function Ue({ text: e, slashCommands: t = [], commandTriggers: n = [], mentionCandidates: r = [] }) {
621
- let i = X(e, r), a = Ze(i.text, i.elements, i.protectedRanges, t, r);
622
- return Be(_e(W({
619
+ function We({ text: e, slashCommands: t = [], commandTriggers: n = [], mentionCandidates: r = [] }) {
620
+ let i = Q(e, r), a = Qe(i.text, i.elements, i.protectedRanges, t, r);
621
+ return Ve(_e(q({
623
622
  initialDraft: {
624
623
  text: i.text,
625
- elements: q([...i.elements, ...a.elements]),
624
+ elements: X([...i.elements, ...a.elements]),
626
625
  mentionBindings: [...i.mentionBindings, ...a.mentionBindings]
627
626
  },
628
627
  slashCommands: t
629
628
  }), t, n));
630
629
  }
631
- function We({ source: e, slashCommands: t = [], mentionCandidates: n = [] }) {
632
- let r = Ue({
630
+ function Ge({ source: e, slashCommands: t = [], mentionCandidates: n = [] }) {
631
+ let r = We({
633
632
  text: e.persistedPrompt,
634
633
  slashCommands: t,
635
634
  mentionCandidates: n
636
635
  }), i = [...e.pendingPastes.flatMap((e) => {
637
- let t = Pe("paste", e.placeholder, r.text ?? "", { detail: `${ze(e.content)} chars` });
636
+ let t = Pe("paste", e.placeholder, r.text ?? "", { detail: `${Z(e.content)} chars` });
638
637
  return t ? [t] : [];
639
638
  })];
640
639
  return {
641
640
  ...r,
642
- elements: q([...r.elements ?? [], ...i]),
641
+ elements: X([...r.elements ?? [], ...i]),
643
642
  remoteImages: e.remoteImages.map((e) => ({ ...e })),
644
- pendingPastes: nt(e.pendingPastes)
643
+ pendingPastes: rt(e.pendingPastes)
645
644
  };
646
645
  }
647
- function Ge(e) {
648
- let t = e.text ?? "", n = q(e.elements ?? []).map((t) => $e(t, e)).filter((e) => !!e).sort((e, t) => t.range.start - e.range.start);
646
+ function Ke(e) {
647
+ let t = e.text ?? "", n = X(e.elements ?? []).map((t) => et(t, e)).filter((e) => !!e).sort((e, t) => t.range.start - e.range.start);
649
648
  for (let e of n) t = De(t, e.range, e.text);
650
649
  return t;
651
650
  }
652
- function Ke(e) {
651
+ function qe(e) {
653
652
  return e.startsWith("composer-text-link://") ? decodeURIComponent(e.replace(/^composer-text-link:\/\//, "")) : e;
654
653
  }
655
- function X(e, t) {
654
+ function Q(e, t) {
656
655
  let n = [], i = [], a = [], o = "";
657
656
  for (let s of r(e)) {
658
657
  if (s.kind === "inline-code" || s.kind === "code-block") {
@@ -667,9 +666,9 @@ function X(e, t) {
667
666
  o += s.source;
668
667
  continue;
669
668
  }
670
- let e = s.label, r = s.href, c = Ke(r), l = qe(e, t), u = l ? U(l) : e, d = o.length;
669
+ let e = s.label, r = s.href, c = qe(r), l = Je(e, t), u = l ? K(l) : e, d = o.length;
671
670
  if (o += u, l) {
672
- let e = Z("mention", u, d);
671
+ let e = $("mention", u, d);
673
672
  n.push({
674
673
  id: e,
675
674
  kind: "mention",
@@ -687,7 +686,7 @@ function X(e, t) {
687
686
  persistsAs: l.persistsAs
688
687
  });
689
688
  } else n.push({
690
- id: Z("link", u, d),
689
+ id: $("link", u, d),
691
690
  kind: "link",
692
691
  label: u,
693
692
  range: {
@@ -704,30 +703,30 @@ function X(e, t) {
704
703
  protectedRanges: a
705
704
  };
706
705
  }
707
- function qe(e, t) {
708
- return t.find((t) => U(t) === e) ?? null;
706
+ function Je(e, t) {
707
+ return t.find((t) => K(t) === e) ?? null;
709
708
  }
710
- function Je(e) {
709
+ function Ye(e) {
711
710
  return [...new Set(e.map((e) => e.trigger).filter(Boolean))].sort((e, t) => t.length - e.length);
712
711
  }
713
- function Ye(e) {
714
- let t = Je(e);
715
- return t.length === 0 ? null : RegExp(`(?:${t.map(w).join("|")})[A-Za-z0-9_:-]+`, "g");
712
+ function Xe(e) {
713
+ let t = Ye(e);
714
+ return t.length === 0 ? null : RegExp(`(?:${le(t)})[A-Za-z0-9_:-]+`, "g");
716
715
  }
717
- function Xe(e, t) {
718
- return Je(t).find((t) => e.startsWith(t))?.length ?? 0;
716
+ function Ze(e, t) {
717
+ return Ye(t).find((t) => e.startsWith(t))?.length ?? 0;
719
718
  }
720
- function Ze(e, t, n, r, i) {
719
+ function Qe(e, t, n, r, i) {
721
720
  let a = [], o = [], s = [], c = (r, i) => {
722
721
  let a = r + i.length;
723
- return (r === 0 || /\s/.test(e[r - 1] ?? "")) && !Qe(r, i, t) && !s.some((e) => r < e.end && a > e.start) && !n.some((e) => r < e.end && a > e.start);
724
- }, l = [...i].sort((e, t) => U(t).length - U(e).length);
722
+ return (r === 0 || /\s/.test(e[r - 1] ?? "")) && !$e(r, i, t) && !s.some((e) => r < e.end && a > e.start) && !n.some((e) => r < e.end && a > e.start);
723
+ }, l = [...i].sort((e, t) => K(t).length - K(e).length);
725
724
  for (let t of l) {
726
- let n = U(t);
725
+ let n = K(t);
727
726
  if (n) for (let r = e.indexOf(n); r !== -1; r = e.indexOf(n, r + n.length)) {
728
727
  let i = r + n.length;
729
728
  if (/[\w-]/.test(e[i] ?? "") || !c(r, n)) continue;
730
- let l = Z("mention", n, r);
729
+ let l = $("mention", n, r);
731
730
  s.push({
732
731
  start: r,
733
732
  end: i
@@ -749,16 +748,16 @@ function Ze(e, t, n, r, i) {
749
748
  });
750
749
  }
751
750
  }
752
- let u = Ye(r);
751
+ let u = Xe(r);
753
752
  for (let t of u ? e.matchAll(u) : []) {
754
753
  let e = t.index ?? 0, n = t[0];
755
754
  if (!c(e, n)) continue;
756
- let i = R(n.slice(Xe(n, r)), r);
755
+ let i = U(n.slice(Ze(n, r)), r);
757
756
  i && (s.push({
758
757
  start: e,
759
758
  end: e + n.length
760
759
  }), a.push({
761
- id: Z("slash-command", n, e),
760
+ id: $("slash-command", n, e),
762
761
  kind: "slash-command",
763
762
  label: n,
764
763
  range: {
@@ -773,11 +772,11 @@ function Ze(e, t, n, r, i) {
773
772
  mentionBindings: o
774
773
  };
775
774
  }
776
- function Qe(e, t, n) {
775
+ function $e(e, t, n) {
777
776
  let r = e + t.length;
778
777
  return n.some((t) => e < t.range.end && r > t.range.start);
779
778
  }
780
- function $e(e, n) {
779
+ function et(e, n) {
781
780
  if (e.kind === "mention") {
782
781
  let t = (n.mentionBindings ?? []).find((t) => t.id === e.id || `${t.trigger}${t.value}` === e.label);
783
782
  return t ? {
@@ -790,7 +789,7 @@ function $e(e, n) {
790
789
  text: t(e.label, e.detail)
791
790
  } : null;
792
791
  }
793
- function et(e) {
792
+ function tt(e) {
794
793
  return e.map((e) => {
795
794
  let t = {
796
795
  ...e,
@@ -802,13 +801,13 @@ function et(e) {
802
801
  } : t;
803
802
  });
804
803
  }
805
- function tt(e) {
804
+ function nt(e) {
806
805
  return e.map((e) => ({ ...e }));
807
806
  }
808
- function nt(e) {
807
+ function rt(e) {
809
808
  return e.map((e) => ({ ...e }));
810
809
  }
811
- function rt(e, t, n, r = 1) {
810
+ function it(e, t, n, r = 1) {
812
811
  if (t.length === 0) return null;
813
812
  let i = t.toLowerCase(), a = e.map((e, t) => ({
814
813
  index: t,
@@ -817,88 +816,88 @@ function rt(e, t, n, r = 1) {
817
816
  if (a.length === 0) return null;
818
817
  if (n === null) return a[0];
819
818
  let o = a.findIndex((e) => e.index === n);
820
- return o === -1 ? a[0] : a[st(o + r, a.length)];
819
+ return o === -1 ? a[0] : a[ct(o + r, a.length)];
821
820
  }
822
- function it(e, t, n) {
821
+ function at(e, t, n) {
823
822
  return n === -1 ? t === 0 || !e.slice(0, t).includes("\n") : t === e.length || !e.slice(t).includes("\n");
824
823
  }
825
- function at(e, t) {
826
- let n = ct(e, t);
827
- for (; n > 0 && ht(dt(e, n));) n = lt(e, n);
824
+ function ot(e, t) {
825
+ let n = lt(e, t);
826
+ for (; n > 0 && gt(ft(e, n));) n = ut(e, n);
828
827
  if (n === 0) return 0;
829
- let r = vt(dt(e, n));
830
- if (r === "cjk") return lt(e, n);
831
- for (; n > 0 && vt(dt(e, n)) === r;) n = lt(e, n);
828
+ let r = yt(ft(e, n));
829
+ if (r === "cjk") return ut(e, n);
830
+ for (; n > 0 && yt(ft(e, n)) === r;) n = ut(e, n);
832
831
  return n;
833
832
  }
834
- function ot(e, t) {
835
- let n = ct(e, t);
836
- for (; n < e.length && ht(ft(e, n));) n = ut(e, n);
833
+ function st(e, t) {
834
+ let n = lt(e, t);
835
+ for (; n < e.length && gt(pt(e, n));) n = dt(e, n);
837
836
  if (n >= e.length) return e.length;
838
- let r = vt(ft(e, n));
839
- if (r === "cjk") return ut(e, n);
840
- for (; n < e.length && vt(ft(e, n)) === r;) n = ut(e, n);
837
+ let r = yt(pt(e, n));
838
+ if (r === "cjk") return dt(e, n);
839
+ for (; n < e.length && yt(pt(e, n)) === r;) n = dt(e, n);
841
840
  return n;
842
841
  }
843
- function st(e, t) {
842
+ function ct(e, t) {
844
843
  return (e % t + t) % t;
845
844
  }
846
- function Z(e, t, n) {
845
+ function $(e, t, n) {
847
846
  return `${e}:${n}:${t}`;
848
847
  }
849
- function ct(e, t) {
850
- let n = Math.max(0, Math.min(t, e.length));
851
- return n > 0 && n < e.length && mt(e.charCodeAt(n)) && --n, n;
852
- }
853
848
  function lt(e, t) {
854
- let n = t - 1;
855
- return n > 0 && mt(e.charCodeAt(n)) ? n - 1 : Math.max(n, 0);
849
+ let n = Math.max(0, Math.min(t, e.length));
850
+ return n > 0 && n < e.length && ht(e.charCodeAt(n)) && --n, n;
856
851
  }
857
852
  function ut(e, t) {
858
- let n = t + (pt(e.charCodeAt(t)) ? 2 : 1);
859
- return Math.min(n, e.length);
853
+ let n = t - 1;
854
+ return n > 0 && ht(e.charCodeAt(n)) ? n - 1 : Math.max(n, 0);
860
855
  }
861
856
  function dt(e, t) {
862
- let n = lt(e, t);
863
- return e.slice(n, t);
857
+ let n = t + (mt(e.charCodeAt(t)) ? 2 : 1);
858
+ return Math.min(n, e.length);
864
859
  }
865
860
  function ft(e, t) {
866
- return e.slice(t, ut(e, t));
861
+ let n = ut(e, t);
862
+ return e.slice(n, t);
867
863
  }
868
- function pt(e) {
869
- return e >= 55296 && e <= 56319;
864
+ function pt(e, t) {
865
+ return e.slice(t, dt(e, t));
870
866
  }
871
867
  function mt(e) {
872
- return e >= 56320 && e <= 57343;
868
+ return e >= 55296 && e <= 56319;
873
869
  }
874
870
  function ht(e) {
875
- return /\s/u.test(e);
871
+ return e >= 56320 && e <= 57343;
876
872
  }
877
873
  function gt(e) {
878
- return !_t(e) && /[\p{Letter}\p{Number}_]/u.test(e);
874
+ return /\s/u.test(e);
879
875
  }
880
876
  function _t(e) {
881
- return /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e);
877
+ return !vt(e) && /[\p{Letter}\p{Number}_]/u.test(e);
882
878
  }
883
879
  function vt(e) {
884
- return _t(e) ? "cjk" : gt(e) ? "word" : "separator";
880
+ return /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e);
881
+ }
882
+ function yt(e) {
883
+ return vt(e) ? "cjk" : _t(e) ? "word" : "separator";
885
884
  }
886
885
  //#endregion
887
886
  //#region src/lib/ComposerDraft.ts
888
- var yt = "composer-draft:v1:";
889
- function bt(e) {
890
- let t = localStorage.getItem(`${yt}${e}`);
887
+ var bt = "composer-draft:v1:";
888
+ function xt(e) {
889
+ let t = localStorage.getItem(`${bt}${e}`);
891
890
  if (!t) return null;
892
891
  try {
893
892
  let e = JSON.parse(t);
894
- return Ct(e) ? e : null;
893
+ return wt(e) ? e : null;
895
894
  } catch {
896
895
  return null;
897
896
  }
898
897
  }
899
- function xt(e, t) {
900
- let n = `${yt}${e}`;
901
- if (!t || St(t)) {
898
+ function St(e, t) {
899
+ let n = `${bt}${e}`;
900
+ if (!t || Ct(t)) {
902
901
  localStorage.removeItem(n);
903
902
  return;
904
903
  }
@@ -906,26 +905,22 @@ function xt(e, t) {
906
905
  localStorage.setItem(n, JSON.stringify(t));
907
906
  } catch {}
908
907
  }
909
- function St(e) {
908
+ function Ct(e) {
910
909
  return !e.persistedPrompt.trim() && e.remoteImages.length === 0 && e.pendingPastes.length === 0;
911
910
  }
912
- function Ct(e) {
913
- return wt(e) && Object.keys(e).every((e) => [
911
+ function wt(e) {
912
+ return Tt(e) && Object.keys(e).every((e) => [
914
913
  "persistedPrompt",
915
914
  "remoteImages",
916
915
  "pendingPastes"
917
916
  ].includes(e)) && typeof e.persistedPrompt == "string" && Array.isArray(e.remoteImages) && Array.isArray(e.pendingPastes);
918
917
  }
919
- function wt(e) {
918
+ function Tt(e) {
920
919
  return typeof e == "object" && !!e;
921
920
  }
922
921
  //#endregion
923
922
  //#region src/lib/ComposerRegistry.tsx
924
- var Tt = Symbol.for("composer.registry.trigger"), Et = Symbol.for("composer.registry.command"), Dt = Symbol.for("composer.registry.mention");
925
- function Ot(e) {
926
- return null;
927
- }
928
- Ot.role = Tt;
923
+ var Et = Symbol.for("composer.registry.trigger"), Dt = Symbol.for("composer.registry.command"), Ot = Symbol.for("composer.registry.mention");
929
924
  function kt(e) {
930
925
  return null;
931
926
  }
@@ -935,6 +930,10 @@ function At(e) {
935
930
  }
936
931
  At.role = Dt;
937
932
  function jt(e) {
933
+ return null;
934
+ }
935
+ jt.role = Ot;
936
+ function Mt(e) {
938
937
  let t = [], n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
939
938
  for (let s of u.toArray(e)) {
940
939
  if (!p(s)) {
@@ -945,8 +944,8 @@ function jt(e) {
945
944
  p(s) && o(s.props.children);
946
945
  continue;
947
946
  }
948
- if (It(s.type, Tt)) {
949
- p(s) && Pt(s.props, {
947
+ if (Lt(s.type, Et)) {
948
+ p(s) && Ft(s.props, {
950
949
  slashCommands: t,
951
950
  mentionCandidates: n,
952
951
  commandTriggers: r,
@@ -954,7 +953,7 @@ function jt(e) {
954
953
  });
955
954
  continue;
956
955
  }
957
- if (It(s.type, Et) || It(s.type, Dt)) throw Error("Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.");
956
+ if (Lt(s.type, Dt) || Lt(s.type, Ot)) throw Error("Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.");
958
957
  a = !0;
959
958
  }
960
959
  };
@@ -966,29 +965,29 @@ function jt(e) {
966
965
  hasLayoutChildren: a
967
966
  };
968
967
  }
969
- function Mt(e) {
968
+ function Nt(e) {
970
969
  return JSON.stringify([
971
- e.slashCommands.map(Nt),
972
- e.mentionCandidates.map(Nt),
970
+ e.slashCommands.map(Pt),
971
+ e.mentionCandidates.map(Pt),
973
972
  e.commandTriggers,
974
973
  e.mentionTriggers
975
974
  ]);
976
975
  }
977
- function Nt(e) {
976
+ function Pt(e) {
978
977
  let { icon: t, ...n } = e;
979
978
  return n;
980
979
  }
981
- function Pt(e, t) {
980
+ function Ft(e, t) {
982
981
  let { trigger: n } = e;
983
982
  for (let r of u.toArray(e.children)) if (p(r)) {
984
983
  if (r.type === d) {
985
- p(r) && Pt({
984
+ p(r) && Ft({
986
985
  trigger: n,
987
986
  children: r.props.children
988
987
  }, t);
989
988
  continue;
990
989
  }
991
- if (It(r.type, Et)) {
990
+ if (Lt(r.type, Dt)) {
992
991
  if (t.mentionTriggers.has(n)) throw Error(`Composer.Trigger "${n}" already holds mentions; a trigger carries either commands or mentions, not both.`);
993
992
  t.commandTriggers.add(n), p(r) && t.slashCommands.push({
994
993
  ...r.props,
@@ -997,15 +996,15 @@ function Pt(e, t) {
997
996
  });
998
997
  continue;
999
998
  }
1000
- if (It(r.type, Dt)) {
999
+ if (Lt(r.type, Ot)) {
1001
1000
  if (t.commandTriggers.has(n)) throw Error(`Composer.Trigger "${n}" already holds commands; a trigger carries either commands or mentions, not both.`);
1002
- t.mentionTriggers.add(n), p(r) && t.mentionCandidates.push(Ft(r.props, n));
1001
+ t.mentionTriggers.add(n), p(r) && t.mentionCandidates.push(It(r.props, n));
1003
1002
  continue;
1004
1003
  }
1005
1004
  throw Error(`<Composer.Trigger trigger="${n}"> accepts only <Composer.Command> and <Composer.Mention> children; wrap them in a fragment rather than a component, which the registry cannot see through.`);
1006
1005
  }
1007
1006
  }
1008
- function Ft(e, t) {
1007
+ function It(e, t) {
1009
1008
  return {
1010
1009
  id: e.id,
1011
1010
  trigger: t,
@@ -1019,43 +1018,341 @@ function Ft(e, t) {
1019
1018
  visibility: e.visibility
1020
1019
  };
1021
1020
  }
1022
- function It(e, t) {
1021
+ function Lt(e, t) {
1023
1022
  return typeof e == "function" && "role" in e && e.role === t;
1024
1023
  }
1025
1024
  //#endregion
1026
1025
  //#region src/lib/ComposerSuggestions.ts
1027
- function Lt(e, t, n, r) {
1028
- return [...L(e.query, t.filter((t) => t.trigger === e.trigger), r), ...Rt(e.query, n.filter((t) => t.trigger === e.trigger), r)];
1026
+ function Rt(e, t, n, r) {
1027
+ return [...oe(e.query, t.filter((t) => t.trigger === e.trigger), r), ...zt(e.query, n.filter((t) => t.trigger === e.trigger), r)];
1029
1028
  }
1030
- function Rt(e, t, n) {
1029
+ function zt(e, t, n) {
1031
1030
  let r = e.slice(1).toLowerCase();
1032
- return t.filter((e) => I(e.visibility, n) && (e.label.toLowerCase().includes(r) || U(e).slice(1).toLowerCase().includes(r))).slice(0, 10);
1031
+ return t.filter((e) => H(e.visibility, n) && (e.label.toLowerCase().includes(r) || K(e).slice(1).toLowerCase().includes(r))).slice(0, 10);
1032
+ }
1033
+ //#endregion
1034
+ //#region src/lib/dictation/ComposerDictationContext.ts
1035
+ var Bt = f(null);
1036
+ function Vt(e) {
1037
+ let t = e === void 0 ? "useComposerDictation" : e;
1038
+ M(t);
1039
+ let n = h(Bt);
1040
+ if (!n) throw Error(`${t} needs the dictation prop of Composer.Root.`);
1041
+ return n;
1042
+ }
1043
+ //#endregion
1044
+ //#region src/lib/dictation/ComposerDictationParts.tsx
1045
+ function Ht(e, t) {
1046
+ return typeof e == "function" ? (n) => e(n, t) : e;
1047
+ }
1048
+ function Ut(e) {
1049
+ let t = i(15), n, r, o;
1050
+ t[0] === e ? (n = t[1], r = t[2], o = t[3]) : ({render: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o);
1051
+ let { disabled: s } = M("Composer.Dictate"), { state: c, start: l, stop: u } = Vt("Composer.Dictate"), d = c.status === "recording", f = (c.status === "idle" || c.status === "failed") && n !== !0 && !s, p = c.status, m = c.status === "finishing" ? c.end : void 0, h = !d && !f, g = d ? u : l, _;
1052
+ t[4] !== o || t[5] !== c ? (_ = Ht(o, c), t[4] = o, t[5] = c, t[6] = _) : _ = t[6];
1053
+ let v;
1054
+ return t[7] !== r || t[8] !== d || t[9] !== c.status || t[10] !== m || t[11] !== h || t[12] !== g || t[13] !== _ ? (v = /* @__PURE__ */ w(a, {
1055
+ ...r,
1056
+ "data-status": p,
1057
+ "data-end": m,
1058
+ "aria-pressed": d,
1059
+ disabled: h,
1060
+ onClick: g,
1061
+ render: _
1062
+ }), t[7] = r, t[8] = d, t[9] = c.status, t[10] = m, t[11] = h, t[12] = g, t[13] = _, t[14] = v) : v = t[14], v;
1063
+ }
1064
+ function Wt(e) {
1065
+ let t = i(13), n, r, o;
1066
+ t[0] === e ? (n = t[1], r = t[2], o = t[3]) : ({render: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o);
1067
+ let { state: s, cancel: c } = Vt("Composer.CancelDictation"), l = s.status === "starting" || s.status === "recording" || s.status === "finishing", u = s.status, d = !l || n === !0, f;
1068
+ t[4] !== o || t[5] !== s ? (f = Ht(o, s), t[4] = o, t[5] = s, t[6] = f) : f = t[6];
1069
+ let p;
1070
+ return t[7] !== c || t[8] !== r || t[9] !== s.status || t[10] !== d || t[11] !== f ? (p = /* @__PURE__ */ w(a, {
1071
+ ...r,
1072
+ "data-status": u,
1073
+ disabled: d,
1074
+ onClick: c,
1075
+ render: f
1076
+ }), t[7] = c, t[8] = r, t[9] = s.status, t[10] = d, t[11] = f, t[12] = p) : p = t[12], p;
1077
+ }
1078
+ //#endregion
1079
+ //#region src/lib/dictation/DictationError.ts
1080
+ var Gt = class extends Error {
1081
+ code;
1082
+ constructor(e, t) {
1083
+ super(`Dictation failed: ${e}`, t), this.name = "DictationError", this.code = e;
1084
+ }
1085
+ }, Kt = class {
1086
+ #e = "unknown";
1087
+ subscribe = (e) => {
1088
+ let t = new AbortController();
1089
+ return navigator.permissions.query({ name: "microphone" }).then((n) => {
1090
+ if (t.signal.aborted) return;
1091
+ let r = () => {
1092
+ this.#e = n.state, e();
1093
+ };
1094
+ r(), n.addEventListener("change", r, { signal: t.signal });
1095
+ }, (e) => {
1096
+ if (!(e instanceof TypeError)) throw e;
1097
+ }), () => {
1098
+ t.abort();
1099
+ };
1100
+ };
1101
+ getSnapshot = () => this.#e;
1102
+ }, qt = /* @__PURE__ */ new Map([
1103
+ ["NotAllowedError", "permission-denied"],
1104
+ ["NotFoundError", "no-microphone"],
1105
+ ["NotReadableError", "microphone-in-use"]
1106
+ ]), Jt = class e {
1107
+ #e = { status: "starting" };
1108
+ #t = /* @__PURE__ */ new Set();
1109
+ #n;
1110
+ constructor(e) {
1111
+ this.#n = e;
1112
+ }
1113
+ static start(t) {
1114
+ let n = new e(t);
1115
+ return n.#r(), n;
1116
+ }
1117
+ subscribe = (e) => (this.#t.add(e), () => {
1118
+ this.#t.delete(e);
1119
+ });
1120
+ getSnapshot = () => this.#e;
1121
+ stop() {
1122
+ let e = this.#e;
1123
+ if (e.status === "starting") {
1124
+ this.cancel();
1125
+ return;
1126
+ }
1127
+ e.status === "recording" && (this.#a({
1128
+ ...e,
1129
+ status: "stopping"
1130
+ }), e.recorder.stop());
1131
+ }
1132
+ cancel() {
1133
+ this.#i({ status: "ended" });
1134
+ }
1135
+ async #r() {
1136
+ let e;
1137
+ try {
1138
+ e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
1139
+ } catch (e) {
1140
+ let t = e instanceof DOMException ? qt.get(e.name) : void 0;
1141
+ if (!t) throw e;
1142
+ this.#i({
1143
+ status: "failed",
1144
+ error: new Gt(t, { cause: e })
1145
+ });
1146
+ return;
1147
+ }
1148
+ if (this.#e.status !== "starting") {
1149
+ for (let t of e.getTracks()) t.stop();
1150
+ return;
1151
+ }
1152
+ let t = new MediaRecorder(e), n = [];
1153
+ t.addEventListener("dataavailable", (e) => {
1154
+ n.push(e.data);
1155
+ }), t.addEventListener("stop", () => {
1156
+ this.#e.status === "stopping" && (this.#i({ status: "ended" }), this.#n(new Blob(n, { type: t.mimeType })));
1157
+ }), t.addEventListener("error", (e) => {
1158
+ this.#i({
1159
+ status: "failed",
1160
+ error: new Gt("interrupted", { cause: e })
1161
+ });
1162
+ });
1163
+ for (let t of e.getAudioTracks()) t.addEventListener("ended", () => {
1164
+ this.#i({
1165
+ status: "failed",
1166
+ error: new Gt("interrupted")
1167
+ });
1168
+ });
1169
+ t.start(), this.#a({
1170
+ status: "recording",
1171
+ stream: e,
1172
+ recorder: t
1173
+ });
1174
+ }
1175
+ #i(e) {
1176
+ let t = this.#e;
1177
+ if (!(t.status === "ended" || t.status === "failed")) {
1178
+ if (t.status !== "starting") {
1179
+ t.recorder.state !== "inactive" && t.recorder.stop();
1180
+ for (let e of t.stream.getTracks()) e.stop();
1181
+ }
1182
+ this.#a(e);
1183
+ }
1184
+ }
1185
+ #a(e) {
1186
+ this.#e = e;
1187
+ for (let e of this.#t) e();
1188
+ }
1189
+ }, Yt = () => () => void 0, Xt = { status: "ended" }, Zt = () => Xt, Qt = () => "unknown";
1190
+ function $t(e) {
1191
+ let t = i(47), { dictation: n, disabled: r, insertTranscript: a, submitDraft: o } = e, s = "MediaRecorder" in globalThis && "mediaDevices" in navigator, c = n !== void 0, [l] = x(en), u = ee(c && s ? l.subscribe : Yt, l.getSnapshot, Qt), [d, f] = x(null), p = ee(d ? d.subscribe : Yt, d ? d.getSnapshot : Zt, Zt), [h, v] = x(0), [y, S] = x("insert"), te = b("insert"), C = b(null), w;
1192
+ t[0] !== n || t[1] !== a || t[2] !== o ? (w = {
1193
+ dictation: n,
1194
+ insertTranscript: a,
1195
+ submitDraft: o
1196
+ }, t[0] = n, t[1] = a, t[2] = o, t[3] = w) : w = t[3];
1197
+ let T = b(w), E;
1198
+ t[4] !== n || t[5] !== a || t[6] !== o ? (E = () => {
1199
+ T.current = {
1200
+ dictation: n,
1201
+ insertTranscript: a,
1202
+ submitDraft: o
1203
+ };
1204
+ }, t[4] = n, t[5] = a, t[6] = o, t[7] = E) : E = t[7], _(E);
1205
+ let D, O;
1206
+ t[8] === Symbol.for("react.memo_cache_sentinel") ? (D = async (e, t) => {
1207
+ let n = new AbortController();
1208
+ C.current = n;
1209
+ try {
1210
+ let { text: e } = await t.transcribe(t.clip, { signal: n.signal });
1211
+ if (!n.signal.aborted) {
1212
+ let t = e.trim();
1213
+ t && T.current.insertTranscript(t), te.current === "send" && T.current.submitDraft();
1214
+ }
1215
+ return {
1216
+ attempt: t.attempt,
1217
+ failure: null
1218
+ };
1219
+ } catch (e) {
1220
+ let r = e;
1221
+ return n.signal.aborted ? {
1222
+ attempt: t.attempt,
1223
+ failure: null
1224
+ } : {
1225
+ attempt: t.attempt,
1226
+ failure: new Gt("transcription-failed", { cause: r })
1227
+ };
1228
+ }
1229
+ }, O = {
1230
+ attempt: 0,
1231
+ failure: null
1232
+ }, t[8] = D, t[9] = O) : (D = t[8], O = t[9]);
1233
+ let [k, A, ne] = g(D, O), re, j;
1234
+ t[10] !== r || t[11] !== c || t[12] !== d ? (re = () => {
1235
+ (r || !c) && (d?.cancel(), C.current?.abort());
1236
+ }, j = [
1237
+ r,
1238
+ c,
1239
+ d
1240
+ ], t[10] = r, t[11] = c, t[12] = d, t[13] = re, t[14] = j) : (re = t[13], j = t[14]), _(re, j);
1241
+ let ie, ae;
1242
+ if (t[15] === d ? (ie = t[16], ae = t[17]) : (ie = () => () => {
1243
+ d?.cancel(), C.current?.abort();
1244
+ }, ae = [d], t[15] = d, t[16] = ie, t[17] = ae), _(ie, ae), !n) return null;
1245
+ let M, N;
1246
+ if (t[18] !== h || t[19] !== y || t[20] !== k || t[21] !== u || t[22] !== p || t[23] !== ne) {
1247
+ N = e(), M = N.status === "starting" || N.status === "recording" || N.status === "finishing";
1248
+ function e() {
1249
+ if (!s) return {
1250
+ status: "unavailable",
1251
+ reason: "unsupported"
1252
+ };
1253
+ switch (p.status) {
1254
+ case "starting": return { status: "starting" };
1255
+ case "recording": return { status: "recording" };
1256
+ case "stopping": return {
1257
+ status: "finishing",
1258
+ end: y
1259
+ };
1260
+ case "ended":
1261
+ case "failed":
1262
+ }
1263
+ return ne ? {
1264
+ status: "finishing",
1265
+ end: y
1266
+ } : u === "denied" ? {
1267
+ status: "unavailable",
1268
+ reason: "blocked"
1269
+ } : p.status === "failed" ? {
1270
+ status: "failed",
1271
+ error: p.error
1272
+ } : k.failure && k.attempt === h ? {
1273
+ status: "failed",
1274
+ error: k.failure
1275
+ } : { status: "idle" };
1276
+ }
1277
+ t[18] = h, t[19] = y, t[20] = k, t[21] = u, t[22] = p, t[23] = ne, t[24] = M, t[25] = N;
1278
+ } else M = t[24], N = t[25];
1279
+ let P;
1280
+ t[26] === Symbol.for("react.memo_cache_sentinel") ? (P = function(e) {
1281
+ te.current = e, S(e);
1282
+ }, t[26] = P) : P = t[26];
1283
+ let F = P, I;
1284
+ t[27] !== M || t[28] !== h || t[29] !== r || t[30] !== N ? (I = function() {
1285
+ if (r || M || N.status === "unavailable") return;
1286
+ let e = h + 1;
1287
+ v(e), F("insert"), f(Jt.start((t) => {
1288
+ let n = T.current.dictation;
1289
+ n && m(() => {
1290
+ A({
1291
+ clip: t,
1292
+ attempt: e,
1293
+ transcribe: n.transcribe
1294
+ });
1295
+ });
1296
+ }));
1297
+ }, t[27] = M, t[28] = h, t[29] = r, t[30] = N, t[31] = I) : I = t[31];
1298
+ let L = I, R;
1299
+ t[32] === d ? R = t[33] : (R = function() {
1300
+ d?.stop();
1301
+ }, t[32] = d, t[33] = R);
1302
+ let z = R, B;
1303
+ t[34] === d ? B = t[35] : (B = function() {
1304
+ d?.cancel(), C.current?.abort();
1305
+ }, t[34] = d, t[35] = B);
1306
+ let V = B, H;
1307
+ t[36] !== d || t[37] !== N ? (H = function() {
1308
+ switch (N.status) {
1309
+ case "starting": return d?.cancel(), !1;
1310
+ case "recording": return F("send"), d?.stop(), !0;
1311
+ case "finishing": return F("send"), !0;
1312
+ default: return !1;
1313
+ }
1314
+ }, t[36] = d, t[37] = N, t[38] = H) : H = t[38];
1315
+ let oe = H, U;
1316
+ t[39] !== V || t[40] !== L || t[41] !== N || t[42] !== z ? (U = {
1317
+ state: N,
1318
+ start: L,
1319
+ stop: z,
1320
+ cancel: V
1321
+ }, t[39] = V, t[40] = L, t[41] = N, t[42] = z, t[43] = U) : U = t[43];
1322
+ let W;
1323
+ return t[44] !== oe || t[45] !== U ? (W = {
1324
+ api: U,
1325
+ endWithSend: oe
1326
+ }, t[44] = oe, t[45] = U, t[46] = W) : W = t[46], W;
1327
+ }
1328
+ function en() {
1329
+ return new Kt();
1033
1330
  }
1034
1331
  //#endregion
1035
1332
  //#region src/lib/tiptap/ComposerTiptapDomain.ts
1036
- function zt(e) {
1333
+ function tn(e) {
1037
1334
  return [
1038
1335
  ie.configure({ link: !1 }),
1039
- te.configure({
1336
+ A.configure({
1040
1337
  autolink: !0,
1041
1338
  linkOnPaste: !1,
1042
1339
  openOnClick: !1,
1043
1340
  HTMLAttributes: { "data-token": "link" }
1044
1341
  }),
1045
- Ht,
1046
- Ut,
1047
- Wt,
1048
- Gt(e)
1342
+ an,
1343
+ on,
1344
+ sn,
1345
+ cn(e)
1049
1346
  ];
1050
1347
  }
1051
- var Bt = 1e3;
1052
- function Vt(e, t) {
1348
+ var nn = 1e3;
1349
+ function rn(e, t) {
1053
1350
  return {
1054
1351
  default: t,
1055
1352
  parseHTML: (n) => n.getAttribute(e) ?? t
1056
1353
  };
1057
1354
  }
1058
- var Ht = T.create({
1355
+ var an = D.create({
1059
1356
  name: "composerSlashCommand",
1060
1357
  inclusive: !1,
1061
1358
  addAttributes() {
@@ -1070,14 +1367,14 @@ var Ht = T.create({
1070
1367
  renderHTML({ HTMLAttributes: e }) {
1071
1368
  return [
1072
1369
  "span",
1073
- D(e, {
1370
+ k(e, {
1074
1371
  "data-token": "slash-command",
1075
1372
  "data-composer-slash-command": e.value
1076
1373
  }),
1077
1374
  0
1078
1375
  ];
1079
1376
  }
1080
- }), Ut = E.create({
1377
+ }), on = O.create({
1081
1378
  name: "composerMention",
1082
1379
  group: "inline",
1083
1380
  inline: !0,
@@ -1085,12 +1382,12 @@ var Ht = T.create({
1085
1382
  selectable: !0,
1086
1383
  addAttributes() {
1087
1384
  return {
1088
- id: Vt("id", null),
1089
- trigger: Vt("trigger", ""),
1090
- value: Vt("value", ""),
1091
- label: Vt("label", ""),
1092
- detail: Vt("detail", ""),
1093
- persistsAs: Vt("persistsAs", null),
1385
+ id: rn("id", null),
1386
+ trigger: rn("trigger", ""),
1387
+ value: rn("value", ""),
1388
+ label: rn("label", ""),
1389
+ detail: rn("detail", ""),
1390
+ persistsAs: rn("persistsAs", null),
1094
1391
  payload: {
1095
1392
  default: null,
1096
1393
  renderHTML: (e) => e.payload === null || e.payload === void 0 ? {} : { payload: JSON.stringify(e.payload) },
@@ -1113,7 +1410,7 @@ var Ht = T.create({
1113
1410
  let n = e.attrs.label || `${e.attrs.trigger ?? ""}${e.attrs.value ?? ""}`;
1114
1411
  return [
1115
1412
  "span",
1116
- D(t, {
1413
+ k(t, {
1117
1414
  "data-token": "mention",
1118
1415
  "data-composer-mention": e.attrs.value,
1119
1416
  "data-composer-mention-trigger": e.attrs.trigger
@@ -1124,7 +1421,7 @@ var Ht = T.create({
1124
1421
  renderText({ node: e }) {
1125
1422
  return e.attrs.label || `${e.attrs.trigger ?? ""}${e.attrs.value ?? ""}`;
1126
1423
  }
1127
- }), Wt = E.create({
1424
+ }), sn = O.create({
1128
1425
  name: "composerAtom",
1129
1426
  group: "inline",
1130
1427
  inline: !0,
@@ -1155,7 +1452,7 @@ var Ht = T.create({
1155
1452
  let n = String(e.attrs.kind ?? "paste"), r = String(e.attrs.label ?? "");
1156
1453
  return [
1157
1454
  "span",
1158
- D(t, {
1455
+ k(t, {
1159
1456
  "data-token": n,
1160
1457
  "data-composer-atom": n,
1161
1458
  "data-composer-atom-detail": e.attrs.detail
@@ -1167,81 +1464,81 @@ var Ht = T.create({
1167
1464
  return String(e.attrs.label ?? "");
1168
1465
  }
1169
1466
  });
1170
- function Gt(e) {
1171
- return ee.create({
1467
+ function cn(e) {
1468
+ return E.create({
1172
1469
  name: "composerClipboard",
1173
1470
  addProseMirrorPlugins() {
1174
- return [new ne({ props: {
1471
+ return [new re({ props: {
1175
1472
  handlePaste(t, n) {
1176
1473
  let r = n.clipboardData;
1177
1474
  if (!r) return !1;
1178
- let i = Array.from(r.files).find((e) => J(e) !== null);
1179
- if (i) return n.preventDefault(), bn(t, e.getRemoteImageCount(), i, e.attachImageFile), !0;
1180
- let a = Array.from(r.files).find((e) => J(e) === null);
1181
- if (a) return n.preventDefault(), xn(t, a.name || "pasted-file", e.getMentionTrigger()), !0;
1182
- let o = Xn(tr(r.getData("text/uri-list")) || nr(r.getData("DownloadURL")) || r.getData("text/plain") || r.getData("text")), s = o.trim();
1475
+ let i = Array.from(r.files).find((e) => Ie(e) !== null);
1476
+ if (i) return n.preventDefault(), Ln(t, e.getRemoteImageCount(), i, e.attachImageFile), !0;
1477
+ let a = Array.from(r.files).find((e) => Ie(e) === null);
1478
+ if (a) return n.preventDefault(), Rn(t, a.name || "pasted-file", e.getMentionTrigger()), !0;
1479
+ let o = fr(_r(r.getData("text/uri-list")) || vr(r.getData("DownloadURL")) || r.getData("text/plain") || r.getData("text")), s = o.trim();
1183
1480
  if (!o) return !1;
1184
- let c = pn(t);
1185
- if (c && rr(s)) {
1481
+ let c = An(t);
1482
+ if (c && yr(s)) {
1186
1483
  n.preventDefault();
1187
- let e = ir(s), r = t.state.schema.marks.link;
1188
- return r ? hn(t, c, e, r) : !1;
1484
+ let e = br(s), r = t.state.schema.marks.link;
1485
+ return r ? Mn(t, c, e, r) : !1;
1189
1486
  }
1190
- return Zn(s) && !s.includes("\n") ? (n.preventDefault(), xn(t, s, e.getMentionTrigger()), !0) : rr(s) && !s.includes("\n") ? (n.preventDefault(), vn(t, s, ir(s))) : c && o && !o.includes("\n") && $(o) <= Bt ? (n.preventDefault(), yn(t, o, c), !0) : $(o) > Bt ? (n.preventDefault(), fn(t, o), !0) : !1;
1487
+ return pr(s) && !s.includes("\n") ? (n.preventDefault(), Rn(t, s, e.getMentionTrigger()), !0) : yr(s) && !s.includes("\n") ? (n.preventDefault(), Fn(t, s, br(s))) : c && o && !o.includes("\n") && Z(o) <= nn ? (n.preventDefault(), In(t, o, c), !0) : Z(o) > nn ? (n.preventDefault(), kn(t, o), !0) : !1;
1191
1488
  },
1192
1489
  handleDrop(t, n) {
1193
1490
  let r = n.dataTransfer;
1194
- return r && Kt(t, r, e.getRemoteImageCount(), e.getMentionTrigger(), e.attachImageFile) ? (n.preventDefault(), !0) : !1;
1491
+ return r && ln(t, r, e.getRemoteImageCount(), e.getMentionTrigger(), e.attachImageFile) ? (n.preventDefault(), !0) : !1;
1195
1492
  }
1196
1493
  } })];
1197
1494
  }
1198
1495
  });
1199
1496
  }
1200
- function Kt(e, t, n, r, i) {
1201
- let a = Array.from(t.files).find((e) => J(e) !== null);
1202
- if (a) return bn(e, n, a, i), !0;
1203
- let o = Array.from(t.files).find((e) => J(e) === null);
1204
- if (o) return xn(e, o.name || "dropped-file", r), !0;
1205
- let s = Xn(tr(t.getData("text/uri-list")) || nr(t.getData("DownloadURL")) || t.getData("text/plain")).trim();
1206
- return s ? Zn(s) && !s.includes("\n") ? (xn(e, s, r), !0) : rr(s) && !s.includes("\n") ? (vn(e, s, ir(s)), !0) : !1 : !1;
1497
+ function ln(e, t, n, r, i) {
1498
+ let a = Array.from(t.files).find((e) => Ie(e) !== null);
1499
+ if (a) return Ln(e, n, a, i), !0;
1500
+ let o = Array.from(t.files).find((e) => Ie(e) === null);
1501
+ if (o) return Rn(e, o.name || "dropped-file", r), !0;
1502
+ let s = fr(_r(t.getData("text/uri-list")) || vr(t.getData("DownloadURL")) || t.getData("text/plain")).trim();
1503
+ return s ? pr(s) && !s.includes("\n") ? (Rn(e, s, r), !0) : yr(s) && !s.includes("\n") ? (Fn(e, s, br(s)), !0) : !1 : !1;
1207
1504
  }
1208
- function qt({ state: e, text: t, slashCommands: n, mentionCandidates: r, triggers: i }) {
1209
- return e ? Jt(W({
1505
+ function un({ state: e, text: t, slashCommands: n, mentionCandidates: r, triggers: i }) {
1506
+ return e ? dn(q({
1210
1507
  initialDraft: e,
1211
1508
  slashCommands: n,
1212
1509
  commandTriggers: i.commandTriggers,
1213
1510
  mentionCandidates: r
1214
- }), n, r, i) : Yt(t ?? "", n, r, i);
1511
+ }), n, r, i) : fn(t ?? "", n, r, i);
1215
1512
  }
1216
- function Jt(e, t, n, r) {
1217
- if (e.elements.length === 0) return Yt(e.text, t, n, r);
1513
+ function dn(e, t, n, r) {
1514
+ if (e.elements.length === 0) return fn(e.text, t, n, r);
1218
1515
  let i = [], a = 0;
1219
- for (let o of Jn(e.elements)) {
1220
- o.range.start > a && i.push(...Xt(e.text.slice(a, o.range.start), t, n, r.commandTriggers, r.mentionTriggers));
1516
+ for (let o of X(e.elements)) {
1517
+ o.range.start > a && i.push(...pn(e.text.slice(a, o.range.start), t, n, r.commandTriggers, r.mentionTriggers));
1221
1518
  let s = e.mentionBindings.find((e) => e.id === o.id || `${e.trigger}${e.value}` === o.label), c = e.pendingPastes.find((e) => e.placeholder === o.label);
1222
- o.kind === "mention" && s ? i.push(on(sn(s, o, n))) : o.kind === "paste" && c ? i.push(cn({
1519
+ o.kind === "mention" && s ? i.push(Cn(wn(s, o, n))) : o.kind === "paste" && c ? i.push(Tn({
1223
1520
  kind: "paste",
1224
1521
  label: c.placeholder,
1225
- detail: o.detail ?? `${$(c.content)} chars`,
1522
+ detail: o.detail ?? `${Z(c.content)} chars`,
1226
1523
  content: c.content
1227
- })) : o.kind === "rich-link" ? i.push(cn({
1524
+ })) : o.kind === "rich-link" ? i.push(Tn({
1228
1525
  kind: "rich-link",
1229
1526
  label: o.label,
1230
1527
  detail: o.detail ?? "",
1231
1528
  href: o.detail ?? "",
1232
1529
  metadata: o.metadata
1233
- })) : o.kind === "link" ? i.push(Q(o.label, [an(o.detail ?? "")])) : i.push(...Xt(e.text.slice(o.range.start, o.range.end), t, n, r.commandTriggers, r.mentionTriggers)), a = o.range.end;
1530
+ })) : o.kind === "link" ? i.push(xn(o.label, [Sn(o.detail ?? "")])) : i.push(...pn(e.text.slice(o.range.start, o.range.end), t, n, r.commandTriggers, r.mentionTriggers)), a = o.range.end;
1234
1531
  }
1235
- return a < e.text.length && i.push(...Xt(e.text.slice(a), t, n, r.commandTriggers, r.mentionTriggers)), nn(i);
1532
+ return a < e.text.length && i.push(...pn(e.text.slice(a), t, n, r.commandTriggers, r.mentionTriggers)), yn(i);
1236
1533
  }
1237
- function Yt(e, t, n, r) {
1238
- let i = Ue({
1534
+ function fn(e, t, n, r) {
1535
+ let i = We({
1239
1536
  text: e,
1240
1537
  slashCommands: t,
1241
1538
  commandTriggers: r.commandTriggers,
1242
1539
  mentionCandidates: n
1243
1540
  });
1244
- return (i.elements?.length ?? 0) > 0 ? Jt(W({
1541
+ return (i.elements?.length ?? 0) > 0 ? dn(q({
1245
1542
  initialDraft: i,
1246
1543
  slashCommands: t,
1247
1544
  commandTriggers: r.commandTriggers,
@@ -1250,39 +1547,39 @@ function Yt(e, t, n, r) {
1250
1547
  type: "doc",
1251
1548
  content: e.split("\n").map((e) => ({
1252
1549
  type: "paragraph",
1253
- content: Xt(e, t, n, r.commandTriggers, r.mentionTriggers)
1550
+ content: pn(e, t, n, r.commandTriggers, r.mentionTriggers)
1254
1551
  }))
1255
1552
  };
1256
1553
  }
1257
- function Xt(e, t, n, i, a) {
1258
- return r(e).flatMap((e) => e.kind === "inline-code" || e.kind === "code-block" || e.kind === "link" || e.kind === "skill-link" ? [Q(e.source)] : Zt(e.source, t, n, i, a));
1554
+ function pn(e, t, n, i, a) {
1555
+ return r(e).flatMap((e) => e.kind === "inline-code" || e.kind === "code-block" || e.kind === "link" || e.kind === "skill-link" ? [xn(e.source)] : mn(e.source, t, n, i, a));
1259
1556
  }
1260
- function Zt(e, t, n, r, i) {
1261
- let a = [], o = pe(r, i);
1262
- if (!o) return [Q(e)];
1557
+ function mn(e, t, n, r, i) {
1558
+ let a = [], o = fe(r, i);
1559
+ if (!o) return [xn(e)];
1263
1560
  let s = 0;
1264
1561
  for (let r of e.matchAll(o)) {
1265
1562
  let o = r.index ?? 0, c = r[0];
1266
1563
  if (o === 0 || /\s/.test(e[o - 1] ?? "")) {
1267
- if (o > s && a.push(Q(e.slice(s, o))), H(c, i)) {
1268
- let e = n.find((e) => U(e) === c);
1269
- a.push(e ? on(e) : Q(c));
1564
+ if (o > s && a.push(xn(e.slice(s, o))), pe(c, i)) {
1565
+ let e = n.find((e) => K(e) === c);
1566
+ a.push(e ? Cn(e) : xn(c));
1270
1567
  } else {
1271
- let e = R(c.replace(/^\//, ""), t);
1272
- a.push(e ? Q(c, [{
1568
+ let e = U(c.replace(/^\//, ""), t);
1569
+ a.push(e ? xn(c, [{
1273
1570
  type: "composerSlashCommand",
1274
1571
  attrs: {
1275
1572
  value: e.value,
1276
1573
  detail: e.detail
1277
1574
  }
1278
- }]) : Q(c));
1575
+ }]) : xn(c));
1279
1576
  }
1280
1577
  s = o + c.length;
1281
1578
  }
1282
1579
  }
1283
- return s < e.length && a.push(Q(e.slice(s))), a;
1580
+ return s < e.length && a.push(xn(e.slice(s))), a;
1284
1581
  }
1285
- function Qt(e, t, n, r, i, a) {
1582
+ function hn(e, t, n, r, i, a) {
1286
1583
  let o = {
1287
1584
  text: "",
1288
1585
  elements: [],
@@ -1290,8 +1587,8 @@ function Qt(e, t, n, r, i, a) {
1290
1587
  imageAttachments: [],
1291
1588
  pendingPastes: []
1292
1589
  };
1293
- $t(e, o, n);
1294
- let s = W({
1590
+ gn(e, o, n);
1591
+ let s = q({
1295
1592
  text: o.text,
1296
1593
  slashCommands: n,
1297
1594
  isTaskRunning: r,
@@ -1300,22 +1597,22 @@ function Qt(e, t, n, r, i, a) {
1300
1597
  return {
1301
1598
  ...s,
1302
1599
  cursor: a,
1303
- elements: Yn([...s.elements, ...o.elements]),
1600
+ elements: dr([...s.elements, ...o.elements]),
1304
1601
  mentionBindings: o.mentionBindings,
1305
1602
  imageAttachments: o.imageAttachments,
1306
1603
  remoteImages: t,
1307
1604
  pendingPastes: o.pendingPastes
1308
1605
  };
1309
1606
  }
1310
- function $t(e, t, n) {
1607
+ function gn(e, t, n) {
1311
1608
  if (e.type === "doc") {
1312
1609
  e.content?.forEach((e, r) => {
1313
- r > 0 && t.text.length > 0 && (t.text += "\n"), $t(e, t, n);
1610
+ r > 0 && t.text.length > 0 && (t.text += "\n"), gn(e, t, n);
1314
1611
  });
1315
1612
  return;
1316
1613
  }
1317
1614
  if (e.type === "paragraph") {
1318
- e.content?.forEach((e) => $t(e, t, n));
1615
+ e.content?.forEach((e) => gn(e, t, n));
1319
1616
  return;
1320
1617
  }
1321
1618
  if (e.type === "hardBreak") {
@@ -1326,7 +1623,7 @@ function $t(e, t, n) {
1326
1623
  let r = e.text ?? "", i = t.text.length;
1327
1624
  t.text += r;
1328
1625
  for (let a of e.marks ?? []) if (a.type === "link" && a.attrs?.href && t.elements.push({
1329
- id: or("link", r, i),
1626
+ id: $("link", r, i),
1330
1627
  kind: "link",
1331
1628
  label: r,
1332
1629
  range: {
@@ -1335,10 +1632,10 @@ function $t(e, t, n) {
1335
1632
  },
1336
1633
  detail: String(a.attrs.href)
1337
1634
  }), a.type === "composerSlashCommand") {
1338
- let e = R(r.replace(/^\//, ""), n);
1635
+ let e = U(r.replace(/^\//, ""), n);
1339
1636
  if (!e) continue;
1340
1637
  t.elements.push({
1341
- id: or("slash-command", r, i),
1638
+ id: $("slash-command", r, i),
1342
1639
  kind: "slash-command",
1343
1640
  label: r,
1344
1641
  range: {
@@ -1351,7 +1648,7 @@ function $t(e, t, n) {
1351
1648
  return;
1352
1649
  }
1353
1650
  if (e.type === "composerMention") {
1354
- let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ?? or("mention", n, r));
1651
+ let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ?? $("mention", n, r));
1355
1652
  t.text += n, t.elements.push({
1356
1653
  id: i,
1357
1654
  kind: "mention",
@@ -1373,11 +1670,11 @@ function $t(e, t, n) {
1373
1670
  return;
1374
1671
  }
1375
1672
  if (e.type === "composerAtom") {
1376
- let n = String(e.attrs?.label ?? ""), r = tn(e.attrs?.kind), i = t.text.length, a = String(e.attrs?.attachmentId ?? "");
1673
+ let n = String(e.attrs?.label ?? ""), r = vn(e.attrs?.kind), i = t.text.length, a = String(e.attrs?.attachmentId ?? "");
1377
1674
  if (r === "image" && !a) return;
1378
- let o = r === "image" ? a : or(r, n, i);
1675
+ let o = r === "image" ? a : $(r, n, i);
1379
1676
  t.text += n;
1380
- let s = r === "rich-link" ? en(e.attrs?.metadata) : void 0;
1677
+ let s = r === "rich-link" ? _n(e.attrs?.metadata) : void 0;
1381
1678
  t.elements.push({
1382
1679
  id: o,
1383
1680
  kind: r,
@@ -1391,7 +1688,7 @@ function $t(e, t, n) {
1391
1688
  }), r === "image" && t.imageAttachments.push({
1392
1689
  id: o,
1393
1690
  placeholder: n,
1394
- media: Y(e.attrs?.media)
1691
+ media: Le(e.attrs?.media)
1395
1692
  }), r === "paste" && t.pendingPastes.push({
1396
1693
  id: o,
1397
1694
  placeholder: n,
@@ -1399,7 +1696,7 @@ function $t(e, t, n) {
1399
1696
  });
1400
1697
  }
1401
1698
  }
1402
- function en(e) {
1699
+ function _n(e) {
1403
1700
  if (!e || typeof e != "object") return;
1404
1701
  let t = {};
1405
1702
  for (let n of [
@@ -1415,7 +1712,7 @@ function en(e) {
1415
1712
  }
1416
1713
  return Object.keys(t).length > 0 ? t : void 0;
1417
1714
  }
1418
- function tn(e) {
1715
+ function vn(e) {
1419
1716
  switch (e) {
1420
1717
  case "slash-command":
1421
1718
  case "mention":
@@ -1426,7 +1723,7 @@ function tn(e) {
1426
1723
  default: return "paste";
1427
1724
  }
1428
1725
  }
1429
- function nn(e) {
1726
+ function yn(e) {
1430
1727
  return {
1431
1728
  type: "doc",
1432
1729
  content: [{
@@ -1435,13 +1732,13 @@ function nn(e) {
1435
1732
  }]
1436
1733
  };
1437
1734
  }
1438
- function rn() {
1735
+ function bn() {
1439
1736
  return {
1440
1737
  type: "doc",
1441
1738
  content: [{ type: "paragraph" }]
1442
1739
  };
1443
1740
  }
1444
- function Q(e, t) {
1741
+ function xn(e, t) {
1445
1742
  return t && t.length > 0 ? {
1446
1743
  type: "text",
1447
1744
  text: e,
@@ -1451,29 +1748,29 @@ function Q(e, t) {
1451
1748
  text: e
1452
1749
  };
1453
1750
  }
1454
- function an(e) {
1751
+ function Sn(e) {
1455
1752
  return {
1456
1753
  type: "link",
1457
1754
  attrs: { href: e }
1458
1755
  };
1459
1756
  }
1460
- function on(e) {
1757
+ function Cn(e) {
1461
1758
  return {
1462
1759
  type: "composerMention",
1463
1760
  attrs: {
1464
1761
  id: e.id,
1465
1762
  trigger: e.trigger,
1466
1763
  value: e.value,
1467
- label: U(e),
1764
+ label: K(e),
1468
1765
  detail: e.detail,
1469
1766
  payload: e.payload,
1470
1767
  persistsAs: e.persistsAs
1471
1768
  }
1472
1769
  };
1473
1770
  }
1474
- function sn(e, t, n) {
1771
+ function wn(e, t, n) {
1475
1772
  let r = `${e.trigger}${e.value}`;
1476
- return n.find((e) => U(e) === t.label || U(e) === r) || {
1773
+ return n.find((e) => K(e) === t.label || K(e) === r) || {
1477
1774
  id: e.id,
1478
1775
  trigger: e.trigger,
1479
1776
  value: e.value,
@@ -1483,7 +1780,7 @@ function sn(e, t, n) {
1483
1780
  payload: e.payload
1484
1781
  };
1485
1782
  }
1486
- function cn({ kind: e, label: t, detail: n = "", content: r = "", href: i = "", metadata: a }) {
1783
+ function Tn({ kind: e, label: t, detail: n = "", content: r = "", href: i = "", metadata: a }) {
1487
1784
  return {
1488
1785
  type: "composerAtom",
1489
1786
  attrs: {
@@ -1496,7 +1793,7 @@ function cn({ kind: e, label: t, detail: n = "", content: r = "", href: i = "",
1496
1793
  }
1497
1794
  };
1498
1795
  }
1499
- function ln(e, t, n = "image") {
1796
+ function En(e, t, n = "image") {
1500
1797
  return {
1501
1798
  type: "composerAtom",
1502
1799
  attrs: {
@@ -1507,12 +1804,12 @@ function ln(e, t, n = "image") {
1507
1804
  }
1508
1805
  };
1509
1806
  }
1510
- function un(e, t) {
1807
+ function Dn(e, t) {
1511
1808
  let { selection: n } = e.state;
1512
1809
  if (!n.empty) return null;
1513
1810
  let r = n.$from, i = r.parent.textBetween(0, r.parentOffset, void 0, ""), a = r.parent.textBetween(r.parentOffset, r.parent.content.size, void 0, ""), o = [...t.commandTriggers, ...t.mentionTriggers];
1514
1811
  if (o.length === 0) return null;
1515
- let s = dn(i, a, o);
1812
+ let s = On(i, a, o);
1516
1813
  if (!s) return null;
1517
1814
  let c = o.find((e) => s.token.startsWith(e));
1518
1815
  return !c || s.token.slice(c.length).includes(c) ? null : {
@@ -1522,8 +1819,8 @@ function un(e, t) {
1522
1819
  to: n.from + s.tail.length
1523
1820
  };
1524
1821
  }
1525
- function dn(e, t, n) {
1526
- let r = `(?:${V(n)})`, i = e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));
1822
+ function On(e, t, n) {
1823
+ let r = `(?:${le(n)})`, i = e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));
1527
1824
  if (i === -1) return null;
1528
1825
  let a = /[\s\ufffc]/.test(e[i] ?? "") ? i + 1 : i, o = t.match(/^[^\s\ufffc]*/)?.[0] ?? "";
1529
1826
  return {
@@ -1532,16 +1829,16 @@ function dn(e, t, n) {
1532
1829
  tail: o
1533
1830
  };
1534
1831
  }
1535
- function fn(e, t) {
1536
- let n = En(e.state.doc.toJSON(), $(t)), r = e.state.schema.nodes.composerAtom?.create({
1832
+ function kn(e, t) {
1833
+ let n = Un(e.state.doc.toJSON(), Z(t)), r = e.state.schema.nodes.composerAtom?.create({
1537
1834
  kind: "paste",
1538
1835
  label: n,
1539
- detail: `${$(t)} chars`,
1836
+ detail: `${Z(t)} chars`,
1540
1837
  content: t
1541
1838
  });
1542
1839
  r && e.dispatch(e.state.tr.replaceSelectionWith(r).scrollIntoView());
1543
1840
  }
1544
- function pn(e) {
1841
+ function An(e) {
1545
1842
  let t = e.dom.ownerDocument.getSelection();
1546
1843
  if (t && t.rangeCount > 0 && !t.isCollapsed) {
1547
1844
  let n = t.getRangeAt(0);
@@ -1550,7 +1847,7 @@ function pn(e) {
1550
1847
  if (r !== i) return {
1551
1848
  from: Math.min(r, i),
1552
1849
  to: Math.max(r, i),
1553
- selectedAtomLabels: mn(n, e.dom),
1850
+ selectedAtomLabels: jn(n, e.dom),
1554
1851
  selectedText: t.toString()
1555
1852
  };
1556
1853
  }
@@ -1560,14 +1857,14 @@ function pn(e) {
1560
1857
  to: e.state.selection.to
1561
1858
  };
1562
1859
  }
1563
- function mn(e, t) {
1860
+ function jn(e, t) {
1564
1861
  return Array.from(t.querySelectorAll("[data-composer-atom]")).filter((t) => e.intersectsNode(t)).map((e) => e.textContent ?? "").filter(Boolean);
1565
1862
  }
1566
- function hn(e, t, n, r) {
1567
- let i = gn(e.state.doc, t), a = _n(e.state.doc, i.from, i.to) || n, o = e.state.schema.text(a, [r.create({ href: n })]), s = e.state.tr.replaceWith(i.from, i.to, o), c = i.from + a.length;
1568
- return e.dispatch(s.setSelection(re.create(s.doc, c)).scrollIntoView()), !0;
1863
+ function Mn(e, t, n, r) {
1864
+ let i = Nn(e.state.doc, t), a = Pn(e.state.doc, i.from, i.to) || n, o = e.state.schema.text(a, [r.create({ href: n })]), s = e.state.tr.replaceWith(i.from, i.to, o), c = i.from + a.length;
1865
+ return e.dispatch(s.setSelection(j.create(s.doc, c)).scrollIntoView()), !0;
1569
1866
  }
1570
- function gn(e, t) {
1867
+ function Nn(e, t) {
1571
1868
  if (!t.selectedText && !t.selectedAtomLabels?.length) return t;
1572
1869
  let n = {
1573
1870
  from: t.from,
@@ -1590,7 +1887,7 @@ function gn(e, t) {
1590
1887
  });
1591
1888
  return n;
1592
1889
  }
1593
- function _n(e, t, n) {
1890
+ function Pn(e, t, n) {
1594
1891
  let r = "";
1595
1892
  return e.nodesBetween(t, n, (e, i) => {
1596
1893
  if (e.isText) {
@@ -1600,119 +1897,119 @@ function _n(e, t, n) {
1600
1897
  return e.type.name === "composerMention" ? (r += String(e.attrs.label ?? ""), !1) : e.type.name === "composerAtom" ? (e.attrs.kind === "rich-link" && (r += String(e.attrs.label ?? "")), !1) : e.type.name === "hardBreak" ? (r += "\n", !1) : !0;
1601
1898
  }), r.replace(/\n+/g, " ").trim();
1602
1899
  }
1603
- function vn(e, t, n) {
1900
+ function Fn(e, t, n) {
1604
1901
  let r = e.state.schema.marks.link;
1605
1902
  if (!r) return !1;
1606
1903
  let { from: i, to: a } = e.state.selection, o = e.state.tr.insertText(t, i, a);
1607
1904
  return o.addMark(i, i + t.length, r.create({ href: n })), e.dispatch(o.scrollIntoView()), !0;
1608
1905
  }
1609
- function yn(e, t, n) {
1906
+ function In(e, t, n) {
1610
1907
  e.dispatch(e.state.tr.replaceWith(n.from, n.to, e.state.schema.text(t)).scrollIntoView());
1611
1908
  }
1612
- function bn(e, t, n, r) {
1909
+ function Ln(e, t, n, r) {
1613
1910
  let i = r(n);
1614
1911
  if (i === null) return;
1615
- let a = t + Dn(e.state.doc.toJSON(), "image") + 1, o = J(n) ?? "image", s = e.state.schema.nodeFromJSON(ln(i, Ie(o, a), o));
1912
+ let a = t + Wn(e.state.doc.toJSON(), "image") + 1, o = Ie(n) ?? "image", s = e.state.schema.nodeFromJSON(En(i, Re(o, a), o));
1616
1913
  if (!s) return;
1617
1914
  let c = e.state.tr.replaceSelectionWith(s);
1618
1915
  c = c.insertText(" ", c.selection.from), e.dispatch(c.scrollIntoView());
1619
1916
  }
1620
- function xn(e, t, n) {
1621
- let r = Qn(t), i = $n(r), a = `${n}${i}`, o = e.state.schema.nodes.composerMention?.create({
1622
- id: or("mention", a, e.state.selection.from),
1917
+ function Rn(e, t, n) {
1918
+ let r = mr(t), i = hr(r), a = `${n}${i}`, o = e.state.schema.nodes.composerMention?.create({
1919
+ id: $("mention", a, e.state.selection.from),
1623
1920
  trigger: n,
1624
1921
  value: i,
1625
1922
  label: a,
1626
- detail: er(r) ? "directory" : "file",
1923
+ detail: gr(r) ? "directory" : "file",
1627
1924
  payload: {
1628
1925
  path: r,
1629
- type: er(r) ? "directory" : "file"
1926
+ type: gr(r) ? "directory" : "file"
1630
1927
  }
1631
1928
  });
1632
1929
  if (!o) return;
1633
1930
  let s = e.state.tr.replaceSelectionWith(o);
1634
1931
  s = s.insertText(" ", s.selection.from), e.dispatch(s.scrollIntoView());
1635
1932
  }
1636
- function Sn(e, t) {
1933
+ function zn(e, t) {
1637
1934
  let n = 0;
1638
- return Cn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" ? e : (n += 1, {
1935
+ return Bn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" ? e : (n += 1, {
1639
1936
  ...e,
1640
1937
  attrs: {
1641
1938
  ...e.attrs,
1642
- label: Ie(Y(e.attrs?.media), t + n)
1939
+ label: Re(Le(e.attrs?.media), t + n)
1643
1940
  }
1644
1941
  }));
1645
1942
  }
1646
- function Cn(e, t) {
1943
+ function Bn(e, t) {
1647
1944
  let n = t(e);
1648
1945
  return {
1649
1946
  ...n,
1650
- content: n.content?.map((e) => Cn(e, t))
1947
+ content: n.content?.map((e) => Bn(e, t))
1651
1948
  };
1652
1949
  }
1653
- function wn(e, t) {
1654
- return Tn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" || e.attrs?.attachmentId !== t);
1950
+ function Vn(e, t) {
1951
+ return Hn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" || e.attrs?.attachmentId !== t);
1655
1952
  }
1656
- function Tn(e, t) {
1953
+ function Hn(e, t) {
1657
1954
  return {
1658
1955
  ...e,
1659
- content: e.content?.filter(t).map((e) => Tn(e, t))
1956
+ content: e.content?.filter(t).map((e) => Hn(e, t))
1660
1957
  };
1661
1958
  }
1662
- function En(e, t) {
1959
+ function Un(e, t) {
1663
1960
  let n = `[Pasted Content ${t} chars]`, r = /* @__PURE__ */ new Set();
1664
- if (On(e, (e) => {
1961
+ if (Gn(e, (e) => {
1665
1962
  e.type === "composerAtom" && e.attrs?.kind === "paste" && r.add(String(e.attrs.label ?? ""));
1666
1963
  }), !r.has(n)) return n;
1667
1964
  let i = 2;
1668
1965
  for (; r.has(`${n} #${i}`);) i += 1;
1669
1966
  return `${n} #${i}`;
1670
1967
  }
1671
- function Dn(e, t) {
1968
+ function Wn(e, t) {
1672
1969
  let n = 0;
1673
- return On(e, (e) => {
1970
+ return Gn(e, (e) => {
1674
1971
  e.type === "composerAtom" && e.attrs?.kind === t && (n += 1);
1675
1972
  }), n;
1676
1973
  }
1677
- function On(e, t) {
1678
- t(e), e.content?.forEach((e) => On(e, t));
1974
+ function Gn(e, t) {
1975
+ t(e), e.content?.forEach((e) => Gn(e, t));
1679
1976
  }
1680
- function kn(e) {
1977
+ function Kn(e) {
1681
1978
  let { selection: t } = e.state, n = t.from;
1682
- return Rn(e, n, t.empty ? t.$from.end() : t.to);
1979
+ return tr(e, n, t.empty ? t.$from.end() : t.to);
1683
1980
  }
1684
- function An(e) {
1685
- let { selection: t } = e.state, n = t.empty ? Pn(e, t.from) : t.from, r = t.to;
1686
- return Rn(e, n, r);
1981
+ function qn(e) {
1982
+ let { selection: t } = e.state, n = t.empty ? Zn(e, t.from) : t.from, r = t.to;
1983
+ return tr(e, n, r);
1687
1984
  }
1688
- function jn(e) {
1985
+ function Jn(e) {
1689
1986
  let { selection: t } = e.state;
1690
- if (!t.empty) return Rn(e, t.from, t.to);
1691
- let n = t.$from.parent.textBetween(0, t.$from.parentOffset, void 0, zn), r = at(n, n.length);
1692
- return Rn(e, In(t.$from.parent, t.$from.start(), r), t.from);
1987
+ if (!t.empty) return tr(e, t.from, t.to);
1988
+ let n = t.$from.parent.textBetween(0, t.$from.parentOffset, void 0, nr), r = ot(n, n.length);
1989
+ return tr(e, $n(t.$from.parent, t.$from.start(), r), t.from);
1693
1990
  }
1694
- function Mn(e) {
1695
- let t = e.state.selection.to, n = Fn(e, t), r = e.state.tr.setSelection(re.create(e.state.doc, n)).scrollIntoView();
1991
+ function Yn(e) {
1992
+ let t = e.state.selection.to, n = Qn(e, t), r = e.state.tr.setSelection(j.create(e.state.doc, n)).scrollIntoView();
1696
1993
  e.view.dispatch(r), e.view.focus();
1697
1994
  }
1698
- function Nn(e, t) {
1699
- let { selection: n } = e.state, r = t === -1 ? n.from : n.to, i = e.state.doc.resolve(r), a = i.parent.textBetween(0, i.parent.content.size, void 0, zn), o = i.parent.textBetween(0, i.parentOffset, void 0, zn).length, s = t === -1 ? at(a, o) : ot(a, o), c = In(i.parent, i.start(), s), l = e.state.tr.setSelection(re.create(e.state.doc, c)).scrollIntoView();
1995
+ function Xn(e, t) {
1996
+ let { selection: n } = e.state, r = t === -1 ? n.from : n.to, i = e.state.doc.resolve(r), a = i.parent.textBetween(0, i.parent.content.size, void 0, nr), o = i.parent.textBetween(0, i.parentOffset, void 0, nr).length, s = t === -1 ? ot(a, o) : st(a, o), c = $n(i.parent, i.start(), s), l = e.state.tr.setSelection(j.create(e.state.doc, c)).scrollIntoView();
1700
1997
  e.view.dispatch(l), e.view.focus();
1701
1998
  }
1702
- function Pn(e, t) {
1999
+ function Zn(e, t) {
1703
2000
  let { selection: n } = e.state, r = n.$from.start();
1704
2001
  return e.state.doc.nodesBetween(r, t, (e, t) => {
1705
2002
  e.type.name === "hardBreak" && (r = t + e.nodeSize);
1706
2003
  }), r;
1707
2004
  }
1708
- function Fn(e, t) {
2005
+ function Qn(e, t) {
1709
2006
  let n = e.state.doc.resolve(t).end();
1710
2007
  return e.state.doc.nodesBetween(t, n, (e, r) => e.type.name === "hardBreak" && r >= t ? (n = r, !1) : !0), n;
1711
2008
  }
1712
- function In(e, t, n) {
2009
+ function $n(e, t, n) {
1713
2010
  let r = 0, i = t;
1714
2011
  for (let t = 0; t < e.childCount; t += 1) {
1715
- let a = e.child(t), o = Ln(a);
2012
+ let a = e.child(t), o = er(a);
1716
2013
  if (o === null) {
1717
2014
  i += a.nodeSize;
1718
2015
  continue;
@@ -1723,13 +2020,13 @@ function In(e, t, n) {
1723
2020
  }
1724
2021
  return i;
1725
2022
  }
1726
- function Ln(e) {
1727
- return e.isText ? e.text ?? "" : e.type.name === "hardBreak" ? "\n" : e.type.name === "composerMention" || e.type.name === "composerAtom" ? zn(e) : null;
2023
+ function er(e) {
2024
+ return e.isText ? e.text ?? "" : e.type.name === "hardBreak" ? "\n" : e.type.name === "composerMention" || e.type.name === "composerAtom" ? nr(e) : null;
1728
2025
  }
1729
- function Rn(e, t, n) {
2026
+ function tr(e, t, n) {
1730
2027
  if (n <= t) return null;
1731
2028
  let r = e.state.doc.slice(t, n), i = {
1732
- text: e.state.doc.textBetween(t, n, "\n", zn),
2029
+ text: e.state.doc.textBetween(t, n, "\n", nr),
1733
2030
  slice: r.toJSON()
1734
2031
  };
1735
2032
  return e.chain().focus().deleteRange({
@@ -1737,10 +2034,10 @@ function Rn(e, t, n) {
1737
2034
  to: n
1738
2035
  }).run(), i;
1739
2036
  }
1740
- function zn(e) {
2037
+ function nr(e) {
1741
2038
  return e.type.name === "composerMention" ? String(e.attrs.label ?? "") || `${String(e.attrs.trigger ?? "")}${String(e.attrs.value ?? "")}` : e.type.name === "composerAtom" ? String(e.attrs.label ?? "") : "";
1742
2039
  }
1743
- function Bn(e, t) {
2040
+ function rr(e, t) {
1744
2041
  let { selection: n } = e.state;
1745
2042
  if (typeof t == "string") {
1746
2043
  if (!n.empty) {
@@ -1750,83 +2047,78 @@ function Bn(e, t) {
1750
2047
  e.chain().focus().insertContent(t).run();
1751
2048
  return;
1752
2049
  }
1753
- let r = O.fromJSON(e.state.schema, t.slice);
2050
+ let r = ne.fromJSON(e.state.schema, t.slice);
1754
2051
  e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()), e.view.focus();
1755
2052
  }
1756
- function Vn(e, t) {
2053
+ function ir(e, t) {
1757
2054
  let { selection: n } = e.state;
1758
2055
  if (!n.empty) return !1;
1759
2056
  let r = n.$from, i = t === "Backspace" ? r.nodeBefore : r.nodeAfter;
1760
- if (!i || !Hn(i)) return !1;
2057
+ if (!i || !ar(i)) return !1;
1761
2058
  let a = t === "Backspace" ? n.from - i.nodeSize : n.from, o = t === "Backspace" ? n.from : n.from + i.nodeSize;
1762
2059
  return e.chain().focus().deleteRange({
1763
2060
  from: a,
1764
2061
  to: o
1765
2062
  }).run(), !0;
1766
2063
  }
1767
- function Hn(e) {
2064
+ function ar(e) {
1768
2065
  return e.isAtom && (e.type.name === "composerMention" || e.type.name === "composerAtom");
1769
2066
  }
1770
- function Un(e) {
2067
+ function or(e) {
1771
2068
  try {
1772
2069
  return e.state.doc.textBetween(0, e.state.selection.from, "\n", "").length;
1773
2070
  } catch {
1774
2071
  return 0;
1775
2072
  }
1776
2073
  }
1777
- function Wn(e) {
1778
- return e.state.selection.empty && Un(e) === 0;
2074
+ function sr(e) {
2075
+ return e.state.selection.empty && or(e) === 0;
1779
2076
  }
1780
- function Gn(e, t) {
1781
- return H(e.persistedPrompt, t) ? "ParseSlash" : e.action;
2077
+ function cr(e, t) {
2078
+ return pe(e.persistedPrompt, t) ? "ParseSlash" : e.action;
1782
2079
  }
1783
- function Kn(e) {
2080
+ function lr(e) {
1784
2081
  return e.key === "ArrowUp" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "p";
1785
2082
  }
1786
- function qn(e) {
2083
+ function ur(e) {
1787
2084
  return e.key === "ArrowDown" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "n";
1788
2085
  }
1789
- function Jn(e) {
1790
- return [...e].sort((e, t) => e.range.start - t.range.start);
1791
- }
1792
- function Yn(e) {
2086
+ function dr(e) {
1793
2087
  let t = /* @__PURE__ */ new Map();
1794
2088
  for (let n of e) t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`, n);
1795
- return Jn([...t.values()]);
2089
+ return X([...t.values()]);
1796
2090
  }
1797
- function Xn(e) {
2091
+ function fr(e) {
1798
2092
  return e.replace(/\r\n?/g, "\n");
1799
2093
  }
1800
- function $(e) {
1801
- return Array.from(e).length;
1802
- }
1803
- function Zn(e) {
2094
+ function pr(e) {
1804
2095
  return e.startsWith("file://") || e.startsWith("/") || e.startsWith("./") || e.startsWith("../") || /^[A-Za-z]:[\\/]/.test(e);
1805
2096
  }
1806
- function Qn(e) {
2097
+ function mr(e) {
1807
2098
  let t = e.trim();
1808
2099
  if (!t.startsWith("file://")) return t;
2100
+ let n = URL.parse(t);
2101
+ if (!n) return t;
1809
2102
  try {
1810
- return decodeURI(new URL(t).pathname);
2103
+ return decodeURIComponent(n.pathname);
1811
2104
  } catch {
1812
- return t;
2105
+ return n.pathname;
1813
2106
  }
1814
2107
  }
1815
- function $n(e) {
1816
- let t = e.replace(/[\\/]+$/, "").split(/[\\/]/).filter(Boolean).pop();
1817
- return t ? decodeURIComponent(t) : e;
2108
+ function hr(e) {
2109
+ return e.replace(/[\\/]+$/, "").split(/[\\/]/).filter(Boolean).pop() ?? e;
1818
2110
  }
1819
- function er(e) {
2111
+ function gr(e) {
1820
2112
  return /[\\/]$/.test(e);
1821
2113
  }
1822
- function tr(e) {
2114
+ function _r(e) {
1823
2115
  return e.split(/\r?\n/).map((e) => e.trim()).find((e) => e && !e.startsWith("#")) ?? "";
1824
2116
  }
1825
- function nr(e) {
1826
- let t = tr(e);
2117
+ function vr(e) {
2118
+ let t = _r(e);
1827
2119
  return t ? t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim() ?? t : "";
1828
2120
  }
1829
- function rr(e) {
2121
+ function yr(e) {
1830
2122
  try {
1831
2123
  let t = new URL(e);
1832
2124
  return t.protocol === "http:" || t.protocol === "https:";
@@ -1834,69 +2126,65 @@ function rr(e) {
1834
2126
  return !1;
1835
2127
  }
1836
2128
  }
1837
- function ir(e) {
1838
- return Ke(e.trim());
1839
- }
1840
- function ar(e, t) {
1841
- return (e % t + t) % t;
1842
- }
1843
- function or(e, t, n) {
1844
- return `${e}:${n}:${t}`;
2129
+ function br(e) {
2130
+ return qe(e.trim());
1845
2131
  }
1846
2132
  //#endregion
1847
2133
  //#region src/lib/Composer.tsx
1848
- function sr(e) {
2134
+ function xr(e) {
1849
2135
  let t = i(3), n = e.draftKey ?? "", r;
1850
- return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */ S(lr, { ...e }, n), t[0] = e, t[1] = n, t[2] = r) : r = t[2], r;
2136
+ return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */ w(Cr, { ...e }, n), t[0] = e, t[1] = n, t[2] = r) : r = t[2], r;
1851
2137
  }
1852
- function cr(e) {
2138
+ function Sr(e) {
1853
2139
  return typeof e == "object" && !!e && "then" in e && typeof e.then == "function";
1854
2140
  }
1855
- function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r = !1, queueSubmissions: i = !1, hasInteracted: a = !1, maxExpandedTextChars: o, editorAriaLabel: u = "Rich prompt composer", className: d, children: f, validateSubmission: p, onSubmit: m, onStateChange: y }) {
1856
- let b = c(), x = jt(f), w = _({
1857
- signature: Mt(x),
1858
- slashCommands: x.slashCommands,
1859
- mentionCandidates: x.mentionCandidates,
1860
- commandTriggers: x.commandTriggers,
1861
- mentionTriggers: x.mentionTriggers
1862
- }), ee = Mt(x);
1863
- ee !== w.current.signature && (w.current = {
1864
- signature: ee,
1865
- slashCommands: x.slashCommands,
1866
- mentionCandidates: x.mentionCandidates,
1867
- commandTriggers: x.commandTriggers,
1868
- mentionTriggers: x.mentionTriggers
2141
+ function Cr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r = !1, queueSubmissions: i = !1, hasInteracted: a = !1, maxExpandedTextChars: o, editorAriaLabel: u = "Rich prompt composer", className: d, children: f, dictation: p, validateSubmission: m, onSubmit: h, onStateChange: g }) {
2142
+ let ee = c(), S = Mt(f), te = b({
2143
+ signature: Nt(S),
2144
+ slashCommands: S.slashCommands,
2145
+ mentionCandidates: S.mentionCandidates,
2146
+ commandTriggers: S.commandTriggers,
2147
+ mentionTriggers: S.mentionTriggers
2148
+ }), C = Nt(S);
2149
+ C !== te.current.signature && (te.current = {
2150
+ signature: C,
2151
+ slashCommands: S.slashCommands,
2152
+ mentionCandidates: S.mentionCandidates,
2153
+ commandTriggers: S.commandTriggers,
2154
+ mentionTriggers: S.mentionTriggers
1869
2155
  });
1870
- let { slashCommands: T, mentionCandidates: E, commandTriggers: D, mentionTriggers: te } = w.current, O = g(() => ({
1871
- commandTriggers: D,
1872
- mentionTriggers: te
1873
- }), [D, te]), ne = _(te);
1874
- ne.current = te;
1875
- let [re] = v(() => {
2156
+ let { slashCommands: E, mentionCandidates: D, commandTriggers: O, mentionTriggers: k } = te.current, A = y(() => ({
2157
+ commandTriggers: O,
2158
+ mentionTriggers: k
2159
+ }), [O, k]), ne = b(k);
2160
+ ne.current = k;
2161
+ let [re] = x(() => {
1876
2162
  if (e) return e;
1877
2163
  if (t === void 0) return;
1878
- let n = bt(t);
1879
- return n ? We({
2164
+ let n = xt(t);
2165
+ return n ? Ge({
1880
2166
  source: n,
1881
- slashCommands: T,
1882
- mentionCandidates: E
2167
+ slashCommands: E,
2168
+ mentionCandidates: D
1883
2169
  }) : void 0;
1884
- }), ie = _(re?.remoteImages ?? []), k = _(qt({
2170
+ }), j = b(re?.remoteImages ?? []), ie = b(un({
1885
2171
  state: re,
1886
- slashCommands: T,
1887
- mentionCandidates: E,
1888
- triggers: O
1889
- })), oe = _(0), se = _(!0);
1890
- h(() => (se.current = !0, () => {
1891
- se.current = !1;
2172
+ slashCommands: E,
2173
+ mentionCandidates: D,
2174
+ triggers: A
2175
+ })), M = b(0), N = b(!0);
2176
+ _(() => (N.current = !0, () => {
2177
+ N.current = !1;
1892
2178
  }), []);
1893
- let [ce, A] = v(ie.current), [j, M] = v(null), [N, P] = v(() => Qt(k.current, ie.current, T, r, i, 0)), F = _(N), I = _(ce), L = _(j), R = _(null), z = _(null), le = _(void 0), B = _(null), ue = _(null), V = _(null), de = _(y), fe = _(p), pe = _(m), H = _(/* @__PURE__ */ new Map()), U = _(() => null), W = _(() => void 0), _e = _(() => void 0), ve = _(() => !1), G = s({
1894
- extensions: g(() => zt({
2179
+ let [P, F] = x(j.current), [I, L] = x(null), [R, z] = x(() => hn(ie.current, j.current, E, r, i, 0)), B = b(R), V = b(P), H = b(I), oe = b(null), U = b(null), W = b(void 0), G = b(null), se = b(null), ce = b(null), le = v((e, t) => {
2180
+ g?.(e, t);
2181
+ }), ue = b(m), de = b(h), fe = b(/* @__PURE__ */ new Map()), pe = b(() => null), K = b(() => void 0), q = b(() => void 0), _e = b(() => !1), J = s({
2182
+ extensions: y(() => tn({
1895
2183
  getMentionTrigger: () => ne.current[0] ?? "@",
1896
- getRemoteImageCount: () => I.current.length,
1897
- attachImageFile: (e) => U.current(e)
2184
+ getRemoteImageCount: () => V.current.length,
2185
+ attachImageFile: (e) => pe.current(e)
1898
2186
  }), []),
1899
- content: k.current,
2187
+ content: ie.current,
1900
2188
  editable: !n,
1901
2189
  editorProps: {
1902
2190
  attributes: {
@@ -1908,65 +2196,61 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
1908
2196
  spellcheck: "false"
1909
2197
  },
1910
2198
  handleKeyDown(e, t) {
1911
- return ve.current(t);
2199
+ return _e.current(t);
1912
2200
  }
1913
2201
  },
1914
2202
  immediatelyRender: !1,
1915
2203
  onUpdate({ editor: e }) {
1916
- W.current(e), _e.current(e);
2204
+ K.current(e), q.current(e);
1917
2205
  },
1918
2206
  onSelectionUpdate({ editor: e }) {
1919
- W.current(e), _e.current(e);
2207
+ K.current(e), q.current(e);
1920
2208
  }
1921
- }), ye = g(() => j ? Lt(j, T, E, a) : [], [
1922
- j,
2209
+ }), ve = y(() => I ? Rt(I, E, D, a) : [], [
2210
+ I,
1923
2211
  a,
1924
- E,
1925
- T
1926
- ]), xe = g(() => he(N, T, D), [
1927
2212
  D,
1928
- N,
1929
- T
2213
+ E
2214
+ ]), ye = y(() => he(R, E, O), [
2215
+ O,
2216
+ R,
2217
+ E
1930
2218
  ]);
1931
- h(() => {
1932
- F.current = N;
1933
- }, [N]), h(() => {
1934
- I.current = ce;
1935
- }, [ce]), h(() => {
1936
- L.current = j;
1937
- }, [j]), h(() => {
1938
- N.shortcutsOpen && (j || N.reverseSearch !== null || !me(N)) && P((e) => e.shortcutsOpen ? {
2219
+ _(() => {
2220
+ B.current = R;
2221
+ }, [R]), _(() => {
2222
+ V.current = P;
2223
+ }, [P]), _(() => {
2224
+ H.current = I;
2225
+ }, [I]), _(() => {
2226
+ R.shortcutsOpen && (I || R.reverseSearch !== null || !me(R)) && z((e) => e.shortcutsOpen ? {
1939
2227
  ...e,
1940
2228
  shortcutsOpen: !1
1941
2229
  } : e);
1942
- }, [j, N]), h(() => {
1943
- de.current = y;
1944
- }, [y]), h(() => {
1945
- fe.current = p;
1946
- }, [p]), h(() => {
1947
- pe.current = m;
1948
- }, [m]), h(() => {
1949
- G && (G.setEditable(!n), G.view.dom.setAttribute("aria-disabled", n ? "true" : "false"), n && M(null));
1950
- }, [n, G]), h(() => {
1951
- G?.view.dom.setAttribute("aria-label", u);
1952
- }, [G, u]), h(() => {
1953
- de.current?.(N, xe), t !== void 0 && (xe ? xt(t, Ve(N, xe.persistedPrompt)) : oe.current === 0 && xt(t, null));
2230
+ }, [I, R]), _(() => {
2231
+ ue.current = m;
2232
+ }, [m]), _(() => {
2233
+ de.current = h;
2234
+ }, [h]), _(() => {
2235
+ J && (J.setEditable(!n), n && L(null));
2236
+ }, [n, J]), _(() => {
2237
+ le(R, ye), t !== void 0 && (ye ? St(t, He(R, ye.persistedPrompt)) : M.current === 0 && St(t, null));
1954
2238
  }, [
1955
- N,
2239
+ R,
1956
2240
  t,
1957
- xe
1958
- ]), h(() => {
1959
- P((e) => e.isTaskRunning === r && e.queueSubmissions === i ? e : {
2241
+ ye
2242
+ ]), _(() => {
2243
+ z((e) => e.isTaskRunning === r && e.queueSubmissions === i ? e : {
1960
2244
  ...e,
1961
2245
  isTaskRunning: r,
1962
2246
  queueSubmissions: i
1963
2247
  });
1964
- }, [r, i]), W.current = (e) => {
2248
+ }, [r, i]), K.current = (e) => {
1965
2249
  if (n) return;
1966
- let t = Qt(e.getJSON(), I.current, T, r, i, Un(e)), a = z.current, o = le.current;
1967
- z.current = null, le.current = void 0, P((e) => {
1968
- let n = o === void 0 ? B.current : o;
1969
- B.current = n;
2250
+ let t = hn(e.getJSON(), V.current, E, r, i, or(e)), a = U.current, o = W.current;
2251
+ U.current = null, W.current = void 0, z((e) => {
2252
+ let n = o === void 0 ? G.current : o;
2253
+ G.current = n;
1970
2254
  let r = e.shortcutsOpen && me(t);
1971
2255
  return {
1972
2256
  ...t,
@@ -1979,46 +2263,46 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
1979
2263
  selectedRemoteImageId: a
1980
2264
  };
1981
2265
  });
1982
- }, _e.current = (e) => {
2266
+ }, q.current = (e) => {
1983
2267
  if (n) {
1984
- M(null);
2268
+ L(null);
1985
2269
  return;
1986
2270
  }
1987
- let t = un(e, O);
2271
+ let t = Dn(e, A);
1988
2272
  if (!t) {
1989
- M(null);
2273
+ L(null);
1990
2274
  return;
1991
2275
  }
1992
- if (D.includes(t.trigger)) {
2276
+ if (O.includes(t.trigger)) {
1993
2277
  let e = {
1994
2278
  trigger: t.trigger,
1995
2279
  query: t.query,
1996
2280
  selectedIndex: 0
1997
- }, n = Lt(e, T, E, a);
1998
- M((t) => n.length === 0 ? null : {
2281
+ }, n = Rt(e, E, D, a);
2282
+ L((t) => n.length === 0 ? null : {
1999
2283
  ...e,
2000
2284
  selectedIndex: t?.trigger === e.trigger ? Math.min(t.selectedIndex, n.length - 1) : 0
2001
2285
  });
2002
2286
  return;
2003
2287
  }
2004
- M((e) => {
2288
+ L((e) => {
2005
2289
  let n = t.trigger, r = {
2006
2290
  trigger: n,
2007
2291
  query: t.query,
2008
2292
  selectedIndex: e?.trigger === n ? e.selectedIndex : 0
2009
- }, i = Lt(r, T, E, a);
2293
+ }, i = Rt(r, E, D, a);
2010
2294
  return {
2011
2295
  ...r,
2012
2296
  selectedIndex: e?.trigger === n ? Math.min(e.selectedIndex, Math.max(i.length - 1, 0)) : 0
2013
2297
  };
2014
2298
  });
2015
2299
  };
2016
- function K(e) {
2017
- G?.commands.setContent(e), G && (W.current(G), _e.current(G));
2300
+ function Y(e) {
2301
+ J?.commands.setContent(e), J && (K.current(J), q.current(J));
2018
2302
  }
2019
- function Se(e) {
2020
- if (n || !G) return;
2021
- let t = un(G, O), r = [{
2303
+ function xe(e) {
2304
+ if (n || !J) return;
2305
+ let t = Dn(J, A), r = [{
2022
2306
  type: "text",
2023
2307
  text: `${e.trigger}${e.value}`,
2024
2308
  marks: [{
@@ -2032,168 +2316,168 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2032
2316
  type: "text",
2033
2317
  text: " "
2034
2318
  }];
2035
- t && t.trigger === e.trigger ? G.chain().focus().deleteRange({
2319
+ t && t.trigger === e.trigger ? J.chain().focus().deleteRange({
2036
2320
  from: t.from,
2037
2321
  to: t.to
2038
- }).insertContent(r).run() : G.chain().focus().insertContent(r).run(), M(null);
2322
+ }).insertContent(r).run() : J.chain().focus().insertContent(r).run(), L(null);
2039
2323
  }
2040
- function Ce({ index: e = L.current?.selectedIndex ?? 0 } = {}) {
2041
- let t = L.current;
2042
- if (n || !G || !t) return;
2043
- let r = Lt(t, T, E, a), i = r[e] ?? r[0];
2324
+ function Se({ index: e = H.current?.selectedIndex ?? 0 } = {}) {
2325
+ let t = H.current;
2326
+ if (n || !J || !t) return;
2327
+ let r = Rt(t, E, D, a), i = r[e] ?? r[0];
2044
2328
  if (!i) return;
2045
2329
  if (!i.atomic) {
2046
- Se(i);
2330
+ xe(i);
2047
2331
  return;
2048
2332
  }
2049
- let o = un(G, O), s = o?.trigger === t.trigger, c = G.chain().focus();
2333
+ let o = Dn(J, A), s = o?.trigger === t.trigger, c = J.chain().focus();
2050
2334
  s && o && c.deleteRange({
2051
2335
  from: o.from,
2052
2336
  to: o.to
2053
- }), c.insertContent([on(i), {
2337
+ }), c.insertContent([Cn(i), {
2054
2338
  type: "text",
2055
2339
  text: " "
2056
- }]).run(), M(null);
2340
+ }]).run(), L(null);
2057
2341
  }
2058
- function we() {
2059
- if (n || !G) return;
2060
- G.commands.focus();
2061
- let e = D[0];
2062
- e && M((t) => t?.trigger === e ? null : {
2342
+ function Ce() {
2343
+ if (n || !J) return;
2344
+ J.commands.focus();
2345
+ let e = O[0];
2346
+ e && L((t) => t?.trigger === e ? null : {
2063
2347
  trigger: e,
2064
2348
  query: "",
2065
2349
  selectedIndex: 0
2066
2350
  });
2067
2351
  }
2068
- function Te(e) {
2069
- return me(e) && e.reverseSearch === null && L.current === null;
2352
+ function we(e) {
2353
+ return me(e) && e.reverseSearch === null && H.current === null;
2070
2354
  }
2071
- function Ee() {
2072
- n || P((e) => Te(e) && !e.shortcutsOpen ? {
2355
+ function Te() {
2356
+ n || z((e) => we(e) && !e.shortcutsOpen ? {
2073
2357
  ...e,
2074
2358
  shortcutsOpen: !0,
2075
2359
  selectedRemoteImageId: null,
2076
2360
  error: null
2077
2361
  } : e);
2078
2362
  }
2079
- function De() {
2080
- P((e) => e.shortcutsOpen ? {
2363
+ function Ee() {
2364
+ z((e) => e.shortcutsOpen ? {
2081
2365
  ...e,
2082
2366
  shortcutsOpen: !1
2083
2367
  } : e);
2084
2368
  }
2085
- function Oe() {
2086
- n || P((e) => e.shortcutsOpen ? {
2369
+ function De() {
2370
+ n || z((e) => e.shortcutsOpen ? {
2087
2371
  ...e,
2088
2372
  shortcutsOpen: !1
2089
- } : Te(e) ? {
2373
+ } : we(e) ? {
2090
2374
  ...e,
2091
2375
  shortcutsOpen: !0,
2092
2376
  selectedRemoteImageId: null,
2093
2377
  error: null
2094
2378
  } : e);
2095
2379
  }
2096
- function ke(e) {
2097
- n || !G || !e || G.chain().focus().insertContent(e).run();
2380
+ function Oe(e) {
2381
+ n || !J || !e || J.chain().focus().insertContent(e).run();
2098
2382
  }
2099
- function Ae(e) {
2100
- if (J(e) === null) return P((t) => ({
2383
+ function ke(e) {
2384
+ if (Ie(e) === null) return z((t) => ({
2101
2385
  ...t,
2102
2386
  error: `Only image, video, or audio files can be attached: ${e.name || "unnamed file"}`,
2103
2387
  shortcutsOpen: !1
2104
- })), M(null), null;
2388
+ })), L(null), null;
2105
2389
  let t = crypto.randomUUID();
2106
- return H.current.set(t, e), t;
2390
+ return fe.current.set(t, e), t;
2107
2391
  }
2108
- function je(e, t) {
2109
- let n = Ae(t);
2392
+ function Ae(e, t) {
2393
+ let n = ke(t);
2110
2394
  if (n === null) return;
2111
- let r = X(), i = r.remoteImages.length + r.imageAttachments.length + 1, a = J(t) ?? "image";
2112
- e.chain().focus().insertContent([ln(n, Ie(a, i), a), {
2395
+ let r = Q(), i = r.remoteImages.length + r.imageAttachments.length + 1, a = Ie(t) ?? "image";
2396
+ e.chain().focus().insertContent([En(n, Re(a, i), a), {
2113
2397
  type: "text",
2114
2398
  text: " "
2115
2399
  }]).run();
2116
2400
  }
2401
+ function je(e) {
2402
+ if (!(n || !J)) for (let t of e) Ae(J, t);
2403
+ }
2117
2404
  function Me(e) {
2118
- if (!(n || !G)) for (let t of e) je(G, t);
2405
+ n || !J || (fe.current.delete(e), Y(zn(Vn(J.getJSON(), e), V.current.length)));
2119
2406
  }
2120
2407
  function Ne(e) {
2121
- n || !G || (H.current.delete(e), K(Sn(wn(G.getJSON(), e), I.current.length)));
2122
- }
2123
- function Pe(e) {
2124
- if (n || !G) return;
2125
- let t = [...I.current, {
2126
- id: or("remote-image", e, b.Date.now()),
2408
+ if (n || !J) return;
2409
+ let t = [...V.current, {
2410
+ id: $("remote-image", e, ee.Date.now()),
2127
2411
  url: e
2128
2412
  }];
2129
- I.current = t, A(t), K(Sn(G.getJSON(), t.length));
2413
+ V.current = t, F(t), Y(zn(J.getJSON(), t.length));
2130
2414
  }
2131
- function q(e) {
2132
- return n || !G ? !1 : Kt(G.view, e, I.current.length, te[0] ?? "@", Ae);
2415
+ function Pe(e) {
2416
+ return n || !J ? !1 : ln(J.view, e, V.current.length, k[0] ?? "@", ke);
2133
2417
  }
2134
- function Fe(e) {
2418
+ function X(e) {
2135
2419
  if (n) return;
2136
- let t = I.current[e] ?? F.current.remoteImages[e];
2137
- t && (z.current = t.id, P((e) => ({
2420
+ let t = V.current[e] ?? B.current.remoteImages[e];
2421
+ t && (U.current = t.id, z((e) => ({
2138
2422
  ...e,
2139
2423
  selectedRemoteImageId: t.id,
2140
2424
  shortcutsOpen: !1
2141
2425
  })));
2142
2426
  }
2143
- function Y() {
2144
- n || (z.current = null, P((e) => e.selectedRemoteImageId ? {
2427
+ function Fe() {
2428
+ n || (U.current = null, z((e) => e.selectedRemoteImageId ? {
2145
2429
  ...e,
2146
2430
  selectedRemoteImageId: null,
2147
2431
  shortcutsOpen: !1
2148
2432
  } : e));
2149
2433
  }
2150
2434
  function Le(e) {
2151
- return F.current.selectedRemoteImageId ? e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Escape" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" ? (Y(), M(null), !0) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? (Y(), !0) : !1 : !1;
2435
+ return B.current.selectedRemoteImageId ? e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Escape" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" ? (Fe(), L(null), !0) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? (Fe(), !0) : !1 : !1;
2152
2436
  }
2153
2437
  function ze(e) {
2154
2438
  if (n) return e.preventDefault(), !0;
2155
- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(), Y(), M(null), G?.commands.selectAll(), !0;
2156
- let t = X(), r = F.current.selectedRemoteImageId;
2157
- if (!L.current && e.key === "ArrowUp") {
2158
- let n = Re({
2439
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(), Fe(), L(null), J?.commands.selectAll(), !0;
2440
+ let t = Q(), r = B.current.selectedRemoteImageId;
2441
+ if (!H.current && e.key === "ArrowUp") {
2442
+ let n = Be({
2159
2443
  ...t,
2160
2444
  selectedRemoteImageId: r
2161
2445
  }, r);
2162
- if (n !== null) return e.preventDefault(), Fe(Math.max(0, n - 1)), !0;
2163
- if ((G && Wn(G) || t.cursor === 0) && t.remoteImages.length > 0) return e.preventDefault(), Fe(t.remoteImages.length - 1), !0;
2446
+ if (n !== null) return e.preventDefault(), X(Math.max(0, n - 1)), !0;
2447
+ if ((J && sr(J) || t.cursor === 0) && t.remoteImages.length > 0) return e.preventDefault(), X(t.remoteImages.length - 1), !0;
2164
2448
  }
2165
- if (!L.current && r && e.key === "ArrowDown") {
2449
+ if (!H.current && r && e.key === "ArrowDown") {
2166
2450
  e.preventDefault();
2167
- let n = Re({
2451
+ let n = Be({
2168
2452
  ...t,
2169
2453
  selectedRemoteImageId: r
2170
2454
  }, r);
2171
- return n !== null && n + 1 < t.remoteImages.length ? Fe(n + 1) : Y(), !0;
2455
+ return n !== null && n + 1 < t.remoteImages.length ? X(n + 1) : Fe(), !0;
2172
2456
  }
2173
- return !L.current && r && (e.key === "Backspace" || e.key === "Delete") ? (e.preventDefault(), Ue(r), !0) : (Le(e), !1);
2457
+ return !H.current && r && (e.key === "Backspace" || e.key === "Delete") ? (e.preventDefault(), We(r), !0) : (Le(e), !1);
2174
2458
  }
2175
- function Ue(e) {
2176
- if (n || !G) return;
2177
- let t = X(), r = t.remoteImages.findIndex((t) => t.id === e), i = t.remoteImages.filter((t) => t.id !== e), a = r === -1 ? null : i[r] ?? i[r - 1] ?? null;
2178
- z.current = a?.id ?? null, I.current = i, A(i), K(Sn(G.getJSON(), i.length)), P((e) => ({
2459
+ function We(e) {
2460
+ if (n || !J) return;
2461
+ let t = Q(), r = t.remoteImages.findIndex((t) => t.id === e), i = t.remoteImages.filter((t) => t.id !== e), a = r === -1 ? null : i[r] ?? i[r - 1] ?? null;
2462
+ U.current = a?.id ?? null, V.current = i, F(i), Y(zn(J.getJSON(), i.length)), z((e) => ({
2179
2463
  ...e,
2180
2464
  remoteImages: i,
2181
2465
  selectedRemoteImageId: a?.id ?? null,
2182
2466
  shortcutsOpen: !1
2183
2467
  }));
2184
2468
  }
2185
- function Ge(e) {
2186
- if (n || !G) return;
2187
- let t = En(G.getJSON(), $(e));
2188
- G.chain().focus().insertContent(cn({
2469
+ function Ke(e) {
2470
+ if (n || !J) return;
2471
+ let t = Un(J.getJSON(), Z(e));
2472
+ J.chain().focus().insertContent(Tn({
2189
2473
  kind: "paste",
2190
2474
  label: t,
2191
- detail: `${$(e)} chars`,
2475
+ detail: `${Z(e)} chars`,
2192
2476
  content: e
2193
2477
  })).run();
2194
2478
  }
2195
- function Ke(e, t = e, r) {
2196
- n || G?.chain().focus().insertContent(cn({
2479
+ function qe(e, t = e, r) {
2480
+ n || J?.chain().focus().insertContent(Tn({
2197
2481
  kind: "rich-link",
2198
2482
  label: t,
2199
2483
  detail: e,
@@ -2201,38 +2485,45 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2201
2485
  metadata: r
2202
2486
  })).run();
2203
2487
  }
2204
- function X() {
2205
- return G ? {
2206
- ...Qt(G.getJSON(), I.current, T, r, i, Un(G)),
2207
- error: F.current.error,
2208
- history: F.current.history,
2209
- historyCursor: B.current ?? F.current.historyCursor,
2210
- killBuffer: F.current.killBuffer,
2211
- reverseSearch: F.current.reverseSearch,
2212
- shortcutsOpen: F.current.shortcutsOpen,
2213
- selectedRemoteImageId: F.current.selectedRemoteImageId
2214
- } : F.current;
2215
- }
2216
- function qe(e) {
2217
- let t = fe.current?.(e);
2218
- return t ? (P((e) => ({
2488
+ function Q() {
2489
+ return J ? {
2490
+ ...hn(J.getJSON(), V.current, E, r, i, or(J)),
2491
+ error: B.current.error,
2492
+ history: B.current.history,
2493
+ historyCursor: G.current ?? B.current.historyCursor,
2494
+ killBuffer: B.current.killBuffer,
2495
+ reverseSearch: B.current.reverseSearch,
2496
+ shortcutsOpen: B.current.shortcutsOpen,
2497
+ selectedRemoteImageId: B.current.selectedRemoteImageId
2498
+ } : B.current;
2499
+ }
2500
+ function Je(e) {
2501
+ let t = ue.current?.(e);
2502
+ return t ? (z((e) => ({
2219
2503
  ...e,
2220
2504
  error: t,
2221
2505
  shortcutsOpen: !1
2222
- })), M(null), !0) : !1;
2506
+ })), L(null), !0) : !1;
2507
+ }
2508
+ function Ye(e) {
2509
+ let t = Q(), n = t.text.slice(0, t.cursor);
2510
+ Oe(n && !/\s$/.test(n) ? ` ${e}` : e);
2223
2511
  }
2224
- function Je() {
2512
+ function Xe() {
2513
+ mt?.endWithSend() || Ze();
2514
+ }
2515
+ function Ze() {
2225
2516
  if (n) return;
2226
- let e = X(), r = G?.getJSON() ?? rn(), i = e.isTaskRunning || e.queueSubmissions, a = i ? null : be(e.text, T, D);
2517
+ let e = Q(), r = J?.getJSON() ?? bn(), i = e.isTaskRunning || e.queueSubmissions, a = i ? null : be(e.text, E, O);
2227
2518
  if (a) {
2228
- P((e) => ({
2519
+ z((e) => ({
2229
2520
  ...e,
2230
2521
  error: `Unrecognized command: /${a}`,
2231
2522
  shortcutsOpen: !1
2232
- })), M(null);
2523
+ })), L(null);
2233
2524
  return;
2234
2525
  }
2235
- let s = he(e, T, D), c = s ?? {
2526
+ let s = he(e, E, O), c = s ?? {
2236
2527
  mode: "submitted",
2237
2528
  prompt: "",
2238
2529
  persistedPrompt: "",
@@ -2246,22 +2537,22 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2246
2537
  mentionBindings: []
2247
2538
  }, l = ge(c, o);
2248
2539
  if (l) {
2249
- P((e) => ({
2540
+ z((e) => ({
2250
2541
  ...e,
2251
2542
  error: l,
2252
2543
  shortcutsOpen: !1
2253
- })), M(null);
2544
+ })), L(null);
2254
2545
  return;
2255
2546
  }
2256
2547
  let u = /* @__PURE__ */ new Map(), d = [];
2257
2548
  for (let t of e.imageAttachments) {
2258
- let e = H.current.get(t.id);
2549
+ let e = fe.current.get(t.id);
2259
2550
  if (!e) {
2260
- P((e) => ({
2551
+ z((e) => ({
2261
2552
  ...e,
2262
2553
  error: `Attached image is no longer available: ${t.placeholder}`,
2263
2554
  shortcutsOpen: !1
2264
- })), M(null);
2555
+ })), L(null);
2265
2556
  return;
2266
2557
  }
2267
2558
  u.set(t.id, e), d.push({
@@ -2276,31 +2567,31 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2276
2567
  ...c.items.filter((e) => e.type !== "remote_image")
2277
2568
  ], p = {
2278
2569
  id: crypto.randomUUID(),
2279
- at: new Date(b.Date.now()).toLocaleTimeString(),
2570
+ at: new Date(ee.Date.now()).toLocaleTimeString(),
2280
2571
  mode: i ? "queued" : c.mode,
2281
2572
  prompt: c.prompt,
2282
2573
  persistedPrompt: c.persistedPrompt,
2283
- action: i ? Gn(c, D) : c.action,
2574
+ action: i ? cr(c, O) : c.action,
2284
2575
  command: c.command,
2285
2576
  args: c.args,
2286
2577
  items: f
2287
2578
  };
2288
- if (qe(p)) return;
2289
- for (let e of u.keys()) H.current.delete(e);
2290
- let m = Ve(e, c.persistedPrompt), h = pe.current?.(p, { editableSource: m });
2291
- cr(h) && (oe.current += 1, h.then(() => {
2292
- t !== void 0 && xt(t, null);
2579
+ if (Je(p)) return;
2580
+ for (let e of u.keys()) fe.current.delete(e);
2581
+ let m = He(e, c.persistedPrompt), h = de.current?.(p, { editableSource: m });
2582
+ Sr(h) && (M.current += 1, h.then(() => {
2583
+ t !== void 0 && St(t, null);
2293
2584
  }).catch((e) => {
2294
- for (let [e, t] of u) H.current.set(e, t);
2295
- t !== void 0 && xt(t, m), se.current && (K(r), G?.commands.focus("end"), P((t) => ({
2585
+ for (let [e, t] of u) fe.current.set(e, t);
2586
+ t !== void 0 && St(t, m), N.current && (Y(r), J?.commands.focus("end"), z((t) => ({
2296
2587
  ...t,
2297
2588
  error: e instanceof Error ? e.message : "Could not send prompt"
2298
2589
  })));
2299
2590
  }).finally(() => {
2300
- --oe.current;
2591
+ --M.current;
2301
2592
  }));
2302
- let g = s ? He(e, c.historyPrompt) : e.history;
2303
- B.current = null, I.current = [], A([]), M(null), K(rn()), P((e) => ({
2593
+ let g = s ? Ue(e, c.historyPrompt) : e.history;
2594
+ G.current = null, V.current = [], F([]), L(null), Y(bn()), z((e) => ({
2304
2595
  ...e,
2305
2596
  text: "",
2306
2597
  cursor: 0,
@@ -2316,10 +2607,10 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2316
2607
  historyCursor: null
2317
2608
  }));
2318
2609
  }
2319
- function Ye() {
2610
+ function Qe() {
2320
2611
  if (n) return;
2321
- let e = F.current.history, t = F.current.killBuffer;
2322
- B.current = null, V.current = null, H.current.clear(), I.current = ie.current, A(ie.current), M(null), K(k.current), G?.commands.focus("end"), P((n) => ({
2612
+ let e = B.current.history, t = B.current.killBuffer;
2613
+ G.current = null, ce.current = null, fe.current.clear(), V.current = j.current, F(j.current), L(null), Y(ie.current), J?.commands.focus("end"), z((n) => ({
2323
2614
  ...n,
2324
2615
  history: e,
2325
2616
  historyCursor: null,
@@ -2330,61 +2621,61 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2330
2621
  shortcutsOpen: !1
2331
2622
  }));
2332
2623
  }
2333
- function Xe(e) {
2334
- if (n || !G || F.current.history.length === 0) return;
2335
- let t = F.current, r = B.current ?? t.historyCursor;
2336
- if (e > 0 && r === 0 && ue.current) {
2337
- Qe(ue.current, null), ue.current = null;
2624
+ function $e(e) {
2625
+ if (n || !J || B.current.history.length === 0) return;
2626
+ let t = B.current, r = G.current ?? t.historyCursor;
2627
+ if (e > 0 && r === 0 && se.current) {
2628
+ tt(se.current, null), se.current = null;
2338
2629
  return;
2339
2630
  }
2340
- let i = r === null ? e < 0 ? 0 : t.history.length - 1 : ar(r + e, t.history.length);
2341
- r === null && (ue.current = Be(X()));
2631
+ let i = r === null ? e < 0 ? 0 : t.history.length - 1 : ct(r + e, t.history.length);
2632
+ r === null && (se.current = Ve(Q()));
2342
2633
  let a = t.history[i];
2343
- Ze(a, i);
2634
+ et(a, i);
2344
2635
  }
2345
- function Ze(e, t) {
2346
- Qe(We({
2636
+ function et(e, t) {
2637
+ tt(Ge({
2347
2638
  source: e,
2348
- slashCommands: T,
2349
- mentionCandidates: E
2639
+ slashCommands: E,
2640
+ mentionCandidates: D
2350
2641
  }), t);
2351
2642
  }
2352
- function Qe(e, t) {
2643
+ function tt(e, t) {
2353
2644
  let n = e.remoteImages ?? [];
2354
- I.current = n, F.current = {
2355
- ...F.current,
2645
+ V.current = n, B.current = {
2646
+ ...B.current,
2356
2647
  historyCursor: t,
2357
2648
  shortcutsOpen: !1
2358
- }, B.current = t, le.current = t, A(n), K(qt({
2649
+ }, G.current = t, W.current = t, F(n), Y(un({
2359
2650
  state: e,
2360
- slashCommands: T,
2361
- mentionCandidates: E,
2362
- triggers: O
2363
- })), G?.commands.focus("end"), P((e) => ({
2651
+ slashCommands: E,
2652
+ mentionCandidates: D,
2653
+ triggers: A
2654
+ })), J?.commands.focus("end"), z((e) => ({
2364
2655
  ...e,
2365
2656
  historyCursor: t,
2366
2657
  shortcutsOpen: !1
2367
2658
  }));
2368
2659
  }
2369
- function $e() {
2370
- n || (M(null), B.current = null, V.current = X(), P((e) => ({
2660
+ function nt() {
2661
+ n || (L(null), G.current = null, ce.current = Q(), z((e) => ({
2371
2662
  ...e,
2372
2663
  reverseSearch: "",
2373
2664
  historyCursor: null,
2374
2665
  shortcutsOpen: !1
2375
2666
  })));
2376
2667
  }
2377
- function et(e) {
2668
+ function rt(e) {
2378
2669
  if (n) {
2379
2670
  e.preventDefault();
2380
2671
  return;
2381
2672
  }
2382
2673
  if (e.preventDefault(), e.key === "Escape") {
2383
- ot(null), V.current = null;
2674
+ ut(null), ce.current = null;
2384
2675
  return;
2385
2676
  }
2386
2677
  if (e.key === "Enter") {
2387
- V.current = null, P((e) => ({
2678
+ ce.current = null, z((e) => ({
2388
2679
  ...e,
2389
2680
  reverseSearch: null,
2390
2681
  shortcutsOpen: !1
@@ -2392,47 +2683,47 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2392
2683
  return;
2393
2684
  }
2394
2685
  if (e.key === "Backspace") {
2395
- tt((e) => e.slice(0, -1));
2686
+ ot((e) => e.slice(0, -1));
2396
2687
  return;
2397
2688
  }
2398
2689
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "r") {
2399
- nt(1);
2690
+ st(1);
2400
2691
  return;
2401
2692
  }
2402
2693
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "s") {
2403
- nt(-1);
2694
+ st(-1);
2404
2695
  return;
2405
2696
  }
2406
- e.key.length === 1 && !e.metaKey && !e.altKey && !e.ctrlKey && tt((t) => `${t}${e.key}`);
2697
+ e.key.length === 1 && !e.metaKey && !e.altKey && !e.ctrlKey && ot((t) => `${t}${e.key}`);
2407
2698
  }
2408
- function tt(e) {
2699
+ function ot(e) {
2409
2700
  if (n) return;
2410
- let t = F.current, r = e(t.reverseSearch ?? ""), i = rt(t.history, r, null);
2411
- if (!G || !i) {
2412
- ot(r);
2701
+ let t = B.current, r = e(t.reverseSearch ?? ""), i = it(t.history, r, null);
2702
+ if (!J || !i) {
2703
+ ut(r);
2413
2704
  return;
2414
2705
  }
2415
- at(i.entry, i.index, r);
2706
+ lt(i.entry, i.index, r);
2416
2707
  }
2417
- function nt(e) {
2418
- if (n || !G) return;
2419
- let t = F.current, r = t.reverseSearch ?? "", i = rt(t.history, r, t.historyCursor, e);
2420
- i && at(i.entry, i.index, r);
2708
+ function st(e) {
2709
+ if (n || !J) return;
2710
+ let t = B.current, r = t.reverseSearch ?? "", i = it(t.history, r, t.historyCursor, e);
2711
+ i && lt(i.entry, i.index, r);
2421
2712
  }
2422
- function at(e, t, n) {
2423
- let r = G;
2713
+ function lt(e, t, n) {
2714
+ let r = J;
2424
2715
  if (!r) return;
2425
- let i = We({
2716
+ let i = Ge({
2426
2717
  source: e,
2427
- slashCommands: T,
2428
- mentionCandidates: E
2718
+ slashCommands: E,
2719
+ mentionCandidates: D
2429
2720
  }), a = i.remoteImages ?? [];
2430
- I.current = a, A(a), K(qt({
2721
+ V.current = a, F(a), Y(un({
2431
2722
  state: i,
2432
- slashCommands: T,
2433
- mentionCandidates: E,
2434
- triggers: O
2435
- })), r.commands.focus("end"), P((e) => ({
2723
+ slashCommands: E,
2724
+ mentionCandidates: D,
2725
+ triggers: A
2726
+ })), r.commands.focus("end"), z((e) => ({
2436
2727
  ...e,
2437
2728
  historyCursor: t,
2438
2729
  reverseSearch: n,
@@ -2440,11 +2731,11 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2440
2731
  shortcutsOpen: !1
2441
2732
  }));
2442
2733
  }
2443
- function ot(e) {
2734
+ function ut(e) {
2444
2735
  if (n) return;
2445
- let t = V.current;
2446
- if (!t || !G) {
2447
- P((t) => ({
2736
+ let t = ce.current;
2737
+ if (!t || !J) {
2738
+ z((t) => ({
2448
2739
  ...t,
2449
2740
  reverseSearch: e,
2450
2741
  shortcutsOpen: !1
@@ -2453,269 +2744,278 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
2453
2744
  }
2454
2745
  let r = {
2455
2746
  ...t,
2456
- history: F.current.history,
2457
- killBuffer: F.current.killBuffer,
2747
+ history: B.current.history,
2748
+ killBuffer: B.current.killBuffer,
2458
2749
  reverseSearch: e,
2459
2750
  historyCursor: null,
2460
2751
  selectedRemoteImageId: null,
2461
2752
  shortcutsOpen: !1
2462
2753
  };
2463
- B.current = null, I.current = r.remoteImages, A(r.remoteImages), K(qt({
2754
+ G.current = null, V.current = r.remoteImages, F(r.remoteImages), Y(un({
2464
2755
  state: r,
2465
- slashCommands: T,
2466
- mentionCandidates: E,
2467
- triggers: O
2468
- })), G.commands.focus("end"), P(r);
2756
+ slashCommands: E,
2757
+ mentionCandidates: D,
2758
+ triggers: A
2759
+ })), J.commands.focus("end"), z(r);
2469
2760
  }
2470
- ve.current = n ? (e) => (e.preventDefault(), !0) : ze, U.current = Ae;
2471
- function st(e) {
2761
+ _e.current = n ? (e) => (e.preventDefault(), !0) : ze, pe.current = ke;
2762
+ function dt(e) {
2472
2763
  if (!(e.target instanceof Element) || !e.target.closest("[data-slot=\"composer-editor\"]")) return;
2473
2764
  if (n) {
2474
2765
  e.preventDefault();
2475
2766
  return;
2476
2767
  }
2477
- if (!G || ze(e)) return;
2478
- if (F.current.reverseSearch !== null) {
2479
- et(e);
2768
+ if (!J || ze(e)) return;
2769
+ if (B.current.reverseSearch !== null) {
2770
+ rt(e);
2480
2771
  return;
2481
2772
  }
2482
- if (F.current.shortcutsOpen && e.key === "Escape") {
2483
- e.preventDefault(), De();
2773
+ if (B.current.shortcutsOpen && e.key === "Escape") {
2774
+ e.preventDefault(), Ee();
2484
2775
  return;
2485
2776
  }
2486
- if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && Te(X())) {
2487
- e.preventDefault(), Oe();
2777
+ if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && we(Q())) {
2778
+ e.preventDefault(), De();
2488
2779
  return;
2489
2780
  }
2490
- if (Mr(e)) {
2491
- e.preventDefault(), G.chain().focus().setHardBreak().run(), B.current = null, M(null);
2781
+ if (Kr(e)) {
2782
+ e.preventDefault(), J.chain().focus().setHardBreak().run(), G.current = null, L(null);
2492
2783
  return;
2493
2784
  }
2494
- if (L.current) {
2495
- if (Kn(e) || qn(e)) {
2496
- e.preventDefault(), ct(Kn(e) ? -1 : 1);
2785
+ if (H.current) {
2786
+ if (lr(e) || ur(e)) {
2787
+ e.preventDefault(), pt(lr(e) ? -1 : 1);
2497
2788
  return;
2498
2789
  }
2499
2790
  if (e.key === "Tab") {
2500
- e.preventDefault(), Ce();
2791
+ e.preventDefault(), Se();
2501
2792
  return;
2502
2793
  }
2503
2794
  if (e.key === "Enter" && !e.shiftKey) {
2504
- if (e.preventDefault(), ye.length === 0) {
2505
- M(null), Je();
2795
+ if (e.preventDefault(), ve.length === 0) {
2796
+ L(null), Xe();
2506
2797
  return;
2507
2798
  }
2508
- Ce();
2799
+ Se();
2509
2800
  return;
2510
2801
  }
2511
2802
  if (e.key === "Escape") {
2512
- e.preventDefault(), M(null);
2803
+ e.preventDefault(), L(null);
2513
2804
  return;
2514
2805
  }
2515
2806
  }
2516
- if (Nr(e)) {
2517
- let t = jn(G);
2518
- t && (e.preventDefault(), R.current = t, P((e) => ({
2807
+ if (qr(e)) {
2808
+ let t = Jn(J);
2809
+ t && (e.preventDefault(), oe.current = t, z((e) => ({
2519
2810
  ...e,
2520
2811
  killBuffer: t.text
2521
- }))), B.current = null;
2812
+ }))), G.current = null;
2522
2813
  return;
2523
2814
  }
2524
- let t = Pr(e);
2815
+ let t = Jr(e);
2525
2816
  if (t !== null) {
2526
- e.preventDefault(), Nn(G, t), B.current = null;
2817
+ e.preventDefault(), Xn(J, t), G.current = null;
2527
2818
  return;
2528
2819
  }
2529
2820
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "e") {
2530
- e.preventDefault(), Mn(G), B.current = null;
2821
+ e.preventDefault(), Yn(J), G.current = null;
2531
2822
  return;
2532
2823
  }
2533
2824
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
2534
- let t = kn(G);
2535
- t && (e.preventDefault(), R.current = t, P((e) => ({
2825
+ let t = Kn(J);
2826
+ t && (e.preventDefault(), oe.current = t, z((e) => ({
2536
2827
  ...e,
2537
2828
  killBuffer: t.text
2538
2829
  })));
2539
2830
  return;
2540
2831
  }
2541
2832
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "u") {
2542
- let t = An(G);
2543
- t && (e.preventDefault(), R.current = t, P((e) => ({
2833
+ let t = qn(J);
2834
+ t && (e.preventDefault(), oe.current = t, z((e) => ({
2544
2835
  ...e,
2545
2836
  killBuffer: t.text
2546
2837
  })));
2547
2838
  return;
2548
2839
  }
2549
- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y" && F.current.killBuffer) {
2550
- e.preventDefault(), Bn(G, R.current ?? F.current.killBuffer);
2840
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y" && B.current.killBuffer) {
2841
+ e.preventDefault(), rr(J, oe.current ?? B.current.killBuffer);
2551
2842
  return;
2552
2843
  }
2553
2844
  if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "r") {
2554
- e.preventDefault(), $e();
2845
+ e.preventDefault(), nt();
2555
2846
  return;
2556
2847
  }
2557
- if ((e.key === "Backspace" || e.key === "Delete") && Ir(G)) {
2558
- e.preventDefault(), B.current = null, M(null);
2848
+ if ((e.key === "Backspace" || e.key === "Delete") && Xr(J)) {
2849
+ e.preventDefault(), G.current = null, L(null);
2559
2850
  return;
2560
2851
  }
2561
- if ((e.key === "Backspace" || e.key === "Delete") && Vn(G, e.key)) {
2562
- e.preventDefault(), B.current = null;
2852
+ if ((e.key === "Backspace" || e.key === "Delete") && ir(J, e.key)) {
2853
+ e.preventDefault(), G.current = null;
2563
2854
  return;
2564
2855
  }
2565
- if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (B.current = null), e.key === "Enter" && !e.shiftKey && !e.altKey) {
2566
- e.preventDefault(), Je();
2856
+ if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (G.current = null), e.key === "Enter" && !e.shiftKey && !e.altKey) {
2857
+ e.preventDefault(), Xe();
2567
2858
  return;
2568
2859
  }
2569
- let r = Fr(e);
2570
- if (r !== null && !L.current) {
2571
- let t = X();
2572
- if (e.key === "ArrowUp" && (Wn(G) || t.cursor === 0) && t.remoteImages.length > 0) {
2573
- e.preventDefault(), Fe(t.remoteImages.length - 1);
2860
+ let r = Yr(e);
2861
+ if (r !== null && !H.current) {
2862
+ let t = Q();
2863
+ if (e.key === "ArrowUp" && (sr(J) || t.cursor === 0) && t.remoteImages.length > 0) {
2864
+ e.preventDefault(), X(t.remoteImages.length - 1);
2574
2865
  return;
2575
2866
  }
2576
- it(t.text, t.cursor, r) && (e.preventDefault(), Xe(r));
2867
+ at(t.text, t.cursor, r) && (e.preventDefault(), $e(r));
2577
2868
  }
2578
2869
  }
2579
- function Z(e) {
2870
+ function ft(e) {
2580
2871
  if (n) {
2581
2872
  e.preventDefault();
2582
2873
  return;
2583
2874
  }
2584
- e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") && Y();
2875
+ e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") && Fe();
2585
2876
  }
2586
- function ct(e) {
2587
- n || M((t) => {
2877
+ function pt(e) {
2878
+ n || L((t) => {
2588
2879
  if (!t) return t;
2589
- let n = Lt(t, T, E, a).length;
2880
+ let n = Rt(t, E, D, a).length;
2590
2881
  return n === 0 ? t : {
2591
2882
  ...t,
2592
- selectedIndex: ar(t.selectedIndex + e, n)
2883
+ selectedIndex: ct(t.selectedIndex + e, n)
2593
2884
  };
2594
2885
  });
2595
2886
  }
2596
- return /* @__PURE__ */ S(ae, {
2887
+ let mt = $t({
2888
+ dictation: p,
2889
+ disabled: n,
2890
+ insertTranscript: Ye,
2891
+ submitDraft: Ze
2892
+ });
2893
+ return /* @__PURE__ */ w(ae, {
2597
2894
  value: {
2598
- state: N,
2895
+ state: R,
2599
2896
  disabled: n,
2600
- commandTriggers: D,
2601
- activePopup: j,
2602
- suggestions: ye,
2603
- attachedImages: H.current,
2897
+ commandTriggers: O,
2898
+ activePopup: I,
2899
+ suggestions: ve,
2900
+ attachedImages: fe.current,
2604
2901
  actions: {
2605
- acceptSuggestion: Ce,
2606
- toggleSlashMenu: we,
2607
- insertText: ke,
2608
- attachImageFiles: Me,
2609
- removeImageAttachment: Ne,
2610
- addRemoteImage: Pe,
2611
- handleDrop: q,
2612
- insertPaste: Ge,
2613
- insertRichLink: Ke,
2614
- openShortcuts: Ee,
2615
- closeShortcuts: De,
2616
- toggleShortcuts: Oe,
2617
- submit: Je,
2618
- reset: Ye
2902
+ acceptSuggestion: Se,
2903
+ toggleSlashMenu: Ce,
2904
+ insertText: Oe,
2905
+ attachImageFiles: je,
2906
+ removeImageAttachment: Me,
2907
+ addRemoteImage: Ne,
2908
+ handleDrop: Pe,
2909
+ insertPaste: Ke,
2910
+ insertRichLink: qe,
2911
+ openShortcuts: Te,
2912
+ closeShortcuts: Ee,
2913
+ toggleShortcuts: De,
2914
+ submit: Xe,
2915
+ reset: Qe
2619
2916
  },
2620
- meta: { editor: G }
2917
+ meta: { editor: J }
2621
2918
  },
2622
- children: /* @__PURE__ */ S("section", {
2623
- "data-slot": "composer",
2624
- className: l("border-border bg-card relative border font-[inherit]", d),
2625
- children: /* @__PURE__ */ C("div", {
2626
- onKeyDownCapture: st,
2627
- onMouseDownCapture: Z,
2628
- children: [f, x.hasLayoutChildren ? null : /* @__PURE__ */ S(ur, {})]
2919
+ children: /* @__PURE__ */ w(Bt, {
2920
+ value: mt?.api ?? null,
2921
+ children: /* @__PURE__ */ w("section", {
2922
+ "data-slot": "composer",
2923
+ className: l("border-border bg-card relative border font-[inherit]", d),
2924
+ children: /* @__PURE__ */ T("div", {
2925
+ onKeyDownCapture: dt,
2926
+ onMouseDownCapture: ft,
2927
+ children: [f, S.hasLayoutChildren ? null : /* @__PURE__ */ w(wr, {})]
2928
+ })
2629
2929
  })
2630
2930
  })
2631
2931
  });
2632
2932
  }
2633
- function ur() {
2933
+ function wr() {
2634
2934
  let e = i(2), t;
2635
- e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ S(gr, {}), e[0] = t) : t = e[0];
2935
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ w(Ar, {}), e[0] = t) : t = e[0];
2636
2936
  let n;
2637
- return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ C(x, { children: [
2937
+ return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ T(C, { children: [
2638
2938
  t,
2639
- /* @__PURE__ */ C(dr, { children: [
2640
- /* @__PURE__ */ S(pr, {}),
2641
- /* @__PURE__ */ S(se, {}),
2642
- /* @__PURE__ */ S(mr, {}),
2643
- /* @__PURE__ */ S(hr, {})
2939
+ /* @__PURE__ */ T(Tr, { children: [
2940
+ /* @__PURE__ */ w(Dr, {}),
2941
+ /* @__PURE__ */ w(P, {}),
2942
+ /* @__PURE__ */ w(Or, {}),
2943
+ /* @__PURE__ */ w(kr, {})
2644
2944
  ] }),
2645
- /* @__PURE__ */ S(br, {}),
2646
- /* @__PURE__ */ S(Cr, {})
2945
+ /* @__PURE__ */ w(Pr, {}),
2946
+ /* @__PURE__ */ w(Lr, {})
2647
2947
  ] }), e[1] = n) : n = e[1], n;
2648
2948
  }
2649
- function dr(e) {
2949
+ function Tr(e) {
2650
2950
  let t = i(8), n, r;
2651
2951
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2652
2952
  let a;
2653
2953
  t[3] === n ? a = t[4] : (a = l("space-y-2", n), t[3] = n, t[4] = a);
2654
2954
  let o;
2655
- return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ S("div", {
2955
+ return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ w("div", {
2656
2956
  className: a,
2657
2957
  ...r
2658
2958
  }), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
2659
2959
  }
2660
- function fr(e) {
2960
+ function Er(e) {
2661
2961
  let t = i(8), n, r;
2662
2962
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2663
2963
  let a;
2664
2964
  t[3] === n ? a = t[4] : (a = l("flex flex-wrap items-center gap-1.5", n), t[3] = n, t[4] = a);
2665
2965
  let o;
2666
- return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ S("div", {
2966
+ return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ w("div", {
2667
2967
  className: a,
2668
2968
  ...r
2669
2969
  }), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
2670
2970
  }
2671
- function pr(e) {
2971
+ function Dr(e) {
2672
2972
  let t = i(14), n, r;
2673
2973
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2674
- let { state: a } = k("Composer.RemoteImages");
2974
+ let { state: a } = M("Composer.RemoteImages");
2675
2975
  if (a.remoteImages.length === 0) return null;
2676
2976
  let o;
2677
2977
  t[3] === n ? o = t[4] : (o = l("border-border space-y-1 border-b pb-2 text-sm", n), t[3] = n, t[4] = o);
2678
2978
  let s;
2679
2979
  if (t[5] !== a.remoteImages || t[6] !== a.selectedRemoteImageId) {
2680
2980
  let e;
2681
- t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */ C("div", {
2981
+ t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */ T("div", {
2682
2982
  className: l("flex h-6 items-center gap-2 rounded-sm px-2", a.selectedRemoteImageId === e.id ? "bg-primary text-primary-foreground" : "text-sky-500"),
2683
- children: [/* @__PURE__ */ C("span", {
2983
+ children: [/* @__PURE__ */ T("span", {
2684
2984
  className: "shrink-0",
2685
2985
  children: [
2686
2986
  "[Image #",
2687
2987
  t + 1,
2688
2988
  "]"
2689
2989
  ]
2690
- }), /* @__PURE__ */ S("span", {
2990
+ }), /* @__PURE__ */ w("span", {
2691
2991
  className: "truncate text-xs opacity-70",
2692
2992
  children: e.url
2693
2993
  })]
2694
2994
  }, e.id), t[8] = a.selectedRemoteImageId, t[9] = e), s = a.remoteImages.map(e), t[5] = a.remoteImages, t[6] = a.selectedRemoteImageId, t[7] = s;
2695
2995
  } else s = t[7];
2696
2996
  let c;
2697
- return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */ S("div", {
2997
+ return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */ w("div", {
2698
2998
  className: o,
2699
2999
  ...r,
2700
3000
  children: s
2701
3001
  }), t[10] = r, t[11] = o, t[12] = s, t[13] = c) : c = t[13], c;
2702
3002
  }
2703
- function mr(e) {
3003
+ function Or(e) {
2704
3004
  let t = i(21), n, r, a, s;
2705
3005
  t[0] === e ? (n = t[1], r = t[2], a = t[3], s = t[4]) : ({className: n, onDrop: r, placeholder: s, ...a} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = s);
2706
- let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } = k("Composer.Editor"), p = u ? "" : void 0, m;
3006
+ let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } = M("Composer.Editor"), p = u ? "" : void 0, m;
2707
3007
  t[5] !== f || t[6] !== r ? (m = (e) => {
2708
3008
  r?.(e), !e.defaultPrevented && f.handleDrop(e.dataTransfer) && e.preventDefault();
2709
3009
  }, t[5] = f, t[6] = r, t[7] = m) : m = t[7];
2710
3010
  let h;
2711
- t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */ S("div", {
3011
+ t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */ w("div", {
2712
3012
  "data-slot": "composer-placeholder",
2713
3013
  children: c
2714
3014
  }) : null, t[8] = c, t[9] = l.text.length, t[10] = h) : h = t[10];
2715
3015
  let g;
2716
- t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */ S(o, { editor: d.editor }), t[11] = d.editor, t[12] = g);
3016
+ t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */ w(o, { editor: d.editor }), t[11] = d.editor, t[12] = g);
2717
3017
  let _;
2718
- return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */ C("div", {
3018
+ return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */ T("div", {
2719
3019
  "data-slot": "composer-frame",
2720
3020
  className: n,
2721
3021
  "aria-disabled": u,
@@ -2725,111 +3025,112 @@ function mr(e) {
2725
3025
  children: [h, g]
2726
3026
  }), t[13] = n, t[14] = u, t[15] = a, t[16] = p, t[17] = m, t[18] = h, t[19] = g, t[20] = _) : _ = t[20], _;
2727
3027
  }
2728
- function hr(e) {
3028
+ function kr(e) {
2729
3029
  let t = i(9), n, r;
2730
3030
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2731
- let { state: a } = k("Composer.Error");
3031
+ let { state: a } = M("Composer.Error");
2732
3032
  if (!a.error) return null;
2733
3033
  let o;
2734
3034
  t[3] === n ? o = t[4] : (o = l("border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs", n), t[3] = n, t[4] = o);
2735
3035
  let s;
2736
- return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */ S("div", {
3036
+ return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */ w("div", {
3037
+ role: "alert",
2737
3038
  className: o,
2738
3039
  ...r,
2739
3040
  children: a.error
2740
3041
  }), t[5] = r, t[6] = a.error, t[7] = o, t[8] = s) : s = t[8], s;
2741
3042
  }
2742
- function gr(e) {
3043
+ function Ar(e) {
2743
3044
  let t = i(25), n, r;
2744
3045
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2745
- let { activePopup: a, suggestions: o, actions: s } = k("Composer.Popup"), { acceptSuggestion: c } = s;
3046
+ let { activePopup: a, suggestions: o, actions: s } = M("Composer.Popup"), { acceptSuggestion: c } = s;
2746
3047
  if (!a) return null;
2747
3048
  let u;
2748
- t[3] === o ? u = t[4] : (u = o.some(_r), t[3] = o, t[4] = u);
3049
+ t[3] === o ? u = t[4] : (u = o.some(jr), t[3] = o, t[4] = u);
2749
3050
  let d = u, f;
2750
3051
  t[5] === n ? f = t[6] : (f = l("border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg", n), t[5] = n, t[6] = f);
2751
3052
  let p;
2752
3053
  if (t[7] !== c || t[8] !== a || t[9] !== o || t[10] !== d) {
2753
3054
  let e;
2754
- t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */ S(vr, {
3055
+ t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */ w(Mr, {
2755
3056
  selected: t === a.selectedIndex,
2756
3057
  icon: d ? e.icon : null,
2757
- token: U(e),
3058
+ token: K(e),
2758
3059
  takesArgs: e.supportsArgs === !0,
2759
3060
  description: e.detail,
2760
3061
  onMouseDown: () => c({ index: t })
2761
3062
  }, `item:${e.id}`), t[12] = c, t[13] = a, t[14] = d, t[15] = e) : e = t[15], p = o.map(e), t[7] = c, t[8] = a, t[9] = o, t[10] = d, t[11] = p;
2762
3063
  } else p = t[11];
2763
3064
  let m;
2764
- t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */ S("div", {
3065
+ t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */ w("div", {
2765
3066
  className: "text-muted-foreground px-2 py-1 text-[13px] leading-4",
2766
3067
  children: "no matches"
2767
3068
  }) : null, t[16] = o.length, t[17] = m);
2768
3069
  let h;
2769
- t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */ C("div", {
3070
+ t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */ T("div", {
2770
3071
  className: "flex max-h-72 flex-col gap-1 overflow-y-auto p-1",
2771
3072
  role: "listbox",
2772
3073
  "aria-label": "Suggestions",
2773
3074
  children: [p, m]
2774
3075
  }), t[18] = p, t[19] = m, t[20] = h) : h = t[20];
2775
3076
  let g;
2776
- return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */ S("div", {
3077
+ return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */ w("div", {
2777
3078
  className: f,
2778
3079
  ...r,
2779
3080
  children: h
2780
3081
  }), t[21] = r, t[22] = f, t[23] = h, t[24] = g) : g = t[24], g;
2781
3082
  }
2782
- function _r(e) {
3083
+ function jr(e) {
2783
3084
  return e.icon;
2784
3085
  }
2785
- function vr(e) {
2786
- let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u = _(null), d, f;
3086
+ function Mr(e) {
3087
+ let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u = b(null), d, f;
2787
3088
  t[0] === n ? (d = t[1], f = t[2]) : (d = () => {
2788
3089
  n && u.current?.scrollIntoView({ block: "nearest" });
2789
- }, f = [n], t[0] = n, t[1] = d, t[2] = f), h(d, f);
3090
+ }, f = [n], t[0] = n, t[1] = d, t[2] = f), _(d, f);
2790
3091
  let p = n ? "bg-accent text-foreground" : "text-foreground/80 hover:bg-accent/60", m;
2791
3092
  t[3] === p ? m = t[4] : (m = l("flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0", p), t[3] = p, t[4] = m);
2792
- let g;
2793
- t[5] === c ? g = t[6] : (g = (e) => {
3093
+ let h;
3094
+ t[5] === c ? h = t[6] : (h = (e) => {
2794
3095
  e.preventDefault(), c();
2795
- }, t[5] = c, t[6] = g);
2796
- let v;
2797
- t[7] === r ? v = t[8] : (v = r === null ? null : /* @__PURE__ */ S("span", {
3096
+ }, t[5] = c, t[6] = h);
3097
+ let g;
3098
+ t[7] === r ? g = t[8] : (g = r === null ? null : /* @__PURE__ */ w("span", {
2798
3099
  className: "flex size-4 shrink-0 items-center justify-center",
2799
3100
  children: r
2800
- }), t[7] = r, t[8] = v);
2801
- let y;
2802
- t[9] === a ? y = t[10] : (y = /* @__PURE__ */ S("span", {
3101
+ }), t[7] = r, t[8] = g);
3102
+ let v;
3103
+ t[9] === a ? v = t[10] : (v = /* @__PURE__ */ w("span", {
2803
3104
  className: "truncate",
2804
3105
  children: a
2805
- }), t[9] = a, t[10] = y);
2806
- let b;
2807
- t[11] === o ? b = t[12] : (b = o ? /* @__PURE__ */ S("span", {
3106
+ }), t[9] = a, t[10] = v);
3107
+ let y;
3108
+ t[11] === o ? y = t[12] : (y = o ? /* @__PURE__ */ w("span", {
2808
3109
  className: "text-muted-foreground shrink-0",
2809
3110
  children: "args"
2810
- }) : null, t[11] = o, t[12] = b);
3111
+ }) : null, t[11] = o, t[12] = y);
2811
3112
  let x;
2812
- t[13] === s ? x = t[14] : (x = /* @__PURE__ */ S("span", {
3113
+ t[13] === s ? x = t[14] : (x = /* @__PURE__ */ w("span", {
2813
3114
  className: "text-muted-foreground truncate",
2814
3115
  children: s
2815
3116
  }), t[13] = s, t[14] = x);
2816
- let w;
2817
- return t[15] !== n || t[16] !== m || t[17] !== g || t[18] !== v || t[19] !== y || t[20] !== b || t[21] !== x ? (w = /* @__PURE__ */ C("button", {
3117
+ let ee;
3118
+ return t[15] !== n || t[16] !== m || t[17] !== h || t[18] !== g || t[19] !== v || t[20] !== y || t[21] !== x ? (ee = /* @__PURE__ */ T("button", {
2818
3119
  ref: u,
2819
3120
  type: "button",
2820
3121
  role: "option",
2821
3122
  "aria-selected": n,
2822
3123
  className: m,
2823
- onMouseDown: g,
3124
+ onMouseDown: h,
2824
3125
  children: [
3126
+ g,
2825
3127
  v,
2826
3128
  y,
2827
- b,
2828
3129
  x
2829
3130
  ]
2830
- }), t[15] = n, t[16] = m, t[17] = g, t[18] = v, t[19] = y, t[20] = b, t[21] = x, t[22] = w) : w = t[22], w;
3131
+ }), t[15] = n, t[16] = m, t[17] = h, t[18] = g, t[19] = v, t[20] = y, t[21] = x, t[22] = ee) : ee = t[22], ee;
2831
3132
  }
2832
- var yr = [
3133
+ var Nr = [
2833
3134
  {
2834
3135
  title: "Send",
2835
3136
  items: [
@@ -2857,22 +3158,22 @@ var yr = [
2857
3158
  ]
2858
3159
  }
2859
3160
  ];
2860
- function br(e) {
3161
+ function Pr(e) {
2861
3162
  let t = i(13), n, r;
2862
3163
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2863
- let { state: a, actions: o } = k("Composer.Shortcuts"), { closeShortcuts: s } = o;
3164
+ let { state: a, actions: o } = M("Composer.Shortcuts"), { closeShortcuts: s } = o;
2864
3165
  if (!a.shortcutsOpen || !me(a)) return null;
2865
3166
  let c;
2866
3167
  t[3] === n ? c = t[4] : (c = l("border-border bg-popover border-t px-3 py-3 text-xs", n), t[3] = n, t[4] = c);
2867
3168
  let u;
2868
- t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ S("div", {
3169
+ t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ w("div", {
2869
3170
  className: "text-foreground font-medium",
2870
3171
  children: "Keyboard shortcuts"
2871
3172
  }), t[5] = u) : u = t[5];
2872
3173
  let d;
2873
- t[6] === s ? d = t[7] : (d = /* @__PURE__ */ C("div", {
3174
+ t[6] === s ? d = t[7] : (d = /* @__PURE__ */ T("div", {
2874
3175
  className: "mb-3 flex items-center justify-between gap-3",
2875
- children: [u, /* @__PURE__ */ S("button", {
3176
+ children: [u, /* @__PURE__ */ w("button", {
2876
3177
  type: "button",
2877
3178
  className: "text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1",
2878
3179
  onClick: s,
@@ -2880,12 +3181,12 @@ function br(e) {
2880
3181
  })]
2881
3182
  }), t[6] = s, t[7] = d);
2882
3183
  let f;
2883
- t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ S("div", {
3184
+ t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ w("div", {
2884
3185
  className: "grid gap-3 sm:grid-cols-3",
2885
- children: yr.map(xr)
3186
+ children: Nr.map(Fr)
2886
3187
  }), t[8] = f) : f = t[8];
2887
3188
  let p;
2888
- return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */ C("div", {
3189
+ return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */ T("div", {
2889
3190
  role: "dialog",
2890
3191
  "aria-label": "Keyboard shortcuts",
2891
3192
  className: c,
@@ -2893,52 +3194,52 @@ function br(e) {
2893
3194
  children: [d, f]
2894
3195
  }), t[9] = r, t[10] = c, t[11] = d, t[12] = p) : p = t[12], p;
2895
3196
  }
2896
- function xr(e) {
2897
- return /* @__PURE__ */ C("div", {
3197
+ function Fr(e) {
3198
+ return /* @__PURE__ */ T("div", {
2898
3199
  className: "space-y-2",
2899
- children: [/* @__PURE__ */ S("div", {
3200
+ children: [/* @__PURE__ */ w("div", {
2900
3201
  className: "text-muted-foreground text-[11px]",
2901
3202
  children: e.title
2902
- }), /* @__PURE__ */ S("div", {
3203
+ }), /* @__PURE__ */ w("div", {
2903
3204
  className: "space-y-1",
2904
- children: e.items.map(Sr)
3205
+ children: e.items.map(Ir)
2905
3206
  })]
2906
3207
  }, e.title);
2907
3208
  }
2908
- function Sr(e) {
3209
+ function Ir(e) {
2909
3210
  let [t, n] = e;
2910
- return /* @__PURE__ */ C("div", {
3211
+ return /* @__PURE__ */ T("div", {
2911
3212
  className: "flex items-center justify-between gap-2",
2912
- children: [/* @__PURE__ */ S("kbd", {
3213
+ children: [/* @__PURE__ */ w("kbd", {
2913
3214
  className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
2914
3215
  children: t
2915
- }), /* @__PURE__ */ S("span", {
3216
+ }), /* @__PURE__ */ w("span", {
2916
3217
  className: "text-muted-foreground text-right",
2917
3218
  children: n
2918
3219
  })]
2919
3220
  }, `${t}-${n}`);
2920
3221
  }
2921
- function Cr(e) {
2922
- let t = i(30), n, r;
3222
+ function Lr(e) {
3223
+ let t = i(29), n, r;
2923
3224
  t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
2924
- let { activePopup: a, state: o, commandTriggers: s } = k("Composer.Footer");
3225
+ let { activePopup: a, state: o } = M("Composer.Footer");
2925
3226
  if (o.reverseSearch !== null) {
2926
3227
  let e;
2927
3228
  t[3] === n ? e = t[4] : (e = l("border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]", n), t[3] = n, t[4] = e);
2928
3229
  let i, a;
2929
- t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ S("kbd", {
3230
+ t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ w("kbd", {
2930
3231
  className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
2931
3232
  children: "Ctrl R"
2932
- }), a = /* @__PURE__ */ S("span", { children: "reverse-i-search:" }), t[5] = i, t[6] = a) : (i = t[5], a = t[6]);
3233
+ }), a = /* @__PURE__ */ w("span", { children: "reverse-i-search:" }), t[5] = i, t[6] = a) : (i = t[5], a = t[6]);
2933
3234
  let s = o.reverseSearch || "_", c;
2934
- t[7] === s ? c = t[8] : (c = /* @__PURE__ */ S("span", {
3235
+ t[7] === s ? c = t[8] : (c = /* @__PURE__ */ w("span", {
2935
3236
  className: "text-foreground",
2936
3237
  children: s
2937
3238
  }), t[7] = s, t[8] = c);
2938
3239
  let u, d, f, p;
2939
- t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ S("span", { children: "Ctrl R previous" }), d = /* @__PURE__ */ S("span", { children: "Ctrl S next" }), f = /* @__PURE__ */ S("span", { children: "Enter accept" }), p = /* @__PURE__ */ S("span", { children: "Esc cancel" }), t[9] = u, t[10] = d, t[11] = f, t[12] = p) : (u = t[9], d = t[10], f = t[11], p = t[12]);
3240
+ t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ w("span", { children: "Ctrl R previous" }), d = /* @__PURE__ */ w("span", { children: "Ctrl S next" }), f = /* @__PURE__ */ w("span", { children: "Enter accept" }), p = /* @__PURE__ */ w("span", { children: "Esc cancel" }), t[9] = u, t[10] = d, t[11] = f, t[12] = p) : (u = t[9], d = t[10], f = t[11], p = t[12]);
2940
3241
  let m;
2941
- return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */ C("div", {
3242
+ return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */ T("div", {
2942
3243
  className: e,
2943
3244
  ...r,
2944
3245
  children: [
@@ -2952,8 +3253,8 @@ function Cr(e) {
2952
3253
  ]
2953
3254
  }), t[13] = r, t[14] = e, t[15] = c, t[16] = m) : m = t[16], m;
2954
3255
  }
2955
- let c;
2956
- t[17] !== a || t[18] !== s || t[19] !== o.isTaskRunning || t[20] !== o.queueSubmissions ? (c = a !== null && s.includes(a.trigger) || a ? [
3256
+ let s;
3257
+ t[17] !== a || t[18] !== o.isTaskRunning || t[19] !== o.queueSubmissions ? (s = a ? [
2957
3258
  ["Enter", "insert"],
2958
3259
  ["Tab", "insert"],
2959
3260
  ["Esc", "dismiss"]
@@ -2969,35 +3270,35 @@ function Cr(e) {
2969
3270
  ["Ctrl W", "word kill"],
2970
3271
  ["Alt B/F", "word move"],
2971
3272
  ["Ctrl Y", "yank"]
2972
- ], t[17] = a, t[18] = s, t[19] = o.isTaskRunning, t[20] = o.queueSubmissions, t[21] = c) : c = t[21];
2973
- let u = c, d;
2974
- t[22] === n ? d = t[23] : (d = l("border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]", n), t[22] = n, t[23] = d);
3273
+ ], t[17] = a, t[18] = o.isTaskRunning, t[19] = o.queueSubmissions, t[20] = s) : s = t[20];
3274
+ let c = s, u;
3275
+ t[21] === n ? u = t[22] : (u = l("border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]", n), t[21] = n, t[22] = u);
3276
+ let d;
3277
+ t[23] === c ? d = t[24] : (d = c.map(Rr), t[23] = c, t[24] = d);
2975
3278
  let f;
2976
- t[24] === u ? f = t[25] : (f = u.map(wr), t[24] = u, t[25] = f);
2977
- let p;
2978
- return t[26] !== r || t[27] !== d || t[28] !== f ? (p = /* @__PURE__ */ S("div", {
2979
- className: d,
3279
+ return t[25] !== r || t[26] !== u || t[27] !== d ? (f = /* @__PURE__ */ w("div", {
3280
+ className: u,
2980
3281
  ...r,
2981
- children: f
2982
- }), t[26] = r, t[27] = d, t[28] = f, t[29] = p) : p = t[29], p;
3282
+ children: d
3283
+ }), t[25] = r, t[26] = u, t[27] = d, t[28] = f) : f = t[28], f;
2983
3284
  }
2984
- function wr(e) {
3285
+ function Rr(e) {
2985
3286
  let [t, n] = e;
2986
- return /* @__PURE__ */ C("span", {
3287
+ return /* @__PURE__ */ T("span", {
2987
3288
  className: "inline-flex items-center gap-1",
2988
- children: [/* @__PURE__ */ S("kbd", {
3289
+ children: [/* @__PURE__ */ w("kbd", {
2989
3290
  className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
2990
3291
  children: t
2991
3292
  }), n]
2992
3293
  }, `${t}-${n}`);
2993
3294
  }
2994
- function Tr(e) {
3295
+ function zr(e) {
2995
3296
  let t = i(19), n, r, a, o;
2996
3297
  t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({accept: a, multiple: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
2997
- let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } = k("Composer.AttachFiles"), d = _(null), f;
3298
+ let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } = M("Composer.AttachFiles"), d = b(null), f;
2998
3299
  t[5] === Symbol.for("react.memo_cache_sentinel") ? (f = () => d.current?.click(), t[5] = f) : f = t[5];
2999
3300
  let p;
3000
- t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */ S(jr, {
3301
+ t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */ w(Gr, {
3001
3302
  action: f,
3002
3303
  disabled: n,
3003
3304
  ...r
@@ -3008,7 +3309,7 @@ function Tr(e) {
3008
3309
  t.files && l.attachImageFiles(t.files), t.value = "";
3009
3310
  }, t[9] = l, t[10] = h);
3010
3311
  let g;
3011
- t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */ S("input", {
3312
+ t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */ w("input", {
3012
3313
  ref: d,
3013
3314
  type: "file",
3014
3315
  accept: s,
@@ -3018,83 +3319,83 @@ function Tr(e) {
3018
3319
  disabled: m,
3019
3320
  onChange: h
3020
3321
  }), t[11] = s, t[12] = c, t[13] = m, t[14] = h, t[15] = g) : g = t[15];
3021
- let v;
3022
- return t[16] !== p || t[17] !== g ? (v = /* @__PURE__ */ C(x, { children: [p, g] }), t[16] = p, t[17] = g, t[18] = v) : v = t[18], v;
3322
+ let _;
3323
+ return t[16] !== p || t[17] !== g ? (_ = /* @__PURE__ */ T(C, { children: [p, g] }), t[16] = p, t[17] = g, t[18] = _) : _ = t[18], _;
3023
3324
  }
3024
- function Er(e) {
3325
+ function Br(e) {
3025
3326
  let t = i(9), n, r;
3026
3327
  t[0] === e ? (n = t[1], r = t[2]) : ({url: r, ...n} = e, t[0] = e, t[1] = n, t[2] = r);
3027
- let { actions: a } = k("Composer.AddRemoteImage"), o;
3328
+ let { actions: a } = M("Composer.AddRemoteImage"), o;
3028
3329
  t[3] !== a || t[4] !== r ? (o = () => a.addRemoteImage(r), t[3] = a, t[4] = r, t[5] = o) : o = t[5];
3029
3330
  let s;
3030
- return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */ S(jr, {
3331
+ return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */ w(Gr, {
3031
3332
  action: o,
3032
3333
  ...n
3033
3334
  }), t[6] = n, t[7] = o, t[8] = s) : s = t[8], s;
3034
3335
  }
3035
- function Dr(e) {
3336
+ function Vr(e) {
3036
3337
  let t = i(9), n, r;
3037
3338
  t[0] === e ? (n = t[1], r = t[2]) : ({content: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
3038
- let { actions: a } = k("Composer.InsertPaste"), o;
3339
+ let { actions: a } = M("Composer.InsertPaste"), o;
3039
3340
  t[3] !== a || t[4] !== n ? (o = () => a.insertPaste(n), t[3] = a, t[4] = n, t[5] = o) : o = t[5];
3040
3341
  let s;
3041
- return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */ S(jr, {
3342
+ return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */ w(Gr, {
3042
3343
  action: o,
3043
3344
  ...r
3044
3345
  }), t[6] = r, t[7] = o, t[8] = s) : s = t[8], s;
3045
3346
  }
3046
- function Or(e) {
3347
+ function Hr(e) {
3047
3348
  let t = i(13), n, r, a, o;
3048
3349
  t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({href: n, label: r, metadata: a, ...o} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
3049
- let { actions: s } = k("Composer.InsertRichLink"), c;
3350
+ let { actions: s } = M("Composer.InsertRichLink"), c;
3050
3351
  t[5] !== s || t[6] !== n || t[7] !== r || t[8] !== a ? (c = () => s.insertRichLink(n, r, a), t[5] = s, t[6] = n, t[7] = r, t[8] = a, t[9] = c) : c = t[9];
3051
3352
  let l;
3052
- return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */ S(jr, {
3353
+ return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */ w(Gr, {
3053
3354
  action: c,
3054
3355
  ...o
3055
3356
  }), t[10] = o, t[11] = c, t[12] = l) : l = t[12], l;
3056
3357
  }
3057
- function kr(e) {
3058
- let t = i(3), { actions: n } = k("Composer.Submit"), r;
3059
- return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */ S(jr, {
3358
+ function Ur(e) {
3359
+ let t = i(3), { actions: n } = M("Composer.Submit"), r;
3360
+ return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */ w(Gr, {
3060
3361
  action: n.submit,
3061
3362
  ...e
3062
3363
  }), t[0] = n.submit, t[1] = e, t[2] = r) : r = t[2], r;
3063
3364
  }
3064
- function Ar(e) {
3065
- let t = i(3), { actions: n } = k("Composer.Reset"), r;
3066
- return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */ S(jr, {
3365
+ function Wr(e) {
3366
+ let t = i(3), { actions: n } = M("Composer.Reset"), r;
3367
+ return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */ w(Gr, {
3067
3368
  action: n.reset,
3068
3369
  ...e
3069
3370
  }), t[0] = n.reset, t[1] = e, t[2] = r) : r = t[2], r;
3070
3371
  }
3071
- function jr(e) {
3372
+ function Gr(e) {
3072
3373
  let t = i(12), n, r, o, s;
3073
3374
  t[0] === e ? (n = t[1], r = t[2], o = t[3], s = t[4]) : ({action: n, onClick: o, disabled: r, ...s} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o, t[4] = s);
3074
- let { disabled: c } = k("Composer.ActionTrigger"), l = c || r, u;
3375
+ let { disabled: c } = M("Composer.ActionTrigger"), l = c || r, u;
3075
3376
  t[5] !== n || t[6] !== o ? (u = (e) => {
3076
3377
  o?.(e), e.defaultPrevented || n();
3077
3378
  }, t[5] = n, t[6] = o, t[7] = u) : u = t[7];
3078
3379
  let d;
3079
- return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */ S(a, {
3380
+ return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */ w(a, {
3080
3381
  ...s,
3081
3382
  disabled: l,
3082
3383
  onClick: u
3083
3384
  }), t[8] = s, t[9] = l, t[10] = u, t[11] = d) : d = t[11], d;
3084
3385
  }
3085
- function Mr(e) {
3386
+ function Kr(e) {
3086
3387
  if (e.metaKey) return !1;
3087
3388
  if (e.key === "Enter") return e.altKey && !e.ctrlKey;
3088
3389
  let t = e.key.toLowerCase();
3089
3390
  return e.ctrlKey && !e.altKey && (t === "j" || t === "m");
3090
3391
  }
3091
- function Nr(e) {
3392
+ function qr(e) {
3092
3393
  if (e.metaKey) return !1;
3093
3394
  if (e.key === "Backspace") return e.ctrlKey || e.altKey;
3094
3395
  let t = e.key.toLowerCase();
3095
3396
  return e.ctrlKey && !e.altKey && t === "w" || e.ctrlKey && e.altKey && t === "h";
3096
3397
  }
3097
- function Pr(e) {
3398
+ function Jr(e) {
3098
3399
  if (e.metaKey || e.shiftKey) return null;
3099
3400
  if (e.key === "ArrowLeft" && (e.altKey || e.ctrlKey)) return -1;
3100
3401
  if (e.key === "ArrowRight" && (e.altKey || e.ctrlKey)) return 1;
@@ -3102,53 +3403,55 @@ function Pr(e) {
3102
3403
  let t = e.key.toLowerCase();
3103
3404
  return t === "b" ? -1 : t === "f" ? 1 : null;
3104
3405
  }
3105
- function Fr(e) {
3406
+ function Yr(e) {
3106
3407
  if (e.key === "ArrowUp") return -1;
3107
3408
  if (e.key === "ArrowDown") return 1;
3108
3409
  if (e.metaKey || e.altKey || e.shiftKey || !e.ctrlKey) return null;
3109
3410
  let t = e.key.toLowerCase();
3110
3411
  return t === "p" ? -1 : t === "n" ? 1 : null;
3111
3412
  }
3112
- function Ir(e) {
3413
+ function Xr(e) {
3113
3414
  let { doc: t, selection: n } = e.state;
3114
- return n.empty || n.from > 1 || n.to < t.content.size - 1 ? !1 : (e.commands.setContent(rn(), { emitUpdate: !0 }), e.commands.focus("start"), e.commands.setTextSelection(1), !0);
3115
- }
3116
- var Lr = {
3117
- Root: sr,
3118
- Trigger: Ot,
3119
- Command: kt,
3120
- Mention: At,
3121
- Content: dr,
3122
- Toolbar: fr,
3123
- RemoteImages: pr,
3124
- Attachments: se,
3125
- Editor: mr,
3126
- Error: hr,
3127
- Popup: gr,
3128
- Shortcuts: br,
3129
- Footer: Cr,
3130
- AttachFiles: Tr,
3131
- AddRemoteImage: Er,
3132
- InsertPaste: Dr,
3133
- InsertRichLink: Or,
3134
- Submit: kr,
3135
- Reset: Ar
3415
+ return n.empty || n.from > 1 || n.to < t.content.size - 1 ? !1 : (e.commands.setContent(bn(), { emitUpdate: !0 }), e.commands.focus("start"), e.commands.setTextSelection(1), !0);
3416
+ }
3417
+ var Zr = {
3418
+ Root: xr,
3419
+ Trigger: kt,
3420
+ Command: At,
3421
+ Mention: jt,
3422
+ Content: Tr,
3423
+ Toolbar: Er,
3424
+ RemoteImages: Dr,
3425
+ Attachments: P,
3426
+ Editor: Or,
3427
+ Error: kr,
3428
+ Popup: Ar,
3429
+ Shortcuts: Pr,
3430
+ Footer: Lr,
3431
+ AttachFiles: zr,
3432
+ AddRemoteImage: Br,
3433
+ InsertPaste: Vr,
3434
+ InsertRichLink: Hr,
3435
+ Dictate: Ut,
3436
+ CancelDictation: Wt,
3437
+ Submit: Ur,
3438
+ Reset: Wr
3136
3439
  };
3137
3440
  //#endregion
3138
3441
  //#region src/lib/ComposerTokenText.tsx
3139
- function Rr(e) {
3442
+ function Qr(e) {
3140
3443
  let t = i(5), { text: n, elements: r } = e, a;
3141
- t[0] !== r || t[1] !== n ? (a = Br(n, r).map(zr), t[0] = r, t[1] = n, t[2] = a) : a = t[2];
3444
+ t[0] !== r || t[1] !== n ? (a = ei(n, r).map($r), t[0] = r, t[1] = n, t[2] = a) : a = t[2];
3142
3445
  let o;
3143
- return t[3] === a ? o = t[4] : (o = /* @__PURE__ */ S(x, { children: a }), t[3] = a, t[4] = o), o;
3446
+ return t[3] === a ? o = t[4] : (o = /* @__PURE__ */ w(C, { children: a }), t[3] = a, t[4] = o), o;
3144
3447
  }
3145
- function zr(e) {
3146
- return e.element ? /* @__PURE__ */ S("span", {
3448
+ function $r(e) {
3449
+ return e.element ? /* @__PURE__ */ w("span", {
3147
3450
  "data-token": e.element.kind,
3148
3451
  children: e.text
3149
- }, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */ S("span", { children: e.text }, `${e.start}-${e.end}`);
3452
+ }, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */ w("span", { children: e.text }, `${e.start}-${e.end}`);
3150
3453
  }
3151
- function Br(e, t) {
3454
+ function ei(e, t) {
3152
3455
  let n = t.toSorted((e, t) => e.range.start - t.range.start).filter((t) => t.range.start >= 0 && t.range.end <= e.length && e.slice(t.range.start, t.range.end) === t.label), r = [], i = 0;
3153
3456
  for (let t of n) t.range.start > i && r.push({
3154
3457
  text: e.slice(i, t.range.start),
@@ -3172,7 +3475,7 @@ function Br(e, t) {
3172
3475
  }
3173
3476
  //#endregion
3174
3477
  //#region src/lib/persisted-prompt-selection.ts
3175
- function Vr(e, t) {
3478
+ function ti(e, t) {
3176
3479
  if (!t || t.isCollapsed || t.rangeCount === 0) return null;
3177
3480
  let n = t.getRangeAt(0);
3178
3481
  if (!e.contains(n.commonAncestorContainer)) return null;
@@ -3185,51 +3488,51 @@ function Vr(e, t) {
3185
3488
  }
3186
3489
  //#endregion
3187
3490
  //#region src/lib/PersistedPromptText.tsx
3188
- function Hr(e) {
3491
+ function ni(e) {
3189
3492
  let t = i(6), { text: n } = e, a, o;
3190
3493
  if (t[0] !== n) {
3191
3494
  let e = r(n);
3192
- a = Gr, o = e.map(Ur), t[0] = n, t[1] = a, t[2] = o;
3495
+ a = ai, o = e.map(ri), t[0] = n, t[1] = a, t[2] = o;
3193
3496
  } else a = t[1], o = t[2];
3194
3497
  let s;
3195
- return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */ S("span", {
3498
+ return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */ w("span", {
3196
3499
  onCopy: a,
3197
3500
  children: o
3198
3501
  }), t[3] = a, t[4] = o, t[5] = s) : s = t[5], s;
3199
3502
  }
3200
- function Ur(e) {
3503
+ function ri(e) {
3201
3504
  switch (e.kind) {
3202
3505
  case "text": return e.value;
3203
- case "inline-code": return /* @__PURE__ */ S("code", {
3506
+ case "inline-code": return /* @__PURE__ */ w("code", {
3204
3507
  "data-persisted-source": e.source,
3205
3508
  className: "bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]",
3206
3509
  children: e.value
3207
3510
  }, e.start);
3208
- case "code-block": return /* @__PURE__ */ S("span", {
3511
+ case "code-block": return /* @__PURE__ */ w("span", {
3209
3512
  "data-persisted-source": e.source,
3210
3513
  className: "bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2",
3211
- children: /* @__PURE__ */ S("code", {
3514
+ children: /* @__PURE__ */ w("code", {
3212
3515
  className: "font-mono text-[0.9em]",
3213
3516
  children: e.value
3214
3517
  })
3215
3518
  }, e.start);
3216
- case "skill-link": return /* @__PURE__ */ S(Wr, {
3519
+ case "skill-link": return /* @__PURE__ */ w(ii, {
3217
3520
  name: e.name,
3218
3521
  source: e.source,
3219
3522
  skillId: e.skillId,
3220
3523
  title: e.href
3221
3524
  }, e.start);
3222
- case "standalone-skill": return /* @__PURE__ */ S(Wr, {
3525
+ case "standalone-skill": return /* @__PURE__ */ w(ii, {
3223
3526
  name: e.name,
3224
3527
  source: e.source
3225
3528
  }, e.start);
3226
- case "mention": return /* @__PURE__ */ S("span", {
3529
+ case "mention": return /* @__PURE__ */ w("span", {
3227
3530
  "data-token": "mention",
3228
3531
  "data-persisted-source": e.source,
3229
3532
  className: "bg-foreground/10 rounded-sm px-0.5 font-medium",
3230
3533
  children: e.label
3231
3534
  }, e.start);
3232
- case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */ S("a", {
3535
+ case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */ w("a", {
3233
3536
  href: e.href,
3234
3537
  "data-persisted-source": e.source,
3235
3538
  className: "text-primary underline underline-offset-2",
@@ -3239,16 +3542,16 @@ function Ur(e) {
3239
3542
  }, e.start) : e.source;
3240
3543
  }
3241
3544
  }
3242
- function Wr(e) {
3545
+ function ii(e) {
3243
3546
  let t = i(9), { name: n, source: r, skillId: a, title: o } = e, s = a ? void 0 : n, c;
3244
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ S(y, {
3547
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ w(S, {
3245
3548
  "aria-hidden": "true",
3246
3549
  className: "size-3.5 self-center"
3247
3550
  }), t[0] = c) : c = t[0];
3248
3551
  let l;
3249
- t[1] === n ? l = t[2] : (l = /* @__PURE__ */ S("span", { children: n }), t[1] = n, t[2] = l);
3552
+ t[1] === n ? l = t[2] : (l = /* @__PURE__ */ w("span", { children: n }), t[1] = n, t[2] = l);
3250
3553
  let u;
3251
- return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */ C("span", {
3554
+ return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */ T("span", {
3252
3555
  "data-skill-id": a,
3253
3556
  "data-skill-name": s,
3254
3557
  "data-persisted-source": r,
@@ -3257,11 +3560,11 @@ function Wr(e) {
3257
3560
  children: [c, l]
3258
3561
  }), t[3] = a, t[4] = r, t[5] = s, t[6] = l, t[7] = o, t[8] = u) : u = t[8], u;
3259
3562
  }
3260
- function Gr(e) {
3261
- let t = Vr(e.currentTarget, window.getSelection());
3563
+ function ai(e) {
3564
+ let t = ti(e.currentTarget, window.getSelection());
3262
3565
  t !== null && (e.clipboardData.setData("text/plain", t), e.preventDefault());
3263
3566
  }
3264
3567
  //#endregion
3265
- export { Lr as Composer, Rr as ComposerTokenText, Hr as PersistedPromptText, Ve as createComposerDraftSource, W as createComposerState, Ue as createDraftFromPersistedText, We as createDraftFromSource, Be as createDraftFromState, Ge as createPersistedTextFromDraft, Ke as decodeComposerTextLinkHref, I as isVisibleInPhase, he as prepareComposerPayload, He as pushComposerHistory, Vr as reconstructPersistedPromptSelection, e as serializeMentionPromptLink, t as serializePersistedPromptLink, n as serializeSkillPromptLink, r as tokenizePersistedPrompt, oe as useComposer };
3568
+ export { Zr as Composer, Qr as ComposerTokenText, Gt as DictationError, ni as PersistedPromptText, He as createComposerDraftSource, q as createComposerState, We as createDraftFromPersistedText, Ge as createDraftFromSource, Ve as createDraftFromState, Ke as createPersistedTextFromDraft, qe as decodeComposerTextLinkHref, H as isVisibleInPhase, he as prepareComposerPayload, Ue as pushComposerHistory, ti as reconstructPersistedPromptSelection, e as serializeMentionPromptLink, t as serializePersistedPromptLink, n as serializeSkillPromptLink, r as tokenizePersistedPrompt, N as useComposer, Vt as useComposerDictation };
3266
3569
 
3267
3570
  //# sourceMappingURL=browser.js.map