@adminide-stack/yantra-mobile 12.0.94 → 12.0.95-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/lib/compute.js +113 -1
  2. package/lib/compute.js.map +1 -1
  3. package/lib/features/agent-chat/NativeAgentChat.js +1 -1
  4. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  5. package/lib/features/apps/AppsCatalog.js +20 -0
  6. package/lib/features/apps/AppsCatalog.js.map +1 -1
  7. package/lib/features/apps/appArt.js +3 -1
  8. package/lib/features/apps/appArt.js.map +1 -1
  9. package/lib/features/apps/appFavorites.js +8 -2
  10. package/lib/features/apps/appFavorites.js.map +1 -1
  11. package/lib/features/apps/mobileAppCatalog.js +27 -1
  12. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  13. package/lib/features/canvas/VideoGeneratorExperience.js +1 -0
  14. package/lib/features/canvas/VideoGeneratorExperience.js.map +1 -1
  15. package/lib/features/canvas/sessionIdentity.js +8 -1
  16. package/lib/features/canvas/sessionIdentity.js.map +1 -1
  17. package/lib/features/canvas/useCanvasSession.js +1 -0
  18. package/lib/features/canvas/useCanvasSession.js.map +1 -1
  19. package/lib/features/canvas/videoEditor/remoteMediaClient.js +51 -24
  20. package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
  21. package/lib/features/chat/connectorConnect.js +1 -1
  22. package/lib/features/inbox/InboxAgentChatPane.js +64 -0
  23. package/lib/features/inbox/InboxAgentChatPane.js.map +1 -0
  24. package/lib/features/inbox/InboxExperience.js +631 -0
  25. package/lib/features/inbox/InboxExperience.js.map +1 -0
  26. package/lib/features/inbox/components/BottomSheet.js +111 -0
  27. package/lib/features/inbox/components/BottomSheet.js.map +1 -0
  28. package/lib/features/inbox/components/ComposeSheet.js +298 -0
  29. package/lib/features/inbox/components/ComposeSheet.js.map +1 -0
  30. package/lib/features/inbox/components/InboxStates.js +182 -0
  31. package/lib/features/inbox/components/InboxStates.js.map +1 -0
  32. package/lib/features/inbox/components/MailBody.js +103 -0
  33. package/lib/features/inbox/components/MailBody.js.map +1 -0
  34. package/lib/features/inbox/components/MessageReader.js +396 -0
  35. package/lib/features/inbox/components/MessageReader.js.map +1 -0
  36. package/lib/features/inbox/components/MessageRow.js +153 -0
  37. package/lib/features/inbox/components/MessageRow.js.map +1 -0
  38. package/lib/features/inbox/components/SenderAvatar.js +24 -0
  39. package/lib/features/inbox/components/SenderAvatar.js.map +1 -0
  40. package/lib/features/inbox/components/Tap.js +55 -0
  41. package/lib/features/inbox/components/Tap.js.map +1 -0
  42. package/lib/features/inbox/composeDraft.js +89 -0
  43. package/lib/features/inbox/composeDraft.js.map +1 -0
  44. package/lib/features/inbox/formatMailDate.js +60 -0
  45. package/lib/features/inbox/formatMailDate.js.map +1 -0
  46. package/lib/features/inbox/inboxAccounts.js +110 -0
  47. package/lib/features/inbox/inboxAccounts.js.map +1 -0
  48. package/lib/features/inbox/inboxClient.js +293 -0
  49. package/lib/features/inbox/inboxClient.js.map +1 -0
  50. package/lib/features/inbox/inboxContext.js +27 -0
  51. package/lib/features/inbox/inboxContext.js.map +1 -0
  52. package/lib/features/inbox/inboxFolders.js +47 -0
  53. package/lib/features/inbox/inboxFolders.js.map +1 -0
  54. package/lib/features/inbox/inboxNormalize.js +144 -0
  55. package/lib/features/inbox/inboxNormalize.js.map +1 -0
  56. package/lib/features/inbox/inboxPreference.js +20 -0
  57. package/lib/features/inbox/inboxPreference.js.map +1 -0
  58. package/lib/features/inbox/inboxTheme.js +54 -0
  59. package/lib/features/inbox/inboxTheme.js.map +1 -0
  60. package/lib/features/inbox/nativeInboxRegistry.js +15 -0
  61. package/lib/features/inbox/nativeInboxRegistry.js.map +1 -0
  62. package/lib/features/inbox/openAttachment.js +43 -0
  63. package/lib/features/inbox/openAttachment.js.map +1 -0
  64. package/lib/features/inbox/useInboxMailbox.js +250 -0
  65. package/lib/features/inbox/useInboxMailbox.js.map +1 -0
  66. package/lib/features/inbox/useMailMessage.js +101 -0
  67. package/lib/features/inbox/useMailMessage.js.map +1 -0
  68. package/lib/features/shopping/OrdersPanel.js +2 -2
  69. package/lib/features/shopping/OrdersPanel.js.map +1 -1
  70. package/lib/features/shopping/ProductCard.js +3 -3
  71. package/lib/features/shopping/ProductCard.js.map +1 -1
  72. package/lib/features/shopping/ProductDetailSheet.js +2 -2
  73. package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
  74. package/lib/features/shopping/SavedPanel.js +2 -2
  75. package/lib/features/shopping/SavedPanel.js.map +1 -1
  76. package/lib/features/shopping/ShoppingExperience.js +46 -13
  77. package/lib/features/shopping/ShoppingExperience.js.map +1 -1
  78. package/lib/features/shopping/cartCloudSync.js +73 -0
  79. package/lib/features/shopping/cartCloudSync.js.map +1 -0
  80. package/lib/features/shopping/catalog.js +5 -1
  81. package/lib/features/shopping/catalog.js.map +1 -1
  82. package/lib/features/shopping/services/cartCloud.js +118 -0
  83. package/lib/features/shopping/services/cartCloud.js.map +1 -0
  84. package/lib/features/shopping/shoppingCart.js +17 -1
  85. package/lib/features/shopping/shoppingCart.js.map +1 -1
  86. package/lib/features/shopping/useCartCloudSync.js +33 -0
  87. package/lib/features/shopping/useCartCloudSync.js.map +1 -0
  88. package/lib/features/study/StudyAgentChatPane.js +67 -0
  89. package/lib/features/study/StudyAgentChatPane.js.map +1 -0
  90. package/lib/features/study/StudyExperience.js +586 -0
  91. package/lib/features/study/StudyExperience.js.map +1 -0
  92. package/lib/features/study/components/CellView.js +133 -0
  93. package/lib/features/study/components/CellView.js.map +1 -0
  94. package/lib/features/study/components/IntakeCard.js +203 -0
  95. package/lib/features/study/components/IntakeCard.js.map +1 -0
  96. package/lib/features/study/components/NotebookSwitcher.js +74 -0
  97. package/lib/features/study/components/NotebookSwitcher.js.map +1 -0
  98. package/lib/features/study/components/SourceStrip.js +69 -0
  99. package/lib/features/study/components/SourceStrip.js.map +1 -0
  100. package/lib/features/study/components/StudyComposer.js +118 -0
  101. package/lib/features/study/components/StudyComposer.js.map +1 -0
  102. package/lib/features/study/components/StudyOnboarding.js +477 -0
  103. package/lib/features/study/components/StudyOnboarding.js.map +1 -0
  104. package/lib/features/study/components/StudySheet.js +120 -0
  105. package/lib/features/study/components/StudySheet.js.map +1 -0
  106. package/lib/features/study/components/StudyStates.js +148 -0
  107. package/lib/features/study/components/StudyStates.js.map +1 -0
  108. package/lib/features/study/components/TextEntrySheet.js +111 -0
  109. package/lib/features/study/components/TextEntrySheet.js.map +1 -0
  110. package/lib/features/study/nativeStudyRegistry.js +15 -0
  111. package/lib/features/study/nativeStudyRegistry.js.map +1 -0
  112. package/lib/features/study/shareExport.js +38 -0
  113. package/lib/features/study/shareExport.js.map +1 -0
  114. package/lib/features/study/studyClient.js +278 -0
  115. package/lib/features/study/studyClient.js.map +1 -0
  116. package/lib/features/study/studyContext.js +25 -0
  117. package/lib/features/study/studyContext.js.map +1 -0
  118. package/lib/features/study/studyFiles.js +140 -0
  119. package/lib/features/study/studyFiles.js.map +1 -0
  120. package/lib/features/study/studyNormalize.js +116 -0
  121. package/lib/features/study/studyNormalize.js.map +1 -0
  122. package/lib/features/study/studyPreference.js +24 -0
  123. package/lib/features/study/studyPreference.js.map +1 -0
  124. package/lib/features/study/studyProfile.js +233 -0
  125. package/lib/features/study/studyProfile.js.map +1 -0
  126. package/lib/features/study/studyPrompts.js +78 -0
  127. package/lib/features/study/studyPrompts.js.map +1 -0
  128. package/lib/features/study/studyTheme.js +47 -0
  129. package/lib/features/study/studyTheme.js.map +1 -0
  130. package/lib/features/study/useStudyWorkspace.js +401 -0
  131. package/lib/features/study/useStudyWorkspace.js.map +1 -0
  132. package/lib/index.js +1 -1
  133. package/lib/index.js.map +1 -1
  134. package/lib/routes.json +108 -0
  135. package/lib/screens/InboxNative/index.js +77 -0
  136. package/lib/screens/InboxNative/index.js.map +1 -0
  137. package/lib/screens/InboxNative/useConnectMailbox.js +42 -0
  138. package/lib/screens/InboxNative/useConnectMailbox.js.map +1 -0
  139. package/lib/screens/InboxNative/useInboxHostChat.js +62 -0
  140. package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -0
  141. package/lib/screens/InboxNative/useMailAccounts.js +54 -0
  142. package/lib/screens/InboxNative/useMailAccounts.js.map +1 -0
  143. package/lib/screens/ShoppingNative/index.js +2 -1
  144. package/lib/screens/ShoppingNative/index.js.map +1 -1
  145. package/lib/screens/StudyNative/index.js +80 -0
  146. package/lib/screens/StudyNative/index.js.map +1 -0
  147. package/lib/screens/StudyNative/useStudyHostChat.js +62 -0
  148. package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -0
  149. package/lib/utils/authUserDisplay.js +11 -1
  150. package/lib/utils/authUserDisplay.js.map +1 -1
  151. package/package.json +4 -4
