@opentiny/tiny-robot 0.2.0-alpha.4 → 0.2.0-alpha.5

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,157 +1,322 @@
1
- import { ref as b, watch as q, reactive as L0, defineComponent as c0, computed as S, resolveComponent as _0, createElementBlock as C, openBlock as d, createBlock as V, createCommentVNode as R, withCtx as $, createVNode as W, unref as F, createElementVNode as B, normalizeClass as z, resolveDynamicComponent as b0, nextTick as A, onMounted as k0, Fragment as r0, renderList as v0, toDisplayString as U, withModifiers as S0, useSlots as x0, Transition as a0, renderSlot as P, isRef as F0, normalizeStyle as D0, createTextVNode as E0 } from "vue";
2
- import { I as R0 } from "../index5.js";
3
- import { B as n0 } from "../index3.js";
4
- import { i as B0 } from "../close.js";
5
- import { _ as I0 } from "../_plugin-vue_export-helper.js";
6
- function $0(n, h) {
7
- const c = b(n.modelValue || n.defaultValue || ""), i = b(null);
8
- q(
1
+ import { ref as x, watch as G, reactive as Se, computed as L, nextTick as P, defineComponent as ce, createElementBlock as D, openBlock as N, createCommentVNode as B, createBlock as H, unref as _, withCtx as j, createVNode as K, normalizeClass as Q, resolveDynamicComponent as Me, createElementVNode as M, onMounted as $e, useSlots as Ae, Transition as re, renderSlot as X, isRef as We, createTextVNode as be, toDisplayString as J, normalizeStyle as Ke, Fragment as we, renderList as _e, withModifiers as Pe } from "vue";
2
+ import { I as He } from "../index6.js";
3
+ import { B as ne } from "../index5.js";
4
+ import { T as ue } from "../index4.js";
5
+ import { i as je } from "../close.js";
6
+ import { I as qe, L as ze, u as Ue, w as Xe, P as Ge, _ as Je } from "../tiny-robot-svgs.js";
7
+ function Qe(n, b) {
8
+ const d = x(n.modelValue || n.defaultValue || ""), t = x(null);
9
+ G(
9
10
  () => n.modelValue,
10
- (f) => {
11
- f !== void 0 && f !== c.value && (c.value = f);
11
+ (g) => {
12
+ g !== void 0 && g !== d.value && (d.value = g);
12
13
  }
13
- ), q(
14
- () => c.value,
15
- (f) => {
16
- h("update:modelValue", f);
14
+ ), G(
15
+ () => d.value,
16
+ (g) => {
17
+ b("update:modelValue", g);
17
18
  }
18
19
  );
19
- const m = (f) => {
20
- c.value = f, h("update:modelValue", f);
21
- }, w = (f) => {
22
- f == null || f.preventDefault();
23
- const a = c.value;
24
- !n.disabled && !n.loading && a.trim() && h("submit", a);
25
- }, r = () => {
26
- c.value = "", h("update:modelValue", ""), h("clear");
27
- }, s = b(!1);
20
+ const m = (g) => {
21
+ d.value = g, b("update:modelValue", g);
22
+ }, s = (g) => {
23
+ g == null || g.preventDefault();
24
+ const S = d.value;
25
+ !n.disabled && !n.loading && S.trim() && b("submit", S);
26
+ }, u = () => {
27
+ d.value = "", b("update:modelValue", ""), b("clear");
28
+ }, o = x(!1);
28
29
  return {
29
- inputValue: c,
30
- inputWrapper: i,
31
- isComposing: s,
30
+ inputValue: d,
31
+ inputWrapper: t,
32
+ isComposing: o,
32
33
  handleChange: m,
33
- handleSubmit: w,
34
- handleClear: r,
34
+ handleSubmit: s,
35
+ handleClear: u,
35
36
  clearInput: () => {
36
- r();
37
+ u();
37
38
  }
38
39
  };
39
40
  }
40
- function M0(n, h, c, i, m, w, r, s, k) {
41
- const f = (l) => !n.disabled && !n.loading && l.trim().length > 0, a = () => {
42
- f(c.value) && h("submit", c.value.trim());
43
- }, v = (l, L) => {
44
- if (!(l.key === "Enter")) return !1;
45
- switch (L) {
41
+ function Ye(n, b, d, t, m, s, u, o, e, g, S, a, C) {
42
+ const f = (v) => !n.disabled && !n.loading && v.trim().length > 0, r = () => {
43
+ f(d.value) && b("submit", d.value.trim());
44
+ }, p = (v, A) => {
45
+ if (!(v.key === "Enter")) return !1;
46
+ switch (A) {
46
47
  case "enter":
47
- return !l.shiftKey && !l.ctrlKey && !l.metaKey;
48
+ return !v.shiftKey && !v.ctrlKey && !v.metaKey;
48
49
  case "ctrlEnter":
49
- return (l.ctrlKey || l.metaKey) && !l.shiftKey;
50
+ return (v.ctrlKey || v.metaKey) && !v.shiftKey;
50
51
  case "shiftEnter":
51
- return l.shiftKey && !l.ctrlKey && !l.metaKey;
52
+ return v.shiftKey && !v.ctrlKey && !v.metaKey;
52
53
  default:
53
54
  return !1;
54
55
  }
55
56
  };
56
57
  return {
57
- handleKeyPress: (l) => {
58
- if (i.value) return;
59
- if (l.key === "Enter" && l.shiftKey && (s == null ? void 0 : s.value) === "single" && k) {
60
- l.preventDefault(), k();
61
- const x = l.target, I = x.selectionStart, M = c.value;
62
- c.value = M.substring(0, I) + `
63
- ` + M.substring(I), setTimeout(() => {
64
- x.selectionStart = x.selectionEnd = I + 1;
58
+ handleKeyPress: (v) => {
59
+ if (t.value) return;
60
+ if (v.key === "Enter" && v.shiftKey && (a == null ? void 0 : a.value) === "single" && C) {
61
+ v.preventDefault(), C();
62
+ const k = v.target, V = k.selectionStart, l = d.value;
63
+ d.value = l.substring(0, V) + `
64
+ ` + l.substring(V), setTimeout(() => {
65
+ k.selectionStart = k.selectionEnd = V + 1;
65
66
  }, 0);
66
67
  return;
67
68
  }
68
- if (l.key === "Escape") {
69
- w.value ? (w.value = !1, l.preventDefault()) : m.isRecording && (r(), l.preventDefault()), h("escape-press");
69
+ if (v.key === "Tab" && s.value && u.value) {
70
+ v.preventDefault(), o();
71
+ return;
72
+ }
73
+ if (s.value) {
74
+ if (v.key === "ArrowDown") {
75
+ v.preventDefault(), g("down");
76
+ return;
77
+ }
78
+ if (v.key === "ArrowUp") {
79
+ v.preventDefault(), g("up");
80
+ return;
81
+ }
82
+ if (v.key === "Enter" && u.value) {
83
+ v.preventDefault(), o();
84
+ return;
85
+ }
86
+ }
87
+ if (v.key === "Escape") {
88
+ s.value ? (e(), v.preventDefault()) : m.isRecording && (S(), v.preventDefault()), b("escape-press");
70
89
  return;
71
90
  }
72
- v(l, n.submitType) && f(c.value) && (l.preventDefault(), a());
91
+ p(v, n.submitType) && f(d.value) && (v.preventDefault(), r());
73
92
  },
74
- triggerSubmit: a
93
+ triggerSubmit: r
94
+ };
95
+ }
96
+ function Ze(n) {
97
+ const b = (s, u, o) => {
98
+ var f;
99
+ const { startContainer: e, startOffset: g, collapsed: S } = u;
100
+ if (!S) return !1;
101
+ const a = e.nodeType === Node.TEXT_NODE && g === 0 && s.key === "ArrowLeft", C = e.nodeType === Node.TEXT_NODE && g === (((f = e.textContent) == null ? void 0 : f.length) || 0) && s.key === "ArrowRight";
102
+ if (a || C) {
103
+ let r = null, p = "inside";
104
+ if (a)
105
+ if (e.parentNode && e.parentNode.classList.contains("template-field"))
106
+ r = e.parentNode, p = "before";
107
+ else {
108
+ let T = e.previousSibling;
109
+ !T && e.parentNode && e.parentNode !== o && (T = e.parentNode.previousSibling), T && T.nodeType === Node.ELEMENT_NODE && T.classList.contains("template-field") && (r = T, p = "inside");
110
+ }
111
+ else if (C)
112
+ if (e.parentNode && e.parentNode.classList.contains("template-field"))
113
+ r = e.parentNode, p = "after";
114
+ else {
115
+ let T = e.nextSibling;
116
+ !T && e.parentNode && e.parentNode !== o && (T = e.parentNode.nextSibling), T && T.nodeType === Node.ELEMENT_NODE && T.classList.contains("template-field") && (r = T, p = "inside");
117
+ }
118
+ if (r) {
119
+ s.preventDefault();
120
+ const T = document.createRange(), v = window.getSelection();
121
+ return v && (p === "before" ? T.setStartBefore(r) : p === "after" ? T.setStartAfter(r) : (T.selectNodeContents(r), T.collapse(s.key === "ArrowLeft")), v.removeAllRanges(), v.addRange(T)), !0;
122
+ }
123
+ }
124
+ if (e.nodeType === Node.ELEMENT_NODE && e.classList.contains("template-field") && !e.textContent) {
125
+ s.preventDefault();
126
+ const r = document.createRange(), p = window.getSelection();
127
+ return p && (s.key === "ArrowLeft" ? r.setStartBefore(e) : r.setStartAfter(e), r.collapse(!0), p.removeAllRanges(), p.addRange(r)), !0;
128
+ }
129
+ return !1;
130
+ }, d = (s, u, o) => {
131
+ if (!u.collapsed) return !1;
132
+ const { startContainer: e, startOffset: g } = u;
133
+ if (e.nodeType === Node.TEXT_NODE && e.parentNode && e.parentNode.classList.contains("template-field") && e.textContent && e.textContent.length === 1 && g === 1) {
134
+ s.preventDefault(), e.textContent = "";
135
+ const C = e.parentNode, f = window.getSelection();
136
+ if (f) {
137
+ const r = document.createRange();
138
+ r.selectNodeContents(C), r.collapse(!0), f.removeAllRanges(), f.addRange(r);
139
+ }
140
+ return n.handleInput(), !0;
141
+ }
142
+ if (g === 0) {
143
+ let C = null;
144
+ if (e.nodeType === Node.ELEMENT_NODE && e.classList.contains("template-field") ? C = e : e.nodeType === Node.TEXT_NODE && e.parentNode && e.parentNode.classList.contains("template-field") && (C = e.parentNode), C) {
145
+ s.preventDefault();
146
+ const f = window.getSelection();
147
+ return f && (u.setStartBefore(C), u.collapse(!0), f.removeAllRanges(), f.addRange(u)), !0;
148
+ }
149
+ }
150
+ let a = null;
151
+ return e === o && g > 0 ? a = o.childNodes[g - 1] : e.nodeType === Node.TEXT_NODE && g === 0 && (a = e.previousSibling), a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field") && a.textContent === "" ? (s.preventDefault(), a.parentNode && a.parentNode.removeChild(a), n.handleInput(), !0) : !1;
152
+ }, t = (s, u, o) => {
153
+ var C;
154
+ if (!u.collapsed) return !1;
155
+ const { startContainer: e, startOffset: g } = u;
156
+ if (e.nodeType === Node.TEXT_NODE && e.parentNode && e.parentNode.classList.contains("template-field") && e.textContent && g === e.textContent.length && e.textContent.length === 1) {
157
+ s.preventDefault(), e.textContent = "";
158
+ const f = e.parentNode, r = window.getSelection();
159
+ if (r) {
160
+ const p = document.createRange();
161
+ p.selectNodeContents(f), p.collapse(!0), r.removeAllRanges(), r.addRange(p);
162
+ }
163
+ return n.handleInput(), !0;
164
+ }
165
+ let a = null;
166
+ return e === o && g < o.childNodes.length ? a = o.childNodes[g] : e.nodeType === Node.TEXT_NODE && g === (((C = e.textContent) == null ? void 0 : C.length) || 0) && (a = e.nextSibling), a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field") && a.textContent === "" ? (s.preventDefault(), a.parentNode && a.parentNode.removeChild(a), n.handleInput(), !0) : !1;
167
+ };
168
+ return {
169
+ handleTemplateKeyDown: (s) => {
170
+ if (n.isComposing.value) return;
171
+ const u = n.editor.value;
172
+ if (!u) return;
173
+ const o = window.getSelection();
174
+ if (!o || o.rangeCount === 0) return;
175
+ const e = o.getRangeAt(0);
176
+ if (s.key === "Enter") {
177
+ s.preventDefault(), n.onSubmit(n.getValueFromDOM());
178
+ return;
179
+ }
180
+ (s.key === "ArrowLeft" || s.key === "ArrowRight") && !s.shiftKey && b(s, e, u) || s.key === "Backspace" && d(s, e, u) || s.key === "Delete" && t(s, e, u);
181
+ }
75
182
  };
76
183
  }
77
- function T0(n) {
78
- const h = L0({
184
+ function et(n) {
185
+ const b = Se({
79
186
  isRecording: !1,
80
187
  isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
81
188
  error: void 0
82
- }), c = h.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
83
- c !== void 0 && (c.continuous = n.continuous ?? !1, c.interimResults = n.interimResults ?? !0, c.lang = n.lang ?? navigator.language, c.onstart = () => {
84
- var r;
85
- h.isRecording = !0, h.error = void 0, (r = n.onStart) == null || r.call(n);
86
- }, c.onend = () => {
87
- var r;
88
- h.isRecording = !1, (r = n.onEnd) == null || r.call(n);
89
- }, c.onresult = (r) => {
90
- var k, f;
91
- const s = Array.from(r.results).map((a) => a[0].transcript).join("");
92
- r.results[0].isFinal ? (k = n.onFinal) == null || k.call(n, s) : (f = n.onInterim) == null || f.call(n, s);
93
- }, c.onerror = (r) => {
94
- var s;
95
- h.error = new Error(r.error), h.isRecording = !1, (s = n.onError) == null || s.call(n, h.error);
189
+ }), d = b.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
190
+ d !== void 0 && (d.continuous = n.continuous ?? !1, d.interimResults = n.interimResults ?? !0, d.lang = n.lang ?? navigator.language, d.onstart = () => {
191
+ var u;
192
+ b.isRecording = !0, b.error = void 0, (u = n.onStart) == null || u.call(n);
193
+ }, d.onend = () => {
194
+ var u;
195
+ b.isRecording = !1, (u = n.onEnd) == null || u.call(n);
196
+ }, d.onresult = (u) => {
197
+ var e, g;
198
+ const o = Array.from(u.results).map((S) => S[0].transcript).join("");
199
+ u.results[0].isFinal ? (e = n.onFinal) == null || e.call(n, o) : (g = n.onInterim) == null || g.call(n, o);
200
+ }, d.onerror = (u) => {
201
+ var o;
202
+ b.error = new Error(u.error), b.isRecording = !1, (o = n.onError) == null || o.call(n, b.error);
96
203
  });
97
- const i = () => {
98
- var r;
99
- if (!c) {
100
- const s = new Error("浏览器不支持语音识别");
101
- h.error = s, (r = n.onError) == null || r.call(n, s);
204
+ const t = () => {
205
+ var u;
206
+ if (!d) {
207
+ const o = new Error("浏览器不支持语音识别");
208
+ b.error = o, (u = n.onError) == null || u.call(n, o);
102
209
  return;
103
210
  }
104
- if (h.isRecording) {
211
+ if (b.isRecording) {
105
212
  try {
106
- c.stop(), setTimeout(() => {
213
+ d.stop(), setTimeout(() => {
107
214
  try {
108
- c.start();
109
- } catch (s) {
110
- w(s);
215
+ d.start();
216
+ } catch (o) {
217
+ s(o);
111
218
  }
112
219
  }, 100);
113
- } catch (s) {
114
- w(s);
220
+ } catch (o) {
221
+ s(o);
115
222
  }
116
223
  return;
117
224
  }
118
225
  try {
119
- c.start();
120
- } catch (s) {
121
- w(s);
226
+ d.start();
227
+ } catch (o) {
228
+ s(o);
122
229
  }
123
230
  }, m = () => {
124
- if (c && h.isRecording)
231
+ if (d && b.isRecording)
125
232
  try {
126
- c.stop();
127
- } catch (r) {
128
- w(r);
233
+ d.stop();
234
+ } catch (u) {
235
+ s(u);
129
236
  }
130
- }, w = (r) => {
131
- var s;
132
- h.error = r instanceof Error ? r : new Error("语音识别操作失败"), h.isRecording = !1, (s = n.onError) == null || s.call(n, h.error);
237
+ }, s = (u) => {
238
+ var o;
239
+ b.error = u instanceof Error ? u : new Error("语音识别操作失败"), b.isRecording = !1, (o = n.onError) == null || o.call(n, b.error);
133
240
  };
134
241
  return {
135
- speechState: h,
136
- start: i,
242
+ speechState: b,
243
+ start: t,
137
244
  stop: m
138
245
  };
139
246
  }
140
- const V0 = "data:image/svg+xml,%3csvg%20width='32.000000'%20height='32.000000'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdesc%3e%20Created%20with%20Pixso.%20%3c/desc%3e%3cdefs/%3e%3crect%20id='矩形'%20rx='8.000000'%20width='32.000000'%20height='32.000000'%20fill='%23000000'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='0.500000'%20y='0.500000'%20rx='8.000000'%20width='31.000000'%20height='31.000000'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3crect%20id='矩形'%20x='4.000000'%20y='4.000000'%20width='24.000000'%20height='24.000000'%20fill='%23D8D8D8'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='4.500000'%20y='4.500000'%20width='23.000000'%20height='23.000000'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3cpath%20id='路径%203'%20d='M13.37%2010.32L13.23%2010.26L15.44%2011.19L12.61%2018.98C12.2%2020.11%2012.81%2021.36%2013.95%2021.72C15.04%2022.07%2016.2%2021.5%2016.59%2020.43L19.35%2012.85L18.8%2012.65L18.79%2012.62C18.79%2012.61%2018.8%2012.61%2018.8%2012.6L15.44%2011.19L15.83%2010.14C16.49%208.31%2018.52%207.37%2020.35%208.03C22.18%208.7%2023.12%2010.72%2022.46%2012.55L19.15%2021.65C18.21%2024.21%2015.38%2025.54%2012.82%2024.6C10.25%2023.67%208.93%2020.83%209.86%2018.27L12.83%2010.12L12.28%209.92L12.27%209.9C12.39%209.58%2012.73%209.42%2013.04%209.54C13.36%209.65%2013.52%209.99%2013.4%2010.31L13.37%2010.32Z'%20fill='%23D8D8D8'%20fill-opacity='0'%20fill-rule='evenodd'/%3e%3cpath%20id='路径%203'%20d='M12.84%2010.1L9.86%2018.27C8.93%2020.83%2010.25%2023.67%2012.82%2024.6C15.38%2025.54%2018.21%2024.21%2019.15%2021.65L22.46%2012.55C23.12%2010.72%2022.18%208.7%2020.35%208.03C18.52%207.37%2016.49%208.31%2015.83%2010.14L12.61%2018.98C12.2%2020.11%2012.81%2021.36%2013.95%2021.72C15.04%2022.07%2016.2%2021.5%2016.59%2020.43L19.35%2012.83'%20stroke='%23595959'%20stroke-opacity='1.000000'%20stroke-width='1.200000'%20stroke-linecap='round'/%3e%3c/svg%3e", Z0 = "data:image/svg+xml,%3csvg%20width='32.000000'%20height='32.000000'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdesc%3e%20Created%20with%20Pixso.%20%3c/desc%3e%3cdefs%3e%3clinearGradient%20x1='12.999998'%20y1='21.128080'%20x2='20.000002'%20y2='6.999999'%20id='paint_linear_447_301_0'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23E280FF'/%3e%3cstop%20offset='0.517615'%20stop-color='%236686FF'/%3e%3cstop%20offset='1.000000'%20stop-color='%234DDDFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20id='矩形'%20rx='8.000000'%20width='32.000000'%20height='32.000000'%20fill='%23000000'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='0.500000'%20y='0.500000'%20rx='8.000000'%20width='31.000000'%20height='31.000000'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3crect%20id='矩形'%20x='4.000000'%20y='4.000000'%20width='24.000000'%20height='24.000000'%20fill='%23D8D8D8'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='4.500000'%20y='4.500000'%20width='23.000000'%20height='23.000000'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3crect%20id='矩形'%20x='13.000000'%20y='7.000000'%20rx='3.500000'%20width='7.000000'%20height='11.000000'%20fill='url(%23paint_linear_447_301_0)'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='13.000000'%20y='7.000000'%20rx='3.500000'%20width='7.000000'%20height='11.000000'%20stroke='%23595959'%20stroke-opacity='1.000000'%20stroke-width='1.200000'%20stroke-linejoin='round'/%3e%3cpath%20id='路径'%20d='M8.41%2014.02L8.39%2014C8.39%2013.66%208.66%2013.4%209%2013.4C9.33%2013.4%209.6%2013.66%209.6%2014L23.39%2014C23.39%2013.66%2023.66%2013.4%2024%2013.4C24.33%2013.4%2024.6%2013.66%2024.6%2014L24.58%2014.02L24%2014.02C23.98%2018.42%2020.63%2022%2016.5%2022C12.36%2022%209.01%2018.42%209%2014.02L8.41%2014.02Z'%20fill='%23D8D8D8'%20fill-opacity='0'%20fill-rule='evenodd'/%3e%3cpath%20id='路径'%20d='M9%2014C9%2018.41%2012.35%2022%2016.5%2022C20.64%2022%2024%2018.41%2024%2014'%20stroke='%23595959'%20stroke-opacity='1.000000'%20stroke-width='1.200000'%20stroke-linecap='round'/%3e%3cpath%20id='路径%202'%20d='M15.91%2022.6L15.89%2022.58C15.89%2022.24%2016.16%2021.98%2016.5%2021.98C16.83%2021.98%2017.1%2022.24%2017.1%2022.58L17.08%2022.6L15.91%2022.6ZM17.08%2025.34L17.1%2025.36C17.1%2025.7%2016.83%2025.96%2016.5%2025.96C16.16%2025.96%2015.89%2025.7%2015.89%2025.36L15.91%2025.34L17.08%2025.34Z'%20fill='%23D8D8D8'%20fill-opacity='0'%20fill-rule='nonzero'/%3e%3cpath%20id='路径%202'%20d='M16.5%2022.58L16.5%2025.36'%20stroke='%23595959'%20stroke-opacity='1.000000'%20stroke-width='1.200000'%20stroke-linecap='round'/%3e%3c/svg%3e", K0 = "data:image/svg+xml,%3csvg%20width='152.343506'%20height='18.000000'%20viewBox='0%200%20152.344%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdesc%3e%20Created%20with%20Pixso.%20%3c/desc%3e%3cdefs%3e%3clinearGradient%20x1='159.655945'%20y1='6.532532'%20x2='-2.217805'%20y2='3.665466'%20id='paint_linear_498_7491_0'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23E6FF7D'%20stop-opacity='0.200000'/%3e%3cstop%20offset='0.264015'%20stop-color='%23FFB22E'%20stop-opacity='0.200000'/%3e%3cstop%20offset='0.522782'%20stop-color='%2397A7FF'%20stop-opacity='0.258824'/%3e%3cstop%20offset='0.702223'%20stop-color='%2376ADFF'%20stop-opacity='0.400000'/%3e%3cstop%20offset='0.830214'%20stop-color='%2367D1FF'%20stop-opacity='0.301961'/%3e%3cstop%20offset='1.000000'%20stop-color='%23D27EFF'%20stop-opacity='0.090196'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20id='Fill%203'%20d='M9.52%209.61C12.69%209.9%2015.86%2010.31%2019.04%2010.74C20.63%2010.94%2022.21%2011.28%2023.8%2011.78C25.39%2012.26%2026.97%2012.84%2028.56%2013.26C30.15%2013.67%2031.73%2013.89%2033.32%2013.89C34.11%2013.88%2034.91%2013.69%2035.7%2013.33C36.49%2012.98%2037.29%2012.49%2038.08%2012.06C38.87%2011.63%2039.67%2011.29%2040.46%2011.19C40.86%2011.13%2041.25%2011.13%2041.65%2011.17C42.05%2011.22%2042.45%2011.31%2042.84%2011.39C44.43%2011.75%2046.02%2012.36%2047.6%2013.19C50.78%2014.81%2053.95%2016.29%2057.12%2017.28C60.3%2018.29%2063.47%2018.26%2066.65%2016.96C69.82%2015.68%2072.99%2014.04%2076.17%2012.73C79.34%2011.4%2082.51%2011.19%2085.69%2011.85C88.86%2012.53%2092.04%2014.04%2095.21%2014.41C96%2014.51%2096.8%2014.56%2097.59%2014.56C98.38%2014.55%2099.18%2014.5%2099.97%2014.46C101.56%2014.35%20103.14%2014.18%20104.73%2013.94C107.91%2013.45%20111.08%2012.64%20114.25%2011.93C117.43%2011.19%20120.6%2010.62%20123.77%2010.26C126.95%209.88%20130.12%209.49%20133.3%209.28C136.47%209.06%20139.64%209%20142.82%209L152.34%209L142.82%209C139.64%208.99%20136.47%208.93%20133.3%208.71C130.12%208.5%20126.95%208.11%20123.77%207.73C120.6%207.37%20117.43%206.8%20114.25%206.06C111.08%205.35%20107.91%204.54%20104.73%204.05C103.14%203.81%20101.56%203.64%2099.97%203.53C99.18%203.49%2098.38%203.44%2097.59%203.43C96.8%203.43%2096%203.48%2095.21%203.58C92.04%203.95%2088.86%205.46%2085.69%206.14C82.51%206.8%2079.34%206.59%2076.17%205.26C72.99%203.95%2069.82%202.31%2066.65%201.03C63.47%20-0.27%2060.3%20-0.31%2057.12%200.71C53.95%201.7%2050.78%203.18%2047.6%204.8C46.02%205.63%2044.43%206.24%2042.84%206.6C42.45%206.68%2042.05%206.77%2041.65%206.82C41.25%206.86%2040.86%206.86%2040.46%206.8C39.67%206.7%2038.87%206.36%2038.08%205.93C37.29%205.51%2036.49%205.01%2035.7%204.66C34.91%204.3%2034.11%204.11%2033.32%204.1C31.73%204.1%2030.15%204.32%2028.56%204.73C26.97%205.15%2025.39%205.73%2023.8%206.21C22.21%206.71%2020.63%207.05%2019.04%207.25C15.86%207.68%2012.69%208.09%209.52%208.38C6.34%208.69%203.17%208.94%200%209C3.17%209.05%206.34%209.3%209.52%209.61Z'%20fill='url(%23paint_linear_498_7491_0)'%20fill-opacity='1.000000'%20fill-rule='evenodd'/%3e%3c/svg%3e", P0 = "data:image/svg+xml,%3csvg%20width='36'%20height='36'%20viewBox='0%200%2036%2036'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdesc%3e%20Created%20with%20Pixso.%20%3c/desc%3e%3cdefs%3e%3cfilter%20id='filter_447_4247_dd'%20x='0'%20y='0'%20width='36'%20height='36'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeColorMatrix%20in='SourceAlpha'%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20127%200'%20result='hardAlpha'/%3e%3cfeOffset%20dx='0'%20dy='2'/%3e%3cfeGaussianBlur%20stdDeviation='1.66667'/%3e%3cfeComposite%20in2='hardAlpha'%20operator='out'%20k2='-1'%20k3='1'/%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.039%200'/%3e%3cfeBlend%20mode='normal'%20in2='BackgroundImageFix'%20result='effect_dropShadow_1'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect_dropShadow_1'%20result='shape'/%3e%3c/filter%3e%3c/defs%3e%3cg%20filter='url(%23filter_447_4247_dd)'%3e%3crect%20id='Rectangle'%20x='0'%20y='0'%20rx='18'%20width='36'%20height='36'%20fill='%231476FF'%20fill-opacity='1'/%3e%3c/g%3e%3cpath%20id='Fill%201'%20d='M26.38%208.7L7.99%2017.45C7.59%2017.64%207.58%2018.21%207.98%2018.4L12.56%2020.7C12.78%2020.81%2013.05%2020.77%2013.23%2020.62L23.54%2011.95C23.71%2011.81%2023.94%2012.05%2023.78%2012.21L14.9%2021.42C14.72%2021.61%2014.63%2021.87%2014.66%2022.14L15.21%2026.9C15.26%2027.36%2015.83%2027.54%2016.14%2027.19L18.36%2024.65C18.49%2024.5%2018.46%2024.25%2018.29%2024.13L16.45%2022.88C16.34%2022.81%2016.44%2022.64%2016.56%2022.7L19%2023.92L21.87%2025.35C22.17%2025.5%2022.52%2025.35%2022.62%2025.03L27.44%209.62C27.64%208.98%2026.98%208.41%2026.38%208.7Z'%20fill='%23FFFFFF'%20fill-opacity='1'%20fill-rule='evenodd'/%3e%3c/svg%3e", W0 = "data:image/svg+xml,%3csvg%20width='102.000000'%20height='36.000000'%20viewBox='0%200%20102%2036'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdesc%3e%20Created%20with%20Pixso.%20%3c/desc%3e%3cdefs/%3e%3crect%20id='沉浸式/输入框/停止生成按钮'%20rx='18.000000'%20width='102.000000'%20height='36.000000'%20fill='%231476FF'%20fill-opacity='0.060000'/%3e%3cpath%20id='停止回答'%20d='M79.96%2013.66L78.75%2013.66C78.4%2014.31%2078.01%2014.92%2077.56%2015.46L76.71%2014.92C77.59%2013.85%2078.23%2012.69%2078.63%2011.42L79.59%2011.63C79.47%2012.01%2079.33%2012.37%2079.19%2012.73L82.95%2012.73L82.95%2013.66L80.98%2013.66C81.25%2014.1%2081.47%2014.53%2081.64%2014.92L80.73%2015.25C80.5%2014.69%2080.24%2014.16%2079.96%2013.66ZM85.88%2013.66L84.54%2013.66C84.28%2014.09%2084%2014.5%2083.71%2014.89L82.87%2014.37C83.6%2013.49%2084.12%2012.51%2084.44%2011.43L85.4%2011.64C85.28%2012.03%2085.14%2012.4%2085%2012.73L89.2%2012.73L89.2%2013.66L86.93%2013.66C87.26%2014.19%2087.54%2014.69%2087.76%2015.14L86.84%2015.46Q86.42%2014.52%2085.88%2013.66ZM34.48%2017.26C35.8%2015.57%2036.77%2013.64%2037.37%2011.49L38.31%2011.92C37.98%2012.96%2037.59%2013.95%2037.13%2014.87L37.13%2024.4L36.11%2024.4L36.11%2016.62C35.72%2017.21%2035.28%2017.79%2034.82%2018.32L34.48%2017.26ZM41.56%2011.65L42.58%2011.49C42.72%2011.84%2042.84%2012.24%2042.98%2012.69L46.97%2012.69L46.97%2013.59L38.31%2013.59L38.31%2012.69L41.98%2012.69C41.85%2012.33%2041.71%2011.98%2041.56%2011.65ZM55.09%2022.81L55.09%2011.63L56.13%2011.63L56.13%2016.18L60.44%2016.18L60.44%2017.16L56.13%2017.16L56.13%2022.81L61.21%2022.81L61.21%2023.79L48.78%2023.79L48.78%2022.81L51.16%2022.81L51.16%2014.08L52.17%2014.08L52.17%2022.81L55.09%2022.81ZM63.38%2012.4L74.61%2012.4L74.61%2024.17L73.63%2024.17L73.63%2023.57L64.36%2023.57L64.36%2024.17L63.38%2024.17L63.38%2012.4ZM64.36%2013.29L64.36%2022.67L73.63%2022.67L73.63%2013.29L64.36%2013.29ZM39.23%2017.04L39.23%2014.4L45.9%2014.4L45.9%2017.04L39.23%2017.04ZM79.78%2018.65L79.78%2018.03C78.96%2018.46%2078.08%2018.87%2077.14%2019.24L76.67%2018.36C79.06%2017.46%2081.05%2016.34%2082.65%2015.01L83.32%2015.01C85.08%2016.44%2087.11%2017.56%2089.41%2018.39L88.92%2019.26C87.96%2018.89%2087.07%2018.47%2086.24%2018.03L86.24%2018.65L79.78%2018.65ZM40.21%2016.28L44.92%2016.28L44.92%2015.17L40.21%2015.17L40.21%2016.28ZM66.31%2020.45L66.31%2015.46L71.71%2015.46L71.71%2020.45L66.31%2020.45ZM80.32%2017.72L85.7%2017.72C84.7%2017.14%2083.79%2016.5%2082.98%2015.8C82.21%2016.48%2081.33%2017.13%2080.32%2017.72ZM67.25%2019.59L70.76%2019.59L70.76%2016.33L67.25%2016.33L67.25%2019.59ZM38.18%2017.86L47%2017.86L47%2020.25L46.25%2020.25L46.25%2020.88L43.22%2020.88L43.22%2023.15C43.22%2023.9%2042.8%2024.3%2041.99%2024.3L40.41%2024.3L40.2%2023.32C40.7%2023.34%2041.18%2023.37%2041.64%2023.37C42%2023.37%2042.18%2023.2%2042.18%2022.9L42.18%2020.88L39.12%2020.88L39.12%2020.25L38.18%2020.25L38.18%2017.86ZM39.16%2018.74L39.16%2020.01L46.04%2020.01L46.04%2018.74L39.16%2018.74ZM78.81%2019.96L87.18%2019.96L87.18%2024.38L86.21%2024.38L86.21%2023.75L79.78%2023.75L79.78%2024.38L78.81%2024.38L78.81%2019.96ZM79.78%2020.88L79.78%2022.83L86.21%2022.83L86.21%2020.88L79.78%2020.88Z'%20fill='%231476FF'%20fill-opacity='1.000000'%20fill-rule='evenodd'/%3e%3crect%20id='矩形'%20x='7.713867'%20y='7.714844'%20width='20.571428'%20height='20.571428'%20fill='%23D8D8D8'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='8.213867'%20y='8.214844'%20width='19.571428'%20height='19.571428'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3crect%20id='矩形'%20x='6.000000'%20y='6.000000'%20width='24.000000'%20height='24.000000'%20fill='%23D8D8D8'%20fill-opacity='0'/%3e%3crect%20id='矩形'%20x='6.500000'%20y='6.500000'%20width='23.000000'%20height='23.000000'%20stroke='%23979797'%20stroke-opacity='0'%20stroke-width='1.000000'/%3e%3crect%20id='矩形'%20x='14.666992'%20y='14.666016'%20rx='1.500000'%20width='6.666667'%20height='6.666667'%20fill='%231476FF'%20fill-opacity='1.000000'/%3e%3ccircle%20id='椭圆形'%20cx='18.000000'%20cy='18.000000'%20r='8.250000'%20fill='%23D8D8D8'%20fill-opacity='0'/%3e%3ccircle%20id='椭圆形'%20cx='18.000000'%20cy='18.000000'%20r='8.250000'%20stroke='%231476FF'%20stroke-opacity='1.000000'%20stroke-width='1.500000'/%3e%3cpath%20id='路径'%20d='M17.8%2010.47C17.48%2010.39%2017.25%2010.1%2017.25%209.75C17.25%209.33%2017.58%209%2018%209L18.02%209.02L18.02%209.75C22.56%209.76%2026.25%2013.45%2026.25%2018C26.25%2022.55%2022.55%2026.25%2018%2026.25C16.52%2026.25%2015.13%2025.86%2013.93%2025.18L13.57%2025.81L13.54%2025.82C13.18%2025.61%2013.06%2025.16%2013.26%2024.8C13.44%2024.49%2013.78%2024.35%2014.11%2024.44L17.8%2010.47Z'%20fill='%23595959'%20fill-opacity='0'%20fill-rule='evenodd'/%3e%3cpath%20id='路径'%20d='M13.91%2025.17C15.12%2025.85%2016.51%2026.25%2018%2026.25C22.55%2026.25%2026.25%2022.55%2026.25%2018C26.25%2013.44%2022.55%209.75%2018%209.75'%20stroke='%231476FF'%20stroke-opacity='1.000000'%20stroke-width='1.500000'%20stroke-linecap='round'/%3e%3c/svg%3e", O0 = { class: "action-buttons" }, j0 = {
141
- key: 0,
142
- src: Z0,
143
- class: "button-icon",
144
- alt: "录音"
145
- }, A0 = {
146
- key: 1,
147
- src: K0,
148
- class: "button-icon recording-icon",
149
- alt: "语音中"
150
- }, U0 = { class: "button-content" }, z0 = {
247
+ const tt = (n, b) => {
248
+ if (!b || !n)
249
+ return [{ text: n, isMatch: !1 }];
250
+ const d = n.toLowerCase(), t = b.toLowerCase(), m = d.indexOf(t);
251
+ if (m === -1)
252
+ return [{ text: n, isMatch: !1 }];
253
+ const s = [];
254
+ return m > 0 && s.push({
255
+ text: n.substring(0, m),
256
+ isMatch: !1
257
+ }), s.push({
258
+ text: n.substring(m, m + b.length),
259
+ isMatch: !0
260
+ }), m + b.length < n.length && s.push({
261
+ text: n.substring(m + b.length),
262
+ isMatch: !1
263
+ }), s;
264
+ };
265
+ function nt(n, b, d, t) {
266
+ const m = x(!1), s = x(-1), u = x(""), o = x(!1), e = x(null), g = x(!1), S = L(() => {
267
+ if (!n.suggestions || !d.value || n.template) return [];
268
+ const k = d.value.toLowerCase();
269
+ return n.suggestions.filter((V) => V.toLowerCase().includes(k));
270
+ }), a = L(() => S.value[s.value] || null), C = (k) => {
271
+ const V = k || (S.value.length > 0 ? S.value[0] : null);
272
+ V && d.value && V.toLowerCase().startsWith(d.value.toLowerCase()) ? u.value = V.substring(d.value.length) : u.value = "";
273
+ };
274
+ G(d, (k) => {
275
+ t.value || g.value || (k && n.suggestions && n.suggestions.length > 0 && !n.template ? (m.value = S.value.length > 0, m.value ? (s.value = 0, C(), o.value = !0) : (s.value = -1, u.value = "", o.value = !1)) : (m.value = !1, s.value = -1, u.value = "", o.value = !1));
276
+ });
277
+ const f = (k) => {
278
+ g.value = !0, d.value = k, b("update:modelValue", k), b("suggestion-select", k), p(), P(() => {
279
+ g.value = !1;
280
+ });
281
+ }, r = () => {
282
+ a.value && f(a.value);
283
+ }, p = () => {
284
+ m.value = !1, o.value = !1, u.value = "", s.value = -1;
285
+ };
286
+ return {
287
+ showSuggestionsPopup: m,
288
+ highlightedIndex: s,
289
+ completionPlaceholder: u,
290
+ showTabHint: o,
291
+ suggestionsListRef: e,
292
+ filteredSuggestions: S,
293
+ activeSuggestion: a,
294
+ updateCompletionPlaceholder: C,
295
+ selectSuggestion: f,
296
+ acceptCurrentSuggestion: r,
297
+ closeSuggestionsPopup: p,
298
+ navigateSuggestions: (k) => {
299
+ if (!m.value || S.value.length === 0) return;
300
+ k === "down" ? s.value = (s.value + 1) % S.value.length : s.value = (s.value - 1 + S.value.length) % S.value.length, a.value && C(a.value);
301
+ const V = e.value;
302
+ if (V) {
303
+ const l = V.children[s.value];
304
+ l && l.scrollIntoView({ block: "nearest" });
305
+ }
306
+ },
307
+ handleSuggestionItemHover: (k) => {
308
+ s.value = k, C(S.value[k]);
309
+ },
310
+ handleClickOutside: () => {
311
+ p();
312
+ },
313
+ highlightSuggestionText: tt
314
+ };
315
+ }
316
+ const st = { class: "action-buttons" }, lt = {
151
317
  key: 0,
152
- src: P0,
153
- alt: "发送"
154
- }, m0 = /* @__PURE__ */ c0({
318
+ class: "action-buttons__utility"
319
+ }, ot = { class: "action-buttons__submit-content" }, at = { class: "action-buttons__cancel" }, Ce = /* @__PURE__ */ ce({
155
320
  __name: "ActionButtons",
156
321
  props: {
157
322
  loading: { type: Boolean, default: !1 },
@@ -169,301 +334,426 @@ const V0 = "data:image/svg+xml,%3csvg%20width='32.000000'%20height='32.000000'%2
169
334
  isOverLimit: { type: Boolean, default: !1 }
170
335
  },
171
336
  emits: ["clear", "toggle-speech", "submit", "cancel"],
172
- setup(n, { emit: h }) {
173
- const c = B0(), i = n, m = h, w = S(() => i.allowSpeech), r = S(() => i.speechStatus.isRecording), s = S(() => i.disabled), k = S(() => s.value || i.isOverLimit), f = () => {
174
- s.value || m("clear");
337
+ setup(n, { emit: b }) {
338
+ const d = je(), t = n, m = b, s = L(() => t.allowSpeech), u = L(() => t.speechStatus.isRecording), o = L(() => t.disabled), e = L(() => o.value || t.isOverLimit), g = L(() => t.allowFiles || t.allowSpeech || t.showClear), S = () => {
339
+ o.value || m("clear");
175
340
  }, a = () => {
176
- if (!s.value) {
177
- const l = !i.speechStatus.isRecording;
178
- m("toggle-speech", l);
341
+ if (!o.value) {
342
+ const r = !t.speechStatus.isRecording;
343
+ m("toggle-speech", r);
179
344
  }
180
- }, v = () => {
181
- k.value || m("submit");
182
- }, Z = () => {
183
- s.value || m("cancel");
345
+ }, C = () => {
346
+ e.value || m("submit");
347
+ }, f = () => {
348
+ o.value || m("cancel");
184
349
  };
185
- return (l, L) => {
186
- const x = _0("tiny-tooltip");
187
- return d(), C("div", O0, [
188
- l.allowFiles && !l.loading ? (d(), V(x, {
350
+ return (r, p) => (N(), D("div", st, [
351
+ g.value ? (N(), D("div", lt, [
352
+ r.allowFiles && !r.loading ? (N(), H(_(ue), {
189
353
  key: 0,
190
354
  content: "上传文件",
191
355
  placement: "top"
192
356
  }, {
193
- default: $(() => [
194
- W(F(n0), {
357
+ default: j(() => [
358
+ K(_(ne), {
359
+ class: "action-buttons__button action-buttons__file-button",
195
360
  type: "text",
196
- disabled: s.value
361
+ disabled: o.value
197
362
  }, {
198
- default: $(() => L[1] || (L[1] = [
199
- B("img", {
200
- src: V0,
201
- class: "button-icon",
363
+ default: j(() => [
364
+ K(_(qe), {
365
+ class: "action-buttons__icon",
202
366
  alt: "上传文件"
203
- }, null, -1)
204
- ])),
367
+ })
368
+ ]),
205
369
  _: 1
206
370
  }, 8, ["disabled"])
207
371
  ]),
208
372
  _: 1
209
- })) : R("", !0),
210
- w.value && !l.loading ? (d(), V(F(n0), {
373
+ })) : B("", !0),
374
+ s.value && !r.loading ? (N(), H(_(ne), {
211
375
  key: 1,
376
+ class: Q(["action-buttons__button action-buttons__speech-button", { "is-recording": u.value }]),
212
377
  type: "text",
213
- disabled: s.value,
214
- onClick: a,
215
- class: z(["speech-button", { "is-recording": r.value }])
378
+ disabled: o.value,
379
+ onClick: a
216
380
  }, {
217
- default: $(() => [
218
- r.value ? (d(), C("img", A0)) : (d(), C("img", j0))
381
+ default: j(() => [
382
+ u.value ? (N(), H(_(Ue), {
383
+ key: 1,
384
+ class: "action-buttons__icon action-buttons__icon--recording",
385
+ alt: "语音中"
386
+ })) : (N(), H(_(ze), {
387
+ key: 0,
388
+ class: "action-buttons__icon",
389
+ alt: "录音"
390
+ }))
219
391
  ]),
220
392
  _: 1
221
- }, 8, ["disabled", "class"])) : R("", !0),
222
- l.showClear ? (d(), V(x, {
393
+ }, 8, ["disabled", "class"])) : B("", !0),
394
+ r.showClear ? (N(), H(_(ue), {
223
395
  key: 2,
224
396
  content: "清空内容",
225
397
  placement: "top"
226
398
  }, {
227
- default: $(() => [
228
- W(F(n0), {
399
+ default: j(() => [
400
+ K(_(ne), {
401
+ class: "action-buttons__button action-buttons__clear-button",
229
402
  type: "text",
230
- disabled: s.value || !l.hasContent,
231
- onClick: f,
232
- style: { "margin-left": "0" }
403
+ disabled: o.value || !r.hasContent,
404
+ onClick: S
233
405
  }, {
234
- default: $(() => [
235
- (d(), V(b0(F(c)), { class: "button-icon" }))
406
+ default: j(() => [
407
+ (N(), H(Me(_(d)), { class: "action-buttons__icon action-buttons__icon--close" }))
236
408
  ]),
237
409
  _: 1
238
410
  }, 8, ["disabled"])
239
411
  ]),
240
412
  _: 1
241
- })) : R("", !0),
242
- l.hasContent || l.loading ? (d(), V(F(n0), {
243
- key: 3,
244
- type: "text",
245
- class: z(l.loading ? "cancel-button" : "submit-button"),
246
- disabled: l.loading ? s.value : k.value,
247
- onClick: L[0] || (L[0] = (I) => l.loading ? Z() : v())
248
- }, {
249
- default: $(() => [
250
- B("div", U0, [
251
- l.loading ? (d(), V(x, {
252
- key: 1,
253
- content: "停止生成",
254
- placement: "top"
255
- }, {
256
- default: $(() => L[2] || (L[2] = [
257
- B("img", {
258
- src: W0,
259
- alt: "加载中",
260
- class: "loading"
261
- }, null, -1)
262
- ])),
263
- _: 1
264
- })) : (d(), C("img", z0))
265
- ])
266
- ]),
267
- _: 1
268
- }, 8, ["class", "disabled"])) : R("", !0)
269
- ]);
270
- };
413
+ })) : B("", !0)
414
+ ])) : B("", !0),
415
+ r.hasContent || r.loading ? (N(), H(_(ne), {
416
+ key: 1,
417
+ type: "text",
418
+ class: "action-buttons__button action-buttons__submit",
419
+ disabled: r.loading ? o.value : e.value,
420
+ onClick: p[0] || (p[0] = (T) => r.loading ? f() : C())
421
+ }, {
422
+ default: j(() => [
423
+ M("div", ot, [
424
+ r.loading ? (N(), H(_(ue), {
425
+ key: 1,
426
+ content: "停止生成",
427
+ placement: "top"
428
+ }, {
429
+ default: j(() => [
430
+ M("div", at, [
431
+ K(_(Ge), {
432
+ class: "action-buttons__icon action-buttons__icon--stop",
433
+ alt: "加载中"
434
+ }),
435
+ p[1] || (p[1] = M("span", { class: "action-buttons__cancel-text" }, "停止回答", -1))
436
+ ])
437
+ ]),
438
+ _: 1
439
+ })) : (N(), H(_(Xe), {
440
+ key: 0,
441
+ class: "action-buttons__icon action-buttons__icon--send",
442
+ alt: "发送"
443
+ }))
444
+ ])
445
+ ]),
446
+ _: 1
447
+ }, 8, ["disabled"])) : B("", !0)
448
+ ]));
271
449
  }
272
- }), q0 = { class: "template-editor" }, G0 = { key: 0 }, H0 = ["onClick"], N0 = ["onInput"], Q0 = {
273
- key: 1,
274
- class: "template-placeholder"
275
- }, J0 = /* @__PURE__ */ c0({
276
- __name: "TemplateEditor",
277
- props: {
278
- template: {},
279
- value: {}
280
- },
281
- emits: ["update:value", "input", "content-status", "field-active"],
282
- setup(n, { expose: h, emit: c }) {
283
- const i = n, m = c, w = b(null), r = b({}), s = b(-1), k = b(!1), f = b(!1), a = b(!1), v = b([]), Z = (t) => {
284
- const o = [];
285
- let u = 0, _ = 0;
286
- const y = /\[(.*?)\]/g;
287
- let D;
288
- for (; (D = y.exec(t)) !== null; )
289
- D.index > u && o.push({
290
- content: t.substring(u, D.index),
291
- isField: !1
292
- }), o.push({
293
- content: D[1],
294
- // 使用占位符作为默认内容
295
- placeholder: D[1],
296
- isField: !0,
297
- fieldIndex: _++
298
- }), u = D.index + D[0].length;
299
- return u < t.length && o.push({
300
- content: t.substring(u),
301
- isField: !1
302
- }), o;
303
- }, l = () => {
304
- v.value = Z(i.template), i.value && L(i.value);
305
- }, L = (t) => {
306
- if (!t || a.value || x() === t) return;
307
- const u = Z(i.template), _ = [];
308
- u.forEach((E) => {
309
- E.isField ? _.push(`__FIELD_${E.fieldIndex}__`) : _.push(E.content);
310
- });
311
- let y = t, D = 0;
312
- for (let E = 0; E < v.value.length; E++) {
313
- if (!v.value[E].isField) continue;
314
- const N = _[D];
315
- D++;
316
- const T = _[D] || "";
317
- if (N && y.startsWith(N))
318
- if (y = y.substring(N.length), T && y.includes(T)) {
319
- const l0 = y.indexOf(T), K = y.substring(0, l0);
320
- K && (v.value[E].content = K, s.value === E && r.value[E] && (f.value = !0)), y = y.substring(l0);
321
- } else !T && y && (v.value[E].content = y, y = "");
450
+ });
451
+ function it(n, b) {
452
+ const d = x(!1), t = Se({ ...b }), m = (l) => {
453
+ Object.assign(t, l);
454
+ }, s = (l) => {
455
+ const c = [];
456
+ let h = 0;
457
+ const y = /\[(.*?)\]/g;
458
+ let w;
459
+ for (; (w = y.exec(l)) !== null; )
460
+ w.index > h && c.push({ type: "text", content: l.substring(h, w.index) }), c.push({ type: "field", content: w[1] }), h = w.index + w[0].length;
461
+ return h < l.length && c.push({ type: "text", content: l.substring(h) }), c;
462
+ }, u = () => {
463
+ if (!n.value) return "";
464
+ let l = "";
465
+ return n.value.childNodes.forEach((c) => {
466
+ (c.nodeType === Node.TEXT_NODE || c.nodeType === Node.ELEMENT_NODE && c.classList.contains("template-field")) && (l += c.textContent || "");
467
+ }), l;
468
+ }, o = (l) => t.initialValues && typeof t.initialValues[l] == "string" ? t.initialValues[l] : "", e = (l, c) => {
469
+ const h = document.createElement("span");
470
+ return h.className = "template-field", h.setAttribute("data-placeholder", l), c && (h.textContent = c), P(() => {
471
+ g(h, c || "");
472
+ }), h;
473
+ }, g = (l, c) => {
474
+ if (!c || c.trim() === "") {
475
+ const h = l.getAttribute("data-placeholder") || "";
476
+ h ? S(l, h, !0) : (l.style.minWidth = "", l.style.width = "");
477
+ return;
478
+ }
479
+ S(l, c, !1);
480
+ }, S = (l, c, h) => {
481
+ const y = document.createElement("span");
482
+ y.className = "template-field", y.style.visibility = "hidden", y.style.position = "absolute", y.style.top = "-9999px", y.style.left = "-9999px", y.style.whiteSpace = "nowrap", y.style.padding = "3px 8px", y.style.margin = "0 2px", y.style.boxSizing = "border-box", y.textContent = c, document.body.appendChild(y);
483
+ const w = getComputedStyle(y), F = y.offsetWidth, O = parseFloat(w.fontSize);
484
+ document.body.removeChild(y);
485
+ const I = h ? 1.5 : 2, W = F / O, $ = Math.max(I, Math.ceil(W));
486
+ l.style.setProperty("min-width", `${$}em`, "important");
487
+ const q = 20;
488
+ $ > q ? (l.style.setProperty("max-width", `${q}em`, "important"), l.style.setProperty("white-space", "normal", "important"), l.style.setProperty("word-break", "break-word", "important")) : l.style.removeProperty("max-width");
489
+ }, a = (l) => {
490
+ const h = (l === void 0 ? u() : l).trim().length > 0;
491
+ d.value !== h && (d.value = h, t.onContentStatusChange(h));
492
+ }, C = (l, c = "inside", h = !1) => {
493
+ P(() => {
494
+ const y = window.getSelection();
495
+ if (!y) return;
496
+ const w = document.createRange();
497
+ switch (c) {
498
+ case "before":
499
+ w.setStartBefore(l);
500
+ break;
501
+ case "after":
502
+ w.setStartAfter(l);
503
+ break;
504
+ case "inside":
505
+ default:
506
+ w.selectNodeContents(l), w.collapse(h);
507
+ break;
322
508
  }
323
- M(t);
324
- }, x = () => v.value.map((t) => t.content).join(""), I = () => {
325
- a.value = !0;
326
- const t = x();
327
- m("update:value", t), m("input", t), M(t), setTimeout(() => {
328
- a.value = !1;
329
- }, 0);
330
- }, M = (t) => {
331
- const u = (t || x()).trim().length > 0;
332
- k.value !== u && (k.value = u, m("content-status", u));
333
- }, G = (t, o) => {
334
- t && (r.value[o] = t, t.textContent || (t.textContent = v.value[o].content), new MutationObserver(() => {
335
- s.value === o && !f.value && (f.value = !0, setTimeout(() => {
336
- v.value[o].content = t.textContent !== null ? t.textContent : "", f.value = !1;
337
- }, 0));
338
- }).observe(t, {
339
- characterData: !0,
340
- childList: !0,
341
- subtree: !0
342
- }));
343
- }, O = (t, o) => {
344
- f.value = !0;
345
- const u = t.target, _ = u.textContent !== null ? u.textContent : "";
346
- v.value[o].content !== _ && (v.value[o].content = _, I()), setTimeout(() => {
347
- f.value = !1;
348
- }, 10);
349
- }, X = (t) => {
350
- if (document.createRange) {
351
- const o = document.createRange();
352
- o.selectNodeContents(t), o.collapse(!1);
353
- const u = window.getSelection();
354
- u && (u.removeAllRanges(), u.addRange(o));
509
+ y.removeAllRanges(), y.addRange(w), l.focus && l.focus();
510
+ });
511
+ }, f = () => {
512
+ P(() => {
513
+ const l = n.value;
514
+ if (l) {
515
+ const c = document.createRange(), h = window.getSelection();
516
+ c.selectNodeContents(l), c.collapse(!1), h && (h.removeAllRanges(), h.addRange(c)), l.focus();
355
517
  }
356
- }, Y = (t) => {
357
- if (s.value !== t) {
358
- if (s.value !== -1) {
359
- const o = s.value, u = r.value[o];
360
- u && (v.value[o].content = u.textContent !== null ? u.textContent : "", I());
518
+ });
519
+ }, r = (l, c) => {
520
+ const h = n.value;
521
+ if (!h) return null;
522
+ h.innerHTML = "";
523
+ let y = null;
524
+ if (!c || c === t.template)
525
+ l.forEach((w) => {
526
+ if (w.type === "field") {
527
+ const F = o(w.content), O = e(w.content, F);
528
+ h.appendChild(O), y || (y = O);
529
+ } else
530
+ h.appendChild(document.createTextNode(w.content));
531
+ }), t.initialValues && Object.keys(t.initialValues).length > 0 && P(() => {
532
+ const w = u();
533
+ w !== t.value && (t.onValueChange(w), t.onInput(w));
534
+ });
535
+ else {
536
+ const w = p(l, c);
537
+ w.success ? w.elements.forEach((F) => {
538
+ h.appendChild(F.node), F.isField && !y && (y = F.node);
539
+ }) : (h.appendChild(document.createTextNode(c)), y = null);
540
+ }
541
+ return y;
542
+ }, p = (l, c) => {
543
+ const h = [];
544
+ let y = 0, w = 0, F = !0;
545
+ for (; w < l.length && y <= c.length && F; ) {
546
+ const O = l[w];
547
+ if (O.type === "text")
548
+ c.substring(y).startsWith(O.content) ? (h.push({
549
+ node: document.createTextNode(O.content),
550
+ isField: !1
551
+ }), y += O.content.length, w++) : F = !1;
552
+ else {
553
+ let I = "";
554
+ const W = l.find(($, q) => q > w && $.type === "text");
555
+ if (W) {
556
+ const $ = c.substring(y), q = $.indexOf(W.content);
557
+ q !== -1 ? (I = $.substring(0, q), y += I.length) : F = !1;
558
+ } else
559
+ I = c.substring(y), y = c.length;
560
+ if (F) {
561
+ const $ = e(O.content, I);
562
+ h.push({ node: $, isField: !0 }), w++;
361
563
  }
362
- s.value = t, m("field-active", !0, t), A(() => {
363
- const o = r.value[t];
364
- o && (o.focus(), !o.textContent && v.value[t].content && (o.textContent = v.value[t].content), X(o));
365
- });
366
564
  }
367
- }, H = () => {
368
- const t = s.value;
369
- if (t >= 0) {
370
- const o = r.value[t];
371
- if (o) {
372
- const u = o.textContent !== null ? o.textContent : "";
373
- v.value[t].content = u;
374
- }
375
- m("field-active", !1, t);
565
+ }
566
+ if (F && w < l.length)
567
+ for (let O = w; O < l.length; O++) {
568
+ const I = l[O];
569
+ if (I.type === "field") {
570
+ const W = !t.value || t.value === "" ? o(I.content) : "", $ = e(I.content, W);
571
+ h.push({ node: $, isField: !0 });
572
+ } else
573
+ h.push({
574
+ node: document.createTextNode(I.content),
575
+ isField: !1
576
+ });
376
577
  }
377
- I(), s.value = -1;
378
- }, e0 = (t) => {
379
- t.key === "Enter" && (t.preventDefault(), H());
380
- };
381
- q(
382
- () => i.value,
383
- (t) => {
384
- t === "" ? t0() : t && !a.value && L(t);
578
+ return { success: F, elements: h };
579
+ }, T = () => {
580
+ if (!n.value) return;
581
+ t.isInternalUpdate = !0;
582
+ const l = s(t.template), c = r(l, t.value);
583
+ a(), P(() => {
584
+ A(), c && c.textContent ? C(c, "inside", !1) : c ? C(c, "inside", !0) : f(), t.isInternalUpdate = !1;
585
+ });
586
+ }, v = () => {
587
+ if (t.isInternalUpdate || t.isComposing) return;
588
+ A();
589
+ const l = u();
590
+ l !== t.value && (t.onValueChange(l), t.onInput(l)), a(l);
591
+ }, A = () => {
592
+ if (!n.value) return;
593
+ n.value.querySelectorAll(".template-field").forEach((c) => {
594
+ const h = c.textContent || "";
595
+ g(c, h);
596
+ });
597
+ };
598
+ return {
599
+ // 状态
600
+ hasContent: d,
601
+ // 解析和DOM操作
602
+ parseTemplateToParts: s,
603
+ getValueFromDOM: u,
604
+ getInitialContentForField: o,
605
+ createFieldElement: e,
606
+ // 光标操作
607
+ setCursorTo: C,
608
+ setCursorToEnd: f,
609
+ // DOM更新
610
+ updateEditorDOM: T,
611
+ renderTemplateToDOM: r,
612
+ // 事件处理
613
+ handleInput: v,
614
+ checkHasContent: a,
615
+ // 方法
616
+ resetFields: () => {
617
+ if (!n.value) return;
618
+ t.isInternalUpdate = !0;
619
+ const l = n.value;
620
+ l.innerHTML = "";
621
+ const c = s(t.template);
622
+ let h = "";
623
+ c.forEach((y) => {
624
+ if (y.type === "field") {
625
+ const w = o(y.content), F = e(y.content, w);
626
+ w && (h += w), l.appendChild(F);
627
+ } else
628
+ l.appendChild(document.createTextNode(y.content)), h += y.content;
629
+ }), t.onValueChange(h), f(), a(h), P(() => {
630
+ t.isInternalUpdate = !1;
631
+ });
632
+ },
633
+ activateFirstField: () => {
634
+ var c;
635
+ const l = (c = n.value) == null ? void 0 : c.querySelector(".template-field");
636
+ l ? C(l, "inside", !1) : f();
637
+ },
638
+ // 选项更新
639
+ updateOptions: m
640
+ };
641
+ }
642
+ const rt = /* @__PURE__ */ ce({
643
+ __name: "TemplateEditor",
644
+ props: {
645
+ template: {},
646
+ value: {},
647
+ autofocus: { type: Boolean },
648
+ initialValues: {}
649
+ },
650
+ emits: ["update:value", "input", "content-status", "submit", "focus", "blur"],
651
+ setup(n, { expose: b, emit: d }) {
652
+ const t = n, m = d, s = x(null), u = x(!1), o = x(!1), e = it(s, {
653
+ template: t.template,
654
+ value: t.value,
655
+ initialValues: t.initialValues,
656
+ isInternalUpdate: u,
657
+ isComposing: o,
658
+ onValueChange: (f) => m("update:value", f),
659
+ onInput: (f) => m("input", f),
660
+ onContentStatusChange: (f) => m("content-status", f),
661
+ onSubmit: (f) => m("submit", f)
662
+ }), g = Ze({
663
+ editor: s,
664
+ isComposing: o,
665
+ getValueFromDOM: e.getValueFromDOM,
666
+ handleInput: e.handleInput,
667
+ onSubmit: (f) => m("submit", f)
668
+ }), S = () => {
669
+ o.value = !0;
670
+ }, a = () => {
671
+ o.value = !1, e.handleInput();
672
+ }, C = (f) => {
673
+ var T;
674
+ if (!s.value) return;
675
+ const r = f.target;
676
+ let p = null;
677
+ if (r.classList.contains("template-field") ? p = r : (T = r.parentElement) != null && T.classList.contains("template-field") && (p = r.parentElement), p && (!p.textContent || p.textContent.trim() === "")) {
678
+ const v = window.getSelection(), A = document.createRange();
679
+ v && (A.selectNodeContents(p), A.collapse(!0), v.removeAllRanges(), v.addRange(A), p.focus(), f.preventDefault(), f.stopPropagation());
385
680
  }
386
- ), q(
387
- () => i.template,
681
+ };
682
+ return $e(() => {
683
+ e.updateEditorDOM(), t.autofocus && s.value && e.setCursorToEnd();
684
+ }), G(
685
+ () => t.template,
388
686
  () => {
389
- l(), A(() => {
390
- M();
391
- });
687
+ u.value || (e.updateOptions({
688
+ template: t.template,
689
+ value: t.value,
690
+ initialValues: t.initialValues
691
+ }), e.updateEditorDOM());
692
+ }
693
+ ), G(
694
+ () => t.value,
695
+ (f) => {
696
+ !u.value && f !== e.getValueFromDOM() && (e.updateOptions({
697
+ template: t.template,
698
+ value: f,
699
+ initialValues: t.initialValues
700
+ }), e.updateEditorDOM());
392
701
  },
393
- { immediate: !0 }
394
- );
395
- const t0 = () => {
396
- v.value.forEach((t) => {
397
- t.isField && (t.content = t.placeholder || "");
398
- }), I();
399
- }, j = () => {
400
- t0();
401
- };
402
- return k0(() => {
403
- M();
404
- }), h({
405
- activateFirstField: () => {
406
- for (let t = 0; t < v.value.length; t++)
407
- if (v.value[t].isField) {
408
- Y(t);
409
- break;
410
- }
702
+ { deep: !1 }
703
+ ), b({
704
+ focus: () => {
705
+ var f;
706
+ (f = s.value) == null || f.focus(), e.setCursorToEnd();
411
707
  },
412
- resetFields: j
413
- }), (t, o) => (d(), C("div", q0, [
414
- B("div", {
415
- class: "template-content",
416
- ref_key: "editorRef",
417
- ref: w
418
- }, [
419
- (d(!0), C(r0, null, v0(v.value, (u, _) => (d(), C(r0, { key: _ }, [
420
- u.isField ? (d(), C("span", {
421
- key: 1,
422
- class: z(["template-field", { "template-field-active": s.value === _ }]),
423
- onClick: (y) => Y(_)
424
- }, [
425
- s.value === _ ? (d(), C("span", {
426
- key: 0,
427
- ref_for: !0,
428
- ref: (y) => G(y, _),
429
- class: "template-editable",
430
- contenteditable: "true",
431
- onInput: (y) => O(y, _),
432
- onBlur: o[0] || (o[0] = (y) => H()),
433
- onKeydown: o[1] || (o[1] = (y) => e0(y)),
434
- onClick: o[2] || (o[2] = S0(() => {
435
- }, ["stop"]))
436
- }, null, 40, N0)) : (d(), C("span", Q0, U(u.content), 1))
437
- ], 10, H0)) : (d(), C("span", G0, U(u.content), 1))
438
- ], 64))), 128))
439
- ], 512)
440
- ]));
708
+ resetFields: e.resetFields,
709
+ activateFirstField: e.activateFirstField
710
+ }), (f, r) => (N(), D("div", {
711
+ class: "template-editor",
712
+ ref_key: "contentEditableRef",
713
+ ref: s,
714
+ contenteditable: "true",
715
+ onInput: r[0] || (r[0] = //@ts-ignore
716
+ (...p) => _(e).handleInput && _(e).handleInput(...p)),
717
+ onKeydown: r[1] || (r[1] = //@ts-ignore
718
+ (...p) => _(g).handleTemplateKeyDown && _(g).handleTemplateKeyDown(...p)),
719
+ onClick: C,
720
+ onCompositionstart: S,
721
+ onCompositionend: a,
722
+ onFocus: r[2] || (r[2] = (p) => f.$emit("focus", p)),
723
+ onBlur: r[3] || (r[3] = (p) => f.$emit("blur", p))
724
+ }, null, 544));
441
725
  }
442
- }), X0 = /* @__PURE__ */ I0(J0, [["__scopeId", "data-v-09e9c7ed"]]), Y0 = ["data-theme"], e2 = { class: "tiny-sender__container" }, t2 = {
726
+ }), ut = ["data-theme"], ct = { class: "tiny-sender__container" }, dt = {
443
727
  key: 0,
444
728
  class: "tiny-sender__header-slot"
445
- }, l2 = {
729
+ }, ft = {
446
730
  key: 0,
447
731
  class: "tiny-sender__prefix-slot"
448
- }, s2 = { class: "tiny-sender__content-area" }, n2 = {
732
+ }, pt = { class: "tiny-sender__content-area" }, ht = {
449
733
  key: 0,
450
734
  class: "tiny-sender__decorative-content"
451
- }, o2 = {
735
+ }, mt = {
736
+ key: 2,
737
+ class: "tiny-sender__input-field-wrapper"
738
+ }, gt = {
739
+ key: 0,
740
+ class: "tiny-sender__completion-placeholder"
741
+ }, vt = { class: "user-input-mirror" }, yt = {
742
+ key: 0,
743
+ class: "tiny-sender__tab-hint"
744
+ }, bt = {
452
745
  key: 1,
453
746
  class: "tiny-sender__actions-slot"
454
- }, i2 = { class: "tiny-sender__footer-left" }, a2 = { class: "tiny-sender__footer-right" }, r2 = { class: "real-word-length" }, c2 = {
747
+ }, wt = { class: "tiny-sender__footer-left" }, _t = { class: "tiny-sender__footer-right" }, Ct = { class: "real-word-length" }, St = {
455
748
  key: 1,
456
749
  class: "tiny-sender__toolbar"
457
- }, u2 = { class: "tiny-sender__buttons-container" }, d2 = {
750
+ }, Et = { class: "tiny-sender__buttons-container" }, Nt = {
458
751
  key: 1,
459
752
  class: "tiny-sender__footer-slot"
460
- }, f2 = {
461
- key: 0,
462
- class: "tiny-sender__suggestions"
463
- }, p2 = ["onClick"], h2 = {
753
+ }, Tt = ["onMouseenter", "onMousedown"], kt = { class: "suggestion-item__icon" }, Rt = { class: "suggestion-item__text" }, It = {
464
754
  key: 0,
465
755
  class: "tiny-sender__error"
466
- }, o0 = /* @__PURE__ */ c0({
756
+ }, se = /* @__PURE__ */ ce({
467
757
  __name: "index",
468
758
  props: {
469
759
  autofocus: { type: Boolean, default: !1 },
@@ -481,292 +771,332 @@ const V0 = "data:image/svg+xml,%3csvg%20width='32.000000'%20height='32.000000'%2
481
771
  speech: { type: [Boolean, Object] },
482
772
  placeholder: { default: "请输入内容..." },
483
773
  showWordLimit: { type: Boolean, default: !1 },
484
- suggestions: {},
774
+ suggestions: { default: () => [] },
485
775
  theme: { default: "light" },
486
776
  template: { default: "" },
487
777
  hasContent: { type: Boolean, default: void 0 },
488
- tipsMessage: {}
778
+ templateInitialValues: { default: () => ({}) }
489
779
  },
490
- emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template", "fixed-link-click"],
491
- setup(n, { expose: h, emit: c }) {
492
- const i = n, m = c, w = b(null), r = b(null), s = b(null), k = b(null), f = S(() => !!i.template), { inputValue: a, isComposing: v, clearInput: Z } = $0(i, m), l = b(i.mode), L = b(!1), x = () => {
493
- l.value === "single" && (l.value = "multiple", A(() => {
780
+ emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
781
+ setup(n, { expose: b, emit: d }) {
782
+ const t = n, m = d, s = x(null), u = x(null), o = x(null), e = x(null), g = x(null), S = L(() => !!t.template), { inputValue: a, isComposing: C, clearInput: f } = Qe(t, m), {
783
+ showSuggestionsPopup: r,
784
+ highlightedIndex: p,
785
+ completionPlaceholder: T,
786
+ showTabHint: v,
787
+ suggestionsListRef: A,
788
+ filteredSuggestions: k,
789
+ activeSuggestion: V,
790
+ updateCompletionPlaceholder: l,
791
+ selectSuggestion: c,
792
+ acceptCurrentSuggestion: h,
793
+ closeSuggestionsPopup: y,
794
+ navigateSuggestions: w,
795
+ handleSuggestionItemHover: F,
796
+ highlightSuggestionText: O
797
+ } = nt(t, m, a, C), I = x(t.mode), W = x(!1), $ = () => {
798
+ I.value === "single" && (I.value = "multiple", P(() => {
494
799
  setTimeout(() => {
495
- const e = document.querySelector(".tiny-textarea__inner");
496
- if (e) {
497
- e.style.whiteSpace = "pre-wrap";
498
- const p = a.value.length;
499
- e.focus(), e.setSelectionRange(p, p);
800
+ const i = document.querySelector(".tiny-textarea__inner");
801
+ if (i) {
802
+ i.style.whiteSpace = "pre-wrap";
803
+ const E = a.value.length;
804
+ i.focus(), i.setSelectionRange(E, E);
500
805
  }
501
806
  }, 50);
502
807
  }));
503
- }, I = (e, p) => {
504
- const g = document.createElement("span");
505
- g.style.visibility = "hidden", g.style.position = "absolute", g.style.whiteSpace = "nowrap", g.style.font = p, g.textContent = e, document.body.appendChild(g);
506
- const J = g.offsetWidth;
507
- return document.body.removeChild(g), J;
508
- }, M = () => {
509
- if (i.mode !== "single" || !w.value || L.value) return;
510
- const p = document.querySelector(".tiny-sender__content-area").querySelector(".tiny-input__inner"), g = k.value || document.querySelector(".tiny-sender__buttons-container");
511
- if (!p) return;
512
- const J = window.getComputedStyle(p).font, p0 = I(a.value, J), w0 = p.offsetWidth - ((g == null ? void 0 : g.offsetWidth) || 0) - 20;
513
- p0 > w0 && l.value === "single" && (L.value = !0, l.value = "multiple", A(() => {
514
- w.value ? setTimeout(() => {
515
- const s0 = document.querySelector(".tiny-textarea__inner");
516
- if (s0) {
517
- s0.style.whiteSpace = "pre-wrap";
518
- const h0 = a.value.length;
519
- s0.focus(), s0.setSelectionRange(h0, h0);
808
+ }, q = (i, E) => {
809
+ const R = document.createElement("span");
810
+ R.style.visibility = "hidden", R.style.position = "absolute", R.style.whiteSpace = "nowrap", R.style.font = E, R.textContent = i, document.body.appendChild(R);
811
+ const z = R.offsetWidth;
812
+ return document.body.removeChild(R), z;
813
+ }, Ee = () => {
814
+ if (t.mode !== "single" || !s.value || W.value) return;
815
+ const E = document.querySelector(".tiny-sender__content-area").querySelector(".tiny-input__inner"), R = g.value || document.querySelector(".tiny-sender__buttons-container");
816
+ if (!E) return;
817
+ const z = window.getComputedStyle(E).font, U = q(a.value, z), Be = E.offsetWidth - ((R == null ? void 0 : R.offsetWidth) || 0) - 20;
818
+ U > Be && I.value === "single" && (W.value = !0, I.value = "multiple", P(() => {
819
+ s.value ? setTimeout(() => {
820
+ const te = document.querySelector(".tiny-textarea__inner");
821
+ if (te) {
822
+ te.style.whiteSpace = "pre-wrap";
823
+ const ye = a.value.length;
824
+ te.focus(), te.setSelectionRange(ye, ye);
520
825
  }
521
- L.value = !1;
522
- }, 300) : L.value = !1;
826
+ W.value = !1;
827
+ }, 300) : W.value = !1;
523
828
  }));
524
- }, G = () => {
525
- Z(), l.value = "single", i.template && m("reset-template"), A(() => {
526
- a.value === "" && (l.value = i.mode || "single");
527
- });
528
- }, O = b(!1), X = S(() => !i.suggestions || !a.value ? [] : i.suggestions.filter((e) => e.toLowerCase().includes(a.value.toLowerCase()))), Y = (e) => {
529
- a.value = e, O.value = !1, m("suggestion-select", e);
530
- }, H = (e) => {
531
- a.value = e, m("update:modelValue", e);
532
- }, e0 = () => {
533
- r.value && r.value.activateFirstField();
534
- }, t0 = S(() => {
535
- const e = typeof i.speech == "object" ? i.speech : {};
829
+ }, le = () => {
830
+ f(), t.template && m("reset-template"), P(() => {
831
+ a.value === "" && (I.value = t.mode || "single");
832
+ }), y();
833
+ }, de = (i) => {
834
+ a.value = i, m("update:modelValue", i);
835
+ }, fe = () => {
836
+ o.value && o.value.activateFirstField();
837
+ }, Ne = L(() => {
838
+ const i = typeof t.speech == "object" ? t.speech : {};
536
839
  return {
537
- ...e,
840
+ ...i,
538
841
  onStart: () => m("speech-start"),
539
- onEnd: (p) => m("speech-end", p),
540
- onInterim: (p) => m("speech-interim", p),
541
- onFinal: (p) => {
542
- if (e.autoReplace)
543
- a.value = p;
842
+ onEnd: (E) => m("speech-end", E),
843
+ onInterim: (E) => m("speech-interim", E),
844
+ onFinal: (E) => {
845
+ if (i.autoReplace)
846
+ a.value = E;
544
847
  else {
545
- const g = a.value;
546
- g && p && !g.endsWith(" ") && !p.startsWith(" ") && g.length > 0 ? a.value = g + " " + p : a.value = g + p;
848
+ const R = a.value;
849
+ R && E && !R.endsWith(" ") && !E.startsWith(" ") && R.length > 0 ? a.value = R + " " + E : a.value = R + E;
547
850
  }
548
- m("speech-end", p);
851
+ m("speech-end", E);
549
852
  },
550
- onError: (p) => {
551
- y0(p.message), m("speech-error", p);
853
+ onError: (E) => {
854
+ Ve(E.message), m("speech-error", E);
552
855
  }
553
856
  };
554
- }), { speechState: j, start: t, stop: o } = T0(t0.value), u = () => {
555
- j.isRecording ? o() : t();
556
- }, { handleKeyPress: _, triggerSubmit: y } = M0(
557
- i,
857
+ }), { speechState: Z, start: pe, stop: he } = et(Ne.value), oe = () => {
858
+ Z.isRecording ? he() : pe();
859
+ }, { handleKeyPress: Te, triggerSubmit: ae } = Ye(
860
+ t,
558
861
  m,
559
862
  a,
560
- v,
561
- j,
562
- O,
563
- u,
564
- l,
565
- x
566
- ), D = (e) => {
567
- m("focus", e);
568
- }, E = (e) => {
569
- m("blur", e);
570
- }, u0 = S(() => l.value === "multiple" ? "textarea" : "text"), N = S(
863
+ C,
864
+ Z,
865
+ r,
866
+ V,
867
+ h,
868
+ y,
869
+ w,
870
+ oe,
871
+ I,
872
+ $
873
+ ), ke = (i) => {
874
+ m("focus", i), a.value && k.value.length > 0 && !t.template && (r.value = !0, v.value = !0, p.value === -1 && (p.value = 0), l(V.value || k.value[0]));
875
+ }, Re = (i) => {
876
+ m("blur", i);
877
+ }, Ie = L(() => I.value === "multiple" ? "textarea" : "text"), De = L(
571
878
  () => ({
572
879
  display: "flex",
573
- justifyContent: i.showWordLimit && i.maxLength !== 1 / 0 ? "space-between" : "flex-end",
880
+ justifyContent: t.showWordLimit && t.maxLength !== 1 / 0 ? "space-between" : "flex-end",
574
881
  alignItems: "center"
575
882
  })
576
- ), T = x0(), l0 = S(() => {
577
- var e;
578
- return !!((e = T.decorativeContent) != null && e.call(T));
579
- }), K = S(() => i.disabled || l0.value), d0 = S(() => i.loading), f0 = S(() => i.hasContent !== void 0 ? i.hasContent : !!a.value), g0 = S(() => ({
580
- "is-disabled": K.value,
581
- "is-loading": d0.value,
582
- "has-error": !!Q.value,
583
- "is-auto-switching": L.value
584
- })), Q = b(""), y0 = (e) => {
585
- Q.value = e, setTimeout(() => Q.value = "", 5e3);
586
- }, C0 = () => {
587
- v.value = !1, setTimeout(() => v.value = !1, 50);
588
- }, i0 = S(() => i.maxLength !== 1 / 0 && a.value.length > i.maxLength);
589
- return q(a, () => {
590
- O.value = !!i.suggestions && !!a.value, A(M), a.value === "" && i.mode === "single" && (l.value = "single");
591
- }), q(
592
- () => f.value,
593
- (e) => {
594
- e && (l.value = "multiple");
883
+ ), xe = Ae(), Fe = L(() => !!xe.decorativeContent), ee = L(() => t.disabled || Fe.value), me = L(() => t.loading), ge = L(() => t.hasContent !== void 0 ? t.hasContent : !!a.value), Le = L(() => ({
884
+ "is-disabled": ee.value,
885
+ "is-loading": me.value,
886
+ "has-error": !!Y.value,
887
+ "is-auto-switching": W.value
888
+ })), Y = x(""), Ve = (i) => {
889
+ Y.value = i, setTimeout(() => Y.value = "", 5e3);
890
+ }, Oe = () => {
891
+ C.value = !1, setTimeout(() => {
892
+ C.value = !1, a.value && t.suggestions && t.suggestions.length > 0 && !t.template && (r.value = k.value.length > 0, r.value && (p.value = 0, l(), v.value = !0));
893
+ }, 50);
894
+ }, ie = L(() => t.maxLength !== 1 / 0 && a.value.length > t.maxLength);
895
+ return G(a, () => {
896
+ P(Ee), a.value === "" && t.mode === "single" && (I.value = "single");
897
+ }), G(
898
+ () => S.value,
899
+ (i) => {
900
+ i && (I.value = "multiple");
595
901
  }
596
- ), h({
902
+ ), b({
597
903
  focus: () => {
598
- if (f.value && r.value)
599
- e0();
600
- else if (w.value)
601
- w.value.focus();
904
+ if (S.value && o.value)
905
+ fe();
906
+ else if (s.value)
907
+ s.value.focus();
602
908
  else {
603
- const e = document.querySelector(".tiny-input__inner");
604
- e == null || e.focus();
909
+ const i = document.querySelector(".tiny-input__inner");
910
+ i == null || i.focus();
605
911
  }
606
912
  },
607
913
  blur: () => {
608
- if (w.value)
609
- w.value.blur();
914
+ if (s.value)
915
+ s.value.blur();
610
916
  else {
611
- const e = document.querySelector(".tiny-input__inner");
612
- e == null || e.blur();
917
+ const i = document.querySelector(".tiny-input__inner");
918
+ i == null || i.blur();
613
919
  }
614
920
  },
615
- clear: G,
616
- submit: y,
617
- startSpeech: t,
618
- stopSpeech: o,
619
- activateTemplateFirstField: e0
620
- }), (e, p) => (d(), C("div", {
621
- class: z(["tiny-sender", [g0.value, `theme-${e.theme}`, `mode-${l.value}`]]),
622
- "data-theme": e.theme
921
+ clear: le,
922
+ submit: ae,
923
+ startSpeech: pe,
924
+ stopSpeech: he,
925
+ activateTemplateFirstField: fe
926
+ }), (i, E) => (N(), D("div", {
927
+ ref_key: "senderRef",
928
+ ref: u,
929
+ class: Q(["tiny-sender", [Le.value, `theme-${i.theme}`, `mode-${I.value}`]]),
930
+ "data-theme": i.theme
623
931
  }, [
624
- B("div", e2, [
625
- B("div", {
932
+ M("div", ct, [
933
+ M("div", {
626
934
  class: "tiny-sender__input-wrapper",
627
935
  ref_key: "inputWrapperRef",
628
- ref: s
936
+ ref: e
629
937
  }, [
630
- W(a0, { name: "tiny-sender-slide-down" }, {
631
- default: $(() => [
632
- e.$slots.header ? (d(), C("div", t2, [
633
- P(e.$slots, "header")
634
- ])) : R("", !0)
938
+ K(re, { name: "tiny-sender-slide-down" }, {
939
+ default: j(() => [
940
+ i.$slots.header ? (N(), D("div", dt, [
941
+ X(i.$slots, "header")
942
+ ])) : B("", !0)
635
943
  ]),
636
944
  _: 3
637
945
  }),
638
- B("div", {
639
- class: z(["tiny-sender__input-row", { "has-prefix": e.$slots.prefix, "has-header": e.$slots.header }])
946
+ M("div", {
947
+ class: Q(["tiny-sender__input-row", { "has-prefix": i.$slots.prefix, "has-header": i.$slots.header }])
640
948
  }, [
641
- e.$slots.prefix ? (d(), C("div", l2, [
642
- P(e.$slots, "prefix")
643
- ])) : R("", !0),
644
- B("div", s2, [
645
- e.$slots.decorativeContent ? (d(), C("div", n2, [
646
- P(e.$slots, "decorativeContent")
647
- ])) : R("", !0),
648
- f.value ? (d(), V(X0, {
949
+ i.$slots.prefix ? (N(), D("div", ft, [
950
+ X(i.$slots, "prefix")
951
+ ])) : B("", !0),
952
+ M("div", pt, [
953
+ i.$slots.decorativeContent ? (N(), D("div", ht, [
954
+ X(i.$slots, "decorativeContent")
955
+ ])) : B("", !0),
956
+ S.value ? (N(), H(rt, {
649
957
  key: 1,
650
958
  ref_key: "templateEditorRef",
651
- ref: r,
652
- template: e.template,
653
- value: F(a),
654
- "onUpdate:value": H,
655
- onInput: H
656
- }, null, 8, ["template", "value"])) : (d(), V(F(R0), {
657
- key: 2,
658
- ref_key: "inputRef",
659
- ref: w,
660
- autosize: e.autoSize,
661
- type: u0.value,
662
- readonly: d0.value,
663
- resize: "none",
664
- modelValue: F(a),
665
- "onUpdate:modelValue": p[0] || (p[0] = (g) => F0(a) ? a.value = g : null),
666
- disabled: K.value,
667
- placeholder: e.placeholder,
668
- autofocus: e.autofocus,
669
- onKeydown: F(_),
670
- onCompositionstart: p[1] || (p[1] = (g) => v.value = !0),
671
- onCompositionend: C0,
672
- onFocus: D,
673
- onBlur: E
674
- }, null, 8, ["autosize", "type", "readonly", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]))
959
+ ref: o,
960
+ template: i.template,
961
+ value: _(a),
962
+ initialValues: i.templateInitialValues,
963
+ "onUpdate:value": de,
964
+ onInput: de
965
+ }, null, 8, ["template", "value", "initialValues"])) : (N(), D("div", mt, [
966
+ K(_(He), {
967
+ ref_key: "inputRef",
968
+ ref: s,
969
+ autosize: i.autoSize,
970
+ type: Ie.value,
971
+ readonly: me.value,
972
+ resize: "none",
973
+ modelValue: _(a),
974
+ "onUpdate:modelValue": E[0] || (E[0] = (R) => We(a) ? a.value = R : null),
975
+ disabled: ee.value,
976
+ placeholder: i.placeholder,
977
+ autofocus: i.autofocus,
978
+ onKeydown: _(Te),
979
+ onCompositionstart: E[1] || (E[1] = (R) => C.value = !0),
980
+ onCompositionend: Oe,
981
+ onFocus: ke,
982
+ onBlur: Re
983
+ }, null, 8, ["autosize", "type", "readonly", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
984
+ _(T) && !_(C) ? (N(), D("div", gt, [
985
+ M("span", vt, J(_(a)), 1),
986
+ be(J(_(T)) + " ", 1),
987
+ _(v) ? (N(), D("div", yt, "TAB")) : B("", !0)
988
+ ])) : B("", !0)
989
+ ]))
675
990
  ]),
676
- l.value === "single" ? (d(), C("div", o2, [
677
- B("div", {
991
+ I.value === "single" ? (N(), D("div", bt, [
992
+ M("div", {
678
993
  class: "tiny-sender__buttons-container",
679
994
  ref_key: "buttonsContainerRef",
680
- ref: k
995
+ ref: g
681
996
  }, [
682
- P(e.$slots, "actions"),
683
- W(m0, {
684
- class: "inline-buttons",
685
- "allow-speech": e.allowSpeech,
686
- "allow-files": e.allowFiles,
687
- loading: e.loading,
688
- disabled: K.value,
689
- "show-clear": e.clearable,
690
- "has-content": f0.value,
691
- "speech-status": F(j),
692
- "submit-type": e.submitType,
693
- "is-over-limit": i0.value,
694
- onClear: G,
695
- onToggleSpeech: u,
696
- onSubmit: F(y),
697
- onCancel: p[2] || (p[2] = (g) => e.$emit("cancel"))
997
+ X(i.$slots, "actions"),
998
+ K(Ce, {
999
+ "allow-speech": i.allowSpeech,
1000
+ "allow-files": i.allowFiles,
1001
+ loading: i.loading,
1002
+ disabled: ee.value,
1003
+ "show-clear": i.clearable,
1004
+ "has-content": ge.value,
1005
+ "speech-status": _(Z),
1006
+ "submit-type": i.submitType,
1007
+ "is-over-limit": ie.value,
1008
+ onClear: le,
1009
+ onToggleSpeech: oe,
1010
+ onSubmit: _(ae),
1011
+ onCancel: E[2] || (E[2] = (R) => i.$emit("cancel"))
698
1012
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
699
1013
  ], 512)
700
- ])) : R("", !0)
1014
+ ])) : B("", !0)
701
1015
  ], 2),
702
- W(a0, { name: "tiny-sender-slide-up" }, {
703
- default: $(() => [
704
- l.value === "multiple" ? (d(), C("div", {
1016
+ K(re, { name: "tiny-sender-slide-up" }, {
1017
+ default: j(() => [
1018
+ I.value === "multiple" ? (N(), D("div", {
705
1019
  key: 0,
706
- style: D0(N.value),
1020
+ style: Ke(De.value),
707
1021
  class: "tiny-sender__footer-slot tiny-sender__bottom-row"
708
1022
  }, [
709
- B("div", i2, [
710
- P(e.$slots, "footer-left")
1023
+ M("div", wt, [
1024
+ X(i.$slots, "footer-left")
711
1025
  ]),
712
- B("div", a2, [
713
- P(e.$slots, "footer-right"),
714
- e.showWordLimit && e.maxLength !== 1 / 0 ? (d(), C("div", {
1026
+ M("div", _t, [
1027
+ X(i.$slots, "footer-right"),
1028
+ i.showWordLimit && i.maxLength !== 1 / 0 ? (N(), D("div", {
715
1029
  key: 0,
716
- class: z(["tiny-sender__word-limit", { "is-over-limit": i0.value }])
1030
+ class: Q(["tiny-sender__word-limit", { "is-over-limit": ie.value }])
717
1031
  }, [
718
- B("span", r2, U(F(a).length), 1),
719
- E0("/" + U(e.maxLength), 1)
720
- ], 2)) : R("", !0),
721
- l.value === "multiple" ? (d(), C("div", c2, [
722
- B("div", u2, [
723
- W(m0, {
724
- "allow-speech": e.allowSpeech,
725
- "allow-files": e.allowFiles,
726
- loading: e.loading,
727
- disabled: K.value,
728
- "show-clear": e.clearable,
729
- "has-content": f0.value,
730
- "speech-status": F(j),
731
- "submit-type": e.submitType,
732
- "is-over-limit": i0.value,
733
- onClear: G,
734
- onToggleSpeech: u,
735
- onSubmit: F(y),
736
- onCancel: p[3] || (p[3] = (g) => e.$emit("cancel"))
1032
+ M("span", Ct, J(_(a).length), 1),
1033
+ be("/" + J(i.maxLength), 1)
1034
+ ], 2)) : B("", !0),
1035
+ I.value === "multiple" ? (N(), D("div", St, [
1036
+ M("div", Et, [
1037
+ K(Ce, {
1038
+ "allow-speech": i.allowSpeech,
1039
+ "allow-files": i.allowFiles,
1040
+ loading: i.loading,
1041
+ disabled: ee.value,
1042
+ "show-clear": i.clearable,
1043
+ "has-content": ge.value,
1044
+ "speech-status": _(Z),
1045
+ "submit-type": i.submitType,
1046
+ "is-over-limit": ie.value,
1047
+ onClear: le,
1048
+ onToggleSpeech: oe,
1049
+ onSubmit: _(ae),
1050
+ onCancel: E[3] || (E[3] = (R) => i.$emit("cancel"))
737
1051
  }, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
738
1052
  ])
739
- ])) : R("", !0)
1053
+ ])) : B("", !0)
740
1054
  ])
741
- ], 4)) : e.$slots.footer ? (d(), C("div", d2, [
742
- P(e.$slots, "footer")
743
- ])) : R("", !0)
1055
+ ], 4)) : i.$slots.footer ? (N(), D("div", Nt, [
1056
+ X(i.$slots, "footer")
1057
+ ])) : B("", !0)
744
1058
  ]),
745
1059
  _: 3
746
1060
  })
747
1061
  ], 512)
748
1062
  ]),
749
- W(a0, { name: "tiny-sender-slide-up" }, {
750
- default: $(() => [
751
- O.value && X.value.length ? (d(), C("div", f2, [
752
- (d(!0), C(r0, null, v0(X.value, (g, J) => (d(), C("div", {
753
- key: J,
754
- class: "suggestion-item",
755
- onClick: (p0) => Y(g)
756
- }, U(g), 9, p2))), 128))
757
- ])) : R("", !0)
1063
+ K(re, { name: "tiny-sender-slide-up" }, {
1064
+ default: j(() => [
1065
+ _(r) && _(k).length ? (N(), D("div", {
1066
+ key: 0,
1067
+ ref_key: "suggestionsListRef",
1068
+ ref: A,
1069
+ class: "tiny-sender__suggestions"
1070
+ }, [
1071
+ (N(!0), D(we, null, _e(_(k), (R, z) => (N(), D("div", {
1072
+ key: z,
1073
+ class: Q(["suggestion-item", { highlighted: z === _(p) }]),
1074
+ onMouseenter: (U) => _(F)(z),
1075
+ onMousedown: Pe((U) => _(c)(R), ["prevent"])
1076
+ }, [
1077
+ M("span", kt, [
1078
+ K(_(Je))
1079
+ ]),
1080
+ M("span", Rt, [
1081
+ (N(!0), D(we, null, _e(_(O)(R, _(a)), (U, ve) => (N(), D("span", {
1082
+ key: ve,
1083
+ class: Q({ "suggestion-item__text--match": U.isMatch, "suggestion-item__text--normal": !U.isMatch })
1084
+ }, J(U.text), 3))), 128))
1085
+ ])
1086
+ ], 42, Tt))), 128))
1087
+ ], 512)) : B("", !0)
758
1088
  ]),
759
1089
  _: 1
760
1090
  }),
761
- Q.value ? (d(), C("div", h2, U(Q.value), 1)) : R("", !0)
762
- ], 10, Y0));
1091
+ Y.value ? (N(), D("div", It, J(Y.value), 1)) : B("", !0)
1092
+ ], 10, ut));
763
1093
  }
764
1094
  });
765
- o0.name = "TrSender";
766
- const m2 = function(n) {
767
- n.component(o0.name, o0);
1095
+ se.name = "TrSender";
1096
+ const Dt = function(n) {
1097
+ n.component(se.name, se);
768
1098
  };
769
- o0.install = m2;
1099
+ se.install = Dt;
770
1100
  export {
771
- o0 as default
1101
+ se as default
772
1102
  };