@remit/web-client-dist 0.0.344 → 0.0.345

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 (110) hide show
  1. package/assets/{BriefPane-Cf0qx6oW.js → BriefPane-1mm_PeUT.js} +1 -1
  2. package/assets/{ErrorState-EG2eHLL1.js → ErrorState-IhTpwfPz.js} +1 -1
  3. package/assets/{FlaggedPane-WLhe7MTQ.js → FlaggedPane-RZF7nBEV.js} +1 -1
  4. package/assets/MailListHeader-BEau0pBP.js +52 -0
  5. package/assets/{MailViewChrome-7pIGoTSB.js → MailViewChrome-DDZ9r_j9.js} +1 -1
  6. package/assets/MailboxPane-CahwbgAR.js +1 -0
  7. package/assets/{NavMenuButton-DiNk3STC.js → NavMenuButton-yWGVKHfp.js} +1 -1
  8. package/assets/{OnboardingWizard-Q6QD6xGn.js → OnboardingWizard-D89jfrHU.js} +1 -1
  9. package/assets/{OutboxPane-DzBz96fV.js → OutboxPane-K7QhugID.js} +1 -1
  10. package/assets/_mailboxId-CzBGL68S.js +1 -0
  11. package/assets/_messageId-BYI7uzhv.js +1 -0
  12. package/assets/_messageId-PByRoW3Q.js +1 -0
  13. package/assets/_messageId-lO_ztI2O.js +1 -0
  14. package/assets/_outboxMessageId-DLoKe3G5.js +1 -0
  15. package/assets/_threadId-BGZs-1Ch.js +1 -0
  16. package/assets/_threadId-Cq6XKFqS.js +1 -0
  17. package/assets/_threadId-DET6BrAQ.js +1 -0
  18. package/assets/{account-form-helpers-1QlePfxz.js → account-form-helpers-BNb3DSVG.js} +1 -1
  19. package/assets/accounts-DnyJTiJI.js +1 -0
  20. package/assets/{advanced-BHmSZ0Kb.js → advanced-yh1pLf-B.js} +1 -1
  21. package/assets/{appearance-Ber4IHv_.js → appearance-DcrksIgM.js} +1 -1
  22. package/assets/{avatar-BpcGfGBY.js → avatar-C1YERaBW.js} +1 -1
  23. package/assets/{bottom-sheet-Bb9_P1q_.js → bottom-sheet-D3ZLbxjc.js} +1 -1
  24. package/assets/brief-BIkek75W.js +1 -0
  25. package/assets/{brief-snQhmfLP.js → brief-Crh5aORi.js} +1 -1
  26. package/assets/{browser-ponyfill-Dth-IE_T.js → browser-ponyfill-BoXA5ljp.js} +1 -1
  27. package/assets/{bug-CDavBQtl.js → bug-BQJiKMvA.js} +1 -1
  28. package/assets/{circle-check-rylkL795.js → circle-check-BzfPpVwA.js} +1 -1
  29. package/assets/{circle-check-big-CBG0107E.js → circle-check-big-E096Rpo6.js} +1 -1
  30. package/assets/{circle-help-aRUYdfvH.js → circle-help-Djyb9g9x.js} +1 -1
  31. package/assets/{clock-tsMaR7Oh.js → clock-BGx-WRwm.js} +1 -1
  32. package/assets/{confirm-dialog-C2G4kIKu.js → confirm-dialog-BqRkjxqY.js} +1 -1
  33. package/assets/{download-CdBITb1R.js → download-D1twBW8-.js} +1 -1
  34. package/assets/filters-DIE1BOtT.js +1 -0
  35. package/assets/{flagged-BkzKKM9G.js → flagged-CH2YuUEr.js} +1 -1
  36. package/assets/flagged-mECxAUaT.js +1 -0
  37. package/assets/{folders-qdT9HdHz.js → folders-Bb-Thje1.js} +1 -1
  38. package/assets/index-64Fc5YpN.js +1 -0
  39. package/assets/index-6Cv_3Tx9.js +1 -0
  40. package/assets/index-BYI7uzhv.js +1 -0
  41. package/assets/index-Be57iCSf.js +1 -0
  42. package/assets/{index-CoNvZIm_.js → index-CJIQUM3m.js} +60 -60
  43. package/assets/index-DYD2vIsa.js +1 -0
  44. package/assets/index-DYxqG2tY.js +1 -0
  45. package/assets/{index-B5g0rcGz.css → index-DivxHcM7.css} +1 -1
  46. package/assets/index-PByRoW3Q.js +1 -0
  47. package/assets/index-t-E-dbnZ.js +1 -0
  48. package/assets/{kbd-37YHrOod.js → kbd-BE6tTCtF.js} +1 -1
  49. package/assets/{labels-Dz8ChP9r.js → labels-0xRxgkIu.js} +1 -1
  50. package/assets/mail-B9B54KdQ.js +1 -0
  51. package/assets/{menu-B6RXxSm8.js → menu-COgUw78E.js} +1 -1
  52. package/assets/{move-options-BHPhC1Kk.js → move-options-CDIApFih.js} +1 -1
  53. package/assets/{nav-link-7QYETm4r.js → nav-link-CAIuq5J3.js} +1 -1
  54. package/assets/{onboarding-DZlyKY0e.js → onboarding-BQk2nuRz.js} +1 -1
  55. package/assets/outbox-BcPTimoR.js +1 -0
  56. package/assets/{pencil-DUvdHUlD.js → pencil-Dg_IctIe.js} +1 -1
  57. package/assets/{rich-text-DYkgFghh.js → rich-text-D9OHMO12.js} +3 -3
  58. package/assets/rich-text-spellcheck-worker-provider-BGQbidNK.js +1 -0
  59. package/assets/{rotate-ccw-BozetpiQ.js → rotate-ccw-B7F_7KUF.js} +1 -1
  60. package/assets/{row-actions-DzYchsTL.js → row-actions-DmMWj-q1.js} +1 -1
  61. package/assets/{search-scope-DpxLT3gw.js → search-scope-C_6gVLxy.js} +1 -1
  62. package/assets/search-token-index-BL_8U2FY.js +1 -0
  63. package/assets/{search-view-DBvRPRa1.js → search-view-IadPSZuy.js} +1 -1
  64. package/assets/{senders-BhtoX47B.js → senders-DB6Z9uah.js} +1 -1
  65. package/assets/settings-Dz-3CiIM.js +1 -0
  66. package/assets/{settings-screen-QrhNeHVs.js → settings-screen-DBate9ZD.js} +1 -1
  67. package/assets/{shield-check-XKwP5L-S.js → shield-check-DfJ2e4bR.js} +1 -1
  68. package/assets/{suggested-vips-B2_DnQVw.js → suggested-vips-YCk6wNsV.js} +1 -1
  69. package/assets/use-match-media-BLEbblZt.js +1 -0
  70. package/assets/{useDebouncedValue-CDnuOkob.js → useDebouncedValue-l5Z3i8R5.js} +1 -1
  71. package/assets/useFilters-1CkubGql.js +1 -0
  72. package/assets/{useLabels-Dxb6ajq-.js → useLabels-BEGvT3oT.js} +1 -1
  73. package/assets/{useRefreshControl-DlypbbhJ.js → useRefreshControl-BgbtWANV.js} +1 -1
  74. package/assets/{useSearchMirror-eiX731bE.js → useSearchMirror-SkZ0dySG.js} +1 -1
  75. package/assets/useSearchTokenContext-cfVjM7Bv.js +84 -0
  76. package/assets/{useSemanticSearch-Dn1P2d8-.js → useSemanticSearch-CH_J9x0n.js} +1 -1
  77. package/assets/{useSignature-DIdZs8UQ.js → useSignature-C7MpJuV_.js} +1 -1
  78. package/index.html +2 -2
  79. package/package.json +1 -1
  80. package/assets/MailListHeader-CsMXujM8.js +0 -52
  81. package/assets/MailboxPane-DkPAPzBT.js +0 -1
  82. package/assets/_mailboxId-BseanUYV.js +0 -1
  83. package/assets/_messageId-BDqdIyPR.js +0 -1
  84. package/assets/_messageId-DUX8pRMi.js +0 -1
  85. package/assets/_messageId-DaIDf_Wh.js +0 -1
  86. package/assets/_outboxMessageId-Vm0R3pBD.js +0 -1
  87. package/assets/_threadId-BjK4yKxL.js +0 -1
  88. package/assets/_threadId-D0JNHKu7.js +0 -1
  89. package/assets/_threadId-D5xYU6At.js +0 -1
  90. package/assets/accounts-Cs4TZIog.js +0 -1
  91. package/assets/brief-CpdHVxqD.js +0 -1
  92. package/assets/filters-DZsPSqyt.js +0 -1
  93. package/assets/flagged-DW5dkEVI.js +0 -1
  94. package/assets/index-BDqdIyPR.js +0 -1
  95. package/assets/index-BfDh6SQq.js +0 -1
  96. package/assets/index-C7HIuKEc.js +0 -1
  97. package/assets/index-ChQ-GJlE.js +0 -1
  98. package/assets/index-DBQOX_n6.js +0 -1
  99. package/assets/index-DaIDf_Wh.js +0 -1
  100. package/assets/index-bfL1KkHk.js +0 -1
  101. package/assets/index-xIZcq_pa.js +0 -1
  102. package/assets/layout-breakpoints-BWjiUQKh.js +0 -1
  103. package/assets/mail-CcVoV5W-.js +0 -1
  104. package/assets/outbox-H1kfEi9p.js +0 -1
  105. package/assets/rich-text-spellcheck-worker-provider-YYonaQ2v.js +0 -1
  106. package/assets/search-token-index-e3fTB436.js +0 -1
  107. package/assets/settings-C1W1bpOs.js +0 -1
  108. package/assets/use-match-media-BezqzsJW.js +0 -1
  109. package/assets/useFilters-BBQH0MKH.js +0 -1
  110. package/assets/useSearchTokenContext-BnSrnFlb.js +0 -67
