@remit/web-client-dist 0.0.331 → 0.0.332

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 (96) hide show
  1. package/assets/{BriefPane-B4OnBw7A.js → BriefPane-meTbnRq_.js} +1 -1
  2. package/assets/{ErrorState-9wFdKXpo.js → ErrorState-CP84eeS4.js} +1 -1
  3. package/assets/{FlaggedPane-VNYPSCvj.js → FlaggedPane-IYICajGH.js} +1 -1
  4. package/assets/{MailListHeader-CA5lvtZs.js → MailListHeader-BNeWjXbS.js} +3 -3
  5. package/assets/{MailViewChrome-D-68x2uE.js → MailViewChrome-CK0UL3tF.js} +1 -1
  6. package/assets/{MailboxPane-BWOjvlNs.js → MailboxPane-CzTjYvaN.js} +1 -1
  7. package/assets/{NavMenuButton-cseqHrgr.js → NavMenuButton-DPx9ykFD.js} +1 -1
  8. package/assets/{OnboardingWizard-DAdN9w-x.js → OnboardingWizard-CBWKlhoa.js} +1 -1
  9. package/assets/{OutboxPane-VocIZWXW.js → OutboxPane-DmmjVOK4.js} +1 -1
  10. package/assets/_mailboxId-BYJkaAfW.js +1 -0
  11. package/assets/_messageId-BtEX6NpF.js +1 -0
  12. package/assets/_messageId-BwXaLIXr.js +1 -0
  13. package/assets/_messageId-DSfFd4Y5.js +1 -0
  14. package/assets/_outboxMessageId-DCqQbT5L.js +1 -0
  15. package/assets/_threadId-B1c-x5uz.js +1 -0
  16. package/assets/_threadId-CIcUAt_O.js +1 -0
  17. package/assets/_threadId-CbkZUxiX.js +1 -0
  18. package/assets/{account-form-helpers-COfJkI9V.js → account-form-helpers-XEzJburQ.js} +1 -1
  19. package/assets/{accounts-CZ83UwON.js → accounts-C0uUGfxC.js} +1 -1
  20. package/assets/{advanced-CIk7-tvi.js → advanced-Bw_Q5SUK.js} +1 -1
  21. package/assets/{appearance-DamZUddD.js → appearance-Ge6rMgGP.js} +1 -1
  22. package/assets/{avatar-BvDbtKy6.js → avatar-CMYtJxZZ.js} +1 -1
  23. package/assets/{bottom-sheet-0UhJ47Gv.js → bottom-sheet-BmQ3r3Kt.js} +1 -1
  24. package/assets/{brief-JcrOpUjt.js → brief-D85x4Fq2.js} +1 -1
  25. package/assets/brief-HPf0khaG.js +1 -0
  26. package/assets/{browser-ponyfill-CU-pwafu.js → browser-ponyfill-wDabvBwu.js} +1 -1
  27. package/assets/{circle-check-Bxbx7HfB.js → circle-check-UvLERYBw.js} +1 -1
  28. package/assets/{circle-check-big-CjzecMB6.js → circle-check-big-CUB52QxG.js} +1 -1
  29. package/assets/{circle-help-BK_hzj_i.js → circle-help-B3-pp3Tw.js} +1 -1
  30. package/assets/{clock-B1X_i57Q.js → clock-BNsjbtTK.js} +1 -1
  31. package/assets/{confirm-dialog-Dh8sRH0e.js → confirm-dialog-hGtWRYMx.js} +1 -1
  32. package/assets/{download-CZ0V6I3x.js → download-Bj2mXU4p.js} +1 -1
  33. package/assets/{filters-CdfgcLH2.js → filters-CbPbaM0i.js} +1 -1
  34. package/assets/flagged-CggWch4C.js +1 -0
  35. package/assets/{flagged-DZMd8zSP.js → flagged-kNclUgtG.js} +1 -1
  36. package/assets/{folders-CWWWGsQ5.js → folders-DRxgp-Ws.js} +1 -1
  37. package/assets/index-B6poxqV9.js +1 -0
  38. package/assets/index-BtEX6NpF.js +1 -0
  39. package/assets/index-BwXaLIXr.js +1 -0
  40. package/assets/index-CYVqE127.js +1 -0
  41. package/assets/index-Db4Orizr.js +1 -0
  42. package/assets/{index-tka6wZr_.js → index-DlSYjfv9.js} +4 -4
  43. package/assets/index-iCaIEIFW.js +1 -0
  44. package/assets/index-k7NTm0Bh.js +1 -0
  45. package/assets/index-xvLNe2UC.js +1 -0
  46. package/assets/{kbd-Dt_vzEGr.js → kbd-B5JolenQ.js} +1 -1
  47. package/assets/{labels-DIFvP3py.js → labels-DIu2b8Zc.js} +1 -1
  48. package/assets/{mail-O6_yrku3.js → mail-C8dWhDfA.js} +1 -1
  49. package/assets/{menu-DAXEVDbj.js → menu-CN5pgf1i.js} +1 -1
  50. package/assets/{move-options-MgiRekSU.js → move-options-BorhqQCn.js} +1 -1
  51. package/assets/{nav-link-CBO_nghm.js → nav-link-DBuKNqpc.js} +1 -1
  52. package/assets/{onboarding-BY09gnzV.js → onboarding-BqYj_bZx.js} +1 -1
  53. package/assets/outbox-B7KFwW2N.js +1 -0
  54. package/assets/{pencil-B5Es_aSh.js → pencil-BTZvVSWp.js} +1 -1
  55. package/assets/{rich-text-DmHS1zFG.js → rich-text-C3lBGcc1.js} +1 -1
  56. package/assets/{rotate-ccw-Bez3srEV.js → rotate-ccw-D16L6_1z.js} +1 -1
  57. package/assets/{row-actions-Bqp5HmTh.js → row-actions-BBTR4yHg.js} +1 -1
  58. package/assets/{search-scope-By6SdCOd.js → search-scope-t1BGmoBc.js} +1 -1
  59. package/assets/{search-token-index-Bw0eYLiL.js → search-token-index-XSJfqZYZ.js} +1 -1
  60. package/assets/{search-view-Cv6MXaNP.js → search-view-C82Fb0dk.js} +1 -1
  61. package/assets/{senders-FBv_d32p.js → senders-D4lI6bHU.js} +1 -1
  62. package/assets/settings-B6ujzMwU.js +1 -0
  63. package/assets/{settings-screen-ClWEZnOS.js → settings-screen-_Q2ABvgj.js} +1 -1
  64. package/assets/{shield-check-C78q6yIg.js → shield-check-DTml29Qo.js} +1 -1
  65. package/assets/{suggested-vips-BFYmT1iv.js → suggested-vips-CYy1AOtW.js} +1 -1
  66. package/assets/{use-match-media-BrJFrufZ.js → use-match-media-CsNk0-Es.js} +1 -1
  67. package/assets/{useDebouncedValue-DiRlxnWS.js → useDebouncedValue-BjzB65o6.js} +1 -1
  68. package/assets/{useFilters-Cafs9rMu.js → useFilters-B4FVrA17.js} +1 -1
  69. package/assets/{useLabels-Dg_FXfB1.js → useLabels-xzgtY3PU.js} +1 -1
  70. package/assets/{useRefreshControl-BHJbdmbT.js → useRefreshControl-BV21MHjp.js} +1 -1
  71. package/assets/{useSearchMirror-Df_I-_ih.js → useSearchMirror-DG86M5do.js} +1 -1
  72. package/assets/{useSearchTokenContext-B60LlfMs.js → useSearchTokenContext-oT9DM0r3.js} +1 -1
  73. package/assets/{useSemanticSearch-ocRX-T7M.js → useSemanticSearch-Bwx7VR_O.js} +1 -1
  74. package/assets/{useSignature-BboURLQ5.js → useSignature-B_nPasvU.js} +1 -1
  75. package/index.html +1 -1
  76. package/package.json +1 -1
  77. package/assets/_mailboxId-BYy5x0wE.js +0 -1
  78. package/assets/_messageId-0tY_nYQ1.js +0 -1
  79. package/assets/_messageId-C7Dc1hnG.js +0 -1
  80. package/assets/_messageId-C8LAzwtA.js +0 -1
  81. package/assets/_outboxMessageId-BHx_kFyq.js +0 -1
  82. package/assets/_threadId-BpoqHy6Q.js +0 -1
  83. package/assets/_threadId-Dcpkewj-.js +0 -1
  84. package/assets/_threadId-QRWabVsi.js +0 -1
  85. package/assets/brief-CAe8f7q6.js +0 -1
  86. package/assets/flagged-5fgl4f2w.js +0 -1
  87. package/assets/index-B3m_6Q-7.js +0 -1
  88. package/assets/index-C7Dc1hnG.js +0 -1
  89. package/assets/index-C8LAzwtA.js +0 -1
  90. package/assets/index-CHntB8XM.js +0 -1
  91. package/assets/index-DIEk2vzA.js +0 -1
  92. package/assets/index-DdWkZUge.js +0 -1
  93. package/assets/index-DgAf2bQz.js +0 -1
  94. package/assets/index-DuJrRaFE.js +0 -1
  95. package/assets/outbox-CvxSD7ed.js +0 -1
  96. package/assets/settings-C-JiUEpC.js +0 -1
