@opentiny/tiny-robot 0.3.0-alpha.7 → 0.3.0-alpha.8

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,286 @@
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";
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";
5
6
  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(
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(
10
11
  () => i.modelValue,
11
- (h) => {
12
- h !== void 0 && h !== a.value && (a.value = h);
12
+ (p) => {
13
+ p !== void 0 && p !== s.value && (s.value = p);
13
14
  }
14
- ), Z(
15
- () => a.value,
16
- (h) => {
17
- r("update:modelValue", h);
15
+ ), Q(
16
+ () => s.value,
17
+ (p) => {
18
+ u("update:modelValue", p);
18
19
  }
19
20
  );
20
- const y = (h) => {
21
- a.value = h, r("update:modelValue", h);
22
- }, w = (h) => {
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);
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);
27
+ }, a = () => {
28
+ s.value = "", u("update:modelValue", ""), u("clear");
29
+ }, h = F(!1);
29
30
  return {
30
- inputValue: a,
31
- inputWrapper: c,
32
- isComposing: p,
31
+ inputValue: s,
32
+ inputWrapper: r,
33
+ isComposing: h,
33
34
  handleChange: y,
34
35
  handleSubmit: w,
35
- handleClear: n,
36
+ handleClear: a,
36
37
  clearInput: () => {
37
- n();
38
+ a();
38
39
  }
39
40
  };
40
41
  }
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) {
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) {
47
48
  case "enter":
48
- return !v.shiftKey && !v.ctrlKey && !v.metaKey;
49
+ return !f.shiftKey && !f.ctrlKey && !f.metaKey;
49
50
  case "ctrlEnter":
50
- return (v.ctrlKey || v.metaKey) && !v.shiftKey;
51
+ return (f.ctrlKey || f.metaKey) && !f.shiftKey;
51
52
  case "shiftEnter":
52
- return v.shiftKey && !v.ctrlKey && !v.metaKey;
53
+ return f.shiftKey && !f.ctrlKey && !f.metaKey;
53
54
  default:
54
55
  return !1;
55
56
  }
56
57
  };
57
58
  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;
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;
66
67
  }, 0);
67
68
  return;
68
69
  }
69
- if (v.key === "Tab" && w.value && n.value) {
70
- v.preventDefault(), p();
70
+ if (f.key === "Tab" && w.value && a.value) {
71
+ f.preventDefault(), h();
71
72
  return;
72
73
  }
73
74
  if (w.value) {
74
- if (v.key === "ArrowDown") {
75
- v.preventDefault(), h("down");
75
+ if (f.key === "ArrowDown") {
76
+ f.preventDefault(), p("down");
76
77
  return;
77
78
  }
78
- if (v.key === "ArrowUp") {
79
- v.preventDefault(), h("up");
79
+ if (f.key === "ArrowUp") {
80
+ f.preventDefault(), p("up");
80
81
  return;
81
82
  }
82
- if (v.key === "Enter" && n.value) {
83
- v.preventDefault(), p();
83
+ if (f.key === "Enter" && a.value) {
84
+ f.preventDefault(), h();
84
85
  return;
85
86
  }
86
87
  }
87
- if (v.key === "Escape") {
88
- w.value ? (C(), v.preventDefault()) : y.isRecording && (_(), v.preventDefault()), r("escape-press");
88
+ if (f.key === "Escape") {
89
+ w.value ? (_(), f.preventDefault()) : y.isRecording && (k(), f.preventDefault()), u("escape-press");
89
90
  return;
90
91
  }
91
- z(v, i.submitType) && (v.preventDefault(), g.value && $());
92
+ v(f, i.submitType) && (f.preventDefault(), g.value && B());
92
93
  },
93
- triggerSubmit: $
94
+ triggerSubmit: B
94
95
  };
95
96
  }
96
- function wt(i) {
97
- const r = et({
97
+ function xt(i) {
98
+ const u = at({
98
99
  isRecording: !1,
99
100
  isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
100
101
  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);
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 = () => {
104
+ var a;
105
+ u.isRecording = !0, u.error = void 0, (a = i.onStart) == null || a.call(i);
106
+ }, s.onend = () => {
107
+ var a;
108
+ u.isRecording = !1, (a = i.onEnd) == null || a.call(i);
109
+ }, 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);
113
+ }, 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);
115
116
  });
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);
117
+ const r = () => {
118
+ var a;
119
+ if (!s) {
120
+ const h = new Error("浏览器不支持语音识别");
121
+ u.error = h, (a = i.onError) == null || a.call(i, h);
121
122
  return;
122
123
  }
123
- if (r.isRecording) {
124
+ if (u.isRecording) {
124
125
  try {
125
- a.stop(), setTimeout(() => {
126
+ s.stop(), setTimeout(() => {
126
127
  try {
127
- a.start();
128
- } catch (p) {
129
- w(p);
128
+ s.start();
129
+ } catch (h) {
130
+ w(h);
130
131
  }
131
132
  }, 100);
132
- } catch (p) {
133
- w(p);
133
+ } catch (h) {
134
+ w(h);
134
135
  }
135
136
  return;
136
137
  }
137
138
  try {
138
- a.start();
139
- } catch (p) {
140
- w(p);
139
+ s.start();
140
+ } catch (h) {
141
+ w(h);
141
142
  }
142
143
  }, y = () => {
143
- if (a && r.isRecording)
144
+ if (s && u.isRecording)
144
145
  try {
145
- a.stop();
146
- } catch (n) {
147
- w(n);
146
+ s.stop();
147
+ } catch (a) {
148
+ w(a);
148
149
  }
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);
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);
152
153
  };
153
154
  return {
154
- speechState: r,
155
- start: c,
155
+ speechState: u,
156
+ start: r,
156
157
  stop: y
157
158
  };
158
159
  }
159
- const St = (i, r) => {
160
- if (!r || !i)
160
+ const It = (i, u) => {
161
+ if (!u || !i)
161
162
  return [{ text: i, isMatch: !1 }];
162
- const a = i.toLowerCase(), c = r.toLowerCase(), y = [];
163
+ const s = i.toLowerCase(), r = u.toLowerCase(), y = [];
163
164
  let w = 0;
164
- for (; w < a.length; ) {
165
- const h = a.indexOf(c, w);
166
- if (h === -1) break;
165
+ for (; w < s.length; ) {
166
+ const p = s.indexOf(r, w);
167
+ if (p === -1) break;
167
168
  y.push({
168
- start: h,
169
- end: h + r.length
170
- }), w = h + 1;
169
+ start: p,
170
+ end: p + u.length
171
+ }), w = p + 1;
171
172
  }
172
173
  if (y.length === 0)
173
174
  return [{ text: i, isMatch: !1 }];
174
- const n = [];
175
- for (const h of y)
176
- if (n.length === 0)
177
- n.push(h);
175
+ const a = [];
176
+ for (const p of y)
177
+ if (a.length === 0)
178
+ a.push(p);
178
179
  else {
179
- const _ = n[n.length - 1];
180
- h.start <= _.end ? _.end = Math.max(_.end, h.end) : n.push(h);
180
+ const k = a[a.length - 1];
181
+ p.start <= k.end ? k.end = Math.max(k.end, p.end) : a.push(p);
181
182
  }
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),
183
+ const h = [];
184
+ let _ = 0;
185
+ for (const p of a)
186
+ _ < p.start && h.push({
187
+ text: i.substring(_, p.start),
187
188
  isMatch: !1
188
- }), p.push({
189
- text: i.substring(h.start, h.end),
189
+ }), h.push({
190
+ text: i.substring(p.start, p.end),
190
191
  isMatch: !0
191
- }), C = h.end;
192
- return C < i.length && p.push({
193
- text: i.substring(C),
192
+ }), _ = p.end;
193
+ return _ < i.length && h.push({
194
+ text: i.substring(_),
194
195
  isMatch: !1
195
- }), p;
196
+ }), h;
196
197
  };
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;
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;
208
209
  return;
