isometrik-plugin-chat-sdk 2.0.18 → 2.0.20

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 (166) hide show
  1. package/dist/cjs/{app-globals-170f9e71.js → app-globals-2824b330.js} +3 -3
  2. package/dist/cjs/{app-globals-170f9e71.js.map → app-globals-2824b330.js.map} +1 -1
  3. package/dist/cjs/attachment-preview_22.cjs.entry.js +114 -141
  4. package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
  5. package/dist/cjs/audio-bubble_4.cjs.entry.js +1 -1
  6. package/dist/cjs/{chat-assets-686620e7.js → chat-assets-8c4dc04f.js} +22 -3
  7. package/dist/cjs/chat-assets-8c4dc04f.js.map +1 -0
  8. package/dist/cjs/chat-tile_3.cjs.entry.js +1 -1
  9. package/dist/cjs/{client-80851676.js → client-fef5fd3d.js} +29 -1
  10. package/dist/cjs/client-fef5fd3d.js.map +1 -0
  11. package/dist/cjs/forward-memebers.cjs.entry.js +1 -1
  12. package/dist/cjs/{groupcast-4239cbfc.js → groupcast-8441b4df.js} +2 -2
  13. package/dist/cjs/{groupcast-4239cbfc.js.map → groupcast-8441b4df.js.map} +1 -1
  14. package/dist/cjs/{groupcast-3cb44a25.js → groupcast-f24da720.js} +14 -4
  15. package/dist/cjs/groupcast-f24da720.js.map +1 -0
  16. package/dist/cjs/index.cjs.js +5 -5
  17. package/dist/cjs/isometrik-webchat.cjs.js +6 -6
  18. package/dist/cjs/loader.cjs.js +6 -6
  19. package/dist/cjs/login-page_3.cjs.entry.js +44 -18
  20. package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
  21. package/dist/cjs/member-add.cjs.entry.js +2 -2
  22. package/dist/cjs/new-chat-sidebar.cjs.entry.js +1 -1
  23. package/dist/cjs/{runtime-controls-99f378d4.js → runtime-controls-cfc8fc31.js} +3 -3
  24. package/dist/cjs/{runtime-controls-99f378d4.js.map → runtime-controls-cfc8fc31.js.map} +1 -1
  25. package/dist/cjs/send-media-4ee967d4.js +1194 -0
  26. package/dist/cjs/send-media-4ee967d4.js.map +1 -0
  27. package/dist/collection/api/groupcast.js +13 -3
  28. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +102 -100
  29. package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -1
  30. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +25 -47
  31. package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -1
  32. package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js +3 -16
  33. package/dist/collection/components/ChatUIComponent/shared/GroupCast/GroupCast.js.map +1 -1
  34. package/dist/collection/components/ChatUIComponent/shared/message-info/message-info.js +10 -4
  35. package/dist/collection/components/ChatUIComponent/shared/message-info/message-info.js.map +1 -1
  36. package/dist/collection/components/my-component/web-chat/data-fetch.js +9 -3
  37. package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
  38. package/dist/collection/components/my-component/web-chat/mutations.js +7 -2
  39. package/dist/collection/components/my-component/web-chat/mutations.js.map +1 -1
  40. package/dist/collection/components/my-component/web-chat/offline-host.js +21 -5
  41. package/dist/collection/components/my-component/web-chat/offline-host.js.map +1 -1
  42. package/dist/collection/components/my-component/web-chat/public-send.js +4 -4
  43. package/dist/collection/components/my-component/web-chat/public-send.js.map +1 -1
  44. package/dist/collection/constants/chat-assets.js +21 -2
  45. package/dist/collection/lib/chat/document-thumbnail.js +433 -0
  46. package/dist/collection/lib/chat/document-thumbnail.js.map +1 -0
  47. package/dist/collection/lib/chat/index.js +1 -1
  48. package/dist/collection/lib/chat/index.js.map +1 -1
  49. package/dist/collection/lib/chat/send-media.js +348 -25
  50. package/dist/collection/lib/chat/send-media.js.map +1 -1
  51. package/dist/collection/lib/offline/client.js +11 -0
  52. package/dist/collection/lib/offline/client.js.map +1 -1
  53. package/dist/collection/lib/offline/idb.js +11 -0
  54. package/dist/collection/lib/offline/idb.js.map +1 -1
  55. package/dist/collection/lib/offline/memory-db.js +6 -0
  56. package/dist/collection/lib/offline/memory-db.js.map +1 -1
  57. package/dist/components/ChatFooter.js +25 -47
  58. package/dist/components/ChatFooter.js.map +1 -1
  59. package/dist/components/ChatSidebar.js +78 -73
  60. package/dist/components/ChatSidebar.js.map +1 -1
  61. package/dist/components/GroupCast2.js +3 -16
  62. package/dist/components/GroupCast2.js.map +1 -1
  63. package/dist/components/WebChat.js +40 -14
  64. package/dist/components/WebChat.js.map +1 -1
  65. package/dist/components/WebChatBody.js +1 -1
  66. package/dist/components/chat-assets.js +21 -2
  67. package/dist/components/chat-assets.js.map +1 -1
  68. package/dist/components/client.js +28 -0
  69. package/dist/components/client.js.map +1 -1
  70. package/dist/components/groupcast.js +13 -3
  71. package/dist/components/groupcast.js.map +1 -1
  72. package/dist/components/message-info2.js +10 -4
  73. package/dist/components/message-info2.js.map +1 -1
  74. package/dist/components/send-media.js +780 -26
  75. package/dist/components/send-media.js.map +1 -1
  76. package/dist/esm/{app-globals-15a6ef50.js → app-globals-e3f4717b.js} +3 -3
  77. package/dist/esm/{app-globals-15a6ef50.js.map → app-globals-e3f4717b.js.map} +1 -1
  78. package/dist/esm/attachment-preview_22.entry.js +114 -141
  79. package/dist/esm/attachment-preview_22.entry.js.map +1 -1
  80. package/dist/esm/audio-bubble_4.entry.js +1 -1
  81. package/dist/esm/{chat-assets-bb056958.js → chat-assets-27beb552.js} +22 -3
  82. package/dist/esm/chat-assets-27beb552.js.map +1 -0
  83. package/dist/esm/chat-tile_3.entry.js +1 -1
  84. package/dist/esm/{client-4a3e00da.js → client-de7fbead.js} +29 -1
  85. package/dist/esm/client-de7fbead.js.map +1 -0
  86. package/dist/esm/forward-memebers.entry.js +1 -1
  87. package/dist/esm/{groupcast-ea2466c8.js → groupcast-5fb19ec3.js} +2 -2
  88. package/dist/esm/{groupcast-ea2466c8.js.map → groupcast-5fb19ec3.js.map} +1 -1
  89. package/dist/esm/{groupcast-cc10c6a4.js → groupcast-f96c1d9e.js} +14 -4
  90. package/dist/esm/groupcast-f96c1d9e.js.map +1 -0
  91. package/dist/esm/index.js +6 -6
  92. package/dist/esm/isometrik-webchat.js +6 -6
  93. package/dist/esm/loader.js +6 -6
  94. package/dist/esm/login-page_3.entry.js +44 -18
  95. package/dist/esm/login-page_3.entry.js.map +1 -1
  96. package/dist/esm/member-add.entry.js +2 -2
  97. package/dist/esm/new-chat-sidebar.entry.js +1 -1
  98. package/dist/esm/{runtime-controls-8a22625e.js → runtime-controls-ff81e90a.js} +3 -3
  99. package/dist/esm/{runtime-controls-8a22625e.js.map → runtime-controls-ff81e90a.js.map} +1 -1
  100. package/dist/esm/send-media-58e7145b.js +1166 -0
  101. package/dist/esm/send-media-58e7145b.js.map +1 -0
  102. package/dist/isometrik-webchat/index.esm.js +1 -1
  103. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  104. package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
  105. package/dist/isometrik-webchat/{p-fd6ce589.entry.js → p-09980c53.entry.js} +2 -2
  106. package/dist/isometrik-webchat/p-352b589e.entry.js +2 -0
  107. package/dist/isometrik-webchat/p-352b589e.entry.js.map +1 -0
  108. package/dist/isometrik-webchat/p-3b3dc33e.js +2 -0
  109. package/dist/isometrik-webchat/p-3b3dc33e.js.map +1 -0
  110. package/dist/isometrik-webchat/{p-ffbbe278.entry.js → p-44da28d3.entry.js} +2 -2
  111. package/dist/isometrik-webchat/p-6f5037b2.js +2 -0
  112. package/dist/isometrik-webchat/p-6f5037b2.js.map +1 -0
  113. package/dist/isometrik-webchat/{p-6fc95e0e.js → p-78fb47c4.js} +2 -2
  114. package/dist/isometrik-webchat/{p-3120b9d3.entry.js → p-a9efcf1c.entry.js} +2 -2
  115. package/dist/isometrik-webchat/p-b0baa9ad.entry.js +2 -0
  116. package/dist/isometrik-webchat/p-b0baa9ad.entry.js.map +1 -0
  117. package/dist/isometrik-webchat/{p-c08055fe.js → p-b385ac4b.js} +2 -2
  118. package/dist/isometrik-webchat/p-c06ad586.js +2 -0
  119. package/dist/isometrik-webchat/p-c06ad586.js.map +1 -0
  120. package/dist/isometrik-webchat/p-d758e431.js +2 -0
  121. package/dist/isometrik-webchat/{p-c49de274.entry.js → p-d864bb9f.entry.js} +2 -2
  122. package/dist/isometrik-webchat/p-f0d4687f.js +2 -0
  123. package/dist/isometrik-webchat/p-f0d4687f.js.map +1 -0
  124. package/dist/isometrik-webchat/{p-39b626ed.entry.js → p-f7d05551.entry.js} +2 -2
  125. package/dist/types/components/ChatUIComponent/ChatSidebar/ChatSidebar.d.ts +3 -2
  126. package/dist/types/components/my-component/web-chat/offline-host.d.ts +2 -0
  127. package/dist/types/components.d.ts +17 -17
  128. package/dist/types/js.d.ts +3 -0
  129. package/dist/types/lib/chat/document-thumbnail.d.ts +38 -0
  130. package/dist/types/lib/chat/index.d.ts +1 -1
  131. package/dist/types/lib/chat/send-media.d.ts +58 -1
  132. package/dist/types/lib/offline/client.d.ts +2 -0
  133. package/dist/types/lib/offline/idb.d.ts +2 -0
  134. package/dist/types/lib/offline/memory-db.d.ts +1 -0
  135. package/package.json +1 -1
  136. package/dist/cjs/chat-assets-686620e7.js.map +0 -1
  137. package/dist/cjs/client-80851676.js.map +0 -1
  138. package/dist/cjs/groupcast-3cb44a25.js.map +0 -1
  139. package/dist/cjs/send-media-7c865c19.js +0 -438
  140. package/dist/cjs/send-media-7c865c19.js.map +0 -1
  141. package/dist/esm/chat-assets-bb056958.js.map +0 -1
  142. package/dist/esm/client-4a3e00da.js.map +0 -1
  143. package/dist/esm/groupcast-cc10c6a4.js.map +0 -1
  144. package/dist/esm/send-media-5527ee9f.js +0 -412
  145. package/dist/esm/send-media-5527ee9f.js.map +0 -1
  146. package/dist/isometrik-webchat/p-1db79cfb.js +0 -2
  147. package/dist/isometrik-webchat/p-4671fe73.js +0 -2
  148. package/dist/isometrik-webchat/p-4671fe73.js.map +0 -1
  149. package/dist/isometrik-webchat/p-643457b8.js +0 -2
  150. package/dist/isometrik-webchat/p-643457b8.js.map +0 -1
  151. package/dist/isometrik-webchat/p-a5707f12.js +0 -2
  152. package/dist/isometrik-webchat/p-a5707f12.js.map +0 -1
  153. package/dist/isometrik-webchat/p-a9380fb3.entry.js +0 -2
  154. package/dist/isometrik-webchat/p-a9380fb3.entry.js.map +0 -1
  155. package/dist/isometrik-webchat/p-ae168135.js +0 -2
  156. package/dist/isometrik-webchat/p-ae168135.js.map +0 -1
  157. package/dist/isometrik-webchat/p-ceb08a13.entry.js +0 -2
  158. package/dist/isometrik-webchat/p-ceb08a13.entry.js.map +0 -1
  159. /package/dist/isometrik-webchat/{p-fd6ce589.entry.js.map → p-09980c53.entry.js.map} +0 -0
  160. /package/dist/isometrik-webchat/{p-ffbbe278.entry.js.map → p-44da28d3.entry.js.map} +0 -0
  161. /package/dist/isometrik-webchat/{p-6fc95e0e.js.map → p-78fb47c4.js.map} +0 -0
  162. /package/dist/isometrik-webchat/{p-3120b9d3.entry.js.map → p-a9efcf1c.entry.js.map} +0 -0
  163. /package/dist/isometrik-webchat/{p-c08055fe.js.map → p-b385ac4b.js.map} +0 -0
  164. /package/dist/isometrik-webchat/{p-1db79cfb.js.map → p-d758e431.js.map} +0 -0
  165. /package/dist/isometrik-webchat/{p-c49de274.entry.js.map → p-d864bb9f.entry.js.map} +0 -0
  166. /package/dist/isometrik-webchat/{p-39b626ed.entry.js.map → p-f7d05551.entry.js.map} +0 -0
