@deepagents/react-input 7.9.0 → 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +743 -757
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/Composer.d.ts +4 -4
- package/dist/lib/Composer.d.ts.map +1 -1
- package/dist/lib/ComposerAttachments.d.ts +1 -1
- package/dist/lib/ComposerAttachments.d.ts.map +1 -1
- package/dist/lib/ComposerContext.d.ts +3 -3
- package/dist/lib/ComposerContext.d.ts.map +1 -1
- package/dist/lib/ComposerCore.d.ts +3 -8
- package/dist/lib/ComposerCore.d.ts.map +1 -1
- package/dist/lib/ComposerDraft.d.ts +1 -1
- package/dist/lib/ComposerDraft.d.ts.map +1 -1
- package/dist/lib/ComposerRegistry.d.ts +5 -5
- package/dist/lib/ComposerRegistry.d.ts.map +1 -1
- package/dist/lib/ComposerSlashCommands.d.ts +1 -1
- package/dist/lib/ComposerSlashCommands.d.ts.map +1 -1
- package/dist/lib/ComposerSuggestions.d.ts +1 -1
- package/dist/lib/ComposerSuggestions.d.ts.map +1 -1
- package/dist/lib/ComposerTokenText.d.ts +1 -1
- package/dist/lib/ComposerTokenText.d.ts.map +1 -1
- package/dist/lib/ComposerTriggers.d.ts.map +1 -1
- package/dist/lib/ComposerTypes.d.ts +1 -1
- package/dist/lib/ComposerTypes.d.ts.map +1 -1
- package/dist/lib/ComposerVisibility.d.ts +1 -1
- package/dist/lib/ComposerVisibility.d.ts.map +1 -1
- package/dist/lib/PersistedPromptText.d.ts.map +1 -1
- package/dist/lib/dictation/ComposerDictationContext.d.ts +2 -2
- package/dist/lib/dictation/ComposerDictationContext.d.ts.map +1 -1
- package/dist/lib/dictation/ComposerDictationParts.d.ts +2 -2
- package/dist/lib/dictation/ComposerDictationParts.d.ts.map +1 -1
- package/dist/lib/dictation/DictationError.d.ts.map +1 -1
- package/dist/lib/dictation/MicrophonePermission.d.ts.map +1 -1
- package/dist/lib/dictation/Recording.d.ts.map +1 -1
- package/dist/lib/dictation/useDictationController.d.ts +1 -1
- package/dist/lib/dictation/useDictationController.d.ts.map +1 -1
- package/dist/lib/persisted-prompt-selection.d.ts.map +1 -1
- package/dist/lib/tiptap/ComposerTiptapDomain.d.ts +6 -9
- package/dist/lib/tiptap/ComposerTiptapDomain.d.ts.map +1 -1
- package/dist/persisted-prompt.d.ts.map +1 -1
- package/package.json +7 -5
package/dist/browser.js
CHANGED
|
@@ -4,24 +4,23 @@ import { Button as a } from "@base-ui/react/button";
|
|
|
4
4
|
import { EditorContent as o, useEditor as s } from "@tiptap/react";
|
|
5
5
|
import { useClock as c } from "@zukhruf/ui";
|
|
6
6
|
import { cn as l } from "cn";
|
|
7
|
-
import { Children as u, Fragment as d, createContext as f, isValidElement as p, startTransition as m, use as h, useActionState as g, useEffect as _,
|
|
8
|
-
import { Package as S, X as
|
|
9
|
-
import { Fragment as
|
|
10
|
-
import { escapeRegExp as T } from "lodash-es";
|
|
7
|
+
import { Children as u, Fragment as d, createContext as f, isValidElement as p, startTransition as m, use as h, useActionState as g, useEffect as _, useEffectEvent as v, useMemo as y, useRef as b, useState as x, useSyncExternalStore as ee } from "react";
|
|
8
|
+
import { Package as S, X as te } from "lucide-react";
|
|
9
|
+
import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
11
10
|
import { Extension as E, Mark as D, Node as O, mergeAttributes as k } from "@tiptap/core";
|
|
12
|
-
import
|
|
13
|
-
import { Slice as
|
|
14
|
-
import { Plugin as
|
|
15
|
-
import
|
|
11
|
+
import A from "@tiptap/extension-link";
|
|
12
|
+
import { Slice as ne } from "@tiptap/pm/model";
|
|
13
|
+
import { Plugin as re, TextSelection as j } from "@tiptap/pm/state";
|
|
14
|
+
import ie from "@tiptap/starter-kit";
|
|
16
15
|
//#region src/lib/ComposerContext.ts
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let t = h(
|
|
16
|
+
var ae = f(null);
|
|
17
|
+
function M(e) {
|
|
18
|
+
let t = h(ae);
|
|
20
19
|
if (!t) throw Error(`${e} must be used inside Composer.Root.`);
|
|
21
20
|
return t;
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
let t = i(9), n =
|
|
22
|
+
function N(e) {
|
|
23
|
+
let t = i(9), n = M(e === void 0 ? "useComposer" : e), r;
|
|
25
24
|
t[0] !== n.activePopup || t[1] !== n.disabled || t[2] !== n.meta || t[3] !== n.suggestions ? (r = {
|
|
26
25
|
...n.meta,
|
|
27
26
|
disabled: n.disabled,
|
|
@@ -37,10 +36,10 @@ function P(e) {
|
|
|
37
36
|
}
|
|
38
37
|
//#endregion
|
|
39
38
|
//#region src/lib/ComposerAttachments.tsx
|
|
40
|
-
function
|
|
39
|
+
function P(e) {
|
|
41
40
|
let t = i(23), n, r;
|
|
42
41
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
43
|
-
let { state: a, attachedImages: o } =
|
|
42
|
+
let { state: a, attachedImages: o } = M("Composer.Attachments"), s = a.imageAttachments, c, u, d, f, p, m;
|
|
44
43
|
if (t[3] !== o || t[4] !== n || t[5] !== r || t[6] !== a.imageAttachments) {
|
|
45
44
|
m = Symbol.for("react.early_return_sentinel");
|
|
46
45
|
bb0: {
|
|
@@ -51,13 +50,13 @@ function F(e) {
|
|
|
51
50
|
m = null;
|
|
52
51
|
break bb0;
|
|
53
52
|
}
|
|
54
|
-
c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(
|
|
53
|
+
c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(F);
|
|
55
54
|
}
|
|
56
55
|
t[3] = o, t[4] = n, t[5] = r, t[6] = a.imageAttachments, t[7] = c, t[8] = u, t[9] = d, t[10] = f, t[11] = p, t[12] = m;
|
|
57
56
|
} else c = t[7], u = t[8], d = t[9], f = t[10], p = t[11], m = t[12];
|
|
58
57
|
if (m !== Symbol.for("react.early_return_sentinel")) return m;
|
|
59
58
|
let h;
|
|
60
|
-
return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */
|
|
59
|
+
return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */ w("div", {
|
|
61
60
|
role: c,
|
|
62
61
|
"aria-label": u,
|
|
63
62
|
className: d,
|
|
@@ -65,35 +64,35 @@ function F(e) {
|
|
|
65
64
|
children: p
|
|
66
65
|
}), t[17] = c, t[18] = u, t[19] = d, t[20] = f, t[21] = p, t[22] = h) : h = t[22], h;
|
|
67
66
|
}
|
|
68
|
-
function
|
|
69
|
-
return /* @__PURE__ */
|
|
67
|
+
function F(e) {
|
|
68
|
+
return /* @__PURE__ */ w(I, { attachment: e }, e.id);
|
|
70
69
|
}
|
|
71
|
-
function
|
|
72
|
-
let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } =
|
|
70
|
+
function I(e) {
|
|
71
|
+
let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } = M("Composer.Attachments"), d;
|
|
73
72
|
t[0] !== c || t[1] !== r ? (d = c.get(r), t[0] = c, t[1] = r, t[2] = d) : d = t[2];
|
|
74
73
|
let f = d;
|
|
75
74
|
if (!f) return null;
|
|
76
75
|
let p;
|
|
77
|
-
t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */
|
|
76
|
+
t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */ w(z, {
|
|
78
77
|
placeholder: o,
|
|
79
78
|
file: f
|
|
80
|
-
}) : s === "audio" ? /* @__PURE__ */
|
|
79
|
+
}) : s === "audio" ? /* @__PURE__ */ w(V, {
|
|
81
80
|
placeholder: o,
|
|
82
81
|
file: f,
|
|
83
82
|
glyph: "♪"
|
|
84
|
-
}) : /* @__PURE__ */
|
|
83
|
+
}) : /* @__PURE__ */ w(R, {
|
|
85
84
|
placeholder: o,
|
|
86
85
|
file: f
|
|
87
86
|
}), t[3] = f, t[4] = s, t[5] = o, t[6] = p) : p = t[6];
|
|
88
87
|
let m = `Remove ${o}`, h;
|
|
89
88
|
t[7] !== u || t[8] !== r ? (h = () => u.removeImageAttachment(r), t[7] = u, t[8] = r, t[9] = h) : h = t[9];
|
|
90
89
|
let g;
|
|
91
|
-
t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */
|
|
90
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ w(te, {
|
|
92
91
|
"aria-hidden": !0,
|
|
93
92
|
className: "size-3"
|
|
94
93
|
}), t[10] = g) : g = t[10];
|
|
95
94
|
let _;
|
|
96
|
-
t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */
|
|
95
|
+
t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */ w(a, {
|
|
97
96
|
type: "button",
|
|
98
97
|
"aria-label": m,
|
|
99
98
|
disabled: l,
|
|
@@ -102,26 +101,26 @@ function L(e) {
|
|
|
102
101
|
children: g
|
|
103
102
|
}), t[11] = l, t[12] = m, t[13] = h, t[14] = _) : _ = t[14];
|
|
104
103
|
let v;
|
|
105
|
-
return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */
|
|
104
|
+
return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */ T("div", {
|
|
106
105
|
role: "listitem",
|
|
107
106
|
className: "relative",
|
|
108
107
|
children: [p, _]
|
|
109
108
|
}), t[15] = p, t[16] = _, t[17] = v) : v = t[17], v;
|
|
110
109
|
}
|
|
111
|
-
function
|
|
112
|
-
let t = i(3), [n, r] =
|
|
110
|
+
function L(e) {
|
|
111
|
+
let t = i(3), [n, r] = x(null), a, o;
|
|
113
112
|
return t[0] === e ? (a = t[1], o = t[2]) : (a = () => {
|
|
114
113
|
let t = URL.createObjectURL(e);
|
|
115
114
|
return r(t), () => URL.revokeObjectURL(t);
|
|
116
115
|
}, o = [e], t[0] = e, t[1] = a, t[2] = o), _(a, o), n;
|
|
117
116
|
}
|
|
118
|
-
function
|
|
119
|
-
let t = i(5), { placeholder: n, file: r } = e, a =
|
|
120
|
-
return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */
|
|
117
|
+
function R(e) {
|
|
118
|
+
let t = i(5), { placeholder: n, file: r } = e, a = L(r), [o, s] = x(null), c;
|
|
119
|
+
return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */ w(V, {
|
|
121
120
|
placeholder: n,
|
|
122
121
|
file: r,
|
|
123
122
|
glyph: "🖼"
|
|
124
|
-
}) : /* @__PURE__ */
|
|
123
|
+
}) : /* @__PURE__ */ w("img", {
|
|
125
124
|
src: a,
|
|
126
125
|
alt: n,
|
|
127
126
|
title: r.name,
|
|
@@ -129,11 +128,11 @@ function z(e) {
|
|
|
129
128
|
onError: () => s(a)
|
|
130
129
|
}), t[0] = o, t[1] = r, t[2] = a, t[3] = n, t[4] = c) : c = t[4], c;
|
|
131
130
|
}
|
|
132
|
-
function
|
|
133
|
-
let t = i(11), { placeholder: n, file: r } = e, a =
|
|
131
|
+
function z(e) {
|
|
132
|
+
let t = i(11), { placeholder: n, file: r } = e, a = L(r), [o, s] = x(null), c = a ?? void 0, l;
|
|
134
133
|
t[0] === Symbol.for("react.memo_cache_sentinel") ? (l = (e) => s(e.currentTarget.duration), t[0] = l) : l = t[0];
|
|
135
134
|
let u;
|
|
136
|
-
t[1] === c ? u = t[2] : (u = /* @__PURE__ */
|
|
135
|
+
t[1] === c ? u = t[2] : (u = /* @__PURE__ */ w("video", {
|
|
137
136
|
src: c,
|
|
138
137
|
muted: !0,
|
|
139
138
|
playsInline: !0,
|
|
@@ -142,18 +141,18 @@ function B(e) {
|
|
|
142
141
|
onLoadedMetadata: l
|
|
143
142
|
}), t[1] = c, t[2] = u);
|
|
144
143
|
let d;
|
|
145
|
-
t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */
|
|
144
|
+
t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ w("span", {
|
|
146
145
|
"aria-hidden": !0,
|
|
147
146
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow",
|
|
148
147
|
children: "▶"
|
|
149
148
|
}), t[3] = d) : d = t[3];
|
|
150
149
|
let f;
|
|
151
|
-
t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */
|
|
150
|
+
t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */ w("span", {
|
|
152
151
|
className: "absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white",
|
|
153
|
-
children:
|
|
152
|
+
children: B(o)
|
|
154
153
|
}) : null, t[4] = o, t[5] = f);
|
|
155
154
|
let p;
|
|
156
|
-
return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */
|
|
155
|
+
return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */ T("div", {
|
|
157
156
|
role: "img",
|
|
158
157
|
"aria-label": n,
|
|
159
158
|
title: r.name,
|
|
@@ -165,28 +164,28 @@ function B(e) {
|
|
|
165
164
|
]
|
|
166
165
|
}), t[6] = r.name, t[7] = n, t[8] = u, t[9] = f, t[10] = p) : p = t[10], p;
|
|
167
166
|
}
|
|
168
|
-
function
|
|
167
|
+
function B(e) {
|
|
169
168
|
let t = Math.round(e);
|
|
170
169
|
return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
|
|
171
170
|
}
|
|
172
|
-
function
|
|
171
|
+
function V(e) {
|
|
173
172
|
let t = i(12), { placeholder: n, file: r, glyph: a } = e, o;
|
|
174
|
-
t[0] === a ? o = t[1] : (o = /* @__PURE__ */
|
|
173
|
+
t[0] === a ? o = t[1] : (o = /* @__PURE__ */ T("span", {
|
|
175
174
|
"aria-hidden": !0,
|
|
176
175
|
children: [a, " "]
|
|
177
176
|
}), t[0] = a, t[1] = o);
|
|
178
177
|
let s = r.name || n, c;
|
|
179
|
-
t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */
|
|
178
|
+
t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */ T("span", {
|
|
180
179
|
className: "text-foreground truncate",
|
|
181
180
|
children: [o, s]
|
|
182
181
|
}), t[2] = o, t[3] = s, t[4] = c) : c = t[4];
|
|
183
182
|
let l = r.type || "file", u;
|
|
184
|
-
t[5] === l ? u = t[6] : (u = /* @__PURE__ */
|
|
183
|
+
t[5] === l ? u = t[6] : (u = /* @__PURE__ */ w("span", {
|
|
185
184
|
className: "truncate",
|
|
186
185
|
children: l
|
|
187
186
|
}), t[5] = l, t[6] = u);
|
|
188
187
|
let d;
|
|
189
|
-
return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */
|
|
188
|
+
return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */ T("div", {
|
|
190
189
|
role: "img",
|
|
191
190
|
"aria-label": n,
|
|
192
191
|
title: r.name,
|
|
@@ -196,15 +195,15 @@ function H(e) {
|
|
|
196
195
|
}
|
|
197
196
|
//#endregion
|
|
198
197
|
//#region src/lib/ComposerVisibility.ts
|
|
199
|
-
function
|
|
198
|
+
function H(e, t) {
|
|
200
199
|
return e === "hidden" ? !1 : e === "before-interaction" ? !t : e !== "after-interaction" || t;
|
|
201
200
|
}
|
|
202
201
|
//#endregion
|
|
203
202
|
//#region src/lib/ComposerSlashCommands.ts
|
|
204
|
-
function
|
|
205
|
-
let r =
|
|
203
|
+
function oe(e, t, n) {
|
|
204
|
+
let r = W(e), i = t.filter((e) => G(e) && H(e.visibility, n));
|
|
206
205
|
return r ? i.map((e, t) => {
|
|
207
|
-
let n =
|
|
206
|
+
let n = ce(r, e);
|
|
208
207
|
return n === null ? null : {
|
|
209
208
|
command: e,
|
|
210
209
|
rank: n,
|
|
@@ -212,52 +211,52 @@ function W(e, t, n) {
|
|
|
212
211
|
};
|
|
213
212
|
}).filter((e) => !!e).sort((e, t) => e.rank - t.rank || e.index - t.index).map((e) => e.command).slice(0, 10) : i.slice(0, 10);
|
|
214
213
|
}
|
|
215
|
-
function
|
|
214
|
+
function U(e, t) {
|
|
216
215
|
let n = e.toLowerCase();
|
|
217
|
-
return t.find((e) =>
|
|
216
|
+
return t.find((e) => G(e) && (e.value.toLowerCase() === n || se(e).some((e) => e === n)));
|
|
218
217
|
}
|
|
219
|
-
function
|
|
218
|
+
function W(e) {
|
|
220
219
|
return e.slice(1).toLowerCase();
|
|
221
220
|
}
|
|
222
|
-
function
|
|
221
|
+
function G(e) {
|
|
223
222
|
return e.availability !== "disabled";
|
|
224
223
|
}
|
|
225
|
-
function
|
|
224
|
+
function se(e) {
|
|
226
225
|
return (e.aliases ?? []).map((e) => e.toLowerCase());
|
|
227
226
|
}
|
|
228
|
-
function
|
|
229
|
-
let n = t.value.toLowerCase(), r =
|
|
227
|
+
function ce(e, t) {
|
|
228
|
+
let n = t.value.toLowerCase(), r = se(t), i = [t.label.toLowerCase(), ...(t.searchTerms ?? []).map((e) => e.toLowerCase())];
|
|
230
229
|
return n === e ? 0 : r.some((t) => t === e) ? 1 : n.startsWith(e) ? 2 : r.some((t) => t.startsWith(e)) ? 3 : i.some((t) => t.startsWith(e)) ? 4 : null;
|
|
231
230
|
}
|
|
232
231
|
//#endregion
|
|
233
232
|
//#region src/lib/ComposerTriggers.ts
|
|
234
|
-
function
|
|
235
|
-
return e.map(
|
|
233
|
+
function le(e) {
|
|
234
|
+
return e.map(RegExp.escape).join("|");
|
|
236
235
|
}
|
|
237
|
-
function
|
|
238
|
-
return `(?:${
|
|
236
|
+
function ue(e) {
|
|
237
|
+
return `(?:${le(e)})[A-Za-z0-9_:-]+`;
|
|
239
238
|
}
|
|
240
|
-
function
|
|
241
|
-
return `(?:${
|
|
239
|
+
function de(e) {
|
|
240
|
+
return `(?:${le(e)})[^\\s]+`;
|
|
242
241
|
}
|
|
243
|
-
function
|
|
242
|
+
function fe(e, t) {
|
|
244
243
|
let n = [];
|
|
245
|
-
return t.length > 0 && n.push(
|
|
244
|
+
return t.length > 0 && n.push(de(t)), e.length > 0 && n.push(ue(e)), n.length > 0 ? new RegExp(n.join("|"), "g") : null;
|
|
246
245
|
}
|
|
247
|
-
function
|
|
246
|
+
function pe(e, t) {
|
|
248
247
|
return t.some((t) => e.startsWith(t));
|
|
249
248
|
}
|
|
250
|
-
function
|
|
249
|
+
function K(e) {
|
|
251
250
|
return `${e.trigger}${e.value}`;
|
|
252
251
|
}
|
|
253
252
|
//#endregion
|
|
254
253
|
//#region src/lib/ComposerCore.ts
|
|
255
|
-
function
|
|
254
|
+
function q({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandidates: r = [], commandTriggers: i = [], remoteImageUrls: a = [], isTaskRunning: o = !1, queueSubmissions: s = !1 } = {}) {
|
|
256
255
|
let c = e?.text ?? t, l = r.flatMap((e) => {
|
|
257
|
-
let t =
|
|
256
|
+
let t = Pe("mention", K(e), c, { detail: e.detail });
|
|
258
257
|
return t ? [t] : [];
|
|
259
258
|
}), u = l.flatMap((e) => {
|
|
260
|
-
let t = r.find((t) =>
|
|
259
|
+
let t = r.find((t) => K(t) === e.label);
|
|
261
260
|
return t ? [{
|
|
262
261
|
id: e.id,
|
|
263
262
|
trigger: t.trigger,
|
|
@@ -266,13 +265,13 @@ function de({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandi
|
|
|
266
265
|
persistsAs: t.persistsAs
|
|
267
266
|
}] : [];
|
|
268
267
|
}), d = e?.remoteImages ?? (e?.remoteImageUrls ?? a).map((e, t) => ({
|
|
269
|
-
id:
|
|
268
|
+
id: $("remote-image", e, t),
|
|
270
269
|
url: e
|
|
271
270
|
}));
|
|
272
271
|
return {
|
|
273
272
|
text: c,
|
|
274
273
|
cursor: c.length,
|
|
275
|
-
elements:
|
|
274
|
+
elements: X(e?.elements ?? [...ve(c, n, i), ...l]),
|
|
276
275
|
mentionBindings: e?.mentionBindings ?? u,
|
|
277
276
|
imageAttachments: [],
|
|
278
277
|
remoteImages: d,
|
|
@@ -288,47 +287,47 @@ function de({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandi
|
|
|
288
287
|
killBuffer: ""
|
|
289
288
|
};
|
|
290
289
|
}
|
|
291
|
-
function
|
|
290
|
+
function me(e) {
|
|
292
291
|
return e.text.length === 0 && e.imageAttachments.length === 0 && e.remoteImages.length === 0 && e.pendingPastes.length === 0;
|
|
293
292
|
}
|
|
294
|
-
function
|
|
295
|
-
return
|
|
293
|
+
function he(e, t, n) {
|
|
294
|
+
return J(e, t, n);
|
|
296
295
|
}
|
|
297
|
-
function
|
|
296
|
+
function ge(e, t) {
|
|
298
297
|
if (!t || t < 1) return null;
|
|
299
|
-
let n =
|
|
298
|
+
let n = Z(e.prompt);
|
|
300
299
|
return n <= t ? null : `Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`;
|
|
301
300
|
}
|
|
302
|
-
function
|
|
303
|
-
let r =
|
|
304
|
-
r = [...r.filter((e) => e.kind !== "slash-command"), ...
|
|
301
|
+
function _e(e, t, n) {
|
|
302
|
+
let r = Oe(e.elements, e.text);
|
|
303
|
+
r = [...r.filter((e) => e.kind !== "slash-command"), ...ve(e.text, t, n)];
|
|
305
304
|
let i = e.mentionBindings.filter((e) => r.some((t) => t.id === e.id)), a = e.imageAttachments.filter((e) => r.some((t) => t.kind === "image" && t.label === e.placeholder)), o = e.pendingPastes.filter((e) => r.some((t) => t.kind === "paste" && t.label === e.placeholder));
|
|
306
305
|
return {
|
|
307
306
|
...e,
|
|
308
|
-
elements:
|
|
307
|
+
elements: X(r),
|
|
309
308
|
mentionBindings: i,
|
|
310
|
-
imageAttachments:
|
|
309
|
+
imageAttachments: ze(a, e.remoteImages.length),
|
|
311
310
|
pendingPastes: o
|
|
312
311
|
};
|
|
313
312
|
}
|
|
314
|
-
function
|
|
315
|
-
let r = e.text.trim(), i =
|
|
313
|
+
function J(e, t, n) {
|
|
314
|
+
let r = e.text.trim(), i = we(e.text, r, e.elements), a = Se(e.text, e.elements, e.pendingPastes), o = a.text, s = o.trim(), c = we(o, s, a.elements), l = e.imageAttachments.filter((t) => e.text.includes(t.placeholder)), u = Te(r, i), d = Ke({
|
|
316
315
|
text: u.text,
|
|
317
316
|
elements: u.elements,
|
|
318
317
|
mentionBindings: e.mentionBindings
|
|
319
|
-
}), f =
|
|
318
|
+
}), f = Ke({
|
|
320
319
|
text: s,
|
|
321
320
|
elements: c,
|
|
322
321
|
mentionBindings: e.mentionBindings
|
|
323
322
|
});
|
|
324
323
|
if (!s && l.length === 0 && e.remoteImages.length === 0) return null;
|
|
325
|
-
let p =
|
|
324
|
+
let p = pe(o, n) ? ye(s, c, t, n) : null, m = p?.prompt === void 0 ? null : p.args ? `${p.prompt}\n\n${Ke({
|
|
326
325
|
text: p.args,
|
|
327
326
|
elements: p.argsElements,
|
|
328
327
|
mentionBindings: e.mentionBindings
|
|
329
328
|
})}` : p.prompt, h = p?.prompt === void 0 ? null : p.args ? (() => {
|
|
330
|
-
let t =
|
|
331
|
-
return `${p.prompt}\n\n${
|
|
329
|
+
let t = Te(p.args, p.argsElements);
|
|
330
|
+
return `${p.prompt}\n\n${Ke({
|
|
332
331
|
text: t.text,
|
|
333
332
|
elements: t.elements,
|
|
334
333
|
mentionBindings: e.mentionBindings
|
|
@@ -377,16 +376,16 @@ function he(e, t, n) {
|
|
|
377
376
|
mentionBindings: e.mentionBindings
|
|
378
377
|
};
|
|
379
378
|
}
|
|
380
|
-
function
|
|
379
|
+
function ve(e, t, n) {
|
|
381
380
|
let r = [];
|
|
382
381
|
if (n.length === 0) return r;
|
|
383
|
-
let i = e.matchAll(RegExp(`(^|\\s)((?:${
|
|
382
|
+
let i = e.matchAll(RegExp(`(^|\\s)((?:${le(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`, "g"));
|
|
384
383
|
for (let e of i) {
|
|
385
|
-
let n =
|
|
384
|
+
let n = U(e[3], t);
|
|
386
385
|
if (!n) continue;
|
|
387
386
|
let i = e[2], a = e.index + e[1].length;
|
|
388
387
|
r.push({
|
|
389
|
-
id:
|
|
388
|
+
id: $("slash-command", i, a),
|
|
390
389
|
kind: "slash-command",
|
|
391
390
|
label: i,
|
|
392
391
|
range: {
|
|
@@ -398,10 +397,10 @@ function ge(e, t, n) {
|
|
|
398
397
|
}
|
|
399
398
|
return r;
|
|
400
399
|
}
|
|
401
|
-
function
|
|
402
|
-
let i = e.match(RegExp(`^(?:${
|
|
400
|
+
function ye(e, t, n, r) {
|
|
401
|
+
let i = e.match(RegExp(`^(?:${le(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));
|
|
403
402
|
if (!i) return null;
|
|
404
|
-
let a =
|
|
403
|
+
let a = U(i[1], n);
|
|
405
404
|
if (!a) return null;
|
|
406
405
|
let o = i[2] ?? "";
|
|
407
406
|
if (!o.trim()) return {
|
|
@@ -414,15 +413,15 @@ function Z(e, t, n, r) {
|
|
|
414
413
|
command: a.value,
|
|
415
414
|
prompt: a.expandsTo,
|
|
416
415
|
args: u,
|
|
417
|
-
argsElements:
|
|
416
|
+
argsElements: Ce(t, l, l + u.length)
|
|
418
417
|
};
|
|
419
418
|
}
|
|
420
|
-
function
|
|
419
|
+
function be(e, t, n) {
|
|
421
420
|
if (n.length === 0) return null;
|
|
422
|
-
let r = e.match(RegExp(`^(?:${
|
|
423
|
-
return !r ||
|
|
421
|
+
let r = e.match(RegExp(`^(?:${le(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));
|
|
422
|
+
return !r || U(r[1], t) || xe(r[1]) ? null : r[1];
|
|
424
423
|
}
|
|
425
|
-
var
|
|
424
|
+
var Y = /* @__PURE__ */ new Set([
|
|
426
425
|
"Applications",
|
|
427
426
|
"Library",
|
|
428
427
|
"System",
|
|
@@ -441,10 +440,10 @@ var ve = /* @__PURE__ */ new Set([
|
|
|
441
440
|
"var",
|
|
442
441
|
"workspace"
|
|
443
442
|
]);
|
|
444
|
-
function
|
|
445
|
-
return
|
|
443
|
+
function xe(e) {
|
|
444
|
+
return Y.has(e);
|
|
446
445
|
}
|
|
447
|
-
function
|
|
446
|
+
function Se(e, t, n) {
|
|
448
447
|
if (n.length === 0 || t.length === 0) return {
|
|
449
448
|
text: e,
|
|
450
449
|
elements: t
|
|
@@ -455,7 +454,7 @@ function be(e, t, n) {
|
|
|
455
454
|
t.push(e.content), r.set(e.placeholder, t);
|
|
456
455
|
}
|
|
457
456
|
let i = "", a = [], o = 0;
|
|
458
|
-
for (let n of
|
|
457
|
+
for (let n of X(t)) {
|
|
459
458
|
let t = Math.min(n.range.start, e.length), s = Math.min(n.range.end, e.length);
|
|
460
459
|
if (t > s) continue;
|
|
461
460
|
t > o && (i += e.slice(o, t));
|
|
@@ -478,7 +477,7 @@ function be(e, t, n) {
|
|
|
478
477
|
elements: a
|
|
479
478
|
};
|
|
480
479
|
}
|
|
481
|
-
function
|
|
480
|
+
function Ce(e, t, n) {
|
|
482
481
|
return e.filter((e) => e.range.end > t && e.range.start < n).map((e) => ({
|
|
483
482
|
...e,
|
|
484
483
|
range: {
|
|
@@ -487,7 +486,7 @@ function xe(e, t, n) {
|
|
|
487
486
|
}
|
|
488
487
|
})).filter((e) => e.range.start < e.range.end);
|
|
489
488
|
}
|
|
490
|
-
function
|
|
489
|
+
function we(e, t, n) {
|
|
491
490
|
let r = e.indexOf(t);
|
|
492
491
|
return r <= 0 ? n : n.filter((e) => e.range.end > r).map((e) => ({
|
|
493
492
|
...e,
|
|
@@ -497,13 +496,13 @@ function Se(e, t, n) {
|
|
|
497
496
|
}
|
|
498
497
|
}));
|
|
499
498
|
}
|
|
500
|
-
function
|
|
501
|
-
let n =
|
|
502
|
-
for (let t of n.toReversed()) e =
|
|
499
|
+
function Te(e, t) {
|
|
500
|
+
let n = X(t.filter((e) => e.kind === "image"));
|
|
501
|
+
for (let t of n.toReversed()) e = De(e, t.range, "");
|
|
503
502
|
let r = (e) => n.reduce((t, n) => t + Math.max(0, Math.min(e, n.range.end) - n.range.start), 0);
|
|
504
503
|
return {
|
|
505
504
|
text: e,
|
|
506
|
-
elements:
|
|
505
|
+
elements: X(t.filter((e) => e.kind !== "image")).map((e) => ({
|
|
507
506
|
...e,
|
|
508
507
|
range: {
|
|
509
508
|
start: e.range.start - r(e.range.start),
|
|
@@ -512,25 +511,25 @@ function Ce(e, t) {
|
|
|
512
511
|
}))
|
|
513
512
|
};
|
|
514
513
|
}
|
|
515
|
-
function
|
|
514
|
+
function Ee(e, t, n, r) {
|
|
516
515
|
return e < r && t > n;
|
|
517
516
|
}
|
|
518
|
-
function
|
|
517
|
+
function De(e, t, n) {
|
|
519
518
|
return e.slice(0, t.start) + n + e.slice(t.end);
|
|
520
519
|
}
|
|
521
|
-
function
|
|
520
|
+
function Oe(e, t) {
|
|
522
521
|
let n = /* @__PURE__ */ new Map();
|
|
523
|
-
return
|
|
524
|
-
let r =
|
|
522
|
+
return X(e).map((e) => {
|
|
523
|
+
let r = ke(t, e.label);
|
|
525
524
|
if (r.length === 0) return null;
|
|
526
|
-
let i = `${e.kind}:${e.label}`, a = n.get(i) ?? [], o =
|
|
525
|
+
let i = `${e.kind}:${e.label}`, a = n.get(i) ?? [], o = Ae(r, e, a) ?? je(r, e, a) ?? Me(r, e);
|
|
527
526
|
return n.set(i, [...a, o]), {
|
|
528
527
|
...e,
|
|
529
528
|
range: o
|
|
530
529
|
};
|
|
531
530
|
}).filter((e) => !!e);
|
|
532
531
|
}
|
|
533
|
-
function
|
|
532
|
+
function ke(e, t) {
|
|
534
533
|
if (!t) return [];
|
|
535
534
|
let n = [], r = e.indexOf(t);
|
|
536
535
|
for (; r !== -1;) n.push({
|
|
@@ -539,22 +538,22 @@ function De(e, t) {
|
|
|
539
538
|
}), r = e.indexOf(t, r + t.length);
|
|
540
539
|
return n;
|
|
541
540
|
}
|
|
542
|
-
function
|
|
543
|
-
return e.find((e) => e.start === t.range.start && e.end === t.range.end && !
|
|
541
|
+
function Ae(e, t, n) {
|
|
542
|
+
return e.find((e) => e.start === t.range.start && e.end === t.range.end && !Ne(e, n));
|
|
544
543
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
544
|
+
function je(e, t, n) {
|
|
545
|
+
return Me(e.filter((e) => !Ne(e, n)), t);
|
|
547
546
|
}
|
|
548
|
-
function
|
|
547
|
+
function Me(e, t) {
|
|
549
548
|
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
549
|
}
|
|
551
|
-
function
|
|
552
|
-
return t.some((t) => e.start === t.start && e.end === t.end &&
|
|
550
|
+
function Ne(e, t) {
|
|
551
|
+
return t.some((t) => e.start === t.start && e.end === t.end && Ee(e.start, e.end, t.start, t.end));
|
|
553
552
|
}
|
|
554
|
-
function
|
|
553
|
+
function Pe(e, t, n, r = {}) {
|
|
555
554
|
let i = n.indexOf(t);
|
|
556
555
|
return i === -1 ? null : {
|
|
557
|
-
id:
|
|
556
|
+
id: $(e, t, i),
|
|
558
557
|
kind: e,
|
|
559
558
|
label: t,
|
|
560
559
|
range: {
|
|
@@ -564,95 +563,95 @@ function Me(e, t, n, r = {}) {
|
|
|
564
563
|
detail: r.detail
|
|
565
564
|
};
|
|
566
565
|
}
|
|
567
|
-
function
|
|
566
|
+
function X(e) {
|
|
568
567
|
return [...e].sort((e, t) => e.range.start - t.range.start);
|
|
569
568
|
}
|
|
570
|
-
var
|
|
569
|
+
var Fe = {
|
|
571
570
|
image: "Image",
|
|
572
571
|
video: "Video",
|
|
573
572
|
audio: "Audio"
|
|
574
573
|
};
|
|
575
|
-
function
|
|
574
|
+
function Ie(e) {
|
|
576
575
|
let t = e.type.split("/")[0];
|
|
577
576
|
return t === "image" || t === "video" || t === "audio" ? t : null;
|
|
578
577
|
}
|
|
579
|
-
function
|
|
578
|
+
function Le(e) {
|
|
580
579
|
return e === "video" || e === "audio" ? e : "image";
|
|
581
580
|
}
|
|
582
|
-
function
|
|
583
|
-
return `[${
|
|
581
|
+
function Re(e, t) {
|
|
582
|
+
return `[${Fe[e]} #${t}]`;
|
|
584
583
|
}
|
|
585
|
-
function
|
|
584
|
+
function ze(e, t) {
|
|
586
585
|
return e.map((e, n) => ({
|
|
587
586
|
...e,
|
|
588
|
-
placeholder:
|
|
587
|
+
placeholder: Re(e.media, t + n + 1)
|
|
589
588
|
}));
|
|
590
589
|
}
|
|
591
|
-
function
|
|
590
|
+
function Be(e, t) {
|
|
592
591
|
if (!t) return null;
|
|
593
592
|
let n = e.remoteImages.findIndex((e) => e.id === t);
|
|
594
593
|
return n === -1 ? null : n;
|
|
595
594
|
}
|
|
596
|
-
function
|
|
595
|
+
function Z(e) {
|
|
597
596
|
return Array.from(e).length;
|
|
598
597
|
}
|
|
599
|
-
function
|
|
600
|
-
let t =
|
|
598
|
+
function Ve(e) {
|
|
599
|
+
let t = Te(e.text, e.elements);
|
|
601
600
|
return {
|
|
602
601
|
text: t.text,
|
|
603
|
-
elements:
|
|
604
|
-
mentionBindings:
|
|
602
|
+
elements: tt(t.elements),
|
|
603
|
+
mentionBindings: nt(e.mentionBindings),
|
|
605
604
|
remoteImages: e.remoteImages.map((e) => ({ ...e })),
|
|
606
|
-
pendingPastes:
|
|
605
|
+
pendingPastes: rt(e.pendingPastes)
|
|
607
606
|
};
|
|
608
607
|
}
|
|
609
|
-
function
|
|
608
|
+
function He(e, t) {
|
|
610
609
|
return {
|
|
611
610
|
persistedPrompt: t,
|
|
612
611
|
remoteImages: e.remoteImages.map((e) => ({ ...e })),
|
|
613
|
-
pendingPastes:
|
|
612
|
+
pendingPastes: rt(e.pendingPastes)
|
|
614
613
|
};
|
|
615
614
|
}
|
|
616
|
-
function
|
|
617
|
-
let n =
|
|
615
|
+
function Ue(e, t) {
|
|
616
|
+
let n = He(e, t);
|
|
618
617
|
return !n.persistedPrompt.trim() && n.remoteImages.length === 0 && n.pendingPastes.length === 0 ? e.history : [n, ...e.history].slice(0, 8);
|
|
619
618
|
}
|
|
620
|
-
function
|
|
621
|
-
let i =
|
|
622
|
-
return
|
|
619
|
+
function We({ text: e, slashCommands: t = [], commandTriggers: n = [], mentionCandidates: r = [] }) {
|
|
620
|
+
let i = Q(e, r), a = Qe(i.text, i.elements, i.protectedRanges, t, r);
|
|
621
|
+
return Ve(_e(q({
|
|
623
622
|
initialDraft: {
|
|
624
623
|
text: i.text,
|
|
625
|
-
elements:
|
|
624
|
+
elements: X([...i.elements, ...a.elements]),
|
|
626
625
|
mentionBindings: [...i.mentionBindings, ...a.mentionBindings]
|
|
627
626
|
},
|
|
628
627
|
slashCommands: t
|
|
629
628
|
}), t, n));
|
|
630
629
|
}
|
|
631
|
-
function
|
|
632
|
-
let r =
|
|
630
|
+
function Ge({ source: e, slashCommands: t = [], mentionCandidates: n = [] }) {
|
|
631
|
+
let r = We({
|
|
633
632
|
text: e.persistedPrompt,
|
|
634
633
|
slashCommands: t,
|
|
635
634
|
mentionCandidates: n
|
|
636
635
|
}), i = [...e.pendingPastes.flatMap((e) => {
|
|
637
|
-
let t =
|
|
636
|
+
let t = Pe("paste", e.placeholder, r.text ?? "", { detail: `${Z(e.content)} chars` });
|
|
638
637
|
return t ? [t] : [];
|
|
639
638
|
})];
|
|
640
639
|
return {
|
|
641
640
|
...r,
|
|
642
|
-
elements:
|
|
641
|
+
elements: X([...r.elements ?? [], ...i]),
|
|
643
642
|
remoteImages: e.remoteImages.map((e) => ({ ...e })),
|
|
644
|
-
pendingPastes:
|
|
643
|
+
pendingPastes: rt(e.pendingPastes)
|
|
645
644
|
};
|
|
646
645
|
}
|
|
647
|
-
function
|
|
648
|
-
let t = e.text ?? "", n =
|
|
649
|
-
for (let e of n) t =
|
|
646
|
+
function Ke(e) {
|
|
647
|
+
let t = e.text ?? "", n = X(e.elements ?? []).map((t) => et(t, e)).filter((e) => !!e).sort((e, t) => t.range.start - e.range.start);
|
|
648
|
+
for (let e of n) t = De(t, e.range, e.text);
|
|
650
649
|
return t;
|
|
651
650
|
}
|
|
652
|
-
function
|
|
651
|
+
function qe(e) {
|
|
653
652
|
return e.startsWith("composer-text-link://") ? decodeURIComponent(e.replace(/^composer-text-link:\/\//, "")) : e;
|
|
654
653
|
}
|
|
655
|
-
function
|
|
654
|
+
function Q(e, t) {
|
|
656
655
|
let n = [], i = [], a = [], o = "";
|
|
657
656
|
for (let s of r(e)) {
|
|
658
657
|
if (s.kind === "inline-code" || s.kind === "code-block") {
|
|
@@ -667,9 +666,9 @@ function Ke(e, t) {
|
|
|
667
666
|
o += s.source;
|
|
668
667
|
continue;
|
|
669
668
|
}
|
|
670
|
-
let e = s.label, r = s.href, c =
|
|
669
|
+
let e = s.label, r = s.href, c = qe(r), l = Je(e, t), u = l ? K(l) : e, d = o.length;
|
|
671
670
|
if (o += u, l) {
|
|
672
|
-
let e =
|
|
671
|
+
let e = $("mention", u, d);
|
|
673
672
|
n.push({
|
|
674
673
|
id: e,
|
|
675
674
|
kind: "mention",
|
|
@@ -687,7 +686,7 @@ function Ke(e, t) {
|
|
|
687
686
|
persistsAs: l.persistsAs
|
|
688
687
|
});
|
|
689
688
|
} else n.push({
|
|
690
|
-
id:
|
|
689
|
+
id: $("link", u, d),
|
|
691
690
|
kind: "link",
|
|
692
691
|
label: u,
|
|
693
692
|
range: {
|
|
@@ -704,30 +703,30 @@ function Ke(e, t) {
|
|
|
704
703
|
protectedRanges: a
|
|
705
704
|
};
|
|
706
705
|
}
|
|
707
|
-
function
|
|
708
|
-
return t.find((t) =>
|
|
706
|
+
function Je(e, t) {
|
|
707
|
+
return t.find((t) => K(t) === e) ?? null;
|
|
709
708
|
}
|
|
710
|
-
function
|
|
709
|
+
function Ye(e) {
|
|
711
710
|
return [...new Set(e.map((e) => e.trigger).filter(Boolean))].sort((e, t) => t.length - e.length);
|
|
712
711
|
}
|
|
713
|
-
function
|
|
714
|
-
let t =
|
|
715
|
-
return t.length === 0 ? null : RegExp(`(?:${t
|
|
712
|
+
function Xe(e) {
|
|
713
|
+
let t = Ye(e);
|
|
714
|
+
return t.length === 0 ? null : RegExp(`(?:${le(t)})[A-Za-z0-9_:-]+`, "g");
|
|
716
715
|
}
|
|
717
|
-
function
|
|
718
|
-
return
|
|
716
|
+
function Ze(e, t) {
|
|
717
|
+
return Ye(t).find((t) => e.startsWith(t))?.length ?? 0;
|
|
719
718
|
}
|
|
720
|
-
function
|
|
719
|
+
function Qe(e, t, n, r, i) {
|
|
721
720
|
let a = [], o = [], s = [], c = (r, i) => {
|
|
722
721
|
let a = r + i.length;
|
|
723
|
-
return (r === 0 || /\s/.test(e[r - 1] ?? "")) &&
|
|
724
|
-
}, l = [...i].sort((e, t) =>
|
|
722
|
+
return (r === 0 || /\s/.test(e[r - 1] ?? "")) && !$e(r, i, t) && !s.some((e) => r < e.end && a > e.start) && !n.some((e) => r < e.end && a > e.start);
|
|
723
|
+
}, l = [...i].sort((e, t) => K(t).length - K(e).length);
|
|
725
724
|
for (let t of l) {
|
|
726
|
-
let n =
|
|
725
|
+
let n = K(t);
|
|
727
726
|
if (n) for (let r = e.indexOf(n); r !== -1; r = e.indexOf(n, r + n.length)) {
|
|
728
727
|
let i = r + n.length;
|
|
729
728
|
if (/[\w-]/.test(e[i] ?? "") || !c(r, n)) continue;
|
|
730
|
-
let l =
|
|
729
|
+
let l = $("mention", n, r);
|
|
731
730
|
s.push({
|
|
732
731
|
start: r,
|
|
733
732
|
end: i
|
|
@@ -749,16 +748,16 @@ function Ze(e, t, n, r, i) {
|
|
|
749
748
|
});
|
|
750
749
|
}
|
|
751
750
|
}
|
|
752
|
-
let u =
|
|
751
|
+
let u = Xe(r);
|
|
753
752
|
for (let t of u ? e.matchAll(u) : []) {
|
|
754
753
|
let e = t.index ?? 0, n = t[0];
|
|
755
754
|
if (!c(e, n)) continue;
|
|
756
|
-
let i =
|
|
755
|
+
let i = U(n.slice(Ze(n, r)), r);
|
|
757
756
|
i && (s.push({
|
|
758
757
|
start: e,
|
|
759
758
|
end: e + n.length
|
|
760
759
|
}), a.push({
|
|
761
|
-
id:
|
|
760
|
+
id: $("slash-command", n, e),
|
|
762
761
|
kind: "slash-command",
|
|
763
762
|
label: n,
|
|
764
763
|
range: {
|
|
@@ -773,11 +772,11 @@ function Ze(e, t, n, r, i) {
|
|
|
773
772
|
mentionBindings: o
|
|
774
773
|
};
|
|
775
774
|
}
|
|
776
|
-
function
|
|
775
|
+
function $e(e, t, n) {
|
|
777
776
|
let r = e + t.length;
|
|
778
777
|
return n.some((t) => e < t.range.end && r > t.range.start);
|
|
779
778
|
}
|
|
780
|
-
function
|
|
779
|
+
function et(e, n) {
|
|
781
780
|
if (e.kind === "mention") {
|
|
782
781
|
let t = (n.mentionBindings ?? []).find((t) => t.id === e.id || `${t.trigger}${t.value}` === e.label);
|
|
783
782
|
return t ? {
|
|
@@ -790,7 +789,7 @@ function $e(e, n) {
|
|
|
790
789
|
text: t(e.label, e.detail)
|
|
791
790
|
} : null;
|
|
792
791
|
}
|
|
793
|
-
function
|
|
792
|
+
function tt(e) {
|
|
794
793
|
return e.map((e) => {
|
|
795
794
|
let t = {
|
|
796
795
|
...e,
|
|
@@ -802,13 +801,13 @@ function et(e) {
|
|
|
802
801
|
} : t;
|
|
803
802
|
});
|
|
804
803
|
}
|
|
805
|
-
function
|
|
804
|
+
function nt(e) {
|
|
806
805
|
return e.map((e) => ({ ...e }));
|
|
807
806
|
}
|
|
808
|
-
function
|
|
807
|
+
function rt(e) {
|
|
809
808
|
return e.map((e) => ({ ...e }));
|
|
810
809
|
}
|
|
811
|
-
function
|
|
810
|
+
function it(e, t, n, r = 1) {
|
|
812
811
|
if (t.length === 0) return null;
|
|
813
812
|
let i = t.toLowerCase(), a = e.map((e, t) => ({
|
|
814
813
|
index: t,
|
|
@@ -817,12 +816,12 @@ function rt(e, t, n, r = 1) {
|
|
|
817
816
|
if (a.length === 0) return null;
|
|
818
817
|
if (n === null) return a[0];
|
|
819
818
|
let o = a.findIndex((e) => e.index === n);
|
|
820
|
-
return o === -1 ? a[0] : a[
|
|
819
|
+
return o === -1 ? a[0] : a[ct(o + r, a.length)];
|
|
821
820
|
}
|
|
822
|
-
function
|
|
821
|
+
function at(e, t, n) {
|
|
823
822
|
return n === -1 ? t === 0 || !e.slice(0, t).includes("\n") : t === e.length || !e.slice(t).includes("\n");
|
|
824
823
|
}
|
|
825
|
-
function
|
|
824
|
+
function ot(e, t) {
|
|
826
825
|
let n = lt(e, t);
|
|
827
826
|
for (; n > 0 && gt(ft(e, n));) n = ut(e, n);
|
|
828
827
|
if (n === 0) return 0;
|
|
@@ -831,7 +830,7 @@ function at(e, t) {
|
|
|
831
830
|
for (; n > 0 && yt(ft(e, n)) === r;) n = ut(e, n);
|
|
832
831
|
return n;
|
|
833
832
|
}
|
|
834
|
-
function
|
|
833
|
+
function st(e, t) {
|
|
835
834
|
let n = lt(e, t);
|
|
836
835
|
for (; n < e.length && gt(pt(e, n));) n = dt(e, n);
|
|
837
836
|
if (n >= e.length) return e.length;
|
|
@@ -840,10 +839,10 @@ function ot(e, t) {
|
|
|
840
839
|
for (; n < e.length && yt(pt(e, n)) === r;) n = dt(e, n);
|
|
841
840
|
return n;
|
|
842
841
|
}
|
|
843
|
-
function
|
|
842
|
+
function ct(e, t) {
|
|
844
843
|
return (e % t + t) % t;
|
|
845
844
|
}
|
|
846
|
-
function
|
|
845
|
+
function $(e, t, n) {
|
|
847
846
|
return `${e}:${n}:${t}`;
|
|
848
847
|
}
|
|
849
848
|
function lt(e, t) {
|
|
@@ -1025,18 +1024,18 @@ function Lt(e, t) {
|
|
|
1025
1024
|
//#endregion
|
|
1026
1025
|
//#region src/lib/ComposerSuggestions.ts
|
|
1027
1026
|
function Rt(e, t, n, r) {
|
|
1028
|
-
return [...
|
|
1027
|
+
return [...oe(e.query, t.filter((t) => t.trigger === e.trigger), r), ...zt(e.query, n.filter((t) => t.trigger === e.trigger), r)];
|
|
1029
1028
|
}
|
|
1030
1029
|
function zt(e, t, n) {
|
|
1031
1030
|
let r = e.slice(1).toLowerCase();
|
|
1032
|
-
return t.filter((e) =>
|
|
1031
|
+
return t.filter((e) => H(e.visibility, n) && (e.label.toLowerCase().includes(r) || K(e).slice(1).toLowerCase().includes(r))).slice(0, 10);
|
|
1033
1032
|
}
|
|
1034
1033
|
//#endregion
|
|
1035
1034
|
//#region src/lib/dictation/ComposerDictationContext.ts
|
|
1036
1035
|
var Bt = f(null);
|
|
1037
1036
|
function Vt(e) {
|
|
1038
1037
|
let t = e === void 0 ? "useComposerDictation" : e;
|
|
1039
|
-
|
|
1038
|
+
M(t);
|
|
1040
1039
|
let n = h(Bt);
|
|
1041
1040
|
if (!n) throw Error(`${t} needs the dictation prop of Composer.Root.`);
|
|
1042
1041
|
return n;
|
|
@@ -1049,10 +1048,10 @@ function Ht(e, t) {
|
|
|
1049
1048
|
function Ut(e) {
|
|
1050
1049
|
let t = i(15), n, r, o;
|
|
1051
1050
|
t[0] === e ? (n = t[1], r = t[2], o = t[3]) : ({render: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o);
|
|
1052
|
-
let { disabled: s } =
|
|
1051
|
+
let { disabled: s } = M("Composer.Dictate"), { state: c, start: l, stop: u } = Vt("Composer.Dictate"), d = c.status === "recording", f = (c.status === "idle" || c.status === "failed") && n !== !0 && !s, p = c.status, m = c.status === "finishing" ? c.end : void 0, h = !d && !f, g = d ? u : l, _;
|
|
1053
1052
|
t[4] !== o || t[5] !== c ? (_ = Ht(o, c), t[4] = o, t[5] = c, t[6] = _) : _ = t[6];
|
|
1054
1053
|
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__ */
|
|
1054
|
+
return t[7] !== r || t[8] !== d || t[9] !== c.status || t[10] !== m || t[11] !== h || t[12] !== g || t[13] !== _ ? (v = /* @__PURE__ */ w(a, {
|
|
1056
1055
|
...r,
|
|
1057
1056
|
"data-status": p,
|
|
1058
1057
|
"data-end": m,
|
|
@@ -1068,7 +1067,7 @@ function Wt(e) {
|
|
|
1068
1067
|
let { state: s, cancel: c } = Vt("Composer.CancelDictation"), l = s.status === "starting" || s.status === "recording" || s.status === "finishing", u = s.status, d = !l || n === !0, f;
|
|
1069
1068
|
t[4] !== o || t[5] !== s ? (f = Ht(o, s), t[4] = o, t[5] = s, t[6] = f) : f = t[6];
|
|
1070
1069
|
let p;
|
|
1071
|
-
return t[7] !== c || t[8] !== r || t[9] !== s.status || t[10] !== d || t[11] !== f ? (p = /* @__PURE__ */
|
|
1070
|
+
return t[7] !== c || t[8] !== r || t[9] !== s.status || t[10] !== d || t[11] !== f ? (p = /* @__PURE__ */ w(a, {
|
|
1072
1071
|
...r,
|
|
1073
1072
|
"data-status": u,
|
|
1074
1073
|
disabled: d,
|
|
@@ -1189,13 +1188,13 @@ var Gt = class extends Error {
|
|
|
1189
1188
|
}
|
|
1190
1189
|
}, Yt = () => () => void 0, Xt = { status: "ended" }, Zt = () => Xt, Qt = () => "unknown";
|
|
1191
1190
|
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] =
|
|
1191
|
+
let t = i(47), { dictation: n, disabled: r, insertTranscript: a, submitDraft: o } = e, s = "MediaRecorder" in globalThis && "mediaDevices" in navigator, c = n !== void 0, [l] = x(en), u = ee(c && s ? l.subscribe : Yt, l.getSnapshot, Qt), [d, f] = x(null), p = ee(d ? d.subscribe : Yt, d ? d.getSnapshot : Zt, Zt), [h, v] = x(0), [y, S] = x("insert"), te = b("insert"), C = b(null), w;
|
|
1193
1192
|
t[0] !== n || t[1] !== a || t[2] !== o ? (w = {
|
|
1194
1193
|
dictation: n,
|
|
1195
1194
|
insertTranscript: a,
|
|
1196
1195
|
submitDraft: o
|
|
1197
1196
|
}, t[0] = n, t[1] = a, t[2] = o, t[3] = w) : w = t[3];
|
|
1198
|
-
let T =
|
|
1197
|
+
let T = b(w), E;
|
|
1199
1198
|
t[4] !== n || t[5] !== a || t[6] !== o ? (E = () => {
|
|
1200
1199
|
T.current = {
|
|
1201
1200
|
dictation: n,
|
|
@@ -1231,21 +1230,21 @@ function $t(e) {
|
|
|
1231
1230
|
attempt: 0,
|
|
1232
1231
|
failure: null
|
|
1233
1232
|
}, t[8] = D, t[9] = O) : (D = t[8], O = t[9]);
|
|
1234
|
-
let [k,
|
|
1235
|
-
t[10] !== r || t[11] !== c || t[12] !== d ? (
|
|
1233
|
+
let [k, A, ne] = g(D, O), re, j;
|
|
1234
|
+
t[10] !== r || t[11] !== c || t[12] !== d ? (re = () => {
|
|
1236
1235
|
(r || !c) && (d?.cancel(), C.current?.abort());
|
|
1237
1236
|
}, j = [
|
|
1238
1237
|
r,
|
|
1239
1238
|
c,
|
|
1240
1239
|
d
|
|
1241
|
-
], t[10] = r, t[11] = c, t[12] = d, t[13] =
|
|
1242
|
-
let
|
|
1243
|
-
if (t[15] === d ? (
|
|
1240
|
+
], t[10] = r, t[11] = c, t[12] = d, t[13] = re, t[14] = j) : (re = t[13], j = t[14]), _(re, j);
|
|
1241
|
+
let ie, ae;
|
|
1242
|
+
if (t[15] === d ? (ie = t[16], ae = t[17]) : (ie = () => () => {
|
|
1244
1243
|
d?.cancel(), C.current?.abort();
|
|
1245
|
-
},
|
|
1246
|
-
let
|
|
1247
|
-
if (t[18] !== h || t[19] !==
|
|
1248
|
-
|
|
1244
|
+
}, ae = [d], t[15] = d, t[16] = ie, t[17] = ae), _(ie, ae), !n) return null;
|
|
1245
|
+
let M, N;
|
|
1246
|
+
if (t[18] !== h || t[19] !== y || t[20] !== k || t[21] !== u || t[22] !== p || t[23] !== ne) {
|
|
1247
|
+
N = e(), M = N.status === "starting" || N.status === "recording" || N.status === "finishing";
|
|
1249
1248
|
function e() {
|
|
1250
1249
|
if (!s) return {
|
|
1251
1250
|
status: "unavailable",
|
|
@@ -1256,14 +1255,14 @@ function $t(e) {
|
|
|
1256
1255
|
case "recording": return { status: "recording" };
|
|
1257
1256
|
case "stopping": return {
|
|
1258
1257
|
status: "finishing",
|
|
1259
|
-
end:
|
|
1258
|
+
end: y
|
|
1260
1259
|
};
|
|
1261
1260
|
case "ended":
|
|
1262
1261
|
case "failed":
|
|
1263
1262
|
}
|
|
1264
|
-
return
|
|
1263
|
+
return ne ? {
|
|
1265
1264
|
status: "finishing",
|
|
1266
|
-
end:
|
|
1265
|
+
end: y
|
|
1267
1266
|
} : u === "denied" ? {
|
|
1268
1267
|
status: "unavailable",
|
|
1269
1268
|
reason: "blocked"
|
|
@@ -1275,56 +1274,56 @@ function $t(e) {
|
|
|
1275
1274
|
error: k.failure
|
|
1276
1275
|
} : { status: "idle" };
|
|
1277
1276
|
}
|
|
1278
|
-
t[18] = h, t[19] =
|
|
1279
|
-
} else
|
|
1280
|
-
let
|
|
1281
|
-
t[26] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
1282
|
-
te.current = e,
|
|
1283
|
-
}, t[26] =
|
|
1284
|
-
let
|
|
1285
|
-
t[27] !==
|
|
1286
|
-
if (r ||
|
|
1277
|
+
t[18] = h, t[19] = y, t[20] = k, t[21] = u, t[22] = p, t[23] = ne, t[24] = M, t[25] = N;
|
|
1278
|
+
} else M = t[24], N = t[25];
|
|
1279
|
+
let P;
|
|
1280
|
+
t[26] === Symbol.for("react.memo_cache_sentinel") ? (P = function(e) {
|
|
1281
|
+
te.current = e, S(e);
|
|
1282
|
+
}, t[26] = P) : P = t[26];
|
|
1283
|
+
let F = P, I;
|
|
1284
|
+
t[27] !== M || t[28] !== h || t[29] !== r || t[30] !== N ? (I = function() {
|
|
1285
|
+
if (r || M || N.status === "unavailable") return;
|
|
1287
1286
|
let e = h + 1;
|
|
1288
|
-
v(e),
|
|
1287
|
+
v(e), F("insert"), f(Jt.start((t) => {
|
|
1289
1288
|
let n = T.current.dictation;
|
|
1290
1289
|
n && m(() => {
|
|
1291
|
-
|
|
1290
|
+
A({
|
|
1292
1291
|
clip: t,
|
|
1293
1292
|
attempt: e,
|
|
1294
1293
|
transcribe: n.transcribe
|
|
1295
1294
|
});
|
|
1296
1295
|
});
|
|
1297
1296
|
}));
|
|
1298
|
-
}, t[27] =
|
|
1299
|
-
let
|
|
1300
|
-
t[32] === d ?
|
|
1297
|
+
}, t[27] = M, t[28] = h, t[29] = r, t[30] = N, t[31] = I) : I = t[31];
|
|
1298
|
+
let L = I, R;
|
|
1299
|
+
t[32] === d ? R = t[33] : (R = function() {
|
|
1301
1300
|
d?.stop();
|
|
1302
|
-
}, t[32] = d, t[33] =
|
|
1303
|
-
let
|
|
1304
|
-
t[34] === d ?
|
|
1301
|
+
}, t[32] = d, t[33] = R);
|
|
1302
|
+
let z = R, B;
|
|
1303
|
+
t[34] === d ? B = t[35] : (B = function() {
|
|
1305
1304
|
d?.cancel(), C.current?.abort();
|
|
1306
|
-
}, t[34] = d, t[35] =
|
|
1307
|
-
let
|
|
1308
|
-
t[36] !== d || t[37] !==
|
|
1309
|
-
switch (
|
|
1305
|
+
}, t[34] = d, t[35] = B);
|
|
1306
|
+
let V = B, H;
|
|
1307
|
+
t[36] !== d || t[37] !== N ? (H = function() {
|
|
1308
|
+
switch (N.status) {
|
|
1310
1309
|
case "starting": return d?.cancel(), !1;
|
|
1311
|
-
case "recording": return
|
|
1312
|
-
case "finishing": return
|
|
1310
|
+
case "recording": return F("send"), d?.stop(), !0;
|
|
1311
|
+
case "finishing": return F("send"), !0;
|
|
1313
1312
|
default: return !1;
|
|
1314
1313
|
}
|
|
1315
|
-
}, t[36] = d, t[37] =
|
|
1316
|
-
let
|
|
1317
|
-
t[39] !==
|
|
1318
|
-
state:
|
|
1319
|
-
start:
|
|
1320
|
-
stop:
|
|
1321
|
-
cancel:
|
|
1322
|
-
}, t[39] =
|
|
1323
|
-
let
|
|
1324
|
-
return t[44] !==
|
|
1325
|
-
api:
|
|
1326
|
-
endWithSend:
|
|
1327
|
-
}, t[44] =
|
|
1314
|
+
}, t[36] = d, t[37] = N, t[38] = H) : H = t[38];
|
|
1315
|
+
let oe = H, U;
|
|
1316
|
+
t[39] !== V || t[40] !== L || t[41] !== N || t[42] !== z ? (U = {
|
|
1317
|
+
state: N,
|
|
1318
|
+
start: L,
|
|
1319
|
+
stop: z,
|
|
1320
|
+
cancel: V
|
|
1321
|
+
}, t[39] = V, t[40] = L, t[41] = N, t[42] = z, t[43] = U) : U = t[43];
|
|
1322
|
+
let W;
|
|
1323
|
+
return t[44] !== oe || t[45] !== U ? (W = {
|
|
1324
|
+
api: U,
|
|
1325
|
+
endWithSend: oe
|
|
1326
|
+
}, t[44] = oe, t[45] = U, t[46] = W) : W = t[46], W;
|
|
1328
1327
|
}
|
|
1329
1328
|
function en() {
|
|
1330
1329
|
return new Kt();
|
|
@@ -1333,8 +1332,8 @@ function en() {
|
|
|
1333
1332
|
//#region src/lib/tiptap/ComposerTiptapDomain.ts
|
|
1334
1333
|
function tn(e) {
|
|
1335
1334
|
return [
|
|
1336
|
-
|
|
1337
|
-
|
|
1335
|
+
ie.configure({ link: !1 }),
|
|
1336
|
+
A.configure({
|
|
1338
1337
|
autolink: !0,
|
|
1339
1338
|
linkOnPaste: !1,
|
|
1340
1339
|
openOnClick: !1,
|
|
@@ -1469,23 +1468,23 @@ function cn(e) {
|
|
|
1469
1468
|
return E.create({
|
|
1470
1469
|
name: "composerClipboard",
|
|
1471
1470
|
addProseMirrorPlugins() {
|
|
1472
|
-
return [new
|
|
1471
|
+
return [new re({ props: {
|
|
1473
1472
|
handlePaste(t, n) {
|
|
1474
1473
|
let r = n.clipboardData;
|
|
1475
1474
|
if (!r) return !1;
|
|
1476
|
-
let i = Array.from(r.files).find((e) =>
|
|
1475
|
+
let i = Array.from(r.files).find((e) => Ie(e) !== null);
|
|
1477
1476
|
if (i) return n.preventDefault(), Ln(t, e.getRemoteImageCount(), i, e.attachImageFile), !0;
|
|
1478
|
-
let a = Array.from(r.files).find((e) =>
|
|
1477
|
+
let a = Array.from(r.files).find((e) => Ie(e) === null);
|
|
1479
1478
|
if (a) return n.preventDefault(), Rn(t, a.name || "pasted-file", e.getMentionTrigger()), !0;
|
|
1480
|
-
let o =
|
|
1479
|
+
let o = fr(_r(r.getData("text/uri-list")) || vr(r.getData("DownloadURL")) || r.getData("text/plain") || r.getData("text")), s = o.trim();
|
|
1481
1480
|
if (!o) return !1;
|
|
1482
1481
|
let c = An(t);
|
|
1483
|
-
if (c &&
|
|
1482
|
+
if (c && yr(s)) {
|
|
1484
1483
|
n.preventDefault();
|
|
1485
|
-
let e =
|
|
1484
|
+
let e = br(s), r = t.state.schema.marks.link;
|
|
1486
1485
|
return r ? Mn(t, c, e, r) : !1;
|
|
1487
1486
|
}
|
|
1488
|
-
return
|
|
1487
|
+
return pr(s) && !s.includes("\n") ? (n.preventDefault(), Rn(t, s, e.getMentionTrigger()), !0) : yr(s) && !s.includes("\n") ? (n.preventDefault(), Fn(t, s, br(s))) : c && o && !o.includes("\n") && Z(o) <= nn ? (n.preventDefault(), In(t, o, c), !0) : Z(o) > nn ? (n.preventDefault(), kn(t, o), !0) : !1;
|
|
1489
1488
|
},
|
|
1490
1489
|
handleDrop(t, n) {
|
|
1491
1490
|
let r = n.dataTransfer;
|
|
@@ -1496,15 +1495,15 @@ function cn(e) {
|
|
|
1496
1495
|
});
|
|
1497
1496
|
}
|
|
1498
1497
|
function ln(e, t, n, r, i) {
|
|
1499
|
-
let a = Array.from(t.files).find((e) =>
|
|
1498
|
+
let a = Array.from(t.files).find((e) => Ie(e) !== null);
|
|
1500
1499
|
if (a) return Ln(e, n, a, i), !0;
|
|
1501
|
-
let o = Array.from(t.files).find((e) =>
|
|
1500
|
+
let o = Array.from(t.files).find((e) => Ie(e) === null);
|
|
1502
1501
|
if (o) return Rn(e, o.name || "dropped-file", r), !0;
|
|
1503
|
-
let s =
|
|
1504
|
-
return s ?
|
|
1502
|
+
let s = fr(_r(t.getData("text/uri-list")) || vr(t.getData("DownloadURL")) || t.getData("text/plain")).trim();
|
|
1503
|
+
return s ? pr(s) && !s.includes("\n") ? (Rn(e, s, r), !0) : yr(s) && !s.includes("\n") ? (Fn(e, s, br(s)), !0) : !1 : !1;
|
|
1505
1504
|
}
|
|
1506
1505
|
function un({ state: e, text: t, slashCommands: n, mentionCandidates: r, triggers: i }) {
|
|
1507
|
-
return e ? dn(
|
|
1506
|
+
return e ? dn(q({
|
|
1508
1507
|
initialDraft: e,
|
|
1509
1508
|
slashCommands: n,
|
|
1510
1509
|
commandTriggers: i.commandTriggers,
|
|
@@ -1514,13 +1513,13 @@ function un({ state: e, text: t, slashCommands: n, mentionCandidates: r, trigger
|
|
|
1514
1513
|
function dn(e, t, n, r) {
|
|
1515
1514
|
if (e.elements.length === 0) return fn(e.text, t, n, r);
|
|
1516
1515
|
let i = [], a = 0;
|
|
1517
|
-
for (let o of
|
|
1516
|
+
for (let o of X(e.elements)) {
|
|
1518
1517
|
o.range.start > a && i.push(...pn(e.text.slice(a, o.range.start), t, n, r.commandTriggers, r.mentionTriggers));
|
|
1519
1518
|
let s = e.mentionBindings.find((e) => e.id === o.id || `${e.trigger}${e.value}` === o.label), c = e.pendingPastes.find((e) => e.placeholder === o.label);
|
|
1520
1519
|
o.kind === "mention" && s ? i.push(Cn(wn(s, o, n))) : o.kind === "paste" && c ? i.push(Tn({
|
|
1521
1520
|
kind: "paste",
|
|
1522
1521
|
label: c.placeholder,
|
|
1523
|
-
detail: o.detail ?? `${
|
|
1522
|
+
detail: o.detail ?? `${Z(c.content)} chars`,
|
|
1524
1523
|
content: c.content
|
|
1525
1524
|
})) : o.kind === "rich-link" ? i.push(Tn({
|
|
1526
1525
|
kind: "rich-link",
|
|
@@ -1533,13 +1532,13 @@ function dn(e, t, n, r) {
|
|
|
1533
1532
|
return a < e.text.length && i.push(...pn(e.text.slice(a), t, n, r.commandTriggers, r.mentionTriggers)), yn(i);
|
|
1534
1533
|
}
|
|
1535
1534
|
function fn(e, t, n, r) {
|
|
1536
|
-
let i =
|
|
1535
|
+
let i = We({
|
|
1537
1536
|
text: e,
|
|
1538
1537
|
slashCommands: t,
|
|
1539
1538
|
commandTriggers: r.commandTriggers,
|
|
1540
1539
|
mentionCandidates: n
|
|
1541
1540
|
});
|
|
1542
|
-
return (i.elements?.length ?? 0) > 0 ? dn(
|
|
1541
|
+
return (i.elements?.length ?? 0) > 0 ? dn(q({
|
|
1543
1542
|
initialDraft: i,
|
|
1544
1543
|
slashCommands: t,
|
|
1545
1544
|
commandTriggers: r.commandTriggers,
|
|
@@ -1556,17 +1555,17 @@ function pn(e, t, n, i, a) {
|
|
|
1556
1555
|
return r(e).flatMap((e) => e.kind === "inline-code" || e.kind === "code-block" || e.kind === "link" || e.kind === "skill-link" ? [xn(e.source)] : mn(e.source, t, n, i, a));
|
|
1557
1556
|
}
|
|
1558
1557
|
function mn(e, t, n, r, i) {
|
|
1559
|
-
let a = [], o =
|
|
1558
|
+
let a = [], o = fe(r, i);
|
|
1560
1559
|
if (!o) return [xn(e)];
|
|
1561
1560
|
let s = 0;
|
|
1562
1561
|
for (let r of e.matchAll(o)) {
|
|
1563
1562
|
let o = r.index ?? 0, c = r[0];
|
|
1564
1563
|
if (o === 0 || /\s/.test(e[o - 1] ?? "")) {
|
|
1565
|
-
if (o > s && a.push(xn(e.slice(s, o))),
|
|
1566
|
-
let e = n.find((e) =>
|
|
1564
|
+
if (o > s && a.push(xn(e.slice(s, o))), pe(c, i)) {
|
|
1565
|
+
let e = n.find((e) => K(e) === c);
|
|
1567
1566
|
a.push(e ? Cn(e) : xn(c));
|
|
1568
1567
|
} else {
|
|
1569
|
-
let e =
|
|
1568
|
+
let e = U(c.replace(/^\//, ""), t);
|
|
1570
1569
|
a.push(e ? xn(c, [{
|
|
1571
1570
|
type: "composerSlashCommand",
|
|
1572
1571
|
attrs: {
|
|
@@ -1589,7 +1588,7 @@ function hn(e, t, n, r, i, a) {
|
|
|
1589
1588
|
pendingPastes: []
|
|
1590
1589
|
};
|
|
1591
1590
|
gn(e, o, n);
|
|
1592
|
-
let s =
|
|
1591
|
+
let s = q({
|
|
1593
1592
|
text: o.text,
|
|
1594
1593
|
slashCommands: n,
|
|
1595
1594
|
isTaskRunning: r,
|
|
@@ -1598,7 +1597,7 @@ function hn(e, t, n, r, i, a) {
|
|
|
1598
1597
|
return {
|
|
1599
1598
|
...s,
|
|
1600
1599
|
cursor: a,
|
|
1601
|
-
elements:
|
|
1600
|
+
elements: dr([...s.elements, ...o.elements]),
|
|
1602
1601
|
mentionBindings: o.mentionBindings,
|
|
1603
1602
|
imageAttachments: o.imageAttachments,
|
|
1604
1603
|
remoteImages: t,
|
|
@@ -1624,7 +1623,7 @@ function gn(e, t, n) {
|
|
|
1624
1623
|
let r = e.text ?? "", i = t.text.length;
|
|
1625
1624
|
t.text += r;
|
|
1626
1625
|
for (let a of e.marks ?? []) if (a.type === "link" && a.attrs?.href && t.elements.push({
|
|
1627
|
-
id:
|
|
1626
|
+
id: $("link", r, i),
|
|
1628
1627
|
kind: "link",
|
|
1629
1628
|
label: r,
|
|
1630
1629
|
range: {
|
|
@@ -1633,10 +1632,10 @@ function gn(e, t, n) {
|
|
|
1633
1632
|
},
|
|
1634
1633
|
detail: String(a.attrs.href)
|
|
1635
1634
|
}), a.type === "composerSlashCommand") {
|
|
1636
|
-
let e =
|
|
1635
|
+
let e = U(r.replace(/^\//, ""), n);
|
|
1637
1636
|
if (!e) continue;
|
|
1638
1637
|
t.elements.push({
|
|
1639
|
-
id:
|
|
1638
|
+
id: $("slash-command", r, i),
|
|
1640
1639
|
kind: "slash-command",
|
|
1641
1640
|
label: r,
|
|
1642
1641
|
range: {
|
|
@@ -1649,7 +1648,7 @@ function gn(e, t, n) {
|
|
|
1649
1648
|
return;
|
|
1650
1649
|
}
|
|
1651
1650
|
if (e.type === "composerMention") {
|
|
1652
|
-
let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ??
|
|
1651
|
+
let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ?? $("mention", n, r));
|
|
1653
1652
|
t.text += n, t.elements.push({
|
|
1654
1653
|
id: i,
|
|
1655
1654
|
kind: "mention",
|
|
@@ -1673,7 +1672,7 @@ function gn(e, t, n) {
|
|
|
1673
1672
|
if (e.type === "composerAtom") {
|
|
1674
1673
|
let n = String(e.attrs?.label ?? ""), r = vn(e.attrs?.kind), i = t.text.length, a = String(e.attrs?.attachmentId ?? "");
|
|
1675
1674
|
if (r === "image" && !a) return;
|
|
1676
|
-
let o = r === "image" ? a :
|
|
1675
|
+
let o = r === "image" ? a : $(r, n, i);
|
|
1677
1676
|
t.text += n;
|
|
1678
1677
|
let s = r === "rich-link" ? _n(e.attrs?.metadata) : void 0;
|
|
1679
1678
|
t.elements.push({
|
|
@@ -1689,7 +1688,7 @@ function gn(e, t, n) {
|
|
|
1689
1688
|
}), r === "image" && t.imageAttachments.push({
|
|
1690
1689
|
id: o,
|
|
1691
1690
|
placeholder: n,
|
|
1692
|
-
media:
|
|
1691
|
+
media: Le(e.attrs?.media)
|
|
1693
1692
|
}), r === "paste" && t.pendingPastes.push({
|
|
1694
1693
|
id: o,
|
|
1695
1694
|
placeholder: n,
|
|
@@ -1762,7 +1761,7 @@ function Cn(e) {
|
|
|
1762
1761
|
id: e.id,
|
|
1763
1762
|
trigger: e.trigger,
|
|
1764
1763
|
value: e.value,
|
|
1765
|
-
label:
|
|
1764
|
+
label: K(e),
|
|
1766
1765
|
detail: e.detail,
|
|
1767
1766
|
payload: e.payload,
|
|
1768
1767
|
persistsAs: e.persistsAs
|
|
@@ -1771,7 +1770,7 @@ function Cn(e) {
|
|
|
1771
1770
|
}
|
|
1772
1771
|
function wn(e, t, n) {
|
|
1773
1772
|
let r = `${e.trigger}${e.value}`;
|
|
1774
|
-
return n.find((e) =>
|
|
1773
|
+
return n.find((e) => K(e) === t.label || K(e) === r) || {
|
|
1775
1774
|
id: e.id,
|
|
1776
1775
|
trigger: e.trigger,
|
|
1777
1776
|
value: e.value,
|
|
@@ -1821,7 +1820,7 @@ function Dn(e, t) {
|
|
|
1821
1820
|
};
|
|
1822
1821
|
}
|
|
1823
1822
|
function On(e, t, n) {
|
|
1824
|
-
let r = `(?:${
|
|
1823
|
+
let r = `(?:${le(n)})`, i = e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));
|
|
1825
1824
|
if (i === -1) return null;
|
|
1826
1825
|
let a = /[\s\ufffc]/.test(e[i] ?? "") ? i + 1 : i, o = t.match(/^[^\s\ufffc]*/)?.[0] ?? "";
|
|
1827
1826
|
return {
|
|
@@ -1831,10 +1830,10 @@ function On(e, t, n) {
|
|
|
1831
1830
|
};
|
|
1832
1831
|
}
|
|
1833
1832
|
function kn(e, t) {
|
|
1834
|
-
let n = Un(e.state.doc.toJSON(),
|
|
1833
|
+
let n = Un(e.state.doc.toJSON(), Z(t)), r = e.state.schema.nodes.composerAtom?.create({
|
|
1835
1834
|
kind: "paste",
|
|
1836
1835
|
label: n,
|
|
1837
|
-
detail: `${
|
|
1836
|
+
detail: `${Z(t)} chars`,
|
|
1838
1837
|
content: t
|
|
1839
1838
|
});
|
|
1840
1839
|
r && e.dispatch(e.state.tr.replaceSelectionWith(r).scrollIntoView());
|
|
@@ -1910,21 +1909,21 @@ function In(e, t, n) {
|
|
|
1910
1909
|
function Ln(e, t, n, r) {
|
|
1911
1910
|
let i = r(n);
|
|
1912
1911
|
if (i === null) return;
|
|
1913
|
-
let a = t + Wn(e.state.doc.toJSON(), "image") + 1, o =
|
|
1912
|
+
let a = t + Wn(e.state.doc.toJSON(), "image") + 1, o = Ie(n) ?? "image", s = e.state.schema.nodeFromJSON(En(i, Re(o, a), o));
|
|
1914
1913
|
if (!s) return;
|
|
1915
1914
|
let c = e.state.tr.replaceSelectionWith(s);
|
|
1916
1915
|
c = c.insertText(" ", c.selection.from), e.dispatch(c.scrollIntoView());
|
|
1917
1916
|
}
|
|
1918
1917
|
function Rn(e, t, n) {
|
|
1919
|
-
let r =
|
|
1920
|
-
id:
|
|
1918
|
+
let r = mr(t), i = hr(r), a = `${n}${i}`, o = e.state.schema.nodes.composerMention?.create({
|
|
1919
|
+
id: $("mention", a, e.state.selection.from),
|
|
1921
1920
|
trigger: n,
|
|
1922
1921
|
value: i,
|
|
1923
1922
|
label: a,
|
|
1924
|
-
detail:
|
|
1923
|
+
detail: gr(r) ? "directory" : "file",
|
|
1925
1924
|
payload: {
|
|
1926
1925
|
path: r,
|
|
1927
|
-
type:
|
|
1926
|
+
type: gr(r) ? "directory" : "file"
|
|
1928
1927
|
}
|
|
1929
1928
|
});
|
|
1930
1929
|
if (!o) return;
|
|
@@ -1937,7 +1936,7 @@ function zn(e, t) {
|
|
|
1937
1936
|
...e,
|
|
1938
1937
|
attrs: {
|
|
1939
1938
|
...e.attrs,
|
|
1940
|
-
label:
|
|
1939
|
+
label: Re(Le(e.attrs?.media), t + n)
|
|
1941
1940
|
}
|
|
1942
1941
|
}));
|
|
1943
1942
|
}
|
|
@@ -1986,7 +1985,7 @@ function qn(e) {
|
|
|
1986
1985
|
function Jn(e) {
|
|
1987
1986
|
let { selection: t } = e.state;
|
|
1988
1987
|
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 =
|
|
1988
|
+
let n = t.$from.parent.textBetween(0, t.$from.parentOffset, void 0, nr), r = ot(n, n.length);
|
|
1990
1989
|
return tr(e, $n(t.$from.parent, t.$from.start(), r), t.from);
|
|
1991
1990
|
}
|
|
1992
1991
|
function Yn(e) {
|
|
@@ -1994,7 +1993,7 @@ function Yn(e) {
|
|
|
1994
1993
|
e.view.dispatch(r), e.view.focus();
|
|
1995
1994
|
}
|
|
1996
1995
|
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 ?
|
|
1996
|
+
let { selection: n } = e.state, r = t === -1 ? n.from : n.to, i = e.state.doc.resolve(r), a = i.parent.textBetween(0, i.parent.content.size, void 0, nr), o = i.parent.textBetween(0, i.parentOffset, void 0, nr).length, s = t === -1 ? ot(a, o) : st(a, o), c = $n(i.parent, i.start(), s), l = e.state.tr.setSelection(j.create(e.state.doc, c)).scrollIntoView();
|
|
1998
1997
|
e.view.dispatch(l), e.view.focus();
|
|
1999
1998
|
}
|
|
2000
1999
|
function Zn(e, t) {
|
|
@@ -2048,7 +2047,7 @@ function rr(e, t) {
|
|
|
2048
2047
|
e.chain().focus().insertContent(t).run();
|
|
2049
2048
|
return;
|
|
2050
2049
|
}
|
|
2051
|
-
let r =
|
|
2050
|
+
let r = ne.fromJSON(e.state.schema, t.slice);
|
|
2052
2051
|
e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()), e.view.focus();
|
|
2053
2052
|
}
|
|
2054
2053
|
function ir(e, t) {
|
|
@@ -2076,7 +2075,7 @@ function sr(e) {
|
|
|
2076
2075
|
return e.state.selection.empty && or(e) === 0;
|
|
2077
2076
|
}
|
|
2078
2077
|
function cr(e, t) {
|
|
2079
|
-
return
|
|
2078
|
+
return pe(e.persistedPrompt, t) ? "ParseSlash" : e.action;
|
|
2080
2079
|
}
|
|
2081
2080
|
function lr(e) {
|
|
2082
2081
|
return e.key === "ArrowUp" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "p";
|
|
@@ -2085,46 +2084,41 @@ function ur(e) {
|
|
|
2085
2084
|
return e.key === "ArrowDown" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "n";
|
|
2086
2085
|
}
|
|
2087
2086
|
function dr(e) {
|
|
2088
|
-
return [...e].sort((e, t) => e.range.start - t.range.start);
|
|
2089
|
-
}
|
|
2090
|
-
function fr(e) {
|
|
2091
2087
|
let t = /* @__PURE__ */ new Map();
|
|
2092
2088
|
for (let n of e) t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`, n);
|
|
2093
|
-
return
|
|
2089
|
+
return X([...t.values()]);
|
|
2094
2090
|
}
|
|
2095
|
-
function
|
|
2091
|
+
function fr(e) {
|
|
2096
2092
|
return e.replace(/\r\n?/g, "\n");
|
|
2097
2093
|
}
|
|
2098
|
-
function
|
|
2099
|
-
return Array.from(e).length;
|
|
2100
|
-
}
|
|
2101
|
-
function hr(e) {
|
|
2094
|
+
function pr(e) {
|
|
2102
2095
|
return e.startsWith("file://") || e.startsWith("/") || e.startsWith("./") || e.startsWith("../") || /^[A-Za-z]:[\\/]/.test(e);
|
|
2103
2096
|
}
|
|
2104
|
-
function
|
|
2097
|
+
function mr(e) {
|
|
2105
2098
|
let t = e.trim();
|
|
2106
2099
|
if (!t.startsWith("file://")) return t;
|
|
2100
|
+
let n = URL.parse(t);
|
|
2101
|
+
if (!n) return t;
|
|
2107
2102
|
try {
|
|
2108
|
-
return
|
|
2103
|
+
return decodeURIComponent(n.pathname);
|
|
2109
2104
|
} catch {
|
|
2110
|
-
return
|
|
2105
|
+
return n.pathname;
|
|
2111
2106
|
}
|
|
2112
2107
|
}
|
|
2113
|
-
function
|
|
2114
|
-
|
|
2115
|
-
return t ? decodeURIComponent(t) : e;
|
|
2108
|
+
function hr(e) {
|
|
2109
|
+
return e.replace(/[\\/]+$/, "").split(/[\\/]/).filter(Boolean).pop() ?? e;
|
|
2116
2110
|
}
|
|
2117
|
-
function
|
|
2111
|
+
function gr(e) {
|
|
2118
2112
|
return /[\\/]$/.test(e);
|
|
2119
2113
|
}
|
|
2120
|
-
function
|
|
2114
|
+
function _r(e) {
|
|
2121
2115
|
return e.split(/\r?\n/).map((e) => e.trim()).find((e) => e && !e.startsWith("#")) ?? "";
|
|
2122
2116
|
}
|
|
2123
|
-
function
|
|
2124
|
-
let t =
|
|
2117
|
+
function vr(e) {
|
|
2118
|
+
let t = _r(e);
|
|
2125
2119
|
return t ? t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim() ?? t : "";
|
|
2126
2120
|
}
|
|
2127
|
-
function
|
|
2121
|
+
function yr(e) {
|
|
2128
2122
|
try {
|
|
2129
2123
|
let t = new URL(e);
|
|
2130
2124
|
return t.protocol === "http:" || t.protocol === "https:";
|
|
@@ -2132,69 +2126,65 @@ function xr(e) {
|
|
|
2132
2126
|
return !1;
|
|
2133
2127
|
}
|
|
2134
2128
|
}
|
|
2135
|
-
function
|
|
2136
|
-
return
|
|
2137
|
-
}
|
|
2138
|
-
function Cr(e, t) {
|
|
2139
|
-
return (e % t + t) % t;
|
|
2140
|
-
}
|
|
2141
|
-
function wr(e, t, n) {
|
|
2142
|
-
return `${e}:${n}:${t}`;
|
|
2129
|
+
function br(e) {
|
|
2130
|
+
return qe(e.trim());
|
|
2143
2131
|
}
|
|
2144
2132
|
//#endregion
|
|
2145
2133
|
//#region src/lib/Composer.tsx
|
|
2146
|
-
function
|
|
2134
|
+
function xr(e) {
|
|
2147
2135
|
let t = i(3), n = e.draftKey ?? "", r;
|
|
2148
|
-
return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */
|
|
2136
|
+
return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */ w(Cr, { ...e }, n), t[0] = e, t[1] = n, t[2] = r) : r = t[2], r;
|
|
2149
2137
|
}
|
|
2150
|
-
function
|
|
2138
|
+
function Sr(e) {
|
|
2151
2139
|
return typeof e == "object" && !!e && "then" in e && typeof e.then == "function";
|
|
2152
2140
|
}
|
|
2153
|
-
function
|
|
2154
|
-
let
|
|
2141
|
+
function Cr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r = !1, queueSubmissions: i = !1, hasInteracted: a = !1, maxExpandedTextChars: o, editorAriaLabel: u = "Rich prompt composer", className: d, children: f, dictation: p, validateSubmission: m, onSubmit: h, onStateChange: g }) {
|
|
2142
|
+
let ee = c(), S = Mt(f), te = b({
|
|
2155
2143
|
signature: Nt(S),
|
|
2156
2144
|
slashCommands: S.slashCommands,
|
|
2157
2145
|
mentionCandidates: S.mentionCandidates,
|
|
2158
2146
|
commandTriggers: S.commandTriggers,
|
|
2159
2147
|
mentionTriggers: S.mentionTriggers
|
|
2160
|
-
}),
|
|
2161
|
-
|
|
2162
|
-
signature:
|
|
2148
|
+
}), C = Nt(S);
|
|
2149
|
+
C !== te.current.signature && (te.current = {
|
|
2150
|
+
signature: C,
|
|
2163
2151
|
slashCommands: S.slashCommands,
|
|
2164
2152
|
mentionCandidates: S.mentionCandidates,
|
|
2165
2153
|
commandTriggers: S.commandTriggers,
|
|
2166
2154
|
mentionTriggers: S.mentionTriggers
|
|
2167
2155
|
});
|
|
2168
|
-
let { slashCommands:
|
|
2169
|
-
commandTriggers:
|
|
2170
|
-
mentionTriggers:
|
|
2171
|
-
}), [
|
|
2172
|
-
ne.current =
|
|
2173
|
-
let [re] =
|
|
2156
|
+
let { slashCommands: E, mentionCandidates: D, commandTriggers: O, mentionTriggers: k } = te.current, A = y(() => ({
|
|
2157
|
+
commandTriggers: O,
|
|
2158
|
+
mentionTriggers: k
|
|
2159
|
+
}), [O, k]), ne = b(k);
|
|
2160
|
+
ne.current = k;
|
|
2161
|
+
let [re] = x(() => {
|
|
2174
2162
|
if (e) return e;
|
|
2175
2163
|
if (t === void 0) return;
|
|
2176
2164
|
let n = xt(t);
|
|
2177
|
-
return n ?
|
|
2165
|
+
return n ? Ge({
|
|
2178
2166
|
source: n,
|
|
2179
|
-
slashCommands:
|
|
2180
|
-
mentionCandidates:
|
|
2167
|
+
slashCommands: E,
|
|
2168
|
+
mentionCandidates: D
|
|
2181
2169
|
}) : void 0;
|
|
2182
|
-
}),
|
|
2170
|
+
}), j = b(re?.remoteImages ?? []), ie = b(un({
|
|
2183
2171
|
state: re,
|
|
2184
|
-
slashCommands:
|
|
2185
|
-
mentionCandidates:
|
|
2186
|
-
triggers:
|
|
2187
|
-
})), M =
|
|
2172
|
+
slashCommands: E,
|
|
2173
|
+
mentionCandidates: D,
|
|
2174
|
+
triggers: A
|
|
2175
|
+
})), M = b(0), N = b(!0);
|
|
2188
2176
|
_(() => (N.current = !0, () => {
|
|
2189
2177
|
N.current = !1;
|
|
2190
2178
|
}), []);
|
|
2191
|
-
let [P, F] =
|
|
2192
|
-
|
|
2179
|
+
let [P, F] = x(j.current), [I, L] = x(null), [R, z] = x(() => hn(ie.current, j.current, E, r, i, 0)), B = b(R), V = b(P), H = b(I), oe = b(null), U = b(null), W = b(void 0), G = b(null), se = b(null), ce = b(null), le = v((e, t) => {
|
|
2180
|
+
g?.(e, t);
|
|
2181
|
+
}), ue = b(m), de = b(h), fe = b(/* @__PURE__ */ new Map()), pe = b(() => null), K = b(() => void 0), q = b(() => void 0), _e = b(() => !1), J = s({
|
|
2182
|
+
extensions: y(() => tn({
|
|
2193
2183
|
getMentionTrigger: () => ne.current[0] ?? "@",
|
|
2194
2184
|
getRemoteImageCount: () => V.current.length,
|
|
2195
|
-
attachImageFile: (e) =>
|
|
2185
|
+
attachImageFile: (e) => pe.current(e)
|
|
2196
2186
|
}), []),
|
|
2197
|
-
content:
|
|
2187
|
+
content: ie.current,
|
|
2198
2188
|
editable: !n,
|
|
2199
2189
|
editorProps: {
|
|
2200
2190
|
attributes: {
|
|
@@ -2206,25 +2196,25 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2206
2196
|
spellcheck: "false"
|
|
2207
2197
|
},
|
|
2208
2198
|
handleKeyDown(e, t) {
|
|
2209
|
-
return
|
|
2199
|
+
return _e.current(t);
|
|
2210
2200
|
}
|
|
2211
2201
|
},
|
|
2212
2202
|
immediatelyRender: !1,
|
|
2213
2203
|
onUpdate({ editor: e }) {
|
|
2214
|
-
|
|
2204
|
+
K.current(e), q.current(e);
|
|
2215
2205
|
},
|
|
2216
2206
|
onSelectionUpdate({ editor: e }) {
|
|
2217
|
-
|
|
2207
|
+
K.current(e), q.current(e);
|
|
2218
2208
|
}
|
|
2219
|
-
}),
|
|
2209
|
+
}), ve = y(() => I ? Rt(I, E, D, a) : [], [
|
|
2220
2210
|
I,
|
|
2221
2211
|
a,
|
|
2222
|
-
E,
|
|
2223
|
-
T
|
|
2224
|
-
]), ge = v(() => pe(R, T, D), [
|
|
2225
2212
|
D,
|
|
2213
|
+
E
|
|
2214
|
+
]), ye = y(() => he(R, E, O), [
|
|
2215
|
+
O,
|
|
2226
2216
|
R,
|
|
2227
|
-
|
|
2217
|
+
E
|
|
2228
2218
|
]);
|
|
2229
2219
|
_(() => {
|
|
2230
2220
|
B.current = R;
|
|
@@ -2233,39 +2223,35 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2233
2223
|
}, [P]), _(() => {
|
|
2234
2224
|
H.current = I;
|
|
2235
2225
|
}, [I]), _(() => {
|
|
2236
|
-
R.shortcutsOpen && (I || R.reverseSearch !== null || !
|
|
2226
|
+
R.shortcutsOpen && (I || R.reverseSearch !== null || !me(R)) && z((e) => e.shortcutsOpen ? {
|
|
2237
2227
|
...e,
|
|
2238
2228
|
shortcutsOpen: !1
|
|
2239
2229
|
} : e);
|
|
2240
2230
|
}, [I, R]), _(() => {
|
|
2241
|
-
|
|
2242
|
-
}, [g]), _(() => {
|
|
2243
|
-
q.current = m;
|
|
2231
|
+
ue.current = m;
|
|
2244
2232
|
}, [m]), _(() => {
|
|
2245
|
-
|
|
2233
|
+
de.current = h;
|
|
2246
2234
|
}, [h]), _(() => {
|
|
2247
|
-
|
|
2248
|
-
}, [n,
|
|
2249
|
-
|
|
2250
|
-
}, [X, u]), _(() => {
|
|
2251
|
-
se.current?.(R, ge), t !== void 0 && (ge ? St(t, Ve(R, ge.persistedPrompt)) : M.current === 0 && St(t, null));
|
|
2235
|
+
J && (J.setEditable(!n), n && L(null));
|
|
2236
|
+
}, [n, J]), _(() => {
|
|
2237
|
+
le(R, ye), t !== void 0 && (ye ? St(t, He(R, ye.persistedPrompt)) : M.current === 0 && St(t, null));
|
|
2252
2238
|
}, [
|
|
2253
2239
|
R,
|
|
2254
2240
|
t,
|
|
2255
|
-
|
|
2241
|
+
ye
|
|
2256
2242
|
]), _(() => {
|
|
2257
2243
|
z((e) => e.isTaskRunning === r && e.queueSubmissions === i ? e : {
|
|
2258
2244
|
...e,
|
|
2259
2245
|
isTaskRunning: r,
|
|
2260
2246
|
queueSubmissions: i
|
|
2261
2247
|
});
|
|
2262
|
-
}, [r, i]),
|
|
2248
|
+
}, [r, i]), K.current = (e) => {
|
|
2263
2249
|
if (n) return;
|
|
2264
|
-
let t = hn(e.getJSON(), V.current,
|
|
2265
|
-
|
|
2266
|
-
let n = o === void 0 ?
|
|
2267
|
-
|
|
2268
|
-
let r = e.shortcutsOpen &&
|
|
2250
|
+
let t = hn(e.getJSON(), V.current, E, r, i, or(e)), a = U.current, o = W.current;
|
|
2251
|
+
U.current = null, W.current = void 0, z((e) => {
|
|
2252
|
+
let n = o === void 0 ? G.current : o;
|
|
2253
|
+
G.current = n;
|
|
2254
|
+
let r = e.shortcutsOpen && me(t);
|
|
2269
2255
|
return {
|
|
2270
2256
|
...t,
|
|
2271
2257
|
error: e.error,
|
|
@@ -2277,22 +2263,22 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2277
2263
|
selectedRemoteImageId: a
|
|
2278
2264
|
};
|
|
2279
2265
|
});
|
|
2280
|
-
},
|
|
2266
|
+
}, q.current = (e) => {
|
|
2281
2267
|
if (n) {
|
|
2282
2268
|
L(null);
|
|
2283
2269
|
return;
|
|
2284
2270
|
}
|
|
2285
|
-
let t = Dn(e,
|
|
2271
|
+
let t = Dn(e, A);
|
|
2286
2272
|
if (!t) {
|
|
2287
2273
|
L(null);
|
|
2288
2274
|
return;
|
|
2289
2275
|
}
|
|
2290
|
-
if (
|
|
2276
|
+
if (O.includes(t.trigger)) {
|
|
2291
2277
|
let e = {
|
|
2292
2278
|
trigger: t.trigger,
|
|
2293
2279
|
query: t.query,
|
|
2294
2280
|
selectedIndex: 0
|
|
2295
|
-
}, n = Rt(e,
|
|
2281
|
+
}, n = Rt(e, E, D, a);
|
|
2296
2282
|
L((t) => n.length === 0 ? null : {
|
|
2297
2283
|
...e,
|
|
2298
2284
|
selectedIndex: t?.trigger === e.trigger ? Math.min(t.selectedIndex, n.length - 1) : 0
|
|
@@ -2304,19 +2290,19 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2304
2290
|
trigger: n,
|
|
2305
2291
|
query: t.query,
|
|
2306
2292
|
selectedIndex: e?.trigger === n ? e.selectedIndex : 0
|
|
2307
|
-
}, i = Rt(r,
|
|
2293
|
+
}, i = Rt(r, E, D, a);
|
|
2308
2294
|
return {
|
|
2309
2295
|
...r,
|
|
2310
2296
|
selectedIndex: e?.trigger === n ? Math.min(e.selectedIndex, Math.max(i.length - 1, 0)) : 0
|
|
2311
2297
|
};
|
|
2312
2298
|
});
|
|
2313
2299
|
};
|
|
2314
|
-
function
|
|
2315
|
-
|
|
2300
|
+
function Y(e) {
|
|
2301
|
+
J?.commands.setContent(e), J && (K.current(J), q.current(J));
|
|
2316
2302
|
}
|
|
2317
|
-
function
|
|
2318
|
-
if (n || !
|
|
2319
|
-
let t = Dn(
|
|
2303
|
+
function xe(e) {
|
|
2304
|
+
if (n || !J) return;
|
|
2305
|
+
let t = Dn(J, A), r = [{
|
|
2320
2306
|
type: "text",
|
|
2321
2307
|
text: `${e.trigger}${e.value}`,
|
|
2322
2308
|
marks: [{
|
|
@@ -2330,21 +2316,21 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2330
2316
|
type: "text",
|
|
2331
2317
|
text: " "
|
|
2332
2318
|
}];
|
|
2333
|
-
t && t.trigger === e.trigger ?
|
|
2319
|
+
t && t.trigger === e.trigger ? J.chain().focus().deleteRange({
|
|
2334
2320
|
from: t.from,
|
|
2335
2321
|
to: t.to
|
|
2336
|
-
}).insertContent(r).run() :
|
|
2322
|
+
}).insertContent(r).run() : J.chain().focus().insertContent(r).run(), L(null);
|
|
2337
2323
|
}
|
|
2338
|
-
function
|
|
2324
|
+
function Se({ index: e = H.current?.selectedIndex ?? 0 } = {}) {
|
|
2339
2325
|
let t = H.current;
|
|
2340
|
-
if (n || !
|
|
2341
|
-
let r = Rt(t,
|
|
2326
|
+
if (n || !J || !t) return;
|
|
2327
|
+
let r = Rt(t, E, D, a), i = r[e] ?? r[0];
|
|
2342
2328
|
if (!i) return;
|
|
2343
2329
|
if (!i.atomic) {
|
|
2344
|
-
|
|
2330
|
+
xe(i);
|
|
2345
2331
|
return;
|
|
2346
2332
|
}
|
|
2347
|
-
let o = Dn(
|
|
2333
|
+
let o = Dn(J, A), s = o?.trigger === t.trigger, c = J.chain().focus();
|
|
2348
2334
|
s && o && c.deleteRange({
|
|
2349
2335
|
from: o.from,
|
|
2350
2336
|
to: o.to
|
|
@@ -2353,145 +2339,145 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2353
2339
|
text: " "
|
|
2354
2340
|
}]).run(), L(null);
|
|
2355
2341
|
}
|
|
2356
|
-
function
|
|
2357
|
-
if (n || !
|
|
2358
|
-
|
|
2359
|
-
let e =
|
|
2342
|
+
function Ce() {
|
|
2343
|
+
if (n || !J) return;
|
|
2344
|
+
J.commands.focus();
|
|
2345
|
+
let e = O[0];
|
|
2360
2346
|
e && L((t) => t?.trigger === e ? null : {
|
|
2361
2347
|
trigger: e,
|
|
2362
2348
|
query: "",
|
|
2363
2349
|
selectedIndex: 0
|
|
2364
2350
|
});
|
|
2365
2351
|
}
|
|
2366
|
-
function
|
|
2367
|
-
return
|
|
2352
|
+
function we(e) {
|
|
2353
|
+
return me(e) && e.reverseSearch === null && H.current === null;
|
|
2368
2354
|
}
|
|
2369
|
-
function
|
|
2370
|
-
n || z((e) =>
|
|
2355
|
+
function Te() {
|
|
2356
|
+
n || z((e) => we(e) && !e.shortcutsOpen ? {
|
|
2371
2357
|
...e,
|
|
2372
2358
|
shortcutsOpen: !0,
|
|
2373
2359
|
selectedRemoteImageId: null,
|
|
2374
2360
|
error: null
|
|
2375
2361
|
} : e);
|
|
2376
2362
|
}
|
|
2377
|
-
function
|
|
2363
|
+
function Ee() {
|
|
2378
2364
|
z((e) => e.shortcutsOpen ? {
|
|
2379
2365
|
...e,
|
|
2380
2366
|
shortcutsOpen: !1
|
|
2381
2367
|
} : e);
|
|
2382
2368
|
}
|
|
2383
|
-
function
|
|
2369
|
+
function De() {
|
|
2384
2370
|
n || z((e) => e.shortcutsOpen ? {
|
|
2385
2371
|
...e,
|
|
2386
2372
|
shortcutsOpen: !1
|
|
2387
|
-
} :
|
|
2373
|
+
} : we(e) ? {
|
|
2388
2374
|
...e,
|
|
2389
2375
|
shortcutsOpen: !0,
|
|
2390
2376
|
selectedRemoteImageId: null,
|
|
2391
2377
|
error: null
|
|
2392
2378
|
} : e);
|
|
2393
2379
|
}
|
|
2394
|
-
function
|
|
2395
|
-
n || !
|
|
2380
|
+
function Oe(e) {
|
|
2381
|
+
n || !J || !e || J.chain().focus().insertContent(e).run();
|
|
2396
2382
|
}
|
|
2397
|
-
function
|
|
2398
|
-
if (
|
|
2383
|
+
function ke(e) {
|
|
2384
|
+
if (Ie(e) === null) return z((t) => ({
|
|
2399
2385
|
...t,
|
|
2400
2386
|
error: `Only image, video, or audio files can be attached: ${e.name || "unnamed file"}`,
|
|
2401
2387
|
shortcutsOpen: !1
|
|
2402
2388
|
})), L(null), null;
|
|
2403
2389
|
let t = crypto.randomUUID();
|
|
2404
|
-
return
|
|
2390
|
+
return fe.current.set(t, e), t;
|
|
2405
2391
|
}
|
|
2406
|
-
function
|
|
2407
|
-
let n =
|
|
2392
|
+
function Ae(e, t) {
|
|
2393
|
+
let n = ke(t);
|
|
2408
2394
|
if (n === null) return;
|
|
2409
|
-
let r =
|
|
2410
|
-
e.chain().focus().insertContent([En(n,
|
|
2395
|
+
let r = Q(), i = r.remoteImages.length + r.imageAttachments.length + 1, a = Ie(t) ?? "image";
|
|
2396
|
+
e.chain().focus().insertContent([En(n, Re(a, i), a), {
|
|
2411
2397
|
type: "text",
|
|
2412
2398
|
text: " "
|
|
2413
2399
|
}]).run();
|
|
2414
2400
|
}
|
|
2415
|
-
function
|
|
2416
|
-
if (!(n || !
|
|
2401
|
+
function je(e) {
|
|
2402
|
+
if (!(n || !J)) for (let t of e) Ae(J, t);
|
|
2417
2403
|
}
|
|
2418
|
-
function
|
|
2419
|
-
n || !
|
|
2404
|
+
function Me(e) {
|
|
2405
|
+
n || !J || (fe.current.delete(e), Y(zn(Vn(J.getJSON(), e), V.current.length)));
|
|
2420
2406
|
}
|
|
2421
|
-
function
|
|
2422
|
-
if (n || !
|
|
2407
|
+
function Ne(e) {
|
|
2408
|
+
if (n || !J) return;
|
|
2423
2409
|
let t = [...V.current, {
|
|
2424
|
-
id:
|
|
2410
|
+
id: $("remote-image", e, ee.Date.now()),
|
|
2425
2411
|
url: e
|
|
2426
2412
|
}];
|
|
2427
|
-
V.current = t, F(t),
|
|
2413
|
+
V.current = t, F(t), Y(zn(J.getJSON(), t.length));
|
|
2428
2414
|
}
|
|
2429
|
-
function
|
|
2430
|
-
return n || !
|
|
2415
|
+
function Pe(e) {
|
|
2416
|
+
return n || !J ? !1 : ln(J.view, e, V.current.length, k[0] ?? "@", ke);
|
|
2431
2417
|
}
|
|
2432
|
-
function
|
|
2418
|
+
function X(e) {
|
|
2433
2419
|
if (n) return;
|
|
2434
2420
|
let t = V.current[e] ?? B.current.remoteImages[e];
|
|
2435
|
-
t && (
|
|
2421
|
+
t && (U.current = t.id, z((e) => ({
|
|
2436
2422
|
...e,
|
|
2437
2423
|
selectedRemoteImageId: t.id,
|
|
2438
2424
|
shortcutsOpen: !1
|
|
2439
2425
|
})));
|
|
2440
2426
|
}
|
|
2441
|
-
function
|
|
2442
|
-
n || (
|
|
2427
|
+
function Fe() {
|
|
2428
|
+
n || (U.current = null, z((e) => e.selectedRemoteImageId ? {
|
|
2443
2429
|
...e,
|
|
2444
2430
|
selectedRemoteImageId: null,
|
|
2445
2431
|
shortcutsOpen: !1
|
|
2446
2432
|
} : e));
|
|
2447
2433
|
}
|
|
2448
|
-
function
|
|
2449
|
-
return B.current.selectedRemoteImageId ? e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Escape" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" ? (
|
|
2434
|
+
function Le(e) {
|
|
2435
|
+
return B.current.selectedRemoteImageId ? e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Escape" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" ? (Fe(), L(null), !0) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? (Fe(), !0) : !1 : !1;
|
|
2450
2436
|
}
|
|
2451
|
-
function
|
|
2437
|
+
function ze(e) {
|
|
2452
2438
|
if (n) return e.preventDefault(), !0;
|
|
2453
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(),
|
|
2454
|
-
let t =
|
|
2439
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(), Fe(), L(null), J?.commands.selectAll(), !0;
|
|
2440
|
+
let t = Q(), r = B.current.selectedRemoteImageId;
|
|
2455
2441
|
if (!H.current && e.key === "ArrowUp") {
|
|
2456
|
-
let n =
|
|
2442
|
+
let n = Be({
|
|
2457
2443
|
...t,
|
|
2458
2444
|
selectedRemoteImageId: r
|
|
2459
2445
|
}, r);
|
|
2460
|
-
if (n !== null) return e.preventDefault(),
|
|
2461
|
-
if ((
|
|
2446
|
+
if (n !== null) return e.preventDefault(), X(Math.max(0, n - 1)), !0;
|
|
2447
|
+
if ((J && sr(J) || t.cursor === 0) && t.remoteImages.length > 0) return e.preventDefault(), X(t.remoteImages.length - 1), !0;
|
|
2462
2448
|
}
|
|
2463
2449
|
if (!H.current && r && e.key === "ArrowDown") {
|
|
2464
2450
|
e.preventDefault();
|
|
2465
|
-
let n =
|
|
2451
|
+
let n = Be({
|
|
2466
2452
|
...t,
|
|
2467
2453
|
selectedRemoteImageId: r
|
|
2468
2454
|
}, r);
|
|
2469
|
-
return n !== null && n + 1 < t.remoteImages.length ?
|
|
2455
|
+
return n !== null && n + 1 < t.remoteImages.length ? X(n + 1) : Fe(), !0;
|
|
2470
2456
|
}
|
|
2471
|
-
return !H.current && r && (e.key === "Backspace" || e.key === "Delete") ? (e.preventDefault(),
|
|
2457
|
+
return !H.current && r && (e.key === "Backspace" || e.key === "Delete") ? (e.preventDefault(), We(r), !0) : (Le(e), !1);
|
|
2472
2458
|
}
|
|
2473
|
-
function
|
|
2474
|
-
if (n || !
|
|
2475
|
-
let t =
|
|
2476
|
-
|
|
2459
|
+
function We(e) {
|
|
2460
|
+
if (n || !J) return;
|
|
2461
|
+
let t = Q(), r = t.remoteImages.findIndex((t) => t.id === e), i = t.remoteImages.filter((t) => t.id !== e), a = r === -1 ? null : i[r] ?? i[r - 1] ?? null;
|
|
2462
|
+
U.current = a?.id ?? null, V.current = i, F(i), Y(zn(J.getJSON(), i.length)), z((e) => ({
|
|
2477
2463
|
...e,
|
|
2478
2464
|
remoteImages: i,
|
|
2479
2465
|
selectedRemoteImageId: a?.id ?? null,
|
|
2480
2466
|
shortcutsOpen: !1
|
|
2481
2467
|
}));
|
|
2482
2468
|
}
|
|
2483
|
-
function
|
|
2484
|
-
if (n || !
|
|
2485
|
-
let t = Un(
|
|
2486
|
-
|
|
2469
|
+
function Ke(e) {
|
|
2470
|
+
if (n || !J) return;
|
|
2471
|
+
let t = Un(J.getJSON(), Z(e));
|
|
2472
|
+
J.chain().focus().insertContent(Tn({
|
|
2487
2473
|
kind: "paste",
|
|
2488
2474
|
label: t,
|
|
2489
|
-
detail: `${
|
|
2475
|
+
detail: `${Z(e)} chars`,
|
|
2490
2476
|
content: e
|
|
2491
2477
|
})).run();
|
|
2492
2478
|
}
|
|
2493
|
-
function
|
|
2494
|
-
n ||
|
|
2479
|
+
function qe(e, t = e, r) {
|
|
2480
|
+
n || J?.chain().focus().insertContent(Tn({
|
|
2495
2481
|
kind: "rich-link",
|
|
2496
2482
|
label: t,
|
|
2497
2483
|
detail: e,
|
|
@@ -2499,36 +2485,36 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2499
2485
|
metadata: r
|
|
2500
2486
|
})).run();
|
|
2501
2487
|
}
|
|
2502
|
-
function
|
|
2503
|
-
return
|
|
2504
|
-
...hn(
|
|
2488
|
+
function Q() {
|
|
2489
|
+
return J ? {
|
|
2490
|
+
...hn(J.getJSON(), V.current, E, r, i, or(J)),
|
|
2505
2491
|
error: B.current.error,
|
|
2506
2492
|
history: B.current.history,
|
|
2507
|
-
historyCursor:
|
|
2493
|
+
historyCursor: G.current ?? B.current.historyCursor,
|
|
2508
2494
|
killBuffer: B.current.killBuffer,
|
|
2509
2495
|
reverseSearch: B.current.reverseSearch,
|
|
2510
2496
|
shortcutsOpen: B.current.shortcutsOpen,
|
|
2511
2497
|
selectedRemoteImageId: B.current.selectedRemoteImageId
|
|
2512
2498
|
} : B.current;
|
|
2513
2499
|
}
|
|
2514
|
-
function
|
|
2515
|
-
let t =
|
|
2500
|
+
function Je(e) {
|
|
2501
|
+
let t = ue.current?.(e);
|
|
2516
2502
|
return t ? (z((e) => ({
|
|
2517
2503
|
...e,
|
|
2518
2504
|
error: t,
|
|
2519
2505
|
shortcutsOpen: !1
|
|
2520
2506
|
})), L(null), !0) : !1;
|
|
2521
2507
|
}
|
|
2522
|
-
function
|
|
2523
|
-
let t =
|
|
2524
|
-
|
|
2508
|
+
function Ye(e) {
|
|
2509
|
+
let t = Q(), n = t.text.slice(0, t.cursor);
|
|
2510
|
+
Oe(n && !/\s$/.test(n) ? ` ${e}` : e);
|
|
2525
2511
|
}
|
|
2526
|
-
function
|
|
2527
|
-
|
|
2512
|
+
function Xe() {
|
|
2513
|
+
mt?.endWithSend() || Ze();
|
|
2528
2514
|
}
|
|
2529
|
-
function
|
|
2515
|
+
function Ze() {
|
|
2530
2516
|
if (n) return;
|
|
2531
|
-
let e =
|
|
2517
|
+
let e = Q(), r = J?.getJSON() ?? bn(), i = e.isTaskRunning || e.queueSubmissions, a = i ? null : be(e.text, E, O);
|
|
2532
2518
|
if (a) {
|
|
2533
2519
|
z((e) => ({
|
|
2534
2520
|
...e,
|
|
@@ -2537,7 +2523,7 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2537
2523
|
})), L(null);
|
|
2538
2524
|
return;
|
|
2539
2525
|
}
|
|
2540
|
-
let s =
|
|
2526
|
+
let s = he(e, E, O), c = s ?? {
|
|
2541
2527
|
mode: "submitted",
|
|
2542
2528
|
prompt: "",
|
|
2543
2529
|
persistedPrompt: "",
|
|
@@ -2549,7 +2535,7 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2549
2535
|
elements: [],
|
|
2550
2536
|
payloadElements: [],
|
|
2551
2537
|
mentionBindings: []
|
|
2552
|
-
}, l =
|
|
2538
|
+
}, l = ge(c, o);
|
|
2553
2539
|
if (l) {
|
|
2554
2540
|
z((e) => ({
|
|
2555
2541
|
...e,
|
|
@@ -2560,7 +2546,7 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2560
2546
|
}
|
|
2561
2547
|
let u = /* @__PURE__ */ new Map(), d = [];
|
|
2562
2548
|
for (let t of e.imageAttachments) {
|
|
2563
|
-
let e =
|
|
2549
|
+
let e = fe.current.get(t.id);
|
|
2564
2550
|
if (!e) {
|
|
2565
2551
|
z((e) => ({
|
|
2566
2552
|
...e,
|
|
@@ -2581,31 +2567,31 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2581
2567
|
...c.items.filter((e) => e.type !== "remote_image")
|
|
2582
2568
|
], p = {
|
|
2583
2569
|
id: crypto.randomUUID(),
|
|
2584
|
-
at: new Date(
|
|
2570
|
+
at: new Date(ee.Date.now()).toLocaleTimeString(),
|
|
2585
2571
|
mode: i ? "queued" : c.mode,
|
|
2586
2572
|
prompt: c.prompt,
|
|
2587
2573
|
persistedPrompt: c.persistedPrompt,
|
|
2588
|
-
action: i ? cr(c,
|
|
2574
|
+
action: i ? cr(c, O) : c.action,
|
|
2589
2575
|
command: c.command,
|
|
2590
2576
|
args: c.args,
|
|
2591
2577
|
items: f
|
|
2592
2578
|
};
|
|
2593
|
-
if (
|
|
2594
|
-
for (let e of u.keys())
|
|
2595
|
-
let m =
|
|
2596
|
-
|
|
2579
|
+
if (Je(p)) return;
|
|
2580
|
+
for (let e of u.keys()) fe.current.delete(e);
|
|
2581
|
+
let m = He(e, c.persistedPrompt), h = de.current?.(p, { editableSource: m });
|
|
2582
|
+
Sr(h) && (M.current += 1, h.then(() => {
|
|
2597
2583
|
t !== void 0 && St(t, null);
|
|
2598
2584
|
}).catch((e) => {
|
|
2599
|
-
for (let [e, t] of u)
|
|
2600
|
-
t !== void 0 && St(t, m), N.current && (
|
|
2585
|
+
for (let [e, t] of u) fe.current.set(e, t);
|
|
2586
|
+
t !== void 0 && St(t, m), N.current && (Y(r), J?.commands.focus("end"), z((t) => ({
|
|
2601
2587
|
...t,
|
|
2602
2588
|
error: e instanceof Error ? e.message : "Could not send prompt"
|
|
2603
2589
|
})));
|
|
2604
2590
|
}).finally(() => {
|
|
2605
2591
|
--M.current;
|
|
2606
2592
|
}));
|
|
2607
|
-
let g = s ?
|
|
2608
|
-
|
|
2593
|
+
let g = s ? Ue(e, c.historyPrompt) : e.history;
|
|
2594
|
+
G.current = null, V.current = [], F([]), L(null), Y(bn()), z((e) => ({
|
|
2609
2595
|
...e,
|
|
2610
2596
|
text: "",
|
|
2611
2597
|
cursor: 0,
|
|
@@ -2621,10 +2607,10 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2621
2607
|
historyCursor: null
|
|
2622
2608
|
}));
|
|
2623
2609
|
}
|
|
2624
|
-
function
|
|
2610
|
+
function Qe() {
|
|
2625
2611
|
if (n) return;
|
|
2626
2612
|
let e = B.current.history, t = B.current.killBuffer;
|
|
2627
|
-
|
|
2613
|
+
G.current = null, ce.current = null, fe.current.clear(), V.current = j.current, F(j.current), L(null), Y(ie.current), J?.commands.focus("end"), z((n) => ({
|
|
2628
2614
|
...n,
|
|
2629
2615
|
history: e,
|
|
2630
2616
|
historyCursor: null,
|
|
@@ -2635,61 +2621,61 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2635
2621
|
shortcutsOpen: !1
|
|
2636
2622
|
}));
|
|
2637
2623
|
}
|
|
2638
|
-
function
|
|
2639
|
-
if (n || !
|
|
2640
|
-
let t = B.current, r =
|
|
2641
|
-
if (e > 0 && r === 0 &&
|
|
2642
|
-
|
|
2624
|
+
function $e(e) {
|
|
2625
|
+
if (n || !J || B.current.history.length === 0) return;
|
|
2626
|
+
let t = B.current, r = G.current ?? t.historyCursor;
|
|
2627
|
+
if (e > 0 && r === 0 && se.current) {
|
|
2628
|
+
tt(se.current, null), se.current = null;
|
|
2643
2629
|
return;
|
|
2644
2630
|
}
|
|
2645
|
-
let i = r === null ? e < 0 ? 0 : t.history.length - 1 :
|
|
2646
|
-
r === null && (
|
|
2631
|
+
let i = r === null ? e < 0 ? 0 : t.history.length - 1 : ct(r + e, t.history.length);
|
|
2632
|
+
r === null && (se.current = Ve(Q()));
|
|
2647
2633
|
let a = t.history[i];
|
|
2648
|
-
|
|
2634
|
+
et(a, i);
|
|
2649
2635
|
}
|
|
2650
|
-
function
|
|
2651
|
-
|
|
2636
|
+
function et(e, t) {
|
|
2637
|
+
tt(Ge({
|
|
2652
2638
|
source: e,
|
|
2653
|
-
slashCommands:
|
|
2654
|
-
mentionCandidates:
|
|
2639
|
+
slashCommands: E,
|
|
2640
|
+
mentionCandidates: D
|
|
2655
2641
|
}), t);
|
|
2656
2642
|
}
|
|
2657
|
-
function
|
|
2643
|
+
function tt(e, t) {
|
|
2658
2644
|
let n = e.remoteImages ?? [];
|
|
2659
2645
|
V.current = n, B.current = {
|
|
2660
2646
|
...B.current,
|
|
2661
2647
|
historyCursor: t,
|
|
2662
2648
|
shortcutsOpen: !1
|
|
2663
|
-
},
|
|
2649
|
+
}, G.current = t, W.current = t, F(n), Y(un({
|
|
2664
2650
|
state: e,
|
|
2665
|
-
slashCommands:
|
|
2666
|
-
mentionCandidates:
|
|
2667
|
-
triggers:
|
|
2668
|
-
})),
|
|
2651
|
+
slashCommands: E,
|
|
2652
|
+
mentionCandidates: D,
|
|
2653
|
+
triggers: A
|
|
2654
|
+
})), J?.commands.focus("end"), z((e) => ({
|
|
2669
2655
|
...e,
|
|
2670
2656
|
historyCursor: t,
|
|
2671
2657
|
shortcutsOpen: !1
|
|
2672
2658
|
}));
|
|
2673
2659
|
}
|
|
2674
|
-
function
|
|
2675
|
-
n || (L(null),
|
|
2660
|
+
function nt() {
|
|
2661
|
+
n || (L(null), G.current = null, ce.current = Q(), z((e) => ({
|
|
2676
2662
|
...e,
|
|
2677
2663
|
reverseSearch: "",
|
|
2678
2664
|
historyCursor: null,
|
|
2679
2665
|
shortcutsOpen: !1
|
|
2680
2666
|
})));
|
|
2681
2667
|
}
|
|
2682
|
-
function
|
|
2668
|
+
function rt(e) {
|
|
2683
2669
|
if (n) {
|
|
2684
2670
|
e.preventDefault();
|
|
2685
2671
|
return;
|
|
2686
2672
|
}
|
|
2687
2673
|
if (e.preventDefault(), e.key === "Escape") {
|
|
2688
|
-
|
|
2674
|
+
ut(null), ce.current = null;
|
|
2689
2675
|
return;
|
|
2690
2676
|
}
|
|
2691
2677
|
if (e.key === "Enter") {
|
|
2692
|
-
|
|
2678
|
+
ce.current = null, z((e) => ({
|
|
2693
2679
|
...e,
|
|
2694
2680
|
reverseSearch: null,
|
|
2695
2681
|
shortcutsOpen: !1
|
|
@@ -2697,46 +2683,46 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2697
2683
|
return;
|
|
2698
2684
|
}
|
|
2699
2685
|
if (e.key === "Backspace") {
|
|
2700
|
-
|
|
2686
|
+
ot((e) => e.slice(0, -1));
|
|
2701
2687
|
return;
|
|
2702
2688
|
}
|
|
2703
2689
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "r") {
|
|
2704
|
-
|
|
2690
|
+
st(1);
|
|
2705
2691
|
return;
|
|
2706
2692
|
}
|
|
2707
2693
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "s") {
|
|
2708
|
-
|
|
2694
|
+
st(-1);
|
|
2709
2695
|
return;
|
|
2710
2696
|
}
|
|
2711
|
-
e.key.length === 1 && !e.metaKey && !e.altKey && !e.ctrlKey &&
|
|
2697
|
+
e.key.length === 1 && !e.metaKey && !e.altKey && !e.ctrlKey && ot((t) => `${t}${e.key}`);
|
|
2712
2698
|
}
|
|
2713
|
-
function
|
|
2699
|
+
function ot(e) {
|
|
2714
2700
|
if (n) return;
|
|
2715
|
-
let t = B.current, r = e(t.reverseSearch ?? ""), i =
|
|
2716
|
-
if (!
|
|
2717
|
-
|
|
2701
|
+
let t = B.current, r = e(t.reverseSearch ?? ""), i = it(t.history, r, null);
|
|
2702
|
+
if (!J || !i) {
|
|
2703
|
+
ut(r);
|
|
2718
2704
|
return;
|
|
2719
2705
|
}
|
|
2720
|
-
|
|
2706
|
+
lt(i.entry, i.index, r);
|
|
2721
2707
|
}
|
|
2722
|
-
function
|
|
2723
|
-
if (n || !
|
|
2724
|
-
let t = B.current, r = t.reverseSearch ?? "", i =
|
|
2725
|
-
i &&
|
|
2708
|
+
function st(e) {
|
|
2709
|
+
if (n || !J) return;
|
|
2710
|
+
let t = B.current, r = t.reverseSearch ?? "", i = it(t.history, r, t.historyCursor, e);
|
|
2711
|
+
i && lt(i.entry, i.index, r);
|
|
2726
2712
|
}
|
|
2727
|
-
function
|
|
2728
|
-
let r =
|
|
2713
|
+
function lt(e, t, n) {
|
|
2714
|
+
let r = J;
|
|
2729
2715
|
if (!r) return;
|
|
2730
|
-
let i =
|
|
2716
|
+
let i = Ge({
|
|
2731
2717
|
source: e,
|
|
2732
|
-
slashCommands:
|
|
2733
|
-
mentionCandidates:
|
|
2718
|
+
slashCommands: E,
|
|
2719
|
+
mentionCandidates: D
|
|
2734
2720
|
}), a = i.remoteImages ?? [];
|
|
2735
|
-
V.current = a, F(a),
|
|
2721
|
+
V.current = a, F(a), Y(un({
|
|
2736
2722
|
state: i,
|
|
2737
|
-
slashCommands:
|
|
2738
|
-
mentionCandidates:
|
|
2739
|
-
triggers:
|
|
2723
|
+
slashCommands: E,
|
|
2724
|
+
mentionCandidates: D,
|
|
2725
|
+
triggers: A
|
|
2740
2726
|
})), r.commands.focus("end"), z((e) => ({
|
|
2741
2727
|
...e,
|
|
2742
2728
|
historyCursor: t,
|
|
@@ -2745,10 +2731,10 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2745
2731
|
shortcutsOpen: !1
|
|
2746
2732
|
}));
|
|
2747
2733
|
}
|
|
2748
|
-
function
|
|
2734
|
+
function ut(e) {
|
|
2749
2735
|
if (n) return;
|
|
2750
|
-
let t =
|
|
2751
|
-
if (!t || !
|
|
2736
|
+
let t = ce.current;
|
|
2737
|
+
if (!t || !J) {
|
|
2752
2738
|
z((t) => ({
|
|
2753
2739
|
...t,
|
|
2754
2740
|
reverseSearch: e,
|
|
@@ -2765,52 +2751,52 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2765
2751
|
selectedRemoteImageId: null,
|
|
2766
2752
|
shortcutsOpen: !1
|
|
2767
2753
|
};
|
|
2768
|
-
|
|
2754
|
+
G.current = null, V.current = r.remoteImages, F(r.remoteImages), Y(un({
|
|
2769
2755
|
state: r,
|
|
2770
|
-
slashCommands:
|
|
2771
|
-
mentionCandidates:
|
|
2772
|
-
triggers:
|
|
2773
|
-
})),
|
|
2756
|
+
slashCommands: E,
|
|
2757
|
+
mentionCandidates: D,
|
|
2758
|
+
triggers: A
|
|
2759
|
+
})), J.commands.focus("end"), z(r);
|
|
2774
2760
|
}
|
|
2775
|
-
|
|
2776
|
-
function
|
|
2761
|
+
_e.current = n ? (e) => (e.preventDefault(), !0) : ze, pe.current = ke;
|
|
2762
|
+
function dt(e) {
|
|
2777
2763
|
if (!(e.target instanceof Element) || !e.target.closest("[data-slot=\"composer-editor\"]")) return;
|
|
2778
2764
|
if (n) {
|
|
2779
2765
|
e.preventDefault();
|
|
2780
2766
|
return;
|
|
2781
2767
|
}
|
|
2782
|
-
if (!
|
|
2768
|
+
if (!J || ze(e)) return;
|
|
2783
2769
|
if (B.current.reverseSearch !== null) {
|
|
2784
|
-
|
|
2770
|
+
rt(e);
|
|
2785
2771
|
return;
|
|
2786
2772
|
}
|
|
2787
2773
|
if (B.current.shortcutsOpen && e.key === "Escape") {
|
|
2788
|
-
e.preventDefault(),
|
|
2774
|
+
e.preventDefault(), Ee();
|
|
2789
2775
|
return;
|
|
2790
2776
|
}
|
|
2791
|
-
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey &&
|
|
2792
|
-
e.preventDefault(),
|
|
2777
|
+
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && we(Q())) {
|
|
2778
|
+
e.preventDefault(), De();
|
|
2793
2779
|
return;
|
|
2794
2780
|
}
|
|
2795
|
-
if (
|
|
2796
|
-
e.preventDefault(),
|
|
2781
|
+
if (Kr(e)) {
|
|
2782
|
+
e.preventDefault(), J.chain().focus().setHardBreak().run(), G.current = null, L(null);
|
|
2797
2783
|
return;
|
|
2798
2784
|
}
|
|
2799
2785
|
if (H.current) {
|
|
2800
2786
|
if (lr(e) || ur(e)) {
|
|
2801
|
-
e.preventDefault(),
|
|
2787
|
+
e.preventDefault(), pt(lr(e) ? -1 : 1);
|
|
2802
2788
|
return;
|
|
2803
2789
|
}
|
|
2804
2790
|
if (e.key === "Tab") {
|
|
2805
|
-
e.preventDefault(),
|
|
2791
|
+
e.preventDefault(), Se();
|
|
2806
2792
|
return;
|
|
2807
2793
|
}
|
|
2808
2794
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2809
|
-
if (e.preventDefault(),
|
|
2810
|
-
L(null),
|
|
2795
|
+
if (e.preventDefault(), ve.length === 0) {
|
|
2796
|
+
L(null), Xe();
|
|
2811
2797
|
return;
|
|
2812
2798
|
}
|
|
2813
|
-
|
|
2799
|
+
Se();
|
|
2814
2800
|
return;
|
|
2815
2801
|
}
|
|
2816
2802
|
if (e.key === "Escape") {
|
|
@@ -2818,218 +2804,218 @@ function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2818
2804
|
return;
|
|
2819
2805
|
}
|
|
2820
2806
|
}
|
|
2821
|
-
if (
|
|
2822
|
-
let t = Jn(
|
|
2823
|
-
t && (e.preventDefault(),
|
|
2807
|
+
if (qr(e)) {
|
|
2808
|
+
let t = Jn(J);
|
|
2809
|
+
t && (e.preventDefault(), oe.current = t, z((e) => ({
|
|
2824
2810
|
...e,
|
|
2825
2811
|
killBuffer: t.text
|
|
2826
|
-
}))),
|
|
2812
|
+
}))), G.current = null;
|
|
2827
2813
|
return;
|
|
2828
2814
|
}
|
|
2829
|
-
let t =
|
|
2815
|
+
let t = Jr(e);
|
|
2830
2816
|
if (t !== null) {
|
|
2831
|
-
e.preventDefault(), Xn(
|
|
2817
|
+
e.preventDefault(), Xn(J, t), G.current = null;
|
|
2832
2818
|
return;
|
|
2833
2819
|
}
|
|
2834
2820
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "e") {
|
|
2835
|
-
e.preventDefault(), Yn(
|
|
2821
|
+
e.preventDefault(), Yn(J), G.current = null;
|
|
2836
2822
|
return;
|
|
2837
2823
|
}
|
|
2838
2824
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
2839
|
-
let t = Kn(
|
|
2840
|
-
t && (e.preventDefault(),
|
|
2825
|
+
let t = Kn(J);
|
|
2826
|
+
t && (e.preventDefault(), oe.current = t, z((e) => ({
|
|
2841
2827
|
...e,
|
|
2842
2828
|
killBuffer: t.text
|
|
2843
2829
|
})));
|
|
2844
2830
|
return;
|
|
2845
2831
|
}
|
|
2846
2832
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "u") {
|
|
2847
|
-
let t = qn(
|
|
2848
|
-
t && (e.preventDefault(),
|
|
2833
|
+
let t = qn(J);
|
|
2834
|
+
t && (e.preventDefault(), oe.current = t, z((e) => ({
|
|
2849
2835
|
...e,
|
|
2850
2836
|
killBuffer: t.text
|
|
2851
2837
|
})));
|
|
2852
2838
|
return;
|
|
2853
2839
|
}
|
|
2854
2840
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y" && B.current.killBuffer) {
|
|
2855
|
-
e.preventDefault(), rr(
|
|
2841
|
+
e.preventDefault(), rr(J, oe.current ?? B.current.killBuffer);
|
|
2856
2842
|
return;
|
|
2857
2843
|
}
|
|
2858
2844
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "r") {
|
|
2859
|
-
e.preventDefault(),
|
|
2845
|
+
e.preventDefault(), nt();
|
|
2860
2846
|
return;
|
|
2861
2847
|
}
|
|
2862
|
-
if ((e.key === "Backspace" || e.key === "Delete") &&
|
|
2863
|
-
e.preventDefault(),
|
|
2848
|
+
if ((e.key === "Backspace" || e.key === "Delete") && Xr(J)) {
|
|
2849
|
+
e.preventDefault(), G.current = null, L(null);
|
|
2864
2850
|
return;
|
|
2865
2851
|
}
|
|
2866
|
-
if ((e.key === "Backspace" || e.key === "Delete") && ir(
|
|
2867
|
-
e.preventDefault(),
|
|
2852
|
+
if ((e.key === "Backspace" || e.key === "Delete") && ir(J, e.key)) {
|
|
2853
|
+
e.preventDefault(), G.current = null;
|
|
2868
2854
|
return;
|
|
2869
2855
|
}
|
|
2870
|
-
if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (
|
|
2871
|
-
e.preventDefault(),
|
|
2856
|
+
if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (G.current = null), e.key === "Enter" && !e.shiftKey && !e.altKey) {
|
|
2857
|
+
e.preventDefault(), Xe();
|
|
2872
2858
|
return;
|
|
2873
2859
|
}
|
|
2874
|
-
let r =
|
|
2860
|
+
let r = Yr(e);
|
|
2875
2861
|
if (r !== null && !H.current) {
|
|
2876
|
-
let t =
|
|
2877
|
-
if (e.key === "ArrowUp" && (sr(
|
|
2878
|
-
e.preventDefault(),
|
|
2862
|
+
let t = Q();
|
|
2863
|
+
if (e.key === "ArrowUp" && (sr(J) || t.cursor === 0) && t.remoteImages.length > 0) {
|
|
2864
|
+
e.preventDefault(), X(t.remoteImages.length - 1);
|
|
2879
2865
|
return;
|
|
2880
2866
|
}
|
|
2881
|
-
|
|
2867
|
+
at(t.text, t.cursor, r) && (e.preventDefault(), $e(r));
|
|
2882
2868
|
}
|
|
2883
2869
|
}
|
|
2884
|
-
function
|
|
2870
|
+
function ft(e) {
|
|
2885
2871
|
if (n) {
|
|
2886
2872
|
e.preventDefault();
|
|
2887
2873
|
return;
|
|
2888
2874
|
}
|
|
2889
|
-
e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") &&
|
|
2875
|
+
e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") && Fe();
|
|
2890
2876
|
}
|
|
2891
|
-
function
|
|
2877
|
+
function pt(e) {
|
|
2892
2878
|
n || L((t) => {
|
|
2893
2879
|
if (!t) return t;
|
|
2894
|
-
let n = Rt(t,
|
|
2880
|
+
let n = Rt(t, E, D, a).length;
|
|
2895
2881
|
return n === 0 ? t : {
|
|
2896
2882
|
...t,
|
|
2897
|
-
selectedIndex:
|
|
2883
|
+
selectedIndex: ct(t.selectedIndex + e, n)
|
|
2898
2884
|
};
|
|
2899
2885
|
});
|
|
2900
2886
|
}
|
|
2901
|
-
let
|
|
2887
|
+
let mt = $t({
|
|
2902
2888
|
dictation: p,
|
|
2903
2889
|
disabled: n,
|
|
2904
|
-
insertTranscript:
|
|
2905
|
-
submitDraft:
|
|
2890
|
+
insertTranscript: Ye,
|
|
2891
|
+
submitDraft: Ze
|
|
2906
2892
|
});
|
|
2907
|
-
return /* @__PURE__ */
|
|
2893
|
+
return /* @__PURE__ */ w(ae, {
|
|
2908
2894
|
value: {
|
|
2909
2895
|
state: R,
|
|
2910
2896
|
disabled: n,
|
|
2911
|
-
commandTriggers:
|
|
2897
|
+
commandTriggers: O,
|
|
2912
2898
|
activePopup: I,
|
|
2913
|
-
suggestions:
|
|
2914
|
-
attachedImages:
|
|
2899
|
+
suggestions: ve,
|
|
2900
|
+
attachedImages: fe.current,
|
|
2915
2901
|
actions: {
|
|
2916
|
-
acceptSuggestion:
|
|
2917
|
-
toggleSlashMenu:
|
|
2918
|
-
insertText:
|
|
2919
|
-
attachImageFiles:
|
|
2920
|
-
removeImageAttachment:
|
|
2921
|
-
addRemoteImage:
|
|
2922
|
-
handleDrop:
|
|
2923
|
-
insertPaste:
|
|
2924
|
-
insertRichLink:
|
|
2925
|
-
openShortcuts:
|
|
2926
|
-
closeShortcuts:
|
|
2927
|
-
toggleShortcuts:
|
|
2928
|
-
submit:
|
|
2929
|
-
reset:
|
|
2902
|
+
acceptSuggestion: Se,
|
|
2903
|
+
toggleSlashMenu: Ce,
|
|
2904
|
+
insertText: Oe,
|
|
2905
|
+
attachImageFiles: je,
|
|
2906
|
+
removeImageAttachment: Me,
|
|
2907
|
+
addRemoteImage: Ne,
|
|
2908
|
+
handleDrop: Pe,
|
|
2909
|
+
insertPaste: Ke,
|
|
2910
|
+
insertRichLink: qe,
|
|
2911
|
+
openShortcuts: Te,
|
|
2912
|
+
closeShortcuts: Ee,
|
|
2913
|
+
toggleShortcuts: De,
|
|
2914
|
+
submit: Xe,
|
|
2915
|
+
reset: Qe
|
|
2930
2916
|
},
|
|
2931
|
-
meta: { editor:
|
|
2917
|
+
meta: { editor: J }
|
|
2932
2918
|
},
|
|
2933
|
-
children: /* @__PURE__ */
|
|
2934
|
-
value:
|
|
2935
|
-
children: /* @__PURE__ */
|
|
2919
|
+
children: /* @__PURE__ */ w(Bt, {
|
|
2920
|
+
value: mt?.api ?? null,
|
|
2921
|
+
children: /* @__PURE__ */ w("section", {
|
|
2936
2922
|
"data-slot": "composer",
|
|
2937
2923
|
className: l("border-border bg-card relative border font-[inherit]", d),
|
|
2938
|
-
children: /* @__PURE__ */
|
|
2939
|
-
onKeyDownCapture:
|
|
2940
|
-
onMouseDownCapture:
|
|
2941
|
-
children: [f, S.hasLayoutChildren ? null : /* @__PURE__ */
|
|
2924
|
+
children: /* @__PURE__ */ T("div", {
|
|
2925
|
+
onKeyDownCapture: dt,
|
|
2926
|
+
onMouseDownCapture: ft,
|
|
2927
|
+
children: [f, S.hasLayoutChildren ? null : /* @__PURE__ */ w(wr, {})]
|
|
2942
2928
|
})
|
|
2943
2929
|
})
|
|
2944
2930
|
})
|
|
2945
2931
|
});
|
|
2946
2932
|
}
|
|
2947
|
-
function
|
|
2933
|
+
function wr() {
|
|
2948
2934
|
let e = i(2), t;
|
|
2949
|
-
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */
|
|
2935
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ w(Ar, {}), e[0] = t) : t = e[0];
|
|
2950
2936
|
let n;
|
|
2951
|
-
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */
|
|
2937
|
+
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ T(C, { children: [
|
|
2952
2938
|
t,
|
|
2953
|
-
/* @__PURE__ */
|
|
2954
|
-
/* @__PURE__ */
|
|
2955
|
-
/* @__PURE__ */
|
|
2956
|
-
/* @__PURE__ */
|
|
2957
|
-
/* @__PURE__ */
|
|
2939
|
+
/* @__PURE__ */ T(Tr, { children: [
|
|
2940
|
+
/* @__PURE__ */ w(Dr, {}),
|
|
2941
|
+
/* @__PURE__ */ w(P, {}),
|
|
2942
|
+
/* @__PURE__ */ w(Or, {}),
|
|
2943
|
+
/* @__PURE__ */ w(kr, {})
|
|
2958
2944
|
] }),
|
|
2959
|
-
/* @__PURE__ */
|
|
2960
|
-
/* @__PURE__ */
|
|
2945
|
+
/* @__PURE__ */ w(Pr, {}),
|
|
2946
|
+
/* @__PURE__ */ w(Lr, {})
|
|
2961
2947
|
] }), e[1] = n) : n = e[1], n;
|
|
2962
2948
|
}
|
|
2963
|
-
function
|
|
2949
|
+
function Tr(e) {
|
|
2964
2950
|
let t = i(8), n, r;
|
|
2965
2951
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2966
2952
|
let a;
|
|
2967
2953
|
t[3] === n ? a = t[4] : (a = l("space-y-2", n), t[3] = n, t[4] = a);
|
|
2968
2954
|
let o;
|
|
2969
|
-
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */
|
|
2955
|
+
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ w("div", {
|
|
2970
2956
|
className: a,
|
|
2971
2957
|
...r
|
|
2972
2958
|
}), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
|
|
2973
2959
|
}
|
|
2974
|
-
function
|
|
2960
|
+
function Er(e) {
|
|
2975
2961
|
let t = i(8), n, r;
|
|
2976
2962
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2977
2963
|
let a;
|
|
2978
2964
|
t[3] === n ? a = t[4] : (a = l("flex flex-wrap items-center gap-1.5", n), t[3] = n, t[4] = a);
|
|
2979
2965
|
let o;
|
|
2980
|
-
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */
|
|
2966
|
+
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ w("div", {
|
|
2981
2967
|
className: a,
|
|
2982
2968
|
...r
|
|
2983
2969
|
}), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
|
|
2984
2970
|
}
|
|
2985
|
-
function
|
|
2971
|
+
function Dr(e) {
|
|
2986
2972
|
let t = i(14), n, r;
|
|
2987
2973
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2988
|
-
let { state: a } =
|
|
2974
|
+
let { state: a } = M("Composer.RemoteImages");
|
|
2989
2975
|
if (a.remoteImages.length === 0) return null;
|
|
2990
2976
|
let o;
|
|
2991
2977
|
t[3] === n ? o = t[4] : (o = l("border-border space-y-1 border-b pb-2 text-sm", n), t[3] = n, t[4] = o);
|
|
2992
2978
|
let s;
|
|
2993
2979
|
if (t[5] !== a.remoteImages || t[6] !== a.selectedRemoteImageId) {
|
|
2994
2980
|
let e;
|
|
2995
|
-
t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */
|
|
2981
|
+
t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */ T("div", {
|
|
2996
2982
|
className: l("flex h-6 items-center gap-2 rounded-sm px-2", a.selectedRemoteImageId === e.id ? "bg-primary text-primary-foreground" : "text-sky-500"),
|
|
2997
|
-
children: [/* @__PURE__ */
|
|
2983
|
+
children: [/* @__PURE__ */ T("span", {
|
|
2998
2984
|
className: "shrink-0",
|
|
2999
2985
|
children: [
|
|
3000
2986
|
"[Image #",
|
|
3001
2987
|
t + 1,
|
|
3002
2988
|
"]"
|
|
3003
2989
|
]
|
|
3004
|
-
}), /* @__PURE__ */
|
|
2990
|
+
}), /* @__PURE__ */ w("span", {
|
|
3005
2991
|
className: "truncate text-xs opacity-70",
|
|
3006
2992
|
children: e.url
|
|
3007
2993
|
})]
|
|
3008
2994
|
}, e.id), t[8] = a.selectedRemoteImageId, t[9] = e), s = a.remoteImages.map(e), t[5] = a.remoteImages, t[6] = a.selectedRemoteImageId, t[7] = s;
|
|
3009
2995
|
} else s = t[7];
|
|
3010
2996
|
let c;
|
|
3011
|
-
return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */
|
|
2997
|
+
return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */ w("div", {
|
|
3012
2998
|
className: o,
|
|
3013
2999
|
...r,
|
|
3014
3000
|
children: s
|
|
3015
3001
|
}), t[10] = r, t[11] = o, t[12] = s, t[13] = c) : c = t[13], c;
|
|
3016
3002
|
}
|
|
3017
|
-
function
|
|
3003
|
+
function Or(e) {
|
|
3018
3004
|
let t = i(21), n, r, a, s;
|
|
3019
3005
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], s = t[4]) : ({className: n, onDrop: r, placeholder: s, ...a} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = s);
|
|
3020
|
-
let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } =
|
|
3006
|
+
let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } = M("Composer.Editor"), p = u ? "" : void 0, m;
|
|
3021
3007
|
t[5] !== f || t[6] !== r ? (m = (e) => {
|
|
3022
3008
|
r?.(e), !e.defaultPrevented && f.handleDrop(e.dataTransfer) && e.preventDefault();
|
|
3023
3009
|
}, t[5] = f, t[6] = r, t[7] = m) : m = t[7];
|
|
3024
3010
|
let h;
|
|
3025
|
-
t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */
|
|
3011
|
+
t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */ w("div", {
|
|
3026
3012
|
"data-slot": "composer-placeholder",
|
|
3027
3013
|
children: c
|
|
3028
3014
|
}) : null, t[8] = c, t[9] = l.text.length, t[10] = h) : h = t[10];
|
|
3029
3015
|
let g;
|
|
3030
|
-
t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */
|
|
3016
|
+
t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */ w(o, { editor: d.editor }), t[11] = d.editor, t[12] = g);
|
|
3031
3017
|
let _;
|
|
3032
|
-
return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */
|
|
3018
|
+
return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */ T("div", {
|
|
3033
3019
|
"data-slot": "composer-frame",
|
|
3034
3020
|
className: n,
|
|
3035
3021
|
"aria-disabled": u,
|
|
@@ -3039,66 +3025,66 @@ function Mr(e) {
|
|
|
3039
3025
|
children: [h, g]
|
|
3040
3026
|
}), t[13] = n, t[14] = u, t[15] = a, t[16] = p, t[17] = m, t[18] = h, t[19] = g, t[20] = _) : _ = t[20], _;
|
|
3041
3027
|
}
|
|
3042
|
-
function
|
|
3028
|
+
function kr(e) {
|
|
3043
3029
|
let t = i(9), n, r;
|
|
3044
3030
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3045
|
-
let { state: a } =
|
|
3031
|
+
let { state: a } = M("Composer.Error");
|
|
3046
3032
|
if (!a.error) return null;
|
|
3047
3033
|
let o;
|
|
3048
3034
|
t[3] === n ? o = t[4] : (o = l("border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs", n), t[3] = n, t[4] = o);
|
|
3049
3035
|
let s;
|
|
3050
|
-
return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */
|
|
3036
|
+
return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */ w("div", {
|
|
3051
3037
|
role: "alert",
|
|
3052
3038
|
className: o,
|
|
3053
3039
|
...r,
|
|
3054
3040
|
children: a.error
|
|
3055
3041
|
}), t[5] = r, t[6] = a.error, t[7] = o, t[8] = s) : s = t[8], s;
|
|
3056
3042
|
}
|
|
3057
|
-
function
|
|
3043
|
+
function Ar(e) {
|
|
3058
3044
|
let t = i(25), n, r;
|
|
3059
3045
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3060
|
-
let { activePopup: a, suggestions: o, actions: s } =
|
|
3046
|
+
let { activePopup: a, suggestions: o, actions: s } = M("Composer.Popup"), { acceptSuggestion: c } = s;
|
|
3061
3047
|
if (!a) return null;
|
|
3062
3048
|
let u;
|
|
3063
|
-
t[3] === o ? u = t[4] : (u = o.some(
|
|
3049
|
+
t[3] === o ? u = t[4] : (u = o.some(jr), t[3] = o, t[4] = u);
|
|
3064
3050
|
let d = u, f;
|
|
3065
3051
|
t[5] === n ? f = t[6] : (f = l("border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg", n), t[5] = n, t[6] = f);
|
|
3066
3052
|
let p;
|
|
3067
3053
|
if (t[7] !== c || t[8] !== a || t[9] !== o || t[10] !== d) {
|
|
3068
3054
|
let e;
|
|
3069
|
-
t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */
|
|
3055
|
+
t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */ w(Mr, {
|
|
3070
3056
|
selected: t === a.selectedIndex,
|
|
3071
3057
|
icon: d ? e.icon : null,
|
|
3072
|
-
token:
|
|
3058
|
+
token: K(e),
|
|
3073
3059
|
takesArgs: e.supportsArgs === !0,
|
|
3074
3060
|
description: e.detail,
|
|
3075
3061
|
onMouseDown: () => c({ index: t })
|
|
3076
3062
|
}, `item:${e.id}`), t[12] = c, t[13] = a, t[14] = d, t[15] = e) : e = t[15], p = o.map(e), t[7] = c, t[8] = a, t[9] = o, t[10] = d, t[11] = p;
|
|
3077
3063
|
} else p = t[11];
|
|
3078
3064
|
let m;
|
|
3079
|
-
t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */
|
|
3065
|
+
t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */ w("div", {
|
|
3080
3066
|
className: "text-muted-foreground px-2 py-1 text-[13px] leading-4",
|
|
3081
3067
|
children: "no matches"
|
|
3082
3068
|
}) : null, t[16] = o.length, t[17] = m);
|
|
3083
3069
|
let h;
|
|
3084
|
-
t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */
|
|
3070
|
+
t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */ T("div", {
|
|
3085
3071
|
className: "flex max-h-72 flex-col gap-1 overflow-y-auto p-1",
|
|
3086
3072
|
role: "listbox",
|
|
3087
3073
|
"aria-label": "Suggestions",
|
|
3088
3074
|
children: [p, m]
|
|
3089
3075
|
}), t[18] = p, t[19] = m, t[20] = h) : h = t[20];
|
|
3090
3076
|
let g;
|
|
3091
|
-
return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */
|
|
3077
|
+
return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */ w("div", {
|
|
3092
3078
|
className: f,
|
|
3093
3079
|
...r,
|
|
3094
3080
|
children: h
|
|
3095
3081
|
}), t[21] = r, t[22] = f, t[23] = h, t[24] = g) : g = t[24], g;
|
|
3096
3082
|
}
|
|
3097
|
-
function
|
|
3083
|
+
function jr(e) {
|
|
3098
3084
|
return e.icon;
|
|
3099
3085
|
}
|
|
3100
|
-
function
|
|
3101
|
-
let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u =
|
|
3086
|
+
function Mr(e) {
|
|
3087
|
+
let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u = b(null), d, f;
|
|
3102
3088
|
t[0] === n ? (d = t[1], f = t[2]) : (d = () => {
|
|
3103
3089
|
n && u.current?.scrollIntoView({ block: "nearest" });
|
|
3104
3090
|
}, f = [n], t[0] = n, t[1] = d, t[2] = f), _(d, f);
|
|
@@ -3109,27 +3095,27 @@ function Ir(e) {
|
|
|
3109
3095
|
e.preventDefault(), c();
|
|
3110
3096
|
}, t[5] = c, t[6] = h);
|
|
3111
3097
|
let g;
|
|
3112
|
-
t[7] === r ? g = t[8] : (g = r === null ? null : /* @__PURE__ */
|
|
3098
|
+
t[7] === r ? g = t[8] : (g = r === null ? null : /* @__PURE__ */ w("span", {
|
|
3113
3099
|
className: "flex size-4 shrink-0 items-center justify-center",
|
|
3114
3100
|
children: r
|
|
3115
3101
|
}), t[7] = r, t[8] = g);
|
|
3116
3102
|
let v;
|
|
3117
|
-
t[9] === a ? v = t[10] : (v = /* @__PURE__ */
|
|
3103
|
+
t[9] === a ? v = t[10] : (v = /* @__PURE__ */ w("span", {
|
|
3118
3104
|
className: "truncate",
|
|
3119
3105
|
children: a
|
|
3120
3106
|
}), t[9] = a, t[10] = v);
|
|
3121
|
-
let
|
|
3122
|
-
t[11] === o ?
|
|
3107
|
+
let y;
|
|
3108
|
+
t[11] === o ? y = t[12] : (y = o ? /* @__PURE__ */ w("span", {
|
|
3123
3109
|
className: "text-muted-foreground shrink-0",
|
|
3124
3110
|
children: "args"
|
|
3125
|
-
}) : null, t[11] = o, t[12] =
|
|
3111
|
+
}) : null, t[11] = o, t[12] = y);
|
|
3126
3112
|
let x;
|
|
3127
|
-
t[13] === s ? x = t[14] : (x = /* @__PURE__ */
|
|
3113
|
+
t[13] === s ? x = t[14] : (x = /* @__PURE__ */ w("span", {
|
|
3128
3114
|
className: "text-muted-foreground truncate",
|
|
3129
3115
|
children: s
|
|
3130
3116
|
}), t[13] = s, t[14] = x);
|
|
3131
|
-
let
|
|
3132
|
-
return t[15] !== n || t[16] !== m || t[17] !== h || t[18] !== g || t[19] !== v || t[20] !==
|
|
3117
|
+
let ee;
|
|
3118
|
+
return t[15] !== n || t[16] !== m || t[17] !== h || t[18] !== g || t[19] !== v || t[20] !== y || t[21] !== x ? (ee = /* @__PURE__ */ T("button", {
|
|
3133
3119
|
ref: u,
|
|
3134
3120
|
type: "button",
|
|
3135
3121
|
role: "option",
|
|
@@ -3139,12 +3125,12 @@ function Ir(e) {
|
|
|
3139
3125
|
children: [
|
|
3140
3126
|
g,
|
|
3141
3127
|
v,
|
|
3142
|
-
|
|
3128
|
+
y,
|
|
3143
3129
|
x
|
|
3144
3130
|
]
|
|
3145
|
-
}), t[15] = n, t[16] = m, t[17] = h, t[18] = g, t[19] = v, t[20] =
|
|
3131
|
+
}), t[15] = n, t[16] = m, t[17] = h, t[18] = g, t[19] = v, t[20] = y, t[21] = x, t[22] = ee) : ee = t[22], ee;
|
|
3146
3132
|
}
|
|
3147
|
-
var
|
|
3133
|
+
var Nr = [
|
|
3148
3134
|
{
|
|
3149
3135
|
title: "Send",
|
|
3150
3136
|
items: [
|
|
@@ -3172,22 +3158,22 @@ var Lr = [
|
|
|
3172
3158
|
]
|
|
3173
3159
|
}
|
|
3174
3160
|
];
|
|
3175
|
-
function
|
|
3161
|
+
function Pr(e) {
|
|
3176
3162
|
let t = i(13), n, r;
|
|
3177
3163
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3178
|
-
let { state: a, actions: o } =
|
|
3179
|
-
if (!a.shortcutsOpen || !
|
|
3164
|
+
let { state: a, actions: o } = M("Composer.Shortcuts"), { closeShortcuts: s } = o;
|
|
3165
|
+
if (!a.shortcutsOpen || !me(a)) return null;
|
|
3180
3166
|
let c;
|
|
3181
3167
|
t[3] === n ? c = t[4] : (c = l("border-border bg-popover border-t px-3 py-3 text-xs", n), t[3] = n, t[4] = c);
|
|
3182
3168
|
let u;
|
|
3183
|
-
t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */
|
|
3169
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ w("div", {
|
|
3184
3170
|
className: "text-foreground font-medium",
|
|
3185
3171
|
children: "Keyboard shortcuts"
|
|
3186
3172
|
}), t[5] = u) : u = t[5];
|
|
3187
3173
|
let d;
|
|
3188
|
-
t[6] === s ? d = t[7] : (d = /* @__PURE__ */
|
|
3174
|
+
t[6] === s ? d = t[7] : (d = /* @__PURE__ */ T("div", {
|
|
3189
3175
|
className: "mb-3 flex items-center justify-between gap-3",
|
|
3190
|
-
children: [u, /* @__PURE__ */
|
|
3176
|
+
children: [u, /* @__PURE__ */ w("button", {
|
|
3191
3177
|
type: "button",
|
|
3192
3178
|
className: "text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1",
|
|
3193
3179
|
onClick: s,
|
|
@@ -3195,12 +3181,12 @@ function Rr(e) {
|
|
|
3195
3181
|
})]
|
|
3196
3182
|
}), t[6] = s, t[7] = d);
|
|
3197
3183
|
let f;
|
|
3198
|
-
t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */
|
|
3184
|
+
t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ w("div", {
|
|
3199
3185
|
className: "grid gap-3 sm:grid-cols-3",
|
|
3200
|
-
children:
|
|
3186
|
+
children: Nr.map(Fr)
|
|
3201
3187
|
}), t[8] = f) : f = t[8];
|
|
3202
3188
|
let p;
|
|
3203
|
-
return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */
|
|
3189
|
+
return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */ T("div", {
|
|
3204
3190
|
role: "dialog",
|
|
3205
3191
|
"aria-label": "Keyboard shortcuts",
|
|
3206
3192
|
className: c,
|
|
@@ -3208,52 +3194,52 @@ function Rr(e) {
|
|
|
3208
3194
|
children: [d, f]
|
|
3209
3195
|
}), t[9] = r, t[10] = c, t[11] = d, t[12] = p) : p = t[12], p;
|
|
3210
3196
|
}
|
|
3211
|
-
function
|
|
3212
|
-
return /* @__PURE__ */
|
|
3197
|
+
function Fr(e) {
|
|
3198
|
+
return /* @__PURE__ */ T("div", {
|
|
3213
3199
|
className: "space-y-2",
|
|
3214
|
-
children: [/* @__PURE__ */
|
|
3200
|
+
children: [/* @__PURE__ */ w("div", {
|
|
3215
3201
|
className: "text-muted-foreground text-[11px]",
|
|
3216
3202
|
children: e.title
|
|
3217
|
-
}), /* @__PURE__ */
|
|
3203
|
+
}), /* @__PURE__ */ w("div", {
|
|
3218
3204
|
className: "space-y-1",
|
|
3219
|
-
children: e.items.map(
|
|
3205
|
+
children: e.items.map(Ir)
|
|
3220
3206
|
})]
|
|
3221
3207
|
}, e.title);
|
|
3222
3208
|
}
|
|
3223
|
-
function
|
|
3209
|
+
function Ir(e) {
|
|
3224
3210
|
let [t, n] = e;
|
|
3225
|
-
return /* @__PURE__ */
|
|
3211
|
+
return /* @__PURE__ */ T("div", {
|
|
3226
3212
|
className: "flex items-center justify-between gap-2",
|
|
3227
|
-
children: [/* @__PURE__ */
|
|
3213
|
+
children: [/* @__PURE__ */ w("kbd", {
|
|
3228
3214
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
3229
3215
|
children: t
|
|
3230
|
-
}), /* @__PURE__ */
|
|
3216
|
+
}), /* @__PURE__ */ w("span", {
|
|
3231
3217
|
className: "text-muted-foreground text-right",
|
|
3232
3218
|
children: n
|
|
3233
3219
|
})]
|
|
3234
3220
|
}, `${t}-${n}`);
|
|
3235
3221
|
}
|
|
3236
|
-
function
|
|
3237
|
-
let t = i(
|
|
3222
|
+
function Lr(e) {
|
|
3223
|
+
let t = i(29), n, r;
|
|
3238
3224
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3239
|
-
let { activePopup: a, state: o
|
|
3225
|
+
let { activePopup: a, state: o } = M("Composer.Footer");
|
|
3240
3226
|
if (o.reverseSearch !== null) {
|
|
3241
3227
|
let e;
|
|
3242
3228
|
t[3] === n ? e = t[4] : (e = l("border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]", n), t[3] = n, t[4] = e);
|
|
3243
3229
|
let i, a;
|
|
3244
|
-
t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */
|
|
3230
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ w("kbd", {
|
|
3245
3231
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
3246
3232
|
children: "Ctrl R"
|
|
3247
|
-
}), a = /* @__PURE__ */
|
|
3233
|
+
}), a = /* @__PURE__ */ w("span", { children: "reverse-i-search:" }), t[5] = i, t[6] = a) : (i = t[5], a = t[6]);
|
|
3248
3234
|
let s = o.reverseSearch || "_", c;
|
|
3249
|
-
t[7] === s ? c = t[8] : (c = /* @__PURE__ */
|
|
3235
|
+
t[7] === s ? c = t[8] : (c = /* @__PURE__ */ w("span", {
|
|
3250
3236
|
className: "text-foreground",
|
|
3251
3237
|
children: s
|
|
3252
3238
|
}), t[7] = s, t[8] = c);
|
|
3253
3239
|
let u, d, f, p;
|
|
3254
|
-
t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */
|
|
3240
|
+
t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ w("span", { children: "Ctrl R previous" }), d = /* @__PURE__ */ w("span", { children: "Ctrl S next" }), f = /* @__PURE__ */ w("span", { children: "Enter accept" }), p = /* @__PURE__ */ w("span", { children: "Esc cancel" }), t[9] = u, t[10] = d, t[11] = f, t[12] = p) : (u = t[9], d = t[10], f = t[11], p = t[12]);
|
|
3255
3241
|
let m;
|
|
3256
|
-
return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */
|
|
3242
|
+
return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */ T("div", {
|
|
3257
3243
|
className: e,
|
|
3258
3244
|
...r,
|
|
3259
3245
|
children: [
|
|
@@ -3267,8 +3253,8 @@ function Vr(e) {
|
|
|
3267
3253
|
]
|
|
3268
3254
|
}), t[13] = r, t[14] = e, t[15] = c, t[16] = m) : m = t[16], m;
|
|
3269
3255
|
}
|
|
3270
|
-
let
|
|
3271
|
-
t[17] !== a || t[18] !==
|
|
3256
|
+
let s;
|
|
3257
|
+
t[17] !== a || t[18] !== o.isTaskRunning || t[19] !== o.queueSubmissions ? (s = a ? [
|
|
3272
3258
|
["Enter", "insert"],
|
|
3273
3259
|
["Tab", "insert"],
|
|
3274
3260
|
["Esc", "dismiss"]
|
|
@@ -3284,35 +3270,35 @@ function Vr(e) {
|
|
|
3284
3270
|
["Ctrl W", "word kill"],
|
|
3285
3271
|
["Alt B/F", "word move"],
|
|
3286
3272
|
["Ctrl Y", "yank"]
|
|
3287
|
-
], t[17] = a, t[18] =
|
|
3288
|
-
let
|
|
3289
|
-
t[
|
|
3273
|
+
], t[17] = a, t[18] = o.isTaskRunning, t[19] = o.queueSubmissions, t[20] = s) : s = t[20];
|
|
3274
|
+
let c = s, u;
|
|
3275
|
+
t[21] === n ? u = t[22] : (u = l("border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]", n), t[21] = n, t[22] = u);
|
|
3276
|
+
let d;
|
|
3277
|
+
t[23] === c ? d = t[24] : (d = c.map(Rr), t[23] = c, t[24] = d);
|
|
3290
3278
|
let f;
|
|
3291
|
-
t[
|
|
3292
|
-
|
|
3293
|
-
return t[26] !== r || t[27] !== d || t[28] !== f ? (p = /* @__PURE__ */ C("div", {
|
|
3294
|
-
className: d,
|
|
3279
|
+
return t[25] !== r || t[26] !== u || t[27] !== d ? (f = /* @__PURE__ */ w("div", {
|
|
3280
|
+
className: u,
|
|
3295
3281
|
...r,
|
|
3296
|
-
children:
|
|
3297
|
-
}), t[
|
|
3282
|
+
children: d
|
|
3283
|
+
}), t[25] = r, t[26] = u, t[27] = d, t[28] = f) : f = t[28], f;
|
|
3298
3284
|
}
|
|
3299
|
-
function
|
|
3285
|
+
function Rr(e) {
|
|
3300
3286
|
let [t, n] = e;
|
|
3301
|
-
return /* @__PURE__ */
|
|
3287
|
+
return /* @__PURE__ */ T("span", {
|
|
3302
3288
|
className: "inline-flex items-center gap-1",
|
|
3303
|
-
children: [/* @__PURE__ */
|
|
3289
|
+
children: [/* @__PURE__ */ w("kbd", {
|
|
3304
3290
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
3305
3291
|
children: t
|
|
3306
3292
|
}), n]
|
|
3307
3293
|
}, `${t}-${n}`);
|
|
3308
3294
|
}
|
|
3309
|
-
function
|
|
3295
|
+
function zr(e) {
|
|
3310
3296
|
let t = i(19), n, r, a, o;
|
|
3311
3297
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({accept: a, multiple: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
|
|
3312
|
-
let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } =
|
|
3298
|
+
let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } = M("Composer.AttachFiles"), d = b(null), f;
|
|
3313
3299
|
t[5] === Symbol.for("react.memo_cache_sentinel") ? (f = () => d.current?.click(), t[5] = f) : f = t[5];
|
|
3314
3300
|
let p;
|
|
3315
|
-
t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */
|
|
3301
|
+
t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */ w(Gr, {
|
|
3316
3302
|
action: f,
|
|
3317
3303
|
disabled: n,
|
|
3318
3304
|
...r
|
|
@@ -3323,7 +3309,7 @@ function Ur(e) {
|
|
|
3323
3309
|
t.files && l.attachImageFiles(t.files), t.value = "";
|
|
3324
3310
|
}, t[9] = l, t[10] = h);
|
|
3325
3311
|
let g;
|
|
3326
|
-
t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */
|
|
3312
|
+
t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */ w("input", {
|
|
3327
3313
|
ref: d,
|
|
3328
3314
|
type: "file",
|
|
3329
3315
|
accept: s,
|
|
@@ -3334,82 +3320,82 @@ function Ur(e) {
|
|
|
3334
3320
|
onChange: h
|
|
3335
3321
|
}), t[11] = s, t[12] = c, t[13] = m, t[14] = h, t[15] = g) : g = t[15];
|
|
3336
3322
|
let _;
|
|
3337
|
-
return t[16] !== p || t[17] !== g ? (_ = /* @__PURE__ */
|
|
3323
|
+
return t[16] !== p || t[17] !== g ? (_ = /* @__PURE__ */ T(C, { children: [p, g] }), t[16] = p, t[17] = g, t[18] = _) : _ = t[18], _;
|
|
3338
3324
|
}
|
|
3339
|
-
function
|
|
3325
|
+
function Br(e) {
|
|
3340
3326
|
let t = i(9), n, r;
|
|
3341
3327
|
t[0] === e ? (n = t[1], r = t[2]) : ({url: r, ...n} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3342
|
-
let { actions: a } =
|
|
3328
|
+
let { actions: a } = M("Composer.AddRemoteImage"), o;
|
|
3343
3329
|
t[3] !== a || t[4] !== r ? (o = () => a.addRemoteImage(r), t[3] = a, t[4] = r, t[5] = o) : o = t[5];
|
|
3344
3330
|
let s;
|
|
3345
|
-
return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */
|
|
3331
|
+
return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */ w(Gr, {
|
|
3346
3332
|
action: o,
|
|
3347
3333
|
...n
|
|
3348
3334
|
}), t[6] = n, t[7] = o, t[8] = s) : s = t[8], s;
|
|
3349
3335
|
}
|
|
3350
|
-
function
|
|
3336
|
+
function Vr(e) {
|
|
3351
3337
|
let t = i(9), n, r;
|
|
3352
3338
|
t[0] === e ? (n = t[1], r = t[2]) : ({content: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3353
|
-
let { actions: a } =
|
|
3339
|
+
let { actions: a } = M("Composer.InsertPaste"), o;
|
|
3354
3340
|
t[3] !== a || t[4] !== n ? (o = () => a.insertPaste(n), t[3] = a, t[4] = n, t[5] = o) : o = t[5];
|
|
3355
3341
|
let s;
|
|
3356
|
-
return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */
|
|
3342
|
+
return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */ w(Gr, {
|
|
3357
3343
|
action: o,
|
|
3358
3344
|
...r
|
|
3359
3345
|
}), t[6] = r, t[7] = o, t[8] = s) : s = t[8], s;
|
|
3360
3346
|
}
|
|
3361
|
-
function
|
|
3347
|
+
function Hr(e) {
|
|
3362
3348
|
let t = i(13), n, r, a, o;
|
|
3363
3349
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({href: n, label: r, metadata: a, ...o} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
|
|
3364
|
-
let { actions: s } =
|
|
3350
|
+
let { actions: s } = M("Composer.InsertRichLink"), c;
|
|
3365
3351
|
t[5] !== s || t[6] !== n || t[7] !== r || t[8] !== a ? (c = () => s.insertRichLink(n, r, a), t[5] = s, t[6] = n, t[7] = r, t[8] = a, t[9] = c) : c = t[9];
|
|
3366
3352
|
let l;
|
|
3367
|
-
return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */
|
|
3353
|
+
return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */ w(Gr, {
|
|
3368
3354
|
action: c,
|
|
3369
3355
|
...o
|
|
3370
3356
|
}), t[10] = o, t[11] = c, t[12] = l) : l = t[12], l;
|
|
3371
3357
|
}
|
|
3372
|
-
function
|
|
3373
|
-
let t = i(3), { actions: n } =
|
|
3374
|
-
return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */
|
|
3358
|
+
function Ur(e) {
|
|
3359
|
+
let t = i(3), { actions: n } = M("Composer.Submit"), r;
|
|
3360
|
+
return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */ w(Gr, {
|
|
3375
3361
|
action: n.submit,
|
|
3376
3362
|
...e
|
|
3377
3363
|
}), t[0] = n.submit, t[1] = e, t[2] = r) : r = t[2], r;
|
|
3378
3364
|
}
|
|
3379
|
-
function
|
|
3380
|
-
let t = i(3), { actions: n } =
|
|
3381
|
-
return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */
|
|
3365
|
+
function Wr(e) {
|
|
3366
|
+
let t = i(3), { actions: n } = M("Composer.Reset"), r;
|
|
3367
|
+
return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */ w(Gr, {
|
|
3382
3368
|
action: n.reset,
|
|
3383
3369
|
...e
|
|
3384
3370
|
}), t[0] = n.reset, t[1] = e, t[2] = r) : r = t[2], r;
|
|
3385
3371
|
}
|
|
3386
|
-
function
|
|
3372
|
+
function Gr(e) {
|
|
3387
3373
|
let t = i(12), n, r, o, s;
|
|
3388
3374
|
t[0] === e ? (n = t[1], r = t[2], o = t[3], s = t[4]) : ({action: n, onClick: o, disabled: r, ...s} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o, t[4] = s);
|
|
3389
|
-
let { disabled: c } =
|
|
3375
|
+
let { disabled: c } = M("Composer.ActionTrigger"), l = c || r, u;
|
|
3390
3376
|
t[5] !== n || t[6] !== o ? (u = (e) => {
|
|
3391
3377
|
o?.(e), e.defaultPrevented || n();
|
|
3392
3378
|
}, t[5] = n, t[6] = o, t[7] = u) : u = t[7];
|
|
3393
3379
|
let d;
|
|
3394
|
-
return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */
|
|
3380
|
+
return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */ w(a, {
|
|
3395
3381
|
...s,
|
|
3396
3382
|
disabled: l,
|
|
3397
3383
|
onClick: u
|
|
3398
3384
|
}), t[8] = s, t[9] = l, t[10] = u, t[11] = d) : d = t[11], d;
|
|
3399
3385
|
}
|
|
3400
|
-
function
|
|
3386
|
+
function Kr(e) {
|
|
3401
3387
|
if (e.metaKey) return !1;
|
|
3402
3388
|
if (e.key === "Enter") return e.altKey && !e.ctrlKey;
|
|
3403
3389
|
let t = e.key.toLowerCase();
|
|
3404
3390
|
return e.ctrlKey && !e.altKey && (t === "j" || t === "m");
|
|
3405
3391
|
}
|
|
3406
|
-
function
|
|
3392
|
+
function qr(e) {
|
|
3407
3393
|
if (e.metaKey) return !1;
|
|
3408
3394
|
if (e.key === "Backspace") return e.ctrlKey || e.altKey;
|
|
3409
3395
|
let t = e.key.toLowerCase();
|
|
3410
3396
|
return e.ctrlKey && !e.altKey && t === "w" || e.ctrlKey && e.altKey && t === "h";
|
|
3411
3397
|
}
|
|
3412
|
-
function
|
|
3398
|
+
function Jr(e) {
|
|
3413
3399
|
if (e.metaKey || e.shiftKey) return null;
|
|
3414
3400
|
if (e.key === "ArrowLeft" && (e.altKey || e.ctrlKey)) return -1;
|
|
3415
3401
|
if (e.key === "ArrowRight" && (e.altKey || e.ctrlKey)) return 1;
|
|
@@ -3417,55 +3403,55 @@ function Qr(e) {
|
|
|
3417
3403
|
let t = e.key.toLowerCase();
|
|
3418
3404
|
return t === "b" ? -1 : t === "f" ? 1 : null;
|
|
3419
3405
|
}
|
|
3420
|
-
function
|
|
3406
|
+
function Yr(e) {
|
|
3421
3407
|
if (e.key === "ArrowUp") return -1;
|
|
3422
3408
|
if (e.key === "ArrowDown") return 1;
|
|
3423
3409
|
if (e.metaKey || e.altKey || e.shiftKey || !e.ctrlKey) return null;
|
|
3424
3410
|
let t = e.key.toLowerCase();
|
|
3425
3411
|
return t === "p" ? -1 : t === "n" ? 1 : null;
|
|
3426
3412
|
}
|
|
3427
|
-
function
|
|
3413
|
+
function Xr(e) {
|
|
3428
3414
|
let { doc: t, selection: n } = e.state;
|
|
3429
3415
|
return n.empty || n.from > 1 || n.to < t.content.size - 1 ? !1 : (e.commands.setContent(bn(), { emitUpdate: !0 }), e.commands.focus("start"), e.commands.setTextSelection(1), !0);
|
|
3430
3416
|
}
|
|
3431
|
-
var
|
|
3432
|
-
Root:
|
|
3417
|
+
var Zr = {
|
|
3418
|
+
Root: xr,
|
|
3433
3419
|
Trigger: kt,
|
|
3434
3420
|
Command: At,
|
|
3435
3421
|
Mention: jt,
|
|
3436
|
-
Content:
|
|
3437
|
-
Toolbar:
|
|
3438
|
-
RemoteImages:
|
|
3439
|
-
Attachments:
|
|
3440
|
-
Editor:
|
|
3441
|
-
Error:
|
|
3442
|
-
Popup:
|
|
3443
|
-
Shortcuts:
|
|
3444
|
-
Footer:
|
|
3445
|
-
AttachFiles:
|
|
3446
|
-
AddRemoteImage:
|
|
3447
|
-
InsertPaste:
|
|
3448
|
-
InsertRichLink:
|
|
3422
|
+
Content: Tr,
|
|
3423
|
+
Toolbar: Er,
|
|
3424
|
+
RemoteImages: Dr,
|
|
3425
|
+
Attachments: P,
|
|
3426
|
+
Editor: Or,
|
|
3427
|
+
Error: kr,
|
|
3428
|
+
Popup: Ar,
|
|
3429
|
+
Shortcuts: Pr,
|
|
3430
|
+
Footer: Lr,
|
|
3431
|
+
AttachFiles: zr,
|
|
3432
|
+
AddRemoteImage: Br,
|
|
3433
|
+
InsertPaste: Vr,
|
|
3434
|
+
InsertRichLink: Hr,
|
|
3449
3435
|
Dictate: Ut,
|
|
3450
3436
|
CancelDictation: Wt,
|
|
3451
|
-
Submit:
|
|
3452
|
-
Reset:
|
|
3437
|
+
Submit: Ur,
|
|
3438
|
+
Reset: Wr
|
|
3453
3439
|
};
|
|
3454
3440
|
//#endregion
|
|
3455
3441
|
//#region src/lib/ComposerTokenText.tsx
|
|
3456
|
-
function
|
|
3442
|
+
function Qr(e) {
|
|
3457
3443
|
let t = i(5), { text: n, elements: r } = e, a;
|
|
3458
|
-
t[0] !== r || t[1] !== n ? (a =
|
|
3444
|
+
t[0] !== r || t[1] !== n ? (a = ei(n, r).map($r), t[0] = r, t[1] = n, t[2] = a) : a = t[2];
|
|
3459
3445
|
let o;
|
|
3460
|
-
return t[3] === a ? o = t[4] : (o = /* @__PURE__ */ C
|
|
3446
|
+
return t[3] === a ? o = t[4] : (o = /* @__PURE__ */ w(C, { children: a }), t[3] = a, t[4] = o), o;
|
|
3461
3447
|
}
|
|
3462
|
-
function
|
|
3463
|
-
return e.element ? /* @__PURE__ */
|
|
3448
|
+
function $r(e) {
|
|
3449
|
+
return e.element ? /* @__PURE__ */ w("span", {
|
|
3464
3450
|
"data-token": e.element.kind,
|
|
3465
3451
|
children: e.text
|
|
3466
|
-
}, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */
|
|
3452
|
+
}, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */ w("span", { children: e.text }, `${e.start}-${e.end}`);
|
|
3467
3453
|
}
|
|
3468
|
-
function
|
|
3454
|
+
function ei(e, t) {
|
|
3469
3455
|
let n = t.toSorted((e, t) => e.range.start - t.range.start).filter((t) => t.range.start >= 0 && t.range.end <= e.length && e.slice(t.range.start, t.range.end) === t.label), r = [], i = 0;
|
|
3470
3456
|
for (let t of n) t.range.start > i && r.push({
|
|
3471
3457
|
text: e.slice(i, t.range.start),
|
|
@@ -3489,7 +3475,7 @@ function ii(e, t) {
|
|
|
3489
3475
|
}
|
|
3490
3476
|
//#endregion
|
|
3491
3477
|
//#region src/lib/persisted-prompt-selection.ts
|
|
3492
|
-
function
|
|
3478
|
+
function ti(e, t) {
|
|
3493
3479
|
if (!t || t.isCollapsed || t.rangeCount === 0) return null;
|
|
3494
3480
|
let n = t.getRangeAt(0);
|
|
3495
3481
|
if (!e.contains(n.commonAncestorContainer)) return null;
|
|
@@ -3502,51 +3488,51 @@ function ai(e, t) {
|
|
|
3502
3488
|
}
|
|
3503
3489
|
//#endregion
|
|
3504
3490
|
//#region src/lib/PersistedPromptText.tsx
|
|
3505
|
-
function
|
|
3491
|
+
function ni(e) {
|
|
3506
3492
|
let t = i(6), { text: n } = e, a, o;
|
|
3507
3493
|
if (t[0] !== n) {
|
|
3508
3494
|
let e = r(n);
|
|
3509
|
-
a =
|
|
3495
|
+
a = ai, o = e.map(ri), t[0] = n, t[1] = a, t[2] = o;
|
|
3510
3496
|
} else a = t[1], o = t[2];
|
|
3511
3497
|
let s;
|
|
3512
|
-
return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */
|
|
3498
|
+
return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */ w("span", {
|
|
3513
3499
|
onCopy: a,
|
|
3514
3500
|
children: o
|
|
3515
3501
|
}), t[3] = a, t[4] = o, t[5] = s) : s = t[5], s;
|
|
3516
3502
|
}
|
|
3517
|
-
function
|
|
3503
|
+
function ri(e) {
|
|
3518
3504
|
switch (e.kind) {
|
|
3519
3505
|
case "text": return e.value;
|
|
3520
|
-
case "inline-code": return /* @__PURE__ */
|
|
3506
|
+
case "inline-code": return /* @__PURE__ */ w("code", {
|
|
3521
3507
|
"data-persisted-source": e.source,
|
|
3522
3508
|
className: "bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]",
|
|
3523
3509
|
children: e.value
|
|
3524
3510
|
}, e.start);
|
|
3525
|
-
case "code-block": return /* @__PURE__ */
|
|
3511
|
+
case "code-block": return /* @__PURE__ */ w("span", {
|
|
3526
3512
|
"data-persisted-source": e.source,
|
|
3527
3513
|
className: "bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2",
|
|
3528
|
-
children: /* @__PURE__ */
|
|
3514
|
+
children: /* @__PURE__ */ w("code", {
|
|
3529
3515
|
className: "font-mono text-[0.9em]",
|
|
3530
3516
|
children: e.value
|
|
3531
3517
|
})
|
|
3532
3518
|
}, e.start);
|
|
3533
|
-
case "skill-link": return /* @__PURE__ */
|
|
3519
|
+
case "skill-link": return /* @__PURE__ */ w(ii, {
|
|
3534
3520
|
name: e.name,
|
|
3535
3521
|
source: e.source,
|
|
3536
3522
|
skillId: e.skillId,
|
|
3537
3523
|
title: e.href
|
|
3538
3524
|
}, e.start);
|
|
3539
|
-
case "standalone-skill": return /* @__PURE__ */
|
|
3525
|
+
case "standalone-skill": return /* @__PURE__ */ w(ii, {
|
|
3540
3526
|
name: e.name,
|
|
3541
3527
|
source: e.source
|
|
3542
3528
|
}, e.start);
|
|
3543
|
-
case "mention": return /* @__PURE__ */
|
|
3529
|
+
case "mention": return /* @__PURE__ */ w("span", {
|
|
3544
3530
|
"data-token": "mention",
|
|
3545
3531
|
"data-persisted-source": e.source,
|
|
3546
3532
|
className: "bg-foreground/10 rounded-sm px-0.5 font-medium",
|
|
3547
3533
|
children: e.label
|
|
3548
3534
|
}, e.start);
|
|
3549
|
-
case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */
|
|
3535
|
+
case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */ w("a", {
|
|
3550
3536
|
href: e.href,
|
|
3551
3537
|
"data-persisted-source": e.source,
|
|
3552
3538
|
className: "text-primary underline underline-offset-2",
|
|
@@ -3556,16 +3542,16 @@ function si(e) {
|
|
|
3556
3542
|
}, e.start) : e.source;
|
|
3557
3543
|
}
|
|
3558
3544
|
}
|
|
3559
|
-
function
|
|
3545
|
+
function ii(e) {
|
|
3560
3546
|
let t = i(9), { name: n, source: r, skillId: a, title: o } = e, s = a ? void 0 : n, c;
|
|
3561
|
-
t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */
|
|
3547
|
+
t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ w(S, {
|
|
3562
3548
|
"aria-hidden": "true",
|
|
3563
3549
|
className: "size-3.5 self-center"
|
|
3564
3550
|
}), t[0] = c) : c = t[0];
|
|
3565
3551
|
let l;
|
|
3566
|
-
t[1] === n ? l = t[2] : (l = /* @__PURE__ */
|
|
3552
|
+
t[1] === n ? l = t[2] : (l = /* @__PURE__ */ w("span", { children: n }), t[1] = n, t[2] = l);
|
|
3567
3553
|
let u;
|
|
3568
|
-
return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */
|
|
3554
|
+
return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */ T("span", {
|
|
3569
3555
|
"data-skill-id": a,
|
|
3570
3556
|
"data-skill-name": s,
|
|
3571
3557
|
"data-persisted-source": r,
|
|
@@ -3574,11 +3560,11 @@ function ci(e) {
|
|
|
3574
3560
|
children: [c, l]
|
|
3575
3561
|
}), t[3] = a, t[4] = r, t[5] = s, t[6] = l, t[7] = o, t[8] = u) : u = t[8], u;
|
|
3576
3562
|
}
|
|
3577
|
-
function
|
|
3578
|
-
let t =
|
|
3563
|
+
function ai(e) {
|
|
3564
|
+
let t = ti(e.currentTarget, window.getSelection());
|
|
3579
3565
|
t !== null && (e.clipboardData.setData("text/plain", t), e.preventDefault());
|
|
3580
3566
|
}
|
|
3581
3567
|
//#endregion
|
|
3582
|
-
export {
|
|
3568
|
+
export { Zr as Composer, Qr as ComposerTokenText, Gt as DictationError, ni as PersistedPromptText, He as createComposerDraftSource, q as createComposerState, We as createDraftFromPersistedText, Ge as createDraftFromSource, Ve as createDraftFromState, Ke as createPersistedTextFromDraft, qe as decodeComposerTextLinkHref, H as isVisibleInPhase, he as prepareComposerPayload, Ue as pushComposerHistory, ti as reconstructPersistedPromptSelection, e as serializeMentionPromptLink, t as serializePersistedPromptLink, n as serializeSkillPromptLink, r as tokenizePersistedPrompt, N as useComposer, Vt as useComposerDictation };
|
|
3583
3569
|
|
|
3584
3570
|
//# sourceMappingURL=browser.js.map
|