@zean-chat/react-native 0.1.2 → 0.1.6
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.
- package/README.md +1 -1
- package/dist/components/AppMark.d.ts +1 -1
- package/dist/components/ChatHeader.d.ts +2 -2
- package/dist/components/ChatModal.d.ts +3 -2
- package/dist/components/ChatNotice.d.ts +1 -1
- package/dist/components/Composer.d.ts +3 -2
- package/dist/components/EmailForm.d.ts +1 -1
- package/dist/components/ImageViewer.d.ts +5 -2
- package/dist/components/MessageBubble.d.ts +5 -2
- package/dist/components/MessageFiles.d.ts +1 -1
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/components/MessageMeta.d.ts +3 -0
- package/dist/components/PendingPhotos.d.ts +3 -0
- package/dist/components/PoweredBy.d.ts +1 -1
- package/dist/components/Skeleton.d.ts +3 -0
- package/dist/components/TypingBubble.d.ts +1 -1
- package/dist/components/ZeanChat.d.ts +1 -1
- package/dist/hooks/use-keyboard-overlap.d.ts +4 -3
- package/dist/hooks/use-pending-photos.d.ts +5 -4
- package/dist/hooks/use-rise-in.d.ts +8 -0
- package/dist/i18n/en.d.ts +5 -0
- package/dist/i18n/fr.d.ts +5 -0
- package/dist/index.js +1165 -544
- package/dist/interfaces.d.ts +11 -2
- package/dist/models/conversation.utils.d.ts +15 -0
- package/dist/models/sdk.constants.d.ts +20 -1
- package/dist/models/sdk.interface.d.ts +55 -13
- package/dist/models/sdk.utils.d.ts +2 -0
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -26,15 +26,20 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/components/ZeanChat.tsx
|
|
29
|
-
var
|
|
29
|
+
var import_react17 = require("react");
|
|
30
30
|
|
|
31
31
|
// ../shared/src/constants/app.ts
|
|
32
32
|
var APP_NAME = "Zean";
|
|
33
|
+
var APP_URL = "https://zean.chat";
|
|
33
34
|
var PRODUCTION_BACKEND_URL = "https://api.zean.chat";
|
|
35
|
+
var STAGING_APP_KEY_PREFIX = "app_stg_";
|
|
36
|
+
var STAGING_BACKEND_URL = "https://api-stg.zean.chat";
|
|
34
37
|
var SUPPORTED_LOCALES = ["fr", "en"];
|
|
35
38
|
var DEFAULT_LOCALE = "fr";
|
|
36
39
|
|
|
37
40
|
// ../shared/src/constants/conversations.ts
|
|
41
|
+
var INBOX_FILTERS = ["all", "mine", "unassigned"];
|
|
42
|
+
var INBOX_VIEWS = [...INBOX_FILTERS, "unread"];
|
|
38
43
|
var CONTACT_ID_MAX_LENGTH = 200;
|
|
39
44
|
var CONTACT_NAME_MAX_LENGTH = 120;
|
|
40
45
|
var CONTACT_PHONE_MAX_LENGTH = 32;
|
|
@@ -196,12 +201,19 @@ function minutesOf(clock) {
|
|
|
196
201
|
// ../sdk-core/src/chat.ts
|
|
197
202
|
var CLOCK_MS = 3e4;
|
|
198
203
|
var TYPING_SIGNAL_MS = 2e3;
|
|
204
|
+
var EMAIL_ASK_TYPING_MS = 1200;
|
|
199
205
|
var SECRET_BYTES = 32;
|
|
200
206
|
var SECRET_RETRY_MS = 2e3;
|
|
207
|
+
var KEPT_MESSAGES = 100;
|
|
208
|
+
var KEPT_VERSION = 1;
|
|
209
|
+
var LIVE_AFTER_CLOSE_MS = 2 * 6e4;
|
|
210
|
+
var ADVANCE_AFTER = WIDGET_PAGE_SIZE / 2;
|
|
201
211
|
function createChatStore(backend, options) {
|
|
202
212
|
const secretKey = `zean:${options.appKey}:device`;
|
|
203
213
|
const outboxKey = `zean:${options.appKey}:outbox`;
|
|
204
214
|
const attributesKey = `zean:${options.appKey}:attributes`;
|
|
215
|
+
const keptKey = `zean:${options.appKey}:conversation`;
|
|
216
|
+
const keep = options.keep === true;
|
|
205
217
|
const listeners2 = /* @__PURE__ */ new Set();
|
|
206
218
|
const stops = [];
|
|
207
219
|
let deviceSecret = null;
|
|
@@ -212,6 +224,14 @@ function createChatStore(backend, options) {
|
|
|
212
224
|
let limit = WIDGET_PAGE_SIZE;
|
|
213
225
|
let loadingOlder = false;
|
|
214
226
|
let stopMessages = null;
|
|
227
|
+
let stopTyping = null;
|
|
228
|
+
let kept = [];
|
|
229
|
+
let keptHasOlder = false;
|
|
230
|
+
let keptHistory = null;
|
|
231
|
+
let askedAfter;
|
|
232
|
+
let windowed = false;
|
|
233
|
+
let open2 = false;
|
|
234
|
+
let liveTimer = null;
|
|
215
235
|
let typing = null;
|
|
216
236
|
let typingTimer = null;
|
|
217
237
|
let lastTypingSignal = 0;
|
|
@@ -222,6 +242,10 @@ function createChatStore(backend, options) {
|
|
|
222
242
|
let reported = false;
|
|
223
243
|
let user = null;
|
|
224
244
|
let contactCode = null;
|
|
245
|
+
let emailGiven = false;
|
|
246
|
+
let wroteHere = false;
|
|
247
|
+
let emailAskWanted = false;
|
|
248
|
+
let emailAskTimer = null;
|
|
225
249
|
let generation = 0;
|
|
226
250
|
let identifying = null;
|
|
227
251
|
let identified = false;
|
|
@@ -230,6 +254,7 @@ function createChatStore(backend, options) {
|
|
|
230
254
|
let destroyed = false;
|
|
231
255
|
let state = derive();
|
|
232
256
|
const emit2 = () => {
|
|
257
|
+
holdEmailAsk();
|
|
233
258
|
state = derive();
|
|
234
259
|
for (const listener of listeners2) listener();
|
|
235
260
|
};
|
|
@@ -253,6 +278,7 @@ function createChatStore(backend, options) {
|
|
|
253
278
|
useSecret(secret);
|
|
254
279
|
outbox = await loadOutbox();
|
|
255
280
|
heldAttributes = { ...await loadAttributes(), ...heldAttributes };
|
|
281
|
+
if (keep) await loadKept();
|
|
256
282
|
if (destroyed) return;
|
|
257
283
|
emit2();
|
|
258
284
|
stops.push(
|
|
@@ -271,11 +297,50 @@ function createChatStore(backend, options) {
|
|
|
271
297
|
backend.watch("session", args(), handleSession, () => {
|
|
272
298
|
failedToLoad = true;
|
|
273
299
|
emit2();
|
|
274
|
-
}),
|
|
275
|
-
backend.watch("typing", args(), handleTyping, () => {
|
|
276
300
|
})
|
|
277
301
|
];
|
|
302
|
+
if (!keep || open2) watchLive();
|
|
303
|
+
}
|
|
304
|
+
function watchLive() {
|
|
278
305
|
watchMessages();
|
|
306
|
+
stopTyping?.();
|
|
307
|
+
stopTyping = backend.watch("typing", args(), handleTyping, () => {
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function stopLive() {
|
|
311
|
+
if (keep && stopMessages) {
|
|
312
|
+
const hasOlder = serverHasOlder();
|
|
313
|
+
kept = serverMessages();
|
|
314
|
+
keptHasOlder = hasOlder;
|
|
315
|
+
page = { messages: [], hasOlder: false, seen: page.seen };
|
|
316
|
+
windowed = false;
|
|
317
|
+
}
|
|
318
|
+
stopMessages?.();
|
|
319
|
+
stopMessages = null;
|
|
320
|
+
stopTyping?.();
|
|
321
|
+
stopTyping = null;
|
|
322
|
+
typing = null;
|
|
323
|
+
}
|
|
324
|
+
function stopLiveLater() {
|
|
325
|
+
keepLive();
|
|
326
|
+
liveTimer = setTimeout(() => {
|
|
327
|
+
liveTimer = null;
|
|
328
|
+
stopLive();
|
|
329
|
+
emit2();
|
|
330
|
+
}, LIVE_AFTER_CLOSE_MS);
|
|
331
|
+
}
|
|
332
|
+
function keepLive() {
|
|
333
|
+
if (liveTimer) clearTimeout(liveTimer);
|
|
334
|
+
liveTimer = null;
|
|
335
|
+
}
|
|
336
|
+
function serverMessages() {
|
|
337
|
+
if (kept.length === 0) return page.messages;
|
|
338
|
+
if (page.messages.length === 0) return kept;
|
|
339
|
+
const keptIds = new Set(kept.map((message) => message.id));
|
|
340
|
+
return [...kept, ...page.messages.filter((message) => !keptIds.has(message.id))];
|
|
341
|
+
}
|
|
342
|
+
function serverHasOlder() {
|
|
343
|
+
return kept.length > 0 ? keptHasOlder : page.hasOlder;
|
|
279
344
|
}
|
|
280
345
|
function sendIdentity() {
|
|
281
346
|
const person = user;
|
|
@@ -310,6 +375,7 @@ function createChatStore(backend, options) {
|
|
|
310
375
|
);
|
|
311
376
|
session = result;
|
|
312
377
|
failedToLoad = false;
|
|
378
|
+
if (keep) checkKept(result);
|
|
313
379
|
emit2();
|
|
314
380
|
if ("report" in result && result.report && !reported) {
|
|
315
381
|
reported = true;
|
|
@@ -350,10 +416,17 @@ function createChatStore(backend, options) {
|
|
|
350
416
|
}
|
|
351
417
|
function watchMessages() {
|
|
352
418
|
stopMessages?.();
|
|
419
|
+
const after = !windowed && kept.length > 0 ? kept.at(-1).createdAt : void 0;
|
|
420
|
+
askedAfter = after;
|
|
353
421
|
stopMessages = backend.watch(
|
|
354
422
|
"messages",
|
|
355
|
-
{ ...args(), limit },
|
|
423
|
+
{ ...args(), limit: after === void 0 ? limit : WIDGET_PAGE_SIZE, ...after === void 0 ? {} : { after } },
|
|
356
424
|
(result) => {
|
|
425
|
+
if (after !== void 0 && result.hasOlder) windowed = true;
|
|
426
|
+
if (after === void 0 || windowed) {
|
|
427
|
+
kept = [];
|
|
428
|
+
keptHasOlder = false;
|
|
429
|
+
}
|
|
357
430
|
page = result;
|
|
358
431
|
pageLoaded = true;
|
|
359
432
|
loadingOlder = false;
|
|
@@ -362,6 +435,12 @@ function createChatStore(backend, options) {
|
|
|
362
435
|
outbox = outbox.filter((entry) => !stored.has(entry.clientId));
|
|
363
436
|
saveOutbox();
|
|
364
437
|
}
|
|
438
|
+
if (after !== void 0 && !windowed && result.messages.length >= ADVANCE_AFTER) {
|
|
439
|
+
kept = serverMessages();
|
|
440
|
+
page = { messages: [], hasOlder: false, seen: result.seen };
|
|
441
|
+
watchMessages();
|
|
442
|
+
}
|
|
443
|
+
saveKept();
|
|
365
444
|
emit2();
|
|
366
445
|
startOnce();
|
|
367
446
|
},
|
|
@@ -393,37 +472,124 @@ function createChatStore(backend, options) {
|
|
|
393
472
|
}
|
|
394
473
|
);
|
|
395
474
|
}
|
|
475
|
+
function statusOf() {
|
|
476
|
+
if (failedToLoad || session && hidesChat(session)) return "hidden";
|
|
477
|
+
const noConversation = keep && session !== null && "contact" in session && !session.contact?.historyKey;
|
|
478
|
+
return session && (pageLoaded || noConversation) ? session.state : "loading";
|
|
479
|
+
}
|
|
480
|
+
function wantsEmail() {
|
|
481
|
+
const app = session && "app" in session ? session.app : null;
|
|
482
|
+
const contact = session && "contact" in session ? session.contact : null;
|
|
483
|
+
return statusOf() === "ready" && !!contact && contact.email === null && !emailGiven && (app?.askEmail ?? false);
|
|
484
|
+
}
|
|
485
|
+
function holdEmailAsk() {
|
|
486
|
+
const wanted = wantsEmail();
|
|
487
|
+
if (wanted && !emailAskWanted && wroteHere) {
|
|
488
|
+
emailAskTimer = setTimeout(() => {
|
|
489
|
+
emailAskTimer = null;
|
|
490
|
+
emit2();
|
|
491
|
+
}, EMAIL_ASK_TYPING_MS);
|
|
492
|
+
} else if (!wanted && emailAskTimer) {
|
|
493
|
+
clearTimeout(emailAskTimer);
|
|
494
|
+
emailAskTimer = null;
|
|
495
|
+
}
|
|
496
|
+
emailAskWanted = wanted;
|
|
497
|
+
}
|
|
396
498
|
function derive() {
|
|
397
|
-
const status =
|
|
499
|
+
const status = statusOf();
|
|
398
500
|
const app = session && "app" in session ? session.app : null;
|
|
399
501
|
const contact = session && "contact" in session ? session.contact : null;
|
|
400
502
|
const locale = localeOf(options.languages, app?.defaultLocale ?? DEFAULT_LOCALE);
|
|
401
503
|
const fallback = DEFAULT_WIDGET_TEXTS;
|
|
402
504
|
const textOf = (key) => pickText(app?.texts[key], locale, app?.defaultLocale ?? DEFAULT_LOCALE, { fr: fallback.fr[key], en: fallback.en[key] });
|
|
403
505
|
const verified = session !== null && "identity" in session && session.identity === "verified";
|
|
404
|
-
const
|
|
506
|
+
const shown = serverMessages();
|
|
507
|
+
const hasOlder = serverHasOlder();
|
|
508
|
+
const stored = new Set(shown.map((message) => message.clientId));
|
|
405
509
|
const pending = outbox.filter((entry) => !stored.has(entry.clientId)).map(fromOutbox);
|
|
406
510
|
return {
|
|
407
511
|
status,
|
|
408
|
-
app: app ? {
|
|
512
|
+
app: app ? {
|
|
513
|
+
name: app.name,
|
|
514
|
+
color: app.color,
|
|
515
|
+
logoUrl: app.logoUrl,
|
|
516
|
+
launcher: app.launcher,
|
|
517
|
+
showBadge: app.showBadge,
|
|
518
|
+
hiddenPages: app.hiddenPages
|
|
519
|
+
} : null,
|
|
409
520
|
locale,
|
|
410
521
|
texts: { header: textOf("header"), welcome: textOf("welcome"), away: textOf("away") },
|
|
411
522
|
online: app ? app.teamOnline && isWithinBusinessHours(app.hours, /* @__PURE__ */ new Date()) : false,
|
|
412
|
-
messages: [...
|
|
523
|
+
messages: [...shown.map(fromServer), ...pending],
|
|
413
524
|
// Past the most the widget holds, older messages stay in the dashboard.
|
|
414
|
-
hasOlder:
|
|
415
|
-
atStart: !
|
|
525
|
+
hasOlder: hasOlder && Math.max(limit, shown.length) < WIDGET_MAX_MESSAGES,
|
|
526
|
+
atStart: !hasOlder,
|
|
416
527
|
loadingOlder,
|
|
417
528
|
seen: page.seen,
|
|
418
529
|
unread: contact?.unread ?? 0,
|
|
419
|
-
teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : null,
|
|
530
|
+
teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : emailAskTimer ? { sender: null } : null,
|
|
420
531
|
email: contact?.email ?? null,
|
|
421
532
|
known: contact !== null,
|
|
533
|
+
askEmail: emailAskWanted && !emailAskTimer,
|
|
534
|
+
emailGiven,
|
|
422
535
|
verified,
|
|
423
536
|
contactCode: verified ? null : contactCode,
|
|
424
537
|
connected
|
|
425
538
|
};
|
|
426
539
|
}
|
|
540
|
+
function checkKept(result) {
|
|
541
|
+
const history = "contact" in result ? result.contact?.historyKey ?? null : null;
|
|
542
|
+
if (history !== keptHistory) {
|
|
543
|
+
keptHistory = history;
|
|
544
|
+
dropKept();
|
|
545
|
+
}
|
|
546
|
+
if (hidesChat(result)) forgetKept();
|
|
547
|
+
else if (history !== null && !stopMessages && serverMessages().length === 0 && deviceSecret) {
|
|
548
|
+
watchLive();
|
|
549
|
+
if (!open2) stopLiveLater();
|
|
550
|
+
} else saveKept();
|
|
551
|
+
}
|
|
552
|
+
async function loadKept() {
|
|
553
|
+
try {
|
|
554
|
+
const saved = JSON.parse(await options.storage.getItem(keptKey) || "null");
|
|
555
|
+
if (saved?.version !== KEPT_VERSION || !Array.isArray(saved.messages) || !("app" in saved.session)) return;
|
|
556
|
+
session = saved.session;
|
|
557
|
+
kept = saved.messages;
|
|
558
|
+
keptHasOlder = saved.hasOlder;
|
|
559
|
+
keptHistory = saved.session.contact?.historyKey ?? null;
|
|
560
|
+
page = { messages: [], hasOlder: false, seen: saved.seen };
|
|
561
|
+
pageLoaded = kept.length > 0 || !saved.session.contact?.historyKey;
|
|
562
|
+
} catch {
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function saveKept() {
|
|
566
|
+
if (!keep || !session || hidesChat(session)) return;
|
|
567
|
+
const current = session;
|
|
568
|
+
const shown = serverMessages();
|
|
569
|
+
const value = {
|
|
570
|
+
version: KEPT_VERSION,
|
|
571
|
+
// Told once per load, by the backend: never from what was kept.
|
|
572
|
+
session: { ...current, report: false },
|
|
573
|
+
messages: shown.slice(-KEPT_MESSAGES),
|
|
574
|
+
hasOlder: shown.length > KEPT_MESSAGES || serverHasOlder(),
|
|
575
|
+
seen: page.seen
|
|
576
|
+
};
|
|
577
|
+
quietly(() => options.storage.setItem(keptKey, JSON.stringify(value)));
|
|
578
|
+
}
|
|
579
|
+
function dropKept() {
|
|
580
|
+
kept = [];
|
|
581
|
+
keptHasOlder = false;
|
|
582
|
+
windowed = false;
|
|
583
|
+
if (stopMessages && askedAfter !== void 0) {
|
|
584
|
+
page = { messages: [], hasOlder: false, seen: false };
|
|
585
|
+
watchMessages();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function forgetKept() {
|
|
589
|
+
dropKept();
|
|
590
|
+
keptHistory = null;
|
|
591
|
+
if (keep) quietly(() => options.storage.setItem(keptKey, ""));
|
|
592
|
+
}
|
|
427
593
|
async function untilDone(task) {
|
|
428
594
|
for (; ; ) {
|
|
429
595
|
try {
|
|
@@ -487,6 +653,7 @@ function createChatStore(backend, options) {
|
|
|
487
653
|
};
|
|
488
654
|
outbox = [...outbox, entry];
|
|
489
655
|
saveOutbox();
|
|
656
|
+
wroteHere = true;
|
|
490
657
|
emit2();
|
|
491
658
|
if (started) deliver(entry);
|
|
492
659
|
},
|
|
@@ -509,11 +676,21 @@ function createChatStore(backend, options) {
|
|
|
509
676
|
},
|
|
510
677
|
loadOlder() {
|
|
511
678
|
if (!state.hasOlder || loadingOlder || !deviceSecret) return;
|
|
512
|
-
|
|
679
|
+
const shown = !windowed && kept.length > 0 ? serverMessages().length : limit;
|
|
680
|
+
limit = Math.min(shown + WIDGET_PAGE_SIZE, WIDGET_MAX_MESSAGES);
|
|
681
|
+
windowed = true;
|
|
513
682
|
loadingOlder = true;
|
|
514
683
|
emit2();
|
|
515
684
|
watchMessages();
|
|
516
685
|
},
|
|
686
|
+
setOpen(value) {
|
|
687
|
+
if (open2 === value) return;
|
|
688
|
+
open2 = value;
|
|
689
|
+
if (!keep) return;
|
|
690
|
+
keepLive();
|
|
691
|
+
if (!value) stopLiveLater();
|
|
692
|
+
else if (!stopMessages && deviceSecret) watchLive();
|
|
693
|
+
},
|
|
517
694
|
markRead() {
|
|
518
695
|
if (state.unread === 0 || !deviceSecret) return;
|
|
519
696
|
backend.call("markRead", args()).catch(() => {
|
|
@@ -530,6 +707,8 @@ function createChatStore(backend, options) {
|
|
|
530
707
|
if (!deviceSecret) return { ok: false, code: "not_found" };
|
|
531
708
|
try {
|
|
532
709
|
await backend.call("setEmail", { ...args(), email });
|
|
710
|
+
emailGiven = true;
|
|
711
|
+
emit2();
|
|
533
712
|
return { ok: true };
|
|
534
713
|
} catch (error) {
|
|
535
714
|
return { ok: false, code: codeOf(error) };
|
|
@@ -561,10 +740,13 @@ function createChatStore(backend, options) {
|
|
|
561
740
|
saveOutbox();
|
|
562
741
|
heldAttributes = {};
|
|
563
742
|
saveAttributes();
|
|
743
|
+
forgetKept();
|
|
744
|
+
emit2();
|
|
564
745
|
}
|
|
565
746
|
if (user?.id !== person.id) {
|
|
566
747
|
generation += 1;
|
|
567
748
|
contactCode = null;
|
|
749
|
+
emailGiven = false;
|
|
568
750
|
}
|
|
569
751
|
user = person;
|
|
570
752
|
identified = false;
|
|
@@ -605,14 +787,16 @@ function createChatStore(backend, options) {
|
|
|
605
787
|
user = null;
|
|
606
788
|
identified = false;
|
|
607
789
|
contactCode = null;
|
|
790
|
+
emailGiven = false;
|
|
608
791
|
identifying = null;
|
|
609
792
|
identifiedKnown = false;
|
|
610
793
|
if (deviceSecret) backend.call("signOut", args()).catch(() => {
|
|
611
794
|
});
|
|
612
795
|
for (const stop of watchers) stop();
|
|
613
796
|
watchers = [];
|
|
614
|
-
|
|
615
|
-
|
|
797
|
+
stopLive();
|
|
798
|
+
forgetKept();
|
|
799
|
+
keepLive();
|
|
616
800
|
deviceSecret = null;
|
|
617
801
|
outbox = [];
|
|
618
802
|
saveOutbox();
|
|
@@ -631,13 +815,23 @@ function createChatStore(backend, options) {
|
|
|
631
815
|
emit2();
|
|
632
816
|
watchAll();
|
|
633
817
|
},
|
|
818
|
+
async joinWithPass(pass) {
|
|
819
|
+
await starting;
|
|
820
|
+
await deviceKnown();
|
|
821
|
+
if (destroyed || !deviceSecret) return;
|
|
822
|
+
await backend.call("joinWithPass", { ...args(), pass }).catch(() => {
|
|
823
|
+
});
|
|
824
|
+
},
|
|
634
825
|
destroy() {
|
|
635
826
|
destroyed = true;
|
|
636
827
|
for (const resolve of deviceWaiters.splice(0)) resolve();
|
|
637
828
|
stopMessages?.();
|
|
829
|
+
stopTyping?.();
|
|
638
830
|
for (const stop of watchers) stop();
|
|
639
831
|
for (const stop of stops) stop();
|
|
640
832
|
if (typingTimer) clearTimeout(typingTimer);
|
|
833
|
+
keepLive();
|
|
834
|
+
if (emailAskTimer) clearTimeout(emailAskTimer);
|
|
641
835
|
listeners2.clear();
|
|
642
836
|
backend.close();
|
|
643
837
|
}
|
|
@@ -666,6 +860,16 @@ function fromOutbox(entry) {
|
|
|
666
860
|
error: entry.error
|
|
667
861
|
};
|
|
668
862
|
}
|
|
863
|
+
function hidesChat(result) {
|
|
864
|
+
return result.state === "not_found" || result.state === "domain_not_allowed";
|
|
865
|
+
}
|
|
866
|
+
function quietly(write) {
|
|
867
|
+
try {
|
|
868
|
+
void Promise.resolve(write()).catch(() => {
|
|
869
|
+
});
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
669
873
|
function codeOf(error) {
|
|
670
874
|
const code2 = error?.code;
|
|
671
875
|
return typeof code2 === "string" ? code2 : "unknown";
|
|
@@ -6010,6 +6214,12 @@ function createChat(options) {
|
|
|
6010
6214
|
return createChatStore(convexBackend(options.backendUrl), options);
|
|
6011
6215
|
}
|
|
6012
6216
|
|
|
6217
|
+
// ../shared/src/utils/app-keys.ts
|
|
6218
|
+
var isStagingKey = (appKey) => appKey.startsWith(STAGING_APP_KEY_PREFIX);
|
|
6219
|
+
function backendUrlFor(appKey) {
|
|
6220
|
+
return isStagingKey(appKey) ? STAGING_BACKEND_URL : PRODUCTION_BACKEND_URL;
|
|
6221
|
+
}
|
|
6222
|
+
|
|
6013
6223
|
// src/models/sdk.store.ts
|
|
6014
6224
|
var chat = null;
|
|
6015
6225
|
var open = false;
|
|
@@ -6157,46 +6367,69 @@ function hexOf({ l, c, h }) {
|
|
|
6157
6367
|
}).join("")}`;
|
|
6158
6368
|
}
|
|
6159
6369
|
|
|
6370
|
+
// ../shared/src/constants/uploads.ts
|
|
6371
|
+
var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
6372
|
+
var MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
6373
|
+
var MAX_ATTACHMENTS = 6;
|
|
6374
|
+
var MAX_IMAGE_SIDE = 1600;
|
|
6375
|
+
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
6376
|
+
|
|
6160
6377
|
// src/models/sdk.constants.ts
|
|
6161
6378
|
var OFFLINE_NOTICE_MS = 3e3;
|
|
6162
6379
|
var ANDROID_NAVIGATION_BAR = 48;
|
|
6380
|
+
var DEFAULT_MAX_PHOTOS = 4;
|
|
6163
6381
|
var LINK_RETRY_MS = 1500;
|
|
6164
6382
|
var LINK_RETRIES = 5;
|
|
6165
6383
|
var LINK_LIFETIME_MS = 50 * 60 * 1e3;
|
|
6166
6384
|
var NEUTRAL_COLORS = {
|
|
6167
6385
|
light: {
|
|
6168
|
-
background: "#
|
|
6169
|
-
surface: "#
|
|
6170
|
-
text: "#
|
|
6171
|
-
muted: "#
|
|
6172
|
-
border: "#
|
|
6173
|
-
danger: "#
|
|
6174
|
-
online: "#22c55e"
|
|
6386
|
+
background: "#f2f2f7",
|
|
6387
|
+
surface: "#ffffff",
|
|
6388
|
+
text: "#000000",
|
|
6389
|
+
muted: "#6c6c70",
|
|
6390
|
+
border: "#dee1e7",
|
|
6391
|
+
danger: "#ff3b30",
|
|
6392
|
+
online: "#22c55e",
|
|
6393
|
+
skeleton: "rgba(120,120,128,0.16)"
|
|
6175
6394
|
},
|
|
6176
6395
|
dark: {
|
|
6177
|
-
background: "#
|
|
6178
|
-
surface: "#
|
|
6179
|
-
text: "#
|
|
6180
|
-
muted: "#
|
|
6181
|
-
border: "#
|
|
6182
|
-
danger: "#
|
|
6183
|
-
online: "#22c55e"
|
|
6396
|
+
background: "#000000",
|
|
6397
|
+
surface: "#1c1c1e",
|
|
6398
|
+
text: "#ffffff",
|
|
6399
|
+
muted: "#98989f",
|
|
6400
|
+
border: "#38383a",
|
|
6401
|
+
danger: "#ff453a",
|
|
6402
|
+
online: "#22c55e",
|
|
6403
|
+
skeleton: "rgba(120,120,128,0.32)"
|
|
6184
6404
|
}
|
|
6185
6405
|
};
|
|
6406
|
+
var RADII = { inner: 4, pill: 14, group: 20, composer: 28 };
|
|
6407
|
+
var COMPOSER_BUTTON = 40;
|
|
6408
|
+
var RUN_GAP_MS = 5 * 60 * 1e3;
|
|
6409
|
+
var NEWEST_BUTTON_OFFSET = 120;
|
|
6410
|
+
var IMAGE_SIDE = 240;
|
|
6411
|
+
var ENTER_MS = 180;
|
|
6186
6412
|
var ICONS = {
|
|
6187
6413
|
close: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACH0lEQVR4nOzZPUoDURTF8esH1mKvNm5AwdK9qER7K8EFuIQ0iYI7ELV3IboCC0HBQlD0HpKBCJl34ryvKc4PLqIjMvmb94wvyyZByyZBCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkSsWho704/P1g/J7if2GbTkM/R5ms5w+rVakt/PisW59Dmb+XzfZ9Pn3srDL3vsc2p/7weP8dE6iqm77vPa8jOufQY+P1YG4ox8judc+7LJvX5YBzF70Jq1B25utESkUBzAY+y8UmL2oBefm8B13PDI8htbexy48nm3jmL3oFufbZ/dlut7NtmT7iwPLOWjwHXEGViE2ECADRkRQpG2LO3G3WzIoWcO4p1YpBSBsMc8WDjSrqX768b2HEj2RyJFICgVqWgcSBUIckcqHgdSBoJckarEgdSBIHWkanEgRyBIFalqHMgVCGIjVY8DOQNB10i9iAO5A8F/I/UmDpQ+u2H/GuA6Ah0GvgevoKNfIS+qdKBFnh0hpY9RiiyxWYsstzbF40DpQNAlUpU4UCMQ4IHiCCR0VNLAnhN1ZBGjVqAGOypJcmQRo3ag0HKrtqxm1Q4EzXLDseiBz6fPuc+F9UDN97Dm2fD59nmznuhboN7Re/OEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhG/AAAA//+WQPYZAAAABklEQVQDAEAXdjf1x/3ZAAAAAElFTkSuQmCC",
|
|
6188
|
-
send: "data:image/png;base64,
|
|
6414
|
+
send: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABnklEQVR4nO3ZS2rDMBSF4bO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V73dJozYUPusyxvCgW0GWnyLJ2JyBESmoNUIu3aAq0DLKBXwzmGF7qCdAfbi3TRhsJbXifvNq/zQcOQLqoJnQz7GcOAeNswY5A2KsD1hDp4Af2B9Lkk1OgFtP8hMWVODTXG7HS+grTZGGqMCUhrBnd7pMLMDzXG1nn0wDobgZNYFUVnMHUMuOXzQboN9iA99IxW6M6qjon8RI9E9emlN3udsh5H+Ru2PK96GURbTiNjOuY5r6NJTT9yGY3qodqQzlneici6dqvFeJ0gGwXbUCxzeWQZ7JCUtsF3ZXljkbsVmp+0FayT6+eje4GpAqGrXHVp/URcPw9fipy0cztHlbxz0f4fAeuBU4s93WmLOiRxgDIdoCol9b+mcKgDcqgDcqgDcqgDcqgDctgHAAD//5X8VgcAAAAGSURBVAMABqK0QlGO9rwAAAAASUVORK5CYII=",
|
|
6420
|
+
check: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABLElEQVR4nO3aSwrCMBRG4X/QUYnrdHvOxQfFfSlKOhGNaZum3tzzQSfiIDncWC1KAAAAAAAA/6iTtJd0iNc+vgZJQdJJ0v3tOhJJrzjDhzjj9Zwkt8KPOPd43FwKGXHcBgqZcVwesTAhzsnbnayXdM6Mc5O0kyM9cb4jTgJxEoiTQJwE4iQQJ4E4CcSxHqfb6InclN9WQ3x/dV18+va+oMvKCzIRR3Faai/MTBzFI1Vzgabi5AQquVBzcX4dsZILNhln/JC+rrxws3FqfBcx8T1nq430rcRZY0PNxSm5sWbjlNhg83GWbNRNnLm3Z9O38rn6CVPhZnLWitRknDnHrfljVXqSmp6cpZPkYnLmTpKryZkayXWcUYjPrms/zzal4z/KAAAAAAAAgNrwALFeI+D8E4TKAAAAAElFTkSuQmCC",
|
|
6421
|
+
seen: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABnElEQVR4nO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
};
|
|
6195
6424
|
|
|
6196
6425
|
// src/models/sdk.utils.ts
|
|
6197
6426
|
function format(template, values) {
|
|
6198
6427
|
return template.replace(/\{(\w+)\}/g, (match, key) => key in values ? String(values[key]) : match);
|
|
6199
6428
|
}
|
|
6429
|
+
function photoLimit(chosen) {
|
|
6430
|
+
if (chosen === void 0 || !Number.isFinite(chosen)) return DEFAULT_MAX_PHOTOS;
|
|
6431
|
+
return Math.min(MAX_ATTACHMENTS, Math.max(1, Math.floor(chosen)));
|
|
6432
|
+
}
|
|
6200
6433
|
function chatColors(color, scheme) {
|
|
6201
6434
|
return { ...accentColors(color, scheme), ...NEUTRAL_COLORS[scheme] };
|
|
6202
6435
|
}
|
|
@@ -6247,8 +6480,8 @@ function hideKeyboard() {
|
|
|
6247
6480
|
}
|
|
6248
6481
|
|
|
6249
6482
|
// src/components/ChatModal.tsx
|
|
6250
|
-
var
|
|
6251
|
-
var
|
|
6483
|
+
var import_react16 = require("react");
|
|
6484
|
+
var import_react_native23 = require("react-native");
|
|
6252
6485
|
|
|
6253
6486
|
// src/hooks/use-app-active.ts
|
|
6254
6487
|
var import_react = require("react");
|
|
@@ -6313,9 +6546,14 @@ var en = {
|
|
|
6313
6546
|
photo_type: "This photo cannot be sent. Send a JPEG, PNG or WebP photo.",
|
|
6314
6547
|
photo_size: "{name} is too large. Send a smaller photo.",
|
|
6315
6548
|
too_many: "At most {count} photos per message.",
|
|
6549
|
+
too_many_one: "One photo per message.",
|
|
6316
6550
|
open_image: "Open the image",
|
|
6317
6551
|
close_image: "Close the image",
|
|
6318
|
-
open_file: "Open {name}"
|
|
6552
|
+
open_file: "Open {name}",
|
|
6553
|
+
today: "Today",
|
|
6554
|
+
yesterday: "Yesterday",
|
|
6555
|
+
newest: "Go to the latest messages",
|
|
6556
|
+
image_count: "{index} of {count}"
|
|
6319
6557
|
};
|
|
6320
6558
|
|
|
6321
6559
|
// src/i18n/fr.ts
|
|
@@ -6360,33 +6598,122 @@ var fr = {
|
|
|
6360
6598
|
photo_type: "Cette photo ne peut pas \xEAtre envoy\xE9e. Envoyez une photo JPEG, PNG ou WebP.",
|
|
6361
6599
|
photo_size: "{name} est trop volumineuse. Envoyez une photo plus l\xE9g\xE8re.",
|
|
6362
6600
|
too_many: "Au plus {count} photos par message.",
|
|
6601
|
+
too_many_one: "Une seule photo par message.",
|
|
6363
6602
|
open_image: "Ouvrir l'image",
|
|
6364
6603
|
close_image: "Fermer l'image",
|
|
6365
|
-
open_file: "Ouvrir {name}"
|
|
6604
|
+
open_file: "Ouvrir {name}",
|
|
6605
|
+
today: "Aujourd'hui",
|
|
6606
|
+
yesterday: "Hier",
|
|
6607
|
+
newest: "Aller aux derniers messages",
|
|
6608
|
+
image_count: "{index} sur {count}"
|
|
6366
6609
|
};
|
|
6367
6610
|
|
|
6368
6611
|
// src/components/ImageViewer.tsx
|
|
6612
|
+
var import_react3 = require("react");
|
|
6613
|
+
var import_react_native4 = require("react-native");
|
|
6614
|
+
|
|
6615
|
+
// src/components/Icon.tsx
|
|
6369
6616
|
var import_react_native3 = require("react-native");
|
|
6370
6617
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
6371
|
-
function
|
|
6618
|
+
function Icon({ name, color, size }) {
|
|
6619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
6620
|
+
import_react_native3.Image,
|
|
6621
|
+
{
|
|
6622
|
+
source: { uri: ICONS[name] },
|
|
6623
|
+
style: { width: size, height: size, tintColor: color },
|
|
6624
|
+
accessibilityElementsHidden: true,
|
|
6625
|
+
importantForAccessibility: "no"
|
|
6626
|
+
}
|
|
6627
|
+
);
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
// src/components/ImageViewer.tsx
|
|
6631
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
6632
|
+
function ImageViewer({ gallery, topInset, onClose }) {
|
|
6372
6633
|
const { t } = useChatContext();
|
|
6373
|
-
|
|
6634
|
+
const window2 = (0, import_react_native4.useWindowDimensions)();
|
|
6635
|
+
const [size, setSize] = (0, import_react3.useState)({ width: window2.width, height: window2.height });
|
|
6636
|
+
const [index, setIndex] = (0, import_react3.useState)(gallery.index);
|
|
6637
|
+
const count = gallery.images.length;
|
|
6638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6639
|
+
import_react_native4.View,
|
|
6640
|
+
{
|
|
6641
|
+
testID: "zean-viewer",
|
|
6642
|
+
style: styles.viewer,
|
|
6643
|
+
accessibilityViewIsModal: true,
|
|
6644
|
+
onLayout: (event) => setSize({ width: event.nativeEvent.layout.width, height: event.nativeEvent.layout.height }),
|
|
6645
|
+
children: [
|
|
6646
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6647
|
+
import_react_native4.FlatList,
|
|
6648
|
+
{
|
|
6649
|
+
testID: "zean-images",
|
|
6650
|
+
horizontal: true,
|
|
6651
|
+
pagingEnabled: true,
|
|
6652
|
+
data: gallery.images,
|
|
6653
|
+
initialScrollIndex: gallery.index,
|
|
6654
|
+
getItemLayout: (_data, item) => ({ length: size.width, offset: size.width * item, index: item }),
|
|
6655
|
+
keyExtractor: (image, item) => `${item}:${image.url}`,
|
|
6656
|
+
showsHorizontalScrollIndicator: false,
|
|
6657
|
+
onMomentumScrollEnd: (event) => setIndex(Math.round(event.nativeEvent.contentOffset.x / size.width)),
|
|
6658
|
+
renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6659
|
+
import_react_native4.ScrollView,
|
|
6660
|
+
{
|
|
6661
|
+
style: size,
|
|
6662
|
+
contentContainerStyle: styles.page,
|
|
6663
|
+
maximumZoomScale: 4,
|
|
6664
|
+
minimumZoomScale: 1,
|
|
6665
|
+
centerContent: true,
|
|
6666
|
+
showsHorizontalScrollIndicator: false,
|
|
6667
|
+
showsVerticalScrollIndicator: false,
|
|
6668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Image, { source: { uri: item.url }, style: size, resizeMode: "contain", accessibilityLabel: item.name })
|
|
6669
|
+
}
|
|
6670
|
+
)
|
|
6671
|
+
}
|
|
6672
|
+
),
|
|
6673
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native4.View, { style: [styles.bar, { top: topInset + 12 }], children: [
|
|
6674
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6675
|
+
import_react_native4.Pressable,
|
|
6676
|
+
{
|
|
6677
|
+
onPress: onClose,
|
|
6678
|
+
accessibilityRole: "button",
|
|
6679
|
+
accessibilityLabel: t.close_image,
|
|
6680
|
+
hitSlop: 8,
|
|
6681
|
+
style: ({ pressed }) => [styles.close, pressed && styles.pressed],
|
|
6682
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", color: "#ffffff", size: 18 })
|
|
6683
|
+
}
|
|
6684
|
+
),
|
|
6685
|
+
count > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Text, { style: styles.count, children: format(t.image_count, { index: index + 1, count }) })
|
|
6686
|
+
] })
|
|
6687
|
+
]
|
|
6688
|
+
}
|
|
6689
|
+
);
|
|
6374
6690
|
}
|
|
6375
|
-
var styles =
|
|
6376
|
-
viewer: { ...
|
|
6377
|
-
|
|
6691
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
6692
|
+
viewer: { ...import_react_native4.StyleSheet.absoluteFill, backgroundColor: "#000000" },
|
|
6693
|
+
page: { flexGrow: 1, alignItems: "center", justifyContent: "center" },
|
|
6694
|
+
bar: { position: "absolute", left: 16, right: 16, flexDirection: "row", alignItems: "center", gap: 12 },
|
|
6695
|
+
close: {
|
|
6696
|
+
width: 36,
|
|
6697
|
+
height: 36,
|
|
6698
|
+
borderRadius: 18,
|
|
6699
|
+
alignItems: "center",
|
|
6700
|
+
justifyContent: "center",
|
|
6701
|
+
backgroundColor: "rgba(255,255,255,0.18)"
|
|
6702
|
+
},
|
|
6703
|
+
pressed: { opacity: 0.6 },
|
|
6704
|
+
count: { color: "#ffffff", fontSize: 15, fontWeight: "600" }
|
|
6378
6705
|
});
|
|
6379
6706
|
|
|
6380
6707
|
// src/components/ChatScreen.tsx
|
|
6381
|
-
var
|
|
6382
|
-
var
|
|
6708
|
+
var import_react15 = require("react");
|
|
6709
|
+
var import_react_native22 = require("react-native");
|
|
6383
6710
|
|
|
6384
6711
|
// src/hooks/use-connection-lost.ts
|
|
6385
|
-
var
|
|
6712
|
+
var import_react4 = require("react");
|
|
6386
6713
|
function useConnectionLost(connected) {
|
|
6387
|
-
const [wasConnected, setWasConnected] = (0,
|
|
6388
|
-
const [lost, setLost] = (0,
|
|
6389
|
-
(0,
|
|
6714
|
+
const [wasConnected, setWasConnected] = (0, import_react4.useState)(connected);
|
|
6715
|
+
const [lost, setLost] = (0, import_react4.useState)(false);
|
|
6716
|
+
(0, import_react4.useEffect)(() => {
|
|
6390
6717
|
if (connected) {
|
|
6391
6718
|
setWasConnected(true);
|
|
6392
6719
|
setLost(false);
|
|
@@ -6400,31 +6727,24 @@ function useConnectionLost(connected) {
|
|
|
6400
6727
|
}
|
|
6401
6728
|
|
|
6402
6729
|
// src/hooks/use-keyboard-overlap.ts
|
|
6403
|
-
var
|
|
6404
|
-
var
|
|
6730
|
+
var import_react5 = require("react");
|
|
6731
|
+
var import_react_native5 = require("react-native");
|
|
6405
6732
|
function useKeyboardOverlap(ref) {
|
|
6406
|
-
const [overlap, setOverlap] = (0,
|
|
6407
|
-
(0,
|
|
6408
|
-
if (
|
|
6409
|
-
const
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
setOverlap(
|
|
6413
|
-
});
|
|
6414
|
-
const hide2 = import_react_native4.Keyboard.addListener("keyboardWillHide", (event) => {
|
|
6415
|
-
animate(event.duration);
|
|
6416
|
-
setOverlap(0);
|
|
6733
|
+
const [overlap, setOverlap] = (0, import_react5.useState)(0);
|
|
6734
|
+
(0, import_react5.useEffect)(() => {
|
|
6735
|
+
if (import_react_native5.Platform.OS === "ios") {
|
|
6736
|
+
const frame = import_react_native5.Keyboard.addListener("keyboardWillChangeFrame", (event) => {
|
|
6737
|
+
const next = Math.max(0, Math.round(import_react_native5.Dimensions.get("screen").height - event.endCoordinates.screenY));
|
|
6738
|
+
if (event.duration > 0) import_react_native5.LayoutAnimation.configureNext(import_react_native5.LayoutAnimation.create(event.duration, "keyboard"));
|
|
6739
|
+
setOverlap(next);
|
|
6417
6740
|
});
|
|
6418
|
-
return () =>
|
|
6419
|
-
show2.remove();
|
|
6420
|
-
hide2.remove();
|
|
6421
|
-
};
|
|
6741
|
+
return () => frame.remove();
|
|
6422
6742
|
}
|
|
6423
|
-
const show =
|
|
6743
|
+
const show = import_react_native5.Keyboard.addListener("keyboardDidShow", (event) => {
|
|
6424
6744
|
const keyboardTop = event.endCoordinates.screenY;
|
|
6425
6745
|
ref.current?.measureInWindow((_x, y, _width, height) => setOverlap(Math.max(0, Math.round(y + height - keyboardTop))));
|
|
6426
6746
|
});
|
|
6427
|
-
const hide =
|
|
6747
|
+
const hide = import_react_native5.Keyboard.addListener("keyboardDidHide", () => setOverlap(0));
|
|
6428
6748
|
return () => {
|
|
6429
6749
|
show.remove();
|
|
6430
6750
|
hide.remove();
|
|
@@ -6437,74 +6757,72 @@ function useKeyboardOverlap(ref) {
|
|
|
6437
6757
|
var import_react_native7 = require("react-native");
|
|
6438
6758
|
|
|
6439
6759
|
// src/components/AppMark.tsx
|
|
6440
|
-
var
|
|
6441
|
-
var
|
|
6760
|
+
var import_react_native6 = require("react-native");
|
|
6761
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6442
6762
|
function AppMark({ app }) {
|
|
6443
6763
|
const { colors } = useChatContext();
|
|
6444
|
-
if (app.logoUrl)
|
|
6445
|
-
|
|
6764
|
+
if (app.logoUrl) {
|
|
6765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6766
|
+
import_react_native6.Image,
|
|
6767
|
+
{
|
|
6768
|
+
source: { uri: app.logoUrl },
|
|
6769
|
+
style: [styles2.mark, styles2.logo, { borderColor: colors.border }],
|
|
6770
|
+
accessibilityIgnoresInvertColors: true
|
|
6771
|
+
}
|
|
6772
|
+
);
|
|
6773
|
+
}
|
|
6774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.mark, styles2.bubble], children: [0, 1, 2].map((dot) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.dot, { backgroundColor: colors.primary }] }, dot)) });
|
|
6446
6775
|
}
|
|
6447
|
-
var styles2 =
|
|
6448
|
-
mark: { width:
|
|
6449
|
-
|
|
6450
|
-
|
|
6776
|
+
var styles2 = import_react_native6.StyleSheet.create({
|
|
6777
|
+
mark: { width: 40, height: 40, borderRadius: 12, borderWidth: 1, borderColor: "transparent", backgroundColor: "#ffffff" },
|
|
6778
|
+
logo: { borderRadius: 20 },
|
|
6779
|
+
bubble: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, borderBottomLeftRadius: 4 },
|
|
6780
|
+
dot: { width: 5, height: 5, borderRadius: 2.5 }
|
|
6451
6781
|
});
|
|
6452
6782
|
|
|
6453
|
-
// src/components/Icon.tsx
|
|
6454
|
-
var import_react_native6 = require("react-native");
|
|
6455
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6456
|
-
function Icon({ name, color, size = 20 }) {
|
|
6457
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6458
|
-
import_react_native6.Image,
|
|
6459
|
-
{
|
|
6460
|
-
source: { uri: ICONS[name] },
|
|
6461
|
-
style: { width: size, height: size, tintColor: color },
|
|
6462
|
-
accessibilityElementsHidden: true,
|
|
6463
|
-
importantForAccessibility: "no"
|
|
6464
|
-
}
|
|
6465
|
-
);
|
|
6466
|
-
}
|
|
6467
|
-
|
|
6468
6783
|
// src/components/ChatHeader.tsx
|
|
6469
6784
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
6470
|
-
function ChatHeader({ app, online,
|
|
6785
|
+
function ChatHeader({ app, online, topInset, onClose }) {
|
|
6471
6786
|
const { t, colors } = useChatContext();
|
|
6472
6787
|
const onPrimary = { color: colors.primaryForeground };
|
|
6473
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.
|
|
6474
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, {
|
|
6475
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
6476
|
-
|
|
6477
|
-
online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
|
|
6478
|
-
] }),
|
|
6479
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
|
|
6480
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
|
|
6481
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], children: online ? t.online : t.away })
|
|
6482
|
-
] }),
|
|
6483
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6484
|
-
import_react_native7.Pressable,
|
|
6485
|
-
{
|
|
6486
|
-
onPress: onClose,
|
|
6487
|
-
accessibilityRole: "button",
|
|
6488
|
-
accessibilityLabel: t.close_chat,
|
|
6489
|
-
hitSlop: 8,
|
|
6490
|
-
style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
|
|
6491
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground })
|
|
6492
|
-
}
|
|
6493
|
-
)
|
|
6788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.header, { backgroundColor: colors.primary, paddingTop: topInset + 16 }], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.row, children: [
|
|
6789
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { children: [
|
|
6790
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AppMark, { app }),
|
|
6791
|
+
online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
|
|
6494
6792
|
] }),
|
|
6495
|
-
|
|
6496
|
-
|
|
6793
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
|
|
6794
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
|
|
6795
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], numberOfLines: 1, children: online ? t.online : t.away })
|
|
6796
|
+
] }),
|
|
6797
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6798
|
+
import_react_native7.Pressable,
|
|
6799
|
+
{
|
|
6800
|
+
onPress: onClose,
|
|
6801
|
+
accessibilityRole: "button",
|
|
6802
|
+
accessibilityLabel: t.close_chat,
|
|
6803
|
+
hitSlop: 8,
|
|
6804
|
+
style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
|
|
6805
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground, size: 18 })
|
|
6806
|
+
}
|
|
6807
|
+
)
|
|
6808
|
+
] }) });
|
|
6497
6809
|
}
|
|
6498
6810
|
var styles3 = import_react_native7.StyleSheet.create({
|
|
6499
|
-
header: {
|
|
6500
|
-
row: { flexDirection: "row", alignItems: "center", gap:
|
|
6501
|
-
online: { position: "absolute", right: -
|
|
6502
|
-
titles: { flex: 1, minWidth: 0 },
|
|
6503
|
-
name: { fontSize:
|
|
6504
|
-
status: { fontSize:
|
|
6505
|
-
close: {
|
|
6506
|
-
|
|
6507
|
-
|
|
6811
|
+
header: { paddingHorizontal: 16, paddingBottom: 20 },
|
|
6812
|
+
row: { flexDirection: "row", alignItems: "center", gap: 12 },
|
|
6813
|
+
online: { position: "absolute", right: -3, bottom: -3, width: 14, height: 14, borderRadius: 7, borderWidth: 2 },
|
|
6814
|
+
titles: { flex: 1, minWidth: 0, gap: 1 },
|
|
6815
|
+
name: { fontSize: 18, fontWeight: "700", letterSpacing: -0.3 },
|
|
6816
|
+
status: { fontSize: 14, fontWeight: "500", opacity: 0.85 },
|
|
6817
|
+
close: {
|
|
6818
|
+
width: 34,
|
|
6819
|
+
height: 34,
|
|
6820
|
+
alignItems: "center",
|
|
6821
|
+
justifyContent: "center",
|
|
6822
|
+
borderRadius: 17,
|
|
6823
|
+
backgroundColor: "rgba(255,255,255,0.18)"
|
|
6824
|
+
},
|
|
6825
|
+
pressed: { opacity: 0.6 }
|
|
6508
6826
|
});
|
|
6509
6827
|
|
|
6510
6828
|
// src/components/ChatNotice.tsx
|
|
@@ -6515,11 +6833,21 @@ function ChatNotice({ children }) {
|
|
|
6515
6833
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native8.Text, { accessibilityLiveRegion: "polite", style: [styles4.notice, { backgroundColor: colors.surface, color: colors.muted }], children });
|
|
6516
6834
|
}
|
|
6517
6835
|
var styles4 = import_react_native8.StyleSheet.create({
|
|
6518
|
-
notice: {
|
|
6836
|
+
notice: {
|
|
6837
|
+
alignSelf: "center",
|
|
6838
|
+
maxWidth: 640,
|
|
6839
|
+
borderRadius: 20,
|
|
6840
|
+
paddingHorizontal: 16,
|
|
6841
|
+
paddingVertical: 12,
|
|
6842
|
+
textAlign: "center",
|
|
6843
|
+
fontSize: 14,
|
|
6844
|
+
lineHeight: 20,
|
|
6845
|
+
overflow: "hidden"
|
|
6846
|
+
}
|
|
6519
6847
|
});
|
|
6520
6848
|
|
|
6521
6849
|
// src/components/ContactCodeCard.tsx
|
|
6522
|
-
var
|
|
6850
|
+
var import_react6 = require("react");
|
|
6523
6851
|
var import_react_native9 = require("react-native");
|
|
6524
6852
|
|
|
6525
6853
|
// ../shared/src/constants/auth.ts
|
|
@@ -6530,9 +6858,9 @@ var CODE_MAX_AGE_SECONDS = 15 * 60;
|
|
|
6530
6858
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
6531
6859
|
function ContactCodeCard({ code: code2, onDismiss }) {
|
|
6532
6860
|
const { chat: chat2, t, colors } = useChatContext();
|
|
6533
|
-
const [value, setValue] = (0,
|
|
6534
|
-
const [error, setError] = (0,
|
|
6535
|
-
const [busy, setBusy] = (0,
|
|
6861
|
+
const [value, setValue] = (0, import_react6.useState)("");
|
|
6862
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6863
|
+
const [busy, setBusy] = (0, import_react6.useState)(false);
|
|
6536
6864
|
const errorOf = (reason) => reason === "contact_code_invalid" ? t.code_invalid : reason === "contact_code_expired" ? t.code_expired : reason === "rate_limited" ? t.code_rate_limited : t.error;
|
|
6537
6865
|
const handleSend = async () => {
|
|
6538
6866
|
setBusy(true);
|
|
@@ -6555,7 +6883,7 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6555
6883
|
if (!result.ok) setError(errorOf(result.code));
|
|
6556
6884
|
};
|
|
6557
6885
|
const label = format(code2.sent ? t.code_label : t.code_prompt, { email: code2.email });
|
|
6558
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, {
|
|
6886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, { backgroundColor: colors.surface }], children: [
|
|
6559
6887
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.prompt, { color: colors.text }], children: label }),
|
|
6560
6888
|
code2.sent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.row, children: [
|
|
6561
6889
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -6572,7 +6900,10 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6572
6900
|
autoComplete: "one-time-code",
|
|
6573
6901
|
textContentType: "oneTimeCode",
|
|
6574
6902
|
returnKeyType: "done",
|
|
6575
|
-
style: [
|
|
6903
|
+
style: [
|
|
6904
|
+
styles5.input,
|
|
6905
|
+
{ backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
|
|
6906
|
+
]
|
|
6576
6907
|
}
|
|
6577
6908
|
),
|
|
6578
6909
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -6581,8 +6912,8 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6581
6912
|
onPress: () => void handleSubmit(),
|
|
6582
6913
|
disabled: busy,
|
|
6583
6914
|
accessibilityRole: "button",
|
|
6584
|
-
style: [styles5.
|
|
6585
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.
|
|
6915
|
+
style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
|
|
6916
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_submit })
|
|
6586
6917
|
}
|
|
6587
6918
|
)
|
|
6588
6919
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.actions, children: [
|
|
@@ -6592,52 +6923,44 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6592
6923
|
onPress: () => void handleSend(),
|
|
6593
6924
|
disabled: busy,
|
|
6594
6925
|
accessibilityRole: "button",
|
|
6595
|
-
style: [styles5.
|
|
6596
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.
|
|
6926
|
+
style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
|
|
6927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_send })
|
|
6597
6928
|
}
|
|
6598
6929
|
),
|
|
6599
6930
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: onDismiss, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }], children: t.code_dismiss }) })
|
|
6600
6931
|
] }),
|
|
6601
6932
|
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { accessibilityLiveRegion: "polite", style: [styles5.error, { color: colors.danger }], children: error }),
|
|
6602
|
-
code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.
|
|
6933
|
+
code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.primaryText }, busy && styles5.dim], children: t.code_resend }) })
|
|
6603
6934
|
] });
|
|
6604
6935
|
}
|
|
6605
6936
|
var styles5 = import_react_native9.StyleSheet.create({
|
|
6606
|
-
card: { gap:
|
|
6607
|
-
prompt: { fontSize:
|
|
6937
|
+
card: { gap: 10, padding: 16, borderRadius: RADII.group },
|
|
6938
|
+
prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
|
|
6608
6939
|
row: { flexDirection: "row", gap: 8 },
|
|
6609
|
-
actions: { flexDirection: "row", alignItems: "center", gap:
|
|
6940
|
+
actions: { flexDirection: "row", alignItems: "center", gap: 16 },
|
|
6610
6941
|
input: {
|
|
6611
6942
|
flex: 1,
|
|
6612
6943
|
minWidth: 0,
|
|
6944
|
+
height: 44,
|
|
6613
6945
|
borderWidth: 1,
|
|
6614
|
-
borderRadius:
|
|
6615
|
-
paddingHorizontal:
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
letterSpacing: 4
|
|
6946
|
+
borderRadius: RADII.pill,
|
|
6947
|
+
paddingHorizontal: 14,
|
|
6948
|
+
fontSize: 18,
|
|
6949
|
+
letterSpacing: 6
|
|
6619
6950
|
},
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
error: { fontSize: 12 }
|
|
6951
|
+
button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
|
|
6952
|
+
buttonText: { fontSize: 15, fontWeight: "600" },
|
|
6953
|
+
dim: { opacity: 0.6 },
|
|
6954
|
+
link: { fontSize: 13, fontWeight: "600" },
|
|
6955
|
+
error: { fontSize: 13 }
|
|
6626
6956
|
});
|
|
6627
6957
|
|
|
6628
6958
|
// src/components/Composer.tsx
|
|
6629
|
-
var
|
|
6630
|
-
var
|
|
6631
|
-
|
|
6632
|
-
// ../shared/src/constants/uploads.ts
|
|
6633
|
-
var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
6634
|
-
var MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
6635
|
-
var MAX_ATTACHMENTS = 6;
|
|
6636
|
-
var MAX_IMAGE_SIDE = 1600;
|
|
6637
|
-
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
6959
|
+
var import_react8 = require("react");
|
|
6960
|
+
var import_react_native11 = require("react-native");
|
|
6638
6961
|
|
|
6639
6962
|
// src/hooks/use-pending-photos.ts
|
|
6640
|
-
var
|
|
6963
|
+
var import_react7 = require("react");
|
|
6641
6964
|
|
|
6642
6965
|
// ../shared/src/utils/files.ts
|
|
6643
6966
|
function isImage(type) {
|
|
@@ -6647,37 +6970,43 @@ function isImage(type) {
|
|
|
6647
6970
|
// src/hooks/use-pending-photos.ts
|
|
6648
6971
|
var lastId = 0;
|
|
6649
6972
|
function usePendingPhotos() {
|
|
6650
|
-
const { chat: chat2, t } = useChatContext();
|
|
6651
|
-
const [photos, setPhotos] = (0,
|
|
6652
|
-
const [problem, setProblem] = (0,
|
|
6973
|
+
const { chat: chat2, t, maxPhotos } = useChatContext();
|
|
6974
|
+
const [photos, setPhotos] = (0, import_react7.useState)([]);
|
|
6975
|
+
const [problem, setProblem] = (0, import_react7.useState)(null);
|
|
6976
|
+
const [sending, setSending] = (0, import_react7.useState)(false);
|
|
6977
|
+
const tooMany = maxPhotos === 1 ? t.too_many_one : format(t.too_many, { count: maxPhotos });
|
|
6653
6978
|
const update = (id, patch) => setPhotos((current) => current.map((photo) => photo.id === id ? { ...photo, ...patch } : photo));
|
|
6654
|
-
const upload = async (
|
|
6979
|
+
const upload = async (photo) => {
|
|
6980
|
+
update(photo.id, { status: "uploading" });
|
|
6655
6981
|
try {
|
|
6656
6982
|
const file = await (await fetch(photo.uri)).blob();
|
|
6657
6983
|
if (file.size > MAX_FILE_BYTES) {
|
|
6658
6984
|
setProblem(format(t.photo_size, { name: photo.name }));
|
|
6659
|
-
update(id, { status: "failed" });
|
|
6660
|
-
return;
|
|
6985
|
+
update(photo.id, { status: "failed" });
|
|
6986
|
+
return null;
|
|
6661
6987
|
}
|
|
6662
|
-
const { key, url } = await chat2.uploadLink(type, file.size);
|
|
6663
|
-
const response = await fetch(url, { method: "PUT", headers: { "Content-Type": type }, body: file });
|
|
6988
|
+
const { key, url } = await chat2.uploadLink(photo.type, file.size);
|
|
6989
|
+
const response = await fetch(url, { method: "PUT", headers: { "Content-Type": photo.type }, body: file });
|
|
6664
6990
|
if (!response.ok) throw new Error(`Upload failed: ${response.status}`);
|
|
6665
6991
|
const attachment = {
|
|
6666
6992
|
key,
|
|
6667
6993
|
name: photo.name,
|
|
6668
|
-
type,
|
|
6994
|
+
type: photo.type,
|
|
6669
6995
|
size: file.size,
|
|
6670
6996
|
...photo.width && photo.height ? { width: photo.width, height: photo.height } : {}
|
|
6671
6997
|
};
|
|
6672
|
-
update(id, { status: "ready", attachment });
|
|
6998
|
+
update(photo.id, { status: "ready", attachment });
|
|
6999
|
+
return attachment;
|
|
6673
7000
|
} catch {
|
|
6674
|
-
update(id, { status: "failed" });
|
|
7001
|
+
update(photo.id, { status: "failed" });
|
|
7002
|
+
return null;
|
|
6675
7003
|
}
|
|
6676
7004
|
};
|
|
6677
7005
|
const add = (picked) => {
|
|
6678
7006
|
setProblem(null);
|
|
6679
|
-
const room =
|
|
6680
|
-
if (picked.length > room) setProblem(
|
|
7007
|
+
const room = maxPhotos - photos.length;
|
|
7008
|
+
if (picked.length > room) setProblem(tooMany);
|
|
7009
|
+
const added = [];
|
|
6681
7010
|
for (const photo of picked.slice(0, Math.max(0, room))) {
|
|
6682
7011
|
if (!photo.type || !isImage(photo.type)) {
|
|
6683
7012
|
setProblem(t.photo_type);
|
|
@@ -6688,29 +7017,33 @@ function usePendingPhotos() {
|
|
|
6688
7017
|
continue;
|
|
6689
7018
|
}
|
|
6690
7019
|
lastId += 1;
|
|
6691
|
-
const
|
|
6692
|
-
|
|
6693
|
-
void upload(id, photo, photo.type);
|
|
7020
|
+
const { uri, name, type, width, height } = photo;
|
|
7021
|
+
added.push({ id: `photo_${lastId}`, uri, name, type, width, height, status: "picked", attachment: null });
|
|
6694
7022
|
}
|
|
7023
|
+
setPhotos((current) => [...current, ...added]);
|
|
6695
7024
|
};
|
|
6696
7025
|
const remove = (id) => setPhotos((current) => current.filter((photo) => photo.id !== id));
|
|
6697
|
-
const
|
|
6698
|
-
const ready = photos.flatMap((photo) => photo.status === "ready" && photo.attachment ? [photo.attachment] : []);
|
|
6699
|
-
setPhotos([]);
|
|
7026
|
+
const send = async () => {
|
|
6700
7027
|
setProblem(null);
|
|
6701
|
-
|
|
7028
|
+
setSending(true);
|
|
7029
|
+
const attachments = await Promise.all(photos.map((photo) => photo.attachment ?? upload(photo)));
|
|
7030
|
+
setSending(false);
|
|
7031
|
+
if (attachments.includes(null)) return null;
|
|
7032
|
+
setPhotos([]);
|
|
7033
|
+
return attachments;
|
|
6702
7034
|
};
|
|
6703
7035
|
return {
|
|
6704
7036
|
photos,
|
|
6705
7037
|
problem,
|
|
6706
7038
|
/** Photos that still fit in the message. */
|
|
6707
|
-
room:
|
|
7039
|
+
room: maxPhotos - photos.length,
|
|
7040
|
+
/** Why no more photos fit. */
|
|
7041
|
+
tooMany,
|
|
6708
7042
|
add,
|
|
6709
7043
|
remove,
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
ready: photos.some((photo) => photo.status === "ready")
|
|
7044
|
+
send,
|
|
7045
|
+
sending,
|
|
7046
|
+
showProblem: setProblem
|
|
6714
7047
|
};
|
|
6715
7048
|
}
|
|
6716
7049
|
|
|
@@ -6775,7 +7108,7 @@ function imagePicker(module2) {
|
|
|
6775
7108
|
}
|
|
6776
7109
|
function photoOf({ uri, fileName, type, width, height, fileSize }) {
|
|
6777
7110
|
const name = fileName || uri.split("/").pop() || "photo.jpg";
|
|
6778
|
-
const extension = name.split(".").pop()
|
|
7111
|
+
const extension = name.split(".").pop().toLowerCase();
|
|
6779
7112
|
return {
|
|
6780
7113
|
uri,
|
|
6781
7114
|
name,
|
|
@@ -6785,24 +7118,81 @@ function photoOf({ uri, fileName, type, width, height, fileSize }) {
|
|
|
6785
7118
|
};
|
|
6786
7119
|
}
|
|
6787
7120
|
|
|
6788
|
-
// src/components/
|
|
7121
|
+
// src/components/PendingPhotos.tsx
|
|
7122
|
+
var import_react_native10 = require("react-native");
|
|
6789
7123
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
7124
|
+
function PendingPhotos({ photos, locked, onRemove }) {
|
|
7125
|
+
const { t, colors } = useChatContext();
|
|
7126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles6.photos, children: photos.map((photo) => {
|
|
7127
|
+
const failed = photo.status === "failed";
|
|
7128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
7129
|
+
import_react_native10.View,
|
|
7130
|
+
{
|
|
7131
|
+
accessible: true,
|
|
7132
|
+
accessibilityLabel: `${photo.name}, ${photo.status === "uploading" ? t.uploading : failed ? t.not_sent : t.ready}`,
|
|
7133
|
+
style: [styles6.photo, { borderColor: failed ? colors.danger : colors.border }],
|
|
7134
|
+
children: [
|
|
7135
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Image, { source: { uri: photo.uri }, style: styles6.preview }),
|
|
7136
|
+
photo.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ActivityIndicator, { color: "#ffffff" }) }),
|
|
7137
|
+
failed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: styles6.failed, children: "!" }) }),
|
|
7138
|
+
!locked && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
7139
|
+
import_react_native10.Pressable,
|
|
7140
|
+
{
|
|
7141
|
+
onPress: () => onRemove(photo.id),
|
|
7142
|
+
accessibilityRole: "button",
|
|
7143
|
+
accessibilityLabel: format(t.remove_photo, { name: photo.name }),
|
|
7144
|
+
hitSlop: 8,
|
|
7145
|
+
style: styles6.remove,
|
|
7146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: "#ffffff", size: 12 })
|
|
7147
|
+
}
|
|
7148
|
+
)
|
|
7149
|
+
]
|
|
7150
|
+
},
|
|
7151
|
+
photo.id
|
|
7152
|
+
);
|
|
7153
|
+
}) });
|
|
7154
|
+
}
|
|
7155
|
+
var styles6 = import_react_native10.StyleSheet.create({
|
|
7156
|
+
photos: { gap: 8, paddingTop: 6, paddingRight: 6 },
|
|
7157
|
+
photo: { width: 64, height: 64, borderRadius: 14, borderWidth: 1, overflow: "hidden" },
|
|
7158
|
+
preview: { width: "100%", height: "100%" },
|
|
7159
|
+
cover: { ...import_react_native10.StyleSheet.absoluteFill, alignItems: "center", justifyContent: "center", backgroundColor: "rgba(0,0,0,0.35)" },
|
|
7160
|
+
failed: { color: "#ffffff", fontSize: 20, fontWeight: "700" },
|
|
7161
|
+
remove: {
|
|
7162
|
+
position: "absolute",
|
|
7163
|
+
top: 4,
|
|
7164
|
+
right: 4,
|
|
7165
|
+
width: 20,
|
|
7166
|
+
height: 20,
|
|
7167
|
+
borderRadius: 10,
|
|
7168
|
+
alignItems: "center",
|
|
7169
|
+
justifyContent: "center",
|
|
7170
|
+
backgroundColor: "rgba(0,0,0,0.6)"
|
|
7171
|
+
}
|
|
7172
|
+
});
|
|
7173
|
+
|
|
7174
|
+
// src/components/Composer.tsx
|
|
7175
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
6790
7176
|
function Composer() {
|
|
6791
7177
|
const { chat: chat2, t, colors } = useChatContext();
|
|
6792
|
-
const [text, setText] = (0,
|
|
6793
|
-
const
|
|
7178
|
+
const [text, setText] = (0, import_react8.useState)("");
|
|
7179
|
+
const typed = (0, import_react8.useRef)("");
|
|
6794
7180
|
const pending = usePendingPhotos();
|
|
6795
7181
|
const picker = photoPicker();
|
|
6796
|
-
const canSend = !pending.
|
|
6797
|
-
const
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
7182
|
+
const canSend = !pending.sending && (text.trim().length > 0 || pending.photos.length > 0);
|
|
7183
|
+
const changeText = (value) => {
|
|
7184
|
+
typed.current = value;
|
|
7185
|
+
setText(value);
|
|
7186
|
+
};
|
|
7187
|
+
const handleSend = async () => {
|
|
7188
|
+
const attachments = pending.photos.length > 0 ? await pending.send() : [];
|
|
7189
|
+
if (!attachments) return;
|
|
7190
|
+
chat2.send(typed.current.trim(), attachments);
|
|
7191
|
+
changeText("");
|
|
6801
7192
|
};
|
|
6802
7193
|
const handlePick = async () => {
|
|
6803
|
-
if (!picker) return;
|
|
6804
7194
|
if (pending.room <= 0) {
|
|
6805
|
-
pending.showProblem(
|
|
7195
|
+
pending.showProblem(pending.tooMany);
|
|
6806
7196
|
return;
|
|
6807
7197
|
}
|
|
6808
7198
|
try {
|
|
@@ -6812,119 +7202,166 @@ function Composer() {
|
|
|
6812
7202
|
pending.showProblem(t.error);
|
|
6813
7203
|
}
|
|
6814
7204
|
};
|
|
6815
|
-
return /* @__PURE__ */ (0,
|
|
6816
|
-
pending.photos.length > 0 && /* @__PURE__ */ (0,
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
style: styles6.remove,
|
|
6834
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: colors.muted, size: 14 })
|
|
6835
|
-
}
|
|
6836
|
-
)
|
|
6837
|
-
]
|
|
6838
|
-
},
|
|
6839
|
-
photo.id
|
|
6840
|
-
)) }),
|
|
6841
|
-
pending.problem && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { accessibilityLiveRegion: "polite", style: [styles6.problem, { color: colors.danger }], children: pending.problem }),
|
|
6842
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: [styles6.field, { backgroundColor: colors.background, borderColor: focused ? colors.primary : colors.border }], children: [
|
|
6843
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
6844
|
-
import_react_native10.TextInput,
|
|
7205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: styles7.composer, children: [
|
|
7206
|
+
pending.photos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PendingPhotos, { photos: pending.photos, locked: pending.sending, onRemove: pending.remove }),
|
|
7207
|
+
pending.problem && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { accessibilityLiveRegion: "polite", style: [styles7.problem, { color: colors.danger }], children: pending.problem }),
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: [styles7.pill, { backgroundColor: colors.surface }], children: [
|
|
7209
|
+
picker && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7210
|
+
import_react_native11.Pressable,
|
|
7211
|
+
{
|
|
7212
|
+
onPress: () => void handlePick(),
|
|
7213
|
+
disabled: pending.sending,
|
|
7214
|
+
accessibilityRole: "button",
|
|
7215
|
+
accessibilityLabel: t.attach,
|
|
7216
|
+
accessibilityState: { disabled: pending.sending },
|
|
7217
|
+
style: ({ pressed }) => [styles7.button, pressed && { backgroundColor: colors.background }],
|
|
7218
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "photo", color: colors.muted, size: 22 })
|
|
7219
|
+
}
|
|
7220
|
+
),
|
|
7221
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7222
|
+
import_react_native11.TextInput,
|
|
6845
7223
|
{
|
|
6846
7224
|
value: text,
|
|
6847
7225
|
onChangeText: (value) => {
|
|
6848
|
-
|
|
7226
|
+
changeText(value);
|
|
6849
7227
|
chat2.typing();
|
|
6850
7228
|
},
|
|
6851
|
-
onFocus: () => setFocused(true),
|
|
6852
|
-
onBlur: () => setFocused(false),
|
|
6853
7229
|
multiline: true,
|
|
6854
7230
|
maxLength: MAX_MESSAGE_LENGTH,
|
|
6855
7231
|
placeholder: t.placeholder,
|
|
6856
7232
|
placeholderTextColor: colors.muted,
|
|
6857
7233
|
accessibilityLabel: t.placeholder,
|
|
6858
|
-
style: [
|
|
7234
|
+
style: [styles7.input, { color: colors.text }, !picker && styles7.inputAlone]
|
|
6859
7235
|
}
|
|
6860
7236
|
),
|
|
6861
|
-
/* @__PURE__ */ (0,
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
disabled: !canSend,
|
|
6878
|
-
accessibilityRole: "button",
|
|
6879
|
-
accessibilityLabel: t.send,
|
|
6880
|
-
accessibilityState: { disabled: !canSend },
|
|
6881
|
-
hitSlop: 6,
|
|
6882
|
-
style: ({ pressed }) => [styles6.send, pressed && styles6.pressed],
|
|
6883
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "send", color: canSend ? colors.primary : colors.border, size: 22 })
|
|
6884
|
-
}
|
|
6885
|
-
)
|
|
6886
|
-
] })
|
|
7237
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7238
|
+
import_react_native11.Pressable,
|
|
7239
|
+
{
|
|
7240
|
+
onPress: () => void handleSend(),
|
|
7241
|
+
disabled: !canSend,
|
|
7242
|
+
accessibilityRole: "button",
|
|
7243
|
+
accessibilityLabel: t.send,
|
|
7244
|
+
accessibilityState: { disabled: !canSend },
|
|
7245
|
+
style: ({ pressed }) => [
|
|
7246
|
+
styles7.button,
|
|
7247
|
+
{ backgroundColor: canSend ? colors.primary : colors.skeleton },
|
|
7248
|
+
pressed && styles7.pressed
|
|
7249
|
+
],
|
|
7250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "send", color: canSend ? colors.primaryForeground : colors.muted, size: 20 })
|
|
7251
|
+
}
|
|
7252
|
+
)
|
|
6887
7253
|
] })
|
|
6888
7254
|
] });
|
|
6889
7255
|
}
|
|
6890
|
-
var
|
|
7256
|
+
var styles7 = import_react_native11.StyleSheet.create({
|
|
6891
7257
|
composer: { gap: 8 },
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
7258
|
+
problem: { fontSize: 12, paddingHorizontal: 8 },
|
|
7259
|
+
pill: { flexDirection: "row", alignItems: "flex-end", gap: 4, padding: 4, borderRadius: RADII.composer },
|
|
7260
|
+
button: {
|
|
7261
|
+
width: COMPOSER_BUTTON,
|
|
7262
|
+
height: COMPOSER_BUTTON,
|
|
7263
|
+
borderRadius: COMPOSER_BUTTON / 2,
|
|
6895
7264
|
alignItems: "center",
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
7265
|
+
justifyContent: "center"
|
|
7266
|
+
},
|
|
7267
|
+
// Five lines of 22 points, and the room around them.
|
|
7268
|
+
input: {
|
|
7269
|
+
flex: 1,
|
|
7270
|
+
minHeight: COMPOSER_BUTTON,
|
|
7271
|
+
maxHeight: 5 * 22 + 18,
|
|
7272
|
+
paddingHorizontal: 4,
|
|
7273
|
+
paddingTop: 9,
|
|
7274
|
+
paddingBottom: 9,
|
|
7275
|
+
fontSize: 16,
|
|
7276
|
+
lineHeight: 22
|
|
6902
7277
|
},
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
remove: { position: "absolute", top: 4, right: 4, width: 20, height: 20, alignItems: "center", justifyContent: "center" },
|
|
6906
|
-
problem: { fontSize: 12 },
|
|
6907
|
-
field: { gap: 4, paddingHorizontal: 8, paddingTop: 8, paddingBottom: 6, borderRadius: 12, borderWidth: 1 },
|
|
6908
|
-
input: { maxHeight: 128, minHeight: 28, paddingHorizontal: 6, paddingVertical: 2, fontSize: 16, lineHeight: 22 },
|
|
6909
|
-
tools: { flexDirection: "row", alignItems: "center" },
|
|
6910
|
-
tool: { width: 28, height: 28, alignItems: "center", justifyContent: "center", borderRadius: 8 },
|
|
6911
|
-
send: { marginLeft: "auto", width: 32, height: 32, alignItems: "center", justifyContent: "center", borderRadius: 8 },
|
|
6912
|
-
pressed: { transform: [{ scale: 0.9 }] }
|
|
7278
|
+
inputAlone: { paddingLeft: 12 },
|
|
7279
|
+
pressed: { transform: [{ scale: 0.92 }] }
|
|
6913
7280
|
});
|
|
6914
7281
|
|
|
6915
7282
|
// src/components/MessageList.tsx
|
|
6916
|
-
var
|
|
6917
|
-
var
|
|
7283
|
+
var import_react14 = require("react");
|
|
7284
|
+
var import_react_native20 = require("react-native");
|
|
7285
|
+
|
|
7286
|
+
// src/models/conversation.utils.ts
|
|
7287
|
+
function authorOf(message) {
|
|
7288
|
+
if (message.from === "contact") return "contact";
|
|
7289
|
+
return `team:${message.sender?.name ?? ""}:${message.sender?.image ?? ""}`;
|
|
7290
|
+
}
|
|
7291
|
+
function startOfDay(timestamp) {
|
|
7292
|
+
const day = new Date(timestamp);
|
|
7293
|
+
day.setHours(0, 0, 0, 0);
|
|
7294
|
+
return day.getTime();
|
|
7295
|
+
}
|
|
7296
|
+
function sameDay(left, right) {
|
|
7297
|
+
return startOfDay(left) === startOfDay(right);
|
|
7298
|
+
}
|
|
7299
|
+
function joins(older, newer) {
|
|
7300
|
+
return older.status !== "failed" && authorOf(older) === authorOf(newer) && newer.createdAt - older.createdAt < RUN_GAP_MS && sameDay(older.createdAt, newer.createdAt);
|
|
7301
|
+
}
|
|
7302
|
+
function conversationRows(messages, seen, welcome) {
|
|
7303
|
+
const all = welcome ? [welcome, ...messages] : [...messages];
|
|
7304
|
+
const lastReply = all.findLastIndex((message) => message.from === "team" && message.sender !== null);
|
|
7305
|
+
return all.map((message, index) => {
|
|
7306
|
+
const older = all[index - 1];
|
|
7307
|
+
const newer = all[index + 1];
|
|
7308
|
+
const isWelcome = message === welcome;
|
|
7309
|
+
return {
|
|
7310
|
+
message,
|
|
7311
|
+
startsRun: !older || !joins(older, message),
|
|
7312
|
+
endsRun: !newer || !joins(message, newer),
|
|
7313
|
+
// Alone, the welcome has no day: there is nothing to date.
|
|
7314
|
+
startsDay: isWelcome ? messages.length > 0 : !older || !sameDay(older.createdAt, message.createdAt),
|
|
7315
|
+
receipt: receiptOf(message, seen || index < lastReply),
|
|
7316
|
+
welcome: isWelcome
|
|
7317
|
+
};
|
|
7318
|
+
});
|
|
7319
|
+
}
|
|
7320
|
+
function receiptOf(message, seen) {
|
|
7321
|
+
if (message.from === "team" || message.status === "failed") return null;
|
|
7322
|
+
if (message.status === "sending") return "sending";
|
|
7323
|
+
return seen ? "seen" : "sent";
|
|
7324
|
+
}
|
|
7325
|
+
var DATE_STYLES = {
|
|
7326
|
+
time: { hour: "2-digit", minute: "2-digit" },
|
|
7327
|
+
weekday: { weekday: "long" },
|
|
7328
|
+
day: { day: "numeric", month: "short" },
|
|
7329
|
+
dayYear: { day: "numeric", month: "short", year: "numeric" }
|
|
7330
|
+
};
|
|
7331
|
+
var formats = /* @__PURE__ */ new Map();
|
|
7332
|
+
function formatDate(timestamp, locale, style) {
|
|
7333
|
+
const key = `${locale}:${style}`;
|
|
7334
|
+
let format2 = formats.get(key);
|
|
7335
|
+
if (!format2) {
|
|
7336
|
+
format2 = new Intl.DateTimeFormat(locale, DATE_STYLES[style]);
|
|
7337
|
+
formats.set(key, format2);
|
|
7338
|
+
}
|
|
7339
|
+
return format2.format(timestamp);
|
|
7340
|
+
}
|
|
7341
|
+
function messageTime(timestamp, locale) {
|
|
7342
|
+
return formatDate(timestamp, locale, "time");
|
|
7343
|
+
}
|
|
7344
|
+
function dayLabel(timestamp, now, locale, t) {
|
|
7345
|
+
const today = startOfDay(now);
|
|
7346
|
+
const day = startOfDay(timestamp);
|
|
7347
|
+
if (day === today) return t.today;
|
|
7348
|
+
if (day === startOfDay(today - 1)) return t.yesterday;
|
|
7349
|
+
const weekAgo = new Date(today);
|
|
7350
|
+
weekAgo.setDate(weekAgo.getDate() - 6);
|
|
7351
|
+
if (day >= weekAgo.getTime()) return formatDate(timestamp, locale, "weekday");
|
|
7352
|
+
const sameYear = new Date(timestamp).getFullYear() === new Date(now).getFullYear();
|
|
7353
|
+
return formatDate(timestamp, locale, sameYear ? "day" : "dayYear");
|
|
7354
|
+
}
|
|
6918
7355
|
|
|
6919
7356
|
// src/components/EmailForm.tsx
|
|
6920
|
-
var
|
|
6921
|
-
var
|
|
6922
|
-
var
|
|
7357
|
+
var import_react9 = require("react");
|
|
7358
|
+
var import_react_native12 = require("react-native");
|
|
7359
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6923
7360
|
function EmailForm({ onSubmit }) {
|
|
6924
7361
|
const { t, colors } = useChatContext();
|
|
6925
|
-
const [email, setEmail] = (0,
|
|
6926
|
-
const [error, setError] = (0,
|
|
6927
|
-
const [busy, setBusy] = (0,
|
|
7362
|
+
const [email, setEmail] = (0, import_react9.useState)("");
|
|
7363
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
7364
|
+
const [busy, setBusy] = (0, import_react9.useState)(false);
|
|
6928
7365
|
const handleSubmit = async () => {
|
|
6929
7366
|
const address = normaliseEmail(email);
|
|
6930
7367
|
if (!isEmail(address)) {
|
|
@@ -6937,11 +7374,11 @@ function EmailForm({ onSubmit }) {
|
|
|
6937
7374
|
setBusy(false);
|
|
6938
7375
|
if (!result.ok) setError(result.code === "invalid_email" ? t.email_invalid : t.error);
|
|
6939
7376
|
};
|
|
6940
|
-
return /* @__PURE__ */ (0,
|
|
6941
|
-
/* @__PURE__ */ (0,
|
|
6942
|
-
/* @__PURE__ */ (0,
|
|
6943
|
-
/* @__PURE__ */ (0,
|
|
6944
|
-
|
|
7377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: [styles8.card, { backgroundColor: colors.surface }], children: [
|
|
7378
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.prompt, { color: colors.text }], children: t.email_prompt }),
|
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: styles8.row, children: [
|
|
7380
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7381
|
+
import_react_native12.TextInput,
|
|
6945
7382
|
{
|
|
6946
7383
|
value: email,
|
|
6947
7384
|
onChangeText: setEmail,
|
|
@@ -6955,39 +7392,54 @@ function EmailForm({ onSubmit }) {
|
|
|
6955
7392
|
autoComplete: "email",
|
|
6956
7393
|
textContentType: "emailAddress",
|
|
6957
7394
|
returnKeyType: "send",
|
|
6958
|
-
style: [
|
|
7395
|
+
style: [
|
|
7396
|
+
styles8.input,
|
|
7397
|
+
{ backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
|
|
7398
|
+
]
|
|
6959
7399
|
}
|
|
6960
7400
|
),
|
|
6961
|
-
/* @__PURE__ */ (0,
|
|
6962
|
-
|
|
7401
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7402
|
+
import_react_native12.Pressable,
|
|
6963
7403
|
{
|
|
6964
7404
|
onPress: () => void handleSubmit(),
|
|
6965
7405
|
disabled: busy,
|
|
6966
7406
|
accessibilityRole: "button",
|
|
6967
|
-
style: [
|
|
6968
|
-
children: /* @__PURE__ */ (0,
|
|
7407
|
+
style: ({ pressed }) => [styles8.button, { backgroundColor: colors.primary }, (busy || pressed) && styles8.dim],
|
|
7408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.buttonText, { color: colors.primaryForeground }], children: t.email_submit })
|
|
6969
7409
|
}
|
|
6970
7410
|
)
|
|
6971
7411
|
] }),
|
|
6972
|
-
error && /* @__PURE__ */ (0,
|
|
7412
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { accessibilityLiveRegion: "polite", style: [styles8.error, { color: colors.danger }], children: error })
|
|
6973
7413
|
] });
|
|
6974
7414
|
}
|
|
6975
|
-
var
|
|
6976
|
-
|
|
6977
|
-
prompt: { fontSize:
|
|
7415
|
+
var styles8 = import_react_native12.StyleSheet.create({
|
|
7416
|
+
card: { gap: 10, marginHorizontal: 12, marginTop: 14, padding: 16, borderRadius: RADII.group },
|
|
7417
|
+
prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
|
|
6978
7418
|
row: { flexDirection: "row", gap: 8 },
|
|
6979
|
-
input: { flex: 1, minWidth: 0, borderWidth: 1, borderRadius:
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
error: { fontSize:
|
|
7419
|
+
input: { flex: 1, minWidth: 0, height: 44, borderWidth: 1, borderRadius: RADII.pill, paddingHorizontal: 14, fontSize: 16 },
|
|
7420
|
+
button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
|
|
7421
|
+
buttonText: { fontSize: 15, fontWeight: "600" },
|
|
7422
|
+
dim: { opacity: 0.6 },
|
|
7423
|
+
error: { fontSize: 13 }
|
|
6984
7424
|
});
|
|
6985
7425
|
|
|
6986
7426
|
// src/components/MessageBubble.tsx
|
|
6987
|
-
var
|
|
7427
|
+
var import_react_native18 = require("react-native");
|
|
7428
|
+
|
|
7429
|
+
// src/hooks/use-rise-in.ts
|
|
7430
|
+
var import_react10 = require("react");
|
|
7431
|
+
var import_react_native13 = require("react-native");
|
|
7432
|
+
function useRiseIn(fresh) {
|
|
7433
|
+
const progress = (0, import_react10.useRef)(new import_react_native13.Animated.Value(fresh ? 0 : 1)).current;
|
|
7434
|
+
(0, import_react10.useEffect)(() => {
|
|
7435
|
+
if (!fresh) return;
|
|
7436
|
+
import_react_native13.Animated.timing(progress, { toValue: 1, duration: ENTER_MS, useNativeDriver: true }).start();
|
|
7437
|
+
}, [fresh, progress]);
|
|
7438
|
+
return { opacity: progress, transform: [{ translateY: progress.interpolate({ inputRange: [0, 1], outputRange: [8, 0] }) }] };
|
|
7439
|
+
}
|
|
6988
7440
|
|
|
6989
7441
|
// src/components/MessageFiles.tsx
|
|
6990
|
-
var
|
|
7442
|
+
var import_react_native15 = require("react-native");
|
|
6991
7443
|
|
|
6992
7444
|
// ../shared/src/utils/file-links.ts
|
|
6993
7445
|
var encoder = new TextEncoder();
|
|
@@ -7000,13 +7452,13 @@ function withFileName(url, name) {
|
|
|
7000
7452
|
}
|
|
7001
7453
|
|
|
7002
7454
|
// src/hooks/use-attachment-links.ts
|
|
7003
|
-
var
|
|
7455
|
+
var import_react11 = require("react");
|
|
7004
7456
|
var signed = /* @__PURE__ */ new Map();
|
|
7005
7457
|
function useAttachmentLinks(chat2, keys, stored) {
|
|
7006
|
-
const [links, setLinks] = (0,
|
|
7007
|
-
const [attempt, setAttempt] = (0,
|
|
7458
|
+
const [links, setLinks] = (0, import_react11.useState)(() => cachedLinks(keys));
|
|
7459
|
+
const [attempt, setAttempt] = (0, import_react11.useState)(0);
|
|
7008
7460
|
const wanted = keys.join("|");
|
|
7009
|
-
(0,
|
|
7461
|
+
(0, import_react11.useEffect)(() => {
|
|
7010
7462
|
if (!stored) return;
|
|
7011
7463
|
const list = wanted ? wanted.split("|") : [];
|
|
7012
7464
|
const missing = list.filter((key) => (signed.get(key)?.until ?? 0) < Date.now());
|
|
@@ -7035,51 +7487,79 @@ function cachedLinks(keys) {
|
|
|
7035
7487
|
return new Map(keys.flatMap((key) => signed.has(key) ? [[key, signed.get(key).url]] : []));
|
|
7036
7488
|
}
|
|
7037
7489
|
|
|
7490
|
+
// src/components/Skeleton.tsx
|
|
7491
|
+
var import_react12 = require("react");
|
|
7492
|
+
var import_react_native14 = require("react-native");
|
|
7493
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
7494
|
+
function Skeleton({ style }) {
|
|
7495
|
+
const { colors } = useChatContext();
|
|
7496
|
+
const opacity = (0, import_react12.useRef)(new import_react_native14.Animated.Value(1)).current;
|
|
7497
|
+
(0, import_react12.useEffect)(() => {
|
|
7498
|
+
const breathe = import_react_native14.Animated.loop(
|
|
7499
|
+
import_react_native14.Animated.sequence([
|
|
7500
|
+
import_react_native14.Animated.timing(opacity, { toValue: 0.5, duration: 700, useNativeDriver: true }),
|
|
7501
|
+
import_react_native14.Animated.timing(opacity, { toValue: 1, duration: 700, useNativeDriver: true })
|
|
7502
|
+
])
|
|
7503
|
+
);
|
|
7504
|
+
breathe.start();
|
|
7505
|
+
return () => breathe.stop();
|
|
7506
|
+
}, [opacity]);
|
|
7507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7508
|
+
import_react_native14.Animated.View,
|
|
7509
|
+
{
|
|
7510
|
+
style: [{ backgroundColor: colors.skeleton, opacity }, style],
|
|
7511
|
+
accessibilityElementsHidden: true,
|
|
7512
|
+
importantForAccessibility: "no-hide-descendants"
|
|
7513
|
+
}
|
|
7514
|
+
);
|
|
7515
|
+
}
|
|
7516
|
+
|
|
7038
7517
|
// src/components/MessageFiles.tsx
|
|
7039
|
-
var
|
|
7040
|
-
var IMAGE_SIDE = 224;
|
|
7518
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
7041
7519
|
function MessageFiles({ attachments, own, stored }) {
|
|
7042
|
-
const { chat: chat2, t, colors,
|
|
7520
|
+
const { chat: chat2, t, colors, openImages } = useChatContext();
|
|
7043
7521
|
const links = useAttachmentLinks(
|
|
7044
7522
|
chat2,
|
|
7045
7523
|
attachments.map((attachment) => attachment.key),
|
|
7046
7524
|
stored
|
|
7047
7525
|
);
|
|
7048
7526
|
if (attachments.length === 0) return null;
|
|
7049
|
-
|
|
7527
|
+
const gallery = attachments.flatMap((attachment) => {
|
|
7528
|
+
const url = links.get(attachment.key);
|
|
7529
|
+
return url && isImage(attachment.type) ? [{ url, name: attachment.name }] : [];
|
|
7530
|
+
});
|
|
7531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.files, { alignItems: own ? "flex-end" : "flex-start" }], children: attachments.map((attachment) => {
|
|
7050
7532
|
const url = links.get(attachment.key);
|
|
7051
7533
|
if (isImage(attachment.type)) {
|
|
7052
7534
|
const size = imageSize(attachment);
|
|
7053
|
-
return url ? /* @__PURE__ */ (0,
|
|
7054
|
-
|
|
7535
|
+
return url ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7536
|
+
import_react_native15.Pressable,
|
|
7055
7537
|
{
|
|
7056
|
-
onPress: () =>
|
|
7538
|
+
onPress: () => openImages({ images: gallery, index: gallery.findIndex((image) => image.url === url) }),
|
|
7057
7539
|
accessibilityRole: "imagebutton",
|
|
7058
7540
|
accessibilityLabel: t.open_image,
|
|
7059
|
-
style: [
|
|
7060
|
-
children: /* @__PURE__ */ (0,
|
|
7061
|
-
},
|
|
7062
|
-
attachment.key
|
|
7063
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7064
|
-
import_react_native12.View,
|
|
7065
|
-
{
|
|
7066
|
-
style: [styles8.image, size, { backgroundColor: colors.surface, borderColor: colors.border }]
|
|
7541
|
+
style: ({ pressed }) => [styles9.image, { borderColor: colors.border }, pressed && styles9.pressed],
|
|
7542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Image, { source: { uri: url }, style: size, resizeMode: "cover", accessibilityLabel: attachment.name })
|
|
7067
7543
|
},
|
|
7068
7544
|
attachment.key
|
|
7069
|
-
);
|
|
7545
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Skeleton, { style: [styles9.image, size, { borderColor: colors.border }] }, attachment.key);
|
|
7070
7546
|
}
|
|
7071
|
-
return /* @__PURE__ */ (0,
|
|
7072
|
-
|
|
7547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
7548
|
+
import_react_native15.Pressable,
|
|
7073
7549
|
{
|
|
7074
7550
|
disabled: !url,
|
|
7075
|
-
onPress: () =>
|
|
7551
|
+
onPress: () => void import_react_native15.Linking.openURL(withFileName(url, attachment.name)),
|
|
7076
7552
|
accessibilityRole: "link",
|
|
7077
7553
|
accessibilityLabel: format(t.open_file, { name: attachment.name }),
|
|
7078
|
-
style:
|
|
7554
|
+
style: ({ pressed }) => [
|
|
7555
|
+
styles9.file,
|
|
7556
|
+
{ borderColor: colors.border, backgroundColor: colors.surface },
|
|
7557
|
+
pressed && styles9.pressed
|
|
7558
|
+
],
|
|
7079
7559
|
children: [
|
|
7080
|
-
/* @__PURE__ */ (0,
|
|
7081
|
-
/* @__PURE__ */ (0,
|
|
7082
|
-
/* @__PURE__ */ (0,
|
|
7560
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.fileIcon, { backgroundColor: colors.primaryTint }], children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "file", color: colors.primaryText, size: 16 }) }),
|
|
7561
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Text, { style: [styles9.fileName, { color: colors.text }], numberOfLines: 1, children: attachment.name }),
|
|
7562
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "download", color: colors.muted, size: 16 })
|
|
7083
7563
|
]
|
|
7084
7564
|
},
|
|
7085
7565
|
attachment.key
|
|
@@ -7087,318 +7567,456 @@ function MessageFiles({ attachments, own, stored }) {
|
|
|
7087
7567
|
}) });
|
|
7088
7568
|
}
|
|
7089
7569
|
function imageSize({ width, height }) {
|
|
7090
|
-
if (!width || !height) return { width:
|
|
7570
|
+
if (!width || !height) return { width: 180, height: 180 };
|
|
7091
7571
|
const scale = IMAGE_SIDE / Math.max(width, height);
|
|
7092
|
-
return { width: Math.max(
|
|
7572
|
+
return { width: Math.max(96, Math.round(width * scale)), height: Math.max(96, Math.round(height * scale)) };
|
|
7093
7573
|
}
|
|
7094
|
-
var
|
|
7095
|
-
files: { gap:
|
|
7096
|
-
image: { overflow: "hidden", borderRadius:
|
|
7574
|
+
var styles9 = import_react_native15.StyleSheet.create({
|
|
7575
|
+
files: { gap: 4 },
|
|
7576
|
+
image: { overflow: "hidden", borderRadius: RADII.group, borderWidth: 1 },
|
|
7577
|
+
pressed: { opacity: 0.8 },
|
|
7097
7578
|
file: {
|
|
7098
7579
|
flexDirection: "row",
|
|
7099
7580
|
alignItems: "center",
|
|
7100
7581
|
gap: 10,
|
|
7101
|
-
width:
|
|
7102
|
-
padding:
|
|
7103
|
-
borderRadius:
|
|
7104
|
-
borderWidth:
|
|
7582
|
+
width: 232,
|
|
7583
|
+
padding: 10,
|
|
7584
|
+
borderRadius: RADII.group,
|
|
7585
|
+
borderWidth: 1
|
|
7105
7586
|
},
|
|
7106
|
-
|
|
7587
|
+
fileIcon: { width: 32, height: 32, borderRadius: 16, alignItems: "center", justifyContent: "center" },
|
|
7588
|
+
fileName: { flex: 1, fontSize: 14, fontWeight: "500" }
|
|
7589
|
+
});
|
|
7590
|
+
|
|
7591
|
+
// src/components/MessageMeta.tsx
|
|
7592
|
+
var import_react_native16 = require("react-native");
|
|
7593
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
7594
|
+
function MessageMeta({ row, onRetry }) {
|
|
7595
|
+
const { t, locale, colors } = useChatContext();
|
|
7596
|
+
const { message, receipt } = row;
|
|
7597
|
+
if (message.status === "failed") {
|
|
7598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native16.View, { style: [styles10.meta, styles10.own], accessibilityLiveRegion: "polite", children: [
|
|
7599
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.danger }], children: message.error === "rate_limited" ? t.rate_limited : t.not_sent }),
|
|
7600
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Pressable, { onPress: onRetry, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, styles10.retry, { color: colors.danger }], children: t.retry }) })
|
|
7601
|
+
] });
|
|
7602
|
+
}
|
|
7603
|
+
if (receipt === "sending") {
|
|
7604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.View, { style: [styles10.meta, styles10.own], children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: t.sending }) });
|
|
7605
|
+
}
|
|
7606
|
+
const time = messageTime(message.createdAt, locale);
|
|
7607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
7608
|
+
import_react_native16.View,
|
|
7609
|
+
{
|
|
7610
|
+
style: [styles10.meta, receipt ? styles10.own : styles10.team],
|
|
7611
|
+
accessible: true,
|
|
7612
|
+
accessibilityLabel: receipt ? `${time}, ${receipt === "seen" ? t.seen : t.sent}` : time,
|
|
7613
|
+
children: [
|
|
7614
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: time }),
|
|
7615
|
+
receipt && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
7616
|
+
Icon,
|
|
7617
|
+
{
|
|
7618
|
+
name: receipt === "seen" ? "seen" : "check",
|
|
7619
|
+
color: receipt === "seen" ? colors.primaryText : colors.muted,
|
|
7620
|
+
size: 14
|
|
7621
|
+
}
|
|
7622
|
+
)
|
|
7623
|
+
]
|
|
7624
|
+
}
|
|
7625
|
+
);
|
|
7626
|
+
}
|
|
7627
|
+
var styles10 = import_react_native16.StyleSheet.create({
|
|
7628
|
+
meta: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 4, marginTop: 4, paddingHorizontal: 4 },
|
|
7629
|
+
own: { alignSelf: "flex-end", justifyContent: "flex-end" },
|
|
7630
|
+
team: { alignSelf: "flex-start" },
|
|
7631
|
+
text: { fontSize: 12 },
|
|
7632
|
+
retry: { fontWeight: "600", textDecorationLine: "underline" }
|
|
7107
7633
|
});
|
|
7108
7634
|
|
|
7109
7635
|
// src/components/TeamAvatar.tsx
|
|
7110
|
-
var
|
|
7111
|
-
var
|
|
7636
|
+
var import_react_native17 = require("react-native");
|
|
7637
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
7112
7638
|
function TeamAvatar({ app, sender }) {
|
|
7113
7639
|
const { colors } = useChatContext();
|
|
7114
7640
|
const image = sender ? sender.image : app.logoUrl;
|
|
7115
|
-
if (image)
|
|
7116
|
-
|
|
7117
|
-
|
|
7641
|
+
if (image) {
|
|
7642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Image, { source: { uri: image }, style: [styles11.avatar, { borderColor: colors.border }], accessibilityIgnoresInvertColors: true });
|
|
7643
|
+
}
|
|
7644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
7645
|
+
import_react_native17.View,
|
|
7118
7646
|
{
|
|
7119
|
-
style: [
|
|
7647
|
+
style: [styles11.avatar, { backgroundColor: sender ? colors.primaryTint : colors.primary }],
|
|
7120
7648
|
accessibilityElementsHidden: true,
|
|
7121
7649
|
importantForAccessibility: "no-hide-descendants",
|
|
7122
|
-
children: /* @__PURE__ */ (0,
|
|
7650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Text, { style: [styles11.initials, { color: sender ? colors.primaryText : colors.primaryForeground }], children: initialsOf(sender?.name ?? app.name) })
|
|
7123
7651
|
}
|
|
7124
7652
|
);
|
|
7125
7653
|
}
|
|
7126
|
-
var
|
|
7127
|
-
avatar: {
|
|
7128
|
-
|
|
7654
|
+
var styles11 = import_react_native17.StyleSheet.create({
|
|
7655
|
+
avatar: {
|
|
7656
|
+
width: 28,
|
|
7657
|
+
height: 28,
|
|
7658
|
+
borderRadius: 14,
|
|
7659
|
+
borderWidth: 1,
|
|
7660
|
+
borderColor: "transparent",
|
|
7661
|
+
alignItems: "center",
|
|
7662
|
+
justifyContent: "center",
|
|
7663
|
+
overflow: "hidden"
|
|
7664
|
+
},
|
|
7665
|
+
initials: { fontSize: 11, fontWeight: "700" }
|
|
7129
7666
|
});
|
|
7130
7667
|
|
|
7131
7668
|
// src/components/MessageBubble.tsx
|
|
7132
|
-
var
|
|
7133
|
-
function MessageBubble({
|
|
7134
|
-
const { t, colors } = useChatContext();
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7669
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
7670
|
+
function MessageBubble({ row, app, onRetry }) {
|
|
7671
|
+
const { t, locale, colors, openedAt } = useChatContext();
|
|
7672
|
+
const { message, startsRun, endsRun, startsDay } = row;
|
|
7673
|
+
const own = message.from === "contact";
|
|
7674
|
+
const rise = useRiseIn(message.createdAt > openedAt && (!own || message.status === "sending"));
|
|
7675
|
+
const corner = startsRun ? RADII.group : RADII.inner;
|
|
7676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.Animated.View, { style: [styles12.row, { paddingTop: startsRun ? 14 : 3 }, rise], children: [
|
|
7677
|
+
startsDay && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.day, { backgroundColor: colors.surface, color: colors.muted }], accessibilityRole: "header", children: dayLabel(message.createdAt, openedAt, locale, t) }),
|
|
7678
|
+
own ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.own, children: [
|
|
7679
|
+
message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7680
|
+
import_react_native18.Text,
|
|
7139
7681
|
{
|
|
7140
7682
|
selectable: true,
|
|
7141
7683
|
style: [
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
{ backgroundColor: colors.primary, color: colors.primaryForeground }
|
|
7145
|
-
message.status === "sending" && styles10.sending
|
|
7684
|
+
styles12.bubble,
|
|
7685
|
+
{ borderTopRightRadius: corner, borderBottomRightRadius: RADII.inner },
|
|
7686
|
+
{ backgroundColor: colors.primary, color: colors.primaryForeground }
|
|
7146
7687
|
],
|
|
7147
7688
|
children: message.body
|
|
7148
7689
|
}
|
|
7149
7690
|
),
|
|
7150
|
-
/* @__PURE__ */ (0,
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7691
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: true, stored: message.status === "sent" }),
|
|
7692
|
+
endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry })
|
|
7693
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.team, children: [
|
|
7694
|
+
startsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.name, { color: colors.muted }], numberOfLines: 1, children: message.sender?.name ?? app.name }),
|
|
7695
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamRow, children: [
|
|
7696
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.avatar, children: endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TeamAvatar, { app, sender: message.sender }) }),
|
|
7697
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamColumn, children: [
|
|
7698
|
+
message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7699
|
+
import_react_native18.Text,
|
|
7700
|
+
{
|
|
7701
|
+
selectable: true,
|
|
7702
|
+
style: [
|
|
7703
|
+
styles12.bubble,
|
|
7704
|
+
{ borderTopLeftRadius: corner, borderBottomLeftRadius: RADII.inner },
|
|
7705
|
+
{ backgroundColor: colors.surface, color: colors.text }
|
|
7706
|
+
],
|
|
7707
|
+
children: message.body
|
|
7708
|
+
}
|
|
7709
|
+
),
|
|
7710
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: false, stored: true })
|
|
7711
|
+
] })
|
|
7712
|
+
] }),
|
|
7713
|
+
endsRun && !row.welcome && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.teamMeta, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry }) })
|
|
7163
7714
|
] })
|
|
7164
7715
|
] });
|
|
7165
7716
|
}
|
|
7166
|
-
var
|
|
7717
|
+
var AVATAR = 28;
|
|
7718
|
+
var styles12 = import_react_native18.StyleSheet.create({
|
|
7719
|
+
row: { paddingHorizontal: 12 },
|
|
7720
|
+
day: {
|
|
7721
|
+
alignSelf: "center",
|
|
7722
|
+
marginBottom: 14,
|
|
7723
|
+
paddingHorizontal: 12,
|
|
7724
|
+
paddingVertical: 4,
|
|
7725
|
+
borderRadius: RADII.pill,
|
|
7726
|
+
overflow: "hidden",
|
|
7727
|
+
fontSize: 12,
|
|
7728
|
+
fontWeight: "700",
|
|
7729
|
+
letterSpacing: 1,
|
|
7730
|
+
textTransform: "uppercase"
|
|
7731
|
+
},
|
|
7167
7732
|
own: { alignSelf: "flex-end", alignItems: "flex-end", maxWidth: "80%", gap: 4 },
|
|
7168
|
-
team: {
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7733
|
+
team: { alignSelf: "flex-start", maxWidth: "85%" },
|
|
7734
|
+
name: { marginBottom: 4, marginLeft: AVATAR + 12, fontSize: 12, fontWeight: "600" },
|
|
7735
|
+
teamRow: { flexDirection: "row", alignItems: "flex-end", gap: 8 },
|
|
7736
|
+
avatar: { width: AVATAR },
|
|
7737
|
+
teamColumn: { flexShrink: 1, alignItems: "flex-start", gap: 4 },
|
|
7738
|
+
teamMeta: { marginLeft: AVATAR + 8 },
|
|
7739
|
+
bubble: {
|
|
7740
|
+
borderRadius: RADII.group,
|
|
7741
|
+
paddingHorizontal: 14,
|
|
7742
|
+
paddingVertical: 10,
|
|
7743
|
+
fontSize: 16,
|
|
7744
|
+
lineHeight: 22,
|
|
7745
|
+
overflow: "hidden"
|
|
7746
|
+
}
|
|
7178
7747
|
});
|
|
7179
7748
|
|
|
7180
7749
|
// src/components/TypingBubble.tsx
|
|
7181
|
-
var
|
|
7182
|
-
var
|
|
7183
|
-
var
|
|
7750
|
+
var import_react13 = require("react");
|
|
7751
|
+
var import_react_native19 = require("react-native");
|
|
7752
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
7184
7753
|
function TypingBubble({ app, sender }) {
|
|
7185
7754
|
const { t, colors } = useChatContext();
|
|
7186
|
-
const
|
|
7187
|
-
(0,
|
|
7188
|
-
|
|
7189
|
-
|
|
7755
|
+
const rise = useRiseIn(true);
|
|
7756
|
+
const dots = (0, import_react13.useRef)([0, 1, 2].map(() => new import_react_native19.Animated.Value(0))).current;
|
|
7757
|
+
(0, import_react13.useEffect)(() => {
|
|
7758
|
+
const bounce = import_react_native19.Animated.loop(
|
|
7759
|
+
import_react_native19.Animated.stagger(
|
|
7190
7760
|
150,
|
|
7191
7761
|
dots.map(
|
|
7192
|
-
(dot) =>
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7762
|
+
(dot) => import_react_native19.Animated.sequence([
|
|
7763
|
+
import_react_native19.Animated.timing(dot, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
7764
|
+
import_react_native19.Animated.timing(dot, { toValue: 0, duration: 300, useNativeDriver: true }),
|
|
7765
|
+
import_react_native19.Animated.delay(300)
|
|
7196
7766
|
])
|
|
7197
7767
|
)
|
|
7198
7768
|
)
|
|
7199
7769
|
);
|
|
7200
|
-
|
|
7201
|
-
return () =>
|
|
7770
|
+
bounce.start();
|
|
7771
|
+
return () => bounce.stop();
|
|
7202
7772
|
}, [dots]);
|
|
7203
|
-
return /* @__PURE__ */ (0,
|
|
7204
|
-
/* @__PURE__ */ (0,
|
|
7205
|
-
/* @__PURE__ */ (0,
|
|
7773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native19.Animated.View, { style: [styles13.row, rise], accessible: true, accessibilityLabel: format(t.typing, { name: sender?.name ?? t.team }), children: [
|
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TeamAvatar, { app, sender }),
|
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native19.View, { style: [styles13.bubble, { backgroundColor: colors.surface }], children: dots.map((dot, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
7776
|
+
import_react_native19.Animated.View,
|
|
7777
|
+
{
|
|
7778
|
+
style: [
|
|
7779
|
+
styles13.dot,
|
|
7780
|
+
{
|
|
7781
|
+
backgroundColor: colors.muted,
|
|
7782
|
+
opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
|
|
7783
|
+
transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -3] }) }]
|
|
7784
|
+
}
|
|
7785
|
+
]
|
|
7786
|
+
},
|
|
7787
|
+
index
|
|
7788
|
+
)) })
|
|
7206
7789
|
] });
|
|
7207
7790
|
}
|
|
7208
|
-
var
|
|
7209
|
-
row: { flexDirection: "row", alignItems: "
|
|
7791
|
+
var styles13 = import_react_native19.StyleSheet.create({
|
|
7792
|
+
row: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 14 },
|
|
7210
7793
|
bubble: {
|
|
7211
7794
|
flexDirection: "row",
|
|
7212
7795
|
alignItems: "center",
|
|
7213
|
-
gap:
|
|
7214
|
-
height:
|
|
7215
|
-
paddingHorizontal:
|
|
7216
|
-
borderRadius:
|
|
7217
|
-
|
|
7796
|
+
gap: 5,
|
|
7797
|
+
height: 42,
|
|
7798
|
+
paddingHorizontal: 16,
|
|
7799
|
+
borderRadius: RADII.group,
|
|
7800
|
+
borderBottomLeftRadius: RADII.inner
|
|
7218
7801
|
},
|
|
7219
|
-
dot: { width:
|
|
7802
|
+
dot: { width: 7, height: 7, borderRadius: 3.5 }
|
|
7220
7803
|
});
|
|
7221
7804
|
|
|
7222
7805
|
// src/components/MessageList.tsx
|
|
7223
|
-
var
|
|
7806
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
7224
7807
|
function MessageList({ state }) {
|
|
7225
|
-
const { chat: chat2, t, colors } = useChatContext();
|
|
7808
|
+
const { chat: chat2, t, colors, openedAt } = useChatContext();
|
|
7809
|
+
const listRef = (0, import_react14.useRef)(null);
|
|
7810
|
+
const [scrolledUp, setScrolledUp] = (0, import_react14.useState)(false);
|
|
7226
7811
|
const app = state.app;
|
|
7227
|
-
const { messages } = state;
|
|
7228
|
-
const
|
|
7229
|
-
const
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
{
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
}
|
|
7261
|
-
)
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.below, children: [
|
|
7265
|
-
state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
|
|
7266
|
-
askEmail && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
|
|
7267
|
-
state.email && !state.online && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native16.Text, { style: [styles12.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
|
|
7268
|
-
] }),
|
|
7269
|
-
ListFooterComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.above, children: [
|
|
7270
|
-
state.hasOlder && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
7271
|
-
import_react_native16.Pressable,
|
|
7812
|
+
const { messages, seen, atStart } = state;
|
|
7813
|
+
const welcomeText = state.texts.welcome;
|
|
7814
|
+
const rows = (0, import_react14.useMemo)(() => {
|
|
7815
|
+
const welcome = atStart ? {
|
|
7816
|
+
id: "welcome",
|
|
7817
|
+
from: "team",
|
|
7818
|
+
sender: null,
|
|
7819
|
+
body: welcomeText,
|
|
7820
|
+
attachments: [],
|
|
7821
|
+
createdAt: messages[0]?.createdAt ?? openedAt,
|
|
7822
|
+
status: "sent",
|
|
7823
|
+
error: null
|
|
7824
|
+
} : null;
|
|
7825
|
+
return conversationRows(messages, seen, welcome).reverse();
|
|
7826
|
+
}, [messages, seen, atStart, welcomeText, openedAt]);
|
|
7827
|
+
const newest = rows.at(0)?.message;
|
|
7828
|
+
const sending = newest?.from === "contact" && newest.status === "sending" ? newest.id : null;
|
|
7829
|
+
(0, import_react14.useEffect)(() => {
|
|
7830
|
+
if (sending) listRef.current?.scrollToOffset({ offset: 0, animated: true });
|
|
7831
|
+
}, [sending]);
|
|
7832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.list, children: [
|
|
7833
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7834
|
+
import_react_native20.FlatList,
|
|
7835
|
+
{
|
|
7836
|
+
ref: listRef,
|
|
7837
|
+
testID: "zean-conversation",
|
|
7838
|
+
inverted: true,
|
|
7839
|
+
data: rows,
|
|
7840
|
+
keyExtractor: (row) => row.message.id,
|
|
7841
|
+
renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MessageBubble, { row: item, app, onRetry: () => chat2.retry(item.message.id) }),
|
|
7842
|
+
ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.below, children: [
|
|
7843
|
+
state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
|
|
7844
|
+
state.askEmail && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
|
|
7845
|
+
state.email && (!state.online || state.emailGiven) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
|
|
7846
|
+
] }),
|
|
7847
|
+
ListFooterComponent: state.hasOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.View, { style: styles14.above, children: state.loadingOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Skeleton, { style: [styles14.bone, styles14.olderBone] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7848
|
+
import_react_native20.Pressable,
|
|
7272
7849
|
{
|
|
7273
7850
|
onPress: chat2.loadOlder,
|
|
7274
|
-
disabled: state.loadingOlder,
|
|
7275
7851
|
accessibilityRole: "button",
|
|
7276
|
-
style: [
|
|
7277
|
-
children: /* @__PURE__ */ (0,
|
|
7852
|
+
style: ({ pressed }) => [styles14.earlier, { backgroundColor: colors.surface }, pressed && styles14.pressed],
|
|
7853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.earlierText, { color: colors.muted }], children: t.earlier })
|
|
7278
7854
|
}
|
|
7279
|
-
),
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7855
|
+
) }) : void 0,
|
|
7856
|
+
onScroll: (event) => setScrolledUp(event.nativeEvent.contentOffset.y > NEWEST_BUTTON_OFFSET),
|
|
7857
|
+
scrollEventThrottle: 64,
|
|
7858
|
+
maintainVisibleContentPosition: scrolledUp ? { minIndexForVisible: 0 } : void 0,
|
|
7859
|
+
contentContainerStyle: styles14.content,
|
|
7860
|
+
keyboardShouldPersistTaps: "handled",
|
|
7861
|
+
keyboardDismissMode: "on-drag",
|
|
7862
|
+
style: styles14.list
|
|
7863
|
+
}
|
|
7864
|
+
),
|
|
7865
|
+
scrolledUp && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7866
|
+
import_react_native20.Pressable,
|
|
7867
|
+
{
|
|
7868
|
+
onPress: () => listRef.current?.scrollToOffset({ offset: 0, animated: true }),
|
|
7869
|
+
accessibilityRole: "button",
|
|
7870
|
+
accessibilityLabel: t.newest,
|
|
7871
|
+
style: ({ pressed }) => [
|
|
7872
|
+
styles14.newest,
|
|
7873
|
+
{ backgroundColor: colors.surface, borderColor: colors.border },
|
|
7874
|
+
pressed && styles14.pressed
|
|
7875
|
+
],
|
|
7876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "down", color: colors.text, size: 20 })
|
|
7877
|
+
}
|
|
7878
|
+
)
|
|
7879
|
+
] });
|
|
7292
7880
|
}
|
|
7293
|
-
var
|
|
7881
|
+
var styles14 = import_react_native20.StyleSheet.create({
|
|
7294
7882
|
list: { flex: 1 },
|
|
7295
7883
|
// Inverted, `flex-end` is the top: a short Conversation starts under the header, as in the web widget.
|
|
7296
|
-
content: { flexGrow: 1, justifyContent: "flex-end",
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7884
|
+
content: { flexGrow: 1, justifyContent: "flex-end", paddingBottom: 12, paddingTop: 4 },
|
|
7885
|
+
below: { gap: 10 },
|
|
7886
|
+
above: { alignItems: "center", paddingTop: 8 },
|
|
7887
|
+
saved: { paddingTop: 10, paddingHorizontal: 16, fontSize: 12, textAlign: "center" },
|
|
7888
|
+
earlier: { paddingHorizontal: 14, paddingVertical: 6, borderRadius: RADII.pill },
|
|
7889
|
+
earlierText: { fontSize: 12, fontWeight: "600" },
|
|
7890
|
+
pressed: { opacity: 0.6 },
|
|
7891
|
+
bone: { height: 44, borderRadius: RADII.group },
|
|
7892
|
+
olderBone: { width: "50%", alignSelf: "flex-start", marginHorizontal: 12 },
|
|
7893
|
+
newest: {
|
|
7894
|
+
position: "absolute",
|
|
7895
|
+
right: 16,
|
|
7896
|
+
bottom: 12,
|
|
7897
|
+
width: COMPOSER_BUTTON,
|
|
7898
|
+
height: COMPOSER_BUTTON,
|
|
7899
|
+
borderRadius: COMPOSER_BUTTON / 2,
|
|
7900
|
+
borderWidth: import_react_native20.StyleSheet.hairlineWidth,
|
|
7901
|
+
alignItems: "center",
|
|
7902
|
+
justifyContent: "center",
|
|
7903
|
+
shadowColor: "#000000",
|
|
7904
|
+
shadowOpacity: 0.12,
|
|
7905
|
+
shadowRadius: 8,
|
|
7906
|
+
shadowOffset: { width: 0, height: 2 },
|
|
7907
|
+
elevation: 3
|
|
7908
|
+
}
|
|
7304
7909
|
});
|
|
7305
7910
|
|
|
7306
7911
|
// src/components/PoweredBy.tsx
|
|
7307
|
-
var
|
|
7308
|
-
var
|
|
7912
|
+
var import_react_native21 = require("react-native");
|
|
7913
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
7309
7914
|
function PoweredBy() {
|
|
7310
7915
|
const { t, colors } = useChatContext();
|
|
7311
|
-
return /* @__PURE__ */ (0,
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
7917
|
+
import_react_native21.Pressable,
|
|
7918
|
+
{
|
|
7919
|
+
style: ({ pressed }) => [styles15.row, pressed && styles15.pressed],
|
|
7920
|
+
accessibilityRole: "link",
|
|
7921
|
+
accessibilityLabel: `${t.powered_by} ${APP_NAME}`,
|
|
7922
|
+
onPress: () => void import_react_native21.Linking.openURL(APP_URL),
|
|
7923
|
+
children: [
|
|
7924
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, { color: colors.muted }], children: t.powered_by }),
|
|
7925
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon, { name: "mark", color: ZEAN_ACCENT_HEX, size: 14 }),
|
|
7926
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, styles15.name, { color: colors.muted }], children: APP_NAME })
|
|
7927
|
+
]
|
|
7928
|
+
}
|
|
7929
|
+
);
|
|
7316
7930
|
}
|
|
7317
|
-
var
|
|
7318
|
-
row: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
7931
|
+
var styles15 = import_react_native21.StyleSheet.create({
|
|
7932
|
+
row: { flexDirection: "row", alignItems: "center", justifyContent: "center", alignSelf: "center", gap: 4 },
|
|
7933
|
+
pressed: { opacity: 0.6 },
|
|
7319
7934
|
text: { fontSize: 12 },
|
|
7320
7935
|
name: { fontWeight: "600" }
|
|
7321
7936
|
});
|
|
7322
7937
|
|
|
7323
7938
|
// src/components/ChatScreen.tsx
|
|
7324
|
-
var
|
|
7939
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
7325
7940
|
function ChatScreen({ state, insets, onClose }) {
|
|
7326
7941
|
const { t, colors } = useChatContext();
|
|
7327
|
-
const rootRef = (0,
|
|
7942
|
+
const rootRef = (0, import_react15.useRef)(null);
|
|
7328
7943
|
const keyboard = useKeyboardOverlap(rootRef);
|
|
7329
7944
|
const connectionLost = useConnectionLost(state.connected);
|
|
7330
|
-
const [codeDismissed, setCodeDismissed] = (0,
|
|
7945
|
+
const [codeDismissed, setCodeDismissed] = (0, import_react15.useState)(false);
|
|
7331
7946
|
const app = state.app;
|
|
7332
|
-
return /* @__PURE__ */ (0,
|
|
7333
|
-
/* @__PURE__ */ (0,
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
onClose
|
|
7341
|
-
}
|
|
7342
|
-
),
|
|
7343
|
-
connectionLost && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native18.View, { style: styles14.notice, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.reconnecting }) }),
|
|
7344
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MessageList, { state }),
|
|
7345
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native18.View, { style: [styles14.footer, { borderTopColor: colors.border, paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
|
|
7346
|
-
state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
|
|
7347
|
-
state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Composer, {}),
|
|
7348
|
-
app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PoweredBy, {})
|
|
7947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { ref: rootRef, style: [styles16.screen, { backgroundColor: colors.background, paddingBottom: keyboard }], children: [
|
|
7948
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatHeader, { app, online: state.online, topInset: insets.top, onClose }),
|
|
7949
|
+
connectionLost && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native22.View, { style: styles16.notice, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.reconnecting }) }),
|
|
7950
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessageList, { state }),
|
|
7951
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { style: [styles16.footer, { paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
|
|
7952
|
+
state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
|
|
7953
|
+
state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Composer, {}),
|
|
7954
|
+
app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PoweredBy, {})
|
|
7349
7955
|
] })
|
|
7350
7956
|
] });
|
|
7351
7957
|
}
|
|
7352
|
-
var
|
|
7958
|
+
var styles16 = import_react_native22.StyleSheet.create({
|
|
7353
7959
|
screen: { flex: 1 },
|
|
7354
|
-
notice: { paddingHorizontal:
|
|
7355
|
-
footer: { gap: 8, paddingHorizontal:
|
|
7960
|
+
notice: { paddingHorizontal: 12, paddingTop: 12 },
|
|
7961
|
+
footer: { gap: 8, paddingHorizontal: 10, paddingTop: 6 }
|
|
7356
7962
|
});
|
|
7357
7963
|
|
|
7358
7964
|
// src/components/ChatModal.tsx
|
|
7359
|
-
var
|
|
7965
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
7360
7966
|
var STRINGS = { fr, en };
|
|
7361
|
-
function ChatModal({ chat: chat2, colorScheme }) {
|
|
7362
|
-
const state = (0,
|
|
7363
|
-
const { open: open2 } = (0,
|
|
7364
|
-
const deviceScheme = (0,
|
|
7967
|
+
function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
|
|
7968
|
+
const state = (0, import_react16.useSyncExternalStore)(chat2.subscribe, chat2.getState);
|
|
7969
|
+
const { open: open2 } = (0, import_react16.useSyncExternalStore)(subscribeChatView, chatView);
|
|
7970
|
+
const deviceScheme = (0, import_react_native23.useColorScheme)();
|
|
7365
7971
|
const scheme = colorScheme ?? (deviceScheme === "dark" ? "dark" : "light");
|
|
7366
7972
|
const active = useAppActive();
|
|
7367
|
-
const dimensions = (0,
|
|
7368
|
-
const [
|
|
7973
|
+
const dimensions = (0, import_react_native23.useWindowDimensions)();
|
|
7974
|
+
const [gallery, setGallery] = (0, import_react16.useState)(null);
|
|
7975
|
+
const [openedAt, setOpenedAt] = (0, import_react16.useState)(Date.now);
|
|
7369
7976
|
const app = state.app;
|
|
7370
7977
|
const visible = open2 && app !== null && state.status !== "loading" && state.status !== "hidden";
|
|
7371
7978
|
const color = app?.color ?? ZEAN_ACCENT_HEX;
|
|
7372
|
-
const context = (0,
|
|
7373
|
-
() => ({
|
|
7374
|
-
|
|
7979
|
+
const context = (0, import_react16.useMemo)(
|
|
7980
|
+
() => ({
|
|
7981
|
+
chat: chat2,
|
|
7982
|
+
t: STRINGS[state.locale],
|
|
7983
|
+
locale: state.locale,
|
|
7984
|
+
colors: chatColors(color, scheme),
|
|
7985
|
+
openedAt,
|
|
7986
|
+
openImages: setGallery,
|
|
7987
|
+
maxPhotos: photoLimit(maxPhotos)
|
|
7988
|
+
}),
|
|
7989
|
+
[chat2, state.locale, color, scheme, openedAt, maxPhotos]
|
|
7375
7990
|
);
|
|
7376
|
-
const insets = (0,
|
|
7377
|
-
(0,
|
|
7991
|
+
const insets = (0, import_react16.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
|
|
7992
|
+
(0, import_react16.useEffect)(() => chat2.setOpen(open2 && active), [chat2, open2, active]);
|
|
7993
|
+
(0, import_react16.useEffect)(() => {
|
|
7378
7994
|
if (visible && active && state.unread > 0) chat2.markRead();
|
|
7379
7995
|
}, [chat2, visible, active, state.unread]);
|
|
7380
|
-
(0,
|
|
7381
|
-
if (
|
|
7996
|
+
(0, import_react16.useEffect)(() => {
|
|
7997
|
+
if (visible) setOpenedAt(Date.now());
|
|
7998
|
+
else setGallery(null);
|
|
7382
7999
|
}, [visible]);
|
|
7383
|
-
return /* @__PURE__ */ (0,
|
|
7384
|
-
|
|
8000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8001
|
+
import_react_native23.Modal,
|
|
7385
8002
|
{
|
|
8003
|
+
testID: "zean-chat",
|
|
7386
8004
|
visible,
|
|
7387
8005
|
animationType: "slide",
|
|
7388
|
-
presentationStyle:
|
|
8006
|
+
presentationStyle: import_react_native23.Platform.OS === "ios" && !import_react_native23.Platform.isPad ? "pageSheet" : "fullScreen",
|
|
7389
8007
|
statusBarTranslucent: true,
|
|
7390
8008
|
navigationBarTranslucent: true,
|
|
7391
|
-
onRequestClose: () =>
|
|
7392
|
-
children: app && /* @__PURE__ */ (0,
|
|
7393
|
-
/* @__PURE__ */ (0,
|
|
7394
|
-
|
|
8009
|
+
onRequestClose: () => import_react_native23.Platform.OS === "android" && gallery ? setGallery(null) : zean.close(),
|
|
8010
|
+
children: app && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ChatContext, { value: context, children: [
|
|
8011
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatScreen, { state, insets, onClose: zean.close }),
|
|
8012
|
+
gallery && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ImageViewer, { gallery, topInset: insets.top, onClose: () => setGallery(null) })
|
|
7395
8013
|
] })
|
|
7396
8014
|
}
|
|
7397
8015
|
);
|
|
7398
8016
|
}
|
|
7399
8017
|
|
|
7400
8018
|
// src/components/ZeanChat.tsx
|
|
7401
|
-
var
|
|
8019
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7402
8020
|
function ZeanChat({
|
|
7403
8021
|
appKey,
|
|
7404
8022
|
storage,
|
|
@@ -7406,14 +8024,15 @@ function ZeanChat({
|
|
|
7406
8024
|
attributes: attributes2,
|
|
7407
8025
|
locale,
|
|
7408
8026
|
colorScheme,
|
|
7409
|
-
|
|
8027
|
+
maxPhotos,
|
|
8028
|
+
backendUrl = backendUrlFor(appKey)
|
|
7410
8029
|
}) {
|
|
7411
|
-
const [chat2, setChat] = (0,
|
|
7412
|
-
const storageRef = (0,
|
|
8030
|
+
const [chat2, setChat] = (0, import_react17.useState)(null);
|
|
8031
|
+
const storageRef = (0, import_react17.useRef)(storage);
|
|
7413
8032
|
const userKey = user ? JSON.stringify(user) : null;
|
|
7414
|
-
const identified = (0,
|
|
8033
|
+
const identified = (0, import_react17.useRef)(false);
|
|
7415
8034
|
const attributesKey = attributes2 ? JSON.stringify(attributes2) : null;
|
|
7416
|
-
(0,
|
|
8035
|
+
(0, import_react17.useEffect)(() => {
|
|
7417
8036
|
const started = createChat({
|
|
7418
8037
|
appKey,
|
|
7419
8038
|
backendUrl,
|
|
@@ -7421,7 +8040,9 @@ function ZeanChat({
|
|
|
7421
8040
|
// A chosen language goes first: the chat takes the first one it speaks.
|
|
7422
8041
|
languages: locale ? [locale] : deviceLanguages(),
|
|
7423
8042
|
deviceLanguage: deviceLanguages()[0],
|
|
7424
|
-
os: deviceOs()
|
|
8043
|
+
os: deviceOs(),
|
|
8044
|
+
// The Conversation stays on the phone: the next start shows it at once and asks only for newer messages.
|
|
8045
|
+
keep: true
|
|
7425
8046
|
});
|
|
7426
8047
|
const detach = attachChat(started);
|
|
7427
8048
|
setChat(started);
|
|
@@ -7430,20 +8051,20 @@ function ZeanChat({
|
|
|
7430
8051
|
started.destroy();
|
|
7431
8052
|
};
|
|
7432
8053
|
}, [appKey, backendUrl, locale]);
|
|
7433
|
-
(0,
|
|
8054
|
+
(0, import_react17.useEffect)(() => {
|
|
7434
8055
|
if (userKey) zean.identify(JSON.parse(userKey));
|
|
7435
8056
|
else if (identified.current) zean.signOut();
|
|
7436
8057
|
identified.current = userKey !== null;
|
|
7437
8058
|
}, [userKey]);
|
|
7438
|
-
(0,
|
|
8059
|
+
(0, import_react17.useEffect)(() => {
|
|
7439
8060
|
if (attributesKey) zean.setAttributes(JSON.parse(attributesKey));
|
|
7440
8061
|
}, [attributesKey]);
|
|
7441
|
-
return chat2 ? /* @__PURE__ */ (0,
|
|
8062
|
+
return chat2 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChatModal, { chat: chat2, colorScheme, maxPhotos }) : null;
|
|
7442
8063
|
}
|
|
7443
8064
|
|
|
7444
8065
|
// src/hooks/use-zean.ts
|
|
7445
|
-
var
|
|
8066
|
+
var import_react18 = require("react");
|
|
7446
8067
|
function useZean() {
|
|
7447
|
-
const { unread } = (0,
|
|
8068
|
+
const { unread } = (0, import_react18.useSyncExternalStore)(subscribeChatView, chatView);
|
|
7448
8069
|
return { ...zean, unreadCount: unread };
|
|
7449
8070
|
}
|