@opentiny/tiny-robot 0.3.0-alpha.9 → 0.3.0-rc.1

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