@remit/web-client-dist 0.0.685 → 0.0.687

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 (187) hide show
  1. package/assets/{BriefPane-BfKwBxLe.js → BriefPane-COrs7CVx.js} +1 -1
  2. package/assets/{CalendarEventEditor-Bsugk6rT.js → CalendarEventEditor-BhA39Rb2.js} +1 -1
  3. package/assets/{CalendarEventPopup-C-BVvxfV.js → CalendarEventPopup-UIRJmAuO.js} +1 -1
  4. package/assets/{CalendarLoadFailed-DcrF_lyr.js → CalendarLoadFailed-DzWtRaUl.js} +1 -1
  5. package/assets/{CalendarQuickCreate-_ki0X3rq.js → CalendarQuickCreate-DcQayG3V.js} +1 -1
  6. package/assets/{CalendarSession-CK-EC1yK.js → CalendarSession-_d6Lwmhn.js} +1 -1
  7. package/assets/{DesktopChrome-BfOVbUXt.js → DesktopChrome-DSSIExOw.js} +1 -1
  8. package/assets/{DropdownMenu-B4qvRStt.js → DropdownMenu-BV6yZUL3.js} +1 -1
  9. package/assets/{EmptyState-BYR2eIr2.js → EmptyState-D_wpVujA.js} +1 -1
  10. package/assets/{ErrorState-BXxvOnci.js → ErrorState-PBZ1dcEl.js} +1 -1
  11. package/assets/FlaggedPane-DTci7Jk9.js +1 -0
  12. package/assets/{FullCompose-DEhDpjci.js → FullCompose-8Kn4aqgN.js} +1 -1
  13. package/assets/{LabelApplyTrigger-C4ode0Y9.js → LabelApplyTrigger-DHCWdym3.js} +1 -1
  14. package/assets/{MailShell-DvQDMygz.js → MailShell-zsU5V1wa.js} +1 -1
  15. package/assets/{MailViewChrome-D66Dcy3c.js → MailViewChrome-jwxzTnpB.js} +1 -1
  16. package/assets/MailboxPane-BLsh7tZx.js +135 -0
  17. package/assets/{MessageBody-CDTfM1lc.js → MessageBody-UqTwvXl6.js} +1 -1
  18. package/assets/MessageToolbar-Du3eOeej.js +1 -0
  19. package/assets/{NavMenuButton-BZWw6TBA.js → NavMenuButton-DhPLjEtb.js} +1 -1
  20. package/assets/{OnboardingWizard-Bppp1CPR.js → OnboardingWizard-B-aWxaHK.js} +1 -1
  21. package/assets/{OutboxPane-B_ihIEGn.js → OutboxPane-DYsbKba9.js} +1 -1
  22. package/assets/{ReportLink-CwxUgr_7.js → ReportLink-DoG9_sx_.js} +1 -1
  23. package/assets/_calendarObjectId-DpkmtwWQ.js +1 -0
  24. package/assets/_mailboxId-oKMOPheQ.js +1 -0
  25. package/assets/_messageId-B4C3azxW.js +1 -0
  26. package/assets/_messageId-BLBWeHlz.js +1 -0
  27. package/assets/_messageId-Dz30t9fR.js +1 -0
  28. package/assets/_outboxMessageId-D2YOJVym.js +1 -0
  29. package/assets/_recurrenceId-Bdirt3_z.js +1 -0
  30. package/assets/{_slotId-D9HVYRDd.js → _slotId-5KFwUvZq.js} +1 -1
  31. package/assets/_threadId-BVXP3HAW.js +1 -0
  32. package/assets/_threadId-Co1awXcC.js +1 -0
  33. package/assets/_threadId-DZ-HOcZo.js +1 -0
  34. package/assets/{_view._date-DCmCYHjG.js → _view._date-DdGWMZqi.js} +1 -1
  35. package/assets/{account-service-status-D-hGpg9e.js → account-service-status-Cb5TPqfG.js} +1 -1
  36. package/assets/{accounts-BcJ04H8d.js → accounts-hQC6mYeG.js} +1 -1
  37. package/assets/{advanced-DnA-3VCS.js → advanced-CRstvPJ0.js} +1 -1
  38. package/assets/{agenda-time-O7rJVIvd.js → agenda-time-CQ_ZOnxJ.js} +1 -1
  39. package/assets/{app-chrome-DvUymvcE.js → app-chrome-DwYQ7bMA.js} +1 -1
  40. package/assets/{appearance-CypE55tV.js → appearance-ChtfB2UX.js} +1 -1
  41. package/assets/{avatar-BgqBWztU.js → avatar-D89ARIcc.js} +1 -1
  42. package/assets/{badge-CfQoDkmE.js → badge-CVkU5AQe.js} +1 -1
  43. package/assets/{bottom-sheet-Dhk1Aqz2.js → bottom-sheet-t8af1PF1.js} +1 -1
  44. package/assets/brief-Dh5YxPIL.js +1 -0
  45. package/assets/{brief-DgC2R0u5.js → brief-e18Dv0qO.js} +1 -1
  46. package/assets/{calendar-Ix1rbLDg.js → calendar-C9Uc5DHo.js} +1 -1
  47. package/assets/{calendar-BJu4Vl-g.js → calendar-XQ9HQLUe.js} +1 -1
  48. package/assets/{calendar-event-popup-B4-Dpgb6.js → calendar-event-popup-0tFSzbbF.js} +1 -1
  49. package/assets/{calendar-event-sidebar-DZum-8WN.js → calendar-event-sidebar-rgc6P7Qv.js} +1 -1
  50. package/assets/{calendar-failure-note-DK-uzvky.js → calendar-failure-note-CVkL5kJS.js} +1 -1
  51. package/assets/{calendar-guests-Diti9JO5.js → calendar-guests-DpHE7dAN.js} +1 -1
  52. package/assets/{calendar-suggestion-C8kx9fKn.js → calendar-suggestion-K7JQT8V7.js} +1 -1
  53. package/assets/{calendars-ne1Oj2RW.js → calendars-CwZPs-ue.js} +1 -1
  54. package/assets/{card-B-YLocTg.js → card-Ca80zdbN.js} +1 -1
  55. package/assets/{checkbox-DL0pObJW.js → checkbox-DNO6b3_M.js} +1 -1
  56. package/assets/chevron-down-B53HizFQ.js +1 -0
  57. package/assets/chevron-left-DTfiqCyD.js +1 -0
  58. package/assets/{circle-check-OUBTwy71.js → circle-check-C2nNDGc4.js} +1 -1
  59. package/assets/{circle-check-big-Czqmzl9y.js → circle-check-big-7sGSIHiw.js} +1 -1
  60. package/assets/{circle-help-DJ-Mtycd.js → circle-help-C6RlLR_U.js} +1 -1
  61. package/assets/{classification-DLUltDdR.js → classification-WKdy6dPa.js} +1 -1
  62. package/assets/{clock-Bw2dEIoB.js → clock-DYmnRixq.js} +1 -1
  63. package/assets/compose._-_outboxMessageId_-BL2ptCY5.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-D02KMdCw.js +1 -0
  65. package/assets/compose._-_outboxMessageId_-DtsflRQr.js +1 -0
  66. package/assets/compose._-_outboxMessageId_-Du3ukNst.js +1 -0
  67. package/assets/{config-import-B6tjROvg.js → config-import-CCz-NB0k.js} +1 -1
  68. package/assets/{confirm-dialog-sa45Xnmn.js → confirm-dialog-CC28wnk2.js} +1 -1
  69. package/assets/{copy-9W6V4dQI.js → copy-lGbXnTE3.js} +1 -1
  70. package/assets/{credential-steps-P9fRg1pE.js → credential-steps-DY-wc9MD.js} +1 -1
  71. package/assets/{download-O3cdl6IV.js → download-CEKWeJ7u.js} +1 -1
  72. package/assets/{draft-QkjvtbSZ.js → draft-DtstxhoA.js} +1 -1
  73. package/assets/edit-Cp-jC8F0.js +1 -0
  74. package/assets/edit-D1bLpxwo.js +1 -0
  75. package/assets/{external-link-BYIIFw9_.js → external-link-DVW2CLL2.js} +1 -1
  76. package/assets/{file-json-vVOzTp-u.js → file-json-7xzXdn_b.js} +1 -1
  77. package/assets/{filters-DohRSViK.js → filters-CEI7jjCN.js} +1 -1
  78. package/assets/flagged-IxYYmmwQ.js +1 -0
  79. package/assets/{flagged-BHlMmpp_.js → flagged-w8DjNJhC.js} +1 -1
  80. package/assets/{folder-input-hVRteCio.js → folder-input-Dt8ZQufS.js} +1 -1
  81. package/assets/{folders-BFfd-sur.js → folders-CoM9eTLM.js} +1 -1
  82. package/assets/{help-copy-_K3IfQdg.js → help-copy-DXfHEQFm.js} +1 -1
  83. package/assets/{import-ByOg30ul.js → import-CZKlaGH6.js} +1 -1
  84. package/assets/index-3_Yz4GxU.js +1 -0
  85. package/assets/index-B4C3azxW.js +1 -0
  86. package/assets/index-BLBWeHlz.js +1 -0
  87. package/assets/index-C3mmn-C6.js +1 -0
  88. package/assets/index-CVj_7ByF.js +1 -0
  89. package/assets/{index-Bn8n_AsE.js → index-CbgROAMc.js} +5 -5
  90. package/assets/index-CwjoqVSo.js +1 -0
  91. package/assets/index-DKd5I80C.js +1 -0
  92. package/assets/index-Dz30t9fR.js +1 -0
  93. package/assets/{index-k6LzEquX.js → index-FaXST499.js} +4 -4
  94. package/assets/index-Onsvetck.js +1 -0
  95. package/assets/index-mm7IuQg8.js +1 -0
  96. package/assets/{kbd-PiHV4odS.js → kbd-Cbl9_QOh.js} +1 -1
  97. package/assets/{label-chip-BnNtXrWd.js → label-chip-CO6By5aO.js} +1 -1
  98. package/assets/{labels-BQe-BkCj.js → labels-BAEGQl1T.js} +1 -1
  99. package/assets/{mail-CPplAOgE.js → mail-DmwnMm2Y.js} +1 -1
  100. package/assets/{mail-BFIBAL7w.js → mail-QqP9ZnpV.js} +1 -1
  101. package/assets/{menu-znX-3dzE.js → menu-DYBcrWqA.js} +1 -1
  102. package/assets/{nav-link-CtuHya9S.js → nav-link-BZqQXeHL.js} +1 -1
  103. package/assets/new-DOmkCJRK.js +1 -0
  104. package/assets/onboarding-DRHhXiMF.js +1 -0
  105. package/assets/{onboarding-completion-CKAiaYkS.js → onboarding-completion-DeJxnEb_.js} +1 -1
  106. package/assets/outbox-Bg3tB7lm.js +1 -0
  107. package/assets/{pencil-DA21sF5f.js → pencil-o08jMG_U.js} +1 -1
  108. package/assets/{people-BQjKSotc.js → people-DsKShbSj.js} +1 -1
  109. package/assets/{plus-6ss9YFRF.js → plus-DgqfTVXj.js} +1 -1
  110. package/assets/{popover-menu-iCbmrU-E.js → popover-menu-CV0D1hyl.js} +1 -1
  111. package/assets/{refresh-cw-CUyjBEl4.js → refresh-cw--NWZ2iVr.js} +1 -1
  112. package/assets/{reply-DmpF7cgR.js → reply-BfphTP4m.js} +1 -1
  113. package/assets/{rich-text-Cppy56p_.js → rich-text-B8hDLkkT.js} +1 -1
  114. package/assets/{rich-text-spellcheck-worker-provider-Bk2_kAe9.js → rich-text-spellcheck-worker-provider-B8oMA2PZ.js} +1 -1
  115. package/assets/{rotate-ccw-Dtkxt0CH.js → rotate-ccw-BOA4cFv9.js} +1 -1
  116. package/assets/{roving-focus-CzX6YmR4.js → roving-focus-Bx7MjTS6.js} +1 -1
  117. package/assets/{row-actions-Cn7bQ_Ks.js → row-actions-wDsGvLou.js} +1 -1
  118. package/assets/{search-mirror-BSzHMUcd.js → search-mirror-DsO_5PBi.js} +1 -1
  119. package/assets/{search-scope-Cl87snrn.js → search-scope-BP5378RT.js} +1 -1
  120. package/assets/{search-token-index-BSaB7qLo.js → search-token-index-CcXSZAVY.js} +1 -1
  121. package/assets/{sections-DwdsQ0ad.js → sections-DGb-88rO.js} +1 -1
  122. package/assets/{segmented-control-68-bWTGV.js → segmented-control-C1MTIwvp.js} +1 -1
  123. package/assets/{select-Cc2Vc4qL.js → select-COD1LjX3.js} +1 -1
  124. package/assets/{senders-DwOfiVHu.js → senders-DNg_Zv2o.js} +1 -1
  125. package/assets/settings-BWW4sHXO.js +1 -0
  126. package/assets/{settings-screen-IjQOks0s.js → settings-screen-DWFOIL8d.js} +1 -1
  127. package/assets/{shield-check-jkVgxi6o.js → shield-check-BAlnfD1b.js} +1 -1
  128. package/assets/{suggest-list-FaY4DThZ.js → suggest-list-BRiCB2iX.js} +1 -1
  129. package/assets/{suggested-vips-BLlvjvH5.js → suggested-vips-cvR97iUF.js} +1 -1
  130. package/assets/{suggestion._suggestionId-CL7hLrk-.js → suggestion._suggestionId-6oFalsW0.js} +1 -1
  131. package/assets/{switch-a7x-CFTd.js → switch-DrrhR1fp.js} +1 -1
  132. package/assets/{task._calendarTaskId-CkPsJj-a.js → task._calendarTaskId-Y2ie8D0j.js} +1 -1
  133. package/assets/{undo-2-CnxBm8gd.js → undo-2-Bp15jwcP.js} +1 -1
  134. package/assets/{useCalendarData-RUYA8D_t.js → useCalendarData-Dq25xr-v.js} +2 -2
  135. package/assets/{useCalendarScheduling-CO3VOpcB.js → useCalendarScheduling-CvootEdV.js} +1 -1
  136. package/assets/{useCalendarSuggestions-Bb4PGHae.js → useCalendarSuggestions-D47uHTtR.js} +1 -1
  137. package/assets/{useCalendarTasks-RmI_Ij1j.js → useCalendarTasks-DvNeuPeL.js} +1 -1
  138. package/assets/{useDebouncedValue-I0sDLoIF.js → useDebouncedValue-DYTYC1kV.js} +1 -1
  139. package/assets/{useFilters-DT8SxgF4.js → useFilters-DlJ0zPcy.js} +1 -1
  140. package/assets/{useLabels-DO4UWjpG.js → useLabels-B-49F105.js} +1 -1
  141. package/assets/{useLayoutTier-Cn3SwiV2.js → useLayoutTier-DPkVl_xo.js} +1 -1
  142. package/assets/{useMediaQuery-C00TiD5k.js → useMediaQuery-7837UC86.js} +1 -1
  143. package/assets/{useMessageBodyContent-lqVkO1fM.js → useMessageBodyContent-DBThR6n4.js} +1 -1
  144. package/assets/{useQueries-Bs7-L_2j.js → useQueries-BC3Dqp3g.js} +1 -1
  145. package/assets/{useRefreshControl-Bt-oDRnY.js → useRefreshControl-C6LnPJKN.js} +1 -1
  146. package/assets/{useResultFolderIndex-CALTzfWS.js → useResultFolderIndex-CUsiZy-x.js} +1 -1
  147. package/assets/{useSignature-DRFIcifS.js → useSignature-BlJUQKXS.js} +1 -1
  148. package/assets/{warnings-ClaUoDQx.js → warnings-BRlhmkTM.js} +1 -1
  149. package/index.html +1 -1
  150. package/package.json +1 -1
  151. package/assets/FlaggedPane-F0FM2UJN.js +0 -1
  152. package/assets/MailboxPane-BDYnlpr2.js +0 -135
  153. package/assets/MessageToolbar-BW852rJj.js +0 -1
  154. package/assets/_calendarObjectId-CSwodc6y.js +0 -1
  155. package/assets/_mailboxId-BlTWUSb1.js +0 -1
  156. package/assets/_messageId-BaqNxGqi.js +0 -1
  157. package/assets/_messageId-DNtVsPPW.js +0 -1
  158. package/assets/_messageId-ciVFKEzn.js +0 -1
  159. package/assets/_outboxMessageId-LLqtF8cH.js +0 -1
  160. package/assets/_recurrenceId-G4qPwsrp.js +0 -1
  161. package/assets/_threadId-BAVZ7S8M.js +0 -1
  162. package/assets/_threadId-DL34NZT4.js +0 -1
  163. package/assets/_threadId-qmAQ7RKu.js +0 -1
  164. package/assets/brief-DcbZ7jHO.js +0 -1
  165. package/assets/chevron-down-BWbeCM3N.js +0 -1
  166. package/assets/chevron-left-CliOUq1O.js +0 -1
  167. package/assets/compose._-_outboxMessageId_-CAx_e1OV.js +0 -1
  168. package/assets/compose._-_outboxMessageId_-CnWaV_IX.js +0 -1
  169. package/assets/compose._-_outboxMessageId_-Dmj8hyvT.js +0 -1
  170. package/assets/compose._-_outboxMessageId_-z980Xa6X.js +0 -1
  171. package/assets/edit-B31QMGS3.js +0 -1
  172. package/assets/edit-DjkZZFBG.js +0 -1
  173. package/assets/flagged-DIi4rqg8.js +0 -1
  174. package/assets/index-BIhlBhBD.js +0 -1
  175. package/assets/index-BaqNxGqi.js +0 -1
  176. package/assets/index-C53Z5hF_.js +0 -1
  177. package/assets/index-CRnDeQMw.js +0 -1
  178. package/assets/index-CzbtDE1H.js +0 -1
  179. package/assets/index-DNtVsPPW.js +0 -1
  180. package/assets/index-DR2Joq7n.js +0 -1
  181. package/assets/index-DbyBl7Lq.js +0 -1
  182. package/assets/index-cVALleyU.js +0 -1
  183. package/assets/index-ciVFKEzn.js +0 -1
  184. package/assets/new-psckzAFd.js +0 -1
  185. package/assets/onboarding-B_l5ow67.js +0 -1
  186. package/assets/outbox-BTiQbMrW.js +0 -1
  187. package/assets/settings-BdeAbD2h.js +0 -1
