@remit/web-client-dist 0.0.682 → 0.0.683

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 (217) hide show
  1. package/assets/BriefPane-B3D5-BM0.js +1 -0
  2. package/assets/CalendarEventEditor-CorHNzvG.js +1 -0
  3. package/assets/CalendarEventPopup-D-SdDSgQ.js +1 -0
  4. package/assets/{CalendarLoadFailed-DNV1DlXi.js → CalendarLoadFailed-fjYDcNBn.js} +1 -1
  5. package/assets/CalendarQuickCreate-BNdOcecP.js +1 -0
  6. package/assets/{CalendarSession-CTmh2tcD.js → CalendarSession-DVmvDWU4.js} +1 -1
  7. package/assets/DesktopChrome-BTELS57y.js +1 -0
  8. package/assets/{DropdownMenu-D3gGWitE.js → DropdownMenu-CMRvH2nc.js} +1 -1
  9. package/assets/{EmptyState-5XJzmFAK.js → EmptyState-D9VF8IjN.js} +1 -1
  10. package/assets/{ErrorState-Dzdw33-3.js → ErrorState-94ifepAa.js} +1 -1
  11. package/assets/FlaggedPane-CpXIW-t2.js +1 -0
  12. package/assets/FullCompose-D0r-tiQo.js +1 -0
  13. package/assets/{LabelApplyTrigger-CSWiFHCu.js → LabelApplyTrigger-C03Hgfzy.js} +1 -1
  14. package/assets/MailShell-CtmFFRYB.js +1 -0
  15. package/assets/{MailViewChrome-C47Pffjf.js → MailViewChrome-Dsvhd_KV.js} +1 -1
  16. package/assets/{MailboxPane-CBl3PnOT.js → MailboxPane-CZB7l_UU.js} +2 -2
  17. package/assets/MessageBody-D3iuMLwF.js +84 -0
  18. package/assets/MessageToolbar-BEI90gj6.js +1 -0
  19. package/assets/{NavMenuButton-CN3ovZVQ.js → NavMenuButton-DSOpFRST.js} +1 -1
  20. package/assets/{OnboardingWizard-CIAVrjJr.js → OnboardingWizard-B59qf55_.js} +1 -1
  21. package/assets/OutboxPane-BUI6ugaL.js +1 -0
  22. package/assets/_calendarObjectId-BY50J2hr.js +1 -0
  23. package/assets/_mailboxId-0i2eghj0.js +1 -0
  24. package/assets/_messageId-BQqk5gfw.js +1 -0
  25. package/assets/_messageId-BqO-NhQa.js +1 -0
  26. package/assets/_messageId-Cmg2GAfD.js +1 -0
  27. package/assets/_outboxMessageId-BDvXTrQM.js +1 -0
  28. package/assets/_recurrenceId-CMVJw-Ue.js +1 -0
  29. package/assets/_slotId-CFujBWsH.js +1 -0
  30. package/assets/_threadId-BSlijLpe.js +1 -0
  31. package/assets/_threadId-BiFfo-Au.js +1 -0
  32. package/assets/_threadId-CvKjrqYT.js +1 -0
  33. package/assets/_view._date-BZkjct9_.js +1 -0
  34. package/assets/{account-service-status-C_MJ-o-p.js → account-service-status-DcgJfCAF.js} +1 -1
  35. package/assets/accounts-CEI9HlTN.js +1 -0
  36. package/assets/advanced-BK0dqfFu.js +1 -0
  37. package/assets/{agenda-time-ACtN6wfF.js → agenda-time-BuLpxvQJ.js} +1 -1
  38. package/assets/{app-chrome-Dbvu4ieD.js → app-chrome-Do6quK12.js} +1 -1
  39. package/assets/appearance-BLw-N7mB.js +1 -0
  40. package/assets/{avatar-BV5vFJ_r.js → avatar-LbufyW4K.js} +1 -1
  41. package/assets/{badge-CbfjHXMg.js → badge-C9PbkapD.js} +1 -1
  42. package/assets/{bottom-sheet-4tvR-sri.js → bottom-sheet-CGUsHUE9.js} +1 -1
  43. package/assets/{brief-DbMpucTQ.js → brief-CcMmKq4G.js} +1 -1
  44. package/assets/brief-ZZJ3nfgH.js +1 -0
  45. package/assets/calendar-C-SC0LmB.js +1 -0
  46. package/assets/calendar-CZgZil9h.js +1 -0
  47. package/assets/{calendar-event-popup-CYCnsOds.js → calendar-event-popup--BJKBvHu.js} +1 -1
  48. package/assets/{calendar-event-sidebar-TTXLpS2C.js → calendar-event-sidebar-s-VGamZ2.js} +1 -1
  49. package/assets/{calendar-failure-note-A4rOKZNb.js → calendar-failure-note-CEYH2UEH.js} +1 -1
  50. package/assets/{calendar-guests-BXmTl5jL.js → calendar-guests-BaqdXc5Z.js} +1 -1
  51. package/assets/calendar-suggestion-hiP6smEM.js +1 -0
  52. package/assets/calendars-BB8BOIZF.js +1 -0
  53. package/assets/{card-f9A3um0u.js → card-D7vOetR8.js} +1 -1
  54. package/assets/{checkbox-BlFhjoed.js → checkbox-BG_wsoD6.js} +1 -1
  55. package/assets/chevron-down-Np6EEMl-.js +1 -0
  56. package/assets/chevron-left-CpG9UDY6.js +1 -0
  57. package/assets/{circle-check-BUMxM7Pv.js → circle-check-DTYzt_6O.js} +1 -1
  58. package/assets/{circle-check-big-BP7Pn5eb.js → circle-check-big-Bm7lzv-i.js} +1 -1
  59. package/assets/{circle-help-B083hm65.js → circle-help-BbeOW2US.js} +1 -1
  60. package/assets/{clock-8nW9RI8K.js → clock-BzJ_fFzJ.js} +1 -1
  61. package/assets/compose._-_outboxMessageId_-BqsxhT9K.js +1 -0
  62. package/assets/compose._-_outboxMessageId_-CproJqKO.js +1 -0
  63. package/assets/compose._-_outboxMessageId_-D4ti_AhM.js +1 -0
  64. package/assets/compose._-_outboxMessageId_-DUOU8Jn4.js +1 -0
  65. package/assets/{config-import-Bk6uFuiN.js → config-import-C8-amzAu.js} +1 -1
  66. package/assets/{confirm-dialog-BXhRj5Sm.js → confirm-dialog-CJxHNbgP.js} +1 -1
  67. package/assets/{copy-cdXYXbA6.js → copy-BXsMQRiH.js} +1 -1
  68. package/assets/{credential-steps-B4j2Icsi.js → credential-steps-rbRE-sDX.js} +1 -1
  69. package/assets/{download-D9_dvZ6g.js → download-BfBVKcRB.js} +1 -1
  70. package/assets/{draft-BIQ0-Lk_.js → draft-DNq8lw24.js} +1 -1
  71. package/assets/edit-BHhIau_f.js +1 -0
  72. package/assets/edit-DgebsJae.js +1 -0
  73. package/assets/{external-link-Ct6hJ8mI.js → external-link-BJSinsZe.js} +1 -1
  74. package/assets/{file-json-FJobBXk2.js → file-json-BQnHw6MM.js} +1 -1
  75. package/assets/filters-PWUZK_ek.js +1 -0
  76. package/assets/{flagged-C439b_WS.js → flagged-CKVThblv.js} +1 -1
  77. package/assets/flagged-CXvEvVrc.js +1 -0
  78. package/assets/{folder-input-DjxVjldz.js → folder-input-ByfaQaN_.js} +1 -1
  79. package/assets/folders-CN4VErkf.js +1 -0
  80. package/assets/{help-copy-YhaxQEIY.js → help-copy-CiMWKARn.js} +1 -1
  81. package/assets/{import-af_hbF-p.js → import-Bp-nuO1l.js} +1 -1
  82. package/assets/index-B9liPKRG.js +1 -0
  83. package/assets/index-BQqk5gfw.js +1 -0
  84. package/assets/index-BxeM8f0P.js +1 -0
  85. package/assets/index-C8IkDmiU.js +1 -0
  86. package/assets/index-CGpfssJ_.js +1 -0
  87. package/assets/{index-D94MOpo0.js → index-CKflMWYU.js} +18 -18
  88. package/assets/index-Cmg2GAfD.js +1 -0
  89. package/assets/index-CnG5iabp.js +1 -0
  90. package/assets/index-CsYB5imQ.js +1 -0
  91. package/assets/{index-BlOq3dK1.js → index-Dd-3T--b.js} +7 -7
  92. package/assets/index-Dzu-4vEF.js +1 -0
  93. package/assets/index-ddvd0V_o.js +1 -0
  94. package/assets/{kbd-cd0_OQ1u.js → kbd-BncXAFDO.js} +1 -1
  95. package/assets/{label-chip-BYIaT-tI.js → label-chip-WqxiwOiU.js} +1 -1
  96. package/assets/labels-Dg7TTcGv.js +1 -0
  97. package/assets/mail-BXR9_JRf.js +1 -0
  98. package/assets/{mail-4EQRG36P.js → mail-D6kMQxBk.js} +1 -1
  99. package/assets/{menu-C3buEsRL.js → menu-DoDMKB2j.js} +1 -1
  100. package/assets/nav-link-D4-gc9H1.js +1 -0
  101. package/assets/new-cj3Hd_mI.js +1 -0
  102. package/assets/onboarding-DVmfGdcY.js +1 -0
  103. package/assets/{onboarding-completion-BxKBJWb5.js → onboarding-completion-CidQapv1.js} +1 -1
  104. package/assets/outbox-FTmGdqfa.js +1 -0
  105. package/assets/{pencil-Cr6xAk53.js → pencil-DWPNxo1l.js} +1 -1
  106. package/assets/people-aWk5_IT2.js +1 -0
  107. package/assets/{plus-BEkGxsOV.js → plus-BQ1_1L0j.js} +1 -1
  108. package/assets/{popover-menu-D1Ggz_nA.js → popover-menu-CNRLhp3y.js} +1 -1
  109. package/assets/{refresh-cw-BDamTi58.js → refresh-cw-BmzOf0Tw.js} +1 -1
  110. package/assets/reply-CM_F5zLS.js +1 -0
  111. package/assets/{rich-text-D3EPlK78.js → rich-text-DGbE9Son.js} +2 -2
  112. package/assets/{rich-text-spellcheck-worker-provider-DPs4YZHA.js → rich-text-spellcheck-worker-provider-CIgyTxax.js} +1 -1
  113. package/assets/{rotate-ccw-Dxx7BcD7.js → rotate-ccw-BGcFG-wN.js} +1 -1
  114. package/assets/{roving-focus-CJC-AjPO.js → roving-focus-5GpSESqn.js} +1 -1
  115. package/assets/{row-actions-uPzTjymf.js → row-actions-Cj5ovPiM.js} +1 -1
  116. package/assets/search-mirror-C3jFbnCg.js +1 -0
  117. package/assets/{search-scope-CdH_SY3a.js → search-scope-4mzoV4f2.js} +1 -1
  118. package/assets/search-token-index-CjZf08nc.js +1 -0
  119. package/assets/sections-HylxNewe.js +1 -0
  120. package/assets/{segmented-control-D_XxaVb8.js → segmented-control-DIfCqJPe.js} +1 -1
  121. package/assets/{select-CB3Efp6I.js → select-DBBB1VI8.js} +1 -1
  122. package/assets/senders-CjRXvk8z.js +1 -0
  123. package/assets/settings-BLU5tEtD.js +1 -0
  124. package/assets/{settings-screen-CF0fiL2l.js → settings-screen-83hRChID.js} +1 -1
  125. package/assets/shield-check-BtDXLNzB.js +1 -0
  126. package/assets/{sparkles-rKmhB5Fk.js → sparkles-DxQ7dXLC.js} +1 -1
  127. package/assets/{suggest-list-Dz1MsIYD.js → suggest-list-B3YTezx4.js} +1 -1
  128. package/assets/{suggested-vips-idJBB-lA.js → suggested-vips-DeXMjfai.js} +1 -1
  129. package/assets/suggestion._suggestionId-BFy5c2Ae.js +1 -0
  130. package/assets/task._calendarTaskId--_XtqsMj.js +1 -0
  131. package/assets/{undo-2-BAub6h7R.js → undo-2-CG4e15mN.js} +1 -1
  132. package/assets/{useCalendarData-DQ7oi-nJ.js → useCalendarData-CjjJgU5o.js} +1 -1
  133. package/assets/{useCalendarScheduling-DAb_8yBj.js → useCalendarScheduling-BgRBx6lW.js} +1 -1
  134. package/assets/{useCalendarSuggestions-BfA31NJY.js → useCalendarSuggestions--U0GEAn1.js} +1 -1
  135. package/assets/{useCalendarTasks-BMPfFFau.js → useCalendarTasks-vfDCVCeh.js} +1 -1
  136. package/assets/{useDebouncedValue-BQRYh_4T.js → useDebouncedValue-DjJaY9PG.js} +1 -1
  137. package/assets/{useFilters-IsqJ-AEH.js → useFilters-CfG8A2Tp.js} +1 -1
  138. package/assets/{useLabels-CrZtVj3Y.js → useLabels-QIv6Xivl.js} +1 -1
  139. package/assets/{useLayoutTier-CIlJuePx.js → useLayoutTier-4MDmjdnr.js} +1 -1
  140. package/assets/{useMediaQuery-CGZfUxdm.js → useMediaQuery-B1PJEoqh.js} +1 -1
  141. package/assets/{useMessageBodyContent-yhApp3IG.js → useMessageBodyContent-B0iiI3OV.js} +2 -2
  142. package/assets/{useQueries-CIIHHroC.js → useQueries-DVcMuKhn.js} +1 -1
  143. package/assets/{useRefreshControl-MOracVIf.js → useRefreshControl-CY786xTG.js} +1 -1
  144. package/assets/{useResultFolderIndex-BjaX8bsI.js → useResultFolderIndex-DkgVg9nE.js} +1 -1
  145. package/assets/useSignature-DR9rEETd.js +1 -0
  146. package/assets/{warnings-BRGgf3x_.js → warnings-BM1pwMF7.js} +4 -4
  147. package/index.html +1 -1
  148. package/package.json +1 -1
  149. package/assets/AccountSession-BYJ1unhC.js +0 -1
  150. package/assets/BriefPane-mADSC2OK.js +0 -1
  151. package/assets/CalendarEventEditor-C8_kOvZ3.js +0 -1
  152. package/assets/CalendarEventPopup-7lWwS7jN.js +0 -1
  153. package/assets/CalendarQuickCreate-BG0qeW8s.js +0 -1
  154. package/assets/DesktopChrome-Bj6-FRYu.js +0 -1
  155. package/assets/FlaggedPane-IgqQna9q.js +0 -1
  156. package/assets/FullCompose-CppNsB88.js +0 -1
  157. package/assets/MailShell-DbZolZ7P.js +0 -1
  158. package/assets/MessageBody-C2-SQjAb.js +0 -84
  159. package/assets/MessageToolbar-2VWnNBpw.js +0 -1
  160. package/assets/OutboxPane-C7vPOisX.js +0 -1
  161. package/assets/_calendarObjectId-BOWn0Wc1.js +0 -1
  162. package/assets/_mailboxId-CbT5t4kO.js +0 -1
  163. package/assets/_messageId-CUzI2YR7.js +0 -1
  164. package/assets/_messageId-DiJIuK0Z.js +0 -1
  165. package/assets/_messageId-aGpmi6EA.js +0 -1
  166. package/assets/_outboxMessageId-D9yNQ74_.js +0 -1
  167. package/assets/_recurrenceId-BUk6g_uR.js +0 -1
  168. package/assets/_threadId-BQKxqX_U.js +0 -1
  169. package/assets/_threadId-DNM46Cj0.js +0 -1
  170. package/assets/_threadId-DQ9Ns1qA.js +0 -1
  171. package/assets/_view._date-Cb0nAaKf.js +0 -1
  172. package/assets/accounts-CahoQhl7.js +0 -1
  173. package/assets/advanced-Cf1h5R7s.js +0 -1
  174. package/assets/appearance-BnPvwrqn.js +0 -1
  175. package/assets/brief-DhhQktQG.js +0 -1
  176. package/assets/calendar-C4YDxHb-.js +0 -1
  177. package/assets/calendar-CNIMaOb7.js +0 -1
  178. package/assets/calendar-suggestion-cOTOb7Lm.js +0 -1
  179. package/assets/calendars-DNlrofPU.js +0 -1
  180. package/assets/chevron-down-UUw56DjM.js +0 -1
  181. package/assets/chevron-left-D5-k3mB7.js +0 -1
  182. package/assets/cloud-off-BRk6zo1b.js +0 -1
  183. package/assets/compose._-_outboxMessageId_-CN2ZUrAe.js +0 -1
  184. package/assets/compose._-_outboxMessageId_-DmK_lXQP.js +0 -1
  185. package/assets/compose._-_outboxMessageId_-Lkfk9hrZ.js +0 -1
  186. package/assets/compose._-_outboxMessageId_-uc2TFREe.js +0 -1
  187. package/assets/edit-DGHa68Jh.js +0 -1
  188. package/assets/edit-cyEdCEG-.js +0 -1
  189. package/assets/filters-BAyEbBhi.js +0 -1
  190. package/assets/flagged-pJGEDQAe.js +0 -1
  191. package/assets/folders-CIyVw-EH.js +0 -1
  192. package/assets/index-BZPylmnf.js +0 -1
  193. package/assets/index-BnrEzeaK.js +0 -1
  194. package/assets/index-CUzI2YR7.js +0 -1
  195. package/assets/index-CpjgMzVc.js +0 -1
  196. package/assets/index-D9j5MCr1.js +0 -1
  197. package/assets/index-DJh02QjC.js +0 -1
  198. package/assets/index-DiJIuK0Z.js +0 -1
  199. package/assets/index-aGpmi6EA.js +0 -1
  200. package/assets/index-g59ADgCj.js +0 -1
  201. package/assets/index-vFdlNYM0.js +0 -1
  202. package/assets/labels-DnNxXAR1.js +0 -1
  203. package/assets/mail-CE3n3sQ0.js +0 -1
  204. package/assets/new-CByizl3m.js +0 -1
  205. package/assets/onboarding-CA8Qn0P1.js +0 -1
  206. package/assets/outbox-wQ86O6i5.js +0 -1
  207. package/assets/people-H9fmtU8R.js +0 -1
  208. package/assets/reply-DPVLqPcI.js +0 -1
  209. package/assets/search-mirror-C2_MRHKT.js +0 -1
  210. package/assets/search-token-index-DXiN1835.js +0 -1
  211. package/assets/sections-Dm0mEk9W.js +0 -1
  212. package/assets/security-C1G2I4K2.js +0 -1
  213. package/assets/senders-BPIkrH6Y.js +0 -1
  214. package/assets/settings-BjSixogd.js +0 -1
  215. package/assets/suggestion._suggestionId-Cn195KCI.js +0 -1
  216. package/assets/task._calendarTaskId-CzVuyEtm.js +0 -1
  217. package/assets/useSignature-ClOAemBi.js +0 -1