209
210
  }
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, $();
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);
216
213
  }, v = () => {
217
- c.value || g.value || q(() => {
218
- a.value && i.suggestions && i.suggestions.length > 0 && !y.value && d.value.length > 0 ? te() : z();
214
+ w.value = !1, a.value = -1, h.value = -1, T.value = null, _.value = "", p.value = !1;
215
+ }, 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();
219
220
  });
220
221
  };
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(() => {
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(() => {
224
225
  g.value = !1;
225
226
  });
227
+ }, q = () => {
228
+ L.value && K(L.value);
226
229
  }, V = () => {
227
- L.value && F(L.value);
228
- }, W = () => {
229
- z();
230
+ v();
230
231
  };
231
232
  return {
232
233
  showSuggestionsPopup: w,
233
- completionPlaceholder: C,
234
- showTabHint: h,
235
- suggestionsListRef: _,
236
- filteredSuggestions: d,
234
+ completionPlaceholder: _,
235
+ showTabHint: p,
236
+ suggestionsListRef: k,
237
+ filteredSuggestions: m,
237
238
  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];
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];
252
253
  ne && ne.scrollIntoView({ block: "nearest" });
253
254
  }
254
255
  },
255
- handleSuggestionItemHover: (x) => {
256
- I.value = "mouse", p.value = x, $(d.value[x]);
256
+ handleSuggestionItemHover: (R) => {
257
+ T.value = "mouse", h.value = R, B(m.value[R]);
257
258
  },
258
259
  handleSuggestionItemLeave: () => {
259
- if (p.value = -1, n.value !== -1) {
260
- I.value = "keyboard";
261
- const x = d.value[n.value];
262
- x && $(x);
260
+ if (h.value = -1, a.value !== -1) {
261
+ T.value = "keyboard";
262
+ const R = m.value[a.value];
263
+ R && B(R);
263
264
  } else
264
- I.value = null, $();
265
+ T.value = null, B();
265
266
  },
266
267
  handleClickOutside: () => {
267
- W();
268
+ V();
268
269
  },
269
- highlightSuggestionText: St
270
+ highlightSuggestionText: It
270
271
  };
271
272
  }
