@fayz-ai/plugin-conversations 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { ConversationsContextProvider, useConversationsStore, assinarChegada, useConversationsConfig, CHANNEL_LABELS, isWaitingOnUs, MessagePreview, mediaPreviewKind } from './chunk-NXYQFOT7.js';
2
2
  import { providersApi } from './chunk-HMWUU5O7.js';
3
- import * as React9 from 'react';
4
- import React9__default from 'react';
5
- import { SquarePen, MessageSquare, Globe, Mail, Instagram, Phone, Search, User, Archive, Inbox, CheckCheck, ChevronLeft, MoreHorizontal, ArchiveRestore, Send, X, Building2, CheckCircle2, MoreVertical, Loader2, Forward, AlertTriangle, Check, Clock, ExternalLink, Reply, Snowflake, Sun, Flame, Ban, BarChart3, MapPin, UserRound, Copy, FileText, Download } from 'lucide-react';
3
+ import * as React7 from 'react';
4
+ import React7__default from 'react';
5
+ import { SquarePen, MessageSquare, Globe, Mail, Instagram, Phone, Search, User, Archive, Inbox, CheckCheck, ChevronLeft, MoreHorizontal, ArchiveRestore, X, Building2, CheckCircle2, MoreVertical, Loader2, Forward, AlertTriangle, Check, Clock, ExternalLink, Reply, FileText, Trash2, Paperclip, Square, Mic, Send, Snowflake, Sun, Flame, Ban, BarChart3, MapPin, UserRound, Copy, Download } from 'lucide-react';
6
6
  import { PageHeaderActions, cn, Button, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Textarea, ModalFooter, Input, FilterChip, Skeleton, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, toast } from '@fayz-ai/ui';
7
7
  import { useRightRailStore, PageActions, useLimitGuard, ContactPicker, invalidateLimit, useConnectors, adminNavigateTo } from '@fayz-ai/admin';
8
8
  import { currentAppPath, appHref, onAppPathChange, replaceApp, useTranslation, useActiveTenantId, errorMessage, tl, getSupabaseClientOptional, getActiveTenantId } from '@fayz-ai/core';
@@ -23,10 +23,10 @@ var CHANNEL_ACCENT = {
23
23
  webchat: { color: "#f59e0b", badge: "bg-[#f59e0b]/12 text-[#b45309] dark:text-[#fcd34d]" }
24
24
  };
