@remit/web-client-dist 0.0.642 → 0.0.643

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 (160) hide show
  1. package/assets/BriefPane-CqQSh_ja.js +1 -0
  2. package/assets/{CalendarComposePane-CaFfehJ3.js → CalendarComposePane-C9l0zjP2.js} +1 -1
  3. package/assets/{CalendarComposeSeed-Qwwu-xz8.js → CalendarComposeSeed-CJm8rCY9.js} +1 -1
  4. package/assets/{CalendarShell-DdBSP0nU.js → CalendarShell-Dew68lMD.js} +1 -1
  5. package/assets/{EmptyState-DffMrivH.js → EmptyState-VLl0Xg-2.js} +1 -1
  6. package/assets/{ErrorState-zb46wwqB.js → ErrorState-DmeOZx31.js} +1 -1
  7. package/assets/FlaggedPane-h6xyDnuf.js +1 -0
  8. package/assets/{FullCompose-CtKaGlct.js → FullCompose-C4K-ff_q.js} +1 -1
  9. package/assets/MailListHeader-BrXXf1Yp.js +7 -0
  10. package/assets/{MailNav-CDMm535x.js → MailNav-3iRwz5bx.js} +1 -1
  11. package/assets/{MailShell-C6XAYw9R.js → MailShell-C7XYJEOC.js} +1 -1
  12. package/assets/{MailViewChrome-BcPAwjzq.js → MailViewChrome-7Gh2Vw-t.js} +1 -1
  13. package/assets/{MailboxPane-Bo_304LU.js → MailboxPane-0KW8VAei.js} +1 -1
  14. package/assets/{NavMenuButton-C7p7FLnh.js → NavMenuButton-B4_xZcAo.js} +1 -1
  15. package/assets/{OnboardingWizard-D15SDpIN.js → OnboardingWizard-Dyv1Jm6j.js} +1 -1
  16. package/assets/{OpenCalendarEvent-CVHpXp5y.js → OpenCalendarEvent-7dAQjmZ0.js} +1 -1
  17. package/assets/{OutboxPane-k7EI73dP.js → OutboxPane--7u1PWnp.js} +1 -1
  18. package/assets/_calendarObjectId-DZ45RvvI.js +1 -0
  19. package/assets/_mailboxId-mXLMaQIT.js +1 -0
  20. package/assets/_messageId-2G79mDVH.js +1 -0
  21. package/assets/_messageId-BproZqyb.js +1 -0
  22. package/assets/_messageId-Yux53ec8.js +1 -0
  23. package/assets/_outboxMessageId-CUrOyyD-.js +1 -0
  24. package/assets/_recurrenceId-7sRPMrJQ.js +1 -0
  25. package/assets/_threadId-BVoqj3ta.js +1 -0
  26. package/assets/_threadId-DClBqCRh.js +1 -0
  27. package/assets/_threadId-wGJAHiFc.js +1 -0
  28. package/assets/{_view._date-BjTcS5dY.js → _view._date-C-6t0plG.js} +1 -1
  29. package/assets/{accounts-BKh6zOiZ.js → accounts-BBm2Fri5.js} +1 -1
  30. package/assets/{advanced-AosgdV6N.js → advanced-C7IVSlq-.js} +1 -1
  31. package/assets/{appearance-lDYvlXFT.js → appearance-DHQkzl84.js} +1 -1
  32. package/assets/{attendee-row-CNSd4msf.js → attendee-row-BVnfl4Ln.js} +1 -1
  33. package/assets/{avatar-BU2Acypp.js → avatar-DD62C_eL.js} +1 -1
  34. package/assets/{bell-off-BDdZq1id.js → bell-off-CsR58N8X.js} +1 -1
  35. package/assets/{bottom-sheet-OT_uLnD0.js → bottom-sheet-BG2Fi0Lb.js} +1 -1
  36. package/assets/{brief-B3LHy3XK.js → brief-BkicXAec.js} +1 -1
  37. package/assets/brief-BmBsP3Eb.js +1 -0
  38. package/assets/{browser-ponyfill-BoSoM_yw.js → browser-ponyfill-vr6sMZpU.js} +1 -1
  39. package/assets/{bug-Byoam9SI.js → bug-BXkTcnP3.js} +1 -1
  40. package/assets/{calendar-BNN6Blwg.js → calendar-Bif9hwZM.js} +1 -1
  41. package/assets/{calendar-clash-strip-CuPoAcuA.js → calendar-clash-strip-CkUcFznp.js} +1 -1
  42. package/assets/{calendar-format-t5pknBPH.js → calendar-format-C1OfWDS9.js} +1 -1
  43. package/assets/{calendar-report-De_YSbMS.js → calendar-report-BY6VcRI-.js} +1 -1
  44. package/assets/{calendar-suggestion-BrsagLDp.js → calendar-suggestion-DSoR-sUT.js} +1 -1
  45. package/assets/{calendars-EiEYrDmO.js → calendars-DxQTaSZf.js} +1 -1
  46. package/assets/{card-BU0ZWUHk.js → card-DggbFcQC.js} +1 -1
  47. package/assets/{checkbox-nuTXvB_z.js → checkbox-DNsJWnQ9.js} +1 -1
  48. package/assets/chevron-left-DVuaPYD9.js +1 -0
  49. package/assets/{circle-check-BzcaYx-L.js → circle-check-DPWZDhPO.js} +1 -1
  50. package/assets/{circle-check-big-CdWGb9Cq.js → circle-check-big-CM7pZZbV.js} +1 -1
  51. package/assets/{circle-help-CVsjKp3b.js → circle-help-BtRmVPpF.js} +1 -1
  52. package/assets/{clock-qn7JbMhU.js → clock-B3HY3HEG.js} +1 -1
  53. package/assets/compose._-_outboxMessageId_-93yCdWlT.js +1 -0
  54. package/assets/compose._-_outboxMessageId_-BuD2Nqen.js +1 -0
  55. package/assets/compose._-_outboxMessageId_-CjOo7QgX.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-m9wrDxnm.js +1 -0
  57. package/assets/{config-import-DhjQZV7D.js → config-import-Fo3m7cZ7.js} +1 -1
  58. package/assets/{confirm-dialog-C4B2Czhl.js → confirm-dialog-CgLhcr4g.js} +1 -1
  59. package/assets/{copy-CJCBL3_e.js → copy-7B_A7tMm.js} +1 -1
  60. package/assets/{credential-steps-BMJ8NHk-.js → credential-steps-CnFqc5oP.js} +1 -1
  61. package/assets/{download-DG45yTbq.js → download-BG6KV76e.js} +1 -1
  62. package/assets/{file-json-Dgau07u1.js → file-json-DKDhkzal.js} +1 -1
  63. package/assets/{filters-BAGXXGHm.js → filters-BjhC4ukE.js} +1 -1
  64. package/assets/{flagged-H7_oalgM.js → flagged-BwEn5mqI.js} +1 -1
  65. package/assets/flagged-CtubMGA7.js +1 -0
  66. package/assets/{folders-BpqgnDKx.js → folders-QYetOmXD.js} +1 -1
  67. package/assets/{help-copy-Cv-E-JTH.js → help-copy-XLWHUTq9.js} +1 -1
  68. package/assets/{import-Br9u2yf5.js → import-BLX36zo9.js} +1 -1
  69. package/assets/index-2G79mDVH.js +1 -0
  70. package/assets/index-B52QS6i2.js +1 -0
  71. package/assets/{index-DQOjICLF.js → index-BUTEicLk.js} +1 -1
  72. package/assets/index-CvXSZNRB.js +1 -0
  73. package/assets/index-Cw1nSElr.js +1 -0
  74. package/assets/{index-TtetXNmc.js → index-DOsp5wL9.js} +4 -4
  75. package/assets/index-DU7GET4S.js +1 -0
  76. package/assets/{index-DDaQbjmr.js → index-DdgwCJ4v.js} +4 -4
  77. package/assets/index-RK66HQoS.js +1 -0
  78. package/assets/index-Yux53ec8.js +1 -0
  79. package/assets/index-dAmO05_k.js +1 -0
  80. package/assets/index-vr5V5mez.js +1 -0
  81. package/assets/{kbd-nBPX_mdB.js → kbd-DKvs5BdK.js} +1 -1
  82. package/assets/{labels-DZRbAx-h.js → labels-CW2ReWm4.js} +1 -1
  83. package/assets/{mail-CWorRVye.js → mail-BJPu5dwh.js} +1 -1
  84. package/assets/{mail-xh-X6l34.js → mail-CRm24o3R.js} +1 -1
  85. package/assets/{map-pin-DXPKFmKy.js → map-pin-CAgVIQRt.js} +1 -1
  86. package/assets/{menu-DziguOgy.js → menu-DeD_0Sd1.js} +1 -1
  87. package/assets/minus-0VqQt5wq.js +1 -0
  88. package/assets/{new-BErOQscw.js → new-CRtnsWv2.js} +1 -1
  89. package/assets/onboarding-50LVQxkR.js +1 -0
  90. package/assets/{onboarding-completion-Bvjs_wV7.js → onboarding-completion-D4p2yV8X.js} +1 -1
  91. package/assets/outbox-jzPfnLIS.js +1 -0
  92. package/assets/{pane-header-BKR2Qgp4.js → pane-header-DCDDVSaQ.js} +1 -1
  93. package/assets/{pencil-C_GgIxQ0.js → pencil-DxSaFuJ4.js} +1 -1
  94. package/assets/{popover-menu-eOwDgIAD.js → popover-menu-4krm3dWT.js} +1 -1
  95. package/assets/{refresh-cw-mlDi8LTp.js → refresh-cw-C_o59REw.js} +1 -1
  96. package/assets/{rich-text-BwY3htQf.js → rich-text-CdLRrg6I.js} +1 -1
  97. package/assets/{rich-text-spellcheck-worker-provider-CxrExxo5.js → rich-text-spellcheck-worker-provider-DAgr-VNc.js} +1 -1
  98. package/assets/{rotate-ccw-B_znez6Z.js → rotate-ccw-C7hQnwfM.js} +1 -1
  99. package/assets/{roving-focus-D45YIEXp.js → roving-focus-wLsuSVCZ.js} +1 -1
  100. package/assets/{row-actions-Bz2BO_Of.js → row-actions-CsDIFX2Z.js} +1 -1
  101. package/assets/{search-mirror-IklPpsgd.js → search-mirror-7ZjhpyaP.js} +1 -1
  102. package/assets/{search-token-index-DfEguIzE.js → search-token-index-Dbim5YtJ.js} +1 -1
  103. package/assets/{sections-BE-YkTuC.js → sections-BHPkRjh5.js} +1 -1
  104. package/assets/{senders-Byg0IyG1.js → senders-CNBlWIiG.js} +1 -1
  105. package/assets/settings-Cb-LOzr3.js +1 -0
  106. package/assets/{settings-screen-Qy0Wa0pr.js → settings-screen-CIUyvyDm.js} +1 -1
  107. package/assets/{shield-check-CCP0KBaU.js → shield-check-D6xreYrB.js} +1 -1
  108. package/assets/{suggested-vips-Cy_wCFhG.js → suggested-vips-Da8IuYnJ.js} +1 -1
  109. package/assets/{suggestion._suggestionId-BaL7q4AC.js → suggestion._suggestionId-CjvTvFz8.js} +1 -1
  110. package/assets/{undo-2-DBjV60-m.js → undo-2-BVpzm_lb.js} +1 -1
  111. package/assets/{useCalendarData-TdBIWROH.js → useCalendarData-D9NX1A9R.js} +1 -1
  112. package/assets/{useCalendarFreeBusy-BCLJxOfD.js → useCalendarFreeBusy-B6fKe2s-.js} +1 -1
  113. package/assets/{useCalendarWrites-CcZJoofA.js → useCalendarWrites-DUx11oF3.js} +1 -1
  114. package/assets/{useCalendars-NXobBPn1.js → useCalendars-BLmllCqQ.js} +1 -1
  115. package/assets/{useDebouncedValue-Dy_g2v71.js → useDebouncedValue-DvXNnDTh.js} +1 -1
  116. package/assets/{useFilters-Dsrj-I6z.js → useFilters-C3B6gyy8.js} +1 -1
  117. package/assets/{useLabels--WOniDuk.js → useLabels-BY5yOSXl.js} +1 -1
  118. package/assets/{useLayoutTier-BnLysTvl.js → useLayoutTier-CbC-hQRr.js} +1 -1
  119. package/assets/{useMessageBodyContent-Azq1Bngf.js → useMessageBodyContent-DRTP4wa0.js} +1 -1
  120. package/assets/{useQueries-D1STUKB_.js → useQueries-B9KsAw6v.js} +1 -1
  121. package/assets/{useRefreshControl-CQDCO_Sz.js → useRefreshControl-BQetpFZ3.js} +1 -1
  122. package/assets/{useResultFolderIndex-TIwJLY0y.js → useResultFolderIndex-IoXcSy-p.js} +1 -1
  123. package/assets/{useSearchTokenContext-DjY64Paa.js → useSearchTokenContext-DMIJPqzA.js} +1 -1
  124. package/assets/{useSemanticSearch-NH8DKMle.js → useSemanticSearch-BTlz1ruP.js} +1 -1
  125. package/assets/{useSignature-DbI73u9N.js → useSignature-Cbp58mOz.js} +1 -1
  126. package/index.html +1 -1
  127. package/package.json +1 -1
  128. package/assets/BriefPane-DTu07n2X.js +0 -1
  129. package/assets/FlaggedPane-StYE07Pk.js +0 -1
  130. package/assets/MailListHeader-DMMl8ZLg.js +0 -7
  131. package/assets/_calendarObjectId-BmWKOwZU.js +0 -1
  132. package/assets/_mailboxId-C5oOoR9Y.js +0 -1
  133. package/assets/_messageId-BQu6o3gE.js +0 -1
  134. package/assets/_messageId-CUK6OwnE.js +0 -1
  135. package/assets/_messageId-DiKCBlFd.js +0 -1
  136. package/assets/_outboxMessageId-BLqK1FUW.js +0 -1
  137. package/assets/_recurrenceId-CTMy5M6x.js +0 -1
  138. package/assets/_threadId-BQ2ENDxN.js +0 -1
  139. package/assets/_threadId-B_-kfUCd.js +0 -1
  140. package/assets/_threadId-CRbs6xQJ.js +0 -1
  141. package/assets/brief-DfHqHUx0.js +0 -1
  142. package/assets/chevron-left-BmceVyuQ.js +0 -1
  143. package/assets/compose._-_outboxMessageId_-CTOa6VlX.js +0 -1
  144. package/assets/compose._-_outboxMessageId_-DX18bVb7.js +0 -1
  145. package/assets/compose._-_outboxMessageId_-Drm1AU0Y.js +0 -1
  146. package/assets/compose._-_outboxMessageId_-SBimViM1.js +0 -1
  147. package/assets/flagged-BG7vNsSo.js +0 -1
  148. package/assets/index-BAIv4ARz.js +0 -1
  149. package/assets/index-BD8lc3NR.js +0 -1
  150. package/assets/index-BQu6o3gE.js +0 -1
  151. package/assets/index-BsPhXbkV.js +0 -1
  152. package/assets/index-COeV6qmo.js +0 -1
  153. package/assets/index-CXwf_sz5.js +0 -1
  154. package/assets/index-D-2HKiNE.js +0 -1
  155. package/assets/index-DiKCBlFd.js +0 -1
  156. package/assets/index-DwXDHT3g.js +0 -1
  157. package/assets/minus-RD6yC1uS.js +0 -1
  158. package/assets/onboarding-DJEkQ9iZ.js +0 -1
  159. package/assets/outbox-CobBj7od.js +0 -1
  160. package/assets/settings-EmCICmfl.js +0 -1