272
- const bt = { class: "action-buttons" }, Ct = { class: "action-buttons__button" }, kt = { class: "action-buttons__submit-content" }, xt = {
273
+ const Tt = { class: "action-buttons" }, Ot = { class: "action-buttons__submit-content" }, $t = {
273
274
  key: 0,
274
275
  class: "action-buttons__cancel-text"
275
- }, It = /* @__PURE__ */ ge({
276
+ }, Bt = /* @__PURE__ */ ge({
276
277
  __name: "ActionButtons",
277
278
  props: {
278
279
  loading: { type: Boolean, default: !1 },
279
280
  disabled: { type: Boolean, default: !1 },
280
281
  showClear: { type: Boolean, default: !0 },
281
282
  hasContent: { type: Boolean, default: !1 },
283
+ buttonGroup: {},
282
284
  allowSpeech: { type: Boolean, default: !1 },
283
285
  speechStatus: { default: () => ({
284
286
  isRecording: !1,
@@ -290,97 +292,134 @@ const bt = { class: "action-buttons" }, Ct = { class: "action-buttons__button" }
290
292
  isOverLimit: { type: Boolean, default: !1 },
291
293
  stopText: { default: void 0 }
292
294
  },
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);
295
+ 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);
301
320
  }
302
- }, g = () => {
303
- p.value || c("submit");
304
- }, I = () => {
305
- n.value || c("cancel");
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");
306
330
  };
307
- return (d, L) => (m(), R("div", bt, [
308
- C.value ? (m(), R("div", {
331
+ return (v, H) => (S(), O("div", Tt, [
332
+ k.value ? (S(), O("div", {
309
333
  key: 0,
310
334
  class: "action-buttons__utility",
311
- style: De({ "padding-right": d.hasContent || d.loading ? "0" : "6px" })
335
+ style: Fe({ "padding-right": v.hasContent || v.loading ? "0" : "6px" })
312
336
  }, [
313
- d.allowFiles && !d.loading ? (m(), X(k(Me), {
337
+ v.allowFiles && !v.loading ? (S(), X(b(Be), {
314
338
  key: 0,
315
- content: "上传文件",
316
- placement: "top"
339
+ effect: "light",
340
+ placement: "top",
341
+ "render-content": y.value,
342
+ "visible-arrow": !1
317
343
  }, {
318
- default: pe(() => [
319
- A("div", Ct, [
320
- j(k(ut), {
321
- class: "action-buttons__icon",
344
+ default: ce(() => [
345
+ N("div", {
346
+ class: "action-buttons__button",
347
+ onClick: B
348
+ }, [
349
+ z(b(gt), {
350
+ class: Y(["action-buttons__icon", "action-buttons__icon--upload", { "is-disabled": M.value }]),
322
351
  alt: "上传文件"
323
- })
352
+ }, null, 8, ["class"])
324
353
  ])
325
354
  ]),
326
355
  _: 1
327
- })) : K("", !0),
328
- y.value && !d.loading ? (m(), R("div", {
356
+ }, 8, ["render-content"])) : A("", !0),
357
+ a.value && !v.loading ? (S(), O("div", {
329
358
  key: 1,
330
- class: ee(["action-buttons__button", { "is-recording": w.value }]),
331
- onClick: _
359
+ class: Y(["action-buttons__button", { "is-recording": h.value }]),
360
+ onClick: T
332
361
  }, [
333
- w.value ? (m(), X(k(dt), {
362
+ h.value ? (S(), X(b(yt), {
334
363
  key: 1,
335
364
  class: "action-buttons__icon action-buttons__icon--recording",
336
365
  alt: "语音中"
337
- })) : (m(), X(k(ct), {
366
+ })) : (S(), X(b(vt), {
338
367
  key: 0,
339
368
  class: "action-buttons__icon",
340
369
  alt: "录音"
341
370
  }))
342
- ], 2)) : K("", !0),
343
- d.showClear ? (m(), X(k(Me), {
371
+ ], 2)) : A("", !0),
372
+ v.showClear ? (S(), X(b(Be), {
344
373
  key: 2,
345
374
  content: "清空内容",
346
375
  placement: "top"
347
376
  }, {
348
- default: pe(() => [
349
- A("div", {
377
+ default: ce(() => [
378
+ N("div", {
350
379
  class: "action-buttons__button",
351
- onClick: h
380
+ onClick: g
352
381
  }, [
353
- j(k(ft), { class: "action-buttons__icon action-buttons__icon--clear" })
382
+ z(b(mt), { class: "action-buttons__icon action-buttons__icon--clear" })
354
383
  ])
355
384
  ]),
356
385
  _: 1
357
- })) : K("", !0)
358
- ], 4)) : K("", !0),
359
- d.hasContent || d.loading ? (m(), R("div", {
386
+ })) : A("", !0)
387
+ ], 4)) : A("", !0),
388
+ v.hasContent || v.loading ? (S(), O("div", {
360
389
  key: 1,
361
390
  class: "action-buttons__button action-buttons__submit",
362
- onClick: L[0] || (L[0] = (U) => d.loading ? I() : g())
391
+ onClick: H[0] || (H[0] = (f) => v.loading ? L() : m())
363
392
  }, [
364
- A("div", kt, [
365
- d.loading ? (m(), R("div", {
393
+ N("div", Ot, [
394
+ v.loading ? (S(), O("div", {
366
395
  key: 1,
367
- class: ee(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !d.stopText }])
396
+ class: Y(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !v.stopText }])
368
397
  }, [
369
- j(k(ht), {
398
+ z(b(wt), {
370
399
  class: "action-buttons__icon action-buttons__icon--cancel",
371
400
  alt: "停止"
372
401
  }),
373
- d.stopText ? (m(), R("span", xt, le(d.stopText), 1)) : K("", !0)
374
- ], 2)) : (m(), X(k(pt), {
402
+ v.stopText ? (S(), O("span", $t, le(v.stopText), 1)) : A("", !0)
403
+ ], 2)) : (S(), X(b(Be), {
375
404
  key: 0,
376
- class: ee(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": p.value }]),
377
- alt: "发送"
378
- }, null, 8, ["class"]))
405
+ effect: "light",
406
+ placement: "top",
407
+ "render-content": w.value,
408
+ "visible-arrow": !1
409
+ }, {
410
+ default: ce(() => [
411
+ z(b(St), {
412
+ class: Y(["action-buttons__icon", "action-buttons__icon--send", { "is-disabled": p.value }]),
413
+ alt: "发送"
414
+ }, null, 8, ["class"])
415
+ ]),
416
+ _: 1
417
+ }, 8, ["render-content"]))
379
418
  ])
380
- ])) : K("", !0)
419
+ ])) : A("", !0)
381
420
  ]));
382
421
  }
383
- }), qe = /* @__PURE__ */ be(It, [["__scopeId", "data-v-f811794c"]]), Rt = ["data-id", "data-type"], Ot = ["data-id", "data-type"], Tt = /* @__PURE__ */ ge({
422
+ }), je = /* @__PURE__ */ be(Bt, [["__scopeId", "data-v-2b573a4e"]]), Lt = ["data-id", "data-type"], Et = ["data-id", "data-type"], Dt = /* @__PURE__ */ ge({
384
423
  inheritAttrs: !1,
385
424
  __name: "Block",
386
425
  props: {
@@ -391,60 +430,60 @@ const bt = { class: "action-buttons" }, Ct = { class: "action-buttons__button" }
391
430
  asChild: { type: Boolean }
392
431
  },
393
432
  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({
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({
398
437
  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({
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({
442
+ key: `${a.id}-${a.type}`
443
+ }, { ref_for: !0 }, a), null, 16))), 128)) : (S(), O("span", pe({
405
444
  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))
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({
449
+ key: `${a.id}-${a.type}`
450
+ }, { ref_for: !0 }, a), null, 16))), 128))
451
+ ], 16, Et))
413
452
  ], 64));
414
453
  };
415
454
  }
416
- }), $t = /* @__PURE__ */ be(Tt, [["__scopeId", "data-v-13862606"]]);
417
- function Lt(i, r = {}) {
418
- let a = [], c = [], y = i;
419
- return { commit: (_) => {
455
+ }), Ft = /* @__PURE__ */ be(Dt, [["__scopeId", "data-v-13862606"]]);
456
+ function Ht(i, u = {}) {
457
+ let s = [], r = [], y = i;
458
+ return { commit: (k) => {
420
459
  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 = [];
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 = [];
425
464
  }, get: () => y };
426
465
  }
427
- const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PURE__ */ ge({
466
+ const Kt = { class: "editor-container" }, Le = "​", Ee = "​", Pt = /* @__PURE__ */ ge({
428
467
  __name: "TemplateEditor",
429
468
  props: {
430
469
  modelValue: { default: () => [] },
431
470
  modelModifiers: {}
432
471
  },
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";
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";
436
475
  function w() {
437
476
  const e = navigator.userAgent;
438
477
  return e.includes("Safari") && !e.includes("Chrome") && !e.includes("Chromium") && !e.includes("CriOS");
439
478
  }
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) => ({
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) => ({
441
480
  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" ? [
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" ? [
444
483
  { id: e.id, type: "prefix", content: e.prefix },
445
484
  { id: e.id, type: "template", content: e.content },
446
485
  { id: e.id, type: "suffix", content: e.suffix }
447
- ] : [e]).flat()), U = D(() => d.value.map((e) => e.type === "text" ? e : n ? {
486
+ ] : [e]).flat()), M = E(() => m.value.map((e) => e.type === "text" ? e : a ? {
448
487
  id: e.id,
449
488
  type: "block",
450
489
  asChild: !0,
@@ -474,86 +513,86 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
474
513
  },
475
514
  { id: e.id, type: "suffix", content: e.suffix }
476
515
  ]
477
- })), $ = E(null), z = (e) => {
516
+ })), B = F(null), v = (e) => {
478
517
  const t = Date.now(), o = JSON.stringify(e);
479
518
  return `${t}:${o}`;
480
- }, te = (e) => {
519
+ }, H = (e) => {
481
520
  const t = parseInt(e.slice(0, 13)), o = JSON.parse(e.slice(14));
482
521
  return {
483
522
  timestamp: t,
484
523
  data: o
485
524
  };
486
- }, v = /* @__PURE__ */ new Map(), F = Lt(z(d.value), {
525
+ }, f = /* @__PURE__ */ new Map(), K = Ht(v(m.value), {
487
526
  onRemoveHistory: (e) => {
488
527
  for (const t of e)
489
- v.delete(t);
528
+ f.delete(t);
490
529
  }
491
530
  });
492
- Z(
493
- () => C.value,
531
+ Q(
532
+ () => _.value,
494
533
  (e) => {
495
- d.value = g(e || []), F.commit(z(d.value));
534
+ m.value = g(e || []), K.commit(v(m.value));
496
535
  },
497
536
  { deep: !0 }
498
537
  );
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) => {
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) => {
500
539
  const t = window.getSelection();
501
540
  if (!t)
502
541
  return null;
503
- const o = t.rangeCount > 0 ? t.getRangeAt(0) : null, u = e.getRootNode();
504
- if (!(u instanceof ShadowRoot))
542
+ const o = t.rangeCount > 0 ? t.getRangeAt(0) : null, c = e.getRootNode();
543
+ if (!(c instanceof ShadowRoot))
505
544
  return o;
506
545
  if (y) {
507
- const l = t.getComposedRanges(n ? u : { shadowRoots: [u] });
546
+ const l = t.getComposedRanges(a ? c : { shadowRoots: [c] });
508
547
  return (l == null ? void 0 : l[0]) ?? null;
509
548
  }
510
- if (c) {
511
- const l = u.getSelection();
549
+ if (r) {
550
+ const l = c.getSelection();
512
551
  return l.rangeCount > 0 ? l.getRangeAt(0) : null;
513
552
  }
514
553
  return o;
515
- }, de = (e, t) => {
516
- var u;
554
+ }, fe = (e, t) => {
555
+ var c;
517
556
  if (!e.firstChild || e.firstChild.nodeType !== Node.TEXT_NODE)
518
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 };
519
- const o = ((u = e.firstChild.textContent) == null ? void 0 : u.length) ?? 0;
558
+ const o = ((c = e.firstChild.textContent) == null ? void 0 : c.length) ?? 0;
520
559
  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) => {
560
+ }, ee = (e, t, o, c) => {
522
561
  const l = window.getSelection();
523
562
  if (!l)
524
563
  return;
525
- const { node: f, offset: b } = de(e, t);
564
+ const { node: d, offset: x } = fe(e, t);
526
565
  if (!o) {
527
- l.setBaseAndExtent(f, b, f, b);
566
+ l.setBaseAndExtent(d, x, d, x);
528
567
  return;
529
568
  }
530
- const { node: S, offset: O } = de(o, u ?? 0);
531
- l.setBaseAndExtent(f, b, S, O);
569
+ const { node: C, offset: $ } = fe(o, c ?? 0);
570
+ l.setBaseAndExtent(d, x, C, $);
532
571
  }, J = (e, t) => {
533
- const o = p(), u = { id: o, type: "text", content: e };
572
+ const o = h(), c = { id: o, type: "text", content: e };
534
573
  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}`);
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}`);
537
576
  } else
538
- d.value.unshift(u);
539
- q(() => {
540
- 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({
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({
545
584
  hasStarted: !1,
546
585
  range: null
547
- }), N = (e) => {
548
- var S;
586
+ }), U = (e) => {
587
+ var C;
549
588
  const t = e;
550
589
  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];
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];
552
591
  if (!l) {
553
592
  console.warn("range is null", l);
554
593
  return;
555
594
  }
556
- const f = [
595
+ const d = [
557
596
  "insertText",
558
597
  "insertFromPaste",
559
598
  "insertReplacementText",
@@ -564,17 +603,17 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
564
603
  "deleteSoftLineBackward",
565
604
  "deleteSoftLineForward",
566
605
  "deleteByCut"
567
- ], b = G($.value);
568
- if (f.includes(o)) {
569
- if (u && W(l.startContainer) && W(l.endContainer)) {
570
- J(u), b && v.set(F.get(), M(b));
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));
571
610
  return;
572
611
  }
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);
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);
578
617
  return {
579
618
  collapsed: e.collapsed,
580
619
  endContainer: e.endContainer,
@@ -586,137 +625,137 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
586
625
  startOffset: e.startOffset,
587
626
  startType: t == null ? void 0 : t.dataset.type
588
627
  };
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)
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)
592
631
  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);
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);
597
636
  return;