@@ -1 +1 @@
1
- import{j as E,v as K,p as Q,B as U,e as N,J as B,r as o,aF as R,P as $,Q as z,l as G,a0 as I,a1 as X,a4 as J}from"./index-Bn8n_AsE.js";import{C as V}from"./circle-check-big-Czqmzl9y.js";import{R as Y}from"./refresh-cw-CUyjBEl4.js";import{u as P}from"./useQueries-Bs7-L_2j.js";function ye({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(V,{className:"size-4 text-positive"}):E.jsx(Y,{className:Q("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const Z=180*1e3,Se=30*1e3;let L=0;const M=new Set,ee=(e=Date.now())=>{L=e+Z;for(const s of M)s()},we=(e=Date.now())=>e<L,xe=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,te=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&te.has(a)||t.set(r.mailboxId,r.highWaterMarkUid)}return t},F=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>F(e,s).length>0,q=o.createContext(null),ne=()=>{const e=o.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=N(),{resultFolderIndex:r}=B(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),v=c.current.get(d);if(c.current.set(d,g),v){const A=F(v,g);A.length>0&&$(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;se(W,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(q.Provider,{value:m,children:s})}const re=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&re.has(e)}const D=3e3,oe=D*2,O={syncing:!1,resolved:!1,synced:0,total:0};function Ee(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),oe);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:D,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(j(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?O:{syncing:y,resolved:!0,synced:w,total:S}}const ae=2e3,ie=45e3,ce=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ue=e=>{J(e,{softError:!0})},T=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,le=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ae})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:k(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ce(c)}},fe=async(e,s,t,r,a)=>{const u=await T(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return ue(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await le({accountId:t,readStatus:()=>T(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},be=(e,s={})=>{const t=N(),r=G(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ee();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ie,d=await Promise.all(x.map(g=>fe(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{Se as H,pe as M,ye as R,be as a,j as b,Ee as c,we as i,xe as s,ne as u};
1
+ import{j as E,v as K,p as Q,B as U,e as N,J as B,r as o,aF as R,P as $,Q as z,l as G,a0 as I,a1 as X,a4 as J}from"./index-CbgROAMc.js";import{C as V}from"./circle-check-big-7sGSIHiw.js";import{R as Y}from"./refresh-cw--NWZ2iVr.js";import{u as P}from"./useQueries-BC3Dqp3g.js";function ye({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(V,{className:"size-4 text-positive"}):E.jsx(Y,{className:Q("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const Z=180*1e3,Se=30*1e3;let L=0;const M=new Set,ee=(e=Date.now())=>{L=e+Z;for(const s of M)s()},we=(e=Date.now())=>e<L,xe=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,te=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&te.has(a)||t.set(r.mailboxId,r.highWaterMarkUid)}return t},F=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>F(e,s).length>0,q=o.createContext(null),ne=()=>{const e=o.useContext(q);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=N(),{resultFolderIndex:r}=B(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),v=c.current.get(d);if(c.current.set(d,g),v){const A=F(v,g);A.length>0&&$(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;se(W,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(q.Provider,{value:m,children:s})}const re=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&re.has(e)}const D=3e3,oe=D*2,O={syncing:!1,resolved:!1,synced:0,total:0};function Ee(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),oe);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:D,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(j(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?O:{syncing:y,resolved:!0,synced:w,total:S}}const ae=2e3,ie=45e3,ce=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ue=e=>{J(e,{softError:!0})},T=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,le=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ae})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:k(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ce(c)}},fe=async(e,s,t,r,a)=>{const u=await T(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return ue(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await le({accountId:t,readStatus:()=>T(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},be=(e,s={})=>{const t=N(),r=G(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ee();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ie,d=await Promise.all(x.map(g=>fe(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{Se as H,pe as M,ye as R,be as a,j as b,Ee as c,we as i,xe as s,ne as u};
@@ -1 +1 @@
1
- import{b as s,U as o,r as n,b_ as r}from"./index-Bn8n_AsE.js";import{u as d}from"./useQueries-Bs7-L_2j.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
1
+ import{b as s,U as o,r as n,b_ as r}from"./index-CbgROAMc.js";import{u as d}from"./useQueries-BC3Dqp3g.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
@@ -1 +1 @@
1
- import{e as m,ak as y,a as b,c as L,r as c,f as w,al as S,k,h as E}from"./index-Bn8n_AsE.js";var u={en:1199414,"en-GB":1199758,nl:3180464},g=["en","en-GB","nl"];const C=()=>typeof g>"u"?[]:g,M=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},_=e=>typeof u>"u"?0:u[e]??0,O=(e,n=C())=>{const t=e.toLowerCase(),a=n.find(i=>i.toLowerCase()===t);if(a)return a;const o=t.split("-")[0];return n.find(i=>i.toLowerCase().split("-")[0]===o)??null},T=[{tag:"ar",detectionCode:"arb"},{tag:"az",detectionCode:"azj"},{tag:"be",detectionCode:"bel"},{tag:"bg",detectionCode:"bul"},{tag:"bs",detectionCode:"bos"},{tag:"cs",detectionCode:"ces"},{tag:"de",detectionCode:"deu"},{tag:"en",detectionCode:"eng"},{tag:"es",detectionCode:"spa"},{tag:"fa",detectionCode:"pes"},{tag:"fr",detectionCode:"fra"},{tag:"ha",detectionCode:"hau"},{tag:"hi",detectionCode:"hin"},{tag:"hr",detectionCode:"hrv"},{tag:"hu",detectionCode:"hun"},{tag:"id",detectionCode:"ind"},{tag:"ig",detectionCode:"ibo"},{tag:"it",detectionCode:"ita"},{tag:"jv",detectionCode:"jav"},{tag:"kk",detectionCode:"kaz"},{tag:"mr",detectionCode:"mar"},{tag:"ms",detectionCode:"zlm"},{tag:"ne",detectionCode:"npi"},{tag:"nl",detectionCode:"nld"},{tag:"pl",detectionCode:"pol"},{tag:"ps",detectionCode:"pbu"},{tag:"pt",detectionCode:"por"},{tag:"ro",detectionCode:"ron"},{tag:"ru",detectionCode:"rus"},{tag:"so",detectionCode:"som"},{tag:"sr",detectionCode:"srp"},{tag:"su",detectionCode:"sun"},{tag:"sv",detectionCode:"swe"},{tag:"sw",detectionCode:"swh"},{tag:"tl",detectionCode:"tgl"},{tag:"tr",detectionCode:"tur"},{tag:"uk",detectionCode:"ukr"},{tag:"ur",detectionCode:"urd"},{tag:"vi",detectionCode:"vie"},{tag:"yo",detectionCode:"yor"},{tag:"zu",detectionCode:"zul"}],d=e=>(e.split("-")[0]??"").toLowerCase(),v=new Map(T.map(e=>[e.tag,e])),x=e=>v.get(d(e))?.detectionCode??null,P=/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i,G=e=>d(e).toUpperCase(),H=e=>{if(!P.test(e))return e;const t=new Intl.DisplayNames([e],{type:"language",fallback:"none"}).of(e);return t?t.charAt(0).toLocaleUpperCase(e)+t.slice(1):e},z=(e,n=C())=>{const t=[...e,...n].filter(o=>x(o)!==null),a=[...new Set(t.map(d))];return a.includes("en")||a.push("en"),a},N=e=>/iPhone|iPad|iPod/.test(e)?"On iPhone and iPad the keyboard decides this. Add the language under Settings, then General, then Keyboard.":/Edg\//.test(e)?"Edge checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Firefox\//.test(e)?"Firefox uses this setting. Right-click the message to add a dictionary for it.":/Chrome\/|Chromium\//.test(e)?"Chrome checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Safari\//.test(e)?"macOS decides this under Keyboard, then Text Input, then Spelling. Automatic by Language covers every language enabled there.":"Your browser decides which dictionaries it checks. Add this language in its own language settings to have it spellchecked.",h=e=>new DOMParser().parseFromString(e,"text/html"),p=e=>{const n=[...e.children];if(n.length!==1)return null;const t=n[0];return t?[...e.childNodes].some(o=>o!==t&&(o.textContent??"").trim()!=="")?null:t:null},R=(e,n)=>{if(e==="")return"";const t=h(e),a=p(t.body);if(a?.tagName==="DIV"&&a.hasAttribute("lang"))return a.setAttribute("lang",n),t.body.innerHTML;const o=t.createElement("div");for(o.setAttribute("lang",n);t.body.firstChild;)o.append(t.body.firstChild);return t.body.append(o),t.body.innerHTML},U=e=>{if(e==="")return{html:e,language:null};const n=h(e),t=p(n.body);return t?.tagName!=="DIV"||!t.hasAttribute("lang")?{html:e,language:null}:{html:t.innerHTML,language:t.getAttribute("lang")}},l={html:"",plainText:""},B=e=>{const n=m(),{pushError:t}=y(),{data:a}=b({...L(),staleTime:1/0}),o=c.useMemo(()=>{if(!e||!a)return l;const s=a.accounts.find(r=>r.accountId===e);return s?{html:s.signatureHtml??"",plainText:s.signaturePlainText??""}:l},[e,a]),i=w({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:k()})},onError:s=>{t(S("Couldn't save signature","The signature wasn't saved.",s))}}),f=c.useCallback((s,r)=>{e&&i.mutate({path:{accountId:e},body:{signatureHtml:s,signaturePlainText:r}})},[e,i]);return{signature:o,setSignature:f,isSaving:i.isPending}};export{T as C,U as a,G as b,N as c,z as d,x as e,O as f,_ as g,H as l,d as p,M as s,B as u,R as w};
1
+ import{e as m,ak as y,a as b,c as L,r as c,f as w,al as S,k,h as E}from"./index-CbgROAMc.js";var u={en:1199414,"en-GB":1199758,nl:3180464},g=["en","en-GB","nl"];const C=()=>typeof g>"u"?[]:g,M=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},_=e=>typeof u>"u"?0:u[e]??0,O=(e,n=C())=>{const t=e.toLowerCase(),a=n.find(i=>i.toLowerCase()===t);if(a)return a;const o=t.split("-")[0];return n.find(i=>i.toLowerCase().split("-")[0]===o)??null},T=[{tag:"ar",detectionCode:"arb"},{tag:"az",detectionCode:"azj"},{tag:"be",detectionCode:"bel"},{tag:"bg",detectionCode:"bul"},{tag:"bs",detectionCode:"bos"},{tag:"cs",detectionCode:"ces"},{tag:"de",detectionCode:"deu"},{tag:"en",detectionCode:"eng"},{tag:"es",detectionCode:"spa"},{tag:"fa",detectionCode:"pes"},{tag:"fr",detectionCode:"fra"},{tag:"ha",detectionCode:"hau"},{tag:"hi",detectionCode:"hin"},{tag:"hr",detectionCode:"hrv"},{tag:"hu",detectionCode:"hun"},{tag:"id",detectionCode:"ind"},{tag:"ig",detectionCode:"ibo"},{tag:"it",detectionCode:"ita"},{tag:"jv",detectionCode:"jav"},{tag:"kk",detectionCode:"kaz"},{tag:"mr",detectionCode:"mar"},{tag:"ms",detectionCode:"zlm"},{tag:"ne",detectionCode:"npi"},{tag:"nl",detectionCode:"nld"},{tag:"pl",detectionCode:"pol"},{tag:"ps",detectionCode:"pbu"},{tag:"pt",detectionCode:"por"},{tag:"ro",detectionCode:"ron"},{tag:"ru",detectionCode:"rus"},{tag:"so",detectionCode:"som"},{tag:"sr",detectionCode:"srp"},{tag:"su",detectionCode:"sun"},{tag:"sv",detectionCode:"swe"},{tag:"sw",detectionCode:"swh"},{tag:"tl",detectionCode:"tgl"},{tag:"tr",detectionCode:"tur"},{tag:"uk",detectionCode:"ukr"},{tag:"ur",detectionCode:"urd"},{tag:"vi",detectionCode:"vie"},{tag:"yo",detectionCode:"yor"},{tag:"zu",detectionCode:"zul"}],d=e=>(e.split("-")[0]??"").toLowerCase(),v=new Map(T.map(e=>[e.tag,e])),x=e=>v.get(d(e))?.detectionCode??null,P=/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i,G=e=>d(e).toUpperCase(),H=e=>{if(!P.test(e))return e;const t=new Intl.DisplayNames([e],{type:"language",fallback:"none"}).of(e);return t?t.charAt(0).toLocaleUpperCase(e)+t.slice(1):e},z=(e,n=C())=>{const t=[...e,...n].filter(o=>x(o)!==null),a=[...new Set(t.map(d))];return a.includes("en")||a.push("en"),a},N=e=>/iPhone|iPad|iPod/.test(e)?"On iPhone and iPad the keyboard decides this. Add the language under Settings, then General, then Keyboard.":/Edg\//.test(e)?"Edge checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Firefox\//.test(e)?"Firefox uses this setting. Right-click the message to add a dictionary for it.":/Chrome\/|Chromium\//.test(e)?"Chrome checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Safari\//.test(e)?"macOS decides this under Keyboard, then Text Input, then Spelling. Automatic by Language covers every language enabled there.":"Your browser decides which dictionaries it checks. Add this language in its own language settings to have it spellchecked.",h=e=>new DOMParser().parseFromString(e,"text/html"),p=e=>{const n=[...e.children];if(n.length!==1)return null;const t=n[0];return t?[...e.childNodes].some(o=>o!==t&&(o.textContent??"").trim()!=="")?null:t:null},R=(e,n)=>{if(e==="")return"";const t=h(e),a=p(t.body);if(a?.tagName==="DIV"&&a.hasAttribute("lang"))return a.setAttribute("lang",n),t.body.innerHTML;const o=t.createElement("div");for(o.setAttribute("lang",n);t.body.firstChild;)o.append(t.body.firstChild);return t.body.append(o),t.body.innerHTML},U=e=>{if(e==="")return{html:e,language:null};const n=h(e),t=p(n.body);return t?.tagName!=="DIV"||!t.hasAttribute("lang")?{html:e,language:null}:{html:t.innerHTML,language:t.getAttribute("lang")}},l={html:"",plainText:""},B=e=>{const n=m(),{pushError:t}=y(),{data:a}=b({...L(),staleTime:1/0}),o=c.useMemo(()=>{if(!e||!a)return l;const s=a.accounts.find(r=>r.accountId===e);return s?{html:s.signatureHtml??"",plainText:s.signaturePlainText??""}:l},[e,a]),i=w({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:k()})},onError:s=>{t(S("Couldn't save signature","The signature wasn't saved.",s))}}),f=c.useCallback((s,r)=>{e&&i.mutate({path:{accountId:e},body:{signatureHtml:s,signaturePlainText:r}})},[e,i]);return{signature:o,setSignature:f,isSaving:i.isPending}};export{T as C,U as a,G as b,N as c,z as d,x as e,O as f,_ as g,H as l,d as p,M as s,B as u,R as w};
@@ -1,4 +1,4 @@
1
- import{j as s,aB as T,B as d,aI as C,bm as j,bk as N,d as $,ad as k,a7 as A,bC as E,bX as f,bY as _,bZ as M,a as P,c as W,r as l,a2 as z,aw as x,ax as p,u as O,ac as B}from"./index-Bn8n_AsE.js";import{B as h,u as L}from"./useResultFolderIndex-CALTzfWS.js";import{B as y}from"./badge-CfQoDkmE.js";import{C as S}from"./circle-check-OUBTwy71.js";import{C as q}from"./copy-9W6V4dQI.js";import{E as D}from"./external-link-BYIIFw9_.js";import{f as U}from"./ErrorState-BXxvOnci.js";import{a as F}from"./sections-DwdsQ0ad.js";import{w as G}from"./help-copy-_K3IfQdg.js";import{S as H}from"./settings-screen-IjQOks0s.js";import"./useQueries-Bs7-L_2j.js";import"./kbd-PiHV4odS.js";import"./avatar-BgqBWztU.js";import"./chevron-left-CliOUq1O.js";import"./menu-znX-3dzE.js";import"./circle-help-DJ-Mtycd.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(T,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(q,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(D,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function w(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{j as s,aB as T,B as d,aI as C,bm as j,bk as N,d as $,ad as k,a7 as A,bC as E,bX as f,bY as _,bZ as M,a as P,c as W,r as l,a2 as z,aw as x,ax as p,u as O,ac as B}from"./index-CbgROAMc.js";import{B as h,u as L}from"./useResultFolderIndex-CUsiZy-x.js";import{B as y}from"./badge-CVkU5AQe.js";import{C as S}from"./circle-check-C2nNDGc4.js";import{C as q}from"./copy-lGbXnTE3.js";import{E as D}from"./external-link-DVW2CLL2.js";import{f as U}from"./ErrorState-PBZ1dcEl.js";import{a as F}from"./sections-DGb-88rO.js";import{w as G}from"./help-copy-DXfHEQFm.js";import{S as H}from"./settings-screen-DWFOIL8d.js";import"./useQueries-BC3Dqp3g.js";import"./kbd-Cbl9_QOh.js";import"./avatar-D89ARIcc.js";import"./chevron-left-DTfiqCyD.js";import"./menu-DYBcrWqA.js";import"./circle-help-C6RlLR_U.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(T,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(q,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(D,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function w(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:J(e.structure).join(`
3
3
  `),disclaimer:K}}function X(e){const{head:t,structure:n,disclaimer:a}=w(e);return[t,"","```",n,"```","",a].join(`
4
4
  `)}function ee(e){return`Message quarantined: ${e.failureCode} at ${e.failureStage}`}function se(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function te({entry:e,onCutBug:t}){return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:Y(e.failureStage)}),s.jsx("p",{className:"truncate text-xs text-fg-muted",title:e.failureMessage,children:e.failureMessage}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[e.mailboxRole&&s.jsx(y,{tone:"warning",children:j(e.mailboxRole)}),s.jsx("span",{className:"truncate",title:e.mailboxPath,children:N(e.mailboxPath,e.mailboxDelimiter)}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:se(e.quarantinedAt)}),e.attempts>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ne({entries:e,onCutBug:t}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),e.length>1&&s.jsx($,{tone:"warning",children:s.jsxs("p",{className:"flex items-start gap-2",children:[s.jsx(k,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:`${e.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(n=>s.jsx(te,{entry:n,onCutBug:t},n.quarantineId))})]})}const ae={Retrying:"The message could not be synced. Remit tries again every sync.",GaveUp:"The message body could not be downloaded. Remit has stopped trying."};function re(e){return ae[e.state]}const ie="_No message content, addresses, subject, folder name or error text are included._";function oe(e){return[`### Message failed to sync at \`${e.stage}\``,"",`- **State**: \`${e.state}\``,`- **Attempts**: ${e.attempts}`,"",ie].join(`
package/index.html CHANGED
@@ -35,7 +35,7 @@
35
35
  } catch (_) {}
36
36
  })();
37
37
  </script>
38
- <script type="module" crossorigin src="/assets/index-Bn8n_AsE.js"></script>
38
+ <script type="module" crossorigin src="/assets/index-CbgROAMc.js"></script>
39
39
  <link rel="stylesheet" crossorigin href="/assets/index-CqMlmBtY.css">
40
40
  </head>
41
41
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.685",
3
+ "version": "0.0.687",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{eM as U,r as n,e4 as $,a as le,J as z,c$ as ce,aw as ue,ax as ge,j as r}from"./index-Bn8n_AsE.js";import{y as he,A as me,ao as pe,aq as fe,aA as xe,ar as Ie,d as Te,M as ye,ax as ve,aB as be,az as Re,m as Ce,G as Se,K as _,J as we,H as je,e as Fe,V as Me,W as H,X as Oe,Z as X,_ as Z,$ as ke,a0 as Pe,a1 as Le}from"./MessageToolbar-BW852rJj.js";import{u as Ae,l as Ne,b as De,a as qe}from"./MailViewChrome-D66Dcy3c.js";import"./nav-link-CtuHya9S.js";import{a as Ee}from"./useMessageBodyContent-lqVkO1fM.js";import{e as Be,f as We}from"./search-token-index-BSaB7qLo.js";import{d as Qe,g as ze,r as He}from"./reply-DmpF7cgR.js";import{u as Ke}from"./sections-DwdsQ0ad.js";import{u as Ve}from"./useMediaQuery-C00TiD5k.js";import{u as Ge,p as J,R as _e}from"./MessageBody-CDTfM1lc.js";import{d as Je,w as Ue}from"./wizard-selection-zWa1qc6-.js";import{f as $e}from"./ErrorState-BXxvOnci.js";const K=t=>({...t,starred:!0,order:"desc"}),Xe=(t={})=>$({query:K(t)});function Y(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=Ae({queryKey:Xe(t),queryFn:async({pageParam:x})=>{const{data:u}=await U({query:{...K(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function Ze(t={}){const e={...K(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:$({query:e}),queryFn:async()=>{const{data:a}=await U({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const Ye=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=he(t),{params:a,residual:i}=me(e,{...s,starred:!0},Ye);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Re(),i=n.useMemo(()=>Ue(t,s),[t,s]);return r.jsx(Ce,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=z(),o=Ge(),k=Ve(),x=ce(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=J(f.trim().toLowerCase(),o),L=J(f.trim(),o).freeText,{criteria:A,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...A,query:j}:A,[A,j]),{threads:N,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=Y(F),p=n.useMemo(()=>Je(N).map(pe).filter(d=>fe(d,m)),[N,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>xe(),[]),se=n.useMemo(()=>p.map(d=>Ie(d,l)),[p,l]),ae=Ze(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=Ne({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),V=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ue(ge());window.open(d,"_blank","noopener,noreferrer")},[]),G=Te(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(ye,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),W?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>B(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(De,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(ve,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(qe,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:G.searchResults?"ready":V,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?$e(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(be,{title:"Starred"}),listBody:G.searchResults??(V==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=Be(),a=We(),i=Ke(),{searchInput:f}=z(),l=t?.threadId,g=t?.messageId,{threads:o}=Y(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=Se(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=_({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=we(),{deleteMessages:j}=je({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Fe({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=_({thread:m,isOpen:m?.messageId===h}),N=Ee(),D=Qe(),y=ze(),E=n.useMemo(()=>He(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Me({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!N&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(B),previousThread:O(W),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=H(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Pe(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Le,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(X,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(_e,{})})]}),r.jsx(Z,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=H(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=z();return r.jsx(ke,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=H(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=Oe(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(X,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx(Z,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const Tt=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{Tt as F};
@@ -1,135 +0,0 @@
1
- import{j as i,bU as Ns,ag as V,r as c,d as gt,B as ne,S as Os,p as Ae,t as _s,bc as zs,e as Mt,ak as Ht,cR as Fs,k as Ds,f as Rt,P as Ls,Q as Ps,a1 as Ut,cS as Bs,ck as $s,s as Ws,cT as Ks,a as pt,cU as Vs,cV as Qt,cW as Jt,cX as Ze,V as qs,cY as Hs,cv as Us,I as Qs,z as Js,T as Yt,cZ as Ys,c_ as Gt,c0 as Gs,c$ as Xs,d0 as Zs,d1 as en,d2 as tn,aw as sn,ax as nn,d3 as on,d4 as rn,l as At,i as ln,bh as an,U as cn,bi as un,bj as dn,J as Xt,_ as hn,bu as fn}from"./index-Bn8n_AsE.js";import{S as mn,M as gn,a as pn,u as xn,l as vn,b as bn}from"./MailViewChrome-D66Dcy3c.js";import{u as Zt,r as Sn,a as Nt,C as es,c as ts,j as yn,M as Cn,t as ss,b as wn,d as Tn,e as ns,f as os,g as In,h as kn,i as En,n as jn,k as Mn,S as Rn,l as An,D as Nn,m as On,o as _n,p as rs,q as zn,s as Fn,v as Dn,w as Ln,x as Pn,y as Bn,z as $n,A as Wn,B as Kn,E as Vn,F as qn,G as Hn,H as Bt,I as $t,J as Un,K as Qn,L as Jn,N as Yn,O as Gn,P as Xn,Q as Zn,R as eo,T as to,U as so,V as no,W as Ot,X as oo,Y as is,Z as ls,_ as as,$ as ro,a0 as io,a1 as lo,a2 as ao,a3 as co,a4 as uo,a5 as ho}from"./MessageToolbar-BW852rJj.js";import{e as et,f as fo,g as mo,h as go,i as po}from"./search-token-index-BSaB7qLo.js";import{u as xo}from"./useLayoutTier-Cn3SwiV2.js";import{u as vo,a as bo,R as So}from"./useRefreshControl-Bt-oDRnY.js";import{t as yo,L as Co,r as wo,s as To}from"./LabelApplyTrigger-C4ode0Y9.js";import{u as Io,p as Wt,R as ko}from"./MessageBody-CDTfM1lc.js";import{P as Eo,N as jo,n as Mo}from"./NavMenuButton-BZWw6TBA.js";import"./nav-link-CtuHya9S.js";import{d as Ro,g as Ao,a as No,u as Oo}from"./useMessageBodyContent-lqVkO1fM.js";import{g as _o,r as zo,d as Fo}from"./reply-DmpF7cgR.js";import{u as Do}from"./sections-DwdsQ0ad.js";import{A as _t}from"./avatar-BgqBWztU.js";import{C as Lo}from"./confirm-dialog-sa45Xnmn.js";import{f as Po}from"./calendar-BJu4Vl-g.js";import{a as Bo}from"./useLabels-DO4UWjpG.js";import{a as $o,D as Wo,u as Ko}from"./useMediaQuery-C00TiD5k.js";import{f as Vo}from"./ErrorState-BXxvOnci.js";import{S as xt}from"./shield-check-jkVgxi6o.js";import{B as qo}from"./bottom-sheet-Dhk1Aqz2.js";import{B as cs}from"./badge-CfQoDkmE.js";import{C as us}from"./checkbox-DL0pObJW.js";import{C as Ho}from"./chevron-down-BWbeCM3N.js";import{C as Uo}from"./circle-help-DJ-Mtycd.js";import{C as Qo}from"./circle-check-OUBTwy71.js";const Jo=e=>e.toLocaleString(),Yo=(e,o)=>{if(e.kind==="unknown")return`Results for “${o}”`;const t=e.value===1?"result":"results";return`${Jo(e.value)} ${t} for “${o}”`};function Go({query:e,count:o}){return i.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-surface-sunken/30 px-3 py-2",children:[i.jsx(Ns,{className:"size-4 text-fg-muted","aria-hidden":"true"}),i.jsx("span",{className:"text-sm text-fg-muted",children:Yo(o,e)})]})}var Xe;(function(e){e[e.UP=-1]="UP",e[e.DOWN=1]="DOWN"})(Xe||(Xe={}));function Xo(e){var o=getComputedStyle(e).overflowY;return e===document.scrollingElement&&o==="visible"?!0:!(o!=="scroll"&&o!=="auto")}function Zo(e,o){if(!Xo(e))return!1;if(o===Xe.DOWN){var t=e.scrollTop+e.clientHeight;return t<e.scrollHeight}if(o===Xe.UP)return e.scrollTop>0;throw new Error("unsupported direction")}function ds(e,o){return Zo(e,o)?!0:e.parentElement==null?!1:ds(e.parentElement,o)}function hs(e,o){o===void 0&&(o={});var t=o.insertAt;if(!(!e||typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t==="top"&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}var er=`.lds-ellipsis {
2
- display: inline-block;
3
- position: relative;
4
- width: 64px;
5
- height: 64px;
6
- }
7
-
8
- .lds-ellipsis div {
9
- position: absolute;
10
- top: 27px;
11
- width: 11px;
12
- height: 11px;
13
- border-radius: 50%;
14
- background: rgb(54, 54, 54);
15
- animation-timing-function: cubic-bezier(0, 1, 1, 0);
16
- }
17
-
18
- .lds-ellipsis div:nth-child(1) {
19
- left: 6px;
20
- animation: lds-ellipsis1 0.6s infinite;
21
- }
22
-
23
- .lds-ellipsis div:nth-child(2) {
24
- left: 6px;
25
- animation: lds-ellipsis2 0.6s infinite;
26
- }
27
-
28
- .lds-ellipsis div:nth-child(3) {
29
- left: 26px;
30
- animation: lds-ellipsis2 0.6s infinite;
31
- }
32
-
33
- .lds-ellipsis div:nth-child(4) {
34
- left: 45px;
35
- animation: lds-ellipsis3 0.6s infinite;
36
- }
37
-
38
- @keyframes lds-ellipsis1 {
39
- 0% {
40
- transform: scale(0);
41
- }
42
- 100% {
43
- transform: scale(1);
44
- }
45
- }
46
- @keyframes lds-ellipsis3 {
47
- 0% {
48
- transform: scale(1);
49
- }
50
- 100% {
51
- transform: scale(0);
52
- }
53
- }
54
- @keyframes lds-ellipsis2 {
55
- 0% {
56
- transform: translate(0, 0);
57
- }
58
- 100% {
59
- transform: translate(19px, 0);
60
- }
61
- }`;hs(er);var tr=function(){return V.createElement("div",{className:"lds-ellipsis"},V.createElement("div",null),V.createElement("div",null),V.createElement("div",null),V.createElement("div",null))},sr=function(){return V.createElement("div",null,V.createElement("p",null,"↧  pull to refresh  ↧"))},nr=`.ptr,
62
- .ptr__children {
63
- height: 100%;
64
- width: 100%;
65
- overflow: hidden;
66
- -webkit-overflow-scrolling: touch;
67
- position: relative;
68
- }
69
-
70
- .ptr.ptr--fetch-more-treshold-breached .ptr__fetch-more {
71
- display: block;
72
- }
73
-
74
- .ptr__fetch-more {
75
- display: none;
76
- }
77
-
78
- /**
79
- * Pull down transition
80
- */
81
- .ptr__children,
82
- .ptr__pull-down {
83
- transition: transform 0.2s cubic-bezier(0, 0, 0.31, 1);
84
- }
85
-
86
- .ptr__pull-down {
87
- position: absolute;
88
- overflow: hidden;
89
- left: 0;
90
- right: 0;
91
- top: 0;
92
- visibility: hidden;
93
- }
94
- .ptr__pull-down > div {
95
- display: none;
96
- }
97
-
98
- .ptr--dragging {
99
- /**
100
- * Hide PullMore content is treshold breached
101
- */
102
- }
103
- .ptr--dragging.ptr--pull-down-treshold-breached .ptr__pull-down--pull-more {
104
- display: none;
105
- }
106
- .ptr--dragging {
107
- /**
108
- * Otherwize, display content
109
- */
110
- }
111
- .ptr--dragging .ptr__pull-down--pull-more {
112
- display: block;
113
- }
114
-
115
- .ptr--pull-down-treshold-breached {
116
- /**
117
- * Force opacity to 1 is pull down trashold breached
118
- */
119
- }
120
- .ptr--pull-down-treshold-breached .ptr__pull-down {
121
- opacity: 1 !important;
122
- }
123
- .ptr--pull-down-treshold-breached {
124
- /**
125
- * And display loader
126
- */
127
- }
128
- .ptr--pull-down-treshold-breached .ptr__pull-down--loading {
129
- display: block;
130
- }
131
-
132
- .ptr__loader {
133
- margin: 0 auto;
134
- text-align: center;
135
- }`;hs(nr);var or=function(e){var o=e.isPullable,t=o===void 0?!0:o,s=e.canFetchMore,n=s===void 0?!1:s,r=e.onRefresh,a=e.onFetchMore,l=e.refreshingContent,u=l===void 0?V.createElement(tr,null):l,d=e.pullingContent,h=d===void 0?V.createElement(sr,null):d,g=e.children,m=e.pullDownThreshold,v=m===void 0?67:m,S=e.fetchMoreThreshold,b=S===void 0?100:S,C=e.maxPullDownDistance,p=C===void 0?95:C,x=e.resistance,E=x===void 0?1:x,T=e.backgroundColor,I=e.className,O=I===void 0?"":I,R=c.useRef(null),A=c.useRef(null),P=c.useRef(null),G=c.useRef(null),N=!1,q=!1,z=!1,F=0,ee=0;c.useEffect(function(){if(!(!t||!A||!A.current)){var j=A.current;return j.addEventListener("touchstart",B,{passive:!0}),j.addEventListener("mousedown",B),j.addEventListener("touchmove",de,{passive:!1}),j.addEventListener("mousemove",de),window.addEventListener("scroll",se),j.addEventListener("touchend",M),j.addEventListener("mouseup",M),document.body.addEventListener("mouseleave",M),function(){j.removeEventListener("touchstart",B),j.removeEventListener("mousedown",B),j.removeEventListener("touchmove",de),j.removeEventListener("mousemove",de),window.removeEventListener("scroll",se),j.removeEventListener("touchend",M),j.removeEventListener("mouseup",M),document.body.removeEventListener("mouseleave",M)}}},[g,t,r,v,p,n,b]),c.useEffect(function(){var j;if(!((j=R)===null||j===void 0)&&j.current){var U=R.current.classList.contains("ptr--fetch-more-treshold-breached");U||n&&ue()<b&&a&&(R.current.classList.add("ptr--fetch-more-treshold-breached"),q=!0,a().then(H).catch(H))}},[n,g]);var ue=function(){if(!A||!A.current)return-1;var j=window.scrollY,U=A.current.scrollHeight;return U-j-window.innerHeight},H=function(){requestAnimationFrame(function(){A.current&&(A.current.style.overflowX="hidden",A.current.style.overflowY="auto",A.current.style.transform="unset"),P.current&&(P.current.style.opacity="0"),R.current&&(R.current.classList.remove("ptr--pull-down-treshold-breached"),R.current.classList.remove("ptr--dragging"),R.current.classList.remove("ptr--fetch-more-treshold-breached")),N&&(N=!1),q&&(q=!1)})},B=function(j){z=!1,j instanceof MouseEvent&&(F=j.pageY),window.TouchEvent&&j instanceof TouchEvent&&(F=j.touches[0].pageY),ee=F,!(j.type==="touchstart"&&ds(j.target,Xe.UP))&&(A.current.getBoundingClientRect().top<0||(z=!0))},de=function(j){if(z){if(window.TouchEvent&&j instanceof TouchEvent?ee=j.touches[0].pageY:ee=j.pageY,R.current.classList.add("ptr--dragging"),ee<F){z=!1;return}j.cancelable&&j.preventDefault();var U=Math.min((ee-F)/E,p);U>=v&&(z=!0,N=!0,R.current.classList.remove("ptr--dragging"),R.current.classList.add("ptr--pull-down-treshold-breached")),!(U>=p)&&(P.current.style.opacity=(U/65).toString(),A.current.style.overflow="visible",A.current.style.transform="translate(0px, "+U+"px)",P.current.style.visibility="visible")}},se=function(j){q||n&&ue()<b&&a&&(q=!0,R.current.classList.add("ptr--fetch-more-treshold-breached"),a().then(H).catch(H))},M=function(){if(z=!1,F=0,ee=0,!N){P.current&&(P.current.style.visibility="hidden"),H();return}A.current&&(A.current.style.overflow="visible",A.current.style.transform="translate(0px, "+v+"px)"),r().then(H).catch(H)};return V.createElement("div",{className:"ptr "+O,style:{backgroundColor:T},ref:R},V.createElement("div",{className:"ptr__pull-down",ref:P},V.createElement("div",{className:"ptr__loader ptr__pull-down--loading"},u),V.createElement("div",{className:"ptr__pull-down--pull-more"},h)),V.createElement("div",{className:"ptr__children",ref:A},g,V.createElement("div",{className:"ptr__fetch-more",ref:G},V.createElement("div",{className:"ptr__loader ptr__fetch-more--loading"},u))))};const rr=({children:e,onRefresh:o,isRefreshing:t})=>$o(Wo)?e:i.jsx(or,{onRefresh:o,isPullable:!t,children:e}),ir=e=>e===1?"message":"messages";function lr({count:e,onReview:o,onDismiss:t,actionLabel:s="Review & rescue"}){return i.jsx(gt,{tone:"info",variant:"soft",onDismiss:t,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[i.jsx(xt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold text-fg",children:`${e} ${ir(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),i.jsx(ne,{variant:"primary",size:"sm",onClick:o,className:"self-start",children:s})]})})}const ar=(e,o)=>e==="vip"?"vip":e==="unknown"&&o==="md"?"unknown-pill":"hidden",fs=({senderTrust:e,size:o="sm",className:t})=>{const s=ar(e,o);return s==="vip"?i.jsx(Os,{className:Ae("text-warning shrink-0",o==="sm"&&"size-3.5",o==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?i.jsx("span",{className:Ae("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function cr({candidate:e,selected:o,onToggle:t,hideSender:s=!1}){const{senderName:n,senderAddress:r,subject:a,snippet:l,trustReason:u,trustSubReason:d,senderTrust:h}=e;return i.jsxs("label",{className:Ae("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",o?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[i.jsx(us,{className:"mt-0.5",checked:o,onChange:t,"aria-label":`${o?"Deselect":"Select"} ${s?a:`message from ${n}`}`}),!s&&i.jsx(_t,{name:n,email:r,size:"sm"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"truncate text-sm font-medium text-fg",children:n}),h&&i.jsx(fs,{senderTrust:h,size:"sm"}),i.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:r})]}),i.jsx("span",{className:"block truncate text-sm text-fg-muted",children:a}),i.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:l}),!s&&i.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.jsxs(cs,{tone:"positive",children:[i.jsx(xt,{className:"size-3","aria-hidden":!0}),u]}),i.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const ur=e=>{const o=new Map,t=[];for(const s of e){const n=(s.senderAddress||s.senderName).toLowerCase(),r=o.get(n);if(r){r.messages.push(s);continue}o.set(n,{key:n,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(n)}return t.map(s=>o.get(s)).sort((s,n)=>n.messages.length-s.messages.length)},dr=(e,o)=>{const t=e.messages.filter(s=>o.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Kt=e=>e===1?"message":"messages";function hr({group:e,selected:o,onToggleGroup:t,onToggleMessage:s}){const[n,r]=c.useState(!1),a=dr(e,o),l=e.messages.length,u=n?Ho:_s;return i.jsxs("div",{className:Ae(a!=="none"?"bg-positive/10":"bg-surface"),children:[i.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[i.jsx(us,{className:"mt-0.5",checked:a==="all",indeterminate:a==="some",onChange:()=>t(e,a!=="all"),"aria-label":`${a==="all"?"Deselect":"Select"} all ${l} ${Kt(l)} from ${e.senderName}`}),i.jsx(_t,{name:e.senderName,email:e.senderAddress,size:"sm"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&i.jsx(fs,{senderTrust:e.senderTrust,size:"sm"}),i.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),i.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.jsxs(cs,{tone:"positive",children:[i.jsx(xt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),i.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),i.jsxs("button",{type:"button",onClick:()=>r(d=>!d),"aria-expanded":n,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${l} ${Kt(l)}`,i.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),n&&i.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>i.jsx(cr,{candidate:d,selected:o.has(d.id),onToggle:()=>s(d.id),hideSender:!0},d.id))})]})}const zt=e=>e===1?"message":"messages",fr=(e,o)=>`Moves ${e===1?"this message":`these ${e} ${zt(e)}`} out of Spam to ${o} now. Nothing later.`,jt=(e,o)=>e.find(t=>t.id===o)?.label??"Inbox";function mr(){return i.jsx(gt,{tone:"info",variant:"soft",children:i.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function gr({candidates:e,selected:o,onToggle:t,onToggleGroup:s,onSelectAll:n,onSelectNone:r,onContinue:a,onCancel:l}){const[u,d]=c.useState(!1),h=o.size,g=c.useMemo(()=>ur(e),[e]);return i.jsxs("div",{className:"flex min-h-0 flex-col",children:[i.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[i.jsx(xt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),i.jsx(ne,{variant:"ghost",size:"sm",icon:i.jsx(Uo,{className:"size-3.5"}),onClick:()=>d(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),i.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&i.jsx("div",{className:"mt-2",children:i.jsx(mr,{})})]}),i.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[i.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),i.jsxs("span",{className:"flex gap-1",children:[i.jsx(ne,{variant:"ghost",size:"sm",onClick:n,children:"Select all"}),i.jsx(ne,{variant:"ghost",size:"sm",onClick:r,children:"Select none"})]})]}),i.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>i.jsx(hr,{group:m,selected:o,onToggleGroup:s,onToggleMessage:t},m.key))}),i.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[i.jsx(ne,{variant:"primary",onClick:a,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${zt(h)}`}),i.jsx(ne,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Cancel"})]})]})}function pr({count:e,folders:o,delimiter:t,destination:s,onPick:n,onMove:r,onBack:a}){const[l,u]=c.useState(!1);return i.jsxs("div",{className:"flex min-h-0 flex-col",children:[i.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),i.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),i.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:l?i.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:i.jsx(zs,{folders:o,selectedId:s,delimiter:t,onSelect:n,onCancel:()=>u(!1)})}):i.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[i.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),i.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:jt(o,s)}),i.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),i.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[i.jsx("p",{className:"text-2xs text-fg-subtle",children:fr(e,jt(o,s))}),i.jsx(ne,{variant:"primary",onClick:r,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),i.jsx(ne,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Back"})]})]})}function xr({count:e,destinationLabel:o,onClose:t}){return i.jsxs("div",{className:"flex min-h-0 flex-col",children:[i.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[i.jsx(Qo,{className:"size-10 text-positive","aria-hidden":!0}),i.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${zt(e)} out of Spam.`}),i.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${o}.`})]}),i.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:i.jsx(ne,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function vr({open:e,candidates:o,defaultDestinationId:t,availableFolders:s,delimiter:n,onConfirmMove:r,onCancel:a}){const[l,u]=c.useState("review"),[d,h]=c.useState(()=>e?new Set(o.map(T=>T.id)):new Set),[g,m]=c.useState(t),[v,S]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(u("review"),h(new Set(o.map(T=>T.id))),m(t),S(0)),b.current=e},[e,o,t]);const C=d.size,p=T=>{h(I=>{const O=new Set(I);return O.has(T)?O.delete(T):O.add(T),O})},x=(T,I)=>{h(O=>{const R=new Set(O);for(const A of T.messages)I?R.add(A.id):R.delete(A.id);return R})},E=()=>{const T=Array.from(d);S(T.length),r(T,g),u("done")};return i.jsxs(qo,{open:e,onClose:a,label:"Rescue from spam",dismissLabel:"Close rescue",children:[l==="review"&&i.jsx(gr,{candidates:o,selected:d,onToggle:p,onToggleGroup:x,onSelectAll:()=>h(new Set(o.map(T=>T.id))),onSelectNone:()=>h(new Set),onContinue:()=>u("destination"),onCancel:a}),l==="destination"&&i.jsx(pr,{count:C,folders:s,delimiter:n,destination:g,onPick:m,onMove:E,onBack:()=>u("review")}),l==="done"&&i.jsx(xr,{count:v,destinationLabel:jt(s,g),onClose:a})]})}const br=(e,o,t,s)=>`${e??""}|${o}|${t??""}|${s??""}`,Sr=({accountId:e,mailboxId:o})=>{const t=Mt(),{pushError:s}=Ht(),{requestAppointment:n}=Fs(),{trashByAccount:r}=Zt(),a=e?r.get(e):void 0,l=br(e,o,a?.mailboxId,a?.source),[u,d]=c.useState({scope:l});u.scope!==l&&d({scope:l});const h=u.scope===l?u:void 0,g=c.useCallback(()=>t.getQueryData(Ds())?.accounts.find(I=>I.accountId===e)?.folderAppointments.find(I=>I.role==="Trash")?.mailboxId??o,[t,e,o]),m=c.useRef(void 0),{mutateAsync:v,isPending:S}=Rt({...Ks(),meta:Ws(409),onMutate:()=>(m.current=l,{scope:l,listMailboxId:g()}),onSuccess:(x,E,T)=>{T.scope===l&&d({scope:l,deletedCount:x.deletedCount})},onError:(x,E,T)=>{const I=Bs(x);if(!I){s({title:"Couldn't empty Trash",detail:$s(x),error:x});return}T?.scope===l&&d({scope:l,refusal:I})},onSettled:(x,E,T,I)=>{m.current===I?.scope&&(m.current=void 0),Ls(t,Ps([I?.listMailboxId??o])),e&&t.invalidateQueries({queryKey:Ut({path:{accountId:e}})})}}),b=c.useCallback(()=>e?(d({scope:l}),v({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,l,v]),C=c.useCallback(()=>{b()},[b]),p=c.useCallback(()=>{const x=h?.refusal;x&&n({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:b})},[h,n,b]);return{emptyTrash:C,isEmptying:S&&m.current===l,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:p}},yr="We can verify this sender";function Cr(e){const{data:o}=pt({...Vs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(o?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:yr,trustSubReason:Sn(s.senderTrust),senderTrust:s.senderTrust}))}}const wr=6e4,Tr=({mailboxId:e,criteria:o,enabled:t})=>{const s={...o,count:!0,results:!1},{data:n}=pt({queryKey:Qt({path:{mailboxId:e},query:s}),queryFn:async()=>{const{data:r}=await Jt({path:{mailboxId:e},query:s,throwOnError:!0});return r},enabled:t,staleTime:wr});return t?yo(n?.count):{kind:"unknown"}},Ir=e=>{const o=new Set,t=[];for(const s of e)o.has(s.threadMessageId)||(o.add(s.threadMessageId),t.push(s));return t};function kr(e){const o=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:o?`To: ${o}`:"(No recipients)",timeLabel:Ze(e.updatedAt),isRead:!0}}function Er(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ze(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,...Nt(e)}}function jr({outboxMessages:e,accountId:o,imapThreads:t}){const s=e.filter(a=>a.status==="draft"&&a.accountId===o).map(kr),n=t.map(Er),r=[];return s.length>0&&r.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),n.length>0&&r.push({id:"imap-drafts",label:"On the server",threads:n}),r}const Mr=({label:e,count:o})=>i.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[i.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),i.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:o})]}),Rr=({row:e,isSelected:o,onOpen:t,onDelete:s,isDeleting:n})=>i.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ae("group",ts({active:o})),children:[i.jsx(Js,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),i.jsx(es,{thread:e}),i.jsx("div",{className:"flex items-center gap-1 shrink-0",children:i.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),s(e.id)},disabled:n,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:i.jsx(Yt,{className:"size-3.5"})})})]}),Ar=({row:e,isSelected:o,onOpen:t})=>{const s=!e.isRead;return i.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ae("group",ts({active:o})),children:[s&&i.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),i.jsx(_t,{name:e.fromName,email:e.fromEmail,size:"sm"}),i.jsx(es,{thread:e})]})};function Nr({accountId:e,selectedMessageId:o,imapThreads:t,title:s,unreadCount:n}){const r=Ro(),a=Ao(),l=et(),u=Mt(),{data:d}=pt(qs()),h=c.useMemo(()=>jr({outboxMessages:d?.items??[],accountId:e,imapThreads:t}),[d?.items,e,t]),g=Rt({...Us(),onSuccess:()=>{u.invalidateQueries({queryKey:Hs()})}}),m=b=>{g.mutate({path:{outboxMessageId:b}})},v=b=>{const C=t.find(p=>p.messageId===b)?.threadId;C&&l({threadId:C,messageId:b})},S=h.length===0;return i.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[i.jsx(Eo,{title:s,leading:i.jsx(jo,{}),children:(n??0)>0&&i.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[n," unread"]})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:S?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[i.jsx(Qs,{className:"size-8 text-fg-subtle"}),i.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),i.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):h.map(b=>i.jsxs("div",{children:[b.label&&i.jsx(Mr,{label:b.label,count:b.threads.length}),i.jsx("div",{className:"divide-y divide-line",children:b.threads.map(C=>b.id==="remit-drafts"?i.jsx(Rr,{row:C,isSelected:C.id===r,onOpen:a,onDelete:m,isDeleting:g.isPending},C.id):i.jsx(Ar,{row:C,isSelected:C.id===o,onOpen:v},C.id))})]},b.id))})]})}const ms=e=>e===1?"1 message":`${Gt(e)} messages`,Or=e=>({title:"Empty Trash?",description:`${ms(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),_r=(e,o={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=o;if(e==="unconfirmed"){const n=Ys(0,"unconfirmed",{trashFolderLabel:t});return{headline:n.title,body:n.description,actionLabel:n.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function zr({messageCount:e,isEmptying:o,deletedCount:t,refusalReason:s,trashFolderLabel:n,staleFolderLabel:r,onEmpty:a,onRepair:l,children:u}){const[d,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return i.jsx(i.Fragment,{children:u});const g=s?_r(s,{trashFolderLabel:n,staleFolderLabel:r}):void 0,m=Or(e);return i.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[i.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:i.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&i.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${ms(t)} erased from the mail server.`}),i.jsx(ne,{variant:"ghost",size:"sm",icon:i.jsx(Yt,{className:"size-3.5","aria-hidden":!0}),disabled:o||e<1,"aria-busy":o,onClick:()=>h(!0),children:o?"Emptying…":"Empty Trash"})]}),g&&i.jsx(gt,{tone:"warning",variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("p",{className:"font-semibold text-fg",children:g.headline}),i.jsx("p",{className:"text-sm",children:g.body}),i.jsx(ne,{variant:"primary",size:"sm",className:"self-start",onClick:l,children:g.actionLabel})]})})]})}),i.jsx("div",{className:"min-h-0 flex-1",children:u}),i.jsx(Lo,{isOpen:d,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),a()},onCancel:()=>h(!1)})]})}function Fr(e,o,t){const s=new Array(e);return new Proxy(s,{get(n,r,a){if(typeof r=="string"){const l=r.charCodeAt(0);if(l>=48&&l<=57){const u=+r;if(Number.isInteger(u)&&u>=0&&u<e){let d=n[u];if(!d){const h=o[u*2];d=n[u]={index:u,key:t(u),start:h,size:o[u*2+1],end:h+o[u*2+1],lane:0}}return d}}if(r==="length")return e}return Reflect.get(n,r,a)}})}function Pe(e,o,t){let s=t.initialDeps??[],n,r=!0;function a(){const l=e();return(l.length!==s.length||l.some((d,h)=>s[h]!==d))&&(s=l,n=o(...l),t?.onChange&&!(r&&t.skipInitialOnChange)&&t.onChange(n),r=!1),n}return a.updateDeps=l=>{s=l},a}function Vt(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const Dr=(e,o)=>Math.abs(e-o)<1.01,Lr=(e,o,t)=>{let s;return function(...n){e.clearTimeout(s),s=e.setTimeout(()=>o.apply(this,n),t)}};let Ge;const kt=()=>{if(Ge!==void 0)return Ge;if(typeof navigator>"u")return Ge=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ge=!0;const e=navigator.maxTouchPoints;return Ge=navigator.platform==="MacIntel"&&e!==void 0&&e>0},qt=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Pr=e=>e,Br=e=>{const o=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-o+1,n=new Array(s);for(let r=0;r<s;r++)n[r]=o+r;return n},$r=(e,o)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const n=a=>{const{width:l,height:u}=a;o({width:Math.round(l),height:Math.round(u)})};if(n(qt(t)),!s.ResizeObserver)return()=>{};const r=new s.ResizeObserver(a=>{const l=()=>{const u=a[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){n({width:d.inlineSize,height:d.blockSize});return}}n(qt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return r.observe(t,{box:"border-box"}),()=>{r.unobserve(t)}},mt={passive:!0},Wr=typeof window>"u"?!0:"onscrollend"in window,Kr=(e,o,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const r=e.options.useScrollendEvent&&Wr;let a=0;const l=r?null:Lr(n,()=>o(a,!1),e.options.isScrollingResetDelay),u=g=>()=>{a=t(s),l?.(),o(a,g)},d=u(!0),h=u(!1);return s.addEventListener("scroll",d,mt),r&&s.addEventListener("scrollend",h,mt),()=>{s.removeEventListener("scroll",d),r&&s.removeEventListener("scrollend",h)}},Vr=(e,o)=>Kr(e,o,t=>{const{horizontal:s,isRtl:n}=e.options;return s?t.scrollLeft*(n&&-1||1):t.scrollTop}),qr=(e,o,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),n=t.options.getItemKey(s);return t.itemSizeCache.get(n)??t.options.estimateSize(s)}if(o?.borderBoxSize){const s=o.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!o){const s=t.indexFromElement(e),n=t.options.getItemKey(s),r=t.itemSizeCache.get(n);if(r!==void 0)return r}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},Hr=(e,{adjustments:o=0,behavior:t},s)=>{var n,r;(r=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||r.call(n,{[s.options.horizontal?"left":"top"]:e+o,behavior:t})},Ur=Hr;class Qr{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,n;return((n=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(r=>{const a=()=>{const l=r.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,h]of this.elementsCache)if(h===l){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,r,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),t=null},observe:n=>{var r;return(r=s())==null?void 0:r.observe(n,{box:"border-box"})},unobserve:n=>{var r;return(r=s())==null?void 0:r.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{var s,n;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Pr,rangeExtractor:Br,onChange:()=>{},measureElement:qr,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const v=t[m];v!==void 0&&(r[m]=v)}const a=this.options;let l=null,u=null,d=!1;if(a!==void 0&&a.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,v=r.count,S=this.getMeasurements(),b=m>0?((s=S[0])==null?void 0:s.key)??a.getItemKey(0):null,C=m>0?((n=S[m-1])==null?void 0:n.key)??a.getItemKey(m-1):null;if(v!==m||m>0&&v>0&&(r.getItemKey(0)!==b||r.getItemKey(v-1)!==C)){d=!0;const E=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??S[0]:null;E&&(l=[E.key,this.getScrollOffset()-E.start]);const T=r.followOnAppend===!0?"auto":r.followOnAppend||null;T&&v>m&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||r.getItemKey(v-1)!==C)&&(u=T)}}this.options=r,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(l&&this.scrollOffset!==null){const[m,v]=l,S=this.getMeasurements(),{count:b,getItemKey:C}=this.options;let p=0;for(;p<b&&C(p)!==m;)p++;if(p<b){const x=S[p];if(x){const E=x.start+v;E!==this.scrollOffset&&(g=E-this.scrollOffset,this.scrollOffset=E,h=!0)}}}(h||u)&&(this.pendingScrollAnchor=[h?l[0]:null,h?l[1]:0,u,g])},this.notify=t=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,t)},this.maybeNotify=Pe(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,a)=>{if(a&&this._intendedScrollOffset===null&&r===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(r-this._intendedScrollOffset)<1.5&&(r=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=a?l===r?this.scrollDirection:l<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=a,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const r=this.scrollElement,a=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!kt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};r.addEventListener("touchstart",a,mt),r.addEventListener("touchend",l,mt),this.unsubs.push(()=>{r.removeEventListener("touchstart",a),r.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[r,a,l,u]=n;r!==null&&!l&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Pe(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,n,r,a,l,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:a,lanes:l,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=Pe(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:n,getItemKey:r,enabled:a,lanes:l,laneAssignmentMode:u,gap:d},h)=>{const g=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),l===1){const p=t*2;let x=this._flatMeasurements;if(!x||x.length<p){const I=new Float64Array(p);x&&m>0&&I.set(x.subarray(0,m*2)),x=I,this._flatMeasurements=x}let E;if(m===0)E=s+n;else{const I=m-1;E=x[I*2]+x[I*2+1]+d}for(let I=m;I<t;I++){const O=r(I),R=g.get(O),A=typeof R=="number"?R:this.options.estimateSize(I);x[I*2]=E,x[I*2+1]=A,E+=A+d}const T=Fr(t,x,r);return this.measurementsCache=T,T}const v=this.measurementsCache.slice(0,m),S=new Array(l).fill(void 0),b=new Float64Array(l);let C=0;for(let p=0;p<m;p++){const x=v[p];x&&(S[x.lane]===void 0&&C++,S[x.lane]=p,b[x.lane]=x.end)}for(let p=m;p<t;p++){const x=r(p),E=this.laneAssignments.get(p);let T,I;const O=u==="estimate"||g.has(x);if(E!==void 0&&this.options.lanes>1){T=E;const G=S[T],N=G!==void 0?v[G]:void 0;I=N?N.end+d:s+n}else if(C===l){let G=0,N=b[0],q=S[0];for(let z=1;z<l;z++){const F=b[z];(F<N||F===N&&S[z]<q)&&(G=z,N=F,q=S[z])}T=G,I=N+d,O&&this.laneAssignments.set(p,T)}else T=p%this.options.lanes,I=s+n,O&&this.laneAssignments.set(p,T);const R=g.get(x),A=typeof R=="number"?R:this.options.estimateSize(p),P=I+A;v[p]={index:p,start:I,size:A,end:P,key:x,lane:T},S[T]===void 0&&C++,S[T]=p,b[T]=P}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Pe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,n,r)=>t.length===0||s===0?(this.range=null,null):(this.range=Yr(t,s,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Pe(()=>{let t=null,s=null;const n=this.calculateRange();return n&&(t=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,n,r,a)=>r===null||a===null?[]:t({startIndex:r,endIndex:a,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,n=t.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const r=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,n-r),l=Math.min(this.options.count-1,n+r);return t>=a&&t<=l}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const s=this.indexFromElement(t),n=this.options.getItemKey(s),r=this.elementsCache.get(n);r!==t&&(r&&this.observer.unobserve(r),this.observer.observe(t),this.elementsCache.set(n,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var n,r;if(t<0||t>=this.options.count)return;let a,l,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(t),l=d[t*2],a=d[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;u=m.key,l=m.start,a=m.size}const h=this.itemSizeCache.get(u)??a,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=m?this.getTotalSize():0,S=((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:u,start:l,size:a,end:l+a,lane:0},g,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-v):S&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Pe(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r],u=s[l];n.push(u)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,r=this.options.lanes===1&&n!=null,a=gs(0,s.length-1,r?l=>n[l*2]:l=>Vt(s[l]).start,t);return Vt(s[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,n=0)=>{if(!this.scrollElement)return 0;const r=this.getSize(),a=this.getScrollOffset();s==="auto"&&(s=t>=a+r?"end":"start"),s==="center"?t+=(n-r)/2:s==="end"&&(t-=r);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getSize(),r=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(s==="auto")if(a.end>=r+n-this.options.scrollPaddingEnd)s="end";else if(a.start<=r+this.options.scrollPaddingStart)s="start";else return[r,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const l=s==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,a.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:n="auto"}={})=>{const r=this.getOffsetForAlignment(t,s),a=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:n="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getOffsetForIndex(t,s);if(!r)return;const[a,l]=r,u=this.now();this.scrollState={index:t,align:l,behavior:n,startedAt:u,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+t,r=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const r=s.length-1,a=this._flatMeasurements;a!=null?n=a[r*2]+a[r*2+1]:n=((t=s[r])==null?void 0:t.end)??0}else{const r=Array(this.options.lanes).fill(null);let a=s.length-1;for(;a>=0&&r.some(l=>l===null);){const l=s[a];r[l.lane]===null&&(r[l.lane]=l.end),a--}n=Math.max(...r.filter(l=>l!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&t.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(o)}applyScrollAdjustment(o,t){o!==0&&(kt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,n=s?s[0]:this.scrollState.lastTargetOffset,r=1,a=n!==this.scrollState.lastTargetOffset;if(!a&&Dr(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=r){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const l=this.getSize()||600,u=Math.abs(n-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=n,d||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const gs=(e,o,t,s)=>{for(;e<=o;){const n=(e+o)/2|0,r=t(n);if(r<s)e=n+1;else if(r>s)o=n-1;else return n}return e>0?e-1:0};function Jr(e,o,t){let s=0;for(;s<=o;){const n=(s+o)/2|0,r=e[n*2];if(r<t)s=n+1;else if(r>t)o=n-1;else return n}return s>0?s-1:0}function Yr(e,o,t,s,n){const r=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:r};if(s===1&&n!==null){const d=Jr(n,r,t);let h=d;const g=t+o;for(;h<r&&n[h*2]+n[h*2+1]<g;)h++;return{startIndex:d,endIndex:h}}let l=gs(0,r,d=>e[d].start,t),u=l;if(s===1)for(;u<r&&e[u].end<t+o;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<r&&d.some(g=>g<t+o);){const g=e[u];d[g.lane]=g.end,u++}const h=Array(s).fill(t+o);for(;l>=0&&h.some(g=>g>=t);){const g=e[l];h[g.lane]=g.start,l--}l=Math.max(0,l-l%s),u=Math.min(r,u+(s-1-u%s))}return{startIndex:l,endIndex:u}}const Et=typeof document<"u"?c.useLayoutEffect:c.useEffect;function Gr({useFlushSync:e=!0,directDomUpdates:o=!1,directDomUpdatesMode:t="transform",...s}){const n=c.useReducer(d=>d+1,0)[1],r=c.useRef({enabled:o,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});r.current.enabled=o,r.current.mode=t;const a=d=>{const h=r.current;if(!h.enabled||!h.container)return;const g=d.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const p=d.options.horizontal?"width":"height";h.container.style[p]=`${g}px`}const m=!!d.options.horizontal,v=h.mode==="transform",S=m?"left":"top",b=d.options.scrollMargin,C=d.getVirtualItems();for(const p of C){const x=p.start-b,E=d.elementsCache.get(p.key);E&&h.lastPositions.get(E)!==x&&(h.lastPositions.set(E,x),v?E.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:E.style[S]=`${x}px`)}},l={...s,onChange:(d,h)=>{var g;const m=r.current;let v=!0;if(m.enabled){a(d);const S=d.range,b=m.prevRange;v=!b||b.isScrolling!==d.isScrolling||b.startIndex!==S?.startIndex||b.endIndex!==S?.endIndex,v&&(m.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:d.isScrolling}:null)}v&&(e&&h?Gs.flushSync(n):n()),(g=s.onChange)==null||g.call(s,d,h)}},[u]=c.useState(()=>{const d=new Qr(l);return Object.assign(d,{containerRef:h=>{const g=r.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const v=d.options.horizontal?"width":"height";h.style[v]=`${m}px`}}})});return u.setOptions(l),Et(()=>u._didMount(),[]),Et(()=>u._willUpdate()),Et(()=>{a(u)}),u}function Xr(e){return Gr({observeElementRect:$r,observeElementOffset:Vr,scrollToFn:Ur,...e})}const Ft=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Zr=e=>`Select all ${Ft(e)}`,ei=(e,o)=>`All ${Gt(o)} ${Ft(e)} selected`,ti=({verb:e,confirmingDelete:o,hasSelection:t,junkMailboxId:s,currentMailboxId:n,deletableMessageId:r})=>{if(o)return{kind:"withheld"};if(e==="junk"){const a=yn(s,n);if(a!==void 0)return{kind:"unavailable",reason:a}}return t?{kind:"openWizard"}:e!=="delete"||r===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:r}},si=(e,o,t)=>e==="BACK"&&o&&t===void 0,ni=(e,o)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ze(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:ss(e.category),messageCount:o,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels,...Nt(e)}),oi=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:r,isChecked:a,onToggleCheck:l,onRowSelect:u,messageCount:d,isMultiSelectMode:h,onLongPress:g,isDesktop:m,density:v})=>i.jsx(Cn,{thread:ni(e,d),link:{mailboxId:o,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:n,density:v,isDesktop:m,onFocusRow:r,selection:{isChecked:a,onToggleCheck:l,onRowSelect:u,isMultiSelectMode:h,onLongPress:g}}),ri=c.memo(oi),ii=e=>{const o=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ze(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:ss(e.category),suspicious:o,...Nt(e)}},li=({thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:r,isChecked:a,onToggleCheck:l,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,onDelete:m,onToggleRead:v,density:S})=>{const[b,C]=c.useState("none"),p=et(),x=c.useCallback(R=>{navigator.vibrate?.(10),R==="trailing"?m(e.messageId):v(e.messageId,e.isRead),C("none")},[m,v,e.messageId,e.isRead]),E=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),T=c.useCallback(()=>{l(e.messageId)},[l,e.messageId]),I=c.useCallback(()=>{p({threadId:e.threadId,messageId:e.messageId})},[p,e.threadId,e.messageId]),O=wn(e.messageId,u);return g||d?i.jsx(ri,{thread:e,mailboxId:o,isSelected:t,isFocused:s,isTabStop:n,onFocusRow:r,isChecked:a,onToggleCheck:l,onRowSelect:u,isMultiSelectMode:d,onLongPress:h,isDesktop:g,density:S}):i.jsx("div",{role:"presentation",onPointerDownCapture:O.onMouseDown,onClickCapture:O.claimClick,onContextMenu:O.onContextMenu,children:i.jsx(mn,{thread:ii(e),selectionMode:!1,checked:!1,active:t,peek:b,onPeek:C,onToggleCheck:T,onLongPress:E,onOpen:I,onAct:x})})},ai=72,ci=32,ui=5,ps="remit:list-density",di=()=>{try{const e=localStorage.getItem(ps);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},hi=(e,o,t)=>wo(e.filter(s=>o.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,fi=({mailboxId:e,threads:o,selectedMessageId:t,isLoading:s,isError:n=!1,error:r,onRetry:a,searchQuery:l,searchPredicate:u,resultCount:d={kind:"unknown"},onDeleteMessages:h,isDeleting:g=!1,isMoving:m=!1,onLoadMore:v,hasMore:S=!1,isLoadingMore:b=!1,accountId:C,listTitle:p,listMeta:x,listFilter:E,listSearchText:T,listScopeLabel:I,onTriageContextChange:O,commandsRef:R,hideHeader:A=!1})=>{const P=c.useRef(null),G=et(),N=Ko(),q=Xs(),{verb:z,start:F,startFromSearch:ee}=q,ue=Zs(),H=!!l?.trim(),B=Tn(),{labels:de}=Bo(C),{pushError:se}=Ht(),[M,j]=c.useState(t),[U,ke]=c.useState(),D=c.useCallback(f=>{ke(y=>y===f?y:void 0),j(f)},[]),[oe,Be]=c.useState(di),Q=c.useCallback(()=>{Be(f=>{const y=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(ps,y)}catch{}return y})},[]),{toggleReadFor:Ee}=ns({mailboxId:e}),{junkMailboxId:Se}=os(C),ye=rs(Se,e),Ne=c.useMemo(()=>[{accountId:C,mailboxId:e}],[C,e]),{outcome:he,staleFolderLabel:$e,guessedMailboxId:We}=In(Ne),{selectedIds:L,selectedCount:$,hasSelection:re,isSelected:ie,toggle:le,select:ae,clearSelection:je,selectRange:Ce,setAnchor:Oe,selectAll:Ke,toggleAll:fe,intersectWith:tt}=kn(),Ve=_n($,N),[we,_]=c.useState(null),st=c.useCallback((f,y,be)=>{const Z=en(f,y,be,he);Z&&se(Z)},[se,he]),Me=H&&!!u,nt=`${e}|${JSON.stringify(u??{})}`,k=En({mailboxId:e,mailboxLabel:p,accountId:C,enabled:Me,predicateKey:nt,searchQuery:u??{},reportEnding:st}),ot=k.phase.kind,qe=k.clear,K=c.useCallback(()=>{ot==="escalated"&&qe(),je()},[je,qe,ot]),[rt,me]=c.useState(null),Te=c.useRef(null),ge=c.useRef(!1),_e=c.useRef(null),Re=!s&&o.length>0,pe=Xr({count:o.length,getScrollElement:()=>P.current,estimateSize:()=>oe==="compact"?ci:ai,overscan:ui}),He=t?o.findIndex(f=>f.messageId===t):-1,J=M?o.findIndex(f=>f.messageId===M):-1,ce=c.useCallback(f=>{if(f<0||f>=o.length)return;const y=o[f];if(Ve){le(y.messageId);return}Te.current=y.messageId,ge.current=!1,ke(y.messageId),j(y.messageId)},[o,Ve,le]),ze=c.useCallback(()=>{if(o.length===0)return;const f=J<0?0:Math.min(J+1,o.length-1);ce(f)},[o.length,J,ce]),it=c.useCallback(()=>{if(o.length===0)return;const f=J<=0?0:J-1;ce(f)},[o.length,J,ce]),Ue=c.useCallback(()=>ce(0),[ce]),Qe=c.useCallback(()=>ce(o.length-1),[ce,o.length]),Ie=c.useCallback(()=>{M&&le(M)},[M,le]),W=c.useMemo(()=>o.map(f=>f.messageId),[o]),Fe=c.useMemo(()=>{const f=[];for(const y of o)L.has(y.messageId)&&f.push({id:y.messageId,sender:y.fromName??y.fromEmail??"Unknown",email:y.fromEmail??"",subject:y.subject??"(No subject)",date:Ze(y.sentDate),accountId:C,mailboxId:y.mailboxId});return f},[o,L,C]),bt=c.useCallback((f,y)=>y.shiftKey?(Ce(W,f,M),!0):y.metaKey||y.ctrlKey?(le(f),!0):(K(),Oe(f),!1),[W,M,Ce,le,K,Oe]),lt=c.useCallback(f=>{!h||f.length===0||(_e.current=M??null,_(f))},[h,M]),De=c.useCallback(f=>{const y=jn(W,M,f);y!==void 0&&(Ce(W,y),Te.current=y,ge.current=!1,ke(void 0),j(y))},[W,M,Ce]),xe=c.useCallback(()=>De(-1),[De]),at=c.useCallback(()=>De(1),[De]),ct=c.useCallback(()=>{W.length>0&&Ke(W)},[W,Ke]),ut=c.useCallback(f=>{const y=ti({verb:f,confirmingDelete:we!==null,hasSelection:re,junkMailboxId:Se,currentMailboxId:e,deletableMessageId:h?M:void 0});return y.kind==="openWizard"?(F(f),!0):y.kind==="confirmDelete"?(lt([y.messageId]),!0):y.kind==="unavailable"?(se({severity:"warning",title:y.reason}),!0):y.kind==="withheld"},[we,h,re,Se,e,F,M,lt,se]),ve=c.useCallback((f,y)=>{const be=o.find(Z=>Z.messageId===f)?.threadId;be&&G({threadId:be,messageId:f},{replace:y?.replace})},[G,o]),dt=c.useCallback(()=>{M&&ve(M)},[M,ve]),Je=c.useRef(void 0),St=c.useCallback(f=>{Je.current=f,ve(f,{replace:!0})},[ve]);Mn({keyboardFocusedMessageId:U,openMessageId:t,enabled:N&&$===0,open:St});const Le=k.phase.kind==="escalated"?{scope:Ft(u??{}),total:k.phase.total,searchQuery:u??{},run:(f,y)=>k.runAction(f,void 0,y),stop:k.stop}:void 0,ht=c.useCallback(f=>{if(f.length===0){_(null);return}const y=new Set(f),be=o.findIndex(te=>y.has(te.messageId));let Z;for(let te=be+1;te<o.length;te++)if(!y.has(o[te].messageId)){Z=o[te].messageId;break}if(Z===void 0){for(let te=be-1;te>=0;te--)if(!y.has(o[te].messageId)){Z=o[te].messageId;break}}h?.(f),K(),_e.current=null,_(null),Z!==void 0&&(Te.current=Z,ge.current=!1,D(Z),N&&ve(Z,{replace:!0})),N||me(tn("delete",f.length,he))},[o,h,K,ve,N,D,he]),yt=c.useCallback(()=>{const f=_e.current;_e.current=null,_(null),f!==null&&(Te.current=f,ge.current=!1,D(f))},[D]),Ye=c.useMemo(()=>hi(o,L,C),[C,L,o]),Ct=c.useCallback(()=>{if(Le){ee();return}F("organize")},[Le,ee,F]),ft=c.useCallback(f=>{h?.([f])},[h]),wt=c.useCallback((f,y)=>{Ee([f],!y)},[Ee]),w=c.useCallback(f=>{N||ae(f)},[N,ae]),X=c.useCallback(()=>{if(k.isRunning||k.phase.kind==="counting"){k.stop();return}K()},[k,K]),Y=c.useCallback(()=>{k.clear()},[k]);c.useEffect(()=>{if(ge.current||!N&&t)return;const f=J>=0?J:He;f>=0&&pe.scrollToIndex(f,{align:"auto"})},[J,He,pe,N,t]),c.useEffect(()=>{if(!t)return;const f=Je.current===t;Je.current=void 0,!f&&(ge.current=!1,D(t))},[t,D]),c.useEffect(()=>{M&&(o.some(f=>f.messageId===M)||D(o[0]?.messageId))},[o,M,D]),c.useEffect(()=>{O?.({focusedMessageId:M,selectedIds:Array.from(L),hasList:Re})},[M,L,Re,O]);const Dt=c.useRef(O);Dt.current=O,c.useEffect(()=>()=>Dt.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{k.phase.kind!=="idle"||k.isRunning||tt(o.map(f=>f.messageId))},[o,tt,k.phase,k.isRunning]);const Lt=c.useRef(e);c.useEffect(()=>{Lt.current!==e&&(Lt.current=e,K())},[e,K]),Po({shouldBlockFn:({action:f})=>si(f,re,ue)?(K(),!0):!1,enableBeforeUnload:!1,disabled:!re||ue!==void 0}),c.useEffect(()=>{const f=P.current;if(!f||!S||!v)return;const y=()=>{if(b)return;const{scrollTop:be,scrollHeight:Z,clientHeight:te}=f;be+te>=Z-200&&v()};return f.addEventListener("scroll",y,{passive:!0}),y(),()=>f.removeEventListener("scroll",y)},[S,b,v]),c.useEffect(()=>{const f=Te.current;if(!f)return;const y=P.current?.querySelector(`[data-message-id="${f}"]`);y&&(Te.current=null,y.focus({preventScroll:!0}))}),c.useEffect(()=>{if(R){if(!Re){R.current=null;return}return R.current={focusNext:ze,focusPrevious:it,focusFirst:Ue,focusLast:Qe,openFocused:dt,toggleSelect:Ie,extendSelectDown:at,extendSelectUp:xe,selectAll:ct,clearSelection:()=>re?(K(),!0):!1,requestVerb:ut,toggleDensity:Q},()=>{R.current=null}}},[R,Re,ze,it,Ue,Qe,dt,Ie,at,xe,ct,re,K,ut,Q]);const Pt=s?"loading":n?"error":o.length===0?"empty":"ready",bs=n?Vo(r):void 0,Ss=c.useCallback(()=>{const f=sn(nn());window.open(f,"_blank","noopener,noreferrer")},[]),ys=[{id:"inbox",threads:[]}],Tt=W.length>0&&W.every(f=>L.has(f)),Cs=Me&&S&&Tt&&!g&&!m&&k.phase.kind==="idle"&&!k.isRunning,ws=g||m||k.isRunning,It=k.phase.kind==="escalated"?k.phase.total:k.progress?k.progress.total:$,Ts=k.runningAction?on(k.runningAction.kind,k.progress?.done??0,k.progress?.total??It):k.phase.kind==="counting"?"Counting matches…":k.phase.kind==="escalated"?ei(u??{},k.phase.total):void 0,Is=k.phase.kind!=="escalated"&&W.length>0?{checked:Tt,indeterminate:$>0&&!Tt,onChange:()=>fe(W)}:void 0,ks=k.runningAction?{value:k.progress?.done??0,max:k.progress?.total??It,tone:rn(k.runningAction.kind)}:void 0,Es=(k.isRunning||k.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:k.stop}}:k.phase.kind==="escalated"?{tone:"info",text:"",action:{label:"Clear selection",onClick:Y}}:Cs?{tone:"info",text:"",action:{label:Zr(u??{}),onClick:k.escalate}}:void 0)??(Ye?{tone:"warning",text:Ye}:void 0),js=i.jsx(Rn,{title:B.title||p,navSlot:B.navSlot,titleMeta:B.titleMeta,searchSlot:B.searchSlot,searchField:B.searchField,idleSlot:B.makeFilterSlot,count:It,onCancel:X,onDelete:()=>F("delete"),onMove:()=>F("move"),onOrganize:Ct,onJunk:ye?()=>F("junk"):void 0,onMarkRead:()=>F("markRead"),overflowSlot:C&&e&&$>0&&de.length>0?i.jsx(Co,{accountId:C,mailboxId:e,messageIds:Array.from(L)}):void 0,isBusy:ws,isCounting:k.phase.kind==="counting",selectAll:Is,statusLabel:Ts,progress:ks,notice:Es}),Ms=An(W,M),Rs=c.useCallback(f=>{ge.current=!0,D(f)},[D]),As=i.jsxs(i.Fragment,{children:[H&&l&&i.jsx(Go,{query:l,count:d}),i.jsxs("div",{ref:P,role:"listbox","aria-multiselectable":!0,"aria-label":p,className:"flex-1 overflow-y-auto",children:[i.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${pe.getTotalSize()}px`},children:pe.getVirtualItems().map(f=>{const y=o[f.index];return i.jsx("div",{role:"presentation","data-index":f.index,ref:pe.measureElement,className:Ae("absolute left-0 top-0 w-full border-b border-line",k.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:i.jsx(li,{thread:y,mailboxId:e,isSelected:t===y.messageId,isFocused:M===y.messageId,isTabStop:Ms===y.messageId,onFocusRow:Rs,isChecked:ie(y.messageId),onToggleCheck:le,onRowSelect:bt,isMultiSelectMode:Ve,onLongPress:w,isDesktop:N,onDelete:ft,onToggleRead:wt,density:oe})},f.key)})}),b&&i.jsx(gn,{})]})]});return i.jsxs(i.Fragment,{children:[rt&&!N&&i.jsx(gt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>me(null),children:rt}),i.jsx(pn,{listTitle:p,listMeta:x,sections:ys,flatList:!0,listState:B.searchResults?"ready":Pt,searchQuery:T,listFilter:E,listScopeLabel:I,errorMessage:bs,onRetry:a,onReportError:Ss,density:oe,selectedThreadId:t,onSelectThread:f=>ve(f),isDesktop:N,hideHeader:A,selectionBar:js,listBody:B.searchResults??(Pt==="ready"?As:void 0)}),i.jsx(Nn,{isOpen:we!==null,messageIds:we??[],outcome:he,accountId:C,trashFolderLabel:p,staleFolderLabel:$e,guessedMailboxId:We,isDeleting:g,onConfirm:ht,onCancel:yt}),i.jsx(On,{verb:z,accountId:C,mailboxId:e,mailboxLabel:p,selection:Fe,selectionRestriction:Ye?"spansAccounts":void 0,escalated:Le,escalatedProgress:k.progress,onFinished:K,onRunEnded:st})]})},mi=e=>Ut({path:{accountId:e}}),gi=e=>{const o=Mt(),t=At(),s=Rt({...ln(),onSuccess:()=>{t.recordEvent("sync.triggered"),o.invalidateQueries({queryKey:mi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},pi=({accountId:e,children:o})=>{const{triggerAsync:t,isPending:s}=gi(e);return i.jsx(rr,{onRefresh:t,isRefreshing:s,children:o})};function xi({accountId:e,currentMailboxId:o,candidates:t,onMove:s,children:n}){const[r,a]=c.useState(!1),l=At(),u=an(),{inboxMailboxId:d}=zn(e),h=Fn(e),{data:g}=pt({...cn({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>un({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:o,translator:u}),[g?.items,h,o,u]),v=c.useMemo(()=>d||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[d,m]),S=c.useRef(!1);c.useEffect(()=>{S.current||(S.current=!0,Dn(l,t.length))},[l,t.length]);const b=c.useCallback(()=>{Ln(l,t.length),a(!0)},[l,t.length]),C=c.useCallback((p,x)=>{Pn(l,{selected:p.length,total:t.length,toInbox:x===d}),s(p,x)},[l,t.length,d,s]);return i.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[i.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:i.jsx(lr,{count:t.length,onReview:b})}),i.jsx("div",{className:"min-h-0 flex-1",children:n}),i.jsx(vr,{open:r,candidates:t,defaultDestinationId:v,availableFolders:m,delimiter:dn(g?.items??[]),onConfirmMove:C,onCancel:()=>a(!1)})]})}const vi=50,xs=c.createContext(null);function vt(){const e=c.useContext(xs);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function bi({mailboxId:e,thread:o,children:t}){const s=et(),n=fo(),r=Do(),a=o?.threadId,l=o?.messageId,u=At(),{accounts:d,searchQuery:h,onToggleIntelligence:g,onSearchClearQuery:m}=Xt(),v=Io(),S=Mo(h),b=S.length>0,{freeText:C,tokens:p}=Wt(S,v),x=Wt(h.trim(),v).freeText,[E,T]=c.useState("all"),[I,O]=c.useState(new Set),R=c.useMemo(()=>({category:E,attributes:I}),[E,I]),A=c.useMemo(()=>Bn(R),[R]),P=b||$n(R),{params:G,residual:N}=Wn(p,A),q={order:"desc",...C?{query:C}:{},...G,...A},z={...q,limit:vi},F={category:z.category,unread:z.unread,starred:z.starred,attachments:z.attachments},ee=P?Qt({path:{mailboxId:e},query:z}):hn({path:{mailboxId:e},query:{order:"desc"}}),{data:ue,isLoading:H,isError:B,error:de,refetch:se,fetchNextPage:M,hasNextPage:j,isFetchingNextPage:U}=xn({queryKey:ee,queryFn:async({pageParam:w})=>{if(P){const{data:Y}=await Jt({path:{mailboxId:e},query:{...z,continuationToken:w},throwOnError:!0});return Y}const{data:X}=await fn({path:{mailboxId:e},query:{order:"desc",continuationToken:w},throwOnError:!0});return X},initialPageParam:void 0,getNextPageParam:w=>w.continuationToken,placeholderData:(w,X)=>ho(X?.queryKey,F)?w:void 0}),ke=Tr({mailboxId:e,criteria:q,enabled:To({hasSearchQuery:b,freeText:C,residualTokenCount:N.length})}),{accountId:D,isLoading:oe}=Kn(e),Be=mo({accounts:d}),Q=Vn(Ir(ue?.pages.flatMap(w=>w.items??[])??[]),N,D),Ee=c.useCallback(w=>{T(w)},[]),Se=c.useCallback(w=>{O(X=>{const Y=new Set(X);return Y.has(w)?Y.delete(w):Y.add(w),Y})},[]),ye=c.useCallback(()=>{T("all"),O(new Set)},[]),Ne=c.useCallback(()=>{ye(),m()},[ye,m]),he=vn({chips:R,tokens:p,reach:N.length>0?"loaded-pages":qn(z),onClear:Ne}),$e=a?Q.find(w=>w.messageId===l)??Q.find(w=>w.threadId===a):void 0,We=Hn(a,l),L=$e??We,$=l??L?.messageId,re=c.useMemo(()=>{if(a)return{threadId:a,mailboxId:L?.mailboxId??e,subject:L?.subject,messageId:$,authenticity:L?.authenticity}},[a,L,$,e]),ie=c.useCallback(w=>{$&&w.includes($)&&n()},[$,n]),{deleteMessages:le,isPending:ae}=Bt({mailboxId:e,onAfterOptimisticRemove:ie}),{moveMessages:je,isPending:Ce}=$t({mailboxId:e,accountId:D,onAfterOptimisticRemove:ie}),Oe=c.useRef(null),Ke=Un(),{listCommandsRef:fe,onTriageContextChange:tt,focusedMessageId:Ve,selectedIds:we}=Ke,_=Q.find(w=>w.messageId===Ve)??L,st=go({accounts:d})??null,Me=Qn({thread:L,isOpen:!0,mailboxId:e,accountId:D,onAfterOptimisticRemove:ie}),{draftsMailboxId:nt}=Jn(D),k=nt!==void 0&&nt===e,{archiveMailboxId:ot}=Yn(D),qe=Gn(),K=_o(),rt=c.useMemo(()=>zo(K,a,$),[K,a,$]),me=c.useMemo(()=>{if(_)return w=>K({threadId:_.threadId,messageId:_.messageId,mode:w})},[K,_]),Te=No(),ge=Fo(),_e=Oo(),Re=c.useCallback(w=>w?qe(w):[],[qe]),{toggleStar:pe}=Xn({threadId:_?.threadId??"",mailboxId:e}),{toggleReadFor:He}=ns({mailboxId:e,accountId:D}),{junkMailboxId:J}=os(D),ce=J!=null&&J===e,ze=rs(J,e),{candidates:it}=Cr(ce?J:void 0),{moveMessages:Ue}=$t({mailboxId:e,threadId:_?.threadId,accountId:D,onAfterOptimisticRemove:ie}),{deleteMessages:Qe}=Bt({mailboxId:e,threadId:_?.threadId,onAfterOptimisticRemove:ie}),{addressId:Ie,address:W}=Zn(_),{updateFlags:Fe}=eo({addressId:Ie,senderEmail:_?.fromEmail??void 0}),bt=c.useCallback(()=>me?.("reply"),[me]),lt=c.useCallback(()=>me?.("reply-all"),[me]),De=c.useCallback(()=>me?.("forward"),[me]),xe=c.useCallback(()=>Re(_),[Re,_]),at=c.useCallback(()=>{if(fe.current?.requestVerb("delete"))return;const w=xe();w.length>0&&Qe(w)},[fe,xe,Qe]),ct=c.useCallback(()=>{if(fe.current?.requestVerb("junk")||!ze)return;const w=xe();w.length!==0&&(to(u,{count:w.length,senderTrust:_?.senderTrust??"unknown",wasRescuable:_?so(_):!1}),Ue(w,ze))},[fe,ze,xe,Ue,u,_]),ut=c.useCallback(()=>{if(we.length>0){const w=!(_?.hasStars??!1),X=new Set(we);for(const Y of Q)X.has(Y.messageId)&&Y.hasStars!==w&&pe(Y.messageId,Y.hasStars);return}_&&pe(_.messageId,_.hasStars)},[we,Q,_,pe]),ve=c.useCallback(()=>{if(fe.current?.requestVerb("markRead"))return;const w=xe();if(w.length===0)return;const X=!(_?.isRead??!1);He(w,X)},[fe,xe,_,He]),dt=c.useCallback(()=>{if(!Ie)return;const w=W?.flags?.muted?.value!==!0;Fe({muted:{value:w}})},[Ie,W,Fe]),Je=c.useCallback(()=>{if(!Ie)return;const w=W?.flags?.vip?.value!==!0;Fe({vip:{value:w}})},[Ie,W,Fe]),St=c.useCallback(()=>{Oe.current?.open()},[]),Le=k?"drafts":ot===e?"archive":J===e?"junk":"inbox",ht=c.useRef("");c.useEffect(()=>{const w=ht.current;ht.current=S,S.length>0&&w.length===0&&u.recordEvent("search.submitted",{mailboxType:Le})},[S,Le,u]);const{goBack:yt,nextMessageId:Ye,previousMessageId:Ct}=no({context:Ke,orderedIds:Q.map(w=>w.messageId),selectedMessageId:$,enabled:!Te&&!ge,hasOpenThread:a!==void 0,onClose:n,handlers:{reply:bt,replyAll:lt,forward:De,delete:at,toggleStar:ut,toggleRead:ve,muteSender:dt,blockSender:L?St:void 0,vipSender:Je,markJunk:ct,toggleIntelligence:L?()=>Oe.current?.toggle():void 0,compose:_e,goBrief:()=>r("brief"),goInbox:()=>r("brief"),goSent:()=>r("brief"),goFlagged:()=>r("flagged"),goSettings:()=>r("settings")}}),ft=w=>{if(!w)return;const X=Q.find(Y=>Y.messageId===w);return X?{threadId:X.threadId,messageId:w}:void 0},wt={mailboxId:e,selectedMessageId:$,selectedThread:L,conversation:re,onOpenThread:s,threads:Q,isLoading:H,isError:B,error:de,mailboxAccountId:D,mailboxAccountLoading:oe,mailboxName:Be,unreadCount:st,isDraftsMailbox:k,isSpamFolder:ce,rescueCandidates:it,filterCategory:E,filterAttributes:I,onSelectFilterCategory:Ee,onToggleFilterAttribute:Se,onClearFilters:ye,listFilter:he,listSearchText:x||void 0,onToggleIntelligence:g,intelligenceRef:Oe,handleDeselectIfRemoved:ie,searchPredicate:b&&N.length===0?z:void 0,resultCount:ke,onDeleteMessages:le,onMoveMessages:je,isDeleting:ae,isMoving:Ce,onLoadMore:M,hasMore:j,isLoadingMore:U,onTriageContextChange:tt,listCommandsRef:fe,onRetry:()=>se(),onReply:rt,onToolbarDelete:Me.deleteThread,onToolbarStar:Me.toggleStar,isStarred:Me.isStarred,onToolbarMove:Me.moveThread,onBack:yt,nextThread:ft(Ye),previousThread:ft(Ct)};return i.jsx(xs.Provider,{value:wt,children:t})}function vs(){const{mailboxId:e,selectedMessageId:o,threads:t,isLoading:s,isError:n,error:r,onDeleteMessages:a,onMoveMessages:l,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,mailboxAccountId:v,mailboxName:S,unreadCount:b,isDraftsMailbox:C,isSpamFolder:p,rescueCandidates:x,onTriageContextChange:E,listCommandsRef:T,onRetry:I,filterCategory:O,filterAttributes:R,onSelectFilterCategory:A,onToggleFilterAttribute:P,onClearFilters:G,listFilter:N,listSearchText:q,searchPredicate:z,resultCount:F}=vt(),{searchQuery:ee,searchInput:ue,accounts:H,resultFolderIndex:B}=Xt(),de=xo(),se=et(),M=S??"Inbox",j=c.useMemo(()=>ao(),[]),{trashMailboxId:U}=co(v),ke=po({accounts:H}),{trashByAccount:D}=Zt(),oe=Sr({accountId:v,mailboxId:e}),Be=U!=null&&U===e,Q=c.useMemo(()=>v?[v]:[],[v]),{hasNewMail:Ee}=vo(),{state:Se,errorMessage:ye,refresh:Ne}=bo(Q,{onSettled:I}),he=c.useMemo(()=>i.jsx(So,{state:Se,onRefresh:Ne,label:`Refresh ${M}`,errorMessage:ye,hasUpdate:Ee(Q)}),[Se,Ne,M,ye,Ee,Q]),$e=c.useMemo(()=>t.map(ae=>uo(ae,B)),[t,B]),We=c.useCallback(ae=>{const je=ae.threadId??t.find(Ce=>Ce.messageId===ae.id)?.threadId;je&&se({threadId:je,messageId:ae.id},{mailboxId:ae.mailboxId??e,query:ue})},[e,se,ue,t]);if(C&&v)return i.jsx(Nr,{accountId:v,selectedMessageId:o,imapThreads:t,title:S??"Drafts",unreadCount:b??void 0});const L=i.jsx(fi,{mailboxId:e,threads:t,selectedMessageId:o,isLoading:s,isError:n,error:r,onRetry:I,searchQuery:ee,searchPredicate:z,resultCount:F,onDeleteMessages:a,isDeleting:u,isMoving:d,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:v,listTitle:M,listFilter:N,listSearchText:q,listScopeLabel:M,hideHeader:!0,onTriageContextChange:E,commandsRef:T}),$=H[0]?.accountId,re=de==="phone"&&$?i.jsx(pi,{accountId:$,children:L}):L,ie=p&&x.length>0&&v?i.jsx(xi,{accountId:v,currentMailboxId:e,candidates:x,onMove:l,children:re}):re,le=Be?i.jsx(zr,{messageCount:ke,isEmptying:oe.isEmptying,deletedCount:oe.deletedCount,refusalReason:oe.refusal?.reason,trashFolderLabel:S??void 0,staleFolderLabel:v?D.get(v)?.staleFolderPath:void 0,onEmpty:oe.emptyTrash,onRepair:oe.repair,children:ie}):ie;return i.jsx(bn,{title:M,unreadCount:b,preset:j,selectedCategory:O,activeFilters:R,onSelectCategory:A,onToggleFilter:P,onClearFilters:G,searchResults:$e,searchLoading:s,onSelectSearchResult:We,searchResultsInBody:!0,refreshControl:he,children:le})}function Si(){const e=Ot(),{mailboxId:o,mailboxAccountId:t,mailboxAccountLoading:s,selectedThread:n,conversation:r,onReply:a,onToolbarDelete:l,onToolbarStar:u,isStarred:d,onToolbarMove:h,handleDeselectIfRemoved:g,intelligenceRef:m,onOpenThread:v}=vt(),S=!!r,b=io(r?.threadId);is(m,b);const C=c.useRef(null),{railFits:p,openRail:x}=b;c.useEffect(()=>{if(!p)return;const T=n?.messageId??null;T&&C.current!==T&&n?.authenticity?.dkimMismatch&&(C.current=T,x())},[p,x,n?.messageId,n?.authenticity?.dkimMismatch]);const E=r?i.jsx(ls,{threadId:r.threadId,mailboxId:r.mailboxId,subject:r.subject,selectedMessageId:r.messageId,authenticity:r.authenticity,onOpenIntelligence:b.open,listOnScreen:!0}):i.jsx(ko,{});return i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[i.jsx(lo,{hasThread:S,messageId:r?.messageId,intelligenceOpen:b.isShowing,canToggleIntelligence:b.canToggle,onToggleIntelligence:b.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:S?l:void 0,onToggleStar:S?u:void 0,isStarred:d,moveContext:S&&t?{accountId:t,currentMailboxId:o,onMove:h}:void 0,moveContextLoading:s}),i.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:E})]}),i.jsx(as,{isOpen:b.drawerOpen,onClose:b.closeDrawer,thread:n,accountId:t,onAfterOptimisticRemove:g,onReplyWithText:e,onOpenThread:v})]})}function yi(){const e=Ot(),{mailboxAccountId:o,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:n,onOpenThread:r}=vt();return i.jsx(ro,{onClose:s,thread:t,accountId:o,onAfterOptimisticRemove:n,onReplyWithText:e,onOpenThread:r})}function Ci(){const e=Ot(),{mailboxAccountId:o,selectedThread:t,conversation:s,onOpenThread:n,onBack:r,nextThread:a,previousThread:l,handleDeselectIfRemoved:u,intelligenceRef:d}=vt(),h=oo(s?.threadId??null);return is(d,h),s?i.jsxs(i.Fragment,{children:[i.jsx(ls,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:r,onOpenIntelligence:h.toggle,onSwipeNext:a?()=>n(a):void 0,onSwipePrevious:l?()=>n(l):void 0,mobileIntelligenceOpen:h.isOpen}),i.jsx(as,{isOpen:h.isOpen,onClose:h.close,thread:t,accountId:o,onAfterOptimisticRemove:u,onReplyWithText:e,onOpenThread:n})]}):i.jsx(vs,{})}const Gi=Object.assign(bi,{List:vs,Reading:Si,Intelligence:yi,Phone:Ci});export{Gi as M};