@adminide-stack/yantra-mobile 12.0.94 → 12.0.95-alpha.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.
Files changed (125) 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/videoEditor/remoteMediaClient.js +51 -24
  16. package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
  17. package/lib/features/chat/connectorConnect.js +1 -1
  18. package/lib/features/inbox/InboxAgentChatPane.js +64 -0
  19. package/lib/features/inbox/InboxAgentChatPane.js.map +1 -0
  20. package/lib/features/inbox/InboxExperience.js +631 -0
  21. package/lib/features/inbox/InboxExperience.js.map +1 -0
  22. package/lib/features/inbox/components/BottomSheet.js +111 -0
  23. package/lib/features/inbox/components/BottomSheet.js.map +1 -0
  24. package/lib/features/inbox/components/ComposeSheet.js +298 -0
  25. package/lib/features/inbox/components/ComposeSheet.js.map +1 -0
  26. package/lib/features/inbox/components/InboxStates.js +182 -0
  27. package/lib/features/inbox/components/InboxStates.js.map +1 -0
  28. package/lib/features/inbox/components/MailBody.js +103 -0
  29. package/lib/features/inbox/components/MailBody.js.map +1 -0
  30. package/lib/features/inbox/components/MessageReader.js +396 -0
  31. package/lib/features/inbox/components/MessageReader.js.map +1 -0
  32. package/lib/features/inbox/components/MessageRow.js +153 -0
  33. package/lib/features/inbox/components/MessageRow.js.map +1 -0
  34. package/lib/features/inbox/components/SenderAvatar.js +24 -0
  35. package/lib/features/inbox/components/SenderAvatar.js.map +1 -0
  36. package/lib/features/inbox/components/Tap.js +55 -0
  37. package/lib/features/inbox/components/Tap.js.map +1 -0
  38. package/lib/features/inbox/composeDraft.js +89 -0
  39. package/lib/features/inbox/composeDraft.js.map +1 -0
  40. package/lib/features/inbox/formatMailDate.js +60 -0
  41. package/lib/features/inbox/formatMailDate.js.map +1 -0
  42. package/lib/features/inbox/inboxAccounts.js +110 -0
  43. package/lib/features/inbox/inboxAccounts.js.map +1 -0
  44. package/lib/features/inbox/inboxClient.js +293 -0
  45. package/lib/features/inbox/inboxClient.js.map +1 -0
  46. package/lib/features/inbox/inboxContext.js +27 -0
  47. package/lib/features/inbox/inboxContext.js.map +1 -0
  48. package/lib/features/inbox/inboxFolders.js +47 -0
  49. package/lib/features/inbox/inboxFolders.js.map +1 -0
  50. package/lib/features/inbox/inboxNormalize.js +144 -0
  51. package/lib/features/inbox/inboxNormalize.js.map +1 -0
  52. package/lib/features/inbox/inboxPreference.js +20 -0
  53. package/lib/features/inbox/inboxPreference.js.map +1 -0
  54. package/lib/features/inbox/inboxTheme.js +54 -0
  55. package/lib/features/inbox/inboxTheme.js.map +1 -0
  56. package/lib/features/inbox/nativeInboxRegistry.js +15 -0
  57. package/lib/features/inbox/nativeInboxRegistry.js.map +1 -0
  58. package/lib/features/inbox/openAttachment.js +43 -0
  59. package/lib/features/inbox/openAttachment.js.map +1 -0
  60. package/lib/features/inbox/useInboxMailbox.js +250 -0
  61. package/lib/features/inbox/useInboxMailbox.js.map +1 -0
  62. package/lib/features/inbox/useMailMessage.js +101 -0
  63. package/lib/features/inbox/useMailMessage.js.map +1 -0
  64. package/lib/features/study/StudyAgentChatPane.js +67 -0
  65. package/lib/features/study/StudyAgentChatPane.js.map +1 -0
  66. package/lib/features/study/StudyExperience.js +586 -0
  67. package/lib/features/study/StudyExperience.js.map +1 -0
  68. package/lib/features/study/components/CellView.js +133 -0
  69. package/lib/features/study/components/CellView.js.map +1 -0
  70. package/lib/features/study/components/IntakeCard.js +203 -0
  71. package/lib/features/study/components/IntakeCard.js.map +1 -0
  72. package/lib/features/study/components/NotebookSwitcher.js +74 -0
  73. package/lib/features/study/components/NotebookSwitcher.js.map +1 -0
  74. package/lib/features/study/components/SourceStrip.js +69 -0
  75. package/lib/features/study/components/SourceStrip.js.map +1 -0
  76. package/lib/features/study/components/StudyComposer.js +118 -0
  77. package/lib/features/study/components/StudyComposer.js.map +1 -0
  78. package/lib/features/study/components/StudyOnboarding.js +477 -0
  79. package/lib/features/study/components/StudyOnboarding.js.map +1 -0
  80. package/lib/features/study/components/StudySheet.js +120 -0
  81. package/lib/features/study/components/StudySheet.js.map +1 -0
  82. package/lib/features/study/components/StudyStates.js +148 -0
  83. package/lib/features/study/components/StudyStates.js.map +1 -0
  84. package/lib/features/study/components/TextEntrySheet.js +111 -0
  85. package/lib/features/study/components/TextEntrySheet.js.map +1 -0
  86. package/lib/features/study/nativeStudyRegistry.js +15 -0
  87. package/lib/features/study/nativeStudyRegistry.js.map +1 -0
  88. package/lib/features/study/shareExport.js +38 -0
  89. package/lib/features/study/shareExport.js.map +1 -0
  90. package/lib/features/study/studyClient.js +278 -0
  91. package/lib/features/study/studyClient.js.map +1 -0
  92. package/lib/features/study/studyContext.js +25 -0
  93. package/lib/features/study/studyContext.js.map +1 -0
  94. package/lib/features/study/studyFiles.js +140 -0
  95. package/lib/features/study/studyFiles.js.map +1 -0
  96. package/lib/features/study/studyNormalize.js +116 -0
  97. package/lib/features/study/studyNormalize.js.map +1 -0
  98. package/lib/features/study/studyPreference.js +24 -0
  99. package/lib/features/study/studyPreference.js.map +1 -0
  100. package/lib/features/study/studyProfile.js +233 -0
  101. package/lib/features/study/studyProfile.js.map +1 -0
  102. package/lib/features/study/studyPrompts.js +78 -0
  103. package/lib/features/study/studyPrompts.js.map +1 -0
  104. package/lib/features/study/studyTheme.js +47 -0
  105. package/lib/features/study/studyTheme.js.map +1 -0
  106. package/lib/features/study/useStudyWorkspace.js +401 -0
  107. package/lib/features/study/useStudyWorkspace.js.map +1 -0
  108. package/lib/index.js +1 -1
  109. package/lib/index.js.map +1 -1
  110. package/lib/routes.json +108 -0
  111. package/lib/screens/InboxNative/index.js +77 -0
  112. package/lib/screens/InboxNative/index.js.map +1 -0
  113. package/lib/screens/InboxNative/useConnectMailbox.js +42 -0
  114. package/lib/screens/InboxNative/useConnectMailbox.js.map +1 -0
  115. package/lib/screens/InboxNative/useInboxHostChat.js +62 -0
  116. package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -0
  117. package/lib/screens/InboxNative/useMailAccounts.js +54 -0
  118. package/lib/screens/InboxNative/useMailAccounts.js.map +1 -0
  119. package/lib/screens/StudyNative/index.js +80 -0
  120. package/lib/screens/StudyNative/index.js.map +1 -0
  121. package/lib/screens/StudyNative/useStudyHostChat.js +62 -0
  122. package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -0
  123. package/lib/utils/authUserDisplay.js +11 -1
  124. package/lib/utils/authUserDisplay.js.map +1 -1
  125. package/package.json +4 -4