@@ -1 +1 @@
1
- import{e}from"./index-DDaQbjmr.js";const d=e("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const h=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{d as C,h as S};
1
+ import{e}from"./index-DdgwCJ4v.js";const d=e("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const h=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{d as C,h as S};
@@ -1 +1 @@
1
- import{j as t,an as e}from"./index-DDaQbjmr.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
1
+ import{j as t,an as e}from"./index-DdgwCJ4v.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
@@ -1 +1 @@
1
- import{r as m,j as c}from"./index-DDaQbjmr.js";import{y as b,C as D,j as x,s as w}from"./calendar-suggestion-BrsagLDp.js";import{e as C,p as T,a as j,E as v,u as A,C as k}from"./CalendarComposePane-CaFfehJ3.js";import{E as N}from"./EmptyState-DffMrivH.js";import{e as F,h as O,u as R,d as E,f as Z,U as L}from"./useCalendars-NXobBPn1.js";import{c as P}from"./calendar-report-De_YSbMS.js";import{M as U,n as H}from"./calendar-format-t5pknBPH.js";import"./ErrorState-zb46wwqB.js";import"./calendar-clash-strip-CuPoAcuA.js";import"./useQueries-D1STUKB_.js";function z(e,t,d){const n={title:e.summary,location:e.location};if(e.allDay){const o=e.dtStart.slice(0,10),i=e.dtEnd.slice(0,10);return{...C(o,t),...n,allDay:!0,startTime:"",endDate:i>o?F(i,-1):o,endTime:""}}const a=o=>e.zoneCertainty==="Ambiguous"?o:O(o,d),s=a(e.dtStart),l=a(e.dtEnd);return{...C(s.slice(0,10),t),...n,startTime:s.slice(11,16),endDate:l.slice(0,10),endTime:l.slice(11,16)}}function B(e,t,d,n){const a=T(t,d,n);if(!a.ok)return a;const l=e.zoneCertainty==="Ambiguous"||a.patch.start!==void 0?{...a.patch,...j(d,n.clock),allDay:d.allDay,timeZone:n.anchor}:a.patch;return{ok:!0,input:{calendarId:d.calendarId,event:l}}}const g="Add from mail",M="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function _({suggestionId:e,onClose:t}){const{suggestion:d,isLoading:n,error:a}=b(e),s=d??void 0,[l,o]=m.useState(void 0);s!==void 0&&l===void 0&&o(s);const i=l??s;if(i!==void 0)return c.jsx($,{suggestion:i,onClose:t},i.suggestionId);if(a!==null){const u="Couldn't read what your mail is waiting on.";return c.jsx(v,{title:g,onClose:t,children:c.jsx(D,{text:`${u} Close this and try again.`,reportHref:P(u),className:"m-row-inset"})})}return c.jsx(v,{title:g,onClose:t,children:c.jsx(N,{message:n?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function $({suggestion:e,onClose:t}){const{calendars:d,defaultCalendarId:n,timeZoneByCalendarId:a}=R(),s=d.filter(r=>!r.readOnly),l=x(),[o]=m.useState(()=>z(e,"",E())),[i,u]=m.useState(o),[y,f]=m.useState(""),S=A(i),p=s.some(r=>r.id===n)?n:s[0]?.id??"";m.useEffect(()=>{p!==""&&u(r=>r.calendarId===""?{...r,calendarId:p}:r)},[p]);const I=()=>{const r=B(e,o,i,{clock:E(),anchor:Z(a[i.calendarId]??L)});if(!r.ok){f(r.problem);return}f(""),l.acceptEdited(e.suggestionId,r.input).then(h=>{if(h.kind==="answered"){t();return}f(`Couldn't add this to your calendar: ${h.message}`)})};return c.jsx(k,{title:g,subtitle:w(e),notice:e.zoneCertainty==="Ambiguous"?M:"",calendars:s,draft:i,onChange:u,problem:y,saveLabel:"Add",isSaving:l.isAnswering,repeatEditable:!1,clashes:S,onSave:I,onCancel:t})}function te(){const e=U(),{closeEvent:t}=H();return e===void 0?null:c.jsx(_,{suggestionId:e,onClose:t})}export{te as component};
1
+ import{r as m,j as c}from"./index-DdgwCJ4v.js";import{y as b,C as D,j as x,s as w}from"./calendar-suggestion-DSoR-sUT.js";import{e as C,p as T,a as j,E as v,u as A,C as k}from"./CalendarComposePane-C9l0zjP2.js";import{E as N}from"./EmptyState-VLl0Xg-2.js";import{e as F,h as O,u as R,d as E,f as Z,U as L}from"./useCalendars-BLmllCqQ.js";import{c as P}from"./calendar-report-BY6VcRI-.js";import{M as U,n as H}from"./calendar-format-C1OfWDS9.js";import"./ErrorState-DmeOZx31.js";import"./calendar-clash-strip-CkUcFznp.js";import"./useQueries-B9KsAw6v.js";function z(e,t,d){const n={title:e.summary,location:e.location};if(e.allDay){const o=e.dtStart.slice(0,10),i=e.dtEnd.slice(0,10);return{...C(o,t),...n,allDay:!0,startTime:"",endDate:i>o?F(i,-1):o,endTime:""}}const a=o=>e.zoneCertainty==="Ambiguous"?o:O(o,d),s=a(e.dtStart),l=a(e.dtEnd);return{...C(s.slice(0,10),t),...n,startTime:s.slice(11,16),endDate:l.slice(0,10),endTime:l.slice(11,16)}}function B(e,t,d,n){const a=T(t,d,n);if(!a.ok)return a;const l=e.zoneCertainty==="Ambiguous"||a.patch.start!==void 0?{...a.patch,...j(d,n.clock),allDay:d.allDay,timeZone:n.anchor}:a.patch;return{ok:!0,input:{calendarId:d.calendarId,event:l}}}const g="Add from mail",M="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function _({suggestionId:e,onClose:t}){const{suggestion:d,isLoading:n,error:a}=b(e),s=d??void 0,[l,o]=m.useState(void 0);s!==void 0&&l===void 0&&o(s);const i=l??s;if(i!==void 0)return c.jsx($,{suggestion:i,onClose:t},i.suggestionId);if(a!==null){const u="Couldn't read what your mail is waiting on.";return c.jsx(v,{title:g,onClose:t,children:c.jsx(D,{text:`${u} Close this and try again.`,reportHref:P(u),className:"m-row-inset"})})}return c.jsx(v,{title:g,onClose:t,children:c.jsx(N,{message:n?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function $({suggestion:e,onClose:t}){const{calendars:d,defaultCalendarId:n,timeZoneByCalendarId:a}=R(),s=d.filter(r=>!r.readOnly),l=x(),[o]=m.useState(()=>z(e,"",E())),[i,u]=m.useState(o),[y,f]=m.useState(""),S=A(i),p=s.some(r=>r.id===n)?n:s[0]?.id??"";m.useEffect(()=>{p!==""&&u(r=>r.calendarId===""?{...r,calendarId:p}:r)},[p]);const I=()=>{const r=B(e,o,i,{clock:E(),anchor:Z(a[i.calendarId]??L)});if(!r.ok){f(r.problem);return}f(""),l.acceptEdited(e.suggestionId,r.input).then(h=>{if(h.kind==="answered"){t();return}f(`Couldn't add this to your calendar: ${h.message}`)})};return c.jsx(k,{title:g,subtitle:w(e),notice:e.zoneCertainty==="Ambiguous"?M:"",calendars:s,draft:i,onChange:u,problem:y,saveLabel:"Add",isSaving:l.isAnswering,repeatEditable:!1,clashes:S,onSave:I,onCancel:t})}function te(){const e=U(),{closeEvent:t}=H();return e===void 0?null:c.jsx(_,{suggestionId:e,onClose:t})}export{te as component};
@@ -1 +1 @@
1
- import{e as a}from"./index-DDaQbjmr.js";const o=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{o as U};
1
+ import{e as a}from"./index-DdgwCJ4v.js";const o=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{o as U};
@@ -1 +1 @@
1
- import{r as m}from"./index-DDaQbjmr.js";import{u as C,d as g,i as I,t as v,U as p,b as D,r as E}from"./useCalendars-NXobBPn1.js";import{x as y,I as L}from"./calendar-format-t5pknBPH.js";function Z(a,n){const t=a.map(e=>e.id);if(n.length===0)return t;const s=new Set(n),o=t.filter(e=>s.has(e));return o.length===0?t:o}function b(a){const{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,isLoading:o}=C(),e=Z(n,a),r=e.length===n.length?[]:e,c=a.length===0||n.length>0;return{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,shown:e,narrowed:r,resolved:c,isLoading:o}}function x(a,n,t){const s=t.join(",");return m.useMemo(()=>{const o=g(),e=new Set(s===""?[]:s.split(","));return a.filter(r=>I(r)&&e.has(r.calendarId)).map(r=>v(r,n[r.calendarId]??p,o))},[a,n,s])}function S({view:a,date:n,calendarIds:t,enabled:s=!0}){const{calendars:o,colorByCalendarId:e,timeZoneByCalendarId:r,shown:c,narrowed:l,resolved:u,isLoading:w}=b(t),h=D(a,n),i=s&&u,d=y({...h,calendarIds:l,enabled:i});L(a,n,l,i);const f=x(d.instances,r,c);return{calendars:o,events:f,colorByCalendarId:e,timeZoneByCalendarId:r,isLoading:w||d.isLoading,error:d.error,retry:d.refetch,instanceOf:E}}export{x as a,S as b,b as u};
1
+ import{r as m}from"./index-DdgwCJ4v.js";import{u as C,d as g,i as I,t as v,U as p,b as D,r as E}from"./useCalendars-BLmllCqQ.js";import{x as y,I as L}from"./calendar-format-C1OfWDS9.js";function Z(a,n){const t=a.map(e=>e.id);if(n.length===0)return t;const s=new Set(n),o=t.filter(e=>s.has(e));return o.length===0?t:o}function b(a){const{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,isLoading:o}=C(),e=Z(n,a),r=e.length===n.length?[]:e,c=a.length===0||n.length>0;return{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,shown:e,narrowed:r,resolved:c,isLoading:o}}function x(a,n,t){const s=t.join(",");return m.useMemo(()=>{const o=g(),e=new Set(s===""?[]:s.split(","));return a.filter(r=>I(r)&&e.has(r.calendarId)).map(r=>v(r,n[r.calendarId]??p,o))},[a,n,s])}function S({view:a,date:n,calendarIds:t,enabled:s=!0}){const{calendars:o,colorByCalendarId:e,timeZoneByCalendarId:r,shown:c,narrowed:l,resolved:u,isLoading:w}=b(t),h=D(a,n),i=s&&u,d=y({...h,calendarIds:l,enabled:i});L(a,n,l,i);const f=x(d.instances,r,c);return{calendars:o,events:f,colorByCalendarId:e,timeZoneByCalendarId:r,isLoading:w||d.isLoading,error:d.error,retry:d.refetch,instanceOf:E}}export{x as a,S as b,b as u};
@@ -1 +1 @@
1
- import{e as R,t as c,j as e,r as N,W as D,X as P,ar as T,dp as Z,f as z,aQ as I,ah as L,eu as O,s as _}from"./index-DDaQbjmr.js";import{c as F,R as B,C as W}from"./calendar-format-t5pknBPH.js";import{M as C}from"./mail-xh-X6l34.js";import{G as A}from"./map-pin-DXPKFmKy.js";import{u as G}from"./useQueries-D1STUKB_.js";const U=R("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function X(s){const n=F(s.color),a=s.rsvp==="tentative"||s.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",n.soft,n.text,n.rail,s.layout==="column"||s.stacked?"flex-col":"items-center gap-1.5",a&&"border-y border-r border-dashed",a&&n.border,s.rsvp==="declined"&&"opacity-60",s.selected&&"ring-2 ring-ring",s.density==="compact"?"text-2xs":"text-xs")}function $({title:s,timeText:n,layout:a,rsvp:l,hasThread:d,isRecurring:m,zoneCertainty:u,trailing:t,detail:p}){const r=a==="column",i=u==="ambiguous",o=!r&&p!==void 0,x=e.jsxs("span",{className:c("flex min-w-0 items-center gap-1",r&&"w-full",l==="declined"&&"line-through"),children:[n!==""&&e.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:n}),e.jsx("span",{className:"truncate font-medium",children:s})]}),h=(m||d||i)&&e.jsxs("span",{className:c("flex shrink-0 items-center gap-1",r&&"mt-0.5",!r&&t===void 0&&"ml-auto"),children:[m&&e.jsx(B,{className:"size-2.5","aria-label":"Repeats"}),d&&e.jsx(C,{className:"size-2.5","aria-label":"From mail"}),i&&e.jsx(A,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),g=t!==void 0&&e.jsx("span",{className:c("shrink-0 opacity-80",!r&&"ml-auto"),children:t});return e.jsxs(e.Fragment,{children:[o?e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,h,g]}):e.jsxs(e.Fragment,{children:[x,h,g]}),p]})}function ne({title:s,timeText:n,color:a,layout:l,density:d,rsvp:m,status:u,hasThread:t,isRecurring:p,zoneCertainty:r,selected:i,onClick:o,leading:x,trailing:h,detail:g}){const j=l==="column";return e.jsxs("button",{type:"button",onClick:o,"aria-pressed":i,className:c("group flex w-full min-w-0 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",j?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,e.jsx("span",{className:c(X({color:a,layout:l,density:d,rsvp:m,status:u,selected:i,stacked:g!==void 0}),"flex-1",j&&"h-full"),children:e.jsx($,{title:s,timeText:n,layout:l,rsvp:m,hasThread:t,isRecurring:p,zoneCertainty:r,trailing:h,detail:g})})]})}const E=96,q=6;function ae({children:s,hasCard:n,onConfirm:a,onReject:l,blocked:d,blockedReason:m,remaining:u,confirmLabel:t="Add",emptyText:p="Nothing in your mail is waiting on a decision about time.",className:r}){const[i,o]=N.useState(0),[x,h]=N.useState(null);if(!n)return e.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",r),children:[e.jsx(D,{className:"size-6 text-fg-subtle","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:p})]});const g=Math.abs(i)>E,j=i>0;return e.jsxs("div",{className:c("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${i}px) rotate(${i/40}deg)`,transition:x===null?"transform 180ms ease-out":"none"},onPointerDown:b=>{h(b.clientX)},onPointerMove:b=>{if(x===null)return;const v=b.clientX-x;Math.abs(v)>q&&!b.currentTarget.hasPointerCapture(b.pointerId)&&b.currentTarget.setPointerCapture(b.pointerId),o(v)},onPointerUp:()=>{Math.abs(i)>E&&(i>0&&!d&&a(),i<0&&l()),h(null),o(0)},onPointerCancel:()=>{h(null),o(0)},children:s}),g&&e.jsx("span",{className:c("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold",j?"right-3 bg-accent-soft text-accent":"left-3 bg-danger-soft text-danger"),children:j?d?m:t:"Not this"})]}),e.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[u," left · swipe right to accept, left to drop, or use the buttons"]})]})}const H="Pick a clock first. The mail never said, and the reader will not choose for you.";function Q(s,n){const a=s.zoneOptions;return a===void 0?{settled:!0,timeZone:""}:a.some(l=>l.timeZone===n)?{settled:!0,timeZone:n}:{settled:!1,reason:H}}function S(s){return s.threadSubject===""?s.sender:`${s.sender} — ${s.threadSubject}`}function K(s){return s>=.85?"Read cleanly":s>=.6?"Read with gaps":"Barely read"}function re({suggestion:s,whenText:n,onAdd:a,onReview:l,onDismiss:d,onOpenThread:m,busy:u=!1,addBlocked:t=!1,zoneChoice:p,onZoneChoice:r,addLabel:i="Add",touch:o,className:x}){const[h,g]=N.useState(""),[j,b]=N.useState(!1),v=N.useId(),k=p??h,M=f=>{b(!1),r?r(f):g(f)},y=Q(s,k),w=f=>()=>{if(!y.settled){b(!0);return}f(y.timeZone)};return e.jsxs("article",{"aria-label":s.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",K(s.confidence)]}),e.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:s.title}),e.jsx("span",{className:"block text-xs text-fg-muted",children:n}),s.location!==""&&e.jsx("span",{className:"block truncate text-xs text-fg-muted",children:s.location})]}),e.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:d,disabled:u,className:c("flex shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",o?"size-11":"size-7"),children:e.jsx(P,{className:"size-4"})})]}),s.ambiguity!==""&&e.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[e.jsx(T,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.ambiguity]}),m?e.jsxs("button",{type:"button",onClick:m,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm text-left text-2xs text-accent-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}):e.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}),s.zoneOptions&&e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[e.jsx(A,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),s.zoneOptions.map(f=>e.jsxs("button",{type:"button","aria-pressed":k===f.timeZone,onClick:()=>M(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11",k===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[e.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),e.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&e.jsx(Z,{id:v,reason:y.reason,nudged:j,className:"text-2xs text-warning"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"primary",size:o?"md":"sm",icon:e.jsx(I,{className:"size-3.5"}),onClick:w(a),disabled:u||t,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:i}),l&&e.jsx(z,{variant:"secondary",size:o?"md":"sm",icon:e.jsx(U,{className:"size-3.5"}),onClick:w(l),disabled:u,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function ie(s){return s.defaultCalendarId!==""?"ready":s.error!==null?"failed":s.isLoading?"loading":"none"}function le(s,n){if(s!=="ready")return s==="loading"?"Reading your calendars…":s==="failed"?e.jsxs(e.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):e.jsxs(e.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",e.jsx(L,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Y=_(400,404);function oe(s){const n=G({queries:s.map(t=>({...O({query:{from:t.from,to:t.to}}),meta:Y,staleTime:W}))}),a=s.map(t=>t.from).join("|"),l=n.map(t=>t.data),d=n.map(t=>t.isPending).join("|"),m=N.useMemo(()=>l.flatMap(t=>t?.items??[]),[a,d]),u=N.useMemo(()=>{const t=new Set;return s.forEach((p,r)=>{n[r]?.isPending&&t.add(p.from)}),t},[a,d]);return{spans:m,pendingWindows:u,error:n.find(t=>t.error)?.error??null,refetch:()=>{for(const t of n)t.error&&t.refetch()}}}export{ne as C,re as E,H as Z,$ as a,ae as b,X as c,le as d,ie as e,Q as s,oe as u};
1
+ import{e as R,t as c,j as e,r as N,W as D,X as P,ar as T,dp as Z,f as z,aQ as I,ah as L,eu as O,s as _}from"./index-DdgwCJ4v.js";import{c as F,R as B,C as W}from"./calendar-format-C1OfWDS9.js";import{M as C}from"./mail-CRm24o3R.js";import{G as A}from"./map-pin-CAgVIQRt.js";import{u as G}from"./useQueries-B9KsAw6v.js";const U=R("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function X(s){const n=F(s.color),a=s.rsvp==="tentative"||s.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",n.soft,n.text,n.rail,s.layout==="column"||s.stacked?"flex-col":"items-center gap-1.5",a&&"border-y border-r border-dashed",a&&n.border,s.rsvp==="declined"&&"opacity-60",s.selected&&"ring-2 ring-ring",s.density==="compact"?"text-2xs":"text-xs")}function $({title:s,timeText:n,layout:a,rsvp:l,hasThread:d,isRecurring:m,zoneCertainty:u,trailing:t,detail:p}){const r=a==="column",i=u==="ambiguous",o=!r&&p!==void 0,x=e.jsxs("span",{className:c("flex min-w-0 items-center gap-1",r&&"w-full",l==="declined"&&"line-through"),children:[n!==""&&e.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:n}),e.jsx("span",{className:"truncate font-medium",children:s})]}),h=(m||d||i)&&e.jsxs("span",{className:c("flex shrink-0 items-center gap-1",r&&"mt-0.5",!r&&t===void 0&&"ml-auto"),children:[m&&e.jsx(B,{className:"size-2.5","aria-label":"Repeats"}),d&&e.jsx(C,{className:"size-2.5","aria-label":"From mail"}),i&&e.jsx(A,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),g=t!==void 0&&e.jsx("span",{className:c("shrink-0 opacity-80",!r&&"ml-auto"),children:t});return e.jsxs(e.Fragment,{children:[o?e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,h,g]}):e.jsxs(e.Fragment,{children:[x,h,g]}),p]})}function ne({title:s,timeText:n,color:a,layout:l,density:d,rsvp:m,status:u,hasThread:t,isRecurring:p,zoneCertainty:r,selected:i,onClick:o,leading:x,trailing:h,detail:g}){const j=l==="column";return e.jsxs("button",{type:"button",onClick:o,"aria-pressed":i,className:c("group flex w-full min-w-0 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",j?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,e.jsx("span",{className:c(X({color:a,layout:l,density:d,rsvp:m,status:u,selected:i,stacked:g!==void 0}),"flex-1",j&&"h-full"),children:e.jsx($,{title:s,timeText:n,layout:l,rsvp:m,hasThread:t,isRecurring:p,zoneCertainty:r,trailing:h,detail:g})})]})}const E=96,q=6;function ae({children:s,hasCard:n,onConfirm:a,onReject:l,blocked:d,blockedReason:m,remaining:u,confirmLabel:t="Add",emptyText:p="Nothing in your mail is waiting on a decision about time.",className:r}){const[i,o]=N.useState(0),[x,h]=N.useState(null);if(!n)return e.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",r),children:[e.jsx(D,{className:"size-6 text-fg-subtle","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:p})]});const g=Math.abs(i)>E,j=i>0;return e.jsxs("div",{className:c("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${i}px) rotate(${i/40}deg)`,transition:x===null?"transform 180ms ease-out":"none"},onPointerDown:b=>{h(b.clientX)},onPointerMove:b=>{if(x===null)return;const v=b.clientX-x;Math.abs(v)>q&&!b.currentTarget.hasPointerCapture(b.pointerId)&&b.currentTarget.setPointerCapture(b.pointerId),o(v)},onPointerUp:()=>{Math.abs(i)>E&&(i>0&&!d&&a(),i<0&&l()),h(null),o(0)},onPointerCancel:()=>{h(null),o(0)},children:s}),g&&e.jsx("span",{className:c("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold",j?"right-3 bg-accent-soft text-accent":"left-3 bg-danger-soft text-danger"),children:j?d?m:t:"Not this"})]}),e.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[u," left · swipe right to accept, left to drop, or use the buttons"]})]})}const H="Pick a clock first. The mail never said, and the reader will not choose for you.";function Q(s,n){const a=s.zoneOptions;return a===void 0?{settled:!0,timeZone:""}:a.some(l=>l.timeZone===n)?{settled:!0,timeZone:n}:{settled:!1,reason:H}}function S(s){return s.threadSubject===""?s.sender:`${s.sender} — ${s.threadSubject}`}function K(s){return s>=.85?"Read cleanly":s>=.6?"Read with gaps":"Barely read"}function re({suggestion:s,whenText:n,onAdd:a,onReview:l,onDismiss:d,onOpenThread:m,busy:u=!1,addBlocked:t=!1,zoneChoice:p,onZoneChoice:r,addLabel:i="Add",touch:o,className:x}){const[h,g]=N.useState(""),[j,b]=N.useState(!1),v=N.useId(),k=p??h,M=f=>{b(!1),r?r(f):g(f)},y=Q(s,k),w=f=>()=>{if(!y.settled){b(!0);return}f(y.timeZone)};return e.jsxs("article",{"aria-label":s.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",K(s.confidence)]}),e.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:s.title}),e.jsx("span",{className:"block text-xs text-fg-muted",children:n}),s.location!==""&&e.jsx("span",{className:"block truncate text-xs text-fg-muted",children:s.location})]}),e.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:d,disabled:u,className:c("flex shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",o?"size-11":"size-7"),children:e.jsx(P,{className:"size-4"})})]}),s.ambiguity!==""&&e.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[e.jsx(T,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.ambiguity]}),m?e.jsxs("button",{type:"button",onClick:m,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm text-left text-2xs text-accent-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}):e.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}),s.zoneOptions&&e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[e.jsx(A,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),s.zoneOptions.map(f=>e.jsxs("button",{type:"button","aria-pressed":k===f.timeZone,onClick:()=>M(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11",k===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[e.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),e.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&e.jsx(Z,{id:v,reason:y.reason,nudged:j,className:"text-2xs text-warning"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"primary",size:o?"md":"sm",icon:e.jsx(I,{className:"size-3.5"}),onClick:w(a),disabled:u||t,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:i}),l&&e.jsx(z,{variant:"secondary",size:o?"md":"sm",icon:e.jsx(U,{className:"size-3.5"}),onClick:w(l),disabled:u,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function ie(s){return s.defaultCalendarId!==""?"ready":s.error!==null?"failed":s.isLoading?"loading":"none"}function le(s,n){if(s!=="ready")return s==="loading"?"Reading your calendars…":s==="failed"?e.jsxs(e.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):e.jsxs(e.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",e.jsx(L,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Y=_(400,404);function oe(s){const n=G({queries:s.map(t=>({...O({query:{from:t.from,to:t.to}}),meta:Y,staleTime:W}))}),a=s.map(t=>t.from).join("|"),l=n.map(t=>t.data),d=n.map(t=>t.isPending).join("|"),m=N.useMemo(()=>l.flatMap(t=>t?.items??[]),[a,d]),u=N.useMemo(()=>{const t=new Set;return s.forEach((p,r)=>{n[r]?.isPending&&t.add(p.from)}),t},[a,d]);return{spans:m,pendingWindows:u,error:n.find(t=>t.error)?.error??null,refetch:()=>{for(const t of n)t.error&&t.refetch()}}}export{ne as C,re as E,H as Z,$ as a,ae as b,X as c,le as d,ie as e,Q as s,oe as u};
@@ -1 +1 @@
1
- import{h as C,r,i as c,eT as h,eU as f,eV as y,s as g,b5 as m}from"./index-DDaQbjmr.js";import{f as I}from"./ErrorState-zb46wwqB.js";const o=g(400,404,412),b=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),d={kind:"written"},i=e=>m(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},O={this:"This",following:"Following",all:"All"};function A(){const e=C();return r.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const s=n._id;return typeof s=="string"&&b.has(s)}})},[e])}const p=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:O[e],recurrenceId:t};function k(){const e=A(),t=c({...h(),meta:o,onSuccess:e}),n=c({...f(),meta:o,onSuccess:e}),s=c({...y(),meta:o,onSuccess:e}),l=r.useCallback(a=>t.mutateAsync({body:a}).then(()=>d).catch(i),[t]),u=r.useCallback((a,v)=>n.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...p(a)},headers:{"If-Match":a.etag},body:v}).then(()=>d).catch(i),[n]),E=r.useCallback(a=>s.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...p(a)},headers:{"If-Match":a.etag}}).then(()=>d).catch(i),[s]);return r.useMemo(()=>({createEvent:l,updateEvent:u,deleteEvent:E,isWriting:t.isPending||n.isPending||s.isPending}),[l,u,E,t.isPending,n.isPending,s.isPending])}export{k as a,A as u};
1
+ import{h as C,r,i as c,eT as h,eU as f,eV as y,s as g,b5 as m}from"./index-DdgwCJ4v.js";import{f as I}from"./ErrorState-DmeOZx31.js";const o=g(400,404,412),b=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),d={kind:"written"},i=e=>m(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},O={this:"This",following:"Following",all:"All"};function A(){const e=C();return r.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const s=n._id;return typeof s=="string"&&b.has(s)}})},[e])}const p=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:O[e],recurrenceId:t};function k(){const e=A(),t=c({...h(),meta:o,onSuccess:e}),n=c({...f(),meta:o,onSuccess:e}),s=c({...y(),meta:o,onSuccess:e}),l=r.useCallback(a=>t.mutateAsync({body:a}).then(()=>d).catch(i),[t]),u=r.useCallback((a,v)=>n.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...p(a)},headers:{"If-Match":a.etag},body:v}).then(()=>d).catch(i),[n]),E=r.useCallback(a=>s.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...p(a)},headers:{"If-Match":a.etag}}).then(()=>d).catch(i),[s]);return r.useMemo(()=>({createEvent:l,updateEvent:u,deleteEvent:E,isWriting:t.isPending||n.isPending||s.isPending}),[l,u,E,t.isPending,n.isPending,s.isPending])}export{k as a,A as u};
@@ -1 +1 @@
1
- import{c as g,ev as T,r as h}from"./index-DDaQbjmr.js";const o=e=>String(e).padStart(2,"0"),y=e=>`${e.getUTCFullYear()}-${o(e.getUTCMonth()+1)}-${o(e.getUTCDate())}`,f=e=>{const t=e<0?"-":"+",r=Math.abs(e);return`${t}${o(Math.floor(r/60))}:${o(r%60)}`};function $(e,t){const r=new Date(`${e}T${t}:00`);return`${e}T${t}:00${f(-r.getTimezoneOffset())}`}const i=new Map;function N(e){if(i.has(e))return i.get(e);let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{t=void 0}return i.set(e,t),t}function d(e,t){const r=N(e);if(!r)return Number.NaN;const n=r.formatToParts(new Date(t)),a=O=>Number(n.find(b=>b.type===O)?.value),s=a("hour")%24;return(Date.UTC(a("year"),a("month")-1,a("day"),s,a("minute"),a("second"))-t)/6e4}function L(e,t,r){if(r==="")return`${e}T${t}:00+00:00`;const n=Date.parse(`${e}T${t}:00Z`),a=d(r,n);if(Number.isNaN(a))return $(e,t);const s=d(r,n-a*6e4);return`${e}T${t}:00${f(Number.isNaN(s)?a:s)}`}function p(e,t){const r=Date.parse(e),n=d(t,r),a=Number.isNaN(n)?-new Date(r).getTimezoneOffset():n,s=new Date(r+a*6e4);return`${y(s)}T${o(s.getUTCHours())}:${o(s.getUTCMinutes())}:${o(s.getUTCSeconds())}${f(a)}`}const c=e=>$(e,"00:00");function u(e,t){const[r,n,a]=e.split("-").map(Number);return y(new Date(Date.UTC(r,n-1,a+t)))}function U(e){const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n));return u(e,-((a.getUTCDay()+6)%7))}function E(e,t){const[r,n]=t.split("-").map(Number);if(e==="year")return[`${r}-01-01`,`${r+1}-01-01`];if(e==="month"){const s=`${r}-${o(n)}-01`,m=n===12?`${r+1}-01-01`:`${r}-${o(n+1)}-01`;return[s,m]}if(e==="day")return[t,u(t,1)];const a=U(t);return[a,u(a,7)]}function M(e,t){const[r,n]=E(e,t);return{from:c(r),to:c(n)}}function F(e,t){return{from:c(e),to:c(u(e,t))}}const R=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,C="";function k(e){if(e!==C)return e;const t=R();return Intl.supportedValuesOf("timeZone").includes(t)?t:C}const v={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},w={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},D="#";function z(e,t){return t===""?e:`${e}${D}${t}`}function l(e){const t=e.indexOf(D);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const I=(e,t)=>{const r=[...e].sort((n,a)=>Date.parse(n.start)-Date.parse(a.start));return r.find(n=>Date.parse(n.end)>Date.parse(t))??r[0]};function B(e,t,r){const n=I(e.filter(a=>{const s=l(a.id);return s.calendarObjectId===t&&s.recurrenceId!==""}),r);return n?l(n.id):void 0}function P(e,t,r,n){const a=I(e.filter(s=>s.calendarObjectId===t&&j(s)).map(s=>x(s,"",n)),r);if(a)return{...l(a.id),calendarId:a.calendarId,date:a.start.slice(0,10)}}function S(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:v[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function x(e,t,r){return{id:z(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):p(e.start,r),end:e.allDay?e.end.slice(0,10):p(e.end,r),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:t,zoneCertainty:w[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const j=e=>e.status!=="Cancelled";function W(){const{data:e,isLoading:t,error:r}=g(T());return h.useMemo(()=>{const n=e?.items??[],a=n.map(S);return{calendars:a,collections:n,colorByCalendarId:Object.fromEntries(a.map(s=>[s.id,s.color])),timeZoneByCalendarId:Object.fromEntries(n.map(s=>[s.calendarId,s.timezone])),defaultCalendarId:(n.find(s=>s.source==="Default")??n[0])?.calendarId??"",isLoading:t,error:r??null}},[e,t,r])}export{C as U,F as a,M as b,z as c,R as d,u as e,k as f,L as g,p as h,j as i,P as j,l as r,B as s,x as t,W as u};
1
+ import{c as g,ev as T,r as h}from"./index-DdgwCJ4v.js";const o=e=>String(e).padStart(2,"0"),y=e=>`${e.getUTCFullYear()}-${o(e.getUTCMonth()+1)}-${o(e.getUTCDate())}`,f=e=>{const t=e<0?"-":"+",r=Math.abs(e);return`${t}${o(Math.floor(r/60))}:${o(r%60)}`};function $(e,t){const r=new Date(`${e}T${t}:00`);return`${e}T${t}:00${f(-r.getTimezoneOffset())}`}const i=new Map;function N(e){if(i.has(e))return i.get(e);let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{t=void 0}return i.set(e,t),t}function d(e,t){const r=N(e);if(!r)return Number.NaN;const n=r.formatToParts(new Date(t)),a=O=>Number(n.find(b=>b.type===O)?.value),s=a("hour")%24;return(Date.UTC(a("year"),a("month")-1,a("day"),s,a("minute"),a("second"))-t)/6e4}function L(e,t,r){if(r==="")return`${e}T${t}:00+00:00`;const n=Date.parse(`${e}T${t}:00Z`),a=d(r,n);if(Number.isNaN(a))return $(e,t);const s=d(r,n-a*6e4);return`${e}T${t}:00${f(Number.isNaN(s)?a:s)}`}function p(e,t){const r=Date.parse(e),n=d(t,r),a=Number.isNaN(n)?-new Date(r).getTimezoneOffset():n,s=new Date(r+a*6e4);return`${y(s)}T${o(s.getUTCHours())}:${o(s.getUTCMinutes())}:${o(s.getUTCSeconds())}${f(a)}`}const c=e=>$(e,"00:00");function u(e,t){const[r,n,a]=e.split("-").map(Number);return y(new Date(Date.UTC(r,n-1,a+t)))}function U(e){const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n));return u(e,-((a.getUTCDay()+6)%7))}function E(e,t){const[r,n]=t.split("-").map(Number);if(e==="year")return[`${r}-01-01`,`${r+1}-01-01`];if(e==="month"){const s=`${r}-${o(n)}-01`,m=n===12?`${r+1}-01-01`:`${r}-${o(n+1)}-01`;return[s,m]}if(e==="day")return[t,u(t,1)];const a=U(t);return[a,u(a,7)]}function M(e,t){const[r,n]=E(e,t);return{from:c(r),to:c(n)}}function F(e,t){return{from:c(e),to:c(u(e,t))}}const R=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,C="";function k(e){if(e!==C)return e;const t=R();return Intl.supportedValuesOf("timeZone").includes(t)?t:C}const v={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},w={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},D="#";function z(e,t){return t===""?e:`${e}${D}${t}`}function l(e){const t=e.indexOf(D);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const I=(e,t)=>{const r=[...e].sort((n,a)=>Date.parse(n.start)-Date.parse(a.start));return r.find(n=>Date.parse(n.end)>Date.parse(t))??r[0]};function B(e,t,r){const n=I(e.filter(a=>{const s=l(a.id);return s.calendarObjectId===t&&s.recurrenceId!==""}),r);return n?l(n.id):void 0}function P(e,t,r,n){const a=I(e.filter(s=>s.calendarObjectId===t&&j(s)).map(s=>x(s,"",n)),r);if(a)return{...l(a.id),calendarId:a.calendarId,date:a.start.slice(0,10)}}function S(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:v[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function x(e,t,r){return{id:z(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):p(e.start,r),end:e.allDay?e.end.slice(0,10):p(e.end,r),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:t,zoneCertainty:w[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const j=e=>e.status!=="Cancelled";function W(){const{data:e,isLoading:t,error:r}=g(T());return h.useMemo(()=>{const n=e?.items??[],a=n.map(S);return{calendars:a,collections:n,colorByCalendarId:Object.fromEntries(a.map(s=>[s.id,s.color])),timeZoneByCalendarId:Object.fromEntries(n.map(s=>[s.calendarId,s.timezone])),defaultCalendarId:(n.find(s=>s.source==="Default")??n[0])?.calendarId??"",isLoading:t,error:r??null}},[e,t,r])}export{C as U,F as a,M as b,z as c,R as d,u as e,k as f,L as g,p as h,j as i,P as j,l as r,B as s,x as t,W as u};
@@ -1 +1 @@
1
- import{r as o}from"./index-DDaQbjmr.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
1
+ import{r as o}from"./index-DdgwCJ4v.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
@@ -1 +1 @@
1
- import{r as m,i as b,eG as x,c as M,eH as D,e0 as I,eI as P,h as v,eJ as N,eK as L,eL as T,eM as w,bm as z}from"./index-DDaQbjmr.js";const G=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},y={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},V=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?y.UserDisabled:y[e.disabledReason],Y=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},A=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,n,i]=r,a=new Date(Number(s),Number(n)-1,Number(i),23,59,59,0);if(Number.isNaN(a.getTime()))return;const o=-t.getTimezoneOffset(),c=o>=0?"+":"-",u=Math.abs(o),d=String(Math.floor(u/60)).padStart(2,"0"),f=String(u%60).padStart(2,"0"),l=p=>String(p).padStart(2,"0");return`${a.getFullYear()}-${l(a.getMonth()+1)}-${l(a.getDate())}T${l(a.getHours())}:${l(a.getMinutes())}:${l(a.getSeconds())}${c}${d}:${f}`},h="None",X=e=>!e.literalClauses.some(t=>t.field==="HasWords"),E=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),Z=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",ee=({mode:e,ruleScope:t,anchorMessageId:r,clauses:s,matchOperator:n,moveMailboxId:i,until:a})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:n==="all"?"And":"Or",literalClauses:s.map(o=>({field:o.field,value:o.value})),moveMailboxId:i,expiresAt:t==="until"?A(a??""):void 0}),C=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),R=new Set(["Complete","Failed"]),O=e=>e!==void 0&&R.has(e),k=1e3,_=15e3,J=e=>{const t=Math.max(0,e),r=k*2**t;return Math.min(r,_)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},te=e=>{const[t,r]=m.useState(),s=b({...x(),onSuccess:g=>r(g.organizeJobId)}),{mutate:n}=s,i=M({...D({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const F=g.state.data?.state;return O(F)?!1:J(g.state.dataUpdateCount)}}),a=m.useCallback(g=>{e&&n({path:{accountId:e},body:E(g)})},[e,n]),{refetch:o}=i,c=m.useCallback(()=>{o()},[o]),u=i.data,d=s.isPending?void 0:u,f=d?.state??s.data?.state,l=O(d?.state),p={state:f,matchedCount:d?.matchedCount??0,appliedCount:d?.appliedCount??0,failedCount:d?.failedCount??0,errorMessage:d?.errorMessage??""};return{start:a,refreshStatus:c,progress:p,isStarting:s.isPending,isRunning:!!t&&!l,isDone:l,failure:$(s.error,i.error,!!u)}},re=["From","Subject","HasWords","ListId","FromDomain"],U=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},se=(e,t)=>e==="ListId"?U(t):t.trim(),q=e=>e==="all"?"And":"Or",Q=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,s=e.clauses.map(n=>({field:n.field,value:n.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:q(e.matchOperator),literalClauses:s}},H=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),K=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ae=(e,t)=>{const r=Q(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?A(e.until??""):void 0}},j=(e,t)=>{if(e.error!==void 0&&e.errorSignature===t)return{status:"error",reason:e.error};if(e.count===void 0)return{status:"loading"};const r=e.indexEmpty===!0?{indexEmpty:!0}:{};return e.previewedSignature===t?{status:"ready",count:e.count,...r}:{status:"ready",count:e.count,stale:!0,...r}},B=350,ne=(e,t,r)=>{const s=b(I()),{mutateAsync:n}=s,i=K(t),[a,o]=m.useState(()=>({})),c=m.useRef(t);c.current=t;const u=m.useRef(i),d=H(t);return m.useEffect(()=>{if(!e||!d||i===a.previewedSignature||i===a.errorSignature)return;const f=setTimeout(()=>{const l=i;u.current=l,n({path:{accountId:e},body:E({...c.current})}).then(p=>{u.current===l&&o({count:p.matchedCount,matchedIds:p.messageIds,indexEmpty:p.semanticIndexEmpty===!0,previewedSignature:l})}).catch(p=>{u.current===l&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:l}))})},B);return()=>clearTimeout(f)},[e,d,i,a.previewedSignature,a.errorSignature,n]),d?{count:j(a,i),matchedIds:a.previewedSignature===i?a.matchedIds??[]:[]}:{count:{status:"error",reason:P},matchedIds:[]}},S=e=>L({path:{accountId:e}}),ie=e=>{const t=M({...T({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},oe=e=>{const t=v(),r=b({...N(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s,mutateAsync:n}=r,i=m.useCallback((o,c,u)=>{e&&s({path:{accountId:e},body:C(o,c,u)})},[e,s]),a=m.useCallback(async(o,c,u)=>e?n({path:{accountId:e},body:C(o,c,u)}).then(()=>!0,()=>!1):!1,[e,n]);return{createFilter:i,createFilterAsync:a,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},le=e=>{const t=v(),r=b({...w(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s}=r;return{deleteFilter:m.useCallback(i=>{e&&s({path:{accountId:e,filterId:i}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},ue=e=>{const t=v(),r=b({...z(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s,variables:n}=r,i=m.useCallback((o,c)=>{e&&s({path:{accountId:e,filterId:o},body:{state:c?"Active":"Disabled"}})},[e,s]),a=m.useCallback(()=>{n&&s(n)},[s,n]);return{toggleFilter:i,retry:a,togglingFilterId:r.isPending?n?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:n?.body?.state==="Active"}};export{h as N,re as S,te as a,S as b,ae as c,V as d,Y as e,G as f,ie as g,le as h,ue as i,E as j,oe as k,ee as l,X as m,se as n,Z as o,A as p,Q as r,ne as u};
1
+ import{r as m,i as b,eG as x,c as M,eH as D,e0 as I,eI as P,h as v,eJ as N,eK as L,eL as T,eM as w,bm as z}from"./index-DdgwCJ4v.js";const G=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},y={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},V=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?y.UserDisabled:y[e.disabledReason],Y=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},A=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,n,i]=r,a=new Date(Number(s),Number(n)-1,Number(i),23,59,59,0);if(Number.isNaN(a.getTime()))return;const o=-t.getTimezoneOffset(),c=o>=0?"+":"-",u=Math.abs(o),d=String(Math.floor(u/60)).padStart(2,"0"),f=String(u%60).padStart(2,"0"),l=p=>String(p).padStart(2,"0");return`${a.getFullYear()}-${l(a.getMonth()+1)}-${l(a.getDate())}T${l(a.getHours())}:${l(a.getMinutes())}:${l(a.getSeconds())}${c}${d}:${f}`},h="None",X=e=>!e.literalClauses.some(t=>t.field==="HasWords"),E=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),Z=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",ee=({mode:e,ruleScope:t,anchorMessageId:r,clauses:s,matchOperator:n,moveMailboxId:i,until:a})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:n==="all"?"And":"Or",literalClauses:s.map(o=>({field:o.field,value:o.value})),moveMailboxId:i,expiresAt:t==="until"?A(a??""):void 0}),C=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),R=new Set(["Complete","Failed"]),O=e=>e!==void 0&&R.has(e),k=1e3,_=15e3,J=e=>{const t=Math.max(0,e),r=k*2**t;return Math.min(r,_)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},te=e=>{const[t,r]=m.useState(),s=b({...x(),onSuccess:g=>r(g.organizeJobId)}),{mutate:n}=s,i=M({...D({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const F=g.state.data?.state;return O(F)?!1:J(g.state.dataUpdateCount)}}),a=m.useCallback(g=>{e&&n({path:{accountId:e},body:E(g)})},[e,n]),{refetch:o}=i,c=m.useCallback(()=>{o()},[o]),u=i.data,d=s.isPending?void 0:u,f=d?.state??s.data?.state,l=O(d?.state),p={state:f,matchedCount:d?.matchedCount??0,appliedCount:d?.appliedCount??0,failedCount:d?.failedCount??0,errorMessage:d?.errorMessage??""};return{start:a,refreshStatus:c,progress:p,isStarting:s.isPending,isRunning:!!t&&!l,isDone:l,failure:$(s.error,i.error,!!u)}},re=["From","Subject","HasWords","ListId","FromDomain"],U=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},se=(e,t)=>e==="ListId"?U(t):t.trim(),q=e=>e==="all"?"And":"Or",Q=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,s=e.clauses.map(n=>({field:n.field,value:n.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:q(e.matchOperator),literalClauses:s}},H=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),K=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ae=(e,t)=>{const r=Q(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?A(e.until??""):void 0}},j=(e,t)=>{if(e.error!==void 0&&e.errorSignature===t)return{status:"error",reason:e.error};if(e.count===void 0)return{status:"loading"};const r=e.indexEmpty===!0?{indexEmpty:!0}:{};return e.previewedSignature===t?{status:"ready",count:e.count,...r}:{status:"ready",count:e.count,stale:!0,...r}},B=350,ne=(e,t,r)=>{const s=b(I()),{mutateAsync:n}=s,i=K(t),[a,o]=m.useState(()=>({})),c=m.useRef(t);c.current=t;const u=m.useRef(i),d=H(t);return m.useEffect(()=>{if(!e||!d||i===a.previewedSignature||i===a.errorSignature)return;const f=setTimeout(()=>{const l=i;u.current=l,n({path:{accountId:e},body:E({...c.current})}).then(p=>{u.current===l&&o({count:p.matchedCount,matchedIds:p.messageIds,indexEmpty:p.semanticIndexEmpty===!0,previewedSignature:l})}).catch(p=>{u.current===l&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:l}))})},B);return()=>clearTimeout(f)},[e,d,i,a.previewedSignature,a.errorSignature,n]),d?{count:j(a,i),matchedIds:a.previewedSignature===i?a.matchedIds??[]:[]}:{count:{status:"error",reason:P},matchedIds:[]}},S=e=>L({path:{accountId:e}}),ie=e=>{const t=M({...T({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},oe=e=>{const t=v(),r=b({...N(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s,mutateAsync:n}=r,i=m.useCallback((o,c,u)=>{e&&s({path:{accountId:e},body:C(o,c,u)})},[e,s]),a=m.useCallback(async(o,c,u)=>e?n({path:{accountId:e},body:C(o,c,u)}).then(()=>!0,()=>!1):!1,[e,n]);return{createFilter:i,createFilterAsync:a,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},le=e=>{const t=v(),r=b({...w(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s}=r;return{deleteFilter:m.useCallback(i=>{e&&s({path:{accountId:e,filterId:i}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},ue=e=>{const t=v(),r=b({...z(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:S(e)})}}),{mutate:s,variables:n}=r,i=m.useCallback((o,c)=>{e&&s({path:{accountId:e,filterId:o},body:{state:c?"Active":"Disabled"}})},[e,s]),a=m.useCallback(()=>{n&&s(n)},[s,n]);return{toggleFilter:i,retry:a,togglingFilterId:r.isPending?n?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:n?.body?.state==="Active"}};export{h as N,re as S,te as a,S as b,ae as c,V as d,Y as e,G as f,ie as g,le as h,ue as i,E as j,oe as k,ee as l,X as m,se as n,Z as o,A as p,Q as r,ne as u};
@@ -1 +1 @@
1
- import{c as p,ep as L,h as n,i as l,eq as d,r as o,er as y,es as c,et as g}from"./index-DDaQbjmr.js";const u=e=>y({path:{accountId:e}}),f=e=>{const r=p({...L({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},h=e=>{const r=n(),t=l({...d(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},m=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,m as b,C as c,h as u};
1
+ import{c as p,ep as L,h as n,i as l,eq as d,r as o,er as y,es as c,et as g}from"./index-DdgwCJ4v.js";const u=e=>y({path:{accountId:e}}),f=e=>{const r=p({...L({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},h=e=>{const r=n(),t=l({...d(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},m=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,m as b,C as c,h as u};
@@ -1 +1 @@
1
- import{c0 as s,c1 as e}from"./index-DDaQbjmr.js";const i=768,r=t=>t!=="desktop",a=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{r as i,a as u};
1
+ import{c0 as s,c1 as e}from"./index-DdgwCJ4v.js";const i=768,r=t=>t!=="desktop",a=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{r as i,a as u};
@@ -1 +1 @@
1
- import{r as a,u as M,cm as O,cn as N,cN as B,a9 as y,co as P,q as U,ab as $,h as D,c as F,cO as v,cC as L}from"./index-DDaQbjmr.js";const w="/mail/brief/compose/{-$outboxMessageId}",R="/mail/flagged/compose/{-$outboxMessageId}",E="/mail/outbox/compose/{-$outboxMessageId}",k="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=y({from:w,shouldThrow:!1}),t=y({from:R,shouldThrow:!1}),r=y({from:E,shouldThrow:!1}),s=y({from:k,shouldThrow:!1});return e??t??r??s}function j(){return T()!==void 0}function J(){return T()?.outboxMessageId}function _(e,t,r){return e==="flagged"?{to:R,params:{outboxMessageId:r}}:e==="outbox"?{to:E,params:{outboxMessageId:r}}:e==="mailbox"&&t?{to:k,params:{mailboxId:t,outboxMessageId:r}}:{to:w,params:{outboxMessageId:r}}}function g(){const e=M(),t=O(),{list:r,mailboxId:s}=N();return a.useCallback((n,o)=>{e({..._(r,s,n),search:B,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,r,s])}function V(){const e=g();return a.useCallback(()=>e(void 0),[e])}function Z(){const e=g();return a.useCallback(t=>e(t),[e])}function ee(){const e=g();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function te(){return P()}const q=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),r=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(r)return{kind:"html",contentUrl:r.contentUrl};const s=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return s?{kind:"text",contentUrl:s.contentUrl}:null},b={all:["messages"],detail:e=>[...b.all,"detail",e],body:e=>[...b.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,r,s,n){super(r),this.name="BodyFetchError",this.reason=t,this.status=s,this.retryAfterSeconds=n}}const K=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},Q=8,I="x-remit-403-reason",X=(e,t)=>{const r=t?.trim()??"";return e===401?"auth":e===403?r.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},G=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,H=(e,t)=>{const r=(t??"").toLowerCase();return!!(e==="text"&&r.startsWith("text/html"))},W=async(e,t,r=async()=>null)=>{const s={},n=await r();n&&(s.Authorization=`Bearer ${n}`);const o=await L(e,{headers:s});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,K(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(I),h=X(o.status,l);throw new f(h,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(H(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(G(m,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},z=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),se=({messageId:e,bodyParts:t,enabled:r=!0})=>{const s=t?q(t):null,n=U(),{getToken:o}=$(),c=a.useRef(null),m=D(),l=a.useRef(!1),h=a.useRef(null),C=e&&s?`${e}:${s.contentUrl}`:null;h.current!==C&&(h.current=C,l.current=!1);const i=F({queryKey:e?[...b.body(e),s?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!s)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,z({fetchContent:(u,S)=>W(u,S,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:v({path:{messageId:e}})})},{contentUrl:s.contentUrl,kind:s.kind,isRetryAfterNotReady:d})},enabled:r&&!!e&&!!s,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<Q:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),p=i.isLoading&&!!s,x=t!==void 0&&s===null;a.useEffect(()=>{p&&(c.current=performance.now())},[p]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,n]);const A=i.data&&s?{kind:s.kind,body:i.data}:void 0;return{picked:s,data:A,isLoading:p,hasNoRenderablePart:x,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,j as a,se as b,X as c,J as d,ee as e,te as f,Z as g,V as u};
1
+ import{r as a,u as M,cm as O,cn as N,cN as B,a9 as y,co as P,q as U,ab as $,h as D,c as F,cO as v,cC as L}from"./index-DdgwCJ4v.js";const w="/mail/brief/compose/{-$outboxMessageId}",R="/mail/flagged/compose/{-$outboxMessageId}",E="/mail/outbox/compose/{-$outboxMessageId}",k="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=y({from:w,shouldThrow:!1}),t=y({from:R,shouldThrow:!1}),r=y({from:E,shouldThrow:!1}),s=y({from:k,shouldThrow:!1});return e??t??r??s}function j(){return T()!==void 0}function J(){return T()?.outboxMessageId}function _(e,t,r){return e==="flagged"?{to:R,params:{outboxMessageId:r}}:e==="outbox"?{to:E,params:{outboxMessageId:r}}:e==="mailbox"&&t?{to:k,params:{mailboxId:t,outboxMessageId:r}}:{to:w,params:{outboxMessageId:r}}}function g(){const e=M(),t=O(),{list:r,mailboxId:s}=N();return a.useCallback((n,o)=>{e({..._(r,s,n),search:B,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,r,s])}function V(){const e=g();return a.useCallback(()=>e(void 0),[e])}function Z(){const e=g();return a.useCallback(t=>e(t),[e])}function ee(){const e=g();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function te(){return P()}const q=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),r=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(r)return{kind:"html",contentUrl:r.contentUrl};const s=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return s?{kind:"text",contentUrl:s.contentUrl}:null},b={all:["messages"],detail:e=>[...b.all,"detail",e],body:e=>[...b.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,r,s,n){super(r),this.name="BodyFetchError",this.reason=t,this.status=s,this.retryAfterSeconds=n}}const K=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},Q=8,I="x-remit-403-reason",X=(e,t)=>{const r=t?.trim()??"";return e===401?"auth":e===403?r.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},G=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,H=(e,t)=>{const r=(t??"").toLowerCase();return!!(e==="text"&&r.startsWith("text/html"))},W=async(e,t,r=async()=>null)=>{const s={},n=await r();n&&(s.Authorization=`Bearer ${n}`);const o=await L(e,{headers:s});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,K(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(I),h=X(o.status,l);throw new f(h,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(H(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(G(m,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},z=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),se=({messageId:e,bodyParts:t,enabled:r=!0})=>{const s=t?q(t):null,n=U(),{getToken:o}=$(),c=a.useRef(null),m=D(),l=a.useRef(!1),h=a.useRef(null),C=e&&s?`${e}:${s.contentUrl}`:null;h.current!==C&&(h.current=C,l.current=!1);const i=F({queryKey:e?[...b.body(e),s?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!s)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,z({fetchContent:(u,S)=>W(u,S,o),refetchDescribeMessage:()=>m.refetchQueries({queryKey:v({path:{messageId:e}})})},{contentUrl:s.contentUrl,kind:s.kind,isRetryAfterNotReady:d})},enabled:r&&!!e&&!!s,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<Q:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),p=i.isLoading&&!!s,x=t!==void 0&&s===null;a.useEffect(()=>{p&&(c.current=performance.now())},[p]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,n]);const A=i.data&&s?{kind:s.kind,body:i.data}:void 0;return{picked:s,data:A,isLoading:p,hasNoRenderablePart:x,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,j as a,se as b,X as c,J as d,ee as e,te as f,Z as g,V as u};
@@ -1 +1 @@
1
- import{c2 as Q,c3 as y,c4 as S,c5 as w,c6 as C,h as k,c7 as q,c8 as x,r as p,c9 as M,ca as H,cb as L,cc as P,cd as O,ce as B,cf as A}from"./index-DDaQbjmr.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&O(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
1
+ import{c2 as Q,c3 as y,c4 as S,c5 as w,c6 as C,h as k,c7 as q,c8 as x,r as p,c9 as M,ca as H,cb as L,cc as P,cd as O,ce as B,cf as A}from"./index-DdgwCJ4v.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&O(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
@@ -1 +1 @@
1
- import{j as E,a0 as K,t as Q,f as U,r as o,aT as R,h as N,C as $,E as z,F as B,q as G,P as I,Q as X,R as V,S as J}from"./index-DDaQbjmr.js";import{C as Y}from"./circle-check-big-CdWGb9Cq.js";import{R as Z}from"./refresh-cw-mlDi8LTp.js";import{u as P}from"./useQueries-D1STUKB_.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:Q("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"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:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n: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 ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function L(e){return!!e&&ee.has(e)}const F=3e3,te=F*2,C={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[n,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),te);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:F,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(L(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?C:{syncing:S,resolved:!0,synced:w,total:y}}const se=180*1e3,xe=30*1e3;let q=0;const M=new Set,re=(e=Date.now())=>{q=e+se;for(const s of M)s()},pe=(e=Date.now())=>e<q,Ee=e=>(M.add(e),()=>{M.delete(e)}),T=6e4,ne=new Set(["sent","drafts","trash","archive"]),_=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&ne.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},j=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function be({accountIds:e,children:s}){const t=N(),{resultFolderIndex:n}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:T,staleTime:T,meta:{softError:!0}}))}),S=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=_(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=j(v,g);A.length>0&&z(t,B(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;oe(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(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,_(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!L(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await O(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));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(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=N(),n=G(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.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 y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),re();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,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"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{xe as H,be as M,ye as R,Re as a,L as b,we as c,pe as i,Ee as s,ae as u};
1
+ import{j as E,a0 as K,t as Q,f as U,r as o,aT as R,h as N,C as $,E as z,F as B,q as G,P as I,Q as X,R as V,S as J}from"./index-DdgwCJ4v.js";import{C as Y}from"./circle-check-big-CM7pZZbV.js";import{R as Z}from"./refresh-cw-C_o59REw.js";import{u as P}from"./useQueries-B9KsAw6v.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:Q("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"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:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n: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 ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function L(e){return!!e&&ee.has(e)}const F=3e3,te=F*2,C={syncing:!1,resolved:!1,synced:0,total:0};function we(e,s){const t=e.join(","),[n,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),te);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:F,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(L(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?C:{syncing:S,resolved:!0,synced:w,total:y}}const se=180*1e3,xe=30*1e3;let q=0;const M=new Set,re=(e=Date.now())=>{q=e+se;for(const s of M)s()},pe=(e=Date.now())=>e<q,Ee=e=>(M.add(e),()=>{M.delete(e)}),T=6e4,ne=new Set(["sent","drafts","trash","archive"]),_=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&ne.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},j=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function be({accountIds:e,children:s}){const t=N(),{resultFolderIndex:n}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:T,staleTime:T,meta:{softError:!0}}))}),S=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=_(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=j(v,g);A.length>0&&z(t,B(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;oe(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(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,_(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!L(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await O(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));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(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=N(),n=G(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.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 y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),re();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,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"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{xe as H,be as M,ye as R,Re as a,L as b,we as c,pe as i,Ee as s,ae as u};
@@ -1 +1 @@
1
- import{K as r,r as s,b7 as t}from"./index-DDaQbjmr.js";import{u as m}from"./useQueries-D1STUKB_.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
1
+ import{K as r,r as s,b7 as t}from"./index-DdgwCJ4v.js";import{u as m}from"./useQueries-B9KsAw6v.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
@@ -1,4 +1,4 @@
1
- import{r as h,j as a,ct as Y,t as b,I as X,h as Z,at as J,i as ee,av as te,cO as se,bS as re,ab as ne,a0 as ae,X as oe,d6 as _,d7 as I,C as ie,cn as ce}from"./index-DDaQbjmr.js";import{K as A}from"./kbd-nBPX_mdB.js";import{B as le,b as de}from"./useMessageBodyContent-Azq1Bngf.js";import{i as ue}from"./search-scope-B5-OK3Cq.js";const me='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',k={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},fe={background:!1,spacing:!1},he="16px",ge=()=>`html{padding:0}body{padding:${he};box-sizing:border-box}`,pe=()=>"html{overflow:hidden}body{overflow-x:auto}",be=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,ye='<meta name="viewport" content="width=device-width, initial-scale=1">',xe=e=>{const t=e?k.dark:k.light;return`
1
+ import{r as h,j as a,ct as Y,t as b,I as X,h as Z,at as J,i as ee,av as te,cO as se,bS as re,ab as ne,a0 as ae,X as oe,d6 as _,d7 as I,C as ie,cn as ce}from"./index-DdgwCJ4v.js";import{K as A}from"./kbd-DKvs5BdK.js";import{B as le,b as de}from"./useMessageBodyContent-DRTP4wa0.js";import{i as ue}from"./search-scope-B5-OK3Cq.js";const me='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',k={light:{fg:"oklch(0.3 0.025 235)",canvas:"oklch(0.96 0.015 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",canvas:"oklch(0.22 0.025 220)",accent:"oklch(0.78 0.16 150)"}},fe={background:!1,spacing:!1},he="16px",ge=()=>`html{padding:0}body{padding:${he};box-sizing:border-box}`,pe=()=>"html{overflow:hidden}body{overflow-x:auto}",be=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,ye='<meta name="viewport" content="width=device-width, initial-scale=1">',xe=e=>{const t=e?k.dark:k.light;return`
2
2
  /* Plain-email base: UI font-stack + theme-aware colors (#424) */
3
3
  html, body {
4
4
  font-family: ${me};
@@ -1 +1 @@
1
- import{h as L,at as M,i as k,E as I,F as E,cy as A,el as R,r as v,dy as j,j as p,em as h,en as w,eo as D,C as _,cn as N,c as Q,dS as z,d6 as O}from"./index-DDaQbjmr.js";import{c as U}from"./popover-menu-eOwDgIAD.js";import{aj as q}from"./MailListHeader-DMMl8ZLg.js";import{a as P}from"./useLabels--WOniDuk.js";import{n as B}from"./search-query-Cr_ZXBCp.js";import{b as F}from"./search-scope-B5-OK3Cq.js";import{u as G,p as H}from"./useSearchTokenContext-DjY64Paa.js";const ne=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},K=e=>{const{mailboxId:t,messages:s}=e,n=L(),{pushError:l}=M(),{mutateAsync:c,isPending:a}=k({...R(),onError:(r,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:A(r),error:r})},onSettled:(r,u,d)=>{I(n,E(q(d.body.messageIds??[],s??[],t)))}});return{applyLabel:v.useCallback((r,u,d)=>{r.length!==0&&j(r,m=>c({body:{messageIds:m,labelId:u,action:d}}))},[c]),isPending:a}};function re({accountId:e,mailboxId:t,messageIds:s}){const{labels:n}=P(e),{applyLabel:l}=K({mailboxId:t}),c=v.useMemo(()=>n.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${w(a.color)?h[a.color]:h.Default}`}),onSelect:()=>l(s,a.labelId,"Apply")})),[n,s,l]);return c.length===0?null:p.jsx(U,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:c,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const V=3,ie=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const n=t.trim();return n.length===0||n.length>=V},ce=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},Y=20,$=new Set(Object.values(O)),J=e=>e!==void 0&&$.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function le({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=_(),n=G(),l=N(),c=B(s),{freeText:a,tokens:i}=H(c,n),r=a.length>0,u=i.find(o=>o.type==="category"),d=J(t)??u?.category,m=i.some(o=>o.type==="hasAttachment")?!0:void 0,f=i.some(o=>o.type==="isStarred")?!0:void 0,y=W(i),b=i.find(o=>o.type==="after"),g=i.find(o=>o.type==="before"),S=i.find(o=>o.type==="in"),x=F({browsed:l,callerMailboxId:e,inTokenMailboxId:S?.mailboxId}),{data:T,isLoading:C}=Q({...z({query:{query:a,mailboxId:x,limit:Y,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...b?{sentDateFrom:b.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:r,staleTime:6e4});return{hits:T?.items??[],isLoading:r&&C}}export{re as L,ne as r,ie as s,ce as t,le as u};
1
+ import{h as L,at as M,i as k,E as I,F as E,cy as A,el as R,r as v,dy as j,j as p,em as h,en as w,eo as D,C as _,cn as N,c as Q,dS as z,d6 as O}from"./index-DdgwCJ4v.js";import{c as U}from"./popover-menu-4krm3dWT.js";import{aj as q}from"./MailListHeader-BrXXf1Yp.js";import{a as P}from"./useLabels-BY5yOSXl.js";import{n as B}from"./search-query-Cr_ZXBCp.js";import{b as F}from"./search-scope-B5-OK3Cq.js";import{u as G,p as H}from"./useSearchTokenContext-DMIJPqzA.js";const ne=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},K=e=>{const{mailboxId:t,messages:s}=e,n=L(),{pushError:l}=M(),{mutateAsync:c,isPending:a}=k({...R(),onError:(r,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:A(r),error:r})},onSettled:(r,u,d)=>{I(n,E(q(d.body.messageIds??[],s??[],t)))}});return{applyLabel:v.useCallback((r,u,d)=>{r.length!==0&&j(r,m=>c({body:{messageIds:m,labelId:u,action:d}}))},[c]),isPending:a}};function re({accountId:e,mailboxId:t,messageIds:s}){const{labels:n}=P(e),{applyLabel:l}=K({mailboxId:t}),c=v.useMemo(()=>n.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${w(a.color)?h[a.color]:h.Default}`}),onSelect:()=>l(s,a.labelId,"Apply")})),[n,s,l]);return c.length===0?null:p.jsx(U,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(D,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:c,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const V=3,ie=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const n=t.trim();return n.length===0||n.length>=V},ce=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},Y=20,$=new Set(Object.values(O)),J=e=>e!==void 0&&$.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function le({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=_(),n=G(),l=N(),c=B(s),{freeText:a,tokens:i}=H(c,n),r=a.length>0,u=i.find(o=>o.type==="category"),d=J(t)??u?.category,m=i.some(o=>o.type==="hasAttachment")?!0:void 0,f=i.some(o=>o.type==="isStarred")?!0:void 0,y=W(i),b=i.find(o=>o.type==="after"),g=i.find(o=>o.type==="before"),S=i.find(o=>o.type==="in"),x=F({browsed:l,callerMailboxId:e,inTokenMailboxId:S?.mailboxId}),{data:T,isLoading:C}=Q({...z({query:{query:a,mailboxId:x,limit:Y,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...b?{sentDateFrom:b.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:r,staleTime:6e4});return{hits:T?.items??[],isLoading:r&&C}}export{re as L,ne as r,ie as s,ce as t,le as u};
@@ -1 +1 @@
1
- import{h as g,at as p,c as f,d as m,r,i as y,av as T,o as E,l as d}from"./index-DDaQbjmr.js";const i={html:"",plainText:""},x=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...d(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{x as u};
1
+ import{h as g,at as p,c as f,d as m,r,i as y,av as T,o as E,l as d}from"./index-DdgwCJ4v.js";const i={html:"",plainText:""},x=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...d(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{x as u};
package/index.html CHANGED
@@ -38,7 +38,7 @@
38
38
  } catch (_) {}
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="/assets/index-DDaQbjmr.js"></script>
41
+ <script type="module" crossorigin src="/assets/index-DdgwCJ4v.js"></script>
42
42
  <link rel="stylesheet" crossorigin href="/assets/index-BtYEmjxr.css">
43
43
  </head>
44
44
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.642",
3
+ "version": "0.0.643",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{j as n,L as Et,W as Ot,eN as $e,eO as ne,e1 as re,r as a,c as Ye,C as ie,bq as Ft,cU as At,K as Nt,dT as Bt,eP as Lt,eQ as qt,a0 as Ve,ek as Pt,eR as Dt,ak as _t,d4 as Qt,d5 as zt}from"./index-DDaQbjmr.js";import{g as Je,e as Wt,f as Ze,u as Ht,p as Ut,R as Kt}from"./useSearchTokenContext-DjY64Paa.js";import{a8 as Gt,z as $t,B as Yt,ak as Vt,al as Jt,am as Zt,an as _e,ao as Xt,ap as es,a7 as ts,aq as ss,ar as os,as as ns,af as rs,M as as,at as is,ag as cs,au as ls,av as ds,d as us,o as fs,ai as ms,l as hs,S as gs,I as ps,N as Qe,L as xs,J as Is,b as ys,X as vs,Y as Ie,Z as bs,$ as Xe,a0 as et,a1 as Ss,a2 as Ts,a3 as Cs}from"./MailListHeader-DMMl8ZLg.js";import{u as ws,a as Rs,R as Ms,b as js,c as ks}from"./useRefreshControl-CQDCO_Sz.js";import{u as ae}from"./useQueries-D1STUKB_.js";import{t as tt,s as Es,u as Os,r as Fs,L as As}from"./useSemanticSearch-NH8DKMle.js";import{a as Ns}from"./useLabels--WOniDuk.js";import{u as Bs}from"./useLayoutTier-BnLysTvl.js";import{d as Ls,w as qs}from"./wizard-selection-DxUM65kM.js";import{m as Ps,e as Ds,f as _s}from"./search-token-index-DfEguIzE.js";import{u as st}from"./sections-BE-YkTuC.js";import{R as Qs}from"./refresh-cw-mlDi8LTp.js";import{a as zs}from"./useMessageBodyContent-Azq1Bngf.js";function Ws({sync:e}){return e?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[n.jsx(Et,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:Hs(e)})]}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[n.jsx(Ot,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Hs({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const ot=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],nt="category",Us={unclassified:"uncategorized"},H=e=>Wt(e).map(t=>t.raw),W=e=>e.join(" "),ye=e=>{const t=Ze(e);if(t)return ot.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ve=e=>{const t=Ze(e);if(!t||t.name!==nt)return;const s=t.value.toLowerCase(),r=Us[s];if(r)return r;if(!(!$e(s)||s==="all"))return s},rt=e=>ot.find(t=>t.id===e),at=e=>rt(e)!==void 0,Ks=e=>{const t=new Set;for(const s of H(e)){const r=ye(s);r&&t.add(r)}return t},Gs=e=>{let t="all";for(const s of H(e)){const r=ve(s);r&&(t=r)}return t},$s=(e,t)=>{const s=rt(t);if(!s)return;const r=H(e),i=r.filter(d=>ye(d)!==t);return i.length<r.length?W(i):W([...r,Je(s.name,s.value)])},Ys=(e,t)=>{const s=H(e).filter(r=>!ve(r));return W(t==="all"?s:[...s,Je(nt,t)])},Vs=e=>W(H(e).filter(t=>!ye(t)&&!ve(t))),it=e=>e.trim().length>0,ze=e=>{if(!it(e.query))return e.ownFilters;const t=new Set(Ks(e.query));for(const s of e.ownFilters)at(s)||t.add(s);return t},We=e=>it(e.query)?Gs(e.query):e.ownCategory,He=6e4,Js=3e4,Zs={kind:"unknown"},Ue=e=>(t,s)=>Gt(s?.queryKey,e)?t:void 0,Xs=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),eo=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),Ke=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function to({categories:e,criteria:t,limit:s,counted:r}){const i=ae({queries:e.map(l=>{const h=Xs(t,l,s),m=Ke(t,l);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:Ue(m),staleTime:He}})}),d=ae({queries:e.map(l=>{const h=eo(t,l),m=Ke(t,l);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:r,placeholderData:Ue(m),staleTime:He}})}),f=a.useMemo(()=>e.map((l,h)=>{const m=i[h],v=d[h],p=m?.data?.items??[];return{category:l,rows:p,atCap:p.length>=s,total:r?tt(v?.data?.count):Zs,loading:m?.isPending??!0,failed:m?.isError??!1,retry:()=>{m?.refetch(),r&&v?.refetch()}}}),[e,i,d,r,s]),c=a.useCallback(()=>{for(const l of i)l.refetch();for(const l of d)l.refetch()},[i,d]);return{sections:f,isLoading:i.length>0&&i.every(l=>l.isPending),isError:i.length>0&&i.every(l=>l.isError),refetch:c}}function so(e,t,s){const r={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:f,refetch:c}=Ye({queryKey:re({query:r}),queryFn:async()=>{const{data:h}=await ne({query:r,throwOnError:!0});return h},enabled:s,staleTime:Js});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&f,refetch:a.useCallback(()=>{c()},[c])}}const oo=3e4,no={kind:"unknown"},ro=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function ao({criteria:e,junkMailboxIds:t,enabled:s}){const r=ae({queries:t.map(i=>{const d=ro(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:f}=await ne({query:d,throwOnError:!0});return f},enabled:s,staleTime:oo}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?tt(r[d]?.data?.count):no,failed:s?r[d]?.isError??!1:!1})),[t,r,s])}const io=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),co=e=>[...e].sort(io),lo=["from","subject","category","unread","starred","attachments"],ct=["contacts","today"],uo=e=>new Set(ct.filter(t=>e.has(t))),fo=(e,t,s,r)=>{const i=$t({category:e,attributes:t}),{params:d,residual:f}=Yt(s,i,lo),c={...d,...i},l={muted:!1};return c.from!==void 0&&(l.from=c.from),c.subject!==void 0&&(l.subject=c.subject),c.unread!==void 0&&(l.unread=c.unread),c.starred!==void 0&&(l.starred=c.starred),c.attachments!==void 0&&(l.attachments=c.attachments),r!==void 0&&(l.accountId=r),{criteria:l,residual:f}},mo=({residual:e,attributes:t})=>e.length===0&&!ct.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,ho=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function go(e,{pageRowsByMailbox:t}){const s=e.map(m=>({...m,pageRows:t.get(m.mailboxId)??0}));for(const[m,v]of t)v<=0||s.some(p=>p.mailboxId===m)||s.push({mailboxId:m,count:{kind:"unknown"},failed:!1,pageRows:v});const r=s[0];if(!r)return;let i=0,d=!0,f=r;for(const m of s)m.count.kind==="unknown"?d=!1:i+=m.count.value,ho(m,f)&&(f=m);const c=s.some(m=>m.pageRows>0),l=s.some(m=>m.failed);if(i===0&&!c&&(d||!l))return;const h=d&&i===0&&c;return{mailboxId:f.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const po=50,xo=200,Io=[],Ge=()=>n.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[n.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),yo=({accountEmail:e})=>{const t=st();return n.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[n.jsx(Ve,{className:"size-3.5 shrink-0"}),n.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),n.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vo=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),r=Fs(s.map(d=>d.accountId));if(r.restriction)return r;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:r.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:r.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function bo({header:e,rows:t,wizard:s,children:r}){const{selectedIds:i,selectedCount:d,exitSelection:f,orderedIds:c,allSelected:l,toggleAllLoaded:h}=ds(),m=a.useMemo(()=>vo(t,i),[t,i]),{junkMailboxId:v}=us(m.accountId),{labels:p}=Ns(m.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>qs(t,i),[t,i]),x=fs(v,m.mailboxId),S=a.useMemo(()=>c.length>0?{checked:l,indeterminate:d>0&&!l,onChange:h}:void 0,[c.length,l,d,h]),A=m.moveDisabledHint?{tone:"warning",text:m.moveDisabledHint}:void 0,T=M=>n.jsx(gs,{title:M.title,navSlot:M.navSlot,titleMeta:M.titleMeta,searchSlot:M.searchSlot,searchField:M.searchField,idleSlot:M.makeFilterSlot,count:d,onCancel:f,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:m.accountId&&m.mailboxId&&d>0&&p.length>0?n.jsx(As,{accountId:m.accountId,mailboxId:m.mailboxId,messageIds:b}):void 0,selectAll:S,notice:A});return n.jsx(ms,{...e,selectionBar:T,paneOverlay:n.jsx(hs,{verb:s.verb,accountId:m.accountId,mailboxId:m.mailboxId,selection:L,selectionRestriction:m.restriction,onFinished:f}),children:r})}function So({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:r,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:f,searchInput:c,resultFolderIndex:l,onSearchChange:h}=ie(),m=Ht(),v=Ft(),p=Bs(),b=At(),L=Ps(),x=a.useMemo(()=>co(e.filter(o=>!o.muted?.value)),[e]),[S,A]=a.useState("all"),[T,M]=a.useState("all"),[N,q]=a.useState(new Set),[le,j]=a.useState(!1),P=a.useCallback(o=>{q(u=>{const g=new Set(u);return g.has(o)?g.delete(o):g.add(o),g})},[]),U=a.useCallback(()=>q(new Set),[]),E=c.trim().length>0,{freeText:w,tokens:D}=Ut(f.trim().toLowerCase(),m),y=w.length>0,_=a.useMemo(()=>ze({query:c,ownFilters:N}),[c,N]),Q=a.useMemo(()=>We({query:c,ownCategory:T}),[c,T]),F=a.useMemo(()=>ze({query:f,ownFilters:N}),[f,N]),C=a.useMemo(()=>We({query:f,ownCategory:T}),[f,T]),I=a.useCallback(o=>{if(!E||!at(o)){P(o);return}const u=$s(c,o);u!==void 0&&h(u)},[E,c,h,P]),k=a.useCallback(o=>{if(!E){M(o);return}h(Ys(c,o))},[E,c,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{$e(o)&&k(o)}:void 0,[C,y,k]),ue=a.useCallback(()=>{M("all"),A("all"),U(),E&&h(Vs(c))},[E,c,h,U]),K=ae({queries:x.map(o=>({...Nt({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),G=a.useMemo(()=>{const o=new Map;for(let u=0;u<x.length;u++){const g=x[u].accountId,te=(K[u]?.data?.items??[]).reduce((O,kt)=>O+(kt.unseenCount??0),0);o.set(g,te)}return o},[x,K]),ut=a.useMemo(()=>x.filter((o,u)=>{const g=K[u];return g?.isError?!Bt(g.error):!1}),[x,K]),{criteria:fe,residual:$}=a.useMemo(()=>fo(C,F,D,S==="all"?void 0:S),[C,F,D,S]),ft=a.useMemo(()=>C==="all"?[...Vt]:[C],[C]),be=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),Se=mo({residual:$,attributes:F}),{sections:Y,isLoading:mt,isError:ht,refetch:Te}=to({categories:y?Io:ft,criteria:fe,limit:C==="all"?ls:po,counted:Se}),{rows:Ce,isLoading:gt,isError:pt,refetch:we}=so(be,xo,y),me=y?gt:mt,Re=y?pt:ht,Me=a.useCallback(()=>{if(y){we();return}Te()},[y,we,Te]),je=a.useMemo(()=>uo(F),[F]),V=a.useCallback(o=>Ls(o).map(Jt).filter(u=>Lt(u,je)&&Zt(u,$)),[je,$]),J=a.useMemo(()=>Y.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:V(o.rows)})),[Y,V]),Z=a.useMemo(()=>V(Ce),[Ce,V]),xt=a.useCallback(o=>{Y.find(u=>u.category===o)?.retry()},[Y]),R=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),It=a.useMemo(()=>qt(l),[l]),ke=ao({criteria:be,junkMailboxIds:It,enabled:Se&&Es({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const u=R.map(O=>_e(O,l)),{spam:g}=Xt(u),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=go(ke,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[R,w,l,ke]),Ee=a.useMemo(()=>{const o=u=>he===void 0?u:u.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:es(J.map(u=>({...u,rows:o(u.rows)})))},[y,Z,J,he]),Oe=a.useCallback((o,u)=>{const g=R.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},u)},[R,s]),yt=a.useCallback(o=>{const u=o.threadId??R.find(g=>g.id===o.id)?.threadId;u&&s?.({threadId:u,messageId:o.id})},[R,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:G.get(o.accountId),active:S===o.accountId}))],[x,G,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),vt=a.useMemo(()=>Array.from(G.values()).reduce((o,u)=>o+u,0),[G]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Fe}=ws(),{state:Ae,errorMessage:Ne,refresh:Be}=Rs(pe,{onSettled:()=>Me()}),bt=a.useMemo(()=>n.jsx(Ms,{state:Ae,onRefresh:Be,label:"Refresh daily brief",errorMessage:Ne,hasUpdate:Fe(pe)}),[Ae,Be,Ne,Fe,pe]),xe=a.useMemo(()=>R.map(o=>_e(o,l)),[R,l]),{hits:Le,isLoading:St}=Os(),Tt=a.useMemo(()=>{const o=new Map(R.map(g=>[g.id,g.threadId])),u=xe.map(g=>o.get(g.id)).filter(g=>g!=null);return ts(Le,u,l)},[Le,xe,R,l]),Ct=a.useMemo(()=>{const o=ss(ge.map(u=>({id:u.id,label:u.label,count:u.count,active:u.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:_,expanded:le,onExpandedChange:j,onSelectCategory:u=>k(u),onSelectSource:A,onToggleFilter:u=>I(u),onClear:ue}},[ge,z,Q,_,le,I,k,ue]),qe=Ee.length===0&&S==="all"&&w.length===0&&D.length===0,wt=a.useMemo(()=>x.map(o=>o.accountId),[x]),Rt=a.useMemo(()=>x.some(o=>js(o.syncPhase)),[x]),ee=ks(wt,qe||Rt),Pe=n.jsxs("div",{className:"h-full overflow-y-auto",children:[n.jsx(Ge,{}),n.jsx(Ge,{})]}),De=!me&&!Re&&!qe,Mt=os({tier:p,hasLiveInput:E,hasCommittedQuery:f.trim().length>0,bodyRendersCommittedResults:!0}),jt=De?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&n.jsx(ns,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,f)}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(rs,{sections:Ee,briefCategory:Q,Row:as,selectedThreadId:t,onSelectThread:Oe,onShowAllSection:de,onRetrySection:xt,flat:y,onSelectBriefCategory:k,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:A,activeFilters:_,onToggleFilter:I,onClearFilters:ue})})]}):me?Pe:Re?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[n.jsx(Ve,{className:"size-8 text-danger"}),n.jsx("p",{children:"Couldn't load your messages"}),n.jsxs("button",{type:"button",onClick:()=>Me(),className:"flex items-center gap-1 text-accent underline text-xs",children:[n.jsx(Qs,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?n.jsx(Ws,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Pe;return n.jsx(Pt,{hasSheet:De&&!Mt,children:n.jsx(is,{selectedMessageId:t,rows:R,onOpen:Oe,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:r,onTriageContextChange:i,children:n.jsx(bo,{wizard:b,header:{title:"Daily brief",unreadCount:vt,footer:v?n.jsx(cs,{}):void 0,searchFilter:Ct,searchResults:xe,searchLoading:me,relatedResults:Tt,relatedLoading:St,onSelectSearchResult:yt,spamOffer:X,searchResultsInBody:!0,refreshControl:bt},rows:R,children:n.jsxs("div",{className:"flex h-full flex-col",children:[ut.map(o=>n.jsx(yo,{accountEmail:o.email,accountId:o.accountId},o.accountId)),n.jsx("div",{className:"min-h-0 flex-1",children:jt})]})})})})}const lt=a.createContext(null);function ce(){const e=a.useContext(lt);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function To({thread:e,children:t}){const s=Ds(),r=_s(),i=st(),{searchInput:d}=ie(),f=e?.threadId,c=e?.messageId,{data:l}=Ye({...Dt(),staleTime:6e4}),h=a.useMemo(()=>l?.items??[],[l]),m=a.useMemo(()=>{if(f)return h.find(I=>I.messageId===c)??h.find(I=>I.threadId===f)},[h,f,c]),v=ps(f,c),p=m??v,b=c??p?.messageId,L=a.useMemo(()=>{if(f)return{threadId:f,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[f,p,b]),x=a.useCallback((I,k)=>{s(I,{replace:k?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&r()},[b,r]),A=Qe({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=xs(),{deleteMessages:M}=Is({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=ys({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,j=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,P=Qe({thread:j,isOpen:j?.messageId===b}),U=zs(),E=_t(),w=Qt(),D=a.useMemo(()=>zt(w,f,b),[w,f,b]),y=a.useMemo(()=>{if(j)return I=>w({threadId:j.threadId,messageId:j.messageId,mode:I})},[w,j]),{nextMessageId:_,previousMessageId:Q}=vs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!U&&!E,hasOpenThread:f!==void 0,onClose:r,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||j&&N([j.messageId],!j.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),F=a.useCallback(I=>{if(!I)return;const k=h.find(de=>de.messageId===I);return k?{threadId:k.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:r,nextThread:F(_),previousThread:F(Q),actions:A,onReply:D,triage:T,onDeleteMessages:M,handleDeselectIfRemoved:S};return n.jsx(lt.Provider,{value:C,children:t})}function dt(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:r}=ce(),{accounts:i}=ie();return n.jsx(So,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:r})}function Co(){const e=Ie(),{conversation:t,selectedThread:s,actions:r,onReply:i,handleDeselectIfRemoved:d}=ce(),f=!!t,c=Ts(t?.threadId);return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(Cs,{hasThread:f,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:f?r.deleteThread:void 0,onToggleStar:f?r.toggleStar:void 0,isStarred:r.isStarred,moveContext:f&&r.accountId&&r.mailboxId?{accountId:r.accountId,currentMailboxId:r.mailboxId,onMove:r.moveThread}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?n.jsx(Xe,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):n.jsx(Kt,{})})]}),n.jsx(et,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e})]})}function wo(){const e=Ie(),{selectedThread:t,handleDeselectIfRemoved:s}=ce(),{onToggleIntelligence:r}=ie();return n.jsx(Ss,{onClose:r,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e})}function Ro(){const e=Ie(),{selectedThread:t,conversation:s,onOpenThread:r,onCloseThread:i,nextThread:d,previousThread:f,handleDeselectIfRemoved:c}=ce(),l=bs(s?.threadId??null);return s?n.jsxs(n.Fragment,{children:[n.jsx(Xe,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:l.toggle,onSwipeNext:d?()=>r(d):void 0,onSwipePrevious:f?()=>r(f):void 0,mobileIntelligenceOpen:l.isOpen}),n.jsx(et,{isOpen:l.isOpen,onClose:l.close,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:c,onReplyWithText:e})]}):n.jsx("div",{className:"h-full",children:n.jsx(dt,{})})}const _o=Object.assign(To,{List:dt,Reading:Co,Intelligence:wo,Phone:Ro});export{_o as B};
@@ -1 +0,0 @@
1
- import{eO as J,r as o,e1 as X,c as le,C as z,bq as ce,cU as ue,aH as ge,aI as he,j as r,ak as me,d4 as pe,d5 as fe}from"./index-DDaQbjmr.js";import{u as xe,p as U,R as Ie}from"./useSearchTokenContext-DjY64Paa.js";import{z as Te,B as ye,al as be,am as ve,aw as Re,an as Ce,a as Se,M as we,at as je,ax as Fe,av as Me,l as Oe,I as ke,N as _,L as Pe,J as Le,b as Ne,X as Ae,Y as H,Z as De,$ as Y,a0 as Z,a1 as qe,a2 as Ee,a3 as Be}from"./MailListHeader-DMMl8ZLg.js";import{u as We,l as Qe,b as ze,a as He}from"./MailViewChrome-BcPAwjzq.js";import{f as Ke}from"./ErrorState-zb46wwqB.js";import{d as Ve,w as Ge}from"./wizard-selection-DxUM65kM.js";import{a as Ue}from"./useMessageBodyContent-Azq1Bngf.js";import{e as _e,f as Je}from"./search-token-index-DfEguIzE.js";import{u as Xe}from"./sections-BE-YkTuC.js";const K=t=>({...t,starred:!0,order:"desc"}),Ye=(t={})=>X({query:K(t)});function $(t={}){const{data:e,isLoading:s,isError:a,error:d,refetch:f,fetchNextPage:n,hasNextPage:u,isFetchingNextPage:l}=We({queryKey:Ye(t),queryFn:async({pageParam:x})=>{const{data:g}=await J({query:{...K(t),continuationToken:x},throwOnError:!0});return g},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:o.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:d,refetch:f,fetchNextPage:n,hasNextPage:u,isFetchingNextPage:l}}function Ze(t={}){const e={...K(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await J({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const $e=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=Te(t),{params:a,residual:d}=ye(e,{...s,starred:!0},$e);return{criteria:{...a,...s},residual:d}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Me(),d=o.useMemo(()=>Ge(t,s),[t,s]);return r.jsx(Oe,{verb:e,selection:d,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:d}){const{searchQuery:f,resultFolderIndex:n,onSearchClearQuery:u}=z(),l=xe(),k=ce(),x=ue(),[g,h]=o.useState("all"),[b,P]=o.useState(new Set),S=o.useCallback(i=>{P(C=>{const I=new Set(C);return I.has(i)?I.delete(i):I.add(i),I})},[]),w=o.useCallback(()=>{h("all"),P(new Set)},[]),T=o.useCallback(()=>{w(),u()},[w,u]),{freeText:j,tokens:v}=U(f.trim().toLowerCase(),l),L=U(f.trim(),l).freeText,{criteria:N,residual:m}=o.useMemo(()=>et({category:g,attributes:b},v),[g,b,v]),F=o.useMemo(()=>j?{...N,query:j}:N,[N,j]),{threads:A,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=$(F),p=o.useMemo(()=>Ve(A).map(be).filter(i=>ve(i,m)),[A,m]),c=o.useCallback((i,C)=>{const I=p.find(de=>de.id===i)?.threadId;I&&e?.({threadId:I,messageId:i},C)},[p,e]),R=o.useCallback(i=>{const C=i.threadId??p.find(I=>I.id===i.id)?.threadId;C&&e?.({threadId:C,messageId:i.id})},[p,e]),Q=o.useMemo(()=>Re(),[]),se=o.useMemo(()=>p.map(i=>Ce(i,n)),[p,n]),ae=Ze(F)??null,re=o.useMemo(()=>v.filter(i=>i.type!=="isStarred"),[v]),oe=Qe({chips:{category:g,attributes:b},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),V=D?"loading":y?"error":p.length===0?"empty":"ready",ne=o.useCallback(()=>{const i=ge(he());window.open(i,"_blank","noopener,noreferrer")},[]),G=Se(),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(i=>r.jsx(we,{thread:i,active:i.id===t,onClick:()=>c(i.id)},i.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(ze,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:g,activeFilters:b,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(je,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:d,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(He,{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?Ke(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(Fe,{title:"Starred"}),listBody:G.searchResults??(V==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=o.createContext(null);function q(){const t=o.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=_e(),a=Je(),d=Xe(),{searchInput:f}=z(),n=t?.threadId,u=t?.messageId,{threads:l}=$(),k=o.useMemo(()=>{if(n)return l.find(c=>c.messageId===u)??l.find(c=>c.threadId===n)},[l,n,u]),x=ke(n,u),g=k??x,h=u??g?.messageId,b=o.useMemo(()=>{if(n)return{threadId:n,mailboxId:g?.mailboxId??"",subject:g?.subject,messageId:h,authenticity:g?.authenticity}},[n,g,h]),P=o.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=o.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=_({thread:g,isOpen:!0,onAfterOptimisticRemove:S}),T=Pe(),{deleteMessages:j}=Le({mailboxId:g?.mailboxId??"",messages:l,onAfterOptimisticRemove:S}),{toggleReadFor:v}=Ne({mailboxId:g?.mailboxId??"",messages:l}),L=T.focusedMessageId,m=o.useMemo(()=>l.find(c=>c.messageId===L),[l,L])??g,F=_({thread:m,isOpen:m?.messageId===h}),A=Ue(),D=me(),y=pe(),E=o.useMemo(()=>fe(y,n,h),[y,n,h]),M=o.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Ae({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!A&&!D,hasOpenThread:n!==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&&v([m.messageId],!m.isRead)},goBrief:()=>d("brief"),goSettings:()=>d("settings")}}),O=o.useCallback(c=>{if(!c)return;const R=l.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[l]),p={selectedMessageId:h,selectedThread:g,conversation:b,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:d,handleDeselectIfRemoved:f}=q(),n=!!e,u=Ee(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(Be,{hasThread:n,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:d?()=>d("reply"):void 0,onReplyAll:d?()=>d("reply-all"):void 0,onForward:d?()=>d("forward"):void 0,onDelete:n?a.deleteThread:void 0,onToggleStar:n?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:n&&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(Y,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open,listOnScreen:!0}):r.jsx(Ie,{})})]}),r.jsx(Z,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t})]})}function ot(){const t=H(),{selectedThread:e,handleDeselectIfRemoved:s}=q(),{onToggleIntelligence:a}=z();return r.jsx(qe,{onClose:a,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t})}function nt(){const t=H(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:d,nextThread:f,previousThread:n,handleDeselectIfRemoved:u}=q(),l=De(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Y,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:l.toggle,onSwipeNext:f?()=>d(f):void 0,onSwipePrevious:n?()=>d(n):void 0,mobileIntelligenceOpen:l.isOpen}),r.jsx(Z,{isOpen:l.isOpen,onClose:l.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u,onReplyWithText:t})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const ft=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{ft as F};