598
637
  }
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);
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", $);
603
642
  }
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);
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);
608
647
  }, 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);
613
- if (f)
614
- Q(f, o.startOffset + t.length);
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
654
  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);
655
+ for (const $ of l) {
656
+ const W = (C = B.value) == null ? void 0 : C.querySelector($);
657
+ if (W) {
658
+ ee(W, 0);
620
659
  break;
621
660
  }
622
661
  }
623
662
  else
624
- console.warn(`can not find el with selector: ${u}`);
663
+ console.warn(`can not find el with selector: ${c}`);
625
664
  });
626
665
  }, 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);
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);
628
667
  if (t === -1 || o === -1 || t > o)
629
668
  return console.warn("startIndex or endIndex is -1, or startIndex > endIndex. ", { range: e }), null;
630
- const u = L.value[t], l = L.value[o];
669
+ const c = L.value[t], l = L.value[o];
631
670
  if (t === o)
632
671
  return [
633
672
  {
634
- id: u.id,
635
- type: u.type,
673
+ id: c.id,
674
+ type: c.type,
636
675
  startOffset: e.startOffset,
637
676
  endOffset: e.endOffset
638
677
  }
639
678
  ];
640
- const f = [
679
+ const d = [
641
680
  {
642
- id: u.id,
643
- type: u.type,
681
+ id: c.id,
682
+ type: c.type,
644
683
  startOffset: e.startOffset,
645
- endOffset: u.content.length
684
+ endOffset: c.content.length
646
685
  }
647
686
  ];
648
- for (let b = t + 1; b < o; b++) {
649
- const S = L.value[b];
650
- f.push({
651
- id: S.id,
652
- type: S.type,
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,
653
692
  startOffset: 0,
654
- endOffset: S.content.length
693
+ endOffset: C.content.length
655
694
  });
656
695
  }
657
- return f.push({
696
+ return d.push({
658
697
  id: l.id,
659
698
  type: l.type,
660
699
  startOffset: 0,
661
700
  endOffset: e.endOffset
662
- }), f;
663
- }, ke = (e, t, o, u) => {
701
+ }), d;
702
+ }, ke = (e, t, o, c) => {
664
703
  const l = e[0];
665
704
  if (l.type !== "prefix" && l.type !== "suffix")
666
705
  return e;
667
706
  if (e.length === 1) {
668
707
  if (t.collapsed)
669
708
  if (t.startOffset === 0) {
670
- const f = ie(l, u);
671
- return f ? [f] : [];
709
+ const d = ie(l, c);
710
+ return d ? [d] : [];
672
711
  } else {
673
- const f = re(l, u);
674
- return f ? [f] : [];
712
+ const d = re(l, c);
713
+ return d ? [d] : [];
675
714
  }
676
715
  if (o.startsWith("insert"))
677
- if (n) {
678
- const f = ie(l, u);
679
- return f ? [f] : [];
716
+ if (a) {
717
+ const d = ie(l, c);
718
+ return d ? [d] : [];
680
719
  } else {
681
- const f = re(l, u);
682
- return f ? [f] : [];
720
+ const d = re(l, c);
721
+ return d ? [d] : [];
683
722
  }
684
723
  if (o.startsWith("delete")) {
685
724
  if (o.includes("Backward")) {
686
- const f = ie(l, u, 1);
687
- return f ? [f] : [];
725
+ const d = ie(l, c, 1);
726
+ return d ? [d] : [];
688
727
  } else if (o.includes("Forward")) {
689
- const f = re(l, u, 1);
690
- return f ? [f] : [];
728
+ const d = re(l, c, 1);
729
+ return d ? [d] : [];
691
730
  }
692
731
  }
693
732
  }
694
- return u.length > 0 ? e.slice(1) : e;
733
+ return c.length > 0 ? e.slice(1) : e;
695
734
  }, 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")
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")
700
739
  return {
701
- id: f,
702
- type: b,
703
- startOffset: S.length - o,
704
- endOffset: S.length
740
+ id: d,
741
+ type: x,
742
+ startOffset: C.length - o,
743
+ endOffset: C.length
705
744
  };
706
745
  if (t.length > 0)
707
- return { tag: "new", afterId: f, type: "text", content: t };
746
+ return { tag: "new", afterId: d, type: "text", content: t };
708
747
  if (console.warn("the previous item is not text or template", { current: e, previous: l }), o === 1)
709
748
  return { ...e, endOffset: e.startOffset };
710
749
  } else return t.length > 0 ? { tag: "new", type: "text", content: t } : (console.warn("the previous item of current is not found", { current: e }), null);
