@remit/web-client-dist 0.0.428 → 0.0.429
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.
- package/assets/{BriefPane-D-GPdOMS.js → BriefPane-D4GKn4Vw.js} +1 -1
- package/assets/{ErrorState-Dl0GEELQ.js → ErrorState-CNHmvGYF.js} +1 -1
- package/assets/{FlaggedPane-wgbCEfwc.js → FlaggedPane-CIICNSCS.js} +1 -1
- package/assets/{FullCompose-DTIMs9gS.js → FullCompose-B0bbns1M.js} +1 -1
- package/assets/{MailListHeader-DR-yN2Hf.js → MailListHeader-BcdPneAy.js} +1 -1
- package/assets/{MailViewChrome-g9339Xgf.js → MailViewChrome-CZb8kPr_.js} +1 -1
- package/assets/{MailboxPane-DHYO5m8m.js → MailboxPane-MXdO0Vz2.js} +1 -1
- package/assets/{NavMenuButton-DwWaQk6g.js → NavMenuButton-BIPTnOry.js} +1 -1
- package/assets/{OnboardingWizard-DF6RTQoG.js → OnboardingWizard-yfi2kykm.js} +1 -1
- package/assets/{OutboxPane-DZUVdbTt.js → OutboxPane-mFkq2dEJ.js} +1 -1
- package/assets/_mailboxId--xq6K8vG.js +1 -0
- package/assets/_messageId-CTALYmhq.js +1 -0
- package/assets/_messageId-CmMd3Ukp.js +1 -0
- package/assets/_messageId-CtxjpTtR.js +1 -0
- package/assets/_outboxMessageId-VPhQOPhK.js +1 -0
- package/assets/_threadId-1kFdcas1.js +1 -0
- package/assets/_threadId-7ZWe-9US.js +1 -0
- package/assets/_threadId-DNmSvZSP.js +1 -0
- package/assets/{accounts-CtKy1GLN.js → accounts--GnFjtNP.js} +1 -1
- package/assets/{advanced-B5VC9IBD.js → advanced-DKEc5X7D.js} +1 -1
- package/assets/{appearance-mg8j2BAS.js → appearance-Bn-KJ5jL.js} +1 -1
- package/assets/{attachment-file-C3KkdQYh.js → attachment-file-BrXH3M3V.js} +1 -1
- package/assets/{avatar-D-2LEFoL.js → avatar-DtND0ruk.js} +1 -1
- package/assets/{bottom-sheet-BkOll7uA.js → bottom-sheet-Cpg512Z8.js} +1 -1
- package/assets/{brief-mO8dyKjJ.js → brief-CP_gyoWx.js} +1 -1
- package/assets/brief-DWBpwjTi.js +1 -0
- package/assets/{browser-ponyfill-3NFCf493.js → browser-ponyfill-BQQucyWN.js} +1 -1
- package/assets/{bug-Dt2yZ_Fk.js → bug-D-5qIgn1.js} +1 -1
- package/assets/{circle-check-BLIfVelj.js → circle-check-CyTXHuU4.js} +1 -1
- package/assets/{circle-check-big-C9ITBTDG.js → circle-check-big-BCgBHZQm.js} +1 -1
- package/assets/{circle-help-5f9x6-lj.js → circle-help-lK4oidSt.js} +1 -1
- package/assets/{clock-xZuQ-ZVe.js → clock-CpWsGek7.js} +1 -1
- package/assets/compose._-_outboxMessageId_-Bh6SV1dn.js +1 -0
- package/assets/compose._-_outboxMessageId_-CYWE1jEd.js +1 -0
- package/assets/compose._-_outboxMessageId_-Cn0WCeO7.js +1 -0
- package/assets/compose._-_outboxMessageId_-SUbFIkQY.js +1 -0
- package/assets/{confirm-dialog-Bmal78Ba.js → confirm-dialog-CSNgGV-I.js} +1 -1
- package/assets/{download-Dn88dTrB.js → download-Yg8MAJuV.js} +1 -1
- package/assets/{filters-pDV8ZyuU.js → filters-BYXepTJ3.js} +1 -1
- package/assets/{flagged-BDUPuFJI.js → flagged-CPZoSWDR.js} +1 -1
- package/assets/flagged-CtM4krn0.js +1 -0
- package/assets/{folders-D1hAWqRI.js → folders-BMWrmSe-.js} +1 -1
- package/assets/{help-copy-CD2cBGh_.js → help-copy-o2bu5jXr.js} +1 -1
- package/assets/index-BaVdEvyR.js +1 -0
- package/assets/index-BgNbixl6.js +1 -0
- package/assets/index-C015CYKF.js +1 -0
- package/assets/index-Cf-KjbzP.js +1 -0
- package/assets/index-CmMd3Ukp.js +1 -0
- package/assets/index-CtxjpTtR.js +1 -0
- package/assets/{index-DGviRyWn.js → index-D_YBuI3z.js} +4 -4
- package/assets/{index-BcBoFAXO.js → index-DwTAdS0U.js} +3 -3
- package/assets/index-TQGaXC_d.js +1 -0
- package/assets/index-zMBRTYBv.js +1 -0
- package/assets/{kbd-BCSsUPEu.js → kbd-BUm8HPo9.js} +1 -1
- package/assets/{labels-BJgRD8QA.js → labels-DriP01Rs.js} +1 -1
- package/assets/{mail-75dnn1DA.js → mail-Byqd_siN.js} +1 -1
- package/assets/{mail-BEe7HAT5.js → mail-yZgIYq66.js} +1 -1
- package/assets/{menu-5xpS7t64.js → menu-B4mmeG34.js} +1 -1
- package/assets/{onboarding-BAui_QLl.js → onboarding-BbbW2CcQ.js} +1 -1
- package/assets/outbox-B7YGZwez.js +1 -0
- package/assets/{pencil-BIHmRrV0.js → pencil-rdzjE11g.js} +1 -1
- package/assets/{rich-text-D1jp8Kpt.js → rich-text-BKM0xPkp.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-_QF-EueZ.js → rich-text-spellcheck-worker-provider-Dg635-7T.js} +1 -1
- package/assets/{rotate-ccw-5HCJGdm3.js → rotate-ccw-5k3dg52M.js} +1 -1
- package/assets/{row-actions-DTPVqC-s.js → row-actions-BGPkkIDv.js} +1 -1
- package/assets/{search-scope-BZLue0kC.js → search-scope-MtY0zpRq.js} +1 -1
- package/assets/{search-token-index-Bmg9xOZ5.js → search-token-index-nAK4hI7B.js} +1 -1
- package/assets/{search-view-Ca2hqhi3.js → search-view-CtInfT0I.js} +1 -1
- package/assets/{senders-w1mzLpkj.js → senders-CRCPlNSI.js} +1 -1
- package/assets/{settings-screen-DfbrZxVv.js → settings-screen-D53GKsd_.js} +1 -1
- package/assets/settings-zuLLX00L.js +1 -0
- package/assets/{shield-check-BnrmVMGk.js → shield-check-BZ36Y5z_.js} +1 -1
- package/assets/{suggested-vips-BbvO8Bqy.js → suggested-vips-BZprt8nM.js} +1 -1
- package/assets/{useDebouncedValue-Cv_Bwb7U.js → useDebouncedValue-4E-721vu.js} +1 -1
- package/assets/{useFilters-DJL0HOst.js → useFilters-BdPFYyLi.js} +1 -1
- package/assets/{useLabels-BGCHHDKW.js → useLabels-CwcqSC09.js} +1 -1
- package/assets/{useMediaQuery-1PKuMa5G.js → useMediaQuery-CDMcFeIb.js} +1 -1
- package/assets/{useMessageBodyContent-BWMOO9Gc.js → useMessageBodyContent-DEOYO0s3.js} +1 -1
- package/assets/{useRefreshControl-CosNAILi.js → useRefreshControl-h1VyXjLX.js} +1 -1
- package/assets/{useSearchMirror-CXOffPdQ.js → useSearchMirror-rswuH5l3.js} +1 -1
- package/assets/{useSearchTokenContext-C38kzFPD.js → useSearchTokenContext-DROeO7xw.js} +1 -1
- package/assets/{useSemanticSearch-DzkahiPf.js → useSemanticSearch-RnkqtV8e.js} +1 -1
- package/assets/{useSignature-CQlGvxZ0.js → useSignature-C3CmLf8D.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/_mailboxId-BGcA7rb5.js +0 -1
- package/assets/_messageId-Bji-YuCD.js +0 -1
- package/assets/_messageId-C76VCp1m.js +0 -1
- package/assets/_messageId-CHJLnuIG.js +0 -1
- package/assets/_outboxMessageId-CTbIKoL5.js +0 -1
- package/assets/_threadId-CB3YY-5Q.js +0 -1
- package/assets/_threadId-DEw-rJeQ.js +0 -1
- package/assets/_threadId-DKWm_jQe.js +0 -1
- package/assets/brief-C-ZEQGwZ.js +0 -1
- package/assets/compose._-_outboxMessageId_-B8VsmZDC.js +0 -1
- package/assets/compose._-_outboxMessageId_-BFzsW8Vu.js +0 -1
- package/assets/compose._-_outboxMessageId_-DvHKLVqD.js +0 -1
- package/assets/compose._-_outboxMessageId_-nexn3yGf.js +0 -1
- package/assets/flagged-DNggXHcA.js +0 -1
- package/assets/index-14h2H5Ph.js +0 -1
- package/assets/index-BtBuktCA.js +0 -1
- package/assets/index-C76VCp1m.js +0 -1
- package/assets/index-CHJLnuIG.js +0 -1
- package/assets/index-CZxO2lK-.js +0 -1
- package/assets/index-DYYURDUn.js +0 -1
- package/assets/index-Ddf8e3gf.js +0 -1
- package/assets/index-UCq1yO8E.js +0 -1
- package/assets/outbox-CJSnFscb.js +0 -1
- package/assets/settings-DaGdsI-U.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,bm as Ts,as as mt,B as X,S as Ms,b as ze,at as Wt,r as c,C as Rs,d as Es,aY as As,m as Ge,n as kt,s as Tt,t as Os,a7 as Mt,bn as Ns,bo as zs,I as Fs,h as Ds,T as Kt,bp as Ls,bq as _s,br as Ps,a5 as Vt,aF as $s,aG as Bs,g as Ws,W as Rt,bs as Ks,K as qt,aV as Vs,q as qs,aW as Hs,aX as Us,bt as Qs,V as Js,bu as Gs,bv as Ys,bw as Xs,bx as Zs,by as en,l as Ht,bz as tn,z as sn,bA as nn,b6 as on}from"./index-DGviRyWn.js";import{u as rn,p as an,R as ln}from"./useSearchTokenContext-C38kzFPD.js";import{u as cn,a as dn,R as un}from"./useRefreshControl-CosNAILi.js";import{C as Ut,a as Qt,c as Jt,j as hn,M as fn,t as Gt,u as mn,b as gn,d as Yt,e as Xt,f as pn,g as xn,h as bn,r as vn,n as Sn,i as yn,k as Cn,l as In,m as jn,o as wn,S as kn,p as Tn,D as Mn,q as Rn,s as En,v as Zt,w as An,x as On,y as Nn,z as zn,A as Fn,B as es,E as Dn,F as Ln,G as _n,H as Pn,I as $n,J as Bn,K as Wn,L as Kn,N as Dt,O as Lt,P as Vn,Q as qn,R as Hn,T as Un,U as Qn,V as Jn,W as Gn,X as Yn,Y as Xn,Z as Zn,_ as eo,$ as to,a0 as ts,a1 as ss,a2 as ns,a3 as so,a4 as no,a5 as oo,a6 as os,a7 as io,a8 as ro,a9 as ao}from"./MailListHeader-DR-yN2Hf.js";import{S as lo,M as co,a as uo,u as ho,b as fo}from"./MailViewChrome-g9339Xgf.js";import{A as Et}from"./avatar-D-2LEFoL.js";import{b as Ye,d as mo,c as is}from"./format-23Av07Go.js";import{k as go,n as po,o as Xe,p as xo,r as bo,f as vo,h as So,u as yo}from"./useMessageBodyContent-BWMOO9Gc.js";import{N as Co}from"./NavMenuButton-DwWaQk6g.js";import{C as Io}from"./confirm-dialog-Bmal78Ba.js";import{f as jo}from"./ErrorState-Dl0GEELQ.js";import{a as wo}from"./useLabels-BGCHHDKW.js";import{a as ko,D as To,u as Mo}from"./useMediaQuery-1PKuMa5G.js";import{L as Ro,r as Eo,u as Ao}from"./useSemanticSearch-DzkahiPf.js";import{S as gt}from"./shield-check-BnrmVMGk.js";import{B as Oo}from"./bottom-sheet-BkOll7uA.js";import{C as No}from"./circle-help-5f9x6-lj.js";import{C as zo}from"./circle-check-BLIfVelj.js";import{j as Fo,k as Do,e as Lo,l as _o}from"./search-token-index-Bmg9xOZ5.js";import{n as Po}from"./search-query-Cr_ZXBCp.js";const $o=({children:e,onRefresh:n,isRefreshing:t})=>ko(To)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),Bo=e=>e===1?"message":"messages";function Wo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(mt,{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(gt,{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} ${Bo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(X,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",rs=({senderTrust:e,size:n="sm",className:t})=>{const s=Ko(e,n);return s==="vip"?r.jsx(Ms,{className:ze("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:ze("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 Vo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:d,trustSubReason:u,senderTrust:h}=e;return r.jsxs("label",{className:ze("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(Ut,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(Et,{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}),h&&r.jsx(rs,{senderTrust:h,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:l}),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(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const qo=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)},Ho=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},_t=e=>e===1?"message":"messages";function Uo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ho(e,n),a=e.messages.length,d=o?Rs:Es;return r.jsxs("div",{className:ze(l!=="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(Ut,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${_t(a)} from ${e.senderName}`}),r.jsx(Et,{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(rs,{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(Wt,{tone:"positive",children:[r.jsx(gt,{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} ${_t(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(Vo,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const At=e=>e===1?"message":"messages",Qo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${n} now. Nothing later.`,wt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Jo(){return r.jsx(mt,{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 Go({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[d,u]=c.useState(!1),h=n.size,g=c.useMemo(()=>qo(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(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(No,{className:"size-3.5"}),onClick:()=>u(f=>!f),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(Jo,{})})]}),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:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(X,{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(f=>r.jsx(Uo,{group:f,selected:n,onToggleGroup:s,onToggleMessage:t},f.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(X,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(X,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Yo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,d]=c.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:wt(n,s)}),r.jsx(X,{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:Qo(e,wt(n,s))}),r.jsx(X,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(X,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Xo({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(zo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(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(X,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Zo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,d]=c.useState("review"),[u,h]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[g,f]=c.useState(t),[b,y]=c.useState(0),C=c.useRef(!1);c.useEffect(()=>{e&&!C.current&&(d("review"),h(new Set(n.map(I=>I.id))),f(t),y(0)),C.current=e},[e,n,t]);const M=u.size,x=I=>{h(j=>{const O=new Set(j);return O.has(I)?O.delete(I):O.add(I),O})},p=(I,j)=>{h(O=>{const E=new Set(O);for(const N of I.messages)j?E.add(N.id):E.delete(N.id);return E})},k=()=>{const I=Array.from(u);y(I.length),i(I,g),d("done")};return r.jsxs(Oo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Go,{candidates:n,selected:u,onToggle:x,onToggleGroup:p,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Yo,{count:M,folders:s,delimiter:o,destination:g,onPick:f,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Xo,{count:b,destinationLabel:wt(s,g),onClose:l})]})}function ei(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:Ye(e.updatedAt),isRead:!0}}function ti(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function si({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(ei),o=t.map(ti),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 ni=({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})]}),oi=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:ze("group",Jt({active:n})),children:[r.jsx(Ds,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Qt,{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(Kt,{className:"size-3.5"})})})]}),ii=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:ze("group",Jt({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(Et,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Qt,{thread:e})]})};function ri({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const l=go(),a=po(),d=Ge(),u=Xe(),h=kt(),{data:g}=Tt(Os()),f=c.useMemo(()=>si({outboxMessages:g?.items??[],accountId:n,imapThreads:s}),[g?.items,n,s]),b=Mt({...zs(),onSuccess:()=>{h.invalidateQueries({queryKey:Ns()})}}),y=x=>{b.mutate({path:{outboxMessageId:x}})},C=x=>{const p=s.find(k=>k.messageId===x)?.threadId;p&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:p,messageId:x},search:k=>k,hash:u})},M=f.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(Co,{}),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:M?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{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."})]}):f.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(ni,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(p=>x.id==="remit-drafts"?r.jsx(oi,{row:p,isSelected:p.id===l,onOpen:a,onDelete:y,isDeleting:b.isPending},p.id):r.jsx(ii,{row:p,isSelected:p.id===t,onOpen:C},p.id))})]},x.id))})]})}const as=e=>e===1?"1 message":`${is(e)} messages`,ai=e=>({title:"Empty Trash?",description:`${as(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),li=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=mo(0,"unconfirmed",{trashFolderLabel:t});return{headline:o.title,body:o.description,actionLabel:o.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function ci({messageCount:e,isEmptying:n,deletedCount:t,refusalReason:s,trashFolderLabel:o,staleFolderLabel:i,onEmpty:l,onRepair:a,children:d}){const[u,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:d});const g=s?li(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,f=ai(e);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.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${as(t)} erased from the mail server.`}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:n||e<1,"aria-busy":n,onClick:()=>h(!0),children:n?"Emptying…":"Empty Trash"})]}),g&&r.jsx(mt,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(X,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:d}),r.jsx(Io,{isOpen:u,title:f.title,description:f.description,confirmLabel:f.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function di(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){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 h=n[d*2];u=o[d]={index:d,key:t(d),start:h,size:n[d*2+1],end:h+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function Ve(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((u,h)=>s[h]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Pt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const ui=(e,n)=>Math.abs(e-n)<1.01,hi=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Je;const It=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},$t=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},fi=e=>e,mi=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},gi=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:d}=l;n({width:Math.round(a),height:Math.round(d)})};if(o($t(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const d=l[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o($t(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ft={passive:!0},pi=typeof window>"u"?!0:"onscrollend"in window,xi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&πlet l=0;const a=i?null:hi(o,()=>n(l,!1),e.options.isScrollingResetDelay),d=g=>()=>{l=t(s),a?.(),n(l,g)},u=d(!0),h=d(!1);return s.addEventListener("scroll",u,ft),i&&s.addEventListener("scrollend",h,ft),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},bi=(e,n)=>xi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),vi=(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"]},Si=(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})},yi=Si;class Ci{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 l=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,h]of this.elementsCache)if(h===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));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:fi,rangeExtractor:mi,onChange:()=>{},measureElement:vi,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 f in t){const b=t[f];b!==void 0&&(i[f]=b)}const l=this.options;let a=null,d=null,u=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const f=l.count,b=i.count,y=this.getMeasurements(),C=f>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,M=f>0?((o=y[f-1])==null?void 0:o.key)??l.getItemKey(f-1):null;if(b!==f||f>0&&b>0&&(i.getItemKey(0)!==C||i.getItemKey(b-1)!==M)){u=!0;const k=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&b>f&&this.isAtEnd(l.scrollEndThreshold)&&(f===0||i.getItemKey(b-1)!==M)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[f,b]=a,y=this.getMeasurements(),{count:C,getItemKey:M}=this.options;let x=0;for(;x<C&&M(x)!==f;)x++;if(x<C){const p=y[x];if(p){const k=p.start+b;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,h=!0)}}}(h||d)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=Ve(()=>(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,l)=>{if(l&&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=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!It()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ft),i.addEventListener("touchend",a,ft),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),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,l,a,d]=o;i!==null&&!a&&(It()&&(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=Ve(()=>[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,l,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:l,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=Ve(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u},h)=>{const g=this.itemSizeCache;if(!l)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 f=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 p=this._flatMeasurements;if(!p||p.length<x){const j=new Float64Array(x);p&&f>0&&j.set(p.subarray(0,f*2)),p=j,this._flatMeasurements=p}let k;if(f===0)k=s+o;else{const j=f-1;k=p[j*2]+p[j*2+1]+u}for(let j=f;j<t;j++){const O=i(j),E=g.get(O),N=typeof E=="number"?E:this.options.estimateSize(j);p[j*2]=k,p[j*2+1]=N,k+=N+u}const I=di(t,p,i);return this.measurementsCache=I,I}const b=this.measurementsCache.slice(0,f),y=new Array(a).fill(void 0),C=new Float64Array(a);let M=0;for(let x=0;x<f;x++){const p=b[x];p&&(y[p.lane]===void 0&&M++,y[p.lane]=x,C[p.lane]=p.end)}for(let x=f;x<t;x++){const p=i(x),k=this.laneAssignments.get(x);let I,j;const O=d==="estimate"||g.has(p);if(k!==void 0&&this.options.lanes>1){I=k;const A=y[I],B=A!==void 0?b[A]:void 0;j=B?B.end+u:s+o}else if(M===a){let A=0,B=C[0],he=y[0];for(let z=1;z<a;z++){const Z=C[z];(Z<B||Z===B&&y[z]<he)&&(A=z,B=Z,he=y[z])}I=A,j=B+u,O&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,j=s+o,O&&this.laneAssignments.set(x,I);const E=g.get(p),N=typeof E=="number"?E:this.options.estimateSize(x),_=j+N;b[x]={index:x,start:j,size:N,end:_,key:p,lane:I},y[I]===void 0&&M++,y[I]=x,C[I]=_}return this.measurementsCache=b,b},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ve(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ji(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ve(()=>{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,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,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)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),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 l,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],l=u[t*2+1];else{const f=this.measurementsCache[t];if(!f)return;d=f.key,a=f.start,l=f.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const f=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,b=f?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:l,end:a+l,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++,f?this.applyScrollAdjustment(this.getTotalSize()-b):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Ve(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;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,l=ls(0,s.length-1,i?a=>o[a*2]:a=>Pt(s[a]).start,t);return Pt(s[l])},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(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+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(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(l.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"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,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[l,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{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,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}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&&(It()&&(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,l=o!==this.scrollState.lastTargetOffset;if(!l&&ui(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,l){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 ls=(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 Ii(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 ji(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=Ii(o,i,t);let h=u;const g=t+n;for(;h<i&&o[h*2]+o[h*2+1]<g;)h++;return{startIndex:u,endIndex:h}}let a=ls(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 h=Array(s).fill(t+n);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[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 jt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function wi({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(u=>u+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=u=>{const h=i.current;if(!h.enabled||!h.container)return;const g=u.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const x=u.options.horizontal?"width":"height";h.container.style[x]=`${g}px`}const f=!!u.options.horizontal,b=h.mode==="transform",y=f?"left":"top",C=u.options.scrollMargin,M=u.getVirtualItems();for(const x of M){const p=x.start-C,k=u.elementsCache.get(x.key);k&&h.lastPositions.get(k)!==p&&(h.lastPositions.set(k,p),b?k.style.transform=f?`translate3d(${p}px, 0, 0)`:`translate3d(0, ${p}px, 0)`:k.style[y]=`${p}px`)}},a={...s,onChange:(u,h)=>{var g;const f=i.current;let b=!0;if(f.enabled){l(u);const y=u.range,C=f.prevRange;b=!C||C.isScrolling!==u.isScrolling||C.startIndex!==y?.startIndex||C.endIndex!==y?.endIndex,b&&(f.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:u.isScrolling}:null)}b&&(e&&h?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new Ci(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const f=u.getTotalSize();g.lastSize=f;const b=u.options.horizontal?"width":"height";h.style[b]=`${f}px`}}})});return d.setOptions(a),jt(()=>d._didMount(),[]),jt(()=>d._willUpdate()),jt(()=>{l(d)}),d}function ki(e){return wi({observeElementRect:gi,observeElementOffset:bi,scrollToFn:yi,...e})}const Ot=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Ti=e=>`Select all ${Ot(e)}`,Mi=(e,n)=>`All ${is(n)} ${Ot(e)} selected`,Ri=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=hn(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Ei=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ai=(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Gt(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Oi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:h,onLongPress:g,isDesktop:f,density:b})=>r.jsx(fn,{thread:Ai(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:b,isDesktop:f,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Ni=c.memo(Oi),zi=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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Gt(e.category),suspicious:n}},Fi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,onDelete:f,onToggleRead:b,density:y})=>{const[C,M]=c.useState("none"),x=Ge(),p=Xe(),k=c.useCallback(N=>{navigator.vibrate?.(10),N==="trailing"?f(e.messageId):b(e.messageId,e.isRead),M("none")},[f,b,e.messageId,e.isRead]),I=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),j=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),O=c.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:N=>N,hash:p})},[x,p,n,e.threadId,e.messageId]),E=mn(e.messageId,d);return g||u?r.jsx(Ni,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(lo,{thread:zi(e),selectionMode:!1,checked:!1,active:t,peek:C,onPeek:M,onToggleCheck:j,onLongPress:I,onOpen:O,onAct:k})})},Di=72,Li=32,_i=5,cs="remit:list-density",Pi=()=>{try{const e=localStorage.getItem(cs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},$i=({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(Ws,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),Bi=(e,n,t)=>Eo(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Wi=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:h=!1,isMoving:g=!1,onLoadMore:f,hasMore:b=!1,isLoadingMore:y=!1,accountId:C,listTitle:M,listMeta:x,listFilter:p,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:O=!1})=>{const E=c.useRef(null),N=Ge(),_=Xe(),A=Mo(),B=_s(),{verb:he,start:z,startFromSearch:Z}=B,Ie=Ps(),ne=!!a?.trim(),J=gn(),{labels:Fe}=wo(C),{pushError:re}=Vt(),[T,je]=c.useState(t),[De,q]=c.useState(),H=c.useCallback(m=>{q(S=>S===m?S:void 0),je(m)},[]),[ee,Le]=c.useState(Pi),ae=c.useCallback(()=>{Le(m=>{const S=m==="comfortable"?"compact":"comfortable";try{localStorage.setItem(cs,S)}catch{}return S})},[]),{toggleReadFor:we}=Yt({mailboxId:e}),{junkMailboxId:fe}=Xt(C),_e=Zt(fe,e),W=c.useMemo(()=>[{accountId:C,mailboxId:e}],[C,e]),{outcome:L,trashIsUnconfirmed:qe,staleFolderLabel:me}=pn(W),{selectedIds:G,selectedCount:U,hasSelection:oe,isSelected:Pe,toggle:Y,select:ke,clearSelection:le,selectRange:ce,setAnchor:F,selectAll:Te,toggleAll:Me,intersectWith:$e}=xn(),R=En(U,A),[Re,ge]=c.useState(null),He=ne&&!!d,Ze=`${e}|${JSON.stringify(d??{})}`,w=bn({mailboxId:e,accountId:C,enabled:He,predicateKey:Ze,searchQuery:d??{}}),et=c.useCallback((m,S,ue)=>{const $=vn(m,S,ue,L);$&&re($)},[re,L]),Ee=w.phase.kind,tt=w.clear,D=c.useCallback(()=>{Ee==="escalated"&&tt(),le()},[le,tt,Ee]),[st,nt]=c.useState(null),pe=c.useRef(null),ie=c.useRef(!1),xe=c.useRef(null),Ae=!s&&n.length>0,be=Re!==null,ve=ki({count:n.length,getScrollElement:()=>E.current,estimateSize:()=>ee==="compact"?Li:Di,overscan:_i}),Be=t?n.findIndex(m=>m.messageId===t):-1,te=T?n.findIndex(m=>m.messageId===T):-1,se=c.useCallback(m=>{if(m<0||m>=n.length)return;const S=n[m];if(R){Y(S.messageId);return}pe.current=S.messageId,ie.current=!1,q(S.messageId),je(S.messageId)},[n,R,Y]),Ue=c.useCallback(()=>{if(n.length===0)return;const m=te<0?0:Math.min(te+1,n.length-1);se(m)},[n.length,te,se]),Se=c.useCallback(()=>{if(n.length===0)return;const m=te<=0?0:te-1;se(m)},[n.length,te,se]),Oe=c.useCallback(()=>se(0),[se]),Ne=c.useCallback(()=>se(n.length-1),[se,n.length]),ot=c.useCallback(()=>{T&&Y(T)},[T,Y]),K=c.useMemo(()=>n.map(m=>m.messageId),[n]),xt=c.useMemo(()=>{const m=[];for(const S of n)G.has(S.messageId)&&m.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Ye(S.sentDate),accountId:C});return m},[n,G,C]),ye=c.useCallback((m,S)=>S.shiftKey?(ce(K,m,T),!0):S.metaKey||S.ctrlKey?(Y(m),!0):(D(),F(m),!1),[K,T,ce,Y,D,F]),it=c.useCallback(m=>{!u||m.length===0||(xe.current=T??null,ge(m))},[u,T]),We=c.useCallback(m=>{const S=Sn(K,T,m);S!==void 0&&(ce(K,S),pe.current=S,ie.current=!1,q(void 0),je(S))},[K,T,ce]),rt=c.useCallback(()=>We(-1),[We]),at=c.useCallback(()=>We(1),[We]),lt=c.useCallback(()=>{K.length>0&&Te(K)},[K,Te]),ct=c.useCallback(m=>{const S=Ri({verb:m,confirmingDelete:Re!==null,hasSelection:oe,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:u?T:void 0});return S.kind==="openWizard"?(z(m),!0):S.kind==="confirmDelete"?(it([S.messageId]),!0):S.kind==="unavailable"?(re({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[Re,u,oe,fe,e,z,T,it,re]),de=c.useCallback((m,S)=>{const ue=n.find($=>$.messageId===m)?.threadId;ue&&N({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:ue,messageId:m},search:$=>$,hash:_,replace:S?.replace})},[N,_,e,n]),Ce=c.useCallback(()=>{T&&de(T)},[T,de]),dt=c.useCallback(m=>de(m,{replace:!0}),[de]);yn({keyboardFocusedMessageId:De,openMessageId:t,enabled:A&&U===0,open:dt});const Ke=w.phase.kind==="escalated"?{scope:Ot(d??{}),total:w.phase.total,searchQuery:d??{},run:m=>w.runAction(m),stop:w.stop}:void 0,bt=c.useCallback(m=>{if(m.length===0){ge(null);return}const S=new Set(m),ue=n.findIndex(Q=>S.has(Q.messageId));let $;for(let Q=ue+1;Q<n.length;Q++)if(!S.has(n[Q].messageId)){$=n[Q].messageId;break}if($===void 0){for(let Q=ue-1;Q>=0;Q--)if(!S.has(n[Q].messageId)){$=n[Q].messageId;break}}u?.(m),D(),xe.current=null,ge(null),$!==void 0&&(pe.current=$,ie.current=!1,H($),A&&de($,{replace:!0})),A||nt(Cn("delete",m.length,L))},[n,u,D,de,A,H,L]),vt=c.useCallback(()=>{const m=xe.current;xe.current=null,ge(null),m!==null&&(pe.current=m,ie.current=!1,H(m))},[H]),Qe=c.useMemo(()=>Bi(n,G,C),[C,G,n]),ut=c.useCallback(()=>{if(Ke){Z();return}z("organize")},[Ke,Z,z]),St=c.useCallback(m=>{u?.([m])},[u]),v=c.useCallback((m,S)=>{we([m],!S)},[we]),P=c.useCallback(m=>{A||ke(m)},[A,ke]),V=c.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}D()},[w,D]),fs=c.useCallback(()=>{w.clear()},[w]);c.useEffect(()=>{if(ie.current||!A&&t)return;const m=te>=0?te:Be;m>=0&&ve.scrollToIndex(m,{align:"auto"})},[te,Be,ve,A,t]),c.useEffect(()=>{t&&(ie.current=!1,H(t))},[t,H]),c.useEffect(()=>{T&&(n.some(m=>m.messageId===T)||H(n[0]?.messageId))},[n,T,H]),c.useEffect(()=>{I?.({focusedMessageId:T,selectedIds:Array.from(G),hasList:Ae,blocksKeyboard:be||B.isOpen})},[T,G,Ae,be,B.isOpen,I]);const Nt=c.useRef(I);Nt.current=I,c.useEffect(()=>()=>Nt.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||$e(n.map(m=>m.messageId))},[n,$e,w.phase,w.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,D())},[e,D]),In({shouldBlockFn:({action:m})=>Ei(m,oe,Ie)?(D(),!0):!1,enableBeforeUnload:!1,disabled:!oe||Ie!==void 0}),c.useEffect(()=>{const m=E.current;if(!m||!b||!f)return;const S=()=>{if(y)return;const{scrollTop:ue,scrollHeight:$,clientHeight:Q}=m;ue+Q>=$-200&&f()};return m.addEventListener("scroll",S,{passive:!0}),S(),()=>m.removeEventListener("scroll",S)},[b,y,f]),c.useEffect(()=>{const m=pe.current;if(!m)return;const S=E.current?.querySelector(`[data-message-id="${m}"]`);S&&(pe.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Ae){j.current=null;return}return j.current={focusNext:Ue,focusPrevious:Se,focusFirst:Oe,focusLast:Ne,openFocused:Ce,toggleSelect:ot,extendSelectDown:at,extendSelectUp:rt,selectAll:lt,clearSelection:()=>oe?(D(),!0):!1,requestVerb:ct,toggleDensity:ae},()=>{j.current=null}}},[j,Ae,Ue,Se,Oe,Ne,Ce,ot,at,rt,lt,oe,D,ct,ae]);const Ft=s?"loading":o?"error":n.length===0?"empty":"ready",ms=o?jo(i):void 0,gs=c.useCallback(()=>{const m=$s(Bs());window.open(m,"_blank","noopener,noreferrer")},[]),ps=[{id:"inbox",threads:[]}],yt=K.length>0&&K.every(m=>G.has(m)),xs=He&&b&&yt&&!h&&!g&&w.phase.kind==="idle"&&!w.isRunning,bs=h||g||w.isRunning,Ct=w.phase.kind==="escalated"?w.phase.total:U,vs=w.runningAction?jn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??Ct):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?Mi(d??{},w.phase.total):void 0,Ss=w.phase.kind!=="escalated"&&K.length>0?{checked:yt,indeterminate:U>0&&!yt,onChange:()=>Me(K)}:void 0,ys=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??Ct,tone:wn(w.runningAction.kind)}:void 0,Cs=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:fs}}:xs?{tone:"info",text:"",action:{label:Ti(d??{}),onClick:w.escalate}}:void 0)??(Qe?{tone:"warning",text:Qe}:void 0),Is=r.jsx(kn,{title:J.title||M,navSlot:J.navSlot,titleMeta:J.titleMeta,searchSlot:J.searchSlot,searchField:J.searchField,idleSlot:J.makeFilterSlot,count:Ct,onCancel:V,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:ut,onJunk:_e?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:C&&e&&U>0&&Fe.length>0?r.jsx(Ro,{accountId:C,mailboxId:e,messageIds:Array.from(G)}):void 0,isBusy:bs,isCounting:w.phase.kind==="counting",selectAll:Ss,statusLabel:vs,progress:ys,notice:Cs}),js=Tn(K,T),ws=c.useCallback(m=>{ie.current=!0,H(m)},[H]),ks=r.jsxs(r.Fragment,{children:[ne&&a&&r.jsx($i,{query:a}),r.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":M,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ve.getTotalSize()}px`},children:ve.getVirtualItems().map(m=>{const S=n[m.index];return r.jsx("div",{role:"presentation","data-index":m.index,ref:ve.measureElement,className:ze("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${m.start}px)`},children:r.jsx(Fi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:T===S.messageId,isTabStop:js===S.messageId,onFocusRow:ws,isChecked:Pe(S.messageId),onToggleCheck:Y,onRowSelect:ye,isMultiSelectMode:R,onLongPress:P,isDesktop:A,onDelete:St,onToggleRead:v,density:ee})},m.key)})}),y&&r.jsx(co,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!A&&r.jsx(mt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>nt(null),children:st}),r.jsx(uo,{listTitle:M,listMeta:x,sections:ps,flatList:!0,listState:J.searchResults?"ready":Ft,searchQuery:ne?a:void 0,listFilter:p,listScopeLabel:k,errorMessage:ms,onRetry:l,onReportError:gs,density:ee,selectedThreadId:t,onSelectThread:m=>de(m),isDesktop:A,hideHeader:O,selectionBar:Is,listBody:J.searchResults??(Ft==="ready"?ks:void 0)}),r.jsx(Mn,{isOpen:Re!==null,messageIds:Re??[],outcome:L,accountId:C,trashFolderLabel:M,staleFolderLabel:me,trashIsUnconfirmed:qe,isDeleting:h,onConfirm:bt,onCancel:vt}),r.jsx(Rn,{verb:he,accountId:C,mailboxId:e,selection:xt,selectionRestriction:Qe?"spansAccounts":void 0,escalated:Ke,escalatedProgress:w.progress,onFinished:D,onRunEnded:et})]})},Ki=e=>qt({path:{accountId:e}}),Vi=e=>{const n=kt(),t=Rt(),s=Mt({...Ks(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},qi=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Vi(e);return r.jsx($o,{onRefresh:t,isRefreshing:s,children:n})};function Hi({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=Rt(),d=Vs(),{inboxMailboxId:u}=An(e),h=On(e),{data:g}=Tt({...qs({path:{accountId:e}}),staleTime:1/0}),f=c.useMemo(()=>Hs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),b=c.useMemo(()=>u||(f.find(p=>p.label.toLowerCase()==="inbox")?.id??f.find(p=>!p.isCurrent)?.id??""),[u,f]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Nn(a,t.length))},[a,t.length]);const C=c.useCallback(()=>{zn(a,t.length),l(!0)},[a,t.length]),M=c.useCallback((x,p)=>{Fn(a,{selected:x.length,total:t.length,toInbox:p===u}),s(x,p)},[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(Wo,{count:t.length,onReview:C})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:b,availableFolders:f,delimiter:Us(g?.items??[]),onConfirmMove:M,onCancel:()=>l(!1)})]})}const Ui=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Qi=({accountId:e,mailboxId:n})=>{const t=kt(),{pushError:s}=Vt(),{requestAppointment:o}=Qs(),{trashByAccount:i}=es(),l=e?i.get(e):void 0,a=Ui(e,n,l?.mailboxId,l?.source),[d,u]=c.useState({scope:a});d.scope!==a&&u({scope:a});const h=d.scope===a?d:void 0,g=c.useCallback(()=>t.getQueryData(Js())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??n,[t,e,n]),f=c.useRef(void 0),{mutateAsync:b,isPending:y}=Mt({...Xs(),onMutate:()=>(f.current=a,{scope:a,listMailboxId:g()}),onSuccess:(p,k,I)=>{I.scope===a&&u({scope:a,deletedCount:p.deletedCount})},onError:(p,k,I)=>{const j=Gs(p);if(!j){s({title:"Couldn't empty Trash",detail:Ys(p),error:p});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(p,k,I,j)=>{f.current===j?.scope&&(f.current=void 0),Dn(t,Ln([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:qt({path:{accountId:e}})})}}),C=c.useCallback(()=>e?(u({scope:a}),b({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,b]),M=c.useCallback(()=>{C()},[C]),x=c.useCallback(()=>{const p=h?.refusal;p&&o({accountId:p.accountId,role:p.role,reason:p.reason,action:{kind:"emptyTrash"},onAppointed:C})},[h,o,C]);return{emptyTrash:M,isEmptying:y&&f.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:x}},Ji="We can verify this sender";function Gi(e){const{data:n}=Tt({...Zs({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:Ji,trustSubReason:_n(s.senderTrust),senderTrust:s.senderTrust}))}}const Yi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Xi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(en)),ds=e=>Zi.has(e),er=e=>ds(e.category)||e.attributes.size>0,tr=e=>{const n={};ds(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Xi[t];s&&(n[s]=!0)}return n},sr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",nr=["category","unread","starred","attachments"],Bt=e=>JSON.stringify(nr.map(n=>e?.[n]??null)),or=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},ir=(e,n)=>{const t=or(e);return t?Bt(t)===Bt(n):!1},ht=e=>e[0],rr=e=>{const n=ht(e.filter(a=>a.type==="from").map(a=>a.value)),t=ht(e.filter(a=>a.type==="subject").map(a=>a.value)),s=ht(e.filter(a=>a.type==="category").map(a=>a.category)),o=ht(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=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}:{},...l!==void 0?{attachments:l}:{}}},ar=(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 lr(e,n={}){const t=rr(e),s={...t,...n};return{params:t,residual:e.filter(o=>!ar(s,o))}}function cr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Pn(o);return $n({...i,accountId:i.accountId??t},s)})}const dr=50,ur=new Map(os().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),us=c.createContext(null);function pt(){const e=c.useContext(us);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function hr({mailboxId:e,thread:n,children:t}){const s=Ge(),o=Xe(),i=n?.threadId,l=n?.messageId,a=Rt(),{accounts:d,searchQuery:u,onToggleIntelligence:h}=Ht(),g=rn(),f=Po(u),b=f.length>0,{freeText:y,tokens:C}=an(f,g),[M,x]=c.useState("all"),[p,k]=c.useState(new Set),I=c.useMemo(()=>({category:M,attributes:p}),[M,p]),j=c.useMemo(()=>tr(I),[I]),O=b||er(I),{params:E,residual:N}=lr(C,j),_={order:"desc",limit:dr,...y?{query:y}:{},...E,...j},A={category:_.category,unread:_.unread,starred:_.starred,attachments:_.attachments},B=O?tn({path:{mailboxId:e},query:_}):sn({path:{mailboxId:e},query:{order:"desc"}}),{data:he,isLoading:z,isError:Z,error:Ie,refetch:ne,fetchNextPage:J,hasNextPage:Fe,isFetchingNextPage:re}=ho({queryKey:B,queryFn:async({pageParam:v})=>{if(O){const{data:V}=await nn({path:{mailboxId:e},query:{..._,continuationToken:v},throwOnError:!0});return V}const{data:P}=await on({path:{mailboxId:e},query:{order:"desc",continuationToken:v},throwOnError:!0});return P},initialPageParam:void 0,getNextPageParam:v=>v.continuationToken,placeholderData:(v,P)=>ir(P?.queryKey,A)?v:void 0}),{accountId:T,isLoading:je}=Bn(e),De=Fo({accounts:d}),q=cr(Wn(Yi(he?.pages.flatMap(v=>v.items??[])??[])),N,T),H=c.useCallback(v=>{x(v)},[]),ee=c.useCallback(v=>{k(P=>{const V=new Set(P);return V.has(v)?V.delete(v):V.add(v),V})},[]),Le=c.useCallback(()=>{x("all"),k(new Set)},[]),ae=ur.get(M),we=ae?{label:ae,reach:N.length>0?"loaded-pages":sr(_),onClear:Le}:void 0,fe=i?q.find(v=>v.messageId===l)??q.find(v=>v.threadId===i):void 0,_e=Kn(i,l),W=fe??_e,L=l??W?.messageId,qe=c.useMemo(()=>{if(i)return{threadId:i,mailboxId:W?.mailboxId??e,subject:W?.subject,messageId:L,authenticity:W?.authenticity}},[i,W,L,e]),me=c.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:v=>v,hash:o})},[e,s,o]),G=c.useCallback(v=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...v},search:P=>P,hash:o})},[e,s,o]),U=c.useCallback(v=>{L&&v.includes(L)&&me()},[L,me]),{deleteMessages:oe,isPending:Pe}=Dt({mailboxId:e,onAfterOptimisticRemove:U}),{moveMessages:Y,isPending:ke}=Lt({mailboxId:e,accountId:T,onAfterOptimisticRemove:U}),le=c.useRef(null),ce=Vn(),{listCommandsRef:F,onTriageContextChange:Te,focusedMessageId:Me,selectedIds:$e}=ce,R=q.find(v=>v.messageId===Me)??W,Re=Do({accounts:d})??0,ge=qn({thread:W,mailboxId:e,accountId:T,onAfterOptimisticRemove:U}),{draftsMailboxId:He}=Hn(T),Ze=He!==void 0&&He===e,{archiveMailboxId:w}=Un(T),et=Qn(),Ee=xo(),tt=c.useMemo(()=>bo(Ee,i,L),[Ee,i,L]),D=c.useMemo(()=>{if(R)return v=>Ee({threadId:R.threadId,messageId:R.messageId,mode:v})},[Ee,R]),st=vo(),nt=So(),pe=yo(),ie=c.useCallback(v=>v?et(v):[],[et]),{toggleStar:xe}=Jn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:Ae}=Yt({mailboxId:e,accountId:T}),{junkMailboxId:be}=Xt(T),ve=be!=null&&be===e,Be=Zt(be,e),{candidates:te}=Gi(ve?be:void 0),{moveMessages:se}=Lt({mailboxId:e,threadId:R?.threadId,accountId:T,onAfterOptimisticRemove:U}),{deleteMessages:Ue}=Dt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:U}),{addressId:Se,address:Oe}=Gn(R),{updateFlags:Ne}=Yn({addressId:Se,senderEmail:R?.fromEmail??void 0}),ot=c.useCallback(()=>D?.("reply"),[D]),K=c.useCallback(()=>D?.("reply-all"),[D]),xt=c.useCallback(()=>D?.("forward"),[D]),ye=c.useCallback(()=>ie(R),[ie,R]),it=c.useCallback(()=>{if(F.current?.requestVerb("delete"))return;const v=ye();v.length>0&&Ue(v)},[F,ye,Ue]),We=c.useCallback(()=>{if(F.current?.requestVerb("junk")||!Be)return;const v=ye();v.length!==0&&(Xn(a,{count:v.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?Zn(R):!1}),se(v,Be))},[F,Be,ye,se,a,R]),rt=c.useCallback(()=>{if($e.length>0){const v=!(R?.hasStars??!1),P=new Set($e);for(const V of q)P.has(V.messageId)&&V.hasStars!==v&&xe(V.messageId,V.hasStars);return}R&&xe(R.messageId,R.hasStars)},[$e,q,R,xe]),at=c.useCallback(()=>{if(F.current?.requestVerb("markRead"))return;const v=ye();if(v.length===0)return;const P=!(R?.isRead??!1);Ae(v,P)},[F,ye,R,Ae]),lt=c.useCallback(()=>{if(!Se)return;const v=Oe?.flags?.muted?.value!==!0;Ne({muted:{value:v}})},[Se,Oe,Ne]),ct=c.useCallback(()=>{if(!Se)return;const v=Oe?.flags?.vip?.value!==!0;Ne({vip:{value:v}})},[Se,Oe,Ne]),de=c.useCallback(()=>{le.current?.open()},[]),Ce=c.useCallback(v=>{s({to:v})},[s]),dt=Ze?"drafts":w===e?"archive":be===e?"junk":"inbox",Ke=c.useRef("");c.useEffect(()=>{const v=Ke.current;Ke.current=f,f.length>0&&v.length===0&&a.recordEvent("search.submitted",{mailboxType:dt})},[f,dt,a]);const{goBack:bt,nextMessageId:vt,previousMessageId:Qe}=eo({context:ce,orderedIds:q.map(v=>v.messageId),selectedMessageId:L,enabled:!st&&!nt,onClose:me,handlers:{reply:ot,replyAll:K,forward:xt,delete:it,toggleStar:rt,toggleRead:at,muteSender:lt,blockSender:W?de:void 0,vipSender:ct,markJunk:We,toggleIntelligence:W?()=>le.current?.toggle():void 0,compose:pe,goBrief:()=>Ce("/mail/brief"),goInbox:()=>Ce("/mail/brief"),goSent:()=>Ce("/mail/brief"),goFlagged:()=>Ce("/mail/flagged"),goSettings:()=>Ce("/settings")}}),ut=v=>{if(!v)return;const P=q.find(V=>V.messageId===v);return P?{threadId:P.threadId,messageId:v}:void 0},St={mailboxId:e,selectedMessageId:L,selectedThread:W,conversation:qe,onOpenThread:G,threads:q,isLoading:z,isError:Z,error:Ie,mailboxAccountId:T,mailboxAccountLoading:je,mailboxName:De,unreadCount:Re,isDraftsMailbox:Ze,isSpamFolder:ve,rescueCandidates:te,filterCategory:M,filterAttributes:p,onSelectFilterCategory:H,onToggleFilterAttribute:ee,onClearFilters:Le,listFilter:we,onToggleIntelligence:h,intelligenceRef:le,handleDeselectIfRemoved:U,searchPredicate:b&&N.length===0?_:void 0,onDeleteMessages:oe,onMoveMessages:Y,isDeleting:Pe,isMoving:ke,onLoadMore:J,hasMore:Fe,isLoadingMore:re,onTriageContextChange:Te,listCommandsRef:F,onRetry:()=>ne(),onReply:tt,onToolbarDelete:ge.deleteThread,onToolbarStar:ge.toggleStar,onToolbarMove:ge.moveThread,onBack:bt,nextThread:ut(vt),previousThread:ut(Qe)};return r.jsx(us.Provider,{value:St,children:t})}function hs(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:f,mailboxAccountId:b,mailboxName:y,unreadCount:C,isDraftsMailbox:M,isSpamFolder:x,rescueCandidates:p,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:O,filterAttributes:E,onSelectFilterCategory:N,onToggleFilterAttribute:_,onClearFilters:A,listFilter:B,searchPredicate:he}=pt(),{searchQuery:z,searchInput:Z,accounts:Ie,resultFolderIndex:ne}=Ht(),J=Lo(),Fe=Ge(),re=Xe(),T=y??"Inbox",je=c.useMemo(()=>os(),[]),{trashMailboxId:De}=io(b),q=_o({accounts:Ie}),{trashByAccount:H}=es(),ee=Qi({accountId:b,mailboxId:e}),Le=De!=null&&De===e,ae=c.useMemo(()=>b?[b]:[],[b]),{hasNewMail:we}=cn(),{state:fe,errorMessage:_e,refresh:W}=dn(ae,{onSettled:j}),L=c.useMemo(()=>r.jsx(un,{state:fe,onRefresh:W,label:`Refresh ${T}`,errorMessage:_e,hasUpdate:we(ae)}),[fe,W,T,_e,we,ae]),qe=c.useMemo(()=>t.map(F=>ro(F,ne)),[t,ne]),{hits:me,isLoading:G}=Ao({mailboxId:e,filterCategory:O}),U=c.useMemo(()=>ao(me,t.map(F=>F.threadId),ne),[me,t,ne]),oe=c.useCallback(F=>{const Te=F.threadId??t.find(Me=>Me.messageId===F.id)?.threadId;Te&&Fe({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:F.mailboxId??e,threadId:Te,messageId:F.id},search:Me=>({...Me,q:Z||void 0}),hash:re})},[e,Fe,re,Z,t]);if(M&&b)return r.jsx(ri,{mailboxId:e,accountId:b,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:C??void 0});const Pe=r.jsx(Wi,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:z,searchPredicate:he,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:f,accountId:b,listTitle:T,listFilter:B,listScopeLabel:T,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),Y=Ie[0]?.accountId,ke=J==="phone"&&Y?r.jsx(qi,{accountId:Y,children:Pe}):Pe,le=x&&p.length>0&&b?r.jsx(Hi,{accountId:b,currentMailboxId:e,candidates:p,onMove:a,children:ke}):ke,ce=Le?r.jsx(ci,{messageCount:q,isEmptying:ee.isEmptying,deletedCount:ee.deletedCount,refusalReason:ee.refusal?.reason,trashFolderLabel:y??void 0,staleFolderLabel:b?H.get(b)?.staleFolderPath:void 0,onEmpty:ee.emptyTrash,onRepair:ee.repair,children:le}):le;return r.jsx(fo,{title:T,unreadCount:C,preset:je,selectedCategory:O,activeFilters:E,onSelectCategory:N,onToggleFilter:_,onClearFilters:A,searchResults:qe,searchLoading:s,relatedResults:U,relatedLoading:G,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:L,children:ce})}function fr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,onToolbarMove:d,handleDeselectIfRemoved:u,intelligenceRef:h}=pt(),g=!!o,f=no(o?.threadId);ts(h,f);const b=c.useRef(null),{railFits:y,openRail:C}=f;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&b.current!==x&&s?.authenticity?.dkimMismatch&&(b.current=x,C())},[y,C,s?.messageId,s?.authenticity?.dkimMismatch]);const M=o?r.jsx(ss,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:f.open}):r.jsx(ln,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(oo,{hasThread:g,messageId:o?.messageId,intelligenceOpen:f.isShowing,canToggleIntelligence:f.canToggle,onToggleIntelligence:f.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?l:void 0,onToggleStar:g?a:void 0,isStarred:s?.hasStars,moveContext:g&&n?{accountId:n,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:M})]}),r.jsx(ns,{isOpen:f.drawerOpen,onClose:f.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:u})]})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=pt();return r.jsx(so,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function gr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=pt(),h=to(s?.threadId??null);return ts(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(ss,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:a?()=>o(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(ns,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(hs,{})}const _r=Object.assign(hr,{List:hs,Reading:fr,Intelligence:mr,Phone:gr});export{_r as M};
|
|
1
|
+
import{j as r,bm as Ts,as as mt,B as X,S as Ms,b as ze,at as Wt,r as c,C as Rs,d as Es,aY as As,m as Ge,n as kt,s as Tt,t as Os,a7 as Mt,bn as Ns,bo as zs,I as Fs,h as Ds,T as Kt,bp as Ls,bq as _s,br as Ps,a5 as Vt,aF as $s,aG as Bs,g as Ws,W as Rt,bs as Ks,K as qt,aV as Vs,q as qs,aW as Hs,aX as Us,bt as Qs,V as Js,bu as Gs,bv as Ys,bw as Xs,bx as Zs,by as en,l as Ht,bz as tn,z as sn,bA as nn,b6 as on}from"./index-D_YBuI3z.js";import{u as rn,p as an,R as ln}from"./useSearchTokenContext-DROeO7xw.js";import{u as cn,a as dn,R as un}from"./useRefreshControl-h1VyXjLX.js";import{C as Ut,a as Qt,c as Jt,j as hn,M as fn,t as Gt,u as mn,b as gn,d as Yt,e as Xt,f as pn,g as xn,h as bn,r as vn,n as Sn,i as yn,k as Cn,l as In,m as jn,o as wn,S as kn,p as Tn,D as Mn,q as Rn,s as En,v as Zt,w as An,x as On,y as Nn,z as zn,A as Fn,B as es,E as Dn,F as Ln,G as _n,H as Pn,I as $n,J as Bn,K as Wn,L as Kn,N as Dt,O as Lt,P as Vn,Q as qn,R as Hn,T as Un,U as Qn,V as Jn,W as Gn,X as Yn,Y as Xn,Z as Zn,_ as eo,$ as to,a0 as ts,a1 as ss,a2 as ns,a3 as so,a4 as no,a5 as oo,a6 as os,a7 as io,a8 as ro,a9 as ao}from"./MailListHeader-BcdPneAy.js";import{S as lo,M as co,a as uo,u as ho,b as fo}from"./MailViewChrome-CZb8kPr_.js";import{A as Et}from"./avatar-DtND0ruk.js";import{b as Ye,d as mo,c as is}from"./format-23Av07Go.js";import{k as go,n as po,o as Xe,p as xo,r as bo,f as vo,h as So,u as yo}from"./useMessageBodyContent-DEOYO0s3.js";import{N as Co}from"./NavMenuButton-BIPTnOry.js";import{C as Io}from"./confirm-dialog-CSNgGV-I.js";import{f as jo}from"./ErrorState-CNHmvGYF.js";import{a as wo}from"./useLabels-CwcqSC09.js";import{a as ko,D as To,u as Mo}from"./useMediaQuery-CDMcFeIb.js";import{L as Ro,r as Eo,u as Ao}from"./useSemanticSearch-RnkqtV8e.js";import{S as gt}from"./shield-check-BZ36Y5z_.js";import{B as Oo}from"./bottom-sheet-Cpg512Z8.js";import{C as No}from"./circle-help-lK4oidSt.js";import{C as zo}from"./circle-check-CyTXHuU4.js";import{j as Fo,k as Do,e as Lo,l as _o}from"./search-token-index-nAK4hI7B.js";import{n as Po}from"./search-query-Cr_ZXBCp.js";const $o=({children:e,onRefresh:n,isRefreshing:t})=>ko(To)?e:r.jsx(Ts,{onRefresh:n,isPullable:!t,children:e}),Bo=e=>e===1?"message":"messages";function Wo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(mt,{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(gt,{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} ${Bo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(X,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",rs=({senderTrust:e,size:n="sm",className:t})=>{const s=Ko(e,n);return s==="vip"?r.jsx(Ms,{className:ze("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:ze("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 Vo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:l,snippet:a,trustReason:d,trustSubReason:u,senderTrust:h}=e;return r.jsxs("label",{className:ze("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(Ut,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(Et,{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}),h&&r.jsx(rs,{senderTrust:h,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:l}),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(Wt,{tone:"positive",children:[r.jsx(gt,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const qo=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)},Ho=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},_t=e=>e===1?"message":"messages";function Uo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ho(e,n),a=e.messages.length,d=o?Rs:Es;return r.jsxs("div",{className:ze(l!=="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(Ut,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${_t(a)} from ${e.senderName}`}),r.jsx(Et,{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(rs,{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(Wt,{tone:"positive",children:[r.jsx(gt,{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} ${_t(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(Vo,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const At=e=>e===1?"message":"messages",Qo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${At(e)}`} out of Spam to ${n} now. Nothing later.`,wt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Jo(){return r.jsx(mt,{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 Go({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:l,onCancel:a}){const[d,u]=c.useState(!1),h=n.size,g=c.useMemo(()=>qo(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(gt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(No,{className:"size-3.5"}),onClick:()=>u(f=>!f),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(Jo,{})})]}),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:`${h} of ${e.length} selected · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(X,{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(f=>r.jsx(Uo,{group:f,selected:n,onToggleGroup:s,onToggleMessage:t},f.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(X,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${At(h)}`}),r.jsx(X,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Yo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:l}){const[a,d]=c.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:wt(n,s)}),r.jsx(X,{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:Qo(e,wt(n,s))}),r.jsx(X,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(X,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Xo({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(zo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${At(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(X,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Zo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:l}){const[a,d]=c.useState("review"),[u,h]=c.useState(()=>e?new Set(n.map(I=>I.id)):new Set),[g,f]=c.useState(t),[b,y]=c.useState(0),C=c.useRef(!1);c.useEffect(()=>{e&&!C.current&&(d("review"),h(new Set(n.map(I=>I.id))),f(t),y(0)),C.current=e},[e,n,t]);const M=u.size,x=I=>{h(j=>{const O=new Set(j);return O.has(I)?O.delete(I):O.add(I),O})},p=(I,j)=>{h(O=>{const E=new Set(O);for(const N of I.messages)j?E.add(N.id):E.delete(N.id);return E})},k=()=>{const I=Array.from(u);y(I.length),i(I,g),d("done")};return r.jsxs(Oo,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Go,{candidates:n,selected:u,onToggle:x,onToggleGroup:p,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Yo,{count:M,folders:s,delimiter:o,destination:g,onPick:f,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Xo,{count:b,destinationLabel:wt(s,g),onClose:l})]})}function ei(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:Ye(e.updatedAt),isRead:!0}}function ti(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function si({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(ei),o=t.map(ti),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 ni=({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})]}),oi=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:ze("group",Jt({active:n})),children:[r.jsx(Ds,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Qt,{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(Kt,{className:"size-3.5"})})})]}),ii=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:ze("group",Jt({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(Et,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Qt,{thread:e})]})};function ri({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const l=go(),a=po(),d=Ge(),u=Xe(),h=kt(),{data:g}=Tt(Os()),f=c.useMemo(()=>si({outboxMessages:g?.items??[],accountId:n,imapThreads:s}),[g?.items,n,s]),b=Mt({...zs(),onSuccess:()=>{h.invalidateQueries({queryKey:Ns()})}}),y=x=>{b.mutate({path:{outboxMessageId:x}})},C=x=>{const p=s.find(k=>k.messageId===x)?.threadId;p&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:p,messageId:x},search:k=>k,hash:u})},M=f.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(Co,{}),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:M?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{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."})]}):f.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(ni,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(p=>x.id==="remit-drafts"?r.jsx(oi,{row:p,isSelected:p.id===l,onOpen:a,onDelete:y,isDeleting:b.isPending},p.id):r.jsx(ii,{row:p,isSelected:p.id===t,onOpen:C},p.id))})]},x.id))})]})}const as=e=>e===1?"1 message":`${is(e)} messages`,ai=e=>({title:"Empty Trash?",description:`${as(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),li=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=mo(0,"unconfirmed",{trashFolderLabel:t});return{headline:o.title,body:o.description,actionLabel:o.confirmLabel}}return e==="stale"?{headline:"Nothing was emptied.",body:s?`The folder you chose for Trash — ${s} — is gone from the mail server.`:"The folder you chose for Trash is gone from the mail server.",actionLabel:"Pick another folder"}:{headline:"Nothing was emptied.",body:"No folder on this account is set as Trash.",actionLabel:"Pick a folder"}};function ci({messageCount:e,isEmptying:n,deletedCount:t,refusalReason:s,trashFolderLabel:o,staleFolderLabel:i,onEmpty:l,onRepair:a,children:d}){const[u,h]=c.useState(!1);if(e<1&&s===void 0&&t===void 0)return r.jsx(r.Fragment,{children:d});const g=s?li(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,f=ai(e);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.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-line px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t!==void 0&&r.jsx("p",{className:"mr-auto text-2xs text-fg-subtle",role:"status",children:`${as(t)} erased from the mail server.`}),r.jsx(X,{variant:"ghost",size:"sm",icon:r.jsx(Kt,{className:"size-3.5","aria-hidden":!0}),disabled:n||e<1,"aria-busy":n,onClick:()=>h(!0),children:n?"Emptying…":"Empty Trash"})]}),g&&r.jsx(mt,{tone:"warning",variant:"soft",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("p",{className:"font-semibold text-fg",children:g.headline}),r.jsx("p",{className:"text-sm",children:g.body}),r.jsx(X,{variant:"primary",size:"sm",className:"self-start",onClick:a,children:g.actionLabel})]})})]})}),r.jsx("div",{className:"min-h-0 flex-1",children:d}),r.jsx(Io,{isOpen:u,title:f.title,description:f.description,confirmLabel:f.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function di(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,l){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 h=n[d*2];u=o[d]={index:d,key:t(d),start:h,size:n[d*2+1],end:h+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,l)}})}function Ve(e,n,t){let s=t.initialDeps??[],o,i=!0;function l(){const a=e();return(a.length!==s.length||a.some((u,h)=>s[h]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return l.updateDeps=a=>{s=a},l}function Pt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const ui=(e,n)=>Math.abs(e-n)<1.01,hi=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Je;const It=()=>{if(Je!==void 0)return Je;if(typeof navigator>"u")return Je=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Je=!0;const e=navigator.maxTouchPoints;return Je=navigator.platform==="MacIntel"&&e!==void 0&&e>0},$t=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},fi=e=>e,mi=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},gi=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=l=>{const{width:a,height:d}=l;n({width:Math.round(a),height:Math.round(d)})};if(o($t(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(l=>{const a=()=>{const d=l[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o($t(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ft={passive:!0},pi=typeof window>"u"?!0:"onscrollend"in window,xi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&πlet l=0;const a=i?null:hi(o,()=>n(l,!1),e.options.isScrollingResetDelay),d=g=>()=>{l=t(s),a?.(),n(l,g)},u=d(!0),h=d(!1);return s.addEventListener("scroll",u,ft),i&&s.addEventListener("scrollend",h,ft),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},bi=(e,n)=>xi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),vi=(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"]},Si=(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})},yi=Si;class Ci{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 l=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,h]of this.elementsCache)if(h===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));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:fi,rangeExtractor:mi,onChange:()=>{},measureElement:vi,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 f in t){const b=t[f];b!==void 0&&(i[f]=b)}const l=this.options;let a=null,d=null,u=!1;if(l!==void 0&&l.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const f=l.count,b=i.count,y=this.getMeasurements(),C=f>0?((s=y[0])==null?void 0:s.key)??l.getItemKey(0):null,M=f>0?((o=y[f-1])==null?void 0:o.key)??l.getItemKey(f-1):null;if(b!==f||f>0&&b>0&&(i.getItemKey(0)!==C||i.getItemKey(b-1)!==M)){u=!0;const k=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&b>f&&this.isAtEnd(l.scrollEndThreshold)&&(f===0||i.getItemKey(b-1)!==M)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[f,b]=a,y=this.getMeasurements(),{count:C,getItemKey:M}=this.options;let x=0;for(;x<C&&M(x)!==f;)x++;if(x<C){const p=y[x];if(p){const k=p.start+b;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,h=!0)}}}(h||d)&&(this.pendingScrollAnchor=[h?a[0]:null,h?a[1]:0,d,g])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=Ve(()=>(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,l)=>{if(l&&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=l?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!It()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ft),i.addEventListener("touchend",a,ft),this.unsubs.push(()=>{i.removeEventListener("touchstart",l),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,l,a,d]=o;i!==null&&!a&&(It()&&(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=Ve(()=>[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,l,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:l,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=Ve(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:l,lanes:a,laneAssignmentMode:d,gap:u},h)=>{const g=this.itemSizeCache;if(!l)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 f=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 p=this._flatMeasurements;if(!p||p.length<x){const j=new Float64Array(x);p&&f>0&&j.set(p.subarray(0,f*2)),p=j,this._flatMeasurements=p}let k;if(f===0)k=s+o;else{const j=f-1;k=p[j*2]+p[j*2+1]+u}for(let j=f;j<t;j++){const O=i(j),E=g.get(O),N=typeof E=="number"?E:this.options.estimateSize(j);p[j*2]=k,p[j*2+1]=N,k+=N+u}const I=di(t,p,i);return this.measurementsCache=I,I}const b=this.measurementsCache.slice(0,f),y=new Array(a).fill(void 0),C=new Float64Array(a);let M=0;for(let x=0;x<f;x++){const p=b[x];p&&(y[p.lane]===void 0&&M++,y[p.lane]=x,C[p.lane]=p.end)}for(let x=f;x<t;x++){const p=i(x),k=this.laneAssignments.get(x);let I,j;const O=d==="estimate"||g.has(p);if(k!==void 0&&this.options.lanes>1){I=k;const A=y[I],B=A!==void 0?b[A]:void 0;j=B?B.end+u:s+o}else if(M===a){let A=0,B=C[0],he=y[0];for(let z=1;z<a;z++){const Z=C[z];(Z<B||Z===B&&y[z]<he)&&(A=z,B=Z,he=y[z])}I=A,j=B+u,O&&this.laneAssignments.set(x,I)}else I=x%this.options.lanes,j=s+o,O&&this.laneAssignments.set(x,I);const E=g.get(p),N=typeof E=="number"?E:this.options.estimateSize(x),_=j+N;b[x]={index:x,start:j,size:N,end:_,key:p,lane:I},y[I]===void 0&&M++,y[I]=x,C[I]=_}return this.measurementsCache=b,b},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ve(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=ji(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ve(()=>{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,l)=>i===null||l===null?[]:t({startIndex:i,endIndex:l,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)),l=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=l&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((l,a)=>{l.isConnected||(this.observer.unobserve(l),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 l,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],l=u[t*2+1];else{const f=this.measurementsCache[t];if(!f)return;d=f.key,a=f.start,l=f.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const f=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,b=f?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:l,end:a+l,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++,f?this.applyScrollAdjustment(this.getTotalSize()-b):y&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=Ve(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,l=t.length;i<l;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,l=ls(0,s.length-1,i?a=>o[a*2]:a=>Pt(s[a]).start,t);return Pt(s[l])},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(),l=this.getScrollOffset();s==="auto"&&(s=t>=l+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(),l=this.measurementsCache[t];if(!l)return;if(s==="auto")if(l.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(l.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"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,l.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),l=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:l,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[l,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{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,l=this._flatMeasurements;l!=null?o=l[i*2]+l[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let l=s.length-1;for(;l>=0&&i.some(a=>a===null);){const a=s[l];i[a.lane]===null&&(i[a.lane]=a.end),l--}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&&(It()&&(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,l=o!==this.scrollState.lastTargetOffset;if(!l&&ui(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,l){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 ls=(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 Ii(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 ji(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=Ii(o,i,t);let h=u;const g=t+n;for(;h<i&&o[h*2]+o[h*2+1]<g;)h++;return{startIndex:u,endIndex:h}}let a=ls(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 h=Array(s).fill(t+n);for(;a>=0&&h.some(g=>g>=t);){const g=e[a];h[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 jt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function wi({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=c.useReducer(u=>u+1,0)[1],i=c.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const l=u=>{const h=i.current;if(!h.enabled||!h.container)return;const g=u.getTotalSize();if(g!==h.lastSize){h.lastSize=g;const x=u.options.horizontal?"width":"height";h.container.style[x]=`${g}px`}const f=!!u.options.horizontal,b=h.mode==="transform",y=f?"left":"top",C=u.options.scrollMargin,M=u.getVirtualItems();for(const x of M){const p=x.start-C,k=u.elementsCache.get(x.key);k&&h.lastPositions.get(k)!==p&&(h.lastPositions.set(k,p),b?k.style.transform=f?`translate3d(${p}px, 0, 0)`:`translate3d(0, ${p}px, 0)`:k.style[y]=`${p}px`)}},a={...s,onChange:(u,h)=>{var g;const f=i.current;let b=!0;if(f.enabled){l(u);const y=u.range,C=f.prevRange;b=!C||C.isScrolling!==u.isScrolling||C.startIndex!==y?.startIndex||C.endIndex!==y?.endIndex,b&&(f.prevRange=y?{startIndex:y.startIndex,endIndex:y.endIndex,isScrolling:u.isScrolling}:null)}b&&(e&&h?Ls.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new Ci(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const f=u.getTotalSize();g.lastSize=f;const b=u.options.horizontal?"width":"height";h.style[b]=`${f}px`}}})});return d.setOptions(a),jt(()=>d._didMount(),[]),jt(()=>d._willUpdate()),jt(()=>{l(d)}),d}function ki(e){return wi({observeElementRect:gi,observeElementOffset:bi,scrollToFn:yi,...e})}const Ot=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",Ti=e=>`Select all ${Ot(e)}`,Mi=(e,n)=>`All ${is(n)} ${Ot(e)} selected`,Ri=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=hn(s,o);if(l!==void 0)return{kind:"unavailable",reason:l}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},Ei=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ai=(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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Gt(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Oi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:h,onLongPress:g,isDesktop:f,density:b})=>r.jsx(fn,{thread:Ai(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:b,isDesktop:f,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Ni=c.memo(Oi),zi=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:Ye(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Gt(e.category),suspicious:n}},Fi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,onDelete:f,onToggleRead:b,density:y})=>{const[C,M]=c.useState("none"),x=Ge(),p=Xe(),k=c.useCallback(N=>{navigator.vibrate?.(10),N==="trailing"?f(e.messageId):b(e.messageId,e.isRead),M("none")},[f,b,e.messageId,e.isRead]),I=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),j=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),O=c.useCallback(()=>{x({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:N=>N,hash:p})},[x,p,n,e.threadId,e.messageId]),E=mn(e.messageId,d);return g||u?r.jsx(Ni,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:h,isDesktop:g,density:y}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(lo,{thread:zi(e),selectionMode:!1,checked:!1,active:t,peek:C,onPeek:M,onToggleCheck:j,onLongPress:I,onOpen:O,onAct:k})})},Di=72,Li=32,_i=5,cs="remit:list-density",Pi=()=>{try{const e=localStorage.getItem(cs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},$i=({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(Ws,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),Bi=(e,n,t)=>Eo(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,Wi=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:l,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:h=!1,isMoving:g=!1,onLoadMore:f,hasMore:b=!1,isLoadingMore:y=!1,accountId:C,listTitle:M,listMeta:x,listFilter:p,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:O=!1})=>{const E=c.useRef(null),N=Ge(),_=Xe(),A=Mo(),B=_s(),{verb:he,start:z,startFromSearch:Z}=B,Ie=Ps(),ne=!!a?.trim(),J=gn(),{labels:Fe}=wo(C),{pushError:re}=Vt(),[T,je]=c.useState(t),[De,q]=c.useState(),H=c.useCallback(m=>{q(S=>S===m?S:void 0),je(m)},[]),[ee,Le]=c.useState(Pi),ae=c.useCallback(()=>{Le(m=>{const S=m==="comfortable"?"compact":"comfortable";try{localStorage.setItem(cs,S)}catch{}return S})},[]),{toggleReadFor:we}=Yt({mailboxId:e}),{junkMailboxId:fe}=Xt(C),_e=Zt(fe,e),W=c.useMemo(()=>[{accountId:C,mailboxId:e}],[C,e]),{outcome:L,trashIsUnconfirmed:qe,staleFolderLabel:me}=pn(W),{selectedIds:G,selectedCount:U,hasSelection:oe,isSelected:Pe,toggle:Y,select:ke,clearSelection:le,selectRange:ce,setAnchor:F,selectAll:Te,toggleAll:Me,intersectWith:$e}=xn(),R=En(U,A),[Re,ge]=c.useState(null),He=ne&&!!d,Ze=`${e}|${JSON.stringify(d??{})}`,w=bn({mailboxId:e,accountId:C,enabled:He,predicateKey:Ze,searchQuery:d??{}}),et=c.useCallback((m,S,ue)=>{const $=vn(m,S,ue,L);$&&re($)},[re,L]),Ee=w.phase.kind,tt=w.clear,D=c.useCallback(()=>{Ee==="escalated"&&tt(),le()},[le,tt,Ee]),[st,nt]=c.useState(null),pe=c.useRef(null),ie=c.useRef(!1),xe=c.useRef(null),Ae=!s&&n.length>0,be=Re!==null,ve=ki({count:n.length,getScrollElement:()=>E.current,estimateSize:()=>ee==="compact"?Li:Di,overscan:_i}),Be=t?n.findIndex(m=>m.messageId===t):-1,te=T?n.findIndex(m=>m.messageId===T):-1,se=c.useCallback(m=>{if(m<0||m>=n.length)return;const S=n[m];if(R){Y(S.messageId);return}pe.current=S.messageId,ie.current=!1,q(S.messageId),je(S.messageId)},[n,R,Y]),Ue=c.useCallback(()=>{if(n.length===0)return;const m=te<0?0:Math.min(te+1,n.length-1);se(m)},[n.length,te,se]),Se=c.useCallback(()=>{if(n.length===0)return;const m=te<=0?0:te-1;se(m)},[n.length,te,se]),Oe=c.useCallback(()=>se(0),[se]),Ne=c.useCallback(()=>se(n.length-1),[se,n.length]),ot=c.useCallback(()=>{T&&Y(T)},[T,Y]),K=c.useMemo(()=>n.map(m=>m.messageId),[n]),xt=c.useMemo(()=>{const m=[];for(const S of n)G.has(S.messageId)&&m.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Ye(S.sentDate),accountId:C});return m},[n,G,C]),ye=c.useCallback((m,S)=>S.shiftKey?(ce(K,m,T),!0):S.metaKey||S.ctrlKey?(Y(m),!0):(D(),F(m),!1),[K,T,ce,Y,D,F]),it=c.useCallback(m=>{!u||m.length===0||(xe.current=T??null,ge(m))},[u,T]),We=c.useCallback(m=>{const S=Sn(K,T,m);S!==void 0&&(ce(K,S),pe.current=S,ie.current=!1,q(void 0),je(S))},[K,T,ce]),rt=c.useCallback(()=>We(-1),[We]),at=c.useCallback(()=>We(1),[We]),lt=c.useCallback(()=>{K.length>0&&Te(K)},[K,Te]),ct=c.useCallback(m=>{const S=Ri({verb:m,confirmingDelete:Re!==null,hasSelection:oe,junkMailboxId:fe,currentMailboxId:e,deletableMessageId:u?T:void 0});return S.kind==="openWizard"?(z(m),!0):S.kind==="confirmDelete"?(it([S.messageId]),!0):S.kind==="unavailable"?(re({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[Re,u,oe,fe,e,z,T,it,re]),de=c.useCallback((m,S)=>{const ue=n.find($=>$.messageId===m)?.threadId;ue&&N({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:ue,messageId:m},search:$=>$,hash:_,replace:S?.replace})},[N,_,e,n]),Ce=c.useCallback(()=>{T&&de(T)},[T,de]),dt=c.useCallback(m=>de(m,{replace:!0}),[de]);yn({keyboardFocusedMessageId:De,openMessageId:t,enabled:A&&U===0,open:dt});const Ke=w.phase.kind==="escalated"?{scope:Ot(d??{}),total:w.phase.total,searchQuery:d??{},run:m=>w.runAction(m),stop:w.stop}:void 0,bt=c.useCallback(m=>{if(m.length===0){ge(null);return}const S=new Set(m),ue=n.findIndex(Q=>S.has(Q.messageId));let $;for(let Q=ue+1;Q<n.length;Q++)if(!S.has(n[Q].messageId)){$=n[Q].messageId;break}if($===void 0){for(let Q=ue-1;Q>=0;Q--)if(!S.has(n[Q].messageId)){$=n[Q].messageId;break}}u?.(m),D(),xe.current=null,ge(null),$!==void 0&&(pe.current=$,ie.current=!1,H($),A&&de($,{replace:!0})),A||nt(Cn("delete",m.length,L))},[n,u,D,de,A,H,L]),vt=c.useCallback(()=>{const m=xe.current;xe.current=null,ge(null),m!==null&&(pe.current=m,ie.current=!1,H(m))},[H]),Qe=c.useMemo(()=>Bi(n,G,C),[C,G,n]),ut=c.useCallback(()=>{if(Ke){Z();return}z("organize")},[Ke,Z,z]),St=c.useCallback(m=>{u?.([m])},[u]),v=c.useCallback((m,S)=>{we([m],!S)},[we]),P=c.useCallback(m=>{A||ke(m)},[A,ke]),V=c.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}D()},[w,D]),fs=c.useCallback(()=>{w.clear()},[w]);c.useEffect(()=>{if(ie.current||!A&&t)return;const m=te>=0?te:Be;m>=0&&ve.scrollToIndex(m,{align:"auto"})},[te,Be,ve,A,t]),c.useEffect(()=>{t&&(ie.current=!1,H(t))},[t,H]),c.useEffect(()=>{T&&(n.some(m=>m.messageId===T)||H(n[0]?.messageId))},[n,T,H]),c.useEffect(()=>{I?.({focusedMessageId:T,selectedIds:Array.from(G),hasList:Ae,blocksKeyboard:be||B.isOpen})},[T,G,Ae,be,B.isOpen,I]);const Nt=c.useRef(I);Nt.current=I,c.useEffect(()=>()=>Nt.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||$e(n.map(m=>m.messageId))},[n,$e,w.phase,w.isRunning]);const zt=c.useRef(e);c.useEffect(()=>{zt.current!==e&&(zt.current=e,D())},[e,D]),In({shouldBlockFn:({action:m})=>Ei(m,oe,Ie)?(D(),!0):!1,enableBeforeUnload:!1,disabled:!oe||Ie!==void 0}),c.useEffect(()=>{const m=E.current;if(!m||!b||!f)return;const S=()=>{if(y)return;const{scrollTop:ue,scrollHeight:$,clientHeight:Q}=m;ue+Q>=$-200&&f()};return m.addEventListener("scroll",S,{passive:!0}),S(),()=>m.removeEventListener("scroll",S)},[b,y,f]),c.useEffect(()=>{const m=pe.current;if(!m)return;const S=E.current?.querySelector(`[data-message-id="${m}"]`);S&&(pe.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!Ae){j.current=null;return}return j.current={focusNext:Ue,focusPrevious:Se,focusFirst:Oe,focusLast:Ne,openFocused:Ce,toggleSelect:ot,extendSelectDown:at,extendSelectUp:rt,selectAll:lt,clearSelection:()=>oe?(D(),!0):!1,requestVerb:ct,toggleDensity:ae},()=>{j.current=null}}},[j,Ae,Ue,Se,Oe,Ne,Ce,ot,at,rt,lt,oe,D,ct,ae]);const Ft=s?"loading":o?"error":n.length===0?"empty":"ready",ms=o?jo(i):void 0,gs=c.useCallback(()=>{const m=$s(Bs());window.open(m,"_blank","noopener,noreferrer")},[]),ps=[{id:"inbox",threads:[]}],yt=K.length>0&&K.every(m=>G.has(m)),xs=He&&b&&yt&&!h&&!g&&w.phase.kind==="idle"&&!w.isRunning,bs=h||g||w.isRunning,Ct=w.phase.kind==="escalated"?w.phase.total:U,vs=w.runningAction?jn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??Ct):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?Mi(d??{},w.phase.total):void 0,Ss=w.phase.kind!=="escalated"&&K.length>0?{checked:yt,indeterminate:U>0&&!yt,onChange:()=>Me(K)}:void 0,ys=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??Ct,tone:wn(w.runningAction.kind)}:void 0,Cs=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:fs}}:xs?{tone:"info",text:"",action:{label:Ti(d??{}),onClick:w.escalate}}:void 0)??(Qe?{tone:"warning",text:Qe}:void 0),Is=r.jsx(kn,{title:J.title||M,navSlot:J.navSlot,titleMeta:J.titleMeta,searchSlot:J.searchSlot,searchField:J.searchField,idleSlot:J.makeFilterSlot,count:Ct,onCancel:V,onDelete:()=>z("delete"),onMove:()=>z("move"),onOrganize:ut,onJunk:_e?()=>z("junk"):void 0,onMarkRead:()=>z("markRead"),overflowSlot:C&&e&&U>0&&Fe.length>0?r.jsx(Ro,{accountId:C,mailboxId:e,messageIds:Array.from(G)}):void 0,isBusy:bs,isCounting:w.phase.kind==="counting",selectAll:Ss,statusLabel:vs,progress:ys,notice:Cs}),js=Tn(K,T),ws=c.useCallback(m=>{ie.current=!0,H(m)},[H]),ks=r.jsxs(r.Fragment,{children:[ne&&a&&r.jsx($i,{query:a}),r.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":M,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ve.getTotalSize()}px`},children:ve.getVirtualItems().map(m=>{const S=n[m.index];return r.jsx("div",{role:"presentation","data-index":m.index,ref:ve.measureElement,className:ze("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${m.start}px)`},children:r.jsx(Fi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:T===S.messageId,isTabStop:js===S.messageId,onFocusRow:ws,isChecked:Pe(S.messageId),onToggleCheck:Y,onRowSelect:ye,isMultiSelectMode:R,onLongPress:P,isDesktop:A,onDelete:St,onToggleRead:v,density:ee})},m.key)})}),y&&r.jsx(co,{})]})]});return r.jsxs(r.Fragment,{children:[st&&!A&&r.jsx(mt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>nt(null),children:st}),r.jsx(uo,{listTitle:M,listMeta:x,sections:ps,flatList:!0,listState:J.searchResults?"ready":Ft,searchQuery:ne?a:void 0,listFilter:p,listScopeLabel:k,errorMessage:ms,onRetry:l,onReportError:gs,density:ee,selectedThreadId:t,onSelectThread:m=>de(m),isDesktop:A,hideHeader:O,selectionBar:Is,listBody:J.searchResults??(Ft==="ready"?ks:void 0)}),r.jsx(Mn,{isOpen:Re!==null,messageIds:Re??[],outcome:L,accountId:C,trashFolderLabel:M,staleFolderLabel:me,trashIsUnconfirmed:qe,isDeleting:h,onConfirm:bt,onCancel:vt}),r.jsx(Rn,{verb:he,accountId:C,mailboxId:e,selection:xt,selectionRestriction:Qe?"spansAccounts":void 0,escalated:Ke,escalatedProgress:w.progress,onFinished:D,onRunEnded:et})]})},Ki=e=>qt({path:{accountId:e}}),Vi=e=>{const n=kt(),t=Rt(),s=Mt({...Ks(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},qi=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Vi(e);return r.jsx($o,{onRefresh:t,isRefreshing:s,children:n})};function Hi({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=Rt(),d=Vs(),{inboxMailboxId:u}=An(e),h=On(e),{data:g}=Tt({...qs({path:{accountId:e}}),staleTime:1/0}),f=c.useMemo(()=>Hs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),b=c.useMemo(()=>u||(f.find(p=>p.label.toLowerCase()==="inbox")?.id??f.find(p=>!p.isCurrent)?.id??""),[u,f]),y=c.useRef(!1);c.useEffect(()=>{y.current||(y.current=!0,Nn(a,t.length))},[a,t.length]);const C=c.useCallback(()=>{zn(a,t.length),l(!0)},[a,t.length]),M=c.useCallback((x,p)=>{Fn(a,{selected:x.length,total:t.length,toInbox:p===u}),s(x,p)},[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(Wo,{count:t.length,onReview:C})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:b,availableFolders:f,delimiter:Us(g?.items??[]),onConfirmMove:M,onCancel:()=>l(!1)})]})}const Ui=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Qi=({accountId:e,mailboxId:n})=>{const t=kt(),{pushError:s}=Vt(),{requestAppointment:o}=Qs(),{trashByAccount:i}=es(),l=e?i.get(e):void 0,a=Ui(e,n,l?.mailboxId,l?.source),[d,u]=c.useState({scope:a});d.scope!==a&&u({scope:a});const h=d.scope===a?d:void 0,g=c.useCallback(()=>t.getQueryData(Js())?.accounts.find(j=>j.accountId===e)?.folderAppointments.find(j=>j.role==="Trash")?.mailboxId??n,[t,e,n]),f=c.useRef(void 0),{mutateAsync:b,isPending:y}=Mt({...Xs(),onMutate:()=>(f.current=a,{scope:a,listMailboxId:g()}),onSuccess:(p,k,I)=>{I.scope===a&&u({scope:a,deletedCount:p.deletedCount})},onError:(p,k,I)=>{const j=Gs(p);if(!j){s({title:"Couldn't empty Trash",detail:Ys(p),error:p});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(p,k,I,j)=>{f.current===j?.scope&&(f.current=void 0),Dn(t,Ln([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:qt({path:{accountId:e}})})}}),C=c.useCallback(()=>e?(u({scope:a}),b({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,b]),M=c.useCallback(()=>{C()},[C]),x=c.useCallback(()=>{const p=h?.refusal;p&&o({accountId:p.accountId,role:p.role,reason:p.reason,action:{kind:"emptyTrash"},onAppointed:C})},[h,o,C]);return{emptyTrash:M,isEmptying:y&&f.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:x}},Ji="We can verify this sender";function Gi(e){const{data:n}=Tt({...Zs({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:Ji,trustSubReason:_n(s.senderTrust),senderTrust:s.senderTrust}))}}const Yi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Xi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(en)),ds=e=>Zi.has(e),er=e=>ds(e.category)||e.attributes.size>0,tr=e=>{const n={};ds(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Xi[t];s&&(n[s]=!0)}return n},sr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",nr=["category","unread","starred","attachments"],Bt=e=>JSON.stringify(nr.map(n=>e?.[n]??null)),or=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},ir=(e,n)=>{const t=or(e);return t?Bt(t)===Bt(n):!1},ht=e=>e[0],rr=e=>{const n=ht(e.filter(a=>a.type==="from").map(a=>a.value)),t=ht(e.filter(a=>a.type==="subject").map(a=>a.value)),s=ht(e.filter(a=>a.type==="category").map(a=>a.category)),o=ht(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,l=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}:{},...l!==void 0?{attachments:l}:{}}},ar=(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 lr(e,n={}){const t=rr(e),s={...t,...n};return{params:t,residual:e.filter(o=>!ar(s,o))}}function cr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Pn(o);return $n({...i,accountId:i.accountId??t},s)})}const dr=50,ur=new Map(os().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),us=c.createContext(null);function pt(){const e=c.useContext(us);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function hr({mailboxId:e,thread:n,children:t}){const s=Ge(),o=Xe(),i=n?.threadId,l=n?.messageId,a=Rt(),{accounts:d,searchQuery:u,onToggleIntelligence:h}=Ht(),g=rn(),f=Po(u),b=f.length>0,{freeText:y,tokens:C}=an(f,g),[M,x]=c.useState("all"),[p,k]=c.useState(new Set),I=c.useMemo(()=>({category:M,attributes:p}),[M,p]),j=c.useMemo(()=>tr(I),[I]),O=b||er(I),{params:E,residual:N}=lr(C,j),_={order:"desc",limit:dr,...y?{query:y}:{},...E,...j},A={category:_.category,unread:_.unread,starred:_.starred,attachments:_.attachments},B=O?tn({path:{mailboxId:e},query:_}):sn({path:{mailboxId:e},query:{order:"desc"}}),{data:he,isLoading:z,isError:Z,error:Ie,refetch:ne,fetchNextPage:J,hasNextPage:Fe,isFetchingNextPage:re}=ho({queryKey:B,queryFn:async({pageParam:v})=>{if(O){const{data:V}=await nn({path:{mailboxId:e},query:{..._,continuationToken:v},throwOnError:!0});return V}const{data:P}=await on({path:{mailboxId:e},query:{order:"desc",continuationToken:v},throwOnError:!0});return P},initialPageParam:void 0,getNextPageParam:v=>v.continuationToken,placeholderData:(v,P)=>ir(P?.queryKey,A)?v:void 0}),{accountId:T,isLoading:je}=Bn(e),De=Fo({accounts:d}),q=cr(Wn(Yi(he?.pages.flatMap(v=>v.items??[])??[])),N,T),H=c.useCallback(v=>{x(v)},[]),ee=c.useCallback(v=>{k(P=>{const V=new Set(P);return V.has(v)?V.delete(v):V.add(v),V})},[]),Le=c.useCallback(()=>{x("all"),k(new Set)},[]),ae=ur.get(M),we=ae?{label:ae,reach:N.length>0?"loaded-pages":sr(_),onClear:Le}:void 0,fe=i?q.find(v=>v.messageId===l)??q.find(v=>v.threadId===i):void 0,_e=Kn(i,l),W=fe??_e,L=l??W?.messageId,qe=c.useMemo(()=>{if(i)return{threadId:i,mailboxId:W?.mailboxId??e,subject:W?.subject,messageId:L,authenticity:W?.authenticity}},[i,W,L,e]),me=c.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:v=>v,hash:o})},[e,s,o]),G=c.useCallback(v=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...v},search:P=>P,hash:o})},[e,s,o]),U=c.useCallback(v=>{L&&v.includes(L)&&me()},[L,me]),{deleteMessages:oe,isPending:Pe}=Dt({mailboxId:e,onAfterOptimisticRemove:U}),{moveMessages:Y,isPending:ke}=Lt({mailboxId:e,accountId:T,onAfterOptimisticRemove:U}),le=c.useRef(null),ce=Vn(),{listCommandsRef:F,onTriageContextChange:Te,focusedMessageId:Me,selectedIds:$e}=ce,R=q.find(v=>v.messageId===Me)??W,Re=Do({accounts:d})??0,ge=qn({thread:W,mailboxId:e,accountId:T,onAfterOptimisticRemove:U}),{draftsMailboxId:He}=Hn(T),Ze=He!==void 0&&He===e,{archiveMailboxId:w}=Un(T),et=Qn(),Ee=xo(),tt=c.useMemo(()=>bo(Ee,i,L),[Ee,i,L]),D=c.useMemo(()=>{if(R)return v=>Ee({threadId:R.threadId,messageId:R.messageId,mode:v})},[Ee,R]),st=vo(),nt=So(),pe=yo(),ie=c.useCallback(v=>v?et(v):[],[et]),{toggleStar:xe}=Jn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:Ae}=Yt({mailboxId:e,accountId:T}),{junkMailboxId:be}=Xt(T),ve=be!=null&&be===e,Be=Zt(be,e),{candidates:te}=Gi(ve?be:void 0),{moveMessages:se}=Lt({mailboxId:e,threadId:R?.threadId,accountId:T,onAfterOptimisticRemove:U}),{deleteMessages:Ue}=Dt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:U}),{addressId:Se,address:Oe}=Gn(R),{updateFlags:Ne}=Yn({addressId:Se,senderEmail:R?.fromEmail??void 0}),ot=c.useCallback(()=>D?.("reply"),[D]),K=c.useCallback(()=>D?.("reply-all"),[D]),xt=c.useCallback(()=>D?.("forward"),[D]),ye=c.useCallback(()=>ie(R),[ie,R]),it=c.useCallback(()=>{if(F.current?.requestVerb("delete"))return;const v=ye();v.length>0&&Ue(v)},[F,ye,Ue]),We=c.useCallback(()=>{if(F.current?.requestVerb("junk")||!Be)return;const v=ye();v.length!==0&&(Xn(a,{count:v.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?Zn(R):!1}),se(v,Be))},[F,Be,ye,se,a,R]),rt=c.useCallback(()=>{if($e.length>0){const v=!(R?.hasStars??!1),P=new Set($e);for(const V of q)P.has(V.messageId)&&V.hasStars!==v&&xe(V.messageId,V.hasStars);return}R&&xe(R.messageId,R.hasStars)},[$e,q,R,xe]),at=c.useCallback(()=>{if(F.current?.requestVerb("markRead"))return;const v=ye();if(v.length===0)return;const P=!(R?.isRead??!1);Ae(v,P)},[F,ye,R,Ae]),lt=c.useCallback(()=>{if(!Se)return;const v=Oe?.flags?.muted?.value!==!0;Ne({muted:{value:v}})},[Se,Oe,Ne]),ct=c.useCallback(()=>{if(!Se)return;const v=Oe?.flags?.vip?.value!==!0;Ne({vip:{value:v}})},[Se,Oe,Ne]),de=c.useCallback(()=>{le.current?.open()},[]),Ce=c.useCallback(v=>{s({to:v})},[s]),dt=Ze?"drafts":w===e?"archive":be===e?"junk":"inbox",Ke=c.useRef("");c.useEffect(()=>{const v=Ke.current;Ke.current=f,f.length>0&&v.length===0&&a.recordEvent("search.submitted",{mailboxType:dt})},[f,dt,a]);const{goBack:bt,nextMessageId:vt,previousMessageId:Qe}=eo({context:ce,orderedIds:q.map(v=>v.messageId),selectedMessageId:L,enabled:!st&&!nt,onClose:me,handlers:{reply:ot,replyAll:K,forward:xt,delete:it,toggleStar:rt,toggleRead:at,muteSender:lt,blockSender:W?de:void 0,vipSender:ct,markJunk:We,toggleIntelligence:W?()=>le.current?.toggle():void 0,compose:pe,goBrief:()=>Ce("/mail/brief"),goInbox:()=>Ce("/mail/brief"),goSent:()=>Ce("/mail/brief"),goFlagged:()=>Ce("/mail/flagged"),goSettings:()=>Ce("/settings")}}),ut=v=>{if(!v)return;const P=q.find(V=>V.messageId===v);return P?{threadId:P.threadId,messageId:v}:void 0},St={mailboxId:e,selectedMessageId:L,selectedThread:W,conversation:qe,onOpenThread:G,threads:q,isLoading:z,isError:Z,error:Ie,mailboxAccountId:T,mailboxAccountLoading:je,mailboxName:De,unreadCount:Re,isDraftsMailbox:Ze,isSpamFolder:ve,rescueCandidates:te,filterCategory:M,filterAttributes:p,onSelectFilterCategory:H,onToggleFilterAttribute:ee,onClearFilters:Le,listFilter:we,onToggleIntelligence:h,intelligenceRef:le,handleDeselectIfRemoved:U,searchPredicate:b&&N.length===0?_:void 0,onDeleteMessages:oe,onMoveMessages:Y,isDeleting:Pe,isMoving:ke,onLoadMore:J,hasMore:Fe,isLoadingMore:re,onTriageContextChange:Te,listCommandsRef:F,onRetry:()=>ne(),onReply:tt,onToolbarDelete:ge.deleteThread,onToolbarStar:ge.toggleStar,onToolbarMove:ge.moveThread,onBack:bt,nextThread:ut(vt),previousThread:ut(Qe)};return r.jsx(us.Provider,{value:St,children:t})}function hs(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:l,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:f,mailboxAccountId:b,mailboxName:y,unreadCount:C,isDraftsMailbox:M,isSpamFolder:x,rescueCandidates:p,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:O,filterAttributes:E,onSelectFilterCategory:N,onToggleFilterAttribute:_,onClearFilters:A,listFilter:B,searchPredicate:he}=pt(),{searchQuery:z,searchInput:Z,accounts:Ie,resultFolderIndex:ne}=Ht(),J=Lo(),Fe=Ge(),re=Xe(),T=y??"Inbox",je=c.useMemo(()=>os(),[]),{trashMailboxId:De}=io(b),q=_o({accounts:Ie}),{trashByAccount:H}=es(),ee=Qi({accountId:b,mailboxId:e}),Le=De!=null&&De===e,ae=c.useMemo(()=>b?[b]:[],[b]),{hasNewMail:we}=cn(),{state:fe,errorMessage:_e,refresh:W}=dn(ae,{onSettled:j}),L=c.useMemo(()=>r.jsx(un,{state:fe,onRefresh:W,label:`Refresh ${T}`,errorMessage:_e,hasUpdate:we(ae)}),[fe,W,T,_e,we,ae]),qe=c.useMemo(()=>t.map(F=>ro(F,ne)),[t,ne]),{hits:me,isLoading:G}=Ao({mailboxId:e,filterCategory:O}),U=c.useMemo(()=>ao(me,t.map(F=>F.threadId),ne),[me,t,ne]),oe=c.useCallback(F=>{const Te=F.threadId??t.find(Me=>Me.messageId===F.id)?.threadId;Te&&Fe({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:F.mailboxId??e,threadId:Te,messageId:F.id},search:Me=>({...Me,q:Z||void 0}),hash:re})},[e,Fe,re,Z,t]);if(M&&b)return r.jsx(ri,{mailboxId:e,accountId:b,selectedMessageId:n,imapThreads:t,title:y??"Drafts",unreadCount:C??void 0});const Pe=r.jsx(Wi,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:z,searchPredicate:he,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:f,accountId:b,listTitle:T,listFilter:B,listScopeLabel:T,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),Y=Ie[0]?.accountId,ke=J==="phone"&&Y?r.jsx(qi,{accountId:Y,children:Pe}):Pe,le=x&&p.length>0&&b?r.jsx(Hi,{accountId:b,currentMailboxId:e,candidates:p,onMove:a,children:ke}):ke,ce=Le?r.jsx(ci,{messageCount:q,isEmptying:ee.isEmptying,deletedCount:ee.deletedCount,refusalReason:ee.refusal?.reason,trashFolderLabel:y??void 0,staleFolderLabel:b?H.get(b)?.staleFolderPath:void 0,onEmpty:ee.emptyTrash,onRepair:ee.repair,children:le}):le;return r.jsx(fo,{title:T,unreadCount:C,preset:je,selectedCategory:O,activeFilters:E,onSelectCategory:N,onToggleFilter:_,onClearFilters:A,searchResults:qe,searchLoading:s,relatedResults:U,relatedLoading:G,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:L,children:ce})}function fr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,onToolbarMove:d,handleDeselectIfRemoved:u,intelligenceRef:h}=pt(),g=!!o,f=no(o?.threadId);ts(h,f);const b=c.useRef(null),{railFits:y,openRail:C}=f;c.useEffect(()=>{if(!y)return;const x=s?.messageId??null;x&&b.current!==x&&s?.authenticity?.dkimMismatch&&(b.current=x,C())},[y,C,s?.messageId,s?.authenticity?.dkimMismatch]);const M=o?r.jsx(ss,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:f.open}):r.jsx(ln,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(oo,{hasThread:g,messageId:o?.messageId,intelligenceOpen:f.isShowing,canToggleIntelligence:f.canToggle,onToggleIntelligence:f.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?l:void 0,onToggleStar:g?a:void 0,isStarred:s?.hasStars,moveContext:g&&n?{accountId:n,currentMailboxId:e,onMove:d}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:M})]}),r.jsx(ns,{isOpen:f.drawerOpen,onClose:f.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:u})]})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=pt();return r.jsx(so,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function gr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=pt(),h=to(s?.threadId??null);return ts(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(ss,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:h.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:a?()=>o(a):void 0,mobileIntelligenceOpen:h.isOpen}),r.jsx(ns,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(hs,{})}const _r=Object.assign(hr,{List:hs,Reading:fr,Intelligence:mr,Phone:gr});export{_r as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as n,j as a,B as o}from"./index-
|
|
1
|
+
import{i as n,j as a,B as o}from"./index-D_YBuI3z.js";import{M as e}from"./menu-B4mmeG34.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};
|