@@ -1 +1 @@
1
- import{j as u,ev as x,X as E,p as M,ew as z,ex as L,al as w,B as O,r as p,f as v,ey as T,a as D,ez as R,eA as $,eB as _,e as S,eC as J,eD as U,eE as B,eF as q,b7 as K}from"./index-D94MOpo0.js";import{u as Q,S as H}from"./suggest-list-Dz1MsIYD.js";import{S as W}from"./select-CB3Efp6I.js";import{P as X}from"./plus-BEkGxsOV.js";const P="inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs";function pe({clause:e,onEdit:t,onRemove:r}){return u.jsxs("span",{className:M(P,e.derived?"border-dashed border-line-strong bg-surface-sunken":"border-line bg-surface"),children:[u.jsxs("button",{type:"button",onClick:t,"aria-label":`Edit ${x(e.field)} clause`,className:"flex items-center gap-1 text-left",children:[u.jsx("span",{className:"font-medium text-fg-muted",children:x(e.field)}),u.jsx("span",{className:"text-fg",children:e.value})]}),e.derived&&u.jsx("span",{className:"text-2xs text-fg-subtle",children:"from sender"}),r&&u.jsx("button",{type:"button",onClick:r,"aria-label":`Remove ${x(e.field)} clause`,className:"flex size-4 items-center justify-center rounded-full text-fg-subtle hover:bg-surface-sunken hover:text-fg-muted",children:u.jsx(E,{className:"size-3"})})]})}function fe({label:e,onClick:t}){return u.jsxs("button",{type:"button",onClick:t,className:M(P,"border-dashed border-line-strong text-fg-muted hover:border-accent-2 hover:text-accent-2"),children:[u.jsx(X,{className:"size-3","aria-hidden":"true"}),e]})}function be({draft:e,mode:t,fields:r=L,suggestions:s=[],onChangeField:o,onChangeValue:a,onSubmit:n,onCancel:c}){const d=z(e.field),l=Q({count:s.length,onAccept:i=>a?.(s[i].value)});return u.jsxs("div",{className:"space-y-1.5 rounded-lg border border-accent-2 bg-surface p-2",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(W,{"aria-label":"Clause field",value:e.field,onChange:i=>o?.(i.target.value),className:"h-8 w-32 shrink-0",children:r.map(i=>u.jsx("option",{value:i,children:x(i)},i))}),u.jsx(w,{"aria-label":"Clause value",value:e.value,placeholder:"value…",autoComplete:"off",onChange:i=>{l.reopen(),a?.(i.target.value)},onKeyDown:i=>{l.handleKeyDown(i)||i.key==="Enter"&&n?.()},className:"h-8 min-w-40 flex-1",...l.comboboxProps}),u.jsx(O,{variant:"primary",size:"sm",onClick:n,disabled:e.value.trim()==="",className:"shrink-0",children:t==="add"?"Add":"Save"}),u.jsx(O,{variant:"ghost",size:"sm",onClick:c,"aria-label":"Cancel clause edit",icon:u.jsx(E,{className:"size-4"}),className:"shrink-0 px-2"})]}),l.open&&u.jsx(H,{id:l.listId,suggestions:s,activeIndex:l.activeIndex,optionId:l.optionId,onPick:i=>{a?.(i.value),l.dismiss()},onHighlight:l.setActiveIndex,label:`${x(e.field)} suggestions`}),d&&u.jsx("p",{className:"px-0.5 text-2xs text-fg-subtle",children:d})]})}const ge=(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},N={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."},he=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?N.UserDisabled:N[e.disabledReason],xe=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"})},j=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,o,a]=r,n=new Date(Number(s),Number(o)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const c=-t.getTimezoneOffset(),d=c>=0?"+":"-",l=Math.abs(c),i=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),m=b=>String(b).padStart(2,"0");return`${n.getFullYear()}-${m(n.getMonth()+1)}-${m(n.getDate())}T${m(n.getHours())}:${m(n.getMinutes())}:${m(n.getSeconds())}${d}${i}:${f}`},h="None",Y=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:h,actionMailboxId:h}),k=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),ve=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",Ce=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:o})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?j(o??""):void 0}),F=(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}),G=new Set(["Complete","Failed"]),A=e=>e!==void 0&&G.has(e),V=1e3,Z=15e3,ee=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,Z)},te=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Se=e=>{const[t,r]=p.useState(),s=v({...T(),onSuccess:g=>r(g.organizeJobId)}),{mutate:o}=s,a=D({...R({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return A(I)?!1:ee(g.state.dataUpdateCount)}}),n=p.useCallback(g=>{e&&o({path:{accountId:e},body:k(g)})},[e,o]),c=p.useCallback(g=>{e&&o({path:{accountId:e},body:Y(g)})},[e,o]),{refetch:d}=a,l=p.useCallback(()=>{d()},[d]),i=a.data,f=s.isPending?void 0:i,m=f?.state??s.data?.state,b=A(f?.state),C={state:m,matchedCount:f?.matchedCount??0,appliedCount:f?.appliedCount??0,failedCount:f?.failedCount??0,errorMessage:f?.errorMessage??""};return{start:n,startForFilter:c,watch:r,refreshStatus:l,progress:C,isStarting:s.isPending,isRunning:!!t&&!b,isDone:b,failure:te(s.error,a.error,!!i)}},ye=["From","Subject","HasWords","ListId","FromDomain"],re=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},Oe=(e,t)=>e==="ListId"?re(t):t.trim(),se=e=>e==="all"?"And":"Or",ae=e=>({matchOperator:se(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),ie=e=>!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),Ne=e=>{const t=ae(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?j(e.until??""):void 0}},oe=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},le=350,Fe=(e,t,r)=>{const s=v($()),{mutateAsync:o}=s,a=ne(t),[n,c]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(a),i=ie(t);return p.useEffect(()=>{if(!e||!i||a===n.previewedSignature||a===n.errorSignature)return;const f=setTimeout(()=>{const m=a;l.current=m,o({path:{accountId:e},body:k({...d.current})}).then(b=>{l.current===m&&c({count:b.matchedCount,matchedIds:b.messageIds,previewedSignature:m})}).catch(b=>{l.current===m&&c(C=>({...C,error:b instanceof Error?b.message:"Couldn't count matches.",errorSignature:m}))})},le);return()=>clearTimeout(f)},[e,i,a,n.previewedSignature,n.errorSignature,o]),i?{count:oe(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:_},matchedIds:[]}},y=e=>U({path:{accountId:e}}),Ae=e=>{const t=D({...B({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},Ee=e=>{const t=S(),r=v({...J(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,mutateAsync:o}=r,a=p.useCallback((c,d,l)=>{e&&s({path:{accountId:e},body:F(c,d,l)})},[e,s]),n=p.useCallback(async(c,d,l)=>{if(e)return o({path:{accountId:e},body:F(c,d,l)}).then(i=>i,()=>{})},[e,o]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},Me=e=>{const t=S(),r=v({...q(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s}=r;return{deleteFilter:p.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},De=e=>{const t=S(),r=v({...K(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,variables:o}=r,a=p.useCallback((c,d)=>{e&&s({path:{accountId:e,filterId:c},body:{state:d?"Active":"Disabled"}})},[e,s]),n=p.useCallback(()=>{o&&s(o)},[s,o]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?o?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:o?.body?.state==="Active"}};export{fe as A,pe as C,h as N,ye as S,be as a,y as b,Se as c,Ne as d,he as e,ge as f,xe as g,Ae as h,Me as i,De as j,Ee as k,Ce as l,Oe as n,ve as o,j as p,ae as r,Fe as u};
1
+ import{j as u,ev as x,X as E,p as M,ew as z,ex as L,an as w,B as O,r as p,f as v,ey as T,a as D,ez as R,eA as $,eB as _,e as S,eC as J,eD as U,eE as B,eF as q,b7 as K}from"./index-CKflMWYU.js";import{u as Q,S as H}from"./suggest-list-B3YTezx4.js";import{S as W}from"./select-DBBB1VI8.js";import{P as X}from"./plus-BQ1_1L0j.js";const P="inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs";function pe({clause:e,onEdit:t,onRemove:r}){return u.jsxs("span",{className:M(P,e.derived?"border-dashed border-line-strong bg-surface-sunken":"border-line bg-surface"),children:[u.jsxs("button",{type:"button",onClick:t,"aria-label":`Edit ${x(e.field)} clause`,className:"flex items-center gap-1 text-left",children:[u.jsx("span",{className:"font-medium text-fg-muted",children:x(e.field)}),u.jsx("span",{className:"text-fg",children:e.value})]}),e.derived&&u.jsx("span",{className:"text-2xs text-fg-subtle",children:"from sender"}),r&&u.jsx("button",{type:"button",onClick:r,"aria-label":`Remove ${x(e.field)} clause`,className:"flex size-4 items-center justify-center rounded-full text-fg-subtle hover:bg-surface-sunken hover:text-fg-muted",children:u.jsx(E,{className:"size-3"})})]})}function fe({label:e,onClick:t}){return u.jsxs("button",{type:"button",onClick:t,className:M(P,"border-dashed border-line-strong text-fg-muted hover:border-accent-2 hover:text-accent-2"),children:[u.jsx(X,{className:"size-3","aria-hidden":"true"}),e]})}function be({draft:e,mode:t,fields:r=L,suggestions:s=[],onChangeField:o,onChangeValue:a,onSubmit:n,onCancel:c}){const d=z(e.field),l=Q({count:s.length,onAccept:i=>a?.(s[i].value)});return u.jsxs("div",{className:"space-y-1.5 rounded-lg border border-accent-2 bg-surface p-2",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx(W,{"aria-label":"Clause field",value:e.field,onChange:i=>o?.(i.target.value),className:"h-8 w-32 shrink-0",children:r.map(i=>u.jsx("option",{value:i,children:x(i)},i))}),u.jsx(w,{"aria-label":"Clause value",value:e.value,placeholder:"value…",autoComplete:"off",onChange:i=>{l.reopen(),a?.(i.target.value)},onKeyDown:i=>{l.handleKeyDown(i)||i.key==="Enter"&&n?.()},className:"h-8 min-w-40 flex-1",...l.comboboxProps}),u.jsx(O,{variant:"primary",size:"sm",onClick:n,disabled:e.value.trim()==="",className:"shrink-0",children:t==="add"?"Add":"Save"}),u.jsx(O,{variant:"ghost",size:"sm",onClick:c,"aria-label":"Cancel clause edit",icon:u.jsx(E,{className:"size-4"}),className:"shrink-0 px-2"})]}),l.open&&u.jsx(H,{id:l.listId,suggestions:s,activeIndex:l.activeIndex,optionId:l.optionId,onPick:i=>{a?.(i.value),l.dismiss()},onHighlight:l.setActiveIndex,label:`${x(e.field)} suggestions`}),d&&u.jsx("p",{className:"px-0.5 text-2xs text-fg-subtle",children:d})]})}const ge=(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},N={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."},he=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?N.UserDisabled:N[e.disabledReason],xe=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"})},j=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,o,a]=r,n=new Date(Number(s),Number(o)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const c=-t.getTimezoneOffset(),d=c>=0?"+":"-",l=Math.abs(c),i=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%60).padStart(2,"0"),m=b=>String(b).padStart(2,"0");return`${n.getFullYear()}-${m(n.getMonth()+1)}-${m(n.getDate())}T${m(n.getHours())}:${m(n.getMinutes())}:${m(n.getSeconds())}${d}${i}:${f}`},h="None",Y=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:h,actionMailboxId:h}),k=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),ve=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",Ce=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:o})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?j(o??""):void 0}),F=(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}),G=new Set(["Complete","Failed"]),A=e=>e!==void 0&&G.has(e),V=1e3,Z=15e3,ee=e=>{const t=Math.max(0,e),r=V*2**t;return Math.min(r,Z)},te=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Se=e=>{const[t,r]=p.useState(),s=v({...T(),onSuccess:g=>r(g.organizeJobId)}),{mutate:o}=s,a=D({...R({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return A(I)?!1:ee(g.state.dataUpdateCount)}}),n=p.useCallback(g=>{e&&o({path:{accountId:e},body:k(g)})},[e,o]),c=p.useCallback(g=>{e&&o({path:{accountId:e},body:Y(g)})},[e,o]),{refetch:d}=a,l=p.useCallback(()=>{d()},[d]),i=a.data,f=s.isPending?void 0:i,m=f?.state??s.data?.state,b=A(f?.state),C={state:m,matchedCount:f?.matchedCount??0,appliedCount:f?.appliedCount??0,failedCount:f?.failedCount??0,errorMessage:f?.errorMessage??""};return{start:n,startForFilter:c,watch:r,refreshStatus:l,progress:C,isStarting:s.isPending,isRunning:!!t&&!b,isDone:b,failure:te(s.error,a.error,!!i)}},ye=["From","Subject","HasWords","ListId","FromDomain"],re=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},Oe=(e,t)=>e==="ListId"?re(t):t.trim(),se=e=>e==="all"?"And":"Or",ae=e=>({matchOperator:se(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),ie=e=>!e.literalClauses.some(t=>t.field==="HasWords"),ne=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),Ne=e=>{const t=ae(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?j(e.until??""):void 0}},oe=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},le=350,Fe=(e,t,r)=>{const s=v($()),{mutateAsync:o}=s,a=ne(t),[n,c]=p.useState(()=>({})),d=p.useRef(t);d.current=t;const l=p.useRef(a),i=ie(t);return p.useEffect(()=>{if(!e||!i||a===n.previewedSignature||a===n.errorSignature)return;const f=setTimeout(()=>{const m=a;l.current=m,o({path:{accountId:e},body:k({...d.current})}).then(b=>{l.current===m&&c({count:b.matchedCount,matchedIds:b.messageIds,previewedSignature:m})}).catch(b=>{l.current===m&&c(C=>({...C,error:b instanceof Error?b.message:"Couldn't count matches.",errorSignature:m}))})},le);return()=>clearTimeout(f)},[e,i,a,n.previewedSignature,n.errorSignature,o]),i?{count:oe(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:_},matchedIds:[]}},y=e=>U({path:{accountId:e}}),Ae=e=>{const t=D({...B({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},Ee=e=>{const t=S(),r=v({...J(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,mutateAsync:o}=r,a=p.useCallback((c,d,l)=>{e&&s({path:{accountId:e},body:F(c,d,l)})},[e,s]),n=p.useCallback(async(c,d,l)=>{if(e)return o({path:{accountId:e},body:F(c,d,l)}).then(i=>i,()=>{})},[e,o]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},Me=e=>{const t=S(),r=v({...q(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s}=r;return{deleteFilter:p.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},De=e=>{const t=S(),r=v({...K(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:y(e)})}}),{mutate:s,variables:o}=r,a=p.useCallback((c,d)=>{e&&s({path:{accountId:e,filterId:c},body:{state:d?"Active":"Disabled"}})},[e,s]),n=p.useCallback(()=>{o&&s(o)},[s,o]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?o?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:o?.body?.state==="Active"}};export{fe as A,pe as C,h as N,ye as S,be as a,y as b,Se as c,Ne as d,he as e,ge as f,xe as g,Ae as h,Me as i,De as j,Ee as k,Ce as l,Oe as n,ve as o,j as p,ae as r,Fe as u};
@@ -1 +1 @@
1
- import{a as L,e9 as d,e as n,f as l,ea as p,r as o,eb as y,ec as c,ed as g}from"./index-D94MOpo0.js";const u=e=>y({path:{accountId:e}}),P=e=>{const a=L({...d({path:{accountId:e??""}}),enabled:!!e});return{labels:a.data?.items??[],isPending:a.isPending,isError:a.isError,error:a.error,refetch:a.refetch}},m=e=>{const a=n(),t=l({...p(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:r}=t;return{createLabel:o.useCallback((s,i="Default")=>e?r({path:{accountId:e},body:{name:s,color:i}}):Promise.reject(new Error("No account")),[e,r]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const a=n(),t=l({...c(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{updateLabel:o.useCallback((s,i)=>{e&&r({path:{accountId:e,labelId:s},body:i})},[e,r]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const a=n(),t=l({...g(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{deleteLabel:o.useCallback(s=>{e&&r({path:{accountId:e,labelId:s}})},[e,r]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,h as b,C as c,m as u};
1
+ import{a as L,e9 as d,e as n,f as l,ea as p,r as o,eb as y,ec as c,ed as g}from"./index-CKflMWYU.js";const u=e=>y({path:{accountId:e}}),P=e=>{const a=L({...d({path:{accountId:e??""}}),enabled:!!e});return{labels:a.data?.items??[],isPending:a.isPending,isError:a.isError,error:a.error,refetch:a.refetch}},m=e=>{const a=n(),t=l({...p(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:r}=t;return{createLabel:o.useCallback((s,i="Default")=>e?r({path:{accountId:e},body:{name:s,color:i}}):Promise.reject(new Error("No account")),[e,r]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},h=e=>{const a=n(),t=l({...c(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{updateLabel:o.useCallback((s,i)=>{e&&r({path:{accountId:e,labelId:s},body:i})},[e,r]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const a=n(),t=l({...g(),onSuccess:()=>{e&&a.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{deleteLabel:o.useCallback(s=>{e&&r({path:{accountId:e,labelId:s}})},[e,r]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,h as b,C as c,m as u};
@@ -1 +1 @@
1
- import{a as s,D as e}from"./useMediaQuery-CGZfUxdm.js";const i=768,a=t=>t!=="desktop",r=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{a as i,r as u};
1
+ import{a as s,D as e}from"./useMediaQuery-B1PJEoqh.js";const i=768,a=t=>t!=="desktop",r=()=>{const t=s(`(min-width: ${i}px)`);return s(e)?"desktop":t?"tablet":"phone"};export{a as i,r as u};
@@ -1 +1 @@
1
- import{r as s}from"./index-D94MOpo0.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=i=>n(i.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
1
+ import{r as s}from"./index-CKflMWYU.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=i=>n(i.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
@@ -1,3 +1,3 @@
1
- import{r as V,u as go,c7 as _o,E as Wt,l as Eo,a7 as yo,e as Ao,a as bo,cw as So,ci as Ro}from"./index-D94MOpo0.js";import{g as Oo,j as wo,k as Do}from"./reply-DPVLqPcI.js";function fn(n,o){(o==null||o>n.length)&&(o=n.length);for(var a=0,l=Array(o);a<o;a++)l[a]=n[a];return l}function Co(n){if(Array.isArray(n))return n}function Lo(n,o){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,p,h,F=[],A=!0,G=!1;try{if(p=(a=a.call(n)).next,o!==0)for(;!(A=(l=p.call(a)).done)&&(F.push(l.value),F.length!==o);A=!0);}catch(W){G=!0,c=W}finally{try{if(!A&&a.return!=null&&(h=a.return(),Object(h)!==h))return}finally{if(G)throw c}}return F}}function No(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as V,u as go,c8 as _o,E as Wt,l as Eo,a6 as yo,e as Ao,a as bo,cw as So,ci as Ro}from"./index-CKflMWYU.js";import{e as Oo,f as wo}from"./reply-CM_F5zLS.js";import{c as Do}from"./nav-link-D4-gc9H1.js";function fn(n,o){(o==null||o>n.length)&&(o=n.length);for(var a=0,l=Array(o);a<o;a++)l[a]=n[a];return l}function Co(n){if(Array.isArray(n))return n}function Lo(n,o){var a=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(a!=null){var l,c,p,h,F=[],A=!0,G=!1;try{if(p=(a=a.call(n)).next,o!==0)for(;!(A=(l=p.call(a)).done)&&(F.push(l.value),F.length!==o);A=!0);}catch(W){G=!0,c=W}finally{try{if(!A&&a.return!=null&&(h=a.return(),Object(h)!==h))return}finally{if(G)throw c}}return F}}function No(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Io(n,o){return Co(n)||Lo(n,o)||Mo(n,o)||No()}function Mo(n,o){if(n){if(typeof n=="string")return fn(n,o);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?fn(n,o):void 0}}const wn=Object.entries,pn=Object.setPrototypeOf,Po=Object.isFrozen,Dn=Object.getPrototypeOf,Cn=Object.getOwnPropertyDescriptor;let O=Object.freeze,D=Object.seal,Tt=Object.create,Ln=typeof Reflect<"u"&&Reflect,De=Ln.apply,Ce=Ln.construct;O||(O=function(o){return o});D||(D=function(o){return o});De||(De=function(o,a){for(var l=arguments.length,c=new Array(l>2?l-2:0),p=2;p<l;p++)c[p-2]=arguments[p];return o.apply(a,c)});Ce||(Ce=function(o){for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];return new o(...l)});const $=E(Array.prototype.forEach),xo=E(Array.prototype.lastIndexOf),mn=E(Array.prototype.pop),Dt=E(Array.prototype.push),vo=E(Array.prototype.slice),ko=E(Array.prototype.splice),_t=Array.isArray,_e=Nn(Set),Ee=E(Set.prototype.add),Ct=E(Set.prototype.has),st=E(String.prototype.toLowerCase),ye=E(String.prototype.toString),dn=E(String.prototype.match),Lt=E(String.prototype.replace),hn=E(String.prototype.indexOf),Uo=E(String.prototype.trim),Fo=E(Number.prototype.toString),zo=E(Boolean.prototype.toString),Tn=typeof BigInt>"u"?null:E(BigInt.prototype.toString),gn=typeof Symbol>"u"?null:E(Symbol.prototype.toString),P=E(Object.prototype.hasOwnProperty),Nt=E(Object.prototype.toString),w=E(RegExp.prototype.test),j=Nn(TypeError);function E(n){return function(o){o instanceof RegExp&&(o.lastIndex=0);for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];return De(n,o,l)}}function Nn(n){return function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return Ce(n,a)}}function d(n,o){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:st;if(pn&&pn(n,null),!_t(o))return n;let l=o.length;for(;l--;){let c=o[l];if(typeof c=="string"){const p=a(c);p!==c&&(Po(o)||(o[l]=p),c=p)}n[c]=!0}return n}function Ho(n){for(let o=0;o<n.length;o++)P(n,o)||(n[o]=null);return n}function x(n){const o=Tt(null);for(const l of wn(n)){var a=Io(l,2);const c=a[0],p=a[1];P(n,c)&&(_t(p)?o[c]=Ho(p):p&&typeof p=="object"&&p.constructor===Object?o[c]=x(p):o[c]=p)}return o}function Bo(n){switch(typeof n){case"string":return n;case"number":return Fo(n);case"boolean":return zo(n);case"bigint":return Tn?Tn(n):"0";case"symbol":return gn?gn(n):"Symbol()";case"undefined":return Nt(n);case"function":case"object":{if(n===null)return Nt(n);const o=n,a=k(o,"toString");if(typeof a=="function"){const l=a(o);return typeof l=="string"?l:Nt(l)}return Nt(n)}default:return Nt(n)}}function k(n,o){for(;n!==null;){const l=Cn(n,o);if(l){if(l.get)return E(l.get);if(typeof l.value=="function")return E(l.value)}n=Dn(n)}function a(){return null}return a}function Go(n,o){for(;n!==null;){const a=Cn(n,o);if(a)return a.get?E(a.get):null;n=Dn(n)}return null}function Wo(n){try{return w(n,""),!0}catch{return!1}}const _n=O(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ae=O(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),be=O(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Yo=O(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Se=O(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$o=O(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),En=O(["#text"]),yn=O(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Re=O(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),An=O(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Yt=O(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jo=D(/{{[\w\W]*|^[\w\W]*}}/g),Vo=D(/<%[\w\W]*|^[\w\W]*%>/g),Xo=D(/\${[\w\W]*/g),Ko=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),qo=D(/^aria-[\-\w]+$/),bn=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qo=D(/^(?:\w+script|data):/i),Zo=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Jo=D(/^html$/i),tr=D(/^[a-z][.\w]*(-[.\w]+)+$/i),Oe=D(/<[/\w!]/g),Sn=D(/<[/\w]/g),er=D(/<\/no(script|embed|frames)/i),Rn=D(/\/>/i),b={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nr=O(d({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),or=function(){return typeof window>"u"?null:window},rr=function(o,a){if(typeof o!="object"||typeof o.createPolicy!="function")return null;let l=null;const c="data-tt-policy-suffix";a&&a.hasAttribute(c)&&(l=a.getAttribute(c));const p="dompurify"+(l?"#"+l:"");try{return o.createPolicy(p,{createHTML(h){return h},createScriptURL(h){return h}})}catch{return console.warn("TrustedTypes policy "+p+" could not be created."),null}},On=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Z=function(o,a,l,c){return P(o,a)&&_t(o[a])?d(c.base?x(c.base):{},o[a],c.transform):l},we=function(o,a,l){const c=P(o,a)?o[a]:void 0;return c&&typeof c=="object"?x(c):l()};function In(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:or();const o=s=>In(s);if(o.version="3.4.17",o.removed=[],!n||!n.document||n.document.nodeType!==b.document||!n.Element)return o.isSupported=!1,o;let a=n.document;const l=a,c=l.currentScript;n.DocumentFragment;const p=n.HTMLTemplateElement,h=n.Node,F=n.Element,A=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const G=n.DOMParser,W=n.trustedTypes,R=F.prototype,Et=k(R,"cloneNode"),yt=k(R,"remove"),It=k(R,"removeAttributeNode"),J=k(R,"nextSibling"),L=k(R,"childNodes"),X=k(R,"parentNode"),$t=k(R,"shadowRoot"),jt=k(R,"attributes"),tt=h&&h.prototype?k(h.prototype,"nodeType"):null,at=h&&h.prototype?k(h.prototype,"nodeName"):null,Mt=h&&h.prototype?k(h.prototype,"ownerDocument"):null,v=function(t){return tt?tt(t):t.nodeType},At=function(t){return at?at(t):t.nodeName},Ie=Go(R,"namespaceURI"),Vt=function(t){return Ie?Ie(t):t.namespaceURI};if(typeof p=="function"){const s=a.createElement("template");s.content&&s.content.ownerDocument&&(a=s.content.ownerDocument)}let N,et="",Xt,Me=!1,bt=0;const Pe=function(){if(bt>0)throw j('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},lt=function(t){Pe(),bt++;try{return N.createHTML(t)}finally{bt--}},Fn=function(t){Pe(),bt++;try{return N.createScriptURL(t)}finally{bt--}},zn=function(){return Me||(Xt=rr(W,c),Me=!0),Xt},Pt=a,Kt=Pt.implementation,xe=Pt.createNodeIterator,Hn=Pt.createDocumentFragment,Bn=Pt.getElementsByTagName,Gn=l.importNode;let T=On();o.isSupported=typeof wn=="function"&&typeof X=="function"&&Kt&&Kt.createHTMLDocument!==void 0;const Wn=jo,Yn=Vo,$n=Xo,jn=Ko,Vn=qo,Xn=Qo,ve=Zo,Kn=tr;let ke=bn,g=null;const qt=d({},[..._n,...Ae,...be,...Se,...En]);let _=null;const Qt=d({},[...yn,...Re,...An,...Yt]);let z=Object.seal(Tt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),St=null,Ue=null;const K=Object.seal(Tt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Fe=!0,Zt=!0,ze=!1,Jt=!0,Y=!1,nt=!0,ot=!1,te=!1,xt=null,vt=null,ee=!1,ct=!1,kt=!1,Ut=!1,He=!0,Be=!1;const Ge="user-content-";let ne=!0,oe=!1,rt=null,ut={},it=null;const We=d({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ye=null;const $e=d({},["audio","video","img","source","image","track"]);let je=null;const Ve=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ft="http://www.w3.org/1998/Math/MathML",zt="http://www.w3.org/2000/svg",H="http://www.w3.org/1999/xhtml";let ft=H,re=!1,ie=null;const qn=d({},[Ft,zt,H],ye),Xe=O(["mi","mo","mn","ms","mtext"]);let se=d({},Xe);const Ke=O(["annotation-xml"]);let ae=d({},Ke);const Qn=d({},["title","style","font","a","script"]);let Rt=null;const Zn=["application/xhtml+xml","text/html"],Jn="text/html";let y=null,pt=null;const to=a.createElement("form"),qe=function(t){return t instanceof RegExp||t instanceof Function},le=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(pt&&pt===t)return;(!t||typeof t!="object")&&(t={}),t=x(t),Rt=Zn.indexOf(t.PARSER_MEDIA_TYPE)===-1?Jn:t.PARSER_MEDIA_TYPE,y=Rt==="application/xhtml+xml"?ye:st,g=Z(t,"ALLOWED_TAGS",qt,{transform:y}),_=Z(t,"ALLOWED_ATTR",Qt,{transform:y}),ie=Z(t,"ALLOWED_NAMESPACES",qn,{transform:ye}),je=Z(t,"ADD_URI_SAFE_ATTR",Ve,{transform:y,base:Ve}),Ye=Z(t,"ADD_DATA_URI_TAGS",$e,{transform:y,base:$e}),it=Z(t,"FORBID_CONTENTS",We,{transform:y}),St=Z(t,"FORBID_TAGS",x({}),{transform:y}),Ue=Z(t,"FORBID_ATTR",x({}),{transform:y}),ut=P(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?x(t.USE_PROFILES):t.USE_PROFILES:!1,Fe=t.ALLOW_ARIA_ATTR!==!1,Zt=t.ALLOW_DATA_ATTR!==!1,ze=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Jt=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Y=t.SAFE_FOR_TEMPLATES||!1,nt=t.SAFE_FOR_XML!==!1,ot=t.WHOLE_DOCUMENT||!1,ct=t.RETURN_DOM||!1,kt=t.RETURN_DOM_FRAGMENT||!1,Ut=t.RETURN_TRUSTED_TYPE||!1,ee=t.FORCE_BODY||!1,He=t.SANITIZE_DOM!==!1,Be=t.SANITIZE_NAMED_PROPS||!1,ne=t.KEEP_CONTENT!==!1,oe=t.IN_PLACE||!1,ke=Wo(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:bn,ft=typeof t.NAMESPACE=="string"?t.NAMESPACE:H,se=we(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>d({},Xe)),ae=we(t,"HTML_INTEGRATION_POINTS",()=>d({},Ke));const e=we(t,"CUSTOM_ELEMENT_HANDLING",()=>Tt(null));if(z=Tt(null),P(e,"tagNameCheck")&&qe(e.tagNameCheck)&&(z.tagNameCheck=e.tagNameCheck),P(e,"attributeNameCheck")&&qe(e.attributeNameCheck)&&(z.attributeNameCheck=e.attributeNameCheck),P(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),D(z),Y&&(Zt=!1),kt&&(ct=!0),ut&&(g=d({},En),_=Tt(null),ut.html===!0&&(d(g,_n),d(_,yn)),ut.svg===!0&&(d(g,Ae),d(_,Re),d(_,Yt)),ut.svgFilters===!0&&(d(g,be),d(_,Re),d(_,Yt)),ut.mathMl===!0&&(d(g,Se),d(_,An),d(_,Yt))),K.tagCheck=null,K.attributeCheck=null,P(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?K.tagCheck=t.ADD_TAGS:_t(t.ADD_TAGS)&&(g===qt&&(g=x(g)),d(g,t.ADD_TAGS,y))),P(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?K.attributeCheck=t.ADD_ATTR:_t(t.ADD_ATTR)&&(_===Qt&&(_=x(_)),d(_,t.ADD_ATTR,y))),P(t,"ADD_FORBID_CONTENTS")&&_t(t.ADD_FORBID_CONTENTS)&&(it===We&&(it=x(it)),d(it,t.ADD_FORBID_CONTENTS,y)),ne&&(g["#text"]=!0),ot&&d(g,["html","head","body"]),g.table&&(d(g,["tbody"]),delete St.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw j('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const r=N;N=t.TRUSTED_TYPES_POLICY;try{et=lt("")}catch(i){throw N=r,i}}else t.TRUSTED_TYPES_POLICY===null?(N=void 0,et=""):(N===void 0&&(N=zn()),N&&typeof et=="string"&&(et=lt("")));O&&O(t),pt=t},Qe=d({},[...Ae,...be,...Yo]),Ze=d({},[...Se,...$o]),eo=function(t,e,r){return e.namespaceURI===H?t==="svg":e.namespaceURI===Ft?t==="svg"&&(r==="annotation-xml"||se[r]):!!Qe[t]},no=function(t,e,r){return e.namespaceURI===H?t==="math":e.namespaceURI===zt?t==="math"&&ae[r]:!!Ze[t]},oo=function(t,e,r){return e.namespaceURI===zt&&!ae[r]||e.namespaceURI===Ft&&!se[r]?!1:!Ze[t]&&(Qn[t]||!Qe[t])},ro=function(t){const e=Vt(t),r=st(At(t)),i=X(t);let u,f;return i&&v(i)===b.element?(u={namespaceURI:Vt(i)},f=st(At(i))):(u={namespaceURI:ft},f="template"),ie[e]?e===zt?eo(r,u,f):e===Ft?no(r,u,f):e===H?oo(r,u,f):!!(Rt==="application/xhtml+xml"&&ie[e]):!1},q=function(t){Dt(o.removed,{element:t});try{X(t).removeChild(t)}catch{if(yt(t),!X(t))throw j("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Je=function(t,e,r){try{It(t,e)}catch{try{t.removeAttribute(r)}catch{}}},ce=function(t){fe(t);const e=L(t);e&&$(vo(e),i=>{try{yt(i)}catch{}});const r=v(t)===b.element?jt(t):null;if(r)for(let i=r.length-1;i>=0;--i){const u=r[i],f=u&&u.name;typeof f=="string"&&Je(t,u,f)}},mt=function(t,e,r){if(!r)try{r=e.getAttributeNode(t)}catch{r=null}Dt(o.removed,{attribute:r||null,from:e});try{r?It(e,r):e.removeAttribute(t)}catch{try{e.removeAttribute(t)}catch{}}if(t==="is")if(ct||kt)try{q(e)}catch{}else try{e.setAttribute(t,"")}catch{}},tn=function(t){const e=jt(t);if(e)for(let r=e.length-1;r>=0;--r){const i=e[r],u=i&&i.name;typeof u!="string"||_[y(u)]||Je(t,i,u)}},ue=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const i=[t];for(;i.length>0;){const u=i.pop();if(e(u)===!1)continue;if(r&&v(u)===b.element){const m=$t(u);Q(m)&&i.push(m)}const f=L(u);if(f)for(let m=f.length-1;m>=0;--m)i.push(f[m])}},fe=function(t){ue(t,e=>{v(e)===b.element&&tn(e)})},pe=function(t){const e=[];return ue(t,r=>{e.push(r)},!0),e},io=function(t,e){const r=_e();$(pe(t),i=>{v(i)===b.element&&Ee(r,i)}),$(e,i=>{v(i)===b.element&&!Ct(r,i)&&tn(i)})},en=function(t,e){let r=!1;return $(o.removed,i=>{i.element&&(r=r||i.element===t,fe(i.element))}),io(t,e),r},so=8,ao=function(t,e){const r=rt;let i=null;const u=()=>(i||(i=_e(),$(e,f=>{Ee(i,f)})),i);for(let f=0;;f++){const m=pe(t),S=[t];let B=!1;if($(m,C=>{v(C)===b.documentFragment?Dt(S,C):!B&&!Ct(r,C)&&(B=Ct(u(),C))}),!B)return;if(f>=so)throw j("the tree kept changing during in-place sanitization; refusing to return it");$(S,(C,I)=>{lo(C,I>0,t,u())})}},lo=function(t,e,r,i){const u=me(t);let f;for(;f=u.nextNode();)!Ct(i,f)||Ct(rt,f)||(e&&U(T.uponSanitizeShadowNode,f,null),he(f,r),Te(f,r),Q(f.content)&&wt(f.content))},co=function(t){rt&&Ee(rt,t)},nn=function(t,e){return nt?t==="patchsrc"?!0:t==="for"&&e!=="label"&&e!=="output":!1},uo=function(t){nt&&ue(t,e=>{const r=v(e);if(r===b.processingInstruction||r===b.comment&&w(Sn,e.data)){try{yt(e)}catch{}return!1}if(r===b.element){const i=e,u=y(At(e));try{i.hasAttribute&&i.hasAttribute("patchsrc")&&i.removeAttribute("patchsrc"),i.hasAttribute&&i.hasAttribute("for")&&nn("for",u)&&i.removeAttribute("for")}catch{}}return!0})},on=function(t){let e=null,r=null;if(ee)t="<remove></remove>"+t;else{const f=dn(t,/^[\r\n\t ]+/);r=f&&f[0]}Rt==="application/xhtml+xml"&&ft===H&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const i=N?lt(t):t;if(ft===H)try{e=new G().parseFromString(i,Rt)}catch{}if(!e||!e.documentElement){e=Kt.createDocument(ft,"template",null);try{e.documentElement.innerHTML=re?et:i}catch{}}const u=e.body||e.documentElement;return t&&r&&u.insertBefore(a.createTextNode(r),u.childNodes[0]||null),ft===H?Bn.call(e,ot?"html":"body")[0]:ot?e.documentElement:u},me=function(t){const e=Mt?Mt(t):t.ownerDocument;return xe.call(e||t,t,A.SHOW_ELEMENT|A.SHOW_COMMENT|A.SHOW_TEXT|A.SHOW_PROCESSING_INSTRUCTION|A.SHOW_CDATA_SECTION,null)},Ht=function(t){return t=Lt(t,Wn," "),t=Lt(t,Yn," "),t=Lt(t,$n," "),t},de=function(t){var e;rn(t);const r=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");r&&$(r,i=>{Q(i.content)&&de(i.content)})},rn=function(t){t.normalize();const e=Mt?Mt(t):t.ownerDocument,r=xe.call(e||t,t,A.SHOW_TEXT|A.SHOW_COMMENT|A.SHOW_CDATA_SECTION|A.SHOW_PROCESSING_INSTRUCTION,null);let i=r.nextNode();for(;i;)i.data=Ht(i.data),i=r.nextNode()},Bt=function(t){const e=at?at(t):null;return typeof e!="string"||y(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==jt(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==tt(t)||t.childNodes!==L(t)},Q=function(t){if(!tt||typeof t!="object"||t===null)return!1;try{return tt(t)===b.documentFragment}catch{return!1}},Ot=function(t){if(!tt||typeof t!="object"||t===null)return!1;try{return typeof tt(t)=="number"}catch{return!1}};function U(s,t,e){s.length!==0&&$(s,r=>{r.call(o,t,e,pt)})}const fo=function(t,e){return!!(nt&&t.hasChildNodes()&&!Ot(t.firstElementChild)&&w(Oe,t.textContent)&&w(Oe,t.innerHTML)||nt&&nr[e]&&v(t)===b.element&&Vt(t)===H&&(Ot(t.firstElementChild)||typeof t.textContent=="string"&&w(Oe,t.textContent))||t.nodeType===b.processingInstruction||nt&&t.nodeType===b.comment&&w(Sn,t.data))},Gt=function(t,e){if(t instanceof RegExp)return w(t,e);if(t instanceof Function){for(var r=arguments.length,i=new Array(r>2?r-2:0),u=2;u<r;u++)i[u-2]=arguments[u];return!!t(e,...i)}return!1},po=function(t,e,r){if(!St[e]&&ln(e)&&Gt(z.tagNameCheck,e))return!1;if(ne&&!it[e]&&!it[st(e)]){const i=X(t),u=L(t);if(u&&i){const f=u.length;for(let m=f-1;m>=0;--m){const S=t===r?Et(u[m],!0):u[m];i.insertBefore(S,J(t))}}}return q(t),!0},sn=function(t,e,r,i){return t.length===0?e:e===r||e===i?x(e):e},dt=function(t,e){return t===e||X(t)!==null?!1:(oe&&fe(t),!0)},he=function(t,e){if(co(t),U(T.beforeSanitizeElements,t,null),dt(t,e))return!0;if(Bt(t))return q(t),!0;const r=y(At(t));if(g=sn(T.uponSanitizeElement,g,qt,xt),U(T.uponSanitizeElement,t,{tagName:r,allowedTags:g}),dt(t,e))return!0;if(fo(t,r))return q(t),!0;if(St[r]||!(K.tagCheck instanceof Function&&K.tagCheck(r))&&!g[r]){const i=po(t,r,e);return i===!1&&(U(T.afterSanitizeElements,t,null),dt(t,e))?!0:i}if(v(t)===b.element&&!ro(t)||(r==="noscript"||r==="noembed"||r==="noframes")&&w(er,t.innerHTML))return q(t),!0;if(Y&&t.nodeType===b.text){const i=Ht(t.textContent);t.textContent!==i&&(Dt(o.removed,{element:t.cloneNode()}),t.textContent=i)}return U(T.afterSanitizeElements,t,null),dt(t,e)},an=function(t,e,r){if(Ue[e]||nn(e,t)||He&&(e==="id"||e==="name")&&(r in a||r in to))return!1;const i=_[e]||K.attributeCheck instanceof Function&&K.attributeCheck(e,t);return Zt&&w(jn,e)||Fe&&w(Vn,e)?!0:i?je[e]||w(ke,Lt(r,ve,""))||(e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&hn(r,"data:")===0&&Ye[t]||ze&&!w(Xn,Lt(r,ve,""))?!0:!r:ln(t)&&Gt(z.tagNameCheck,t)&&Gt(z.attributeNameCheck,e,t)||e==="is"&&z.allowCustomizedBuiltInElements&&Gt(z.tagNameCheck,r)},mo=d({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(t){return!mo[st(t)]&&w(Kn,t)},ho=function(t,e,r,i){if(N&&typeof W=="object"&&typeof W.getAttributeType=="function"&&!r)switch(W.getAttributeType(t,e)){case"TrustedHTML":return lt(i);case"TrustedScriptURL":return Fn(i)}return i},To=function(t,e,r,i){try{return r?t.setAttributeNS(r,e,i):t.setAttribute(e,i),Bt(t)?(q(t),!1):!0}catch{return mt(e,t),!1}},cn=function(t,e){return nt&&w(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e)?!0:st(t)==="attributename"&&dn(e,"href")!==null},Te=function(t,e){if(U(T.beforeSanitizeAttributes,t,null),dt(t,e))return;const r=t.attributes;if(!r||Bt(t))return;_=sn(T.uponSanitizeAttribute,_,Qt,vt);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:_,forceKeepAttr:void 0};let u=r.length;const f=y(t.nodeName);for(;u--;){const m=r[u],S=m.name,B=m.namespaceURI,C=m.value,I=y(S),ht=C;let M=S==="value"?ht:Uo(ht),un=!1;if(i.attrName=I,i.attrValue=M,i.keepAttr=!0,i.forceKeepAttr=void 0,U(T.uponSanitizeAttribute,t,i),M=i.attrValue,Be&&(I==="id"||I==="name")&&hn(M,Ge)!==0&&(mt(S,t,m),M=Ge+M,un=!0),cn(S,M)){mt(S,t,m);continue}if(!i.forceKeepAttr){if(!i.keepAttr){mt(S,t,m);continue}if(!Jt&&w(Rn,M)){mt(S,t,m);continue}if(Y&&(M=Ht(M)),!an(f,I,M)){mt(S,t,m);continue}M=ho(f,I,B,M),M!==ht&&To(t,S,B,M)&&un&&mn(o.removed)}}U(T.afterSanitizeAttributes,t,null),dt(t,e)},wt=function(t){let e=null;const r=me(t);for(U(T.beforeSanitizeShadowDOM,t,null);e=r.nextNode();)if(U(T.uponSanitizeShadowNode,e,null),he(e,t),Te(e,t),Q(e.content)&&wt(e.content),v(e)===b.element){const i=$t(e);Q(i)&&(ge(i),wt(i))}Y&&rn(t),U(T.afterSanitizeShadowDOM,t,null)},ge=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const r=e.pop();if(r.shadow){wt(r.shadow);continue}const i=r.node,u=v(i)===b.element,f=L(i);if(f)for(let m=f.length-1;m>=0;--m)e.push({node:f[m],shadow:null});if(u){const m=at?at(i):null;if(typeof m=="string"&&y(m)==="template"){const S=i.content;Q(S)&&e.push({node:S,shadow:null})}}if(u){const m=$t(i);Q(m)&&e.push({node:null,shadow:m},{node:m,shadow:null})}}};return o.sanitize=function(s){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,r=null,i=null,u=null;if(re=!s,re&&(s="<!-->"),typeof s!="string"&&!Ot(s)&&(s=Bo(s),typeof s!="string"))throw j("dirty is not a string, aborting");if(!o.isSupported)return s;te?(g=xt,_=vt):le(t),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(g=x(g)),T.uponSanitizeAttribute.length>0&&(_=x(_)),o.removed=[];const f=oe&&typeof s!="string"&&Ot(s);let m=[];const S=rt;if(f){uo(s);const I=At(s);if(typeof I=="string"){const ht=y(I);if(!g[ht]||St[ht])throw ce(s),j("root node is forbidden and cannot be sanitized in-place")}if(Bt(s))throw ce(s),j("root node is clobbered and cannot be sanitized in-place");m=pe(s),rt=_e()}else if(Ot(s))e=on("<!---->"),r=e.ownerDocument.importNode(s,!0),r.nodeType===b.element&&r.nodeName==="BODY"||r.nodeName==="HTML"?e=r:e.appendChild(r),ge(e);else{if(!ct&&!Y&&!ot&&s.indexOf("<")===-1)return N&&Ut?lt(s):s;if(e=on(s),!e)return ct?null:Ut?et:""}e&&ee&&q(e.firstChild);const B=f?s:e;try{f&&ge(s);const I=me(B);for(;i=I.nextNode();)he(i,B),Te(i,B),Q(i.content)&&wt(i.content);f&&ao(s,m)}catch(I){throw f&&(ce(s),en(s,m)),I}finally{rt=S}if(f){if(en(s,m))throw j("a node selected for removal could not be safely returned; refusing to sanitize in place");return Y&&de(s),s}if(ct){if(Y&&de(e),kt)for(u=Hn.call(e.ownerDocument);e.firstChild;)u.appendChild(e.firstChild);else u=e;return(_.shadowroot||_.shadowrootmode)&&(u=Gn.call(l,u,!0)),u}let C=ot?e.outerHTML:e.innerHTML;return ot&&g["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&w(Jo,e.ownerDocument.doctype.name)&&(C="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
3
- `+C),Y&&(C=Ht(C)),N&&Ut?lt(C):C},o.setConfig=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};le(s),te=!0,xt=g,vt=_},o.clearConfig=function(){pt=null,te=!1,xt=null,vt=null,N=Xt,et=""},o.isValidAttribute=function(s,t,e){pt||le({});const r=y(s),i=y(t);return typeof e=="string"&&(cn(t,e)||!Jt&&w(Rn,e))?!1:an(r,i,e)},o.addHook=function(s,t){typeof t=="function"&&P(T,s)&&Dt(T[s],t)},o.removeHook=function(s,t){if(P(T,s)){if(t!==void 0){const e=xo(T[s],t);return e===-1?void 0:ko(T[s],e,1)[0]}return mn(T[s])}},o.removeHooks=function(s){P(T,s)&&(T[s]=[])},o.removeAllHooks=function(){T=On()},o}var yr=In();const Mn="/mail/brief/compose/{-$outboxMessageId}",Pn="/mail/flagged/compose/{-$outboxMessageId}",xn="/mail/outbox/compose/{-$outboxMessageId}",vn="/mail/$mailboxId/compose/{-$outboxMessageId}";function kn(){const n=Wt({from:Mn,shouldThrow:!1}),o=Wt({from:Pn,shouldThrow:!1}),a=Wt({from:xn,shouldThrow:!1}),l=Wt({from:vn,shouldThrow:!1});return n??o??a??l}function Ar(){return kn()!==void 0}function br(){return kn()?.outboxMessageId}function ir(n,o,a){return n==="flagged"?{to:Pn,params:{outboxMessageId:a}}:n==="outbox"?{to:xn,params:{outboxMessageId:a}}:n==="mailbox"&&o?{to:vn,params:{mailboxId:o,outboxMessageId:a}}:{to:Mn,params:{outboxMessageId:a}}}function Ne(){const n=go(),o=Oo(),{list:a,mailboxId:l}=wo();return V.useCallback((c,p)=>{n({...ir(a,l,c),search:_o,hash:p?.keepPanels?!0:o,replace:p?.replace??!1})},[n,o,a,l])}function Sr(){const n=Ne();return V.useCallback(()=>n(void 0),[n])}function Rr(){const n=Ne();return V.useCallback(o=>n(o),[n])}function Or(){const n=Ne();return V.useCallback(o=>n(o,{replace:!0,keepPanels:!0}),[n])}function wr(){return Do()}const sr=new Set(["rfc822","global"]),ar=n=>n.mediaType.toUpperCase()==="MESSAGE"&&sr.has(n.mediaSubtype.toLowerCase()),Un=(n,o)=>n.partPath.startsWith(`${o}.`),lr=n=>{const o=n.filter(ar);return n.filter(a=>!o.some(l=>Un(a,l.partPath)))},Dr=(n,o)=>n.filter(a=>Un(a,o)),cr=n=>{const o=lr(n).filter(c=>!c.isMultipart&&c.disposition!=="attachment"&&c.mediaType==="TEXT"&&c.contentUrl.length>0),a=o.find(c=>c.mediaSubtype.toUpperCase()==="HTML");if(a)return{kind:"html",contentUrl:a.contentUrl};const l=o.find(c=>c.mediaSubtype.toUpperCase()==="PLAIN");return l?{kind:"text",contentUrl:l.contentUrl}:null},Le={all:["messages"],detail:n=>[...Le.all,"detail",n],body:n=>[...Le.detail(n),"body"]};class gt extends Error{reason;status;retryAfterSeconds;constructor(o,a,l,c){super(a),this.name="BodyFetchError",this.reason=o,this.status=l,this.retryAfterSeconds=c}}const ur=n=>{const o=Number.parseInt(n??"",10);return!Number.isFinite(o)||o<=0?1:Math.min(o,30)},fr=8,pr="x-remit-403-reason",mr=(n,o)=>{const a=o?.trim()??"";return n===401?"auth":n===403?a.length>0?"auth":"body-missing":n===404?"body-missing":"generic"},dr=(n,o)=>(o??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(n):!1,hr=(n,o)=>{const a=(o??"").toLowerCase();return!!(n==="text"&&a.startsWith("text/html"))},Tr=async(n,o,a=async()=>null)=>{const l={},c=await a();c&&(l.Authorization=`Bearer ${c}`);const p=await Ro(n,{headers:l});if(p.status===202)throw new gt("not-ready","Message body is still syncing",202,ur(p.headers.get("Retry-After")));if(!p.ok){const A=p.headers.get(pr),G=mr(p.status,A);throw new gt(G,`Failed to load message body (${p.status} ${p.statusText})`,p.status)}const h=p.headers.get("content-type");if(hr(o,h))throw new gt("content-type-mismatch",`Refusing to render message body — expected ${o}, got Content-Type ${h}`);const F=await p.text();if(dr(F,h))throw new gt("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return F},gr=async(n,o)=>(o.isRetryAfterNotReady&&await n.refetchDescribeMessage(),n.fetchContent(o.contentUrl,o.kind)),Cr=({messageId:n,bodyParts:o,enabled:a=!0})=>{const l=o?cr(o):null,c=Eo(),{getToken:p}=yo(),h=V.useRef(null),F=Ao(),A=V.useRef(!1),G=V.useRef(null),W=n&&l?`${n}:${l.contentUrl}`:null;G.current!==W&&(G.current=W,A.current=!1);const R=bo({queryKey:n?[...Le.body(n),l?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!l)throw new Error("No renderable body part");if(!n)throw new Error("No messageId");const J=A.current;return A.current=!1,gr({fetchContent:(L,X)=>Tr(L,X,p),refetchDescribeMessage:()=>F.refetchQueries({queryKey:So({path:{messageId:n}})})},{contentUrl:l.contentUrl,kind:l.kind,isRetryAfterNotReady:J})},enabled:a&&!!n&&!!l,staleTime:300*1e3,gcTime:1800*1e3,retry:(J,L)=>L instanceof gt&&L.reason==="not-ready"?J<fr:J<1,retryDelay:(J,L)=>L instanceof gt&&L.reason==="not-ready"?(A.current=!0,(L.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),Et=R.isLoading&&!!l,yt=o!==void 0&&l===null;V.useEffect(()=>{Et&&(h.current=performance.now())},[Et]),V.useEffect(()=>{R.isSuccess&&h.current!==null&&(c.recordTiming("message.body.load",Math.round(performance.now()-h.current)),h.current=null)},[R.isSuccess,c]);const It=R.data&&l?{kind:l.kind,body:R.data}:void 0;return{picked:l,data:It,isLoading:Et,hasNoRenderablePart:yt,isError:R.isError,error:R.error,refetch:R.refetch}};export{gt as B,Ar as a,Cr as b,mr as c,br as d,Or as e,wr as f,Rr as g,Dr as h,ar as i,lr as o,yr as p,Sr as u};
3
+ `+C),Y&&(C=Ht(C)),N&&Ut?lt(C):C},o.setConfig=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};le(s),te=!0,xt=g,vt=_},o.clearConfig=function(){pt=null,te=!1,xt=null,vt=null,N=Xt,et=""},o.isValidAttribute=function(s,t,e){pt||le({});const r=y(s),i=y(t);return typeof e=="string"&&(cn(t,e)||!Jt&&w(Rn,e))?!1:an(r,i,e)},o.addHook=function(s,t){typeof t=="function"&&P(T,s)&&Dt(T[s],t)},o.removeHook=function(s,t){if(P(T,s)){if(t!==void 0){const e=xo(T[s],t);return e===-1?void 0:ko(T[s],e,1)[0]}return mn(T[s])}},o.removeHooks=function(s){P(T,s)&&(T[s]=[])},o.removeAllHooks=function(){T=On()},o}var Ar=In();const Mn="/mail/brief/compose/{-$outboxMessageId}",Pn="/mail/flagged/compose/{-$outboxMessageId}",xn="/mail/outbox/compose/{-$outboxMessageId}",vn="/mail/$mailboxId/compose/{-$outboxMessageId}";function kn(){const n=Wt({from:Mn,shouldThrow:!1}),o=Wt({from:Pn,shouldThrow:!1}),a=Wt({from:xn,shouldThrow:!1}),l=Wt({from:vn,shouldThrow:!1});return n??o??a??l}function br(){return kn()!==void 0}function Sr(){return kn()?.outboxMessageId}function ir(n,o,a){return n==="flagged"?{to:Pn,params:{outboxMessageId:a}}:n==="outbox"?{to:xn,params:{outboxMessageId:a}}:n==="mailbox"&&o?{to:vn,params:{mailboxId:o,outboxMessageId:a}}:{to:Mn,params:{outboxMessageId:a}}}function Ne(){const n=go(),o=Do(),{list:a,mailboxId:l}=Oo();return V.useCallback((c,p)=>{n({...ir(a,l,c),search:_o,hash:p?.keepPanels?!0:o,replace:p?.replace??!1})},[n,o,a,l])}function Rr(){const n=Ne();return V.useCallback(()=>n(void 0),[n])}function Or(){const n=Ne();return V.useCallback(o=>n(o),[n])}function wr(){const n=Ne();return V.useCallback(o=>n(o,{replace:!0,keepPanels:!0}),[n])}function Dr(){return wo()}const sr=new Set(["rfc822","global"]),ar=n=>n.mediaType.toUpperCase()==="MESSAGE"&&sr.has(n.mediaSubtype.toLowerCase()),Un=(n,o)=>n.partPath.startsWith(`${o}.`),lr=n=>{const o=n.filter(ar);return n.filter(a=>!o.some(l=>Un(a,l.partPath)))},Cr=(n,o)=>n.filter(a=>Un(a,o)),cr=n=>{const o=lr(n).filter(c=>!c.isMultipart&&c.disposition!=="attachment"&&c.mediaType==="TEXT"&&c.contentUrl.length>0),a=o.find(c=>c.mediaSubtype.toUpperCase()==="HTML");if(a)return{kind:"html",contentUrl:a.contentUrl};const l=o.find(c=>c.mediaSubtype.toUpperCase()==="PLAIN");return l?{kind:"text",contentUrl:l.contentUrl}:null},Le={all:["messages"],detail:n=>[...Le.all,"detail",n],body:n=>[...Le.detail(n),"body"]};class gt extends Error{reason;status;retryAfterSeconds;constructor(o,a,l,c){super(a),this.name="BodyFetchError",this.reason=o,this.status=l,this.retryAfterSeconds=c}}const ur=n=>{const o=Number.parseInt(n??"",10);return!Number.isFinite(o)||o<=0?1:Math.min(o,30)},fr=8,pr="x-remit-403-reason",mr=(n,o)=>{const a=o?.trim()??"";return n===401?"auth":n===403?a.length>0?"auth":"body-missing":n===404?"body-missing":"generic"},dr=(n,o)=>(o??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(n):!1,hr=(n,o)=>{const a=(o??"").toLowerCase();return!!(n==="text"&&a.startsWith("text/html"))},Tr=async(n,o,a=async()=>null)=>{const l={},c=await a();c&&(l.Authorization=`Bearer ${c}`);const p=await Ro(n,{headers:l});if(p.status===202)throw new gt("not-ready","Message body is still syncing",202,ur(p.headers.get("Retry-After")));if(!p.ok){const A=p.headers.get(pr),G=mr(p.status,A);throw new gt(G,`Failed to load message body (${p.status} ${p.statusText})`,p.status)}const h=p.headers.get("content-type");if(hr(o,h))throw new gt("content-type-mismatch",`Refusing to render message body — expected ${o}, got Content-Type ${h}`);const F=await p.text();if(dr(F,h))throw new gt("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return F},gr=async(n,o)=>(o.isRetryAfterNotReady&&await n.refetchDescribeMessage(),n.fetchContent(o.contentUrl,o.kind)),Lr=({messageId:n,bodyParts:o,enabled:a=!0})=>{const l=o?cr(o):null,c=Eo(),{getToken:p}=yo(),h=V.useRef(null),F=Ao(),A=V.useRef(!1),G=V.useRef(null),W=n&&l?`${n}:${l.contentUrl}`:null;G.current!==W&&(G.current=W,A.current=!1);const R=bo({queryKey:n?[...Le.body(n),l?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!l)throw new Error("No renderable body part");if(!n)throw new Error("No messageId");const J=A.current;return A.current=!1,gr({fetchContent:(L,X)=>Tr(L,X,p),refetchDescribeMessage:()=>F.refetchQueries({queryKey:So({path:{messageId:n}})})},{contentUrl:l.contentUrl,kind:l.kind,isRetryAfterNotReady:J})},enabled:a&&!!n&&!!l,staleTime:300*1e3,gcTime:1800*1e3,retry:(J,L)=>L instanceof gt&&L.reason==="not-ready"?J<fr:J<1,retryDelay:(J,L)=>L instanceof gt&&L.reason==="not-ready"?(A.current=!0,(L.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),Et=R.isLoading&&!!l,yt=o!==void 0&&l===null;V.useEffect(()=>{Et&&(h.current=performance.now())},[Et]),V.useEffect(()=>{R.isSuccess&&h.current!==null&&(c.recordTiming("message.body.load",Math.round(performance.now()-h.current)),h.current=null)},[R.isSuccess,c]);const It=R.data&&l?{kind:l.kind,body:R.data}:void 0;return{picked:l,data:It,isLoading:Et,hasNoRenderablePart:yt,isError:R.isError,error:R.error,refetch:R.refetch}};export{gt as B,br as a,Lr as b,mr as c,Sr as d,wr as e,Dr as f,Or as g,Cr as h,ar as i,lr as o,Ar as p,Rr as u};
@@ -1 +1 @@
1
- import{cx as Q,cy as y,cz as S,cA as w,cB as C,e as k,cC as x,cD as q,r as p,cE as M,cF as H,cG as B,cH as L,cI as O,cJ as P,cK as A}from"./index-D94MOpo0.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function z(r,e,s){const t=r.slice(0);return t[e]=s,t}var I=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=z(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 D({queries:r,...e},s){const t=k(),i=x(),n=q(),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)}),B(n);const[a]=p.useState(()=>new I(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)):L,[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 P(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{D as u};
1
+ import{cx as Q,cy as y,cz as S,cA as w,cB as C,e as k,cC as x,cD as q,r as p,cE as M,cF as H,cG as B,cH as L,cI as O,cJ as P,cK as A}from"./index-CKflMWYU.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function z(r,e,s){const t=r.slice(0);return t[e]=s,t}var I=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=z(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 D({queries:r,...e},s){const t=k(),i=x(),n=q(),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)}),B(n);const[a]=p.useState(()=>new I(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)):L,[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 P(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{D as u};
@@ -1 +1 @@
1
- import{j as E,t as K,p as Q,B as U,e as T,H as $,r as o,aE as R,N as B,P as z,l as G,$ as I,a0 as X,a3 as V}from"./index-D94MOpo0.js";import{C as J}from"./circle-check-big-BP7Pn5eb.js";import{R as Y}from"./refresh-cw-BDamTi58.js";import{u as P}from"./useQueries-CIIHHroC.js";function ye({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(J,{className:"size-4 text-positive"}):E.jsx(Y,{className:Q("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const Z=180*1e3,Se=30*1e3;let L=0;const M=new Set,ee=(e=Date.now())=>{L=e+Z;for(const s of M)s()},we=(e=Date.now())=>e<L,xe=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,te=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&te.has(a)||t.set(r.mailboxId,r.highWaterMarkUid)}return t},q=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>q(e,s).length>0,F=o.createContext(null),ne=()=>{const e=o.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=T(),{resultFolderIndex:r}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),v=c.current.get(d);if(c.current.set(d,g),v){const A=q(v,g);A.length>0&&B(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;se(W,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(F.Provider,{value:m,children:s})}const re=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&re.has(e)}const D=3e3,oe=D*2,N={syncing:!1,resolved:!1,synced:0,total:0};function Ee(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),oe);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:D,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(j(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?N:{syncing:y,resolved:!0,synced:w,total:S}}const ae=2e3,ie=45e3,ce=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ue=e=>{V(e,{softError:!0})},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,le=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ae})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:k(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ce(c)}},fe=async(e,s,t,r,a)=>{const u=await O(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return ue(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await le({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},be=(e,s={})=>{const t=T(),r=G(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ee();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ie,d=await Promise.all(x.map(g=>fe(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{Se as H,pe as M,ye as R,be as a,j as b,Ee as c,we as i,xe as s,ne as u};
1
+ import{j as E,t as K,p as Q,B as U,e as T,H as $,r as o,aE as R,N as B,P as z,l as G,$ as I,a0 as X,a3 as V}from"./index-CKflMWYU.js";import{C as J}from"./circle-check-big-Bm7lzv-i.js";import{R as Y}from"./refresh-cw-BmzOf0Tw.js";import{u as P}from"./useQueries-DVcMuKhn.js";function ye({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(J,{className:"size-4 text-positive"}):E.jsx(Y,{className:Q("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const Z=180*1e3,Se=30*1e3;let L=0;const M=new Set,ee=(e=Date.now())=>{L=e+Z;for(const s of M)s()},we=(e=Date.now())=>e<L,xe=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,te=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&te.has(a)||t.set(r.mailboxId,r.highWaterMarkUid)}return t},q=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},se=(e,s)=>q(e,s).length>0,F=o.createContext(null),ne=()=>{const e=o.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function pe({accountIds:e,children:s}){const t=T(),{resultFolderIndex:r}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),v=c.current.get(d);if(c.current.set(d,g),v){const A=q(v,g);A.length>0&&B(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;se(W,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(F.Provider,{value:m,children:s})}const re=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&re.has(e)}const D=3e3,oe=D*2,N={syncing:!1,resolved:!1,synced:0,total:0};function Ee(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),oe);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:D,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(j(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?N:{syncing:y,resolved:!0,synced:w,total:S}}const ae=2e3,ie=45e3,ce=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ue=e=>{V(e,{softError:!0})},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,le=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ae})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:k(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ce(c)}},fe=async(e,s,t,r,a)=>{const u=await O(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return ue(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await le({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},be=(e,s={})=>{const t=T(),r=G(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ee();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ie,d=await Promise.all(x.map(g=>fe(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{Se as H,pe as M,ye as R,be as a,j as b,Ee as c,we as i,xe as s,ne as u};
@@ -1 +1 @@
1
- import{b as s,R as o,r as n,bU as r}from"./index-D94MOpo0.js";import{u as d}from"./useQueries-CIIHHroC.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
1
+ import{b as s,R as o,r as n,bU as r}from"./index-CKflMWYU.js";import{u as d}from"./useQueries-DVcMuKhn.js";const h=s("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]),p=t=>({items:t.map(e=>e.data?.items??[]),isPending:t.some(e=>e.isPending),error:t.find(e=>e.error)?.error??null});function u(t){const e=d({queries:t.map(i=>({...o({path:{accountId:i.accountId}}),staleTime:1/0})),combine:p});return{index:n.useMemo(()=>r(t.map((i,a)=>({folderAppointments:i.folderAppointments,mailboxes:e.items[a]??[]}))),[t,e]),isPending:e.isPending,error:e.error}}export{h as B,u};
@@ -0,0 +1 @@
1
+ import{e as m,aj as y,a as b,c as L,r as c,f as w,ak as S,k,h as E}from"./index-CKflMWYU.js";var u={en:1199414,"en-GB":1199758,nl:3180464},g=["en","en-GB","nl"];const C=()=>typeof g>"u"?[]:g,M=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},_=e=>typeof u>"u"?0:u[e]??0,O=(e,n=C())=>{const t=e.toLowerCase(),a=n.find(i=>i.toLowerCase()===t);if(a)return a;const o=t.split("-")[0];return n.find(i=>i.toLowerCase().split("-")[0]===o)??null},T=[{tag:"ar",detectionCode:"arb"},{tag:"az",detectionCode:"azj"},{tag:"be",detectionCode:"bel"},{tag:"bg",detectionCode:"bul"},{tag:"bs",detectionCode:"bos"},{tag:"cs",detectionCode:"ces"},{tag:"de",detectionCode:"deu"},{tag:"en",detectionCode:"eng"},{tag:"es",detectionCode:"spa"},{tag:"fa",detectionCode:"pes"},{tag:"fr",detectionCode:"fra"},{tag:"ha",detectionCode:"hau"},{tag:"hi",detectionCode:"hin"},{tag:"hr",detectionCode:"hrv"},{tag:"hu",detectionCode:"hun"},{tag:"id",detectionCode:"ind"},{tag:"ig",detectionCode:"ibo"},{tag:"it",detectionCode:"ita"},{tag:"jv",detectionCode:"jav"},{tag:"kk",detectionCode:"kaz"},{tag:"mr",detectionCode:"mar"},{tag:"ms",detectionCode:"zlm"},{tag:"ne",detectionCode:"npi"},{tag:"nl",detectionCode:"nld"},{tag:"pl",detectionCode:"pol"},{tag:"ps",detectionCode:"pbu"},{tag:"pt",detectionCode:"por"},{tag:"ro",detectionCode:"ron"},{tag:"ru",detectionCode:"rus"},{tag:"so",detectionCode:"som"},{tag:"sr",detectionCode:"srp"},{tag:"su",detectionCode:"sun"},{tag:"sv",detectionCode:"swe"},{tag:"sw",detectionCode:"swh"},{tag:"tl",detectionCode:"tgl"},{tag:"tr",detectionCode:"tur"},{tag:"uk",detectionCode:"ukr"},{tag:"ur",detectionCode:"urd"},{tag:"vi",detectionCode:"vie"},{tag:"yo",detectionCode:"yor"},{tag:"zu",detectionCode:"zul"}],d=e=>(e.split("-")[0]??"").toLowerCase(),v=new Map(T.map(e=>[e.tag,e])),x=e=>v.get(d(e))?.detectionCode??null,P=/^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i,G=e=>d(e).toUpperCase(),H=e=>{if(!P.test(e))return e;const t=new Intl.DisplayNames([e],{type:"language",fallback:"none"}).of(e);return t?t.charAt(0).toLocaleUpperCase(e)+t.slice(1):e},z=(e,n=C())=>{const t=[...e,...n].filter(o=>x(o)!==null),a=[...new Set(t.map(d))];return a.includes("en")||a.push("en"),a},N=e=>/iPhone|iPad|iPod/.test(e)?"On iPhone and iPad the keyboard decides this. Add the language under Settings, then General, then Keyboard.":/Edg\//.test(e)?"Edge checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Firefox\//.test(e)?"Firefox uses this setting. Right-click the message to add a dictionary for it.":/Chrome\/|Chromium\//.test(e)?"Chrome checks every language you add under Settings, then Languages. Adding one there checks it alongside the others.":/Safari\//.test(e)?"macOS decides this under Keyboard, then Text Input, then Spelling. Automatic by Language covers every language enabled there.":"Your browser decides which dictionaries it checks. Add this language in its own language settings to have it spellchecked.",h=e=>new DOMParser().parseFromString(e,"text/html"),p=e=>{const n=[...e.children];if(n.length!==1)return null;const t=n[0];return t?[...e.childNodes].some(o=>o!==t&&(o.textContent??"").trim()!=="")?null:t:null},R=(e,n)=>{if(e==="")return"";const t=h(e),a=p(t.body);if(a?.tagName==="DIV"&&a.hasAttribute("lang"))return a.setAttribute("lang",n),t.body.innerHTML;const o=t.createElement("div");for(o.setAttribute("lang",n);t.body.firstChild;)o.append(t.body.firstChild);return t.body.append(o),t.body.innerHTML},U=e=>{if(e==="")return{html:e,language:null};const n=h(e),t=p(n.body);return t?.tagName!=="DIV"||!t.hasAttribute("lang")?{html:e,language:null}:{html:t.innerHTML,language:t.getAttribute("lang")}},l={html:"",plainText:""},B=e=>{const n=m(),{pushError:t}=y(),{data:a}=b({...L(),staleTime:1/0}),o=c.useMemo(()=>{if(!e||!a)return l;const s=a.accounts.find(r=>r.accountId===e);return s?{html:s.signatureHtml??"",plainText:s.signaturePlainText??""}:l},[e,a]),i=w({...E(),onSuccess:()=>{n.invalidateQueries({queryKey:k()})},onError:s=>{t(S("Couldn't save signature","The signature wasn't saved.",s))}}),f=c.useCallback((s,r)=>{e&&i.mutate({path:{accountId:e},body:{signatureHtml:s,signaturePlainText:r}})},[e,i]);return{signature:o,setSignature:f,isSaving:i.isPending}};export{T as C,U as a,G as b,N as c,z as d,x as e,O as f,_ as g,H as l,d as p,M as s,B as u,R as w};
@@ -1,5 +1,5 @@
1
- import{j as s,ay as w,B as u,aH as C,be as j,bc as N,d as A,aa as _,a7 as $,bu as E,bR as f,bS as k,bT as M,a as P,c as W,r as c,a1 as z,at as x,au as p,u as O,aA as B,aC as L}from"./index-D94MOpo0.js";import{B as h,u as q}from"./useResultFolderIndex-BjaX8bsI.js";import{B as y}from"./badge-CbfjHXMg.js";import{C as S}from"./circle-check-BUMxM7Pv.js";import{C as D}from"./copy-cdXYXbA6.js";import{E as U}from"./external-link-Ct6hJ8mI.js";import{f as F}from"./ErrorState-Dzdw33-3.js";import{w as G}from"./help-copy-YhaxQEIY.js";import{S as H}from"./settings-screen-CF0fiL2l.js";import"./useQueries-CIIHHroC.js";import"./kbd-cd0_OQ1u.js";import"./avatar-BV5vFJ_r.js";import"./chevron-left-D5-k3mB7.js";import"./menu-C3buEsRL.js";import"./circle-help-B083hm65.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(w,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(u,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(u,{variant:"secondary",size:"sm",icon:s.jsx(D,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(U,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function T(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{j as s,aA as T,B as d,aH as C,be as j,bc as N,d as $,ac as A,a6 as k,bu as E,bR as f,bS as _,bT as M,a as P,c as W,r as l,a1 as z,av as p,aw as x,u as O,ab as B}from"./index-CKflMWYU.js";import{B as h,u as L}from"./useResultFolderIndex-DkgVg9nE.js";import{B as y}from"./badge-C9PbkapD.js";import{C as S}from"./circle-check-DTYzt_6O.js";import{C as q}from"./copy-BXsMQRiH.js";import{E as D}from"./external-link-BJSinsZe.js";import{f as U}from"./ErrorState-94ifepAa.js";import{a as F}from"./sections-HylxNewe.js";import{w as G}from"./help-copy-CiMWKARn.js";import{S as H}from"./settings-screen-83hRChID.js";import"./useQueries-DVcMuKhn.js";import"./kbd-BncXAFDO.js";import"./avatar-LbufyW4K.js";import"./chevron-left-CpG9UDY6.js";import"./menu-DoDMKB2j.js";import"./circle-help-BbeOW2US.js";function Q({report:e,onClose:t,issueUrl:n,onCopy:a}){return e===null?null:s.jsx(T,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(q,{className:"size-3.5"}),onClick:()=>a(e),children:"Copy report"}),s.jsx(C,{external:!0,size:"sm",href:n,icon:s.jsx(D,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,v=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function Z(e){const t=R(e);return v.test(t)?t:JSON.stringify(t)}const g="_not read_";function J(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${Z(t.contentType)}`)}const K="_No message content, addresses, subject, attachment names or parser output are included._";function w(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),v)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:J(e.structure).join(`
3
- `),disclaimer:K}}function X(e){const{head:t,structure:n,disclaimer:a}=T(e);return[t,"","```",n,"```","",a].join(`
4
- `)}function ee(e){return`Message quarantined: ${e.failureCode} at ${e.failureStage}`}function se(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function te({entry:e,onCutBug:t}){return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:Y(e.failureStage)}),s.jsx("p",{className:"truncate text-xs text-fg-muted",title:e.failureMessage,children:e.failureMessage}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[e.mailboxRole&&s.jsx(y,{tone:"warning",children:j(e.mailboxRole)}),s.jsx("span",{className:"truncate",title:e.mailboxPath,children:N(e.mailboxPath,e.mailboxDelimiter)}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:se(e.quarantinedAt)}),e.attempts>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]})]}),s.jsx(u,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ne({entries:e,onCutBug:t}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),e.length>1&&s.jsx(A,{tone:"warning",children:s.jsxs("p",{className:"flex items-start gap-2",children:[s.jsx(_,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:`${e.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(n=>s.jsx(te,{entry:n,onCutBug:t},n.quarantineId))})]})}const ae={Retrying:"The message could not be synced. Remit tries again every sync.",GaveUp:"The message body could not be downloaded. Remit has stopped trying."};function re(e){return ae[e.state]}const ie="_No message content, addresses, subject, folder name or error text are included._";function oe(e){return[`### Message failed to sync at \`${e.stage}\``,"",`- **State**: \`${e.state}\``,`- **Attempts**: ${e.attempts}`,"",ie].join(`
5
- `)}function le(e){return`Message failed to sync: ${e.state} at ${e.stage}`}function ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function de({entry:e,onReport:t}){const n=e.state==="GaveUp";return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:re(e)}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.jsx(y,{tone:n?"danger":"warning",children:n?"Gave up":"Retrying"}),s.jsx("span",{className:"truncate",children:e.folderLabel}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`since ${ce(e.createdAt)}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]}),s.jsx(u,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ue({entries:e,total:t,onReport:n}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages that failed to sync"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"A message shows here after three failed rounds and leaves on its own once it syncs. The rest of the folder keeps syncing."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message is syncing. Nothing has failed."})]}),t>e.length&&s.jsx("p",{className:"text-xs text-fg-muted",children:`Showing the ${e.length} newest of ${t} messages that failed to sync.`}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(a=>s.jsx(de,{entry:a,onReport:n},a.syncWarningId))})]})}function me(){const{Account:e}=$();return s.jsx(e,{children:({signOut:t})=>s.jsx("button",{type:"button",onClick:()=>t(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}function ge(e,t){return{quarantineId:e.quarantineId,accountId:e.accountId,mailboxId:e.mailboxId,uidValidity:e.uidValidity,uid:e.uid,mailboxRole:e.mailboxRole?E[e.mailboxRole]:void 0,mailboxPath:e.mailboxPath,mailboxDelimiter:t,failureStage:e.failureStage,failureCode:e.failureCode,failureMessage:e.failureMessage,failurePartPath:e.failurePartPath,quarantinedAt:e.quarantinedAt,attempts:e.attempts,sizeBytes:e.sizeBytes,contentType:e.contentType,transferEncoding:e.transferEncoding,charset:e.charset,structure:e.structure,messageIdHash:e.messageIdHash,workerVersion:e.workerVersion}}const xe=3,pe=(e,t)=>e===k.Body&&t>=xe?f.GaveUp:f.Retrying,he="A folder no longer listed";function fe(e){return e?.role?j(e.role):e?.providerPath?N(e.providerPath,e.hierarchyDelimiter):he}function be(e,t){return{syncWarningId:e.syncWarningId,uid:e.uid,stage:e.stage,state:pe(e.stage,e.attempts),attempts:e.attempts,createdAt:e.createdAt,folderLabel:fe(t)}}const je=[],Ne=[];function ye(e){window.open(e,"_blank","noopener,noreferrer")}function Se(e){return{report:X(e),issueUrl:x(p({quarantine:T(e),title:ee(e)}))}}function Re(e){const t=oe(e);return{report:t,issueUrl:x(p({syncWarning:t,title:le(e)}))}}function ve({signIn:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"Your session has ended."}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Sign in again to see the messages that failed to sync or were set aside."}),e]})})}function Te({error:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"The warnings could not be read."}),s.jsx("p",{className:"break-words text-sm text-fg-muted",children:F(e)}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still be failing to sync or have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),s.jsx(u,{variant:"secondary",size:"sm",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>ye(x(p())),children:"Report this"})]})})}function Ie({read:e,signIn:t}){const[n,a]=c.useState(null),[o,r]=c.useState(!1);if(e.kind==="Pending")return s.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for warnings…"});if(e.kind==="SignedOut")return s.jsx(ve,{signIn:t});if(e.kind==="Failed")return s.jsx(Te,{error:e.error});const l=i=>{navigator.clipboard.writeText(i).then(()=>{r(!1),a(null)},()=>{r(!0),a(null)})};return s.jsxs("div",{className:"space-y-6",children:[o&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),s.jsx(ue,{entries:e.warnings,total:e.warningsTotal,onReport:i=>a(Re(i))}),s.jsx(ne,{entries:e.quarantine,onCutBug:i=>a(Se(i))}),s.jsx(Q,{report:n?.report??null,issueUrl:n?.issueUrl??"",onClose:()=>a(null),onCopy:l})]})}function we(e,t){return e.get(t)?.hierarchyDelimiter??""}function Ce(){const e=M(),t=P(W()),n=c.useMemo(()=>t.data?.accounts??[],[t.data]),a=q(n),o=e.data?.entries??je,r=e.data?.warnings??Ne,l=c.useMemo(()=>o.map(d=>ge(d,we(a.index,d.mailboxId))),[o,a.index]),i=c.useMemo(()=>r.map(d=>be(d,a.index.get(d.mailboxId))),[r,a.index]),I=Ae(e.error??t.error??a.error,e.isPending||t.isPending||a.isPending,{kind:"Ready",quarantine:l,warnings:i,warningsTotal:e.data?.warningsTotal??0});return s.jsx(Ie,{read:I,signIn:s.jsx(me,{})})}function Ae(e,t,n){return z(e)?{kind:"SignedOut"}:e?{kind:"Failed",error:e}:t?{kind:"Pending"}:n}function Ge(){const e=O(),t=B(),[n,a]=c.useState(!0),o=r=>{const l=L[r];l&&e({to:l})};return s.jsx(H,{items:t,activeId:"warnings",title:"Warnings",description:"Messages that failed to sync, and messages set aside.",help:G,helpOpen:n,onToggleHelp:()=>a(r=>!r),onSelect:o,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(Ce,{})})}export{Ge as component};
3
+ `),disclaimer:K}}function X(e){const{head:t,structure:n,disclaimer:a}=w(e);return[t,"","```",n,"```","",a].join(`
4
+ `)}function ee(e){return`Message quarantined: ${e.failureCode} at ${e.failureStage}`}function se(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function te({entry:e,onCutBug:t}){return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:Y(e.failureStage)}),s.jsx("p",{className:"truncate text-xs text-fg-muted",title:e.failureMessage,children:e.failureMessage}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[e.mailboxRole&&s.jsx(y,{tone:"warning",children:j(e.mailboxRole)}),s.jsx("span",{className:"truncate",title:e.mailboxPath,children:N(e.mailboxPath,e.mailboxDelimiter)}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:se(e.quarantinedAt)}),e.attempts>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ne({entries:e,onCutBug:t}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),e.length>1&&s.jsx($,{tone:"warning",children:s.jsxs("p",{className:"flex items-start gap-2",children:[s.jsx(A,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:`${e.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(n=>s.jsx(te,{entry:n,onCutBug:t},n.quarantineId))})]})}const ae={Retrying:"The message could not be synced. Remit tries again every sync.",GaveUp:"The message body could not be downloaded. Remit has stopped trying."};function re(e){return ae[e.state]}const ie="_No message content, addresses, subject, folder name or error text are included._";function oe(e){return[`### Message failed to sync at \`${e.stage}\``,"",`- **State**: \`${e.state}\``,`- **Attempts**: ${e.attempts}`,"",ie].join(`
5
+ `)}function le(e){return`Message failed to sync: ${e.state} at ${e.stage}`}function ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function de({entry:e,onReport:t}){const n=e.state==="GaveUp";return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:re(e)}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.jsx(y,{tone:n?"danger":"warning",children:n?"Gave up":"Retrying"}),s.jsx("span",{className:"truncate",children:e.folderLabel}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`since ${ce(e.createdAt)}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ue({entries:e,total:t,onReport:n}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages that failed to sync"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"A message shows here after three failed rounds and leaves on its own once it syncs. The rest of the folder keeps syncing."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message is syncing. Nothing has failed."})]}),t>e.length&&s.jsx("p",{className:"text-xs text-fg-muted",children:`Showing the ${e.length} newest of ${t} messages that failed to sync.`}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(a=>s.jsx(de,{entry:a,onReport:n},a.syncWarningId))})]})}function me(){const{Account:e}=k();return s.jsx(e,{children:({signOut:t})=>s.jsx("button",{type:"button",onClick:()=>t(),className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Sign in again"})})}function ge(e,t){return{quarantineId:e.quarantineId,accountId:e.accountId,mailboxId:e.mailboxId,uidValidity:e.uidValidity,uid:e.uid,mailboxRole:e.mailboxRole?E[e.mailboxRole]:void 0,mailboxPath:e.mailboxPath,mailboxDelimiter:t,failureStage:e.failureStage,failureCode:e.failureCode,failureMessage:e.failureMessage,failurePartPath:e.failurePartPath,quarantinedAt:e.quarantinedAt,attempts:e.attempts,sizeBytes:e.sizeBytes,contentType:e.contentType,transferEncoding:e.transferEncoding,charset:e.charset,structure:e.structure,messageIdHash:e.messageIdHash,workerVersion:e.workerVersion}}const pe=3,xe=(e,t)=>e===_.Body&&t>=pe?f.GaveUp:f.Retrying,he="A folder no longer listed";function fe(e){return e?.role?j(e.role):e?.providerPath?N(e.providerPath,e.hierarchyDelimiter):he}function be(e,t){return{syncWarningId:e.syncWarningId,uid:e.uid,stage:e.stage,state:xe(e.stage,e.attempts),attempts:e.attempts,createdAt:e.createdAt,folderLabel:fe(t)}}const je=[],Ne=[];function ye(e){window.open(e,"_blank","noopener,noreferrer")}function Se(e){return{report:X(e),issueUrl:p(x({quarantine:w(e),title:ee(e)}))}}function Re(e){const t=oe(e);return{report:t,issueUrl:p(x({syncWarning:t,title:le(e)}))}}function ve({signIn:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"Your session has ended."}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Sign in again to see the messages that failed to sync or were set aside."}),e]})})}function we({error:e}){return s.jsx("section",{role:"alert",className:"space-y-3",children:s.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[s.jsx("p",{className:"text-sm font-medium text-danger",children:"The warnings could not be read."}),s.jsx("p",{className:"break-words text-sm text-fg-muted",children:U(e)}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still be failing to sync or have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>ye(p(x())),children:"Report this"})]})})}function Ie({read:e,signIn:t}){const[n,a]=l.useState(null),[o,r]=l.useState(!1);if(e.kind==="Pending")return s.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for warnings…"});if(e.kind==="SignedOut")return s.jsx(ve,{signIn:t});if(e.kind==="Failed")return s.jsx(we,{error:e.error});const u=i=>{navigator.clipboard.writeText(i).then(()=>{r(!1),a(null)},()=>{r(!0),a(null)})};return s.jsxs("div",{className:"space-y-6",children:[o&&s.jsx("p",{role:"alert",className:"text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),s.jsx(ue,{entries:e.warnings,total:e.warningsTotal,onReport:i=>a(Re(i))}),s.jsx(ne,{entries:e.quarantine,onCutBug:i=>a(Se(i))}),s.jsx(Q,{report:n?.report??null,issueUrl:n?.issueUrl??"",onClose:()=>a(null),onCopy:u})]})}function Te(e,t){return e.get(t)?.hierarchyDelimiter??""}function Ce(){const e=M(),t=P(W()),n=l.useMemo(()=>t.data?.accounts??[],[t.data]),a=L(n),o=e.data?.entries??je,r=e.data?.warnings??Ne,u=l.useMemo(()=>o.map(c=>ge(c,Te(a.index,c.mailboxId))),[o,a.index]),i=l.useMemo(()=>r.map(c=>be(c,a.index.get(c.mailboxId))),[r,a.index]),I=$e(e.error??t.error??a.error,e.isPending||t.isPending||a.isPending,{kind:"Ready",quarantine:u,warnings:i,warningsTotal:e.data?.warningsTotal??0});return s.jsx(Ie,{read:I,signIn:s.jsx(me,{})})}function $e(e,t,n){return z(e)?{kind:"SignedOut"}:e?{kind:"Failed",error:e}:t?{kind:"Pending"}:n}function He(){const e=O(),t=B(),n=F(),[a,o]=l.useState(!0);return s.jsx(H,{items:t,activeId:"warnings",title:"Warnings",description:"Messages that failed to sync, and messages set aside.",help:G,helpOpen:a,onToggleHelp:()=>o(r=>!r),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:s.jsx(Ce,{})})}export{He as component};
package/index.html CHANGED
@@ -35,7 +35,7 @@
35
35
  } catch (_) {}
36
36
  })();
37
37
  </script>
38
- <script type="module" crossorigin src="/assets/index-D94MOpo0.js"></script>
38
+ <script type="module" crossorigin src="/assets/index-CKflMWYU.js"></script>
39
39
  <link rel="stylesheet" crossorigin href="/assets/index-CMNnsfzR.css">
40
40
  </head>
41
41
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.682",
3
+ "version": "0.0.683",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -1 +0,0 @@
1
- import{a7 as t,j as r}from"./index-D94MOpo0.js";const c=({children:s})=>{const{Account:o}=t();return r.jsx(o,{children:s})};export{c as A};
@@ -1 +0,0 @@
1
- import{j as r,L as Mt,eG as ne,d_ as re,r as a,a as Ke,H as ie,cV as jt,R as kt,dz as Et,eH as Ot,t as Ue,eI as At}from"./index-D94MOpo0.js";import{a5 as Ft,y as Nt,A as Bt,an as Lt,ao as qt,ap as _t,aq as Dt,ar as _e,as as Pt,at as Qt,au as zt,av as Wt,aw as Ht,ag as Gt,M as Kt,aj as Ut,ax as Vt,ah as $t,ay as Yt,az as Jt,f as Zt,p as Xt,ak as es,m as ts,S as ss,G as os,K as De,J as ns,H as rs,e as as,V as is,W as xe,X as cs,Z as Ve,_ as $e,$ as ls,a0 as ds,a1 as us}from"./MessageToolbar-2VWnNBpw.js";import{h as fs,n as ms,r as hs}from"./reply-DPVLqPcI.js";import{a as gs}from"./useMessageBodyContent-yhApp3IG.js";import{o as ps,e as xs,f as Is}from"./search-token-index-DXiN1835.js";import{u as Ye}from"./sections-Dm0mEk9W.js";import{u as ae}from"./useQueries-CIIHHroC.js";import{t as Je,s as ys,r as vs,L as bs}from"./LabelApplyTrigger-CSWiFHCu.js";import{u as Ss,a as Ts,R as Cs,b as ws,c as Rs}from"./useRefreshControl-MOracVIf.js";import{a as Ms}from"./useLabels-CrZtVj3Y.js";import{u as js}from"./useLayoutTier-CIlJuePx.js";import{u as ks}from"./useMediaQuery-CGZfUxdm.js";import{r as Ze,n as Es,o as Xe,w as et,u as Os,p as As,R as Fs}from"./MessageBody-C2-SQjAb.js";import{d as Ns,w as Bs}from"./wizard-selection-zWa1qc6-.js";import{R as Ls}from"./refresh-cw-BDamTi58.js";import{S as qs}from"./sparkles-rKmhB5Fk.js";function _s({sync:e}){return e?r.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:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ds(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(qs,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ds({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 tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",Ps={unclassified:"uncategorized"},H=e=>Es(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Xe(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Xe(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=Ps[s];if(n)return n;if(!(!et(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ze(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ze(st,t)])},Gs=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,Pe=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Ks=3e4,Us={kind:"unknown"},We=e=>(t,s)=>Ft(s?.queryKey,e)?t:void 0,Vs=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),$s=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(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 Ys({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=Vs(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=$s(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Je(v?.data?.count):Us,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ke({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Ks});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Je(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Nt({category:e,attributes:t}),{params:d,residual:m}=Bt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.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,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=Ye();return r.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:[r.jsx(Ue,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=vs(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=Jt(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=Zt(u.accountId),{labels:p}=Ms(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Bs(t,i),[t,i]),x=Xt(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),F=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(ss,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(bs,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:F});return r.jsx(es,{...e,selectionBar:T,paneOverlay:r.jsx(ts,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=Os(),v=ks(),p=js(),b=jt(),L=ps(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,F]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),_=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),G=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:D}=As(m.trim().toLowerCase(),u),y=w.length>0,P=a.useMemo(()=>Pe({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),A=a.useMemo(()=>Pe({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){_(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,_]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{et(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),F("all"),G(),E&&h(Gs(l))},[E,l,h,G]),K=ae({queries:x.map(o=>({...kt({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),U=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(K[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,K]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=K[f];return g?.isError?!Et(g.error):!1}),[x,K]),{criteria:fe,residual:V}=a.useMemo(()=>ao(C,A,D,S==="all"?void 0:S),[C,A,D,S]),dt=a.useMemo(()=>C==="all"?[...Lt]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:V,attributes:A}),{sections:$,isLoading:ut,isError:ft,refetch:Se}=Ys({categories:y?mo:dt,criteria:fe,limit:C==="all"?Yt:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(A),[A]),Y=a.useCallback(o=>Ns(o).map(qt).filter(f=>_t(f,Me)&&Dt(f,V)),[Me,V]),J=a.useMemo(()=>$.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:Y(o.rows)})),[$,Y]),Z=a.useMemo(()=>Y(Te),[Te,Y]),gt=a.useCallback(o=>{$.find(f=>f.category===o)?.retry()},[$]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>Ot(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&ys({hasSearchQuery:y,freeText:w,residualTokenCount:V.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>_e(O,c)),{spam:g}=Pt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:Qt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,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:U.get(o.accountId),active:S===o.accountId}))],[x,U,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(U.values()).reduce((o,f)=>o+f,0),[U]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ss(),{state:Ae,errorMessage:Fe,refresh:Ne}=Ts(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Cs,{state:Ae,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Fe,hasUpdate:Oe(pe)}),[Ae,Ne,Fe,Oe,pe]),vt=a.useMemo(()=>k.map(o=>_e(o,c)),[k,c]),bt=a.useMemo(()=>{const o=zt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:P,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:F,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,P,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&D.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>ws(o.syncPhase)),[x]),ee=Rs(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=Wt({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Ht,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Gt,{sections:ke,briefCategory:Q,Row:Kt,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:F,activeFilters:P,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx(Ue,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Ls,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(_s,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx(Ut,{hasSheet:qe&&!Ct,children:r.jsx(Vt,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx($t,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=xs(),n=Is(),i=Ye(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ke({...At(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=os(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),F=De({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=ns(),{deleteMessages:R}=rs({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=as({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,_=De({thread:M,isOpen:M?.messageId===b}),G=gs(),E=fs(),w=ms(),D=a.useMemo(()=>hs(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:P,previousMessageId:Q}=is({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||_.deleteThread()},toggleStar:_.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),A=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:A(P),previousThread:A(Q),actions:F,onReply:D,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=ds(t?.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(us,{hasThread:l,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:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx(Ve,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(Fs,{})})]}),r.jsx($e,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(ls,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=cs(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Ve,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx($e,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const _o=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{_o as B};
@@ -1 +0,0 @@
1
- import{r as t,eR as Ze,b_ as Fe,j as v,eg as we}from"./index-D94MOpo0.js";import{c as xe,m as Ne,d as Oe,t as Be,p as je}from"./draft-BIQ0-Lk_.js";import{b as le,e as fe,f as oe,p as Ae,U as me,c as ge,s as ze,i as Ge}from"./useCalendarSuggestions-BfA31NJY.js";import{c as Qe,r as Le,s as Pe,t as Ue,R as We}from"./useCalendarData-DQ7oi-nJ.js";import{u as pe,b as ve}from"./useCalendarScheduling-DAb_8yBj.js";import{f as qe}from"./calendar-format-BwCpz-JZ.js";import"./reply-DPVLqPcI.js";import{a as ye,j as He,b as ie,i as Ve}from"./calendar-CNIMaOb7.js";import{e as _e}from"./CalendarQuickCreate-BG0qeW8s.js";import{u as x}from"./CalendarSession-CTmh2tcD.js";import{C as Se}from"./calendar-event-sidebar-TTXLpS2C.js";import{C as $e}from"./confirm-dialog-BXhRj5Sm.js";import{s as Je}from"./calendar-guests-BXmTl5jL.js";import{a as Ke}from"./calendar-event-popup-CYCnsOds.js";const he="This calendar changed while you were writing. Close the form and try again.",be=Intl.supportedValuesOf("timeZone"),Me=(e,n)=>e.date===n.date&&e.endDate===n.endDate&&e.startTime===n.startTime&&e.endTime===n.endTime&&e.allDay===n.allDay,_=e=>({date:e.date,endDate:e.endDate,startTime:e.allDay?"":e.startTime,endTime:e.allDay?"":e.endTime,allDay:e.allDay}),Ce=e=>e?"Opaque":"Transparent";function Ye(e,n){const{carriedFocus:l}=x(),f=t.useRef(!1);t.useEffect(()=>{if(!n||f.current)return;f.current=!0;const o=l.current;l.current="",((o===""?null:document.querySelector(`[data-event-sidebar] [aria-label="${CSS.escape(o)}"]`))??e.current)?.focus()},[l,e,n])}function Ee(e){const{requestClose:n}=x(),{closeToView:l}=ie(),[f,o]=t.useState(!1),y=t.useRef(!1);Ve(e&&!f,()=>y.current?!1:(o(!0),!0));const b=()=>{if(e){o(!0);return}l()},R=t.useRef(b);return R.current=b,t.useEffect(()=>(n.current=()=>R.current(),()=>{n.current=null}),[n]),{close:b,confirm:v.jsx($e,{isOpen:f,title:"Discard draft?",description:"Your event has unsaved changes. Are you sure you want to discard them?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:()=>{y.current=!0,o(!1),l()},onCancel:()=>o(!1)}),leave:()=>{y.current=!0,l()}}}function pt(){const{session:e,dispatch:n,focusSaved:l}=x(),{date:f}=ye(),o=He(),{setNewEventBounds:y}=ie(),{calendars:b,defaultCalendarId:R,timeZoneByCalendarId:j}=le(),C=b.filter(s=>!s.readOnly),{createEvent:A,isWriting:$}=fe(),{senders:z,defaultSenderId:J}=pe(),[K,M]=t.useState(),[G,Y]=t.useState(""),X=ve(G),{trackSends:ee}=x(),Q=t.useRef(null),L=t.useRef(null),E=oe(),[g,T]=t.useState({notes:"",repeat:"",timeZone:E,busy:!0}),[P,N]=t.useState(""),[O,a]=t.useState(),[i]=t.useState(()=>e.mode==="sidebar"?e.draft:void 0),m=Ze(o?.start,o?.end,f,E);t.useEffect(()=>{e.mode!=="sidebar"&&n({type:"sidebar-range",range:m})},[e.mode,n,m]);const d=e.mode==="sidebar"?e.draft:void 0,r=d?.range;t.useEffect(()=>{if(!r)return;const s=Fe(r,E);s.start===o?.start&&s.end===o?.end||y(s)},[r,o,E,y]),Ye(Q,e.mode==="sidebar"),t.useEffect(()=>{O&&L.current?.focus()},[O]);const I=C.find(s=>s.id===R)?.id??C[0]?.id??"";t.useEffect(()=>{d?.calendarId!==""||I===""||n({type:"change",draft:{...d,calendarId:I}})},[d,I,n]);const k=d!==void 0&&(g.notes!==""||g.repeat!==""||!g.busy||d.title!==(i?.title??"")||d.location!==(i?.location??"")||d.guests.length!==(i?.guests.length??0)),{close:U,confirm:Z,leave:te}=Ee(k);if(!d)return null;const W=K??J??C.find(s=>s.id===d.calendarId)?.accountId??"",F={..._e(d),notes:g.notes,repeat:g.repeat},q=()=>{const s=g.timeZone,u=xe(F,{clock:s,anchor:s!==E?s:Ae(j[d.calendarId]??me)},W);if(!u.ok){N(u.problem);return}N(""),a(void 0),A({...u.input,transparency:Ce(g.busy)}).then(S=>{if(S.kind==="created"){n({type:"saved"}),ee(S.sends),l(S.calendarObjectId),te();return}const p=S.kind==="conflict"?he:`Couldn't save this event: ${S.message}`;a({text:p,reportHref:ge(p),onRetry:q})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"New event",draft:F,onChange:s=>{n({type:"change",draft:{range:_(s),title:s.title,location:s.location,calendarId:s.calendarId,guests:s.guests}}),T(u=>({...u,notes:s.notes,repeat:s.repeat}))},calendars:C,calendarEditable:!0,repeatEditable:!0,timeZone:g.timeZone,timeZones:be,onTimeZone:s=>T(u=>({...u,timeZone:s})),busy:g.busy,onBusy:s=>T(u=>({...u,busy:s})),guests:{suggestions:X,onQuery:Y,senders:z,sender:W,onSender:M,senderEditable:!0},onSave:q,onCancel:U,saving:$,problem:P,failure:O,failureRef:L,titleRef:Q}),Z]})}function vt({calendarObjectId:e,recurrenceId:n}){const{session:l,dispatch:f,focusSaved:o}=x(),{view:y,date:b,calendarIds:R}=ye(),{events:j,isLoading:C,freeIds:A}=Qe({view:y,date:b,calendarIds:R}),{calendars:$,timeZoneByCalendarId:z}=le(),{closeToView:J}=ie(),{updateEvent:K,isWriting:M}=fe(),{senders:G,defaultSenderId:Y}=pe(),[X,ee]=t.useState(),[Q,L]=t.useState(""),E=ve(Q),{trackSends:g}=x(),T=t.useRef(null),P=t.useRef(null),N=t.useId(),O=Ge(e,n??""),a=j.find(c=>c.id===O),{resource:i}=ze(e,a?.calendarId??""),[m,d]=t.useState(),[r,I]=t.useState(),[k,U]=t.useState(!0),[Z,te]=t.useState(oe()),[W,F]=t.useState(!1),[q,s]=t.useState(""),[u,S]=t.useState();t.useEffect(()=>{if(m||!a||!i)return;const c=Le(i.icalData),h=Pe(i.icalData,z[a.calendarId]??me),B=a.allDay?"":a.start.slice(11,16),re=a.allDay?c:Ne(c,we(a.start,h===""?"UTC":h).slice(0,10),a.start.slice(0,10)),D=Ue(i.icalData),w=Oe(a,{repeat:c===""?"":Be(re,B)??"Repeats",location:D.location,notes:D.description,guests:i.attendees.filter(V=>V.role==="Guest").map(V=>Je(V.email,V.displayName))}),ue=!A.has(a.id);d({draft:w,busy:ue,anchor:h}),I(w),U(ue),f({type:"sidebar-range",range:_(w)})},[m,a,i,A,z,f]);const p=l.mode==="sidebar"?l.draft.range:void 0;t.useEffect(()=>{!p||!r||Me(p,_(r))||I({...r,date:p.date,endDate:p.endDate,startTime:p.startTime,endTime:p.endTime,allDay:p.allDay})},[p,r]);const ce=r!==void 0;t.useEffect(()=>{ce&&T.current?.focus()},[ce]),t.useEffect(()=>{u&&P.current?.focus()},[u]);const Ie=m!==void 0&&r!==void 0&&(JSON.stringify(m.draft)!==JSON.stringify(r)||k!==m.busy),{close:De,confirm:Re,leave:Te}=Ee(Ie);if(!C&&a===void 0)return v.jsx("section",{className:"flex h-full flex-col bg-surface","aria-labelledby":N,children:v.jsx(Ke,{headingId:N,onClose:J})});if(!a||!m||!r)return null;const se=$.find(c=>c.id===a.calendarId),de=a.seriesId!==""&&n!==void 0,H=i?.organizer??"",ke=i!==void 0&&(i.participation==="Organizer"||i.participation==="Unscheduled"&&H===""),ne=G.find(c=>c.email===H)?.accountId??X??Y??se?.accountId??"",ae=c=>{F(!1);const h=je(m.draft,r,{clock:Z,anchor:Z!==oe()?Z:m.anchor});if(!h.ok){s(h.problem);return}s(""),S(void 0);const B=k!==m.busy?{...h.patch,transparency:Ce(k)}:h.patch,re=B.attendees!==void 0&&H===""&&ne!==""?{...B,organizerAccountId:ne}:B;K({calendarObjectId:e,calendarId:a.calendarId,recurrenceId:n??"",scope:c,etag:i?.etag??""},re).then(D=>{if(D.kind==="written"){f({type:"saved"}),g(D.sends),o(e),Te();return}const w=D.kind==="conflict"?he:`Couldn't save this event: ${D.message}`;S({text:w,reportHref:ge(w),onRetry:()=>ae(c)})})};return v.jsxs(v.Fragment,{children:[v.jsx(Se,{heading:"Edit event",draft:r,onChange:c=>{I(c),f({type:"sidebar-range",range:_(c)})},calendars:se?[se]:[],calendarEditable:!1,repeatEditable:!de,timeZone:Z,timeZones:be,onTimeZone:te,busy:k,onBusy:U,guests:ke?{suggestions:E,onQuery:L,senders:G,sender:ne,onSender:ee,senderEditable:H===""}:void 0,onSave:()=>de?F(!0):ae(void 0),onCancel:De,saving:M,problem:q,failure:u,failureRef:P,titleRef:T,children:W&&v.jsx(We,{title:a.title,ruleText:r.repeat===""?"It repeats":r.repeat,instanceText:qe(a),onChoose:ae,onCancel:()=>F(!1)})}),Re]})}export{pt as C,vt as a};
@@ -1 +0,0 @@
1
- import{r as s,j as n,a9 as k}from"./index-D94MOpo0.js";import{b as ce,e as de,v as ue,w as pe,s as fe,c as D,x as ve,i as me}from"./useCalendarSuggestions-BfA31NJY.js";import{c as he,t as Ce,R as V}from"./useCalendarData-DQ7oi-nJ.js";import{f as N}from"./calendar-format-BwCpz-JZ.js";import"./reply-DPVLqPcI.js";import{a as xe,b as ge}from"./calendar-CNIMaOb7.js";import{u as ye}from"./CalendarSession-CTmh2tcD.js";import{C as T}from"./useCalendarTasks-BMPfFFau.js";import{a as Se,b as Ee}from"./calendar-event-popup-CYCnsOds.js";import{d as $e,e as we}from"./calendar-guests-BXmTl5jL.js";import{C as Ie}from"./confirm-dialog-BXhRj5Sm.js";const Re={Accepted:"accepted",Declined:"declined",Tentative:"tentative",NeedsAction:"noReply"},je=a=>({name:a.displayName,email:a.email,rsvp:Re[a.status],role:a.role==="Organizer"?"organizer":"attendee"}),ke={accepted:"Accepted",declined:"Declined",tentative:"Tentative"},J="This calendar changed while you were writing.",De=a=>a.kind==="conflict"?`${J} Close the popup and open the event again.`:a.kind==="refused"?`Couldn't delete this event: ${a.message}`:"";function ze({calendarObjectId:a,recurrenceId:p}){const{view:f,date:g,calendarIds:v}=xe(),{events:A,isLoading:U,freeIds:M}=he({view:f,date:g,calendarIds:v}),{calendars:Q}=ce(),{closeToView:m,openEditor:X}=ge(),{deleteEvent:Y,updateEvent:Z,isWriting:F}=de(),b=ye(),[O,y]=s.useState(),[ee,P]=s.useState(),c=s.useId(),L=s.useRef(null),B=s.useRef(null),G=s.useRef(null),[te,h]=s.useState(!1),[ne,S]=s.useState(!1),[E,ae]=s.useState(void 0),[K,se]=s.useState(null),C=me(a,p??""),t=A.find(e=>e.id===C),$=p===void 0&&t===void 0?ue(A,a,new Date().toISOString()):void 0,d=pe(a,t===void 0&&!U&&$===void 0),w=Q.find(e=>e.id===t?.calendarId),{resource:r}=fe(a,t?.calendarId??""),re=r?Ce(r.icalData):void 0,W=t!==void 0&&r!==void 0&&!w?.readOnly,I=t!==void 0&&t.seriesId!=="";s.useLayoutEffect(()=>{se(t?document.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`):null)},[t]);const R=d.kind==="Deleted"||d.kind==="NoOccurrenceFound";s.useEffect(()=>{R?B.current?.focus():t&&L.current?.focus()},[R,t]),s.useEffect(()=>{E&&G.current?.focus()},[E]),s.useEffect(()=>{const e=`[data-event-id="${CSS.escape(C)}"]`;return()=>{document.querySelector(e)?.focus()}},[C]);const z=e=>({calendarObjectId:a,calendarId:t?.calendarId??"",recurrenceId:p??"",scope:e,etag:r?.etag??""}),H=(r?.attendees??[]).filter(e=>e.role==="Guest").map(e=>e.displayName===""?e.email:e.displayName),oe=()=>{if(H.length>0){S(!0);return}if(I){h(!0);return}x(void 0)},ie=()=>{if(S(!1),I){h(!0);return}x(void 0)},x=e=>{h(!1),Y(z(e)).then(i=>{if(i.kind==="written"){b.trackSends(i.sends),m();return}const l=De(i);ae({text:l,reportHref:D(l),onRetry:()=>x(e)})})},j=(e,i)=>{y(void 0),P(void 0),Z(z(i),{answer:ke[e]}).then(l=>{if(l.kind==="written"){b.trackSends(l.sends);return}const q=l.kind==="conflict"?`${J} Close the popup and open the event again.`:`Couldn't send your reply: ${l.message}`;P({text:q,reportHref:D(q),onRetry:()=>j(e,i)})})},u=r?.participation,le=u!==void 0&&u!=="Organizer"&&u!=="Unscheduled";if($)return n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:g,calendarObjectId:a,recurrenceId:$.recurrenceId},search:!0,hash:!0,replace:!0});const o=d.kind==="Found"?d.jump:void 0,_=o!==void 0&&v.length>0&&!v.includes(o.calendarId);if(o&&(o.date!==g||_)){const e=_?i=>({...i,calendarId:[...v,o.calendarId]}):!0;return o.recurrenceId===""?n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId",params:{view:f,date:o.date,calendarObjectId:a},search:e,hash:!0,replace:!0}):n.jsx(k,{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:f,date:o.date,calendarObjectId:a,recurrenceId:o.recurrenceId},search:e,hash:!0,replace:!0})}if(d.kind==="Failed"&&!t){const e=`Couldn't open this event: ${d.reason}`;return n.jsx(T,{anchor:null,anchorKey:"failed",labelledBy:c,children:n.jsxs("div",{className:"flex flex-col gap-3 p-4",id:c,children:[n.jsxs("p",{role:"alert",className:"text-sm text-danger",children:[e," ",n.jsx("a",{href:D(e),target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}),n.jsx("button",{type:"button",onClick:m,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium",children:"Close"})]})})}return R?n.jsx(T,{anchor:null,anchorKey:"gone",labelledBy:c,children:n.jsx(Se,{headingId:c,onClose:m,closeRef:B})}):t?n.jsxs(n.Fragment,{children:[n.jsx(T,{anchor:K,anchorKey:`${C}:${K?"chip":"none"}`,labelledBy:c,children:n.jsxs(Ee,{headingId:c,headingRef:L,title:t.title,color:w?.color??"cal-1",when:N(t).replace(", "," · "),location:re?.location??"",calendarName:w?.name??"",availability:M.has(t.id)?"Free":"Busy",onEdit:W?()=>X(a,p):void 0,onDelete:W?oe:void 0,deleting:F,onClose:m,failure:E,failureRef:G,children:[r&&n.jsx($e,{attendees:r.attendees.map(je),counts:r.attendeeCounts}),le&&u&&n.jsx(we,{current:ve(u),onAnswer:e=>I?y(e):j(e,void 0),sending:F,failure:ee}),O&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),scopes:["this","all"],onChoose:e=>j(O,e),onCancel:()=>y(void 0)}),te&&n.jsx(V,{title:t.title,ruleText:"It repeats",instanceText:N(t),onChoose:x,onCancel:()=>h(!1)})]})}),n.jsx(Ie,{isOpen:ne,title:"Delete and tell the guests?",description:`${H.join(", ")} will get a cancellation.`,confirmLabel:"Delete and send",cancelLabel:"Keep event",destructive:!0,onConfirm:ie,onCancel:()=>S(!1)})]}):null}export{ze as C};
@@ -1 +0,0 @@
1
- import{b as _,p as j,j as e,X as q,r as c,bZ as X}from"./index-D94MOpo0.js";import{c as J}from"./draft-BIQ0-Lk_.js";import{b as V,e as F,c as ee,p as K,U,f as W}from"./useCalendarSuggestions-BfA31NJY.js";import{u as te,b as ae}from"./useCalendarScheduling-DAb_8yBj.js";import{u as ne,C as re}from"./useCalendarTasks-BMPfFFau.js";import"./reply-DPVLqPcI.js";import{i as se}from"./calendar-CNIMaOb7.js";import{u as le}from"./CalendarSession-CTmh2tcD.js";import{i as ie,c as oe}from"./calendar-guests-BXmTl5jL.js";import{C as ce}from"./calendar-event-popup-CYCnsOds.js";const ue=_("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),de="h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",$=(s,r)=>{const m={...s.range,...r};return r.date!==void 0&&!m.allDay&&(m.endDate=r.date),r.date!==void 0&&m.allDay&&m.endDate<r.date&&(m.endDate=r.date),{...s,range:m}};function me({headingId:s,mode:r,onMode:m,fields:i,taskFields:o,onTaskChange:u,calendars:g,taskLists:N,guestSuggestions:T,onGuestQuery:v,onChange:f,onSave:x,onMoreOptions:R,onClose:A,saving:y=!1,problem:w="",failure:S,failureRef:M,titleRef:P,settingsHref:z,dragHandle:E,touch:h=!1}){const n=r==="task",C=n?N:g,D=C.length===0,d=!n&&ie(i.guests)!==void 0,p=j(de,h&&"h-11"),G=n?o.title:i.title,I=t=>n?u({...o,title:t}):f({...i,title:t});return e.jsxs("form",{className:"relative flex flex-col",onSubmit:t=>{t.preventDefault(),!D&&!y&&!d&&x()},children:[e.jsxs("div",{onPointerDown:E?.onPointerDown,className:j("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1",E&&"cursor-grab"),children:[e.jsx(ue,{className:"size-4 text-fg-subtle","aria-hidden":"true"}),e.jsx("h2",{id:s,className:"sr-only",children:n?"New task":"New event"})]}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("input",{ref:P,"aria-label":"Title",placeholder:"Add title",value:G,onChange:t=>I(t.target.value),className:j("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent")}),e.jsxs("fieldset",{className:"flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm",children:[e.jsx("legend",{className:"sr-only",children:"Kind"}),["event","task"].map(t=>e.jsxs("label",{className:j("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",r===t?"bg-surface text-fg shadow-sm":"text-fg-muted",h&&"min-h-11"),children:[e.jsx("input",{type:"radio",name:`${s}-kind`,value:t,checked:r===t,onChange:()=>m(t),className:"sr-only"}),t==="event"?"Event":"Task"]},t))]}),n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-fg-muted",children:"Due"}),e.jsx("input",{type:"date","aria-label":"Due date",value:o.dueDate,onChange:t=>t.target.value!==""&&u({...o,dueDate:t.target.value}),className:p}),o.dueTime===""?e.jsx("button",{type:"button",onClick:()=>u({...o,dueTime:"09:00"}),className:"rounded-md px-2 font-medium text-accent hover:bg-accent-soft",children:"Add time"}):e.jsx("input",{type:"time","aria-label":"Due time",step:900,value:o.dueTime,onChange:t=>u({...o,dueTime:t.target.value}),className:p})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("input",{type:"date","aria-label":"Date",value:i.range.date,onChange:t=>t.target.value!==""&&f($(i,{date:t.target.value})),className:p}),i.range.allDay?e.jsx("span",{className:"text-fg-muted",children:"All day"}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"time","aria-label":"Start time",step:900,value:i.range.startTime,onChange:t=>t.target.value!==""&&f($(i,{startTime:t.target.value})),className:p}),e.jsx("span",{"aria-hidden":"true",children:"–"}),e.jsx("input",{type:"time","aria-label":"End time",step:900,value:i.range.endTime,onChange:t=>t.target.value!==""&&f($(i,{endTime:t.target.value})),className:p})]})]}),!n&&e.jsx(oe,{value:i.guests,onChange:t=>f({...i,guests:t}),suggestions:T,onQuery:v,touch:h}),n?e.jsx("textarea",{"aria-label":"Description",placeholder:"Add description",rows:2,value:o.description,onChange:t=>u({...o,description:t.target.value}),className:"w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30"}):e.jsx("input",{"aria-label":"Location",placeholder:"Add location",value:i.location,onChange:t=>f({...i,location:t.target.value}),className:p}),D?e.jsxs("p",{role:"status",tabIndex:-1,className:"text-sm text-fg-muted",children:["None of your calendars accepts new events."," ",e.jsx("a",{href:z,className:"font-medium text-accent hover:underline",children:"Calendar settings"})]}):e.jsx("select",{"aria-label":n?"Task list":"Calendar",value:n?o.calendarId:i.calendarId,onChange:t=>n?u({...o,calendarId:t.target.value}):f({...i,calendarId:t.target.value}),className:p,children:C.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),w!==""&&e.jsx("p",{className:"text-sm text-danger",role:"status",children:w}),S&&e.jsx(ce,{failure:S,focusRef:M})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-4",children:[n?e.jsx("span",{}):e.jsx("button",{type:"button",onClick:R,className:j("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring",h?"min-h-11":"h-9"),children:"More options"}),e.jsx("button",{type:"submit",disabled:D||y||d,className:j("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",h?"min-h-11":"h-9"),children:y?"Saving…":"Save"})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:A,className:j("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",h?"size-11":"size-8"),children:e.jsx(q,{className:"size-4"})})]})}const fe=80;function ge({labelledBy:s,onDismiss:r,children:m,sheetRef:i,className:o}){const u=c.useRef(null),[g,N]=c.useState(0),T=x=>{u.current=x.clientY,x.currentTarget.setPointerCapture(x.pointerId)},v=x=>{u.current!==null&&N(Math.max(0,x.clientY-u.current))},f=()=>{u.current!==null&&(u.current=null,g>fe&&r(),N(0))};return e.jsxs("div",{ref:i,role:"dialog","aria-modal":"false","aria-labelledby":s,"data-calendar-popover":"",className:j("fixed inset-x-0 bottom-0 z-50 max-h-[70dvh] overflow-y-auto rounded-t-2xl border-t border-line bg-surface-raised pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",o),style:{transform:`translateY(${g}px)`,transition:g===0?"transform 200ms ease-out":"none"},children:[e.jsx("div",{"aria-hidden":"true","data-sheet-grabber":"",onPointerDown:T,onPointerMove:v,onPointerUp:f,onPointerCancel:f,className:"flex h-6 cursor-grab touch-none items-center justify-center",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-line-strong"})}),m]})}const xe="/settings/calendars";function pe(s){return{title:s.title,date:s.range.date,startTime:s.range.startTime,endDate:s.range.endDate,endTime:s.range.endTime,allDay:s.range.allDay,calendarId:s.calendarId,location:s.location,guests:s.guests,notes:"",repeat:""}}function ke({session:s,dispatch:r,onMoreOptions:m,onSaved:i,touch:o=!1}){const u=c.useId(),g=c.useRef(null),N=c.useRef(null),[T,v]=c.useState(""),{calendars:f,taskLists:x,defaultCalendarId:R,timeZoneByCalendarId:A}=V(),y=f.filter(a=>!a.readOnly),{createEvent:w}=F(),{createTask:S}=ne(),{defaultSenderId:M}=te(),[P,z]=c.useState(""),E=ae(P),h=le(),{draft:n}=s,[C,D]=c.useState("event"),[d,p]=c.useState({title:"",dueDate:"",dueTime:"",description:"",calendarId:""}),G=a=>{if(a!==C){if(D(a),a==="event"){r({type:"change",draft:{...n,title:d.title}});return}p(l=>({...l,title:n.title,dueDate:n.range.date,dueTime:n.range.allDay?"":n.range.startTime,calendarId:l.calendarId===""?x[0]?.id??"":l.calendarId}))}},I=y.find(a=>a.id===R)?.id??y[0]?.id??"",t=M??y.find(a=>a.id===n.calendarId)?.accountId??"";c.useEffect(()=>{g.current?.focus()},[]),c.useEffect(()=>{n.calendarId!==""||I===""||r({type:"change",draft:{...n,calendarId:I}})},[n,I,r]),c.useEffect(()=>{s.status==="failed"&&N.current?.focus()},[s.status]);const L=c.useRef(null),B=c.useRef(null);se(o,()=>(r({type:"outside"}),!0));const k=`${n.range.date}T${n.range.startTime}/${n.range.endDate}T${n.range.endTime}`;c.useEffect(()=>{const a=B.current;if(k==="")return;const l=document.querySelector("[data-draft-block]"),b=document.querySelector("[role='grid'][aria-label='Time grid']");if(!a||!l||!b)return;const Q=l.getBoundingClientRect().bottom-a.getBoundingClientRect().top+16;Q>0&&(b.scrollTop+=Q)},[k]);const H=c.useRef(null);c.useEffect(()=>{const a=H.current;if(!a)return;const l=b=>{(b.target instanceof HTMLInputElement||b.target instanceof HTMLSelectElement)&&(L.current=b.target)};return a.addEventListener("focusin",l),()=>a.removeEventListener("focusin",l)},[]),c.useEffect(()=>{const a=L.current;k===""||!a||document.activeElement===a||a.focus()},[k]);const Y=()=>{if(d.title.trim()===""){v("Give the task a title before saving it."),g.current?.focus();return}v(""),r({type:"save"});const a=W(),l=d.dueTime==="";S({calendarId:d.calendarId,summary:d.title.trim(),description:d.description,allDay:l,due:l?d.dueDate:X(d.dueDate,d.dueTime,a),...l?{}:{timeZone:K(U)}}).then(b=>{if(b.kind==="written"){r({type:"saved"});return}r({type:"save-failed",problem:`Couldn't save the task: ${b.message}`})})},Z=()=>{if(C==="task"){Y();return}const a=J(pe(n),{clock:W(),anchor:K(A[n.calendarId]??U)},t);if(!a.ok){v(a.problem),g.current?.focus();return}v(""),r({type:"save"}),w(a.input).then(l=>{if(l.kind==="created"){r({type:"saved"}),h.trackSends(l.sends),i(l.calendarObjectId);return}r({type:"save-failed",problem:l.kind==="conflict"?"This calendar changed while you were writing. Close the form and try again.":`Couldn't save this event: ${l.message}`})})},O=a=>e.jsx("div",{ref:H,children:e.jsx(me,{headingId:u,mode:C,onMode:G,fields:n,taskFields:d,onTaskChange:p,calendars:y,taskLists:x,guestSuggestions:E,onGuestQuery:z,onChange:l=>r({type:"change",draft:l}),onSave:Z,onMoreOptions:()=>m(L.current?.getAttribute("aria-label")??""),onClose:()=>r({type:"outside"}),saving:s.status==="saving",problem:T,failure:s.status==="failed"?{text:s.problem,reportHref:ee(s.problem),onRetry:Z}:void 0,failureRef:N,titleRef:g,settingsHref:xe,dragHandle:a,touch:o})});return o?e.jsx(ge,{labelledBy:u,onDismiss:()=>r({type:"outside"}),sheetRef:B,children:O()}):e.jsx(re,{anchor:"[data-draft-block]",anchorKey:k,labelledBy:u,wrapTab:!0,header:a=>O(a),children:null})}export{ke as C,pe as e};
@@ -1 +0,0 @@
1
- import{b as d,r as c,j as e,a6 as b,p as u,C as j,u as y,G as N}from"./index-D94MOpo0.js";import{u as x}from"./useLayoutTier-CIlJuePx.js";import{g as A,u as w}from"./reply-DPVLqPcI.js";import{u as S}from"./sections-Dm0mEk9W.js";import{A as k}from"./AccountSession-BYJ1unhC.js";import{A as C}from"./avatar-BV5vFJ_r.js";import{u as P,P as M,a as R,b as p}from"./popover-menu-D1Ggz_nA.js";import{u as L}from"./roving-focus-CJC-AjPO.js";import{M as z}from"./mail-4EQRG36P.js";import{A as T}from"./app-chrome-Dbvu4ieD.js";const O=d("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Z=d("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function F({email:a,onOpenSecurity:s,onSignOut:n}){const t=c.useRef(null),{open:r,setOpen:i,containerRef:l,panelRef:o,getAnchor:g}=P("account-menu",()=>t.current?.focus());c.useEffect(()=>{if(!r)return;const m=requestAnimationFrame(()=>o.current?.querySelector('[role="menuitem"]')?.focus());return()=>cancelAnimationFrame(m)},[r,o]);const f=a??"Account";return e.jsxs("div",{ref:l,className:"relative",children:[e.jsx("button",{ref:t,type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":r,onClick:()=>i(m=>!m),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-raised hover:text-fg",children:e.jsx(C,{name:f,email:a??void 0,size:"sm"})}),e.jsx(M,{open:r,align:"end",panelRef:o,getAnchor:g,children:e.jsxs(R,{ref:o,label:f,children:[a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"truncate px-4 py-2 text-xs text-fg-muted",title:a,"data-testid":"account-menu-email",children:a}),e.jsx("hr",{className:"my-1 h-px border-0 bg-line"})]}),s&&e.jsx(p,{label:"Security",icon:e.jsx(b,{className:"size-4"}),onSelect:()=>{i(!1),s()}}),e.jsx(p,{label:"Sign out",icon:e.jsx(O,{className:"size-4"}),onSelect:()=>{i(!1),t.current?.focus(),n()}})]})})]})}const E={mail:z,calendar:j},D="[data-app-item]",B=a=>a.button===0&&!a.metaKey&&!a.ctrlKey&&!a.shiftKey&&!a.altKey;function h({item:a,active:s,onNavigate:n,className:t,iconClassName:r}){const i=E[a.id];return e.jsxs("a",{href:a.href,"data-app-item":"","aria-current":s?"page":void 0,onClick:l=>{B(l)&&(l.preventDefault(),n(a.id))},className:u("flex flex-col items-center justify-center gap-0.5 rounded-lg outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring",s?"bg-accent-soft text-accent":"text-fg-muted hover:bg-surface-sunken hover:text-fg",t),children:[e.jsx(i,{className:r,"aria-hidden":"true"}),e.jsx("span",{className:"text-2xs font-medium",children:a.label})]})}function I({items:a,active:s,onNavigate:n,className:t}){const r=c.useRef(null);return L({containerRef:r,itemSelector:D}),e.jsx("nav",{ref:r,"aria-label":"Apps",className:u("flex w-16 shrink-0 flex-col items-center gap-1 border-r border-line bg-surface py-2",t),children:a.map(i=>e.jsx(h,{item:i,active:i.id===s,onNavigate:n,className:"size-14",iconClassName:"size-5"},i.id))})}function K({items:a,active:s,onNavigate:n,className:t}){return e.jsx("nav",{"aria-label":"Apps",className:u("flex shrink-0 items-stretch justify-around border-t border-line bg-surface px-2 pt-1 pb-[max(0.25rem,env(safe-area-inset-bottom))]",t),children:a.map(r=>e.jsx(h,{item:r,active:r.id===s,onNavigate:n,className:"min-h-12 min-w-16 flex-1",iconClassName:"size-5"},r.id))})}function ee({leading:a,search:s,actions:n,className:t}){return e.jsxs("header",{className:u("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",t),children:[a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a}),e.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:e.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:s})}),n&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n})]})}const q=a=>a.startsWith("/calendar")?"calendar":"mail";function v(){const a=y(),s=N(),n=A(),t=w({select:o=>o.pathname}),r=q(t),i=c.useMemo(()=>[{id:"mail",label:"Mail",href:s.buildLocation({to:"/mail",hash:n}).href},{id:"calendar",label:"Calendar",href:s.buildLocation({to:"/calendar",hash:n}).href}],[s,n]),l=c.useCallback(o=>{a({to:o==="calendar"?"/calendar":"/mail",hash:n})},[a,n]);return{items:i,active:r,switchTo:l}}function ae({children:a,hideTabBar:s=!1}){const n=x()==="phone",{items:t,active:r,switchTo:i}=v();return n?e.jsxs("div",{className:"flex h-full w-full flex-col",style:s?void 0:{"--app-tab-bar":"3.5rem"},children:[e.jsx("div",{className:"min-h-0 flex-1",children:a}),!s&&e.jsx(K,{items:t,active:r,onNavigate:i})]}):e.jsx(e.Fragment,{children:a})}const se=()=>{const a=S();return e.jsx(k,{children:({email:s,signOut:n,securityUrl:t})=>e.jsx(F,{email:s,onOpenSecurity:t?()=>a("security"):void 0,onSignOut:n})})};function V(){const{items:a,active:s,switchTo:n}=v();return e.jsx(I,{items:a,active:s,onNavigate:n})}function ne({topBar:a,children:s}){return x()==="phone"?e.jsx(e.Fragment,{children:s}):e.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden bg-canvas",children:e.jsx(T,{topBar:a,appBar:e.jsx(V,{}),children:s})})}export{ee as A,ne as D,O as L,Z as S,se as a,ae as b,V as c};
@@ -1 +0,0 @@
1
- import{eG as J,r as n,d_ as X,a as le,H,cV as ce,at as ue,au as ge,j as r}from"./index-D94MOpo0.js";import{y as he,A as me,ao as pe,aq as fe,aA as xe,ar as Ie,d as Te,M as ye,ax as ve,aB as be,az as Re,m as Ce,G as Se,K as _,J as we,H as je,e as Fe,V as Me,W as V,X as Oe,Z,_ as $,$ as ke,a0 as Pe,a1 as Le}from"./MessageToolbar-2VWnNBpw.js";import{u as Ae,l as Ne,b as De,a as qe}from"./MailViewChrome-C47Pffjf.js";import{h as Ee,n as Be,r as We}from"./reply-DPVLqPcI.js";import{a as Qe}from"./useMessageBodyContent-yhApp3IG.js";import{e as He,f as Ve}from"./search-token-index-DXiN1835.js";import{u as ze}from"./sections-Dm0mEk9W.js";import{u as Ge}from"./useMediaQuery-CGZfUxdm.js";import{u as Ke,p as U,R as _e}from"./MessageBody-C2-SQjAb.js";import{d as Ue,w as Je}from"./wizard-selection-zWa1qc6-.js";import{f as Xe}from"./ErrorState-Dzdw33-3.js";const z=t=>({...t,starred:!0,order:"desc"}),Ze=(t={})=>X({query:z(t)});function Y(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=Ae({queryKey:Ze(t),queryFn:async({pageParam:x})=>{const{data:u}=await J({query:{...z(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function $e(t={}){const e={...z(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 Ye=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=he(t),{params:a,residual:i}=me(e,{...s,starred:!0},Ye);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Re(),i=n.useMemo(()=>Je(t,s),[t,s]);return r.jsx(Ce,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=H(),o=Ke(),k=Ge(),x=ce(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=U(f.trim().toLowerCase(),o),L=U(f.trim(),o).freeText,{criteria:A,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...A,query:j}:A,[A,j]),{threads:N,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=Y(F),p=n.useMemo(()=>Ue(N).map(pe).filter(d=>fe(d,m)),[N,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>xe(),[]),se=n.useMemo(()=>p.map(d=>Ie(d,l)),[p,l]),ae=$e(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=Ne({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),G=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ue(ge());window.open(d,"_blank","noopener,noreferrer")},[]),K=Te(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(ye,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),W?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>B(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(De,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(ve,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(qe,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:K.searchResults?"ready":G,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?Xe(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(be,{title:"Starred"}),listBody:K.searchResults??(G==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=He(),a=Ve(),i=ze(),{searchInput:f}=H(),l=t?.threadId,g=t?.messageId,{threads:o}=Y(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=Se(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=_({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=we(),{deleteMessages:j}=je({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Fe({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=_({thread:m,isOpen:m?.messageId===h}),N=Qe(),D=Ee(),y=Be(),E=n.useMemo(()=>We(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Me({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!N&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(B),previousThread:O(W),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=V(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Pe(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Le,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Z,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(_e,{})})]}),r.jsx($,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=V(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=H();return r.jsx(ke,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=V(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=Oe(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Z,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx($,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const It=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{It as F};
@@ -1 +0,0 @@
1
- import{r as n,a as f,c as m,n as N,j as e,X as w}from"./index-D94MOpo0.js";import{D as r,C as u,u as E}from"./index-BlOq3dK1.js";import{u as k}from"./useMediaQuery-CGZfUxdm.js";import"./reply-DPVLqPcI.js";import{d as x,e as p,f as h}from"./useMessageBodyContent-yhApp3IG.js";import{E as b}from"./ErrorState-Dzdw33-3.js";import{C as S}from"./confirm-dialog-BXhRj5Sm.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=x(),i=p(),s=h(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},K=()=>{const t=x(),i=p(),s=h(),a=k(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(b,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(u,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{K as F};