@mobilon-dev/chotto 0.3.125 → 0.3.127

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.
Files changed (28) hide show
  1. package/dist/chotto.css +1 -1
  2. package/dist/components/2_blocks/CommunicationPanel/CommunicationPanel.vue.js +51 -51
  3. package/dist/components/2_blocks/CommunicationPanel/composables/useCommunicationActions.js +52 -50
  4. package/dist/components/2_blocks/FeedFoundItem/FeedFoundItem.vue.js +2 -2
  5. package/dist/components/2_blocks/FeedFoundItem/FeedFoundItem.vue2.js +41 -31
  6. package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue.js +2 -2
  7. package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue2.js +51 -30
  8. package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue.js +2 -2
  9. package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue2.js +286 -270
  10. package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue.js +3 -3
  11. package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue2.js +40 -34
  12. package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +1 -1
  13. package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +282 -259
  14. package/dist/components/3_compounds/Feed/composables/useFeedScroll.js +79 -59
  15. package/dist/functions/parseMarkdown.js +7 -6
  16. package/dist/hooks/messages/useImageFeedSrc.js +50 -0
  17. package/dist/index.js +118 -113
  18. package/dist/themes/dark.css +1 -1
  19. package/dist/themes/default.css +1 -1
  20. package/dist/themes/glass.css +1 -1
  21. package/dist/themes/green.css +1 -1
  22. package/dist/themes/mobilon1.css +1 -1
  23. package/dist/types/src/components/2_feed_elements/ImageMessage/stories/ImageMessage.stories.d.ts +2 -0
  24. package/dist/types/src/components/3_compounds/Feed/composables/useFeedScroll.d.ts +3 -0
  25. package/dist/types/src/components/4_layouts/ChatWrapper/styles/types.d.ts +4 -0
  26. package/dist/types/src/hooks/messages/index.d.ts +1 -0
  27. package/dist/types/src/hooks/messages/useImageFeedSrc.d.ts +29 -0
  28. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { defineComponent as Ge, inject as Oe, watch as p, ref as b, computed as v, provide as Ue, nextTick as F, unref as r, onMounted as Ve, onUnmounted as Ye, createElementBlock as g, openBlock as h, normalizeClass as q, toDisplayString as N, Fragment as ie, createElementVNode as f, createVNode as z, createCommentVNode as V, renderList as Xe, createBlock as Je, renderSlot as oe, withDirectives as Qe, withKeys as Ze, vModelText as et } from "vue";
2
- import { useImmediateDebouncedRef as tt } from "../../../hooks/useImmediateDebouncedRef.js";
3
- import { MAX_ATTACHED_FILES as se, resolveMessageDraftStore as nt, useMessageDraft as lt, getDraftFiles as it } from "../../../hooks/useMessageDraft.js";
4
- import { useEmojiNative as ot } from "../../../hooks/useEmojiNative.js";
1
+ import { defineComponent as $e, inject as Oe, watch as p, ref as S, computed as v, provide as Ge, nextTick as I, unref as d, onMounted as Ue, onUnmounted as Ve, createElementBlock as g, openBlock as h, normalizeClass as j, toDisplayString as q, Fragment as re, createElementVNode as f, createVNode as z, createCommentVNode as Q, renderList as Xe, createBlock as Ye, renderSlot as ce, withDirectives as Je, withKeys as Qe, vModelText as Ze } from "vue";
2
+ import { useImmediateDebouncedRef as et } from "../../../hooks/useImmediateDebouncedRef.js";
3
+ import { MAX_ATTACHED_FILES as ue, resolveMessageDraftStore as tt, useMessageDraft as nt, getDraftFiles as it } from "../../../hooks/useMessageDraft.js";
4
+ import { useEmojiNative as lt } from "../../../hooks/useEmojiNative.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
7
  import { t as m } from "../../../locale/useLocale.js";
@@ -9,25 +9,25 @@ import { t as m } from "../../../locale/useLocale.js";
9
9
  import "../../../node_modules/linkifyjs/dist/linkify.js";
10
10
  import "../../../node_modules/linkify-string/dist/linkify-string.js";
11
11
  import "../../../functions/parseMarkdown.js";
