@opentiny/tiny-robot 0.2.12 → 0.2.14

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