711
750
  return e;
712
751
  }, 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")
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")
717
756
  return {
718
- id: f,
719
- type: b,
757
+ id: d,
758
+ type: x,
720
759
  startOffset: 0,
721
760
  endOffset: 0 + o
722
761
  };
@@ -727,76 +766,76 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
727
766
  } 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);
728
767
  return e;
729
768
  }, xe = () => {
730
- x.value = { hasStarted: !0, range: null };
769
+ R.value = { hasStarted: !0, range: null };
731
770
  }, 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 };
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 };
734
773
  }, ue = (() => {
735
774
  const e = navigator.userAgent.toLowerCase();
736
775
  return /macintosh|mac os x|iphone|ipad|ipod/.test(e);
737
776
  })(), Ie = (e) => {
738
777
  const t = ue && e.metaKey && !e.shiftKey && e.key.toLowerCase() === "z" || // Cmd+Z
739
778
  !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";
779
+ !ue && e.ctrlKey && (e.key.toLowerCase() === "y" || e.shiftKey && e.key.toLowerCase() === "z"), c = e.key.toLowerCase() === "enter";
741
780
  if (t) {
742
781
  e.preventDefault();
743
- const l = G($.value);
744
- l && v.set(F.get(), M(l));
745
- const f = F.undo();
746
- f && oe(f);
782
+ const l = Z(B.value);
783
+ l && f.set(K.get(), j(l));
784
+ const d = K.undo();
785
+ d && oe(d);
747
786
  }
748
787
  if (o) {
749
788
  e.preventDefault();
750
- const l = F.redo();
789
+ const l = K.redo();
751
790
  l && oe(l);
752
791
  }
753
- u && (e.preventDefault(), h("submit"));
792
+ c && (e.preventDefault(), p("submit"));
754
793
  }, 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);
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);
761
800
  });
762
801
  }
763
802
  };