12
- import { textToAppleEmojiHtml as st, textContainsEmoji as at, previousGraphemeIndex as ae, nextGraphemeIndex as re, snapIndexToGrapheme as ce } from "../../../functions/renderAppleEmojis.js";
13
- import { useStartEdit as rt, hideEditPreview as ct } from "../../../hooks/messages/useStartEdit.js";
14
- import { canStartEditLastSent as ut, isEditableLastSentCandidate as dt } from "../../../hooks/messages/canStartEditLastSent.js";
15
- import { buildEditPayload as ft } from "../../../hooks/messages/buildEditPayload.js";
16
- import pt from "./icons/SendIcon.vue.js";
17
- import ue from "./icons/ArrowIcon.vue.js";
18
- import ht from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
19
- import mt from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
20
- const vt = {
12
+ import { textToAppleEmojiHtml as ot, textContainsEmoji as at, previousGraphemeIndex as de, nextGraphemeIndex as fe, snapIndexToGrapheme as pe } from "../../../functions/renderAppleEmojis.js";
13
+ import { useStartEdit as st, hideEditPreview as rt } from "../../../hooks/messages/useStartEdit.js";
14
+ import { canStartEditLastSent as ct, isEditableLastSentCandidate as ut } from "../../../hooks/messages/canStartEditLastSent.js";
15
+ import { buildEditPayload as dt } from "../../../hooks/messages/buildEditPayload.js";
16
+ import ft from "./icons/SendIcon.vue.js";
17
+ import he from "./icons/ArrowIcon.vue.js";
18
+ import pt from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
19
+ import ht from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
20
+ const mt = {
21
21
  key: 0,
22
22
  class: "chat-input__disabled-placeholder",
23
23
  "data-testid": "chat-input-disabled-placeholder"
24
- }, gt = ["id"], yt = ["id"], St = { class: "chat-input__file-counter" }, _t = { class: "chat-input__file-chips-wrap" }, xt = ["aria-label"], bt = ["aria-label"], It = { class: "chat-input__inline-buttons" }, Ct = {
24
+ }, vt = ["id"], gt = ["id"], yt = { class: "chat-input__file-counter" }, _t = { class: "chat-input__file-chips-wrap" }, bt = ["aria-label"], xt = ["aria-label"], St = { class: "chat-input__inline-buttons" }, It = {
25
25
  key: 0,
26
26
  class: "chat-input__input chat-input__disabled-placeholder"
27
- }, Ft = {
27
+ }, Tt = {
28
28
  key: 1,
29
29
  class: "chat-input__input-wrap"
30
- }, Tt = ["innerHTML"], Et = ["disabled", "placeholder"], At = ["disabled"], wt = { class: "" }, Mt = { class: "chat-input__third-line" }, Y = 40, Jt = /* @__PURE__ */ Ge({
30
+ }, Ft = ["innerHTML"], Mt = ["disabled", "placeholder"], wt = ["disabled"], Ct = { class: "" }, Et = { class: "chat-input__third-line" }, $ = 40, Z = "​", Xt = /* @__PURE__ */ $e({
31
31
  __name: "ChatInput",
32
32
  props: {
33
33
  state: {
@@ -57,7 +57,7 @@ const vt = {
57
57
  maxAttachedFiles: {
58
58
  type: Number,
59
59
  required: !1,
60
- default: se
60
+ default: ue
61
61
  },
62
62
  resolveEditLastSentMessage: {
63
63
  type: Function,
@@ -66,45 +66,45 @@ const vt = {
66
66
  }
67
67
  },
68
68
  emits: ["send", "typing"],
69
- setup(M, { emit: de }) {
70
- const D = de, I = Oe("chatAppId"), fe = nt(I), { resetMessage: pe, getMessage: o, setMessageText: H, setForceSendMessage: he, resetEdit: me, removeMessageFile: ve } = lt(I), { startEdit: ge } = rt(I), { isNative: ye, emojiSrc: Se } = ot(I);
71
- let X = o().id;
69
+ setup(k, { emit: me }) {
70
+ const D = me, T = Oe("chatAppId"), ve = tt(T), { resetMessage: ge, getMessage: o, setMessageText: W, setForceSendMessage: ye, resetEdit: _e, removeMessageFile: be } = nt(T), { startEdit: xe } = st(T), { isNative: Se, emojiSrc: Ie } = lt(T);
71
+ let ee = o().id;
72
72
  p(
73
73
  () => o().id,
74
74
  (e) => {
75
- X = e;
75
+ ee = e;
76
76
  }
77
77
  );
78
- const l = b(), T = b(), L = b(), E = b(null), R = b(!1), _e = tt("", 2e3), B = b(!1), j = b(!1);
78
+ const i = S(), w = S(), L = S(), C = S(null), R = S(!1), Te = et("", 2e3), O = S(!1), G = S(!1);
79
79
  let y = null;
80
- const S = v(() => it(o()));
80
+ const _ = v(() => it(o()));
81
81
  function K() {
82
82
  const e = L.value;
83
83
  if (!e) {
84
- B.value = !1, j.value = !1;
84
+ O.value = !1, G.value = !1;
85
85
  return;
86
86
  }
87
87
  const t = e.scrollWidth - e.clientWidth;
88
- B.value = e.scrollLeft > 1, j.value = t - e.scrollLeft > 1;
88
+ O.value = e.scrollLeft > 1, G.value = t - e.scrollLeft > 1;
89
89
  }
90
- function xe(e) {
90
+ function Fe(e) {
91
91
  const t = e.firstElementChild;
92
92
  if (!t) return e.clientWidth;
93
93
  const n = parseFloat(getComputedStyle(e).gap) || 8;
94
94
  return t.offsetWidth + n;
95
95
  }
96
- function J(e) {
96
+ function te(e) {
97
97
  const t = L.value;
98
98
  if (!t) return;
99
- const n = xe(t);
99
+ const n = Fe(t);
100
100
  t.scrollBy({ left: e === "right" ? n : -n, behavior: "smooth" });
101
101
  }
102
- function Q() {
102
+ function ne() {
103
103
  y == null || y.disconnect();
104
104
  const e = L.value;
105
105
  e && (y = new ResizeObserver(() => K()), y.observe(e));
106
106
  }
107
- function be(e) {
107
+ function Me(e) {
108
108
  return e.preview ?? {
109
109
  isImage: !1,
110
110
  isVideo: !1,
@@ -113,152 +113,152 @@ const vt = {
113
113
  fileSize: ""
114
114
  };
115
115
  }
116
- const Ie = v(
117
- () => st(o().text || "", E.value, Se.value)
118
- ), A = v(
119
- () => !ye.value && at(o().text || "")
120
- ), _ = () => {
121
- if (!T.value || !l.value) return;
122
- const e = l.value, t = T.value, n = Math.max(0, e.offsetWidth - e.clientWidth);
116
+ const we = v(
117
+ () => ot(o().text || "", C.value, Ie.value)
118
+ ), F = v(
119
+ () => !Se.value && at(o().text || "")
120
+ ), b = () => {
121
+ if (!w.value || !i.value) return;
122
+ const e = i.value, t = w.value, n = Math.max(0, e.offsetWidth - e.clientWidth);
123
123
  t.style.right = n > 0 ? `${n}px` : "", t.scrollTop = e.scrollTop;
124
124
  };
125
- let w = 0;
126
- function $() {
127
- E.value = null;
125
+ let E = 0;
126
+ function U() {
127
+ C.value = null;
128
128
  }
129
129
  function Ce(e = "nearest") {
130
- const t = l.value;
131
- if (!t || !A.value) return;
132
- const n = t.value, i = ce(n, t.selectionStart, e), a = ce(n, t.selectionEnd, e);
133
- (i !== t.selectionStart || a !== t.selectionEnd) && t.setSelectionRange(i, a);
130
+ const t = i.value;
131
+ if (!t || !F.value) return;
132
+ const n = t.value, a = pe(n, t.selectionStart, e), c = pe(n, t.selectionEnd, e);
133
+ (a !== t.selectionStart || c !== t.selectionEnd) && t.setSelectionRange(a, c);
134
134
  }
135
- function G() {
136
- Ce("nearest"), C();
135
+ function V() {
136
+ Ce("nearest"), M();
137
137
  }
138
- function Fe(e) {
139
- var a, c, u;
140
- const t = o(), n = l.value;
141
- if (!ut({
138
+ function Ee(e) {
139
+ var c, s, l;
140
+ const t = o(), n = i.value;
141
+ if (!ct({
142
142
  key: e.key,
143
143
  altKey: e.altKey,
144
144
  metaKey: e.metaKey,
145
145
  ctrlKey: e.ctrlKey,
146
146
  shiftKey: e.shiftKey,
147
- hasResolver: typeof s.resolveEditLastSentMessage == "function",
148
- disabled: s.state === "disabled",
147
+ hasResolver: typeof r.resolveEditLastSentMessage == "function",
148
+ disabled: r.state === "disabled",
149
149
  isRecording: t.isRecording,
150
150
  draftText: t.text ?? "",
151
- replyMessageId: (a = t.reply) == null ? void 0 : a.messageId,
152
- editMessageId: (c = t.edit) == null ? void 0 : c.messageId,
151
+ replyMessageId: (c = t.reply) == null ? void 0 : c.messageId,
152
+ editMessageId: (s = t.edit) == null ? void 0 : s.messageId,
153
153
  textareaText: (n == null ? void 0 : n.value) ?? t.text ?? "",
154
154
  selectionStart: (n == null ? void 0 : n.selectionStart) ?? 0
155
155
  })) return !1;
156
- const i = (u = s.resolveEditLastSentMessage) == null ? void 0 : u.call(s);
157
- return dt(i) ? (e.preventDefault(), ge(ft(i)), !0) : !1;
156
+ const a = (l = r.resolveEditLastSentMessage) == null ? void 0 : l.call(r);
157
+ return ut(a) ? (e.preventDefault(), xe(dt(a)), !0) : !1;
158
158
  }
159
- function Te(e) {
160
- if (Fe(e) || !A.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
161
- const t = l.value;
159
+ function Ae(e) {
160
+ if (Ee(e) || !F.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
161
+ const t = i.value;
162
162
  if (!t) return;
163
- const n = t.value, i = t.selectionStart !== t.selectionEnd;
163
+ const n = t.value, a = t.selectionStart !== t.selectionEnd;
164
164
  if (e.shiftKey) {
165
- requestAnimationFrame(() => G());
165
+ requestAnimationFrame(() => V());
166
166
  return;
167
167
  }
168
- if (i) {
168
+ if (a) {
169
169
  e.preventDefault();
170
- const u = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, x = e.key === "ArrowLeft" ? ae(n, u) : re(n, u);
171
- t.setSelectionRange(x, x), C();
170
+ const l = e.key === "ArrowLeft" ? t.selectionStart : t.selectionEnd, x = e.key === "ArrowLeft" ? de(n, l) : fe(n, l);
171
+ t.setSelectionRange(x, x), M();
172
172
  return;
173
173
  }
174
174
  e.preventDefault();
175
- const a = t.selectionStart, c = e.key === "ArrowLeft" ? ae(n, a) : re(n, a);
176
- t.setSelectionRange(c, c), C();
175
+ const c = t.selectionStart, s = e.key === "ArrowLeft" ? de(n, c) : fe(n, c);
176
+ t.setSelectionRange(s, s), M();
177
177
  }
178
- function C() {
179
- if (!A.value) {
180
- $();
178
+ function M() {
179
+ if (!F.value) {
180
+ U();
181
181
  return;
182
182
  }
183
- w && cancelAnimationFrame(w), w = requestAnimationFrame(() => {
184
- var c;
185
- w = 0;
186
- const e = l.value;
183
+ E && cancelAnimationFrame(E), E = requestAnimationFrame(() => {
184
+ var s;
185
+ E = 0;
186
+ const e = i.value;
187
187
  if (!e) {
188
- $();
188
+ U();
189
189
  return;
190
190
  }
191
191
  const t = e.selectionStart, n = e.selectionEnd;
192
192
  if (t === n) {
193
- E.value !== null && (E.value = null, F(_));
193
+ C.value !== null && (C.value = null, I(b));
194
194
  return;
195
195
  }
196
- const i = E.value;
197
- if (i && i.start === t && i.end === n) return;
198
- const a = ((c = T.value) == null ? void 0 : c.scrollTop) ?? 0;
199
- E.value = { start: t, end: n }, F(() => {
200
- T.value && (T.value.scrollTop = a), _();
196
+ const a = C.value;
197
+ if (a && a.start === t && a.end === n) return;
198
+ const c = ((s = w.value) == null ? void 0 : s.scrollTop) ?? 0;
199
+ C.value = { start: t, end: n }, I(() => {
200
+ w.value && (w.value.scrollTop = c), b();
201
201
  });
202
202
  });
203
203
  }
204
- function Ee(e) {
205
- e.buttons && C();
204
+ function ke(e) {
205
+ e.buttons && M();
206
206
  }
207
- function Z() {
208
- document.activeElement === l.value && C();
207
+ function ie() {
208
+ document.activeElement === i.value && M();
209
209
  }
210
- const s = M, ee = v(
211
- () => s.state === "disabled" && !!s.disabledPlaceholder
212
- ), te = v(() => {
213
- const e = Number(s.maxAttachedFiles);
214
- return Number.isFinite(e) && e > 0 ? Math.floor(e) : se;
210
+ const r = k, le = v(
211
+ () => r.state === "disabled" && !!r.disabledPlaceholder
212
+ ), oe = v(() => {
213
+ const e = Number(r.maxAttachedFiles);
214
+ return Number.isFinite(e) && e > 0 ? Math.floor(e) : ue;
215
215
  });
216
- Ue("maxAttachedFiles", te);
217
- const Ae = v(
218
- () => m("component.ChatInput.FilesSelectedCount").replace("{count}", String(S.value.length)).replace("{max}", String(te.value))
219
- ), we = v(() => !!(s.state == "disabled" || o().text == "" && !S.value.length || o().isRecording)), Me = v(() => {
216
+ Ge("maxAttachedFiles", oe);
217
+ const Le = v(
218
+ () => m("component.ChatInput.FilesSelectedCount").replace("{count}", String(_.value.length)).replace("{max}", String(oe.value))
219
+ ), Re = v(() => !!(r.state == "disabled" || o().text == "" && !_.value.length || o().isRecording)), He = v(() => {
220
220
  var t;
221
- if (s.inputButtonColor)
222
- return s.inputButtonColor;
223
- if (!((t = s.selectedChannel) != null && t.channelId))
221
+ if (r.inputButtonColor)
222
+ return r.inputButtonColor;
223
+ if (!((t = r.selectedChannel) != null && t.channelId))
224
224
  return "#25D366";
225
- const e = s.selectedChannel.channelId.toLowerCase();
225
+ const e = r.selectedChannel.channelId.toLowerCase();
226
226
  return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
227
- }), Le = v(() => {
227
+ }), De = v(() => {
228
228
  var t;
229
- if (!((t = s.selectedChannel) != null && t.channelId))
229
+ if (!((t = r.selectedChannel) != null && t.channelId))
230
230
  return m("component.ChatInput.InputPlaceholder");
231
- const e = s.selectedChannel.channelId.toLowerCase();
231
+ const e = r.selectedChannel.channelId.toLowerCase();
232
232
  return e.includes("whatsapp") || e.includes("waba") ? m("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? m("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? m("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? m("component.ChatInput.MaxInputPlaceholder") : m("component.ChatInput.InputPlaceholder");
233
233
  });
234
234
  p(
235
- () => _e.value,
235
+ () => Te.value,
236
236
  () => {
237
237
  D("typing");
238
238
  }
239
239
  );
240
- function ne(e = !1) {
241
- F(() => {
240
+ function ae(e = !1) {
241
+ I(() => {
242
242
  if (e && !R.value) return;
243
- const t = l.value;
244
- t && (k(t), e && (R.value = !1), P(t), requestAnimationFrame(() => P(t)));
243
+ const t = i.value;
244
+ t && (H(t), e && (R.value = !1), N(t), requestAnimationFrame(() => N(t)));
245
245
  });
246
246
  }
247
247
  p(
248
248
  () => o().edit,
249
249
  (e) => {
250
- (e == null ? void 0 : e.messageId) != null && (R.value = !0, ne(!0));
250
+ (e == null ? void 0 : e.messageId) != null && (R.value = !0, ae(!0));
251
251
  }
252
252
  ), p(
253
253
  () => o().reply,
254
254
  (e) => {
255
- (e == null ? void 0 : e.messageId) != null && ne();
255
+ (e == null ? void 0 : e.messageId) != null && ae();
256
256
  }
257
257
  ), p(
258
- () => s.focusOnInputArea,
258
+ () => r.focusOnInputArea,
259
259
  () => {
260
- s.focusOnInputArea && F(() => {
261
- const e = r(l);
260
+ r.focusOnInputArea && I(() => {
261
+ const e = d(i);
262
262
  e == null || e.focus();
263
263
  });
264
264
  },
@@ -266,265 +266,288 @@ const vt = {
266
266
  ), p(
267
267
  () => o().text,
268
268
  () => {
269
- const e = l.value;
270
- e && (k(e), R.value && (R.value = !1, P(e), requestAnimationFrame(() => P(e))));
269
+ const e = i.value;
270
+ e && (H(e), R.value && (R.value = !1, N(e), requestAnimationFrame(() => N(e))));
271
271
  },
272
272
  { immediate: !0, flush: "post" }
273
273
  ), p(
274
274
  () => o().id,
275
275
  () => {
276
- const e = l.value;
277
- e && (W(e), requestAnimationFrame(() => {
278
- const t = l.value;
279
- t && k(t);
276
+ const e = i.value;
277
+ e && (X(e), requestAnimationFrame(() => {
278
+ const t = i.value;
279
+ t && H(t);
280
280
  }));
281
281
  }
282
- ), p(A, (e) => {
283
- e && F(() => {
284
- const t = l.value;
282
+ ), p(F, (e) => {
283
+ e && I(() => {
284
+ const t = i.value;
285
285
  if (!t) return;
286
286
  const n = t.scrollTop;
287
- k(t), t.scrollTop = n, _(), requestAnimationFrame(_);
287
+ H(t), t.scrollTop = n, b(), requestAnimationFrame(b);
288
288
  });
289
289
  });
290
- function W(e) {
290
+ let A = null;
291
+ function We() {
292
+ if (A) return A;
293
+ const e = document.createElement("textarea");
294
+ e.tabIndex = -1, e.setAttribute("aria-hidden", "true");
295
+ for (const [t, n] of Object.entries({
296
+ position: "absolute",
297
+ visibility: "hidden",
298
+ height: "0",
299
+ "min-height": "0",
300
+ "max-height": "none",
301
+ overflow: "hidden",
302
+ "z-index": "-1000",
303
+ top: "0",
304
+ right: "0"
305
+ }))
306
+ e.style.setProperty(t, n, "important");
307
+ return document.body.appendChild(e), A = e, e;
308
+ }
309
+ function P(e) {
310
+ return e.split(Z).join("");
311
+ }
312
+ function X(e) {
291
313
  const t = o().inputHeight;
292
- e.style.height = (t || Y) + "px", (!t || t <= Y) && (e.style.overflowY = "hidden");
314
+ e.style.height = (t || $) + "px", (!t || t <= $) && (e.style.overflowY = "hidden");
293
315
  }
294
- function Re(e) {
316
+ function Ke(e) {
295
317
  const t = parseFloat(e.style.height);
296
318
  Number.isFinite(t) && (o().inputHeight = t);
297
319
  }
298
- function k(e) {
320
+ function H(e) {
299
321
  const t = o().text || "";
300
- if (e.value !== t || e.clientWidth === 0) {
301
- W(e);
322
+ if (e.clientWidth === 0) {
323
+ X(e);
302
324
  return;
303
325
  }
304
- const n = e.scrollTop;
305
- e.style.height = "auto";
306
- const i = getComputedStyle(e), a = parseFloat(i.fontSize) || 16, c = parseFloat(i.lineHeight) || a * 1.4, u = Y, x = c * 11, U = e.scrollHeight, qe = t.split(`
307
- `).length > 1, d = document.createElement("div");
308
- d.style.position = "absolute", d.style.visibility = "hidden", d.style.whiteSpace = "nowrap", d.style.font = i.font, d.style.fontSize = i.fontSize, d.style.fontFamily = i.fontFamily, d.style.fontWeight = i.fontWeight, d.style.letterSpacing = i.letterSpacing, d.textContent = t, document.body.appendChild(d);
309
- const Ne = d.offsetWidth;
310
- document.body.removeChild(d);
311
- const ze = parseFloat(i.paddingLeft) || 0, Be = parseFloat(i.paddingRight) || 0, je = e.clientWidth - ze - Be, $e = Ne > je, le = qe || $e;
312
- if (le && U <= u + 1) {
313
- W(e);
314
- return;
326
+ if (e.value !== t) return;
327
+ const n = P(t);
328
+ let a = $, c = !1;
329
+ if (n.trim()) {
330
+ const l = getComputedStyle(e), x = (parseFloat(l.borderLeftWidth) || 0) + (parseFloat(l.borderRightWidth) || 0), u = We();
331
+ u.style.boxSizing = "border-box", u.style.width = `${e.clientWidth + x}px`, u.style.font = l.font, u.style.letterSpacing = l.letterSpacing, u.style.lineHeight = l.lineHeight, u.style.padding = l.padding, u.style.border = l.border, u.style.whiteSpace = l.whiteSpace, u.style.wordBreak = l.wordBreak, u.style.overflowWrap = l.overflowWrap, u.value = n.endsWith(`
332
+ `) ? `${n} ` : n;
333
+ let B = u.scrollHeight;
334
+ l.boxSizing === "border-box" && (B += (parseFloat(l.borderTopWidth) || 0) + (parseFloat(l.borderBottomWidth) || 0));
335
+ const J = parseFloat(l.maxHeight), se = Number.isFinite(J) && J > 0 ? J : B;
336
+ a = Math.max($, Math.min(B, se)), c = B > se + 0.5;
337
+ }
338
+ Math.abs(e.offsetHeight - a) >= 1 && (e.style.height = `${a}px`, Ke(e)), e.style.overflowY = c ? "auto" : "hidden";
339
+ const s = c && n.endsWith(`
340
+ `) ? n + Z : n;
341
+ if (s !== t) {
342
+ const l = s.endsWith(Z) ? s.length - 1 : s.length;
343
+ W(s), e.value = s, e.setSelectionRange(l, l);
315
344
  }
316
- t.trim() && le ? U <= x ? (e.style.height = U + "px", e.style.overflowY = "hidden") : (e.style.height = x + "px", e.style.overflowY = "auto", e.scrollTop = n) : (e.style.height = u + "px", e.style.overflowY = "hidden"), Re(e), _(), requestAnimationFrame(_);
345
+ c && (e.selectionEnd ?? 0) >= n.length && (e.scrollTop = e.scrollHeight), b(), F.value && I(b);
317
346
  }
318
- function P(e) {
319
- if (s.state === "disabled" || o().isRecording) return;
347
+ function N(e) {
348
+ if (r.state === "disabled" || o().isRecording) return;
320
349
  const t = e.value.length;
321
- e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, _();
350
+ e.focus(), e.setSelectionRange(t, t), e.scrollTop = e.scrollHeight, b();
322
351
  }
323
352
  p(
324
353
  () => o().forceSend,
325
354
  () => {
326
- o().forceSend && (O(), he(!1));
355
+ o().forceSend && (Y(), ye(!1));
327
356
  }
328
357
  );
329
- const ke = (e) => {
358
+ const Pe = (e) => {
330
359
  const t = e.target;
331
- D("typing", t.value), C();
360
+ D("typing", t.value), M();
332
361
  };
333
362
  p(
334
- S,
363
+ _,
335
364
  (e, t) => {
336
- F(() => {
337
- Q(), K();
365
+ I(() => {
366
+ ne(), K();
338
367
  const n = L.value;
339
368
  n && e.length > ((t == null ? void 0 : t.length) ?? 0) && n.scrollTo({ left: n.scrollWidth, behavior: "smooth" });
340
369
  });
341
370
  },
342
371
  { flush: "post" }
343
- ), Ve(() => {
344
- const e = l.value;
345
- e && (W(e), k(e)), Q(), K(), document.addEventListener("selectionchange", Z);
346
- }), Ye(() => {
347
- fe.commitChatDraftToList(X), document.removeEventListener("selectionchange", Z), y == null || y.disconnect(), w && cancelAnimationFrame(w);
372
+ ), Ue(() => {
373
+ const e = i.value;
374
+ e && (X(e), H(e)), ne(), K(), document.addEventListener("selectionchange", ie);
375
+ }), Ve(() => {
376
+ ve.commitChatDraftToList(ee), document.removeEventListener("selectionchange", ie), y == null || y.disconnect(), E && cancelAnimationFrame(E), A && (A.remove(), A = null);
348
377
  });
349
- const De = (e) => {
350
- if (e.shiftKey) {
351
- if (l.value instanceof HTMLTextAreaElement) {
352
- let t = l.value.selectionStart;
353
- t && (l.value.setRangeText(`
354
- `, t, t, "end"), H(l.value.value));
355
- }
356
- e.preventDefault();
357
- } else if (e.ctrlKey) {
358
- if (l.value instanceof HTMLTextAreaElement) {
359
- let t = l.value.selectionStart;
360
- t && (l.value.setRangeText(`
361
- `, t, t, "end"), H(l.value.value));
378
+ const Ne = (e) => {
379
+ if (e.shiftKey || e.ctrlKey) {
380
+ if (i.value instanceof HTMLTextAreaElement) {
381
+ const t = i.value.selectionStart;
382
+ t != null && (i.value.setRangeText(`
383
+ `, t, t, "end"), W(i.value.value));
362
384
  }
363
385
  e.preventDefault();
364
386
  } else
365
- e.preventDefault(), O();
366
- }, He = (e) => {
367
- if (l.value) {
368
- const t = l.value.value;
369
- l.value.value = e.newText;
370
- const n = e.newText.length - (t.length - (e.end - e.start)), i = e.start + n;
371
- H(e.newText), F(() => {
372
- l.value && (l.value.setSelectionRange(i, i), l.value.focus());
387
+ e.preventDefault(), Y();
388
+ }, Be = (e) => {
389
+ if (i.value) {
390
+ const t = i.value.value;
391
+ i.value.value = e.newText;
392
+ const n = e.newText.length - (t.length - (e.end - e.start)), a = e.start + n;
393
+ W(e.newText), I(() => {
394
+ i.value && (i.value.setSelectionRange(a, a), i.value.focus());
373
395
  });
374
396
  }
375
397
  };
376
- function Ke(e) {
377
- ve(e);
398
+ function je(e) {
399
+ be(e);
378
400
  }
379
- function We() {
380
- me(), H(""), ct(I), l.value && l.value.focus();
401
+ function qe() {
402
+ _e(), W(""), rt(T), i.value && i.value.focus();
381
403
  }
382
- function Pe() {
404
+ function ze() {
383
405
  const e = o();
384
- return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
406
+ return e.edit ? P(e.text ?? "").trim() === P(e.edit.text ?? "").trim() : !1;
385
407
  }
386
- const O = () => {
387
- const e = b(o());
388
- if (e.value.edit && Pe() && !S.value.length) {
389
- We();
408
+ const Y = () => {
409
+ const e = S(o());
410
+ if (e.value.edit && ze() && !_.value.length) {
411
+ qe();
390
412
  return;
391
413
  }
392
- if (e.value.text != "" || S.value.length) {
393
- const t = {
414
+ const t = P(e.value.text ?? "");
415
+ if (t != "" || _.value.length) {
416
+ const n = {
394
417
  type: "",
395
418
  text: "",
396
419
  url: "",
397
420
  filename: "",
398
421
  size: "",
399
422
  reply: void 0
400
- }, n = S.value;
401
- if (n.length) {
402
- const i = e.value.text.trim();
403
- n.forEach((a, c) => {
404
- var x;
405
- const u = {
406
- type: "message." + a.type,
407
- url: a.url,
408
- filename: a.name,
409
- size: (x = a.size) == null ? void 0 : x.toString(),
410
- text: c === 0 ? i : ""
423
+ }, a = _.value;
424
+ if (a.length) {
425
+ const c = t.trim();
426
+ a.forEach((s, l) => {
427
+ var u;
428
+ const x = {
429
+ type: "message." + s.type,
430
+ url: s.url,
431
+ filename: s.name,
432
+ size: (u = s.size) == null ? void 0 : u.toString(),
433
+ text: l === 0 ? c : ""
411
434
  };
412
- c === 0 && (e.value.reply && (u.reply = e.value.reply), e.value.edit && (u.edit = e.value.edit)), D("send", u);
435
+ l === 0 && (e.value.reply && (x.reply = e.value.reply), e.value.edit && (x.edit = e.value.edit)), D("send", x);
413
436
  });
414
437
  } else
415
- t.type = "message.text", t.text = e.value.text.trim(), e.value.reply && (t.reply = e.value.reply), e.value.edit && (t.edit = e.value.edit), D("send", t);
416
- pe(), l.value && l.value.focus();
438
+ n.type = "message.text", n.text = t.trim(), e.value.reply && (n.reply = e.value.reply), e.value.edit && (n.edit = e.value.edit), D("send", n);
439
+ ge(), i.value && i.value.focus();
417
440
  }
418
441
  };
419
442
  return (e, t) => (h(), g("div", {
420
- class: q(["chat-input__container", { "chat-input__container--disabled-notice": ee.value }]),
443
+ class: j(["chat-input__container", { "chat-input__container--disabled-notice": le.value }]),
421
444
  "data-testid": "chat-input"
422
445
  }, [
423
- ee.value ? (h(), g("div", vt, N(M.disabledPlaceholder), 1)) : (h(), g(ie, { key: 1 }, [
446
+ le.value ? (h(), g("div", mt, q(k.disabledPlaceholder), 1)) : (h(), g(re, { key: 1 }, [
424
447
  f("div", {
425
- id: "chat-input-reply-line-" + r(I),
448
+ id: "chat-input-reply-line-" + d(T),
426
449
  class: "chat-input__reply-line",
427
450
  "data-testid": "chat-input-reply-line"
428
- }, null, 8, gt),
451
+ }, null, 8, vt),
429
452
  f("div", {
430
- id: "chat-input-file-line-" + r(I),
431
- class: q(["chat-input__file-line", { "chat-input__file-line--visible": S.value.length > 0 }])
453
+ id: "chat-input-file-line-" + d(T),
454
+ class: j(["chat-input__file-line", { "chat-input__file-line--visible": _.value.length > 0 }])
432
455
  }, [
433
- f("span", St, [
434
- f("span", null, N(r(m)("component.ChatInput.FilesSelected")), 1),
435
- f("span", null, N(Ae.value), 1)
456
+ f("span", yt, [
457
+ f("span", null, q(d(m)("component.ChatInput.FilesSelected")), 1),
458
+ f("span", null, q(Le.value), 1)
436
459
  ]),
437
460
  f("div", _t, [
438
- B.value ? (h(), g("button", {
461
+ O.value ? (h(), g("button", {
439
462
  key: 0,
440
463
  type: "button",
441
464
  class: "chat-input__file-scroll chat-input__file-scroll--left",
442
- "aria-label": r(m)("component.ChatInput.FilesScrollLeft"),
443
- onClick: t[0] || (t[0] = (n) => J("left"))
465
+ "aria-label": d(m)("component.ChatInput.FilesScrollLeft"),
466
+ onClick: t[0] || (t[0] = (n) => te("left"))
444
467
  }, [
445
- z(r(ue))
446
- ], 8, xt)) : V("", !0),
468
+ z(d(he))
469
+ ], 8, bt)) : Q("", !0),
447
470
  f("div", {
448
471
  ref_key: "refFileChips",
449
472
  ref: L,
450
473
  class: "chat-input__file-chips",
451
474
  onScroll: K
452
475
  }, [
453
- (h(!0), g(ie, null, Xe(S.value, (n, i) => (h(), Je(mt, {
454
- key: (n.url || n.name || "") + "-" + i,
455
- "file-info": be(n),
456
- onReset: (a) => Ke(i)
476
+ (h(!0), g(re, null, Xe(_.value, (n, a) => (h(), Ye(ht, {
477
+ key: (n.url || n.name || "") + "-" + a,
478
+ "file-info": Me(n),
479
+ onReset: (c) => je(a)
457
480
  }, null, 8, ["file-info", "onReset"]))), 128))
458
481
  ], 544),
459
- j.value ? (h(), g("button", {
482
+ G.value ? (h(), g("button", {
460
483
  key: 1,
461
484
  type: "button",
462
485
  class: "chat-input__file-scroll chat-input__file-scroll--right",
463
- "aria-label": r(m)("component.ChatInput.FilesScrollRight"),
464
- onClick: t[1] || (t[1] = (n) => J("right"))
486
+ "aria-label": d(m)("component.ChatInput.FilesScrollRight"),
487
+ onClick: t[1] || (t[1] = (n) => te("right"))
465
488
  }, [
466
- z(r(ue))
467
- ], 8, bt)) : V("", !0)
489
+ z(d(he))
490
+ ], 8, xt)) : Q("", !0)
468
491
  ])
469
- ], 10, yt),
470
- f("div", It, [
471
- oe(e.$slots, "inline-buttons", {}, void 0, !0)
492
+ ], 10, gt),
493
+ f("div", St, [
494
+ ce(e.$slots, "inline-buttons", {}, void 0, !0)
472
495
  ]),
473
- M.disabledPlaceholder && r(o)().isRecording ? (h(), g("div", Ct, N(M.disabledPlaceholder), 1)) : (h(), g("div", Ft, [
474
- A.value ? (h(), g("div", {
496
+ k.disabledPlaceholder && d(o)().isRecording ? (h(), g("div", It, q(k.disabledPlaceholder), 1)) : (h(), g("div", Tt, [
497
+ F.value ? (h(), g("div", {
475
498
  key: 0,
476
499
  ref_key: "refMirror",
477
- ref: T,
500
+ ref: w,
478
501
  class: "chat-input__input-mirror",
479
502
  "aria-hidden": "true",
480
- innerHTML: Ie.value
481
- }, null, 8, Tt)) : V("", !0),
482
- Qe(f("textarea", {
503
+ innerHTML: we.value
504
+ }, null, 8, Ft)) : Q("", !0),
505
+ Je(f("textarea", {
483
506
  ref_key: "refInput",
484
- ref: l,
485
- "onUpdate:modelValue": t[2] || (t[2] = (n) => r(o)().text = n),
507
+ ref: i,
508
+ "onUpdate:modelValue": t[2] || (t[2] = (n) => d(o)().text = n),
486
509
  rows: "1",
487
510
  "data-testid": "chat-input-textarea",
488
- disabled: M.state == "disabled" || r(o)().isRecording,
489
- class: q(["chat-input__input", { "chat-input__input--emoji-images": A.value }]),
490
- placeholder: Le.value,
511
+ disabled: k.state == "disabled" || d(o)().isRecording,
512
+ class: j(["chat-input__input", { "chat-input__input--emoji-images": F.value }]),
513
+ placeholder: De.value,
491
514
  onKeydown: [
492
- Te,
493
- Ze(De, ["enter"])
515
+ Ae,
516
+ Qe(Ne, ["enter"])
494
517
  ],
495
- onInput: ke,
496
- onScroll: _,
497
- onSelect: C,
498
- onMouseup: G,
499
- onKeyup: G,
500
- onMousemove: Ee,
501
- onBlur: $
502
- }, null, 42, Et), [
503
- [et, r(o)().text]
518
+ onInput: Pe,
519
+ onScroll: b,
520
+ onSelect: M,
521
+ onMouseup: V,
522
+ onKeyup: V,
523
+ onMousemove: ke,
524
+ onBlur: U
525
+ }, null, 42, Mt), [
526
+ [Ze, d(o)().text]
504
527
  ])
505
528
  ])),
506
- z(ht, {
507
- textarea: l.value,
508
- onFormatApplied: He
529
+ z(pt, {
530
+ textarea: i.value,
531
+ onFormatApplied: Be
509
532
  }, null, 8, ["textarea"]),
510
533
  f("button", {
511
534
  type: "button",
512
- class: q(["chat-input__button", { "chat-input__button-disabled": we.value }]),
535
+ class: j(["chat-input__button", { "chat-input__button-disabled": Re.value }]),
513
536
  "data-testid": "chat-input-send",
514
- disabled: r(o)().isRecording,
515
- onClick: O
537
+ disabled: d(o)().isRecording,
538
+ onClick: Y
516
539
  }, [
517
- f("span", wt, [
518
- z(r(pt), { color: Me.value }, null, 8, ["color"])
540
+ f("span", Ct, [
541
+ z(d(ft), { color: He.value }, null, 8, ["color"])
519
542
  ])
520
- ], 10, At),
521
- f("div", Mt, [
522
- oe(e.$slots, "buttons", {}, void 0, !0)
543
+ ], 10, wt),
544
+ f("div", Et, [
545
+ ce(e.$slots, "buttons", {}, void 0, !0)
523
546
  ])
524
547
  ], 64))
525
548
  ], 2));
526
549
  }
527
550
  });
528
551
  export {
529
- Jt as default
552
+ Xt as default
530
553
  };