@@ -1 +0,0 @@
1
- import{c as z,r as i,u as ze,j as e,S as De,a as pe,b as I,C as ee,d as te,e as Fe,f as ge,F as Te,g as _e,X as be,T as Be,O as Ke,M as Ve,A as Qe,h as qe,I as He,i as ve,B as T,k as U,l as ye,m as $e,n as We,o as je,p as Y,q as Se,s as Ne,t as Ue,v as G,w as J,x as Ce,y as Ye,z as Ge,D as Je,E as $,G as Xe,H as Ze,J as et,K as tt,L as st,N as at,P as nt,Q as rt,R as ot,U as it,V as lt,W as ct,Y as ut,Z as dt,_ as mt,$ as xt,a0 as ht}from"./index-CoNvZIm_.js";import{B as ft,S as pt,D as gt,a as bt,b as vt,u as yt,s as jt,K as St,c as Nt,d as Ct,e as kt,f as wt,g as It,i as Mt}from"./search-token-index-e3fTB436.js";import{u as se}from"./search-scope-DpxLT3gw.js";import{P as Et}from"./pencil-DUvdHUlD.js";import{M as Ot,s as Rt,c as At}from"./search-view-DBvRPRa1.js";import{u as Lt,a as Pt,R as zt,M as Dt}from"./useRefreshControl-DlypbbhJ.js";import{M as Ft}from"./menu-B6RXxSm8.js";import{B as ke}from"./bug-CDavBQtl.js";import{A as Tt}from"./avatar-BpcGfGBY.js";import{i as _t}from"./outbox-status-CPfNHfUQ.js";import{N as L}from"./nav-link-7QYETm4r.js";import{E as Bt}from"./ErrorState-EG2eHLL1.js";import{K as ae}from"./kbd-37YHrOod.js";import{u as Kt}from"./useDebouncedValue-CDnuOkob.js";import{w as ne}from"./intelligence-pref-C6lFpj6U.js";import"./use-match-media-BezqzsJW.js";import"./layout-breakpoints-BWjiUQKh.js";import"./circle-check-big-CBG0107E.js";const Vt=z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);const Qt=z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const we=z("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 Ie=z("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"}]]);const qt=z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),Ht="button:not([disabled]), a[href]",O="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function $t({active:t,dimmed:s,indent:a}){return I("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",O,a&&"pl-7",t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",s&&"opacity-55")}function Wt({icon:t,label:s,count:a,active:n}){return e.jsxs(e.Fragment,{children:[t&&e.jsx("span",{className:I("shrink-0",n?"text-accent-2":"text-fg-subtle"),children:t}),e.jsx("span",{className:"flex-1 truncate",children:s}),a!=null&&a>0&&e.jsx("span",{className:I("text-2xs tabular-nums",n?"text-accent-2":"text-fg-subtle"),children:a})]})}function P({icon:t,label:s,count:a,active:n,dimmed:r,indent:o,navId:l,linkComponent:m,ariaLabel:x,title:p,onClick:b}){const u=$t({active:n,dimmed:r,indent:o}),h=e.jsx(Wt,{icon:t,label:s,count:a,active:n});return l&&m?m({navId:l,className:u,ariaLabel:x??s,title:p,onClick:b,children:h}):e.jsx("button",{type:"button",onClick:b,className:u,"aria-label":x,title:p,children:h})}const re={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function Ut(t){switch(t){case"inbox":return e.jsx(He,{className:"size-4"});case"flagged":return e.jsx(pe,{className:"size-4"});case"drafts":return e.jsx(qe,{className:"size-4"});case"sent":return e.jsx(ge,{className:"size-4"});case"archive":return e.jsx(Qe,{className:"size-4"});case"all":return e.jsx(Ve,{className:"size-4"});case"junk":return e.jsx(Ke,{className:"size-4"});case"trash":return e.jsx(Be,{className:"size-4"})}}const oe=t=>t.role!=null,H=8,ie="remit.nav.folders.open.",le="remit.nav.account.open.";function ce(t,s,a){if(typeof localStorage>"u")return a;const n=localStorage.getItem(t+s);return n===null?a:n!=="0"}function ue(t,s,a){typeof localStorage>"u"||localStorage.setItem(t+s,a?"1":"0")}function Yt({query:t,onSelect:s,onRemove:a}){return e.jsxs("div",{className:"group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface",children:[e.jsxs("button",{type:"button",onClick:s,className:I("flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",O),children:[e.jsx(_e,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),a&&e.jsx("button",{type:"button",onClick:a,"aria-label":`Remove saved search: ${t}`,className:I("shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",O),children:e.jsx(be,{className:"size-3.5"})})]})}function Gt({savedSearches:t,saveableQuery:s,onSelectSavedSearch:a,onRemoveSavedSearch:n,onSaveCurrentSearch:r}){return t.length===0&&!s?null:e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Saved searches"}),s&&e.jsxs("button",{type:"button",onClick:r,className:I("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",O),children:[e.jsx(Vt,{className:"size-4 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",s,"”"]})]}),t.map(o=>e.jsx(Yt,{query:o,onSelect:()=>a?.(o),onRemove:n?()=>n(o):void 0},o))]})}function Jt({account:t,selectedNavId:s,onSelectNav:a,linkComponent:n}){const[r,o]=i.useState(()=>ce(le,t.id,!0)),[l,m]=i.useState(()=>ce(ie,t.id,!0)),[x,p]=i.useState(!1),b=()=>{o(c=>{const y=!c;return ue(le,t.id,y),y})},u=()=>{m(c=>{const y=!c;return ue(ie,t.id,y),y})},h=t.mailboxes.filter(oe).sort((c,y)=>re[c.role]-re[y.role]),f=t.mailboxes.filter(c=>!oe(c)),v=x||f.length<=H?f:f.slice(0,H),S=f.length-v.length,g=t.status??"ready",R=g==="ready"&&h.length===0&&f.length===0;return e.jsxs("div",{className:"mt-3",children:[e.jsxs("button",{type:"button",onClick:b,"aria-expanded":r,className:I("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",O,t.muted&&"opacity-55"),children:[r?e.jsx(ee,{className:"size-3 shrink-0 text-fg-subtle"}):e.jsx(te,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),t.muted&&e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"size-3 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]})]}),r&&e.jsxs(e.Fragment,{children:[g==="loading"&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),g==="error"&&e.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[e.jsx(Fe,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),t.onRetry&&e.jsx("button",{type:"button",onClick:t.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),R&&e.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),g==="ready"&&e.jsxs(e.Fragment,{children:[h.map(c=>e.jsx(P,{navId:c.id,linkComponent:n,icon:Ut(c.role),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),t.outboxPending!==void 0&&e.jsx(P,{navId:"outbox",linkComponent:n,icon:e.jsx(ge,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:t.outboxPending>0?t.outboxPending:void 0,active:s==="outbox",dimmed:t.muted,onClick:()=>a?.("outbox")}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:u,"aria-expanded":l,className:I("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",O),children:[l?e.jsx(ee,{className:"size-3 shrink-0"}):e.jsx(te,{className:"size-3 shrink-0"}),e.jsx("span",{className:"flex-1",children:"Folders"}),e.jsx("span",{className:"tabular-nums opacity-70",children:f.length})]}),l&&e.jsxs(e.Fragment,{children:[v.map(c=>e.jsx(P,{navId:c.id,linkComponent:n,icon:e.jsx(Te,{className:"size-4"}),label:c.name,ariaLabel:c.name,title:c.fullPath??c.name,count:c.unseen,active:s===c.id,dimmed:t.muted,onClick:()=>a?.(c.id)},c.id)),(S>0||x)&&f.length>H&&e.jsx("button",{type:"button",onClick:()=>p(c=>!c),className:I("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",O),children:x?"Show less":`Show all (${f.length})`})]})]})]})]})]})}function Xt({accounts:t,selectedNavId:s,briefUnseen:a,onSelectNav:n,variant:r="desktop",linkComponent:o,calendarNav:l="hidden",savedSearches:m=[],saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}){const h=i.useRef(null);ze({containerRef:h,itemSelector:Ht});const f=r==="drawer",v=e.jsxs("nav",{ref:f?h:void 0,className:f?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[e.jsx(P,{navId:"brief",linkComponent:o,icon:e.jsx(De,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:a,active:s==="brief",onClick:()=>n?.("brief")}),l==="shown"&&e.jsx(P,{navId:"calendar",linkComponent:o,icon:e.jsx(Qt,{className:"size-4"}),label:"Calendar",ariaLabel:"Calendar",active:s==="calendar",onClick:()=>n?.("calendar")}),e.jsx(P,{navId:"flagged",linkComponent:o,icon:e.jsx(pe,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:s==="flagged",onClick:()=>n?.("flagged")}),e.jsx(Gt,{savedSearches:m,saveableQuery:x,onSelectSavedSearch:p,onRemoveSavedSearch:b,onSaveCurrentSearch:u}),t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):t.map(S=>e.jsx(Jt,{account:S,selectedNavId:s,onSelectNav:n,linkComponent:o},S.id))]});return f?v:e.jsx("aside",{ref:h,className:"flex h-full w-full flex-col bg-surface-sunken",children:v})}function Zt({leading:t,search:s,actions:a,className:n}){return e.jsxs("header",{className:I("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",n),children:[t&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:t}),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})}),a&&e.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a})]})}function es(){const t=ve();if(!t)return null;const s=t.showNavPane?!t.navCollapsed:!1;return e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ft,{className:"size-4"}),onClick:t.toggleNav,"aria-label":s?"Hide folders":"Show folders","aria-expanded":s,title:"Folders",className:"shrink-0"})}const ts={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function ss({search:t,onCompose:s,onReportBug:a,onOpenSettings:n,composeShortcut:r,refreshControl:o,account:l}){return e.jsx(Zt,{leading:e.jsx(es,{}),search:e.jsx(pt,{value:t.value,onChange:t.onChange,onClear:t.onClear,onClearQuery:t.onClearQuery,chips:t.chips,onRemoveChip:t.onRemoveChip,placeholder:ts[t.scope]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(qt,{className:"size-4"}),title:r?`Compose (${r})`:"Compose","aria-label":"Compose",onClick:s}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(ke,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:a}),e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(Ie,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:n}),o,l]})})}const as=()=>{const{state:t,openCompose:s}=U(),a=ye(),n=i.useCallback(()=>{s({mode:"new"})},[s]),r=$e(a.pathname);return!a.pathname.startsWith("/mail")||t.isOpen||r?null:e.jsx("button",{type:"button",onClick:n,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(env(safe-area-inset-bottom, 0) + 1rem)"},children:e.jsx(Et,{className:"size-6"})})},Me=({children:t})=>{const{Account:s}=We();return e.jsx(s,{children:t})},ns=({email:t,onSignOut:s})=>{const a=t??"Account";return e.jsxs(gt,{trigger:e.jsx(Tt,{name:a,email:t??void 0,size:"sm"}),align:"right",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-2 text-xs text-fg-muted truncate",title:t,"data-testid":"account-menu-email",children:t}),e.jsx(bt,{})]}),e.jsxs(vt,{onClick:s,children:[e.jsx(we,{className:"size-4"}),"Sign out"]})]})},rs=()=>e.jsx(Me,{children:({email:t,signOut:s})=>e.jsx(ns,{email:t,onSignOut:s})});function os({accounts:t}){const{searchInput:s,onSearchChange:a,onSearchClear:n,onSearchClearQuery:r}=je(),o=Y(),{openCompose:l}=U(),m=i.useCallback(()=>{l({mode:"new"})},[l]),{scope:x,clearScope:p}=yt(t),b=x.kind==="scoped"?[{id:x.chip.id,label:x.chip.label,tone:"scope"}]:void 0,u=i.useMemo(()=>t.map(g=>g.accountId),[t]),{hasNewMail:h}=Lt(),{state:f,errorMessage:v,refresh:S}=Pt(u);return e.jsx(ss,{search:{value:s,scope:x.kind,chips:b,onChange:a,onClear:n,onClearQuery:r,onRemoveChip:p},onCompose:m,onReportBug:Se,onOpenSettings:()=>o({to:"/settings/accounts"}),composeShortcut:jt("compose"),refreshControl:e.jsx(zt,{state:f,onRefresh:S,label:"Refresh all accounts",errorMessage:v,hasUpdate:h(u)}),account:e.jsx(rs,{})})}const X="remit.savedSearches",is=25;function B(){try{const t=localStorage.getItem(X);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(a=>typeof a=="string"):[]}catch{return[]}}function ls(t){const s=t.trim();if(!s)return B();const a=[s,...B().filter(n=>n!==s)].slice(0,is);try{localStorage.setItem(X,JSON.stringify(a))}catch{return a}return a}function cs(t){const s=B().filter(a=>a!==t);try{localStorage.setItem(X,JSON.stringify(s))}catch{return s}return s}const de=t=>/^\d/.test(t),us=(t,s)=>{const a=de(t),n=de(s);return a&&!n?-1:!a&&n?1:t.localeCompare(s,void 0,{sensitivity:"base",numeric:!0})};function ds(t,s,a){const n=[],r=[];for(const o of t)s.has(o.mailboxId)?n.push(o):r.push(o);return r.sort((o,l)=>us($(o,void 0,a),$(l,void 0,a))),{system:n,labels:r}}function ms(t,s,a){const n=Xe(s)&&t.unseenCount>0;return{id:t.mailboxId,name:$(t,s,a),unseen:n?t.unseenCount:void 0,role:s,fullPath:t.fullPath}}function xs(){const t=ye(),s=Je({strict:!1});return t.pathname.startsWith("/settings")?"settings":t.pathname.startsWith("/mail/outbox")?"outbox":t.pathname.startsWith("/mail/flagged")?"flagged":t.pathname.startsWith("/mail/brief")?"brief":s.mailboxId?s.mailboxId:""}function me({accounts:t,onMailboxSelect:s,variant:a="desktop"}){const n=Ne(),r=Y(),o=xs(),{searchInput:l,onSearchChange:m}=je(),[x,p]=i.useState(B),{t:b}=Ue("mail",{useSuspense:!1}),u=i.useCallback((d,N)=>b(d,{defaultValue:N}),[b]),h=G({queries:t.map(d=>({...J({path:{accountId:d.accountId}}),staleTime:1/0}))}),{data:f}=Ce(Ye()),v=i.useMemo(()=>(f?.items??[]).filter(d=>_t(d.status)).length,[f?.items]),S=i.useMemo(()=>t.map((d,N)=>{const C=h[N],M=C?.data?.items??[],w=Ge(d.folderAppointments),{system:E,labels:q}=ds(M,w,u),k=C?.isError?"error":C?.isLoading?"loading":"ready";return{id:d.accountId,label:d.email,email:d.email,muted:!!d.muted,outboxPending:v,status:k,onRetry:()=>C?.refetch(),mailboxes:[...E,...q].map(D=>ms(D,w.get(D.mailboxId),u))}}),[t,h,v,u]),g=d=>{n.invalidateQueries({queryKey:Ze({path:{mailboxId:d},query:{order:"desc"}})})},R=({navId:d,className:N,ariaLabel:C,title:M,children:w,onClick:E})=>d==="brief"?e.jsx(L,{to:"/mail/brief",search:{q:void 0},activeOptions:{includeSearch:!1},onClick:()=>E?.(),className:N,"aria-label":C,title:M,children:w}):d==="outbox"?e.jsx(L,{to:"/mail/outbox",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":C,title:M,children:w}):d==="flagged"?e.jsx(L,{to:"/mail/flagged",search:{q:void 0},onClick:()=>E?.(),className:N,"aria-label":C,title:M,children:w}):d==="settings"?e.jsx(L,{to:"/settings/accounts",onClick:()=>E?.(),className:N,"aria-label":C,title:M,children:w}):e.jsx(L,{to:"/mail/$mailboxId",params:{mailboxId:d},search:{q:void 0},onClick:()=>{g(d),E?.()},className:N,"aria-label":C,title:M,children:w}),c=()=>{m(""),s?.()},y=l.trim(),A=y.length>0&&!x.includes(y)?y:void 0,K=i.useCallback(()=>{A&&p(ls(A))},[A]),V=i.useCallback(d=>{p(cs(d))},[]),Q=i.useCallback(d=>{m(d),r({to:"/mail/brief",search:{q:d}}),s?.()},[m,r,s]);return e.jsx(Xt,{accounts:S,selectedNavId:o,onSelectNav:c,linkComponent:R,variant:a,savedSearches:x,saveableQuery:A,onSaveCurrentSearch:K,onSelectSavedSearch:Q,onRemoveSavedSearch:V})}function hs(){return e.jsxs("button",{type:"button",onClick:Se,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[e.jsx(ke,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]})}function fs({accounts:t,onMailboxSelect:s}){return ve()?.showNavPane??!0?e.jsx(me,{accounts:t}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(me,{accounts:t,onMailboxSelect:s,variant:"drawer"})}),e.jsxs("div",{className:"border-t border-line px-2 py-2",children:[e.jsxs(L,{to:"/settings/accounts",onClick:s,children:[e.jsx(Ie,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),e.jsx(hs,{}),e.jsx(Me,{children:({signOut:r})=>e.jsxs("button",{type:"button",onClick:()=>{s?.(),r()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[e.jsx(we,{className:"size-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}const ps=({isOpen:t,onClose:s})=>{const a=i.useCallback(n=>{n.key==="Escape"&&(n.preventDefault(),s())},[s]);return i.useEffect(()=>{if(t)return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,a]),t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx(et,{label:"Dismiss keyboard shortcuts",onDismiss:s,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",className:tt("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),e.jsx("button",{type:"button",onClick:s,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:e.jsx(be,{className:"size-5"})})]}),e.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:St.map(n=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:n.title}),e.jsx("div",{className:"space-y-2",children:n.hints.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:r.description}),e.jsx("span",{className:"flex shrink-0 items-center gap-1",children:r.keys.map((o,l)=>e.jsxs(i.Fragment,{children:[l>0&&r.keys[0]==="g"&&e.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),e.jsx(ae,{children:o})]},o))})]},`${r.action}-${r.keys.join("+")}`))})]},n.title))}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",e.jsx(ae,{children:"Esc"})," to close"]})})]})]}):null};function gs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0}))});return i.useMemo(()=>Nt(s.map(a=>a.data?.items??[])),[s])}const bs=t=>t.map(s=>s.data?.items??[]);function vs(t){const s=G({queries:t.map(a=>({...J({path:{accountId:a.accountId}}),staleTime:1/0})),combine:bs});return i.useMemo(()=>st(t.map((a,n)=>({folderAppointments:a.folderAppointments,mailboxes:s[n]??[]}))),[t,s])}var F={exports:{}},xe;function ys(){if(xe)return F.exports;xe=1;const t=(s,a,n)=>new Promise((r,o)=>{if(n=Object.assign({concurrency:1/0},n),typeof a!="function")throw new TypeError("Mapper function is required");const{concurrency:l}=n;if(!(typeof l=="number"&&l>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${l}\` (${typeof l})`);const m=[],x=s[Symbol.iterator]();let p=!1,b=!1,u=0,h=0;const f=()=>{if(p)return;const v=x.next(),S=h;if(h++,v.done){b=!0,u===0&&r(m);return}u++,Promise.resolve(v.value).then(g=>a(g,S)).then(g=>{m[S]=g,u--,f()},g=>{p=!0,o(g)})};for(let v=0;v<l&&(f(),!b);v++);});return F.exports=t,F.exports.default=t,F.exports}var js=ys();const Ss=at(js),Ns=900*1e3,Cs=300,ks=(t,s)=>{if(!t)return s;const a=Number.parseInt(t,10);return Number.isFinite(a)&&a>0?a:s},ws=60*1e3,Is=t=>Math.max(ks(t,Cs)*1e3,ws),_=Is(lt().mailboxPollIntervalSeconds),Ms=5,W=new Set,Es=(t,s,a=Ns)=>t.filter(n=>{const r=n.lastSyncAt;return r==null?!0:s-r>a}).map(n=>n.accountId),Os=(t,s,a=_)=>t-s>=a,Rs=(t,s)=>t.filter(a=>!s.has(a)),he=(t,s)=>{if(W.delete(t),ot(s,{softError:!0})){it(s);return}console.warn("[remit] background mailbox sync failed",{accountId:t,error:s})},fe=(t,s)=>nt({path:{accountId:t},throwOnError:!0}).then(()=>{s.invalidateQueries({queryKey:rt({path:{accountId:t}})})}),As=t=>{const s=Ne(),a=i.useRef(t);a.current=t;const n=t.map(r=>r.accountId).join(",");i.useEffect(()=>{const r=Date.now(),l=Es(a.current,r).filter(m=>!W.has(m));if(l.length!==0)for(const m of l)W.add(m),fe(m,s).catch(x=>{he(m,x)})},[n,s]),i.useEffect(()=>{let r=Date.now(),o;const l=new Set,m=()=>{r=Date.now();const b=Rs(a.current.map(u=>u.accountId),l);for(const u of b)l.add(u);Ss(b,u=>fe(u,s).catch(h=>{he(u,h)}).finally(()=>{l.delete(u)}),{concurrency:Ms})},x=()=>{if(document.visibilityState==="visible"){m(),o=setTimeout(x,_);return}},p=()=>{document.visibilityState==="visible"&&Os(Date.now(),r)&&(o!==void 0&&clearTimeout(o),m(),o=setTimeout(x,_))};return o=setTimeout(x,_),document.addEventListener("visibilitychange",p),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",p)}},[n,s])};function Js(){const{q:t=""}=ct({from:"/mail"}),s=Y(),a=Ct(),n=Mt(a),[r,o]=i.useState(!1),[l,m]=i.useState(!1),[x,p]=i.useState(!1),b=i.useCallback(j=>{p(j),ne(j)},[]),[u,h]=i.useState(t),f=Kt(u,200),v=At(u,f),S=se({select:j=>j.location.pathname}),g=se({select:j=>ut(j.matches)}),[R,c]=i.useState(g);if(R!==g){const j=Rt(R,g,t);c(g),j!==void 0&&h(j)}const{data:y,isLoading:A,isError:K,error:V,refetch:Q}=Ce({...dt(),staleTime:1/0}),d=!!(y&&(y.accounts?.length??0)===0);i.useEffect(()=>{d&&s({to:"/onboarding",replace:!0})},[d,s]),kt({enabled:!r,bindings:[{key:"?",handler:()=>o(!0),noModifiers:!1,preventDefault:!0}]});const{openCompose:N}=U(),C=i.useMemo(()=>({compose:()=>N({mode:"new"})}),[N]);wt({enabled:!mt(S),handlers:C});const M=i.useCallback(j=>{h(j)},[]),w=i.useCallback(()=>{h("")},[]),E=i.useCallback(()=>{h("")},[]),q=i.useCallback(()=>{p(j=>{const Z=!j;return ne(Z),Z})},[]),k=y?.accounts??[],D=i.useMemo(()=>k.map(j=>j.accountId),[k]),Ee=gs(k),Oe=vs(k),Re=i.useMemo(()=>It(k),[k]);As(k);const Ae=i.useCallback(()=>{m(!1)},[]),Le={accounts:k,mailboxNameIndex:Ee,accountNameIndex:Re,resultFolderIndex:Oe,searchQuery:v,searchInput:u,searchViewKey:g,onSearchChange:M,onSearchClear:w,onSearchClearQuery:E,intelligenceOpen:x,onToggleIntelligence:q,onSetIntelligenceOpen:b},Pe={isSinglePane:n,isLoading:A||d,intelligenceOpen:x,nav:e.jsx(fs,{accounts:k,onMailboxSelect:Ae}),topBar:n?void 0:e.jsx(os,{accounts:k}),overlay:n?e.jsx(as,{}):void 0,navOpen:l,onOpenNav:()=>m(!0),onCloseNav:()=>m(!1)};return e.jsx(xt.Provider,{value:Le,children:e.jsxs(Dt,{accountIds:D,children:[K?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(Bt,{title:"Couldn't load your account",error:V,onRetry:()=>{Q()}})}):e.jsx(Ot,{chrome:Pe,children:e.jsx(ht,{})}),e.jsx(ps,{isOpen:r,onClose:()=>o(!1)})]})})}export{Js as component,je as useMailContext};
@@ -1 +0,0 @@
1
- import{D as i,j as o,a0 as s}from"./index-CoNvZIm_.js";import{a as m}from"./search-view-DBvRPRa1.js";import{O as t}from"./OutboxPane-DzBz96fV.js";import{u as a}from"./useSearchMirror-eiX731bE.js";import"./nav-link-7QYETm4r.js";import"./useSearchTokenContext-BnSrnFlb.js";import"./kbd-37YHrOod.js";import"./use-match-media-BezqzsJW.js";import"./enums-CCxx0t2v.js";import"./search-scope-DpxLT3gw.js";import"./circle-check-big-CBG0107E.js";import"./clock-tsMaR7Oh.js";import"./row-actions-DzYchsTL.js";import"./rotate-ccw-BozetpiQ.js";import"./NavMenuButton-DiNk3STC.js";import"./menu-B6RXxSm8.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function e(){return i({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function w(){const r=e();return a({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(s,{})})})}export{w as component};
@@ -1 +0,0 @@
1
- import{o as d}from"./rich-text-spellcheck-provider-J8m9wz6A.js";var r={en:1199414,"en-GB":1199758,nl:3180464},a=["en","en-GB","nl"];const l=()=>typeof a>"u"?[]:a,i=()=>{const e="/spellcheck/de99b00dc30674fd/";return typeof document>"u"?e:new URL(e,document.baseURI).href},p=e=>typeof r>"u"?0:r[e]??0,f=(e,t=l())=>{const n=e.toLowerCase(),o=t.find(s=>s.toLowerCase()===n);if(o)return o;const c=n.split("-")[0];return t.find(s=>s.toLowerCase().split("-")[0]===c)??null},u=e=>({post:t=>e.postMessage(t),listen:t=>e.addEventListener("message",n=>t(n.data)),fail:t=>e.addEventListener("error",n=>t(n.message)),terminate:()=>e.terminate()}),m=async e=>{const t=f(e);if(!t)return null;const n=new Worker(new URL("/assets/rich-text-spellcheck-worker-pWkhC-WR.js",import.meta.url),{type:"module"});return d(t,i(),u(n),p(t))};export{m as openSpellcheckWorker};
@@ -1 +0,0 @@
1
- import{c as A,r as u,j as m,g as V,b as I,cN as z,X as G,K as N,D as j,l as $,t as X,v as F,w as q,z as W,E as J,p as Y,o as Z,co as R}from"./index-CoNvZIm_.js";import{u as ee,b as te,S as ne}from"./search-scope-DpxLT3gw.js";import{u as L}from"./use-match-media-BezqzsJW.js";import{D as oe}from"./layout-breakpoints-BWjiUQKh.js";const Ie=A("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);const Ne=A("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),re=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Te(e){return re.filter(t=>e[t.action]!==void 0)}const se=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus next message"},{action:"focusPrevious",keys:["k"],description:"Focus previous message"},{action:"focusNext",keys:["↓"],description:"Focus next message"},{action:"focusPrevious",keys:["↑"],description:"Focus previous message"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function ie(e){for(const t of se){const n=t.hints.find(r=>r.action===e);if(n)return n.keys}}function ae(e){const t=ie(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function De(e){const t=ae(e);return t===""?"":`(${t})`}const b={action:null,nextPrefix:null,preventDefault:!1},ce={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},le={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function ue(e,t){const n=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...b,nextPrefix:t==="g"?null:t};if(e.onControl&&(n==="enter"||n===" "))return{...b,nextPrefix:t==="g"?null:t};if(r&&n==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&n==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...b,nextPrefix:t==="g"?null:t};if(n==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const a=ce[n===","?",":n]??null;return{action:a,nextPrefix:null,preventDefault:a!==null}}if(n==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const s=n==="j"||n==="arrowdown";if(s||(n==="k"||n==="arrowup"))return{action:s?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const o=le[n];if(o){const s=o.requireShift===!0,a=n.length===1&&!/[a-z0-9]/.test(n);return!s&&e.shiftKey&&!a?b:{action:o.action,nextPrefix:null,preventDefault:!0}}return b}function fe(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const de="data-message-row",pe='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function me(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(pe);return t?!t.hasAttribute(de):!1}function he({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:r,hasValue:o,chipCount:s}){const a=s-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?s===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!r||s===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function ye({key:e,repeat:t=!1,index:n,chipCount:r}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=r-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ge(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const xe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,be=({chips:e=[],onRemoveChip:t,value:n,onChange:r,onClear:o,onClearQuery:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h="sm",inputId:p,suggest:d,className:x})=>{const O=u.useId(),T=p??O,k=u.useRef(null),D=u.useRef([]),P=s??o,[K,w]=u.useState(null),C=u.useRef(void 0),[B,H]=u.useState(""),E=e.length>0;u.useEffect(()=>{w(i=>i!==null&&i>=e.length?null:i)},[e.length]),u.useEffect(()=>{const i=C.current;if(i!==void 0){if(C.current=void 0,i===null){k.current?.focus();return}D.current[i]?.focus()}});const M=u.useRef(void 0);u.useEffect(()=>{const i=d?.caret;if(!i||i===M.current)return;M.current=i;const l=k.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(i.cursor,i.cursor),d?.onCaretChange(i.cursor))});const S=i=>{d?.onCaretChange(i.selectionStart??i.value.length)},y=u.useCallback(i=>{w(i),C.current=i},[]),v=u.useCallback(i=>{const l=e[i];l&&t&&(y(ge(i,e.length)),H(`${l.label} removed`),t(l.id))},[e,t,y]),_=u.useCallback(()=>{y(null),o()},[o,y]),U=u.useCallback(i=>{const l=i.currentTarget;if(d?.onKeyDown(i))return;const g=he({key:i.key,shiftKey:i.shiftKey,repeat:i.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":i.preventDefault(),y(g.index);return;case"clearQuery":P();return;case"blur":l.blur();return;case"none":return}},[e.length,n,P,y,d]),Q=u.useCallback(i=>l=>{const g=ye({key:l.key,repeat:l.repeat,index:i,chipCount:e.length});switch(g.type!=="none"&&l.preventDefault(),g.type){case"removeChip":v(g.index);return;case"focusChip":y(g.index);return;case"focusInput":y(null);return;case"activateChip":return;case"none":return}},[e,v,y]);return u.useEffect(()=>{if(!c)return;const i=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||xe(l.target)||(l.preventDefault(),k.current?.focus())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),m.jsxs("label",{htmlFor:T,className:I("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[m.jsx(V,{className:I("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[E&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((i,l)=>m.jsx(z,{ref:g=>{D.current[l]=g},label:i.label,tone:i.tone,focused:K===l,onFocusLabel:()=>w(l),onKeyDown:Q(l),onRemove:()=>v(l)},i.id))}),m.jsx("input",{ref:k,id:T,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:K===null?0:-1,onChange:i=>{r(i.target.value),S(i.target)},onKeyDown:U,onKeyUp:i=>S(i.currentTarget),onClick:i=>S(i.currentTarget),onFocus:i=>{w(null),d?.onFocusChange?.(!0),S(i.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:E?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||E)&&f&&m.jsx("button",{type:"button",onClick:_,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:I("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:B})]})},Pe=({value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h,inputId:p,suggest:d,className:x})=>m.jsx(be,{value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a,globalFocusKey:c,showClearButton:f,size:h,inputId:p,suggest:d,className:x});function Ke({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:r=1e3}){const o=u.useRef(e);o.current=e;const s=u.useRef(null),a=u.useRef(null);u.useEffect(()=>{if(!t)return;const c=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},f=p=>{const d=ue({key:p.key,shiftKey:p.shiftKey,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,inEditable:fe(p.target),onControl:me(p.target)},s.current);if(c(),s.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{s.current=null,a.current=null},r)),d.action===null)return;const x=o.current[d.action];x&&(d.preventDefault&&p.preventDefault(),x())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",f),()=>{h.removeEventListener("keydown",f),c(),s.current=null}},[t,r,n])}const Me=({trigger:e,children:t,align:n="right"})=>{const[r,o]=u.useState(!1),s=u.useRef(null),a=u.useCallback(f=>{s.current&&!s.current.contains(f.target)&&o(!1)},[]),c=u.useCallback(f=>{f.key==="Escape"&&o(!1)},[]);return u.useEffect(()=>(r&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",c)),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",c)}),[r,a,c]),m.jsxs("div",{ref:s,className:"relative",children:[m.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o(!r)},className:N("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&m.jsx("div",{className:N("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Re=({onClick:e,disabled:t,destructive:n,children:r})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:N("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:r}),Le=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ke=({accounts:e})=>{const t=j({strict:!1}),n=$(),r=t.mailboxId,{t:o}=X("mail",{useSuspense:!1}),s=u.useCallback((c,f)=>o(c,{defaultValue:f}),[o]),a=F({queries:e.map(c=>({...q({path:{accountId:c.accountId}}),staleTime:1/0}))});if(n.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let c=0;c<e.length;c++){const f=a[c]?.data?.items;if(!f)continue;const h=f.find(d=>d.mailboxId===r);if(!h)continue;const p=W(e[c].folderAppointments);return J(h,p.get(r),s)}return null},Ae=({accounts:e})=>{const n=j({strict:!1}).mailboxId,r=F({queries:e.map(o=>({...q({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!n)return null;for(const o of r){const s=o.data?.items;if(!s)continue;const a=s.find(c=>c.mailboxId===n);if(a)return a.unseenCount}return null};function je(e){const t=Y(),{searchInput:n}=Z(),r=ke({accounts:e}),o=ee({select:c=>c.matches}),s=te(o,r),a=u.useCallback(c=>{c===ne&&t({to:"/mail/brief",search:{q:n||void 0}})},[t,n]);return{scope:s,clearScope:a}}const Fe=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=u.useCallback(o=>{const s=o.target;if(!(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable))for(const a of t){if(!(o.key.toLowerCase()===a.key.toLowerCase())||a.requireShift!==void 0&&a.requireShift!==o.shiftKey)continue;const f=o.ctrlKey||o.metaKey;if(a.requireMeta!==void 0){if(a.requireMeta!==f)continue}else{const h=a.noModifiers??!0,p=f||o.altKey||a.requireShift===void 0&&o.shiftKey;if(h&&p)continue}a.preventDefault&&o.preventDefault(),a.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),a.handler(o);return}},[t]);u.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},we=768,qe=e=>e!=="desktop",Oe=()=>{const e=L(`(min-width: ${we}px)`);return L(oe)?"desktop":e?"tablet":"phone"};function Be(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase(),o=r.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(r)||t.set(r,n.accountId)}return t}function He(e){const t=new Map;for(const n of e)for(const r of n){const o=r.fullPath?.toLowerCase();if(!o)continue;const s=o.split("/").pop();t.has(o)||t.set(o,r.mailboxId),s&&!t.has(s)&&t.set(s,r.mailboxId)}return t}function _e(e,t=[]){const n=e.flat().filter(s=>s.fullPath),r=new Map;for(const s of n){const a=R(s.fullPath).toLowerCase();r.set(a,(r.get(a)??0)+1)}const o=new Map(t.map(s=>[s.accountId,s.email]));return n.map(s=>{const a=R(s.fullPath),c=r.get(a.toLowerCase())===1,f=t.length>1?o.get(s.accountId):void 0;return{value:c?a:s.fullPath,label:s.displayNameOverride?.trim()||a,...f?{hint:f}:{}}})}function Ue(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase().split("@")[0]??"";t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=n.email.split("@")[0]??n.email,o=t.get(r.toLowerCase())===1,s=n.displayName?.trim();return{value:o?r:n.email,label:s||n.email,...s?{hint:n.email}:{}}})}export{Ie as B,Me as D,se as K,Ne as R,Pe as S,Le as a,Re as b,He as c,Oe as d,Fe as e,Ke as f,Be as g,ke as h,qe as i,Ae as j,re as k,Te as l,de as m,_e as n,Ue as o,ae as s,De as t,je as u};
@@ -1 +0,0 @@
1
- import{j as t,a0 as o}from"./index-CoNvZIm_.js";const n=()=>t.jsx(o,{});export{n as component};
@@ -1 +0,0 @@
1
- import{r as d}from"./index-CoNvZIm_.js";const r=e=>{const[i,n]=d.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return d.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=s=>n(s.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),i};export{r as u};
@@ -1 +0,0 @@
1
- import{r as m,af as b,cR as E,x as C,cS as D,cA as x,cT as F,s as M,cU as P,cV as N,cW as L,cX as T}from"./index-CoNvZIm_.js";import{u as z}from"./use-match-media-BezqzsJW.js";import{D as w}from"./layout-breakpoints-BWjiUQKh.js";const Y=()=>z(w),G=(e,t)=>{if(e.state==="Expired")return"Expired";if(e.scope!=="Temporary"||!e.expiresAt)return"Active";const r=Date.parse(e.expiresAt);return Number.isNaN(r)?"Active":r<=t?"Expired":"Active"},Z=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"})},O=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,a,i,n]=r,s=new Date(Number(a),Number(i)-1,Number(n),23,59,59,0);if(Number.isNaN(s.getTime()))return;const o=-t.getTimezoneOffset(),d=o>=0?"+":"-",c=Math.abs(o),l=String(Math.floor(c/60)).padStart(2,"0"),f=String(c%60).padStart(2,"0"),u=p=>String(p).padStart(2,"0");return`${s.getFullYear()}-${u(s.getMonth()+1)}-${u(s.getDate())}T${u(s.getHours())}:${u(s.getMinutes())}:${u(s.getSeconds())}${d}${l}:${f}`},h="None",ee=e=>!e.literalClauses.some(t=>t.field==="HasWords"),y=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),te=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",re=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?O(s??""):void 0}),S=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),_=new Set(["Complete","Failed"]),v=e=>e!==void 0&&_.has(e),R=1e3,k=15e3,J=e=>{const t=Math.max(0,e),r=R*2**t;return Math.min(r,k)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},se=e=>{const[t,r]=m.useState(),a=b({...E(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=a,n=C({...D({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return v(I)?!1:J(g.state.dataUpdateCount)}}),s=m.useCallback(g=>{e&&i({path:{accountId:e},body:y(g)})},[e,i]),{refetch:o}=n,d=m.useCallback(()=>{o()},[o]),c=n.data,l=a.isPending?void 0:c,f=l?.state??a.data?.state,u=v(l?.state),p={state:f,matchedCount:l?.matchedCount??0,appliedCount:l?.appliedCount??0,failedCount:l?.failedCount??0,errorMessage:l?.errorMessage??""};return{start:s,refreshStatus:d,progress:p,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:$(a.error,n.error,!!c)}},ae=["From","Subject","HasWords","ListId","FromDomain"],U=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ne=(e,t)=>e==="ListId"?U(t):t.trim(),Q=e=>e==="all"?"And":"Or",W=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,a=e.clauses.map(i=>({field:i.field,value:i.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:Q(e.matchOperator),literalClauses:a}},j=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=(e,t)=>{const r=W(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?O(e.until??""):void 0}},H=(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},K=350,oe=(e,t,r)=>{const a=b(x()),{mutateAsync:i}=a,n=q(t),[s,o]=m.useState(()=>({})),d=m.useRef(t);d.current=t;const c=m.useRef(n),l=j(t);return m.useEffect(()=>{if(!e||!l||n===s.previewedSignature||n===s.errorSignature)return;const f=setTimeout(()=>{const u=n;c.current=u,i({path:{accountId:e},body:y({...d.current})}).then(p=>{c.current===u&&o({count:p.matchedCount,matchedIds:p.messageIds,previewedSignature:u})}).catch(p=>{c.current===u&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:u}))})},K);return()=>clearTimeout(f)},[e,l,n,s.previewedSignature,s.errorSignature,i]),l?{count:H(s,n),matchedIds:s.previewedSignature===n?s.matchedIds??[]:[]}:{count:{status:"error",reason:F},matchedIds:[]}},A=e=>N({path:{accountId:e}}),ue=e=>{const t=C({...L({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ce=e=>{const t=M(),r=b({...P(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a,mutateAsync:i}=r,n=m.useCallback((o,d,c)=>{e&&a({path:{accountId:e},body:S(o,d,c)})},[e,a]),s=m.useCallback(async(o,d,c)=>e?i({path:{accountId:e},body:S(o,d,c)}).then(()=>!0,()=>!1):!1,[e,i]);return{createFilter:n,createFilterAsync:s,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},le=e=>{const t=M(),r=b({...T(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a}=r;return{deleteFilter:m.useCallback(n=>{e&&a({path:{accountId:e,filterId:n}})},[e,a]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}};export{h as N,ae as S,se as a,A as b,ie as c,Y as d,Z as e,G as f,ue as g,le as h,y as i,ce as j,re as k,ee as l,ne as n,te as o,O as p,W as r,oe as u};
@@ -1,67 +0,0 @@
1
- import{c3 as X,r as h,j as a,b as B,I as Y,a2 as Z,n as P,s as W,x as J,cr as H,cq as ee,ad as te,af as se,ag as re,bd as ne,e as ae,X as oe,K as C,o as ie}from"./index-CoNvZIm_.js";import{K as L}from"./kbd-37YHrOod.js";import{u as ce}from"./use-match-media-BezqzsJW.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as le,i as de}from"./search-scope-DpxLT3gw.js";const ue=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},fe=()=>`
2
- /* Zero the UA default body margin and clamp the document to the iframe width so
3
- wide author markup can't push the body (and the page) past the viewport. */
4
- html, body {
5
- margin: 0;
6
- padding: 0;
7
- max-width: 100%;
8
- }
9
- body {
10
- overflow-wrap: anywhere;
11
- word-break: break-word;
12
- }
13
- /* Media never wider than the frame; keep aspect ratio when width is capped. */
14
- img, video, iframe, svg, canvas {
15
- max-width: 100% !important;
16
- height: auto;
17
- }
18
- /* Fixed-width author tables (\`<table width="600">\`) collapse to fit. */
19
- table {
20
- max-width: 100% !important;
21
- table-layout: auto;
22
- }
23
- /* Cells carry the fixed widths in real newsletters (\`<td width="600">\`);
24
- cap them too or the table can't actually shrink. */
25
- td, th {
26
- max-width: 100% !important;
27
- }
28
- /* \`max-width\` alone can't beat an inline \`min-width\`; zeroing the min lets
29
- flex / grid / table children actually collapse to the clamped width. */
30
- * {
31
- min-width: 0;
32
- }
33
- /* Long unbroken strings (URLs, tokens) wrap instead of forcing a wide line. */
34
- pre, code {
35
- white-space: pre-wrap;
36
- overflow-wrap: anywhere;
37
- word-break: break-word;
38
- }
39
- `,me=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},he=/^(none|transparent|inherit|initial|unset)\s*$/i,ge=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},pe=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!he.test(r))return!0;s=t.exec(e)}return!1},ye=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of ge(e))if(pe(t))return!0;return!1},be=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],xe=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],we="data:image/svg+xml,"+encodeURIComponent(`
40
- <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
41
- <rect fill="#f0f0f0" width="100" height="100"/>
42
- <text x="50" y="50" text-anchor="middle" dy=".3em" fill="#999" font-size="12">
43
- Image blocked
44
- </text>
45
- </svg>
46
- `),ve=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),ke=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Ae=(e={})=>{const t=X(),s={FORBID_TAGS:be,FORBID_ATTR:xe,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const c=n.slice(4).replace(/^<|>$/g,""),f=e.resolveCid?.(c);f&&(r.setAttribute("src",f),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",we),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",ve(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=ke(o)}}),r=>{const n=ye(r),o=t.sanitize(r,s);return{html:`<style>${fe()}</style>${o}`,hasAuthorBackground:n}}},Ee='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',_={light:{fg:"oklch(0.3 0.025 235)",surface:"oklch(0.975 0.012 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",surface:"oklch(0.25 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Se=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,O='<meta name="viewport" content="width=device-width, initial-scale=1">',Te=e=>{const t=e?_.dark:_.light;return`
47
- /* Plain-email base: UI font-stack + theme-aware colors (#424) */
48
- html, body {
49
- font-family: ${Ee};
50
- font-size: 14px;
51
- line-height: 1.6;
52
- color: ${t.fg};
53
- background-color: ${t.surface};
54
- margin: 0;
55
- padding: 0;
56
- }
57
- /* Strip author unreadable text colors and element backgrounds, scoped to body
58
- descendants so the themed html/body surface above survives this reset. */
59
- body * {
60
- color: inherit !important;
61
- background-color: transparent !important;
62
- }
63
- a, a:visited {
64
- color: ${t.accent} !important;
65
- text-decoration: underline;
66
- }
67
- `},Ne=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",je=(e,t,s)=>{if(t==="plain")return`${O}<style>${Te(s)}</style>${e}`;const r=Se.test(e);return`${O}<style>${Ne(s,r)}</style>${e}`},Re=5e4,Ce=1e4,Me="(max-width: 640px)",Le=.4,Be="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),De=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Le,t/e),$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=h.useRef(null),o=h.useRef(null),[c,f]=h.useState(0),[i,l]=h.useState(0),[p,d]=h.useState(0),g=ce(Me),x=h.useMemo(()=>je(e,t,s),[e,t,s]);h.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(A=>A===b.clientWidth?A:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),h.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,Re);f(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Ce);l(S=>S===$?S:$)};let w,A;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),A=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),A?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?De(i,p):1,m=u<1,v=m?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Be,srcDoc:x,className:m?void 0:r,scrolling:"no",style:{width:v,maxWidth:m?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:m?`scale(${u})`:void 0,transformOrigin:m?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:m?r:void 0,children:m?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:f})=>{const i=h.useMemo(()=>!e||typeof document>"u"?null:Ae({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=ue(r,i?.hasAuthorBackground??!1),g=h.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:f?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:B("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Y,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function q(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class E extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},qe=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,Ge=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new E("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new E(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(Ge(t,c))throw new E("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const f=await o.text();if(qe(f,c))throw new E("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return f},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=h.useRef(null),f=W(),i=h.useRef(!1),l=h.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(m,v)=>Ve(m,v,o),refetchDescribeMessage:()=>f.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,m)=>m instanceof E&&m.reason==="not-ready"?u<We:u<1,retryDelay:(u,m)=>m instanceof E&&m.reason==="not-ready"?(i.current=!0,(m.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;h.useEffect(()=>{g&&(c.current=performance.now())},[g]),h.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},G=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=G(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,m])=>({queryKey:u,data:m}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:G(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=h.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return h.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof E?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[c,f]=h.useState(!1),{Account:i}=P();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ae,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>f(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(oe,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:f})=>{const[i,l]=h.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:m,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=h.useMemo(()=>me(e??[]),[e]),A=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",f),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",f),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!m)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:f,html:A,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),St=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(Q).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ue(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return mt(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of q(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return q(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function jt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function Rt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...le({select:r=>de(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,kt as R,dt as S,q as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,jt as g,St as h,Tt as p,Nt as r,At as s,Rt as u};