@@ -1 +1 @@
1
- import{j as r,bc as Ts,aA as _t,B as fe,S as Rs,b as Be,aB as Yt,r as l,C as Es,d as Os,aW as As,k as vt,x as tt,Z as Xt,X as Ns,p as st,s as Lt,y as zs,af as Pt,bd as Zt,be as es,I as Ds,h as Fs,T as _s,bf as Ls,bg as Ps,bh as $s,ad as ts,bi as Bs,bj as Ws,K as Ks,g as Vs,a2 as $t,bk as qs,Q as Hs,w as Us,bl as Qs,o as ss,bm as Js,H as Gs,ag as Ys,i as Xs,bn as Zs,b1 as en}from"./index-tka6wZr_.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-B60LlfMs.js";import{u as on,a as rn,R as an}from"./useRefreshControl-BHJbdmbT.js";import{C as ns,D as Pe,a as os,b as is,c as rs,j as ln,M as cn,t as as,d as dn,e as un,f as ls,g as cs,h as hn,i as fn,k as mn,l as gn,m as Vt,n as pn,o as xn,p as bn,q as vn,r as Sn,S as yn,s as Cn,v as In,w as wn,x as ds,y as jn,z as kn,A as Mn,B as Tn,E as Rn,F as En,G as On,H as An,I as Nn,J as zn,K as Dn,L as qt,N as Ht,O as Fn,P as _n,Q as Ln,R as Pn,T as $n,U as Bn,V as Wn,W as Kn,X as Vn,Y as qn,Z as Hn,_ as us,$ as Un,a0 as hs,a1 as Qn,a2 as fs,a3 as Jn,a4 as Gn}from"./MailListHeader-CA5lvtZs.js";import{S as Yn,M as Xn,a as Zn,u as eo,b as to}from"./MailViewChrome-D-68x2uE.js";import{E as ms,f as so}from"./ErrorState-9wFdKXpo.js";import{d as gs}from"./useFilters-Cafs9rMu.js";import{C as ps}from"./confirm-dialog-Dh8sRH0e.js";import{A as Bt}from"./avatar-BvDbtKy6.js";import{b as nt,c as no,d as oo}from"./format-De9HZKjg.js";import{N as io}from"./NavMenuButton-cseqHrgr.js";import{a as ro}from"./useLabels-Dg_FXfB1.js";import{L as ao,u as lo}from"./useSemanticSearch-ocRX-T7M.js";import{D as co}from"./layout-breakpoints-BWjiUQKh.js";import{u as uo}from"./use-match-media-BrJFrufZ.js";import{S as St}from"./shield-check-C78q6yIg.js";import{B as ho}from"./bottom-sheet-0UhJ47Gv.js";import{C as fo}from"./circle-help-BK_hzj_i.js";import{C as mo}from"./circle-check-Bxbx7HfB.js";import{a as go,b as po,f as xo}from"./move-options-MgiRekSU.js";import{d as xs,h as bo,j as vo,e as So}from"./search-token-index-Bw0eYLiL.js";import{M as yo}from"./enums-CCxx0t2v.js";import{r as Co}from"./intelligence-pref-C6lFpj6U.js";import{n as Io}from"./search-query-Cr_ZXBCp.js";const wo=({children:e,onRefresh:n,isRefreshing:t})=>uo(co)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),jo=e=>e===1?"message":"messages";function ko({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(_t,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(St,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${jo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(fe,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Mo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",bs=({senderTrust:e,size:n="sm",className:t})=>{const s=Mo(e,n);return s==="vip"?r.jsx(Rs,{className:Be("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Be("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function To({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:d,trustSubReason:u,senderTrust:f}=e;return r.jsxs("label",{className:Be("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ns,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?c:`message from ${o}`}`}),!s&&r.jsx(Bt,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(bs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:c}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Yt,{tone:"positive",children:[r.jsx(St,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ro=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Eo=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ut=e=>e===1?"message":"messages";function Oo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=l.useState(!1),c=Eo(e,n),a=e.messages.length,d=o?Es:Os;return r.jsxs("div",{className:Be(c!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ns,{className:"mt-0.5",checked:c==="all",indeterminate:c==="some",onChange:()=>t(e,c!=="all"),"aria-label":`${c==="all"?"Deselect":"Select"} all ${a} ${Ut(a)} from ${e.senderName}`}),r.jsx(Bt,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(bs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Yt,{tone:"positive",children:[r.jsx(St,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Ut(a)}`,r.jsx(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(To,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Wt=e=>e===1?"message":"messages",Ao=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Wt(e)}`} out of Spam to ${n} now. Nothing later.`,Ft=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function No(){return r.jsx(_t,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function zo({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[d,u]=l.useState(!1),f=n.size,g=l.useMemo(()=>Ro(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(St,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(fe,{variant:"ghost",size:"sm",icon:r.jsx(fo,{className:"size-3.5"}),onClick:()=>u(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(No,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(fe,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(Oo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(fe,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Wt(f)}`}),r.jsx(fe,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Do({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:c}){const[a,d]=l.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Ft(n,s)}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>d(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Ao(e,Ft(n,s))}),r.jsx(fe,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(fe,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Fo({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(mo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Wt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(fe,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function _o({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,d]=l.useState("review"),[u,f]=l.useState(()=>e?new Set(n.map(C=>C.id)):new Set),[g,m]=l.useState(t),[S,y]=l.useState(0),w=l.useRef(!1);l.useEffect(()=>{e&&!w.current&&(d("review"),f(new Set(n.map(C=>C.id))),m(t),y(0)),w.current=e},[e,n,t]);const T=u.size,x=C=>{f(k=>{const A=new Set(k);return A.has(C)?A.delete(C):A.add(C),A})},b=(C,k)=>{f(A=>{const O=new Set(A);for(const P of C.messages)k?O.add(P.id):O.delete(P.id);return O})},j=()=>{const C=Array.from(u);y(C.length),i(C,g),d("done")};return r.jsxs(ho,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(zo,{candidates:n,selected:u,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(C=>C.id))),onSelectNone:()=>f(new Set),onContinue:()=>d("destination"),onCancel:c}),a==="destination"&&r.jsx(Do,{count:T,folders:s,delimiter:o,destination:g,onPick:m,onMove:j,onBack:()=>d("review")}),a==="done"&&r.jsx(Fo,{count:S,destinationLabel:Ft(s,g),onClose:c})]})}const Lo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Po=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},$o=()=>{const{state:e,closeCompose:n}=vt(),t=Po(),[s,o]=l.useState(!1),{isError:i,error:c,refetch:a}=tt({...Xt(),staleTime:1/0}),d=l.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),u=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const g=Lo[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:d,children:[r.jsxs(Pe.Portal,{children:[r.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Pe.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:[r.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:g}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(ms,{title:"Couldn't load compose",error:c,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(os,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(ps,{isOpen:s,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:u,onCancel:f})]})},Bo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},vs=()=>{const{state:e,closeCompose:n}=vt(),t=gs(),{isError:s,error:o,refetch:i}=tt({...Xt(),staleTime:1/0});if(!t)return r.jsx($o,{});if(!e.isOpen)return null;const c=Bo[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:c})}),r.jsx("button",{type:"button",onClick:n,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:r.jsx(Ns,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(ms,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(os,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Wo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Ko(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Vo({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Wo),o=t.map(Ko),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const qo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),Ho=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",rs({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(is,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(_s,{className:"size-3.5"})})})]}),Uo=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",rs({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Bt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(is,{thread:e})]})};function Qo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:c,state:a}=vt(),d=st(),u=Lt(),{data:f}=tt(zs()),g=l.useMemo(()=>Vo({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Pt({...es(),onSuccess:()=>{u.invalidateQueries({queryKey:Zt()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},y=x=>{c({mode:"new",outboxMessageId:x})},w=x=>{const b=s.find(j=>j.messageId===x)?.threadId;b&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:j=>j})},T=g.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(io,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Ds,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):g.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(qo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(Ho,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:y,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Uo,{row:b,isSelected:b.id===t,onOpen:w},b.id))})]},x.id))})]})}function Jo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const f=n[d*2];u=o[d]={index:d,key:t(d),start:f,size:n[d*2+1],end:f+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,t){let s=t.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==s.length||a.some((u,f)=>s[f]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return c.updateDeps=a=>{s=a},c}function Qt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Go=(e,n)=>Math.abs(e-n)<1.01,Yo=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const zt=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Jt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Xo=e=>e,Zo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},ei=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=c=>{const{width:a,height:d}=c;n({width:Math.round(a),height:Math.round(d)})};if(o(Jt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(c=>{const a=()=>{const d=c[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Jt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},bt={passive:!0},ti=typeof window>"u"?!0:"onscrollend"in window,si=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ti;let c=0;const a=i?null:Yo(o,()=>n(c,!1),e.options.isScrollingResetDelay),d=g=>()=>{c=t(s),a?.(),n(c,g)},u=d(!0),f=d(!1);return s.addEventListener("scroll",u,bt),i&&s.addEventListener("scrollend",f,bt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",f)}},ni=(e,n)=>si(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),oi=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},ii=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ri=ii;class ai{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const c=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,f]of this.elementsCache)if(f===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xo,rangeExtractor:Zo,onChange:()=>{},measureElement:oi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const c=this.options;let a=null,d=null,u=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=c.count,S=i.count,y=this.getMeasurements(),w=m>0?((s=y[0])==null?void 0:s.key)??c.getItemKey(0):null,T=m>0?((o=y[m-1])==null?void 0:o.key)??c.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==w||i.getItemKey(S-1)!==T)){u=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const C=i.followOnAppend===!0?"auto":i.followOnAppend||null;C&&S>m&&this.isAtEnd(c.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==T)&&(d=C)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(a&&this.scrollOffset!==null){const[m,S]=a,y=this.getMeasurements(),{count:w,getItemKey:T}=this.options;let x=0;for(;x<w&&T(x)!==m;)x++;if(x<w){const b=y[x];if(b){const j=b.start+S;j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=$e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,c)=>{if(c&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=c?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!zt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,bt),i.addEventListener("touchend",a,bt),this.unsubs.push(()=>{i.removeEventListener("touchstart",c),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,c,a,d]=o;i!==null&&!a&&(zt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,c,a,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u},f)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const x=t*2;let b=this._flatMeasurements;if(!b||b.length<x){const k=new Float64Array(x);b&&m>0&&k.set(b.subarray(0,m*2)),b=k,this._flatMeasurements=b}let j;if(m===0)j=s+o;else{const k=m-1;j=b[k*2]+b[k*2+1]+u}for(let k=m;k<t;k++){const A=i(k),O=g.get(A),P=typeof O=="number"?O:this.options.estimateSize(k);b[k*2]=j,b[k*2+1]=P,j+=P+u}const C=Jo(t,b,i);return this.measurementsCache=C,C}const S=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),w=new Float64Array(a);let T=0;for(let x=0;x<m;x++){const b=S[x];b&&(y[b.lane]===void 0&&T++,y[b.lane]=x,w[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),j=this.laneAssignments.get(x);let C,k;const A=d==="estimate"||g.has(b);if(j!==void 0&&this.options.lanes>1){C=j;const U=y[C],B=U!==void 0?S[U]:void 0;k=B?B.end+u:s+o}else if(T===a){let U=0,B=w[0],z=y[0];for(let Q=1;Q<a;Q++){const se=w[Q];(se<B||se===B&&y[Q]<z)&&(U=Q,B=se,z=y[Q])}C=U,k=B+u,A&&this.laneAssignments.set(x,C)}else C=x%this.options.lanes,k=s+o,A&&this.laneAssignments.set(x,C);const O=g.get(b),P=typeof O=="number"?O:this.options.estimateSize(x),D=k+P;S[x]={index:x,start:k,size:P,end:D,key:b,lane:C},y[C]===void 0&&T++,y[C]=x,w[C]=D}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ci(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,c)=>i===null||c===null?[]:t({startIndex:i,endIndex:c,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=c&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let c,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],c=u[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,c=m.size}const f=this.itemSizeCache.get(d)??c,g=s-f;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,S=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:c,end:a+c,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,c=t.length;i<c;i++){const a=t[i],d=s[a];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,c=Ss(0,s.length-1,i?a=>o[a*2]:a=>Qt(s[a]).start,t);return Qt(s[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),c=this.getScrollOffset();s==="auto"&&(s=t>=c+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),c=this.measurementsCache[t];if(!c)return;if(s==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(c.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,c.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),c=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[c,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=s.length-1;for(;c>=0&&i.some(a=>a===null);){const a=s[c];i[a.lane]===null&&(i[a.lane]=a.end),c--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(zt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Go(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Ss=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function li(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function ci(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const u=li(o,i,t);let f=u;const g=t+n;for(;f<i&&o[f*2]+o[f*2+1]<g;)f++;return{startIndex:u,endIndex:f}}let a=Ss(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(g=>g<t+n);){const g=e[d];u[g.lane]=g.end,d++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(g=>g>=t);){const g=e[a];f[g.lane]=g.start,a--}a=Math.max(0,a-a%s),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const Dt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function di({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=l.useReducer(u=>u+1,0)[1],i=l.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const c=u=>{const f=i.current;if(!f.enabled||!f.container)return;const g=u.getTotalSize();if(g!==f.lastSize){f.lastSize=g;const x=u.options.horizontal?"width":"height";f.container.style[x]=`${g}px`}const m=!!u.options.horizontal,S=f.mode==="transform",y=m?"left":"top",w=u.options.scrollMargin,T=u.getVirtualItems();for(const x of T){const b=x.start-w,j=u.elementsCache.get(x.key);j&&f.lastPositions.get(j)!==b&&(f.lastPositions.set(j,b),S?j.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:j.style[y]=`${b}px`)}},a={...s,onChange:(u,f)=>{var g;const m=i.current;let S=!0;if(m.enabled){c(u);const y=u.range,w=m.prevRange;S=!w||w.isScrolling!==u.isScrolling||w.startIndex!==y?.startIndex||w.endIndex!==y?.endIndex,S&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:u.isScrolling}:null)}S&&(e&&f?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,f)}},[d]=l.useState(()=>{const u=new ai(a);return Object.assign(u,{containerRef:f=>{const g=i.current;if(g.container=f,g.lastSize=null,f&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const S=u.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return d.setOptions(a),Dt(()=>d._didMount(),[]),Dt(()=>d._willUpdate()),Dt(()=>{c(d)}),d}function ui(e){return di({observeElementRect:ei,observeElementOffset:ni,scrollToFn:ri,...e})}const Kt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",hi=e=>`Select all ${Kt(e)}`,fi=(e,n)=>`All ${no(n)} ${Kt(e)} selected`,mi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=ln(s,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},gi=(e,n,t)=>e==="BACK"&&n&&t===void 0,pi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:as(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),xi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:f,onLongPress:g,isDesktop:m,density:S})=>r.jsx(cn,{thread:pi(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:f,onLongPress:g}}),bi=l.memo(xi),vi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:as(e.category),suspicious:n}},Si=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,onDelete:m,onToggleRead:S,density:y})=>{const[w,T]=l.useState("none"),x=st(),b=l.useCallback(O=>{navigator.vibrate?.(10),O==="trailing"?m(e.messageId):S(e.messageId,e.isRead),T("none")},[m,S,e.messageId,e.isRead]),j=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),C=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),k=l.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:O=>O})},[x,n,e.threadId,e.messageId]),A=dn(e.messageId,d);return g||u?r.jsx(bi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:A.onMouseDown,onClickCapture:A.claimClick,onContextMenu:A.onContextMenu,children:r.jsx(Yn,{thread:vi(e),selectionMode:!1,checked:!1,active:t,peek:w,onPeek:T,onToggleCheck:C,onLongPress:j,onOpen:k,onAct:b})})},yi=72,Ci=32,Ii=5,ys="remit:list-density",wi=()=>{try{const e=localStorage.getItem(ys);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},ji=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ki=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:f=!1,isMoving:g=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:y=!1,accountId:w,listTitle:T,listMeta:x,listFilter:b,listScopeLabel:j,onTriageContextChange:C,commandsRef:k,hideHeader:A=!1})=>{const O=l.useRef(null),P=st(),D=gs(),U=Ps(),{verb:B,start:z,startFromSearch:Q}=U,se=$s(),Ie=!!a?.trim(),W=un(),{labels:We}=ro(w),{pushError:le}=ts(),[M,we]=l.useState(t),[je,pe]=l.useState(),N=l.useCallback(h=>{pe(v=>v===h?v:void 0),we(h)},[]),[xe,K]=l.useState(wi),Ee=l.useCallback(()=>{K(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(ys,v)}catch{}return v})},[]),{toggleReadFor:Oe}=ls({mailboxId:e}),{junkMailboxId:me}=cs(w),Ae=ds(me,e),{selectedIds:ee,selectedCount:ne,hasSelection:oe,isSelected:R,toggle:E,select:Ne,clearSelection:V,selectRange:ie,setAnchor:J,selectAll:ot,toggleAll:Ct,intersectWith:it}=hn(),Ke=wn(ne,D),[re,te]=l.useState(null),rt=Ie&&!!d,ke=`${e}|${JSON.stringify(d??{})}`,I=fn({mailboxId:e,accountId:w,enabled:rt,predicateKey:ke,searchQuery:d??{}}),F=l.useCallback((h,v,Y)=>{if(Y.error===void 0){if(Y.cancelled){le({severity:"warning",title:gn(Y.done),detail:mn(h,Y.done,v)});return}le({severity:"info",title:Vt(h,Y.done)})}},[le]),Ve=I.phase.kind,qe=I.clear,H=l.useCallback(()=>{Ve==="escalated"&&qe(),V()},[V,qe,Ve]),[He,at]=l.useState(null),G=l.useRef(null),ce=l.useRef(!1),be=l.useRef(null),ze=!s&&n.length>0,Ue=re!==null,_=ui({count:n.length,getScrollElement:()=>O.current,estimateSize:()=>xe==="compact"?Ci:yi,overscan:Ii}),lt=t?n.findIndex(h=>h.messageId===t):-1,ae=M?n.findIndex(h=>h.messageId===M):-1,de=l.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(Ke){E(v.messageId);return}G.current=v.messageId,ce.current=!1,pe(v.messageId),we(v.messageId)},[n,Ke,E]),ue=l.useCallback(()=>{if(n.length===0)return;const h=ae<0?0:Math.min(ae+1,n.length-1);de(h)},[n.length,ae,de]),Qe=l.useCallback(()=>{if(n.length===0)return;const h=ae<=0?0:ae-1;de(h)},[n.length,ae,de]),ge=l.useCallback(()=>de(0),[de]),ct=l.useCallback(()=>de(n.length-1),[de,n.length]),Je=l.useCallback(()=>{M&&E(M)},[M,E]),$=l.useMemo(()=>n.map(h=>h.messageId),[n]),It=l.useMemo(()=>{const h=[];for(const v of n)ee.has(v.messageId)&&h.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:nt(v.sentDate)});return h},[n,ee]),dt=l.useCallback((h,v)=>v.shiftKey?(ie($,h,M),!0):v.metaKey||v.ctrlKey?(E(h),!0):(H(),J(h),!1),[$,M,ie,E,H,J]),De=l.useCallback(h=>{!u||h.length===0||(be.current=M??null,te(h))},[u,M]),Me=l.useCallback(h=>{const v=pn($,M,h);v!==void 0&&(ie($,v),G.current=v,ce.current=!1,pe(void 0),we(v))},[$,M,ie]),ve=l.useCallback(()=>Me(-1),[Me]),Ge=l.useCallback(()=>Me(1),[Me]),Fe=l.useCallback(()=>{$.length>0&&ot($)},[$,ot]),ut=l.useCallback(h=>{const v=mi({verb:h,confirmingDelete:re!==null,hasSelection:oe,junkMailboxId:me,currentMailboxId:e,deletableMessageId:u?M:void 0});return v.kind==="openWizard"?(z(h),!0):v.kind==="confirmDelete"?(De([v.messageId]),!0):v.kind==="unavailable"?(le({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[re,u,oe,me,e,z,M,De,le]),he=l.useCallback((h,v)=>{const Y=n.find(X=>X.messageId===h)?.threadId;Y&&P({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:Y,messageId:h},search:X=>X,replace:v?.replace})},[P,e,n]),Ye=l.useCallback(()=>{M&&he(M)},[M,he]),Te=l.useCallback(h=>he(h,{replace:!0}),[he]);xn({keyboardFocusedMessageId:je,openMessageId:t,enabled:D&&ne===0,open:Te});const Se=I.phase.kind==="escalated"?{scope:Kt(d??{}),total:I.phase.total,searchQuery:d??{},run:h=>I.runAction(h),stop:I.stop}:void 0,_e=l.useCallback(()=>{if(!re)return;const h=re;if(h.length===0){te(null);return}const v=new Set(h),Y=n.findIndex(Z=>v.has(Z.messageId));let X;for(let Z=Y+1;Z<n.length;Z++)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}if(X===void 0){for(let Z=Y-1;Z>=0;Z--)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}}u?.(h),H(),be.current=null,te(null),X!==void 0&&(G.current=X,ce.current=!1,N(X),D&&he(X,{replace:!0})),D||at(Vt("delete",h.length))},[re,n,u,H,he,D,N]),ye=l.useCallback(()=>{const h=be.current;be.current=null,te(null),h!==null&&(G.current=h,ce.current=!1,N(h))},[N]),Xe=l.useMemo(()=>{if(ne===0)return;const h=new Set;for(const v of n)ee.has(v.messageId)&&h.add(v.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[ne,ee,n]),wt=l.useCallback(()=>{if(Se){Q();return}z("organize")},[Se,Q,z]),jt=l.useCallback(h=>{u?.([h])},[u]),Ce=l.useCallback((h,v)=>{Oe([h],!v)},[Oe]),kt=l.useCallback(h=>{D||Ne(h)},[D,Ne]),Mt=l.useCallback(()=>{if(I.isRunning||I.phase.kind==="counting"){I.stop();return}H()},[I,H]),Tt=l.useCallback(()=>{I.clear()},[I]);l.useEffect(()=>{if(ce.current||!D&&t)return;const h=ae>=0?ae:lt;h>=0&&_.scrollToIndex(h,{align:"auto"})},[ae,lt,_,D,t]),l.useEffect(()=>{t&&(ce.current=!1,N(t))},[t,N]),l.useEffect(()=>{M&&(n.some(h=>h.messageId===M)||N(n[0]?.messageId))},[n,M,N]),l.useEffect(()=>{C?.({focusedMessageId:M,selectedIds:Array.from(ee),hasList:ze,blocksKeyboard:Ue||U.isOpen})},[M,ee,ze,Ue,U.isOpen,C]);const ht=l.useRef(C);ht.current=C,l.useEffect(()=>()=>ht.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{I.phase.kind!=="idle"||I.isRunning||it(n.map(h=>h.messageId))},[n,it,I.phase,I.isRunning]);const ft=l.useRef(e);l.useEffect(()=>{ft.current!==e&&(ft.current=e,H())},[e,H]),bn({shouldBlockFn:({action:h})=>gi(h,oe,se)?(H(),!0):!1,enableBeforeUnload:!1,disabled:!oe||se!==void 0}),l.useEffect(()=>{const h=O.current;if(!h||!S||!m)return;const v=()=>{if(y)return;const{scrollTop:Y,scrollHeight:X,clientHeight:Z}=h;Y+Z>=X-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,y,m]),l.useEffect(()=>{const h=G.current;if(!h)return;const v=O.current?.querySelector(`[data-message-id="${h}"]`);v&&(G.current=null,v.focus({preventScroll:!0}))}),l.useEffect(()=>{if(k){if(!ze){k.current=null;return}return k.current={focusNext:ue,focusPrevious:Qe,focusFirst:ge,focusLast:ct,openFocused:Ye,toggleSelect:Je,extendSelectDown:Ge,extendSelectUp:ve,selectAll:Fe,clearSelection:()=>oe?(H(),!0):!1,requestVerb:ut,toggleDensity:Ee},()=>{k.current=null}}},[k,ze,ue,Qe,ge,ct,Ye,Je,Ge,ve,Fe,oe,H,ut,Ee]);const mt=s?"loading":o?"error":n.length===0?"empty":"ready",Rt=o?so(i):void 0,Re=l.useCallback(()=>{const h=Bs(Ws());window.open(h,"_blank","noopener,noreferrer")},[]),gt=[{id:"inbox",threads:[]}],Le=$.length>0&&$.every(h=>ee.has(h)),Et=rt&&S&&Le&&!f&&!g&&I.phase.kind==="idle"&&!I.isRunning,Ot=f||g||I.isRunning,Ze=I.phase.kind==="escalated"?I.phase.total:ne,At=I.runningAction?vn(I.runningAction.kind,I.progress?.done??0,I.progress?.total??Ze):I.phase.kind==="counting"?"Counting matches…":I.phase.kind==="escalated"?fi(d??{},I.phase.total):void 0,pt=I.phase.kind!=="escalated"&&$.length>0?{checked:Le,indeterminate:ne>0&&!Le,onChange:()=>Ct($)}:void 0,Nt=I.runningAction?{value:I.progress?.done??0,max:I.progress?.total??Ze,tone:Sn(I.runningAction.kind)}:void 0,L=(I.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:I.stop}}:I.phase.kind==="escalated"&&!I.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:Tt}}:Et?{tone:"info",text:"",action:{label:hi(d??{}),onClick:I.escalate}}:void 0)??(Xe?{tone:"warning",text:Xe}:void 0),q=r.jsx(yn,{title:W.title||T,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:Ze,onCancel:Mt,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:wt,onJunk:Ae?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:w&&e&&ne>0&&We.length>0?r.jsx(ao,{accountId:w,mailboxId:e,messageIds:Array.from(ee)}):void 0,isBusy:Ot,isCounting:I.phase.kind==="counting",selectAll:pt,statusLabel:At,progress:Nt,notice:L}),js=Cn($,M),ks=l.useCallback(h=>{ce.current=!0,N(h)},[N]),Ms=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(ji,{query:a}),r.jsxs("div",{ref:O,role:"listbox","aria-multiselectable":!0,"aria-label":T,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${_.getTotalSize()}px`},children:_.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:_.measureElement,className:Ks("absolute left-0 top-0 w-full border-b border-line",I.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(Si,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:js===v.messageId,onFocusRow:ks,isChecked:R(v.messageId),onToggleCheck:E,onRowSelect:dt,isMultiSelectMode:Ke,onLongPress:kt,isDesktop:D,onDelete:jt,onToggleRead:Ce,density:xe})},h.key)})}),y&&r.jsx(Xn,{})]})]});return r.jsxs(r.Fragment,{children:[He&&!D&&r.jsx(_t,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>at(null),children:He}),r.jsx(Zn,{listTitle:T,listMeta:x,sections:gt,flatList:!0,listState:W.searchResults?"ready":mt,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:j,errorMessage:Rt,onRetry:c,onReportError:Re,density:xe,selectedThreadId:t,onSelectThread:h=>he(h),isDesktop:D,hideHeader:A,selectionBar:q,listBody:W.searchResults??(mt==="ready"?Ms:void 0)}),r.jsx(ps,{isOpen:re!==null,title:oo(re?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:_e,onCancel:ye}),r.jsx(In,{verb:B,accountId:w,mailboxId:e,selection:It,crossAccount:Xe!==void 0,escalated:Se,escalatedProgress:I.progress,onFinished:H,onRunEnded:F})]})},Mi=e=>Hs({path:{accountId:e}}),Ti=e=>{const n=Lt(),t=$t(),s=Pt({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Mi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ri=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Ti(e);return r.jsx(wo,{onRefresh:t,isRefreshing:s,children:n})};function Ei({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,c]=l.useState(!1),a=$t(),d=go(),{inboxMailboxId:u}=jn(e),f=kn(e),{data:g}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),m=l.useMemo(()=>po({mailboxes:g?.items??[],folderAppointments:f,currentMailboxId:n,translator:d}),[g?.items,f,n,d]),S=l.useMemo(()=>u||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[u,m]),y=l.useRef(!1);l.useEffect(()=>{y.current||(y.current=!0,Mn(a,t.length))},[a,t.length]);const w=l.useCallback(()=>{Tn(a,t.length),c(!0)},[a,t.length]),T=l.useCallback((x,b)=>{Rn(a,{selected:x.length,total:t.length,toInbox:b===u}),s(x,b)},[a,t.length,u,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(ko,{count:t.length,onReview:w})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(_o,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:xo(g?.items??[]),onConfirmMove:T,onCancel:()=>c(!1)})]})}const Oi="We can verify this sender";function Ai(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Oi,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ni=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},zi={unread:"unread",flagged:"starred",attachment:"attachments"},Di=new Set(Object.values(yo)),Cs=e=>Di.has(e),Fi=e=>Cs(e.category)||e.attributes.size>0,_i=e=>{const n={};Cs(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=zi[t];s&&(n[s]=!0)}return n},Li=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Pi=["category","unread","starred","attachments"],Gt=e=>JSON.stringify(Pi.map(n=>e?.[n]??null)),$i=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},Bi=(e,n)=>{const t=$i(e);return t?Gt(t)===Gt(n):!1},xt=e=>e[0],Wi=e=>{const n=xt(e.filter(a=>a.type==="from").map(a=>a.value)),t=xt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=xt(e.filter(a=>a.type==="category").map(a=>a.category)),o=xt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,c=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Ki=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Vi(e,n={}){const t=Wi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Ki(s,o))}}function qi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const Hi=50,Ui=new Map(fs().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Is=l.createContext(null);function yt(){const e=l.useContext(Is);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Qi({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,a=xs()==="desktop",d=$t(),{accounts:u,searchQuery:f,intelligenceOpen:g,onToggleIntelligence:m,onSetIntelligenceOpen:S}=ss(),y=tn(),w=Io(f),T=w.length>0,{freeText:x,tokens:b}=sn(w,y),[j,C]=l.useState("all"),[k,A]=l.useState(new Set),O=l.useMemo(()=>({category:j,attributes:k}),[j,k]),P=l.useMemo(()=>_i(O),[O]),D=T||Fi(O),{params:U,residual:B}=Vi(b,P),z={order:"desc",limit:Hi,...x?{query:x}:{},...U,...P},Q={category:z.category,unread:z.unread,starred:z.starred,attachments:z.attachments},se=D?Js({path:{mailboxId:e},query:z}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:Ie,isLoading:W,isError:We,error:le,refetch:M,fetchNextPage:we,hasNextPage:je,isFetchingNextPage:pe}=eo({queryKey:se,queryFn:async({pageParam:p})=>{if(D){const{data:q}=await Zs({path:{mailboxId:e},query:{...z,continuationToken:p},throwOnError:!0});return q}const{data:L}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:p},throwOnError:!0});return L},initialPageParam:void 0,getNextPageParam:p=>p.continuationToken,placeholderData:(p,L)=>Bi(L?.queryKey,Q)?p:void 0}),{accountId:N}=Nn(e),xe=bo({accounts:u}),K=qi(zn(Ni(Ie?.pages.flatMap(p=>p.items??[])??[])),B,N),Ee=l.useCallback(p=>{C(p)},[]),Oe=l.useCallback(p=>{A(L=>{const q=new Set(L);return q.has(p)?q.delete(p):q.add(p),q})},[]),me=l.useCallback(()=>{C("all"),A(new Set)},[]),Ae=Ui.get(j),ee=Ae?{label:Ae,reach:B.length>0?"loaded-pages":Li(z),onClear:me}:void 0,ne=o?K.find(p=>p.messageId===i)??K.find(p=>p.threadId===o):void 0,oe=Dn(o,i),R=ne??oe,E=i??R?.messageId,Ne=l.useMemo(()=>{if(o)return{threadId:o,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:E,authenticity:R?.authenticity}},[o,R,E,e]),V=l.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:p=>p})},[e,s]),ie=l.useCallback(p=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...p},search:L=>L})},[e,s]),J=l.useCallback(p=>{E&&p.includes(E)&&V()},[E,V]),{deleteMessages:ot,isPending:Ct}=qt({mailboxId:e,onAfterOptimisticRemove:J}),{moveMessages:it,isPending:Ke}=Ht({mailboxId:e,accountId:N,onAfterOptimisticRemove:J}),re=Fn(),{listCommandsRef:te,onTriageContextChange:rt,focusedMessageId:ke,selectedIds:I}=re,F=K.find(p=>p.messageId===ke)??R,Ve=l.useRef(null);l.useEffect(()=>{const p=R?.messageId??null;p&&Ve.current!==p&&R?.authenticity?.dkimMismatch&&(Ve.current=p,g||m())},[R?.messageId,R?.authenticity?.dkimMismatch,g,m]);const qe=l.useRef(!1);l.useEffect(()=>{qe.current||a&&R?.messageId&&(qe.current=!0,Co()&&!g&&S(!0))},[a,R?.messageId,g,S]);const H=vo({accounts:u})??0,He=Lt(),{pushError:at}=ts(),G=_n({thread:R,mailboxId:e,accountId:N,onAfterOptimisticRemove:J}),{draftsMailboxId:ce}=Ln(N),be=ce!==void 0&&ce===e,{archiveMailboxId:ze}=Pn(N),Ue=$n(),{requestCompose:_}=G,lt=l.useCallback(()=>{_("reply")},[_]),ae=l.useCallback(()=>{_("reply_all")},[_]),de=l.useCallback(()=>{_("forward")},[_]),{state:ue,openCompose:Qe,closeCompose:ge}=vt(),ct=l.useCallback(()=>{Qe({mode:"new"})},[Qe]),Je=l.useRef(E);l.useEffect(()=>{const p=Je.current;Je.current=E,!(!E||E===p)&&ge()},[E,ge]);const $=Pt({...es(),onError:p=>{at(Ys("Couldn't discard draft","The draft wasn't deleted.",p))}}),It=l.useCallback(()=>{const p=ue.outboxMessageId;p&&($.mutate({path:{outboxMessageId:p}}),He.invalidateQueries({queryKey:Zt()}),ge())},[ue.outboxMessageId,$,He,ge]),dt=l.useCallback(p=>p?Ue(p):[],[Ue]),{toggleStar:De}=Bn({threadId:F?.threadId??"",mailboxId:e}),{toggleReadFor:Me}=ls({mailboxId:e,accountId:N}),{junkMailboxId:ve}=cs(N),Ge=ve!=null&&ve===e,Fe=ds(ve,e),{candidates:ut}=Ai(Ge?ve:void 0),{moveMessages:he}=Ht({mailboxId:e,threadId:F?.threadId,accountId:N,onAfterOptimisticRemove:J}),{deleteMessages:Ye}=qt({mailboxId:e,threadId:F?.threadId,onAfterOptimisticRemove:J}),{addressId:Te,address:Se}=Wn(F),{updateFlags:_e}=Kn({addressId:Te,senderEmail:F?.fromEmail??void 0}),ye=l.useCallback(()=>{if(E||!ke)return!1;const p=K.find(L=>L.messageId===ke);return p?(ie({threadId:p.threadId,messageId:ke}),!0):!1},[E,ke,K,ie]),Xe=l.useCallback(()=>{ye()||R&&_("reply")},[ye,R,_]),wt=l.useCallback(()=>{ye()||R&&_("reply_all")},[ye,R,_]),jt=l.useCallback(()=>{ye()||R&&_("forward")},[ye,R,_]),Ce=l.useCallback(()=>dt(F),[dt,F]),kt=l.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const p=Ce();p.length>0&&Ye(p)},[te,Ce,Ye]),Mt=l.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const p=Ce();p.length!==0&&(Vn(d,{count:p.length,senderTrust:F?.senderTrust??"unknown",wasRescuable:F?qn(F):!1}),he(p,Fe))},[te,Fe,Ce,he,d,F]),Tt=l.useCallback(()=>{if(I.length>0){const p=!(F?.hasStars??!1),L=new Set(I);for(const q of K)L.has(q.messageId)&&q.hasStars!==p&&De(q.messageId,q.hasStars);return}F&&De(F.messageId,F.hasStars)},[I,K,F,De]),ht=l.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const p=Ce();if(p.length===0)return;const L=!(F?.isRead??!1);Me(p,L)},[te,Ce,F,Me]),ft=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.muted?.value!==!0;_e({muted:{value:p}})},[Te,Se,_e]),mt=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.vip?.value!==!0;_e({vip:{value:p}})},[Te,Se,_e]),Rt=l.useCallback(()=>{g||m()},[g,m]),Re=l.useCallback(p=>{s({to:p})},[s]),gt=be?"drafts":ze===e?"archive":ve===e?"junk":"inbox",Le=l.useRef("");l.useEffect(()=>{const p=Le.current;Le.current=w,w.length>0&&p.length===0&&d.recordEvent("search.submitted",{mailboxType:gt})},[w,gt,d]);const Et=be&&ue.isOpen&&!!ue.outboxMessageId&&!R,{goBack:Ot,nextMessageId:Ze,previousMessageId:At}=Hn({context:re,orderedIds:K.map(p=>p.messageId),selectedMessageId:E,enabled:!ue.isOpen,onClose:V,handlers:{reply:Xe,replyAll:wt,forward:jt,delete:kt,toggleStar:Tt,toggleRead:ht,muteSender:ft,blockSender:Rt,vipSender:mt,markJunk:Mt,toggleIntelligence:R?m:void 0,compose:ct,goBrief:()=>Re("/mail/brief"),goInbox:()=>Re("/mail/brief"),goSent:()=>Re("/mail/brief"),goFlagged:()=>Re("/mail/flagged"),goSettings:()=>Re("/settings")}});So({enabled:ue.isOpen,bindings:[{key:"Escape",handler:ge,preventDefault:!0}]});const pt=p=>{if(!p)return;const L=K.find(q=>q.messageId===p);return L?{threadId:L.threadId,messageId:p}:void 0},Nt={mailboxId:e,selectedMessageId:E,selectedThread:R,conversation:Ne,onOpenThread:ie,threads:K,isLoading:W,isError:We,error:le,mailboxAccountId:N,mailboxName:xe,unreadCount:H,isDraftsMailbox:be,isSpamFolder:Ge,rescueCandidates:ut,filterCategory:j,filterAttributes:k,onSelectFilterCategory:Ee,onToggleFilterAttribute:Oe,onClearFilters:me,listFilter:ee,intelligenceOpen:g,onToggleIntelligence:m,handleDeselectIfRemoved:J,searchPredicate:T&&B.length===0?z:void 0,onDeleteMessages:ot,onMoveMessages:it,isDeleting:Ct,isMoving:Ke,onLoadMore:we,hasMore:je,isLoadingMore:pe,onTriageContextChange:rt,listCommandsRef:te,onRetry:()=>M(),toolbarComposeRequest:G.composeRequest,onToolbarReply:lt,onToolbarReplyAll:ae,onToolbarForward:de,onClearComposeRequest:G.clearComposeRequest,onToolbarDelete:G.deleteThread,onToolbarStar:G.toggleStar,onToolbarDiscardDraft:It,onToolbarMove:G.moveThread,composeState:ue,closeCompose:ge,hasRemitDraftOpen:Et,onBack:Ot,nextThread:pt(Ze),previousThread:pt(At)};return r.jsx(Is.Provider,{value:Nt,children:t})}function ws(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,mailboxAccountId:S,mailboxName:y,unreadCount:w,isDraftsMailbox:T,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:j,listCommandsRef:C,onRetry:k,filterCategory:A,filterAttributes:O,onSelectFilterCategory:P,onToggleFilterAttribute:D,onClearFilters:U,listFilter:B,searchPredicate:z}=yt(),{searchQuery:Q,searchInput:se,accounts:Ie,resultFolderIndex:W}=ss(),We=xs(),le=st(),M=y??"Inbox",we=l.useMemo(()=>fs(),[]),je=l.useMemo(()=>S?[S]:[],[S]),{hasNewMail:pe}=on(),{state:N,errorMessage:xe,refresh:K}=rn(je,{onSettled:k}),Ee=l.useMemo(()=>r.jsx(an,{state:N,onRefresh:K,label:`Refresh ${M}`,errorMessage:xe,hasUpdate:pe(je)}),[N,K,M,xe,pe,je]),Oe=l.useMemo(()=>t.map(V=>Jn(V,W)),[t,W]),{hits:me,isLoading:Ae}=lo({mailboxId:e,filterCategory:A}),ee=l.useMemo(()=>Gn(me,t.map(V=>V.threadId),W),[me,t,W]),ne=l.useCallback(V=>{const ie=V.threadId??t.find(J=>J.messageId===V.id)?.threadId;ie&&le({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:V.mailboxId??e,threadId:ie,messageId:V.id},search:J=>({...J,q:se||void 0})})},[e,le,se,t]);if(T&&S)return r.jsx(Qo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:w??void 0});const oe=r.jsx(ki,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:k,searchQuery:Q,searchPredicate:z,onDeleteMessages:c,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,accountId:S,listTitle:M,listFilter:B,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:C}),R=Ie[0]?.accountId,E=We==="phone"&&R?r.jsx(Ri,{accountId:R,children:oe}):oe,Ne=x&&b.length>0&&S?r.jsx(Ei,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:E}):E;return r.jsx(to,{title:M,unreadCount:w,preset:we,selectedCategory:A,activeFilters:O,onSelectCategory:P,onToggleFilter:D,onClearFilters:U,searchResults:Oe,searchLoading:s,relatedResults:ee,relatedLoading:Ae,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:Ee,children:Ne})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:d,onToolbarReplyAll:u,onToolbarForward:f,onClearComposeRequest:g,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:y,onToolbarMove:w,composeState:T}=yt(),x=Xs()?.showIntelligencePane??!1,b=!!s,j=x&&b,C=T.isOpen&&!s?r.jsx(vs,{}):s?r.jsx(us,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?c:void 0,composeRequest:a,onComposeClose:g}):r.jsx(nn,{});return r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Qn,{hasThread:b,intelligenceOpen:j&&i,canToggleIntelligence:j,onToggleIntelligence:c,onReply:b?d:void 0,onReplyAll:b?u:void 0,onForward:b?f:void 0,canDelete:b||o,onDelete:b?m:o?y:void 0,onToggleStar:b?S:void 0,isStarred:t?.hasStars,moveContext:b&&n?{accountId:n,currentMailboxId:e,onMove:w}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:C})]})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=yt();return r.jsx(hs,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Yi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:c,onBack:a,nextThread:d,previousThread:u,composeState:f,handleDeselectIfRemoved:g}=yt();return s?r.jsxs(r.Fragment,{children:[r.jsx(us,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:c,onSwipeNext:d?()=>o(d):void 0,onSwipePrevious:u?()=>o(u):void 0,mobileIntelligenceOpen:i}),r.jsx(Un,{isOpen:i,onClose:c,ariaLabel:"Message details",side:"right",children:r.jsx(hs,{onClose:c,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:g})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(vs,{})}):r.jsx(ws,{})}const Ir=Object.assign(Qi,{List:ws,Reading:Ji,Intelligence:Gi,Phone:Yi});export{Ir as M};
1
+ import{j as r,bc as Ts,aA as _t,B as fe,S as Rs,b as Be,aB as Yt,r as l,C as Es,d as Os,aW as As,k as vt,x as tt,Z as Xt,X as Ns,p as st,s as Lt,y as zs,af as Pt,bd as Zt,be as es,I as Ds,h as Fs,T as _s,bf as Ls,bg as Ps,bh as $s,ad as ts,bi as Bs,bj as Ws,K as Ks,g as Vs,a2 as $t,bk as qs,Q as Hs,w as Us,bl as Qs,o as ss,bm as Js,H as Gs,ag as Ys,i as Xs,bn as Zs,b1 as en}from"./index-DlSYjfv9.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-oT9DM0r3.js";import{u as on,a as rn,R as an}from"./useRefreshControl-BV21MHjp.js";import{C as ns,D as Pe,a as os,b as is,c as rs,j as ln,M as cn,t as as,d as dn,e as un,f as ls,g as cs,h as hn,i as fn,k as mn,l as gn,m as Vt,n as pn,o as xn,p as bn,q as vn,r as Sn,S as yn,s as Cn,v as In,w as wn,x as ds,y as jn,z as kn,A as Mn,B as Tn,E as Rn,F as En,G as On,H as An,I as Nn,J as zn,K as Dn,L as qt,N as Ht,O as Fn,P as _n,Q as Ln,R as Pn,T as $n,U as Bn,V as Wn,W as Kn,X as Vn,Y as qn,Z as Hn,_ as us,$ as Un,a0 as hs,a1 as Qn,a2 as fs,a3 as Jn,a4 as Gn}from"./MailListHeader-BNeWjXbS.js";import{S as Yn,M as Xn,a as Zn,u as eo,b as to}from"./MailViewChrome-CK0UL3tF.js";import{E as ms,f as so}from"./ErrorState-CP84eeS4.js";import{d as gs}from"./useFilters-B4FVrA17.js";import{C as ps}from"./confirm-dialog-hGtWRYMx.js";import{A as Bt}from"./avatar-CMYtJxZZ.js";import{b as nt,c as no,d as oo}from"./format-De9HZKjg.js";import{N as io}from"./NavMenuButton-DPx9ykFD.js";import{a as ro}from"./useLabels-xzgtY3PU.js";import{L as ao,u as lo}from"./useSemanticSearch-Bwx7VR_O.js";import{D as co}from"./layout-breakpoints-BWjiUQKh.js";import{u as uo}from"./use-match-media-CsNk0-Es.js";import{S as St}from"./shield-check-DTml29Qo.js";import{B as ho}from"./bottom-sheet-BmQ3r3Kt.js";import{C as fo}from"./circle-help-B3-pp3Tw.js";import{C as mo}from"./circle-check-UvLERYBw.js";import{a as go,b as po,f as xo}from"./move-options-BorhqQCn.js";import{d as xs,h as bo,j as vo,e as So}from"./search-token-index-XSJfqZYZ.js";import{M as yo}from"./enums-CCxx0t2v.js";import{r as Co}from"./intelligence-pref-C6lFpj6U.js";import{n as Io}from"./search-query-Cr_ZXBCp.js";const wo=({children:e,onRefresh:n,isRefreshing:t})=>uo(co)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),jo=e=>e===1?"message":"messages";function ko({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(_t,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(St,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${jo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(fe,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Mo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",bs=({senderTrust:e,size:n="sm",className:t})=>{const s=Mo(e,n);return s==="vip"?r.jsx(Rs,{className:Be("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Be("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function To({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:d,trustSubReason:u,senderTrust:f}=e;return r.jsxs("label",{className:Be("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ns,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?c:`message from ${o}`}`}),!s&&r.jsx(Bt,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(bs,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:c}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Yt,{tone:"positive",children:[r.jsx(St,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ro=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Eo=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ut=e=>e===1?"message":"messages";function Oo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=l.useState(!1),c=Eo(e,n),a=e.messages.length,d=o?Es:Os;return r.jsxs("div",{className:Be(c!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ns,{className:"mt-0.5",checked:c==="all",indeterminate:c==="some",onChange:()=>t(e,c!=="all"),"aria-label":`${c==="all"?"Deselect":"Select"} all ${a} ${Ut(a)} from ${e.senderName}`}),r.jsx(Bt,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(bs,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Yt,{tone:"positive",children:[r.jsx(St,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Ut(a)}`,r.jsx(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(To,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Wt=e=>e===1?"message":"messages",Ao=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Wt(e)}`} out of Spam to ${n} now. Nothing later.`,Ft=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function No(){return r.jsx(_t,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function zo({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[d,u]=l.useState(!1),f=n.size,g=l.useMemo(()=>Ro(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(St,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(fe,{variant:"ghost",size:"sm",icon:r.jsx(fo,{className:"size-3.5"}),onClick:()=>u(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(No,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(fe,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(Oo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(fe,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Wt(f)}`}),r.jsx(fe,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Do({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:c}){const[a,d]=l.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(As,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Ft(n,s)}),r.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>d(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Ao(e,Ft(n,s))}),r.jsx(fe,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(fe,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Fo({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(mo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Wt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(fe,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function _o({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,d]=l.useState("review"),[u,f]=l.useState(()=>e?new Set(n.map(C=>C.id)):new Set),[g,m]=l.useState(t),[S,y]=l.useState(0),w=l.useRef(!1);l.useEffect(()=>{e&&!w.current&&(d("review"),f(new Set(n.map(C=>C.id))),m(t),y(0)),w.current=e},[e,n,t]);const T=u.size,x=C=>{f(k=>{const A=new Set(k);return A.has(C)?A.delete(C):A.add(C),A})},b=(C,k)=>{f(A=>{const O=new Set(A);for(const P of C.messages)k?O.add(P.id):O.delete(P.id);return O})},j=()=>{const C=Array.from(u);y(C.length),i(C,g),d("done")};return r.jsxs(ho,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(zo,{candidates:n,selected:u,onToggle:x,onToggleGroup:b,onSelectAll:()=>f(new Set(n.map(C=>C.id))),onSelectNone:()=>f(new Set),onContinue:()=>d("destination"),onCancel:c}),a==="destination"&&r.jsx(Do,{count:T,folders:s,delimiter:o,destination:g,onPick:m,onMove:j,onBack:()=>d("review")}),a==="done"&&r.jsx(Fo,{count:S,destinationLabel:Ft(s,g),onClose:c})]})}const Lo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Po=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},$o=()=>{const{state:e,closeCompose:n}=vt(),t=Po(),[s,o]=l.useState(!1),{isError:i,error:c,refetch:a}=tt({...Xt(),staleTime:1/0}),d=l.useCallback(m=>{m||(t()?o(!0):n())},[n,t]),u=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const g=Lo[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:d,children:[r.jsxs(Pe.Portal,{children:[r.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Pe.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:[r.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:g}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(ms,{title:"Couldn't load compose",error:c,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(os,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(ps,{isOpen:s,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:u,onCancel:f})]})},Bo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},vs=()=>{const{state:e,closeCompose:n}=vt(),t=gs(),{isError:s,error:o,refetch:i}=tt({...Xt(),staleTime:1/0});if(!t)return r.jsx($o,{});if(!e.isOpen)return null;const c=Bo[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:c})}),r.jsx("button",{type:"button",onClick:n,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:r.jsx(Ns,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(ms,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(os,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Wo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Ko(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Vo({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Wo),o=t.map(Ko),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const qo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),Ho=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",rs({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(is,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(_s,{className:"size-3.5"})})})]}),Uo=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Be("group",rs({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx(Bt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(is,{thread:e})]})};function Qo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:c,state:a}=vt(),d=st(),u=Lt(),{data:f}=tt(zs()),g=l.useMemo(()=>Vo({outboxMessages:f?.items??[],accountId:n,imapThreads:s}),[f?.items,n,s]),m=Pt({...es(),onSuccess:()=>{u.invalidateQueries({queryKey:Zt()})}}),S=x=>{m.mutate({path:{outboxMessageId:x}})},y=x=>{c({mode:"new",outboxMessageId:x})},w=x=>{const b=s.find(j=>j.messageId===x)?.threadId;b&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:b,messageId:x},search:j=>j})},T=g.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(io,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:T?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Ds,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):g.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(qo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(b=>x.id==="remit-drafts"?r.jsx(Ho,{row:b,isSelected:a.isOpen&&b.id===a.outboxMessageId,onOpen:y,onDelete:S,isDeleting:m.isPending},b.id):r.jsx(Uo,{row:b,isSelected:b.id===t,onOpen:w},b.id))})]},x.id))})]})}function Jo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const f=n[d*2];u=o[d]={index:d,key:t(d),start:f,size:n[d*2+1],end:f+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,t){let s=t.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==s.length||a.some((u,f)=>s[f]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return c.updateDeps=a=>{s=a},c}function Qt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Go=(e,n)=>Math.abs(e-n)<1.01,Yo=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const zt=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Jt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Xo=e=>e,Zo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},ei=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=c=>{const{width:a,height:d}=c;n({width:Math.round(a),height:Math.round(d)})};if(o(Jt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(c=>{const a=()=>{const d=c[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Jt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},bt={passive:!0},ti=typeof window>"u"?!0:"onscrollend"in window,si=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ti;let c=0;const a=i?null:Yo(o,()=>n(c,!1),e.options.isScrollingResetDelay),d=g=>()=>{c=t(s),a?.(),n(c,g)},u=d(!0),f=d(!1);return s.addEventListener("scroll",u,bt),i&&s.addEventListener("scrollend",f,bt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",f)}},ni=(e,n)=>si(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),oi=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},ii=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ri=ii;class ai{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const c=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,f]of this.elementsCache)if(f===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xo,rangeExtractor:Zo,onChange:()=>{},measureElement:oi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const S=t[m];S!==void 0&&(i[m]=S)}const c=this.options;let a=null,d=null,u=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=c.count,S=i.count,y=this.getMeasurements(),w=m>0?((s=y[0])==null?void 0:s.key)??c.getItemKey(0):null,T=m>0?((o=y[m-1])==null?void 0:o.key)??c.getItemKey(m-1):null;if(S!==m||m>0&&S>0&&(i.getItemKey(0)!==w||i.getItemKey(S-1)!==T)){u=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;j&&(a=[j.key,this.getScrollOffset()-j.start]);const C=i.followOnAppend===!0?"auto":i.followOnAppend||null;C&&S>m&&this.isAtEnd(c.scrollEndThreshold)&&(m===0||i.getItemKey(S-1)!==T)&&(d=C)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(a&&this.scrollOffset!==null){const[m,S]=a,y=this.getMeasurements(),{count:w,getItemKey:T}=this.options;let x=0;for(;x<w&&T(x)!==m;)x++;if(x<w){const b=y[x];if(b){const j=b.start+S;j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=$e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,c)=>{if(c&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=c?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!zt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,bt),i.addEventListener("touchend",a,bt),this.unsubs.push(()=>{i.removeEventListener("touchstart",c),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,c,a,d]=o;i!==null&&!a&&(zt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,c,a,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u},f)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const x of this.laneAssignments.keys())x>=t&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const x=t*2;let b=this._flatMeasurements;if(!b||b.length<x){const k=new Float64Array(x);b&&m>0&&k.set(b.subarray(0,m*2)),b=k,this._flatMeasurements=b}let j;if(m===0)j=s+o;else{const k=m-1;j=b[k*2]+b[k*2+1]+u}for(let k=m;k<t;k++){const A=i(k),O=g.get(A),P=typeof O=="number"?O:this.options.estimateSize(k);b[k*2]=j,b[k*2+1]=P,j+=P+u}const C=Jo(t,b,i);return this.measurementsCache=C,C}const S=this.measurementsCache.slice(0,m),y=new Array(a).fill(void 0),w=new Float64Array(a);let T=0;for(let x=0;x<m;x++){const b=S[x];b&&(y[b.lane]===void 0&&T++,y[b.lane]=x,w[b.lane]=b.end)}for(let x=m;x<t;x++){const b=i(x),j=this.laneAssignments.get(x);let C,k;const A=d==="estimate"||g.has(b);if(j!==void 0&&this.options.lanes>1){C=j;const U=y[C],B=U!==void 0?S[U]:void 0;k=B?B.end+u:s+o}else if(T===a){let U=0,B=w[0],z=y[0];for(let Q=1;Q<a;Q++){const se=w[Q];(se<B||se===B&&y[Q]<z)&&(U=Q,B=se,z=y[Q])}C=U,k=B+u,A&&this.laneAssignments.set(x,C)}else C=x%this.options.lanes,k=s+o,A&&this.laneAssignments.set(x,C);const O=g.get(b),P=typeof O=="number"?O:this.options.estimateSize(x),D=k+P;S[x]={index:x,start:k,size:P,end:D,key:b,lane:C},y[C]===void 0&&T++,y[C]=x,w[C]=D}return this.measurementsCache=S,S},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ci(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,c)=>i===null||c===null?[]:t({startIndex:i,endIndex:c,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=c&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let c,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],c=u[t*2+1];else{const m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,c=m.size}const f=this.itemSizeCache.get(d)??c,g=s-f;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,S=m?this.getTotalSize():0,y=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:c,end:a+c,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-S):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,c=t.length;i<c;i++){const a=t[i],d=s[a];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,c=Ss(0,s.length-1,i?a=>o[a*2]:a=>Qt(s[a]).start,t);return Qt(s[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),c=this.getScrollOffset();s==="auto"&&(s=t>=c+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),c=this.measurementsCache[t];if(!c)return;if(s==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(c.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,c.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),c=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[c,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=s.length-1;for(;c>=0&&i.some(a=>a===null);){const a=s[c];i[a.lane]===null&&(i[a.lane]=a.end),c--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(zt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Go(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Ss=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function li(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function ci(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const u=li(o,i,t);let f=u;const g=t+n;for(;f<i&&o[f*2]+o[f*2+1]<g;)f++;return{startIndex:u,endIndex:f}}let a=Ss(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(g=>g<t+n);){const g=e[d];u[g.lane]=g.end,d++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(g=>g>=t);){const g=e[a];f[g.lane]=g.start,a--}a=Math.max(0,a-a%s),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const Dt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function di({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=l.useReducer(u=>u+1,0)[1],i=l.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const c=u=>{const f=i.current;if(!f.enabled||!f.container)return;const g=u.getTotalSize();if(g!==f.lastSize){f.lastSize=g;const x=u.options.horizontal?"width":"height";f.container.style[x]=`${g}px`}const m=!!u.options.horizontal,S=f.mode==="transform",y=m?"left":"top",w=u.options.scrollMargin,T=u.getVirtualItems();for(const x of T){const b=x.start-w,j=u.elementsCache.get(x.key);j&&f.lastPositions.get(j)!==b&&(f.lastPositions.set(j,b),S?j.style.transform=m?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:j.style[y]=`${b}px`)}},a={...s,onChange:(u,f)=>{var g;const m=i.current;let S=!0;if(m.enabled){c(u);const y=u.range,w=m.prevRange;S=!w||w.isScrolling!==u.isScrolling||w.startIndex!==y?.startIndex||w.endIndex!==y?.endIndex,S&&(m.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:u.isScrolling}:null)}S&&(e&&f?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,f)}},[d]=l.useState(()=>{const u=new ai(a);return Object.assign(u,{containerRef:f=>{const g=i.current;if(g.container=f,g.lastSize=null,f&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const S=u.options.horizontal?"width":"height";f.style[S]=`${m}px`}}})});return d.setOptions(a),Dt(()=>d._didMount(),[]),Dt(()=>d._willUpdate()),Dt(()=>{c(d)}),d}function ui(e){return di({observeElementRect:ei,observeElementOffset:ni,scrollToFn:ri,...e})}const Kt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",hi=e=>`Select all ${Kt(e)}`,fi=(e,n)=>`All ${no(n)} ${Kt(e)} selected`,mi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=ln(s,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},gi=(e,n,t)=>e==="BACK"&&n&&t===void 0,pi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:as(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),xi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:f,onLongPress:g,isDesktop:m,density:S})=>r.jsx(cn,{thread:pi(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:S,isDesktop:m,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:f,onLongPress:g}}),bi=l.memo(xi),vi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:as(e.category),suspicious:n}},Si=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,onDelete:m,onToggleRead:S,density:y})=>{const[w,T]=l.useState("none"),x=st(),b=l.useCallback(O=>{navigator.vibrate?.(10),O==="trailing"?m(e.messageId):S(e.messageId,e.isRead),T("none")},[m,S,e.messageId,e.isRead]),j=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),C=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),k=l.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:O=>O})},[x,n,e.threadId,e.messageId]),A=dn(e.messageId,d);return g||u?r.jsx(bi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:g,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:A.onMouseDown,onClickCapture:A.claimClick,onContextMenu:A.onContextMenu,children:r.jsx(Yn,{thread:vi(e),selectionMode:!1,checked:!1,active:t,peek:w,onPeek:T,onToggleCheck:C,onLongPress:j,onOpen:k,onAct:b})})},yi=72,Ci=32,Ii=5,ys="remit:list-density",wi=()=>{try{const e=localStorage.getItem(ys);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},ji=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ki=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:f=!1,isMoving:g=!1,onLoadMore:m,hasMore:S=!1,isLoadingMore:y=!1,accountId:w,listTitle:T,listMeta:x,listFilter:b,listScopeLabel:j,onTriageContextChange:C,commandsRef:k,hideHeader:A=!1})=>{const O=l.useRef(null),P=st(),D=gs(),U=Ps(),{verb:B,start:z,startFromSearch:Q}=U,se=$s(),Ie=!!a?.trim(),W=un(),{labels:We}=ro(w),{pushError:le}=ts(),[M,we]=l.useState(t),[je,pe]=l.useState(),N=l.useCallback(h=>{pe(v=>v===h?v:void 0),we(h)},[]),[xe,K]=l.useState(wi),Ee=l.useCallback(()=>{K(h=>{const v=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(ys,v)}catch{}return v})},[]),{toggleReadFor:Oe}=ls({mailboxId:e}),{junkMailboxId:me}=cs(w),Ae=ds(me,e),{selectedIds:ee,selectedCount:ne,hasSelection:oe,isSelected:R,toggle:E,select:Ne,clearSelection:V,selectRange:ie,setAnchor:J,selectAll:ot,toggleAll:Ct,intersectWith:it}=hn(),Ke=wn(ne,D),[re,te]=l.useState(null),rt=Ie&&!!d,ke=`${e}|${JSON.stringify(d??{})}`,I=fn({mailboxId:e,accountId:w,enabled:rt,predicateKey:ke,searchQuery:d??{}}),F=l.useCallback((h,v,Y)=>{if(Y.error===void 0){if(Y.cancelled){le({severity:"warning",title:gn(Y.done),detail:mn(h,Y.done,v)});return}le({severity:"info",title:Vt(h,Y.done)})}},[le]),Ve=I.phase.kind,qe=I.clear,H=l.useCallback(()=>{Ve==="escalated"&&qe(),V()},[V,qe,Ve]),[He,at]=l.useState(null),G=l.useRef(null),ce=l.useRef(!1),be=l.useRef(null),ze=!s&&n.length>0,Ue=re!==null,_=ui({count:n.length,getScrollElement:()=>O.current,estimateSize:()=>xe==="compact"?Ci:yi,overscan:Ii}),lt=t?n.findIndex(h=>h.messageId===t):-1,ae=M?n.findIndex(h=>h.messageId===M):-1,de=l.useCallback(h=>{if(h<0||h>=n.length)return;const v=n[h];if(Ke){E(v.messageId);return}G.current=v.messageId,ce.current=!1,pe(v.messageId),we(v.messageId)},[n,Ke,E]),ue=l.useCallback(()=>{if(n.length===0)return;const h=ae<0?0:Math.min(ae+1,n.length-1);de(h)},[n.length,ae,de]),Qe=l.useCallback(()=>{if(n.length===0)return;const h=ae<=0?0:ae-1;de(h)},[n.length,ae,de]),ge=l.useCallback(()=>de(0),[de]),ct=l.useCallback(()=>de(n.length-1),[de,n.length]),Je=l.useCallback(()=>{M&&E(M)},[M,E]),$=l.useMemo(()=>n.map(h=>h.messageId),[n]),It=l.useMemo(()=>{const h=[];for(const v of n)ee.has(v.messageId)&&h.push({id:v.messageId,sender:v.fromName??v.fromEmail??"Unknown",email:v.fromEmail??"",subject:v.subject??"(No subject)",date:nt(v.sentDate)});return h},[n,ee]),dt=l.useCallback((h,v)=>v.shiftKey?(ie($,h,M),!0):v.metaKey||v.ctrlKey?(E(h),!0):(H(),J(h),!1),[$,M,ie,E,H,J]),De=l.useCallback(h=>{!u||h.length===0||(be.current=M??null,te(h))},[u,M]),Me=l.useCallback(h=>{const v=pn($,M,h);v!==void 0&&(ie($,v),G.current=v,ce.current=!1,pe(void 0),we(v))},[$,M,ie]),ve=l.useCallback(()=>Me(-1),[Me]),Ge=l.useCallback(()=>Me(1),[Me]),Fe=l.useCallback(()=>{$.length>0&&ot($)},[$,ot]),ut=l.useCallback(h=>{const v=mi({verb:h,confirmingDelete:re!==null,hasSelection:oe,junkMailboxId:me,currentMailboxId:e,deletableMessageId:u?M:void 0});return v.kind==="openWizard"?(z(h),!0):v.kind==="confirmDelete"?(De([v.messageId]),!0):v.kind==="unavailable"?(le({severity:"warning",title:v.reason}),!0):v.kind==="withheld"},[re,u,oe,me,e,z,M,De,le]),he=l.useCallback((h,v)=>{const Y=n.find(X=>X.messageId===h)?.threadId;Y&&P({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:Y,messageId:h},search:X=>X,replace:v?.replace})},[P,e,n]),Ye=l.useCallback(()=>{M&&he(M)},[M,he]),Te=l.useCallback(h=>he(h,{replace:!0}),[he]);xn({keyboardFocusedMessageId:je,openMessageId:t,enabled:D&&ne===0,open:Te});const Se=I.phase.kind==="escalated"?{scope:Kt(d??{}),total:I.phase.total,searchQuery:d??{},run:h=>I.runAction(h),stop:I.stop}:void 0,_e=l.useCallback(()=>{if(!re)return;const h=re;if(h.length===0){te(null);return}const v=new Set(h),Y=n.findIndex(Z=>v.has(Z.messageId));let X;for(let Z=Y+1;Z<n.length;Z++)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}if(X===void 0){for(let Z=Y-1;Z>=0;Z--)if(!v.has(n[Z].messageId)){X=n[Z].messageId;break}}u?.(h),H(),be.current=null,te(null),X!==void 0&&(G.current=X,ce.current=!1,N(X),D&&he(X,{replace:!0})),D||at(Vt("delete",h.length))},[re,n,u,H,he,D,N]),ye=l.useCallback(()=>{const h=be.current;be.current=null,te(null),h!==null&&(G.current=h,ce.current=!1,N(h))},[N]),Xe=l.useMemo(()=>{if(ne===0)return;const h=new Set;for(const v of n)ee.has(v.messageId)&&h.add(v.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[ne,ee,n]),wt=l.useCallback(()=>{if(Se){Q();return}z("organize")},[Se,Q,z]),jt=l.useCallback(h=>{u?.([h])},[u]),Ce=l.useCallback((h,v)=>{Oe([h],!v)},[Oe]),kt=l.useCallback(h=>{D||Ne(h)},[D,Ne]),Mt=l.useCallback(()=>{if(I.isRunning||I.phase.kind==="counting"){I.stop();return}H()},[I,H]),Tt=l.useCallback(()=>{I.clear()},[I]);l.useEffect(()=>{if(ce.current||!D&&t)return;const h=ae>=0?ae:lt;h>=0&&_.scrollToIndex(h,{align:"auto"})},[ae,lt,_,D,t]),l.useEffect(()=>{t&&(ce.current=!1,N(t))},[t,N]),l.useEffect(()=>{M&&(n.some(h=>h.messageId===M)||N(n[0]?.messageId))},[n,M,N]),l.useEffect(()=>{C?.({focusedMessageId:M,selectedIds:Array.from(ee),hasList:ze,blocksKeyboard:Ue||U.isOpen})},[M,ee,ze,Ue,U.isOpen,C]);const ht=l.useRef(C);ht.current=C,l.useEffect(()=>()=>ht.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{I.phase.kind!=="idle"||I.isRunning||it(n.map(h=>h.messageId))},[n,it,I.phase,I.isRunning]);const ft=l.useRef(e);l.useEffect(()=>{ft.current!==e&&(ft.current=e,H())},[e,H]),bn({shouldBlockFn:({action:h})=>gi(h,oe,se)?(H(),!0):!1,enableBeforeUnload:!1,disabled:!oe||se!==void 0}),l.useEffect(()=>{const h=O.current;if(!h||!S||!m)return;const v=()=>{if(y)return;const{scrollTop:Y,scrollHeight:X,clientHeight:Z}=h;Y+Z>=X-200&&m()};return h.addEventListener("scroll",v,{passive:!0}),v(),()=>h.removeEventListener("scroll",v)},[S,y,m]),l.useEffect(()=>{const h=G.current;if(!h)return;const v=O.current?.querySelector(`[data-message-id="${h}"]`);v&&(G.current=null,v.focus({preventScroll:!0}))}),l.useEffect(()=>{if(k){if(!ze){k.current=null;return}return k.current={focusNext:ue,focusPrevious:Qe,focusFirst:ge,focusLast:ct,openFocused:Ye,toggleSelect:Je,extendSelectDown:Ge,extendSelectUp:ve,selectAll:Fe,clearSelection:()=>oe?(H(),!0):!1,requestVerb:ut,toggleDensity:Ee},()=>{k.current=null}}},[k,ze,ue,Qe,ge,ct,Ye,Je,Ge,ve,Fe,oe,H,ut,Ee]);const mt=s?"loading":o?"error":n.length===0?"empty":"ready",Rt=o?so(i):void 0,Re=l.useCallback(()=>{const h=Bs(Ws());window.open(h,"_blank","noopener,noreferrer")},[]),gt=[{id:"inbox",threads:[]}],Le=$.length>0&&$.every(h=>ee.has(h)),Et=rt&&S&&Le&&!f&&!g&&I.phase.kind==="idle"&&!I.isRunning,Ot=f||g||I.isRunning,Ze=I.phase.kind==="escalated"?I.phase.total:ne,At=I.runningAction?vn(I.runningAction.kind,I.progress?.done??0,I.progress?.total??Ze):I.phase.kind==="counting"?"Counting matches…":I.phase.kind==="escalated"?fi(d??{},I.phase.total):void 0,pt=I.phase.kind!=="escalated"&&$.length>0?{checked:Le,indeterminate:ne>0&&!Le,onChange:()=>Ct($)}:void 0,Nt=I.runningAction?{value:I.progress?.done??0,max:I.progress?.total??Ze,tone:Sn(I.runningAction.kind)}:void 0,L=(I.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:I.stop}}:I.phase.kind==="escalated"&&!I.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:Tt}}:Et?{tone:"info",text:"",action:{label:hi(d??{}),onClick:I.escalate}}:void 0)??(Xe?{tone:"warning",text:Xe}:void 0),q=r.jsx(yn,{title:W.title||T,navSlot:W.navSlot,titleMeta:W.titleMeta,searchSlot:W.searchSlot,searchField:W.searchField,idleSlot:W.makeFilterSlot,count:Ze,onCancel:Mt,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:wt,onJunk:Ae?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:w&&e&&ne>0&&We.length>0?r.jsx(ao,{accountId:w,mailboxId:e,messageIds:Array.from(ee)}):void 0,isBusy:Ot,isCounting:I.phase.kind==="counting",selectAll:pt,statusLabel:At,progress:Nt,notice:L}),js=Cn($,M),ks=l.useCallback(h=>{ce.current=!0,N(h)},[N]),Ms=r.jsxs(r.Fragment,{children:[Ie&&a&&r.jsx(ji,{query:a}),r.jsxs("div",{ref:O,role:"listbox","aria-multiselectable":!0,"aria-label":T,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${_.getTotalSize()}px`},children:_.getVirtualItems().map(h=>{const v=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:_.measureElement,className:Ks("absolute left-0 top-0 w-full border-b border-line",I.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(Si,{thread:v,mailboxId:e,isSelected:t===v.messageId,isFocused:M===v.messageId,isTabStop:js===v.messageId,onFocusRow:ks,isChecked:R(v.messageId),onToggleCheck:E,onRowSelect:dt,isMultiSelectMode:Ke,onLongPress:kt,isDesktop:D,onDelete:jt,onToggleRead:Ce,density:xe})},h.key)})}),y&&r.jsx(Xn,{})]})]});return r.jsxs(r.Fragment,{children:[He&&!D&&r.jsx(_t,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>at(null),children:He}),r.jsx(Zn,{listTitle:T,listMeta:x,sections:gt,flatList:!0,listState:W.searchResults?"ready":mt,searchQuery:Ie?a:void 0,listFilter:b,listScopeLabel:j,errorMessage:Rt,onRetry:c,onReportError:Re,density:xe,selectedThreadId:t,onSelectThread:h=>he(h),isDesktop:D,hideHeader:A,selectionBar:q,listBody:W.searchResults??(mt==="ready"?Ms:void 0)}),r.jsx(ps,{isOpen:re!==null,title:oo(re?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:_e,onCancel:ye}),r.jsx(In,{verb:B,accountId:w,mailboxId:e,selection:It,crossAccount:Xe!==void 0,escalated:Se,escalatedProgress:I.progress,onFinished:H,onRunEnded:F})]})},Mi=e=>Hs({path:{accountId:e}}),Ti=e=>{const n=Lt(),t=$t(),s=Pt({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Mi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ri=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Ti(e);return r.jsx(wo,{onRefresh:t,isRefreshing:s,children:n})};function Ei({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,c]=l.useState(!1),a=$t(),d=go(),{inboxMailboxId:u}=jn(e),f=kn(e),{data:g}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),m=l.useMemo(()=>po({mailboxes:g?.items??[],folderAppointments:f,currentMailboxId:n,translator:d}),[g?.items,f,n,d]),S=l.useMemo(()=>u||(m.find(b=>b.label.toLowerCase()==="inbox")?.id??m.find(b=>!b.isCurrent)?.id??""),[u,m]),y=l.useRef(!1);l.useEffect(()=>{y.current||(y.current=!0,Mn(a,t.length))},[a,t.length]);const w=l.useCallback(()=>{Tn(a,t.length),c(!0)},[a,t.length]),T=l.useCallback((x,b)=>{Rn(a,{selected:x.length,total:t.length,toInbox:b===u}),s(x,b)},[a,t.length,u,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(ko,{count:t.length,onReview:w})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(_o,{open:i,candidates:t,defaultDestinationId:S,availableFolders:m,delimiter:xo(g?.items??[]),onConfirmMove:T,onCancel:()=>c(!1)})]})}const Oi="We can verify this sender";function Ai(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Oi,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ni=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},zi={unread:"unread",flagged:"starred",attachment:"attachments"},Di=new Set(Object.values(yo)),Cs=e=>Di.has(e),Fi=e=>Cs(e.category)||e.attributes.size>0,_i=e=>{const n={};Cs(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=zi[t];s&&(n[s]=!0)}return n},Li=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Pi=["category","unread","starred","attachments"],Gt=e=>JSON.stringify(Pi.map(n=>e?.[n]??null)),$i=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},Bi=(e,n)=>{const t=$i(e);return t?Gt(t)===Gt(n):!1},xt=e=>e[0],Wi=e=>{const n=xt(e.filter(a=>a.type==="from").map(a=>a.value)),t=xt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=xt(e.filter(a=>a.type==="category").map(a=>a.category)),o=xt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,c=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Ki=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Vi(e,n={}){const t=Wi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Ki(s,o))}}function qi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const Hi=50,Ui=new Map(fs().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Is=l.createContext(null);function yt(){const e=l.useContext(Is);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Qi({mailboxId:e,thread:n,children:t}){const s=st(),o=n?.threadId,i=n?.messageId,a=xs()==="desktop",d=$t(),{accounts:u,searchQuery:f,intelligenceOpen:g,onToggleIntelligence:m,onSetIntelligenceOpen:S}=ss(),y=tn(),w=Io(f),T=w.length>0,{freeText:x,tokens:b}=sn(w,y),[j,C]=l.useState("all"),[k,A]=l.useState(new Set),O=l.useMemo(()=>({category:j,attributes:k}),[j,k]),P=l.useMemo(()=>_i(O),[O]),D=T||Fi(O),{params:U,residual:B}=Vi(b,P),z={order:"desc",limit:Hi,...x?{query:x}:{},...U,...P},Q={category:z.category,unread:z.unread,starred:z.starred,attachments:z.attachments},se=D?Js({path:{mailboxId:e},query:z}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:Ie,isLoading:W,isError:We,error:le,refetch:M,fetchNextPage:we,hasNextPage:je,isFetchingNextPage:pe}=eo({queryKey:se,queryFn:async({pageParam:p})=>{if(D){const{data:q}=await Zs({path:{mailboxId:e},query:{...z,continuationToken:p},throwOnError:!0});return q}const{data:L}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:p},throwOnError:!0});return L},initialPageParam:void 0,getNextPageParam:p=>p.continuationToken,placeholderData:(p,L)=>Bi(L?.queryKey,Q)?p:void 0}),{accountId:N}=Nn(e),xe=bo({accounts:u}),K=qi(zn(Ni(Ie?.pages.flatMap(p=>p.items??[])??[])),B,N),Ee=l.useCallback(p=>{C(p)},[]),Oe=l.useCallback(p=>{A(L=>{const q=new Set(L);return q.has(p)?q.delete(p):q.add(p),q})},[]),me=l.useCallback(()=>{C("all"),A(new Set)},[]),Ae=Ui.get(j),ee=Ae?{label:Ae,reach:B.length>0?"loaded-pages":Li(z),onClear:me}:void 0,ne=o?K.find(p=>p.messageId===i)??K.find(p=>p.threadId===o):void 0,oe=Dn(o,i),R=ne??oe,E=i??R?.messageId,Ne=l.useMemo(()=>{if(o)return{threadId:o,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:E,authenticity:R?.authenticity}},[o,R,E,e]),V=l.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:p=>p})},[e,s]),ie=l.useCallback(p=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...p},search:L=>L})},[e,s]),J=l.useCallback(p=>{E&&p.includes(E)&&V()},[E,V]),{deleteMessages:ot,isPending:Ct}=qt({mailboxId:e,onAfterOptimisticRemove:J}),{moveMessages:it,isPending:Ke}=Ht({mailboxId:e,accountId:N,onAfterOptimisticRemove:J}),re=Fn(),{listCommandsRef:te,onTriageContextChange:rt,focusedMessageId:ke,selectedIds:I}=re,F=K.find(p=>p.messageId===ke)??R,Ve=l.useRef(null);l.useEffect(()=>{const p=R?.messageId??null;p&&Ve.current!==p&&R?.authenticity?.dkimMismatch&&(Ve.current=p,g||m())},[R?.messageId,R?.authenticity?.dkimMismatch,g,m]);const qe=l.useRef(!1);l.useEffect(()=>{qe.current||a&&R?.messageId&&(qe.current=!0,Co()&&!g&&S(!0))},[a,R?.messageId,g,S]);const H=vo({accounts:u})??0,He=Lt(),{pushError:at}=ts(),G=_n({thread:R,mailboxId:e,accountId:N,onAfterOptimisticRemove:J}),{draftsMailboxId:ce}=Ln(N),be=ce!==void 0&&ce===e,{archiveMailboxId:ze}=Pn(N),Ue=$n(),{requestCompose:_}=G,lt=l.useCallback(()=>{_("reply")},[_]),ae=l.useCallback(()=>{_("reply_all")},[_]),de=l.useCallback(()=>{_("forward")},[_]),{state:ue,openCompose:Qe,closeCompose:ge}=vt(),ct=l.useCallback(()=>{Qe({mode:"new"})},[Qe]),Je=l.useRef(E);l.useEffect(()=>{const p=Je.current;Je.current=E,!(!E||E===p)&&ge()},[E,ge]);const $=Pt({...es(),onError:p=>{at(Ys("Couldn't discard draft","The draft wasn't deleted.",p))}}),It=l.useCallback(()=>{const p=ue.outboxMessageId;p&&($.mutate({path:{outboxMessageId:p}}),He.invalidateQueries({queryKey:Zt()}),ge())},[ue.outboxMessageId,$,He,ge]),dt=l.useCallback(p=>p?Ue(p):[],[Ue]),{toggleStar:De}=Bn({threadId:F?.threadId??"",mailboxId:e}),{toggleReadFor:Me}=ls({mailboxId:e,accountId:N}),{junkMailboxId:ve}=cs(N),Ge=ve!=null&&ve===e,Fe=ds(ve,e),{candidates:ut}=Ai(Ge?ve:void 0),{moveMessages:he}=Ht({mailboxId:e,threadId:F?.threadId,accountId:N,onAfterOptimisticRemove:J}),{deleteMessages:Ye}=qt({mailboxId:e,threadId:F?.threadId,onAfterOptimisticRemove:J}),{addressId:Te,address:Se}=Wn(F),{updateFlags:_e}=Kn({addressId:Te,senderEmail:F?.fromEmail??void 0}),ye=l.useCallback(()=>{if(E||!ke)return!1;const p=K.find(L=>L.messageId===ke);return p?(ie({threadId:p.threadId,messageId:ke}),!0):!1},[E,ke,K,ie]),Xe=l.useCallback(()=>{ye()||R&&_("reply")},[ye,R,_]),wt=l.useCallback(()=>{ye()||R&&_("reply_all")},[ye,R,_]),jt=l.useCallback(()=>{ye()||R&&_("forward")},[ye,R,_]),Ce=l.useCallback(()=>dt(F),[dt,F]),kt=l.useCallback(()=>{if(te.current?.requestVerb("delete"))return;const p=Ce();p.length>0&&Ye(p)},[te,Ce,Ye]),Mt=l.useCallback(()=>{if(te.current?.requestVerb("junk")||!Fe)return;const p=Ce();p.length!==0&&(Vn(d,{count:p.length,senderTrust:F?.senderTrust??"unknown",wasRescuable:F?qn(F):!1}),he(p,Fe))},[te,Fe,Ce,he,d,F]),Tt=l.useCallback(()=>{if(I.length>0){const p=!(F?.hasStars??!1),L=new Set(I);for(const q of K)L.has(q.messageId)&&q.hasStars!==p&&De(q.messageId,q.hasStars);return}F&&De(F.messageId,F.hasStars)},[I,K,F,De]),ht=l.useCallback(()=>{if(te.current?.requestVerb("markRead"))return;const p=Ce();if(p.length===0)return;const L=!(F?.isRead??!1);Me(p,L)},[te,Ce,F,Me]),ft=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.muted?.value!==!0;_e({muted:{value:p}})},[Te,Se,_e]),mt=l.useCallback(()=>{if(!Te)return;const p=Se?.flags?.vip?.value!==!0;_e({vip:{value:p}})},[Te,Se,_e]),Rt=l.useCallback(()=>{g||m()},[g,m]),Re=l.useCallback(p=>{s({to:p})},[s]),gt=be?"drafts":ze===e?"archive":ve===e?"junk":"inbox",Le=l.useRef("");l.useEffect(()=>{const p=Le.current;Le.current=w,w.length>0&&p.length===0&&d.recordEvent("search.submitted",{mailboxType:gt})},[w,gt,d]);const Et=be&&ue.isOpen&&!!ue.outboxMessageId&&!R,{goBack:Ot,nextMessageId:Ze,previousMessageId:At}=Hn({context:re,orderedIds:K.map(p=>p.messageId),selectedMessageId:E,enabled:!ue.isOpen,onClose:V,handlers:{reply:Xe,replyAll:wt,forward:jt,delete:kt,toggleStar:Tt,toggleRead:ht,muteSender:ft,blockSender:Rt,vipSender:mt,markJunk:Mt,toggleIntelligence:R?m:void 0,compose:ct,goBrief:()=>Re("/mail/brief"),goInbox:()=>Re("/mail/brief"),goSent:()=>Re("/mail/brief"),goFlagged:()=>Re("/mail/flagged"),goSettings:()=>Re("/settings")}});So({enabled:ue.isOpen,bindings:[{key:"Escape",handler:ge,preventDefault:!0}]});const pt=p=>{if(!p)return;const L=K.find(q=>q.messageId===p);return L?{threadId:L.threadId,messageId:p}:void 0},Nt={mailboxId:e,selectedMessageId:E,selectedThread:R,conversation:Ne,onOpenThread:ie,threads:K,isLoading:W,isError:We,error:le,mailboxAccountId:N,mailboxName:xe,unreadCount:H,isDraftsMailbox:be,isSpamFolder:Ge,rescueCandidates:ut,filterCategory:j,filterAttributes:k,onSelectFilterCategory:Ee,onToggleFilterAttribute:Oe,onClearFilters:me,listFilter:ee,intelligenceOpen:g,onToggleIntelligence:m,handleDeselectIfRemoved:J,searchPredicate:T&&B.length===0?z:void 0,onDeleteMessages:ot,onMoveMessages:it,isDeleting:Ct,isMoving:Ke,onLoadMore:we,hasMore:je,isLoadingMore:pe,onTriageContextChange:rt,listCommandsRef:te,onRetry:()=>M(),toolbarComposeRequest:G.composeRequest,onToolbarReply:lt,onToolbarReplyAll:ae,onToolbarForward:de,onClearComposeRequest:G.clearComposeRequest,onToolbarDelete:G.deleteThread,onToolbarStar:G.toggleStar,onToolbarDiscardDraft:It,onToolbarMove:G.moveThread,composeState:ue,closeCompose:ge,hasRemitDraftOpen:Et,onBack:Ot,nextThread:pt(Ze),previousThread:pt(At)};return r.jsx(Is.Provider,{value:Nt,children:t})}function ws(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,mailboxAccountId:S,mailboxName:y,unreadCount:w,isDraftsMailbox:T,isSpamFolder:x,rescueCandidates:b,onTriageContextChange:j,listCommandsRef:C,onRetry:k,filterCategory:A,filterAttributes:O,onSelectFilterCategory:P,onToggleFilterAttribute:D,onClearFilters:U,listFilter:B,searchPredicate:z}=yt(),{searchQuery:Q,searchInput:se,accounts:Ie,resultFolderIndex:W}=ss(),We=xs(),le=st(),M=y??"Inbox",we=l.useMemo(()=>fs(),[]),je=l.useMemo(()=>S?[S]:[],[S]),{hasNewMail:pe}=on(),{state:N,errorMessage:xe,refresh:K}=rn(je,{onSettled:k}),Ee=l.useMemo(()=>r.jsx(an,{state:N,onRefresh:K,label:`Refresh ${M}`,errorMessage:xe,hasUpdate:pe(je)}),[N,K,M,xe,pe,je]),Oe=l.useMemo(()=>t.map(V=>Jn(V,W)),[t,W]),{hits:me,isLoading:Ae}=lo({mailboxId:e,filterCategory:A}),ee=l.useMemo(()=>Gn(me,t.map(V=>V.threadId),W),[me,t,W]),ne=l.useCallback(V=>{const ie=V.threadId??t.find(J=>J.messageId===V.id)?.threadId;ie&&le({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:V.mailboxId??e,threadId:ie,messageId:V.id},search:J=>({...J,q:se||void 0})})},[e,le,se,t]);if(T&&S)return r.jsx(Qo,{mailboxId:e,accountId:S,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:w??void 0});const oe=r.jsx(ki,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:k,searchQuery:Q,searchPredicate:z,onDeleteMessages:c,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:g,isLoadingMore:m,accountId:S,listTitle:M,listFilter:B,listScopeLabel:M,hideHeader:!0,onTriageContextChange:j,commandsRef:C}),R=Ie[0]?.accountId,E=We==="phone"&&R?r.jsx(Ri,{accountId:R,children:oe}):oe,Ne=x&&b.length>0&&S?r.jsx(Ei,{accountId:S,currentMailboxId:e,candidates:b,onMove:a,children:E}):E;return r.jsx(to,{title:M,unreadCount:w,preset:we,selectedCategory:A,activeFilters:O,onSelectCategory:P,onToggleFilter:D,onClearFilters:U,searchResults:Oe,searchLoading:s,relatedResults:ee,relatedLoading:Ae,onSelectSearchResult:ne,searchResultsInBody:!0,refreshControl:Ee,children:Ne})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:d,onToolbarReplyAll:u,onToolbarForward:f,onClearComposeRequest:g,onToolbarDelete:m,onToolbarStar:S,onToolbarDiscardDraft:y,onToolbarMove:w,composeState:T}=yt(),x=Xs()?.showIntelligencePane??!1,b=!!s,j=x&&b,C=T.isOpen&&!s?r.jsx(vs,{}):s?r.jsx(us,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?c:void 0,composeRequest:a,onComposeClose:g}):r.jsx(nn,{});return r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Qn,{hasThread:b,intelligenceOpen:j&&i,canToggleIntelligence:j,onToggleIntelligence:c,onReply:b?d:void 0,onReplyAll:b?u:void 0,onForward:b?f:void 0,canDelete:b||o,onDelete:b?m:o?y:void 0,onToggleStar:b?S:void 0,isStarred:t?.hasStars,moveContext:b&&n?{accountId:n,currentMailboxId:e,onMove:w}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:C})]})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=yt();return r.jsx(hs,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Yi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:c,onBack:a,nextThread:d,previousThread:u,composeState:f,handleDeselectIfRemoved:g}=yt();return s?r.jsxs(r.Fragment,{children:[r.jsx(us,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:c,onSwipeNext:d?()=>o(d):void 0,onSwipePrevious:u?()=>o(u):void 0,mobileIntelligenceOpen:i}),r.jsx(Un,{isOpen:i,onClose:c,ariaLabel:"Message details",side:"right",children:r.jsx(hs,{onClose:c,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:g})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(vs,{})}):r.jsx(ws,{})}const Ir=Object.assign(Qi,{List:ws,Reading:Ji,Intelligence:Gi,Phone:Yi});export{Ir as M};
@@ -1 +1 @@
1
- import{i as n,j as a,B as o}from"./index-tka6wZr_.js";import{M as e}from"./menu-DAXEVDbj.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
1
+ import{i as n,j as a,B as o}from"./index-DlSYjfv9.js";import{M as e}from"./menu-CN5pgf1i.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};