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