@@ -0,0 +1,1194 @@
1
+ 'use strict';
2
+
3
+ const toast = require('./toast-91093c84.js');
4
+ const localNotification = require('./local-notification-bdd04d7a.js');
5
+
6
+ async function fetchMessagesPage(opts) {
7
+ var _a, _b;
8
+ const res = await toast.M.getInstance().message.getMessages({
9
+ conversationId: opts.conversationId,
10
+ limit: (_a = opts.limit) !== null && _a !== void 0 ? _a : 20,
11
+ skip: (_b = opts.skip) !== null && _b !== void 0 ? _b : 0,
12
+ });
13
+ return ((res === null || res === void 0 ? void 0 : res.messages) || []).slice().reverse();
14
+ }
15
+ /** Mark an open conversation read on the server (idempotent). */
16
+ async function markConversationRead(conversationId) {
17
+ const id = String(conversationId || '').trim();
18
+ if (!id)
19
+ return;
20
+ await toast.M.getInstance().message.putRead({ conversationId: id });
21
+ }
22
+ function messageIdOf(m) {
23
+ var _a;
24
+ return String((_a = m === null || m === void 0 ? void 0 : m.messageId) !== null && _a !== void 0 ? _a : '').trim();
25
+ }
26
+ function sentAtOf(m) {
27
+ var _a, _b;
28
+ const n = Number((_b = (_a = m.sentAt) !== null && _a !== void 0 ? _a : m.updatedAt) !== null && _b !== void 0 ? _b : 0);
29
+ return Number.isFinite(n) ? n : 0;
30
+ }
31
+ /** Soft merge for gap-fill — keeps existing rows, upserts by messageId. */
32
+ function mergeMessagesById(existing, incoming) {
33
+ const byId = new Map();
34
+ for (const m of existing) {
35
+ const id = messageIdOf(m);
36
+ if (id)
37
+ byId.set(id, m);
38
+ }
39
+ let added = 0;
40
+ for (const m of incoming) {
41
+ const id = messageIdOf(m);
42
+ if (!id)
43
+ continue;
44
+ if (!byId.has(id))
45
+ added += 1;
46
+ byId.set(id, m);
47
+ }
48
+ const next = Array.from(byId.values()).sort((a, b) => sentAtOf(a) - sentAtOf(b));
49
+ return { next, added };
50
+ }
51
+ async function searchMessages(opts) {
52
+ var _a, _b;
53
+ const res = await toast.M.getInstance().message.getMessages({
54
+ conversationId: opts.conversationId,
55
+ searchTag: opts.searchTag,
56
+ skip: (_a = opts.skip) !== null && _a !== void 0 ? _a : 0,
57
+ limit: (_b = opts.limit) !== null && _b !== void 0 ? _b : 20,
58
+ });
59
+ return (res === null || res === void 0 ? void 0 : res.messages) || [];
60
+ }
61
+ async function fetchLinkMessages(conversationId) {
62
+ const res = await toast.M.getInstance().message.getMessages({
63
+ conversationId,
64
+ customTypes: 'AttachmentMessage:Link',
65
+ });
66
+ return (res === null || res === void 0 ? void 0 : res.messages) || [];
67
+ }
68
+ async function fetchMediaCount(conversationId) {
69
+ var _a;
70
+ const res = await toast.M.getInstance().message.getMessagesCount({
71
+ conversationId,
72
+ customTypes: 'AttachmentMessage:Link,AttachmentMessage:Multiple,AttachmentMessage:Image,AttachmentMessage:Video,AttachmentMessage:Audio,AttachmentMessage:File,AttachmentMessage:Doc',
73
+ });
74
+ return (_a = res === null || res === void 0 ? void 0 : res.messagesCount) !== null && _a !== void 0 ? _a : 0;
75
+ }
76
+ const RASTER = /\.(jpe?g|png|gif|webp|bmp|avif)(\?|#|$)/i;
77
+ /** http(s) image first, then the local preview the chat bubble is already showing. */
78
+ function mediaPreviewUrls(att) {
79
+ if (!att)
80
+ return [];
81
+ const all = [att.thumbnailUrl, att.mediaUrl, att.localUrl, att.url].map(u => String(u || '')).filter(Boolean);
82
+ const raster = all.filter(u => /^https?:/i.test(u) && RASTER.test(u));
83
+ const local = all.filter(u => u.startsWith('data:') || u.startsWith('blob:'));
84
+ const rest = all.filter(u => !raster.includes(u) && !local.includes(u));
85
+ return [...new Set([...raster, ...local, ...rest])];
86
+ }
87
+ /** pdf / excel / rtf / txt from mime, extension, or file name. */
88
+ function docIconKind(doc) {
89
+ const t = `${(doc === null || doc === void 0 ? void 0 : doc.mimeType) || ''} ${(doc === null || doc === void 0 ? void 0 : doc.extension) || ''} ${(doc === null || doc === void 0 ? void 0 : doc.name) || ''} ${(doc === null || doc === void 0 ? void 0 : doc.nameWithExtension) || ''} ${(doc === null || doc === void 0 ? void 0 : doc.fileName) || ''}`.toLowerCase();
90
+ if (/xlsx?|spreadsheet|excel|csv/.test(t))
91
+ return 'excel';
92
+ if (t.includes('pdf'))
93
+ return 'pdf';
94
+ if (t.includes('rtf'))
95
+ return 'rtf';
96
+ if (t.includes('text/plain') || /(^|[^a-z])txt([^a-z]|$)/.test(t))
97
+ return 'txt';
98
+ return 'file';
99
+ }
100
+ /** send-media.ts: 0 image, 1 video → media; 3 document → docs. */
101
+ function attachmentBucket(att) {
102
+ if (!att)
103
+ return null;
104
+ const mime = String(att.mimeType || '');
105
+ if (mime.startsWith('image/') || mime.startsWith('video/'))
106
+ return 'media';
107
+ if (mime.startsWith('application/') || mime === 'text/plain' || mime.includes('rtf'))
108
+ return 'docs';
109
+ const type = att.mediaType == null || att.mediaType === '' ? NaN : Number(att.mediaType);
110
+ if (type === 0 || type === 1)
111
+ return 'media';
112
+ if (type === 3)
113
+ return 'docs';
114
+ return null;
115
+ }
116
+ function splitSharedMessages(messages) {
117
+ const media = [];
118
+ const docs = [];
119
+ const list = Array.isArray(messages) ? messages : [];
120
+ list.forEach(message => {
121
+ const atts = Array.isArray(message === null || message === void 0 ? void 0 : message.attachments)
122
+ ? message.attachments
123
+ : (message === null || message === void 0 ? void 0 : message.mediaUrl) || (message === null || message === void 0 ? void 0 : message.thumbnailUrl)
124
+ ? [message]
125
+ : [];
126
+ atts.forEach((att) => {
127
+ var _a;
128
+ const item = Object.assign(Object.assign({}, att), { date: (message === null || message === void 0 ? void 0 : message.sentAt) || (att === null || att === void 0 ? void 0 : att.date), sender: ((_a = message === null || message === void 0 ? void 0 : message.senderInfo) === null || _a === void 0 ? void 0 : _a.userName) || (att === null || att === void 0 ? void 0 : att.sender) });
129
+ const bucket = attachmentBucket(att);
130
+ if (bucket === 'docs')
131
+ docs.push(item);
132
+ else if (bucket === 'media')
133
+ media.push(item);
134
+ });
135
+ });
136
+ return { media, docs };
137
+ }
138
+ /** Keep messages that have non-document media attachments. */
139
+ function filterMediaMessages(messages) {
140
+ if (!Array.isArray(messages))
141
+ return [];
142
+ return messages.filter(message => {
143
+ if (!message.attachments || !Array.isArray(message.attachments))
144
+ return false;
145
+ const valid = message.attachments.filter((attachment) => (attachment === null || attachment === void 0 ? void 0 : attachment.mimeType) && !String(attachment.mimeType).startsWith('application'));
146
+ return valid.length > 0;
147
+ });
148
+ }
149
+ async function fetchMediaAttachments(conversationId) {
150
+ const customTypes = 'AttachmentMessage:Media,AttachmentMessage:Multiple,AttachmentMessage:Image,AttachmentMessage:Video,AttachmentMessage:Audio,AttachmentMessage:File,AttachmentMessage:Doc';
151
+ const pageSize = 20;
152
+ const all = [];
153
+ for (let skip = 0; skip < 1000; skip += pageSize) {
154
+ const res = await toast.M.getInstance().message.getMessages({
155
+ conversationId,
156
+ customTypes,
157
+ limit: pageSize,
158
+ skip,
159
+ });
160
+ const batch = Array.isArray(res === null || res === void 0 ? void 0 : res.messages) ? res.messages : [];
161
+ all.push(...batch);
162
+ if (batch.length < pageSize)
163
+ break;
164
+ }
165
+ return all;
166
+ }
167
+
168
+ /** One chat message may carry at most this many attachments. */
169
+ const MAX_MEDIA_PER_MESSAGE = 5;
170
+ /** Cap incoming files so total (existing + new) never exceeds MAX_MEDIA_PER_MESSAGE. */
171
+ function takeMediaFiles(incoming, alreadyCount = 0) {
172
+ const list = Array.from(incoming || []).filter(Boolean);
173
+ const remaining = Math.max(0, MAX_MEDIA_PER_MESSAGE - Math.max(0, alreadyCount));
174
+ const accepted = list.slice(0, remaining);
175
+ const rejected = Math.max(0, list.length - accepted.length);
176
+ return {
177
+ accepted,
178
+ rejected,
179
+ atLimit: rejected > 0 || remaining === 0,
180
+ remaining: Math.max(0, remaining - accepted.length),
181
+ };
182
+ }
183
+ function mediaLimitToastMessage(rejected, max = MAX_MEDIA_PER_MESSAGE) {
184
+ if (rejected <= 0)
185
+ return `You can attach up to ${max} files per message`;
186
+ return `Only ${max} files per message — ${rejected} file${rejected === 1 ? '' : 's'} skipped`;
187
+ }
188
+
189
+ const WORD_EXTENSIONS = new Set(['doc', 'docx', 'docm']);
190
+ const EXCEL_EXTENSIONS = new Set(['xls', 'xlsx', 'xlsm']);
191
+ const OOXML_EXTENSIONS = new Set(['docx', 'docm', 'xlsx', 'xlsm']);
192
+ /** Skip parsing huge workbooks; those still get a typed card thumbnail. */
193
+ const MAX_PREVIEW_BYTES = 12 * 1024 * 1024;
194
+ const MAX_XML_BYTES = 8 * 1024 * 1024;
195
+ const WORD_LINES = 12;
196
+ const EXCEL_ROWS = 8;
197
+ const EXCEL_COLS = 6;
198
+ const WORD_COLOR = '#2b579a';
199
+ const EXCEL_COLOR = '#217346';
200
+ /** True when this URL is the document itself, which Image.network cannot draw. */
201
+ function looksLikeDocumentFileUrl(url) {
202
+ const path = String(url || '')
203
+ .split('?')[0]
204
+ .split('#')[0]
205
+ .toLowerCase();
206
+ return /\.(pdf|docx?|docm|xlsx?|xlsm|pptx?|csv|txt|rtf)$/.test(path);
207
+ }
208
+ function officePreviewKind(file) {
209
+ const mime = String((file === null || file === void 0 ? void 0 : file.mimeType) || '').toLowerCase();
210
+ const name = String((file === null || file === void 0 ? void 0 : file.nameWithExtension) || (file === null || file === void 0 ? void 0 : file.name) || '');
211
+ const ext = extensionOf(name);
212
+ const word = WORD_EXTENSIONS.has(ext) ||
213
+ mime === 'application/msword' ||
214
+ mime.includes('wordprocessingml') ||
215
+ mime.includes('ms-word') ||
216
+ mime.includes('msword');
217
+ if (word)
218
+ return 'word';
219
+ const excel = EXCEL_EXTENSIONS.has(ext) ||
220
+ mime === 'application/vnd.ms-excel' ||
221
+ mime.includes('spreadsheetml') ||
222
+ mime.includes('ms-excel');
223
+ if (excel)
224
+ return 'excel';
225
+ return null;
226
+ }
227
+ /**
228
+ * First-page text (Word) or first-sheet grid (Excel) from an OOXML zip.
229
+ * Returns null when the zip cannot be read; callers then paint a file card.
230
+ */
231
+ async function extractOfficePreview(data, kind) {
232
+ const entries = listZipEntries(data);
233
+ if (!entries.length)
234
+ return null;
235
+ if (kind === 'word') {
236
+ const entry = findEntry(entries, 'word/document.xml');
237
+ if (!entry)
238
+ return null;
239
+ const xml = await readZipXml(data, entry);
240
+ if (!xml)
241
+ return null;
242
+ return { lines: docxLines(xml), rows: [] };
243
+ }
244
+ const sheet = firstSheetEntry(entries);
245
+ if (!sheet)
246
+ return null;
247
+ const shared = findEntry(entries, 'xl/sharedStrings.xml');
248
+ const [sheetXml, sharedXml] = await Promise.all([
249
+ readZipXml(data, sheet),
250
+ shared ? readZipXml(data, shared) : Promise.resolve(''),
251
+ ]);
252
+ if (!sheetXml)
253
+ return null;
254
+ return { lines: [], rows: xlsxRows(sheetXml, sharedXml || '') };
255
+ }
256
+ /**
257
+ * JPEG the send pipeline uploads as `thumbnailUrl`.
258
+ * Null for any file that is not Word or Excel, and when canvas is unavailable.
259
+ */
260
+ async function captureOfficeThumbnailBlob(file) {
261
+ if (typeof document === 'undefined')
262
+ return null;
263
+ const kind = officePreviewKind({ mimeType: file === null || file === void 0 ? void 0 : file.type, name: file === null || file === void 0 ? void 0 : file.name });
264
+ if (!kind)
265
+ return null;
266
+ // A failed preview must not block the file upload. Callers send the document either way.
267
+ try {
268
+ const label = (file === null || file === void 0 ? void 0 : file.name) || (kind === 'excel' ? 'Spreadsheet.xlsx' : 'Document.docx');
269
+ let content = null;
270
+ if (file.size > 0 && file.size <= MAX_PREVIEW_BYTES && OOXML_EXTENSIONS.has(extensionOf(label))) {
271
+ content = await extractOfficePreview(new Uint8Array(await file.arrayBuffer()), kind);
272
+ }
273
+ const hasWord = !!(content === null || content === void 0 ? void 0 : content.lines.some(line => line.trim()));
274
+ const hasExcel = !!(content === null || content === void 0 ? void 0 : content.rows.some(row => row.some(cell => cell.trim())));
275
+ if (kind === 'word' && hasWord && content)
276
+ return await paintWordPage(content.lines, label);
277
+ if (kind === 'excel' && hasExcel && content)
278
+ return await paintExcelSheet(content.rows, label);
279
+ return await paintFileCard(kind, label);
280
+ }
281
+ catch (_a) {
282
+ return null;
283
+ }
284
+ }
285
+ function extensionOf(name) {
286
+ const base = (name || '').split(/[/\\]/).pop() || '';
287
+ const idx = base.lastIndexOf('.');
288
+ if (idx <= 0)
289
+ return '';
290
+ return base.slice(idx + 1).toLowerCase();
291
+ }
292
+ function decodeXml(value) {
293
+ return value
294
+ .replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)))
295
+ .replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number(dec)))
296
+ .replace(/&lt;/g, '<')
297
+ .replace(/&gt;/g, '>')
298
+ .replace(/&quot;/g, '"')
299
+ .replace(/&apos;/g, "'")
300
+ .replace(/&amp;/g, '&');
301
+ }
302
+ /** Paragraph text from word/document.xml, in reading order. */
303
+ function docxLines(xml) {
304
+ const lines = [];
305
+ const paragraphs = xml.match(/<w:p\b[\s\S]*?<\/w:p>/g) || [];
306
+ for (const paragraph of paragraphs) {
307
+ const normalized = paragraph.replace(/<w:tab\/>/g, ' ').replace(/<w:br\/>/g, '\n');
308
+ const parts = [...normalized.matchAll(/<w:t\b[^>]*>([\s\S]*?)<\/w:t>/g)].map(match => decodeXml(match[1]));
309
+ const text = parts.join('').replace(/\s+/g, ' ').trim();
310
+ if (!text)
311
+ continue;
312
+ lines.push(text.slice(0, 180));
313
+ if (lines.length >= WORD_LINES)
314
+ break;
315
+ }
316
+ return lines;
317
+ }
318
+ /** First rows and columns of a worksheet. Shared strings are optional. */
319
+ function xlsxRows(sheetXml, sharedStringsXml) {
320
+ const strings = sharedStrings(sharedStringsXml);
321
+ const cells = [];
322
+ const cellRe = /<c\b([^>]*?)(?:\/>|>([\s\S]*?)<\/c>)/g;
323
+ let match;
324
+ while ((match = cellRe.exec(sheetXml))) {
325
+ const attrs = match[1] || '';
326
+ const ref = attr(attrs, 'r');
327
+ const parsed = parseCellRef(ref);
328
+ if (!parsed || parsed.row >= 40 || parsed.col >= 20)
329
+ continue;
330
+ const value = cellText(match[2] || '', attr(attrs, 't'), strings);
331
+ if (!value)
332
+ continue;
333
+ cells.push({ row: parsed.row, col: parsed.col, value: value.slice(0, 40) });
334
+ }
335
+ return denseGrid(cells);
336
+ }
337
+ function sharedStrings(xml) {
338
+ if (!xml)
339
+ return [];
340
+ const items = xml.match(/<si\b[\s\S]*?<\/si>/g) || [];
341
+ return items.map(item => {
342
+ const withoutPhonetic = item.replace(/<rPh\b[\s\S]*?<\/rPh>/g, '');
343
+ return [...withoutPhonetic.matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(match => decodeXml(match[1])).join('');
344
+ });
345
+ }
346
+ function attr(attrs, name) {
347
+ const match = new RegExp(`\\b${name}="([^"]*)"`).exec(attrs);
348
+ return match ? match[1] : '';
349
+ }
350
+ function parseCellRef(ref) {
351
+ const match = /^([A-Z]+)(\d+)$/i.exec(ref || '');
352
+ if (!match)
353
+ return null;
354
+ let col = 0;
355
+ for (const ch of match[1].toUpperCase())
356
+ col = col * 26 + (ch.charCodeAt(0) - 64);
357
+ return { col: col - 1, row: Number(match[2]) - 1 };
358
+ }
359
+ function cellText(inner, type, strings) {
360
+ if (type === 'inlineStr') {
361
+ return [...inner.matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(match => decodeXml(match[1])).join('').trim();
362
+ }
363
+ const value = /<v\b[^>]*>([\s\S]*?)<\/v>/.exec(inner);
364
+ if (!value)
365
+ return '';
366
+ const raw = decodeXml(value[1]).trim();
367
+ if (type === 's')
368
+ return strings[Number(raw)] || '';
369
+ return raw;
370
+ }
371
+ function denseGrid(cells) {
372
+ if (!cells.length)
373
+ return [];
374
+ const rowIds = [...new Set(cells.map(cell => cell.row))].sort((a, b) => a - b).slice(0, EXCEL_ROWS);
375
+ const colIds = [...new Set(cells.map(cell => cell.col))].sort((a, b) => a - b).slice(0, EXCEL_COLS);
376
+ const rowPos = new Map(rowIds.map((row, index) => [row, index]));
377
+ const colPos = new Map(colIds.map((col, index) => [col, index]));
378
+ const grid = rowIds.map(() => colIds.map(() => ''));
379
+ for (const cell of cells) {
380
+ const row = rowPos.get(cell.row);
381
+ const col = colPos.get(cell.col);
382
+ if (row == null || col == null)
383
+ continue;
384
+ grid[row][col] = cell.value;
385
+ }
386
+ return grid;
387
+ }
388
+ function listZipEntries(data) {
389
+ if (data.length < 22)
390
+ return [];
391
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
392
+ const eocd = findEocd(data);
393
+ if (eocd < 0)
394
+ return [];
395
+ const count = view.getUint16(eocd + 10, true);
396
+ const cdOffset = view.getUint32(eocd + 16, true);
397
+ if (cdOffset === 0xffffffff || cdOffset >= data.length)
398
+ return [];
399
+ const entries = [];
400
+ let cursor = cdOffset;
401
+ for (let i = 0; i < count && cursor + 46 <= data.length; i++) {
402
+ if (view.getUint32(cursor, true) !== 0x02014b50)
403
+ break;
404
+ const method = view.getUint16(cursor + 10, true);
405
+ const compressedSize = view.getUint32(cursor + 20, true);
406
+ const uncompressedSize = view.getUint32(cursor + 24, true);
407
+ const nameLen = view.getUint16(cursor + 28, true);
408
+ const extraLen = view.getUint16(cursor + 30, true);
409
+ const commentLen = view.getUint16(cursor + 32, true);
410
+ const localOffset = view.getUint32(cursor + 42, true);
411
+ const name = new TextDecoder().decode(data.subarray(cursor + 46, cursor + 46 + nameLen));
412
+ entries.push({ name, method, compressedSize, uncompressedSize, localOffset });
413
+ cursor += 46 + nameLen + extraLen + commentLen;
414
+ }
415
+ return entries;
416
+ }
417
+ function findEocd(data) {
418
+ const start = Math.max(0, data.length - (22 + 0xffff));
419
+ for (let i = data.length - 22; i >= start; i--) {
420
+ if (data[i] === 0x50 && data[i + 1] === 0x4b && data[i + 2] === 0x05 && data[i + 3] === 0x06)
421
+ return i;
422
+ }
423
+ return -1;
424
+ }
425
+ function findEntry(entries, name) {
426
+ const want = name.toLowerCase();
427
+ return entries.find(entry => entry.name.replace(/\\/g, '/').toLowerCase() === want);
428
+ }
429
+ function firstSheetEntry(entries) {
430
+ const sheets = entries.filter(entry => /^xl\/worksheets\/sheet\d+\.xml$/i.test(entry.name.replace(/\\/g, '/')));
431
+ sheets.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
432
+ return sheets[0];
433
+ }
434
+ async function readZipXml(data, entry) {
435
+ if (entry.uncompressedSize > MAX_XML_BYTES)
436
+ return null;
437
+ const bytes = await unzipEntry(data, entry);
438
+ if (!bytes)
439
+ return null;
440
+ return new TextDecoder().decode(bytes);
441
+ }
442
+ async function unzipEntry(data, entry) {
443
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
444
+ const local = entry.localOffset;
445
+ if (local < 0 || local + 30 > data.length)
446
+ return null;
447
+ if (view.getUint32(local, true) !== 0x04034b50)
448
+ return null;
449
+ const nameLen = view.getUint16(local + 26, true);
450
+ const extraLen = view.getUint16(local + 28, true);
451
+ const start = local + 30 + nameLen + extraLen;
452
+ const end = start + entry.compressedSize;
453
+ if (end > data.length)
454
+ return null;
455
+ const compressed = data.subarray(start, end);
456
+ if (entry.method === 0)
457
+ return compressed;
458
+ if (entry.method === 8)
459
+ return inflateRaw(compressed);
460
+ return null;
461
+ }
462
+ async function inflateRaw(compressed) {
463
+ var _a, _b;
464
+ const DecompressionStreamCtor = globalThis.DecompressionStream;
465
+ if (typeof DecompressionStreamCtor !== 'function')
466
+ return null;
467
+ try {
468
+ const copy = compressed.buffer.slice(compressed.byteOffset, compressed.byteOffset + compressed.byteLength);
469
+ const blob = new Blob([copy]);
470
+ const source = (_b = (_a = blob).stream) === null || _b === void 0 ? void 0 : _b.call(_a);
471
+ if (!source)
472
+ return null;
473
+ const stream = source.pipeThrough(new DecompressionStreamCtor('deflate-raw'));
474
+ const buffer = await new Response(stream).arrayBuffer();
475
+ return new Uint8Array(buffer);
476
+ }
477
+ catch (_c) {
478
+ return null;
479
+ }
480
+ }
481
+ function renderJpeg(width, height, draw) {
482
+ const canvas = document.createElement('canvas');
483
+ canvas.width = width;
484
+ canvas.height = height;
485
+ const ctx = canvas.getContext('2d');
486
+ if (!ctx || typeof canvas.toBlob !== 'function')
487
+ return Promise.resolve(null);
488
+ draw(ctx);
489
+ return new Promise(resolve => canvas.toBlob(blob => resolve(blob), 'image/jpeg', 0.85));
490
+ }
491
+ function paintWordPage(lines, fileName) {
492
+ return renderJpeg(640, 840, ctx => {
493
+ ctx.fillStyle = '#ffffff';
494
+ ctx.fillRect(0, 0, 640, 840);
495
+ ctx.fillStyle = WORD_COLOR;
496
+ ctx.fillRect(0, 0, 640, 10);
497
+ ctx.fillStyle = WORD_COLOR;
498
+ ctx.font = '700 12px sans-serif';
499
+ ctx.fillText(badge(fileName, 'word'), 36, 40);
500
+ ctx.fillStyle = '#1f2937';
501
+ ctx.font = '16px sans-serif';
502
+ let y = 72;
503
+ for (const line of lines) {
504
+ const wrapped = wrapText(ctx, line, 568, 3);
505
+ for (const row of wrapped) {
506
+ ctx.fillText(row, 36, y);
507
+ y += 26;
508
+ if (y > 760)
509
+ return;
510
+ }
511
+ y += 8;
512
+ }
513
+ paintFileName(ctx, fileName, 800);
514
+ });
515
+ }
516
+ function paintExcelSheet(rows, fileName) {
517
+ return renderJpeg(800, 560, ctx => {
518
+ ctx.fillStyle = '#ffffff';
519
+ ctx.fillRect(0, 0, 800, 560);
520
+ ctx.fillStyle = EXCEL_COLOR;
521
+ ctx.fillRect(0, 0, 800, 48);
522
+ ctx.fillStyle = '#ffffff';
523
+ ctx.font = '600 16px sans-serif';
524
+ ctx.fillText(fitText(ctx, baseName(fileName), 740), 20, 30);
525
+ const cols = Math.max(1, ...rows.map(row => row.length));
526
+ const bodyTop = 48;
527
+ const rowHeight = Math.min(56, Math.floor((560 - bodyTop) / Math.max(rows.length, 1)));
528
+ const colWidth = Math.floor(800 / cols);
529
+ rows.forEach((row, rowIndex) => {
530
+ const y = bodyTop + rowIndex * rowHeight;
531
+ for (let col = 0; col < cols; col++) {
532
+ const x = col * colWidth;
533
+ ctx.fillStyle = rowIndex === 0 ? '#e7f4ec' : rowIndex % 2 ? '#f8faf9' : '#ffffff';
534
+ ctx.fillRect(x, y, colWidth, rowHeight);
535
+ ctx.strokeStyle = '#d1d5db';
536
+ ctx.strokeRect(x + 0.5, y + 0.5, colWidth - 1, rowHeight - 1);
537
+ ctx.fillStyle = '#111827';
538
+ ctx.font = rowIndex === 0 ? '700 14px sans-serif' : '14px sans-serif';
539
+ const text = fitText(ctx, row[col] || '', colWidth - 16);
540
+ ctx.fillText(text, x + 8, y + Math.min(28, rowHeight - 14));
541
+ }
542
+ });
543
+ });
544
+ }
545
+ function paintFileCard(kind, fileName) {
546
+ const color = kind === 'excel' ? EXCEL_COLOR : WORD_COLOR;
547
+ const title = kind === 'excel' ? 'Excel spreadsheet' : 'Word document';
548
+ return renderJpeg(640, 800, ctx => {
549
+ ctx.fillStyle = '#f8fafc';
550
+ ctx.fillRect(0, 0, 640, 800);
551
+ ctx.fillStyle = '#ffffff';
552
+ roundRect(ctx, 70, 150, 500, 460, 20);
553
+ ctx.fill();
554
+ ctx.fillStyle = color;
555
+ roundRect(ctx, 230, 230, 180, 140, 16);
556
+ ctx.fill();
557
+ ctx.fillStyle = '#ffffff';
558
+ ctx.font = '700 36px sans-serif';
559
+ const label = badge(fileName, kind);
560
+ ctx.fillText(label, 320 - ctx.measureText(label).width / 2, 312);
561
+ ctx.fillStyle = '#111827';
562
+ ctx.font = '600 22px sans-serif';
563
+ const name = fitText(ctx, baseName(fileName), 420);
564
+ ctx.fillText(name, 320 - ctx.measureText(name).width / 2, 440);
565
+ ctx.fillStyle = '#6b7280';
566
+ ctx.font = '16px sans-serif';
567
+ ctx.fillText(title, 320 - ctx.measureText(title).width / 2, 478);
568
+ });
569
+ }
570
+ function paintFileName(ctx, fileName, y) {
571
+ ctx.fillStyle = '#6b7280';
572
+ ctx.font = '13px sans-serif';
573
+ ctx.fillText(fitText(ctx, baseName(fileName), 560), 36, y);
574
+ }
575
+ function badge(fileName, kind) {
576
+ const ext = extensionOf(fileName);
577
+ if (ext)
578
+ return ext.toUpperCase();
579
+ return kind === 'excel' ? 'XLS' : 'DOC';
580
+ }
581
+ function baseName(fileName) {
582
+ return (fileName || 'Document').split(/[/\\]/).pop() || 'Document';
583
+ }
584
+ function fitText(ctx, text, maxWidth) {
585
+ if (ctx.measureText(text).width <= maxWidth)
586
+ return text;
587
+ let trimmed = text;
588
+ while (trimmed.length > 1 && ctx.measureText(`${trimmed}…`).width > maxWidth)
589
+ trimmed = trimmed.slice(0, -1);
590
+ return `${trimmed}…`;
591
+ }
592
+ function wrapText(ctx, text, maxWidth, maxLines) {
593
+ const words = text.split(/\s+/).filter(Boolean);
594
+ const lines = [];
595
+ let current = '';
596
+ for (const word of words) {
597
+ const next = current ? `${current} ${word}` : word;
598
+ if (current && ctx.measureText(next).width > maxWidth) {
599
+ lines.push(current);
600
+ current = word;
601
+ if (lines.length >= maxLines)
602
+ return lines;
603
+ }
604
+ else {
605
+ current = next;
606
+ }
607
+ }
608
+ if (current && lines.length < maxLines)
609
+ lines.push(fitText(ctx, current, maxWidth));
610
+ return lines;
611
+ }
612
+ function roundRect(ctx, x, y, width, height, radius) {
613
+ ctx.beginPath();
614
+ ctx.moveTo(x + radius, y);
615
+ ctx.arcTo(x + width, y, x + width, y + height, radius);
616
+ ctx.arcTo(x + width, y + height, x, y + height, radius);
617
+ ctx.arcTo(x, y + height, x, y, radius);
618
+ ctx.arcTo(x, y, x + width, y, radius);
619
+ ctx.closePath();
620
+ }
621
+
622
+ /**
623
+ * Shared media-send helpers for ChatFooter + public web-chat.sendMedia.
624
+ * Conversation path only (groupcast keeps using ChatFooter).
625
+ *
626
+ * Attachment body contract (Flutter / Swift / web):
627
+ * - API rejects empty body → caption, filename (single doc), or 'AttachmentMessage:Multiple'
628
+ * - Real caption for UI lives in metaData.caption (read captionMessage for older web sends)
629
+ */
630
+ const ATTACHMENT_BODY_PLACEHOLDER = 'AttachmentMessage:Multiple';
631
+ function mediaTypeFromMime(mime) {
632
+ if (!mime)
633
+ return 3;
634
+ if (mime.startsWith('image/'))
635
+ return 0;
636
+ if (mime.startsWith('video/'))
637
+ return 1;
638
+ if (mime.startsWith('audio/'))
639
+ return 2;
640
+ return 3;
641
+ }
642
+ function customTypeFromMime(mime) {
643
+ if (!mime)
644
+ return ATTACHMENT_BODY_PLACEHOLDER;
645
+ if (mime.startsWith('image/'))
646
+ return 'AttachmentMessage:Image';
647
+ if (mime.startsWith('video/'))
648
+ return 'AttachmentMessage:Video';
649
+ if (mime.startsWith('audio/'))
650
+ return 'AttachmentMessage:Audio';
651
+ if (mime.startsWith('application/') || mime.startsWith('text/'))
652
+ return 'AttachmentMessage:Doc';
653
+ return ATTACHMENT_BODY_PLACEHOLDER;
654
+ }
655
+ function isAttachmentBodyPlaceholder(body) {
656
+ const s = (body !== null && body !== void 0 ? body : '').toString().trim();
657
+ return !s || s.startsWith('AttachmentMessage:');
658
+ }
659
+ /** Caption for UI — never treat AttachmentMessage:* body placeholders as caption. */
660
+ function attachmentCaption(message) {
661
+ var _a, _b, _c, _d;
662
+ const meta = message === null || message === void 0 ? void 0 : message.metaData;
663
+ const fromMeta = String((_b = (_a = meta === null || meta === void 0 ? void 0 : meta.caption) !== null && _a !== void 0 ? _a : meta === null || meta === void 0 ? void 0 : meta.captionMessage) !== null && _b !== void 0 ? _b : '').trim();
664
+ if (fromMeta)
665
+ return fromMeta;
666
+ const body = String((_c = message === null || message === void 0 ? void 0 : message.body) !== null && _c !== void 0 ? _c : '').trim();
667
+ const customType = String((_d = message === null || message === void 0 ? void 0 : message.customType) !== null && _d !== void 0 ? _d : '').trim();
668
+ // Multiple attachments: real caption lives in metaData only (Flutter/Swift/web); never use body text
669
+ if (body === ATTACHMENT_BODY_PLACEHOLDER || customType === ATTACHMENT_BODY_PLACEHOLDER)
670
+ return '';
671
+ if (isAttachmentBodyPlaceholder(body))
672
+ return '';
673
+ return body;
674
+ }
675
+ /** @deprecated Prefer attachmentBodyForOutgoing — kept for callers that only pass caption. */
676
+ function attachmentBodyForApi(caption) {
677
+ return (caption === null || caption === void 0 ? void 0 : caption.trim()) || ATTACHMENT_BODY_PLACEHOLDER;
678
+ }
679
+ /** File extension without dot (e.g. "report.pdf" → "pdf"). */
680
+ function extensionFromFileName(name) {
681
+ const base = (name || '').split(/[/\\]/).pop() || '';
682
+ const idx = base.lastIndexOf('.');
683
+ if (idx <= 0)
684
+ return '';
685
+ return base.slice(idx + 1).toLowerCase();
686
+ }
687
+ /**
688
+ * MIME stored on each attachment. Flutter parity: `mimeTypeForAttachmentExtension`
689
+ * in Flutter_Chat_Sdk send_message_media.dart (mediaType 0 image, 1 video, 2 audio, 3 doc).
690
+ */
691
+ function mimeTypeForAttachmentExtension(extension, mediaType) {
692
+ const ext = (extension !== null && extension !== void 0 ? extension : '').toLowerCase().replace(/^\./, '');
693
+ switch (ext) {
694
+ case 'jpg':
695
+ case 'jpeg':
696
+ return 'image/jpeg';
697
+ case 'png':
698
+ return 'image/png';
699
+ case 'gif':
700
+ return 'image/gif';
701
+ case 'webp':
702
+ return 'image/webp';
703
+ case 'heic':
704
+ case 'heif':
705
+ return 'image/heic';
706
+ case 'mp4':
707
+ return mediaType === 2 ? 'audio/mp4' : 'video/mp4';
708
+ case 'mov':
709
+ return 'video/quicktime';
710
+ case 'webm':
711
+ return mediaType === 2 ? 'audio/webm' : 'video/webm';
712
+ case 'mkv':
713
+ return 'video/x-matroska';
714
+ case 'mp3':
715
+ return 'audio/mpeg';
716
+ case 'm4a':
717
+ case 'aac':
718
+ return 'audio/mp4';
719
+ case 'wav':
720
+ return 'audio/wav';
721
+ case 'pdf':
722
+ return 'application/pdf';
723
+ case 'doc':
724
+ return 'application/msword';
725
+ case 'docx':
726
+ return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
727
+ case 'docm':
728
+ return 'application/vnd.ms-word.document.macroEnabled.12';
729
+ case 'xls':
730
+ return 'application/vnd.ms-excel';
731
+ case 'xlsx':
732
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
733
+ case 'xlsm':
734
+ return 'application/vnd.ms-excel.sheet.macroEnabled.12';
735
+ case 'txt':
736
+ return 'text/plain';
737
+ case 'csv':
738
+ return 'text/csv';
739
+ case 'rtf':
740
+ return 'application/rtf';
741
+ default:
742
+ switch (mediaType) {
743
+ case 1:
744
+ return 'video/mp4';
745
+ case 2:
746
+ return 'audio/mpeg';
747
+ case 3:
748
+ return 'application/pdf';
749
+ default:
750
+ return 'image/jpeg';
751
+ }
752
+ }
753
+ }
754
+ function inferMediaTypeFromExtension(ext) {
755
+ const e = (ext || '').toLowerCase();
756
+ if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif', 'bmp'].includes(e))
757
+ return 0;
758
+ if (['mp4', 'mov', 'webm', 'mkv'].includes(e))
759
+ return 1;
760
+ if (['mp3', 'wav', 'm4a', 'aac', 'ogg'].includes(e))
761
+ return 2;
762
+ return 3;
763
+ }
764
+ /** Prefer browser File.type; infer from extension when empty (common for PDF picks). */
765
+ function resolveMimeType(file) {
766
+ const trimmed = (file.type || '').trim();
767
+ if (trimmed)
768
+ return trimmed;
769
+ const ext = extensionFromFileName(file.name);
770
+ const mediaType = inferMediaTypeFromExtension(ext);
771
+ return mimeTypeForAttachmentExtension(ext, mediaType);
772
+ }
773
+ /** Flutter single-document send uses filename as body when there is no caption. */
774
+ function attachmentBodyForOutgoing(caption, files) {
775
+ const cap = caption === null || caption === void 0 ? void 0 : caption.trim();
776
+ if (cap)
777
+ return cap;
778
+ if (files.length === 1) {
779
+ const f = files[0];
780
+ const name = 'nameWithExtension' in f ? f.nameWithExtension : f.name;
781
+ const mime = 'mimeType' in f ? f.mimeType : resolveMimeType(f);
782
+ if (mediaTypeFromMime(mime) === 3)
783
+ return name;
784
+ }
785
+ return ATTACHMENT_BODY_PLACEHOLDER;
786
+ }
787
+ function resolveCustomTypeForUpload(attachments) {
788
+ if (!(attachments === null || attachments === void 0 ? void 0 : attachments.length) || attachments.length !== 1)
789
+ return ATTACHMENT_BODY_PLACEHOLDER;
790
+ return customTypeFromMime(attachments[0].mimeType);
791
+ }
792
+ function buildReplyMetaData(replyMessage, caption) {
793
+ var _a, _b, _c;
794
+ if (!replyMessage && !(caption === null || caption === void 0 ? void 0 : caption.trim()))
795
+ return {};
796
+ const trimmed = caption === null || caption === void 0 ? void 0 : caption.trim();
797
+ return Object.assign(Object.assign({}, (replyMessage && Object.assign({ parentMessageId: replyMessage.messageId, parentMessage: replyMessage.body, parentMessageTime: replyMessage.sentAt, parentMessageSenderId: ((_a = replyMessage.senderInfo) === null || _a === void 0 ? void 0 : _a.userId) || replyMessage.senderId, parentMessageSenderName: ((_b = replyMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName) || replyMessage.userName }, (((_c = replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.attachments) === null || _c === void 0 ? void 0 : _c[0]) && {
798
+ parentMessageName: replyMessage.attachments[0].name,
799
+ parentMessageMediaUrl: replyMessage.attachments[0].mediaUrl,
800
+ parentMessageType: replyMessage.attachments[0].mimeType,
801
+ })))), (trimmed && { caption: trimmed, captionMessage: trimmed }));
802
+ }
803
+ function prepareMediaAttachments(files) {
804
+ const capped = takeMediaFiles(files, 0).accepted;
805
+ return capped.map(file => {
806
+ const mimeType = resolveMimeType(file);
807
+ return {
808
+ nameWithExtension: file.name,
809
+ mediaType: mediaTypeFromMime(mimeType),
810
+ mediaId: String(file.lastModified || Date.now()) + Math.random().toString(36).slice(2, 6),
811
+ mimeType,
812
+ size: file.size,
813
+ file,
814
+ };
815
+ });
816
+ }
817
+ function buildLocalMediaAttachments(files) {
818
+ return files.map(file => {
819
+ const mimeType = resolveMimeType(file);
820
+ return {
821
+ name: file.name,
822
+ size: file.size,
823
+ type: mimeType.split('/')[0] || 'file',
824
+ mediaUrl: typeof URL !== 'undefined' ? URL.createObjectURL(file) : '',
825
+ mimeType,
826
+ mediaType: mediaTypeFromMime(mimeType),
827
+ };
828
+ });
829
+ }
830
+ /** PDF (or a file named *.pdf). The app cannot paint these bytes with Image.network. */
831
+ function isPdfFileAttachment(file) {
832
+ const mime = String((file === null || file === void 0 ? void 0 : file.mimeType) || '').toLowerCase();
833
+ const name = String((file === null || file === void 0 ? void 0 : file.nameWithExtension) || (file === null || file === void 0 ? void 0 : file.name) || '').toLowerCase();
834
+ return mime === 'application/pdf' || name.endsWith('.pdf');
835
+ }
836
+ /** Word or Excel. Same thumbnail slot as PDF: a JPEG, with the file itself on mediaUrl. */
837
+ function isOfficeFileAttachment(file) {
838
+ return officePreviewKind(file) != null;
839
+ }
840
+ /**
841
+ * Public image URL for a document preview.
842
+ *
843
+ * Reuse this for PDF, Word, and Excel. Flutter draws `thumbnailUrl` with
844
+ * Image.network, so the value has to be a JPEG/PNG. Returns '' when the only
845
+ * candidate is the document file itself.
846
+ */
847
+ function documentThumbnailUrl(opts) {
848
+ const media = String(opts.mediaUrl || '').trim();
849
+ const thumb = String(opts.thumbnailUrl || '').trim();
850
+ if (!thumb || thumb === media)
851
+ return '';
852
+ if (looksLikeDocumentFileUrl(thumb))
853
+ return '';
854
+ return thumb;
855
+ }
856
+ /**
857
+ * First page of a PDF as a JPEG, for the same thumbnail slot videos already fill.
858
+ *
859
+ * pdf.js is loaded only when a PDF is sent (same CDN Flutter web documents in
860
+ * README_web.md). If the host page already set `window.pdfjsLib`, that copy is reused.
861
+ */
862
+ async function capturePdfThumbnailBlob(file) {
863
+ var _a;
864
+ if (typeof document === 'undefined')
865
+ return null;
866
+ if (!isPdfFileAttachment({ mimeType: file === null || file === void 0 ? void 0 : file.type, name: file === null || file === void 0 ? void 0 : file.name }))
867
+ return null;
868
+ try {
869
+ const pdfjs = await loadPdfJs();
870
+ const data = new Uint8Array(await file.arrayBuffer());
871
+ const loadingTask = pdfjs.getDocument({ data, disableWorker: true, isEvalSupported: false });
872
+ const pdf = await loadingTask.promise;
873
+ const page = await pdf.getPage(1);
874
+ const base = page.getViewport({ scale: 1 });
875
+ const longest = Math.max(base.width, base.height) || 1;
876
+ const scale = Math.min(2, 1024 / longest);
877
+ const viewport = page.getViewport({ scale });
878
+ const canvas = document.createElement('canvas');
879
+ canvas.width = Math.max(1, Math.floor(viewport.width));
880
+ canvas.height = Math.max(1, Math.floor(viewport.height));
881
+ const ctx = canvas.getContext('2d');
882
+ if (!ctx)
883
+ return null;
884
+ ctx.fillStyle = '#ffffff';
885
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
886
+ await page.render({ canvasContext: ctx, viewport }).promise;
887
+ const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/jpeg', 0.85));
888
+ await ((_a = pdf.destroy) === null || _a === void 0 ? void 0 : _a.call(pdf));
889
+ return blob;
890
+ }
891
+ catch (_b) {
892
+ return null;
893
+ }
894
+ }
895
+ const PDFJS_VERSION = '3.11.174';
896
+ /** Reuse a host-provided pdf.js, otherwise load the same build Flutter web uses. */
897
+ async function loadPdfJs() {
898
+ const existing = globalThis.pdfjsLib;
899
+ if (existing === null || existing === void 0 ? void 0 : existing.getDocument)
900
+ return existing;
901
+ await new Promise((resolve, reject) => {
902
+ var _a;
903
+ const timer = setTimeout(() => reject(new Error('pdf.js load timed out')), 8000);
904
+ const done = (err) => {
905
+ clearTimeout(timer);
906
+ if (err)
907
+ reject(err);
908
+ else
909
+ resolve();
910
+ };
911
+ const prior = document.querySelector('script[data-ism-pdfjs]');
912
+ if (prior) {
913
+ if ((_a = globalThis.pdfjsLib) === null || _a === void 0 ? void 0 : _a.getDocument) {
914
+ done();
915
+ return;
916
+ }
917
+ prior.addEventListener('load', () => done(), { once: true });
918
+ prior.addEventListener('error', () => done(new Error('pdf.js failed to load')), { once: true });
919
+ return;
920
+ }
921
+ const script = document.createElement('script');
922
+ script.src = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${PDFJS_VERSION}/legacy/build/pdf.min.js`;
923
+ script.async = true;
924
+ script.dataset.ismPdfjs = '1';
925
+ script.onload = () => done();
926
+ script.onerror = () => done(new Error('pdf.js failed to load'));
927
+ document.head.appendChild(script);
928
+ });
929
+ const pdfjs = globalThis.pdfjsLib;
930
+ if (!(pdfjs === null || pdfjs === void 0 ? void 0 : pdfjs.getDocument))
931
+ throw new Error('pdf.js missing getDocument');
932
+ return pdfjs;
933
+ }
934
+ /**
935
+ * Grab a JPEG frame from a local video File for thumbnailPresignedUrl upload.
936
+ * Mobile clients already send this; web must generate it client-side.
937
+ */
938
+ async function captureVideoThumbnailBlob(file, seekSeconds = 0.1) {
939
+ var _a;
940
+ if (typeof document === 'undefined')
941
+ return null;
942
+ if (!((_a = file === null || file === void 0 ? void 0 : file.type) === null || _a === void 0 ? void 0 : _a.startsWith('video/')))
943
+ return null;
944
+ const objectUrl = URL.createObjectURL(file);
945
+ try {
946
+ const video = document.createElement('video');
947
+ video.muted = true;
948
+ video.playsInline = true;
949
+ video.preload = 'auto';
950
+ video.src = objectUrl;
951
+ await new Promise((resolve, reject) => {
952
+ const onReady = () => resolve();
953
+ video.addEventListener('loadeddata', onReady, { once: true });
954
+ video.addEventListener('error', () => reject(new Error('video load failed')), { once: true });
955
+ });
956
+ const duration = Number.isFinite(video.duration) && video.duration > 0 ? video.duration : 0;
957
+ if (duration > 0) {
958
+ video.currentTime = Math.min(Math.max(0, seekSeconds), duration * 0.25);
959
+ await new Promise(resolve => {
960
+ video.addEventListener('seeked', () => resolve(), { once: true });
961
+ });
962
+ }
963
+ const w = video.videoWidth;
964
+ const h = video.videoHeight;
965
+ if (!w || !h)
966
+ return null;
967
+ const canvas = document.createElement('canvas');
968
+ canvas.width = w;
969
+ canvas.height = h;
970
+ const ctx = canvas.getContext('2d');
971
+ if (!ctx)
972
+ return null;
973
+ ctx.drawImage(video, 0, 0, w, h);
974
+ return await new Promise(resolve => canvas.toBlob(resolve, 'image/jpeg', 0.85));
975
+ }
976
+ catch (_b) {
977
+ return null;
978
+ }
979
+ finally {
980
+ URL.revokeObjectURL(objectUrl);
981
+ }
982
+ }
983
+ /**
984
+ * Store a rendered document preview where the app reads `thumbnailUrl`.
985
+ *
986
+ * Shared by PDF pages and Word/Excel previews. Prefer the file's own thumbnail
987
+ * slot when it is a different URL from the document (same contract as video).
988
+ * Otherwise request a new image presign — Flutter does this with
989
+ * `isUpdateThumbnail` — so Image.network receives a JPEG.
990
+ */
991
+ async function putDocumentThumbnail(opts) {
992
+ var _a;
993
+ const slot = documentThumbnailUrl({
994
+ mediaUrl: opts.mediaUrl,
995
+ thumbnailUrl: opts.thumbnailUrl,
996
+ });
997
+ if (slot && opts.thumbnailPresignedUrl) {
998
+ const response = await fetch(opts.thumbnailPresignedUrl, {
999
+ method: 'PUT',
1000
+ body: opts.blob,
1001
+ headers: { 'Content-Type': 'image/jpeg' },
1002
+ });
1003
+ if (response.ok)
1004
+ return slot;
1005
+ }
1006
+ if (!opts.conversationId)
1007
+ return '';
1008
+ const res = await toast.M.getInstance().message.postMessagesPresignedurls({
1009
+ conversationId: opts.conversationId,
1010
+ attachments: [
1011
+ {
1012
+ nameWithExtension: `${opts.mediaId || 'doc'}-thumb.jpg`,
1013
+ // 0 = image. A document presign (3) does not give the app a decodable preview.
1014
+ mediaType: 0,
1015
+ mediaId: `${opts.mediaId || 'doc'}-thumb`,
1016
+ },
1017
+ ],
1018
+ });
1019
+ const details = ((_a = res === null || res === void 0 ? void 0 : res.presignedUrls) === null || _a === void 0 ? void 0 : _a[0]) || ((res === null || res === void 0 ? void 0 : res.mediaUrl) || (res === null || res === void 0 ? void 0 : res.presignedUrl) ? res : null);
1020
+ const putUrl = (details === null || details === void 0 ? void 0 : details.mediaPresignedUrl) || (details === null || details === void 0 ? void 0 : details.presignedUrl) || (details === null || details === void 0 ? void 0 : details.thumbnailPresignedUrl);
1021
+ const publicUrl = documentThumbnailUrl({
1022
+ mediaUrl: opts.mediaUrl,
1023
+ thumbnailUrl: (details === null || details === void 0 ? void 0 : details.mediaUrl) || (details === null || details === void 0 ? void 0 : details.thumbnailUrl),
1024
+ });
1025
+ if (!putUrl || !publicUrl)
1026
+ return '';
1027
+ const response = await fetch(putUrl, {
1028
+ method: 'PUT',
1029
+ body: opts.blob,
1030
+ headers: { 'Content-Type': 'image/jpeg' },
1031
+ });
1032
+ return response.ok ? publicUrl : '';
1033
+ }
1034
+ /**
1035
+ * PUT the file, and for video, PDF, Word, and Excel also PUT a JPEG the app can show.
1036
+ *
1037
+ * [renderPdfThumbnail] and [renderOfficeThumbnail] are the production renderers.
1038
+ * Tests pass a stub so they do not load pdf.js or paint a canvas. Callers should
1039
+ * pass [conversationId] so a document can get its own image presign when the
1040
+ * file slot's thumbnail URL is the document itself.
1041
+ */
1042
+ async function uploadPresignedMediaAttachment(opts) {
1043
+ const { urlDetails, attachment } = opts;
1044
+ if (!attachment)
1045
+ return null;
1046
+ const mediaPresignedUrl = (urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.mediaPresignedUrl) || (urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.presignedUrl);
1047
+ const mediaId = (urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.mediaId) || (urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.mediaUrl);
1048
+ const mediaUrl = urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.mediaUrl;
1049
+ const thumbnailPresignedUrl = urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.thumbnailPresignedUrl;
1050
+ const isPdf = isPdfFileAttachment(attachment);
1051
+ const isOffice = isOfficeFileAttachment(attachment);
1052
+ const needsImageThumb = isPdf || isOffice;
1053
+ // Document files stay on mediaUrl. thumbnailUrl is only a JPEG/PNG the app can draw.
1054
+ let thumbnailUrl = needsImageThumb
1055
+ ? documentThumbnailUrl({ mediaUrl, thumbnailUrl: urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.thumbnailUrl })
1056
+ : (urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.thumbnailUrl) || mediaUrl;
1057
+ if (!mediaPresignedUrl || !mediaUrl)
1058
+ return null;
1059
+ await fetch(mediaPresignedUrl, {
1060
+ method: 'PUT',
1061
+ body: attachment.file,
1062
+ headers: { 'Content-Type': attachment.mimeType },
1063
+ });
1064
+ // Web must fill thumbnailPresignedUrl for video — API returns empty object otherwise.
1065
+ if (thumbnailPresignedUrl && attachment.mimeType.startsWith('video/')) {
1066
+ const thumb = await captureVideoThumbnailBlob(attachment.file);
1067
+ if (thumb) {
1068
+ await fetch(thumbnailPresignedUrl, {
1069
+ method: 'PUT',
1070
+ body: thumb,
1071
+ headers: { 'Content-Type': 'image/jpeg' },
1072
+ });
1073
+ }
1074
+ }
1075
+ // Skip the preview render when there is nowhere to store the JPEG. Otherwise a
1076
+ // missing pdf.js load would block the document send.
1077
+ const imageSlot = documentThumbnailUrl({ mediaUrl, thumbnailUrl: urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.thumbnailUrl });
1078
+ const canStoreDocumentThumb = (isPdf && !!opts.renderPdfThumbnail) ||
1079
+ (isOffice && !!opts.renderOfficeThumbnail) ||
1080
+ !!opts.conversationId ||
1081
+ !!(thumbnailPresignedUrl && imageSlot);
1082
+ if (needsImageThumb && canStoreDocumentThumb) {
1083
+ const render = isPdf
1084
+ ? opts.renderPdfThumbnail || capturePdfThumbnailBlob
1085
+ : opts.renderOfficeThumbnail || captureOfficeThumbnailBlob;
1086
+ const thumb = await render(attachment.file);
1087
+ if (thumb) {
1088
+ const uploaded = await putDocumentThumbnail({
1089
+ blob: thumb,
1090
+ mediaUrl,
1091
+ mediaId: String(mediaId || attachment.mediaId || ''),
1092
+ conversationId: opts.conversationId,
1093
+ thumbnailPresignedUrl,
1094
+ thumbnailUrl: urlDetails === null || urlDetails === void 0 ? void 0 : urlDetails.thumbnailUrl,
1095
+ });
1096
+ if (uploaded)
1097
+ thumbnailUrl = uploaded;
1098
+ }
1099
+ }
1100
+ const fileExt = extensionFromFileName(attachment.nameWithExtension);
1101
+ return {
1102
+ mediaId,
1103
+ mediaUrl,
1104
+ thumbnailUrl,
1105
+ mediaType: attachment.mediaType,
1106
+ nameWithExtension: attachment.nameWithExtension,
1107
+ name: attachment.nameWithExtension,
1108
+ mimeType: attachment.mimeType,
1109
+ extension: fileExt,
1110
+ size: attachment.size,
1111
+ // Flutter: 0 is image — must match mediaType for documents (3).
1112
+ attachmentType: attachment.mediaType,
1113
+ };
1114
+ }
1115
+ /** Presign → PUT files → postMessages. Returns API messageId. */
1116
+ async function uploadAndPostMediaMessage(args) {
1117
+ const { conversationId, deviceId, attachments, replyMessage, caption, mentionedUsers, pushContext } = args;
1118
+ if (!conversationId || !(attachments === null || attachments === void 0 ? void 0 : attachments.length))
1119
+ return null;
1120
+ const resForPresignedUrl = await toast.M.getInstance().message.postMessagesPresignedurls({
1121
+ conversationId,
1122
+ attachments,
1123
+ });
1124
+ const presignedUrls = (resForPresignedUrl === null || resForPresignedUrl === void 0 ? void 0 : resForPresignedUrl.presignedUrls)
1125
+ ? resForPresignedUrl.presignedUrls
1126
+ : (resForPresignedUrl === null || resForPresignedUrl === void 0 ? void 0 : resForPresignedUrl.presignedUrl)
1127
+ ? [resForPresignedUrl]
1128
+ : null;
1129
+ if (!(presignedUrls === null || presignedUrls === void 0 ? void 0 : presignedUrls.length)) {
1130
+ throw new Error('No presigned URLs returned for media upload');
1131
+ }
1132
+ /** Typed array so `postMessages` payload is not `any[]` (strict noImplicitAny). */
1133
+ const allPayloads = [];
1134
+ await Promise.all(presignedUrls.map(async (urlDetails, index) => {
1135
+ const attachmentPayload = attachments[index];
1136
+ if (!attachmentPayload)
1137
+ return;
1138
+ const payload = await uploadPresignedMediaAttachment({
1139
+ urlDetails,
1140
+ attachment: attachmentPayload,
1141
+ conversationId,
1142
+ });
1143
+ if (payload)
1144
+ allPayloads.push(payload);
1145
+ }));
1146
+ const customType = resolveCustomTypeForUpload(attachments);
1147
+ const payload = {
1148
+ showInConversation: true,
1149
+ messageType: replyMessage ? 2 : 0,
1150
+ parentMessageId: replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.messageId,
1151
+ encrypted: false,
1152
+ conversationId,
1153
+ body: attachmentBodyForOutgoing(caption, attachments),
1154
+ customType,
1155
+ attachments: allPayloads,
1156
+ deviceId,
1157
+ metaData: buildReplyMetaData(replyMessage, caption),
1158
+ };
1159
+ if (mentionedUsers === null || mentionedUsers === void 0 ? void 0 : mentionedUsers.length)
1160
+ payload.mentionedUsers = mentionedUsers;
1161
+ localNotification.withHostMessagePushFields(payload, pushContext);
1162
+ const sendMessageRes = await toast.M.getInstance().message.postMessages(payload);
1163
+ return (sendMessageRes === null || sendMessageRes === void 0 ? void 0 : sendMessageRes.messageId) || null;
1164
+ }
1165
+
1166
+ exports.ATTACHMENT_BODY_PLACEHOLDER = ATTACHMENT_BODY_PLACEHOLDER;
1167
+ exports.MAX_MEDIA_PER_MESSAGE = MAX_MEDIA_PER_MESSAGE;
1168
+ exports.attachmentBodyForApi = attachmentBodyForApi;
1169
+ exports.attachmentBodyForOutgoing = attachmentBodyForOutgoing;
1170
+ exports.attachmentCaption = attachmentCaption;
1171
+ exports.buildLocalMediaAttachments = buildLocalMediaAttachments;
1172
+ exports.buildReplyMetaData = buildReplyMetaData;
1173
+ exports.customTypeFromMime = customTypeFromMime;
1174
+ exports.docIconKind = docIconKind;
1175
+ exports.fetchLinkMessages = fetchLinkMessages;
1176
+ exports.fetchMediaAttachments = fetchMediaAttachments;
1177
+ exports.fetchMediaCount = fetchMediaCount;
1178
+ exports.fetchMessagesPage = fetchMessagesPage;
1179
+ exports.filterMediaMessages = filterMediaMessages;
1180
+ exports.isAttachmentBodyPlaceholder = isAttachmentBodyPlaceholder;
1181
+ exports.markConversationRead = markConversationRead;
1182
+ exports.mediaLimitToastMessage = mediaLimitToastMessage;
1183
+ exports.mediaPreviewUrls = mediaPreviewUrls;
1184
+ exports.mediaTypeFromMime = mediaTypeFromMime;
1185
+ exports.mergeMessagesById = mergeMessagesById;
1186
+ exports.prepareMediaAttachments = prepareMediaAttachments;
1187
+ exports.resolveCustomTypeForUpload = resolveCustomTypeForUpload;
1188
+ exports.searchMessages = searchMessages;
1189
+ exports.splitSharedMessages = splitSharedMessages;
1190
+ exports.takeMediaFiles = takeMediaFiles;
1191
+ exports.uploadAndPostMediaMessage = uploadAndPostMediaMessage;
1192
+ exports.uploadPresignedMediaAttachment = uploadPresignedMediaAttachment;
1193
+
1194
+ //# sourceMappingURL=send-media-4ee967d4.js.map