@mobilon-dev/chotto 0.3.92 → 0.3.93

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,9 +1,9 @@
1
- import { defineComponent as Te, inject as be, ref as E, computed as _, watch as p, nextTick as S, unref as u, onMounted as we, onUnmounted as Ce, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as G, normalizeClass as z, createBlock as Ae, createCommentVNode as O, renderSlot as U, toDisplayString as Ee, withDirectives as Fe, withKeys as Me, vModelText as Re } from "vue";
2
- import { useImmediateDebouncedRef as He } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { useMessageDraft as ke } from "../../../hooks/useMessageDraft.js";
1
+ import { defineComponent as be, inject as we, watch as d, ref as E, computed as _, nextTick as S, unref as u, onMounted as Ce, onUnmounted as Ae, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as O, normalizeClass as z, createBlock as Ee, createCommentVNode as U, renderSlot as Y, toDisplayString as Fe, withDirectives as Me, withKeys as Re, vModelText as He } from "vue";
2
+ import { useImmediateDebouncedRef as ke } from "../../../hooks/useImmediateDebouncedRef.js";
3
+ import { useMessageDraft as Le, commitChatDraftToList as De } from "../../../hooks/useMessageDraft.js";
4
4
  import "../../../hooks/useSearchModel.js";
5
5
  import "../../../hooks/useTheme.js";
6
- import { useEmojiNative as Le } from "../../../hooks/useEmojiNative.js";
6
+ import { useEmojiNative as Pe } from "../../../hooks/useEmojiNative.js";
7
7
  /* empty css */
8
8
  /* empty css */
9
9
  import { t as I } from "../../../locale/useLocale.js";
@@ -11,18 +11,18 @@ import { t as I } from "../../../locale/useLocale.js";
11
11
  import "../../../node_modules/linkifyjs/dist/linkify.js";
12
12
  import "../../../node_modules/linkify-string/dist/linkify-string.js";
13
13
  import "../../../functions/parseMarkdown.js";
