@remit/web-client-dist 0.0.429 → 0.0.430
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-CytP3J7O.js +1 -0
- package/assets/{ErrorState-CNHmvGYF.js → ErrorState-B_pp6XjY.js} +1 -1
- package/assets/FlaggedPane-BTGAqs21.js +1 -0
- package/assets/FullCompose-D8BBZrtI.js +1 -0
- package/assets/MailListHeader-BjsRsJYI.js +7 -0
- package/assets/MailShell-CvPQWjl1.js +1 -0
- package/assets/{MailViewChrome-CZb8kPr_.js → MailViewChrome-ZN5UsScT.js} +1 -1
- package/assets/MailboxPane-Bca57rKs.js +1 -0
- package/assets/{NavMenuButton-BIPTnOry.js → NavMenuButton-_aiK1QXb.js} +1 -1
- package/assets/OnboardingWizard-BdBknD3m.js +1 -0
- package/assets/OutboxPane-3nlNVjx6.js +1 -0
- package/assets/_mailboxId-ByYUZV2Y.js +1 -0
- package/assets/_messageId-DLU18Mnl.js +1 -0
- package/assets/_messageId-DzC6VHu2.js +1 -0
- package/assets/_messageId-yJtPeY_Z.js +1 -0
- package/assets/_outboxMessageId-AEnONMiY.js +1 -0
- package/assets/_threadId-BdblixoD.js +1 -0
- package/assets/_threadId-CC5eBVBw.js +1 -0
- package/assets/_threadId-Cb8ALPnU.js +1 -0
- package/assets/accounts-Cji9zFqV.js +1 -0
- package/assets/{advanced-DKEc5X7D.js → advanced-BXCAioJN.js} +2 -2
- package/assets/appearance-Dg7qROVT.js +1 -0
- package/assets/{attachment-file-BrXH3M3V.js → attachment-file-CLrI3kMw.js} +1 -1
- package/assets/{avatar-DtND0ruk.js → avatar-C8lpjlQO.js} +1 -1
- package/assets/{bottom-sheet-Cpg512Z8.js → bottom-sheet-BuEgZWXh.js} +1 -1
- package/assets/brief-06HoE0GS.js +1 -0
- package/assets/{brief-CP_gyoWx.js → brief-Dt7lMB8R.js} +1 -1
- package/assets/{browser-ponyfill-BQQucyWN.js → browser-ponyfill-g58jgFl_.js} +2 -2
- package/assets/{bug-D-5qIgn1.js → bug-CDU4oK_3.js} +1 -1
- package/assets/{circle-check-CyTXHuU4.js → circle-check-BhMyR8BA.js} +1 -1
- package/assets/{circle-check-big-BCgBHZQm.js → circle-check-big-5NMrNFUI.js} +1 -1
- package/assets/{circle-help-lK4oidSt.js → circle-help-BAup3nOG.js} +1 -1
- package/assets/{clock-CpWsGek7.js → clock-DCdX5E4T.js} +1 -1
- package/assets/compose._-_outboxMessageId_-CyN4sUxa.js +1 -0
- package/assets/compose._-_outboxMessageId_-D5_JMiLJ.js +1 -0
- package/assets/compose._-_outboxMessageId_-Db3_5Bzx.js +1 -0
- package/assets/compose._-_outboxMessageId_-YqQysly2.js +1 -0
- package/assets/{confirm-dialog-CSNgGV-I.js → confirm-dialog-BxXd7BDT.js} +1 -1
- package/assets/{download-Yg8MAJuV.js → download-Br1uSntK.js} +1 -1
- package/assets/filters-snY8U8V2.js +1 -0
- package/assets/{flagged-CPZoSWDR.js → flagged-DBt5871J.js} +1 -1
- package/assets/flagged-DErOl3l4.js +1 -0
- package/assets/folders-BzRKidwZ.js +1 -0
- package/assets/{help-copy-o2bu5jXr.js → help-copy-D1mikTkH.js} +1 -1
- package/assets/index--TsBKY5T.js +1 -0
- package/assets/index-BG1B897N.js +1 -0
- package/assets/index-BIcRfpbR.js +1 -0
- package/assets/index-DLU18Mnl.js +1 -0
- package/assets/{index-DwTAdS0U.js → index-DX5RhVmh.js} +7 -7
- package/assets/index-DqLBbxu3.js +1 -0
- package/assets/index-DwKeNLeB.js +1 -0
- package/assets/{index-D_YBuI3z.js → index-idulIG65.js} +69 -69
- package/assets/index-yJtPeY_Z.js +1 -0
- package/assets/index-zNCEv1vY.js +1 -0
- package/assets/{kbd-BUm8HPo9.js → kbd-eZWvlfcb.js} +1 -1
- package/assets/labels-DFa210V0.js +1 -0
- package/assets/{mail-yZgIYq66.js → mail-Ba7j-n-X.js} +1 -1
- package/assets/mail-lLnBwPN-.js +1 -0
- package/assets/{menu-B4mmeG34.js → menu-MXmFQ7m-.js} +1 -1
- package/assets/onboarding-BQv4jg_d.js +1 -0
- package/assets/outbox-Dye6uwnb.js +1 -0
- package/assets/{pencil-rdzjE11g.js → pencil-CFys2EU7.js} +1 -1
- package/assets/{rich-text-BKM0xPkp.js → rich-text-DUWqcHC5.js} +3 -3
- package/assets/{rich-text-spellcheck-worker-provider-Dg635-7T.js → rich-text-spellcheck-worker-provider-DTxcyJ9W.js} +1 -1
- package/assets/{rotate-ccw-5k3dg52M.js → rotate-ccw-DfGOnKhE.js} +1 -1
- package/assets/{row-actions-BGPkkIDv.js → row-actions-zVghhE3a.js} +1 -1
- package/assets/search-mirror-_pK4jqc8.js +1 -0
- package/assets/search-scope-DTcpOp3S.js +1 -0
- package/assets/search-token-index-C-cpQFN3.js +1 -0
- package/assets/senders-Gj8Yentl.js +1 -0
- package/assets/settings-D96it8Kf.js +1 -0
- package/assets/{settings-screen-D53GKsd_.js → settings-screen-B17eDLDl.js} +1 -1
- package/assets/{shield-check-BZ36Y5z_.js → shield-check-DG9twqa-.js} +1 -1
- package/assets/suggested-vips--KmGV5np.js +1 -0
- package/assets/{useDebouncedValue-4E-721vu.js → useDebouncedValue-CntZIoMR.js} +1 -1
- package/assets/{useFilters-BdPFYyLi.js → useFilters-DaiBln2b.js} +1 -1
- package/assets/useLabels-amyS-Wph.js +1 -0
- package/assets/useMessageBodyContent-5kw10g9a.js +1 -0
- package/assets/useRefreshControl-CUTMAyIA.js +1 -0
- package/assets/{useSearchTokenContext-DROeO7xw.js → useSearchTokenContext-BxDapNdu.js} +4 -4
- package/assets/useSemanticSearch-BDxoAQSc.js +1 -0
- package/assets/useSignature-osTmnWZe.js +1 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-D4GKn4Vw.js +0 -1
- package/assets/FlaggedPane-CIICNSCS.js +0 -1
- package/assets/FullCompose-B0bbns1M.js +0 -1
- package/assets/MailListHeader-BcdPneAy.js +0 -7
- package/assets/MailboxPane-MXdO0Vz2.js +0 -1
- package/assets/OnboardingWizard-yfi2kykm.js +0 -1
- package/assets/OutboxPane-mFkq2dEJ.js +0 -1
- package/assets/_mailboxId--xq6K8vG.js +0 -1
- package/assets/_messageId-CTALYmhq.js +0 -1
- package/assets/_messageId-CmMd3Ukp.js +0 -1
- package/assets/_messageId-CtxjpTtR.js +0 -1
- package/assets/_outboxMessageId-VPhQOPhK.js +0 -1
- package/assets/_threadId-1kFdcas1.js +0 -1
- package/assets/_threadId-7ZWe-9US.js +0 -1
- package/assets/_threadId-DNmSvZSP.js +0 -1
- package/assets/accounts--GnFjtNP.js +0 -1
- package/assets/appearance-Bn-KJ5jL.js +0 -1
- package/assets/brief-DWBpwjTi.js +0 -1
- package/assets/compose._-_outboxMessageId_-Bh6SV1dn.js +0 -1
- package/assets/compose._-_outboxMessageId_-CYWE1jEd.js +0 -1
- package/assets/compose._-_outboxMessageId_-Cn0WCeO7.js +0 -1
- package/assets/compose._-_outboxMessageId_-SUbFIkQY.js +0 -1
- package/assets/filters-BYXepTJ3.js +0 -1
- package/assets/flagged-CtM4krn0.js +0 -1
- package/assets/folders-BMWrmSe-.js +0 -1
- package/assets/index-BaVdEvyR.js +0 -1
- package/assets/index-BgNbixl6.js +0 -1
- package/assets/index-C015CYKF.js +0 -1
- package/assets/index-Cf-KjbzP.js +0 -1
- package/assets/index-CmMd3Ukp.js +0 -1
- package/assets/index-CtxjpTtR.js +0 -1
- package/assets/index-TQGaXC_d.js +0 -1
- package/assets/index-zMBRTYBv.js +0 -1
- package/assets/labels-DriP01Rs.js +0 -1
- package/assets/mail-Byqd_siN.js +0 -1
- package/assets/onboarding-BbbW2CcQ.js +0 -1
- package/assets/outbox-B7YGZwez.js +0 -1
- package/assets/search-scope-MtY0zpRq.js +0 -1
- package/assets/search-token-index-nAK4hI7B.js +0 -1
- package/assets/search-view-CtInfT0I.js +0 -1
- package/assets/senders-CRCPlNSI.js +0 -1
- package/assets/settings-zuLLX00L.js +0 -1
- package/assets/suggested-vips-BZprt8nM.js +0 -1
- package/assets/useLabels-CwcqSC09.js +0 -1
- package/assets/useMediaQuery-CDMcFeIb.js +0 -1
- package/assets/useMessageBodyContent-DEOYO0s3.js +0 -1
- package/assets/useRefreshControl-h1VyXjLX.js +0 -1
- package/assets/useSearchMirror-rswuH5l3.js +0 -1
- package/assets/useSemanticSearch-RnkqtV8e.js +0 -1
- package/assets/useSignature-C3CmLf8D.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as n,ar as Xe,S as Ze,bS as es,v as Y,b3 as ss,bF as ts,r as a,D as ne,bT as oe,z as ns,bU as os,bV as as,bW as rs,e as Te,bX as is,a8 as cs,bP as ls,bQ as ds}from"./index-idulIG65.js";import{s as je,a as us,b as Re,u as ms,p as fs,R as hs}from"./useSearchTokenContext-BxDapNdu.js";import{aa as be,H as ve,ab as gs,ac as xs,I as ps,ad as ye,ae as Is,af as bs,ag as vs,a9 as ys,ah as Ss,ai as Cs,aj as Ts,M as js,ak as Rs,al as ws,am as Ms,e as ks,v as Fs,an as As,q as Ns,S as Os,L as Bs,Q as Se,P as Ds,N as Ls,d as Es,_ as Ps,$ as qs,a1 as we,a2 as Me,a3 as zs,a4 as Qs,a5 as Hs}from"./MailListHeader-BjsRsJYI.js";import{u as _s,a as Ws,R as $s,i as Us,b as Vs}from"./useRefreshControl-CUTMAyIA.js";import{f as Gs,p as Ys,d as Js,R as Ks,k as Xs,l as Zs}from"./search-token-index-C-cpQFN3.js";import{a as et}from"./useLabels-amyS-Wph.js";import{u as st,r as tt,L as nt}from"./useSemanticSearch-BDxoAQSc.js";import{w as ot}from"./wizard-selection-B1bng5Jq.js";import{u as ke}from"./index-DX5RhVmh.js";import{a as at}from"./useMessageBodyContent-5kw10g9a.js";function rt({sync:e}){return e?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[n.jsx(Xe,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:it(e)})]}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[n.jsx(Ze,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function it({synced:e,total:s}){return s>0?`${e.toLocaleString()} of ${s.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const Fe=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Ae="category",ct={unclassified:"uncategorized"},W=e=>us(e).map(s=>s.raw),_=e=>e.join(" "),ae=e=>{const s=Re(e);if(s)return Fe.find(o=>o.name===s.name&&o.value===s.value.toLowerCase())?.id},re=e=>{const s=Re(e);if(!s||s.name!==Ae)return;const o=s.value.toLowerCase(),r=ct[o];if(r)return r;if(!(!es(o)||o==="all"))return o},Ne=e=>Fe.find(s=>s.id===e),Oe=e=>Ne(e)!==void 0,lt=e=>{const s=new Set;for(const o of W(e)){const r=ae(o);r&&s.add(r)}return s},dt=e=>{let s="all";for(const o of W(e)){const r=re(o);r&&(s=r)}return s},ut=(e,s)=>{const o=Ne(s);if(!o)return;const r=W(e),l=r.filter(d=>ae(d)!==s);return l.length<r.length?_(l):_([...r,je(o.name,o.value)])},mt=(e,s)=>{const o=W(e).filter(r=>!re(r));return _(s==="all"?o:[...o,je(Ae,s)])},ft=e=>_(W(e).filter(s=>!ae(s)&&!re(s))),Be=e=>e.trim().length>0,ht=e=>{if(!Be(e.query))return e.ownFilters;const s=new Set(lt(e.query));for(const o of e.ownFilters)Oe(o)||s.add(o);return s},gt=e=>Be(e.query)?dt(e.query):e.ownCategory,xt=(e,s)=>e.createdAt!==s.createdAt?e.createdAt-s.createdAt:e.accountId.localeCompare(s.accountId),pt=e=>[...e].sort(xt),It=200,Ce=()=>n.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,s)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[n.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},s))}),bt=({accountEmail:e})=>{const s=ke();return n.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[n.jsx(Te,{className:"size-3.5 shrink-0"}),n.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),n.jsx("button",{type:"button",onClick:()=>s("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},vt=(e,s)=>{if(s.size===0)return{};const o=e.filter(d=>s.has(d.id)),r=tt(o.map(d=>d.accountId));if(r.restriction)return r;const l=new Set;for(const d of o)d.mailboxId&&l.add(d.mailboxId);return l.size>1?{accountId:r.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${l.size} folders`}:{accountId:r.accountId,mailboxId:l.size===1?[...l][0]:void 0}};function yt({header:e,rows:s,wizard:o,children:r}){const{selectedIds:l,selectedCount:d,exitSelection:u,orderedIds:m,allSelected:b,toggleAllLoaded:f}=Ms(),x=a.useMemo(()=>vt(s,l),[s,l]),{junkMailboxId:D}=ks(x.accountId),{labels:I}=et(x.accountId),p=a.useMemo(()=>Array.from(l),[l]),L=a.useMemo(()=>ot(s,l),[s,l]),h=Fs(D,x.mailboxId),v=a.useMemo(()=>m.length>0?{checked:b,indeterminate:d>0&&!b,onChange:f}:void 0,[m.length,b,d,f]),F=x.moveDisabledHint?{tone:"warning",text:x.moveDisabledHint}:void 0,S=C=>n.jsx(Os,{title:C.title,navSlot:C.navSlot,titleMeta:C.titleMeta,searchSlot:C.searchSlot,searchField:C.searchField,idleSlot:C.makeFilterSlot,count:d,onCancel:u,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:h?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:x.accountId&&x.mailboxId&&d>0&&I.length>0?n.jsx(nt,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:p}):void 0,selectAll:v,notice:F});return n.jsx(As,{...e,selectionBar:S,paneOverlay:n.jsx(Ns,{verb:o.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:L,selectionRestriction:x.restriction,onFinished:u}),children:r})}function St({accounts:e,selectedMessageId:s,onOpenThread:o,commandsRef:r,onTriageContextChange:l,onDeleteMessages:d}){const{searchQuery:u,searchInput:m,resultFolderIndex:b,onSearchChange:f}=Y(),x=ms(),D=ss(),I=Gs(),p=ts(),L=Ys(),h=a.useMemo(()=>pt(e.filter(t=>!t.muted?.value)),[e]),[v,F]=a.useState("all"),[S,C]=a.useState("all"),[$,E]=a.useState(new Set),[K,T]=a.useState(!1),P=a.useCallback(t=>{E(i=>{const c=new Set(i);return c.has(t)?c.delete(t):c.add(t),c})},[]),U=a.useCallback(()=>E(new Set),[]),R=m.trim().length>0,j=a.useMemo(()=>ht({query:m,ownFilters:$}),[m,$]),w=a.useMemo(()=>gt({query:m,ownCategory:S}),[m,S]),A=a.useCallback(t=>{if(!R||!Oe(t)){P(t);return}const i=ut(m,t);i!==void 0&&f(i)},[R,m,f,P]),q=a.useCallback(t=>{if(!R){C(t);return}f(mt(m,t))},[R,m,f]),z=a.useCallback(()=>{C("all"),F("all"),U(),R&&f(ft(m))},[R,m,f,U]),{data:N,isLoading:Q,isError:g,refetch:O}=ne({...oe(),staleTime:6e4}),B=Js({queries:h.map(t=>({...ns({path:{accountId:t.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),V=a.useMemo(()=>{const t=new Map;for(let i=0;i<h.length;i++){const c=h[i].accountId,Ye=(B[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);t.set(c,Ye)}return t},[h,B]),Ee=a.useMemo(()=>h.filter((t,i)=>{const c=B[i];return c?.isError?!os(c.error):!1}),[h,B]),{freeText:M,tokens:X}=fs(u.trim().toLowerCase(),x),{data:ie,isFetching:Pe}=ne({...oe({query:{query:M,limit:It}}),enabled:M.length>0,staleTime:3e4}),y=a.useMemo(()=>{const t=be(N?.items??[]).map(ve);return(M?gs(t.filter(c=>xs(c,M)),be(ie?.items??[]).map(ve)):t).filter(c=>(v==="all"||c.accountId===v)&&ps(c,X))},[N,ie,v,M,X]),{bodyRows:ce,briefSpamOffer:Z}=a.useMemo(()=>{if(!M)return{bodyRows:y,briefSpamOffer:void 0};const t=y.map(k=>ye(k,b)),{spam:i}=Is(t);if(i.length===0)return{bodyRows:y,briefSpamOffer:void 0};const c=new Set(i.map(k=>k.id));return{bodyRows:y.filter(k=>!c.has(k.id)),briefSpamOffer:bs(t)}},[y,M,b]),le=a.useMemo(()=>vs(ce),[ce]),de=a.useCallback((t,i)=>{const c=y.find(k=>k.id===t)?.threadId;c&&o?.({threadId:c,messageId:t},i)},[y,o]),qe=a.useCallback(t=>{const i=t.threadId??y.find(c=>c.id===t.id)?.threadId;i&&o?.({threadId:i,messageId:t.id})},[y,o]),ee=a.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:v==="all"},...h.map(t=>({id:t.accountId,label:t.email.split("@")[0]??t.email,count:V.get(t.accountId),active:v===t.accountId}))],[h,V,v]),H=a.useMemo(()=>e.filter(t=>t.muted?.value).length,[e]),ze=a.useMemo(()=>Array.from(V.values()).reduce((t,i)=>t+i,0),[V]),se=a.useMemo(()=>h.map(t=>t.accountId),[h]),{hasNewMail:ue}=_s(),{state:me,errorMessage:fe,refresh:he}=Ws(se,{onSettled:()=>O()}),Qe=a.useMemo(()=>n.jsx($s,{state:me,onRefresh:he,label:"Refresh daily brief",errorMessage:fe,hasUpdate:ue(se)}),[me,he,fe,ue,se]),te=a.useMemo(()=>y.filter(t=>(w==="all"||t.category===w)&&as(t,j)).map(t=>ye(t,b)),[y,w,j,b]),{hits:ge,isLoading:He}=st(),_e=a.useMemo(()=>{const t=new Map;for(const c of N?.items??[])t.set(c.messageId,c.threadId);const i=te.map(c=>t.get(c.id)).filter(c=>c!=null);return ys(ge,i,b)},[ge,te,N,b]),We=a.useMemo(()=>{const t=Ss(ee.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:t.categories,filters:t.filters,sources:t.sources,sourcesNote:H>0?`+${H} muted`:void 0,selectedCategory:w,activeFilters:j,expanded:K,onExpandedChange:T,onSelectCategory:i=>q(i),onSelectSource:F,onToggleFilter:i=>A(i),onClear:z}},[ee,H,w,j,K,A,q,z]),xe=le.length===0&&v==="all"&&M.length===0&&X.length===0,$e=a.useMemo(()=>h.map(t=>t.accountId),[h]),Ue=a.useMemo(()=>h.some(t=>Us(t.syncPhase)),[h]),G=Vs($e,xe||Ue),pe=n.jsxs("div",{className:"h-full overflow-y-auto",children:[n.jsx(Ce,{}),n.jsx(Ce,{})]}),Ie=!Q&&!g&&!xe,Ve=Cs({tier:I,hasLiveInput:R,hasCommittedQuery:u.trim().length>0,bodyRendersCommittedResults:!0}),Ge=Ie?n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Z&&n.jsx(Ts,{count:Z.count,onScopeToSpam:()=>L(Z.mailboxId,u)}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(rs,{sections:le,briefCategory:w,Row:js,selectedThreadId:s,onSelectThread:de,onSelectBriefCategory:q,sources:ee,sourcesNote:H>0?`+${H} muted`:void 0,onSelectSource:F,activeFilters:j,onToggleFilter:A,onClearFilters:z})})]}):Q?pe:g?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[n.jsx(Te,{className:"size-8 text-danger"}),n.jsx("p",{children:"Couldn't load your messages"}),n.jsxs("button",{type:"button",onClick:()=>O(),className:"flex items-center gap-1 text-accent underline text-xs",children:[n.jsx(Ks,{className:"size-3.5"}),"Try again"]})]}):G.resolved?n.jsx(rt,{sync:G.syncing?{synced:G.synced,total:G.total}:void 0}):pe;return n.jsx(is,{hasSheet:Ie&&!Ve,children:n.jsx(Rs,{selectedMessageId:s,rows:y,onOpen:de,onDeleteMessages:d,onSelectionVerb:p.start,wizardOpen:p.isOpen,commandsRef:r,onTriageContextChange:l,children:n.jsx(yt,{wizard:p,header:{title:"Daily brief",unreadCount:ze,footer:D?n.jsx(ws,{}):void 0,searchFilter:We,searchResults:te,searchLoading:Q||Pe,relatedResults:_e,relatedLoading:He,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:y,children:n.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(t=>n.jsx(bt,{accountEmail:t.email,accountId:t.accountId},t.accountId)),n.jsx("div",{className:"min-h-0 flex-1",children:Ge})]})})})})}const De=a.createContext(null);function J(){const e=a.useContext(De);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Ct({thread:e,children:s}){const o=Xs(),r=Zs(),l=ke(),{searchInput:d}=Y(),u=e?.threadId,m=e?.messageId,{data:b}=ne({...oe(),staleTime:6e4}),f=a.useMemo(()=>b?.items??[],[b]),x=a.useMemo(()=>{if(u)return f.find(g=>g.messageId===m)??f.find(g=>g.threadId===u)},[f,u,m]),D=Bs(u,m),I=x??D,p=m??I?.messageId,L=a.useMemo(()=>{if(u)return{threadId:u,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:p,authenticity:I?.authenticity}},[u,I,p]),h=a.useCallback((g,O)=>{o(g,{replace:O?.replace,query:d})},[o,d]),v=a.useCallback(g=>{p&&g.includes(p)&&r()},[p,r]),F=Se({thread:I,onAfterOptimisticRemove:v}),S=Ds(),{deleteMessages:C}=Ls({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:v}),{toggleReadFor:$}=Es({mailboxId:I?.mailboxId??"",messages:f}),E=S.focusedMessageId,T=a.useMemo(()=>f.find(g=>g.messageId===E),[f,E])??I,P=Se({thread:T}),U=at(),R=cs(),j=ls(),w=a.useMemo(()=>ds(j,u,p),[j,u,p]),A=a.useMemo(()=>{if(T)return g=>j({threadId:T.threadId,messageId:T.messageId,mode:g})},[j,T]),{nextMessageId:q,previousMessageId:z}=Ps({context:S,orderedIds:S.orderedIds,selectedMessageId:p,enabled:!U&&!R,onClose:r,handlers:{reply:()=>A?.("reply"),replyAll:()=>A?.("reply-all"),forward:()=>A?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||T&&$([T.messageId],!T.isRead)},goFlagged:()=>l("flagged"),goSettings:()=>l("settings")}}),N=a.useCallback(g=>{if(!g)return;const O=f.find(B=>B.messageId===g);return O?{threadId:O.threadId,messageId:g}:void 0},[f]),Q={selectedMessageId:p,selectedThread:I,conversation:L,onOpenThread:h,onCloseThread:r,nextThread:N(q),previousThread:N(z),actions:F,onReply:w,triage:S,onDeleteMessages:C,handleDeselectIfRemoved:v};return n.jsx(De.Provider,{value:Q,children:s})}function Le(){const{selectedMessageId:e,onOpenThread:s,triage:o,onDeleteMessages:r}=J(),{accounts:l}=Y();return n.jsx(St,{accounts:l,selectedMessageId:e,onOpenThread:s,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:r})}function Tt(){const{conversation:e,selectedThread:s,actions:o,onReply:r,handleDeselectIfRemoved:l}=J(),d=!!e,u=Qs(e?.threadId);return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(Hs,{hasThread:d,intelligenceOpen:u.isShowing,canToggleIntelligence:u.canToggle,onToggleIntelligence:u.toggle,onReply:r?()=>r("reply"):void 0,onReplyAll:r?()=>r("reply-all"):void 0,onForward:r?()=>r("forward"):void 0,onDelete:d?o.deleteThread:void 0,onToggleStar:d?o.toggleStar:void 0,isStarred:o.isStarred,moveContext:d&&o.accountId&&o.mailboxId?{accountId:o.accountId,currentMailboxId:o.mailboxId,onMove:o.moveThread}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?n.jsx(we,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:u.open}):n.jsx(hs,{})})]}),n.jsx(Me,{isOpen:u.drawerOpen,onClose:u.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:l})]})}function jt(){const{selectedThread:e,handleDeselectIfRemoved:s}=J(),{onToggleIntelligence:o}=Y();return n.jsx(zs,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function Rt(){const{selectedThread:e,conversation:s,onOpenThread:o,onCloseThread:r,nextThread:l,previousThread:d,handleDeselectIfRemoved:u}=J(),m=qs(s?.threadId??null);return s?n.jsxs(n.Fragment,{children:[n.jsx(we,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:r,onOpenIntelligence:m.toggle,onSwipeNext:l?()=>o(l):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:m.isOpen}),n.jsx(Me,{isOpen:m.isOpen,onClose:m.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:u})]}):n.jsx("div",{className:"h-full",children:n.jsx(Le,{})})}const Et=Object.assign(Ct,{List:Le,Reading:Tt,Intelligence:jt,Phone:Rt});export{Et as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,e as r}from"./index-
|
|
1
|
+
import{j as t,e as r}from"./index-idulIG65.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dJ as $,r as n,d0 as X,v as z,b3 as Y,bF as Z,aR as ee,aS as te,j as a,a8 as se,bP as ae,bQ as oe}from"./index-idulIG65.js";import{u as re,p as ne,R as de}from"./useSearchTokenContext-BxDapNdu.js";import{H as ie,ac as le,I as ce,aw as ue,ad as ge,b as he,M as me,ak as fe,ax as Ie,am as pe,q as xe,L as Te,Q as V,P as ye,N as be,d as ve,_ as Re,$ as Ce,a1 as K,a2 as W,a3 as Se,a4 as we,a5 as je}from"./MailListHeader-BjsRsJYI.js";import{u as Fe,b as Me,a as Pe}from"./MailViewChrome-ZN5UsScT.js";import{f as ke}from"./ErrorState-B_pp6XjY.js";import{w as Oe}from"./wizard-selection-B1bng5Jq.js";import{a as Le}from"./useMessageBodyContent-5kw10g9a.js";import{k as Ae,l as Ne}from"./search-token-index-C-cpQFN3.js";import{u as De}from"./index-DX5RhVmh.js";const Ee=()=>X({query:{starred:!0,order:"desc"}});function _(){const{data:e,isLoading:t,isError:s,error:d,refetch:g,fetchNextPage:c,hasNextPage:o,isFetchingNextPage:h}=Fe({queryKey:Ee(),queryFn:async({pageParam:p})=>{const{data:b}=await $({query:{starred:!0,order:"desc",continuationToken:p},throwOnError:!0});return b},initialPageParam:void 0,getNextPageParam:p=>p.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(p=>p.items??[]),[e]),isLoading:t,isError:s,error:d,refetch:g,fetchNextPage:c,hasNextPage:o,isFetchingNextPage:h}}const Be=e=>{const t=new Set;return e.filter(s=>t.has(s.threadId)?!1:(t.add(s.threadId),!0))},qe={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0};function Qe({rows:e,verb:t}){const{selectedIds:s,exitSelection:d}=pe(),g=n.useMemo(()=>Oe(e,s),[e,s]);return a.jsx(xe,{verb:t,selection:g,selectionRestriction:"spansAccounts",onFinished:d})}function ze({selectedMessageId:e,onOpenThread:t,commandsRef:s,onTriageContextChange:d,onDeleteMessages:g}){const{searchQuery:c,resultFolderIndex:o}=z(),h=re(),I=Y(),p=Z(),[b,m]=n.useState("all"),[f,F]=n.useState(new Set),D=n.useCallback(r=>{F(u=>{const x=new Set(u);return x.has(r)?x.delete(r):x.add(r),x})},[]),C=n.useCallback(()=>{m("all"),F(new Set)},[]),{threads:M,isLoading:y,isError:P,error:E,refetch:k,fetchNextPage:H,hasNextPage:T,isFetchingNextPage:S}=_(),{freeText:R,tokens:O}=ne(c.trim().toLowerCase(),h),i=n.useMemo(()=>{const r=Array.from(f).map(u=>qe[u]).filter(u=>u!=null);return Be(M).map(ie).filter(u=>(b==="all"||u.category===b)&&r.every(x=>x(u))&&(!R||le(u,R))&&ce(u,O))},[M,b,f,R,O]),w=n.useCallback((r,u)=>{const x=i.find(U=>U.id===r)?.threadId;x&&t?.({threadId:x,messageId:r},u)},[i,t]),j=n.useCallback(r=>{const u=r.threadId??i.find(x=>x.id===r.id)?.threadId;u&&t?.({threadId:u,messageId:r.id})},[i,t]),B=n.useMemo(()=>ue(),[]),q=n.useMemo(()=>i.map(r=>ge(r,o)),[i,o]),L=n.useMemo(()=>i.filter(r=>!r.isRead).length,[i]),A=y?"loading":P?"error":i.length===0?"empty":"ready",l=n.useCallback(()=>{const r=ee(te());window.open(r,"_blank","noopener,noreferrer")},[]),v=he(),Q=a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"divide-y divide-line",children:i.map(r=>a.jsx(me,{thread:r,active:r.id===e,onClick:()=>w(r.id)},r.id))}),T?a.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>H(),disabled:S,children:S?"Loading…":"Load more"}):null]})});return a.jsx(Me,{title:"Starred",unreadCount:L,preset:B,selectedCategory:b,activeFilters:f,onSelectCategory:m,onToggleFilter:D,onClearFilters:C,searchResults:q,searchLoading:y,onSelectSearchResult:j,searchResultsInBody:!0,children:a.jsxs(fe,{selectedMessageId:e,rows:i,onOpen:w,onDeleteMessages:g,onSelectionVerb:p.start,wizardOpen:p.isOpen,commandsRef:s,onTriageContextChange:d,children:[a.jsx(Pe,{listTitle:"Starred",sections:[{id:"flagged",threads:i}],flatList:!0,hideHeader:!0,listState:v.searchResults?"ready":A,searchQuery:R?c:void 0,errorMessage:P?ke(E):void 0,onRetry:()=>k(),onReportError:l,selectedThreadId:e,onSelectThread:w,isDesktop:I,selectionBar:a.jsx(Ie,{title:"Starred"}),listBody:v.searchResults??(A==="ready"?Q:void 0)}),a.jsx(Qe,{rows:i,verb:p.verb})]})})}const G=n.createContext(null);function N(){const e=n.useContext(G);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function He({thread:e,children:t}){const s=Ae(),d=Ne(),g=De(),{searchInput:c}=z(),o=e?.threadId,h=e?.messageId,{threads:I}=_(),p=n.useMemo(()=>{if(o)return I.find(l=>l.messageId===h)??I.find(l=>l.threadId===o)},[I,o,h]),b=Te(o,h),m=p??b,f=h??m?.messageId,F=n.useMemo(()=>{if(o)return{threadId:o,mailboxId:m?.mailboxId??"",subject:m?.subject,messageId:f,authenticity:m?.authenticity}},[o,m,f]),D=n.useCallback((l,v)=>{s(l,{replace:v?.replace,query:c})},[s,c]),C=n.useCallback(l=>{f&&l.includes(f)&&d()},[f,d]),M=V({thread:m,onAfterOptimisticRemove:C}),y=ye(),{deleteMessages:P}=be({mailboxId:m?.mailboxId??"",messages:I,onAfterOptimisticRemove:C}),{toggleReadFor:E}=ve({mailboxId:m?.mailboxId??"",messages:I}),k=y.focusedMessageId,T=n.useMemo(()=>I.find(l=>l.messageId===k),[I,k])??m,S=V({thread:T}),R=Le(),O=se(),i=ae(),w=n.useMemo(()=>oe(i,o,f),[i,o,f]),j=n.useMemo(()=>{if(T)return l=>i({threadId:T.threadId,messageId:T.messageId,mode:l})},[i,T]),{nextMessageId:B,previousMessageId:q}=Re({context:y,orderedIds:y.orderedIds,selectedMessageId:f,enabled:!R&&!O,onClose:d,handlers:{reply:()=>j?.("reply"),replyAll:()=>j?.("reply-all"),forward:()=>j?.("forward"),delete:()=>{y.listCommandsRef.current?.requestVerb("delete")||S.deleteThread()},toggleStar:S.toggleStar,toggleRead:()=>{y.listCommandsRef.current?.requestVerb("markRead")||T&&E([T.messageId],!T.isRead)},goBrief:()=>g("brief"),goSettings:()=>g("settings")}}),L=n.useCallback(l=>{if(!l)return;const v=I.find(Q=>Q.messageId===l);return v?{threadId:v.threadId,messageId:l}:void 0},[I]),A={selectedMessageId:f,selectedThread:m,conversation:F,onOpenThread:D,onCloseThread:d,nextThread:L(B),previousThread:L(q),actions:M,onReply:w,triage:y,onDeleteMessages:P,handleDeselectIfRemoved:C};return a.jsx(G.Provider,{value:A,children:t})}function J(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:d}=N();return a.jsx(ze,{selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:d})}function Ve(){const{conversation:e,selectedThread:t,actions:s,onReply:d,handleDeselectIfRemoved:g}=N(),c=!!e,o=we(e?.threadId);return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsx(je,{hasThread:c,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:d?()=>d("reply"):void 0,onReplyAll:d?()=>d("reply-all"):void 0,onForward:d?()=>d("forward"):void 0,onDelete:c?s.deleteThread:void 0,onToggleStar:c?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:c&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.moveThread}:void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?a.jsx(K,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open}):a.jsx(de,{})})]}),a.jsx(W,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:g})]})}function Ke(){const{selectedThread:e,handleDeselectIfRemoved:t}=N(),{onToggleIntelligence:s}=z();return a.jsx(Se,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function We(){const{selectedThread:e,conversation:t,onCloseThread:s,onOpenThread:d,nextThread:g,previousThread:c,handleDeselectIfRemoved:o}=N(),h=Ce(t?.threadId??null);return t?a.jsxs(a.Fragment,{children:[a.jsx(K,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:s,onOpenIntelligence:h.toggle,onSwipeNext:g?()=>d(g):void 0,onSwipePrevious:c?()=>d(c):void 0,mobileIntelligenceOpen:h.isOpen}),a.jsx(W,{isOpen:h.isOpen,onClose:h.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:o})]}):a.jsx("div",{className:"h-full",children:a.jsx(J,{})})}const tt=Object.assign(He,{List:J,Reading:Ve,Intelligence:Ke,Phone:We});export{tt as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,D as f,a1 as m,j as e,b3 as N,X as w}from"./index-idulIG65.js";import{E as u}from"./ErrorState-B_pp6XjY.js";import{D as r,C as x,a as E}from"./index-DX5RhVmh.js";import{b as h,e as p,f as b}from"./useMessageBodyContent-5kw10g9a.js";import{C as k}from"./confirm-dialog-BxXd7BDT.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},S=()=>{const t=h(),i=p(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(v=>{v||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),D=n.useCallback(()=>{o(!1)},[]);return e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(k,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:D})]})},F=()=>{const t=h(),i=p(),s=b(),a=N(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(E({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(S,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(w,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{F};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{ag as vs,cK as yr,r as l,c as ie,j as a,C as ut,d as On,B as G,X as Pt,aF as Ie,cL as zn,b as U,a as Ye,S as We,b5 as vr,cM as kr,as as Dt,T as Ft,cN as _n,bn as ks,cO as jr,cP as Un,az as wr,ar as Kn,e as Cr,cQ as Sr,aE as Bn,cR as Nr,cS as Tr,cT as Ir,cU as Er,cV as Mr,cW as Rr,cX as Ar,cY as $r,n as Lr,D as Z,a1 as gt,z as bt,cZ as Pr,c_ as Dr,c$ as Ot,K as qn,bO as Qn,d0 as Hn,x as ae,ah as ge,aj as me,Y as Je,bK as Me,d1 as zt,cx as Fr,d2 as Re,d3 as Or,d4 as Gs,d5 as zr,d6 as _r,d7 as Ur,d8 as Kr,co as Br,bI as Gn,bJ as qr,d9 as Qr,b3 as js,y as Hr,b6 as Vn,b0 as Wn,b7 as Yn,b8 as Jn,b9 as Gr,aR as Vr,aS as Wr,cJ as Yr,da as Jr,t as Xn,cI as Xr,db as Zr,dc as eo,dd as Zn,de as to,bP as so,by as ws,c1 as no,bU as Vs,df as ao,dg as es,dh as ro,bx as oo,_ as io,a6 as lo,N as ea,L as co,bR as Ws,bh as uo,di as fo,dj as mo,ak as Ys,bM as po,dk as ho,dl as go,v as _t,dm as bo,dn as xo,dp as Js,dq as yo,dr as vo,ds as ko,i as ta,dt as Cs,bN as ve,du as jo,cp as wo,c0 as Co,dv as So,dw as Xs,g as No,cq as To}from"./index-idulIG65.js";import{B as Io,q as Eo,r as Mo,S as sa,d as Ss,l as Ro,g as Ao,D as $o,b as Tt,a as Lo,t as it,h as Po,v as Do,w as Fo,p as Oo,f as zo,u as _o,j as Uo}from"./search-token-index-C-cpQFN3.js";import{K as Ko}from"./kbd-eZWvlfcb.js";import{P as na,f as Bo,U as qo,E as Qo,s as Ho}from"./attachment-file-CLrI3kMw.js";import{M as Go}from"./mail-Ba7j-n-X.js";import{A as ft}from"./avatar-C8lpjlQO.js";import{M as Vo,c as Wo,d as aa,e as Yo,f as ra,g as oa,a as Jo,b as Xo,S as Zs,s as ia,u as la,p as Zo,r as ei}from"./useSearchTokenContext-BxDapNdu.js";import{C as ti,D as Qe,a as si}from"./index-DX5RhVmh.js";import{E as Oe}from"./ErrorState-B_pp6XjY.js";import{e as ca,b as Xe,a as ni,g as ai,c as ze,d as ri}from"./format-23Av07Go.js";import{D as oi}from"./download-Br1uSntK.js";import{g as ii}from"./useMessageBodyContent-5kw10g9a.js";import{S as li}from"./shield-check-DG9twqa-.js";import{u as da}from"./useDebouncedValue-CntZIoMR.js";import{h as en,u as ci,a as di,i as ui,n as fi,o as mi,j as pi,k as hi,S as gi}from"./useFilters-DaiBln2b.js";import{C as It}from"./confirm-dialog-BxXd7BDT.js";import{C as bi}from"./clock-DCdX5E4T.js";import{r as xi,b as yi}from"./search-scope-DTcpOp3S.js";import{M as vi}from"./menu-MXmFQ7m-.js";function mt(e){if(ki())e.focus({preventScroll:!0});else{let t=ji(e);e.focus(),wi(t)}}let Et=null;function ki(){if(Et==null){Et=!1;try{document.createElement("div").focus({get preventScroll(){return Et=!0,!0}})}catch{}}return Et}function ji(e){let t=e.parentNode,s=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&s.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),s}function wi(e){for(let{element:t,scrollTop:s,scrollLeft:n}of e)t.scrollTop=s,t.scrollLeft=n}const Te=e=>e?.ownerDocument??document,Ee=e=>e&&"window"in e&&e.window===e?e:Te(e).defaultView||window;function Ci(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Si(e){return Ci(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Ni=!1;function ua(){return Ni}function he(e,t){if(!ua())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!==null;){if(s===e)return!0;s.tagName==="SLOT"&&s.assignedSlot?s=s.assignedSlot.parentNode:Si(s)?s=s.host:s=s.parentNode}return!1}function X(e){if(ua()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}const Ti=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Ii(e){const t=Ee(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:n}=e.style,r=s!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:o}=Ee(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function Ei(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function fa(e,t){return Ti?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Ii(e)&&Ei(e,t)&&(!e.parentElement||fa(e.parentElement,e))}const ma=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],Mi=ma.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ma.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function Ri(e,t){return e.matches(Mi)&&!Ai(e)&&(t?.skipVisibilityCheck||fa(e))}function Ai(e){let t=e;for(;t!=null;){if(t instanceof Ee(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Ns=typeof document<"u"?vs.useLayoutEffect:()=>{};function $i(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Li(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Pi(e){for(;e&&!Ri(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ee(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=h=>{(X(h)===s||n)&&h.stopImmediatePropagation()},o=h=>{(X(h)===s||n)&&(h.stopImmediatePropagation(),!e&&!n&&(n=!0,mt(s),d()))},i=h=>{(X(h)===e||n)&&h.stopImmediatePropagation()},c=h=>{(X(h)===e||n)&&(h.stopImmediatePropagation(),n||(n=!0,mt(s),d()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let d=()=>{cancelAnimationFrame(b),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},b=requestAnimationFrame(d);return d}function Ut(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(s=>e.test(s.brand))||e.test(window.navigator.userAgent)}function Ts(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Ae(e){let t=null;return()=>(t==null&&(t=e()),t)}const At=Ae(function(){return Ts(/^Mac/i)}),Di=Ae(function(){return Ts(/^iPhone/i)}),pa=Ae(function(){return Ts(/^iPad/i)||At()&&navigator.maxTouchPoints>1}),ha=Ae(function(){return Di()||pa()}),Fi=Ae(function(){return Ut(/AppleWebKit/i)&&!Oi()}),Oi=Ae(function(){return Ut(/Chrome/i)}),ga=Ae(function(){return Ut(/Android/i)}),zi=Ae(function(){return Ut(/Firefox/i)});function _i(e){return e.pointerType===""&&e.isTrusted?!0:ga()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ui(e){return!ga()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function pt(e,t,s=!0){let{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}=t;zi()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(At()?n=!0:r=!0);let c=Fi()&&At()&&!pa()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});pt.isOpening=s,mt(e),e.dispatchEvent(c),pt.isOpening=!1}pt.isOpening=!1;let Ne=new Map,ds=new Set;function tn(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{let r=X(n);if(!e(n)||!r)return;let o=Ne.get(r);o||(o=new Set,Ne.set(r,o),r.addEventListener("transitioncancel",s,{once:!0})),o.add(n.propertyName)},s=n=>{let r=X(n);if(!e(n)||!r)return;let o=Ne.get(r);if(o&&(o.delete(n.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",s),Ne.delete(r)),Ne.size===0)){for(let i of ds)i();ds.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?tn():document.addEventListener("DOMContentLoaded",tn));function Ki(){for(const[e]of Ne)"isConnected"in e&&!e.isConnected&&Ne.delete(e)}function Bi(e){requestAnimationFrame(()=>{Ki(),Ne.size===0?e():ds.add(e)})}function ba(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let us=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{us.delete(e)});function qi(e,t){if(e===t)return e;let s=us.get(e);if(s)return s.forEach(r=>r.current=t),t;let n=us.get(t);return n?(n.forEach(r=>r.current=e),e):t}function Qi(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const n=e.map(r=>{const o=sn(r,t);return s||=typeof o=="function",o});if(s)return()=>{n.forEach((r,o)=>{typeof r=="function"?r():sn(e[o],null)})}}}function sn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function xt(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let n=e[s];for(let r in n){let o=t[r],i=n[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=ba(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=yr(o,i):r==="id"&&o&&i?t.id=qi(o,i):r==="ref"&&o&&i?t.ref=Qi(o,i):t[r]=i!==void 0?i:o}}return t}function Hi(e,t){Ns(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Gi=vs.useInsertionEffect??Ns;function ts(e){const t=l.useRef(null);return Gi(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let Ge="default",fs="",Rt=new WeakMap;function Vi(e){if(ha()){if(Ge==="default"){const t=Te(e);fs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Ge="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Rt.set(e,e.style[t]),e.style[t]="none"}}function nn(e){if(ha()){if(Ge!=="disabled")return;Ge="restoring",setTimeout(()=>{Bi(()=>{if(Ge==="restoring"){const t=Te(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=fs||""),fs="",Ge="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Rt.has(e)){let t=Rt.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Rt.delete(e)}}function an(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let ss=new WeakMap;function Wi(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return an(t);if(ss.has(t))return ss.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),n=s&&s instanceof Ee(s).HTMLMetaElement&&(s.nonce||s.content)||an(t)||void 0;return n!==void 0&&ss.set(t,n),n}const xa=vs.createContext({register:()=>{}});xa.displayName="PressResponderContext";function ya(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let d=c?.once?(...b)=>{e.current.delete(i),i(...b)}:i;e.current.set(i,{type:o,eventTarget:r,fn:d,options:c}),r.addEventListener(o,d,c)},[]),s=l.useCallback((r,o,i,c)=>{let d=e.current.get(i)?.fn||i;r.removeEventListener(o,d,c),e.current.delete(i)},[]),n=l.useCallback(()=>{e.current.forEach((r,o)=>{s(r.eventTarget,r.type,o,r.options)})},[s]);return l.useEffect(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:n}}function Yi(e){let t=l.useContext(xa);if(t){let{register:s,ref:n,...r}=t;e=xt(r,e),s()}return Hi(t,e.ref),e}class Mt{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,d=0,b,h=null;n.clientX!=null&&n.clientY!=null&&(b=n.clientX,h=n.clientY),i&&(b!=null&&h!=null?(c=b-i.left,d=h-i.top):(c=i.width/2,d=i.height/2)),this.type=t,this.pointerType=s,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=c,this.y=d,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const rn=Symbol("linkClicked"),on="react-aria-pressable-style",ln="data-react-aria-pressable";function Ji(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:d,preventFocusOnPress:b,shouldCancelOnPointerExit:h,allowTextSelectionOnPress:x,ref:p,...y}=Yi(e),[f,u]=l.useState(!1),m=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:g,removeAllGlobalListeners:w}=ya(),v=l.useCallback((j,I)=>{let A=m.current;if(c||A.didFirePressStart)return!1;let C=!0;if(A.isTriggeringEvent=!0,n){let E=new Mt("pressstart",I,j);n(E),C=E.shouldStopPropagation}return s&&s(!0),A.isTriggeringEvent=!1,A.didFirePressStart=!0,u(!0),C},[c,n,s]),k=l.useCallback((j,I,A=!0)=>{let C=m.current;if(!C.didFirePressStart)return!1;C.didFirePressStart=!1,C.isTriggeringEvent=!0;let E=!0;if(r){let S=new Mt("pressend",I,j);r(S),E=S.shouldStopPropagation}if(s&&s(!1),u(!1),t&&A&&!c){let S=new Mt("press",I,j);t(S),E&&=S.shouldStopPropagation}return C.isTriggeringEvent=!1,E},[c,r,s,t]),T=ts(k),R=l.useCallback((j,I)=>{let A=m.current;if(c)return!1;if(o){A.isTriggeringEvent=!0;let C=new Mt("pressup",I,j);return o(C),A.isTriggeringEvent=!1,C.shouldStopPropagation}return!0},[c,o]),P=ts(R),M=l.useCallback(j=>{let I=m.current;if(I.isPressed&&I.target){I.didFirePressStart&&I.pointerType!=null&&k(De(I.target,j),I.pointerType,!1),I.isPressed=!1,I.isOverTarget=!1,I.activePointerId=null,I.pointerType=null,w(),x||nn(I.target);for(let A of I.disposables)A();I.disposables=[]}},[x,w,k]),F=ts(M);l.useEffect(()=>{c&&m.current.isPressed&&F({currentTarget:m.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let D=l.useCallback(j=>{h&&M(j)},[h,M]),O=l.useCallback(j=>{c||i?.(j)},[c,i]),_=l.useCallback((j,I)=>{if(!c&&i){let A=new MouseEvent("click",j);Li(A,I),i($i(A))}},[c,i]),q=l.useMemo(()=>{let j=m.current,I={onKeyDown(C){if(ns(C.nativeEvent,C.currentTarget)&&he(C.currentTarget,X(C))){cn(X(C),C.key)&&C.preventDefault();let E=!0;!j.isPressed&&!C.repeat&&(j.target=C.currentTarget,j.isPressed=!0,j.pointerType="keyboard",E=v(C,"keyboard"));let S=C.currentTarget,z=K=>{ns(K,S)&&!K.repeat&&he(S,X(K))&&j.target&&P(De(j.target,K),"keyboard")};g(Te(C.currentTarget),"keyup",ba(z,A),!0),E&&C.stopPropagation(),C.metaKey&&At()&&j.metaKeyEvents?.set(C.key,C.nativeEvent)}else C.key==="Meta"&&(j.metaKeyEvents=new Map)},onClick(C){if(!(C&&!he(C.currentTarget,X(C)))&&C&&C.button===0&&!j.isTriggeringEvent&&!pt.isOpening){let E=!0;if(c&&C.preventDefault(),!j.ignoreEmulatedMouseEvents&&!j.isPressed&&(j.pointerType==="virtual"||_i(C.nativeEvent))){let S=v(C,"virtual"),z=P(C,"virtual"),K=T(C,"virtual");O(C),E=S&&z&&K}else if(j.isPressed&&j.pointerType!=="keyboard"){let S=j.pointerType||C.nativeEvent.pointerType||"virtual",z=P(De(C.currentTarget,C),S),K=T(De(C.currentTarget,C),S,!0);E=z&&K,j.isOverTarget=!1,O(C),F(C)}j.ignoreEmulatedMouseEvents=!1,E&&C.stopPropagation()}}},A=C=>{if(j.isPressed&&j.target&&ns(C,j.target)){cn(X(C),C.key)&&C.preventDefault();let E=X(C),S=he(j.target,E);T(De(j.target,C),"keyboard",S),S&&_(C,j.target),w(),C.key!=="Enter"&&Is(j.target)&&he(j.target,E)&&!C[rn]&&(C[rn]=!0,pt(j.target,C,!1)),j.isPressed=!1,j.metaKeyEvents?.delete(C.key)}else if(C.key==="Meta"&&j.metaKeyEvents?.size){let E=j.metaKeyEvents;j.metaKeyEvents=void 0;for(let S of E.values())j.target?.dispatchEvent(new KeyboardEvent("keyup",S))}};if(typeof PointerEvent<"u"){I.onPointerDown=S=>{if(S.button!==0||!he(S.currentTarget,X(S)))return;if(Ui(S.nativeEvent)){j.pointerType="virtual";return}j.pointerType=S.pointerType;let z=!0;if(!j.isPressed){j.isPressed=!0,j.isOverTarget=!0,j.activePointerId=S.pointerId,j.target=S.currentTarget,x||Vi(j.target),z=v(S,j.pointerType);let K=X(S);"releasePointerCapture"in K&&("hasPointerCapture"in K?K.hasPointerCapture(S.pointerId)&&K.releasePointerCapture(S.pointerId):K.releasePointerCapture(S.pointerId)),g(Te(S.currentTarget),"pointerup",C,!1),g(Te(S.currentTarget),"pointercancel",E,!1)}z&&S.stopPropagation()},I.onMouseDown=S=>{if(he(S.currentTarget,X(S))&&S.button===0){if(b){let z=Pi(S.target);z&&j.disposables.push(z)}S.stopPropagation()}},I.onPointerUp=S=>{!he(S.currentTarget,X(S))||j.pointerType==="virtual"||S.button===0&&!j.isPressed&&P(S,j.pointerType||S.pointerType)},I.onPointerEnter=S=>{S.pointerId===j.activePointerId&&j.target&&!j.isOverTarget&&j.pointerType!=null&&(j.isOverTarget=!0,v(De(j.target,S),j.pointerType))},I.onPointerLeave=S=>{S.pointerId===j.activePointerId&&j.target&&j.isOverTarget&&j.pointerType!=null&&(j.isOverTarget=!1,T(De(j.target,S),j.pointerType,!1),D(S))};let C=S=>{if(S.pointerId===j.activePointerId&&j.isPressed&&S.button===0&&j.target){if(he(j.target,X(S))&&j.pointerType!=null){let z=!1,K=setTimeout(()=>{j.isPressed&&j.target instanceof HTMLElement&&(z?F(S):(mt(j.target),j.target.click()))},80);g(S.currentTarget,"click",()=>z=!0,!0),j.disposables.push(()=>clearTimeout(K))}else F(S);j.isOverTarget=!1}},E=S=>{F(S)};I.onDragStart=S=>{he(S.currentTarget,X(S))&&F(S)}}return I},[g,c,b,w,x,D,v,O,_]);return l.useEffect(()=>{if(!p)return;const j=Te(p.current);if(!j||!j.head||j.getElementById(on))return;const I=j.createElement("style");I.id=on;let A=Wi(j);A&&(I.nonce=A),I.textContent=`
|
|
2
|
+
@layer {
|
|
3
|
+
[${ln}] {
|
|
4
|
+
touch-action: pan-x pan-y pinch-zoom;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
`.trim(),j.head.prepend(I)},[p]),l.useEffect(()=>{let j=m.current;return()=>{x||nn(j.target??void 0);for(let I of j.disposables)I();j.disposables=[]}},[x]),{isPressed:d||f,pressProps:xt(y,q,{[ln]:!0})}}function Is(e){return e.tagName==="A"&&e.hasAttribute("href")}function ns(e,t){const{key:s,code:n}=e,r=t,o=r.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||n==="Space")&&!(r instanceof Ee(r).HTMLInputElement&&!va(r,s)||r instanceof Ee(r).HTMLTextAreaElement||r.isContentEditable)&&!((o==="link"||!o&&Is(r))&&s!=="Enter")}function De(e,t){let s=t.clientX,n=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:n,key:t.key}}function Xi(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Is(e)}function cn(e,t){return e instanceof HTMLInputElement?!va(e,t):Xi(e)}const Zi=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function va(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":Zi.has(e.type)}let el=0;const as=new Map;function tl(e){let[t,s]=l.useState();return Ns(()=>{if(!e)return;let n=as.get(e);if(n)s(n.element.id);else{let r=`react-aria-description-${el++}`;s(r);let o=document.createElement("div");o.id=r,o.style.display="none",o.textContent=e,document.body.appendChild(o),n={refCount:0,element:o},as.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),as.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const sl=500;function nl(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=sl,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:d,removeGlobalListener:b}=ya(),{pressProps:h}=Ji({isDisabled:t,onPressStart(p){if(p.continuePropagation(),(p.pointerType==="mouse"||p.pointerType==="touch")&&(s&&s({...p,type:"longpressstart"}),c.current=setTimeout(()=>{p.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Te(p.target).activeElement!==p.target&&mt(p.target),r&&r({...p,type:"longpress"}),c.current=void 0},o),p.pointerType==="touch")){let y=u=>{u.preventDefault()},f=Ee(p.target);d(p.target,"contextmenu",y,{once:!0}),d(f,"pointerup",()=>{setTimeout(()=>{b(p.target,"contextmenu",y)},30)},{once:!0})}},onPressEnd(p){c.current&&clearTimeout(c.current),n&&(p.pointerType==="mouse"||p.pointerType==="touch")&&n({...p,type:"longpressend"})}}),x=tl(r&&!t?i:void 0);return{longPressProps:xt(h,x)}}const Kt=ie("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ka=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const ja=ie("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const al=ie("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const Es=ie("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const rl=ie("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);const ol=ie("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Bt=ie("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);const wa=ie("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const Ca=ie("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const Ze=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const il=ie("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const ll=ie("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),cl=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?a.jsxs("span",{children:[a.jsx("span",{className:"text-fg",children:e.displayName}),a.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):a.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},dl=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[n,r]=l.useState(!1);if(t.length===0)return null;const o=t.length>3,i=c=>{const d=s&&c.flags?.trusted?.value===!0;return a.jsx(cl,{address:c,showTrustedBadge:d})};return a.jsxs("div",{className:"flex gap-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),a.jsx("div",{className:"flex-1 min-w-0",children:n?a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((c,d)=>a.jsxs("span",{children:[i(c),d<t.length-1&&", "]},d))}):a.jsx("div",{className:"truncate",children:t.map((c,d)=>a.jsxs("span",{children:[i(c),d<t.length-1&&", "]},d))})}),o&&a.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!n)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":n?"Collapse":"Expand",children:n?a.jsx(ut,{className:"h-4 w-4"}):a.jsx(On,{className:"h-4 w-4"})})]})},ul={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function He({label:e,children:t,className:s}){return a.jsxs("section",{className:U("border-b border-line px-row-inset py-3",s),children:[a.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),a.jsx("div",{className:"mt-2",children:t})]})}function fl({sender:e}){const t=ul[e.trust],s=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ft,{name:e.name,email:e.email,size:"md"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),a.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?a.jsx(Ie,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):a.jsx(Ie,{tone:t.tone,dot:!0,children:t.label})}),a.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function ml({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return a.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[a.jsx(li,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),a.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[a.jsx(il,{className:"mt-0.5 size-4 shrink-0"}),a.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const s=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return a.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),a.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&a.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&a.jsxs(G,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:t,children:[e.similarCount," similar messages"]})]})}function lt({icon:e,label:t,active:s,danger:n,onClick:r,pending:o}){const i=r===void 0||o===!0;return a.jsxs("button",{type:"button",onClick:r,disabled:i,className:U("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",s?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",n&&!s&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const pl={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function Sa({data:e,onClose:t,onShowSimilar:s,actions:n,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:d=!1,notSpamPending:b=!1}){const{sender:h,authenticity:x,category:p,flags:y={},similar:f}=e;return a.jsxs("aside",{className:U("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(He,{label:"Sender",children:a.jsx(fl,{sender:h})}),a.jsx(He,{label:"Authenticity",children:a.jsx(ml,{auth:x,onShowSimilar:s})}),a.jsx(He,{label:"Category",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ie,{tone:zn[p.value],children:p.value}),p.overridden&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),a.jsx("button",{type:"button",className:U("ml-auto text-2xs text-accent hover:underline",!n?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!n?.onReclassify,onClick:n?.onReclassify,children:"reclassify"})]})}),a.jsxs(He,{label:"Quick actions",children:[a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a.jsx(lt,{icon:a.jsx(Ye,{className:"size-3.5"}),label:"VIP",active:y.vip,onClick:n?.onToggleVip}),a.jsx(lt,{icon:a.jsx(Io,{className:"size-3.5"}),label:"Mute",active:y.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(lt,{icon:a.jsx(al,{className:"size-3.5"}),label:b?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:b}),n?.onReportSpam&&a.jsx(lt,{icon:a.jsx(ll,{className:"size-3.5"}),label:d?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:d}),a.jsx(lt,{icon:a.jsx(rl,{className:"size-3.5"}),label:"Unsubscribe",active:y.unsubscribed,onClick:n?.onToggleUnsubscribe})]}),n?.onNotSpam&&a.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||f.length>0)&&a.jsx(He,{label:"Similar messages",children:r==="loading"?a.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((u,m)=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},m))}):r==="error"?a.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):a.jsx("ul",{className:"-mx-1 space-y-1",children:f.map(u=>{const m="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",g=`Open message from ${u.fromName||"unknown sender"}: ${u.subject}`,w=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"truncate text-xs font-medium text-fg",children:u.fromName}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:u.timeLabel})]}),a.jsx("div",{className:"truncate text-xs text-fg-muted",children:u.subject}),a.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:pl[u.matched]})]});return a.jsx("li",{children:o?o({mailboxId:u.mailboxId,threadId:u.threadId,messageId:u.id,className:m,ariaLabel:g,children:w}):a.jsx("div",{className:m,children:w})},u.id)})})}),a.jsx(He,{label:"Coming soon",className:"border-b-0 opacity-70",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const ms=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),dn=e=>e.shiftKey||e.metaKey||e.ctrlKey,hl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",gl=(e,t)=>!t&&e>0,bl=(e,t,s)=>{const n=e.indexOf(s);if(n===-1)return[];const r=t===void 0?-1:e.indexOf(t);if(r===-1)return[s];const o=Math.min(r,n),i=Math.max(r,n);return e.slice(o,i+1)},xl=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,yl=(e,t)=>{const s=new Set(t),n=new Set;for(const r of e)s.has(r)&&n.add(r);return n},vl=(e,t,s)=>{if(e.length===0)return;const n=t===void 0?-1:e.indexOf(t);if(n===-1)return s>0?e[0]:e[e.length-1];const r=Math.min(Math.max(n+s,0),e.length-1);return e[r]},kl=e=>{const[t,s]=l.useState(()=>new Set(e?.initialSelectedIds)),[n,r]=l.useState(void 0),o=l.useCallback(u=>t.has(u),[t]),i=l.useCallback(u=>{r(u),s(m=>{const g=new Set(m);return g.has(u)?g.delete(u):g.add(u),g})},[]),c=l.useCallback(u=>{r(u),s(m=>{if(m.has(u))return m;const g=new Set(m);return g.add(u),g})},[]),d=l.useCallback(u=>{s(m=>{if(!m.has(u))return m;const g=new Set(m);return g.delete(u),g})},[]),b=l.useCallback(u=>{s(new Set(u))},[]),h=l.useCallback(()=>{r(void 0),s(new Set)},[]),x=l.useCallback(u=>{s(m=>u.every(w=>m.has(w))?new Set:new Set(u))},[]),p=l.useCallback(u=>{r(u)},[]),y=l.useCallback(u=>{s(m=>{if(m.size===0)return m;const g=yl(m,u);return g.size===m.size?m:g})},[]),f=l.useCallback((u,m,g)=>{const w=xl(u,n,g,m);s(v=>{const k=bl(u,w,m);if(k.length===0)return v;const T=new Set(v);for(const R of k)T.add(R);return T}),r(w)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:d,selectAll:b,clearSelection:h,toggleAll:x,selectRange:f,setAnchor:p,anchorId:n,intersectWith:y}};function qf({hints:e=Eo,className:t}){return e.length===0?null:a.jsx("footer",{className:U("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>a.jsx(jl,{hint:s},s.label))})}function jl({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(Ko,{children:t},t)),a.jsx("span",{children:e.label})]})}const Na="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ta=({active:e,focused:t})=>U("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",Na,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),Ms=({active:e,focused:t})=>U("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",Na,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function Ia({thread:e}){const t=!e.isRead;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?a.jsx(Ze,{className:"size-3.5 text-danger"}):e.starred?a.jsx(Ye,{className:"size-3 fill-warning text-warning"}):t?a.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),a.jsx("span",{className:U("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[a.jsx("span",{className:U(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),a.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function un(e,t){const s=t?.trim();if(!s)return e;const n=e.toLowerCase(),r=s.toLowerCase(),o=[];let i=0,c=n.indexOf(r,i),d=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(a.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},d++)),i=c+r.length,c=n.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function wl({thread:e,badge:t,highlightQuery:s}){const n=!e.isRead;return a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:U("flex min-w-0 items-center gap-1.5 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),a.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&a.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:U("truncate text-sm",n?"text-fg":"text-fg-muted"),children:un(e.subject,s)}),e.suspicious&&a.jsx(Ze,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&a.jsx(Ye,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:un(e.snippet,s)}),e.category&&e.category!=="personal"&&a.jsx(Ie,{tone:zn[e.category],className:"shrink-0",children:e.category}),e.labels?.map(r=>a.jsx(vr,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function Cl({thread:e,selection:t}){if(!t)return a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:n}=t;return a.jsxs("span",{className:"relative size-7 shrink-0",children:[a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"sm",className:U("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||n)&&"opacity-0")}),a.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),t.onToggle(r))},className:U("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",n?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":n?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&a.jsx(Dt,{className:"size-3"})})]})}function Rs({thread:e,selection:t,badge:s,highlightQuery:n}){const r=!e.isRead;return a.jsxs(a.Fragment,{children:[r&&a.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),a.jsx(Cl,{thread:e,selection:t}),a.jsx(wl,{thread:e,badge:s,highlightQuery:n})]})}const Ea=e=>({...kr,[Mo]:"","data-message-id":e.id});function Qf({thread:e,active:t,focused:s,tabIndex:n,onClick:r}){return a.jsx("button",{type:"button",...Ea(e),tabIndex:n,onClick:r,className:Ta({active:t,focused:s}),children:a.jsx(Ia,{thread:e})})}function Hf({thread:e,active:t,focused:s,tabIndex:n,selection:r,onClick:o}){return a.jsx("button",{type:"button",...Ea(e),tabIndex:n,onClick:o,className:U("group",Ms({active:t,focused:s})),children:a.jsx(Rs,{thread:e,selection:r})})}let Ve;const Sl=5e3;function Ma(e){e.preventDefault(),$t()}function $t(){Ve!==void 0&&(clearTimeout(Ve),Ve=void 0,document.removeEventListener("contextmenu",Ma,!0),document.removeEventListener("pointerup",$t,!0))}function Nl(){Ve===void 0?(document.addEventListener("contextmenu",Ma,!0),document.addEventListener("pointerup",$t,!0)):clearTimeout(Ve),Ve=setTimeout($t,Sl)}function Tl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=nl({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||Nl()},[]);return{longPressProps:xt(r,{onPointerDown:o})}}const ct="min-h-11 min-w-11 px-0";function Ra({hasThread:e,onReply:t,onReplyAll:s,onForward:n,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:d,moveSlot:b,overflowItems:h=[],onUnavailable:x,unavailableHint:p,className:y}){const f=(m,g)=>()=>{if(!e){x?.(m);return}g?.()},u=d?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(Go,{className:"size-4"}):a.jsx(Es,{className:"size-4"}),onSelect:f("toggleRead",d)}]:[];return a.jsxs("div",{className:U("relative",y),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-5"}),onClick:f("reply",t),"aria-label":"Reply",title:"Reply",className:ct}),s&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-5"}),onClick:f("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:ct}),n&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(ja,{className:"size-5"}),onClick:f("forward",n),"aria-label":"Forward",title:"Forward",className:ct}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:U("size-5",r&&"fill-warning text-warning")}),onClick:f("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:ct}),b,i&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-5"}),onClick:f("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:ct}),a.jsx(na,{triggerLabel:"More actions",items:[...u,...h]})]}),!e&&p&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:p})]})}function Il({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(_n,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:U(e&&"bg-accent-2-soft text-accent-2",n)})}function El({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:b,moveSlot:h,onMove:x,replyTitle:p="Reply (r)",replyAllTitle:y="Reply all (a)",forwardTitle:f="Forward (f)",deleteTitle:u="Move to Trash (#)",flagTitle:m="Star (s)",children:g,className:w}){const v=(k,T)=>()=>{if(!e||!T){t?.(k);return}T()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:U("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",w),children:[a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-4"}),title:p,"aria-label":"Reply",onClick:v("reply",o)}),a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-4"}),title:y,"aria-label":"Reply all",onClick:v("replyAll",i)}),a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(ja,{className:"size-4"}),title:f,"aria-label":"Forward",onClick:v("forward",c)}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-4"}),title:u,"aria-label":"Move to Trash",onClick:v("delete",d)}),h??a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(ks,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:v("move",x)}),a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:U("size-4",n&&"fill-warning text-warning")}),title:m,"aria-label":"Star",onClick:v("flag",b)})]}),a.jsx("div",{className:"flex-1"}),g]}),s&&a.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}function Aa({message:e,onClick:t,isFocused:s,isUnread:n,trailing:r}){const o=a.jsxs(a.Fragment,{children:[a.jsx(On,{className:"size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"md"}),n&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),a.jsx("span",{className:U("w-36 shrink-0 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=U("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",s&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return t?a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:c=>{jr(c)&&(c.preventDefault(),t())},className:U(i,"cursor-pointer"),children:o}):a.jsx("div",{className:i,children:o})}function $a({message:e,warning:t,onHeaderClick:s,isFocused:n,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:d,actionBar:b,body:h}){const x=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??a.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),a.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&a.jsx("div",{className:"text-xs text-fg-subtle",children:i??a.jsxs(a.Fragment,{children:["to ",e.toLabel]})})]});return a.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[a.jsxs("div",{className:U("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",n&&"ring-1 ring-inset ring-accent/30"),children:[s?a.jsx("button",{type:"button",onClick:s,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:a.jsx(ut,{className:"size-3.5"})}):a.jsx(ut,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),a.jsx(ft,{name:e.fromName,email:e.fromEmail,size:"md"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[s?a.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:x}):x,c]}),d&&a.jsx("div",{className:"shrink-0",children:d})]}),t&&a.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"text-sm text-fg",children:[a.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",a.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),b&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:b}),a.jsx(Vo,{children:h??a.jsx(Wo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function Ml({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[d,b]=l.useState(!1),h=r!==void 0,x=h?n??!1:d,p=!!s||h,y=()=>{if(h){r?.();return}b(u=>!u)},f=()=>{if(h){x&&r?.();return}b(!1)};return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Un,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),p&&a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(_n,{className:"size-4"}),onClick:y,"aria-label":x?"Hide intelligence panel":"Show intelligence panel","aria-pressed":x,title:"Intelligence",className:U("shrink-0",x&&"bg-accent-2-soft text-accent-2")})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",style:c?{touchAction:"pan-y"}:void 0,...c,children:i??[...e.messages].reverse().map(u=>{const m=g=>g?()=>g(u.id):void 0;return u.expanded?a.jsx($a,{message:u,warning:e.warning,onHeaderClick:m(o?.onToggleExpand),actionBar:a.jsx(Ra,{hasThread:!0,onReply:m(o?.onReply),onReplyAll:m(o?.onReplyAll),onForward:m(o?.onForward),onToggleStar:m(o?.onToggleStar),onDelete:m(o?.onDelete),onToggleRead:m(o?.onToggleRead),moveSlot:o?.moveSlot?.(u.id)})},u.id):a.jsx(Aa,{message:u,onClick:m(o?.onToggleExpand)},u.id)})}),s&&!h&&a.jsx(wr,{open:x,onClose:f,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(Sa,{data:s,onClose:f,className:"h-full w-full border-l-0"})})]})}function Rl({state:e,onRetry:t}){return a.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[a.jsx(Cr,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-danger",children:e.title}),a.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx("button",{type:"button",onClick:t,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&a.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function Al({attachments:e,onDownload:t,hasUnlistedAttachment:s=!1,className:n}){return e.length===0&&!s?null:a.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:U("space-y-1.5",n),children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[a.jsx(Bt,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&a.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return a.jsxs("li",{className:"border-t border-line first:border-t-0",children:[a.jsxs("button",{type:"button",onClick:()=>t(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),a.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",Bo(r.sizeOctets)]})]}),o?a.jsx(Kn,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):a.jsx(oi,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&a.jsx(Rl,{state:r.download,onRetry:()=>t(r.attachmentId)})]},r.attachmentId)})}),s&&a.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function $l({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Ie,{tone:"accent",className:U("py-1 text-xs",r),children:[a.jsx(qo,{className:"size-3.5 shrink-0","aria-hidden":!0}),a.jsx("span",{children:e}),t&&a.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:s}),n&&a.jsx("a",{href:n,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const Ll="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",fn="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function Pl({label:e,description:t,indeterminate:s=!1,checked:n,onChange:r,className:o,...i}){const c=l.useRef(null);l.useEffect(()=>{c.current&&(c.current.indeterminate=s)},[s]);const d=a.jsxs("span",{className:"relative inline-flex",children:[a.jsx("input",{ref:c,type:"checkbox",checked:n,onChange:r,className:Ll,...i}),a.jsx(Dt,{className:U(fn,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(ol,{className:U(fn,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?a.jsx("span",{className:o,children:d}):a.jsxs("label",{className:U("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[d,a.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&a.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&a.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}function Dl(e){return{id:e.id,fromName:e.sender,fromEmail:e.senderEmail??e.sender,subject:e.subject,snippet:e.snippet,timeLabel:e.date,isRead:!e.unread,starred:e.flagged,...e.mailboxId?{mailboxId:e.mailboxId}:{}}}function Fl({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?Sr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:U("group",Ms({}),"border-b border-line"),children:a.jsx(Rs,{thread:Dl(e),highlightQuery:s,badge:a.jsxs(a.Fragment,{children:[r&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:r}),e.category&&a.jsx(Ie,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&a.jsx(Ie,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const Ol=e=>e===1?"result":"results";function zl({count:e,onScopeToSpam:t}){return a.jsx(Bn,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[a.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${Ol(e)} from Spam`]}),a.jsx(G,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const mn=6,_l={kind:"global"},Ul=e=>e.kind==="folder"&&e.role==="junk",Kl=e=>e.folder?.role==="junk";function La(e){const t=[],s=[];for(const n of e)Kl(n)?s.push(n):t.push(n);return{kept:t,spam:s}}function Pa({onClick:e,blockedReason:t}){const s=l.useId(),[n,r]=l.useState(!1);return a.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[a.jsxs("button",{type:"button",onClick:()=>{if(t){r(!0);return}e()},"aria-describedby":t?s:void 0,className:U("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",t?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[a.jsx(Nr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(Tr,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function Bl({section:e,query:t,onSelectResult:s,showFolder:n}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),d=e.results.length>mn,h=!i&&d?e.results.slice(0,mn):e.results,x=e.results.length-h.length;return a.jsxs("div",{children:[a.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(p=>!p),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[a.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),a.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),a.jsx(ut,{className:U("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[h.map(p=>a.jsx(Fl,{result:p,query:t,showFolder:n,onClick:s?()=>s(p):void 0},p.id)),d&&a.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${x} more`,!i&&a.jsx(ut,{className:"ml-1 size-3"})]})]})]})}function Da({value:e,recentSearches:t,onPickRecent:s,sections:n,loading:r,onSelectResult:o,tokens:i,scope:c=_l,makeFilter:d}){if(!(e.trim().length>0))return t&&t.length>0?a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),t.map(k=>a.jsxs("button",{type:"button",onClick:()=>s?.(k),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[a.jsx(bi,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:k})]},k))]}):a.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const h=i&&i.length>0&&a.jsx(Ir,{tokens:i}),x=d&&a.jsx(Pa,{...d});if(r)return a.jsxs("div",{className:"flex flex-col",children:[x,h,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(k=>a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},k))})]});const p=c.kind==="global",y=Ul(c)||c.kind==="collection",f=p||c.kind==="collection",u=(n??[]).map(k=>{if(y)return{section:k,spam:[]};const{kept:T,spam:R}=La(k.results);return{section:{...k,results:T},spam:R}}),m=u.map(k=>k.section),g=u.reduce((k,T)=>k+T.spam.length,0),w=c.kind==="global"&&g>0&&c.onScopeToSpam!==void 0?a.jsx(zl,{count:g,onScopeToSpam:c.onScopeToSpam}):void 0;return m.some(k=>k.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[x,h,w,m.filter(k=>k.results.length>0).map(k=>a.jsx(Bl,{section:k,query:e,showFolder:f,onSelectResult:o},k.id))]}):a.jsxs("div",{className:"flex flex-col",children:[x,h,w,a.jsxs("div",{className:"px-row-inset py-10 text-center",children:[a.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),a.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function ql({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:b,tokens:h,chips:x,onRemoveChip:p,scope:y,makeFilter:f,suggest:u,suggestList:m}){const g=a.jsx(Da,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:b,tokens:h,scope:y,makeFilter:f});return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(sa,{value:e,onChange:t,onClear:s,chips:x,onRemoveChip:p,globalFocusKey:!1,showClearButton:!1,suggest:u})}),a.jsx(G,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),m,r&&e.trim().length===0?a.jsx(Er,{children:a.jsx(Mr,{...r,children:g})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:g})]})}const pn=e=>e.toLocaleString();function hn({selectAll:e,selecting:t,className:s}){return a.jsx(Pl,{className:s,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:a.jsx("span",{className:"font-medium text-accent",children:e.checked&&t?"Deselect all":"Select all"})})}function Ql({title:e,count:t,onCancel:s,onDelete:n,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:d,titleMeta:b,searchSlot:h,searchField:x,idleSlot:p,overflowSlot:y,isBusy:f=!1,isCounting:u=!1,selectAll:m,statusLabel:g,progress:w,notice:v}){const k=t>0||u,T=m?.checked?`All ${pn(t)} loaded selected`:`${pn(t)} ${t===1?"message":"messages"} selected`,R=[];return i&&!f&&!u&&R.push({key:"junk",label:"Junk",icon:a.jsx(Ze,{className:"size-4"}),onSelect:i}),c&&!f&&!u&&R.push({key:"mark-read",label:"Mark read",icon:a.jsx(Es,{className:"size-4"}),onSelect:c}),a.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[a.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[k?a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(Un,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):d,m&&a.jsx(hn,{selectAll:m,selecting:k,className:"hidden shrink-0 pr-2 md:flex"}),k?a.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:g??T}):x?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:x}):a.jsxs(a.Fragment,{children:[a.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),b,h]}),k&&!u&&a.jsxs(a.Fragment,{children:[a.jsx(G,{variant:"ghost",size:"touch",icon:f?a.jsx(Kn,{className:"size-5 animate-spin"}):a.jsx(Ft,{className:"size-5 text-danger"}),onClick:f?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":f||void 0,className:"shrink-0"}),!f&&r&&a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(ks,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!f&&o&&a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(We,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),k&&a.jsx(na,{triggerLabel:"More actions",items:R,className:"shrink-0",children:!f&&!u&&y})]}),!k&&p,k&&m&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(hn,{selectAll:m,selecting:k,className:"w-full"})}),w&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx(Rr,{value:w.value,max:w.max,tone:w.tone})}),v&&a.jsx(Bn,{"data-selection-notice":"",tone:v.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v.text&&a.jsx("span",{children:v.text}),v.action&&a.jsx(G,{variant:"ghost",size:"md",onClick:v.action.onClick,className:"-my-1 min-h-11 shrink-0",children:v.action.label})]})})]})}const As=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{id:"uncategorized",label:"Unclassified",tone:"neutral"},{id:"transactional",label:"Transactional",tone:"positive"},{id:"newsletter",label:"Newsletter",tone:"neutral"},{id:"marketing",label:"Marketing",tone:"warning"},{id:"social",label:"Social",tone:"warning"},{id:"automated",label:"Automated",tone:"neutral"}],Fa={id:"unread",label:"Unread"},Hl={id:"flagged",label:"Starred"},Oa={id:"attachment",label:"Has attachment"};function Gl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function Gf(e=[]){return{categories:[...As],filters:Ar,sources:Gl(e)}}function Vf(){return{categories:[...As],filters:[Fa,Hl,Oa]}}function Wf(){return{categories:[...As],filters:[Fa,Oa]}}function Vl(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function Wl(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function Yl(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(Vl(t,o))return o}let n=0;if(t.startsWith("."))for(;n<t.length&&t[n]===".";)n+=1;return e.length===t.length-n?null:Wl(t,e)}const rs=/[\t\n\r]/g;let ps=!1;function gn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function bn(e,t,s){const n=s-t,r=e.charCodeAt(t)|32;if(n===2)return r===119&&(e.charCodeAt(t+1)|32)===115?1:0;if(n===3){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(n===4){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32,c=e.charCodeAt(t+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(n===5)return r===104&&(e.charCodeAt(t+1)|32)===116&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===112&&(e.charCodeAt(t+4)|32)===115?1:0;return 0}function dt(e,t,s=!1){let n=0,r=e.length,o=!1,i=!1;if(ps=!1,!t){if(e.startsWith("data:"))return null;for(;n<e.length&&e.charCodeAt(n)<=32;)n+=1;for(;r>n+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47)n+=2;else{const m=e.indexOf(":/",n);if(m!==-1){const g=bn(e,n,m);if(g===1)for(i=!0,n=m+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(g===2){i=!0,n=m+1;let w=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&w<2;)n+=1,w+=1;if(w<2)return null}else{for(let w=n;w<m;w+=1){const v=e.charCodeAt(w)|32;if(!(v>=97&&v<=122||v>=48&&v<=57||v===46||v===45||v===43)){const k=e.charCodeAt(w);return k===9||k===10||k===13?dt(e.replace(rs,""),t,s):null}}if(e.charCodeAt(m+2)===47)n=m+3;else return null}}else if(e.charCodeAt(n)!==91){let g=-1;for(let w=n;w<r;w+=1){const v=e.charCodeAt(w);if(v===9||v===10||v===13)return dt(e.replace(rs,""),t,s);if(v===58){g=w;break}if(v===47||v===92||v===63||v===35)break}if(g!==-1){let w=!1;for(let v=g+1;v<r;v+=1){const k=e.charCodeAt(v);if(k===47||k===92||k===63||k===35)break;if(k===64){w=!0;break}}if(!w){let v=!0,k=g+1;for(;k<r;k+=1){const T=e.charCodeAt(k);if(T===47||T===92||T===63||T===35)break;if(T<48||T>57){v=!1;break}}if(k===g+1&&(v=!1),!v){const T=bn(e,n,g);if(T===0){let R=!1;for(let P=g+1;P<r;P+=1){const M=e.charCodeAt(P);if(M===47||M===92||M===63||M===35)break;if(M===58){R=!0;break}}if(!R)return null}else if(i=!0,n=g+1,T===2){let R=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&R<2;)n+=1,R+=1;if(R<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let d=-1,b=-1,h=-1,x=-1,p=!1,y=s,f=n-1,u=-1;if(s&&n<r){const m=e.charCodeAt(n);(!(gn(m)||m===46||m===95)||m===45)&&(y=!1)}for(let m=n;m<r;m+=1){const g=e.charCodeAt(m);if(g<64)if(g===47||g===35||g===63){r=m;break}else g===58?(x===-1&&(x=m),h=m):g===9||g===10||g===13?p=!0:s&&(g===46?((m-f>64||u===46||u===45)&&(y=!1),f=m):(g<48||g>57)&&(g!==45||u===46)&&(y=!1));else if(i&&g===92){r=m;break}else g===64?(d=m,x=-1):g===93?b=m:g>=65&&g<=90?o=!0:s&&!gn(g)&&(y=!1);s&&(u=g)}if(p)return dt(e.replace(rs,""),t,s);if(d!==-1&&d>=n&&d<r&&(n=d+1),e.charCodeAt(n)===91)return b!==-1?e.slice(n+1,b).toLowerCase():null;if(h!==-1&&h>n&&h<r&&x===h&&(r=h),n>=r)return null;s&&y&&d===-1&&h===-1&&b===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-f-1<=63&&u!==45&&(ps=!0)}for(;r>n+1&&e.charCodeAt(r-1)===46;)r-=1;const c=n!==0||r!==e.length?e.slice(n,r):e;return o?c.toLowerCase():c}function Jl(e){if(e.length<7||e.length>15)return!1;let t=0;for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n===46)t+=1;else if(n<48||n>57)return!1}return t===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function Xl(e){if(e.length<3)return!1;let t=e.startsWith("[")?1:0,s=e.length;if(e[s-1]==="]"&&(s-=1),s-t>39)return!1;let n=!1;for(;t<s;t+=1){const r=e.charCodeAt(t);if(r===58)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return n}function Zl(e){return Xl(e)||Jl(e)}function xn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function yn(e){if(e.length>255||e.length===0||!xn(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let t=-1,s=-1;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-t>64||s===46||s===45)return!1;t=r}else if(!(xn(o)||o===45||o===95)||o===45&&s===46)return!1;s=o}return n-t-1<=63&&s!==45}function ec({allowIcannDomains:e=!0,allowPrivateDomains:t=!1,detectIp:s=!0,detectSpecialUse:n=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:t,detectIp:s,detectSpecialUse:n,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const tc=ec({});function sc(e){return tc}function nc(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function ac(e){e.domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.isSpecialUse=null,e.publicSuffix=null,e.subdomain=null}function rc(e,t,s,n,r){const o=sc();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=yn(e),r.hostname=dt(e,i,o.validateHostname)):r.hostname=dt(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=Zl(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!ps&&!yn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Yl(r.publicSuffix,r.hostname,o)),r)}const vn=nc();function oc(e,t){return ac(vn),rc(e,3,$r,t,vn).domain}const qt=e=>{const t=new Set,s=[];for(const n of e){const r=n.trim();if(r==="")continue;const o=r.toLowerCase();t.has(o)||(t.add(o),s.push(r))}return s},ic=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},za=e=>oc(ic(e.trim())),lc=e=>{const t=qt(e);if(t.length<2)return null;let s=null;for(const n of t){const r=za(n);if(r===null)return null;if(s===null)s=r;else if(s!==r)return null}return s},Qt=e=>{const t=lc(e);return t!==null?[{field:"FromDomain",value:t}]:qt(e).map(s=>({field:"From",value:s}))},cc=e=>{const t=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=t.get(o);i?i.count+=1:t.set(o,{sender:r,count:1})}let s,n=0;for(const{sender:r,count:o}of t.values())o<=n||(s=r,n=o);return s},_a=e=>e.displayName?.trim()||e.normalizedEmail,dc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,uc=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(dc,"");if(s===t)return t.trim();t=s}},fc=new Set(["a","an","and","are","as","at","be","by","for","from","has","have","in","is","it","me","my","new","of","on","or","our","the","this","to","was","we","with","you","your"]),mc=3,os=e=>e.split(" ").filter(t=>t!==""),kn=e=>e.length===0||e.join(" ").length<mc?!1:e.some(t=>!fc.has(t.toLowerCase())),pc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),hc=e=>{const t=e.map(uc).filter(o=>o!=="");if(t.length===0)return;const[s,...n]=t;if(n.length===0)return kn(os(s))?s:void 0;const r=os(s);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(kn(c)&&n.every(d=>pc(os(d),c)>=0))return c.join(" ")}},gc=(e,t)=>{const s=Qt(e);if(qt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=hc(t);return n!==void 0?[{field:"Subject",value:n}]:s},bc=({match:e,sender:t,folder:s})=>{const n=e??t;return n?s?`${n} → ${s}`:e?`Mail matching ${e}`:`Mail from ${n}`:s?`Mail to ${s}`:""},xc=e=>e.clauses.length>0,yc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(t=>t.label),droppedSemantic:e.droppedSemantic}),vc=({orderedIds:e,isDesktop:t,initialFocusedId:s,initialSelectedIds:n,onExitSelection:r})=>{const[o,i]=l.useState(s),[c,d]=l.useState(),b=l.useCallback(C=>{d(E=>E===C?E:void 0),i(C)},[]),h=kl({initialSelectedIds:n}),{selectedCount:x,toggle:p,clearSelection:y,selectRange:f,setAnchor:u,selectAll:m}=h,g=gl(x,t),w=l.useRef(null),v=l.useRef(!1),k=l.useCallback(()=>{r?.(),y()},[y,r]),T=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),R=l.useCallback(C=>{if(C<0||C>=e.length)return;const E=e[C];if(g){p(E);return}w.current=E,v.current=!1,d(E),i(E)},[e,g,p]),P=l.useCallback(()=>{e.length!==0&&R(T<0?0:Math.min(T+1,e.length-1))},[e.length,T,R]),M=l.useCallback(()=>{e.length!==0&&R(T<=0?0:T-1)},[e.length,T,R]),F=l.useCallback(()=>R(0),[R]),D=l.useCallback(()=>R(e.length-1),[R,e.length]),O=l.useCallback(()=>{o&&p(o)},[o,p]),_=l.useCallback((C,E)=>{const S=hl(E);return S==="range"?(f(e,C,o),!0):S==="toggle"?(p(C),!0):(k(),u(C),!1)},[e,o,f,p,k,u]),q=l.useCallback(C=>{const E=vl(e,o,C);E!==void 0&&(f(e,E),w.current=E,v.current=!1,d(void 0),i(E))},[e,o,f]),j=l.useCallback(()=>q(-1),[q]),I=l.useCallback(()=>q(1),[q]),A=l.useCallback(()=>{e.length>0&&m(e)},[e,m]);return{focusedMessageId:o,setFocusedMessageId:b,keyboardFocusedMessageId:c,focusIndex:T,pendingDomFocusRef:w,cursorMovedByPointerRef:v,selection:h,isMultiSelectMode:g,exitSelection:k,moveFocusToIndex:R,focusNext:P,focusPrevious:M,focusFirst:F,focusLast:D,toggleFocusedSelection:O,extendRangeUp:j,extendRangeDown:I,selectAllLoaded:A,handleRowSelect:_}};function kc(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const s=!!(e.condition??!0),n=e.blockerFn;return{shouldBlockFn:async()=>s&&n!==void 0?await n():s,enableBeforeUnload:s,withResolver:n===void 0}}function jc(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=kc(e),i=Lr(),{history:c}=i,[d,b]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const h=async x=>{function p(g){const w=i.parseLocation(g),v=i.getMatchedRoutes(w.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:v.routeParams,search:i.options.parseSearch(g.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:w.pathname,params:v.routeParams,search:i.options.parseSearch(g.search)}}const y=p(x.currentLocation),f=p(x.nextLocation);if(y.routeId==="__notFound__"&&f.routeId!=="__notFound__")return!1;const u=await s({action:x.action,current:y,next:f});if(!o)return u;if(!u)return!1;const m=await new Promise(g=>{b({status:"blocked",current:y,next:f,action:x.action,proceed:()=>g(!1),reset:()=>g(!0)})});return b({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),m};return r?void 0:c.block({blockerFn:h,enableBeforeUnload:n})},[s,n,r,o,c,i]),d}const $s=e=>{const{data:t,isLoading:s}=Z({...gt(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=Ss({queries:n.map(c=>({...bt({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=s||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<n.length;c++)if((r[c].data?.items??[]).some(h=>h.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},wc=({surface:e})=>{const t=Pr(),s=Dr(),{data:n}=Z({...Ot({path:{messageId:e.sourceMessageId}})}),{data:r}=Z({...gt(),staleTime:1/0}),{accountId:o}=$s(n?.message.mailboxId),i=r?.accounts?.find(c=>c.accountId===o);return a.jsx("div",{className:"border-b border-line bg-canvas",children:a.jsx(ti,{layout:"flow",mode:e.mode,account:i,sourceMessage:n,outboxMessageId:e.outboxMessageId,onDraftCreated:t,onClose:s})})},Ua=({message:e,icon:t})=>a.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&a.jsx("div",{className:"mb-4 text-fg-muted",children:t}),a.jsx("p",{className:"text-fg-muted",children:e})]}),Ka=100,hs=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),Cc=(e,t=Ka)=>{if(e.length===0)return[];const s=[];for(let n=0;n<e.length;n+=t)s.push(e.slice(n,n+t));return s},Sc=(e,t=Ka)=>{const s=new Map;for(const n of e){const r=s.get(n.accountId);if(r){r.push(n.id);continue}s.set(n.accountId,[n.id])}return[...s.values()].flatMap(n=>Cc(n,t))},Ba=async(e,t,s,n)=>{const r=Sc(e),o=e.length;let i=0;const c=[];for(let d=0;d<r.length;d++){if(n())return c.push(...r.slice(d).flat()),{done:i,failedIds:c,cancelled:!0};const b=r[d],h=await hs(t(b));if(!h.ok)return c.push(...r.slice(d).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:h.error};i+=b.length,s({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},ht=async(e,t)=>{await Ba(e.map(s=>({id:s,accountId:void 0})),async s=>(await t(s),{successCount:s.length,failureCount:0}),()=>{},()=>!1)},Nc=async(e,t,s,n,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const d=await hs(e(c));if(!d.ok)return{done:o,failedIds:i,cancelled:!1,error:d.error};const b=d.value;if(b.ids.length>0){const h=await hs(s(b.ids));if(!h.ok)return{done:o,failedIds:i,cancelled:!1,error:h.error};o+=b.ids.length,n({done:o,total:t})}c=b.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},Tc=e=>({done:e.done,total:Math.max(e.total,e.done)}),qa=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),Qa=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Ha=(e,t)=>e===void 0?e:qa(e)?{...e,pages:e.pages.map(s=>({...s,items:t(s.items)}))}:Qa(e)?{...e,items:t(e.items)}:e,ke=e=>{const t=[];for(const s of new Set(e))t.push(qn({path:{mailboxId:s}})),t.push(Qn({path:{mailboxId:s}}));return t.push(Hn()),t},yt=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),vt=(e,t)=>t.flatMap(s=>e.getQueriesData({queryKey:s})).filter(s=>s[1]!==void 0).map(([s,n])=>({queryKey:s,data:n})),kt=(e,t,s)=>{const n=r=>Ha(r,s);for(const r of t)e.setQueriesData({queryKey:r},n)},jt=(e,t)=>{for(const s of t)e.setQueryData(s.queryKey,s.data)},je=(e,t)=>{for(const s of t)e.invalidateQueries({queryKey:s})},Ic=3e3,Ec=(e,t,s)=>{if(e.length===0)return()=>{};const n=setTimeout(()=>s(e),t);return()=>clearTimeout(n)},Ls=(e,t,s)=>{const n=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(n.get(o)??s);return[...r]},Lt=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),Mc=(e,t,s,n)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!s.has(r.messageId)&&!n.has(r.messageId)).map(r=>r.messageId),Rc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=ae(),{pushError:i}=ge(),c=l.useRef(new Set),d=l.useRef(new Set),{mutate:b}=me({...zt(),meta:Fr,onMutate:async p=>{const y=new Set(p.body.messageIds??[]),f=p.body.isRead??!0,u=Re({path:{threadId:s}}),m=ke(Ls(y,e,n));await Promise.all([o.cancelQueries({queryKey:u}),yt(o,m)]);const g=o.getQueriesData({queryKey:u}).filter(v=>v[1]!==void 0).map(([v,k])=>({queryKey:v,data:k})),w=vt(o,m);return o.setQueriesData({queryKey:u},v=>v&&{...v,items:Lt(v.items,y,f)}),kt(o,m,v=>Lt(v,y,f)),{threadMessagesPrefix:u,listPrefixes:m,previousThreadMessages:g,previousThreadsList:w}},onSuccess:(p,y)=>{const f=y.body.messageIds??[];for(const u of f)c.current.add(u),d.current.delete(u)},onError:(p,y,f)=>{const u=y.body.messageIds??[];for(const g of u)d.current.delete(g);if(f){for(const g of f.previousThreadMessages)o.setQueryData(g.queryKey,g.data);jt(o,f.previousThreadsList)}const m=y.body.isRead??!0;i({title:m?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(p),error:p})},onSettled:(p,y,f,u)=>{u&&(o.invalidateQueries({queryKey:u.threadMessagesPrefix}),je(o,u.listPrefixes),r&&o.invalidateQueries({queryKey:Je({path:{accountId:r}})}))}}),h=l.useCallback(p=>{const y=p.filter(f=>!c.current.has(f)&&!d.current.has(f));if(y.length!==0){for(const f of y)d.current.add(f);b({body:{messageIds:y,isRead:!0}})}},[b]),x=l.useMemo(()=>Mc(e,t,c.current,d.current),[e,t]);l.useEffect(()=>Ec(x,Ic,h),[x,h]),l.useEffect(()=>{c.current.clear(),d.current.clear()},[s])},Yf=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=ae(),{pushError:o}=ge(),{mutateAsync:i,isPending:c}=me({...zt(),onError:(b,h)=>{const x=h.body.isRead??!0;o({title:x?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(b),error:b})},onSettled:(b,h,x)=>{je(r,ke(Ls(x.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((b,h)=>{b.length!==0&&ht(b,x=>i({body:{messageIds:x,isRead:h}}))},[i]),isPending:c}},Ac=60,$c=1.5,Lc=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*$c?{direction:null}:{direction:e<0?"left":"right"}},Pc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Ac})=>{const n=l.useRef(null),r=l.useCallback(d=>{if(d.pointerType==="mouse"){n.current=null;return}n.current={x:d.clientX,y:d.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(d=>{const b=n.current;if(n.current=null,!b)return;const{direction:h}=Lc(d.clientX-b.x,d.clientY-b.y,s);h==="left"&&e?.(),h==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},Dc=(e,t,s)=>t?.find(n=>n.messageId===e)?.mailboxId??s,jn=(e,t,s)=>e.map(n=>n.messageId===t?{...n,hasStars:s}:n),Ga=({threadId:e,mailboxId:t,messages:s})=>{const n=ae(),{pushError:r}=ge(),{mutate:o,isPending:i,variables:c}=me({...Or(),onMutate:async b=>{const h=b.path.messageId,x=b.body.isStarred??!1,p=Re({path:{threadId:e}}),y=ke([Dc(h,s,t)]);await Promise.all([n.cancelQueries({queryKey:p}),yt(n,y)]);const f=n.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,g])=>({queryKey:m,data:g})),u=vt(n,y);return n.setQueriesData({queryKey:p},m=>Ha(m,g=>jn(g,h,x))),kt(n,y,m=>jn(m,h,x)),{threadMessagesPrefix:p,listPrefixes:y,previousThreadMessages:f,previousThreadsList:u}},onError:(b,h,x)=>{if(x){for(const y of x.previousThreadMessages)n.setQueryData(y.queryKey,y.data);jt(n,x.previousThreadsList)}const p=h.body.isStarred??!1;r({title:p?"Couldn't star message":"Couldn't unstar message",detail:Me(b),error:b})},onSettled:(b,h,x,p)=>{p&&(n.invalidateQueries({queryKey:p.threadMessagesPrefix}),je(n,p.listPrefixes))}});return{toggleStar:(b,h)=>{o({path:{messageId:b},body:{isStarred:!h}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function wn({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?a.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",a.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",t&&a.jsx("button",{type:"button",onClick:t,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function Va(e){return e===void 0?"uncategorized":e}const Fc={inbox:"Inbox",junk:"Junk"},Ps=e=>e.destinationMailboxId!==void 0,Oc=(e,t)=>{if(Ps(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${Fc[s]??"another folder"} by Remit`},zc=(e,t)=>{if(e===Gs.MoveToInbox)return t.inboxMailboxId;if(e===Gs.MoveToJunk)return t.junkMailboxId},_c=(e,t,s)=>{if(!e||!t)return!1;const n=Ps(e)?e.destinationMailboxId:zc(e.action,s);return n!==void 0&&n===t},Uc="Reported as spam",Kc=(e,t)=>{if(e){if(Ps(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},wt=(e,t)=>{const{data:s,isLoading:n}=Z({...gt(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:n}},Jf=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Archive");return{archiveMailboxId:t,isLoading:s}},Xf=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Bc=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},Wa=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Junk");return{junkMailboxId:t,isLoading:s}},Zf=e=>{const{mailboxId:t,isLoading:s}=wt(e,"Trash");return{trashMailboxId:t,isLoading:s}},qc=()=>{const{data:e,isError:t}=Z({...gt(),staleTime:1/0});return{trashByAccount:l.useMemo(()=>{const n=new Map;for(const r of e?.accounts??[]){const o=r.folderAppointments.find(i=>i.role==="Trash");n.set(r.accountId,{mailboxId:o?.mailboxId,source:o?.source??"None",staleFolderPath:o?.staleAppointmentPath})}return n},[e]),hasAppointments:e!==void 0,isError:t}},Ya=e=>{const{data:t}=Z({...gt(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},Cn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Ht=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=ae(),{pushError:o}=ge(),{mutateAsync:i,isPending:c,isError:d}=me({...zr(),onMutate:async h=>{const x=new Set(h.body.messageIds??[]),p=t?Re({path:{threadId:t}}):[],y=ke([e,h.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:p})]:[],yt(r,y)]);const f=t?r.getQueriesData({queryKey:p}).filter(m=>m[1]!==void 0).map(([m,g])=>({queryKey:m,data:g})):[],u=vt(r,y);return t&&r.setQueriesData({queryKey:p},m=>m&&{...m,items:Cn(m.items,x)}),kt(r,y,m=>Cn(m,x)),n?.(Array.from(x)),{threadMessagesPrefix:p,listPrefixes:y,previousThreadMessages:f,previousThreadsList:u}},onError:(h,x,p)=>{if(p){for(const f of p.previousThreadMessages)r.setQueryData(f.queryKey,f.data);jt(r,p.previousThreadsList)}const y=x.body.messageIds?.length??0;o({title:y>1?`Couldn't move ${y} messages`:"Couldn't move this message",detail:Me(h),error:h})},onSettled:(h,x,p,y)=>{y&&(t&&r.invalidateQueries({queryKey:y.threadMessagesPrefix}),je(r,y.listPrefixes),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((h,x)=>{h.length!==0&&ht(h,p=>i({body:{messageIds:p,destinationMailboxId:x}}))},[i]),isPending:c,isError:d}},Qc="This message could not be processed. Please try again. If it keeps failing, report it.",Hc=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),Sn=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],s=t?.reason??Qc,n=t?Hc(s,t.messageId):s;throw new Kr(n,422)};function Ja({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=ae(),{pushError:o}=ge(),i=ke([e]),c=t?Re({path:{threadId:t}}):[],d=()=>{t&&r.invalidateQueries({queryKey:c}),je(r,i),s&&r.invalidateQueries({queryKey:Je({path:{accountId:s}})})},b=()=>(u,m)=>{d(),n?.(m.body.messageIds)},h=u=>(m,g)=>{o({title:u(g.body.messageIds.length),detail:Me(m),error:m})},x=me({mutationFn:async u=>{const{data:m}=await _r({...u,throwOnError:!0});return Sn(m),m},meta:{softError:!0},onSuccess:b(),onError:h(u=>u>1?`Couldn't report ${u} messages as spam`:"Couldn't report this message as spam")}),p=me({mutationFn:async u=>{const{data:m}=await Ur({...u,throwOnError:!0});return Sn(m),m},meta:{softError:!0},onSuccess:b(),onError:h(u=>u>1?`Couldn't undo the spam report for ${u} messages`:"Couldn't undo the spam report")}),y=l.useCallback(u=>{u.length!==0&&ht(u,m=>x.mutateAsync({body:{messageIds:m}}))},[x.mutateAsync]),f=l.useCallback(u=>{u.length!==0&&ht(u,m=>p.mutateAsync({body:{messageIds:m}}))},[p.mutateAsync]);return{reportSpam:y,notSpam:f,isReporting:x.isPending,isRestoring:p.isPending}}const Gc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=Bc(e),{junkMailboxId:c}=Wa(e),{moveMessages:d,isPending:b}=Ht({mailboxId:n,threadId:s,accountId:e}),{notSpam:h,isRestoring:x}=Ja({mailboxId:n,threadId:s,accountId:e}),{data:p}=Z({...bt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),y={inboxMailboxId:i,junkMailboxId:c},f=Kc(r,y),u=l.useCallback(()=>{f&&d([t],f)},[d,t,f]),m=l.useCallback(()=>{h([t])},[h,t]);if(o)return{show:!0,label:Uc,onUndo:m,isUndoing:x};if(!_c(r,n,y)||!r)return{show:!1,label:"",isUndoing:!1};const w=r.fromMailboxId?p?.items.filter(v=>v.mailboxId===r.fromMailboxId).map(v=>Br(v))[0]:void 0;return{show:!0,label:Oc(r,w),onUndo:f?u:void 0,isUndoing:b,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function Vc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Gc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx($l,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const Nn=(e,t)=>e.filter(s=>!t.has(s.messageId)),em=e=>e.filter(t=>t.isDeleted!==!0),Ds=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=ae(),{pushError:i}=ge(),{requestAppointment:c}=Gn(),d=l.useRef([]),b=l.useRef(async()=>{}),{mutateAsync:h,isPending:x}=me({...Qr(),onMutate:async f=>{const u=new Set(f.body.messageIds??[]),m=t?Re({path:{threadId:t}}):[],g=ke(Ls(u,n??[],e));await Promise.all([o.cancelQueries({queryKey:m}),yt(o,g)]);const w=t?o.getQueriesData({queryKey:m}).filter(k=>k[1]!==void 0).map(([k,T])=>({queryKey:k,data:T})):[],v=vt(o,g);return t&&o.setQueriesData({queryKey:m},k=>k&&{...k,items:Nn(k.items,u)}),kt(o,g,k=>Nn(k,u)),r?.(Array.from(u)),{threadMessagesPrefix:m,listPrefixes:g,previousThreadMessages:w,previousThreadsList:v}},onError:(f,u,m)=>{if(m){for(const v of m.previousThreadMessages)o.setQueryData(v.queryKey,v.data);jt(o,m.previousThreadsList)}const g=qr(f);if(g){const v=d.current;c({accountId:g.accountId,role:g.role,reason:g.reason,action:{kind:"delete",count:v.length},onAppointed:()=>b.current(v)});return}const w=u.body.messageIds?.length??0;i({title:w>1?`Couldn't delete ${w} messages`:"Couldn't delete this message",detail:Me(f),error:f})},onSettled:(f,u,m,g)=>{g&&(t&&o.invalidateQueries({queryKey:g.threadMessagesPrefix}),je(o,g.listPrefixes),s&&o.invalidateQueries({queryKey:Je({path:{accountId:s}})}))}}),p=l.useCallback(f=>ht(f,u=>h({body:{messageIds:u}})),[h]);return l.useEffect(()=>{b.current=p},[p]),{deleteMessages:l.useCallback(f=>{f.length!==0&&(d.current=f,p(f))},[p]),isPending:x}},Xa="inline-flex items-center justify-center transition-colors",Wc=U(Xa,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Yc=U(Xa,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Fs=({accountId:e,currentMailboxId:t,onMove:s,disabled:n=!1,disabledHint:r,variant:o="icon-only",label:i,defaultOpen:c=!1})=>{const[d,b]=l.useState(c),[h,x]=l.useState(),p=js(),y=l.useRef(null),f=i??"Move to folder",u=l.useId(),{t:m}=Hr("mail",{useSuspense:!1}),g=Vn(),{data:w,isLoading:v,isError:k,error:T,refetch:R}=Z({...bt({path:{accountId:e}}),staleTime:1/0,enabled:d}),P=Ya(e),{createFolderIn:M}=Wn(e),F=l.useMemo(()=>Yn({mailboxes:w?.items??[],folderAppointments:P,currentMailboxId:t,translator:g}),[w?.items,P,t,g]),D=Jn(w?.items??[]),O=F.find(E=>E.id===h),_=l.useCallback(()=>{b(!1),x(void 0)},[]),q=l.useCallback(()=>{O&&(_(),s(O.id))},[O,_,s]);l.useEffect(()=>{if(!d||!p)return;const E=z=>{y.current&&!y.current.contains(z.target)&&_()},S=z=>{z.key==="Escape"&&_()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",S)}},[d,p,_]);const j=n||!!r,I=a.jsxs("button",{type:"button",onClick:E=>{E.stopPropagation(),!j&&b(S=>!S)},"aria-label":f,"aria-haspopup":p?"tree":"dialog","aria-expanded":d,"aria-controls":d?u:void 0,title:r,className:o==="icon-only"?Wc:Yc,children:[a.jsx(ks,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),A=v?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):k?a.jsx("div",{className:"p-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load folders",error:T,onRetry:()=>R()})}):a.jsx(Gr,{folders:F,selectedId:h,delimiter:D,onSelect:x,onCreateFolder:M,onCancel:_,labels:{filterPlaceholder:m("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:m("move_picker_filter_label",{defaultValue:"Filter folders"})}}),C=O&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(G,{variant:"primary",onClick:q,className:"h-11 w-full font-semibold",children:`Move to ${O.label}`})});return p?a.jsxs("div",{ref:y,className:"relative inline-block",children:[I,d&&a.jsxs("div",{id:u,className:U("absolute right-0 mt-1 z-50 w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[A,C]})]}):a.jsxs(a.Fragment,{children:[I,a.jsx(Qe.Root,{open:d,onOpenChange:E=>E?b(!0):_(),children:a.jsxs(Qe.Portal,{children:[a.jsx(Qe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(Qe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{maxHeight:"85dvh"},id:u,children:[a.jsx(Qe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(Qe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),a.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:A}),C]})]})})]})},Jc=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:d})=>{const b=ae(),h=Ro(),{pushError:x}=ge(),p=Ao()?.messageId,{mutate:y,isPending:f}=me({...zt(),onMutate:async I=>{const A=I.body.isRead??!0,C=new Set(I.body.messageIds??[]),E=Re({path:{threadId:t}}),S=ke([s]);await Promise.all([b.cancelQueries({queryKey:E}),yt(b,S)]);const z=b.getQueriesData({queryKey:E}).filter(Q=>Q[1]!==void 0).map(([Q,W])=>({queryKey:Q,data:W})),K=vt(b,S);return b.setQueriesData({queryKey:E},Q=>Q&&{...Q,items:Lt(Q.items,C,A)}),kt(b,S,Q=>Lt(Q,C,A)),{threadMessagesPrefix:E,listPrefixes:S,previousThreadMessages:z,previousThreadsList:K}},onError:(I,A,C)=>{if(C){for(const S of C.previousThreadMessages)b.setQueryData(S.queryKey,S.data);jt(b,C.previousThreadsList)}const E=A.body.isRead??!0;x({title:E?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(I),error:I})},onSettled:(I,A,C,E)=>{E&&(b.invalidateQueries({queryKey:E.threadMessagesPrefix}),je(b,E.listPrefixes))}}),u=l.useCallback(I=>{p&&I.includes(p)&&h()},[p,h]),{deleteMessages:m,isPending:g}=Ds({mailboxId:s,threadId:t,onAfterOptimisticRemove:u}),{moveMessages:w,isPending:v}=Ht({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:u}),{toggleTrusted:k,isPending:T,error:R,reset:P}=aa({messageId:e}),M=()=>{y({body:{messageIds:[e],isRead:!1}})},F=()=>{m([e])},D=()=>{o&&k(o,i)},O=f||g||v||T,_=O||!o,q=l.useCallback(I=>{w([e],I)},[w,e]),j=o?void 0:"Sender has no parseable address";return a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(Fs,{accountId:r,currentMailboxId:s,onMove:q,disabled:O,label:"Move this message"}),a.jsxs($o,{trigger:a.jsx(Qo,{className:"size-4"}),children:[a.jsxs(Tt,{onClick:D,disabled:_,children:[i?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4 opacity-0"}),a.jsx("span",{title:j,children:"Trusted sender"})]}),n&&a.jsxs(Tt,{onClick:M,disabled:O,children:[a.jsx(Es,{className:"size-4"}),"Mark as unread"]}),d&&a.jsxs(Tt,{onClick:d,children:[a.jsx(ka,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(Lo,{}),a.jsxs(Tt,{onClick:F,disabled:O,destructive:!0,children:[a.jsx(Ft,{className:"size-4"}),"Delete"]})]})]}),R&&a.jsx("div",{className:"w-64",children:a.jsx(Oe,{variant:"inline",title:"Couldn't update trust",error:R,onRetry:()=>{P(),D()}})})]})},Xc=e=>e==="link-expired"||e==="not-ready";class gs extends Error{reason;status;constructor(t,s,n){super(s),this.name="AttachmentFetchError",this.reason=t,this.status=n}}const Zc="x-remit-403-reason",ed="expired",td=(e,t)=>{if(t?.trim()===ed)return"link-expired";const s=ii(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},sd=300*1e3,Tn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Yr(e,{headers:s,signal:AbortSignal.timeout(sd)});if(r.status===202)throw new gs("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new gs(td(r.status,r.headers.get(Zc)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},nd=(e,t,s)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:s}}},In=e=>e instanceof gs?e.reason:"generic",ad=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",rd=(e,t,s)=>{if(e!=="auth")return Vr(Wr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},od=(e,t)=>{const s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,n.rel="noopener",document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)},id=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},ld=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},En=e=>e.filter(t=>!t.isMultipart&&t.disposition===Jr.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Ho(t.dispositionFilename??"",ld(t.mediaSubtype)),typeLabel:id(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),Mn={status:"idle"},cd=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Xn(),o=ae(),[i,c]=l.useState({}),d=l.useMemo(()=>En(t??[]),[t]),b=Xr({path:{messageId:e}}),h=f=>Tn(f.contentUrl,r).catch(u=>{if(!Xc(In(u)))throw u;return o.refetchQueries({queryKey:b}).then(()=>{const m=o.getQueryData(b),g=m?En(m.bodyParts).find(w=>w.bodyPartId===f.bodyPartId):void 0;return Tn(g?.contentUrl??f.contentUrl,r)})}),x=(f,u)=>c(m=>({...m,[f]:u})),p=f=>{const u=d.find(m=>m.bodyPartId===f);if(!u)throw new Error(`No attachment part ${f} on message ${e}`);x(f,{status:"downloading"}),h(u).then(m=>{od(m,u.filename),x(f,Mn)}).catch(m=>{const g=In(m),w=ad(m),{title:v,detail:k}=nd(g,u.filename,w);x(f,{status:"failed",title:v,detail:k,reportUrl:rd(g,u.filename,w)})})},y=s&&t!==void 0&&d.length===0;return a.jsx(Al,{className:n,attachments:d.map(f=>({attachmentId:f.bodyPartId,filename:f.filename,typeLabel:f.typeLabel,sizeOctets:f.sizeOctets,download:i[f.bodyPartId]??Mn})),onDownload:p,hasUnlistedAttachment:y})},dd=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:d,showRaw:b,onToggleRaw:h,onReply:x,onReplyAll:p,onForward:y})=>{const f=ae(),{deleteMessages:u}=Ds({mailboxId:s,threadId:t}),{moveMessages:m}=Ht({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:g}=aa({messageId:e}),{mutate:w}=me({...zt(),onSettled:()=>{f.invalidateQueries({queryKey:Re({path:{threadId:t}})}),je(f,ke([s]))}}),v=l.useCallback(P=>{m([e],P)},[m,e]),k=l.useCallback(()=>{u([e])},[u,e]),T=l.useCallback(()=>{w({body:{messageIds:[e],isRead:!r}})},[w,e,r]),R=[];return c&&R.push({key:"trusted",label:d?"Trusted sender":"Mark sender trusted",icon:d?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4"}),onSelect:()=>g(c,d)}),h&&R.push({key:"raw",label:b?"Show formatted":"Show raw email",icon:a.jsx(ka,{className:"size-4"}),onSelect:h}),a.jsx(Ra,{hasThread:!0,onReply:x,onReplyAll:p,onForward:y,isStarred:o,onToggleStar:i,onDelete:k,isRead:r,onToggleRead:T,overflowItems:R,moveSlot:n?a.jsx(Fs,{accountId:n,currentMailboxId:s,onMove:v,label:"Move this message"}):void 0})},ud=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),fd=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=Z({...Zr({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(ud,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=s?.raw??"";return c===""?a.jsx("div",{className:"message-body",children:a.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):a.jsx("div",{className:"message-body",children:a.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},md=()=>a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),Za=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),er=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:n})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:U("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":U("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Ye,{className:U("size-3.5",e&&"fill-current")})}),pd=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=ca(e.sentDate,"datetime"),i=Za(e,o);return a.jsx(Aa,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(er,{isStarred:e.hasStars,onToggleStar:n,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},hd=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:d,isStarPending:b,accountId:h,showRaw:x,onToggleRaw:p,mobile:y,onReply:f,onReplyAll:u,onForward:m})=>{const g=ca(e.sentDate,"long"),w=!e.isRead,v=t?.envelope.from[0]?.flags?.trusted?.value===!0,k=t?.envelope.from[0]?.addressId,T=Za(e,g),R=e.autoMoved||e.spamReport?a.jsx(Vc,{accountId:h,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx($a,{message:T,isFocused:y?!1:i,onHeaderClick:c,senderBadge:v?a.jsx(md,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:g}),to:t?a.jsx(dl,{label:"To",addresses:t.envelope.to}):null,indicators:R||!y?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[R,!y&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(er,{isStarred:e.hasStars,onToggleStar:d,isStarPending:b})}),w&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:y?void 0:a.jsx(Jc,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:h,fromAddressId:k,isTrusted:v,showRaw:x,onToggleRaw:p}),actionBar:y?a.jsx(dd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:h,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:d,fromAddressId:k,isTrusted:v,showRaw:x,onToggleRaw:p,onReply:f,onReplyAll:u,onForward:m}):void 0,body:s?a.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):n&&eo(r)?a.jsx("div",{className:"mt-3",children:a.jsx(Ua,{message:"This message has been deleted"})}):n?a.jsx("div",{className:"mt-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):x?a.jsx("div",{className:"mt-3",children:a.jsx(fd,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(Yo,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:v,category:Va(e.category)}),a.jsx(cd,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},gd=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:d,onReplyAll:b,onForward:h})=>{const[x,p]=l.useState(!1),{data:y,isLoading:f,isError:u,error:m,refetch:g}=Z({...Ot({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(hd,{threadMessage:e,messageData:y,isLoading:f,isError:u,error:m,onRetry:()=>g(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:x,onToggleRaw:()=>p(w=>!w),mobile:c,onReply:d,onReplyAll:b,onForward:h}):a.jsx(pd,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},bd=()=>a.jsxs("div",{className:"animate-pulse p-4",children:[a.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),a.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>a.jsxs("div",{className:"flex gap-3 py-3",children:[a.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]}),tm=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:d,mobileIntelligenceOpen:b})=>{const h=js(),{handlers:x}=Pc({onSwipeLeft:c,onSwipeRight:d}),{accountId:p}=$s(t),{data:y,isLoading:f,isError:u,error:m,refetch:g}=Z({...Zn({path:{threadId:e}})}),w=l.useMemo(()=>y?.items??[],[y?.items]),v=w[w.length-1],k=l.useMemo(()=>[...w].reverse(),[w]),T=l.useRef(new Map),[R,P]=l.useState(new Set),[M,F]=l.useState(null),[D,O]=l.useState(0);l.useEffect(()=>{if(w.length>0&&e!==M){F(e);const L=new Set([w[w.length-1].threadMessageId]);if(n){const B=w.find(Y=>Y.messageId===n);B&&L.add(B.threadMessageId)}P(L),O(0)}},[e,w,M,n]);const _=l.useCallback(L=>{P(B=>{const Y=new Set(B);return Y.has(L)?Y.delete(L):Y.add(L),Y})},[]),q=l.useCallback(L=>{const B=k[L];if(!B)return;T.current.get(B.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[k]),j=l.useCallback(()=>{if(k.length===0)return;const L=Math.min(D+1,k.length-1);O(L),q(L)},[k.length,D,q]),I=l.useCallback(()=>{if(k.length===0)return;const L=Math.max(D-1,0);O(L),q(L)},[k.length,D,q]),A=l.useCallback(()=>{const L=k[D];L&&_(L.threadMessageId)},[k,D,_]);Rc({messages:w,expandedIds:R,threadId:e,mailboxId:t,accountId:p});const{toggleStar:C,isPending:E,pendingMessageId:S}=Ga({threadId:e,mailboxId:t,messages:w}),z=to(),K=so(),Q=n??v?.messageId,W=l.useCallback((L,B)=>{B&&K({threadId:e,messageId:B,mode:L})},[K,e]),be=l.useCallback(()=>W("reply",Q),[W,Q]),ee=l.useCallback(()=>W("reply-all",Q),[W,Q]),re=l.useCallback(()=>W("forward",Q),[W,Q]),pe=l.useRef(null),te=z?.kind==="reply"?`${z.mode}:${z.sourceMessageId}`:void 0;if(l.useEffect(()=>{te&&pe.current?.scrollIntoView({behavior:"smooth",block:"start"})},[te]),si({enabled:!f&&w.length>0&&z===void 0,bindings:[{key:"j",handler:j,preventDefault:!0},{key:"ArrowDown",handler:j,preventDefault:!0},{key:"k",handler:I,preventDefault:!0},{key:"ArrowUp",handler:I,preventDefault:!0},{key:"Enter",handler:A,preventDefault:!0},{key:"o",handler:A,preventDefault:!0},{key:"r",handler:be,preventDefault:!0},{key:"R",handler:ee,noModifiers:!1,preventDefault:!0},{key:"f",handler:re,preventDefault:!0}]}),f)return a.jsx(bd,{});if(u)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(Oe,{title:z?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:m,onRetry:()=>g()})});if(w.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:z?a.jsx(Oe,{variant:"inline",title:"There is nothing here to answer",error:"This conversation has no messages left. Another mail client may have moved or deleted them."}):a.jsx(Ua,{message:"No messages in this thread"})});const le=s||w[0]?.subject||"(No subject)",oe=w.length,ue=L=>a.jsx("div",{"data-testid":"conversation-messages",children:k.map((B,Y)=>a.jsx("div",{ref:we=>{we&&T.current.set(B.threadMessageId,we)},children:a.jsx(gd,{threadMessage:B,isExpanded:R.has(B.threadMessageId),isFocused:Y===D,onToggle:()=>_(B.threadMessageId),onToggleStar:()=>C(B.messageId,B.hasStars),isStarPending:E&&S===B.messageId,accountId:p,mobile:L,onReply:L?()=>W("reply",B.messageId):void 0,onReplyAll:L?()=>W("reply-all",B.messageId):void 0,onForward:L?()=>W("forward",B.messageId):void 0})},B.threadMessageId))}),ce=z&&a.jsx("div",{ref:pe,children:z.kind==="reply"?a.jsx(wc,{surface:z}):a.jsx("div",{className:"border-b border-line bg-canvas p-4",children:a.jsx(Oe,{variant:"inline",title:"That is not a way to answer a message",error:`"${z.segment}" is not reply, reply-all or forward.`})})}),de=a.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[a.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:le}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[oe," ",oe===1?"message":"messages"]})]});return h?a.jsxs("article",{className:"h-full flex flex-col",children:[de,r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[ce,ue(!1)]})]}):a.jsxs(Ml,{thread:{subject:le,messages:[]},onBack:i??(()=>{}),intelligenceOpen:b,onToggleIntelligence:o,touchHandlers:x,children:[r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),ce,ue(!0)]})},xd=({isOpen:e,onClose:t,children:s,ariaLabel:n="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]"})=>{const i=l.useRef(null),c=l.useRef(null);if(l.useEffect(()=>{if(!e)return;c.current=document.activeElement;const b=p=>{p.key==="Escape"&&(p.preventDefault(),t())};document.addEventListener("keydown",b),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",b),document.body.style.overflow=x,c.current?.focus()}},[e,t]),!e)return null;const d=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":n,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),a.jsxs("div",{ref:i,className:U("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,d),children:[a.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:a.jsx("button",{type:"button",onClick:t,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close menu",children:a.jsx(Pt,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},yd=10,tr=e=>({q:e?.toLowerCase()??"",limit:yd}),vd=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function kd(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":ni(t,{month:"short",year:"numeric"})}function sr(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const jd="We can't verify the sender of this email, which could mean it's from an insecure source.",wd="We couldn't read this sender's address, so we can't confirm who really sent this message.";function Cd(e,t){const s=e.category??"personal";return{value:ao(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function Sd(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?kd(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:sr(e.fromEmail)}}function Nd(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0,unsubscribed:e.flags.unsubscribed?.value===!0}:{}}function Rn(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function Td(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Id(e,t){const s=[],n=e.displayNameCorrespondence;t&&(n===es.Unrelated?s.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):n===es.Lookalike?s.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`):n===es.ForeignAddress&&s.push(`The name it shows, "${t}", is an address ${e.fromDomain} cannot send from.`));const r=Ed(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${Td(r.slice(0,3))}.`),s}function Ed(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Md(e,t){const s=t>0?t:void 0;if(sr(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:wd,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:jd};if(!n.dkimMismatch){const b=Rn(e),h=Id(n,b);return h.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:b,summary:h.join(" ")}:{verdict:"aligned",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,summary:n.dkimDomain?`This message was signed by ${n.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=n.fromDomain,o=n.dkimDomain,i=Rn(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",d=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:d,similarCount:s}}function Rd(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=Z({...ws({query:tr(s??void 0)}),enabled:!!s,staleTime:3e4}),i=vd(r?.items,s??void 0),c=[n,s].filter(Boolean).join(" "),{data:d,isLoading:b,error:h}=Z({...no({query:{query:c,limit:5}}),enabled:!!(e&&c.length>3),staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const p=(d?.items??[]).filter(g=>g.messageId!==e.messageId).map(g=>({id:g.messageId,threadId:g.threadId,mailboxId:t!=null&&g.mailboxIds.includes(t)?t:g.mailboxIds[0]??"",fromName:g.fromName??"",subject:g.subject??"(No subject)",timeLabel:g.sentDate!=null?Xe(g.sentDate*1e3):"",matched:g.matchedChunkType})),y=Sd(e,i),f=Md(e,p.length),u=Cd(e,i),m=Nd(i);return{sender:y,authenticity:f,category:u,flags:m,similar:p}},[e,i,d,t]),isSimilarLoading:b,similarError:h,similarErrorIsFatal:Vs(h),addressErrorIsFatal:Vs(o),addressId:i?.addressId,address:i}}function Ad(e,t){const s={...e??{}};for(const[n,r]of Object.entries(t))r==null?delete s[n]:s[n]={...r,setAt:r.setAt??Date.now()};return s}function $d({addressId:e,senderEmail:t}){const s=ae(),{pushError:n}=ge(),r=ro({query:tr(t)}),{mutate:o,isPending:i}=me({...oo(),onMutate:async d=>{const b=d.body.flags??{};await s.cancelQueries({queryKey:r});const h=s.getQueryData(r);return s.setQueryData(r,x=>x&&{...x,items:x.items.map(p=>p.addressId===d.path.addressId?{...p,flags:Ad(p.flags,b)}:p)}),{previous:h}},onError:(d,b,h)=>{h?.previous!==void 0&&s.setQueryData(r,h.previous),n({title:"Couldn't update sender preference",detail:Me(d),error:d})},onSettled:()=>{s.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(d=>{if(!e){io(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${t??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:{flags:d}})},[e,o,t]),isPending:i}}const sm=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Ld=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function nm(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function am(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function rm(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Pd(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Dd=["personal","newsletter","marketing","automated","transactional","social"],Fd=e=>e.spamReport?"notSpam":"reportSpam",Od=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function zd(){return a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"h-8 rounded bg-surface"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>a.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function _d({isOpen:e,current:t,onSelect:s,onCancel:n}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(co,{label:"Dismiss reclassify sender",onDismiss:n,className:"backdrop-blur-sm"}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),a.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),a.jsx("div",{className:"mt-4 flex flex-col gap-1",children:Dd.map(r=>a.jsxs("button",{type:"button",onClick:()=>s(r),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${r===t?"font-semibold text-accent":"text-fg"}`,children:[r,r===t&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},r))}),a.jsx("div",{className:"mt-6 flex justify-end",children:a.jsx("button",{type:"button",onClick:n,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function Ud({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:d,similarError:b,similarErrorIsFatal:h}=Rd(e,s),[x,p]=l.useState(!1),y=e.fromEmail??void 0,{updateFlags:f}=$d({addressId:c,senderEmail:y}),{reportSpam:u,notSpam:m,isReporting:g,isRestoring:w}=Ja({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),v=lo(),k=Fd(e),T=l.useCallback(()=>{m([e.messageId])},[m,e.messageId]),R=l.useCallback(()=>{Pd(v,{count:1,senderTrust:e.senderTrust,wasRescuable:Ld(e)}),u([e.messageId])},[u,e,v]),P=l.useCallback(()=>{},[]),M=l.useCallback(()=>{const A=i?.flags?.vip!==!0;f({vip:{value:A}})},[i?.flags?.vip,f]),F=l.useCallback(()=>{const A=i?.flags?.muted!==!0;f({muted:{value:A}})},[i?.flags?.muted,f]),D=l.useCallback(()=>{const A=i?.flags?.unsubscribed!==!0;f({unsubscribed:{value:A}})},[i?.flags?.unsubscribed,f]),O=l.useCallback(A=>{p(!1),f({category:{value:A}})},[f]),_=c!==void 0,q={onToggleVip:_?M:void 0,onToggleMute:_?F:void 0,onToggleUnsubscribe:_?D:void 0,onReclassify:_?()=>p(!0):void 0,onNotSpam:k==="notSpam"?T:void 0,onReportSpam:k==="reportSpam"?R:void 0},j=({mailboxId:A,threadId:C,messageId:E,className:S,ariaLabel:z,children:K})=>a.jsx(ea,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:A,threadId:C,messageId:E},search:Q=>Q,variant:"row",className:S,"aria-label":z,children:K});if(!i)return a.jsx(zd,{});const I=Od({similarError:b,similarErrorIsFatal:h,isSimilarLoading:d});return a.jsxs(a.Fragment,{children:[a.jsx(Sa,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:P,actions:q,similarState:I,similarLinkComponent:j,reportSpamPending:g,notSpamPending:w,className:"border-l-0 h-full w-full"}),a.jsx(_d,{isOpen:x,current:i.category.value,onSelect:O,onCancel:()=>p(!1)})]})}const Kd=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(Ud,{thread:t,onClose:e,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}):a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[a.jsx(We,{className:"size-8 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),a.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]});function om({isOpen:e,onClose:t,thread:s,mailboxId:n,accountId:r,onAfterOptimisticRemove:o}){return a.jsx(xd,{isOpen:e,onClose:t,ariaLabel:"Message details",side:"right",children:a.jsx(Kd,{onClose:t,thread:s,mailboxId:n,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:o})})}const Bd=e=>{const{trashByAccount:t,hasAppointments:s,isError:n}=qc();return l.useMemo(()=>{const r=ai({targets:e,trashByAccount:t,hasAppointments:s,isError:n}),o=i=>i.accountId?t.get(i.accountId):void 0;return{outcome:r,trashIsUnconfirmed:e.some(i=>{const c=o(i);return c?.source==="Proposed"&&c.mailboxId===i.mailboxId}),staleFolderLabel:e.map(o).find(i=>i?.source==="Stale")?.staleFolderPath}},[e,t,s,n])},qd={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},Qd={delete:"moved to Trash",move:"moved",markRead:"marked as read"},nr=(e,t)=>e==="delete"&&t==="permanent"?"permanently deleted":Qd[e],Hd={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},Gd={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},Vd={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},im=(e,t,s)=>qd[e](ze(t),ze(s)),Wd=(e,t,s="trash")=>`${ze(t)} ${nr(e,s)}. Your mail server is still catching up.`,Yd=e=>`Stopped after ${ze(e)}`,Jd=(e,t,s,n="trash")=>`${ze(t)} of ${ze(s)} ${nr(e,n)}. Nothing was sent for the rest, so they are untouched.`,Xd=(e,t)=>t>0?`Stopped after ${ze(t)} — some messages ${Hd[e]}`:Gd[e],Zd=e=>Vd[e],lm=e=>e==="delete"?"danger":"info",cm=(e,t,s,n)=>s.error!==void 0?null:s.cancelled?{severity:"warning",title:Yd(s.done),detail:Jd(e,s.done,t,n)}:{severity:"info",title:Wd(e,s.done,n)},eu=100,tu=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],su=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,d]=l.useState(void 0),[b,h]=l.useState(void 0),x=l.useRef(!1),p=l.useRef(!1),y=ae(),{pushError:f}=ge();l.useEffect(()=>{p.current||(x.current=!0),i({kind:"idle"})},[s,n]);const u=l.useRef(r);u.current=r;const m=l.useCallback(M=>async F=>{const{data:D}=await Ws({path:{mailboxId:e},query:{...M,continuationToken:F,limit:eu},throwOnError:!0});return{ids:(D.items??[]).map(O=>O.messageId),continuationToken:D.continuationToken}},[e]),g=l.useCallback(async()=>{const{data:M}=await Ws({path:{mailboxId:e},query:{...u.current,count:!0,results:!1},throwOnError:!0});if(M.count===void 0)throw new Error("the search returned no count for the selection");return M.count},[e]),w=l.useCallback(M=>async F=>{if(M.kind==="move"){const{data:O}=await uo({body:{messageIds:F,destinationMailboxId:M.destinationMailboxId},throwOnError:!0});return O}if(M.kind==="markRead"){const{data:O}=await fo({body:{messageIds:F,isRead:!0},throwOnError:!0});return O}const{data:D}=await mo({body:{messageIds:F},throwOnError:!0});return D},[]),v=l.useCallback((M,F)=>{je(y,ke(tu(M,e)));const D=new Set;t&&D.add(t);for(const O of F)O.accountId&&D.add(O.accountId);for(const O of D)y.invalidateQueries({queryKey:Je({path:{accountId:O}})})},[y,e,t]),k=l.useCallback(()=>{x.current=!1,i({kind:"counting"}),g().then(M=>{if(x.current){i({kind:"idle"});return}i({kind:"escalated",total:M})},M=>{f(Ys("Couldn't count matching messages","The count didn't finish.",M)),i({kind:"idle"})})},[g,f]),T=l.useCallback(()=>{x.current=!0},[]),R=l.useCallback(()=>{p.current||(x.current=!0,i({kind:"idle"}))},[]),P=l.useCallback(async(M,F)=>{x.current=!1,p.current=!0,d(M);const D=j=>h(Tc(j)),O=w(M),_=m(u.current);let q;try{q=F!==void 0?await Ba(F,O,D,()=>x.current):await Nc(_,o.kind==="escalated"?o.total:0,O,D,()=>x.current)}finally{p.current=!1}return d(void 0),h(void 0),i({kind:"idle"}),q.error&&f(Ys(Xd(M.kind,q.done),Zd(M.kind),q.error)),q.done>0&&v(M,F??[]),q},[w,m,o,f,v]);return{phase:o,escalate:k,stop:T,clear:R,isRunning:c!==void 0,runningAction:c,progress:b,runAction:P}},nu=120,au=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=nu})=>{const o=l.useRef(n);o.current=n;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!s){i.current=c;return}if(c===void 0||c===t)return;if(c===i.current){i.current=void 0;return}const d=setTimeout(()=>o.current(c),r);return()=>clearTimeout(d)},[s,e,t,r])},ar="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",ru="These are already in Junk, so there is nowhere to file them.",ou=(e,t)=>e!==void 0&&e!==t?e:void 0,dm=(e,t)=>{if(ou(e,t)===void 0)return e===void 0?ar:ru};function iu(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const lu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},bs=l.createContext(lu),rr=()=>l.useContext(bs),cu=({isOpen:e,messageIds:t,outcome:s,accountId:n,trashFolderLabel:r,staleFolderLabel:o,trashIsUnconfirmed:i=!1,isDeleting:c=!1,onConfirm:d,onCancel:b})=>{const{Account:h}=Xn(),{requestAppointment:x}=Gn(),p=t.length,y=()=>d([...t]),f=ri(p,s,{trashFolderLabel:r,staleFolderLabel:o,trashIsUnconfirmed:i});return s==="noTrash"||s==="staleTrash"?a.jsx(It,{isOpen:e,...f,onConfirm:()=>{if(!n)return y();const u=[...t];b(),x({accountId:n,role:"Trash",reason:s==="noTrash"?"none":"stale",action:{kind:"delete",count:p},staleFolderLabel:o,onAppointed:async()=>d(u)})},onCancel:b}):s==="unavailable"?a.jsx(h,{fallback:a.jsx(It,{isOpen:e,...f,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:b}),children:({signOut:u})=>a.jsx(It,{isOpen:e,...f,onConfirm:()=>u(),onCancel:b})}):a.jsx(It,{isOpen:e,...f,destructive:!0,isBusy:c||s==="unknown",onConfirm:y,onCancel:b})},or=8,ir=e=>e==="From"||e==="FromDomain",du=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),uu=e=>{const t=za(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},fu=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),mu=(e,t,s)=>{if(!ir(e))return[];const n=t.trim().toLowerCase(),r=new Set,o=[];for(const i of s){if(i.email.trim()==="")continue;const c=e==="From"?du(i):uu(i);if(!c)continue;const d=c.value.toLowerCase();if(!(d===""||r.has(d))&&(r.add(d),d!==n&&!(n!==""&&!fu(c,n))&&(o.push(c),o.length===or)))break}return o},pu=250,hu=2,gu=(e,t,s)=>{const n=t.trim(),r=da(n,pu),o=e!==void 0&&ir(e),{data:i}=Z({...ws({query:{q:r,limit:or}}),enabled:o&&r.length>=hu});if(!o||e===void 0)return[];const c=[...s.map(d=>({email:d,fromSelection:!0})),...(i?.items??[]).map(d=>({email:d.normalizedEmail,...d.displayName?{displayName:d.displayName}:{}}))];return mu(e,n,c)},lr=12,bu=e=>{const{envelope:t}=e,s=t.from[0];return{id:t.messageId,sender:s?_a({normalizedEmail:s.normalizedEmail,displayName:s.displayName}):"Unknown",subject:t.subject??"(No subject)",date:Xe(t.date)}},xu=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=Z({...po({path:{mailboxId:e??""},query:{...t,limit:lr}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(yu),isPending:s&&r}},yu=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Xe(e.sentDate)}),vu=e=>Ss({queries:e.slice(0,lr).map(t=>({...Ot({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(s=>s.data).filter(s=>s!==void 0).map(bu),isPending:t.some(s=>s.isPending)})}),ku=e=>({matchOperator:"Or",literalClauses:Qt(e)}),ju=(e,t,s)=>{const n=me(ho()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),d=l.useMemo(()=>qt(s),[s]),b=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:en({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),h=l.useCallback(()=>{c(!1),o()},[o]),x=n.data,p=x?.semanticUnavailable===!0&&!i&&d.length>0;l.useEffect(()=>{!p||!e||(c(!0),r({path:{accountId:e},body:en(ku(d))}))},[p,e,d,r]);const y=i||(x?.semanticUnavailable??!1),f=n.isPending||p,u=i?{matchOperator:"Or",literalClauses:Qt(d)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:b,reset:h,matchedCount:f?void 0:x?.matchedCount,messageIds:f?void 0:x?.messageIds,semanticUnavailable:y,senderFallback:i,senders:d,matchPredicate:u,isPending:f,isError:n.isError,error:n.error}},wu=()=>[qn({path:{mailboxId:""}}),Qn({path:{mailboxId:""}}),Hn()].map(e=>[{_id:e[0]._id}]),Cu=e=>qa(e)?e.pages:Qa(e)?[e]:[],Su=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",Nu=(e,t)=>{const s=new Set(t),n=new Map;for(const r of e)for(const o of Cu(r))for(const i of o.items){if(!Su(i)||!s.has(i.messageId))continue;const c=i.subject?.trim();c&&n.set(i.messageId,c)}return t.map(r=>n.get(r)).filter(r=>r!==void 0)},Tu=e=>{const t=ae(),s=e.join("\0");return l.useMemo(()=>{const n=wu().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return Nu(n,e)},[t,s])},Iu=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),Eu=e=>Iu.has(e),Mu=(e,{searchHadSemanticReach:t})=>{const s=[],n=[];let r,o;for(const d of e.tokens){if(d.type==="from"){s.push({field:"From",value:d.value});continue}if(d.type==="subject"){s.push({field:"Subject",value:d.value});continue}if(d.type==="in"){r={mailboxId:d.mailboxId,label:d.value};continue}if(d.type==="account"){o=d.accountId;continue}Eu(d.type)&&n.push({type:d.type,label:ra(d)})}const i=e.freeText.trim(),c=i.length>0;return c&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},Ru=(e,t,s)=>e.targetAccountId??t??s[0]?.accountId,Au=({failure:e,isStarting:t,isRunning:s,isDone:n,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":n?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||s?"backApplyRunning":"saving",$u=e=>{if(e.runState==="statusUnknown")return{kind:"refreshStatus"};if(e.isEscalated)return{kind:"rerunEscalated"};if(e.committedScope==="standing"||e.committedScope==="temporary")return e.createFilterFailed?{kind:"resetAndResend"}:e.backApplyPending?{kind:"startBackApply"}:{kind:"waitOnJob"};if(e.committedScope==="all-like-these"&&e.widenRunsAsJob)return{kind:"resend"};const t=new Set(e.failedIds);return{kind:"rerunBulk",targets:t.size>0?e.sent.filter(s=>t.has(s.id)):e.sent}},Lu=e=>e!==void 0&&e.outcome===void 0&&e.failureReason===void 0,Pu=(e,t)=>{if(e){e.stop();return}t()},Du=(e,t)=>e==="run"?t.dismiss:t.cancel,Fu={clauses:[],matchOperator:"any"},Ou={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},zu=[],_u=(e,t,s)=>({verb:"organize",accountId:Ru(e,t.accountId,s),selection:zu,selectionRestriction:void 0,escalated:void 0,searchConversion:e}),Fe={state:"saving",matched:0,applied:0,failed:0,failures:[]},is=(e,t)=>e.map((s,n)=>({...s,id:`${t}-${n}`})),An=(e,t,s)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const n=e==="junk"?s:t;return n?{kind:"move",destinationMailboxId:n}:void 0},ls=e=>e==="move"||e==="junk"||e==="organize",$n=e=>e==="junk"?ar:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function Uu({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:d,onRunEnded:b,step:h,goToStep:x,goBack:p,closeWizard:y}){const[f]=l.useState(()=>c),[u]=l.useState(()=>o),m=f!==void 0,[g,w]=l.useState(m?"properties":"selected"),v=u?"escalated":g,[k,T]=l.useState(()=>f?{clauses:is(f.clauses,"search"),matchOperator:f.matchOperator}:Fu),[R,P]=l.useState(void 0),[M,F]=l.useState(void 0),[D,O]=l.useState(!1),[_,q]=l.useState(void 0),[j,I]=l.useState(void 0),[A,C]=l.useState(),E=l.useRef(!1),S=l.useRef(!1),z=l.useMemo(()=>n.map(N=>N.id),[n]),K=l.useMemo(()=>n.map(N=>({id:N.id,accountId:N.accountId})),[n]),Q=l.useMemo(()=>n.map(N=>N.email).filter(Boolean),[n]),W=z[0],be=Tu(z),{junkMailboxId:ee}=Wa(t),re=ju(u?void 0:t,W,Q),{preview:pe}=re;l.useEffect(()=>{pe()},[pe]);const te=v==="similar"||v==="properties",le=l.useMemo(()=>({matchOperator:k.matchOperator==="all"?"And":"Or",literalClauses:k.clauses.map(N=>({field:N.field,value:N.value}))}),[k.clauses,k.matchOperator]),oe=v==="similar"?re.matchPredicate:le,{count:ue,matchedIds:ce}=ci(te?t:void 0,oe),de=vu(te?ce:[]),L=xu(u?s:void 0,u?.searchQuery),B=u?{status:"ready",count:u.total}:te?ue:{status:"ready",count:n.length},{data:Y}=Z({...bt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),we=Ya(t),Gt=Vn(),et=l.useMemo(()=>Yn({mailboxes:Y?.items??[],folderAppointments:we,currentMailboxId:s,translator:Gt}),[Y?.items,we,s,Gt]),{createFolderIn:Vt}=Wn(t),tt=et.find(N=>N.id===k.moveMailboxId)?.label,st=cc(n.map(N=>({normalizedEmail:N.email,displayName:N.sender}))),nt=bc({match:v==="properties"&&k.clauses[0]?.value.trim()||void 0,sender:st?_a(st):void 0,folder:tt}),H=l.useMemo(()=>({...k,name:k.name??nt}),[k,nt]),Ct=gu(R?.draft.field,R?.draft.value??"",Q),fe=di(t),xe=ui(t),_e=su({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:Ue}=_e,se=xo({verb:e,mode:v,scope:k.scope,fromSearch:m}),J=se[Js(se,h)],$e=yo(t,r),Ce=(N=>{if(N==="folder")return $e.destination;if(N==="rule")return H.scope==="standing"||H.scope==="until"?$e.rule:void 0})(J)??vo(J,H,B),Le=l.useCallback(()=>is(gc(Q,be),"seed"),[Q,be]),Wt=l.useCallback(N=>{w(N),T($=>({...$,widen:N==="similar"&&W?{anchorCount:Math.max(n.length,1)}:void 0,...N==="properties"&&$.clauses.length===0?{clauses:Le()}:{}}))},[W,n.length,Le]),Ke=l.useCallback(()=>{O(!0),w("properties"),T(N=>({...N,widen:void 0,clauses:is(Qt(Q),"sender"),matchOperator:"any"})),x("properties")},[Q,x]),Se=re.semanticUnavailable||re.isError;l.useEffect(()=>{J==="match"&&(v!=="similar"||!Se||D||Ke())},[J,v,Se,D,Ke]);const at=l.useCallback(()=>{P({mode:"add",draft:{field:"From",value:""}})},[]),rt=l.useCallback(N=>{const $=k.clauses.find(V=>V.id===N);$&&P({mode:"edit",clauseId:N,draft:{field:$.field,value:$.value}})},[k.clauses]),ne=l.useCallback(N=>{T($=>({...$,clauses:$.clauses.filter(V=>V.id!==N)}))},[]),ye=l.useCallback(N=>{P($=>$&&{...$,draft:N})},[]),fr=l.useCallback(()=>{P(N=>{if(!N)return;const $=fi(N.draft.field,N.draft.value),V={...N.draft,value:$};T(Be=>({...Be,clauses:N.clauseId?Be.clauses.map(ot=>ot.id===N.clauseId?{...ot,...V}:ot):[...Be.clauses,{id:crypto.randomUUID(),...V}]}))})},[]),mr=l.useCallback(()=>{if(Ce){F(J);return}F(void 0);const N=se[Js(se,J)+1];N&&x(N)},[Ce,J,se,x]),Yt=l.useCallback(async N=>{const $=An(e,H.moveMailboxId,ee);if(!$){I({matched:N.length,sent:N,failureReason:$n(e)});return}I({matched:N.length,sent:N});const V=await Ue($,N);I({matched:N.length,sent:N,outcome:V}),S.current&&b?.($.kind,N.length,V)},[e,H.moveMailboxId,ee,Ue,b]),Jt=l.useCallback(async()=>{if(!u)return;const N=An(e,H.moveMailboxId,ee);if(!N){I({matched:u.total,sent:[],failureReason:$n(e)});return}I({matched:u.total,sent:[]});const $=await u.run(N);I({matched:u.total,sent:[],outcome:$}),S.current&&b?.(N.kind,u.total,$)},[u,e,H.moveMailboxId,ee,b]),{start:St}=fe,{createFilterAsync:Us}=xe,Nt=l.useCallback(()=>{if(u){Jt();return}const N=mi({mode:g,ruleScope:H.scope}),$=pi({mode:g,ruleScope:H.scope,anchorMessageId:W,clauses:H.clauses,matchOperator:H.matchOperator,moveMailboxId:H.moveMailboxId,until:H.until});if(q(N),N==="standing"||N==="temporary"){const V=hi($)?$:void 0;C(V),Us($,N,(H.name??"").trim()).then(Be=>{Be&&V&&St(V)});return}if(N==="all-like-these"&&ls(e)){St($);return}Yt(N==="just-these"?K:ce.map(V=>({id:V,accountId:t})))},[u,Jt,g,H,W,e,t,K,ce,Us,St,Yt]),pr=l.useCallback(()=>{if(Ce){F(J);return}E.current||(E.current=!0,x("run"),Nt())},[Ce,J,x,Nt]),Ks=l.useCallback(N=>{const $=fe.progress,V=Au({failure:fe.failure,isStarting:fe.isStarting,isRunning:fe.isRunning,isDone:fe.isDone,failedCount:$.failedCount,ruleSaved:N});return V==="saving"||V==="commitFailed"||V==="backApplyStartFailed"?{...Fe,state:V}:{state:V,matched:$.matchedCount,applied:$.appliedCount,failed:V==="backApplyFailed"||V==="backApplyRestartFailed"?$.failedCount:0,failures:[]}},[fe]),Bs=l.useMemo(()=>{const N=new Map;for(const $ of[...n,...de.messages,...L.messages])N.set($.id,$);return N},[n,de.messages,L.messages]),qs=u?i:_e.progress,Qs=l.useCallback(()=>{if(!j)return Fe;const{matched:N,outcome:$,failureReason:V}=j;if(V!==void 0)return{...Fe,state:"commitFailed",failureReason:V};if(!$){const qe=qs?.done??0;return{state:"backApplyRunning",matched:Math.max(N,qe),applied:qe,failed:0,failures:[]}}if(!($.cancelled||$.error!==void 0))return{state:"backApplyComplete",matched:Math.max(N,$.done),applied:$.done,failed:0,failures:[]};if($.done===0)return{...Fe,state:"commitFailed"};const ot=$.failedIds.map(qe=>Bs.get(qe)).filter(qe=>qe!==void 0),xr=$.failedIds.length>0?$.failedIds.length:Math.max(N-$.done,1);return{state:"runStopped",matched:Math.max(N,$.done),applied:$.done,failed:xr,failures:ot}},[j,qs,Bs]),Pe=u?Qs():_==="standing"||_==="temporary"?xe.isError?{...Fe,state:"commitFailed"}:xe.isSuccess?A?Ks(!0):{...Fe,state:"filterSaved"}:Fe:_==="all-like-these"&&ls(e)?Ks(!1):Qs(),hr=()=>{const N=$u({runState:Pe.state,isEscalated:u!==void 0,committedScope:_,createFilterFailed:xe.isError,backApplyPending:A!==void 0,widenRunsAsJob:ls(e),failedIds:j?.outcome?.failedIds??[],sent:j?.sent??K});switch(N.kind){case"refreshStatus":fe.refreshStatus();return;case"rerunEscalated":Jt();return;case"resetAndResend":xe.reset(),Nt();return;case"resend":Nt();return;case"startBackApply":A&&St(A);return;case"waitOnJob":return;case"rerunBulk":Yt(N.targets);return}},gr=l.useCallback(()=>{y(se,J)},[y,se,J]),Xt=l.useCallback(()=>{S.current=!0,y(se,J),d()},[y,se,J,d]),{stop:Hs}=_e,br=l.useCallback(()=>{Pu(u,Hs)},[u,Hs]);jc({shouldBlockFn:({action:N})=>N!=="BACK"?!1:(Xt(),!0),enableBeforeUnload:!1,disabled:J!=="run"});const Zt={messages:u?L.messages:te?de.messages:n,count:B,label:v==="selected"?"Your selection":"A sample of what matches",emptyReason:v==="similar"&&Se?"notIndexed":"noMatch",loading:u?L.isPending:te&&(B.status==="loading"||de.isPending)};return a.jsx(ko,{verb:e,steps:se,step:J,blockedReason:Ce,nudged:M===J,onBack:p,onExit:Du(J,{dismiss:Xt,cancel:gr}),onContinue:mr,onCommit:pr,match:{selectedCount:n.length,mode:v,accountId:$e.accountId,onModeChange:Wt,semanticUnavailable:Se,semanticErrorDetail:re.error instanceof Error?re.error.message:void 0,semanticFallbackTaken:D,onSemanticFallback:Ke,escalatedScope:u?.scope,sample:Zt},properties:{clauses:H.clauses,matchOperator:H.matchOperator,onMatchOperatorChange:N=>T($=>({...$,matchOperator:N})),clauseEdit:R,onStartAddClause:at,onStartEditClause:rt,onRemoveClause:ne,onChangeDraft:ye,onSubmitClause:fr,onCancelClause:()=>P(void 0),clauseFields:gi,clauseSuggestions:Ct,conversionNotice:f?yc(f):void 0,semanticFallbackTaken:D,sample:{...Zt,label:"What this matches"}},folder:{folders:et,mailboxId:H.moveMailboxId,delimiter:Jn(Y?.items??[]),onSelect:N=>T($=>({...$,moveMailboxId:N})),onCreateFolder:t?Vt:void 0,restriction:$e.destination},rule:{draft:H,onScopeChange:N=>T($=>({...$,scope:N})),onUntilChange:N=>T($=>({...$,until:N})),restriction:$e.rule},name:{name:H.name??"",onNameChange:N=>T($=>({...$,name:N})),nudged:M===J},review:{verb:e,mode:v,selectedCount:n.length,clauses:H.clauses,matchOperator:H.matchOperator,folder:tt,scope:H.scope,until:H.until,ruleName:se.includes("name")?H.name:void 0,escalatedScope:u?.scope,sample:Zt},run:{state:Pe.state,verb:e,scope:H.scope,matched:Pe.matched,applied:Pe.applied,failedCount:Pe.failed,failures:Pe.failures,failureReason:Pe.failureReason,onRetry:hr,onDismiss:Xt,onCancelRun:Lu(j)?br:void 0}})}function um(e){const t=go()==="search",{searchConversion:s}=rr(),{accounts:n}=_t(),{step:r,goToStep:o,goBack:i,closeWizard:c}=bo(t?"properties":"match");if(!r)return null;const d=t?s??Ou:void 0;return a.jsx(Uu,{...e,...d?_u(d,e,n):{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Ku=[],Os=l.createContext(null),Bu=e=>{const t=l.useContext(Os);return t?t.rowInteraction(e):null},qu=()=>{const e=l.useContext(Os);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},Qu="[data-message-id]",Hu=e=>Array.from(e.querySelectorAll(Qu)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),Gu=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),Vu=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=Hu(n);s(c=>Gu(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function fm({selectedMessageId:e,rows:t,onOpen:s,onDeleteMessages:n,onSelectionVerb:r,wizardOpen:o=!1,isDeleting:i=!1,commandsRef:c,onTriageContextChange:d,children:b}){const h=js(),{pushError:x}=ge(),p=l.useRef(null),y=Vu(p),f=vc({orderedIds:y,isDesktop:h,initialFocusedId:e}),{focusedMessageId:u,setFocusedMessageId:m,pendingDomFocusRef:g,cursorMovedByPointerRef:w,selection:v,isMultiSelectMode:k,exitSelection:T,handleRowSelect:R}=f,{selectedIds:P,selectedCount:M,isSelected:F,toggle:D,select:O,toggleAll:_}=v,q=y.length>0&&y.every(L=>P.has(L)),j=l.useCallback(()=>{y.length>0&&_(y)},[y,_]),{intersectWith:I}=v;l.useEffect(()=>{I(y)},[I,y]),l.useEffect(()=>{const L=g.current;L!==null&&(g.current=null,p.current?.querySelector(`[data-message-id="${L}"]`)?.focus())});const A=l.useCallback(L=>{w.current=!0,m(L)},[w,m]),C=l.useCallback(L=>{h||O(L)},[h,O]),E=l.useCallback(()=>{u&&s(u)},[u,s]),S=l.useCallback(L=>s(L,{replace:!0}),[s]);au({keyboardFocusedMessageId:f.keyboardFocusedMessageId,openMessageId:e,enabled:h&&M===0,open:S});const[z,K]=l.useState(null),{outcome:Q,trashIsUnconfirmed:W,staleFolderLabel:be}=Bd(z?.targets??Ku),ee=l.useCallback(L=>{if(z!==null)return!0;if(M>0)return r(L),!0;if(L!=="delete"||!u)return!1;const B=t.find(Y=>Y.id===u);return!B?.mailboxId||!B.accountId?(x({title:"Couldn't delete this message",detail:"This list has lost track of which account and folder it is in, so reader can't tell whether deleting it would move it to Trash or erase it. Nothing was deleted.",action:{label:"Reload the list",href:window.location.href}}),!0):(K({ids:[u],targets:[{accountId:B.accountId,mailboxId:B.mailboxId}]}),!0)},[z,M,r,u,t,x]),re=l.useCallback(L=>{L.length!==0&&(n(L),K(null),T())},[n,T]),pe=l.useCallback(()=>K(null),[]),te=l.useCallback(()=>M===0?!1:(T(),!0),[M,T]),le=y.length>0;l.useEffect(()=>{if(c){if(!le){c.current=null;return}return c.current={focusNext:f.focusNext,focusPrevious:f.focusPrevious,focusFirst:f.focusFirst,focusLast:f.focusLast,openFocused:E,toggleSelect:f.toggleFocusedSelection,extendSelectDown:f.extendRangeDown,extendSelectUp:f.extendRangeUp,selectAll:f.selectAllLoaded,clearSelection:te,requestVerb:ee,toggleDensity:()=>{}},()=>{c.current=null}}},[c,le,f.focusNext,f.focusPrevious,f.focusFirst,f.focusLast,f.toggleFocusedSelection,f.extendRangeDown,f.extendRangeUp,f.selectAllLoaded,E,te,ee]);const oe=l.useMemo(()=>Array.from(P),[P]),ue=z!==null;l.useEffect(()=>{d?.({focusedMessageId:u,selectedIds:oe,orderedIds:y,hasList:le,blocksKeyboard:ue||o})},[d,u,oe,y,le,ue,o]);const ce=iu(y,u),de=l.useMemo(()=>({selectedIds:P,selectedCount:M,exitSelection:T,startSelectionVerb:r,orderedIds:y,allSelected:q,toggleAllLoaded:j,rowInteraction:L=>({focused:L===u,isTabStop:L===ce,isDesktop:h,onFocusRow:A,selection:{isChecked:F(L),onToggleCheck:D,onRowSelect:R,isMultiSelectMode:k,onLongPress:C}})}),[P,M,T,r,y,q,j,u,ce,h,A,F,D,R,k,C]);return a.jsxs(Os.Provider,{value:de,children:[a.jsx("div",{ref:p,className:"contents",children:b}),a.jsx(cu,{isOpen:ue,messageIds:z?.ids??[],outcome:Q,accountId:z?.targets[0]?.accountId,staleFolderLabel:be,trashIsUnconfirmed:W,isDeleting:i,onConfirm:re,onCancel:pe})]})}function mm({title:e,isDeleting:t}){const s=rr(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:d}=qu();return a.jsx(Ql,{title:s.title||e,navSlot:s.navSlot,titleMeta:s.titleMeta,searchSlot:s.searchSlot,searchField:s.searchField,idleSlot:s.makeFilterSlot,count:n,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:n>0&&!c,onChange:d}:void 0})}const cs=e=>{e.preventDefault(),e.stopPropagation()},Wu=(e,t)=>{const s=l.useRef(!1),n=l.useCallback(i=>{if(s.current=!1,i.button!==0)return;const c=ms(i);dn(c)&&t?.(e,c)&&(cs(i),s.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[t,e]),r=l.useCallback(i=>{!i.ctrlKey||!t||i.preventDefault()},[t]),o=l.useCallback(i=>{if(s.current)return s.current=!1,cs(i),!0;const c=ms(i);return!dn(c)||!t?.(e,c)?!1:(cs(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:n,onContextMenu:r,claimClick:o}},Yu=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:d=!1,link:b,onClick:h,onFocusRow:x})=>{const p=ae(),y=e.id,f=Bu(y),u=s??f?.focused??!1,m=n??f?.isTabStop??!1,g=c??f?.selection,w=x??f?.onFocusRow,v=o??f?.isDesktop??!0,k=g?.isChecked??!1,T=g?.isMultiSelectMode??!1,R=g?.onToggleCheck,P=g?.onRowSelect,M=g?.onLongPress,F=l.useCallback(S=>{S.preventDefault(),S.stopPropagation(),R?.(y)},[R,y]),D=Wu(y,P),O=l.useCallback(S=>{if(!D.claimClick(S)){if(!v){if(T){S.preventDefault(),S.stopPropagation(),R?.(y);return}h?.();return}P?.(y,ms(S)),h?.()}},[D,v,T,R,P,h,y]),_=l.useCallback(()=>{M?.(y)},[M,y]),{longPressProps:q}=Tl({onLongPress:_,accessibilityDescription:k?"Deselect message":"Select message"}),j=l.useCallback(()=>{p.prefetchQuery(Ot({path:{messageId:y}}))},[p,y]),I=l.useCallback(()=>{j(),w?.(y)},[j,w,y]),A=xt({"data-list-row":"","data-message-row":!0,"data-message-id":y,...d?{role:"option","aria-selected":k}:{},tabIndex:m?0:-1,onClick:O,onMouseDown:D.onMouseDown,onContextMenu:D.onContextMenu,onMouseEnter:j,onFocus:I},v||!g?{}:q),C=U(r==="compact"?Ta({active:t,focused:u}):U("group",Ms({active:t,focused:u})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",k&&"bg-accent-soft",!v&&"min-h-11 select-none [-webkit-touch-callout:none]"),E=r==="compact"?a.jsx(Ia,{thread:e}):a.jsx(Rs,{thread:e,badge:i,selection:g?{checked:k,alwaysVisible:T,onToggle:F}:void 0});return b===void 0?a.jsx("button",{type:"button",...A,className:C,children:E}):a.jsx(ea,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...b,messageId:y},search:S=>S,variant:"row",...A,className:C,children:E})},pm=l.memo(Yu),Ju="Open a message first",Xu="This conversation hasn't loaded yet",Zu="The mailbox list hasn't loaded yet",ef="Couldn't find this mailbox's account — reload to try again",tf={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},hm=({hasThread:e,messageId:t,intelligenceOpen:s,canToggleIntelligence:n,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:b,isStarred:h,moveContext:x,moveContextLoading:p})=>{const[y,f]=l.useState(null),u=t??null,m=M=>e?M==="move"?x?null:p?Zu:ef:{reply:o,replyAll:i,forward:c,delete:d,flag:b}[M]?null:Xu:Ju,g=y&&y.messageId===u?y:null,w=g?m(g.action):null,v=g?.action==="move"&&g.overThread&&!!x,k=w??(g&&!v?`${tf[g.action]} is ready — press it again`:null),T=M=>f({action:M,messageId:u,overThread:e}),R=M=>()=>T(M),P=(M,F)=>F?()=>{f(null),F()}:R(M);return a.jsx(El,{hasThread:e,isStarred:h,onUnavailable:T,unavailableHint:k,replyTitle:`Reply ${it("reply")}`,replyAllTitle:`Reply all ${it("replyAll")}`,forwardTitle:`Forward ${it("forward")}`,deleteTitle:`Move to Trash ${it("delete")}`,flagTitle:`Star ${it("toggleStar")}`,onReply:P("reply",o),onReplyAll:P("replyAll",i),onForward:P("forward",c),onDelete:P("delete",d),onToggleStar:P("flag",b),onMove:R("move"),moveSlot:x?a.jsx(Fs,{accountId:x.accountId,currentMailboxId:x.currentMailboxId,onMove:x.onMove,label:"Move to mailbox",defaultOpen:v}):void 0,children:a.jsx(Il,{open:s,enabled:n,onToggle:r})})};function sf(e){const[t,s]=l.useState(null);t!==null&&t!==e&&s(null);const n=e!==null&&t===e,r=l.useCallback(()=>s(null),[]),o=l.useCallback(()=>s(e),[e]),i=l.useCallback(()=>s(n?null:e),[n,e]);return{isOpen:n,open:o,close:r,toggle:i}}const gm=e=>{const{intelligenceOpen:t,onToggleIntelligence:s,onRaiseIntelligence:n}=_t(),r=ta()?.showIntelligencePane??!1,o=e??null,i=sf(o),c=!r&&i.isOpen,{open:d,toggle:b}=i,h=l.useCallback(()=>{if(r){s();return}b()},[r,s,b]),x=l.useCallback(()=>{!r||t||n()},[r,t,n]),p=l.useCallback(()=>{if(!r){d();return}x()},[r,d,x]);return{canToggle:o!==null,isShowing:o!==null&&(r?t:c),toggle:h,open:p,drawerOpen:c,closeDrawer:i.close,railFits:r,openRail:x}},bm=(e,{toggle:t,open:s})=>{l.useEffect(()=>(e.current={toggle:t,open:s},()=>{e.current=null}),[e,t,s])},nf=()=>{const e=ae();return l.useCallback(t=>{const s=Re({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},xm=({thread:e,mailboxId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=t??e?.mailboxId,o=s??e?.accountId,{accountId:i}=$s(o?void 0:r),c=o??i,d=nf(),{deleteMessages:b}=Ds({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{moveMessages:h}=Ht({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{toggleStar:x}=Ga({threadId:e?.threadId??"",mailboxId:r??""}),p=l.useCallback(()=>{e&&b(d(e))},[e,d,b]),y=l.useCallback(u=>{e&&h(d(e),u)},[e,d,h]),f=l.useCallback(()=>{e&&x(e.messageId,e.hasStars)},[e,x]);return{mailboxId:r,accountId:c,isStarred:e?.hasStars,deleteThread:p,moveThread:y,toggleStar:f}},ym=(e,t)=>{const{data:s}=Z({...Zn({path:{threadId:e??""}}),enabled:!!e}),n=s?.items??[],r=t?n.find(i=>i.messageId===t):void 0,o=n.length>0?n[n.length-1]:void 0;return r??o},Ln=(e,t,s)=>{if(!t)return null;const n=e.indexOf(t);if(n===-1)return null;const r=s==="next"?n+1:n-1;return r<0||r>=e.length?null:e[r]},vm=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,d]=l.useState(!1),[b,h]=l.useState(!1),x=l.useCallback(p=>{t(p.focusedMessageId),n(p.selectedIds),p.orderedIds&&o(p.orderedIds),d(p.hasList),h(p.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:x,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c,blocksKeyboard:b}},km=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:d}=e,b=l.useCallback(()=>{i.current?.clearSelection()||s&&r()},[i,s,r]);return Po({enabled:n&&!d,handlers:{...c?{focusNext:()=>i.current?.focusNext(),focusPrevious:()=>i.current?.focusPrevious(),focusFirst:()=>i.current?.focusFirst(),focusLast:()=>i.current?.focusLast(),openFocused:()=>i.current?.openFocused(),toggleSelect:()=>i.current?.toggleSelect(),extendSelectDown:()=>i.current?.extendSelectDown(),extendSelectUp:()=>i.current?.extendSelectUp(),selectAll:()=>i.current?.selectAll(),toggleDensity:()=>i.current?.toggleDensity()}:{},back:b,...o}}),{goBack:b,nextMessageId:Ln(t,s,"next")??void 0,previousMessageId:Ln(t,s,"previous")??void 0}},af={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function rf(e){return af[e]??e}function jm(e,t){const{folder:s}=Cs(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Xe(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function wm(e,t){const{folder:s}=Cs(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function of(e,t){const{mailboxId:s,folder:n}=Cs(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Xe(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:rf(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function Cm(e,t,s){const n=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))n.has(o.threadId)||(n.add(o.threadId),r.push(of(o,s)));return r}function Sm(e){const t=e.authenticity?.dkimMismatch===!0;return{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:Xe(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Va(e.category),suspicious:t}}function Nm(e){return e.filter(t=>t.muted!==!0)}function Tm(e,t){const s=new Set,n=[];for(const r of[...e,...t])s.has(r.id)||(s.add(r.id),n.push(r));return n.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const Pn=[{id:"personal",label:"Personal",category:ve.personal},{id:"transactional",label:"Transactional",category:ve.transactional},{id:"newsletter",label:"Newsletter",category:ve.newsletter},{id:"marketing",label:"Marketing",category:ve.marketing},{id:"social",label:"Social",category:ve.social},{id:"automated",label:"Automated",category:ve.automated},{id:"uncategorized",label:"Unclassified",category:ve.uncategorized}];function Im(e){const t=new Map(Pn.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ve.uncategorized;(t.get(r)??t.get(ve.uncategorized))?.push(n)}const s=[];for(const n of Pn){const r=t.get(n.category);r&&r.length>0&&s.push({id:n.id,label:n.label,threads:r})}return s}function Em(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Mm(e,t){return t.every(s=>{switch(s.type){case"from":{const n=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(n)||e.fromName.toLowerCase().includes(n)}case"subject":return e.subject.toLowerCase().includes(s.value.toLowerCase());case"category":return(e.category??"uncategorized")===s.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=s.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<s.epochSeconds*1e3;case"in":return e.mailboxId===s.mailboxId;case"account":return e.accountId===s.accountId;default:return!1}})}const cr=8;function zs(e,t){const s=Math.max(0,Math.min(t,e.length)),n=Jo(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=Xo(n.raw);return r?{start:n.start,end:n.end,raw:n.raw,name:r.name,value:r.value}:{start:n.start,end:n.end,raw:n.raw}}function lf(e,t){const s=zs(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=oa(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const cf={mailbox:"mailboxes",account:"accounts",contact:"contacts"},df=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=cf[e.values];return s?t[s]??[]:[]},uf=(e,t)=>{if(t==="")return 1;const s=e.toLowerCase();return s.startsWith(t)?0:s.includes(t)?1:-1},xs=(e,...t)=>{let s=-1;for(const n of t){if(n===void 0)continue;const r=uf(n,e);r<0||(s<0||r<s)&&(s=r)}return s},dr=e=>{const t=new Set;return e.filter(s=>s.rank>=0).sort((s,n)=>s.rank-n.rank).filter(s=>{const n=s.suggestion.value.toLowerCase();return t.has(n)?!1:(t.add(n),!0)}).slice(0,cr).map(s=>s.suggestion)},Dn=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function ff(e){const t=e.trim().toLowerCase();if(t==="")return Zs.map(Dn);const s=[];for(const n of Zs)if(s.push({rank:xs(t,`${n.name}:`,n.label),suggestion:Dn(n)}),n.values==="fixed")for(const r of n.options??[]){const o=ia(n.name,r.value);s.push({rank:xs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return dr(s)}function mf(e,t,s){const n=t.trim().toLowerCase(),r=df(e,s).map(o=>({rank:xs(n,o.value,o.label),suggestion:{value:ia(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return dr(r)}function pf(e,t,s={}){const n=zs(e,t);if(n.name===void 0)return ff(n.raw);const r=oa(n.name);return r?mf(r,n.value??"",s):[]}function hf(e,t,s){const n=zs(e,t),r=!s.value.endsWith(":"),o=/\s/.test(e.slice(n.end,n.end+1)),i=r&&!o?`${s.value} `:s.value;return{query:e.slice(0,n.start)+i+e.slice(n.end),cursor:n.start+i.length+(r&&o?1:0)}}const gf=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),bf=250,xf=2;function yf({query:e,cursor:t,enabled:s}){const{accounts:n}=_t(),{mailboxesByName:r}=la(),o=r!==void 0,i=s?lf(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",d=da(c,bf),{data:b}=Z({...ws({query:{q:d,limit:cr}}),enabled:d.length>=xf}),h=Ss({queries:n.map(f=>({...bt({path:{accountId:f.accountId}}),staleTime:1/0}))}),x=l.useMemo(()=>o?Do(h.map(f=>f.data?.items??[]),n):[],[o,h,n]),p=l.useMemo(()=>Fo(n),[n]),y=l.useMemo(()=>(b?.items??[]).map(gf),[b]);return l.useMemo(()=>{if(!s)return[];const f=pf(e,t,{mailboxes:x,accounts:p,contacts:y});return o?f:f.filter(u=>u.value!=="in:")},[s,e,t,x,p,y,o])}const ur="remit.recentSearches",vf=5;function ys(){try{const e=localStorage.getItem(ur);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Fn(e){const t=e.trim();if(!t)return ys();const s=[t,...ys().filter(n=>n!==t)].slice(0,vf);try{localStorage.setItem(ur,JSON.stringify(s))}catch{return s}return s}const kf=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function jf(e){const{spam:t}=La([...e]),s=new Map;for(const r of t)r.mailboxId&&s.set(r.mailboxId,(s.get(r.mailboxId)??0)+1);let n;for(const[r,o]of s)(!n||o>n.count)&&(n={mailboxId:r,count:o});return n}function Rm({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:d,relatedResults:b,relatedLoading:h,onSelectSearchResult:x,searchResultsLabel:p="Top matches",relatedResultsLabel:y="Related",searchResultsInBody:f=!1,refreshControl:u}){const{accounts:m,resultFolderIndex:g,searchQuery:w,searchInput:v,onSearchChange:k,onSearchClear:T,searchViewKey:R}=_t(),P=la(),M=Oo(),F=ta(),D=zo(),[O,_]=l.useState(!1),[q,j]=l.useState(ys),I=jo(),A=l.useRef(R);l.useEffect(()=>{A.current!==R&&(A.current=R,_(!1))},[R]);const[C,E]=l.useState(0),[S,z]=l.useState(!1),[K,Q]=l.useState(void 0),W=yf({query:v,cursor:C,enabled:S&&v.trim().length>0}),be=l.useCallback(ne=>{const ye=hf(v,C,ne);k(ye.query),Q({cursor:ye.cursor})},[v,C,k]),ee=wo({count:W.length,onAccept:ne=>{const ye=W[ne];ye&&be(ye)}}),{comboboxProps:re,handleKeyDown:pe}=ee,te=l.useMemo(()=>({comboboxProps:re,onKeyDown:pe,onCaretChange:E,onFocusChange:z,...K?{caret:K}:{}}),[re,pe,K]),le=ee.open?a.jsx(To,{id:ee.listId,suggestions:W,activeIndex:ee.activeIndex,optionId:ee.optionId,onPick:be,onHighlight:ee.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,oe=v.trim().length>0,{mailboxesByName:ue,accountsByName:ce}=P,de=l.useMemo(()=>Zo(v,{mailboxesByName:ue,accountsByName:ce}),[v,ue,ce]),L=de.tokens.map(ne=>({label:ra(ne),onRemove:()=>k(ei(v,ne))})),B=c??[],Y=b??[],we=oe?[{id:"top",label:p,results:B},{id:"related",label:y,results:Y}]:[],et=!(B.length+Y.length>0)&&(d===!0||h===!0),{scope:Vt}=_o(m),tt=Co(),st=xi(tt),nt=yi(tt,Vt,st?g.get(st)?.role:void 0),H=nt.kind==="global"?jf([...B,...Y]):void 0,Ct=H?{kind:"global",onScopeToSpam:()=>M(H.mailboxId,w)}:nt,fe=Y.length>0,xe=l.useMemo(()=>Mu(de,{searchHadSemanticReach:fe}),[de,fe]),_e=oe?xe:void 0,Ue=oe?{onClick:()=>{_(!1),I("properties","search")},blockedReason:xc(xe)?void 0:So(xe.droppedFacets.map(ne=>ne.label))}:void 0,se=Ue?a.jsx(Pa,{...Ue}):null,J=kf({tier:D,hasLiveInput:oe,hasCommittedQuery:w.trim().length>0,bodyRendersCommittedResults:f}),$e=ne=>{j(Fn(v)),x?.(ne)},_s=a.jsx(Da,{value:v,sections:we,loading:et,onSelectResult:$e,tokens:L,scope:Ct}),Ce=n===void 0,Le=J?a.jsx("div",{className:"h-full overflow-y-auto",children:_s}):null,Wt=Le&&!Ce?Le:s,Ke=Le&&Ce?Le:null,Se=Uo(D),at=Se&&(O||oe),rt=l.useMemo(()=>({title:e,searchResults:Ke,makeFilterSlot:se,searchConversion:_e,navSlot:F&&!F.showNavPane&&a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(vi,{className:"size-5"}),onClick:()=>F.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[t.toLocaleString()," unread"]}),a.jsx(Xs,{}),u]}),searchSlot:Se&&!at&&a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(No,{className:"size-5"}),onClick:()=>_(!0),"aria-label":"Search",className:"shrink-0"}),searchField:at&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(sa,{value:v,onChange:k,onClear:T,globalFocusKey:!1,showClearButton:!1,suggest:te})}),a.jsx(G,{variant:"ghost",size:"touch",icon:a.jsx(Pt,{className:"size-5"}),onClick:()=>{T(),_(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(Xs,{})]})}),[e,t,F,Se,at,v,k,T,te,Ke,se,_e,u]);if(D==="phone"&&O){const ne=ye=>{j(Fn(v)),_(!1),x?.(ye)};return a.jsxs(bs.Provider,{value:rt,children:[a.jsx(ql,{value:v,onChange:k,onClear:T,onCancel:()=>{_(!1),T()},filter:i,recentSearches:q,onPickRecent:k,makeFilter:Ue,sections:we,loading:et,onSelectResult:ne,tokens:L,scope:Ct,suggest:te,suggestList:le}),r]})}return a.jsx(bs.Provider,{value:rt,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[n?.(rt),le,a.jsx("div",{className:"min-h-0 flex-1",children:Wt}),o,r]})})}export{sf as $,rm as A,qc as B,Pl as C,cu as D,je as E,ke as F,sm as G,Sm as H,Mm as I,$s as J,em as K,ym as L,pm as M,Ds as N,Ht as O,vm as P,xm as Q,Xf as R,Ql as S,Jf as T,nf as U,Ga as V,Rd as W,$d as X,Pd as Y,Ld as Z,km as _,wl as a,bm as a0,tm as a1,om as a2,Kd as a3,gm as a4,hm as a5,Vf as a6,Zf as a7,jm as a8,Cm as a9,Nm as aa,Tm as ab,Em as ac,wm as ad,La as ae,jf as af,Im as ag,Gf as ah,kf as ai,zl as aj,fm as ak,qf as al,qu as am,Rm as an,Ls as ao,ht as ap,Tl as aq,xt as ar,Es as as,ms as at,Qf as au,Hf as av,Wf as aw,mm as ax,rr as b,Ms as c,Yf as d,Wa as e,Bd as f,kl as g,su as h,au as i,dm as j,Wd as k,jc as l,im as m,vl as n,lm as o,iu as p,um as q,cm as r,gl as s,Va as t,Wu as u,ou as v,Bc as w,Ya as x,nm as y,am as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as v,r as u,j as s,a9 as l,aa as p}from"./index-idulIG65.js";import{F as x}from"./FullCompose-D8BBZrtI.js";import{a as m}from"./useMessageBodyContent-5kw10g9a.js";function S(o,n,r){if(o!==n)return r}function d(o,n){return o===""?"":n}function j({searchInput:o,committedQuery:n,urlQuery:r,pathname:t,listPath:a}){return!v(t,a)||n!==o?!1:n!==r}const c=u.createContext(null),C=({chrome:o,children:n})=>s.jsx(c.Provider,{value:o,children:n});function M({phone:o,list:n,reading:r,intelligence:t,hasThread:a=!1}){const e=u.useContext(c),f=m();if(!e)return s.jsx(l,{});const i={nav:e.nav,overlay:e.overlay,skeleton:s.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?s.jsx(p,{...i,list:f?s.jsx(x,{}):o,intelligenceOpen:e.intelligenceOpen}):s.jsx(p,{...i,topBar:e.topBar,list:n,reading:r,intelligence:t,intelligenceOpen:e.intelligenceOpen,hasThread:a})}export{C as M,M as a,j as b,d as c,S as s};
|