25
25
  function useMediaQuery(query) {
26
- const [matches, setMatches] = React9__default.useState(
26
+ const [matches, setMatches] = React7__default.useState(
27
27
  () => typeof window !== "undefined" && window.matchMedia(query).matches
28
28
  );
29
- React9__default.useEffect(() => {
29
+ React7__default.useEffect(() => {
30
30
  if (typeof window === "undefined") return;
31
31
  const mql = window.matchMedia(query);
32
32
  const onChange = () => setMatches(mql.matches);
@@ -108,9 +108,9 @@ var whatsappConnected = () => {
108
108
  return whatsappCache;
109
109
  };
110
110
  function useChannelConnections() {
111
- const [whatsapp, setWhatsapp] = React9.useState(void 0);
111
+ const [whatsapp, setWhatsapp] = React7.useState(void 0);
112
112
  const { connectors } = useConnectors({ hostPluginId: "conversations", includeGrants: false });
113
- React9.useEffect(() => {
113
+ React7.useEffect(() => {
114
114
  let cancelled = false;
115
115
  void whatsappConnected().then((v) => {
116
116
  if (!cancelled) setWhatsapp(v);
@@ -119,7 +119,7 @@ function useChannelConnections() {
119
119
  cancelled = true;
120
120
  };
121
121
  }, []);
122
- return React9.useMemo(() => {
122
+ return React7.useMemo(() => {
123
123
  if (whatsapp === void 0) return void 0;
124
124
  const live = (needle) => (connectors ?? []).some((c) => c.state === "connected" && c.slug.toLowerCase().includes(needle));
125
125
  return { whatsapp: whatsapp || live("whatsapp"), email: live("mail"), instagram: live("instagram") };
@@ -178,12 +178,12 @@ function ConversationList({ className }) {
178
178
  setLeadOwnerFilter,
179
179
  setSearch
180
180
  } = useConversationsStore((s) => s);
181
- const [archived, setArchived] = React9__default.useState(false);
182
- const shown = React9__default.useMemo(
181
+ const [archived, setArchived] = React7__default.useState(false);
182
+ const shown = React7__default.useMemo(
183
183
  () => conversations.filter((c) => archived ? c.status === "closed" : c.status !== "closed"),
184
184
  [conversations, archived]
185
185
  );
186
- const donos = React9__default.useMemo(() => {
186
+ const donos = React7__default.useMemo(() => {
187
187
  const vistos = /* @__PURE__ */ new Map();
188
188
  for (const c of conversations) {
189
189
  if (c.leadOwnerId) vistos.set(c.leadOwnerId, c.leadOwnerName ?? c.leadOwnerId);
@@ -350,9 +350,9 @@ function ConversationList({ className }) {
350
350
  ] });
351
351
  }
352
352
  function useSendWindow(conversationId) {
353
- const [row, setRow] = React9__default.useState(null);
354
- const [providers, setProviders] = React9__default.useState(null);
355
- React9__default.useEffect(() => {
353
+ const [row, setRow] = React7__default.useState(null);
354
+ const [providers, setProviders] = React7__default.useState(null);
355
+ React7__default.useEffect(() => {
356
356
  let alive = true;
357
357
  providersApi.list().then((p) => {
358
358
  if (alive) setProviders(p);
@@ -363,7 +363,7 @@ function useSendWindow(conversationId) {
363
363
  alive = false;
364
364
  };
365
365
  }, []);
366
- React9__default.useEffect(() => {
366
+ React7__default.useEffect(() => {
367
367
  let alive = true;
368
368
  if (!conversationId) {
369
369
  setRow(null);
@@ -384,7 +384,7 @@ function useSendWindow(conversationId) {
384
384
  };
385
385
  }, [conversationId]);
386
386
  const provider = (providers ?? []).find((p) => p.isActive);
387
- const mode = React9__default.useMemo(() => {
387
+ const mode = React7__default.useMemo(() => {
388
388
  if (!provider) return { kind: "blocked", reason: "no_provider" };
389
389
  if (!provider.capabilities?.requires_template) {
390
390
  return { kind: "free", until: null, minutesLeft: null };
@@ -459,10 +459,10 @@ function DeliveryMark({ m }) {
459
459
  ] });
460
460
  }
461
461
  function MessageMenu({ m }) {
462
- const [open, setOpen] = React9__default.useState(false);
463
- const [detail, setDetail] = React9__default.useState(null);
464
- const [loading, setLoading] = React9__default.useState(false);
465
- const [err, setErr] = React9__default.useState(null);
462
+ const [open, setOpen] = React7__default.useState(false);
463
+ const [detail, setDetail] = React7__default.useState(null);
464
+ const [loading, setLoading] = React7__default.useState(false);
465
+ const [err, setErr] = React7__default.useState(null);
466
466
  async function load() {
467
467
  setOpen(true);
468
468
  if (!m.providerMessageId) return;
@@ -540,9 +540,9 @@ function temArquivo(m) {
540
540
  return !!m.mediaPath && COM_ARQUIVO.has(String(m.messageType));
541
541
  }
542
542
  function useUrlAssinada(m, visivel) {
543
- const [url, setUrl] = React9.useState(null);
544
- const [erro, setErro] = React9.useState(false);
545
- React9.useEffect(() => {
543
+ const [url, setUrl] = React7.useState(null);
544
+ const [erro, setErro] = React7.useState(false);
545
+ React7.useEffect(() => {
546
546
  if (!visivel || url || erro || !temArquivo(m)) return;
547
547
  let vivo = true;
548
548
  (async () => {
@@ -577,10 +577,10 @@ function duracao(seg) {
577
577
  return `${m}:${String(s).padStart(2, "0")}`;
578
578
  }
579
579
  function MediaBubble({ m, outbound }) {
580
- const ref = React9.useRef(null);
581
- const [visivel, setVisivel] = React9.useState(false);
580
+ const ref = React7.useRef(null);
581
+ const [visivel, setVisivel] = React7.useState(false);
582
582
  const { url, erro } = useUrlAssinada(m, visivel);
583
- React9.useEffect(() => {
583
+ React7.useEffect(() => {
584
584
  const el = ref.current;
585
585
  if (!el || typeof IntersectionObserver === "undefined") {
586
586
  setVisivel(true);
@@ -660,6 +660,172 @@ function MediaBubble({ m, outbound }) {
660
660
  legenda ? /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap break-words", children: legenda }) : null
661
661
  ] });
662
662
  }
663
+ function recordingMime() {
664
+ if (typeof MediaRecorder === "undefined") return void 0;
665
+ for (const m of ["audio/ogg;codecs=opus", "audio/webm;codecs=opus", "audio/webm", "audio/mp4"]) {
666
+ if (MediaRecorder.isTypeSupported?.(m)) return m;
667
+ }
668
+ return void 0;
669
+ }
670
+ function clock(seconds) {
671
+ return `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
672
+ }
673
+ function Composer({ canType, placeholder, sending, onSendText, onSendMedia }) {
674
+ const t = useTranslation();
675
+ const [draft, setDraft] = React7.useState("");
676
+ const [file, setFile] = React7.useState(null);
677
+ const [preview, setPreview] = React7.useState(null);
678
+ const [recording, setRecording] = React7.useState(false);
679
+ const [seconds, setSeconds] = React7.useState(0);
680
+ const [busy, setBusy] = React7.useState(false);
681
+ const inputRef = React7.useRef(null);
682
+ const recorder = React7.useRef(null);
683
+ const chunks = React7.useRef([]);
684
+ const discard = React7.useRef(false);
685
+ const timer = React7.useRef(null);
686
+ React7.useEffect(() => {
687
+ if (!file || !/^(image|video)\//u.test(file.type)) {
688
+ setPreview(null);
689
+ return;
690
+ }
691
+ const url = URL.createObjectURL(file);
692
+ setPreview(url);
693
+ return () => URL.revokeObjectURL(url);
694
+ }, [file]);
695
+ React7.useEffect(() => () => {
696
+ if (timer.current) window.clearInterval(timer.current);
697
+ recorder.current?.stream.getTracks().forEach((tr) => tr.stop());
698
+ }, []);
699
+ async function send() {
700
+ if (busy || sending) return;
701
+ setBusy(true);
702
+ try {
703
+ if (file) {
704
+ await onSendMedia({ file, fileName: file.name, caption: draft.trim() || void 0 });
705
+ setFile(null);
706
+ setDraft("");
707
+ } else if (draft.trim()) {
708
+ const text = draft;
709
+ setDraft("");
710
+ await onSendText(text);
711
+ }
712
+ } catch (e) {
713
+ toast.error(e.message);
714
+ } finally {
715
+ setBusy(false);
716
+ }
717
+ }
718
+ async function startRecording() {
719
+ const mime = recordingMime();
720
+ if (!navigator.mediaDevices?.getUserMedia || !mime) {
721
+ toast.error(t("conversations.composer.noMic"));
722
+ return;
723
+ }
724
+ try {
725
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
726
+ const rec = new MediaRecorder(stream, { mimeType: mime });
727
+ chunks.current = [];
728
+ discard.current = false;
729
+ rec.ondataavailable = (e) => {
730
+ if (e.data.size) chunks.current.push(e.data);
731
+ };
732
+ rec.onstop = async () => {
733
+ stream.getTracks().forEach((tr) => tr.stop());
734
+ if (timer.current) {
735
+ window.clearInterval(timer.current);
736
+ timer.current = null;
737
+ }
738
+ setRecording(false);
739
+ if (discard.current || chunks.current.length === 0) return;
740
+ const blob = new Blob(chunks.current, { type: mime.split(";")[0] });
741
+ setBusy(true);
742
+ try {
743
+ await onSendMedia({ file: blob, fileName: `audio.${mime.includes("ogg") ? "ogg" : mime.includes("mp4") ? "m4a" : "webm"}`, ptt: true });
744
+ } catch (e) {
745
+ toast.error(e.message);
746
+ } finally {
747
+ setBusy(false);
748
+ }
749
+ };
750
+ recorder.current = rec;
751
+ rec.start();
752
+ setSeconds(0);
753
+ setRecording(true);
754
+ timer.current = window.setInterval(() => setSeconds((s) => s + 1), 1e3);
755
+ } catch {
756
+ toast.error(t("conversations.composer.micDenied"));
757
+ }
758
+ }
759
+ function stopRecording(sendIt) {
760
+ discard.current = !sendIt;
761
+ recorder.current?.stop();
762
+ recorder.current = null;
763
+ }
764
+ const empty = !draft.trim() && !file;
765
+ return /* @__PURE__ */ jsxs("div", { children: [
766
+ file && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b border-border bg-muted/30 px-4 py-2", children: [
767
+ preview && file.type.startsWith("image/") ? /* @__PURE__ */ jsx("img", { src: preview, alt: "", className: "h-14 w-14 rounded-md object-cover" }) : preview && file.type.startsWith("video/") ? /* @__PURE__ */ jsx("video", { src: preview, className: "h-14 w-20 rounded-md object-cover" }) : /* @__PURE__ */ jsx("span", { className: "flex h-14 w-14 items-center justify-center rounded-md bg-card", children: /* @__PURE__ */ jsx(FileText, { className: "h-6 w-6 text-muted-foreground" }) }),
768
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
769
+ /* @__PURE__ */ jsx("p", { className: "truncate text-sm", children: file.name }),
770
+ /* @__PURE__ */ jsxs("p", { className: "text-[11px] text-muted-foreground", children: [
771
+ (file.size / 1024 / 1024).toFixed(1),
772
+ " MB \xB7 ",
773
+ t("conversations.composer.captionHint")
774
+ ] })
775
+ ] }),
776
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", onClick: () => setFile(null), "aria-label": t("conversations.composer.removeFile"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) })
777
+ ] }),
778
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2 px-4 py-3", children: [
779
+ /* @__PURE__ */ jsx(
780
+ "input",
781
+ {
782
+ ref: inputRef,
783
+ type: "file",
784
+ className: "hidden",
785
+ accept: "image/*,video/*,audio/*,application/pdf,.doc,.docx,.xls,.xlsx,.csv,.txt,.zip",
786
+ onChange: (e) => {
787
+ const f = e.target.files?.[0];
788
+ if (f) setFile(f);
789
+ e.target.value = "";
790
+ }
791
+ }
792
+ ),
793
+ recording ? /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-3 rounded-md border border-destructive/40 bg-destructive-soft/40 px-3 py-2", children: [
794
+ /* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 animate-pulse rounded-full bg-destructive" }),
795
+ /* @__PURE__ */ jsx("span", { className: "text-sm tabular-nums", children: clock(seconds) }),
796
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("conversations.composer.recording") }),
797
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "ml-auto h-8 w-8", onClick: () => stopRecording(false), "aria-label": t("conversations.composer.discard"), children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
798
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
799
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "shrink-0", disabled: !canType || busy, onClick: () => inputRef.current?.click(), "aria-label": t("conversations.composer.attach"), children: /* @__PURE__ */ jsx(Paperclip, { className: "h-4 w-4" }) }),
800
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
801
+ Textarea,
802
+ {
803
+ value: draft,
804
+ onChange: (e) => setDraft(e.target.value),
805
+ onKeyDown: (e) => {
806
+ if (e.key === "Enter" && !e.shiftKey) {
807
+ e.preventDefault();
808
+ void send();
809
+ }
810
+ },
811
+ onPaste: (e) => {
812
+ const f = Array.from(e.clipboardData.files ?? [])[0];
813
+ if (f) {
814
+ e.preventDefault();
815
+ setFile(f);
816
+ }
817
+ },
818
+ rows: 1,
819
+ disabled: !canType,
820
+ placeholder: file ? t("conversations.composer.caption") : placeholder,
821
+ className: "max-h-32 min-h-[40px] resize-none rounded-md border-border bg-background shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0 disabled:bg-muted/40 disabled:text-muted-foreground disabled:opacity-100"
822
+ }
823
+ ) })
824
+ ] }),
825
+ recording ? /* @__PURE__ */ jsx(Button, { onClick: () => stopRecording(true), "aria-label": t("conversations.thread.send"), children: /* @__PURE__ */ jsx(Square, { className: "h-3.5 w-3.5 fill-current" }) }) : empty ? /* @__PURE__ */ jsx(Button, { onClick: () => void startRecording(), disabled: !canType || busy || sending, "aria-label": t("conversations.composer.record"), className: cn(busy && "opacity-70"), children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Mic, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx(Button, { onClick: () => void send(), disabled: !canType || busy || sending, "aria-label": t("conversations.thread.send"), children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" }) })
826
+ ] })
827
+ ] });
828
+ }
663
829
  var URL_RE = /(https?:\/\/[^\s<]+[^\s<.,;:!?)\]'"])/gu;
664
830
  function RichText({ text, outbound }) {
665
831
  const linkCls = outbound ? "underline text-white" : "text-[hsl(var(--info))] underline";
@@ -826,7 +992,7 @@ function isFoldedRow(m) {
826
992
  return m.messageType === "reaction" || m.messageType === "edit" || m.messageType === "revoke";
827
993
  }
828
994
  function ContactCard({ contacts, outbound }) {
829
- const [copied, setCopied] = React9__default.useState(null);
995
+ const [copied, setCopied] = React7__default.useState(null);
830
996
  const copy = (value) => {
831
997
  void navigator.clipboard?.writeText(value);
832
998
  setCopied(value);
@@ -896,15 +1062,14 @@ function buildRows(messages) {
896
1062
  }
897
1063
  function MessageThread({ selected, onTogglePanel, panelOpen, onBack, backAlways, className }) {
898
1064
  const t = useTranslation();
899
- const { messages, sending, send, setStatus, refreshMessages } = useConversationsStore((s) => s);
900
- const [draft, setDraft] = React9__default.useState("");
1065
+ const { messages, sending, send, sendMedia, setStatus, refreshMessages } = useConversationsStore((s) => s);
901
1066
  const win = useSendWindow(selected.id);
902
1067
  const canType = win.mode.kind === "free";
903
- const threadRef = React9__default.useRef(null);
904
- React9__default.useEffect(() => {
1068
+ const threadRef = React7__default.useRef(null);
1069
+ React7__default.useEffect(() => {
905
1070
  threadRef.current?.scrollTo({ top: threadRef.current.scrollHeight, behavior: "smooth" });
906
1071
  }, [messages.length, selected.id]);
907
- React9__default.useEffect(() => {
1072
+ React7__default.useEffect(() => {
908
1073
  if (!selected.id) return;
909
1074
  let timer = null;
910
1075
  const start = () => {
@@ -926,15 +1091,9 @@ function MessageThread({ selected, onTogglePanel, panelOpen, onBack, backAlways,
926
1091
  document.removeEventListener("visibilitychange", onVis);
927
1092
  };
928
1093
  }, [selected.id, refreshMessages]);
929
- async function handleSend() {
930
- if (!draft.trim()) return;
931
- const body = draft;
932
- setDraft("");
933
- await send(body);
934
- }
935
1094
  const accent = CHANNEL_ACCENT[selected.channel];
936
- const rows = React9__default.useMemo(() => buildRows(messages.filter((m) => !isFoldedRow(m))), [messages]);
937
- const jumpTo = React9__default.useCallback((providerId) => {
1095
+ const rows = React7__default.useMemo(() => buildRows(messages.filter((m) => !isFoldedRow(m))), [messages]);
1096
+ const jumpTo = React7__default.useCallback((providerId) => {
938
1097
  const el = threadRef.current?.querySelector(`[data-provider-id="${CSS.escape(providerId)}"]`);
939
1098
  if (!el) return;
940
1099
  el.scrollIntoView({ behavior: "smooth", block: "center" });
@@ -1056,26 +1215,16 @@ function MessageThread({ selected, onTogglePanel, panelOpen, onBack, backAlways,
1056
1215
  ] }),
1057
1216
  /* @__PURE__ */ jsxs("div", { className: "border-t border-border bg-card", children: [
1058
1217
  /* @__PURE__ */ jsx(SendWindowBanner, { state: win }),
1059
- /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2 px-4 py-3", children: [
1060
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
1061
- Textarea,
1062
- {
1063
- value: draft,
1064
- onChange: (e) => setDraft(e.target.value),
1065
- onKeyDown: (e) => {
1066
- if (e.key === "Enter" && !e.shiftKey) {
1067
- e.preventDefault();
1068
- void handleSend();
1069
- }
1070
- },
1071
- rows: 1,
1072
- disabled: !canType,
1073
- placeholder: canType ? t("conversations.thread.reply", { channel: CHANNEL_LABELS[selected.channel] }) : win.mode.kind === "blocked" ? "Envio bloqueado" : "Fora da janela \u2014 envie um template",
1074
- className: "max-h-32 min-h-[40px] resize-none rounded-md border-border bg-background shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0 disabled:bg-muted/40 disabled:text-muted-foreground disabled:opacity-100"
1075
- }
1076
- ) }),
1077
- /* @__PURE__ */ jsx(Button, { onClick: () => void handleSend(), disabled: !canType || sending || !draft.trim(), "aria-label": t("conversations.thread.send"), children: /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" }) })
1078
- ] })
1218
+ /* @__PURE__ */ jsx(
1219
+ Composer,
1220
+ {
1221
+ canType,
1222
+ sending,
1223
+ placeholder: canType ? t("conversations.thread.reply", { channel: CHANNEL_LABELS[selected.channel] }) : win.mode.kind === "blocked" ? "Envio bloqueado" : "Fora da janela \u2014 envie um template",
1224
+ onSendText: (text) => send(text),
1225
+ onSendMedia: (input) => sendMedia(input)
1226
+ }
1227
+ )
1079
1228
  ] })
1080
1229
  ] });
1081
1230
  }
@@ -1102,8 +1251,8 @@ function declaredCompany(meta) {
1102
1251
  };
1103
1252
  }
1104
1253
  function useContactProfile(personId, handle) {
1105
- const [profile, setProfile] = React9__default.useState(void 0);
1106
- React9__default.useEffect(() => {
1254
+ const [profile, setProfile] = React7__default.useState(void 0);
1255
+ React7__default.useEffect(() => {
1107
1256
  let alive = true;
1108
1257
  setProfile(void 0);
1109
1258
  const sb = getSupabaseClientOptional();
@@ -1357,14 +1506,14 @@ function NewConversationPanel({
1357
1506
  const create = useConversationsStore((s) => s.create);
1358
1507
  const config = useConversationsConfig();
1359
1508
  const guardConversations = useLimitGuard("conversations_month");
1360
- const [channel, setChannel] = React9__default.useState("whatsapp");
1361
- const [contact, setContact] = React9__default.useState(null);
1362
- const [typedHandle, setTypedHandle] = React9__default.useState("");
1363
- const [creatingContact, setCreatingContact] = React9__default.useState(false);
1364
- const [firstMessage, setFirstMessage] = React9__default.useState("");
1365
- const [submitting, setSubmitting] = React9__default.useState(false);
1366
- const [pickerKey, setPickerKey] = React9__default.useState(0);
1367
- React9__default.useEffect(() => {
1509
+ const [channel, setChannel] = React7__default.useState("whatsapp");
1510
+ const [contact, setContact] = React7__default.useState(null);
1511
+ const [typedHandle, setTypedHandle] = React7__default.useState("");
1512
+ const [creatingContact, setCreatingContact] = React7__default.useState(false);
1513
+ const [firstMessage, setFirstMessage] = React7__default.useState("");
1514
+ const [submitting, setSubmitting] = React7__default.useState(false);
1515
+ const [pickerKey, setPickerKey] = React7__default.useState(0);
1516
+ React7__default.useEffect(() => {
1368
1517
  if (open) {
1369
1518
  setChannel("whatsapp");
1370
1519
  setContact(null);
@@ -1481,9 +1630,9 @@ function useCaixaAoVivo() {
1481
1630
  const load = useConversationsStore((s) => s.load);
1482
1631
  const refreshMessages = useConversationsStore((s) => s.refreshMessages);
1483
1632
  const selectedId = useConversationsStore((s) => s.selectedId);
1484
- const abertoRef = React9.useRef(selectedId);
1633
+ const abertoRef = React7.useRef(selectedId);
1485
1634
  abertoRef.current = selectedId;
1486
- React9.useEffect(() => {
1635
+ React7.useEffect(() => {
1487
1636
  if (!tenantId) return;
1488
1637
  return assinarChegada(tenantId, ({ conversationId }) => {
1489
1638
  void load();
@@ -1501,16 +1650,16 @@ function InboxView({ layout = "page", newSignal = 0 } = {}) {
1501
1650
  const isWideViewport = useMediaQuery("(min-width: 1280px)");
1502
1651
  const isWidePanel = isWideViewport && !dock;
1503
1652
  const railOpen = useRightRailStore((s) => s.open);
1504
- const [panelOpen, setPanelOpen] = React9__default.useState(false);
1505
- const [newOpen, setNewOpen] = React9__default.useState(false);
1653
+ const [panelOpen, setPanelOpen] = React7__default.useState(false);
1654
+ const [newOpen, setNewOpen] = React7__default.useState(false);
1506
1655
  const selected = conversations.find((c) => c.id === selectedId) ?? null;
1507
- React9__default.useEffect(() => {
1656
+ React7__default.useEffect(() => {
1508
1657
  if (newSignal > 0) setNewOpen(true);
1509
1658
  }, [newSignal]);
1510
- React9__default.useEffect(() => {
1659
+ React7__default.useEffect(() => {
1511
1660
  setPanelOpen(isWidePanel && !railOpen);
1512
1661
  }, [isWidePanel, railOpen]);
1513
- const newActions = React9__default.useMemo(() => [{
1662
+ const newActions = React7__default.useMemo(() => [{
1514
1663
  id: "new-conversation",
1515
1664
  label: t("conversations.list.new"),
1516
1665
  icon: SquarePen,
@@ -1590,7 +1739,7 @@ function conversationIdFromPath(path) {
1590
1739
  return m ? decodeURIComponent(m[1]) : null;
1591
1740
  }
1592
1741
  function ConversationsPage({ store, config }) {
1593
- React9__default.useEffect(() => {
1742
+ React7__default.useEffect(() => {
1594
1743
  const wanted = requestedContact();
1595
1744
  if (!wanted) {
1596
1745
  const fromPath = conversationIdFromPath(currentAppPath());
@@ -1608,7 +1757,7 @@ function ConversationsPage({ store, config }) {
1608
1757
  } catch {
1609
1758
  }
1610
1759
  }, []);
1611
- React9__default.useEffect(() => {
1760
+ React7__default.useEffect(() => {
1612
1761
  const write = (id) => {
1613
1762
  const path = currentAppPath();
1614
1763
  if (!path.startsWith("/conversations")) return;
@@ -1633,5 +1782,5 @@ function ConversationsPage({ store, config }) {
1633
1782
  }
1634
1783
 
1635
1784
  export { ConversationsPage, conversationIdFromPath };
1636
- //# sourceMappingURL=ConversationsPage-2D343Q5P.js.map
1637
- //# sourceMappingURL=ConversationsPage-2D343Q5P.js.map
1785
+ //# sourceMappingURL=ConversationsPage-TT33VW3H.js.map
1786
+ //# sourceMappingURL=ConversationsPage-TT33VW3H.js.map