@remit/web-client-dist 0.0.488 → 0.0.490
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-8e5wD9U2.js → BriefPane-Chh89Ls8.js} +1 -1
- package/assets/{CalendarComposePane-CnkwI8w6.js → CalendarComposePane-B0ESup6A.js} +1 -1
- package/assets/{CalendarComposeSeed-bGtEytNs.js → CalendarComposeSeed-BuYpzJin.js} +1 -1
- package/assets/{CalendarShell-D8nnETBx.js → CalendarShell-B4Ev9evX.js} +1 -1
- package/assets/{EmptyState-Bnpl3mxy.js → EmptyState-BxLeI5a7.js} +1 -1
- package/assets/{ErrorState-BN1KI1QC.js → ErrorState-B16NlU7u.js} +1 -1
- package/assets/{FlaggedPane--S_CB4Cc.js → FlaggedPane-Dz6az4Ch.js} +1 -1
- package/assets/{FullCompose-BOiOQ-Qf.js → FullCompose-CKDKSEUF.js} +1 -1
- package/assets/{MailListHeader-D3QJgz1J.js → MailListHeader-CxqJgX-k.js} +1 -1
- package/assets/{MailNav-BmcDEbrF.js → MailNav-54pF4-Wf.js} +1 -1
- package/assets/{MailShell-CZF1GQXr.js → MailShell-DA_4KXyC.js} +1 -1
- package/assets/{MailViewChrome-BSKS3ijj.js → MailViewChrome-BDmv5d9y.js} +1 -1
- package/assets/{MailboxPane-M3YI2Lhj.js → MailboxPane-Cot-E3G4.js} +1 -1
- package/assets/{NavMenuButton-DZeoJSH-.js → NavMenuButton-FBbQvMN0.js} +1 -1
- package/assets/{OnboardingWizard-Dpl2R9Cy.js → OnboardingWizard-BuifJm-8.js} +1 -1
- package/assets/OpenCalendarEvent-BcgQLU8V.js +2 -0
- package/assets/{OutboxPane-uihHargp.js → OutboxPane-BUzXwXuC.js} +1 -1
- package/assets/_calendarObjectId-mny-4EXP.js +1 -0
- package/assets/_mailboxId-DSVCDMo4.js +1 -0
- package/assets/_messageId-BGcgfODq.js +1 -0
- package/assets/_messageId-DYefqN3E.js +1 -0
- package/assets/_messageId-DhbKo3B6.js +1 -0
- package/assets/_outboxMessageId-CtUxM86V.js +1 -0
- package/assets/_recurrenceId-CG1uEnuq.js +1 -0
- package/assets/_threadId-BuNYV3q0.js +1 -0
- package/assets/_threadId-D4jC1uwj.js +1 -0
- package/assets/_threadId-owspbibg.js +1 -0
- package/assets/_view._date-W-1Y9W21.js +1 -0
- package/assets/{accounts-Coh0pl5z.js → accounts--qzTAuMz.js} +1 -1
- package/assets/{advanced-BMnUr3k2.js → advanced-BCOHYqWC.js} +1 -1
- package/assets/{appearance-Cc_1nX_R.js → appearance-B_BCHiNs.js} +1 -1
- package/assets/{attachment-file-DEgj4Vud.js → attachment-file-vWrTKKNW.js} +1 -1
- package/assets/{avatar-jIsSo2Zf.js → avatar-BxToBov5.js} +1 -1
- package/assets/{bottom-sheet-DheWfAIR.js → bottom-sheet-BVBJeXZ0.js} +1 -1
- package/assets/{brief-CcZTo542.js → brief-1IhifgBt.js} +1 -1
- package/assets/brief-D6axyIWt.js +1 -0
- package/assets/{browser-ponyfill-B4xJekFS.js → browser-ponyfill-C_e5y55O.js} +1 -1
- package/assets/{bug-D1kIQg-0.js → bug-B_S4InDq.js} +1 -1
- package/assets/{calendar-DxJZvi6b.js → calendar-Cxa7ah-g.js} +1 -1
- package/assets/{calendar-days-C_HOm0G3.js → calendar-days-CPA8pt11.js} +1 -1
- package/assets/{card-BvJM4Bar.js → card-CQW-PX25.js} +1 -1
- package/assets/chevron-left-ywps-Gyo.js +1 -0
- package/assets/{circle-check-DtpNGVtU.js → circle-check-BkneSfe9.js} +1 -1
- package/assets/{circle-check-big-UXLrOtDo.js → circle-check-big-Dge9pLwP.js} +1 -1
- package/assets/{circle-help-Bn8ystJn.js → circle-help-BIrTTaE1.js} +1 -1
- package/assets/{clock-a9wtJIFb.js → clock-jA6Z_hAe.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BsmyGcLW.js +1 -0
- package/assets/compose._-_outboxMessageId_-CWb5oqtG.js +1 -0
- package/assets/compose._-_outboxMessageId_-Cz4sST6-.js +1 -0
- package/assets/compose._-_outboxMessageId_-ON1pjxCP.js +1 -0
- package/assets/{config-import-B94_wCpF.js → config-import-BW-n-4Yl.js} +1 -1
- package/assets/{confirm-dialog-5hKuL5ov.js → confirm-dialog-BAOm_tmO.js} +1 -1
- package/assets/{credential-steps-DJcQCoMN.js → credential-steps-DxrEA0OS.js} +1 -1
- package/assets/{download-CiAfXfNQ.js → download-CsyaiJfT.js} +1 -1
- package/assets/{filters-BNAxy-pd.js → filters-ENJaCJ6i.js} +1 -1
- package/assets/{flagged-C0mYVO9Q.js → flagged-CHS7Sv5L.js} +1 -1
- package/assets/flagged-ClM4D6w4.js +1 -0
- package/assets/{folders-B8E9XQGy.js → folders-RAY3kNRb.js} +1 -1
- package/assets/{format-CxG3FNVs.js → format-CTO21bLP.js} +1 -1
- package/assets/{help-copy-DC0qUPIv.js → help-copy-CHa0UGds.js} +1 -1
- package/assets/{import-mtITAI1H.js → import-vggCfFY7.js} +1 -1
- package/assets/index-3e125Hab.js +1 -0
- package/assets/index-BGcgfODq.js +1 -0
- package/assets/index-BM0UvHaM.js +1 -0
- package/assets/index-BcqF5DIR.js +1 -0
- package/assets/index-CSZc00Y0.js +1 -0
- package/assets/index-Cn0HxZE8.js +1 -0
- package/assets/{index-Bcu7BqZh.js → index-CvHgBKzk.js} +61 -61
- package/assets/{index-BW01bO1J.js → index-D-XMtAaX.js} +8 -8
- package/assets/{index-DThWcnpG.js → index-D23sIPjL.js} +1 -1
- package/assets/index-DYefqN3E.js +1 -0
- package/assets/index-Da7gFljw.js +1 -0
- package/assets/index-JhCVbgdu.js +1 -0
- package/assets/{kbd-wWeybs89.js → kbd-CFfFFeOa.js} +1 -1
- package/assets/{labels-RhvMKifz.js → labels-JtbKl6kA.js} +1 -1
- package/assets/{mail-WRNyVFjV.js → mail-BtsVUuTG.js} +1 -1
- package/assets/{mail-BAbQAZ9G.js → mail-DxviAVO4.js} +1 -1
- package/assets/{menu-BXqls5WZ.js → menu-z3yGPHVO.js} +1 -1
- package/assets/minus-DgJyoX-1.js +1 -0
- package/assets/{new-CzBf8alD.js → new-Bn847M0C.js} +1 -1
- package/assets/onboarding-DxcXNbpR.js +1 -0
- package/assets/{onboarding-completion-lWgQaoiS.js → onboarding-completion-BibtVMVq.js} +1 -1
- package/assets/outbox-B0Er3Qme.js +1 -0
- package/assets/{pencil-CkHvTVt7.js → pencil-D4BuHCoD.js} +1 -1
- package/assets/{rich-text-CTg_ypvW.js → rich-text-1RhkdX-3.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-DNPJIUYl.js → rich-text-spellcheck-worker-provider-CyU5XlL_.js} +1 -1
- package/assets/{rotate-ccw-Coc_HVFv.js → rotate-ccw-BAMGL0nD.js} +1 -1
- package/assets/{row-actions-D6pg-4y5.js → row-actions-NntamOda.js} +1 -1
- package/assets/{search-mirror-Csy2vxLR.js → search-mirror-iyqYtIOH.js} +1 -1
- package/assets/{search-token-index-B4kJtFA_.js → search-token-index-CMEbenCb.js} +1 -1
- package/assets/{sections-DT0azgaj.js → sections-kEi5uTHL.js} +1 -1
- package/assets/{senders-DzxfBV7S.js → senders-BCbJ8qc6.js} +1 -1
- package/assets/settings-DS8owM2f.js +1 -0
- package/assets/{settings-screen-EigWdTdk.js → settings-screen-Bas4TeYt.js} +1 -1
- package/assets/{shield-check-CWXSXjpp.js → shield-check-BncfAN35.js} +1 -1
- package/assets/{suggested-vips-HChlmA8o.js → suggested-vips-BXyjY5hr.js} +1 -1
- package/assets/useCalendarData-DDXYjxV5.js +1 -0
- package/assets/useCalendars-C17p7Nzh.js +1 -0
- package/assets/{useDebouncedValue-jtTlNJDr.js → useDebouncedValue-DT0N2ZZ8.js} +1 -1
- package/assets/{useFilters-BxnI0t9W.js → useFilters-CFGQOfNb.js} +1 -1
- package/assets/{useLabels-C-ytwpWV.js → useLabels-4QZ-fg0L.js} +1 -1
- package/assets/{useLayoutTier-P9na-5Xh.js → useLayoutTier-CRRZIH_b.js} +1 -1
- package/assets/{useMessageBodyContent-ClKIcNPh.js → useMessageBodyContent-DAz3qVkt.js} +1 -1
- package/assets/{useQueries-4YYdm8Yg.js → useQueries-BxE36uj9.js} +1 -1
- package/assets/{useRefreshControl-BMS0clfU.js → useRefreshControl-D87kZX8a.js} +1 -1
- package/assets/{useSearchTokenContext-BW55Y3Yb.js → useSearchTokenContext-Dvm-Yobe.js} +4 -4
- package/assets/useSemanticSearch-Fk64TQcq.js +1 -0
- package/assets/{useSignature-BISqUCGf.js → useSignature-uiUpBdh0.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/OpenCalendarEvent-kYb3ZTPU.js +0 -2
- package/assets/_calendarObjectId-B1Oalf3b.js +0 -1
- package/assets/_mailboxId-DdbPW7YF.js +0 -1
- package/assets/_messageId-BP9-n-lV.js +0 -1
- package/assets/_messageId-C-cSawQe.js +0 -1
- package/assets/_messageId-mWUrP87X.js +0 -1
- package/assets/_outboxMessageId-IVVtaP13.js +0 -1
- package/assets/_recurrenceId-DMP1BEIN.js +0 -1
- package/assets/_threadId-C5CRN2ch.js +0 -1
- package/assets/_threadId-DOK4zcvh.js +0 -1
- package/assets/_threadId-qUW2tqRz.js +0 -1
- package/assets/_view._date-Djnasj-2.js +0 -1
- package/assets/brief-Dln7pOiH.js +0 -1
- package/assets/chevron-left-DLqD6AAq.js +0 -1
- package/assets/compose._-_outboxMessageId_-BEQR2RT3.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bdvxfy8-.js +0 -1
- package/assets/compose._-_outboxMessageId_-CUn9IfOQ.js +0 -1
- package/assets/compose._-_outboxMessageId_-YNuTsqHY.js +0 -1
- package/assets/flagged-BYKUghBm.js +0 -1
- package/assets/index-BP9-n-lV.js +0 -1
- package/assets/index-C-cSawQe.js +0 -1
- package/assets/index-CpVVKgK6.js +0 -1
- package/assets/index-Crs0s6jC.js +0 -1
- package/assets/index-DAUjRbOW.js +0 -1
- package/assets/index-DHdIEMDT.js +0 -1
- package/assets/index-DX4E3icM.js +0 -1
- package/assets/index-DXZ_UtbG.js +0 -1
- package/assets/index-Dz7e4G6z.js +0 -1
- package/assets/minus-BaGFpEMe.js +0 -1
- package/assets/onboarding-D7fm-uK7.js +0 -1
- package/assets/outbox-BJe-Ixj_.js +0 -1
- package/assets/settings-HKkjK28O.js +0 -1
- package/assets/useCalendarData-Uek-8FpX.js +0 -1
- package/assets/useCalendars-Rv-pJFtI.js +0 -1
- package/assets/useSemanticSearch-BrrFjCJ5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bJ as js,bK as Ts,j as r,cB as ws,B as dt,f as te,V as ks,t as Ee,g as Pt,r as c,Y as Ms,Z as Rs,bh as Es,h as It,c as jt,ac as As,i as Tt,cC as Os,cs as Ns,I as zs,a6 as Fs,a2 as Bt,bG as Ds,bc as Ls,cD as _s,cE as Ps,as as $t,aY as Bs,aZ as $s,a1 as Ws,q as wt,m as Ks,N as Wt,bf as Vs,G as qs,bg as Hs,aV as Us,cF as Qs,o as Js,cG as Gs,cq as Ys,cH as Zs,cI as Xs,cJ as en,C as Kt,c6 as tn,ah as sn,cK as nn,cL as on,aj as rn,cM as an,bq as ln}from"./index-Bcu7BqZh.js";import{u as cn,p as dn,R as un}from"./useSearchTokenContext-BW55Y3Yb.js";import{u as hn,a as fn,R as mn}from"./useRefreshControl-BMS0clfU.js";import{C as Vt,a as qt,c as Ht,j as gn,M as pn,t as Ut,u as xn,b as bn,d as Qt,e as Jt,f as vn,g as Sn,h as yn,r as Cn,n as In,i as jn,k as Tn,l as wn,m as kn,o as Mn,S as Rn,p as En,D as An,q as On,s as Nn,v as Gt,w as zn,x as Fn,y as Dn,z as Ln,A as _n,B as Yt,E as Pn,F as Bn,G as $n,H as Wn,I as Kn,J as Vn,K as Nt,L as zt,N as qn,O as Hn,P as Un,Q as Qn,R as Jn,T as Gn,U as Yn,V as Zn,W as Xn,X as eo,Y as to,Z as so,_ as Zt,$ as Xt,a0 as es,a1 as no,a2 as oo,a3 as io,a4 as ts,a5 as ro,a6 as ao,a7 as lo}from"./MailListHeader-D3QJgz1J.js";import{S as co,M as uo,a as ho,u as fo,b as mo}from"./MailViewChrome-BSKS3ijj.js";import{A as kt}from"./avatar-jIsSo2Zf.js";import{b as Qe,d as go,c as ss}from"./format-CxG3FNVs.js";import{c as po,f as xo,a as bo,u as vo}from"./useMessageBodyContent-ClKIcNPh.js";import{g as Je,i as So,t as yo,h as Co,j as Io,k as jo,l as To}from"./search-token-index-B4kJtFA_.js";import{N as wo}from"./NavMenuButton-DZeoJSH-.js";import{C as ko}from"./confirm-dialog-5hKuL5ov.js";import{f as Mo}from"./ErrorState-BN1KI1QC.js";import{a as Ro}from"./useLabels-C-ytwpWV.js";import{L as Eo,r as Ao,u as Oo}from"./useSemanticSearch-BrrFjCJ5.js";import{S as ut}from"./shield-check-CWXSXjpp.js";import{B as No}from"./bottom-sheet-DheWfAIR.js";import{C as zo}from"./circle-help-Bn8ystJn.js";import{C as Fo}from"./circle-check-DtpNGVtU.js";import{u as Do}from"./useLayoutTier-P9na-5Xh.js";import{n as Lo}from"./search-query-Cr_ZXBCp.js";import{u as _o}from"./sections-DT0azgaj.js";const Po=({children:e,onRefresh:n,isRefreshing:t})=>js(Ts)?e:r.jsx(ws,{onRefresh:n,isPullable:!t,children:e}),Bo=e=>e===1?"message":"messages";function $o({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(dt,{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(ut,{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(te,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Wo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",ns=({senderTrust:e,size:n="sm",className:t})=>{const s=Wo(e,n);return s==="vip"?r.jsx(ks,{className:Ee("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:Ee("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 Ko({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:Ee("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(Vt,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(kt,{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(ns,{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(Pt,{tone:"positive",children:[r.jsx(ut,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Vo=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)},qo=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ft=e=>e===1?"message":"messages";function Ho({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=qo(e,n),a=e.messages.length,d=o?Ms:Rs;return r.jsxs("div",{className:Ee(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(Vt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Ft(a)} from ${e.senderName}`}),r.jsx(kt,{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(ns,{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(Pt,{tone:"positive",children:[r.jsx(ut,{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} ${Ft(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(Ko,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Mt=e=>e===1?"message":"messages",Uo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Mt(e)}`} out of Spam to ${n} now. Nothing later.`,Ct=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Qo(){return r.jsx(dt,{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 Jo({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(()=>Vo(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(ut,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(zo,{className:"size-3.5"}),onClick:()=>u(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(Qo,{})})]}),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(te,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(te,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(Ho,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(te,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Mt(h)}`}),r.jsx(te,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Go({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(Es,{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:Ct(n,s)}),r.jsx(te,{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:Uo(e,Ct(n,s))}),r.jsx(te,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(te,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Yo({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(Fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Mt(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(te,{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,m]=c.useState(t),[p,C]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(d("review"),h(new Set(n.map(I=>I.id))),m(t),C(0)),b.current=e},[e,n,t]);const w=u.size,v=I=>{h(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},x=(I,j)=>{h(E=>{const A=new Set(E);for(const L of I.messages)j?A.add(L.id):A.delete(L.id);return A})},k=()=>{const I=Array.from(u);C(I.length),i(I,g),d("done")};return r.jsxs(No,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Jo,{candidates:n,selected:u,onToggle:v,onToggleGroup:x,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Go,{count:w,folders:s,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Yo,{count:p,destinationLabel:Ct(s,g),onClose:l})]})}function Xo(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:Qe(e.updatedAt),isRead:!0}}function ei(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function ti({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(Xo),o=t.map(ei),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 si=({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})]}),ni=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ee("group",Ht({active:n})),children:[r.jsx(Fs,{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(Bt,{className:"size-3.5"})})})]}),oi=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ee("group",Ht({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(kt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(qt,{thread:e})]})};function ii({accountId:e,selectedMessageId:n,imapThreads:t,title:s,unreadCount:o}){const i=po(),l=xo(),a=Je(),d=It(),{data:u}=jt(As()),h=c.useMemo(()=>ti({outboxMessages:u?.items??[],accountId:e,imapThreads:t}),[u?.items,e,t]),g=Tt({...Ns(),onSuccess:()=>{d.invalidateQueries({queryKey:Os()})}}),m=b=>{g.mutate({path:{outboxMessageId:b}})},p=b=>{const w=t.find(v=>v.messageId===b)?.threadId;w&&a({threadId:w,messageId:b})},C=h.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(wo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(o??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[o," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:C?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{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."})]}):h.map(b=>r.jsxs("div",{children:[b.label&&r.jsx(si,{label:b.label,count:b.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:b.threads.map(w=>b.id==="remit-drafts"?r.jsx(ni,{row:w,isSelected:w.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},w.id):r.jsx(oi,{row:w,isSelected:w.id===n,onOpen:p},w.id))})]},b.id))})]})}const os=e=>e===1?"1 message":`${ss(e)} messages`,ri=e=>({title:"Empty Trash?",description:`${os(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),ai=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=go(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 li({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?ai(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,m=ri(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:`${os(t)} erased from the mail server.`}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Bt,{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(dt,{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(te,{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(ko,{isOpen:u,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function ci(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 _e(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 Dt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const di=(e,n)=>Math.abs(e-n)<1.01,ui=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Ue;const St=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>"u")return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;const e=navigator.maxTouchPoints;return Ue=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Lt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},hi=e=>e,fi=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},mi=(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(Lt(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(Lt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ct={passive:!0},gi=typeof window>"u"?!0:"onscrollend"in window,pi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&gi;let l=0;const a=i?null:ui(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,ct),i&&s.addEventListener("scrollend",h,ct),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},xi=(e,n)=>pi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),bi=(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"]},vi=(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})},Si=vi;class yi{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:hi,rangeExtractor:fi,onChange:()=>{},measureElement:bi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(i[m]=p)}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 m=l.count,p=i.count,C=this.getMeasurements(),b=m>0?((s=C[0])==null?void 0:s.key)??l.getItemKey(0):null,w=m>0?((o=C[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==b||i.getItemKey(p-1)!==w)){u=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==w)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,C=this.getMeasurements(),{count:b,getItemKey:w}=this.options;let v=0;for(;v<b&&w(v)!==m;)v++;if(v<b){const x=C[v];if(x){const k=x.start+p;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=_e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,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,!(!St()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ct),i.addEventListener("touchend",a,ct),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&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,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=_e(()=>[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 v of this.laneAssignments.keys())v>=t&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const v=t*2;let x=this._flatMeasurements;if(!x||x.length<v){const j=new Float64Array(v);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let k;if(m===0)k=s+o;else{const j=m-1;k=x[j*2]+x[j*2+1]+u}for(let j=m;j<t;j++){const E=i(j),A=g.get(E),L=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=k,x[j*2+1]=L,k+=L+u}const I=ci(t,x,i);return this.measurementsCache=I,I}const p=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),b=new Float64Array(a);let w=0;for(let v=0;v<m;v++){const x=p[v];x&&(C[x.lane]===void 0&&w++,C[x.lane]=v,b[x.lane]=x.end)}for(let v=m;v<t;v++){const x=i(v),k=this.laneAssignments.get(v);let I,j;const E=d==="estimate"||g.has(x);if(k!==void 0&&this.options.lanes>1){I=k;const F=C[I],J=F!==void 0?p[F]:void 0;j=J?J.end+u:s+o}else if(w===a){let F=0,J=b[0],_=C[0];for(let G=1;G<a;G++){const se=b[G];(se<J||se===J&&C[G]<_)&&(F=G,J=se,_=C[G])}I=F,j=J+u,E&&this.laneAssignments.set(v,I)}else I=v%this.options.lanes,j=s+o,E&&this.laneAssignments.set(v,I);const A=g.get(x),L=typeof A=="number"?A:this.options.estimateSize(v),O=j+L;p[v]={index:v,start:j,size:L,end:O,key:x,lane:I},C[I]===void 0&&w++,C[I]=v,b[I]=O}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Ii(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,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 m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,C=((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++,m?this.applyScrollAdjustment(this.getTotalSize()-p):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=_e(()=>[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=is(0,s.length-1,i?a=>o[a*2]:a=>Dt(s[a]).start,t);return Dt(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&&(St()&&(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&&di(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 is=(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 Ci(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 Ii(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=Ci(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=is(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 yt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function ji({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 v=u.options.horizontal?"width":"height";h.container.style[v]=`${g}px`}const m=!!u.options.horizontal,p=h.mode==="transform",C=m?"left":"top",b=u.options.scrollMargin,w=u.getVirtualItems();for(const v of w){const x=v.start-b,k=u.elementsCache.get(v.key);k&&h.lastPositions.get(k)!==x&&(h.lastPositions.set(k,x),p?k.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:k.style[C]=`${x}px`)}},a={...s,onChange:(u,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(u);const C=u.range,b=m.prevRange;p=!b||b.isScrolling!==u.isScrolling||b.startIndex!==C?.startIndex||b.endIndex!==C?.endIndex,p&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:u.isScrolling}:null)}p&&(e&&h?Ds.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new yi(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const p=u.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return d.setOptions(a),yt(()=>d._didMount(),[]),yt(()=>d._willUpdate()),yt(()=>{l(d)}),d}function Ti(e){return ji({observeElementRect:mi,observeElementOffset:xi,scrollToFn:Si,...e})}const Rt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",wi=e=>`Select all ${Rt(e)}`,ki=(e,n)=>`All ${ss(n)} ${Rt(e)} selected`,Mi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=gn(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}},Ri=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ei=(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Ai=({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:m,density:p})=>r.jsx(pn,{thread:Ei(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Oi=c.memo(Ai),Ni=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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),suspicious:n}},zi=({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:m,onToggleRead:p,density:C})=>{const[b,w]=c.useState("none"),v=Je(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),w("none")},[m,p,e.messageId,e.isRead]),k=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{v({threadId:e.threadId,messageId:e.messageId})},[v,e.threadId,e.messageId]),E=xn(e.messageId,d);return g||u?r.jsx(Oi,{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:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(co,{thread:Ni(e),selectionMode:!1,checked:!1,active:t,peek:b,onPeek:w,onToggleCheck:I,onLongPress:k,onOpen:j,onAct:x})})},Fi=72,Di=32,Li=5,rs="remit:list-density",_i=()=>{try{const e=localStorage.getItem(rs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Pi=({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)=>Ao(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,$i=({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:m,hasMore:p=!1,isLoadingMore:C=!1,accountId:b,listTitle:w,listMeta:v,listFilter:x,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),L=Je(),O=Ls(),F=_s(),{verb:J,start:_,startFromSearch:G}=F,se=Ps(),pe=!!a?.trim(),P=bn(),{labels:Pe}=Ro(b),{pushError:ae}=$t(),[M,Ce]=c.useState(t),[W,Ie]=c.useState(),K=c.useCallback(f=>{Ie(S=>S===f?S:void 0),Ce(f)},[]),[D,Be]=c.useState(_i),xe=c.useCallback(()=>{Be(f=>{const S=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(rs,S)}catch{}return S})},[]),{toggleReadFor:be}=Qt({mailboxId:e}),{junkMailboxId:le}=Jt(b),Ae=Gt(le,e),Oe=c.useMemo(()=>[{accountId:b,mailboxId:e}],[b,e]),{outcome:ce,staleFolderLabel:V,guessedMailboxId:q}=vn(Oe),{selectedIds:X,selectedCount:H,hasSelection:oe,isSelected:Ne,toggle:ee,select:je,clearSelection:de,selectRange:ue,setAnchor:N,selectAll:Te,toggleAll:$e,intersectWith:ze}=Sn(),R=Nn(H,O),[Fe,he]=c.useState(null),We=pe&&!!d,Ge=`${e}|${JSON.stringify(d??{})}`,T=yn({mailboxId:e,accountId:b,enabled:We,predicateKey:Ge,searchQuery:d??{}}),Ye=c.useCallback((f,S,ge)=>{const Q=Cn(f,S,ge,ce);Q&&ae(Q)},[ae,ce]),we=T.phase.kind,Ze=T.clear,z=c.useCallback(()=>{we==="escalated"&&Ze(),de()},[de,Ze,we]),[Xe,et]=c.useState(null),ve=c.useRef(null),ie=c.useRef(!1),Se=c.useRef(null),ke=!s&&n.length>0,ne=Ti({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>D==="compact"?Di:Fi,overscan:Li}),Ke=t?n.findIndex(f=>f.messageId===t):-1,Y=M?n.findIndex(f=>f.messageId===M):-1,re=c.useCallback(f=>{if(f<0||f>=n.length)return;const S=n[f];if(R){ee(S.messageId);return}ve.current=S.messageId,ie.current=!1,Ie(S.messageId),Ce(S.messageId)},[n,R,ee]),Ve=c.useCallback(()=>{if(n.length===0)return;const f=Y<0?0:Math.min(Y+1,n.length-1);re(f)},[n.length,Y,re]),qe=c.useCallback(()=>{if(n.length===0)return;const f=Y<=0?0:Y-1;re(f)},[n.length,Y,re]),ye=c.useCallback(()=>re(0),[re]),Me=c.useCallback(()=>re(n.length-1),[re,n.length]),Re=c.useCallback(()=>{M&&ee(M)},[M,ee]),B=c.useMemo(()=>n.map(f=>f.messageId),[n]),ft=c.useMemo(()=>{const f=[];for(const S of n)X.has(S.messageId)&&f.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Qe(S.sentDate),accountId:b});return f},[n,X,b]),mt=c.useCallback((f,S)=>S.shiftKey?(ue(B,f,M),!0):S.metaKey||S.ctrlKey?(ee(f),!0):(z(),N(f),!1),[B,M,ue,ee,z,N]),fe=c.useCallback(f=>{!u||f.length===0||(Se.current=M??null,he(f))},[u,M]),De=c.useCallback(f=>{const S=In(B,M,f);S!==void 0&&(ue(B,S),ve.current=S,ie.current=!1,Ie(void 0),Ce(S))},[B,M,ue]),tt=c.useCallback(()=>De(-1),[De]),st=c.useCallback(()=>De(1),[De]),nt=c.useCallback(()=>{B.length>0&&Te(B)},[B,Te]),ot=c.useCallback(f=>{const S=Mi({verb:f,confirmingDelete:Fe!==null,hasSelection:oe,junkMailboxId:le,currentMailboxId:e,deletableMessageId:u?M:void 0});return S.kind==="openWizard"?(_(f),!0):S.kind==="confirmDelete"?(fe([S.messageId]),!0):S.kind==="unavailable"?(ae({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[Fe,u,oe,le,e,_,M,fe,ae]),me=c.useCallback((f,S)=>{const ge=n.find(Q=>Q.messageId===f)?.threadId;ge&&L({threadId:ge,messageId:f},{replace:S?.replace})},[L,n]),it=c.useCallback(()=>{M&&me(M)},[M,me]),rt=c.useCallback(f=>me(f,{replace:!0}),[me]);jn({keyboardFocusedMessageId:W,openMessageId:t,enabled:O&&H===0,open:rt});const Le=T.phase.kind==="escalated"?{scope:Rt(d??{}),total:T.phase.total,searchQuery:d??{},run:f=>T.runAction(f),stop:T.stop}:void 0,gt=c.useCallback(f=>{if(f.length===0){he(null);return}const S=new Set(f),ge=n.findIndex(Z=>S.has(Z.messageId));let Q;for(let Z=ge+1;Z<n.length;Z++)if(!S.has(n[Z].messageId)){Q=n[Z].messageId;break}if(Q===void 0){for(let Z=ge-1;Z>=0;Z--)if(!S.has(n[Z].messageId)){Q=n[Z].messageId;break}}u?.(f),z(),Se.current=null,he(null),Q!==void 0&&(ve.current=Q,ie.current=!1,K(Q),O&&me(Q,{replace:!0})),O||et(Tn("delete",f.length,ce))},[n,u,z,me,O,K,ce]),pt=c.useCallback(()=>{const f=Se.current;Se.current=null,he(null),f!==null&&(ve.current=f,ie.current=!1,K(f))},[K]),He=c.useMemo(()=>Bi(n,X,b),[b,X,n]),at=c.useCallback(()=>{if(Le){G();return}_("organize")},[Le,G,_]),xt=c.useCallback(f=>{u?.([f])},[u]),y=c.useCallback((f,S)=>{be([f],!S)},[be]),U=c.useCallback(f=>{O||je(f)},[O,je]),$=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}z()},[T,z]),ds=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(ie.current||!O&&t)return;const f=Y>=0?Y:Ke;f>=0&&ne.scrollToIndex(f,{align:"auto"})},[Y,Ke,ne,O,t]),c.useEffect(()=>{t&&(ie.current=!1,K(t))},[t,K]),c.useEffect(()=>{M&&(n.some(f=>f.messageId===M)||K(n[0]?.messageId))},[n,M,K]),c.useEffect(()=>{I?.({focusedMessageId:M,selectedIds:Array.from(X),hasList:ke})},[M,X,ke,I]);const Et=c.useRef(I);Et.current=I,c.useEffect(()=>()=>Et.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||ze(n.map(f=>f.messageId))},[n,ze,T.phase,T.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,z())},[e,z]),wn({shouldBlockFn:({action:f})=>Ri(f,oe,se)?(z(),!0):!1,enableBeforeUnload:!1,disabled:!oe||se!==void 0}),c.useEffect(()=>{const f=A.current;if(!f||!p||!m)return;const S=()=>{if(C)return;const{scrollTop:ge,scrollHeight:Q,clientHeight:Z}=f;ge+Z>=Q-200&&m()};return f.addEventListener("scroll",S,{passive:!0}),S(),()=>f.removeEventListener("scroll",S)},[p,C,m]),c.useEffect(()=>{const f=ve.current;if(!f)return;const S=A.current?.querySelector(`[data-message-id="${f}"]`);S&&(ve.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!ke){j.current=null;return}return j.current={focusNext:Ve,focusPrevious:qe,focusFirst:ye,focusLast:Me,openFocused:it,toggleSelect:Re,extendSelectDown:st,extendSelectUp:tt,selectAll:nt,clearSelection:()=>oe?(z(),!0):!1,requestVerb:ot,toggleDensity:xe},()=>{j.current=null}}},[j,ke,Ve,qe,ye,Me,it,Re,st,tt,nt,oe,z,ot,xe]);const Ot=s?"loading":o?"error":n.length===0?"empty":"ready",us=o?Mo(i):void 0,hs=c.useCallback(()=>{const f=Bs($s());window.open(f,"_blank","noopener,noreferrer")},[]),fs=[{id:"inbox",threads:[]}],bt=B.length>0&&B.every(f=>X.has(f)),ms=We&&p&&bt&&!h&&!g&&T.phase.kind==="idle"&&!T.isRunning,gs=h||g||T.isRunning,vt=T.phase.kind==="escalated"?T.phase.total:H,ps=T.runningAction?kn(T.runningAction.kind,T.progress?.done??0,T.progress?.total??vt):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?ki(d??{},T.phase.total):void 0,xs=T.phase.kind!=="escalated"&&B.length>0?{checked:bt,indeterminate:H>0&&!bt,onChange:()=>$e(B)}:void 0,bs=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??vt,tone:Mn(T.runningAction.kind)}:void 0,vs=(T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"&&!T.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:ds}}:ms?{tone:"info",text:"",action:{label:wi(d??{}),onClick:T.escalate}}:void 0)??(He?{tone:"warning",text:He}:void 0),Ss=r.jsx(Rn,{title:P.title||w,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:vt,onCancel:$,onDelete:()=>_("delete"),onMove:()=>_("move"),onOrganize:at,onJunk:Ae?()=>_("junk"):void 0,onMarkRead:()=>_("markRead"),overflowSlot:b&&e&&H>0&&Pe.length>0?r.jsx(Eo,{accountId:b,mailboxId:e,messageIds:Array.from(X)}):void 0,isBusy:gs,isCounting:T.phase.kind==="counting",selectAll:xs,statusLabel:ps,progress:bs,notice:vs}),ys=En(B,M),Cs=c.useCallback(f=>{ie.current=!0,K(f)},[K]),Is=r.jsxs(r.Fragment,{children:[pe&&a&&r.jsx(Pi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":w,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ne.getTotalSize()}px`},children:ne.getVirtualItems().map(f=>{const S=n[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ne.measureElement,className:Ee("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(zi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:M===S.messageId,isTabStop:ys===S.messageId,onFocusRow:Cs,isChecked:Ne(S.messageId),onToggleCheck:ee,onRowSelect:mt,isMultiSelectMode:R,onLongPress:U,isDesktop:O,onDelete:xt,onToggleRead:y,density:D})},f.key)})}),C&&r.jsx(uo,{})]})]});return r.jsxs(r.Fragment,{children:[Xe&&!O&&r.jsx(dt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>et(null),children:Xe}),r.jsx(ho,{listTitle:w,listMeta:v,sections:fs,flatList:!0,listState:P.searchResults?"ready":Ot,searchQuery:pe?a:void 0,listFilter:x,listScopeLabel:k,errorMessage:us,onRetry:l,onReportError:hs,density:D,selectedThreadId:t,onSelectThread:f=>me(f),isDesktop:O,hideHeader:E,selectionBar:Ss,listBody:P.searchResults??(Ot==="ready"?Is:void 0)}),r.jsx(An,{isOpen:Fe!==null,messageIds:Fe??[],outcome:ce,accountId:b,trashFolderLabel:w,staleFolderLabel:V,guessedMailboxId:q,isDeleting:h,onConfirm:gt,onCancel:pt}),r.jsx(On,{verb:J,accountId:b,mailboxId:e,selection:ft,selectionRestriction:He?"spansAccounts":void 0,escalated:Le,escalatedProgress:T.progress,onFinished:z,onRunEnded:Ye})]})},Wi=e=>Wt({path:{accountId:e}}),Ki=e=>{const n=It(),t=wt(),s=Tt({...Ks(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Wi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Vi=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Ki(e);return r.jsx(Po,{onRefresh:t,isRefreshing:s,children:n})};function qi({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,l]=c.useState(!1),a=wt(),d=Vs(),{inboxMailboxId:u}=zn(e),h=Fn(e),{data:g}=jt({...qs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>Hs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),p=c.useMemo(()=>u||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[u,m]),C=c.useRef(!1);c.useEffect(()=>{C.current||(C.current=!0,Dn(a,t.length))},[a,t.length]);const b=c.useCallback(()=>{Ln(a,t.length),l(!0)},[a,t.length]),w=c.useCallback((v,x)=>{_n(a,{selected:v.length,total:t.length,toInbox:x===u}),s(v,x)},[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($o,{count:t.length,onReview:b})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Us(g?.items??[]),onConfirmMove:w,onCancel:()=>l(!1)})]})}const Hi=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Ui=({accountId:e,mailboxId:n})=>{const t=It(),{pushError:s}=$t(),{requestAppointment:o}=Qs(),{trashByAccount:i}=Yt(),l=e?i.get(e):void 0,a=Hi(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]),m=c.useRef(void 0),{mutateAsync:p,isPending:C}=Tt({...Zs(),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,k,I)=>{I.scope===a&&u({scope:a,deletedCount:x.deletedCount})},onError:(x,k,I)=>{const j=Gs(x);if(!j){s({title:"Couldn't empty Trash",detail:Ys(x),error:x});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(x,k,I,j)=>{m.current===j?.scope&&(m.current=void 0),So(t,yo([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),b=c.useCallback(()=>e?(u({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),w=c.useCallback(()=>{b()},[b]),v=c.useCallback(()=>{const x=h?.refusal;x&&o({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:b})},[h,o,b]);return{emptyTrash:w,isEmptying:C&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:v}},Qi="We can verify this sender";function Ji(e){const{data:n}=jt({...Xs({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:Qi,trustSubReason:Pn(s.senderTrust),senderTrust:s.senderTrust}))}}const Gi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Yi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(en)),as=e=>Zi.has(e),Xi=e=>as(e.category)||e.attributes.size>0,er=e=>{const n={};as(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Yi[t];s&&(n[s]=!0)}return n},tr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",sr=["category","unread","starred","attachments"],_t=e=>JSON.stringify(sr.map(n=>e?.[n]??null)),nr=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},or=(e,n)=>{const t=nr(e);return t?_t(t)===_t(n):!1},lt=e=>e[0],ir=e=>{const n=lt(e.filter(a=>a.type==="from").map(a=>a.value)),t=lt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=lt(e.filter(a=>a.type==="category").map(a=>a.category)),o=lt(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}:{}}},rr=(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 ar(e,n={}){const t=ir(e),s={...t,...n};return{params:t,residual:e.filter(o=>!rr(s,o))}}function lr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Bn(o);return $n({...i,accountId:i.accountId??t},s)})}const cr=50,dr=new Map(ts().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ls=c.createContext(null);function ht(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ur({mailboxId:e,thread:n,children:t}){const s=Je(),o=Co(),i=_o(),l=n?.threadId,a=n?.messageId,d=wt(),{accounts:u,searchQuery:h,onToggleIntelligence:g}=Kt(),m=cn(),p=Lo(h),C=p.length>0,{freeText:b,tokens:w}=dn(p,m),[v,x]=c.useState("all"),[k,I]=c.useState(new Set),j=c.useMemo(()=>({category:v,attributes:k}),[v,k]),E=c.useMemo(()=>er(j),[j]),A=C||Xi(j),{params:L,residual:O}=ar(w,E),F={order:"desc",limit:cr,...b?{query:b}:{},...L,...E},J={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},_=A?tn({path:{mailboxId:e},query:F}):sn({path:{mailboxId:e},query:{order:"desc"}}),{data:G,isLoading:se,isError:pe,error:P,refetch:Pe,fetchNextPage:ae,hasNextPage:M,isFetchingNextPage:Ce}=fo({queryKey:_,queryFn:async({pageParam:y})=>{if(A){const{data:$}=await an({path:{mailboxId:e},query:{...F,continuationToken:y},throwOnError:!0});return $}const{data:U}=await ln({path:{mailboxId:e},query:{order:"desc",continuationToken:y},throwOnError:!0});return U},initialPageParam:void 0,getNextPageParam:y=>y.continuationToken,placeholderData:(y,U)=>or(U?.queryKey,J)?y:void 0}),{accountId:W,isLoading:Ie}=Wn(e),K=Io({accounts:u}),D=lr(Kn(Gi(G?.pages.flatMap(y=>y.items??[])??[])),O,W),Be=c.useCallback(y=>{x(y)},[]),xe=c.useCallback(y=>{I(U=>{const $=new Set(U);return $.has(y)?$.delete(y):$.add(y),$})},[]),be=c.useCallback(()=>{x("all"),I(new Set)},[]),le=dr.get(v),Ae=le?{label:le,reach:O.length>0?"loaded-pages":tr(F),onClear:be}:void 0,Oe=l?D.find(y=>y.messageId===a)??D.find(y=>y.threadId===l):void 0,ce=Vn(l,a),V=Oe??ce,q=a??V?.messageId,X=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:V?.mailboxId??e,subject:V?.subject,messageId:q,authenticity:V?.authenticity}},[l,V,q,e]),H=c.useCallback(y=>{q&&y.includes(q)&&o()},[q,o]),{deleteMessages:oe,isPending:Ne}=Nt({mailboxId:e,onAfterOptimisticRemove:H}),{moveMessages:ee,isPending:je}=zt({mailboxId:e,accountId:W,onAfterOptimisticRemove:H}),de=c.useRef(null),ue=qn(),{listCommandsRef:N,onTriageContextChange:Te,focusedMessageId:$e,selectedIds:ze}=ue,R=D.find(y=>y.messageId===$e)??V,Fe=jo({accounts:u})??0,he=Hn({thread:V,isOpen:!0,mailboxId:e,accountId:W,onAfterOptimisticRemove:H}),{draftsMailboxId:We}=Un(W),Ge=We!==void 0&&We===e,{archiveMailboxId:T}=Qn(W),Ye=Jn(),we=nn(),Ze=c.useMemo(()=>on(we,l,q),[we,l,q]),z=c.useMemo(()=>{if(R)return y=>we({threadId:R.threadId,messageId:R.messageId,mode:y})},[we,R]),Xe=bo(),et=rn(),ve=vo(),ie=c.useCallback(y=>y?Ye(y):[],[Ye]),{toggleStar:Se}=Gn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:ke}=Qt({mailboxId:e,accountId:W}),{junkMailboxId:ne}=Jt(W),Ke=ne!=null&&ne===e,Y=Gt(ne,e),{candidates:re}=Ji(Ke?ne:void 0),{moveMessages:Ve}=zt({mailboxId:e,threadId:R?.threadId,accountId:W,onAfterOptimisticRemove:H}),{deleteMessages:qe}=Nt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:H}),{addressId:ye,address:Me}=Yn(R),{updateFlags:Re}=Zn({addressId:ye,senderEmail:R?.fromEmail??void 0}),B=c.useCallback(()=>z?.("reply"),[z]),ft=c.useCallback(()=>z?.("reply-all"),[z]),mt=c.useCallback(()=>z?.("forward"),[z]),fe=c.useCallback(()=>ie(R),[ie,R]),De=c.useCallback(()=>{if(N.current?.requestVerb("delete"))return;const y=fe();y.length>0&&qe(y)},[N,fe,qe]),tt=c.useCallback(()=>{if(N.current?.requestVerb("junk")||!Y)return;const y=fe();y.length!==0&&(Xn(d,{count:y.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?eo(R):!1}),Ve(y,Y))},[N,Y,fe,Ve,d,R]),st=c.useCallback(()=>{if(ze.length>0){const y=!(R?.hasStars??!1),U=new Set(ze);for(const $ of D)U.has($.messageId)&&$.hasStars!==y&&Se($.messageId,$.hasStars);return}R&&Se(R.messageId,R.hasStars)},[ze,D,R,Se]),nt=c.useCallback(()=>{if(N.current?.requestVerb("markRead"))return;const y=fe();if(y.length===0)return;const U=!(R?.isRead??!1);ke(y,U)},[N,fe,R,ke]),ot=c.useCallback(()=>{if(!ye)return;const y=Me?.flags?.muted?.value!==!0;Re({muted:{value:y}})},[ye,Me,Re]),me=c.useCallback(()=>{if(!ye)return;const y=Me?.flags?.vip?.value!==!0;Re({vip:{value:y}})},[ye,Me,Re]),it=c.useCallback(()=>{de.current?.open()},[]),rt=Ge?"drafts":T===e?"archive":ne===e?"junk":"inbox",Le=c.useRef("");c.useEffect(()=>{const y=Le.current;Le.current=p,p.length>0&&y.length===0&&d.recordEvent("search.submitted",{mailboxType:rt})},[p,rt,d]);const{goBack:gt,nextMessageId:pt,previousMessageId:He}=to({context:ue,orderedIds:D.map(y=>y.messageId),selectedMessageId:q,enabled:!Xe&&!et,hasOpenThread:l!==void 0,onClose:o,handlers:{reply:B,replyAll:ft,forward:mt,delete:De,toggleStar:st,toggleRead:nt,muteSender:ot,blockSender:V?it:void 0,vipSender:me,markJunk:tt,toggleIntelligence:V?()=>de.current?.toggle():void 0,compose:ve,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),at=y=>{if(!y)return;const U=D.find($=>$.messageId===y);return U?{threadId:U.threadId,messageId:y}:void 0},xt={mailboxId:e,selectedMessageId:q,selectedThread:V,conversation:X,onOpenThread:s,threads:D,isLoading:se,isError:pe,error:P,mailboxAccountId:W,mailboxAccountLoading:Ie,mailboxName:K,unreadCount:Fe,isDraftsMailbox:Ge,isSpamFolder:Ke,rescueCandidates:re,filterCategory:v,filterAttributes:k,onSelectFilterCategory:Be,onToggleFilterAttribute:xe,onClearFilters:be,listFilter:Ae,onToggleIntelligence:g,intelligenceRef:de,handleDeselectIfRemoved:H,searchPredicate:C&&O.length===0?F:void 0,onDeleteMessages:oe,onMoveMessages:ee,isDeleting:Ne,isMoving:je,onLoadMore:ae,hasMore:M,isLoadingMore:Ce,onTriageContextChange:Te,listCommandsRef:N,onRetry:()=>Pe(),onReply:Ze,onToolbarDelete:he.deleteThread,onToolbarStar:he.toggleStar,isStarred:he.isStarred,onToolbarMove:he.moveThread,onBack:gt,nextThread:at(pt),previousThread:at(He)};return r.jsx(ls.Provider,{value:xt,children:t})}function cs(){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:m,mailboxAccountId:p,mailboxName:C,unreadCount:b,isDraftsMailbox:w,isSpamFolder:v,rescueCandidates:x,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:L,onToggleFilterAttribute:O,onClearFilters:F,listFilter:J,searchPredicate:_}=ht(),{searchQuery:G,searchInput:se,accounts:pe,resultFolderIndex:P}=Kt(),Pe=Do(),ae=Je(),M=C??"Inbox",Ce=c.useMemo(()=>ts(),[]),{trashMailboxId:W}=ro(p),Ie=To({accounts:pe}),{trashByAccount:K}=Yt(),D=Ui({accountId:p,mailboxId:e}),Be=W!=null&&W===e,xe=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:be}=hn(),{state:le,errorMessage:Ae,refresh:Oe}=fn(xe,{onSettled:j}),ce=c.useMemo(()=>r.jsx(mn,{state:le,onRefresh:Oe,label:`Refresh ${M}`,errorMessage:Ae,hasUpdate:be(xe)}),[le,Oe,M,Ae,be,xe]),V=c.useMemo(()=>t.map(N=>ao(N,P)),[t,P]),{hits:q,isLoading:X}=Oo({mailboxId:e,filterCategory:E}),H=c.useMemo(()=>lo(q,t.map(N=>N.threadId),P),[q,t,P]),oe=c.useCallback(N=>{const Te=N.threadId??t.find($e=>$e.messageId===N.id)?.threadId;Te&&ae({threadId:Te,messageId:N.id},{mailboxId:N.mailboxId??e,query:se})},[e,ae,se,t]);if(w&&p)return r.jsx(ii,{accountId:p,selectedMessageId:n,imapThreads:t,title:C??"Drafts",unreadCount:b??void 0});const Ne=r.jsx($i,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:G,searchPredicate:_,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:J,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),ee=pe[0]?.accountId,je=Pe==="phone"&&ee?r.jsx(Vi,{accountId:ee,children:Ne}):Ne,de=v&&x.length>0&&p?r.jsx(qi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:je}):je,ue=Be?r.jsx(li,{messageCount:Ie,isEmptying:D.isEmptying,deletedCount:D.deletedCount,refusalReason:D.refusal?.reason,trashFolderLabel:C??void 0,staleFolderLabel:p?K.get(p)?.staleFolderPath:void 0,onEmpty:D.emptyTrash,onRepair:D.repair,children:de}):de;return r.jsx(mo,{title:M,unreadCount:b,preset:Ce,selectedCategory:E,activeFilters:A,onSelectCategory:L,onToggleFilter:O,onClearFilters:F,searchResults:V,searchLoading:s,relatedResults:H,relatedLoading:X,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:ce,children:ue})}function hr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:d,onToolbarMove:u,handleDeselectIfRemoved:h,intelligenceRef:g}=ht(),m=!!o,p=oo(o?.threadId);Zt(g,p);const C=c.useRef(null),{railFits:b,openRail:w}=p;c.useEffect(()=>{if(!b)return;const x=s?.messageId??null;x&&C.current!==x&&s?.authenticity?.dkimMismatch&&(C.current=x,w())},[b,w,s?.messageId,s?.authenticity?.dkimMismatch]);const v=o?r.jsx(Xt,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(un,{});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(io,{hasThread:m,messageId:o?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:d,moveContext:m&&n?{accountId:n,currentMailboxId:e,onMove:u}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v})]}),r.jsx(es,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:h})]})}function fr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=ht();return r.jsx(no,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=ht(),h=so(s?.threadId??null);return Zt(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(Xt,{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(es,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(cs,{})}const _r=Object.assign(ur,{List:cs,Reading:hr,Intelligence:fr,Phone:mr});export{_r as M};
|
|
1
|
+
import{bN as js,bO as Ts,j as r,cF as ws,B as dt,f as te,V as ks,t as Ee,g as Pt,r as c,Y as Ms,Z as Rs,bh as Es,h as It,c as jt,ac as As,i as Tt,cG as Os,cw as Ns,I as zs,a6 as Fs,a2 as Bt,bH as Ds,bc as Ls,cH as _s,cI as Ps,as as $t,aY as Bs,aZ as $s,a1 as Ws,q as wt,m as Vs,N as Wt,bf as Ks,G as Hs,bg as qs,aV as Us,cJ as Qs,o as Js,cK as Gs,cu as Ys,cL as Zs,cM as Xs,cN as en,C as Vt,ca as tn,ah as sn,cO as nn,cP as on,aj as rn,cQ as an,bq as ln}from"./index-CvHgBKzk.js";import{u as cn,p as dn,R as un}from"./useSearchTokenContext-Dvm-Yobe.js";import{u as hn,a as fn,R as mn}from"./useRefreshControl-D87kZX8a.js";import{C as Kt,a as Ht,c as qt,j as gn,M as pn,t as Ut,u as xn,b as bn,d as Qt,e as Jt,f as vn,g as Sn,h as yn,r as Cn,n as In,i as jn,k as Tn,l as wn,m as kn,o as Mn,S as Rn,p as En,D as An,q as On,s as Nn,v as Gt,w as zn,x as Fn,y as Dn,z as Ln,A as _n,B as Yt,E as Pn,F as Bn,G as $n,H as Wn,I as Vn,J as Kn,K as Nt,L as zt,N as Hn,O as qn,P as Un,Q as Qn,R as Jn,T as Gn,U as Yn,V as Zn,W as Xn,X as eo,Y as to,Z as so,_ as Zt,$ as Xt,a0 as es,a1 as no,a2 as oo,a3 as io,a4 as ts,a5 as ro,a6 as ao,a7 as lo}from"./MailListHeader-CxqJgX-k.js";import{S as co,M as uo,a as ho,u as fo,b as mo}from"./MailViewChrome-BDmv5d9y.js";import{A as kt}from"./avatar-BxToBov5.js";import{b as Qe,d as go,c as ss}from"./format-CTO21bLP.js";import{c as po,f as xo,a as bo,u as vo}from"./useMessageBodyContent-DAz3qVkt.js";import{g as Je,i as So,t as yo,h as Co,j as Io,k as jo,l as To}from"./search-token-index-CMEbenCb.js";import{N as wo}from"./NavMenuButton-FBbQvMN0.js";import{C as ko}from"./confirm-dialog-BAOm_tmO.js";import{f as Mo}from"./ErrorState-B16NlU7u.js";import{a as Ro}from"./useLabels-4QZ-fg0L.js";import{L as Eo,r as Ao,u as Oo}from"./useSemanticSearch-Fk64TQcq.js";import{S as ut}from"./shield-check-BncfAN35.js";import{B as No}from"./bottom-sheet-BVBJeXZ0.js";import{C as zo}from"./circle-help-BIrTTaE1.js";import{C as Fo}from"./circle-check-BkneSfe9.js";import{u as Do}from"./useLayoutTier-CRRZIH_b.js";import{n as Lo}from"./search-query-Cr_ZXBCp.js";import{u as _o}from"./sections-kEi5uTHL.js";const Po=({children:e,onRefresh:n,isRefreshing:t})=>js(Ts)?e:r.jsx(ws,{onRefresh:n,isPullable:!t,children:e}),Bo=e=>e===1?"message":"messages";function $o({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(dt,{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(ut,{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(te,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const Wo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",ns=({senderTrust:e,size:n="sm",className:t})=>{const s=Wo(e,n);return s==="vip"?r.jsx(ks,{className:Ee("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:Ee("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:Ee("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(Kt,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?l:`message from ${o}`}`}),!s&&r.jsx(kt,{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(ns,{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(Pt,{tone:"positive",children:[r.jsx(ut,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const Ko=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"},Ft=e=>e===1?"message":"messages";function qo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=c.useState(!1),l=Ho(e,n),a=e.messages.length,d=o?Ms:Rs;return r.jsxs("div",{className:Ee(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(Kt,{className:"mt-0.5",checked:l==="all",indeterminate:l==="some",onChange:()=>t(e,l!=="all"),"aria-label":`${l==="all"?"Deselect":"Select"} all ${a} ${Ft(a)} from ${e.senderName}`}),r.jsx(kt,{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(ns,{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(Pt,{tone:"positive",children:[r.jsx(ut,{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} ${Ft(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 Mt=e=>e===1?"message":"messages",Uo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Mt(e)}`} out of Spam to ${n} now. Nothing later.`,Ct=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Qo(){return r.jsx(dt,{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 Jo({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(()=>Ko(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(ut,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(zo,{className:"size-3.5"}),onClick:()=>u(m=>!m),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(Qo,{})})]}),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(te,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(te,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:g.map(m=>r.jsx(qo,{group:m,selected:n,onToggleGroup:s,onToggleMessage:t},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(te,{variant:"primary",onClick:l,className:"h-11 w-full font-semibold",children:`Continue with ${h} ${Mt(h)}`}),r.jsx(te,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Go({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(Es,{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:Ct(n,s)}),r.jsx(te,{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:Uo(e,Ct(n,s))}),r.jsx(te,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(te,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Back"})]})]})}function Yo({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(Fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Mt(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(te,{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,m]=c.useState(t),[p,C]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(d("review"),h(new Set(n.map(I=>I.id))),m(t),C(0)),b.current=e},[e,n,t]);const w=u.size,v=I=>{h(j=>{const E=new Set(j);return E.has(I)?E.delete(I):E.add(I),E})},x=(I,j)=>{h(E=>{const A=new Set(E);for(const L of I.messages)j?A.add(L.id):A.delete(L.id);return A})},k=()=>{const I=Array.from(u);C(I.length),i(I,g),d("done")};return r.jsxs(No,{open:e,onClose:l,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(Jo,{candidates:n,selected:u,onToggle:v,onToggleGroup:x,onSelectAll:()=>h(new Set(n.map(I=>I.id))),onSelectNone:()=>h(new Set),onContinue:()=>d("destination"),onCancel:l}),a==="destination"&&r.jsx(Go,{count:w,folders:s,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>d("review")}),a==="done"&&r.jsx(Yo,{count:p,destinationLabel:Ct(s,g),onClose:l})]})}function Xo(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:Qe(e.updatedAt),isRead:!0}}function ei(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function ti({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(l=>l.status==="draft"&&l.accountId===n).map(Xo),o=t.map(ei),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 si=({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})]}),ni=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ee("group",qt({active:n})),children:[r.jsx(Fs,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(Ht,{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(Bt,{className:"size-3.5"})})})]}),oi=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Ee("group",qt({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(kt,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(Ht,{thread:e})]})};function ii({accountId:e,selectedMessageId:n,imapThreads:t,title:s,unreadCount:o}){const i=po(),l=xo(),a=Je(),d=It(),{data:u}=jt(As()),h=c.useMemo(()=>ti({outboxMessages:u?.items??[],accountId:e,imapThreads:t}),[u?.items,e,t]),g=Tt({...Ns(),onSuccess:()=>{d.invalidateQueries({queryKey:Os()})}}),m=b=>{g.mutate({path:{outboxMessageId:b}})},p=b=>{const w=t.find(v=>v.messageId===b)?.threadId;w&&a({threadId:w,messageId:b})},C=h.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(wo,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),(o??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[o," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:C?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{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."})]}):h.map(b=>r.jsxs("div",{children:[b.label&&r.jsx(si,{label:b.label,count:b.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:b.threads.map(w=>b.id==="remit-drafts"?r.jsx(ni,{row:w,isSelected:w.id===i,onOpen:l,onDelete:m,isDeleting:g.isPending},w.id):r.jsx(oi,{row:w,isSelected:w.id===n,onOpen:p},w.id))})]},b.id))})]})}const os=e=>e===1?"1 message":`${ss(e)} messages`,ri=e=>({title:"Empty Trash?",description:`${os(e)} ${e===1?"is":"are"} erased from the mail server and cannot be restored.`,confirmLabel:"Empty Trash"}),ai=(e,n={})=>{const{trashFolderLabel:t,staleFolderLabel:s}=n;if(e==="unconfirmed"){const o=go(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 li({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?ai(s,{trashFolderLabel:o,staleFolderLabel:i}):void 0,m=ri(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:`${os(t)} erased from the mail server.`}),r.jsx(te,{variant:"ghost",size:"sm",icon:r.jsx(Bt,{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(dt,{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(te,{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(ko,{isOpen:u,title:m.title,description:m.description,confirmLabel:m.confirmLabel,destructive:!0,onConfirm:()=>{h(!1),l()},onCancel:()=>h(!1)})]})}function ci(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 _e(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 Dt(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const di=(e,n)=>Math.abs(e-n)<1.01,ui=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let Ue;const St=()=>{if(Ue!==void 0)return Ue;if(typeof navigator>"u")return Ue=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ue=!0;const e=navigator.maxTouchPoints;return Ue=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Lt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},hi=e=>e,fi=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},mi=(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(Lt(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(Lt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ct={passive:!0},gi=typeof window>"u"?!0:"onscrollend"in window,pi=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&gi;let l=0;const a=i?null:ui(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,ct),i&&s.addEventListener("scrollend",h,ct),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",h)}},xi=(e,n)=>pi(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),bi=(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"]},vi=(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})},Si=vi;class yi{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:hi,rangeExtractor:fi,onChange:()=>{},measureElement:bi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(i[m]=p)}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 m=l.count,p=i.count,C=this.getMeasurements(),b=m>0?((s=C[0])==null?void 0:s.key)??l.getItemKey(0):null,w=m>0?((o=C[m-1])==null?void 0:o.key)??l.getItemKey(m-1):null;if(p!==m||m>0&&p>0&&(i.getItemKey(0)!==b||i.getItemKey(p-1)!==w)){u=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const I=i.followOnAppend===!0?"auto":i.followOnAppend||null;I&&p>m&&this.isAtEnd(l.scrollEndThreshold)&&(m===0||i.getItemKey(p-1)!==w)&&(d=I)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,g=0;if(a&&this.scrollOffset!==null){const[m,p]=a,C=this.getMeasurements(),{count:b,getItemKey:w}=this.options;let v=0;for(;v<b&&w(v)!==m;)v++;if(v<b){const x=C[v];if(x){const k=x.start+p;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=_e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,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,!(!St()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",l,ct),i.addEventListener("touchend",a,ct),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&&(St()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,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=_e(()=>[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 v of this.laneAssignments.keys())v>=t&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const v=t*2;let x=this._flatMeasurements;if(!x||x.length<v){const j=new Float64Array(v);x&&m>0&&j.set(x.subarray(0,m*2)),x=j,this._flatMeasurements=x}let k;if(m===0)k=s+o;else{const j=m-1;k=x[j*2]+x[j*2+1]+u}for(let j=m;j<t;j++){const E=i(j),A=g.get(E),L=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=k,x[j*2+1]=L,k+=L+u}const I=ci(t,x,i);return this.measurementsCache=I,I}const p=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),b=new Float64Array(a);let w=0;for(let v=0;v<m;v++){const x=p[v];x&&(C[x.lane]===void 0&&w++,C[x.lane]=v,b[x.lane]=x.end)}for(let v=m;v<t;v++){const x=i(v),k=this.laneAssignments.get(v);let I,j;const E=d==="estimate"||g.has(x);if(k!==void 0&&this.options.lanes>1){I=k;const F=C[I],J=F!==void 0?p[F]:void 0;j=J?J.end+u:s+o}else if(w===a){let F=0,J=b[0],_=C[0];for(let G=1;G<a;G++){const se=b[G];(se<J||se===J&&C[G]<_)&&(F=G,J=se,_=C[G])}I=F,j=J+u,E&&this.laneAssignments.set(v,I)}else I=v%this.options.lanes,j=s+o,E&&this.laneAssignments.set(v,I);const A=g.get(x),L=typeof A=="number"?A:this.options.estimateSize(v),O=j+L;p[v]={index:v,start:j,size:L,end:O,key:x,lane:I},C[I]===void 0&&w++,C[I]=v,b[I]=O}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=Ii(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,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 m=this.measurementsCache[t];if(!m)return;d=m.key,a=m.start,l=m.size}const h=this.itemSizeCache.get(d)??l,g=s-h;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=m?this.getTotalSize():0,C=((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++,m?this.applyScrollAdjustment(this.getTotalSize()-p):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=_e(()=>[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=is(0,s.length-1,i?a=>o[a*2]:a=>Dt(s[a]).start,t);return Dt(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&&(St()&&(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&&di(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 is=(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 Ci(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 Ii(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=Ci(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=is(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 yt=typeof document<"u"?c.useLayoutEffect:c.useEffect;function ji({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 v=u.options.horizontal?"width":"height";h.container.style[v]=`${g}px`}const m=!!u.options.horizontal,p=h.mode==="transform",C=m?"left":"top",b=u.options.scrollMargin,w=u.getVirtualItems();for(const v of w){const x=v.start-b,k=u.elementsCache.get(v.key);k&&h.lastPositions.get(k)!==x&&(h.lastPositions.set(k,x),p?k.style.transform=m?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:k.style[C]=`${x}px`)}},a={...s,onChange:(u,h)=>{var g;const m=i.current;let p=!0;if(m.enabled){l(u);const C=u.range,b=m.prevRange;p=!b||b.isScrolling!==u.isScrolling||b.startIndex!==C?.startIndex||b.endIndex!==C?.endIndex,p&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:u.isScrolling}:null)}p&&(e&&h?Ds.flushSync(o):o()),(g=s.onChange)==null||g.call(s,u,h)}},[d]=c.useState(()=>{const u=new yi(a);return Object.assign(u,{containerRef:h=>{const g=i.current;if(g.container=h,g.lastSize=null,h&&g.enabled){const m=u.getTotalSize();g.lastSize=m;const p=u.options.horizontal?"width":"height";h.style[p]=`${m}px`}}})});return d.setOptions(a),yt(()=>d._didMount(),[]),yt(()=>d._willUpdate()),yt(()=>{l(d)}),d}function Ti(e){return ji({observeElementRect:mi,observeElementOffset:xi,scrollToFn:Si,...e})}const Rt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",wi=e=>`Select all ${Rt(e)}`,ki=(e,n)=>`All ${ss(n)} ${Rt(e)} selected`,Mi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const l=gn(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}},Ri=(e,n,t)=>e==="BACK"&&n&&t===void 0,Ei=(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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),Ai=({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:m,density:p})=>r.jsx(pn,{thread:Ei(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:p,isDesktop:m,onFocusRow:i,selection:{isChecked:l,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:h,onLongPress:g}}),Oi=c.memo(Ai),Ni=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:Qe(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Ut(e.category),suspicious:n}},zi=({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:m,onToggleRead:p,density:C})=>{const[b,w]=c.useState("none"),v=Je(),x=c.useCallback(A=>{navigator.vibrate?.(10),A==="trailing"?m(e.messageId):p(e.messageId,e.isRead),w("none")},[m,p,e.messageId,e.isRead]),k=c.useCallback(()=>{h(e.messageId)},[h,e.messageId]),I=c.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=c.useCallback(()=>{v({threadId:e.threadId,messageId:e.messageId})},[v,e.threadId,e.messageId]),E=xn(e.messageId,d);return g||u?r.jsx(Oi,{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:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:E.onMouseDown,onClickCapture:E.claimClick,onContextMenu:E.onContextMenu,children:r.jsx(co,{thread:Ni(e),selectionMode:!1,checked:!1,active:t,peek:b,onPeek:w,onToggleCheck:I,onLongPress:k,onOpen:j,onAct:x})})},Fi=72,Di=32,Li=5,rs="remit:list-density",_i=()=>{try{const e=localStorage.getItem(rs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Pi=({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)=>Ao(e.filter(s=>n.has(s.messageId)).map(s=>s.accountId??t)).moveDisabledHint,$i=({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:m,hasMore:p=!1,isLoadingMore:C=!1,accountId:b,listTitle:w,listMeta:v,listFilter:x,listScopeLabel:k,onTriageContextChange:I,commandsRef:j,hideHeader:E=!1})=>{const A=c.useRef(null),L=Je(),O=Ls(),F=_s(),{verb:J,start:_,startFromSearch:G}=F,se=Ps(),pe=!!a?.trim(),P=bn(),{labels:Pe}=Ro(b),{pushError:ae}=$t(),[M,Ce]=c.useState(t),[W,Ie]=c.useState(),V=c.useCallback(f=>{Ie(S=>S===f?S:void 0),Ce(f)},[]),[D,Be]=c.useState(_i),xe=c.useCallback(()=>{Be(f=>{const S=f==="comfortable"?"compact":"comfortable";try{localStorage.setItem(rs,S)}catch{}return S})},[]),{toggleReadFor:be}=Qt({mailboxId:e}),{junkMailboxId:le}=Jt(b),Ae=Gt(le,e),Oe=c.useMemo(()=>[{accountId:b,mailboxId:e}],[b,e]),{outcome:ce,staleFolderLabel:K,guessedMailboxId:H}=vn(Oe),{selectedIds:X,selectedCount:q,hasSelection:oe,isSelected:Ne,toggle:ee,select:je,clearSelection:de,selectRange:ue,setAnchor:N,selectAll:Te,toggleAll:$e,intersectWith:ze}=Sn(),R=Nn(q,O),[Fe,he]=c.useState(null),We=pe&&!!d,Ge=`${e}|${JSON.stringify(d??{})}`,T=yn({mailboxId:e,accountId:b,enabled:We,predicateKey:Ge,searchQuery:d??{}}),Ye=c.useCallback((f,S,ge)=>{const Q=Cn(f,S,ge,ce);Q&&ae(Q)},[ae,ce]),we=T.phase.kind,Ze=T.clear,z=c.useCallback(()=>{we==="escalated"&&Ze(),de()},[de,Ze,we]),[Xe,et]=c.useState(null),ve=c.useRef(null),ie=c.useRef(!1),Se=c.useRef(null),ke=!s&&n.length>0,ne=Ti({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>D==="compact"?Di:Fi,overscan:Li}),Ve=t?n.findIndex(f=>f.messageId===t):-1,Y=M?n.findIndex(f=>f.messageId===M):-1,re=c.useCallback(f=>{if(f<0||f>=n.length)return;const S=n[f];if(R){ee(S.messageId);return}ve.current=S.messageId,ie.current=!1,Ie(S.messageId),Ce(S.messageId)},[n,R,ee]),Ke=c.useCallback(()=>{if(n.length===0)return;const f=Y<0?0:Math.min(Y+1,n.length-1);re(f)},[n.length,Y,re]),He=c.useCallback(()=>{if(n.length===0)return;const f=Y<=0?0:Y-1;re(f)},[n.length,Y,re]),ye=c.useCallback(()=>re(0),[re]),Me=c.useCallback(()=>re(n.length-1),[re,n.length]),Re=c.useCallback(()=>{M&&ee(M)},[M,ee]),B=c.useMemo(()=>n.map(f=>f.messageId),[n]),ft=c.useMemo(()=>{const f=[];for(const S of n)X.has(S.messageId)&&f.push({id:S.messageId,sender:S.fromName??S.fromEmail??"Unknown",email:S.fromEmail??"",subject:S.subject??"(No subject)",date:Qe(S.sentDate),accountId:b});return f},[n,X,b]),mt=c.useCallback((f,S)=>S.shiftKey?(ue(B,f,M),!0):S.metaKey||S.ctrlKey?(ee(f),!0):(z(),N(f),!1),[B,M,ue,ee,z,N]),fe=c.useCallback(f=>{!u||f.length===0||(Se.current=M??null,he(f))},[u,M]),De=c.useCallback(f=>{const S=In(B,M,f);S!==void 0&&(ue(B,S),ve.current=S,ie.current=!1,Ie(void 0),Ce(S))},[B,M,ue]),tt=c.useCallback(()=>De(-1),[De]),st=c.useCallback(()=>De(1),[De]),nt=c.useCallback(()=>{B.length>0&&Te(B)},[B,Te]),ot=c.useCallback(f=>{const S=Mi({verb:f,confirmingDelete:Fe!==null,hasSelection:oe,junkMailboxId:le,currentMailboxId:e,deletableMessageId:u?M:void 0});return S.kind==="openWizard"?(_(f),!0):S.kind==="confirmDelete"?(fe([S.messageId]),!0):S.kind==="unavailable"?(ae({severity:"warning",title:S.reason}),!0):S.kind==="withheld"},[Fe,u,oe,le,e,_,M,fe,ae]),me=c.useCallback((f,S)=>{const ge=n.find(Q=>Q.messageId===f)?.threadId;ge&&L({threadId:ge,messageId:f},{replace:S?.replace})},[L,n]),it=c.useCallback(()=>{M&&me(M)},[M,me]),rt=c.useCallback(f=>me(f,{replace:!0}),[me]);jn({keyboardFocusedMessageId:W,openMessageId:t,enabled:O&&q===0,open:rt});const Le=T.phase.kind==="escalated"?{scope:Rt(d??{}),total:T.phase.total,searchQuery:d??{},run:f=>T.runAction(f),stop:T.stop}:void 0,gt=c.useCallback(f=>{if(f.length===0){he(null);return}const S=new Set(f),ge=n.findIndex(Z=>S.has(Z.messageId));let Q;for(let Z=ge+1;Z<n.length;Z++)if(!S.has(n[Z].messageId)){Q=n[Z].messageId;break}if(Q===void 0){for(let Z=ge-1;Z>=0;Z--)if(!S.has(n[Z].messageId)){Q=n[Z].messageId;break}}u?.(f),z(),Se.current=null,he(null),Q!==void 0&&(ve.current=Q,ie.current=!1,V(Q),O&&me(Q,{replace:!0})),O||et(Tn("delete",f.length,ce))},[n,u,z,me,O,V,ce]),pt=c.useCallback(()=>{const f=Se.current;Se.current=null,he(null),f!==null&&(ve.current=f,ie.current=!1,V(f))},[V]),qe=c.useMemo(()=>Bi(n,X,b),[b,X,n]),at=c.useCallback(()=>{if(Le){G();return}_("organize")},[Le,G,_]),xt=c.useCallback(f=>{u?.([f])},[u]),y=c.useCallback((f,S)=>{be([f],!S)},[be]),U=c.useCallback(f=>{O||je(f)},[O,je]),$=c.useCallback(()=>{if(T.isRunning||T.phase.kind==="counting"){T.stop();return}z()},[T,z]),ds=c.useCallback(()=>{T.clear()},[T]);c.useEffect(()=>{if(ie.current||!O&&t)return;const f=Y>=0?Y:Ve;f>=0&&ne.scrollToIndex(f,{align:"auto"})},[Y,Ve,ne,O,t]),c.useEffect(()=>{t&&(ie.current=!1,V(t))},[t,V]),c.useEffect(()=>{M&&(n.some(f=>f.messageId===M)||V(n[0]?.messageId))},[n,M,V]),c.useEffect(()=>{I?.({focusedMessageId:M,selectedIds:Array.from(X),hasList:ke})},[M,X,ke,I]);const Et=c.useRef(I);Et.current=I,c.useEffect(()=>()=>Et.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1}),[]),c.useEffect(()=>{T.phase.kind!=="idle"||T.isRunning||ze(n.map(f=>f.messageId))},[n,ze,T.phase,T.isRunning]);const At=c.useRef(e);c.useEffect(()=>{At.current!==e&&(At.current=e,z())},[e,z]),wn({shouldBlockFn:({action:f})=>Ri(f,oe,se)?(z(),!0):!1,enableBeforeUnload:!1,disabled:!oe||se!==void 0}),c.useEffect(()=>{const f=A.current;if(!f||!p||!m)return;const S=()=>{if(C)return;const{scrollTop:ge,scrollHeight:Q,clientHeight:Z}=f;ge+Z>=Q-200&&m()};return f.addEventListener("scroll",S,{passive:!0}),S(),()=>f.removeEventListener("scroll",S)},[p,C,m]),c.useEffect(()=>{const f=ve.current;if(!f)return;const S=A.current?.querySelector(`[data-message-id="${f}"]`);S&&(ve.current=null,S.focus({preventScroll:!0}))}),c.useEffect(()=>{if(j){if(!ke){j.current=null;return}return j.current={focusNext:Ke,focusPrevious:He,focusFirst:ye,focusLast:Me,openFocused:it,toggleSelect:Re,extendSelectDown:st,extendSelectUp:tt,selectAll:nt,clearSelection:()=>oe?(z(),!0):!1,requestVerb:ot,toggleDensity:xe},()=>{j.current=null}}},[j,ke,Ke,He,ye,Me,it,Re,st,tt,nt,oe,z,ot,xe]);const Ot=s?"loading":o?"error":n.length===0?"empty":"ready",us=o?Mo(i):void 0,hs=c.useCallback(()=>{const f=Bs($s());window.open(f,"_blank","noopener,noreferrer")},[]),fs=[{id:"inbox",threads:[]}],bt=B.length>0&&B.every(f=>X.has(f)),ms=We&&p&&bt&&!h&&!g&&T.phase.kind==="idle"&&!T.isRunning,gs=h||g||T.isRunning,vt=T.phase.kind==="escalated"?T.phase.total:q,ps=T.runningAction?kn(T.runningAction.kind,T.progress?.done??0,T.progress?.total??vt):T.phase.kind==="counting"?"Counting matches…":T.phase.kind==="escalated"?ki(d??{},T.phase.total):void 0,xs=T.phase.kind!=="escalated"&&B.length>0?{checked:bt,indeterminate:q>0&&!bt,onChange:()=>$e(B)}:void 0,bs=T.runningAction?{value:T.progress?.done??0,max:T.progress?.total??vt,tone:Mn(T.runningAction.kind)}:void 0,vs=(T.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:T.stop}}:T.phase.kind==="escalated"&&!T.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:ds}}:ms?{tone:"info",text:"",action:{label:wi(d??{}),onClick:T.escalate}}:void 0)??(qe?{tone:"warning",text:qe}:void 0),Ss=r.jsx(Rn,{title:P.title||w,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:vt,onCancel:$,onDelete:()=>_("delete"),onMove:()=>_("move"),onOrganize:at,onJunk:Ae?()=>_("junk"):void 0,onMarkRead:()=>_("markRead"),overflowSlot:b&&e&&q>0&&Pe.length>0?r.jsx(Eo,{accountId:b,mailboxId:e,messageIds:Array.from(X)}):void 0,isBusy:gs,isCounting:T.phase.kind==="counting",selectAll:xs,statusLabel:ps,progress:bs,notice:vs}),ys=En(B,M),Cs=c.useCallback(f=>{ie.current=!0,V(f)},[V]),Is=r.jsxs(r.Fragment,{children:[pe&&a&&r.jsx(Pi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":w,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ne.getTotalSize()}px`},children:ne.getVirtualItems().map(f=>{const S=n[f.index];return r.jsx("div",{role:"presentation","data-index":f.index,ref:ne.measureElement,className:Ee("absolute left-0 top-0 w-full border-b border-line",T.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${f.start}px)`},children:r.jsx(zi,{thread:S,mailboxId:e,isSelected:t===S.messageId,isFocused:M===S.messageId,isTabStop:ys===S.messageId,onFocusRow:Cs,isChecked:Ne(S.messageId),onToggleCheck:ee,onRowSelect:mt,isMultiSelectMode:R,onLongPress:U,isDesktop:O,onDelete:xt,onToggleRead:y,density:D})},f.key)})}),C&&r.jsx(uo,{})]})]});return r.jsxs(r.Fragment,{children:[Xe&&!O&&r.jsx(dt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>et(null),children:Xe}),r.jsx(ho,{listTitle:w,listMeta:v,sections:fs,flatList:!0,listState:P.searchResults?"ready":Ot,searchQuery:pe?a:void 0,listFilter:x,listScopeLabel:k,errorMessage:us,onRetry:l,onReportError:hs,density:D,selectedThreadId:t,onSelectThread:f=>me(f),isDesktop:O,hideHeader:E,selectionBar:Ss,listBody:P.searchResults??(Ot==="ready"?Is:void 0)}),r.jsx(An,{isOpen:Fe!==null,messageIds:Fe??[],outcome:ce,accountId:b,trashFolderLabel:w,staleFolderLabel:K,guessedMailboxId:H,isDeleting:h,onConfirm:gt,onCancel:pt}),r.jsx(On,{verb:J,accountId:b,mailboxId:e,selection:ft,selectionRestriction:qe?"spansAccounts":void 0,escalated:Le,escalatedProgress:T.progress,onFinished:z,onRunEnded:Ye})]})},Wi=e=>Wt({path:{accountId:e}}),Vi=e=>{const n=It(),t=wt(),s=Tt({...Vs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Wi(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ki=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Vi(e);return r.jsx(Po,{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=wt(),d=Ks(),{inboxMailboxId:u}=zn(e),h=Fn(e),{data:g}=jt({...Hs({path:{accountId:e}}),staleTime:1/0}),m=c.useMemo(()=>qs({mailboxes:g?.items??[],folderAppointments:h,currentMailboxId:n,translator:d}),[g?.items,h,n,d]),p=c.useMemo(()=>u||(m.find(x=>x.label.toLowerCase()==="inbox")?.id??m.find(x=>!x.isCurrent)?.id??""),[u,m]),C=c.useRef(!1);c.useEffect(()=>{C.current||(C.current=!0,Dn(a,t.length))},[a,t.length]);const b=c.useCallback(()=>{Ln(a,t.length),l(!0)},[a,t.length]),w=c.useCallback((v,x)=>{_n(a,{selected:v.length,total:t.length,toInbox:x===u}),s(v,x)},[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($o,{count:t.length,onReview:b})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Zo,{open:i,candidates:t,defaultDestinationId:p,availableFolders:m,delimiter:Us(g?.items??[]),onConfirmMove:w,onCancel:()=>l(!1)})]})}const qi=(e,n,t,s)=>`${e??""}|${n}|${t??""}|${s??""}`,Ui=({accountId:e,mailboxId:n})=>{const t=It(),{pushError:s}=$t(),{requestAppointment:o}=Qs(),{trashByAccount:i}=Yt(),l=e?i.get(e):void 0,a=qi(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]),m=c.useRef(void 0),{mutateAsync:p,isPending:C}=Tt({...Zs(),onMutate:()=>(m.current=a,{scope:a,listMailboxId:g()}),onSuccess:(x,k,I)=>{I.scope===a&&u({scope:a,deletedCount:x.deletedCount})},onError:(x,k,I)=>{const j=Gs(x);if(!j){s({title:"Couldn't empty Trash",detail:Ys(x),error:x});return}I?.scope===a&&u({scope:a,refusal:j})},onSettled:(x,k,I,j)=>{m.current===j?.scope&&(m.current=void 0),So(t,yo([j?.listMailboxId??n])),e&&t.invalidateQueries({queryKey:Wt({path:{accountId:e}})})}}),b=c.useCallback(()=>e?(u({scope:a}),p({path:{accountId:e}}).then(()=>{},()=>{})):Promise.resolve(),[e,a,p]),w=c.useCallback(()=>{b()},[b]),v=c.useCallback(()=>{const x=h?.refusal;x&&o({accountId:x.accountId,role:x.role,reason:x.reason,action:{kind:"emptyTrash"},onAppointed:b})},[h,o,b]);return{emptyTrash:w,isEmptying:C&&m.current===a,deletedCount:h?.deletedCount,refusal:h?.refusal,repair:v}},Qi="We can verify this sender";function Ji(e){const{data:n}=jt({...Xs({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:Qi,trustSubReason:Pn(s.senderTrust),senderTrust:s.senderTrust}))}}const Gi=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Yi={unread:"unread",flagged:"starred",attachment:"attachments"},Zi=new Set(Object.values(en)),as=e=>Zi.has(e),Xi=e=>as(e.category)||e.attributes.size>0,er=e=>{const n={};as(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Yi[t];s&&(n[s]=!0)}return n},tr=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",sr=["category","unread","starred","attachments"],_t=e=>JSON.stringify(sr.map(n=>e?.[n]??null)),nr=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},or=(e,n)=>{const t=nr(e);return t?_t(t)===_t(n):!1},lt=e=>e[0],ir=e=>{const n=lt(e.filter(a=>a.type==="from").map(a=>a.value)),t=lt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=lt(e.filter(a=>a.type==="category").map(a=>a.category)),o=lt(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}:{}}},rr=(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 ar(e,n={}){const t=ir(e),s={...t,...n};return{params:t,residual:e.filter(o=>!rr(s,o))}}function lr(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=Bn(o);return $n({...i,accountId:i.accountId??t},s)})}const cr=50,dr=new Map(ts().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ls=c.createContext(null);function ht(){const e=c.useContext(ls);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function ur({mailboxId:e,thread:n,children:t}){const s=Je(),o=Co(),i=_o(),l=n?.threadId,a=n?.messageId,d=wt(),{accounts:u,searchQuery:h,onToggleIntelligence:g}=Vt(),m=cn(),p=Lo(h),C=p.length>0,{freeText:b,tokens:w}=dn(p,m),[v,x]=c.useState("all"),[k,I]=c.useState(new Set),j=c.useMemo(()=>({category:v,attributes:k}),[v,k]),E=c.useMemo(()=>er(j),[j]),A=C||Xi(j),{params:L,residual:O}=ar(w,E),F={order:"desc",limit:cr,...b?{query:b}:{},...L,...E},J={category:F.category,unread:F.unread,starred:F.starred,attachments:F.attachments},_=A?tn({path:{mailboxId:e},query:F}):sn({path:{mailboxId:e},query:{order:"desc"}}),{data:G,isLoading:se,isError:pe,error:P,refetch:Pe,fetchNextPage:ae,hasNextPage:M,isFetchingNextPage:Ce}=fo({queryKey:_,queryFn:async({pageParam:y})=>{if(A){const{data:$}=await an({path:{mailboxId:e},query:{...F,continuationToken:y},throwOnError:!0});return $}const{data:U}=await ln({path:{mailboxId:e},query:{order:"desc",continuationToken:y},throwOnError:!0});return U},initialPageParam:void 0,getNextPageParam:y=>y.continuationToken,placeholderData:(y,U)=>or(U?.queryKey,J)?y:void 0}),{accountId:W,isLoading:Ie}=Wn(e),V=Io({accounts:u}),D=lr(Vn(Gi(G?.pages.flatMap(y=>y.items??[])??[])),O,W),Be=c.useCallback(y=>{x(y)},[]),xe=c.useCallback(y=>{I(U=>{const $=new Set(U);return $.has(y)?$.delete(y):$.add(y),$})},[]),be=c.useCallback(()=>{x("all"),I(new Set)},[]),le=dr.get(v),Ae=le?{label:le,reach:O.length>0?"loaded-pages":tr(F),onClear:be}:void 0,Oe=l?D.find(y=>y.messageId===a)??D.find(y=>y.threadId===l):void 0,ce=Kn(l,a),K=Oe??ce,H=a??K?.messageId,X=c.useMemo(()=>{if(l)return{threadId:l,mailboxId:K?.mailboxId??e,subject:K?.subject,messageId:H,authenticity:K?.authenticity}},[l,K,H,e]),q=c.useCallback(y=>{H&&y.includes(H)&&o()},[H,o]),{deleteMessages:oe,isPending:Ne}=Nt({mailboxId:e,onAfterOptimisticRemove:q}),{moveMessages:ee,isPending:je}=zt({mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),de=c.useRef(null),ue=Hn(),{listCommandsRef:N,onTriageContextChange:Te,focusedMessageId:$e,selectedIds:ze}=ue,R=D.find(y=>y.messageId===$e)??K,Fe=jo({accounts:u})??0,he=qn({thread:K,isOpen:!0,mailboxId:e,accountId:W,onAfterOptimisticRemove:q}),{draftsMailboxId:We}=Un(W),Ge=We!==void 0&&We===e,{archiveMailboxId:T}=Qn(W),Ye=Jn(),we=nn(),Ze=c.useMemo(()=>on(we,l,H),[we,l,H]),z=c.useMemo(()=>{if(R)return y=>we({threadId:R.threadId,messageId:R.messageId,mode:y})},[we,R]),Xe=bo(),et=rn(),ve=vo(),ie=c.useCallback(y=>y?Ye(y):[],[Ye]),{toggleStar:Se}=Gn({threadId:R?.threadId??"",mailboxId:e}),{toggleReadFor:ke}=Qt({mailboxId:e,accountId:W}),{junkMailboxId:ne}=Jt(W),Ve=ne!=null&&ne===e,Y=Gt(ne,e),{candidates:re}=Ji(Ve?ne:void 0),{moveMessages:Ke}=zt({mailboxId:e,threadId:R?.threadId,accountId:W,onAfterOptimisticRemove:q}),{deleteMessages:He}=Nt({mailboxId:e,threadId:R?.threadId,onAfterOptimisticRemove:q}),{addressId:ye,address:Me}=Yn(R),{updateFlags:Re}=Zn({addressId:ye,senderEmail:R?.fromEmail??void 0}),B=c.useCallback(()=>z?.("reply"),[z]),ft=c.useCallback(()=>z?.("reply-all"),[z]),mt=c.useCallback(()=>z?.("forward"),[z]),fe=c.useCallback(()=>ie(R),[ie,R]),De=c.useCallback(()=>{if(N.current?.requestVerb("delete"))return;const y=fe();y.length>0&&He(y)},[N,fe,He]),tt=c.useCallback(()=>{if(N.current?.requestVerb("junk")||!Y)return;const y=fe();y.length!==0&&(Xn(d,{count:y.length,senderTrust:R?.senderTrust??"unknown",wasRescuable:R?eo(R):!1}),Ke(y,Y))},[N,Y,fe,Ke,d,R]),st=c.useCallback(()=>{if(ze.length>0){const y=!(R?.hasStars??!1),U=new Set(ze);for(const $ of D)U.has($.messageId)&&$.hasStars!==y&&Se($.messageId,$.hasStars);return}R&&Se(R.messageId,R.hasStars)},[ze,D,R,Se]),nt=c.useCallback(()=>{if(N.current?.requestVerb("markRead"))return;const y=fe();if(y.length===0)return;const U=!(R?.isRead??!1);ke(y,U)},[N,fe,R,ke]),ot=c.useCallback(()=>{if(!ye)return;const y=Me?.flags?.muted?.value!==!0;Re({muted:{value:y}})},[ye,Me,Re]),me=c.useCallback(()=>{if(!ye)return;const y=Me?.flags?.vip?.value!==!0;Re({vip:{value:y}})},[ye,Me,Re]),it=c.useCallback(()=>{de.current?.open()},[]),rt=Ge?"drafts":T===e?"archive":ne===e?"junk":"inbox",Le=c.useRef("");c.useEffect(()=>{const y=Le.current;Le.current=p,p.length>0&&y.length===0&&d.recordEvent("search.submitted",{mailboxType:rt})},[p,rt,d]);const{goBack:gt,nextMessageId:pt,previousMessageId:qe}=to({context:ue,orderedIds:D.map(y=>y.messageId),selectedMessageId:H,enabled:!Xe&&!et,hasOpenThread:l!==void 0,onClose:o,handlers:{reply:B,replyAll:ft,forward:mt,delete:De,toggleStar:st,toggleRead:nt,muteSender:ot,blockSender:K?it:void 0,vipSender:me,markJunk:tt,toggleIntelligence:K?()=>de.current?.toggle():void 0,compose:ve,goBrief:()=>i("brief"),goInbox:()=>i("brief"),goSent:()=>i("brief"),goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),at=y=>{if(!y)return;const U=D.find($=>$.messageId===y);return U?{threadId:U.threadId,messageId:y}:void 0},xt={mailboxId:e,selectedMessageId:H,selectedThread:K,conversation:X,onOpenThread:s,threads:D,isLoading:se,isError:pe,error:P,mailboxAccountId:W,mailboxAccountLoading:Ie,mailboxName:V,unreadCount:Fe,isDraftsMailbox:Ge,isSpamFolder:Ve,rescueCandidates:re,filterCategory:v,filterAttributes:k,onSelectFilterCategory:Be,onToggleFilterAttribute:xe,onClearFilters:be,listFilter:Ae,onToggleIntelligence:g,intelligenceRef:de,handleDeselectIfRemoved:q,searchPredicate:C&&O.length===0?F:void 0,onDeleteMessages:oe,onMoveMessages:ee,isDeleting:Ne,isMoving:je,onLoadMore:ae,hasMore:M,isLoadingMore:Ce,onTriageContextChange:Te,listCommandsRef:N,onRetry:()=>Pe(),onReply:Ze,onToolbarDelete:he.deleteThread,onToolbarStar:he.toggleStar,isStarred:he.isStarred,onToolbarMove:he.moveThread,onBack:gt,nextThread:at(pt),previousThread:at(qe)};return r.jsx(ls.Provider,{value:xt,children:t})}function cs(){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:m,mailboxAccountId:p,mailboxName:C,unreadCount:b,isDraftsMailbox:w,isSpamFolder:v,rescueCandidates:x,onTriageContextChange:k,listCommandsRef:I,onRetry:j,filterCategory:E,filterAttributes:A,onSelectFilterCategory:L,onToggleFilterAttribute:O,onClearFilters:F,listFilter:J,searchPredicate:_}=ht(),{searchQuery:G,searchInput:se,accounts:pe,resultFolderIndex:P}=Vt(),Pe=Do(),ae=Je(),M=C??"Inbox",Ce=c.useMemo(()=>ts(),[]),{trashMailboxId:W}=ro(p),Ie=To({accounts:pe}),{trashByAccount:V}=Yt(),D=Ui({accountId:p,mailboxId:e}),Be=W!=null&&W===e,xe=c.useMemo(()=>p?[p]:[],[p]),{hasNewMail:be}=hn(),{state:le,errorMessage:Ae,refresh:Oe}=fn(xe,{onSettled:j}),ce=c.useMemo(()=>r.jsx(mn,{state:le,onRefresh:Oe,label:`Refresh ${M}`,errorMessage:Ae,hasUpdate:be(xe)}),[le,Oe,M,Ae,be,xe]),K=c.useMemo(()=>t.map(N=>ao(N,P)),[t,P]),{hits:H,isLoading:X}=Oo({mailboxId:e,filterCategory:E}),q=c.useMemo(()=>lo(H,t.map(N=>N.threadId),P),[H,t,P]),oe=c.useCallback(N=>{const Te=N.threadId??t.find($e=>$e.messageId===N.id)?.threadId;Te&&ae({threadId:Te,messageId:N.id},{mailboxId:N.mailboxId??e,query:se})},[e,ae,se,t]);if(w&&p)return r.jsx(ii,{accountId:p,selectedMessageId:n,imapThreads:t,title:C??"Drafts",unreadCount:b??void 0});const Ne=r.jsx($i,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:G,searchPredicate:_,onDeleteMessages:l,isDeleting:d,isMoving:u,onLoadMore:h,hasMore:g,isLoadingMore:m,accountId:p,listTitle:M,listFilter:J,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:I}),ee=pe[0]?.accountId,je=Pe==="phone"&&ee?r.jsx(Ki,{accountId:ee,children:Ne}):Ne,de=v&&x.length>0&&p?r.jsx(Hi,{accountId:p,currentMailboxId:e,candidates:x,onMove:a,children:je}):je,ue=Be?r.jsx(li,{messageCount:Ie,isEmptying:D.isEmptying,deletedCount:D.deletedCount,refusalReason:D.refusal?.reason,trashFolderLabel:C??void 0,staleFolderLabel:p?V.get(p)?.staleFolderPath:void 0,onEmpty:D.emptyTrash,onRepair:D.repair,children:de}):de;return r.jsx(mo,{title:M,unreadCount:b,preset:Ce,selectedCategory:E,activeFilters:A,onSelectCategory:L,onToggleFilter:O,onClearFilters:F,searchResults:K,searchLoading:s,relatedResults:q,relatedLoading:X,onSelectSearchResult:oe,searchResultsInBody:!0,refreshControl:ce,children:ue})}function hr(){const{mailboxId:e,mailboxAccountId:n,mailboxAccountLoading:t,selectedThread:s,conversation:o,onReply:i,onToolbarDelete:l,onToolbarStar:a,isStarred:d,onToolbarMove:u,handleDeselectIfRemoved:h,intelligenceRef:g}=ht(),m=!!o,p=oo(o?.threadId);Zt(g,p);const C=c.useRef(null),{railFits:b,openRail:w}=p;c.useEffect(()=>{if(!b)return;const x=s?.messageId??null;x&&C.current!==x&&s?.authenticity?.dkimMismatch&&(C.current=x,w())},[b,w,s?.messageId,s?.authenticity?.dkimMismatch]);const v=o?r.jsx(Xt,{threadId:o.threadId,mailboxId:o.mailboxId,subject:o.subject,selectedMessageId:o.messageId,authenticity:o.authenticity,onOpenIntelligence:p.open,listOnScreen:!0}):r.jsx(un,{});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(io,{hasThread:m,messageId:o?.messageId,intelligenceOpen:p.isShowing,canToggleIntelligence:p.canToggle,onToggleIntelligence:p.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:m?l:void 0,onToggleStar:m?a:void 0,isStarred:d,moveContext:m&&n?{accountId:n,currentMailboxId:e,onMove:u}:void 0,moveContextLoading:t}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v})]}),r.jsx(es,{isOpen:p.drawerOpen,onClose:p.closeDrawer,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:h})]})}function fr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=ht();return r.jsx(no,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function mr(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,onBack:i,nextThread:l,previousThread:a,handleDeselectIfRemoved:d,intelligenceRef:u}=ht(),h=so(s?.threadId??null);return Zt(u,h),s?r.jsxs(r.Fragment,{children:[r.jsx(Xt,{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(es,{isOpen:h.isOpen,onClose:h.close,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:d})]}):r.jsx(cs,{})}const _r=Object.assign(ur,{List:cs,Reading:hr,Intelligence:fr,Phone:mr});export{_r as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as n,j as a,f as o}from"./index-
|
|
1
|
+
import{v as n,j as a,f as o}from"./index-CvHgBKzk.js";import{M as e}from"./menu-z3yGPHVO.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as ie,r as t,j as e,h as ce,i as Z,o as le,aw as de,c as q,aN as K,d as ee,f as k,L as _,B as H,aO as G,ax as ue,ay as $,n as me,I as pe}from"./index-Bcu7BqZh.js";import{K as he}from"./kbd-wWeybs89.js";import{c as fe,d as xe,s as U,W as L,C as D,g as ye,e as X,f as ge,h as ve,b as Se,R as be,a as W,S as je}from"./credential-steps-DJcQCoMN.js";import{c as we}from"./account-form-helpers-DhckT_PN.js";import{M as Ce}from"./mail-WRNyVFjV.js";import{F as ke}from"./card-BvJM4Bar.js";const Q=ie("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),te=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function Y(a){return te.find(d=>d.id===a)}const Ee={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function Ne(a){const d=a.indexOf("@");if(d===-1)return"";const c=a.slice(d+1).toLowerCase();return Ee[c]??""}const T=["Connector","Address","Servers","Credentials","Test","Sync"],A={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},V={host:"",port:993,security:"tls"},J={host:"",port:587,security:"starttls"};function Pe({onStart:a,onImportConfig:d}){return t.useEffect(()=>{const c=p=>{p.key==="Enter"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(L,{steps:T,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:d?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[d?e.jsx(k,{variant:"secondary",icon:e.jsx(ke,{className:"size-4"}),onClick:d,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(he,{children:"Enter"})," to continue"]}),e.jsx(k,{variant:"primary",onClick:a,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(Ce,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."}),d&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Te({onContinue:a,onMicrosoft:d,onBack:c,showBack:p}){const[h,o]=t.useState("imap");t.useEffect(()=>{const y=i=>{i.key==="Enter"&&(h==="microsoft"?d():a()),i.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,d,c,h]);const n=()=>{h==="microsoft"?d():a()};return e.jsx(L,{steps:T,activeStep:A.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[p?e.jsx(k,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:n,children:h==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(je,{className:"size-5"}),selected:h==="imap",onSelect:()=>o("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(Q,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(pe,{className:"size-5"}),selected:h==="microsoft",onSelect:()=>o("microsoft")})]})})}function Ae({onBack:a,onConnected:d}){const[c,p]=t.useState(""),[h,o]=t.useState(null),[n,y]=t.useState(!1),[i,g]=t.useState(!1),v=t.useRef(!0);t.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=t.useRef(new Set),{refetch:w}=q(ee()),j=Se(r=>{if(g(!1),r==="stalled"){y(!1),o(be);return}w().then(({data:u,isError:N})=>{if(!v.current)return;if(N||!u){o("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}o(null);const C=u.accounts.find(P=>!E.current.has(P.accountId));C&&d(C.accountId)})}),S=Z({...me(),onSuccess:r=>{v.current&&(j(),y(!0),window.location.assign(r.authorizationUrl))},onError:r=>{g(!1),o(r instanceof Error?r.message:"Failed to start sign-in")}}),l=i||S.isPending,f=()=>{l||(o(null),g(!0),w().then(({data:r,isError:u})=>{if(v.current){if(u||!r){g(!1),o("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}E.current=new Set(r.accounts.map(N=>N.accountId)),S.mutate({body:{email:c.trim()||void 0}})}}))},x=t.useRef(f);return x.current=f,t.useEffect(()=>{const r=u=>{u.key==="Enter"&&x.current(),u.key==="Escape"&&a()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a]),e.jsx(L,{steps:T,activeStep:A.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(k,{variant:"primary",onClick:f,disabled:l,icon:l?e.jsx(_,{className:"size-4 animate-spin"}):void 0,children:l?"Redirecting…":n?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx($,{id:"microsoft-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@outlook.com",value:c,onChange:r=>p(r.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),n&&e.jsx(H,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),h&&e.jsx(H,{tone:"danger",children:h})]})})}function Ie({initialEmail:a,initialDisplayName:d,onContinue:c,onBack:p}){const[h,o]=t.useState(a),[n,y]=t.useState(d),[i,g]=t.useState(!1),[v,E]=t.useState(""),[w,j]=t.useState(null),S=t.useCallback(async()=>{const l=h.trim();if(!l.includes("@")||!l.includes(".")){j("Enter a valid email address.");return}j(null),g(!0),E(ge(l));try{const f=await ve(l);c(l,n.trim(),f)}finally{g(!1)}},[h,n,c]);return t.useEffect(()=>{const l=f=>{f.key==="Enter"&&!i&&S(),f.key==="Escape"&&p()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[S,i,p]),e.jsx(L,{steps:T,activeStep:A.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:p,children:"Back"}),e.jsx(k,{variant:"primary",disabled:i,onClick:()=>{S()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx($,{id:"onboarding-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@example.com",value:h,onChange:l=>{o(l.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx($,{id:"onboarding-display-name",placeholder:"Alice",value:n,onChange:l=>y(l.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(_,{className:"size-3.5 animate-spin text-accent"}),v]}),w&&!i&&e.jsx("div",{className:"mt-3",children:e.jsx(H,{tone:"danger",children:w})})]})})}function Me({email:a,imapConfig:d,smtpConfig:c,discovered:p,onContinue:h,onBack:o,onChange:n}){const[y,i]=t.useState(d),[g,v]=t.useState(c),[E,w]=t.useState(()=>Ne(a)),[j,S]=t.useState(!1),[l,f]=t.useState(null),x=Y(E),r=x!==void 0&&!j,u=t.useCallback(m=>{w(m),S(!1),f(null);const s=Y(m);s&&(i({host:s.imap.host,port:s.imap.port,security:s.imap.security}),v({host:s.smtp.host,port:s.smtp.port,security:s.smtp.security}))},[]);t.useEffect(()=>{n(y,g)},[y,g,n]);const N=y.host.trim()!=="",C=t.useCallback(()=>{if(!N){f("Enter the IMAP host.");return}f(null),h()},[N,h]);t.useEffect(()=>{const m=s=>{s.key==="Enter"&&C(),s.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[C,o]);const P=a.split("@")[1]??"your domain",F=x?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":p?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${P} — enter them manually.`,I=r?{label:"preset",tone:"neutral"}:!x&&p?{label:"detected",tone:"positive"}:void 0,M=x?.passwordHelp.url??ye(a);return e.jsx(L,{steps:T,activeStep:A.servers,title:"Confirm server settings",subtitle:F,footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(k,{variant:"primary",onClick:C,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[l&&e.jsx(H,{tone:"danger",children:l}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(ue,{id:"provider-select",value:E,onChange:m=>u(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),te.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),x&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:r?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",x.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>S(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",x.label,"'s settings by hand."]})})]}),e.jsx(X,{legend:"IMAP — incoming",badge:I,readOnly:r,host:y.host,port:String(y.port),security:y.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{i(s=>({...s,host:m})),f(null)},onPortChange:m=>i(s=>({...s,port:Number(m)})),onSecurityChange:m=>i(s=>({...s,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(X,{legend:"SMTP — outgoing (optional)",badge:I,readOnly:r,host:g.host,port:String(g.port),security:g.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{v(s=>({...s,host:m})),f(null)},onPortChange:m=>v(s=>({...s,port:Number(m)})),onSecurityChange:m=>v(s=>({...s,security:m}))}),x&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[x.passwordHelp.text," ",M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Le=2e4;function Fe({email:a,displayName:d,imapConfig:c,smtpConfig:p,username:h,password:o,onGoToInbox:n}){const y=ce(),[i,g]=t.useState(null),[v,E]=t.useState(null),w=t.useRef(!1),j=U(c.security),S=U(p.security),l=Z({...de(),onSuccess:b=>{g(b.accountId),y.invalidateQueries({queryKey:le()})},onError:b=>{E(b instanceof Error?b.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const b=p.host.trim()!=="",O=we({imapHost:c.host,smtpHost:p.host,smtpPort:p.port}),R=b?O??{smtpHost:p.host,smtpPort:p.port,smtpTls:S.tls,smtpStartTls:S.startTls}:null;l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:R?.smtpHost||void 0,smtpPort:R?.smtpPort||void 0,smtpTls:R?.smtpTls??!1,smtpStartTls:R?.smtpStartTls??!1}})},[]);const{data:f,isError:x}=q({...K({path:{accountId:i??""}}),enabled:!!i,refetchInterval:b=>{const O=b.state.data?.syncPhase;return O==="complete"||O==="error"?!1:2e3}}),r=f?.syncPhase==="error",{data:u}=q({...ee(),enabled:!!i&&r}),N=u?.accounts.find(b=>b.accountId===i)?.lastError,C=f?.mailboxes.find(b=>b.fullPath==="INBOX"||b.fullPath==="Inbox"),P=f?.mailboxCountTotal??0,F=f?.mailboxCountSynced??0,I=C?.messagesTotal??0,M=C?.messagesSynced??0,m=I>0?M/I:0,s=f?.syncPhase,se=r?"failed":s==="idle"||s===void 0||s==="discovering_mailboxes"?"running":P>0?"ok":"running",z=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"?"pending":s==="syncing_inbox"||s==="syncing_others"?"running":"ok",B=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"||s==="syncing_inbox"?"pending":s==="syncing_others"?"running":"ok",ne=M>0||C?.phase==="complete"||s==="complete"||r,[ae,oe]=t.useState(!1);t.useEffect(()=>{if(!i)return;const b=setTimeout(()=>oe(!0),Le);return()=>clearTimeout(b)},[i]);const re=!!i&&(ne||x||ae);return v?e.jsx(L,{steps:T,activeStep:A.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:()=>{w.current=!1,E(null),l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:p.host||void 0,smtpPort:p.port||void 0,smtpTls:S.tls,smtpStartTls:S.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})}):e.jsx(L,{steps:T,activeStep:A.sync,title:`Syncing ${a}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),re?e.jsx(k,{variant:"primary",onClick:()=>i&&n(i),children:"Go to inbox"}):e.jsx(k,{variant:"primary",disabled:!0,icon:e.jsx(_,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:l.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(_,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[I>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[M.toLocaleString()," / ",I.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(D,{label:"Mailboxes discovered",detail:P>0?`${P} mailbox${P===1?"":"es"} found`:"Discovering…",state:se}),e.jsx(D,{label:"INBOX",detail:z==="ok"?`${M.toLocaleString()} messages synced`:z==="running"?"Syncing newest first…":"Queued",state:z}),F>1||s==="syncing_others"||s==="complete"?e.jsx(D,{label:"Other mailboxes",detail:B==="ok"?`${F-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{y.invalidateQueries({queryKey:K({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),N&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:N})]})]})})}function Be({skipWelcome:a=!1,onComplete:d,onCancel:c,onImportConfig:p}){const[h,o]=t.useState(a?"connector":"welcome"),[n,y]=t.useState({email:"",displayName:"",imapConfig:V,smtpConfig:J,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),i=t.useCallback(()=>o("connector"),[]),g=t.useCallback(()=>o("address"),[]),v=t.useCallback(()=>o("microsoft-email"),[]),E=t.useCallback(()=>{a?c?.():o("welcome")},[a,c]),w=t.useCallback((x,r,u)=>{let N=V,C=J,P=!1;u&&(P=u.source!=="heuristic",N={host:u.imap.host,port:u.imap.port,security:u.imap.security},C={host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}),y(F=>({...F,email:x,displayName:r,imapConfig:N,smtpConfig:C,discoveryResult:u,discovered:P,username:x})),o("servers")},[]),j=t.useCallback((x,r)=>{y(u=>({...u,imapConfig:x,smtpConfig:r}))},[]),S=t.useCallback((x,r)=>{y(u=>({...u,username:x,password:r}))},[]),l=t.useCallback(()=>o("sync"),[]),f=t.useCallback(x=>{d(x)},[d]);switch(h){case"welcome":return e.jsx(Pe,{onStart:i,onImportConfig:p});case"connector":return e.jsx(Te,{onContinue:g,onMicrosoft:v,onBack:E,showBack:!a});case"microsoft-email":return e.jsx(Ae,{onBack:()=>o("connector"),onConnected:f});case"address":return e.jsx(Ie,{initialEmail:n.email,initialDisplayName:n.displayName,onContinue:w,onBack:()=>o("connector")});case"servers":return e.jsx(Me,{email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,discovered:n.discovered,onContinue:()=>o("credentials"),onBack:()=>o("address"),onChange:j});case"credentials":return e.jsx(xe,{steps:T,activeStep:A.credentials,title:`Sign in to ${n.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:n.email,username:n.username,password:n.password,onContinue:()=>o("test"),onBack:()=>o("servers"),onChange:S});case"test":return e.jsx(fe,{steps:T,activeStep:A.test,email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onSuccess:l,onBackToCredentials:()=>o("credentials"),onBackToServers:()=>o("servers")});case"sync":return e.jsx(Fe,{email:n.email,displayName:n.displayName,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onGoToInbox:f})}}export{Be as O,te as P,Y as g};
|
|
1
|
+
import{e as ie,r as t,j as e,h as ce,i as Z,o as le,aw as de,c as q,aN as K,d as ee,f as k,L as _,B as H,aO as G,ax as ue,ay as $,n as me,I as pe}from"./index-CvHgBKzk.js";import{K as he}from"./kbd-CFfFFeOa.js";import{c as fe,d as xe,s as U,W as L,C as D,g as ye,e as X,f as ge,h as ve,b as Se,R as be,a as W,S as je}from"./credential-steps-DxrEA0OS.js";import{c as we}from"./account-form-helpers-DhckT_PN.js";import{M as Ce}from"./mail-BtsVUuTG.js";import{F as ke}from"./card-CQW-PX25.js";const Q=ie("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),te=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function Y(a){return te.find(d=>d.id===a)}const Ee={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function Ne(a){const d=a.indexOf("@");if(d===-1)return"";const c=a.slice(d+1).toLowerCase();return Ee[c]??""}const T=["Connector","Address","Servers","Credentials","Test","Sync"],A={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},V={host:"",port:993,security:"tls"},J={host:"",port:587,security:"starttls"};function Pe({onStart:a,onImportConfig:d}){return t.useEffect(()=>{const c=p=>{p.key==="Enter"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(L,{steps:T,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:d?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[d?e.jsx(k,{variant:"secondary",icon:e.jsx(ke,{className:"size-4"}),onClick:d,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(he,{children:"Enter"})," to continue"]}),e.jsx(k,{variant:"primary",onClick:a,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(Ce,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."}),d&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Te({onContinue:a,onMicrosoft:d,onBack:c,showBack:p}){const[h,o]=t.useState("imap");t.useEffect(()=>{const y=i=>{i.key==="Enter"&&(h==="microsoft"?d():a()),i.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[a,d,c,h]);const n=()=>{h==="microsoft"?d():a()};return e.jsx(L,{steps:T,activeStep:A.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[p?e.jsx(k,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:n,children:h==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(je,{className:"size-5"}),selected:h==="imap",onSelect:()=>o("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(Q,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(pe,{className:"size-5"}),selected:h==="microsoft",onSelect:()=>o("microsoft")})]})})}function Ae({onBack:a,onConnected:d}){const[c,p]=t.useState(""),[h,o]=t.useState(null),[n,y]=t.useState(!1),[i,g]=t.useState(!1),v=t.useRef(!0);t.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=t.useRef(new Set),{refetch:w}=q(ee()),j=Se(r=>{if(g(!1),r==="stalled"){y(!1),o(be);return}w().then(({data:u,isError:N})=>{if(!v.current)return;if(N||!u){o("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}o(null);const C=u.accounts.find(P=>!E.current.has(P.accountId));C&&d(C.accountId)})}),S=Z({...me(),onSuccess:r=>{v.current&&(j(),y(!0),window.location.assign(r.authorizationUrl))},onError:r=>{g(!1),o(r instanceof Error?r.message:"Failed to start sign-in")}}),l=i||S.isPending,f=()=>{l||(o(null),g(!0),w().then(({data:r,isError:u})=>{if(v.current){if(u||!r){g(!1),o("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}E.current=new Set(r.accounts.map(N=>N.accountId)),S.mutate({body:{email:c.trim()||void 0}})}}))},x=t.useRef(f);return x.current=f,t.useEffect(()=>{const r=u=>{u.key==="Enter"&&x.current(),u.key==="Escape"&&a()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[a]),e.jsx(L,{steps:T,activeStep:A.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(k,{variant:"primary",onClick:f,disabled:l,icon:l?e.jsx(_,{className:"size-4 animate-spin"}):void 0,children:l?"Redirecting…":n?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx($,{id:"microsoft-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@outlook.com",value:c,onChange:r=>p(r.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),n&&e.jsx(H,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),h&&e.jsx(H,{tone:"danger",children:h})]})})}function Ie({initialEmail:a,initialDisplayName:d,onContinue:c,onBack:p}){const[h,o]=t.useState(a),[n,y]=t.useState(d),[i,g]=t.useState(!1),[v,E]=t.useState(""),[w,j]=t.useState(null),S=t.useCallback(async()=>{const l=h.trim();if(!l.includes("@")||!l.includes(".")){j("Enter a valid email address.");return}j(null),g(!0),E(ge(l));try{const f=await ve(l);c(l,n.trim(),f)}finally{g(!1)}},[h,n,c]);return t.useEffect(()=>{const l=f=>{f.key==="Enter"&&!i&&S(),f.key==="Escape"&&p()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[S,i,p]),e.jsx(L,{steps:T,activeStep:A.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:p,children:"Back"}),e.jsx(k,{variant:"primary",disabled:i,onClick:()=>{S()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx($,{id:"onboarding-email",icon:e.jsx(Q,{className:"size-4"}),placeholder:"you@example.com",value:h,onChange:l=>{o(l.target.value),j(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx($,{id:"onboarding-display-name",placeholder:"Alice",value:n,onChange:l=>y(l.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(_,{className:"size-3.5 animate-spin text-accent"}),v]}),w&&!i&&e.jsx("div",{className:"mt-3",children:e.jsx(H,{tone:"danger",children:w})})]})})}function Me({email:a,imapConfig:d,smtpConfig:c,discovered:p,onContinue:h,onBack:o,onChange:n}){const[y,i]=t.useState(d),[g,v]=t.useState(c),[E,w]=t.useState(()=>Ne(a)),[j,S]=t.useState(!1),[l,f]=t.useState(null),x=Y(E),r=x!==void 0&&!j,u=t.useCallback(m=>{w(m),S(!1),f(null);const s=Y(m);s&&(i({host:s.imap.host,port:s.imap.port,security:s.imap.security}),v({host:s.smtp.host,port:s.smtp.port,security:s.smtp.security}))},[]);t.useEffect(()=>{n(y,g)},[y,g,n]);const N=y.host.trim()!=="",C=t.useCallback(()=>{if(!N){f("Enter the IMAP host.");return}f(null),h()},[N,h]);t.useEffect(()=>{const m=s=>{s.key==="Enter"&&C(),s.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[C,o]);const P=a.split("@")[1]??"your domain",F=x?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":p?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${P} — enter them manually.`,I=r?{label:"preset",tone:"neutral"}:!x&&p?{label:"detected",tone:"positive"}:void 0,M=x?.passwordHelp.url??ye(a);return e.jsx(L,{steps:T,activeStep:A.servers,title:"Confirm server settings",subtitle:F,footer:e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(k,{variant:"primary",onClick:C,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[l&&e.jsx(H,{tone:"danger",children:l}),e.jsxs("div",{children:[e.jsx(G,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(ue,{id:"provider-select",value:E,onChange:m=>u(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),te.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),x&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:r?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",x.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>S(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",x.label,"'s settings by hand."]})})]}),e.jsx(X,{legend:"IMAP — incoming",badge:I,readOnly:r,host:y.host,port:String(y.port),security:y.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{i(s=>({...s,host:m})),f(null)},onPortChange:m=>i(s=>({...s,port:Number(m)})),onSecurityChange:m=>i(s=>({...s,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(X,{legend:"SMTP — outgoing (optional)",badge:I,readOnly:r,host:g.host,port:String(g.port),security:g.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{v(s=>({...s,host:m})),f(null)},onPortChange:m=>v(s=>({...s,port:Number(m)})),onSecurityChange:m=>v(s=>({...s,security:m}))}),x&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[x.passwordHelp.text," ",M&&e.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Le=2e4;function Fe({email:a,displayName:d,imapConfig:c,smtpConfig:p,username:h,password:o,onGoToInbox:n}){const y=ce(),[i,g]=t.useState(null),[v,E]=t.useState(null),w=t.useRef(!1),j=U(c.security),S=U(p.security),l=Z({...de(),onSuccess:b=>{g(b.accountId),y.invalidateQueries({queryKey:le()})},onError:b=>{E(b instanceof Error?b.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const b=p.host.trim()!=="",O=we({imapHost:c.host,smtpHost:p.host,smtpPort:p.port}),R=b?O??{smtpHost:p.host,smtpPort:p.port,smtpTls:S.tls,smtpStartTls:S.startTls}:null;l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:R?.smtpHost||void 0,smtpPort:R?.smtpPort||void 0,smtpTls:R?.smtpTls??!1,smtpStartTls:R?.smtpStartTls??!1}})},[]);const{data:f,isError:x}=q({...K({path:{accountId:i??""}}),enabled:!!i,refetchInterval:b=>{const O=b.state.data?.syncPhase;return O==="complete"||O==="error"?!1:2e3}}),r=f?.syncPhase==="error",{data:u}=q({...ee(),enabled:!!i&&r}),N=u?.accounts.find(b=>b.accountId===i)?.lastError,C=f?.mailboxes.find(b=>b.fullPath==="INBOX"||b.fullPath==="Inbox"),P=f?.mailboxCountTotal??0,F=f?.mailboxCountSynced??0,I=C?.messagesTotal??0,M=C?.messagesSynced??0,m=I>0?M/I:0,s=f?.syncPhase,se=r?"failed":s==="idle"||s===void 0||s==="discovering_mailboxes"?"running":P>0?"ok":"running",z=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"?"pending":s==="syncing_inbox"||s==="syncing_others"?"running":"ok",B=r?"failed":!s||s==="idle"||s==="discovering_mailboxes"||s==="syncing_inbox"?"pending":s==="syncing_others"?"running":"ok",ne=M>0||C?.phase==="complete"||s==="complete"||r,[ae,oe]=t.useState(!1);t.useEffect(()=>{if(!i)return;const b=setTimeout(()=>oe(!0),Le);return()=>clearTimeout(b)},[i]);const re=!!i&&(ne||x||ae);return v?e.jsx(L,{steps:T,activeStep:A.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(k,{variant:"primary",onClick:()=>{w.current=!1,E(null),l.mutate({body:{email:a,displayName:d||void 0,username:h!==a?h:void 0,password:o,imapHost:c.host,imapPort:c.port,imapTls:j.tls,imapStartTls:j.startTls,smtpHost:p.host||void 0,smtpPort:p.port||void 0,smtpTls:S.tls,smtpStartTls:S.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:v})}):e.jsx(L,{steps:T,activeStep:A.sync,title:`Syncing ${a}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),re?e.jsx(k,{variant:"primary",onClick:()=>i&&n(i),children:"Go to inbox"}):e.jsx(k,{variant:"primary",disabled:!0,icon:e.jsx(_,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:l.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(_,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[I>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[M.toLocaleString()," / ",I.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(D,{label:"Mailboxes discovered",detail:P>0?`${P} mailbox${P===1?"":"es"} found`:"Discovering…",state:se}),e.jsx(D,{label:"INBOX",detail:z==="ok"?`${M.toLocaleString()} messages synced`:z==="running"?"Syncing newest first…":"Queued",state:z}),F>1||s==="syncing_others"||s==="complete"?e.jsx(D,{label:"Other mailboxes",detail:B==="ok"?`${F-1} mailboxes synced`:B==="running"?"Syncing…":"Queued",state:B}):null]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{y.invalidateQueries({queryKey:K({path:{accountId:i??""}}).queryKey})},children:"retry"})]}),N&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:N})]})]})})}function Be({skipWelcome:a=!1,onComplete:d,onCancel:c,onImportConfig:p}){const[h,o]=t.useState(a?"connector":"welcome"),[n,y]=t.useState({email:"",displayName:"",imapConfig:V,smtpConfig:J,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),i=t.useCallback(()=>o("connector"),[]),g=t.useCallback(()=>o("address"),[]),v=t.useCallback(()=>o("microsoft-email"),[]),E=t.useCallback(()=>{a?c?.():o("welcome")},[a,c]),w=t.useCallback((x,r,u)=>{let N=V,C=J,P=!1;u&&(P=u.source!=="heuristic",N={host:u.imap.host,port:u.imap.port,security:u.imap.security},C={host:u.smtp.host,port:u.smtp.port,security:u.smtp.security}),y(F=>({...F,email:x,displayName:r,imapConfig:N,smtpConfig:C,discoveryResult:u,discovered:P,username:x})),o("servers")},[]),j=t.useCallback((x,r)=>{y(u=>({...u,imapConfig:x,smtpConfig:r}))},[]),S=t.useCallback((x,r)=>{y(u=>({...u,username:x,password:r}))},[]),l=t.useCallback(()=>o("sync"),[]),f=t.useCallback(x=>{d(x)},[d]);switch(h){case"welcome":return e.jsx(Pe,{onStart:i,onImportConfig:p});case"connector":return e.jsx(Te,{onContinue:g,onMicrosoft:v,onBack:E,showBack:!a});case"microsoft-email":return e.jsx(Ae,{onBack:()=>o("connector"),onConnected:f});case"address":return e.jsx(Ie,{initialEmail:n.email,initialDisplayName:n.displayName,onContinue:w,onBack:()=>o("connector")});case"servers":return e.jsx(Me,{email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,discovered:n.discovered,onContinue:()=>o("credentials"),onBack:()=>o("address"),onChange:j});case"credentials":return e.jsx(xe,{steps:T,activeStep:A.credentials,title:`Sign in to ${n.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:n.email,username:n.username,password:n.password,onContinue:()=>o("test"),onBack:()=>o("servers"),onChange:S});case"test":return e.jsx(fe,{steps:T,activeStep:A.test,email:n.email,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onSuccess:l,onBackToCredentials:()=>o("credentials"),onBackToServers:()=>o("servers")});case"sync":return e.jsx(Fe,{email:n.email,displayName:n.displayName,imapConfig:n.imapConfig,smtpConfig:n.smtpConfig,username:n.username,password:n.password,onGoToInbox:f})}}export{Be as O,te as P,Y as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,X as G,aA as X,t as m,r as j,f as I,a2 as H,c as J,ed as ee,s as se,_ as te}from"./index-CvHgBKzk.js";import{u as ne,t as ae,C as re,d as ie,p as le}from"./CalendarComposePane-B0ESup6A.js";import{c as oe,R as ce,u as de,i as xe,d as me,f as fe,U as ue}from"./useCalendars-C17p7Nzh.js";import{A as he}from"./avatar-BxToBov5.js";import{M as pe}from"./minus-DgJyoX-1.js";import{C as _}from"./clock-jA6Z_hAe.js";import{G as U,M as ge,c as ve}from"./useCalendarData-DDXYjxV5.js";import{M as be}from"./mail-BtsVUuTG.js";import{P as je}from"./pencil-D4BuHCoD.js";import{C as Ne}from"./calendar-days-CPA8pt11.js";const q={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},we={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},ye={accepted:X,tentative:_,declined:G,noReply:pe};function K({rsvp:s,className:t}){const a=ye[s];return e.jsxs("span",{className:m("inline-flex items-center gap-1 text-2xs font-medium",we[s],t),children:[e.jsx(a,{className:"size-3"}),q[s]]})}function Ce({attendee:s,active:t=!1,onActivate:a,contextId:n,touch:i=!1,className:o}){const x=e.jsxs(e.Fragment,{children:[e.jsx(he,{name:s.name,email:s.email,size:"sm"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm text-fg",children:s.name}),s.role==="organizer"&&e.jsx("span",{className:"block text-2xs text-fg-subtle",children:"Organiser"})]}),e.jsx(K,{rsvp:s.rsvp})]});return a?e.jsx("button",{type:"button","aria-expanded":t,"aria-controls":t&&n!==void 0?n:void 0,onClick:()=>a(t?"":s.email),onKeyDown:d=>{d.key==="Escape"&&a("")},onBlur:d=>{t&&d.relatedTarget!==null&&(d.currentTarget.parentElement?.contains(d.relatedTarget)||a(""))},className:m("flex w-full items-center gap-2.5 rounded-md px-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",i?"min-h-11":"min-h-9",t?"bg-accent-2-soft":"hover:bg-surface-sunken",o),children:x}):e.jsx("div",{className:m("flex min-h-9 items-center gap-2.5",o),children:x})}function ke({attendees:s,activeEmail:t="",onActivate:a,renderContext:n,touch:i=!1,className:o}){const x=j.useId();if(s.length===0)return null;const d=["accepted","tentative","declined","noReply"].map(l=>({state:l,count:s.filter(h=>h.rsvp===l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${q[l.state].toLowerCase()}`).join(" · ");return e.jsxs("div",{className:m("flex flex-col",o),children:[e.jsx("p",{className:"pb-1 text-2xs uppercase tracking-wider text-fg-subtle",children:`${s.length} guests · ${d}`}),s.map((l,h)=>{const g=l.email===t,v=`${x}-guest-${h}`,r=e.jsx(Ce,{attendee:l,active:g,onActivate:a,contextId:n?v:void 0,touch:i});return a?e.jsxs("div",{children:[r,g&&n&&e.jsx("div",{id:v,className:"py-1",children:n(l)})]},l.email):e.jsx(j.Fragment,{children:r},l.email)})]})}function y({icon:s,children:t}){return e.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:s}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:t})]})}function Ee({event:s,calendar:t,whenText:a,onEdit:n,onDelete:i,onOpenThread:o,onClose:x,activeAttendee:d="",onActivateAttendee:l,renderAttendeeContext:h,touch:g=!1,chrome:v="header",className:r}){const R=oe(t.color),f=e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s.title}),e.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[e.jsx(y,{icon:e.jsx(_,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[a,s.attendees.length>0&&e.jsx(K,{rsvp:s.myRsvp})]})}),s.zoneCertainty==="ambiguous"?e.jsx(y,{icon:e.jsx(U,{className:"size-4 text-warning"}),children:e.jsx("span",{className:"text-warning",children:"The mail said a time but never a zone. Shown in your own; confirm before you travel for it."})}):s.timeZone!==""&&e.jsx(y,{icon:e.jsx(U,{className:"size-4"}),children:s.timeZone}),s.recurrenceRule!==""&&e.jsx(y,{icon:e.jsx(ce,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.recurrenceRule,s.seriesException&&e.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),s.location!==""&&e.jsx(y,{icon:e.jsx(ge,{className:"size-4"}),children:s.location})]}),s.threadId!==""&&o&&e.jsxs("button",{type:"button",onClick:o,className:"mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(be,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),e.jsx("span",{className:"block truncate text-sm text-fg",children:s.threadSubject})]})]}),s.attendees.length>0&&e.jsx(ke,{attendees:s.attendees,activeEmail:d,onActivate:l,renderContext:h,touch:g,className:"mt-3"}),s.notes!==""&&e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:s.notes})]});return v==="bare"?e.jsx("div",{className:m("flex flex-col",r),children:f}):e.jsxs("article",{className:m("flex h-full w-full flex-col bg-surface",r),children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx("span",{className:m("size-2.5 shrink-0 rounded-full",R.solid)}),e.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[t.name," · ",t.accountLabel]}),n&&e.jsx(I,{variant:"ghost",size:"sm",icon:e.jsx(je,{className:"size-3.5"}),onClick:n,children:"Edit"}),i&&e.jsx(I,{variant:"ghost",size:"sm",icon:e.jsx(H,{className:"size-3.5"}),onClick:i,className:"text-danger",children:"Delete"}),x&&e.jsx("button",{type:"button","aria-label":"Close event",onClick:x,className:"flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(G,{className:"size-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:f})]})}const De=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Re({title:s,ruleText:t,instanceText:a,onChoose:n,onCancel:i,touch:o,className:x}){return e.jsxs("div",{className:m("flex flex-col gap-3",x),children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-md font-semibold text-fg",children:[s," repeats"]}),e.jsx("p",{className:"text-xs text-fg-muted",children:t}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",a,"."]})]}),e.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:De.map(d=>e.jsxs("button",{type:"button",onClick:()=>n(d.scope),className:m("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11 justify-center"),children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:d.label}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:d.note})]},d.scope))}),e.jsx(I,{variant:"ghost",size:o?"md":"sm",onClick:i,className:m("self-start",o&&"min-h-11"),children:"Cancel"})]})}const Te=s=>s.replace(/\r?\n[ \t]/g,""),Z=s=>s.replace(/\\n/gi,`
|
|
2
|
+
`).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function ze(s,t){let a=!1;for(let n=t.length;n<s.length;n+=1){const i=s[n];if(n===t.length&&i!==";"&&i!==":")return;if(i==='"'){a=!a;continue}if(!a&&i===":")return s.slice(n+1).trim()}}function S(s,t){for(const a of Te(s).split(/\r?\n/)){if(!a.startsWith(t))continue;const n=ze(a,t);if(n!==void 0)return n}return""}const Ie=s=>S(s,"RRULE"),Se=s=>({location:Z(S(s,"LOCATION")),description:Z(S(s,"DESCRIPTION"))}),$e=se(404);function Le(s,t){const{data:a,isLoading:n,error:i,refetch:o}=J({...ee({path:{calendarObjectId:s},query:{calendarId:t}}),meta:$e,enabled:s!==""&&t!==""});return{resource:a,isLoading:n,error:i,refetch:()=>{o()}}}const z=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),D=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});function Y(s){const t=new Date(s.start),a=new Date(s.end),n=z.format(t);return s.allDay?`${n}, all day`:z.format(a)===n?`${n}, ${D.format(t)} – ${D.format(a)}`:`${n}, ${D.format(t)} – ${z.format(a)}, ${D.format(a)}`}function Ae({event:s,calendar:t,isOccurrence:a,problem:n="",onEdit:i,onDelete:o,onClose:x}){return!s||!t?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[e.jsx(Ne,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"That event isn't on this week"}),e.jsx("p",{className:"max-w-xs text-sm text-fg-muted",children:"The address names an event the calendar doesn't have here."}),e.jsx("button",{type:"button",onClick:x,className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Back to the calendar"})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[a&&e.jsx("p",{className:"shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"One occurrence of a repeating event"}),n!==""&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm",children:[e.jsx(te,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:n})]}),e.jsx(Ee,{event:s,calendar:t,whenText:Y(s),onEdit:i,onDelete:o,onClose:x,className:"min-h-0 flex-1"})]})}const Fe="This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";function Ke({calendarObjectId:s,recurrenceId:t}){const{view:a,date:n,calendarIds:i}=de(),{events:o}=ve({view:a,date:n,calendarIds:i}),{calendars:x,timeZoneByCalendarId:d}=xe(),{closeEvent:l}=me(),{updateEvent:h,deleteEvent:g,isWriting:v}=ne(),r=o.find(c=>c.id===fe(s,t??"")),R=x.find(c=>c.id===r?.calendarId),{resource:f}=Le(s,r?.calendarId??""),[$,N]=j.useState(void 0),[p,T]=j.useState(void 0),[b,C]=j.useState(void 0),[L,w]=j.useState(""),k=f?Se(f.icalData):void 0,A=f?Ie(f.icalData):"",Q=r&&!r.allDay?r.start.slice(11,16):"",E=A===""?"":ae(A,Q)??"Repeats",F=r!==void 0&&r.seriesId!==""&&t!==void 0&&t!=="",O=r!==void 0&&f!==void 0,M=(c,u)=>{if(c.kind==="written"){w(""),u();return}w(c.kind==="conflict"?Fe:c.message)},P=c=>({calendarObjectId:s,calendarId:r?.calendarId??"",recurrenceId:t??"",scope:c,etag:f?.etag??""}),B=c=>{if(!r)return;const u=ie(r,{repeat:E,location:k?.location??"",notes:k?.description??""});N(void 0),T({before:u,scope:c}),C(u),w("")},W=c=>{N(void 0),g(P(c)).then(u=>M(u,l))},V=()=>{if(!p||!b)return;const c=le(p.before,b,d[b.calendarId]??ue);if(!c.ok){w(c.problem);return}h(P(p.scope),c.patch).then(u=>M(u,()=>{T(void 0),C(void 0)}))};return $!==void 0&&r?e.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:e.jsx(Re,{className:"mx-auto w-full max-w-md",title:r.title,ruleText:E===""?"It repeats":E,instanceText:Y(r),onChoose:$==="edit"?B:W,onCancel:()=>N(void 0)})}):p&&b?e.jsx(re,{title:"Edit event",subtitle:p.scope==="this"?"This occurrence only":b.date,calendars:x,draft:b,onChange:C,problem:L,saveLabel:"Save",isSaving:v,repeatEditable:p.scope===void 0||p.scope==="all",calendarEditable:!1,onSave:V,onCancel:()=>{T(void 0),C(void 0),w("")}}):e.jsx(Ae,{event:r&&{...r,location:k?.location??"",notes:k?.description??"",recurrenceRule:E},calendar:R,isOccurrence:t!==void 0,problem:L,onEdit:O?()=>F?N("edit"):B(void 0):void 0,onDelete:O?()=>F?N("delete"):W(void 0):void 0,onClose:l})}export{Ke as O};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aq as g,_ as w,L as C,j as s,t as b,cP as F,a2 as _,$ as S,a8 as q,u as U,c3 as H,r as x,c5 as K,c as W,ac as G,C as J,U as k,dC as R,cT as V,h as X,as as Y,cC as Z,i as v,au as y,cr as ee,cs as se}from"./index-Bcu7BqZh.js";import{u as te,p as ne,R as j,c as ae}from"./useSearchTokenContext-BW55Y3Yb.js";import{C as I}from"./circle-check-big-UXLrOtDo.js";import{C as T}from"./clock-a9wtJIFb.js";import{R as oe}from"./row-actions-D6pg-4y5.js";import{R as re}from"./rotate-ccw-Coc_HVFv.js";import{N as D}from"./NavMenuButton-DZeoJSH-.js";import{a as p,t as ie}from"./format-CxG3FNVs.js";import{i as le,s as A}from"./outbox-status-BlKn6P0x.js";import{n as ce}from"./search-query-Cr_ZXBCp.js";import{f as de}from"./useMessageBodyContent-ClKIcNPh.js";const ue={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:I,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:n,className:a}){const t=ue[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"||e==="unfiled"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:l,onSelect:c,onRetry:r,retrying:d,onEdit:i,onDelete:f,deleting:u}){const m=t==="failed"||t==="blocked"||t==="unfiled";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,l)),children:[s.jsxs("button",{type:"button",...F,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),m&&s.jsx("div",{className:"shrink-0",children:s.jsx(oe,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(re,{className:"size-3.5"}),busy:d,onClick:r}]:[],...t==="unfiled"?[]:[{label:"Edit as draft",iconOnly:!0,icon:s.jsx(S,{className:"size-3.5"}),onClick:i}]],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(_,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function Ee(){return q({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function me(){const e=U(),n=H();return x.useCallback(a=>{e({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:a},search:t=>t,hash:n})},[e,n])}function he(){return K()}function be(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function ge(e){return e.tokens.length>0&&e.freeText.trim().length===0}const L={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2"},sent:{icon:I,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}},pe=e=>ie(e).toDateString()===new Date().toDateString()?p(e,{hour:"numeric",minute:"2-digit"}):p(e,{month:"short",day:"numeric"}),M=e=>p(e,{dateStyle:"medium",timeStyle:"short"}),je=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},E=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",P=x.createContext(null);function N(){const e=x.useContext(P);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function Ne({outboxMessageId:e,children:n}){const a=me(),t=he(),{data:o,isLoading:l}=W(G()),{searchQuery:c}=J(),r=te(),d=ce(c),i=ne(d,r),f=d.length>0,u=ge(i),m=x.useMemo(()=>u?[]:(o?.items??[]).filter(h=>le(h.status)).filter(h=>be(h,i.freeText)),[o,i.freeText,u]),z=x.useMemo(()=>m.find(h=>h.outboxMessageId===e),[m,e]),$={messages:m,hasQuery:f,unsupportedQuery:u,isLoading:l,selectedMessageId:e,selectedMessage:z,onOpenMessage:a,onCloseMessage:t};return s.jsx(P.Provider,{value:$,children:n})}function Q({message:e,isSelected:n,onSelect:a}){const t=X(),o=de(),{pushError:l}=Y(),c=x.useCallback(()=>{t.invalidateQueries({queryKey:Z()})},[t]),r=v({...ee(),onSuccess:c,onError:u=>{l(y("Couldn't resend message","The message wasn't sent.",u))}}),d=v({...se(),onSuccess:c,onError:u=>{l(y("Couldn't delete message","The message wasn't deleted.",u))}}),i=e.status;if(!L[i])return null;const f=A(e.status);return s.jsx(fe,{recipients:je(e),subject:e.subject||"",time:pe(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o(e.outboxMessageId),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function B({message:e,onBack:n}){const a=e.status,t=L[a],o=t?.icon??S,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(V,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:b("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:b("text-xs font-medium",t.className),children:t.label}),A(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(ae,{html:e.htmlBody,text:e.textBody})})]})}function ve(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:l}=N(),c=x.useRef(null);return k({containerRef:c,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(D,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(Q,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function ye(){const{selectedMessage:e}=N();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(j,{message:"Select a message to read",showHints:!1})})]})}function Oe(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=N(),d=x.useRef(null);return k({containerRef:d,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(D,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(Q,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const Pe=Object.assign(Ne,{List:ve,Reading:ye,Phone:Oe});export{Pe as O,Ee as u};
|
|
1
|
+
import{aq as g,_ as w,L as C,j as s,t as b,cT as F,a2 as _,$ as S,a8 as q,u as U,c7 as G,r as x,c9 as H,c as K,ac as W,C as X,U as k,dG as R,cX as J,h as V,as as Y,cG as Z,i as v,au as y,cv as ee,cw as se}from"./index-CvHgBKzk.js";import{u as te,p as ne,R as j,c as ae}from"./useSearchTokenContext-Dvm-Yobe.js";import{C as I}from"./circle-check-big-Dge9pLwP.js";import{C as T}from"./clock-jA6Z_hAe.js";import{R as oe}from"./row-actions-NntamOda.js";import{R as re}from"./rotate-ccw-BAMGL0nD.js";import{N as D}from"./NavMenuButton-FBbQvMN0.js";import{a as p,t as ie}from"./format-CTO21bLP.js";import{i as le,s as A}from"./outbox-status-BlKn6P0x.js";import{n as ce}from"./search-query-Cr_ZXBCp.js";import{f as de}from"./useMessageBodyContent-DAz3qVkt.js";const ue={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:I,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:n,className:a}){const t=ue[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"||e==="unfiled"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:l,onSelect:c,onRetry:r,retrying:d,onEdit:i,onDelete:f,deleting:u}){const m=t==="failed"||t==="blocked"||t==="unfiled";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,l)),children:[s.jsxs("button",{type:"button",...F,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),m&&s.jsx("div",{className:"shrink-0",children:s.jsx(oe,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(re,{className:"size-3.5"}),busy:d,onClick:r}]:[],...t==="unfiled"?[]:[{label:"Edit as draft",iconOnly:!0,icon:s.jsx(S,{className:"size-3.5"}),onClick:i}]],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(_,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function Ee(){return q({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function me(){const e=U(),n=G();return x.useCallback(a=>{e({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:a},search:t=>t,hash:n})},[e,n])}function he(){return H()}function be(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function ge(e){return e.tokens.length>0&&e.freeText.trim().length===0}const L={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2"},sent:{icon:I,label:"Sent",className:"text-positive"},unfiled:{icon:g,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:g,label:"Blocked",className:"text-warning"}},pe=e=>ie(e).toDateString()===new Date().toDateString()?p(e,{hour:"numeric",minute:"2-digit"}):p(e,{month:"short",day:"numeric"}),M=e=>p(e,{dateStyle:"medium",timeStyle:"short"}),je=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},E=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",Q=x.createContext(null);function N(){const e=x.useContext(Q);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function Ne({outboxMessageId:e,children:n}){const a=me(),t=he(),{data:o,isLoading:l}=K(W()),{searchQuery:c}=X(),r=te(),d=ce(c),i=ne(d,r),f=d.length>0,u=ge(i),m=x.useMemo(()=>u?[]:(o?.items??[]).filter(h=>le(h.status)).filter(h=>be(h,i.freeText)),[o,i.freeText,u]),z=x.useMemo(()=>m.find(h=>h.outboxMessageId===e),[m,e]),$={messages:m,hasQuery:f,unsupportedQuery:u,isLoading:l,selectedMessageId:e,selectedMessage:z,onOpenMessage:a,onCloseMessage:t};return s.jsx(Q.Provider,{value:$,children:n})}function P({message:e,isSelected:n,onSelect:a}){const t=V(),o=de(),{pushError:l}=Y(),c=x.useCallback(()=>{t.invalidateQueries({queryKey:Z()})},[t]),r=v({...ee(),onSuccess:c,onError:u=>{l(y("Couldn't resend message","The message wasn't sent.",u))}}),d=v({...se(),onSuccess:c,onError:u=>{l(y("Couldn't delete message","The message wasn't deleted.",u))}}),i=e.status;if(!L[i])return null;const f=A(e.status);return s.jsx(fe,{recipients:je(e),subject:e.subject||"",time:pe(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o(e.outboxMessageId),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function B({message:e,onBack:n}){const a=e.status,t=L[a],o=t?.icon??S,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(J,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:b("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:b("text-xs font-medium",t.className),children:t.label}),A(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(ae,{html:e.htmlBody,text:e.textBody})})]})}function ve(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:l}=N(),c=x.useRef(null);return k({containerRef:c,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(D,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(P,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function ye(){const{selectedMessage:e}=N();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(j,{message:"Select a message to read",showHints:!1})})]})}function Oe(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=N(),d=x.useRef(null);return k({containerRef:d,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(D,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(P,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const Qe=Object.assign(Ne,{List:ve,Reading:ye,Phone:Oe});export{Qe as O,Ee as u};
|