764
- return r({
803
+ return u({
765
804
  clearHistory: () => {
766
- F.clear(), v.clear();
805
+ K.clear(), f.clear();
767
806
  },
768
807
  activateFirstField: () => {
769
- if (!$.value)
808
+ if (!B.value)
770
809
  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"]`);
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"]`);
775
814
  if (t) {
776
- const l = ((u = t.textContent) == null ? void 0 : u.length) || 0;
777
- Q(t, l);
815
+ const l = ((c = t.textContent) == null ? void 0 : c.length) || 0;
816
+ ee(t, l);
778
817
  }
779
818
  });
780
819
  }
781
- }), (e, t) => (m(), R("div", Bt, [
782
- (m(), R("div", {
820
+ }), (e, t) => (S(), O("div", Kt, [
821
+ (S(), O("div", {
783
822
  contenteditable: "true",
784
823
  ref_key: "editorRef",
785
- ref: $,
786
- key: _.value,
824
+ ref: B,
825
+ key: k.value,
787
826
  class: "editor",
788
- onBeforeinput: N,
827
+ onBeforeinput: U,
789
828
  onCompositionstart: xe,
790
829
  onCompositionend: ve,
791
830
  onKeydown: Ie
792
831
  }, [
793
- (m(!0), R(ce, null, he(U.value, (o) => (m(), X($t, fe({
832
+ (S(!0), O(de, null, he(M.value, (o) => (S(), X(Ft, pe({
794
833
  key: `${o.id}-${o.type}`
795
834
  }, { ref_for: !0 }, o), null, 16))), 128))
796
835
  ], 32))
797
836
  ]));
798
837
  }
799
- }), Dt = /* @__PURE__ */ be(Et, [["__scopeId", "data-v-b0269a2a"]]), Ft = ["onMouseenter", "onMousedown"], Pt = { class: "suggestion-list__text" }, Ht = /* @__PURE__ */ ge({
838
+ }), Wt = /* @__PURE__ */ be(Pt, [["__scopeId", "data-v-b0269a2a"]]), At = ["onMouseenter", "onMousedown"], Vt = { class: "suggestion-list__text" }, Nt = /* @__PURE__ */ ge({
800
839
  __name: "SuggestionList",
801
840
  props: {
802
841
  show: { type: Boolean },
@@ -807,71 +846,71 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
807
846
  inputValue: {}
808
847
  },
809
848
  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);
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", _);
817
856
  };
818
- return (C, h) => (m(), X(Ee, { name: "tiny-sender-slide-up" }, {
819
- default: pe(() => [
820
- a.show && a.suggestions.length ? (m(), R("div", {
857
+ return (_, p) => (S(), X(De, { name: "tiny-sender-slide-up" }, {
858
+ default: ce(() => [
859
+ s.show && s.suggestions.length ? (S(), O("div", {
821
860
  key: 0,
822
861
  ref_key: "suggestionsListRef",
823
862
  ref: y,
824
863
  class: "suggestion-list",
825
- style: De(a.popupStyle)
864
+ style: Fe(s.popupStyle)
826
865
  }, [
827
- (m(!0), R(ce, null, he(a.suggestions, (_, g) => (m(), R("div", {
866
+ (S(!0), O(de, null, he(s.suggestions, (k, g) => (S(), O("div", {
828
867
  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"])
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"])
833
872
  }, [
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
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
841
880
  })
842
- }, le(I.text), 3))), 128))
881
+ }, le(T.text), 3))), 128))
843
882
  ])
844
- ], 42, Ft))), 128))
845
- ], 4)) : K("", !0)
883
+ ], 42, At))), 128))
884
+ ], 4)) : A("", !0)
846
885
  ]),
847
886
  _: 1
848
887
  }));
849
888
  }
