@opentiny/tiny-robot 0.3.0-alpha.8 → 0.3.0-rc.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.
@@ -1,279 +1,227 @@
1
- import { ref as F, watch as Q, reactive as at, computed as E, nextTick as G, defineComponent as ge, createElementBlock as O, openBlock as S, createCommentVNode as A, normalizeStyle as Fe, createBlock as X, unref as b, withCtx as ce, createElementVNode as N, createVNode as z, normalizeClass as Y, toDisplayString as le, useAttrs as lt, resolveComponent as it, mergeProps as pe, Fragment as de, renderList as he, mergeModels as rt, useModel as ut, Transition as De, withModifiers as ct, useSlots as dt, renderSlot as ae, isRef as ft, createTextVNode as Ue } from "vue";
2
- import { I as pt } from "../index6.js";
3
- import { d as ht } from "../index3.js";
4
- import { T as Be } from "../index2.js";
5
- import { d as gt, o as vt, j as yt, a as mt, S as St, K as wt, u as _t } from "../tiny-robot-svgs.js";
6
- import { _ as be } from "../_plugin-vue_export-helper.js";
7
- import { t as bt } from "../utils.js";
8
- function Ct(i, u) {
9
- const s = F(i.modelValue || i.defaultValue || ""), r = F(null);
10
- Q(
11
- () => i.modelValue,
12
- (p) => {
13
- p !== void 0 && p !== s.value && (s.value = p);
1
+ import { ref as M, watch as ne, reactive as ot, computed as B, defineComponent as Se, createElementBlock as I, openBlock as b, createCommentVNode as N, normalizeStyle as Ve, createBlock as Y, unref as C, withCtx as he, createElementVNode as U, createVNode as Z, normalizeClass as oe, toDisplayString as ue, useAttrs as st, resolveComponent as at, mergeProps as _e, Fragment as ye, renderList as we, mergeModels as lt, useModel as rt, onMounted as it, onUnmounted as ut, nextTick as te, Transition as We, withModifiers as ct, useSlots as dt, renderSlot as ie, isRef as ft, createTextVNode as je } from "vue";
2
+ import { TinyTooltip as Fe, TinyInput as pt } from "@opentiny/vue";
3
+ import { d as ht } from "../index2.js";
4
+ import { IconUpload as yt, IconVoice as vt, IconLoadingSpeech as gt, IconClose as mt, IconSend as bt, IconStop as _t, IconAssociate as wt } from "@opentiny/tiny-robot-svgs";
5
+ import { _ as Ce } from "../_plugin-vue_export-helper.js";
6
+ import { t as St } from "../utils.js";
7
+ function Ct(l, c) {
8
+ const s = M(l.modelValue || l.defaultValue || ""), i = M(null);
9
+ ne(
10
+ () => l.modelValue,
11
+ (h) => {
12
+ h !== void 0 && h !== s.value && (s.value = h);
14
13
  }
15
- ), Q(
14
+ ), ne(
16
15
  () => s.value,
17
- (p) => {
18
- u("update:modelValue", p);
16
+ (h) => {
17
+ c("update:modelValue", h);
19
18
  }
20
19
  );
21
- const y = (p) => {
22
- s.value = p, u("update:modelValue", p);
23
- }, w = (p) => {
24
- p == null || p.preventDefault();
25
- const k = s.value;
26
- !i.disabled && !i.loading && k.trim() && u("submit", k);
20
+ const v = (h) => {
21
+ s.value = h, c("update:modelValue", h);
22
+ }, S = (h) => {
23
+ h == null || h.preventDefault();
24
+ const w = s.value;
25
+ !l.disabled && !l.loading && w.trim() && c("submit", w);
27
26
  }, a = () => {
28
- s.value = "", u("update:modelValue", ""), u("clear");
29
- }, h = F(!1);
27
+ s.value = "", c("update:modelValue", ""), c("clear");
28
+ }, d = M(!1);
30
29
  return {
31
30
  inputValue: s,
32
- inputWrapper: r,
33
- isComposing: h,
34
- handleChange: y,
35
- handleSubmit: w,
31
+ inputWrapper: i,
32
+ isComposing: d,
33
+ handleChange: v,
34
+ handleSubmit: S,
36
35
  handleClear: a,
37
36
  clearInput: () => {
38
37
  a();
39
38
  }
40
39
  };
41
40
  }
42
- function kt(i, u, s, r, y, w, a, h, _, p, k, g, T, m, L, M) {
43
- const B = () => {
44
- g.value && (L != null && L.value && (M == null || M()), u("submit", s.value.trim()));
45
- }, v = (f, K) => {
46
- if (!(f.key === "Enter")) return !1;
47
- switch (K) {
41
+ function xt(l, c, s, i, v, S, a, d, x, h, w, y, K, W, F, P) {
42
+ const T = () => {
43
+ y.value && (F != null && F.value && (P == null || P()), c("submit", s.value.trim()));
44
+ }, g = (p, Q) => {
45
+ if (!(p.key === "Enter")) return !1;
46
+ switch (Q) {
48
47
  case "enter":
49
- return !f.shiftKey && !f.ctrlKey && !f.metaKey;
48
+ return !p.shiftKey && !p.ctrlKey && !p.metaKey;
50
49
  case "ctrlEnter":
51
- return (f.ctrlKey || f.metaKey) && !f.shiftKey;
50
+ return (p.ctrlKey || p.metaKey) && !p.shiftKey;
52
51
  case "shiftEnter":
53
- return f.shiftKey && !f.ctrlKey && !f.metaKey;
52
+ return p.shiftKey && !p.ctrlKey && !p.metaKey;
54
53
  default:
55
54
  return !1;
56
55
  }
57
56
  };
58
57
  return {
59
- handleKeyPress: (f) => {
60
- if (r.value) return;
61
- if (f.key === "Enter" && f.shiftKey && (T == null ? void 0 : T.value) === "single" && m) {
62
- f.preventDefault(), m();
63
- const q = f.target, V = q.selectionStart, Z = s.value;
64
- s.value = Z.substring(0, V) + `
65
- ` + Z.substring(V), setTimeout(() => {
66
- q.selectionStart = q.selectionEnd = V + 1;
58
+ handleKeyPress: (p) => {
59
+ if (i.value) return;
60
+ if (p.key === "Enter" && p.shiftKey && (K == null ? void 0 : K.value) === "single" && W) {
61
+ p.preventDefault(), W();
62
+ const E = p.target, q = E.selectionStart, ee = s.value;
63
+ s.value = ee.substring(0, q) + `
64
+ ` + ee.substring(q), setTimeout(() => {
65
+ E.selectionStart = E.selectionEnd = q + 1;
67
66
  }, 0);
68
67
  return;
69
68
  }
70
- if (f.key === "Tab" && w.value && a.value) {
71
- f.preventDefault(), h();
69
+ if (p.key === "Tab" && S.value && a.value) {
70
+ p.preventDefault(), d();
72
71
  return;
73
72
  }
74
- if (w.value) {
75
- if (f.key === "ArrowDown") {
76
- f.preventDefault(), p("down");
73
+ if (S.value) {
74
+ if (p.key === "ArrowDown") {
75
+ p.preventDefault(), h("down");
77
76
  return;
78
77
  }
79
- if (f.key === "ArrowUp") {
80
- f.preventDefault(), p("up");
78
+ if (p.key === "ArrowUp") {
79
+ p.preventDefault(), h("up");
81
80
  return;
82
81
  }
83
- if (f.key === "Enter" && a.value) {
84
- f.preventDefault(), h();
82
+ if (p.key === "Enter" && a.value) {
83
+ p.preventDefault(), d();
85
84
  return;
86
85
  }
87
86
  }
88
- if (f.key === "Escape") {
89
- w.value ? (_(), f.preventDefault()) : y.isRecording && (k(), f.preventDefault()), u("escape-press");
87
+ if (p.key === "Escape") {
88
+ S.value ? (x(), p.preventDefault()) : v.isRecording && (w(), p.preventDefault()), c("escape-press");
90
89
  return;
91
90
  }
92
- v(f, i.submitType) && (f.preventDefault(), g.value && B());
91
+ g(p, l.submitType) && (p.preventDefault(), y.value && T());
93
92
  },
94
- triggerSubmit: B
93
+ triggerSubmit: T
95
94
  };
96
95
  }
97
- function xt(i) {
98
- const u = at({
96
+ function kt(l) {
97
+ const c = ot({
99
98
  isRecording: !1,
100
99
  isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
101
100
  error: void 0
102
- }), s = u.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
103
- s !== void 0 && (s.continuous = i.continuous ?? !1, s.interimResults = i.interimResults ?? !0, s.lang = i.lang ?? navigator.language, s.onstart = () => {
101
+ }), s = c.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
102
+ s !== void 0 && (s.continuous = l.continuous ?? !1, s.interimResults = l.interimResults ?? !0, s.lang = l.lang ?? navigator.language, s.onstart = () => {
104
103
  var a;
105
- u.isRecording = !0, u.error = void 0, (a = i.onStart) == null || a.call(i);
104
+ c.isRecording = !0, c.error = void 0, (a = l.onStart) == null || a.call(l);
106
105
  }, s.onend = () => {
107
106
  var a;
108
- u.isRecording = !1, (a = i.onEnd) == null || a.call(i);
107
+ c.isRecording = !1, (a = l.onEnd) == null || a.call(l);
109
108
  }, s.onresult = (a) => {
110
- var _, p;
111
- const h = Array.from(a.results).map((k) => k[0].transcript).join("");
112
- a.results[0].isFinal ? (_ = i.onFinal) == null || _.call(i, h) : (p = i.onInterim) == null || p.call(i, h);
109
+ var x, h;
110
+ const d = Array.from(a.results).map((w) => w[0].transcript).join("");
111
+ a.results[0].isFinal ? (x = l.onFinal) == null || x.call(l, d) : (h = l.onInterim) == null || h.call(l, d);
113
112
  }, s.onerror = (a) => {
114
- var h;
115
- u.error = new Error(a.error), u.isRecording = !1, (h = i.onError) == null || h.call(i, u.error);
113
+ var d;
114
+ c.error = new Error(a.error), c.isRecording = !1, (d = l.onError) == null || d.call(l, c.error);
116
115
  });
117
- const r = () => {
116
+ const i = () => {
118
117
  var a;
119
118
  if (!s) {
120
- const h = new Error("浏览器不支持语音识别");
121
- u.error = h, (a = i.onError) == null || a.call(i, h);
119
+ const d = new Error("浏览器不支持语音识别");
120
+ c.error = d, (a = l.onError) == null || a.call(l, d);
122
121
  return;
123
122
  }
124
- if (u.isRecording) {
123
+ if (c.isRecording) {
125
124
  try {
126
125
  s.stop(), setTimeout(() => {
127
126
  try {
128
127
  s.start();
129
- } catch (h) {
130
- w(h);
128
+ } catch (d) {
129
+ S(d);
131
130
  }
132
131
  }, 100);
133
- } catch (h) {
134
- w(h);
132
+ } catch (d) {
133
+ S(d);
135
134
  }
136
135
  return;
137
136
  }
138
137
  try {
139
138
  s.start();
140
- } catch (h) {
141
- w(h);
139
+ } catch (d) {
140
+ S(d);
142
141
  }
143
- }, y = () => {
144
- if (s && u.isRecording)
142
+ }, v = () => {
143
+ if (s && c.isRecording)
145
144
  try {
146
145
  s.stop();
147
146
  } catch (a) {
148
- w(a);
147
+ S(a);
149
148
  }
150
- }, w = (a) => {
151
- var h;
152
- u.error = a instanceof Error ? a : new Error("语音识别操作失败"), u.isRecording = !1, (h = i.onError) == null || h.call(i, u.error);
149
+ }, S = (a) => {
150
+ var d;
151
+ c.error = a instanceof Error ? a : new Error("语音识别操作失败"), c.isRecording = !1, (d = l.onError) == null || d.call(l, c.error);
153
152
  };
154
153
  return {
155
- speechState: u,
156
- start: r,
157
- stop: y
154
+ speechState: c,
155
+ start: i,
156
+ stop: v
158
157
  };
159
158
  }
160
- const It = (i, u) => {
161
- if (!u || !i)
162
- return [{ text: i, isMatch: !1 }];
163
- const s = i.toLowerCase(), r = u.toLowerCase(), y = [];
164
- let w = 0;
165
- for (; w < s.length; ) {
166
- const p = s.indexOf(r, w);
167
- if (p === -1) break;
168
- y.push({
169
- start: p,
170
- end: p + u.length
171
- }), w = p + 1;
172
- }
173
- if (y.length === 0)
174
- return [{ text: i, isMatch: !1 }];
175
- const a = [];
176
- for (const p of y)
177
- if (a.length === 0)
178
- a.push(p);
179
- else {
180
- const k = a[a.length - 1];
181
- p.start <= k.end ? k.end = Math.max(k.end, p.end) : a.push(p);
182
- }
183
- const h = [];
184
- let _ = 0;
185
- for (const p of a)
186
- _ < p.start && h.push({
187
- text: i.substring(_, p.start),
188
- isMatch: !1
189
- }), h.push({
190
- text: i.substring(p.start, p.end),
191
- isMatch: !0
192
- }), _ = p.end;
193
- return _ < i.length && h.push({
194
- text: i.substring(_),
195
- isMatch: !1
196
- }), h;
197
- };
198
- function Rt(i, u, s, r, y) {
199
- const w = F(!1), a = F(-1), h = F(-1), _ = F(""), p = F(!1), k = F(null), g = F(!1), T = F(null), m = E(() => {
200
- if (!i.suggestions || !s.value || y.value) return [];
201
- const R = s.value.toLowerCase();
202
- return i.suggestions.filter((U) => U.toLowerCase().includes(R));
203
- }), L = E(() => {
204
- let R = -1;
205
- return T.value === "mouse" && h.value !== -1 ? R = h.value : T.value === "keyboard" && a.value !== -1 && (R = a.value), m.value[R] || null;
206
- }), M = (R) => R === a.value || R === h.value, B = (R) => {
207
- if (T.value === null) {
208
- _.value = "", p.value = !1;
159
+ function It(l, c, s, i, v, S) {
160
+ const a = M(!1), d = M(-1), x = M(-1), h = M(null), w = M(""), y = M(!1), K = B(() => {
161
+ var j, J;
162
+ if (!((j = l.value) != null && j.length)) return "";
163
+ const k = h.value === "mouse" ? x.value : d.value;
164
+ return ((J = l.value[k]) == null ? void 0 : J.content) || "";
165
+ }), W = (k) => {
166
+ w.value = k, y.value = !0;
167
+ }, F = () => {
168
+ w.value = "", y.value = !1;
169
+ }, P = (k) => {
170
+ const j = k || K.value;
171
+ if (!j || !c.value) {
172
+ F();
209
173
  return;
210
174
  }
211
- const U = R || L.value;
212
- U && s.value && U.toLowerCase().startsWith(s.value.toLowerCase()) ? (_.value = U.substring(s.value.length), p.value = !0) : (_.value = "", p.value = !1);
213
- }, v = () => {
214
- w.value = !1, a.value = -1, h.value = -1, T.value = null, _.value = "", p.value = !1;
175
+ const J = j.substring(c.value.length);
176
+ j.toLowerCase().startsWith(c.value.toLowerCase()) && J ? W(J) : F();
177
+ }, T = () => {
178
+ d.value = -1, x.value = -1, h.value = null;
179
+ }, g = () => {
180
+ a.value = !0, P();
181
+ }, O = () => {
182
+ a.value = !1, T(), F();
183
+ }, p = B(() => {
184
+ var k;
185
+ return s.value ? !0 : !!(c.value && ((k = l.value) == null ? void 0 : k.length) > 0 && !i.value);
186
+ }), Q = (k) => {
187
+ O(), c.value = k, v(k), S(k);
188
+ }, E = () => {
189
+ K.value && Q(K.value);
190
+ }, q = (k) => {
191
+ !a.value || !l.value || (h.value = "keyboard", d.value === -1 ? d.value = k === "down" ? 0 : l.value.length - 1 : k === "down" ? d.value = (d.value + 1) % l.value.length : d.value = (d.value - 1 + l.value.length) % l.value.length, P());
192
+ }, ee = (k) => {
193
+ l.value && (h.value = "mouse", x.value = k, P());
215
194
  }, H = () => {
216
- w.value = !0, a.value = -1, h.value = -1, T.value = null, B();
217
- }, f = () => {
218
- r.value || g.value || G(() => {
219
- s.value && i.suggestions && i.suggestions.length > 0 && !y.value && m.value.length > 0 ? H() : v();
220
- });
221
- };
222
- Q(s, f), Q(() => i.suggestions, f);
223
- const K = (R) => {
224
- g.value = !0, s.value = R, u("update:modelValue", R), u("suggestion-select", R), V(), G(() => {
225
- g.value = !1;
226
- });
227
- }, q = () => {
228
- L.value && K(L.value);
229
- }, V = () => {
230
- v();
195
+ l.value && (x.value = -1, d.value !== -1 ? h.value = "keyboard" : h.value = null, P());
231
196
  };
232
- return {
233
- showSuggestionsPopup: w,
234
- completionPlaceholder: _,
235
- showTabHint: p,
236
- suggestionsListRef: k,
237
- filteredSuggestions: m,
238
- activeSuggestion: L,
239
- isItemHighlighted: M,
240
- updateCompletionPlaceholder: B,
241
- updateSuggestionsState: f,
242
- selectSuggestion: K,
243
- acceptCurrentSuggestion: q,
244
- closeSuggestionsPopup: V,
245
- navigateSuggestions: (R) => {
246
- if (!w.value || m.value.length === 0) return;
247
- T.value = "keyboard", a.value === -1 ? a.value = R === "down" ? 0 : m.value.length - 1 : R === "down" ? a.value = (a.value + 1) % m.value.length : a.value = (a.value - 1 + m.value.length) % m.value.length;
248
- const U = m.value[a.value];
249
- U && B(U);
250
- const j = k.value;
251
- if (j) {
252
- const ne = j.children[a.value];
253
- ne && ne.scrollIntoView({ block: "nearest" });
254
- }
255
- },
256
- handleSuggestionItemHover: (R) => {
257
- T.value = "mouse", h.value = R, B(m.value[R]);
258
- },
259
- handleSuggestionItemLeave: () => {
260
- if (h.value = -1, a.value !== -1) {
261
- T.value = "keyboard";
262
- const R = m.value[a.value];
263
- R && B(R);
264
- } else
265
- T.value = null, B();
266
- },
267
- handleClickOutside: () => {
268
- V();
269
- },
270
- highlightSuggestionText: It
197
+ return ne(p, (k) => {
198
+ k ? a.value || g() : a.value && O();
199
+ }), {
200
+ // 弹窗控制
201
+ isPopupVisible: a,
202
+ openPopup: g,
203
+ closePopup: O,
204
+ // 自动完成占位符
205
+ autoCompleteText: w,
206
+ showTabIndicator: y,
207
+ syncAutoComplete: P,
208
+ // 选中控制层
209
+ activeSuggestion: K,
210
+ activeKeyboardIndex: d,
211
+ activeMouseIndex: x,
212
+ // 交互处理
213
+ navigateWithKeyboard: q,
214
+ handleMouseEnter: ee,
215
+ handleMouseLeave: H,
216
+ // 业务操作
217
+ applySuggestion: Q,
218
+ confirmSelection: E
271
219
  };
272
220
  }
273
- const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-content" }, $t = {
221
+ const Tt = { class: "action-buttons" }, Rt = { class: "action-buttons__submit-content" }, Ot = {
274
222
  key: 0,
275
223
  class: "action-buttons__cancel-text"
276
- }, Bt = /* @__PURE__ */ ge({
224
+ }, Et = /* @__PURE__ */ Se({
277
225
  __name: "ActionButtons",
278
226
  props: {
279
227
  loading: { type: Boolean, default: !1 },
@@ -293,133 +241,144 @@ const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-co
293
241
  stopText: { default: void 0 }
294
242
  },
295
243
  emits: ["clear", "toggle-speech", "submit", "cancel", "trigger-select"],
296
- setup(i, { emit: u }) {
297
- const s = i, r = u, y = E(() => {
298
- var H, f;
299
- const v = (f = (H = s.buttonGroup) == null ? void 0 : H.file) == null ? void 0 : f.tooltips;
300
- if (typeof v == "string" && v)
301
- return () => v;
302
- if (typeof v == "function")
303
- return v;
304
- }), w = E(() => {
305
- var H, f;
306
- const v = (f = (H = s.buttonGroup) == null ? void 0 : H.submit) == null ? void 0 : f.tooltips;
307
- if (typeof v == "string" && v)
308
- return () => v;
309
- if (typeof v == "function")
310
- return v;
311
- }), a = E(() => s.allowSpeech), h = E(() => s.speechStatus.isRecording), _ = E(() => s.disabled), p = E(() => {
312
- var v, H;
313
- return _.value || s.isOverLimit || ((H = (v = s.buttonGroup) == null ? void 0 : v.submit) == null ? void 0 : H.disabled);
314
- }), k = E(() => s.allowFiles || s.allowSpeech || s.showClear), g = () => {
315
- _.value || r("clear");
316
- }, T = () => {
317
- if (!_.value) {
318
- const v = !s.speechStatus.isRecording;
319
- r("toggle-speech", v);
244
+ setup(l, { emit: c }) {
245
+ const s = l, i = c, v = B(() => {
246
+ var O, p;
247
+ const g = (p = (O = s.buttonGroup) == null ? void 0 : O.file) == null ? void 0 : p.tooltips;
248
+ if (typeof g == "string" && g)
249
+ return () => g;
250
+ if (typeof g == "function")
251
+ return g;
252
+ }), S = B(() => {
253
+ var O, p;
254
+ const g = (p = (O = s.buttonGroup) == null ? void 0 : O.submit) == null ? void 0 : p.tooltips;
255
+ if (typeof g == "string" && g)
256
+ return () => g;
257
+ if (typeof g == "function")
258
+ return g;
259
+ }), a = B(() => s.allowSpeech), d = B(() => s.speechStatus.isRecording), x = B(() => s.disabled), h = B(() => {
260
+ var g, O;
261
+ return x.value || s.isOverLimit || ((O = (g = s.buttonGroup) == null ? void 0 : g.submit) == null ? void 0 : O.disabled);
262
+ }), w = B(() => s.allowFiles || s.allowSpeech || s.showClear), y = () => {
263
+ x.value || i("clear");
264
+ }, K = () => {
265
+ if (!x.value) {
266
+ const g = !s.speechStatus.isRecording;
267
+ i("toggle-speech", g);
320
268
  }
321
- }, m = () => {
322
- p.value || r("submit");
323
- }, L = () => {
324
- _.value || r("cancel");
325
- }, M = E(() => {
326
- var v, H;
327
- return _.value || ((H = (v = s.buttonGroup) == null ? void 0 : v.file) == null ? void 0 : H.disabled);
328
- }), B = () => {
329
- M.value || r("trigger-select");
269
+ }, W = () => {
270
+ h.value || i("submit");
271
+ }, F = () => {
272
+ x.value || i("cancel");
273
+ }, P = B(() => {
274
+ var g, O;
275
+ return x.value || ((O = (g = s.buttonGroup) == null ? void 0 : g.file) == null ? void 0 : O.disabled);
276
+ }), T = () => {
277
+ P.value || i("trigger-select");
330
278
  };
331
- return (v, H) => (S(), O("div", Tt, [
332
- k.value ? (S(), O("div", {
279
+ return (g, O) => (b(), I("div", Tt, [
280
+ w.value ? (b(), I("div", {
333
281
  key: 0,
334
282
  class: "action-buttons__utility",
335
- style: Fe({ "padding-right": v.hasContent || v.loading ? "0" : "6px" })
283
+ style: Ve({ "padding-right": g.hasContent || g.loading ? "0" : "6px" })
336
284
  }, [
337
- v.allowFiles && !v.loading ? (S(), X(b(Be), {
285
+ g.allowFiles && !g.loading ? (b(), Y(C(Fe), {
338
286
  key: 0,
339
287
  effect: "light",
340
288
  placement: "top",
341
- "render-content": y.value,
289
+ "render-content": v.value,
342
290
  "visible-arrow": !1
343
291
  }, {
344
- default: ce(() => [
345
- N("div", {
292
+ default: he(() => [
293
+ U("div", {
346
294
  class: "action-buttons__button",
347
- onClick: B
295
+ onClick: T
348
296
  }, [
349
- z(b(gt), {
350
- class: Y(["action-buttons__icon", "action-buttons__icon--upload", { "is-disabled": M.value }]),
297
+ Z(C(yt), {
298
+ class: oe(["action-buttons__icon", "action-buttons__icon--upload", { "is-disabled": P.value }]),
351
299
  alt: "上传文件"
352
300
  }, null, 8, ["class"])
353
301
  ])
354
302
  ]),
355
303
  _: 1
356
- }, 8, ["render-content"])) : A("", !0),
357
- a.value && !v.loading ? (S(), O("div", {
304
+ }, 8, ["render-content"])) : N("", !0),
305
+ a.value && !g.loading ? (b(), I("div", {
358
306
  key: 1,
359
- class: Y(["action-buttons__button", { "is-recording": h.value }]),
360
- onClick: T
307
+ class: oe(["action-buttons__button", { "is-recording": d.value }]),
308
+ onClick: K
361
309
  }, [
362
- h.value ? (S(), X(b(yt), {
310
+ d.value ? (b(), Y(C(gt), {
363
311
  key: 1,
364
312
  class: "action-buttons__icon action-buttons__icon--recording",
365
313
  alt: "语音中"
366
- })) : (S(), X(b(vt), {
314
+ })) : (b(), Y(C(vt), {
367
315
  key: 0,
368
316
  class: "action-buttons__icon",
369
317
  alt: "录音"
370
318
  }))
371
- ], 2)) : A("", !0),
372
- v.showClear ? (S(), X(b(Be), {
319
+ ], 2)) : N("", !0),
320
+ g.showClear ? (b(), Y(C(Fe), {
373
321
  key: 2,
374
322
  content: "清空内容",
375
323
  placement: "top"
376
324
  }, {
377
- default: ce(() => [
378
- N("div", {
325
+ default: he(() => [
326
+ U("div", {
379
327
  class: "action-buttons__button",
380
- onClick: g
328
+ onClick: y
381
329
  }, [
382
- z(b(mt), { class: "action-buttons__icon action-buttons__icon--clear" })
330
+ Z(C(mt), { class: "action-buttons__icon action-buttons__icon--clear" })
383
331
  ])
384
332
  ]),
385
333
  _: 1
386
- })) : A("", !0)
387
- ], 4)) : A("", !0),
388
- v.hasContent || v.loading ? (S(), O("div", {
334
+ })) : N("", !0)
335
+ ], 4)) : N("", !0),
336
+ g.hasContent || g.loading ? (b(), I("div", {
389
337
  key: 1,
390
338
  class: "action-buttons__button action-buttons__submit",
391
- onClick: H[0] || (H[0] = (f) => v.loading ? L() : m())
339
+ onClick: O[0] || (O[0] = (p) => g.loading ? F() : W())
392
340
  }, [
393
- N("div", Ot, [
394
- v.loading ? (S(), O("div", {
341
+ U("div", Rt, [
342
+ g.loading ? (b(), I("div", {
395
343
  key: 1,
396
- class: Y(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !v.stopText }])
344
+ class: oe(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !g.stopText }])
397
345
  }, [
398
- z(b(wt), {
346
+ Z(C(_t), {
399
347
  class: "action-buttons__icon action-buttons__icon--cancel",
400
348
  alt: "停止"
401
349
  }),
402
- v.stopText ? (S(), O("span", $t, le(v.stopText), 1)) : A("", !0)
403
- ], 2)) : (S(), X(b(Be), {
350
+ g.stopText ? (b(), I("span", Ot, ue(g.stopText), 1)) : N("", !0)
351
+ ], 2)) : (b(), Y(C(Fe), {
404
352
  key: 0,
405
353
  effect: "light",
406
354
  placement: "top",
407
- "render-content": w.value,
355
+ "render-content": S.value,
408
356
  "visible-arrow": !1
409
357
  }, {
410
- default: ce(() => [
411
- z(b(St), {
412
- class: Y(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": p.value }]),
358
+ default: he(() => [
359
+ Z(C(bt), {
360
+ class: oe(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": h.value }]),
413
361
  alt: "发送"
414
362
  }, null, 8, ["class"])
415
363
  ]),
416
364
  _: 1
417
365
  }, 8, ["render-content"]))
418
366
  ])
419
- ])) : A("", !0)
367
+ ])) : N("", !0)
420
368
  ]));
421
369
  }
422
- }), je = /* @__PURE__ */ be(Bt, [["__scopeId", "data-v-2b573a4e"]]), Lt = ["data-id", "data-type"], Et = ["data-id", "data-type"], Dt = /* @__PURE__ */ ge({
370
+ }), Je = /* @__PURE__ */ Ce(Et, [["__scopeId", "data-v-ee42294d"]]);
371
+ function $t(l, c = {}) {
372
+ let s = [], i = [], v = l;
373
+ return { commit: (w) => {
374
+ var y;
375
+ s.push(v), v = w, i.length && ((y = c.onRemoveHistory) == null || y.call(c, i)), i = [];
376
+ }, undo: () => s.length ? (i.push(v), v = s.pop(), v) : null, redo: () => i.length ? (s.push(v), v = i.pop(), v) : null, clear: () => {
377
+ var w, y;
378
+ s.length && ((w = c.onRemoveHistory) == null || w.call(c, s)), i.length && ((y = c.onRemoveHistory) == null || y.call(c, i)), s = [], i = [];
379
+ }, get: () => v };
380
+ }
381
+ const Lt = ["data-id", "data-type"], Bt = ["data-id", "data-type"], Dt = /* @__PURE__ */ Se({
423
382
  inheritAttrs: !1,
424
383
  __name: "Block",
425
384
  props: {
@@ -429,61 +388,63 @@ const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-co
429
388
  readonly: { type: Boolean },
430
389
  asChild: { type: Boolean }
431
390
  },
432
- setup(i) {
433
- const u = i, s = lt();
434
- return (r, y) => {
435
- const w = it("Block", !0);
436
- return u.type !== "block" ? (S(), O("span", pe({
391
+ setup(l) {
392
+ const c = l, s = st();
393
+ return (i, v) => {
394
+ const S = at("Block", !0);
395
+ return c.type !== "block" ? (b(), I("span", _e({
437
396
  key: 0,
438
- "data-id": u.id,
439
- "data-type": u.type
440
- }, b(s)), le(u.content), 17, Lt)) : (S(), O(de, { key: 1 }, [
441
- u.asChild ? (S(!0), O(de, { key: 0 }, he(u.content, (a) => (S(), X(w, pe({
397
+ "data-id": c.id,
398
+ "data-type": c.type
399
+ }, C(s)), ue(c.content), 17, Lt)) : (b(), I(ye, { key: 1 }, [
400
+ c.asChild ? (b(!0), I(ye, { key: 0 }, we(c.content, (a) => (b(), Y(S, _e({
442
401
  key: `${a.id}-${a.type}`
443
- }, { ref_for: !0 }, a), null, 16))), 128)) : (S(), O("span", pe({
402
+ }, { ref_for: !0 }, a), null, 16))), 128)) : (b(), I("span", _e({
444
403
  key: 1,
445
- "data-id": u.id,
446
- "data-type": u.type
447
- }, b(s)), [
448
- (S(!0), O(de, null, he(u.content, (a) => (S(), X(w, pe({
404
+ "data-id": c.id,
405
+ "data-type": c.type
406
+ }, C(s)), [
407
+ (b(!0), I(ye, null, we(c.content, (a) => (b(), Y(S, _e({
449
408
  key: `${a.id}-${a.type}`
450
409
  }, { ref_for: !0 }, a), null, 16))), 128))
451
- ], 16, Et))
410
+ ], 16, Bt))
452
411
  ], 64));
453
412
  };
454
413
  }
455
- }), Ft = /* @__PURE__ */ be(Dt, [["__scopeId", "data-v-13862606"]]);
456
- function Ht(i, u = {}) {
457
- let s = [], r = [], y = i;
458
- return { commit: (k) => {
459
- var g;
460
- s.push(y), y = k, r.length && ((g = u.onRemoveHistory) == null || g.call(u, r)), r = [];
461
- }, undo: () => s.length ? (r.push(y), y = s.pop(), y) : null, redo: () => r.length ? (s.push(y), y = r.pop(), y) : null, clear: () => {
462
- var k, g;
463
- s.length && ((k = u.onRemoveHistory) == null || k.call(u, s)), r.length && ((g = u.onRemoveHistory) == null || g.call(u, r)), s = [], r = [];
464
- }, get: () => y };
465
- }
466
- const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PURE__ */ ge({
414
+ }), At = /* @__PURE__ */ Ce(Dt, [["__scopeId", "data-v-13862606"]]), Kt = { class: "editor-container" }, Pe = "​", Mt = /* @__PURE__ */ Se({
467
415
  __name: "TemplateEditor",
468
416
  props: {
469
417
  modelValue: { default: () => [] },
470
418
  modelModifiers: {}
471
419
  },
472
- emits: /* @__PURE__ */ rt(["submit"], ["update:modelValue"]),
473
- setup(i, { expose: u, emit: s }) {
474
- const r = typeof window.ShadowRoot.prototype.getSelection == "function", y = typeof window.Selection.prototype.getComposedRanges == "function";
475
- function w() {
420
+ emits: /* @__PURE__ */ lt(["submit"], ["update:modelValue"]),
421
+ setup(l, { expose: c, emit: s }) {
422
+ const i = typeof window.ShadowRoot.prototype.getSelection == "function", v = typeof window.Selection.prototype.getComposedRanges == "function";
423
+ function S() {
476
424
  const e = navigator.userAgent;
477
425
  return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
478
426
  }
479
- const a = w(), h = () => Math.random().toString(36).substring(2, 15), _ = ut(i, "modelValue"), p = s, k = F(0), g = (e) => e.map((t, o) => ({
480
- id: `id-${o}`,
481
- ...t.type === "template" ? { ...t, prefix: Le, suffix: Ee } : t
482
- })), T = (e) => e.map((t) => ({ type: t.type, content: t.content })), m = F(g(_.value || [])), L = E(() => m.value.map((e) => e.type === "template" ? [
427
+ const a = S(), d = () => Math.random().toString(36).substring(2, 15), x = Pe, h = Pe, w = Pe, y = rt(l, "modelValue"), K = s, W = M(0), F = (e) => e.map((t) => ({
428
+ id: t.id || d(),
429
+ ...t.type === "template" ? { ...t, prefix: h, suffix: w } : t
430
+ })), P = (e) => e.map((t) => ({ id: t.id, type: t.type, content: t.content })), T = M(F(y.value || [])), g = (e) => {
431
+ T.value = e;
432
+ }, O = B(() => {
433
+ const e = [], t = [], n = T.value;
434
+ if (n.length >= 2) {
435
+ const r = n[0], f = n[1];
436
+ r.type === "text" && r.content.length === 0 && f.type === "template" && e.push({ ...r, content: x });
437
+ const _ = n[n.length - 1], $ = n[n.length - 2];
438
+ _.type === "text" && _.content.length === 0 && $.type === "template" && t.push({ ..._, content: x });
439
+ }
440
+ n.length > 0 && n[0].type === "template" && e.push({ type: "text", content: x, id: d() }), n.length > 0 && n[n.length - 1].type === "template" && t.push({ type: "text", content: x, id: d() });
441
+ const u = new RegExp(x, "g");
442
+ return n.length > 0 && (n[0].content !== x && (n[0].content = n[0].content.replace(u, "")), n[n.length - 1].content !== x && (n[n.length - 1].content = n[n.length - 1].content.replace(u, ""))), e.concat(n).concat(t);
443
+ }), p = B(() => T.value.map((e) => e.type === "template" ? [
483
444
  { id: e.id, type: "prefix", content: e.prefix },
484
445
  { id: e.id, type: "template", content: e.content },
485
446
  { id: e.id, type: "suffix", content: e.suffix }
486
- ] : [e]).flat()), M = E(() => m.value.map((e) => e.type === "text" ? e : a ? {
447
+ ] : [e]).flat()), Q = B(() => O.value.map((e) => e.type === "text" ? e : a ? {
487
448
  id: e.id,
488
449
  type: "block",
489
450
  asChild: !0,
@@ -513,86 +474,95 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
513
474
  },
514
475
  { id: e.id, type: "suffix", content: e.suffix }
515
476
  ]
516
- })), B = F(null), v = (e) => {
517
- const t = Date.now(), o = JSON.stringify(e);
518
- return `${t}:${o}`;
519
- }, H = (e) => {
520
- const t = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
477
+ })), E = M(null), q = (e) => {
478
+ const t = Date.now(), n = JSON.stringify(e);
479
+ return `${t}:${n}`;
480
+ }, ee = (e) => {
481
+ const t = parseInt(e.slice(0, 13)), n = JSON.parse(e.slice(14));
521
482
  return {
522
483
  timestamp: t,
523
- data: o
484
+ data: n
524
485
  };
525
- }, f = /* @__PURE__ */ new Map(), K = Ht(v(m.value), {
486
+ }, H = /* @__PURE__ */ new Map(), k = $t(q(T.value), {
526
487
  onRemoveHistory: (e) => {
527
488
  for (const t of e)
528
- f.delete(t);
489
+ H.delete(t);
529
490
  }
530
491
  });
531
- Q(
532
- () => _.value,
492
+ ne(
493
+ () => y.value,
533
494
  (e) => {
534
- m.value = g(e || []), K.commit(v(m.value));
495
+ const t = F(e || []);
496
+ if (JSON.stringify(t) !== JSON.stringify(T.value)) {
497
+ if (E.value) {
498
+ const u = le(E.value);
499
+ u && H.set(k.get(), X(u));
500
+ }
501
+ g(t), k.commit(q(T.value));
502
+ }
535
503
  },
536
504
  { deep: !0 }
537
505
  );
538
- const q = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? q(e.parentElement, t) : null : null, V = (e) => e === B.value, Z = (e) => {
506
+ const j = (e, t = document.body) => t.contains(e) ? e instanceof HTMLElement && e.dataset.id ? e : e.parentElement ? j(e.parentElement, t) : null : null, J = (e) => e === E.value, le = (e) => {
539
507
  const t = window.getSelection();
540
508
  if (!t)
541
509
  return null;
542
- const o = t.rangeCount > 0 ? t.getRangeAt(0) : null, c = e.getRootNode();
543
- if (!(c instanceof ShadowRoot))
544
- return o;
545
- if (y) {
546
- const l = t.getComposedRanges(a ? c : { shadowRoots: [c] });
547
- return (l == null ? void 0 : l[0]) ?? null;
510
+ const n = t.rangeCount > 0 ? t.getRangeAt(0) : null, u = e.getRootNode();
511
+ if (!(u instanceof ShadowRoot))
512
+ return n;
513
+ if (v) {
514
+ const r = t.getComposedRanges(a ? u : { shadowRoots: [u] });
515
+ return (r == null ? void 0 : r[0]) ?? null;
548
516
  }
549
- if (r) {
550
- const l = c.getSelection();
551
- return l.rangeCount > 0 ? l.getRangeAt(0) : null;
517
+ if (i) {
518
+ const r = u.getSelection();
519
+ return r.rangeCount > 0 ? r.getRangeAt(0) : null;
552
520
  }
553
- return o;
554
- }, fe = (e, t) => {
555
- var c;
521
+ return n;
522
+ }, V = (e, t) => {
523
+ var u;
556
524
  if (!e.firstChild || e.firstChild.nodeType !== Node.TEXT_NODE)
557
- return console.warn("el.firstChild is not a text node. set anchor and focus to the element with offset 0", e), { node: e, offset: 0 };
558
- const o = ((c = e.firstChild.textContent) == null ? void 0 : c.length) ?? 0;
559
- return t > o && console.warn("offset is too large", { offset: t, el: e }), { node: e.firstChild, offset: Math.min(t, o) };
560
- }, ee = (e, t, o, c) => {
561
- const l = window.getSelection();
562
- if (!l)
525
+ return { node: e, offset: 0 };
526
+ const n = ((u = e.firstChild.textContent) == null ? void 0 : u.length) ?? 0;
527
+ return { node: e.firstChild, offset: Math.min(t, n) };
528
+ }, z = (e, t, n, u) => {
529
+ const r = window.getSelection();
530
+ if (!r)
563
531
  return;
564
- const { node: d, offset: x } = fe(e, t);
565
- if (!o) {
566
- l.setBaseAndExtent(d, x, d, x);
532
+ const { node: f, offset: _ } = V(e, t);
533
+ if (!n) {
534
+ r.setBaseAndExtent(f, _, f, _);
567
535
  return;
568
536
  }
569
- const { node: C, offset: $ } = fe(o, c ?? 0);
570
- l.setBaseAndExtent(d, x, C, $);
571
- }, J = (e, t) => {
572
- const o = h(), c = { id: o, type: "text", content: e };
537
+ const { node: $, offset: G } = V(n, u ?? 0);
538
+ r.setBaseAndExtent(f, _, $, G);
539
+ }, ve = (e, t) => {
540
+ const n = d(), u = { id: n, type: "text", content: e };
573
541
  if (t) {
574
- const l = m.value.findIndex((d) => d.id === t);
575
- l !== -1 ? m.value = m.value.slice(0, l + 1).concat(c).concat(m.value.slice(l + 1)) : console.warn(`can not find item with id: ${t}`);
542
+ const r = T.value.findIndex((f) => f.id === t);
543
+ r !== -1 ? (g(
544
+ T.value.slice(0, r + 1).concat(u).concat(T.value.slice(r + 1))
545
+ ), k.commit(q(T.value))) : console.warn(`can not find item with id: ${t}`);
576
546
  } else
577
- m.value.unshift(c);
578
- G(() => {
579
- var d;
580
- const l = (d = B.value) == null ? void 0 : d.querySelector(`[data-id="${o}"][data-type="text"]`);
581
- l && ee(l, e.length);
582
- }), _.value = T(m.value);
583
- }, R = F({
547
+ g([u].concat(T.value)), k.commit(q(T.value));
548
+ te(() => {
549
+ var f;
550
+ const r = (f = E.value) == null ? void 0 : f.querySelector(`[data-id="${n}"][data-type="text"]`);
551
+ r && z(r, e.length);
552
+ }), y.value = P(T.value);
553
+ }, se = M({
584
554
  hasStarted: !1,
585
555
  range: null
586
- }), U = (e) => {
587
- var C;
556
+ }), xe = (e) => {
557
+ var $;
588
558
  const t = e;
589
559
  e.preventDefault();
590
- const { inputType: o } = t, c = (t.data || ((C = t.dataTransfer) == null ? void 0 : C.getData("text/plain")) || "").replace(Le, "").replace(Ee, ""), l = t.getTargetRanges()[0];
591
- if (!l) {
592
- console.warn("range is null", l);
560
+ const { inputType: n } = t, u = (t.data || (($ = t.dataTransfer) == null ? void 0 : $.getData("text/plain")) || "").replace(h, "").replace(w, ""), r = t.getTargetRanges()[0];
561
+ if (!r) {
562
+ console.warn("range is null", r);
593
563
  return;
594
564
  }
595
- const d = [
565
+ const f = [
596
566
  "insertText",
597
567
  "insertFromPaste",
598
568
  "insertReplacementText",
@@ -603,317 +573,409 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
603
573
  "deleteSoftLineBackward",
604
574
  "deleteSoftLineForward",
605
575
  "deleteByCut"
606
- ], x = Z(B.value);
607
- if (d.includes(o)) {
608
- if (c && V(l.startContainer) && V(l.endContainer)) {
609
- J(c), x && f.set(K.get(), j(x));
576
+ ], _ = le(E.value);
577
+ if (f.includes(n)) {
578
+ if (u && J(r.startContainer) && J(r.endContainer)) {
579
+ _ && H.set(k.get(), X(_)), ve(u);
610
580
  return;
611
581
  }
612
- const $ = j(l);
613
- $.startId && $.endId ? (P($, o, c), x && f.set(K.get(), j(x))) : console.warn("range is not valid, range:", $);
614
- } else o === "insertCompositionText" && R.value.hasStarted && (R.value = { hasStarted: !1, range: j(l) });
615
- }, j = (e) => {
616
- const t = q(e.startContainer, B.value), o = q(e.endContainer, B.value);
582
+ const G = X(r);
583
+ G.startId && G.endId ? (_ && H.set(k.get(), X(_)), ce(G, n, u)) : console.warn("range is not valid, range:", G);
584
+ } else n === "insertCompositionText" && se.value.hasStarted && (se.value = { hasStarted: !1, range: X(r) });
585
+ }, X = (e) => {
586
+ const t = j(e.startContainer, E.value), n = j(e.endContainer, E.value);
617
587
  return {
618
588
  collapsed: e.collapsed,
619
589
  endContainer: e.endContainer,
620
- endId: o == null ? void 0 : o.dataset.id,
590
+ endId: n == null ? void 0 : n.dataset.id,
591
+ endEl: n,
621
592
  endOffset: e.endOffset,
622
- endType: o == null ? void 0 : o.dataset.type,
593
+ endType: n == null ? void 0 : n.dataset.type,
623
594
  startContainer: e.startContainer,
624
595
  startId: t == null ? void 0 : t.dataset.id,
596
+ startEl: t,
625
597
  startOffset: e.startOffset,
626
598
  startType: t == null ? void 0 : t.dataset.type
627
599
  };
628
- }, ne = (e, t, o, c) => e.slice(0, o) + t + e.slice(c), P = (e, t, o) => {
629
- const c = Ce(e);
630
- if (!Array.isArray(c) || c.length === 0)
600
+ }, ke = (e, t, n, u) => e.slice(0, n) + t + e.slice(u), ce = (e, t, n) => {
601
+ const u = Be(e);
602
+ if (!Array.isArray(u) || u.length === 0)
631
603
  return;
632
- const l = ke(c, e, t, o);
633
- if (l.some((C) => C.tag === "new")) {
634
- const { afterId: C, content: $ } = l[0];
635
- J($, C);
604
+ const r = De(u, e, t, n);
605
+ if (r.some((R) => R.tag === "new")) {
606
+ const { afterId: R, content: L } = r[0];
607
+ ve(L, R);
636
608
  return;
637
609
  }
638
- const d = l, x = [];
639
- for (const [C, $] of d.entries()) {
640
- const W = m.value.find((Oe) => Oe.id === $.id), te = C === 0 ? o : "";
641
- W ? W.type === "text" ? W.content = ne(W.content, te, $.startOffset, $.endOffset) : W.type === "template" ? $.type === "prefix" || $.type === "suffix" ? $.startOffset === 0 && $.endOffset === 1 && te.length === 0 ? W[$.type] = "" : console.warn(`${$.type} can not be inserted text. it only can be deleted`, $) : $.startOffset < 0 || $.endOffset > W.content.length ? x.push(W.id) : W.content = ne(W.content, te, $.startOffset, $.endOffset) : console.warn("dataItem.type is not text or template", W) : console.warn("can not find dataItem", $);
610
+ const f = r, _ = [];
611
+ for (const [R, L] of f.entries()) {
612
+ const D = T.value.find((m) => m.id === L.id), o = R === 0 ? n : "";
613
+ D ? D.type === "text" ? D.content = ke(D.content, o, L.startOffset, L.endOffset) : D.type === "template" ? L.type === "prefix" || L.type === "suffix" ? L.startOffset === 0 && L.endOffset === 1 && o.length === 0 ? D[L.type] = "" : console.warn(`${L.type} can not be inserted text. it only can be deleted`, L) : L.startOffset < 0 || L.endOffset > D.content.length ? _.push(D.id) : D.content = ke(D.content, o, L.startOffset, L.endOffset) : console.warn("dataItem.type is not text or template", D) : console.warn("can not find dataItem", L);
642
614
  }
643
- m.value = m.value.filter((C) => !x.includes(C.id)), m.value = m.value.filter((C) => C.type === "text" ? C.content.length > 0 : [C.prefix, C.suffix, C.content].join("").length > 0);
644
- for (const C of m.value.filter(($) => $.type === "template"))
645
- C.prefix.length === 0 && (C.prefix = Le), C.suffix.length === 0 && (C.suffix = Ee);
646
- d.length > 0 && se(d, o), _.value = T(m.value);
647
- }, se = (e, t) => {
648
- const o = e[0], c = `[data-id="${o.id}"][data-type="${o.type}"]`, l = e.slice(1).map((d) => `[data-id="${d.id}"][data-type="${d.type}"]`);
649
- G(() => {
650
- var x, C;
651
- const d = (x = B.value) == null ? void 0 : x.querySelector(c);
652
- if (d)
653
- ee(d, o.startOffset + t.length);
615
+ let $ = T.value.filter((R) => !_.includes(R.id));
616
+ $ = $.filter((R) => !(R.type === "template" && [R.prefix, R.suffix, R.content].join("").length === 0));
617
+ const G = /* @__PURE__ */ new Set();
618
+ $.forEach((R, L, D) => {
619
+ if (D.length >= 2) {
620
+ if (L === 0 || L === 1) {
621
+ const o = D[0], m = D[1];
622
+ if (o.type === "text" && o.content.length === 0 && m.type === "template")
623
+ return;
624
+ }
625
+ if (L === D.length - 2 || L === D.length - 1) {
626
+ const o = D[D.length - 1], m = D[D.length - 2];
627
+ if (o.type === "text" && o.content.length === 0 && m.type === "template")
628
+ return;
629
+ }
630
+ }
631
+ R.type === "text" && R.content.length === 0 && G.add(R.id);
632
+ }), $ = $.filter((R) => !G.has(R.id));
633
+ for (const R of $.filter((L) => L.type === "template"))
634
+ R.prefix.length === 0 && (R.prefix = h), R.suffix.length === 0 && (R.suffix = w);
635
+ g($), k.commit(q(T.value)), f.length > 0 && ge(f, n), y.value = P(T.value);
636
+ }, ge = (e, t) => {
637
+ const n = e[0], u = `[data-id="${n.id}"][data-type="${n.type}"]`, r = e.slice(1).map((f) => `[data-id="${f.id}"][data-type="${f.type}"]`);
638
+ te(() => {
639
+ var _, $;
640
+ const f = (_ = E.value) == null ? void 0 : _.querySelector(u);
641
+ if (f)
642
+ z(f, n.startOffset + t.length);
654
643
  else if (t.length === 0)
655
- for (const $ of l) {
656
- const W = (C = B.value) == null ? void 0 : C.querySelector($);
657
- if (W) {
658
- ee(W, 0);
644
+ for (const G of r) {
645
+ const R = ($ = E.value) == null ? void 0 : $.querySelector(G);
646
+ if (R) {
647
+ z(R, 0);
659
648
  break;
660
649
  }
661
650
  }
662
651
  else
663
- console.warn(`can not find el with selector: ${c}`);
652
+ console.warn(`can not find el with selector: ${u}`);
664
653
  });
665
- }, Ce = (e) => {
666
- const t = L.value.findIndex((x) => x.id === e.startId && x.type === e.startType), o = L.value.findIndex((x) => x.id === e.endId && x.type === e.endType);
667
- if (t === -1 || o === -1 || t > o)
654
+ }, Be = (e) => {
655
+ const t = p.value.findIndex((_) => _.id === e.startId && _.type === e.startType), n = p.value.findIndex((_) => _.id === e.endId && _.type === e.endType);
656
+ if (t === -1 || n === -1 || t > n)
668
657
  return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
669
- const c = L.value[t], l = L.value[o];
670
- if (t === o)
658
+ const u = p.value[t], r = p.value[n];
659
+ if (t === n)
671
660
  return [
672
661
  {
673
- id: c.id,
674
- type: c.type,
662
+ id: u.id,
663
+ type: u.type,
675
664
  startOffset: e.startOffset,
676
665
  endOffset: e.endOffset
677
666
  }
678
667
  ];
679
- const d = [
668
+ const f = [
680
669
  {
681
- id: c.id,
682
- type: c.type,
670
+ id: u.id,
671
+ type: u.type,
683
672
  startOffset: e.startOffset,
684
- endOffset: c.content.length
673
+ endOffset: u.content.length
685
674
  }
686
675
  ];
687
- for (let x = t + 1; x < o; x++) {
688
- const C = L.value[x];
689
- d.push({
690
- id: C.id,
691
- type: C.type,
676
+ for (let _ = t + 1; _ < n; _++) {
677
+ const $ = p.value[_];
678
+ f.push({
679
+ id: $.id,
680
+ type: $.type,
692
681
  startOffset: 0,
693
- endOffset: C.content.length
682
+ endOffset: $.content.length
694
683
  });
695
684
  }
696
- return d.push({
697
- id: l.id,
698
- type: l.type,
685
+ return f.push({
686
+ id: r.id,
687
+ type: r.type,
699
688
  startOffset: 0,
700
689
  endOffset: e.endOffset
701
- }), d;
702
- }, ke = (e, t, o, c) => {
703
- const l = e[0];
704
- if (l.type !== "prefix" && l.type !== "suffix")
690
+ }), f;
691
+ }, De = (e, t, n, u) => {
692
+ const r = e[0];
693
+ if (r.type !== "prefix" && r.type !== "suffix")
705
694
  return e;
706
695
  if (e.length === 1) {
707
696
  if (t.collapsed)
708
697
  if (t.startOffset === 0) {
709
- const d = ie(l, c);
710
- return d ? [d] : [];
698
+ const f = ae(r, u);
699
+ return f ? [f] : [];
711
700
  } else {
712
- const d = re(l, c);
713
- return d ? [d] : [];
701
+ const f = de(r, u);
702
+ return f ? [f] : [];
714
703
  }
715
- if (o.startsWith("insert"))
704
+ if (n.startsWith("insert"))
716
705
  if (a) {
717
- const d = ie(l, c);
718
- return d ? [d] : [];
706
+ const f = ae(r, u);
707
+ return f ? [f] : [];
719
708
  } else {
720
- const d = re(l, c);
721
- return d ? [d] : [];
709
+ const f = de(r, u);
710
+ return f ? [f] : [];
722
711
  }
723
- if (o.startsWith("delete")) {
724
- if (o.includes("Backward")) {
725
- const d = ie(l, c, 1);
726
- return d ? [d] : [];
727
- } else if (o.includes("Forward")) {
728
- const d = re(l, c, 1);
729
- return d ? [d] : [];
712
+ if (n.startsWith("delete")) {
713
+ if (n.includes("Backward")) {
714
+ const f = ae(r, u, 1);
715
+ return f ? [f] : [];
716
+ } else if (n.includes("Forward")) {
717
+ const f = de(r, u, 1);
718
+ return f ? [f] : [];
730
719
  }
731
720
  }
732
721
  }
733
- return c.length > 0 ? e.slice(1) : e;
734
- }, ie = (e, t, o = 0) => {
735
- const c = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
736
- if (c > 0) {
737
- const l = L.value[c - 1], { id: d, type: x, content: C } = l;
738
- if (x === "text" || x === "template")
722
+ return u.length > 0 ? e.slice(1) : e;
723
+ }, ae = (e, t, n = 0) => {
724
+ const u = p.value.findIndex((r) => r.id === e.id && r.type === e.type);
725
+ if (u > 0) {
726
+ const r = p.value[u - 1], { id: f, type: _, content: $ } = r;
727
+ if (_ === "text" || _ === "template")
739
728
  return {
740
- id: d,
741
- type: x,
742
- startOffset: C.length - o,
743
- endOffset: C.length
729
+ id: f,
730
+ type: _,
731
+ startOffset: $.length - n,
732
+ endOffset: $.length
744
733
  };
745
734
  if (t.length > 0)
746
- return { tag: "new", afterId: d, type: "text", content: t };
747
- if (console.warn("the previous item is not text or template", { current: e, previous: l }), o === 1)
735
+ return { tag: "new", afterId: f, type: "text", content: t };
736
+ if (console.warn("the previous item is not text or template", { current: e, previous: r }), n === 1)
748
737
  return { ...e, endOffset: e.startOffset };
749
738
  } else return t.length > 0 ? { tag: "new", type: "text", content: t } : (console.warn("the previous item of current is not found", { current: e }), null);
750
739
  return e;
751
- }, re = (e, t, o = 0) => {
752
- const c = L.value.findIndex((l) => l.id === e.id && l.type === e.type);
753
- if (c < L.value.length - 1) {
754
- const l = L.value[c + 1], { id: d, type: x } = l;
755
- if (x === "text" || x === "template")
740
+ }, de = (e, t, n = 0) => {
741
+ const u = p.value.findIndex((r) => r.id === e.id && r.type === e.type);
742
+ if (u < p.value.length - 1) {
743
+ const r = p.value[u + 1], { id: f, type: _ } = r;
744
+ if (_ === "text" || _ === "template")
756
745
  return {
757
- id: d,
758
- type: x,
746
+ id: f,
747
+ type: _,
759
748
  startOffset: 0,
760
- endOffset: 0 + o
749
+ endOffset: 0 + n
761
750
  };
762
751
  if (t.length > 0)
763
752
  return { tag: "new", afterId: e.id, type: "text", content: t };
764
- if (console.warn("the next item is not text or template", { current: e, next: l }), o === 1)
753
+ if (console.warn("the next item is not text or template", { current: e, next: r }), n === 1)
765
754
  return { ...e, startOffset: e.endOffset };
766
755
  } else return t.length > 0 ? { tag: "new", afterId: e.id, type: "text", content: t } : (console.warn("the next item of current is not found", { current: e }), null);
767
756
  return e;
768
- }, xe = () => {
769
- R.value = { hasStarted: !0, range: null };
770
- }, ve = (e) => {
771
- const t = R.value.range;
772
- t ? (e.data && V(t.startContainer) && V(t.endContainer) ? (J(e.data), f.set(K.get(), j(t))) : t.startId && t.endId ? (P(t, "insertCompositionText", e.data), f.set(K.get(), j(t))) : console.warn("range is not valid, range:", t), k.value++) : console.warn("range is null, compositionEnd:", e), R.value = { hasStarted: !1, range: null };
773
- }, ue = (() => {
757
+ }, Ie = () => {
758
+ se.value = { hasStarted: !0, range: null };
759
+ }, me = (e) => {
760
+ const t = se.value.range;
761
+ t ? (e.data && J(t.startContainer) && J(t.endContainer) ? (H.set(k.get(), X(t)), ve(e.data)) : t.startId && t.endId ? (H.set(k.get(), X(t)), ce(t, "insertCompositionText", e.data)) : console.warn("range is not valid, range:", t), W.value++) : console.warn("range is null, compositionEnd:", e), se.value = { hasStarted: !1, range: null };
762
+ }, fe = (() => {
774
763
  const e = navigator.userAgent.toLowerCase();
775
764
  return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
776
- })(), Ie = (e) => {
777
- const t = ue && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
778
- !ue && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", o = ue && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
779
- !ue && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
765
+ })(), pe = (e) => {
766
+ const t = fe && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
767
+ !fe && e.ctrlKey && !e.shiftKey && e.key.toLowerCase() === "z", n = fe && e.metaKey && e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Shift+z
768
+ !fe && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), u = e.key.toLowerCase() === "enter";
780
769
  if (t) {
781
770
  e.preventDefault();
782
- const l = Z(B.value);
783
- l && f.set(K.get(), j(l));
784
- const d = K.undo();
785
- d && oe(d);
771
+ const r = le(E.value);
772
+ r && H.set(k.get(), X(r));
773
+ const f = k.undo();
774
+ f && Te(f);
786
775
  }
787
- if (o) {
776
+ if (n) {
788
777
  e.preventDefault();
789
- const l = K.redo();
790
- l && oe(l);
778
+ const r = k.redo();
779
+ r && Te(r);
791
780
  }
792
- c && (e.preventDefault(), p("submit"));
793
- }, oe = (e) => {
794
- const { data: t } = H(e);
795
- if (m.value = t, f.has(e)) {
796
- const o = f.get(e);
797
- G(() => {
798
- const c = B.value.querySelector(`[data-id="${o.startId}"][data-type="${o.startType}"]`), l = B.value.querySelector(`[data-id="${o.endId}"][data-type="${o.endType}"]`);
799
- c && ee(c, o.startOffset, l, o.endOffset);
781
+ u && (e.preventDefault(), K("submit"));
782
+ }, Te = (e) => {
783
+ const { data: t } = ee(e);
784
+ if (g(t), H.has(e)) {
785
+ const n = H.get(e);
786
+ te(() => {
787
+ const u = E.value.querySelector(`[data-id="${n.startId}"][data-type="${n.startType}"]`), r = E.value.querySelector(`[data-id="${n.endId}"][data-type="${n.endType}"]`);
788
+ u && z(u, n.startOffset, r, n.endOffset);
800
789
  });
801
790
  }
802
- };
803
- return u({
804
- clearHistory: () => {
805
- K.clear(), f.clear();
806
- },
807
- activateFirstField: () => {
808
- if (!B.value)
791
+ y.value = P(T.value);
792
+ }, Re = (e, t) => {
793
+ var r, f;
794
+ const n = (r = E.value) == null ? void 0 : r.querySelector(`[data-id="${e}"][data-type="${t}"]`);
795
+ if (!n) return;
796
+ const u = ((f = n.textContent) == null ? void 0 : f.length) || 0;
797
+ z(n, u);
798
+ }, Ae = () => {
799
+ E.value && te(() => {
800
+ const e = T.value, t = e.find((u) => u.type === "template");
801
+ t && Re(t.id, "template"), e.every((u) => u.type === "text") && e.length === 1 && Re(e[0].id, "text");
802
+ });
803
+ }, Ke = () => {
804
+ k.clear(), H.clear();
805
+ }, Oe = () => {
806
+ if (!E.value || se.value.range)
807
+ return;
808
+ const e = le(E.value);
809
+ if (e != null && e.collapsed && O.value.length > 0) {
810
+ const t = X(e), n = O.value[0];
811
+ if (t.startEl && t.startId === n.id && t.startOffset === 0 && n.content === x && n.type === "text") {
812
+ z(t.startEl, 1);
809
813
  return;
810
- const e = m.value.find((t) => t.type === "template");
811
- e && G(() => {
812
- var o, c;
813
- const t = (o = B.value) == null ? void 0 : o.querySelector(`[data-id="${e.id}"][data-type="template"]`);
814
- if (t) {
815
- const l = ((c = t.textContent) == null ? void 0 : c.length) || 0;
816
- ee(t, l);
817
- }
818
- });
814
+ }
815
+ const u = O.value[O.value.length - 1];
816
+ if (t.endEl && t.endId === u.id && t.endOffset === 1 && u.content === x && u.type === "text") {
817
+ z(t.endEl, 0);
818
+ return;
819
+ }
819
820
  }
820
- }), (e, t) => (S(), O("div", Kt, [
821
- (S(), O("div", {
821
+ };
822
+ return it(() => {
823
+ document.addEventListener("selectionchange", Oe);
824
+ }), ut(() => {
825
+ document.removeEventListener("selectionchange", Oe);
826
+ }), c({
827
+ clearHistory: Ke,
828
+ activateFirstField: Ae
829
+ }), (e, t) => (b(), I("div", Kt, [
830
+ (b(), I("div", {
822
831
  contenteditable: "true",
823
832
  ref_key: "editorRef",
824
- ref: B,
825
- key: k.value,
833
+ ref: E,
834
+ key: W.value,
826
835
  class: "editor",
827
- onBeforeinput: U,
828
- onCompositionstart: xe,
829
- onCompositionend: ve,
830
- onKeydown: Ie
836
+ onBeforeinput: xe,
837
+ onCompositionstart: Ie,
838
+ onCompositionend: me,
839
+ onKeydown: pe
831
840
  }, [
832
- (S(!0), O(de, null, he(M.value, (o) => (S(), X(Ft, pe({
833
- key: `${o.id}-${o.type}`
834
- }, { ref_for: !0 }, o), null, 16))), 128))
841
+ (b(!0), I(ye, null, we(Q.value, (n) => (b(), Y(At, _e({
842
+ key: `${n.id}-${n.type}`
843
+ }, { ref_for: !0 }, n), null, 16))), 128))
835
844
  ], 32))
836
845
  ]));
837
846
  }
838
- }), Wt = /* @__PURE__ */ be(Pt, [["__scopeId", "data-v-b0269a2a"]]), At = ["onMouseenter", "onMousedown"], Vt = { class: "suggestion-list__text" }, Nt = /* @__PURE__ */ ge({
847
+ }), Ft = /* @__PURE__ */ Ce(Mt, [["__scopeId", "data-v-5fda773e"]]), Xe = (l, c) => {
848
+ if (!c.length)
849
+ return [{ text: l, isMatch: !1 }];
850
+ const s = [];
851
+ for (const a of c) {
852
+ if (!a) continue;
853
+ let d = 0;
854
+ const x = l.toLowerCase(), h = a.toLowerCase();
855
+ for (; ; ) {
856
+ const w = x.indexOf(h, d);
857
+ if (w === -1) break;
858
+ s.push({
859
+ start: w,
860
+ end: w + a.length
861
+ }), d = w + 1;
862
+ }
863
+ }
864
+ if (s.length === 0)
865
+ return [{ text: l, isMatch: !1 }];
866
+ s.sort((a, d) => a.start - d.start);
867
+ const i = [];
868
+ for (const a of s)
869
+ if (i.length === 0)
870
+ i.push(a);
871
+ else {
872
+ const d = i[i.length - 1];
873
+ a.start <= d.end ? d.end = Math.max(d.end, a.end) : i.push(a);
874
+ }
875
+ const v = [];
876
+ let S = 0;
877
+ for (const a of i)
878
+ S < a.start && v.push({
879
+ text: l.substring(S, a.start),
880
+ isMatch: !1
881
+ }), v.push({
882
+ text: l.substring(a.start, a.end),
883
+ isMatch: !0
884
+ }), S = a.end;
885
+ return S < l.length && v.push({
886
+ text: l.substring(S),
887
+ isMatch: !1
888
+ }), v;
889
+ }, Pt = (l, c) => !c || !l ? [{ text: l, isMatch: !1 }] : Xe(l, [c]), Wt = (l, c) => {
890
+ const { content: s, highlights: i } = l;
891
+ return typeof i == "function" ? i(s, c) : Array.isArray(i) ? Xe(s, i) : Pt(s, c);
892
+ }, Vt = ["onMouseenter", "onMousedown"], Nt = { class: "suggestion-list__text" }, Ht = /* @__PURE__ */ Se({
839
893
  __name: "SuggestionList",
840
894
  props: {
841
895
  show: { type: Boolean },
842
896
  suggestions: {},
843
897
  popupStyle: {},
844
- isItemHighlighted: { type: Function },
845
- highlightSuggestionText: { type: Function },
898
+ activeKeyboardIndex: {},
899
+ activeMouseIndex: {},
846
900
  inputValue: {}
847
901
  },
848
- emits: ["item-hover", "item-leave", "select"],
849
- setup(i, { emit: u }) {
850
- const s = i, r = u, y = F(null), w = (_) => {
851
- r("item-hover", _);
852
- }, a = () => {
853
- r("item-leave");
854
- }, h = (_) => {
855
- r("select", _);
902
+ emits: ["select", "mouse-enter", "mouse-leave"],
903
+ setup(l, { emit: c }) {
904
+ const s = l, i = c, v = M(null), S = (h) => h === s.activeKeyboardIndex || h === s.activeMouseIndex, a = (h) => {
905
+ i("mouse-enter", h);
906
+ }, d = () => {
907
+ i("mouse-leave");
908
+ }, x = (h) => {
909
+ i("select", h);
856
910
  };
857
- return (_, p) => (S(), X(De, { name: "tiny-sender-slide-up" }, {
858
- default: ce(() => [
859
- s.show && s.suggestions.length ? (S(), O("div", {
911
+ return ne(
912
+ () => s.activeKeyboardIndex,
913
+ (h) => {
914
+ if (h !== -1 && v.value) {
915
+ const w = v.value.children[h];
916
+ w && w.scrollIntoView({ block: "nearest" });
917
+ }
918
+ }
919
+ ), (h, w) => (b(), Y(We, { name: "tiny-sender-slide-up" }, {
920
+ default: he(() => [
921
+ s.show && s.suggestions.length ? (b(), I("div", {
860
922
  key: 0,
861
923
  ref_key: "suggestionsListRef",
862
- ref: y,
924
+ ref: v,
863
925
  class: "suggestion-list",
864
- style: Fe(s.popupStyle)
926
+ style: Ve(s.popupStyle)
865
927
  }, [
866
- (S(!0), O(de, null, he(s.suggestions, (k, g) => (S(), O("div", {
867
- key: g,
868
- class: Y(["suggestion-list__item", { highlighted: s.isItemHighlighted(g) }]),
869
- onMouseenter: (T) => w(g),
870
- onMouseleave: a,
871
- onMousedown: ct((T) => h(k), ["prevent"])
928
+ (b(!0), I(ye, null, we(s.suggestions, (y, K) => (b(), I("div", {
929
+ key: K,
930
+ class: oe(["suggestion-list__item", { highlighted: S(K) }]),
931
+ onMouseenter: (W) => a(K),
932
+ onMouseleave: d,
933
+ onMousedown: ct((W) => x(y.content), ["prevent"])
872
934
  }, [
873
- z(b(_t), { class: "suggestion-list__icon" }),
874
- N("span", Vt, [
875
- (S(!0), O(de, null, he(s.highlightSuggestionText(k, s.inputValue), (T, m) => (S(), O("span", {
876
- key: m,
877
- class: Y({
878
- "suggestion-list__text--match": T.isMatch,
879
- "suggestion-list__text--normal": !T.isMatch
935
+ Z(C(wt), { class: "suggestion-list__icon" }),
936
+ U("span", Nt, [
937
+ (b(!0), I(ye, null, we(C(Wt)(y, s.inputValue), (W, F) => (b(), I("span", {
938
+ key: F,
939
+ class: oe({
940
+ "suggestion-list__text--match": W.isMatch,
941
+ "suggestion-list__text--normal": !W.isMatch
880
942
  })
881
- }, le(T.text), 3))), 128))
943
+ }, ue(W.text), 3))), 128))
882
944
  ])
883
- ], 42, At))), 128))
884
- ], 4)) : A("", !0)
945
+ ], 42, Vt))), 128))
946
+ ], 4)) : N("", !0)
885
947
  ]),
886
948
  _: 1
887
949
  }));
888
950
  }
889
- }), Mt = /* @__PURE__ */ be(Nt, [["__scopeId", "data-v-238fcdfd"]]), qt = ["data-theme"], Ut = { class: "tiny-sender__container" }, jt = {
951
+ }), Ut = /* @__PURE__ */ Ce(Ht, [["__scopeId", "data-v-e0ec9fe3"]]), qt = ["data-theme"], zt = { class: "tiny-sender__container" }, Gt = {
890
952
  key: 0,
891
953
  class: "tiny-sender__header-slot"
892
- }, zt = {
954
+ }, jt = {
893
955
  key: 0,
894
956
  class: "tiny-sender__prefix-slot"
895
- }, Gt = { class: "tiny-sender__content-area" }, Xt = {
957
+ }, Jt = { class: "tiny-sender__content-area" }, Xt = {
896
958
  key: 0,
897
959
  class: "tiny-sender__decorative-content"
898
- }, Jt = {
960
+ }, Zt = {
899
961
  key: 2,
900
962
  class: "tiny-sender__input-field-wrapper"
901
963
  }, Qt = {
902
964
  key: 0,
903
965
  class: "tiny-sender__completion-placeholder"
904
- }, Yt = { class: "user-input-mirror" }, Zt = {
966
+ }, Yt = { class: "user-input-mirror" }, en = {
905
967
  key: 0,
906
968
  class: "tiny-sender__tab-hint"
907
- }, en = {
969
+ }, tn = {
908
970
  key: 1,
909
971
  class: "tiny-sender__actions-slot"
910
- }, tn = { class: "tiny-sender__footer-left" }, nn = { class: "tiny-sender__footer-right" }, sn = { class: "real-word-length" }, on = {
972
+ }, nn = { class: "tiny-sender__footer-left" }, on = { class: "tiny-sender__footer-right" }, sn = { class: "real-word-length" }, an = {
911
973
  key: 1,
912
974
  class: "tiny-sender__toolbar"
913
- }, an = { class: "tiny-sender__buttons-container" }, ln = {
975
+ }, ln = { class: "tiny-sender__buttons-container" }, rn = {
914
976
  key: 1,
915
977
  class: "tiny-sender__footer-slot"
916
- }, _e = /* @__PURE__ */ ge({
978
+ }, un = /* @__PURE__ */ Se({
917
979
  __name: "index",
918
980
  props: {
919
981
  autofocus: { type: Boolean, default: !1 },
@@ -939,353 +1001,359 @@ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PUR
939
1001
  stopText: { default: "" }
940
1002
  },
941
1003
  emits: ["update:modelValue", "update:templateData", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template", "files-selected"],
942
- setup(i, { expose: u, emit: s }) {
943
- var Pe;
944
- const r = i, y = s, w = F(null), a = F(null), h = F(null), _ = F(null), p = F(null), k = E(() => r.templateData && r.templateData.length > 0), { inputValue: g, isComposing: T, clearInput: m } = Ct(r, y), L = E(() => !!g.value.trim()), M = E(() => {
945
- var n, I;
946
- return !(r.disabled || r.loading || !L.value || t.value || (I = (n = r.buttonGroup) == null ? void 0 : n.submit) != null && I.disabled);
1004
+ setup(l, { expose: c, emit: s }) {
1005
+ var D;
1006
+ const i = l, v = s, S = M(null), a = M(null), d = M(null), x = M(null), h = M(null), w = B(() => i.templateData && i.templateData.length > 0), { inputValue: y, isComposing: K, clearInput: W } = Ct(i, v), F = B(() => !!y.value.trim()), P = B(() => {
1007
+ var o, m;
1008
+ return !(i.disabled || i.loading || !F.value || be.value || (m = (o = i.buttonGroup) == null ? void 0 : o.submit) != null && m.disabled);
947
1009
  }), {
948
- showSuggestionsPopup: B,
949
- completionPlaceholder: v,
950
- showTabHint: H,
951
- suggestionsListRef: f,
952
- filteredSuggestions: K,
953
- activeSuggestion: q,
954
- isItemHighlighted: V,
955
- updateSuggestionsState: Z,
956
- selectSuggestion: fe,
957
- acceptCurrentSuggestion: ee,
958
- closeSuggestionsPopup: J,
959
- navigateSuggestions: R,
960
- handleSuggestionItemHover: U,
961
- handleSuggestionItemLeave: j,
962
- highlightSuggestionText: ne
963
- } = Rt(r, y, g, T, k), P = F(r.mode), se = F(!1), Ce = () => {
964
- P.value === "single" && (P.value = "multiple", G(() => {
1010
+ isPopupVisible: T,
1011
+ activeSuggestion: g,
1012
+ activeKeyboardIndex: O,
1013
+ activeMouseIndex: p,
1014
+ autoCompleteText: Q,
1015
+ showTabIndicator: E,
1016
+ syncAutoComplete: q,
1017
+ closePopup: ee,
1018
+ applySuggestion: H,
1019
+ confirmSelection: k,
1020
+ navigateWithKeyboard: j,
1021
+ handleMouseEnter: J,
1022
+ handleMouseLeave: le
1023
+ } = It(
1024
+ B(() => i.suggestions),
1025
+ y,
1026
+ K,
1027
+ w,
1028
+ (o) => v("update:modelValue", o),
1029
+ (o) => v("suggestion-select", o)
1030
+ ), V = M(i.mode), z = M(!1), ve = () => {
1031
+ V.value === "single" && (V.value = "multiple", te(() => {
965
1032
  setTimeout(() => {
966
- const n = document.querySelector(".tiny-textarea__inner");
967
- if (n) {
968
- n.style.whiteSpace = "pre-wrap";
969
- const I = g.value.length;
970
- n.focus(), n.setSelectionRange(I, I);
1033
+ const o = document.querySelector(".tiny-textarea__inner");
1034
+ if (o) {
1035
+ o.style.whiteSpace = "pre-wrap";
1036
+ const m = y.value.length;
1037
+ o.focus(), o.setSelectionRange(m, m);
971
1038
  }
972
1039
  }, 50);
973
1040
  }));
974
- }, ke = (n, I) => {
975
- const D = document.createElement("span");
976
- D.style.visibility = "hidden", D.style.position = "absolute", D.style.whiteSpace = "nowrap", D.style.font = I, D.textContent = n, document.body.appendChild(D);
977
- const me = D.offsetWidth;
978
- return document.body.removeChild(D), me;
979
- }, ie = () => {
980
- var Se, Ve, Ne;
981
- if (r.mode !== "single" || !w.value || se.value || !a.value || !_.value) return;
982
- const n = a.value.querySelector(".tiny-sender__content-area");
983
- if (!n) return;
984
- const I = ((Ve = (Se = w.value) == null ? void 0 : Se.querySelector) == null ? void 0 : Ve.call(Se, ".tiny-input__inner")) || n.querySelector(".tiny-input__inner"), D = p.value || a.value.querySelector(".tiny-sender__buttons-container");
985
- if (!I) {
1041
+ }, se = (o, m) => {
1042
+ const A = document.createElement("span");
1043
+ A.style.visibility = "hidden", A.style.position = "absolute", A.style.whiteSpace = "nowrap", A.style.font = m, A.textContent = o, document.body.appendChild(A);
1044
+ const re = A.offsetWidth;
1045
+ return document.body.removeChild(A), re;
1046
+ }, xe = () => {
1047
+ var Ee, Ue, qe;
1048
+ if (i.mode !== "single" || !S.value || z.value || !a.value || !x.value) return;
1049
+ const o = a.value.querySelector(".tiny-sender__content-area");
1050
+ if (!o) return;
1051
+ const m = ((Ue = (Ee = S.value) == null ? void 0 : Ee.querySelector) == null ? void 0 : Ue.call(Ee, ".tiny-input__inner")) || o.querySelector(".tiny-input__inner"), A = h.value || a.value.querySelector(".tiny-sender__buttons-container");
1052
+ if (!m) {
986
1053
  console.warn("Cannot find input element for overflow check");
987
1054
  return;
988
1055
  }
989
- const me = I.getBoundingClientRect(), $e = D == null ? void 0 : D.getBoundingClientRect();
990
- if (me.width === 0) {
991
- setTimeout(() => ie(), 50);
1056
+ const re = m.getBoundingClientRect(), Me = A == null ? void 0 : A.getBoundingClientRect();
1057
+ if (re.width === 0) {
1058
+ setTimeout(() => xe(), 50);
992
1059
  return;
993
1060
  }
994
- const Ze = window.getComputedStyle(I).font, et = ke(g.value, Ze), We = (Ne = a.value) == null ? void 0 : Ne.classList.contains("tr-sender-compact"), tt = We ? 12 : 20, nt = me.width, st = ($e == null ? void 0 : $e.width) || 0, Ae = nt - st - tt, ot = We ? 50 : 80;
995
- et > Ae && Ae > ot && P.value === "single" && (se.value = !0, P.value = "multiple", G(() => {
996
- w.value ? setTimeout(() => {
997
- var Me;
998
- const we = (Me = a.value) == null ? void 0 : Me.querySelector(".tiny-textarea__inner");
999
- if (we) {
1000
- we.style.whiteSpace = "pre-wrap";
1001
- const qe = g.value.length;
1002
- we.focus(), we.setSelectionRange(qe, qe);
1061
+ const Ze = window.getComputedStyle(m).font, Qe = se(y.value, Ze), Ne = (qe = a.value) == null ? void 0 : qe.classList.contains("tr-sender-compact"), Ye = Ne ? 12 : 20, et = re.width, tt = (Me == null ? void 0 : Me.width) || 0, He = et - tt - Ye, nt = Ne ? 50 : 80;
1062
+ Qe > He && He > nt && V.value === "single" && (z.value = !0, V.value = "multiple", te(() => {
1063
+ S.value ? setTimeout(() => {
1064
+ var ze;
1065
+ const $e = (ze = a.value) == null ? void 0 : ze.querySelector(".tiny-textarea__inner");
1066
+ if ($e) {
1067
+ $e.style.whiteSpace = "pre-wrap";
1068
+ const Ge = y.value.length;
1069
+ $e.focus(), $e.setSelectionRange(Ge, Ge);
1003
1070
  }
1004
- se.value = !1;
1005
- }, 300) : se.value = !1;
1071
+ z.value = !1;
1072
+ }, 300) : z.value = !1;
1006
1073
  }));
1007
- }, re = () => {
1008
- if (k.value && h.value)
1009
- He();
1010
- else if (w.value)
1011
- w.value.focus();
1074
+ }, X = () => {
1075
+ if (w.value && d.value)
1076
+ _();
1077
+ else if (S.value)
1078
+ S.value.focus();
1012
1079
  else {
1013
- const n = document.querySelector(".tiny-input__inner");
1014
- n == null || n.focus();
1080
+ const o = document.querySelector(".tiny-input__inner");
1081
+ o == null || o.focus();
1015
1082
  }
1016
- }, xe = () => {
1017
- if (w.value)
1018
- w.value.blur();
1083
+ }, ke = () => {
1084
+ if (S.value)
1085
+ S.value.blur();
1019
1086
  else {
1020
- const n = document.querySelector(".tiny-input__inner");
1021
- n == null || n.blur();
1087
+ const o = document.querySelector(".tiny-input__inner");
1088
+ o == null || o.blur();
1022
1089
  }
1023
- }, ve = () => {
1024
- var n;
1025
- y("update:templateData", []), (n = h.value) == null || n.clearHistory(), G(() => {
1026
- g.value === "" && (P.value = r.mode || "single"), setTimeout(() => {
1027
- re();
1090
+ }, ce = () => {
1091
+ var o;
1092
+ v("update:templateData", []), (o = d.value) == null || o.clearHistory(), te(() => {
1093
+ y.value === "" && (V.value = i.mode || "single"), setTimeout(() => {
1094
+ X();
1028
1095
  }, 50);
1029
- }), J();
1030
- }, ye = () => {
1031
- var n;
1032
- m(), k.value ? ve() : (n = a.value) == null || n.focus(), G(() => {
1033
- g.value === "" && (P.value = r.mode || "single");
1034
- }), J();
1035
- }, ue = (n) => {
1036
- y("update:templateData", n);
1096
+ });
1097
+ }, ge = () => {
1098
+ var o;
1099
+ W(), w.value ? ce() : (o = a.value) == null || o.focus(), te(() => {
1100
+ y.value === "" && (V.value = i.mode || "single");
1101
+ });
1102
+ }, Be = (o) => {
1103
+ const m = (re) => re.type === "text" && re.content === "​";
1104
+ if (o.length === 0 || o.every(m)) {
1105
+ ce();
1106
+ return;
1107
+ }
1108
+ v("update:templateData", o);
1037
1109
  };
1038
- Q(
1039
- () => r.templateData,
1110
+ ne(
1111
+ () => i.templateData,
1040
1112
  () => {
1041
- g.value = r.templateData.map((n) => n.content).join("");
1113
+ y.value = i.templateData.map((o) => o.content).join("");
1042
1114
  },
1043
1115
  { deep: !0 }
1044
1116
  );
1045
- const Ie = E(() => {
1046
- const n = typeof r.speech == "object" ? r.speech : {};
1117
+ const De = B(() => {
1118
+ const o = typeof i.speech == "object" ? i.speech : {};
1047
1119
  return {
1048
- ...n,
1049
- onStart: () => y("speech-start"),
1050
- onEnd: (I) => y("speech-end", I),
1051
- onInterim: (I) => y("speech-interim", I),
1052
- onFinal: (I) => {
1053
- if (n.autoReplace)
1054
- g.value = I;
1120
+ ...o,
1121
+ onStart: () => v("speech-start"),
1122
+ onEnd: (m) => v("speech-end", m),
1123
+ onInterim: (m) => v("speech-interim", m),
1124
+ onFinal: (m) => {
1125
+ if (o.autoReplace)
1126
+ y.value = m;
1055
1127
  else {
1056
- const D = g.value;
1057
- D && I && !D.endsWith(" ") && !I.startsWith(" ") && D.length > 0 ? g.value = D + " " + I : g.value = D + I;
1128
+ const A = y.value;
1129
+ A && m && !A.endsWith(" ") && !m.startsWith(" ") && A.length > 0 ? y.value = A + " " + m : y.value = A + m;
1058
1130
  }
1059
- y("speech-end", I);
1131
+ v("speech-end", m);
1060
1132
  },
1061
- onError: (I) => {
1062
- y("speech-error", I);
1133
+ onError: (m) => {
1134
+ v("speech-error", m);
1063
1135
  }
1064
1136
  };
1065
- }), { speechState: oe, start: Re, stop: Te } = xt(Ie.value), e = () => {
1066
- oe.isRecording ? Te() : Re();
1067
- }, t = E(() => r.maxLength !== 1 / 0 && g.value.length > r.maxLength), { handleKeyPress: o, triggerSubmit: c } = kt(
1068
- r,
1137
+ }), { speechState: ae, start: de, stop: Ie } = kt(De.value), me = () => {
1138
+ ae.isRecording ? Ie() : de();
1139
+ }, be = B(() => i.maxLength !== 1 / 0 && y.value.length > i.maxLength), { handleKeyPress: fe, triggerSubmit: pe } = xt(
1140
+ i,
1141
+ v,
1069
1142
  y,
1070
- g,
1143
+ K,
1144
+ ae,
1071
1145
  T,
1072
- oe,
1073
- B,
1074
- q,
1146
+ g,
1147
+ k,
1075
1148
  ee,
1076
- J,
1077
- R,
1078
- e,
1079
- M,
1149
+ j,
1150
+ me,
1080
1151
  P,
1081
- Ce,
1082
- k,
1083
- ve
1084
- ), l = (n) => {
1085
- y("focus", n), g.value && K.value.length > 0 && !k.value && (B.value = !0, H.value = !0);
1086
- }, d = (n) => {
1087
- y("blur", n), J();
1088
- }, x = E(() => P.value === "multiple" ? "textarea" : "text"), C = E(
1152
+ V,
1153
+ ve,
1154
+ w,
1155
+ ce
1156
+ ), Te = (o) => {
1157
+ v("focus", o), y.value && !w.value && (T.value = !0);
1158
+ }, Re = (o) => {
1159
+ v("blur", o), ee();
1160
+ }, Ae = B(() => V.value === "multiple" ? "textarea" : "text"), Ke = B(
1089
1161
  () => ({
1090
1162
  display: "flex",
1091
- justifyContent: r.showWordLimit && r.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1163
+ justifyContent: i.showWordLimit && i.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1092
1164
  alignItems: "center"
1093
1165
  })
1094
- ), $ = dt(), W = E(() => !!$.decorativeContent), te = E(() => r.disabled || W.value), Oe = E(() => r.loading), ze = E(() => ({
1095
- "is-disabled": te.value,
1096
- "is-loading": Oe.value,
1097
- "is-auto-switching": se.value
1098
- })), Ge = E(() => ({
1099
- width: bt(r.suggestionPopupWidth),
1166
+ ), Oe = dt(), e = B(() => !!Oe.decorativeContent), t = B(() => i.disabled || e.value), n = B(() => i.loading), u = B(() => ({
1167
+ "is-disabled": t.value,
1168
+ "is-loading": n.value,
1169
+ "is-auto-switching": z.value
1170
+ })), r = B(() => ({
1171
+ width: St(i.suggestionPopupWidth),
1100
1172
  maxWidth: "100%"
1101
1173
  // 确保不超出父容器宽度
1102
- })), Xe = () => {
1103
- T.value = !1, setTimeout(() => {
1104
- T.value = !1, Z();
1105
- }, 50);
1174
+ })), f = () => {
1175
+ K.value = !1;
1106
1176
  };
1107
- Q(g, () => {
1108
- G(ie), g.value === "" && r.mode === "single" && (P.value = "single");
1109
- }), Q(
1110
- () => k.value,
1111
- (n) => {
1112
- n && (P.value = "multiple");
1177
+ ne(y, () => {
1178
+ te(xe), y.value === "" && i.mode === "single" && (V.value = "single"), q();
1179
+ }), ne(
1180
+ () => w.value,
1181
+ (o) => {
1182
+ o && (V.value = "multiple");
1113
1183
  }
1114
1184
  );
1115
- const He = () => {
1116
- h.value && h.value.activateFirstField();
1117
- }, { accept: Je = "*", multiple: Qe = !0 } = ((Pe = r.buttonGroup) == null ? void 0 : Pe.file) || {}, { open: Ke, files: Ye } = ht({ accept: Je, multiple: Qe });
1118
- return Q(Ye, (n) => {
1119
- n && n.length > 0 && y("files-selected", Array.from(n));
1120
- }), u({
1121
- focus: re,
1122
- blur: xe,
1123
- clear: ye,
1124
- submit: c,
1125
- startSpeech: Re,
1126
- stopSpeech: Te,
1127
- activateTemplateFirstField: He
1128
- }), (n, I) => (S(), O("div", {
1185
+ const _ = () => {
1186
+ d.value && d.value.activateFirstField();
1187
+ }, { accept: $ = "*", multiple: G = !0 } = ((D = i.buttonGroup) == null ? void 0 : D.file) || {}, { open: R, files: L } = ht({ accept: $, multiple: G });
1188
+ return ne(L, (o) => {
1189
+ o && o.length > 0 && v("files-selected", Array.from(o));
1190
+ }), c({
1191
+ focus: X,
1192
+ blur: ke,
1193
+ clear: ge,
1194
+ submit: pe,
1195
+ startSpeech: de,
1196
+ stopSpeech: Ie,
1197
+ activateTemplateFirstField: _
1198
+ }), (o, m) => (b(), I("div", {
1129
1199
  ref_key: "senderRef",
1130
1200
  ref: a,
1131
- class: Y(["tiny-sender", [ze.value, `theme-${n.theme}`, `mode-${P.value}`]]),
1132
- "data-theme": n.theme
1201
+ class: oe(["tiny-sender", [u.value, `theme-${o.theme}`, `mode-${V.value}`]]),
1202
+ "data-theme": o.theme
1133
1203
  }, [
1134
- N("div", Ut, [
1135
- N("div", {
1204
+ U("div", zt, [
1205
+ U("div", {
1136
1206
  class: "tiny-sender__input-wrapper",
1137
1207
  ref_key: "inputWrapperRef",
1138
- ref: _
1208
+ ref: x
1139
1209
  }, [
1140
- z(De, { name: "tiny-sender-slide-down" }, {
1141
- default: ce(() => [
1142
- n.$slots.header ? (S(), O("div", jt, [
1143
- ae(n.$slots, "header")
1144
- ])) : A("", !0)
1210
+ Z(We, { name: "tiny-sender-slide-down" }, {
1211
+ default: he(() => [
1212
+ o.$slots.header ? (b(), I("div", Gt, [
1213
+ ie(o.$slots, "header", {}, void 0, !0)
1214
+ ])) : N("", !0)
1145
1215
  ]),
1146
1216
  _: 3
1147
1217
  }),
1148
- N("div", {
1149
- class: Y(["tiny-sender__input-row", { "has-prefix": n.$slots.prefix, "has-header": n.$slots.header }])
1218
+ U("div", {
1219
+ class: oe(["tiny-sender__input-row", { "has-prefix": o.$slots.prefix, "has-header": o.$slots.header }])
1150
1220
  }, [
1151
- n.$slots.prefix ? (S(), O("div", zt, [
1152
- ae(n.$slots, "prefix")
1153
- ])) : A("", !0),
1154
- N("div", Gt, [
1155
- n.$slots.decorativeContent ? (S(), O("div", Xt, [
1156
- ae(n.$slots, "decorativeContent")
1157
- ])) : A("", !0),
1158
- k.value ? (S(), X(Wt, {
1221
+ o.$slots.prefix ? (b(), I("div", jt, [
1222
+ ie(o.$slots, "prefix", {}, void 0, !0)
1223
+ ])) : N("", !0),
1224
+ U("div", Jt, [
1225
+ o.$slots.decorativeContent ? (b(), I("div", Xt, [
1226
+ ie(o.$slots, "decorativeContent", {}, void 0, !0)
1227
+ ])) : N("", !0),
1228
+ w.value ? (b(), Y(Ft, {
1159
1229
  key: 1,
1160
1230
  ref_key: "templateEditorRef",
1161
- ref: h,
1162
- "model-value": r.templateData,
1163
- "onUpdate:modelValue": ue,
1164
- onSubmit: b(c)
1165
- }, null, 8, ["model-value", "onSubmit"])) : (S(), O("div", Jt, [
1166
- z(b(pt), {
1231
+ ref: d,
1232
+ "model-value": i.templateData,
1233
+ "onUpdate:modelValue": Be,
1234
+ onSubmit: C(pe)
1235
+ }, null, 8, ["model-value", "onSubmit"])) : (b(), I("div", Zt, [
1236
+ Z(C(pt), {
1167
1237
  ref_key: "inputRef",
1168
- ref: w,
1169
- autosize: n.autoSize,
1170
- type: x.value,
1238
+ ref: S,
1239
+ autosize: o.autoSize,
1240
+ type: Ae.value,
1171
1241
  resize: "none",
1172
- modelValue: b(g),
1173
- "onUpdate:modelValue": I[0] || (I[0] = (D) => ft(g) ? g.value = D : null),
1174
- disabled: te.value,
1175
- placeholder: n.placeholder,
1176
- autofocus: n.autofocus,
1177
- onKeydown: b(o),
1178
- onCompositionstart: I[1] || (I[1] = (D) => T.value = !0),
1179
- onCompositionend: Xe,
1180
- onFocus: l,
1181
- onBlur: d
1242
+ modelValue: C(y),
1243
+ "onUpdate:modelValue": m[0] || (m[0] = (A) => ft(y) ? y.value = A : null),
1244
+ disabled: t.value,
1245
+ placeholder: o.placeholder,
1246
+ autofocus: o.autofocus,
1247
+ onKeydown: C(fe),
1248
+ onCompositionstart: m[1] || (m[1] = (A) => K.value = !0),
1249
+ onCompositionend: f,
1250
+ onFocus: Te,
1251
+ onBlur: Re
1182
1252
  }, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
1183
- b(v) && !b(T) ? (S(), O("div", Qt, [
1184
- N("span", Yt, le(b(g)), 1),
1185
- Ue(le(b(v)) + " ", 1),
1186
- b(H) ? (S(), O("div", Zt, "TAB")) : A("", !0)
1187
- ])) : A("", !0)
1253
+ C(Q) && !C(K) ? (b(), I("div", Qt, [
1254
+ U("span", Yt, ue(C(y)), 1),
1255
+ je(ue(C(Q)) + " ", 1),
1256
+ C(E) ? (b(), I("div", en, "TAB")) : N("", !0)
1257
+ ])) : N("", !0)
1188
1258
  ]))
1189
1259
  ]),
1190
- P.value === "single" ? (S(), O("div", en, [
1191
- N("div", {
1260
+ V.value === "single" ? (b(), I("div", tn, [
1261
+ U("div", {
1192
1262
  class: "tiny-sender__buttons-container",
1193
1263
  ref_key: "buttonsContainerRef",
1194
- ref: p
1264
+ ref: h
1195
1265
  }, [
1196
- ae(n.$slots, "actions"),
1197
- z(je, {
1198
- "allow-speech": n.allowSpeech,
1199
- "allow-files": n.allowFiles,
1200
- loading: n.loading,
1201
- disabled: te.value,
1202
- "show-clear": n.clearable,
1203
- "has-content": L.value,
1204
- "speech-status": b(oe),
1205
- "button-group": n.buttonGroup,
1206
- "submit-type": n.submitType,
1207
- "is-over-limit": t.value,
1208
- "stop-text": n.stopText,
1209
- onClear: ye,
1210
- onToggleSpeech: e,
1211
- onSubmit: b(c),
1212
- onCancel: I[2] || (I[2] = (D) => n.$emit("cancel")),
1213
- onTriggerSelect: b(Ke)
1266
+ ie(o.$slots, "actions", {}, void 0, !0),
1267
+ Z(Je, {
1268
+ "allow-speech": o.allowSpeech,
1269
+ "allow-files": o.allowFiles,
1270
+ loading: o.loading,
1271
+ disabled: t.value,
1272
+ "show-clear": o.clearable,
1273
+ "has-content": F.value,
1274
+ "speech-status": C(ae),
1275
+ "button-group": o.buttonGroup,
1276
+ "submit-type": o.submitType,
1277
+ "is-over-limit": be.value,
1278
+ "stop-text": o.stopText,
1279
+ onClear: ge,
1280
+ onToggleSpeech: me,
1281
+ onSubmit: C(pe),
1282
+ onCancel: m[2] || (m[2] = (A) => o.$emit("cancel")),
1283
+ onTriggerSelect: C(R)
1214
1284
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
1215
1285
  ], 512)
1216
- ])) : A("", !0)
1286
+ ])) : N("", !0)
1217
1287
  ], 2),
1218
- z(De, { name: "tiny-sender-slide-up" }, {
1219
- default: ce(() => [
1220
- P.value === "multiple" ? (S(), O("div", {
1288
+ Z(We, { name: "tiny-sender-slide-up" }, {
1289
+ default: he(() => [
1290
+ V.value === "multiple" ? (b(), I("div", {
1221
1291
  key: 0,
1222
- style: Fe(C.value),
1292
+ style: Ve(Ke.value),
1223
1293
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1224
1294
  }, [
1225
- N("div", tn, [
1226
- ae(n.$slots, "footer-left")
1295
+ U("div", nn, [
1296
+ ie(o.$slots, "footer-left", {}, void 0, !0)
1227
1297
  ]),
1228
- N("div", nn, [
1229
- ae(n.$slots, "footer-right"),
1230
- n.showWordLimit && n.maxLength !== 1 / 0 ? (S(), O("div", {
1298
+ U("div", on, [
1299
+ ie(o.$slots, "footer-right", {}, void 0, !0),
1300
+ o.showWordLimit && o.maxLength !== 1 / 0 ? (b(), I("div", {
1231
1301
  key: 0,
1232
- class: Y(["tiny-sender__word-limit", { "is-over-limit": t.value }])
1302
+ class: oe(["tiny-sender__word-limit", { "is-over-limit": be.value }])
1233
1303
  }, [
1234
- N("span", sn, le(b(g).length), 1),
1235
- Ue("/" + le(n.maxLength), 1)
1236
- ], 2)) : A("", !0),
1237
- P.value === "multiple" ? (S(), O("div", on, [
1238
- N("div", an, [
1239
- z(je, {
1240
- "allow-speech": n.allowSpeech,
1241
- "allow-files": n.allowFiles,
1242
- loading: n.loading,
1243
- disabled: te.value,
1244
- "show-clear": n.clearable,
1245
- "has-content": L.value,
1246
- "speech-status": b(oe),
1247
- "button-group": n.buttonGroup,
1248
- "submit-type": n.submitType,
1249
- "is-over-limit": t.value,
1250
- "stop-text": n.stopText,
1251
- onClear: ye,
1252
- onToggleSpeech: e,
1253
- onSubmit: b(c),
1254
- onCancel: I[3] || (I[3] = (D) => n.$emit("cancel")),
1255
- onTriggerSelect: b(Ke)
1304
+ U("span", sn, ue(C(y).length), 1),
1305
+ je("/" + ue(o.maxLength), 1)
1306
+ ], 2)) : N("", !0),
1307
+ V.value === "multiple" ? (b(), I("div", an, [
1308
+ U("div", ln, [
1309
+ Z(Je, {
1310
+ "allow-speech": o.allowSpeech,
1311
+ "allow-files": o.allowFiles,
1312
+ loading: o.loading,
1313
+ disabled: t.value,
1314
+ "show-clear": o.clearable,
1315
+ "has-content": F.value,
1316
+ "speech-status": C(ae),
1317
+ "button-group": o.buttonGroup,
1318
+ "submit-type": o.submitType,
1319
+ "is-over-limit": be.value,
1320
+ "stop-text": o.stopText,
1321
+ onClear: ge,
1322
+ onToggleSpeech: me,
1323
+ onSubmit: C(pe),
1324
+ onCancel: m[3] || (m[3] = (A) => o.$emit("cancel")),
1325
+ onTriggerSelect: C(R)
1256
1326
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "button-group", "submit-type", "is-over-limit", "stop-text", "onSubmit", "onTriggerSelect"])
1257
1327
  ])
1258
- ])) : A("", !0)
1328
+ ])) : N("", !0)
1259
1329
  ])
1260
- ], 4)) : n.$slots.footer ? (S(), O("div", ln, [
1261
- ae(n.$slots, "footer")
1262
- ])) : A("", !0)
1330
+ ], 4)) : o.$slots.footer ? (b(), I("div", rn, [
1331
+ ie(o.$slots, "footer", {}, void 0, !0)
1332
+ ])) : N("", !0)
1263
1333
  ]),
1264
1334
  _: 3
1265
1335
  })
1266
1336
  ], 512)
1267
1337
  ]),
1268
- z(Mt, {
1269
- ref_key: "suggestionsListRef",
1270
- ref: f,
1271
- show: b(B),
1272
- suggestions: b(K),
1273
- "popup-style": Ge.value,
1274
- "is-item-highlighted": b(V),
1275
- "highlight-suggestion-text": b(ne),
1276
- "input-value": b(g),
1277
- onItemHover: b(U),
1278
- onItemLeave: b(j),
1279
- onSelect: b(fe)
1280
- }, null, 8, ["show", "suggestions", "popup-style", "is-item-highlighted", "highlight-suggestion-text", "input-value", "onItemHover", "onItemLeave", "onSelect"])
1338
+ Z(Ut, {
1339
+ show: C(T),
1340
+ suggestions: o.suggestions,
1341
+ "popup-style": r.value,
1342
+ "active-keyboard-index": C(O),
1343
+ "active-mouse-index": C(p),
1344
+ "input-value": C(y),
1345
+ onSelect: C(H),
1346
+ onMouseEnter: C(J),
1347
+ onMouseLeave: C(le)
1348
+ }, null, 8, ["show", "suggestions", "popup-style", "active-keyboard-index", "active-mouse-index", "input-value", "onSelect", "onMouseEnter", "onMouseLeave"])
1281
1349
  ], 10, qt));
1282
1350
  }
1283
- });
1284
- _e.name = "TrSender";
1285
- const rn = function(i) {
1286
- i.component(_e.name, _e);
1351
+ }), Le = /* @__PURE__ */ Ce(un, [["__scopeId", "data-v-520fdb31"]]);
1352
+ Le.name = "TrSender";
1353
+ const cn = function(l) {
1354
+ l.component(Le.name, Le);
1287
1355
  };
1288
- _e.install = rn;
1356
+ Le.install = cn;
1289
1357
  export {
1290
- _e as default
1358
+ Le as default
1291
1359
  };