14
- import { textToAppleEmojiHtml as De, textContainsEmoji as Pe, previousGraphemeIndex as Y, nextGraphemeIndex as V, snapIndexToGrapheme as $ } from "../../../functions/renderAppleEmojis.js";
15
- import { hideEditPreview as We } from "../../../hooks/messages/useStartEdit.js";
16
- import qe from "./icons/SendIcon.vue.js";
17
- import Be from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
- import ze from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
19
- const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = { class: "chat-input__inline-buttons" }, Oe = {
14
+ import { textToAppleEmojiHtml as We, textContainsEmoji as qe, previousGraphemeIndex as V, nextGraphemeIndex as $, snapIndexToGrapheme as J } from "../../../functions/renderAppleEmojis.js";
15
+ import { hideEditPreview as Be } from "../../../hooks/messages/useStartEdit.js";
16
+ import ze from "./icons/SendIcon.vue.js";
17
+ import Ke from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
18
+ import je from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
19
+ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = { class: "chat-input__inline-buttons" }, Ye = {
20
20
  key: 0,
21
21
  class: "chat-input__input chat-input__disabled-placeholder"
22
- }, Ue = {
22
+ }, Ve = {
23
23
  key: 1,
24
24
  class: "chat-input__input-wrap"
25
- }, Ye = ["innerHTML"], Ve = ["disabled", "placeholder"], $e = ["disabled"], Je = { class: "" }, Qe = { class: "chat-input__third-line" }, K = 40, gt = /* @__PURE__ */ Te({
25
+ }, $e = ["innerHTML"], Je = ["disabled", "placeholder"], Qe = ["disabled"], Xe = { class: "" }, Ze = { class: "chat-input__third-line" }, K = 40, xt = /* @__PURE__ */ be({
26
26
  __name: "ChatInput",
27
27
  props: {
28
28
  state: {
@@ -51,18 +51,26 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
51
51
  }
52
52
  },
53
53
  emits: ["send", "typing"],
54
- setup(T, { emit: J }) {
55
- const L = J, b = be("chatAppId"), { resetMessage: Q, getMessage: o, setMessageText: M, setForceSendMessage: X, resetEdit: Z, resetMessageFile: ee } = ke(b), { isNative: te } = Le(b), n = E(), m = E(), v = E(null), w = E(!1), ne = He("", 2e3), D = _(() => {
54
+ setup(T, { emit: Q }) {
55
+ const L = Q, b = we("chatAppId"), { resetMessage: X, getMessage: l, setMessageText: M, setForceSendMessage: Z, resetEdit: ee, resetMessageFile: te } = Le(b), { isNative: ne } = Pe(b);
56
+ let j = l().id;
57
+ d(
58
+ () => l().id,
59
+ (e) => {
60
+ j = e;
61
+ }
62
+ );
63
+ const n = E(), m = E(), v = E(null), w = E(!1), ie = ke("", 2e3), D = _(() => {
56
64
  var e;
57
- return (e = o().file) == null ? void 0 : e.preview;
58
- }), ie = _(
59
- () => De(o().text || "", v.value)
65
+ return (e = l().file) == null ? void 0 : e.preview;
66
+ }), oe = _(
67
+ () => We(l().text || "", v.value)
60
68
  ), g = _(
61
- () => !te.value && Pe(o().text || "")
69
+ () => !ne.value && qe(l().text || "")
62
70
  ), c = () => {
63
71
  if (!m.value || !n.value) return;
64
- const e = n.value, t = m.value, l = Math.max(0, e.offsetWidth - e.clientWidth);
65
- t.style.right = l > 0 ? `${l}px` : "", t.scrollTop = e.scrollTop;
72
+ const e = n.value, t = m.value, o = Math.max(0, e.offsetWidth - e.clientWidth);
73
+ t.style.right = o > 0 ? `${o}px` : "", t.scrollTop = e.scrollTop;
66
74
  };
67
75
  let y = 0;
68
76
  function P() {
@@ -71,64 +79,64 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
71
79
  function le(e = "nearest") {
72
80
  const t = n.value;
73
81
  if (!t || !g.value) return;
74
- const l = t.value, i = $(l, t.selectionStart, e), r = $(l, t.selectionEnd, e);
82
+ const o = t.value, i = J(o, t.selectionStart, e), r = J(o, t.selectionEnd, e);
75
83
  (i !== t.selectionStart || r !== t.selectionEnd) && t.setSelectionRange(i, r);
76
84
  }
77
85
  function W() {
78
- le("nearest"), d();
86
+ le("nearest"), f();
79
87
  }
80
- function oe(e) {
88
+ function se(e) {
81
89
  if (!g.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
82
90
  const t = n.value;
83
91
  if (!t) return;
84
- const l = t.value, i = t.selectionStart !== t.selectionEnd;
92
+ const o = t.value, i = t.selectionStart !== t.selectionEnd;
85
93
  if (e.shiftKey) {
86
94
  requestAnimationFrame(() => W());
87
95
  return;
88
96
  }
89
97
  if (i) {
90
98
  e.preventDefault();
91
- const x = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, A = e.key === "ArrowLeft" ? Y(l, x) : V(l, x);
92
- t.setSelectionRange(A, A), d();
99
+ const x = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, A = e.key === "ArrowLeft" ? V(o, x) : $(o, x);
100
+ t.setSelectionRange(A, A), f();
93
101
  return;
94
102
  }
95
103
  e.preventDefault();
96
- const r = t.selectionStart, f = e.key === "ArrowLeft" ? Y(l, r) : V(l, r);
97
- t.setSelectionRange(f, f), d();
104
+ const r = t.selectionStart, p = e.key === "ArrowLeft" ? V(o, r) : $(o, r);
105
+ t.setSelectionRange(p, p), f();
98
106
  }
99
- function d() {
107
+ function f() {
100
108
  if (!g.value) {
101
109
  P();
102
110
  return;
103
111
  }
104
112
  y && cancelAnimationFrame(y), y = requestAnimationFrame(() => {
105
- var f;
113
+ var p;
106
114
  y = 0;
107
115
  const e = n.value;
108
116
  if (!e) {
109
117
  P();
110
118
  return;
111
119
  }
112
- const t = e.selectionStart, l = e.selectionEnd;
113
- if (t === l) {
120
+ const t = e.selectionStart, o = e.selectionEnd;
121
+ if (t === o) {
114
122
  v.value !== null && (v.value = null, S(c));
115
123
  return;
116
124
  }
117
125
  const i = v.value;
118
- if (i && i.start === t && i.end === l) return;
119
- const r = ((f = m.value) == null ? void 0 : f.scrollTop) ?? 0;
120
- v.value = { start: t, end: l }, S(() => {
126
+ if (i && i.start === t && i.end === o) return;
127
+ const r = ((p = m.value) == null ? void 0 : p.scrollTop) ?? 0;
128
+ v.value = { start: t, end: o }, S(() => {
121
129
  m.value && (m.value.scrollTop = r), c();
122
130
  });
123
131
  });
124
132
  }
125
- function se(e) {
126
- e.buttons && d();
133
+ function ae(e) {
134
+ e.buttons && f();
127
135
  }
128
- function j() {
129
- document.activeElement === n.value && d();
136
+ function N() {
137
+ document.activeElement === n.value && f();
130
138
  }
131
- const a = T, ae = _(() => !!(a.state == "disabled" || o().text == "" && !o().file || o().isRecording)), re = _(() => {
139
+ const a = T, re = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ue = _(() => {
132
140
  var t;
133
141
  if (a.inputButtonColor)
134
142
  return a.inputButtonColor;
@@ -136,31 +144,31 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
136
144
  return "#25D366";
137
145
  const e = a.selectedChannel.channelId.toLowerCase();
138
146
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
139
- }), ue = _(() => {
147
+ }), ce = _(() => {
140
148
  var t;
141
149
  if (!((t = a.selectedChannel) != null && t.channelId))
142
150
  return I("component.ChatInput.InputPlaceholder");
143
151
  const e = a.selectedChannel.channelId.toLowerCase();
144
152
  return e.includes("whatsapp") || e.includes("waba") ? I("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? I("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? I("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? I("component.ChatInput.MaxInputPlaceholder") : I("component.ChatInput.InputPlaceholder");
145
153
  });
146
- p(
147
- () => ne.value,
154
+ d(
155
+ () => ie.value,
148
156
  () => {
149
157
  L("typing");
150
158
  }
151
- ), p(
159
+ ), d(
152
160
  () => {
153
161
  var e;
154
- return (e = o().edit) == null ? void 0 : e.messageId;
162
+ return (e = l().edit) == null ? void 0 : e.messageId;
155
163
  },
156
164
  (e, t) => {
157
165
  e != null && e !== t && (w.value = !0, S(() => {
158
166
  if (!w.value) return;
159
- const l = n.value;
160
- l && (C(l), w.value = !1, H(l), requestAnimationFrame(() => H(l)));
167
+ const o = n.value;
168
+ o && (C(o), w.value = !1, H(o), requestAnimationFrame(() => H(o)));
161
169
  }));
162
170
  }
163
- ), p(
171
+ ), d(
164
172
  () => a.focusOnInputArea,
165
173
  () => {
166
174
  a.focusOnInputArea && S(() => {
@@ -169,15 +177,15 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
169
177
  });
170
178
  },
171
179
  { immediate: !0 }
172
- ), p(
173
- () => o().text,
180
+ ), d(
181
+ () => l().text,
174
182
  () => {
175
183
  const e = n.value;
176
184
  e && (C(e), w.value && (w.value = !1, H(e), requestAnimationFrame(() => H(e))));
177
185
  },
178
186
  { immediate: !0, flush: "post" }
179
- ), p(
180
- () => o().id,
187
+ ), d(
188
+ () => l().id,
181
189
  () => {
182
190
  const e = n.value;
183
191
  e && (R(e), requestAnimationFrame(() => {
@@ -185,64 +193,64 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
185
193
  t && C(t);
186
194
  }));
187
195
  }
188
- ), p(g, (e) => {
196
+ ), d(g, (e) => {
189
197
  e && S(() => {
190
198
  const t = n.value;
191
199
  if (!t) return;
192
- const l = t.scrollTop;
193
- C(t), t.scrollTop = l, c(), requestAnimationFrame(c);
200
+ const o = t.scrollTop;
201
+ C(t), t.scrollTop = o, c(), requestAnimationFrame(c);
194
202
  });
195
203
  });
196
204
  function R(e) {
197
- const t = o().inputHeight;
205
+ const t = l().inputHeight;
198
206
  e.style.height = (t || K) + "px", (!t || t <= K) && (e.style.overflowY = "hidden");
199
207
  }
200
- function ce(e) {
208
+ function de(e) {
201
209
  const t = parseFloat(e.style.height);
202
- Number.isFinite(t) && (o().inputHeight = t);
210
+ Number.isFinite(t) && (l().inputHeight = t);
203
211
  }
204
212
  function C(e) {
205
- const t = o().text || "";
213
+ const t = l().text || "";
206
214
  if (e.value !== t || e.clientWidth === 0) {
207
215
  R(e);
208
216
  return;
209
217
  }
210
- const l = e.scrollTop;
218
+ const o = e.scrollTop;
211
219
  e.style.height = "auto";
212
- const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, f = parseFloat(i.lineHeight) || r * 1.4, x = K, A = f * 11, B = e.scrollHeight, ge = t.split(`
220
+ const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x = K, A = p * 11, B = e.scrollHeight, ye = t.split(`
213
221
  `).length > 1, s = document.createElement("div");
214
222
  s.style.position = "absolute", s.style.visibility = "hidden", s.style.whiteSpace = "nowrap", s.style.font = i.font, s.style.fontSize = i.fontSize, s.style.fontFamily = i.fontFamily, s.style.fontWeight = i.fontWeight, s.style.letterSpacing = i.letterSpacing, s.textContent = t, document.body.appendChild(s);
215
- const ye = s.offsetWidth;
223
+ const xe = s.offsetWidth;
216
224
  document.body.removeChild(s);
217
- const xe = parseFloat(i.paddingLeft) || 0, _e = parseFloat(i.paddingRight) || 0, Se = e.clientWidth - xe - _e, Ie = ye > Se, N = ge || Ie;
218
- if (N && B <= x + 1) {
225
+ const _e = parseFloat(i.paddingLeft) || 0, Se = parseFloat(i.paddingRight) || 0, Ie = e.clientWidth - _e - Se, Te = xe > Ie, G = ye || Te;
226
+ if (G && B <= x + 1) {
219
227
  R(e);
220
228
  return;
221
229
  }
222
- t.trim() && N ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = l) : (e.style.height = x + "px", e.style.overflowY = "hidden"), ce(e), c(), requestAnimationFrame(c);
230
+ t.trim() && G ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = o) : (e.style.height = x + "px", e.style.overflowY = "hidden"), de(e), c(), requestAnimationFrame(c);
223
231
  }
224
232
  function H(e) {
225
- if (a.state === "disabled" || o().isRecording) return;
233
+ if (a.state === "disabled" || l().isRecording) return;
226
234
  const t = e.value.length;
227
235
  e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, c();
228
236
  }
229
- p(
230
- () => o().forceSend,
237
+ d(
238
+ () => l().forceSend,
231
239
  () => {
232
- o().forceSend && (q(), X(!1));
240
+ l().forceSend && (q(), Z(!1));
233
241
  }
234
242
  );
235
- const de = (e) => {
243
+ const fe = (e) => {
236
244
  const t = e.target;
237
- L("typing", t.value), d();
245
+ L("typing", t.value), f();
238
246
  };
239
- we(() => {
247
+ Ce(() => {
240
248
  const e = n.value;
241
- e && (R(e), C(e)), document.addEventListener("selectionchange", j);
242
- }), Ce(() => {
243
- document.removeEventListener("selectionchange", j), y && cancelAnimationFrame(y);
249
+ e && (R(e), C(e)), document.addEventListener("selectionchange", N);
250
+ }), Ae(() => {
251
+ De(j), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
244
252
  });
245
- const fe = (e) => {
253
+ const pe = (e) => {
246
254
  if (e.shiftKey) {
247
255
  if (n.value instanceof HTMLTextAreaElement) {
248
256
  let t = n.value.selectionStart;
@@ -259,31 +267,31 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
259
267
  e.preventDefault();
260
268
  } else
261
269
  e.preventDefault(), q();
262
- }, pe = (e) => {
270
+ }, he = (e) => {
263
271
  if (n.value) {
264
272
  const t = n.value.value;
265
273
  n.value.value = e.newText;
266
- const l = e.newText.length - (t.length - (e.end - e.start)), i = e.start + l;
274
+ const o = e.newText.length - (t.length - (e.end - e.start)), i = e.start + o;
267
275
  M(e.newText), S(() => {
268
276
  n.value && (n.value.setSelectionRange(i, i), n.value.focus());
269
277
  });
270
278
  }
271
279
  };
272
- function he() {
273
- ee();
274
- }
275
280
  function me() {
276
- Z(), M(""), We(b), n.value && n.value.focus();
281
+ te();
277
282
  }
278
283
  function ve() {
279
- const e = o();
284
+ ee(), M(""), Be(b), n.value && n.value.focus();
285
+ }
286
+ function ge() {
287
+ const e = l();
280
288
  return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
281
289
  }
282
290
  const q = () => {
283
- var t, l;
284
- const e = E(o());
285
- if (e.value.edit && ve()) {
286
- me();
291
+ var t, o;
292
+ const e = E(l());
293
+ if (e.value.edit && ge()) {
294
+ ve();
287
295
  return;
288
296
  }
289
297
  if (e.value.text != "" || e.value.file) {
@@ -295,78 +303,78 @@ const Ke = { class: "chat-input__container" }, je = ["id"], Ne = ["id"], Ge = {
295
303
  size: "",
296
304
  reply: void 0
297
305
  };
298
- e.value.file ? (i.type = "message." + e.value.file.type, i.url = e.value.file.url, i.filename = e.value.file.name, i.size = (t = e.value.file.size) == null ? void 0 : t.toString(), i.text = (l = e == null ? void 0 : e.value) == null ? void 0 : l.text.trim()) : (i.type = "message.text", i.text = e.value.text.trim()), e.value.reply && (i.reply = e.value.reply), e.value.edit && (i.edit = e.value.edit), L("send", i), Q(), n.value && n.value.focus();
306
+ e.value.file ? (i.type = "message." + e.value.file.type, i.url = e.value.file.url, i.filename = e.value.file.name, i.size = (t = e.value.file.size) == null ? void 0 : t.toString(), i.text = (o = e == null ? void 0 : e.value) == null ? void 0 : o.text.trim()) : (i.type = "message.text", i.text = e.value.text.trim()), e.value.reply && (i.reply = e.value.reply), e.value.edit && (i.edit = e.value.edit), L("send", i), X(), n.value && n.value.focus();
299
307
  }
300
308
  };
301
- return (e, t) => (F(), k("div", Ke, [
309
+ return (e, t) => (F(), k("div", Ne, [
302
310
  h("div", {
303
311
  id: "chat-input-reply-line-" + u(b),
304
312
  class: "chat-input__reply-line"
305
- }, null, 8, je),
313
+ }, null, 8, Ge),
306
314
  h("div", {
307
315
  id: "chat-input-file-line-" + u(b),
308
316
  class: z(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
309
317
  }, [
310
- D.value ? (F(), Ae(ze, {
318
+ D.value ? (F(), Ee(je, {
311
319
  key: 0,
312
320
  "file-info": D.value,
313
- onReset: he
314
- }, null, 8, ["file-info"])) : O("", !0)
315
- ], 10, Ne),
316
- h("div", Ge, [
317
- U(e.$slots, "inline-buttons", {}, void 0, !0)
321
+ onReset: me
322
+ }, null, 8, ["file-info"])) : U("", !0)
323
+ ], 10, Oe),
324
+ h("div", Ue, [
325
+ Y(e.$slots, "inline-buttons", {}, void 0, !0)
318
326
  ]),
319
- T.disabledPlaceholder && (T.state == "disabled" || u(o)().isRecording) ? (F(), k("div", Oe, Ee(T.disabledPlaceholder), 1)) : (F(), k("div", Ue, [
327
+ T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ye, Fe(T.disabledPlaceholder), 1)) : (F(), k("div", Ve, [
320
328
  g.value ? (F(), k("div", {
321
329
  key: 0,
322
330
  ref_key: "refMirror",
323
331
  ref: m,
324
332
  class: "chat-input__input-mirror",
325
333
  "aria-hidden": "true",
326
- innerHTML: ie.value
327
- }, null, 8, Ye)) : O("", !0),
328
- Fe(h("textarea", {
334
+ innerHTML: oe.value
335
+ }, null, 8, $e)) : U("", !0),
336
+ Me(h("textarea", {
329
337
  ref_key: "refInput",
330
338
  ref: n,
331
- "onUpdate:modelValue": t[0] || (t[0] = (l) => u(o)().text = l),
339
+ "onUpdate:modelValue": t[0] || (t[0] = (o) => u(l)().text = o),
332
340
  rows: "1",
333
- disabled: T.state == "disabled" || u(o)().isRecording,
341
+ disabled: T.state == "disabled" || u(l)().isRecording,
334
342
  class: z(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
335
- placeholder: ue.value,
343
+ placeholder: ce.value,
336
344
  onKeydown: [
337
- oe,
338
- Me(fe, ["enter"])
345
+ se,
346
+ Re(pe, ["enter"])
339
347
  ],
340
- onInput: de,
348
+ onInput: fe,
341
349
  onScroll: c,
342
- onSelect: d,
350
+ onSelect: f,
343
351
  onMouseup: W,
344
352
  onKeyup: W,
345
- onMousemove: se,
353
+ onMousemove: ae,
346
354
  onBlur: P
347
- }, null, 42, Ve), [
348
- [Re, u(o)().text]
355
+ }, null, 42, Je), [
356
+ [He, u(l)().text]
349
357
  ])
350
358
  ])),
351
- G(Be, {
359
+ O(Ke, {
352
360
  textarea: n.value,
353
- onFormatApplied: pe
361
+ onFormatApplied: he
354
362
  }, null, 8, ["textarea"]),
355
363
  h("button", {
356
- class: z(["chat-input__button", { "chat-input__button-disabled": ae.value }]),
357
- disabled: u(o)().isRecording,
364
+ class: z(["chat-input__button", { "chat-input__button-disabled": re.value }]),
365
+ disabled: u(l)().isRecording,
358
366
  onClick: q
359
367
  }, [
360
- h("span", Je, [
361
- G(u(qe), { color: re.value }, null, 8, ["color"])
368
+ h("span", Xe, [
369
+ O(u(ze), { color: ue.value }, null, 8, ["color"])
362
370
  ])
363
- ], 10, $e),
364
- h("div", Qe, [
365
- U(e.$slots, "buttons", {}, void 0, !0)
371
+ ], 10, Qe),
372
+ h("div", Ze, [
373
+ Y(e.$slots, "buttons", {}, void 0, !0)
366
374
  ])
367
375
  ]));
368
376
  }
369
377
  });
370
378
  export {
371
- gt as default
379
+ xt as default
372
380
  };
@@ -1,101 +1,123 @@
1
- import { ref as x, getCurrentInstance as R, inject as h, computed as S, unref as D, watch as C } from "vue";
2
- const o = x([]);
3
- function E(s) {
1
+ import { ref as R, getCurrentInstance as D, inject as C, computed as F, unref as P, watch as S } from "vue";
2
+ const r = R([]);
3
+ function T(e) {
4
4
  return {
5
- id: s,
5
+ id: e,
6
6
  text: "",
7
7
  file: void 0,
8
8
  forceSend: !1,
9
9
  isRecording: !1
10
10
  };
11
11
  }
12
- function u(s) {
13
- const t = o.value.find((a) => a.id === s);
14
- if (t) return t;
15
- const i = E(s);
16
- return o.value.push(i), i;
12
+ function f(e) {
13
+ const i = r.value.find((c) => c.id === e);
14
+ if (i) return i;
15
+ const s = T(e);
16
+ return r.value.push(s), s;
17
17
  }
18
- function j(s, t) {
19
- if (!(t == null || t === ""))
20
- return o.value.find((i) => i.id === `${s}:${t}`);
18
+ function B(e, i) {
19
+ if (!(i == null || i === ""))
20
+ return r.value.find((s) => s.id === `${e}:${i}`);
21
21
  }
22
- function F(s, t) {
22
+ function E(e) {
23
+ return e.replace(/\s+/g, " ").trim();
24
+ }
25
+ function a(e) {
26
+ var c, u, o;
27
+ if (!e) return;
28
+ if (e.edit) {
29
+ e.listPreviewText = void 0, e.listPreviewFile = void 0;
30
+ return;
31
+ }
32
+ const i = E(e.text || "");
33
+ e.listPreviewText = i || void 0;
34
+ const s = ((c = e.file) == null ? void 0 : c.name) || ((o = (u = e.file) == null ? void 0 : u.preview) == null ? void 0 : o.fileName) || "";
35
+ e.listPreviewFile = e.file ? { name: s, type: e.file.type } : void 0;
36
+ }
37
+ function b(e) {
38
+ e && a(r.value.find((i) => i.id === e));
39
+ }
40
+ function L(e, i) {
23
41
  if (typeof document > "u") return;
24
- const i = document.getElementById("chat-input-reply-line-" + s);
25
- i && (i.style.display = t.reply || t.edit ? "inherit" : "none");
42
+ const s = document.getElementById("chat-input-reply-line-" + e);
43
+ s && (s.style.display = i.reply || i.edit ? "inherit" : "none");
26
44
  }
27
- const B = (s) => {
28
- const t = R() ? h("selectedChat", void 0) : void 0, i = S(() => {
29
- const e = t ? D(t) : void 0, n = e == null ? void 0 : e.chatId;
30
- return n == null || n === "" ? s : `${s}:${n}`;
45
+ const k = (e) => {
46
+ const i = D() ? C("selectedChat", void 0) : void 0, s = F(() => {
47
+ const t = i ? P(i) : void 0, n = t == null ? void 0 : t.chatId;
48
+ return n == null || n === "" ? e : `${e}:${n}`;
31
49
  });
32
- C(
33
- i,
34
- (e, n) => {
35
- const c = u(e);
36
- n !== void 0 && n !== e && F(s, c);
50
+ S(
51
+ s,
52
+ (t, n) => {
53
+ const l = f(t);
54
+ if (n !== void 0 && n !== t) {
55
+ const w = r.value.find((h) => h.id === n);
56
+ a(w), L(e, l);
57
+ }
37
58
  },
38
59
  { immediate: !0 }
39
60
  );
40
- const a = () => {
41
- const e = i.value, n = o.value.findIndex((c) => c.id === e);
42
- return n !== -1 ? n : (u(e), o.value.findIndex((c) => c.id === e));
43
- }, f = () => {
44
- const e = d();
45
- o.value[a()] = {
46
- id: e.id,
61
+ const c = () => {
62
+ const t = s.value, n = r.value.findIndex((l) => l.id === t);
63
+ return n !== -1 ? n : (f(t), r.value.findIndex((l) => l.id === t));
64
+ }, u = () => {
65
+ const t = d();
66
+ r.value[c()] = {
67
+ id: t.id,
47
68
  text: "",
48
69
  file: void 0,
49
70
  reply: void 0,
50
71
  edit: void 0,
51
72
  forceSend: !1,
52
- isRecording: e.isRecording
73
+ isRecording: t.isRecording
53
74
  };
54
- }, r = (e) => {
75
+ }, o = (t) => {
55
76
  const n = d();
56
- o.value[a()] = {
77
+ r.value[c()] = {
57
78
  ...n,
58
79
  forceSend: !1,
59
- ...e,
80
+ ...t,
60
81
  id: n.id
61
82
  };
62
- }, l = (e) => {
63
- r({ text: e });
64
- }, v = (e) => {
65
- r({ file: e });
66
- }, g = () => {
67
- r({ file: void 0 });
68
- }, p = (e) => {
69
- r({ reply: e, edit: void 0 });
83
+ }, v = (t) => {
84
+ o({ text: t });
85
+ }, g = (t) => {
86
+ o({ file: t });
87
+ }, p = () => {
88
+ o({ file: void 0 });
89
+ }, m = (t) => {
90
+ o({ reply: t, edit: void 0 });
70
91
  }, y = () => {
71
- r({ reply: void 0 });
72
- }, M = (e) => {
73
- r({ edit: e, reply: void 0 });
74
- }, m = () => {
75
- r({ edit: void 0 });
92
+ o({ reply: void 0 });
93
+ }, x = (t) => {
94
+ o({ edit: t, reply: void 0 });
95
+ }, M = () => {
96
+ o({ edit: void 0 });
76
97
  };
77
98
  function d() {
78
- return u(i.value);
99
+ return f(s.value);
79
100
  }
80
101
  return {
81
102
  getMessage: d,
82
- resetMessage: f,
83
- setMessageFile: v,
84
- resetMessageFile: g,
85
- setMessageText: l,
86
- setReply: p,
103
+ resetMessage: u,
104
+ setMessageFile: g,
105
+ resetMessageFile: p,
106
+ setMessageText: v,
107
+ setReply: m,
87
108
  resetReply: y,
88
- setEdit: M,
89
- resetEdit: m,
90
- setForceSendMessage: (e) => {
91
- d().forceSend = e;
109
+ setEdit: x,
110
+ resetEdit: M,
111
+ setForceSendMessage: (t) => {
112
+ d().forceSend = t;
92
113
  },
93
- setRecordingMessage: (e) => {
94
- d().isRecording = e;
114
+ setRecordingMessage: (t) => {
115
+ d().isRecording = t;
95
116
  }
96
117
  };
97
118
  };
98
119
  export {
99
- j as getChatDraft,
100
- B as useMessageDraft
120
+ b as commitChatDraftToList,
121
+ B as getChatDraft,
122
+ k as useMessageDraft
101
123
  };