850
- }), Kt = /* @__PURE__ */ be(Ht, [["__scopeId", "data-v-238fcdfd"]]), Wt = ["data-theme"], At = { class: "tiny-sender__container" }, Vt = {
889
+ }), Mt = /* @__PURE__ */ be(Nt, [["__scopeId", "data-v-238fcdfd"]]), qt = ["data-theme"], Ut = { class: "tiny-sender__container" }, jt = {
851
890
  key: 0,
852
891
  class: "tiny-sender__header-slot"
853
- }, Nt = {
892
+ }, zt = {
854
893
  key: 0,
855
894
  class: "tiny-sender__prefix-slot"
856
- }, Mt = { class: "tiny-sender__content-area" }, qt = {
895
+ }, Gt = { class: "tiny-sender__content-area" }, Xt = {
857
896
  key: 0,
858
897
  class: "tiny-sender__decorative-content"
859
- }, Ut = {
898
+ }, Jt = {
860
899
  key: 2,
861
900
  class: "tiny-sender__input-field-wrapper"
862
- }, zt = {
901
+ }, Qt = {
863
902
  key: 0,
864
903
  class: "tiny-sender__completion-placeholder"
865
- }, jt = { class: "user-input-mirror" }, Xt = {
904
+ }, Yt = { class: "user-input-mirror" }, Zt = {
866
905
  key: 0,
867
906
  class: "tiny-sender__tab-hint"
868
- }, Jt = {
907
+ }, en = {
869
908
  key: 1,
870
909
  class: "tiny-sender__actions-slot"
871
- }, Gt = { class: "tiny-sender__footer-left" }, Qt = { class: "tiny-sender__footer-right" }, Yt = { class: "real-word-length" }, Zt = {
910
+ }, tn = { class: "tiny-sender__footer-left" }, nn = { class: "tiny-sender__footer-right" }, sn = { class: "real-word-length" }, on = {
872
911
  key: 1,
873
912
  class: "tiny-sender__toolbar"
874
- }, en = { class: "tiny-sender__buttons-container" }, tn = {
913
+ }, an = { class: "tiny-sender__buttons-container" }, ln = {
875
914
  key: 1,
876
915
  class: "tiny-sender__footer-slot"
877
916
  }, _e = /* @__PURE__ */ ge({
@@ -888,6 +927,7 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
888
927
  modelValue: { default: "" },
889
928
  mode: { default: "single" },
890
929
  maxLength: { default: 1 / 0 },
930
+ buttonGroup: {},
891
931
  submitType: { default: "enter" },
892
932
  speech: { type: [Boolean, Object] },
893
933
  placeholder: { default: "请输入内容..." },
@@ -898,344 +938,354 @@ const Bt = { class: "editor-container" }, Le = "​", Be = "​", Et = /* @__PUR
898
938
  templateData: { default: () => [] },
899
939
  stopText: { default: "" }
900
940
  },
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,
941
+ 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);
947
+ }), {
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,
914
958
  closeSuggestionsPopup: J,
915
- navigateSuggestions: x,
916
- handleSuggestionItemHover: N,
917
- handleSuggestionItemLeave: M,
959
+ navigateSuggestions: R,
960
+ handleSuggestionItemHover: U,
961
+ handleSuggestionItemLeave: j,
918
962
  highlightSuggestionText: ne
919
- } = _t(c, y, g, I, _), P = E(c.mode), se = E(!1), Ce = () => {
920
- P.value === "single" && (P.value = "multiple", q(() => {
963
+ } = Rt(r, y, g, T, k), P = F(r.mode), se = F(!1), Ce = () => {
964
+ P.value === "single" && (P.value = "multiple", G(() => {
921
965
  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);
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);
927
971
  }
928
972
  }, 50);
929
973
  }));
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;
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;
935
979
  }, 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) {
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) {
942
986
  console.warn("Cannot find input element for overflow check");
943
987
  return;
944
988
  }
945
- const me = T.getBoundingClientRect(), $e = B == null ? void 0 : B.getBoundingClientRect();
989
+ const me = I.getBoundingClientRect(), $e = D == null ? void 0 : D.getBoundingClientRect();
946
990
  if (me.width === 0) {
947
991
  setTimeout(() => ie(), 50);
948
992
  return;
949
993
  }
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(() => {
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(() => {
952
996
  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);
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);
959
1003
  }
960
1004
  se.value = !1;
961
1005
  }, 300) : se.value = !1;
962
1006
  }));
963
1007
  }, re = () => {
964
- if (_.value && p.value)
965
- Fe();
1008
+ if (k.value && h.value)
1009
+ He();
966
1010
  else if (w.value)
967
1011
  w.value.focus();
968
1012
  else {
969
- const s = document.querySelector(".tiny-input__inner");
970
- s == null || s.focus();
1013
+ const n = document.querySelector(".tiny-input__inner");
1014
+ n == null || n.focus();
971
1015
  }
972
1016
  }, xe = () => {
973
1017
  if (w.value)
974
1018
  w.value.blur();
975
1019
  else {
976
- const s = document.querySelector(".tiny-input__inner");
977
- s == null || s.blur();
1020
+ const n = document.querySelector(".tiny-input__inner");
1021
+ n == null || n.blur();
978
1022
  }
979
1023
  }, ve = () => {
980
- var s;
981
- y("update:templateData", []), (s = p.value) == null || s.clearHistory(), q(() => {
982
- g.value === "" && (P.value = c.mode || "single"), setTimeout(() => {
1024
+ var n;
1025
+ y("update:templateData", []), (n = h.value) == null || n.clearHistory(), G(() => {
1026
+ g.value === "" && (P.value = r.mode || "single"), setTimeout(() => {
983
1027
  re();
984
1028
  }, 50);
985
1029
  }), J();
986
1030
  }, ye = () => {
987
- var s;
988
- d(), _.value ? ve() : (s = n.value) == null || s.focus(), q(() => {
989
- g.value === "" && (P.value = c.mode || "single");
1031
+ var n;
1032
+ m(), k.value ? ve() : (n = a.value) == null || n.focus(), G(() => {
1033
+ g.value === "" && (P.value = r.mode || "single");
990
1034
  }), J();
991
- }, ue = (s) => {
992
- y("update:templateData", s);
1035
+ }, ue = (n) => {
1036
+ y("update:templateData", n);
993
1037
  };
994
- Z(
995
- () => c.templateData,
1038
+ Q(
1039
+ () => r.templateData,
996
1040
  () => {
997
- g.value = c.templateData.map((s) => s.content).join("");
1041
+ g.value = r.templateData.map((n) => n.content).join("");
998
1042
  },
999
1043
  { deep: !0 }
1000
1044
  );
1001
- const Ie = D(() => {
1002
- const s = typeof c.speech == "object" ? c.speech : {};
1045
+ const Ie = E(() => {
1046
+ const n = typeof r.speech == "object" ? r.speech : {};
1003
1047
  return {
1004
- ...s,
1048
+ ...n,
1005
1049
  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;
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;
1011
1055
  else {
1012
- const B = g.value;
1013
- B && T && !B.endsWith(" ") && !T.startsWith(" ") && B.length > 0 ? g.value = B + " " + T : g.value = B + T;
1056
+ const D = g.value;
1057
+ D && I && !D.endsWith(" ") && !I.startsWith(" ") && D.length > 0 ? g.value = D + " " + I : g.value = D + I;
1014
1058
  }
1015
- y("speech-end", T);
1059
+ y("speech-end", I);
1016
1060
  },
1017
- onError: (T) => {
1018
- y("speech-error", T);
1061
+ onError: (I) => {
1062
+ y("speech-error", I);
1019
1063
  }
1020
1064
  };
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,
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,
1025
1069
  y,
1026
1070
  g,
1027
- I,
1071
+ T,
1028
1072
  oe,
1029
- $,
1030
- V,
1031
- Q,
1073
+ B,
1074
+ q,
1075
+ ee,
1032
1076
  J,
1033
- x,
1077
+ R,
1034
1078
  e,
1035
- U,
1079
+ M,
1036
1080
  P,
1037
1081
  Ce,
1038
- _,
1082
+ k,
1039
1083
  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(
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(
1045
1089
  () => ({
1046
1090
  display: "flex",
1047
- justifyContent: c.showWordLimit && c.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1091
+ justifyContent: r.showWordLimit && r.maxLength !== 1 / 0 ? "space-between" : "flex-end",
1048
1092
  alignItems: "center"
1049
1093
  })
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,
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,
1053
1097
  "is-auto-switching": se.value
1054
- })), ze = D(() => ({
1055
- width: vt(c.suggestionPopupWidth),
1098
+ })), Ge = E(() => ({
1099
+ width: bt(r.suggestionPopupWidth),
1056
1100
  maxWidth: "100%"
1057
1101
  // 确保不超出父容器宽度
1058
- })), je = () => {
1059
- I.value = !1, setTimeout(() => {
1060
- I.value = !1, G();
1102
+ })), Xe = () => {
1103
+ T.value = !1, setTimeout(() => {
1104
+ T.value = !1, Z();
1061
1105
  }, 50);
1062
1106
  };
1063
- Z(g, () => {
1064
- q(ie), g.value === "" && c.mode === "single" && (P.value = "single");
1065
- }), Z(
1066
- () => _.value,
1067
- (s) => {
1068
- s && (P.value = "multiple");
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");
1069
1113
  }
1070
1114
  );
1071
- const Fe = () => {
1072
- p.value && p.value.activateFirstField();
1073
- };
1074
- return r({
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({
1075
1121
  focus: re,
1076
1122
  blur: xe,
1077
1123
  clear: ye,
1078
- submit: u,
1124
+ submit: c,
1079
1125
  startSpeech: Re,
1080
- stopSpeech: Oe,
1081
- activateTemplateFirstField: Fe
1082
- }), (s, T) => (m(), R("div", {
1126
+ stopSpeech: Te,
1127
+ activateTemplateFirstField: He
1128
+ }), (n, I) => (S(), O("div", {
1083
1129
  ref_key: "senderRef",
1084
- ref: n,
1085
- class: ee(["tiny-sender", [Ue.value, `theme-${s.theme}`, `mode-${P.value}`]]),
1086
- "data-theme": s.theme
1130
+ ref: a,
1131
+ class: Y(["tiny-sender", [ze.value, `theme-${n.theme}`, `mode-${P.value}`]]),
1132
+ "data-theme": n.theme
1087
1133
  }, [
1088
- A("div", At, [
1089
- A("div", {
1134
+ N("div", Ut, [
1135
+ N("div", {
1090
1136
  class: "tiny-sender__input-wrapper",
1091
1137
  ref_key: "inputWrapperRef",
1092
- ref: C
1138
+ ref: _
1093
1139
  }, [
1094
- j(Ee, { name: "tiny-sender-slide-down" }, {
1095
- default: pe(() => [
1096
- s.$slots.header ? (m(), R("div", Vt, [
1097
- ae(s.$slots, "header")
1098
- ])) : K("", !0)
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)
1099
1145
  ]),
1100
1146
  _: 3
1101
1147
  }),
1102
- A("div", {
1103
- class: ee(["tiny-sender__input-row", { "has-prefix": s.$slots.prefix, "has-header": s.$slots.header }])
1148
+ N("div", {
1149
+ class: Y(["tiny-sender__input-row", { "has-prefix": n.$slots.prefix, "has-header": n.$slots.header }])
1104
1150
  }, [
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, {
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, {
1113
1159
  key: 1,
1114
1160
  ref_key: "templateEditorRef",
1115
- ref: p,
1116
- "model-value": c.templateData,
1161
+ ref: h,
1162
+ "model-value": r.templateData,
1117
1163
  "onUpdate:modelValue": ue,
1118
- onSubmit: k(u)
1119
- }, null, 8, ["model-value", "onSubmit"])) : (m(), R("div", Ut, [
1120
- j(k(rt), {
1164
+ onSubmit: b(c)
1165
+ }, null, 8, ["model-value", "onSubmit"])) : (S(), O("div", Jt, [
1166
+ z(b(pt), {
1121
1167
  ref_key: "inputRef",
1122
1168
  ref: w,
1123
- autosize: s.autoSize,
1124
- type: b.value,
1169
+ autosize: n.autoSize,
1170
+ type: x.value,
1125
1171
  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,
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,
1134
1180
  onFocus: l,
1135
- onBlur: f
1181
+ onBlur: d
1136
1182
  }, 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)
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)
1142
1188
  ]))
1143
1189
  ]),
1144
- P.value === "single" ? (m(), R("div", Jt, [
1145
- A("div", {
1190
+ P.value === "single" ? (S(), O("div", en, [
1191
+ N("div", {
1146
1192
  class: "tiny-sender__buttons-container",
1147
1193
  ref_key: "buttonsContainerRef",
1148
- ref: h
1194
+ ref: p
1149
1195
  }, [
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,
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,
1157
1203
  "has-content": L.value,
1158
- "speech-status": k(oe),
1159
- "submit-type": s.submitType,
1204
+ "speech-status": b(oe),
1205
+ "button-group": n.buttonGroup,
1206
+ "submit-type": n.submitType,
1160
1207
  "is-over-limit": t.value,
1161
- "stop-text": s.stopText,
1208
+ "stop-text": n.stopText,
1162
1209
  onClear: ye,
1163
1210
  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"])
1211
+ onSubmit: b(c),
1212
+ onCancel: I[2] || (I[2] = (D) => n.$emit("cancel")),
1213
+ onTriggerSelect: b(Ke)
1214
+ }, 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
1215
  ], 512)
1168
- ])) : K("", !0)
1216
+ ])) : A("", !0)
1169
1217
  ], 2),
1170
- j(Ee, { name: "tiny-sender-slide-up" }, {
1171
- default: pe(() => [
1172
- P.value === "multiple" ? (m(), R("div", {
1218
+ z(De, { name: "tiny-sender-slide-up" }, {
1219
+ default: ce(() => [
1220
+ P.value === "multiple" ? (S(), O("div", {
1173
1221
  key: 0,
1174
- style: De(S.value),
1222
+ style: Fe(C.value),
1175
1223
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
1176
1224
  }, [
1177
- A("div", Gt, [
1178
- ae(s.$slots, "footer-left")
1225
+ N("div", tn, [
1226
+ ae(n.$slots, "footer-left")
1179
1227
  ]),
1180
- A("div", Qt, [
1181
- ae(s.$slots, "footer-right"),
1182
- s.showWordLimit && s.maxLength !== 1 / 0 ? (m(), R("div", {
1228
+ N("div", nn, [
1229
+ ae(n.$slots, "footer-right"),
1230
+ n.showWordLimit && n.maxLength !== 1 / 0 ? (S(), O("div", {
1183
1231
  key: 0,
1184
- class: ee(["tiny-sender__word-limit", { "is-over-limit": t.value }])
1232
+ class: Y(["tiny-sender__word-limit", { "is-over-limit": t.value }])
1185
1233
  }, [
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,
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,
1197
1245
  "has-content": L.value,
1198
- "speech-status": k(oe),
1199
- "submit-type": s.submitType,
1246
+ "speech-status": b(oe),
1247
+ "button-group": n.buttonGroup,
1248
+ "submit-type": n.submitType,
1200
1249
  "is-over-limit": t.value,
1201
- "stop-text": s.stopText,
1250
+ "stop-text": n.stopText,
1202
1251
  onClear: ye,
1203
1252
  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"])
1253
+ onSubmit: b(c),
1254
+ onCancel: I[3] || (I[3] = (D) => n.$emit("cancel")),
1255
+ onTriggerSelect: b(Ke)
1256
+ }, 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
1257
  ])
1208
- ])) : K("", !0)
1258
+ ])) : A("", !0)
1209
1259
  ])
1210
- ], 4)) : s.$slots.footer ? (m(), R("div", tn, [
1211
- ae(s.$slots, "footer")
1212
- ])) : K("", !0)
1260
+ ], 4)) : n.$slots.footer ? (S(), O("div", ln, [
1261
+ ae(n.$slots, "footer")
1262
+ ])) : A("", !0)
1213
1263
  ]),
1214
1264
  _: 3
1215
1265
  })
1216
1266
  ], 512)
1217
1267
  ]),
1218
- j(Kt, {
1268
+ z(Mt, {
1219
1269
  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)
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)
1230
1280
  }, null, 8, ["show", "suggestions", "popup-style", "is-item-highlighted", "highlight-suggestion-text", "input-value", "onItemHover", "onItemLeave", "onSelect"])
1231
- ], 10, Wt));
1281
+ ], 10, qt));
1232
1282
  }
1233
1283
  });
1234
1284
  _e.name = "TrSender";
1235
- const nn = function(i) {
1285
+ const rn = function(i) {
1236
1286
  i.component(_e.name, _e);
1237
1287
  };
1238
- _e.install = nn;
1288
+ _e.install = rn;
1239
1289
  export {
1240
1290
  _e as default
1241
1291
  };