@@ -0,0 +1,631 @@
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useState,useRef,useCallback,useEffect}from'react';import {StyleSheet,BackHandler,View,ActivityIndicator,TextInput,Pressable,Text,ScrollView,FlatList,RefreshControl,Keyboard}from'react-native';import {GestureHandlerRootView}from'react-native-gesture-handler';import {MaterialCommunityIcons}from'@expo/vector-icons';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {createRemoteConnectorExec}from'../canvas/videoEditor/remoteMediaClient.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {pickMailAccount}from'./inboxAccounts.js';import {createInboxClient,toInboxError}from'./inboxClient.js';import {messageReference}from'./inboxContext.js';import {mailFolder,MAIL_FOLDERS}from'./inboxFolders.js';import {readPreferredMailbox,writePreferredMailbox}from'./inboxPreference.js';import {inboxTheme}from'./inboxTheme.js';import {draftFor,parseRecipients}from'./composeDraft.js';import {openAttachment}from'./openAttachment.js';import {useInboxMailbox}from'./useInboxMailbox.js';import {useMailMessage}from'./useMailMessage.js';import {InboxAgentChatPane}from'./InboxAgentChatPane.js';import {BottomSheet,SheetRow}from'./components/BottomSheet.js';import {ComposeSheet}from'./components/ComposeSheet.js';import {CenteredState,NoticeStrip,Toast}from'./components/InboxStates.js';import {MessageReader}from'./components/MessageReader.js';import {MessageRow}from'./components/MessageRow.js';import {Tap,DIM}from'./components/Tap.js';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const TOAST_MS = 3e3;
21
+ const TOP_ROW_HEIGHT = 48;
22
+ const REMOVED_LABEL = {
23
+ archive: "Archived",
24
+ trash: "Moved to Trash",
25
+ spam: "Marked as spam"
26
+ };
27
+ function swipeActionFor(folder) {
28
+ if (folder === "trash") return null;
29
+ if (folder === "archive" || folder === "spam") return "trash";
30
+ return "archive";
31
+ }
32
+ function canArchive(folder) {
33
+ return folder !== "archive" && folder !== "trash" && folder !== "spam";
34
+ }
35
+ function canTrash(folder) {
36
+ return folder !== "trash";
37
+ }
38
+ function canSpam(folder) {
39
+ return folder === "inbox" || folder === "starred" || folder === "archive";
40
+ }
41
+ function providerName(provider) {
42
+ var _a;
43
+ if (!provider || provider === "auto" || provider === "other") return "Mail account";
44
+ const names = {
45
+ gmail: "Gmail",
46
+ google: "Gmail",
47
+ microsoft: "Outlook",
48
+ outlook: "Outlook",
49
+ zoho: "Zoho Mail",
50
+ yahoo: "Yahoo Mail",
51
+ icloud: "iCloud Mail"
52
+ };
53
+ return (_a = names[provider.toLowerCase()]) != null ? _a : provider;
54
+ }
55
+ function ListFooter({
56
+ theme,
57
+ loading,
58
+ hasMore,
59
+ count,
60
+ onLoadMore,
61
+ bottomPad
62
+ }) {
63
+ let content;
64
+ if (loading) content = /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent });
65
+ else if (hasMore) {
66
+ content = /* @__PURE__ */ jsx(Pressable, { onPress: onLoadMore, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ jsx(Text, { style: [styles.footerAction, {
67
+ color: theme.accent
68
+ }], children: "Load more" }) });
69
+ } else {
70
+ content = /* @__PURE__ */ jsx(Text, { style: [styles.footerText, {
71
+ color: theme.faint
72
+ }], children: count === 1 ? "1 message" : `${count} messages` });
73
+ }
74
+ return /* @__PURE__ */ jsx(View, { style: [styles.footer, {
75
+ paddingBottom: bottomPad
76
+ }], children: content });
77
+ }
78
+ function RowMenu({
79
+ message,
80
+ folder,
81
+ theme,
82
+ onClose,
83
+ onRead,
84
+ onStar,
85
+ onRemove,
86
+ onReply,
87
+ onAsk
88
+ }) {
89
+ const act = (fn) => () => {
90
+ if (!message) return;
91
+ onClose();
92
+ fn(message);
93
+ };
94
+ return /* @__PURE__ */ jsx(BottomSheet, { visible: Boolean(message), title: message == null ? void 0 : message.subject, subtitle: message == null ? void 0 : message.from.address, theme, onClose, children: message ? /* @__PURE__ */ jsxs(Fragment, { children: [
95
+ /* @__PURE__ */ jsx(SheetRow, { icon: "reply", label: "Reply", onPress: act(onReply), theme }),
96
+ /* @__PURE__ */ jsx(SheetRow, { icon: message.unread ? "email-open-outline" : "email-mark-as-unread", label: message.unread ? "Mark as read" : "Mark as unread", onPress: act(onRead), theme }),
97
+ /* @__PURE__ */ jsx(SheetRow, { icon: message.starred ? "star-off-outline" : "star-outline", label: message.starred ? "Unstar" : "Star", onPress: act(onStar), theme }),
98
+ canArchive(folder) ? /* @__PURE__ */ jsx(SheetRow, { icon: "archive-arrow-down-outline", label: "Archive", onPress: act((m) => onRemove(m, "archive")), theme }) : null,
99
+ canSpam(folder) ? /* @__PURE__ */ jsx(SheetRow, { icon: "alert-octagon-outline", label: "Mark as spam", onPress: act((m) => onRemove(m, "spam")), theme }) : null,
100
+ canTrash(folder) ? /* @__PURE__ */ jsx(SheetRow, { icon: "trash-can-outline", label: "Move to Trash", destructive: true, onPress: act((m) => onRemove(m, "trash")), theme }) : null,
101
+ /* @__PURE__ */ jsx(SheetRow, { icon: "creation", label: "Ask Yantra about this", onPress: act(onAsk), theme })
102
+ ] }) : null });
103
+ }
104
+ function InboxExperience({
105
+ isDark: hostIsDark,
106
+ token,
107
+ indexUrl,
108
+ sessionError,
109
+ onRetrySession,
110
+ orgName,
111
+ accounts,
112
+ legacyMailboxes = [],
113
+ accountsLoading = false,
114
+ accountsError,
115
+ onRetryAccounts,
116
+ onConnectMailbox,
117
+ connectingMailbox = false,
118
+ connectMailboxError = null,
119
+ focusAccountId = null,
120
+ onExit,
121
+ hostChat,
122
+ initialAgentSeed = null
123
+ }) {
124
+ const appTheme = useAppTheme();
125
+ const isDark = hostIsDark != null ? hostIsDark : appTheme.isDark;
126
+ const theme = useMemo(() => inboxTheme(isDark), [isDark]);
127
+ const insets = useSafeInsets();
128
+ const client = useMemo(() => token ? createInboxClient(createRemoteConnectorExec(token, indexUrl)) : null, [token, indexUrl]);
129
+ const [openMessage, setOpenMessage] = useState(null);
130
+ const [compose, setCompose] = useState(null);
131
+ const [pickerOpen, setPickerOpen] = useState(false);
132
+ const [rowMenu, setRowMenu] = useState(null);
133
+ const [agentOpen, setAgentOpen] = useState(Boolean(initialAgentSeed));
134
+ const [agentSeed, setAgentSeed] = useState(initialAgentSeed ? {
135
+ id: "initial",
136
+ text: initialAgentSeed.text
137
+ } : null);
138
+ const [toast, setToast] = useState(null);
139
+ const [downloadingIndex, setDownloadingIndex] = useState(null);
140
+ const [reconnectDismissed, setReconnectDismissed] = useState(null);
141
+ const toastTimer = useRef(null);
142
+ const showToast = useCallback((message) => {
143
+ if (toastTimer.current) clearTimeout(toastTimer.current);
144
+ setToast(message);
145
+ toastTimer.current = setTimeout(() => setToast(null), TOAST_MS);
146
+ }, []);
147
+ useEffect(() => () => {
148
+ if (toastTimer.current) clearTimeout(toastTimer.current);
149
+ }, []);
150
+ const [preferredId, setPreferredId] = useState(null);
151
+ const [preferenceRead, setPreferenceRead] = useState(false);
152
+ useEffect(() => {
153
+ let alive = true;
154
+ void readPreferredMailbox(orgName != null ? orgName : "").then((id) => {
155
+ if (!alive) return;
156
+ setPreferredId(id);
157
+ setPreferenceRead(true);
158
+ });
159
+ return () => {
160
+ alive = false;
161
+ };
162
+ }, [orgName]);
163
+ const account = useMemo(() => preferenceRead ? pickMailAccount(accounts, preferredId) : null, [accounts, preferredId, preferenceRead]);
164
+ useEffect(() => {
165
+ if (!focusAccountId || !accounts.some((item) => item.id === focusAccountId)) return;
166
+ setPreferredId(focusAccountId);
167
+ writePreferredMailbox(orgName != null ? orgName : "", focusAccountId);
168
+ }, [focusAccountId, accounts, orgName]);
169
+ const chooseAccount = (next) => {
170
+ setPreferredId(next.id);
171
+ writePreferredMailbox(orgName != null ? orgName : next.orgName, next.id);
172
+ setPickerOpen(false);
173
+ };
174
+ const [folder, setFolder] = useState("inbox");
175
+ const [searchOpen, setSearchOpen] = useState(false);
176
+ const [searchText, setSearchText] = useState("");
177
+ const [query, setQuery] = useState("");
178
+ const mailbox = useInboxMailbox({
179
+ client,
180
+ account,
181
+ folder,
182
+ query
183
+ });
184
+ const reader = useMailMessage({
185
+ client,
186
+ account,
187
+ summary: openMessage,
188
+ onReadChange: (id, read) => void mailbox.setRead(id, read)
189
+ });
190
+ useEffect(() => {
191
+ setOpenMessage(null);
192
+ setRowMenu(null);
193
+ setFolder("inbox");
194
+ setSearchOpen(false);
195
+ setSearchText("");
196
+ setQuery("");
197
+ }, [account == null ? void 0 : account.id]);
198
+ const askYantra = (text) => {
199
+ Keyboard.dismiss();
200
+ setAgentSeed({
201
+ id: `${Date.now()}`,
202
+ text
203
+ });
204
+ setAgentOpen(true);
205
+ };
206
+ const closeSearch = () => {
207
+ setSearchOpen(false);
208
+ setSearchText("");
209
+ setQuery("");
210
+ Keyboard.dismiss();
211
+ };
212
+ useEffect(() => {
213
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
214
+ if (compose) return false;
215
+ if (agentOpen) {
216
+ setAgentOpen(false);
217
+ return true;
218
+ }
219
+ if (openMessage) {
220
+ setOpenMessage(null);
221
+ return true;
222
+ }
223
+ if (searchOpen) {
224
+ closeSearch();
225
+ return true;
226
+ }
227
+ return false;
228
+ });
229
+ return () => sub.remove();
230
+ }, [compose, agentOpen, openMessage, searchOpen]);
231
+ const removeMessage = (message, kind) => {
232
+ if ((openMessage == null ? void 0 : openMessage.id) === message.id) setOpenMessage(null);
233
+ mailbox.remove(message, kind);
234
+ };
235
+ const startCompose = (mode, source) => {
236
+ var _a, _b;
237
+ const detail = source && ((_a = reader.detail) == null ? void 0 : _a.id) === source.id ? reader.detail : void 0;
238
+ setCompose(draftFor(mode, detail != null ? detail : source ? __spreadValues({}, source) : void 0, (_b = account == null ? void 0 : account.email) != null ? _b : ""));
239
+ };
240
+ const sendDraft = async (draft) => {
241
+ if (!client || !account) throw new Error("No mailbox is open.");
242
+ const cc = parseRecipients(draft.cc).addresses;
243
+ try {
244
+ if (draft.mode === "new") {
245
+ await client.send(account, {
246
+ to: parseRecipients(draft.to).addresses,
247
+ cc,
248
+ subject: draft.subject.trim() || "(no subject)",
249
+ text: draft.body
250
+ });
251
+ } else if (draft.mode === "forward" && draft.source) {
252
+ await client.forward(account, {
253
+ messageId: draft.source.id,
254
+ to: parseRecipients(draft.to).addresses,
255
+ cc,
256
+ note: draft.body
257
+ });
258
+ } else if (draft.source) {
259
+ const initial = draftFor(draft.mode, draft.source, account.email);
260
+ const ccEdited = draft.cc.trim() !== initial.cc.trim();
261
+ await client.reply(account, {
262
+ messageId: draft.source.id,
263
+ text: draft.body,
264
+ replyAll: draft.mode === "replyAll" && !ccEdited,
265
+ cc: draft.mode === "replyAll" && !ccEdited ? void 0 : cc
266
+ });
267
+ }
268
+ } catch (err) {
269
+ throw toInboxError(err, "send", account);
270
+ }
271
+ setCompose(null);
272
+ showToast(draft.mode === "forward" ? "Forwarded" : "Sent");
273
+ };
274
+ const downloadAttachment = async (attachment) => {
275
+ if (!client || !account || !openMessage) return;
276
+ setDownloadingIndex(attachment.index);
277
+ try {
278
+ const file = await client.getAttachment(account, openMessage.id, attachment.index);
279
+ const outcome = await openAttachment(file);
280
+ if (outcome === "saved") showToast(`Saved ${attachment.filename}`);
281
+ } catch (err) {
282
+ showToast(toInboxError(err, "attachment", account).message);
283
+ } finally {
284
+ setDownloadingIndex(null);
285
+ }
286
+ };
287
+ const body = (() => {
288
+ if (sessionError) {
289
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "cloud-alert", title: "Inbox could not sign in", body: sessionError, theme, primary: onRetrySession ? {
290
+ label: "Try again",
291
+ onPress: onRetrySession
292
+ } : void 0 });
293
+ }
294
+ if (accountsError && accounts.length === 0) {
295
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "cloud-alert", title: "Could not load your mailboxes", body: accountsError, theme, primary: onRetryAccounts ? {
296
+ label: "Try again",
297
+ onPress: onRetryAccounts
298
+ } : void 0 });
299
+ }
300
+ if (!token || accountsLoading && accounts.length === 0 || !preferenceRead) {
301
+ return /* @__PURE__ */ jsx(View, { style: styles.loading, children: /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }) });
302
+ }
303
+ if (!account) {
304
+ const legacy = legacyMailboxes[0];
305
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "email-plus-outline", title: legacy ? `Reconnect your ${legacy.label} mailbox` : "Connect your mailbox", body: legacy ? `${legacy.label} is now connected as a Mail account. Add it again with your email to read it here.` : "Add your email account to read, answer and triage mail here, with Yantra helping.", theme, primary: {
306
+ label: "Connect a mailbox",
307
+ onPress: onConnectMailbox
308
+ }, busy: connectingMailbox, note: connectMailboxError, secondary: {
309
+ label: "Ask Yantra to help",
310
+ onPress: () => askYantra("Help me connect my email account.")
311
+ }, testID: "inbox-connect" });
312
+ }
313
+ return null;
314
+ })();
315
+ const currentFolder = mailFolder(folder);
316
+ const swipeAction = swipeActionFor(folder);
317
+ const showRecipient = folder === "sent" || folder === "drafts";
318
+ const searching = Boolean(query.trim());
319
+ const listEmpty = () => {
320
+ var _a;
321
+ if (mailbox.phase === "loading" || !mailbox.loaded) {
322
+ return /* @__PURE__ */ jsx(View, { style: styles.listState, children: /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }) });
323
+ }
324
+ if (mailbox.error) {
325
+ const reconnect = mailbox.error.kind === "reconnect";
326
+ return /* @__PURE__ */ jsx(CenteredState, { icon: reconnect ? "lock-alert-outline" : "cloud-alert", title: reconnect ? "Mailbox sign-in stopped working" : "Could not load mail", body: mailbox.error.message, theme, primary: reconnect ? {
327
+ label: "Reconnect mailbox",
328
+ onPress: onConnectMailbox
329
+ } : {
330
+ label: "Try again",
331
+ onPress: mailbox.retry
332
+ }, secondary: reconnect ? {
333
+ label: "Try again",
334
+ onPress: mailbox.retry
335
+ } : void 0, testID: "inbox-list-error" });
336
+ }
337
+ if (searching) {
338
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "magnify-close", title: "No matches", body: `Nothing in ${currentFolder.label} matches \u201C${query.trim()}\u201D.`, theme });
339
+ }
340
+ if (mailbox.syncing) {
341
+ return /* @__PURE__ */ jsx(CenteredState, { icon: "email-sync-outline", title: "Checking for mail\u2026", body: `Fetching the newest mail for ${(_a = account == null ? void 0 : account.email) != null ? _a : "this mailbox"}.`, theme, busy: true });
342
+ }
343
+ return /* @__PURE__ */ jsx(CenteredState, { icon: folder === "inbox" ? "check-circle-outline" : currentFolder.icon, title: currentFolder.emptyText, body: folder === "inbox" ? "Pull down to check for new mail." : void 0, theme, testID: "inbox-empty" });
344
+ };
345
+ const {
346
+ notice,
347
+ undo
348
+ } = mailbox;
349
+ return /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
350
+ backgroundColor: theme.screen
351
+ }], testID: "inbox-panel", children: [
352
+ /* @__PURE__ */ jsx(View, { style: [styles.topBar, {
353
+ paddingTop: insets.top + 4,
354
+ backgroundColor: theme.screen
355
+ }], children: searchOpen ? /* @__PURE__ */ jsxs(View, { style: [styles.searchField, {
356
+ backgroundColor: theme.chip
357
+ }], children: [
358
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "magnify", size: 20, color: theme.muted }),
359
+ /* @__PURE__ */ jsx(TextInput, { value: searchText, onChangeText: (text) => {
360
+ setSearchText(text);
361
+ if (!text.trim()) setQuery("");
362
+ }, onSubmitEditing: () => setQuery(searchText.trim()), placeholder: `Search ${currentFolder.label}`, placeholderTextColor: theme.faint, style: [styles.searchInput, {
363
+ color: theme.ink
364
+ }], returnKeyType: "search", autoFocus: true, autoCorrect: false, autoCapitalize: "none", clearButtonMode: "while-editing", accessibilityLabel: "Search mail", testID: "inbox-search-input" }),
365
+ /* @__PURE__ */ jsx(Pressable, { onPress: closeSearch, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: "Close search", children: /* @__PURE__ */ jsx(Text, { style: [styles.searchCancel, {
366
+ color: theme.accent
367
+ }], children: "Cancel" }) })
368
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
369
+ /* @__PURE__ */ jsx(Tap, { onPress: onExit, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: "Back", style: styles.iconButton, pressedStyle: DIM, testID: "inbox-exit", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 30, color: theme.ink }) }),
370
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => accounts.length > 0 && setPickerOpen(true), disabled: accounts.length === 0, accessibilityRole: "button", accessibilityLabel: account ? `${currentFolder.label}, ${account.email}. Switch mailbox` : "Inbox", style: styles.titleButton, pressedStyle: DIM, testID: "inbox-mailbox-switcher", children: [
371
+ /* @__PURE__ */ jsx(Text, { style: [styles.title, {
372
+ color: theme.ink
373
+ }], numberOfLines: 1, children: account ? currentFolder.label : "Inbox" }),
374
+ account ? /* @__PURE__ */ jsxs(View, { style: styles.mailboxLine, children: [
375
+ /* @__PURE__ */ jsx(Text, { style: [styles.mailboxText, {
376
+ color: theme.muted
377
+ }], numberOfLines: 1, children: mailbox.syncing && mailbox.messages.length > 0 ? "Checking for new mail\u2026" : account.email }),
378
+ accounts.length > 0 ? /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-down", size: 16, color: theme.muted }) : null
379
+ ] }) : null
380
+ ] }),
381
+ account ? /* @__PURE__ */ jsx(Tap, { onPress: () => setSearchOpen(true), hitSlop: 6, accessibilityRole: "button", accessibilityLabel: "Search mail", style: [styles.ghostButton, {
382
+ backgroundColor: theme.chip
383
+ }], pressedStyle: DIM, testID: "inbox-search", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "magnify", size: 20, color: theme.ink }) }) : null,
384
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => {
385
+ setAgentSeed(null);
386
+ setAgentOpen(true);
387
+ }, accessibilityRole: "button", accessibilityLabel: "Open Inbox agent", style: [styles.agentChip, {
388
+ backgroundColor: theme.accentSoft
389
+ }], pressedStyle: DIM, testID: "inbox-agent", children: [
390
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "creation", size: 18, color: theme.accent }),
391
+ /* @__PURE__ */ jsx(Text, { style: [styles.agentLabel, {
392
+ color: theme.accent
393
+ }], children: "Agent" })
394
+ ] })
395
+ ] }) }),
396
+ body != null ? body : /* @__PURE__ */ jsxs(View, { style: styles.fill, children: [
397
+ /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles.folders, style: styles.folderBar, keyboardShouldPersistTaps: "handled", children: MAIL_FOLDERS.map((item) => {
398
+ const selected = item.id === folder;
399
+ return /* @__PURE__ */ jsxs(Pressable, { onPress: () => setFolder(item.id), accessibilityRole: "tab", accessibilityState: {
400
+ selected
401
+ }, accessibilityLabel: item.label, testID: `inbox-folder-${item.id}`, style: [styles.folderChip, {
402
+ backgroundColor: selected ? theme.ink : theme.card,
403
+ borderColor: selected ? theme.ink : theme.border
404
+ }], children: [
405
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: item.icon, size: 15, color: selected ? theme.screen : theme.muted }),
406
+ /* @__PURE__ */ jsx(Text, { style: [styles.folderLabel, {
407
+ color: selected ? theme.screen : theme.ink
408
+ }], children: item.label })
409
+ ] }, item.id);
410
+ }) }),
411
+ (account == null ? void 0 : account.needsReconnect) && reconnectDismissed !== account.id ? /* @__PURE__ */ jsx(NoticeStrip, { tone: "warning", message: `Sign-in for ${account.email} needs attention. Reconnect it to keep mail flowing.`, theme, action: {
412
+ label: "Reconnect",
413
+ onPress: onConnectMailbox
414
+ }, onDismiss: () => setReconnectDismissed(account.id) }) : null,
415
+ notice ? /* @__PURE__ */ jsx(NoticeStrip, { tone: notice.kind === "reconnect" ? "warning" : "info", message: notice.message, theme, action: notice.kind === "reconnect" ? {
416
+ label: "Reconnect",
417
+ onPress: onConnectMailbox
418
+ } : void 0, onDismiss: mailbox.dismissNotice }) : null,
419
+ /* @__PURE__ */ jsx(FlatList, { data: mailbox.messages, keyExtractor: (item) => item.id, renderItem: ({
420
+ item
421
+ }) => /* @__PURE__ */ jsx(MessageRow, { message: item, theme, swipeAction, showRecipient, onOpen: (message) => setOpenMessage(message), onLongPress: (message) => setRowMenu(message), onToggleStar: (message) => void mailbox.setStarred(message.id, !message.starred), onToggleRead: (message) => void mailbox.setRead(message.id, message.unread), onSwipeAction: (message, action) => removeMessage(message, action) }), ListEmptyComponent: listEmpty, ListFooterComponent: mailbox.messages.length > 0 ? /* @__PURE__ */ jsx(ListFooter, { theme, loading: mailbox.phase === "loadingMore", hasMore: mailbox.hasMore, count: mailbox.messages.length, onLoadMore: () => void mailbox.loadMore(), bottomPad: insets.bottom + 88 }) : null, contentContainerStyle: mailbox.messages.length === 0 ? styles.emptyList : void 0, onEndReached: () => void mailbox.loadMore(), onEndReachedThreshold: 0.4, refreshControl: /* @__PURE__ */ jsx(RefreshControl, { refreshing: mailbox.phase === "refreshing", onRefresh: () => void mailbox.refresh(), tintColor: theme.accent, colors: [theme.accent] }), keyboardShouldPersistTaps: "handled", keyboardDismissMode: "on-drag", initialNumToRender: 12, windowSize: 9, testID: "inbox-list" }),
422
+ /* @__PURE__ */ jsxs(Tap, { onPress: () => startCompose("new"), accessibilityRole: "button", accessibilityLabel: "Compose a new message", style: [styles.fab, {
423
+ backgroundColor: theme.accent,
424
+ bottom: insets.bottom + 20
425
+ }], pressedStyle: styles.fabPressed, testID: "inbox-compose-button", children: [
426
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "pencil-outline", size: 20, color: theme.accentInk }),
427
+ /* @__PURE__ */ jsx(Text, { style: [styles.fabLabel, {
428
+ color: theme.accentInk
429
+ }], children: "Compose" })
430
+ ] })
431
+ ] }),
432
+ openMessage && account ? /* @__PURE__ */ jsx(View, { style: StyleSheet.absoluteFill, children: /* @__PURE__ */ jsx(MessageReader, { summary: openMessage, detail: reader.detail, loading: reader.loading, error: reader.error, attachments: reader.attachments, folder, ownAddress: account.email, theme, downloadingIndex, onBack: () => setOpenMessage(null), onRetry: () => void reader.retry(), onRetryAttachments: () => void reader.retryAttachments(), onOpenAttachment: (attachment) => void downloadAttachment(attachment), onArchive: canArchive(folder) ? () => removeMessage(openMessage, "archive") : void 0, onTrash: canTrash(folder) ? () => removeMessage(openMessage, "trash") : void 0, onSpam: canSpam(folder) ? () => removeMessage(openMessage, "spam") : void 0, onToggleUnread: () => {
433
+ var _a;
434
+ const unread = !((_a = reader.detail) != null ? _a : openMessage).unread;
435
+ reader.patchDetail({
436
+ unread
437
+ });
438
+ void mailbox.setRead(openMessage.id, !unread);
439
+ if (unread) setOpenMessage(null);
440
+ }, onToggleStar: () => {
441
+ var _a;
442
+ const starred = !((_a = reader.detail) != null ? _a : openMessage).starred;
443
+ reader.patchDetail({
444
+ starred
445
+ });
446
+ setOpenMessage(__spreadProps(__spreadValues({}, openMessage), {
447
+ starred
448
+ }));
449
+ void mailbox.setStarred(openMessage.id, starred);
450
+ }, onCompose: (mode) => startCompose(mode, openMessage), onAskYantra: () => {
451
+ var _a;
452
+ const ref = messageReference((_a = reader.detail) != null ? _a : __spreadValues({}, openMessage));
453
+ askYantra(`Help me reply to ${ref}. Draft a reply in my tone and show it to me before sending.`);
454
+ }, onReconnect: onConnectMailbox }) }) : null,
455
+ undo || toast ? /* @__PURE__ */ jsx(Toast, { message: undo ? REMOVED_LABEL[undo.kind] : toast != null ? toast : "", theme, action: undo ? {
456
+ label: "Undo",
457
+ onPress: mailbox.undoRemove
458
+ } : void 0, bottom: insets.bottom + (openMessage ? 72 : 84) }) : null,
459
+ compose && account ? /* @__PURE__ */ jsx(ComposeSheet, { initial: compose, fromAddress: account.email, theme, onSend: sendDraft, onClose: () => setCompose(null) }) : null,
460
+ /* @__PURE__ */ jsxs(BottomSheet, { visible: pickerOpen, title: "Mailboxes", theme, onClose: () => setPickerOpen(false), children: [
461
+ accounts.map((item) => /* @__PURE__ */ jsx(SheetRow, { icon: "email-outline", label: item.email, detail: item.needsReconnect ? "Needs reconnecting" : providerName(item.provider), selected: item.id === (account == null ? void 0 : account.id), onPress: () => chooseAccount(item), theme, testID: `inbox-mailbox-${item.id}` }, item.id)),
462
+ /* @__PURE__ */ jsx(SheetRow, { icon: "plus", label: "Connect another mailbox", onPress: () => {
463
+ setPickerOpen(false);
464
+ onConnectMailbox();
465
+ }, theme })
466
+ ] }),
467
+ /* @__PURE__ */ jsx(RowMenu, { message: rowMenu, folder, theme, onClose: () => setRowMenu(null), onRead: (message) => void mailbox.setRead(message.id, message.unread), onStar: (message) => void mailbox.setStarred(message.id, !message.starred), onRemove: removeMessage, onReply: (message) => {
468
+ setOpenMessage(message);
469
+ startCompose("reply", message);
470
+ }, onAsk: (message) => askYantra(`Tell me what ${messageReference(__spreadValues({}, message))} is about and whether it needs a reply.`) }),
471
+ /* @__PURE__ */ jsx(InboxAgentChatPane, { visible: agentOpen, onClose: () => {
472
+ setAgentOpen(false);
473
+ setAgentSeed(null);
474
+ }, hostChat, account, orgName, seed: agentSeed, theme })
475
+ ] });
476
+ }
477
+ const styles = StyleSheet.create({
478
+ fill: {
479
+ flex: 1
480
+ },
481
+ loading: {
482
+ flex: 1,
483
+ alignItems: "center",
484
+ justifyContent: "center"
485
+ },
486
+ topBar: {
487
+ flexDirection: "row",
488
+ alignItems: "center",
489
+ gap: 8,
490
+ paddingLeft: 4,
491
+ paddingRight: 12,
492
+ paddingBottom: 8,
493
+ minHeight: 52
494
+ },
495
+ iconButton: {
496
+ width: 40,
497
+ height: 44,
498
+ alignItems: "center",
499
+ justifyContent: "center"
500
+ },
501
+ // Title block and search field share one height, so opening search never shifts the folders.
502
+ titleButton: {
503
+ flex: 1,
504
+ minWidth: 0,
505
+ height: TOP_ROW_HEIGHT,
506
+ justifyContent: "center"
507
+ },
508
+ title: {
509
+ fontSize: 22,
510
+ fontWeight: "700",
511
+ letterSpacing: -0.3
512
+ },
513
+ mailboxLine: {
514
+ flexDirection: "row",
515
+ alignItems: "center",
516
+ gap: 2,
517
+ marginTop: 1
518
+ },
519
+ mailboxText: {
520
+ flexShrink: 1,
521
+ fontSize: 13
522
+ },
523
+ ghostButton: {
524
+ width: 38,
525
+ height: 38,
526
+ borderRadius: 19,
527
+ alignItems: "center",
528
+ justifyContent: "center"
529
+ },
530
+ agentChip: {
531
+ flexDirection: "row",
532
+ alignItems: "center",
533
+ gap: 6,
534
+ height: 38,
535
+ paddingHorizontal: 12,
536
+ borderRadius: 19
537
+ },
538
+ agentLabel: {
539
+ fontSize: 14,
540
+ fontWeight: "600"
541
+ },
542
+ searchField: {
543
+ flex: 1,
544
+ flexDirection: "row",
545
+ alignItems: "center",
546
+ gap: 8,
547
+ height: 40,
548
+ marginVertical: (TOP_ROW_HEIGHT - 40) / 2,
549
+ marginLeft: 8,
550
+ paddingLeft: 12,
551
+ paddingRight: 12,
552
+ borderRadius: 12
553
+ },
554
+ searchInput: {
555
+ flex: 1,
556
+ fontSize: 16,
557
+ paddingVertical: 0
558
+ },
559
+ searchCancel: {
560
+ fontSize: 15,
561
+ fontWeight: "500"
562
+ },
563
+ folderBar: {
564
+ flexGrow: 0
565
+ },
566
+ folders: {
567
+ paddingHorizontal: 12,
568
+ paddingBottom: 10,
569
+ gap: 8
570
+ },
571
+ folderChip: {
572
+ flexDirection: "row",
573
+ alignItems: "center",
574
+ gap: 6,
575
+ height: 32,
576
+ paddingHorizontal: 12,
577
+ borderRadius: 16,
578
+ borderWidth: StyleSheet.hairlineWidth
579
+ },
580
+ folderLabel: {
581
+ fontSize: 13,
582
+ fontWeight: "600"
583
+ },
584
+ listState: {
585
+ flex: 1,
586
+ alignItems: "center",
587
+ justifyContent: "center",
588
+ paddingVertical: 48
589
+ },
590
+ emptyList: {
591
+ flexGrow: 1
592
+ },
593
+ footer: {
594
+ alignItems: "center",
595
+ paddingTop: 16
596
+ },
597
+ footerAction: {
598
+ fontSize: 14,
599
+ fontWeight: "600"
600
+ },
601
+ footerText: {
602
+ fontSize: 12
603
+ },
604
+ fab: {
605
+ position: "absolute",
606
+ right: 16,
607
+ flexDirection: "row",
608
+ alignItems: "center",
609
+ gap: 8,
610
+ height: 52,
611
+ paddingHorizontal: 20,
612
+ borderRadius: 26,
613
+ shadowColor: "#000",
614
+ shadowOpacity: 0.2,
615
+ shadowRadius: 10,
616
+ shadowOffset: {
617
+ width: 0,
618
+ height: 4
619
+ },
620
+ elevation: 6
621
+ },
622
+ fabPressed: {
623
+ transform: [{
624
+ scale: 0.97
625
+ }]
626
+ },
627
+ fabLabel: {
628
+ fontSize: 15,
629
+ fontWeight: "600"
630
+ }
631
+ });export{InboxExperience,InboxExperience as default};//# sourceMappingURL=InboxExperience.js.map