@@ -0,0 +1,24 @@
1
+ import {jsx}from'react/jsx-runtime';import {StyleSheet,View,Text}from'react-native';import {senderAvatarColor,senderInitials}from'../inboxTheme.js';function SenderAvatar({
2
+ label,
3
+ seed,
4
+ size = 40
5
+ }) {
6
+ return /* @__PURE__ */ jsx(View, { style: [styles.avatar, {
7
+ width: size,
8
+ height: size,
9
+ borderRadius: size / 2,
10
+ backgroundColor: senderAvatarColor(seed || label)
11
+ }], accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: /* @__PURE__ */ jsx(Text, { style: [styles.initials, {
12
+ fontSize: Math.round(size * 0.4)
13
+ }], children: senderInitials(label) }) });
14
+ }
15
+ const styles = StyleSheet.create({
16
+ avatar: {
17
+ alignItems: "center",
18
+ justifyContent: "center"
19
+ },
20
+ initials: {
21
+ color: "#ffffff",
22
+ fontWeight: "600"
23
+ }
24
+ });export{SenderAvatar};//# sourceMappingURL=SenderAvatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SenderAvatar.js","sources":["../../../../src/features/inbox/components/SenderAvatar.tsx"],"sourcesContent":["import React from 'react';\nimport { StyleSheet, Text, View } from 'react-native';\nimport { senderAvatarColor, senderInitials } from '../inboxTheme';\n\nexport function SenderAvatar({ label, seed, size = 40 }: { label: string; seed: string; size?: number }) {\n return (\n <View\n style={[\n styles.avatar,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor: senderAvatarColor(seed || label),\n },\n ]}\n accessibilityElementsHidden\n importantForAccessibility=\"no-hide-descendants\"\n >\n <Text style={[styles.initials, { fontSize: Math.round(size * 0.4) }]}>{senderInitials(label)}</Text>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n avatar: { alignItems: 'center', justifyContent: 'center' },\n initials: { color: '#ffffff', fontWeight: '600' },\n});\n"],"names":[],"mappings":"oJAGO,SAAS,YAAa,CAAA;AAAA,EAC3B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA;AACT,CAIG,EAAA;AACD,EAAA,uBAAQ,GAAA,CAAA,IAAA,EAAA,EAAK,KAAO,EAAA,CAAC,OAAO,MAAQ,EAAA;AAAA,IAClC,KAAO,EAAA,IAAA;AAAA,IACP,MAAQ,EAAA,IAAA;AAAA,IACR,cAAc,IAAO,GAAA,CAAA;AAAA,IACrB,eAAA,EAAiB,iBAAkB,CAAA,IAAA,IAAQ,KAAK;AAAA,GACjD,CAAG,EAAA,2BAAA,EAA2B,IAAC,EAAA,yBAAA,EAA0B,qBAChD,EAAA,QAAA,kBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,KAAA,EAAO,CAAC,MAAA,CAAO,QAAU,EAAA;AAAA,IACrC,QAAU,EAAA,IAAA,CAAK,KAAM,CAAA,IAAA,GAAO,GAAG;AAAA,GAChC,CAAA,EAAI,QAAe,EAAA,cAAA,CAAA,KAAK,GAAE,CACvB,EAAA,CAAA;AACR;AACA,MAAM,MAAA,GAAS,WAAW,MAAO,CAAA;AAAA,EAC/B,MAAQ,EAAA;AAAA,IACN,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,SAAA;AAAA,IACP,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
@@ -0,0 +1,55 @@
1
+ import {jsx}from'react/jsx-runtime';import {useState}from'react';import {Pressable}from'react-native';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
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ function Tap(_a) {
33
+ var _b = _a, {
34
+ style,
35
+ pressedStyle,
36
+ onPressIn,
37
+ onPressOut
38
+ } = _b, rest = __objRest(_b, [
39
+ "style",
40
+ "pressedStyle",
41
+ "onPressIn",
42
+ "onPressOut"
43
+ ]);
44
+ const [pressed, setPressed] = useState(false);
45
+ return /* @__PURE__ */ jsx(Pressable, __spreadProps(__spreadValues({}, rest), { onPressIn: (event) => {
46
+ setPressed(true);
47
+ onPressIn == null ? void 0 : onPressIn(event);
48
+ }, onPressOut: (event) => {
49
+ setPressed(false);
50
+ onPressOut == null ? void 0 : onPressOut(event);
51
+ }, style: [style, pressed ? pressedStyle : null] }));
52
+ }
53
+ const DIM = {
54
+ opacity: 0.55
55
+ };export{DIM,Tap};//# sourceMappingURL=Tap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tap.js","sources":["../../../../src/features/inbox/components/Tap.tsx"],"sourcesContent":["/**\n * A Pressable with press feedback that only ever passes a STATIC style.\n *\n * NativeWind's css-interop wraps Pressable, and in the lazily loaded native\n * experiences a function `style={({ pressed }) => …}` is dropped entirely: the\n * button renders with no size, padding or fill. Tracking the pressed state here\n * keeps the feedback without the style callback.\n */\nimport React, { useState } from 'react';\nimport { Pressable, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';\n\nexport type TapProps = Omit<PressableProps, 'style'> & {\n style?: StyleProp<ViewStyle>;\n /** Added on top of `style` while a finger is down. */\n pressedStyle?: StyleProp<ViewStyle>;\n};\n\nexport function Tap({ style, pressedStyle, onPressIn, onPressOut, ...rest }: TapProps) {\n const [pressed, setPressed] = useState(false);\n return (\n <Pressable\n {...rest}\n onPressIn={(event) => {\n setPressed(true);\n onPressIn?.(event);\n }}\n onPressOut={(event) => {\n setPressed(false);\n onPressOut?.(event);\n }}\n style={[style, pressed ? pressedStyle : null]}\n />\n );\n}\n\n/** The default feedback for icon and text buttons. */\nexport const DIM = { opacity: 0.55 } as const;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,IAAI,EAMP,EAAA;AANO,EAClB,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GAnBF,GAeoB,EAKf,EAAA,IAAA,GAAA,SAAA,CALe,EAKf,EAAA;AAAA,IAJH,OAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GAAA,CAAA;AAGA,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,uBAAQ,GAAA,CAAA,SAAA,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAc,IAAd,CAAA,EAAA,EAAoB,WAAW,CAAS,KAAA,KAAA;AAC9C,IAAA,UAAA,CAAW,IAAI,CAAA;AACf,IAAY,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,KAAA,CAAA;AAAA,GACd,EAAG,YAAY,CAAS,KAAA,KAAA;AACtB,IAAA,UAAA,CAAW,KAAK,CAAA;AAChB,IAAa,UAAA,IAAA,IAAA,GAAA,MAAA,GAAA,UAAA,CAAA,KAAA,CAAA;AAAA,KACZ,KAAO,EAAA,CAAC,OAAO,OAAU,GAAA,YAAA,GAAe,IAAI,CAAG,EAAA,CAAA,CAAA;AACpD;AAGO,MAAM,GAAM,GAAA;AAAA,EACjB,OAAS,EAAA;AACX"}
@@ -0,0 +1,89 @@
1
+ import {splitAddressList,parseMailAddress}from'./inboxNormalize.js';function prefixed(subject, prefix) {
2
+ const clean = subject.trim() || "(no subject)";
3
+ return new RegExp(`^${prefix}:`, "i").test(clean) ? clean : `${prefix}: ${clean}`;
4
+ }
5
+ function formatAddress(name, address) {
6
+ return name ? `${name} <${address}>` : address;
7
+ }
8
+ function replyAllCc(source, ownAddress) {
9
+ var _a;
10
+ const own = ownAddress.trim().toLowerCase();
11
+ const sender = source.from.address.toLowerCase();
12
+ const seen = /* @__PURE__ */ new Set();
13
+ const out = [];
14
+ for (const raw of [...splitAddressList(source.to), ...splitAddressList((_a = source.cc) != null ? _a : "")]) {
15
+ const parsed = parseMailAddress(raw);
16
+ const key = parsed.address.toLowerCase();
17
+ if (!key || key === own || key === sender || seen.has(key)) continue;
18
+ seen.add(key);
19
+ out.push(formatAddress(parsed.name, parsed.address));
20
+ }
21
+ return out.join(", ");
22
+ }
23
+ function draftFor(mode, source, ownAddress) {
24
+ if (!source || mode === "new") return {
25
+ mode: "new",
26
+ to: "",
27
+ cc: "",
28
+ subject: "",
29
+ body: ""
30
+ };
31
+ if (mode === "forward") {
32
+ return {
33
+ mode,
34
+ source,
35
+ to: "",
36
+ cc: "",
37
+ subject: prefixed(source.subject, "Fwd"),
38
+ body: ""
39
+ };
40
+ }
41
+ return {
42
+ mode,
43
+ source,
44
+ to: formatAddress(source.from.name, source.from.address),
45
+ cc: mode === "replyAll" ? replyAllCc(source, ownAddress) : "",
46
+ subject: prefixed(source.subject, "Re"),
47
+ body: ""
48
+ };
49
+ }
50
+ const EMAIL = /^[^\s@<>(),;:"]+@[^\s@<>(),;:"]+\.[^\s@<>(),;:"]+$/;
51
+ function parseRecipients(line) {
52
+ const addresses = [];
53
+ const invalid = [];
54
+ for (const part of splitAddressList(line)) {
55
+ const parsed = parseMailAddress(part);
56
+ if (parsed.address && EMAIL.test(parsed.address)) addresses.push(parsed.address);
57
+ else invalid.push(part);
58
+ }
59
+ return {
60
+ addresses,
61
+ invalid
62
+ };
63
+ }
64
+ function draftProblem(draft) {
65
+ const cc = parseRecipients(draft.cc);
66
+ if (draft.mode === "new" || draft.mode === "forward") {
67
+ const to = parseRecipients(draft.to);
68
+ if (to.invalid.length) return {
69
+ field: "to",
70
+ message: `"${to.invalid[0]}" is not an email address.`
71
+ };
72
+ if (!to.addresses.length) return {
73
+ field: "to",
74
+ message: "Add at least one recipient."
75
+ };
76
+ }
77
+ if (cc.invalid.length) return {
78
+ field: "cc",
79
+ message: `"${cc.invalid[0]}" is not an email address.`
80
+ };
81
+ if (draft.mode !== "forward" && !draft.body.trim()) return {
82
+ field: "body",
83
+ message: "Write a message first."
84
+ };
85
+ return null;
86
+ }
87
+ function draftHasWork(draft, initial) {
88
+ return draft.body.trim().length > 0 || draft.to.trim() !== initial.to.trim() || draft.cc.trim() !== initial.cc.trim() || draft.subject.trim() !== initial.subject.trim();
89
+ }export{draftFor,draftHasWork,draftProblem,parseRecipients,replyAllCc};//# sourceMappingURL=composeDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composeDraft.js","sources":["../../../src/features/inbox/composeDraft.ts"],"sourcesContent":["/**\n * Compose prefill and validation, kept out of the sheet so it is testable.\n *\n * Replies go through YANTRA_MAILER_REPLY_MESSAGE, which addresses and threads the\n * reply from the stored original itself; the To line on a reply is shown for\n * the user, not sent. A forward and a new message need recipients typed in.\n */\nimport { splitAddressList, parseMailAddress } from './inboxNormalize';\nimport type { ComposeDraft, ComposeMode, MailMessageDetail } from './types';\n\nfunction prefixed(subject: string, prefix: 'Re' | 'Fwd'): string {\n const clean = subject.trim() || '(no subject)';\n return new RegExp(`^${prefix}:`, 'i').test(clean) ? clean : `${prefix}: ${clean}`;\n}\n\nfunction formatAddress(name: string, address: string): string {\n return name ? `${name} <${address}>` : address;\n}\n\n/** Everyone on the original except the sender and this mailbox: the reply-all Cc line. */\nexport function replyAllCc(source: MailMessageDetail, ownAddress: string): string {\n const own = ownAddress.trim().toLowerCase();\n const sender = source.from.address.toLowerCase();\n const seen = new Set<string>();\n const out: string[] = [];\n for (const raw of [...splitAddressList(source.to), ...splitAddressList(source.cc ?? '')]) {\n const parsed = parseMailAddress(raw);\n const key = parsed.address.toLowerCase();\n if (!key || key === own || key === sender || seen.has(key)) continue;\n seen.add(key);\n out.push(formatAddress(parsed.name, parsed.address));\n }\n return out.join(', ');\n}\n\nexport function draftFor(mode: ComposeMode, source: MailMessageDetail | undefined, ownAddress: string): ComposeDraft {\n if (!source || mode === 'new') return { mode: 'new', to: '', cc: '', subject: '', body: '' };\n if (mode === 'forward') {\n return { mode, source, to: '', cc: '', subject: prefixed(source.subject, 'Fwd'), body: '' };\n }\n return {\n mode,\n source,\n to: formatAddress(source.from.name, source.from.address),\n cc: mode === 'replyAll' ? replyAllCc(source, ownAddress) : '',\n subject: prefixed(source.subject, 'Re'),\n body: '',\n };\n}\n\nconst EMAIL = /^[^\\s@<>(),;:\"]+@[^\\s@<>(),;:\"]+\\.[^\\s@<>(),;:\"]+$/;\n\n/** Bare addresses from a typed line (`Jane <j@x.com>, k@y.com`); `invalid` lists what is not an address. */\nexport function parseRecipients(line: string): { addresses: string[]; invalid: string[] } {\n const addresses: string[] = [];\n const invalid: string[] = [];\n for (const part of splitAddressList(line)) {\n const parsed = parseMailAddress(part);\n if (parsed.address && EMAIL.test(parsed.address)) addresses.push(parsed.address);\n else invalid.push(part);\n }\n return { addresses, invalid };\n}\n\nexport interface DraftProblem {\n field: 'to' | 'cc' | 'body';\n message: string;\n}\n\n/** What stops this draft from sending, or null when it can go. */\nexport function draftProblem(draft: ComposeDraft): DraftProblem | null {\n const cc = parseRecipients(draft.cc);\n if (draft.mode === 'new' || draft.mode === 'forward') {\n const to = parseRecipients(draft.to);\n if (to.invalid.length) return { field: 'to', message: `\"${to.invalid[0]}\" is not an email address.` };\n if (!to.addresses.length) return { field: 'to', message: 'Add at least one recipient.' };\n }\n if (cc.invalid.length) return { field: 'cc', message: `\"${cc.invalid[0]}\" is not an email address.` };\n if (draft.mode !== 'forward' && !draft.body.trim()) return { field: 'body', message: 'Write a message first.' };\n return null;\n}\n\n/** Anything the user typed that closing the sheet would throw away. */\nexport function draftHasWork(draft: ComposeDraft, initial: ComposeDraft): boolean {\n return (\n draft.body.trim().length > 0 ||\n draft.to.trim() !== initial.to.trim() ||\n draft.cc.trim() !== initial.cc.trim() ||\n draft.subject.trim() !== initial.subject.trim()\n );\n}\n"],"names":[],"mappings":"oEASA,SAAS,QAAA,CAAS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IAAA;AACT;AAGgB,SAAA,YAAA,CAAa,OAAqB,OAAgC,EAAA;AAChF,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,IAAK,EAAA,CAAE,MAAS,GAAA,CAAA,IAAK,KAAM,CAAA,EAAA,CAAG,IAAK,EAAA,KAAM,OAAQ,CAAA,EAAA,CAAG,IAAK,EAAA,IAAK,KAAM,CAAA,EAAA,CAAG,IAAK,EAAA,KAAM,OAAQ,CAAA,EAAA,CAAG,IAAK,EAAA,IAAK,KAAM,CAAA,OAAA,CAAQ,IAAK,EAAA,KAAM,OAAQ,CAAA,OAAA,CAAQ,IAAK,EAAA;AACzK"}
@@ -0,0 +1,60 @@
1
+ const DAY_MS = 864e5;
2
+ function startOfDay(date) {
3
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
4
+ }
5
+ function formatMailListDate(iso, now = /* @__PURE__ */ new Date()) {
6
+ if (!iso) return "";
7
+ const date = new Date(iso);
8
+ if (Number.isNaN(date.getTime())) return "";
9
+ const days = Math.round((startOfDay(now) - startOfDay(date)) / DAY_MS);
10
+ if (days <= 0) return date.toLocaleTimeString(void 0, {
11
+ hour: "numeric",
12
+ minute: "2-digit"
13
+ });
14
+ if (days === 1) return "Yesterday";
15
+ if (days < 7) return date.toLocaleDateString(void 0, {
16
+ weekday: "short"
17
+ });
18
+ if (date.getFullYear() === now.getFullYear()) {
19
+ return date.toLocaleDateString(void 0, {
20
+ month: "short",
21
+ day: "numeric"
22
+ });
23
+ }
24
+ return date.toLocaleDateString(void 0, {
25
+ year: "numeric",
26
+ month: "short",
27
+ day: "numeric"
28
+ });
29
+ }
30
+ function formatMailHeaderDate(iso, now = /* @__PURE__ */ new Date()) {
31
+ if (!iso) return "";
32
+ const date = new Date(iso);
33
+ if (Number.isNaN(date.getTime())) return "";
34
+ if (date.getFullYear() !== now.getFullYear()) {
35
+ return date.toLocaleDateString(void 0, {
36
+ year: "numeric",
37
+ month: "short",
38
+ day: "numeric"
39
+ });
40
+ }
41
+ return date.toLocaleString(void 0, {
42
+ month: "short",
43
+ day: "numeric",
44
+ hour: "numeric",
45
+ minute: "2-digit"
46
+ });
47
+ }
48
+ function formatMailFullDate(iso) {
49
+ if (!iso) return "";
50
+ const date = new Date(iso);
51
+ if (Number.isNaN(date.getTime())) return "";
52
+ return date.toLocaleString(void 0, {
53
+ weekday: "short",
54
+ year: "numeric",
55
+ month: "short",
56
+ day: "numeric",
57
+ hour: "numeric",
58
+ minute: "2-digit"
59
+ });
60
+ }export{formatMailFullDate,formatMailHeaderDate,formatMailListDate};//# sourceMappingURL=formatMailDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatMailDate.js","sources":["../../../src/features/inbox/formatMailDate.ts"],"sourcesContent":["/**\n * List timestamps the way mail apps show them: the time for today, the weekday\n * within the last week, the month and day this year, and the full date before.\n */\nconst DAY_MS = 86_400_000;\n\nfunction startOfDay(date: Date): number {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();\n}\n\nexport function formatMailListDate(iso: string | undefined, now: Date = new Date()): string {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n const days = Math.round((startOfDay(now) - startOfDay(date)) / DAY_MS);\n if (days <= 0) return date.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });\n if (days === 1) return 'Yesterday';\n if (days < 7) return date.toLocaleDateString(undefined, { weekday: 'short' });\n if (date.getFullYear() === now.getFullYear()) {\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n }\n return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });\n}\n\n/** The reader's sender line: `Oct 10, 9:41 AM` this year, `Oct 10, 2025` before. */\nexport function formatMailHeaderDate(iso: string | undefined, now: Date = new Date()): string {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n if (date.getFullYear() !== now.getFullYear()) {\n return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });\n }\n return date.toLocaleString(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });\n}\n\n/** The reader's full timestamp: `Fri, Oct 10, 2026, 9:41 AM`. */\nexport function formatMailFullDate(iso: string | undefined): string {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n return date.toLocaleString(undefined, {\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n });\n}\n"],"names":[],"mappings":"AAIA,MAAM,MAAS,GAAA,KAAA;AACf,SAAS,WAAW,IAAoB,EAAA;AACtC,EAAA,OAAO,IAAI,IAAA,CAAK,IAAK,CAAA,WAAA,EAAe,EAAA,IAAA,CAAK,QAAS,EAAA,EAAG,IAAK,CAAA,OAAA,EAAS,CAAA,CAAE,OAAQ,EAAA;AAC/E;AACO,SAAS,kBAAmB,CAAA,GAAA,EAAyB,GAAY,mBAAA,IAAI,MAAgB,EAAA;AAC1F,EAAI,IAAA,CAAC,KAAY,OAAA,EAAA;AACjB,EAAM,MAAA,IAAA,GAAO,IAAI,IAAA,CAAK,GAAG,CAAA;AACzB,EAAA,IAAI,OAAO,KAAM,CAAA,IAAA,CAAK,OAAQ,EAAC,GAAU,OAAA,EAAA;AACzC,EAAM,MAAA,IAAA,GAAO,KAAK,KAAO,CAAA,CAAA,UAAA,CAAW,GAAG,CAAI,GAAA,UAAA,CAAW,IAAI,CAAA,IAAK,MAAM,CAAA;AACrE,EAAA,IAAI,IAAQ,IAAA,CAAA,EAAU,OAAA,IAAA,CAAK,mBAAmB,MAAW,EAAA;AAAA,IACvD,IAAM,EAAA,SAAA;AAAA,IACN,MAAQ,EAAA;AAAA,GACT,CAAA;AACD,EAAI,IAAA,IAAA,KAAS,GAAU,OAAA,WAAA;AACvB,EAAA,IAAI,IAAO,GAAA,CAAA,EAAU,OAAA,IAAA,CAAK,mBAAmB,MAAW,EAAA;AAAA,IACtD,OAAS,EAAA;AAAA,GACV,C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A,EAAA;AACzC,EAAO,OAAA,IAAA,CAAK,eAAe,MAAW,EAAA;AAAA,IACpC,OAAS,EAAA,OAAA;AAAA,IACT,IAAM,EAAA,SAAA;AAAA,IACN,KAAO,EAAA,OAAA;AAAA,IACP,GAAK,EAAA,SAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,MAAQ,EAAA;AAAA,GACT,CAAA;AACH"}
@@ -0,0 +1,110 @@
1
+ const MAILER_CONNECTOR = "yantra-mailer";
2
+ const LEGACY_CONNECTORS = {
3
+ "google-gmail": {
4
+ label: "Gmail",
5
+ aliases: ["gmail", "google"]
6
+ },
7
+ "microsoft-outlook": {
8
+ label: "Outlook",
9
+ aliases: ["outlook", "microsoft", "office365"]
10
+ }
11
+ };
12
+ function record(value) {
13
+ if (value && typeof value === "object" && !Array.isArray(value)) return value;
14
+ if (typeof value === "string" && value.trim().startsWith("{")) {
15
+ try {
16
+ const parsed = JSON.parse(value);
17
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
18
+ } catch (e) {
19
+ }
20
+ }
21
+ return {};
22
+ }
23
+ function pick(fields, keys) {
24
+ for (const key of keys) {
25
+ const value = fields[key];
26
+ if (typeof value === "string" && value.trim()) return value.trim();
27
+ }
28
+ return "";
29
+ }
30
+ function mailConnectorOf(row) {
31
+ var _a, _b;
32
+ const custom = record((_a = row.metadata) == null ? void 0 : _a.customFields);
33
+ const form = record(row.formData);
34
+ const declared = pick(custom, ["connectorName", "providerId"]) || pick(form, ["providerId", "provider"]);
35
+ const candidates = [declared, ((_b = row.name) != null ? _b : "").trim()].map((value) => value.toLowerCase()).filter(Boolean);
36
+ for (const value of candidates) {
37
+ if (value === MAILER_CONNECTOR || value.startsWith(`${MAILER_CONNECTOR}-`)) return MAILER_CONNECTOR;
38
+ for (const [connector, {
39
+ aliases
40
+ }] of Object.entries(LEGACY_CONNECTORS)) {
41
+ if (value === connector || value.startsWith(`${connector}-`)) return connector;
42
+ if (aliases.some((alias) => value === alias || value.startsWith(`${alias}-`))) return connector;
43
+ }
44
+ }
45
+ return null;
46
+ }
47
+ function hasErrors(value) {
48
+ if (Array.isArray(value)) return value.length > 0;
49
+ if (value && typeof value === "object") return Object.keys(value).length > 0;
50
+ return typeof value === "string" && value.trim().length > 0;
51
+ }
52
+ function vaultSaysBroken(row) {
53
+ return row.isValid === false || hasErrors(row.validationErrors);
54
+ }
55
+ function mailAccountsFromCredentials(rows, orgName) {
56
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
57
+ const org = orgName.trim();
58
+ const accounts = [];
59
+ const legacy = [];
60
+ const seen = /* @__PURE__ */ new Set();
61
+ for (const row of rows != null ? rows : []) {
62
+ if (!(row == null ? void 0 : row.id) || seen.has(row.id)) continue;
63
+ if (row.status && row.status !== "active") continue;
64
+ const rowOrg = (_b = (_a = row.organization) == null ? void 0 : _a.name) == null ? void 0 : _b.trim();
65
+ if (org && rowOrg && rowOrg.toLowerCase() !== org.toLowerCase()) continue;
66
+ const connector = mailConnectorOf(row);
67
+ if (!connector) continue;
68
+ seen.add(row.id);
69
+ if (connector !== MAILER_CONNECTOR) {
70
+ legacy.push({
71
+ id: row.id,
72
+ connectorName: connector,
73
+ label: LEGACY_CONNECTORS[connector].label
74
+ });
75
+ continue;
76
+ }
77
+ const projectId = (_e = (_d = (_c = row.project) == null ? void 0 : _c.id) == null ? void 0 : _d.trim()) != null ? _e : "";
78
+ const environmentTagId = (_h = (_g = (_f = row.environmentTag) == null ? void 0 : _f.id) == null ? void 0 : _g.trim()) != null ? _h : "";
79
+ if (!projectId || !environmentTagId) continue;
80
+ const form = record(row.formData);
81
+ const email = pick(form, ["imapUsername", "email", "emailAddress", "defaultChannel", "fromAddress"]);
82
+ const channel = pick(form, ["defaultChannel", "channel", "imapUsername", "email", "emailAddress"]) || email;
83
+ if (!channel) continue;
84
+ accounts.push({
85
+ id: row.id,
86
+ credentialName: ((_i = row.name) == null ? void 0 : _i.trim()) || `${MAILER_CONNECTOR}-inbox`,
87
+ email: email || channel,
88
+ channel,
89
+ provider: pick(form, ["mailAccountProvider", "mailProvider"]) || void 0,
90
+ orgName: rowOrg || org,
91
+ projectId,
92
+ environmentTagId,
93
+ connectedAt: row.createdAt || row.updatedAt || "",
94
+ needsReconnect: vaultSaysBroken(row)
95
+ });
96
+ }
97
+ accounts.sort((a, b) => (Date.parse(b.connectedAt) || 0) - (Date.parse(a.connectedAt) || 0));
98
+ return {
99
+ accounts,
100
+ legacy
101
+ };
102
+ }
103
+ function pickMailAccount(accounts, preferredId) {
104
+ var _a;
105
+ if (preferredId) {
106
+ const hit = accounts.find((account) => account.id === preferredId);
107
+ if (hit) return hit;
108
+ }
109
+ return (_a = accounts[0]) != null ? _a : null;
110
+ }export{MAILER_CONNECTOR,mailAccountsFromCredentials,mailConnectorOf,pickMailAccount};//# sourceMappingURL=inboxAccounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxAccounts.js","sources":["../../../src/features/inbox/inboxAccounts.ts"],"sourcesContent":["/**\n * Vault credential rows -> the mailboxes the native Inbox can open.\n *\n * Mirrors the web Inbox (container-stack mail-campaign useMailInboxAccounts):\n * every mailbox is a yantra-mailer \"Mail account\", a workspace can hold several,\n * and rows of the retired direct connectors (google-gmail / microsoft-outlook)\n * come back as `legacy` so the screen can ask for a reconnect instead of\n * silently dropping them. Pure: the host screen runs the query, this only reads\n * the rows, so it is safe inside the federated remote too.\n */\nimport type { LegacyMailbox, MailAccount } from './types';\n\nexport const MAILER_CONNECTOR = 'yantra-mailer';\n\nconst LEGACY_CONNECTORS: Record<string, { label: string; aliases: string[] }> = {\n 'google-gmail': { label: 'Gmail', aliases: ['gmail', 'google'] },\n 'microsoft-outlook': { label: 'Outlook', aliases: ['outlook', 'microsoft', 'office365'] },\n};\n\n/** The fields of a `formBuilderCredentials` row this mapper reads. */\nexport interface MailCredentialRow {\n id?: string | null;\n name?: string | null;\n status?: string | null;\n formData?: unknown;\n metadata?: { customFields?: unknown; formId?: string | null } | null;\n project?: { id?: string | null; projectId?: string | null } | null;\n environmentTag?: { id?: string | null } | null;\n organization?: { name?: string | null } | null;\n isValid?: boolean | null;\n validationErrors?: unknown;\n createdAt?: string | null;\n updatedAt?: string | null;\n}\n\nexport interface MailAccountsResult {\n accounts: MailAccount[];\n legacy: LegacyMailbox[];\n}\n\nfunction record(value: unknown): Record<string, unknown> {\n if (value && typeof value === 'object' && !Array.isArray(value)) return value as Record<string, unknown>;\n if (typeof value === 'string' && value.trim().startsWith('{')) {\n try {\n const parsed: unknown = JSON.parse(value);\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))\n return parsed as Record<string, unknown>;\n } catch {\n /* not JSON: no fields */\n }\n }\n return {};\n}\n\nfunction pick(fields: Record<string, unknown>, keys: string[]): string {\n for (const key of keys) {\n const value = fields[key];\n if (typeof value === 'string' && value.trim()) return value.trim();\n }\n return '';\n}\n\n/** Which inbox connector a credential belongs to, or null when it is not a mailbox. */\nexport function mailConnectorOf(row: MailCredentialRow): string | null {\n const custom = record(row.metadata?.customFields);\n const form = record(row.formData);\n const declared = pick(custom, ['connectorName', 'providerId']) || pick(form, ['providerId', 'provider']);\n const candidates = [declared, (row.name ?? '').trim()].map((value) => value.toLowerCase()).filter(Boolean);\n for (const value of candidates) {\n if (value === MAILER_CONNECTOR || value.startsWith(`${MAILER_CONNECTOR}-`)) return MAILER_CONNECTOR;\n for (const [connector, { aliases }] of Object.entries(LEGACY_CONNECTORS)) {\n if (value === connector || value.startsWith(`${connector}-`)) return connector;\n if (aliases.some((alias) => value === alias || value.startsWith(`${alias}-`))) return connector;\n }\n }\n return null;\n}\n\nfunction hasErrors(value: unknown): boolean {\n if (Array.isArray(value)) return value.length > 0;\n if (value && typeof value === 'object') return Object.keys(value).length > 0;\n return typeof value === 'string' && value.trim().length > 0;\n}\n\n/**\n * The vault itself says the sign-in no longer works. Token expiry alone does not\n * count: an OAuth mailbox renews its token on use, and app passwords never expire.\n */\nfunction vaultSaysBroken(row: MailCredentialRow): boolean {\n return row.isValid === false || hasErrors(row.validationErrors);\n}\n\n/**\n * The org's mailboxes, newest first. `orgName` scopes the rows: the server can\n * answer with rows of other orgs the caller belongs to, and those never show.\n */\nexport function mailAccountsFromCredentials(\n rows: ReadonlyArray<MailCredentialRow | null | undefined> | null | undefined,\n orgName: string,\n): MailAccountsResult {\n const org = orgName.trim();\n const accounts: MailAccount[] = [];\n const legacy: LegacyMailbox[] = [];\n const seen = new Set<string>();\n for (const row of rows ?? []) {\n if (!row?.id || seen.has(row.id)) continue;\n if (row.status && row.status !== 'active') continue;\n const rowOrg = row.organization?.name?.trim();\n if (org && rowOrg && rowOrg.toLowerCase() !== org.toLowerCase()) continue;\n const connector = mailConnectorOf(row);\n if (!connector) continue;\n seen.add(row.id);\n if (connector !== MAILER_CONNECTOR) {\n legacy.push({ id: row.id, connectorName: connector, label: LEGACY_CONNECTORS[connector].label });\n continue;\n }\n const projectId = row.project?.id?.trim() ?? '';\n const environmentTagId = row.environmentTag?.id?.trim() ?? '';\n // The store path is org/project/env/channel: without the scope the list reads an empty path.\n if (!projectId || !environmentTagId) continue;\n const form = record(row.formData);\n const email = pick(form, ['imapUsername', 'email', 'emailAddress', 'defaultChannel', 'fromAddress']);\n const channel = pick(form, ['defaultChannel', 'channel', 'imapUsername', 'email', 'emailAddress']) || email;\n if (!channel) continue;\n accounts.push({\n id: row.id,\n credentialName: row.name?.trim() || `${MAILER_CONNECTOR}-inbox`,\n email: email || channel,\n channel,\n provider: pick(form, ['mailAccountProvider', 'mailProvider']) || undefined,\n orgName: rowOrg || org,\n projectId,\n environmentTagId,\n connectedAt: row.createdAt || row.updatedAt || '',\n needsReconnect: vaultSaysBroken(row),\n });\n }\n accounts.sort((a, b) => (Date.parse(b.connectedAt) || 0) - (Date.parse(a.connectedAt) || 0));\n return { accounts, legacy };\n}\n\n/** The mailbox to open: the one picked before when it still exists, else the newest. */\nexport function pickMailAccount(accounts: readonly MailAccount[], preferredId?: string | null): MailAccount | null {\n if (preferredId) {\n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