@remit/web-client-dist 0.0.394 → 0.0.395
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-DMMDtygd.js +1 -0
- package/assets/{ErrorState-H9VKb2xQ.js → ErrorState-B7CjpNr1.js} +1 -1
- package/assets/FlaggedPane-CenbD3ZX.js +1 -0
- package/assets/{FullCompose-CPAuWem3.js → FullCompose-DxrPtE97.js} +1 -1
- package/assets/MailListHeader-CHNpg6hW.js +7 -0
- package/assets/{MailViewChrome-Yy2MMgrX.js → MailViewChrome-DMZMXGmb.js} +1 -1
- package/assets/{MailboxPane-0ONRtVFQ.js → MailboxPane-OZyhyKc7.js} +1 -1
- package/assets/{NavMenuButton-wJyAXMeW.js → NavMenuButton-DhvPRMRY.js} +1 -1
- package/assets/{OnboardingWizard-93_omLJF.js → OnboardingWizard-BluSoABC.js} +1 -1
- package/assets/{OutboxPane-BYdNsw8s.js → OutboxPane-D3bO5X-e.js} +1 -1
- package/assets/_mailboxId-J5_6ra6B.js +1 -0
- package/assets/_messageId-D2K3LdXn.js +1 -0
- package/assets/_messageId-D4ArJQW8.js +1 -0
- package/assets/_messageId-jvQuCDOc.js +1 -0
- package/assets/_outboxMessageId-gim2DZV_.js +1 -0
- package/assets/_threadId-BGlMohCp.js +1 -0
- package/assets/_threadId-BSiNkuUO.js +1 -0
- package/assets/_threadId-NAbzmkAv.js +1 -0
- package/assets/{accounts-CdiJ7ird.js → accounts-CPLm36Op.js} +1 -1
- package/assets/{advanced-PLoPkb_s.js → advanced-sbx4VVnK.js} +1 -1
- package/assets/{appearance-BvwLd24O.js → appearance-D4J4pM2o.js} +1 -1
- package/assets/{attachment-file-JS4jrpkd.js → attachment-file-BBxRM9lo.js} +1 -1
- package/assets/{avatar-C-fjco_O.js → avatar-CL1i6pSF.js} +1 -1
- package/assets/{bottom-sheet-eA9VF9K3.js → bottom-sheet-bT5EwgTl.js} +1 -1
- package/assets/{brief-kr9UzMKp.js → brief-CW_Q_fiU.js} +1 -1
- package/assets/brief-ChRvybYN.js +1 -0
- package/assets/{browser-ponyfill-BStBmswd.js → browser-ponyfill-CaDG7Bnr.js} +1 -1
- package/assets/{bug-CP5PzOSB.js → bug-BWIkahBq.js} +1 -1
- package/assets/{circle-check-CFJIEGPM.js → circle-check-Dwjx4wHC.js} +1 -1
- package/assets/{circle-check-big-Bn-U867g.js → circle-check-big-CuPf64kI.js} +1 -1
- package/assets/{circle-help-CqebdUGf.js → circle-help-LMxllVQt.js} +1 -1
- package/assets/{clock-D1VZsyzj.js → clock-DI632I1n.js} +1 -1
- package/assets/compose._-_outboxMessageId_-B8w5ctOJ.js +1 -0
- package/assets/compose._-_outboxMessageId_-BpxJbzZF.js +1 -0
- package/assets/compose._-_outboxMessageId_-BpzjtJmx.js +1 -0
- package/assets/compose._-_outboxMessageId_-ovjFvylS.js +1 -0
- package/assets/{confirm-dialog-D9OnJgiz.js → confirm-dialog-D8xOy16a.js} +1 -1
- package/assets/{download-B37WxhaV.js → download-BOHIxI00.js} +1 -1
- package/assets/{filters-7Vj0APfi.js → filters-DWJ4zdr_.js} +1 -1
- package/assets/flagged-hN-dNkKd.js +1 -0
- package/assets/{flagged-D9DdUvhY.js → flagged-jmdm1fX1.js} +1 -1
- package/assets/{folders-cMBHVisY.js → folders-T0pT68e9.js} +1 -1
- package/assets/{help-copy-DhkifcuK.js → help-copy-BEu07mo8.js} +1 -1
- package/assets/index-BN5JojAL.js +1 -0
- package/assets/index-BSL-XBxc.js +1 -0
- package/assets/index-BZEHAEtA.js +1 -0
- package/assets/index-Bhi8kbud.js +1 -0
- package/assets/index-D2K3LdXn.js +1 -0
- package/assets/index-DTWpI2oc.js +1 -0
- package/assets/index-Du1-Zqh_.js +1 -0
- package/assets/{index-CUU0jfxN.js → index-RG6hjVja.js} +4 -4
- package/assets/{index-ZioC_miX.js → index-fTBVdymx.js} +3 -3
- package/assets/index-jvQuCDOc.js +1 -0
- package/assets/{kbd-B9W2hN8q.js → kbd-J48_YAed.js} +1 -1
- package/assets/{labels-CemT_pJ4.js → labels-j3Y4hbKZ.js} +1 -1
- package/assets/{mail-D7_J4Hka.js → mail-B3Zq8Bsj.js} +1 -1
- package/assets/{mail-DMEzVsxa.js → mail-D4IROUAs.js} +1 -1
- package/assets/{menu-btYfykob.js → menu-jalQ9e9M.js} +1 -1
- package/assets/{move-options-wVZLzzOm.js → move-options-izqmkqX6.js} +1 -1
- package/assets/{onboarding-CtyIS6yc.js → onboarding-BiIDG6k1.js} +1 -1
- package/assets/outbox-UADei6Tu.js +1 -0
- package/assets/{pencil-D2sBRM9X.js → pencil-D5S7CYV_.js} +1 -1
- package/assets/{rich-text-BnbIA7Bu.js → rich-text-D6jrJ74x.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-YzYor_i_.js → rich-text-spellcheck-worker-provider-BqpvRbx8.js} +1 -1
- package/assets/{rotate-ccw-BACEtlTy.js → rotate-ccw-D101rc-2.js} +1 -1
- package/assets/{row-actions-4gTc4HYo.js → row-actions-DsrPtjsg.js} +1 -1
- package/assets/{search-scope-Yr3PP072.js → search-scope-Bw1jfRMO.js} +1 -1
- package/assets/{search-token-index-TdpCnc3g.js → search-token-index--lUeNQdC.js} +1 -1
- package/assets/{search-view-DaZ48UAg.js → search-view-BVORUYOp.js} +1 -1
- package/assets/{senders-CRn1SGMP.js → senders-CBVfzTiV.js} +1 -1
- package/assets/settings-DXT4Fy4H.js +1 -0
- package/assets/{settings-screen-ccDxzeKU.js → settings-screen-D115ER-L.js} +1 -1
- package/assets/{shield-check-CugI8TKD.js → shield-check-VW8L3t2E.js} +1 -1
- package/assets/{suggested-vips-BKkTuGJU.js → suggested-vips-W1AP7aMy.js} +1 -1
- package/assets/{useDebouncedValue-C0bvXsb6.js → useDebouncedValue-CIzVPWhk.js} +1 -1
- package/assets/{useFilters-5IVBxCIT.js → useFilters-C1t-twQv.js} +1 -1
- package/assets/{useLabels-DGD7TVPX.js → useLabels--yOYyuAO.js} +1 -1
- package/assets/{useMediaQuery-Cb7mCL7B.js → useMediaQuery-koJY7-su.js} +1 -1
- package/assets/{useMessageBodyContent-BLpH5rtV.js → useMessageBodyContent-B4CmbWQa.js} +1 -1
- package/assets/{useRefreshControl-Dfa_Gg5j.js → useRefreshControl-BUJKeOlz.js} +1 -1
- package/assets/{useSearchMirror-cpHAc0ae.js → useSearchMirror-DBlzJer9.js} +1 -1
- package/assets/{useSearchTokenContext-B7jozGQi.js → useSearchTokenContext-DtAc62ht.js} +1 -1
- package/assets/{useSemanticSearch-Btg1EU-p.js → useSemanticSearch-YPC2Eqfk.js} +1 -1
- package/assets/{useSignature-kWMgLd2m.js → useSignature-BCSQUPZ6.js} +1 -1
- package/assets/wizard-selection-B1bng5Jq.js +1 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-BKPfO9yK.js +0 -1
- package/assets/FlaggedPane-UtNzGG5k.js +0 -1
- package/assets/MailListHeader-l1gE_NNB.js +0 -7
- package/assets/_mailboxId-ByIWv5xd.js +0 -1
- package/assets/_messageId-CkSQAjeW.js +0 -1
- package/assets/_messageId-DuRIZtLk.js +0 -1
- package/assets/_messageId-Dzjyi4Fo.js +0 -1
- package/assets/_outboxMessageId-V7nKAWAe.js +0 -1
- package/assets/_threadId-BQQ8KFWm.js +0 -1
- package/assets/_threadId-Bm6nE0M-.js +0 -1
- package/assets/_threadId-DhNy2BzO.js +0 -1
- package/assets/brief-BIfUx2p4.js +0 -1
- package/assets/compose._-_outboxMessageId_-B2qtDZqF.js +0 -1
- package/assets/compose._-_outboxMessageId_-D2hJJTII.js +0 -1
- package/assets/compose._-_outboxMessageId_-DMY1TqDQ.js +0 -1
- package/assets/compose._-_outboxMessageId_-DpR4RcSm.js +0 -1
- package/assets/flagged-SdS13ff9.js +0 -1
- package/assets/index-BuN-p4yT.js +0 -1
- package/assets/index-C-GYzpo-.js +0 -1
- package/assets/index-C1tsVEt6.js +0 -1
- package/assets/index-CkSQAjeW.js +0 -1
- package/assets/index-D4T1SjUm.js +0 -1
- package/assets/index-DXAgIWNJ.js +0 -1
- package/assets/index-Dzjyi4Fo.js +0 -1
- package/assets/index-d0Cju6v4.js +0 -1
- package/assets/outbox-vqwjBkDe.js +0 -1
- package/assets/settings-DLcVyKfn.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as a,af as Xe,S as Ze,bh as es,l as G,bb as ss,m as oe,r as o,s as ae,bi as ne,q as ts,bj as as,bk as ns,bl as os,e as we,bm as rs}from"./index-RG6hjVja.js";import{s as Re,a as is,b as Te,u as ls,p as cs,R as ds}from"./useSearchTokenContext-DtAc62ht.js";import{a6 as ve,E as ye,a7 as us,a8 as ms,F as fs,a9 as Se,aa as hs,ab as gs,ac as xs,a5 as ps,ad as Is,ae as bs,af as vs,M as ys,ag as Ss,ah as Cs,ai as js,e as ws,v as Rs,aj as Ts,q as Ms,S as ks,I as Fs,N as Ce,L as As,J as Ns,d as Os,X as Bs,Y as Ds,_ as Me,$ as ke,a0 as Ls,a1 as Es,a2 as Ps}from"./MailListHeader-CHNpg6hW.js";import{u as qs,a as zs,R as Qs,i as Hs,b as _s}from"./useRefreshControl-BUJKeOlz.js";import{e as $s,c as Ws,R as Us}from"./search-token-index--lUeNQdC.js";import{a as Vs}from"./useLabels--yOYyuAO.js";import{u as Ys}from"./useMediaQuery-koJY7-su.js";import{u as Gs,L as Js}from"./useSemanticSearch-YPC2Eqfk.js";import{w as Ks}from"./wizard-selection-B1bng5Jq.js";import{o as Xs,f as Zs,h as et,p as st,r as tt}from"./useMessageBodyContent-B4CmbWQa.js";function at({sync:e}){return e?a.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:[a.jsx(Xe,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),a.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),a.jsx("p",{className:"text-xs text-fg-subtle",children:nt(e)})]}):a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[a.jsx(Ze,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),a.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),a.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function nt({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",ot={unclassified:"uncategorized"},$=e=>is(e).map(s=>s.raw),_=e=>e.join(" "),re=e=>{const s=Te(e);if(s)return Fe.find(n=>n.name===s.name&&n.value===s.value.toLowerCase())?.id},ie=e=>{const s=Te(e);if(!s||s.name!==Ae)return;const n=s.value.toLowerCase(),r=ot[n];if(r)return r;if(!(!es(n)||n==="all"))return n},Ne=e=>Fe.find(s=>s.id===e),Oe=e=>Ne(e)!==void 0,rt=e=>{const s=new Set;for(const n of $(e)){const r=re(n);r&&s.add(r)}return s},it=e=>{let s="all";for(const n of $(e)){const r=ie(n);r&&(s=r)}return s},lt=(e,s)=>{const n=Ne(s);if(!n)return;const r=$(e),d=r.filter(l=>re(l)!==s);return d.length<r.length?_(d):_([...r,Re(n.name,n.value)])},ct=(e,s)=>{const n=$(e).filter(r=>!ie(r));return _(s==="all"?n:[...n,Re(Ae,s)])},dt=e=>_($(e).filter(s=>!re(s)&&!ie(s))),Be=e=>e.trim().length>0,ut=e=>{if(!Be(e.query))return e.ownFilters;const s=new Set(rt(e.query));for(const n of e.ownFilters)Oe(n)||s.add(n);return s},mt=e=>Be(e.query)?it(e.query):e.ownCategory,ft=(e,s)=>e.createdAt!==s.createdAt?e.createdAt-s.createdAt:e.accountId.localeCompare(s.accountId),ht=e=>[...e].sort(ft),gt=200,je=()=>a.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,s)=>a.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[a.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsxs("div",{className:"flex justify-between gap-2",children:[a.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),a.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},s))}),xt=({accountEmail:e})=>{const s=oe();return a.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:[a.jsx(we,{className:"size-3.5 shrink-0"}),a.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),a.jsx("button",{type:"button",onClick:()=>s({to:"/settings/accounts"}),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},pt=(e,s)=>{if(s.size===0)return{};const n=new Set,r=new Set;for(const l of e)s.has(l.id)&&(l.accountId&&n.add(l.accountId),l.mailboxId&&r.add(l.mailboxId));if(n.size>1)return{restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"};const d=n.size===1?[...n][0]:void 0;return r.size>1?{accountId:d,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${r.size} folders`}:{accountId:d,mailboxId:r.size===1?[...r][0]:void 0}};function It({header:e,rows:s,wizard:n,children:r}){const{selectedIds:d,selectedCount:l,exitSelection:f,orderedIds:u,allSelected:h,toggleAllLoaded:y}=js(),x=o.useMemo(()=>pt(s,d),[s,d]),{junkMailboxId:p}=ws(x.accountId),{labels:I}=Vs(x.accountId),A=o.useMemo(()=>Array.from(d),[d]),L=o.useMemo(()=>Ks(s,d),[s,d]),m=Rs(p,x.mailboxId),b=o.useMemo(()=>u.length>0?{checked:h,indeterminate:l>0&&!h,onChange:y}:void 0,[u.length,h,l,y]),N=x.moveDisabledHint?{tone:"warning",text:x.moveDisabledHint}:void 0,S=C=>a.jsx(ks,{title:C.title,navSlot:C.navSlot,titleMeta:C.titleMeta,searchSlot:C.searchSlot,searchField:C.searchField,idleSlot:C.makeFilterSlot,count:l,onCancel:f,onDelete:()=>n.start("delete"),onMove:()=>n.start("move"),onOrganize:()=>n.start("organize"),onJunk:m?()=>n.start("junk"):void 0,onMarkRead:()=>n.start("markRead"),overflowSlot:x.accountId&&x.mailboxId&&l>0&&I.length>0?a.jsx(Js,{accountId:x.accountId,mailboxId:x.mailboxId,messageIds:A}):void 0,selectAll:b,notice:N});return a.jsx(Ts,{...e,selectionBar:S,paneOverlay:a.jsx(Ms,{verb:n.verb,accountId:x.accountId,mailboxId:x.mailboxId,selection:L,selectionRestriction:x.restriction,onFinished:f}),children:r})}function bt({accounts:e,selectedMessageId:s,onOpenThread:n,commandsRef:r,onTriageContextChange:d,onDeleteMessages:l}){const{searchQuery:f,searchInput:u,resultFolderIndex:h,onSearchChange:y}=G(),x=ls(),p=Ys(),I=$s(),A=ss(),L=oe(),m=o.useMemo(()=>ht(e.filter(t=>!t.muted?.value)),[e]),[b,N]=o.useState("all"),[S,C]=o.useState("all"),[W,E]=o.useState(new Set),[K,j]=o.useState(!1),P=o.useCallback(t=>{E(i=>{const c=new Set(i);return c.has(t)?c.delete(t):c.add(t),c})},[]),U=o.useCallback(()=>E(new Set),[]),R=u.trim().length>0,w=o.useMemo(()=>ut({query:u,ownFilters:W}),[u,W]),T=o.useMemo(()=>mt({query:u,ownCategory:S}),[u,S]),O=o.useCallback(t=>{if(!R||!Oe(t)){P(t);return}const i=lt(u,t);i!==void 0&&y(i)},[R,u,y,P]),q=o.useCallback(t=>{if(!R){C(t);return}y(ct(u,t))},[R,u,y]),z=o.useCallback(()=>{C("all"),N("all"),U(),R&&y(dt(u))},[R,u,y,U]),{data:B,isLoading:Q,isError:g,refetch:D}=ae({...ne(),staleTime:6e4}),M=Ws({queries:m.map(t=>({...ts({path:{accountId:t.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),V=o.useMemo(()=>{const t=new Map;for(let i=0;i<m.length;i++){const c=m[i].accountId,Ge=(M[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);t.set(c,Ge)}return t},[m,M]),Ee=o.useMemo(()=>m.filter((t,i)=>{const c=M[i];return c?.isError?!as(c.error):!1}),[m,M]),{freeText:k,tokens:X}=cs(f.trim().toLowerCase(),x),{data:le,isFetching:Pe}=ae({...ne({query:{query:k,limit:gt}}),enabled:k.length>0,staleTime:3e4}),v=o.useMemo(()=>{const t=ve(B?.items??[]).map(ye);return(k?us(t.filter(c=>ms(c,k)),ve(le?.items??[]).map(ye)):t).filter(c=>(b==="all"||c.accountId===b)&&fs(c,X))},[B,le,b,k,X]),{bodyRows:ce,briefSpamOffer:Z}=o.useMemo(()=>{if(!k)return{bodyRows:v,briefSpamOffer:void 0};const t=v.map(F=>Se(F,h)),{spam:i}=hs(t);if(i.length===0)return{bodyRows:v,briefSpamOffer:void 0};const c=new Set(i.map(F=>F.id));return{bodyRows:v.filter(F=>!c.has(F.id)),briefSpamOffer:gs(t)}},[v,k,h]),de=o.useMemo(()=>xs(ce),[ce]),ue=o.useCallback((t,i)=>{const c=v.find(F=>F.id===t)?.threadId;c&&n?.({threadId:c,messageId:t},i)},[v,n]),qe=o.useCallback(t=>{const i=t.threadId??v.find(c=>c.id===t.id)?.threadId;i&&n?.({threadId:i,messageId:t.id})},[v,n]),ee=o.useMemo(()=>m.length<=1?[]:[{id:"all",label:"All",active:b==="all"},...m.map(t=>({id:t.accountId,label:t.email.split("@")[0]??t.email,count:V.get(t.accountId),active:b===t.accountId}))],[m,V,b]),H=o.useMemo(()=>e.filter(t=>t.muted?.value).length,[e]),ze=o.useMemo(()=>Array.from(V.values()).reduce((t,i)=>t+i,0),[V]),se=o.useMemo(()=>m.map(t=>t.accountId),[m]),{hasNewMail:me}=qs(),{state:fe,errorMessage:he,refresh:ge}=zs(se,{onSettled:()=>D()}),Qe=o.useMemo(()=>a.jsx(Qs,{state:fe,onRefresh:ge,label:"Refresh daily brief",errorMessage:he,hasUpdate:me(se)}),[fe,ge,he,me,se]),te=o.useMemo(()=>v.filter(t=>(T==="all"||t.category===T)&&ns(t,w)).map(t=>Se(t,h)),[v,T,w,h]),{hits:xe,isLoading:He}=Gs(),_e=o.useMemo(()=>{const t=new Map;for(const c of B?.items??[])t.set(c.messageId,c.threadId);const i=te.map(c=>t.get(c.id)).filter(c=>c!=null);return ps(xe,i,h)},[xe,te,B,h]),$e=o.useMemo(()=>{const t=Is(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:T,activeFilters:w,expanded:K,onExpandedChange:j,onSelectCategory:i=>q(i),onSelectSource:N,onToggleFilter:i=>O(i),onClear:z}},[ee,H,T,w,K,O,q,z]),pe=de.length===0&&b==="all"&&k.length===0&&X.length===0,We=o.useMemo(()=>m.map(t=>t.accountId),[m]),Ue=o.useMemo(()=>m.some(t=>Hs(t.syncPhase)),[m]),Y=_s(We,pe||Ue),Ie=a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(je,{}),a.jsx(je,{})]}),be=!Q&&!g&&!pe,Ve=bs({tier:I,hasLiveInput:R,hasCommittedQuery:f.trim().length>0,bodyRendersCommittedResults:!0}),Ye=be?a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Z&&a.jsx(vs,{count:Z.count,onScopeToSpam:()=>L({to:"/mail/$mailboxId",params:{mailboxId:Z.mailboxId},search:{q:f||void 0}})}),a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(os,{sections:de,briefCategory:T,Row:ys,selectedThreadId:s,onSelectThread:ue,onSelectBriefCategory:q,sources:ee,sourcesNote:H>0?`+${H} muted`:void 0,onSelectSource:N,activeFilters:w,onToggleFilter:O,onClearFilters:z})})]}):Q?Ie:g?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[a.jsx(we,{className:"size-8 text-danger"}),a.jsx("p",{children:"Couldn't load your messages"}),a.jsxs("button",{type:"button",onClick:()=>D(),className:"flex items-center gap-1 text-accent underline text-xs",children:[a.jsx(Us,{className:"size-3.5"}),"Try again"]})]}):Y.resolved?a.jsx(at,{sync:Y.syncing?{synced:Y.synced,total:Y.total}:void 0}):Ie;return a.jsx(rs,{hasSheet:be&&!Ve,children:a.jsx(Ss,{selectedMessageId:s,rows:v,onOpen:ue,onDeleteMessages:l,onSelectionVerb:A.start,wizardOpen:A.isOpen,commandsRef:r,onTriageContextChange:d,children:a.jsx(It,{wizard:A,header:{title:"Daily brief",unreadCount:ze,footer:p?a.jsx(Cs,{}):void 0,searchFilter:$e,searchResults:te,searchLoading:Q||Pe,relatedResults:_e,relatedLoading:He,onSelectSearchResult:qe,searchResultsInBody:!0,refreshControl:Qe},rows:v,children:a.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(t=>a.jsx(xt,{accountEmail:t.email,accountId:t.accountId},t.accountId)),a.jsx("div",{className:"min-h-0 flex-1",children:Ye})]})})})})}const De=o.createContext(null);function J(){const e=o.useContext(De);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function vt({thread:e,children:s}){const n=oe(),r=Xs(),{searchInput:d}=G(),l=e?.threadId,f=e?.messageId,{data:u}=ae({...ne(),staleTime:6e4}),h=o.useMemo(()=>u?.items??[],[u]),y=o.useMemo(()=>{if(l)return h.find(g=>g.messageId===f)??h.find(g=>g.threadId===l)},[h,l,f]),x=Fs(l,f),p=y??x,I=f??p?.messageId,A=o.useMemo(()=>{if(l)return{threadId:l,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:I,authenticity:p?.authenticity}},[l,p,I]),L=o.useCallback((g,D)=>{n({to:"/mail/brief/$threadId/$messageId",params:g,replace:D?.replace,search:M=>({...M,q:d||void 0}),hash:r})},[n,r,d]),m=o.useCallback(()=>{n({to:"/mail/brief",search:g=>g,hash:r})},[n,r]),b=o.useCallback(g=>{I&&g.includes(I)&&m()},[I,m]),N=Ce({thread:p,onAfterOptimisticRemove:b}),S=As(),{deleteMessages:C}=Ns({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:b}),{toggleReadFor:W}=Os({mailboxId:p?.mailboxId??"",messages:h}),E=S.focusedMessageId,j=o.useMemo(()=>h.find(g=>g.messageId===E),[h,E])??p,P=Ce({thread:j}),U=Zs(),R=et(),w=st(),T=o.useMemo(()=>tt(w,l,I),[w,l,I]),O=o.useMemo(()=>{if(j)return g=>w({threadId:j.threadId,messageId:j.messageId,mode:g})},[w,j]),{nextMessageId:q,previousMessageId:z}=Bs({context:S,orderedIds:S.orderedIds,selectedMessageId:I,enabled:!U&&!R,onClose:m,handlers:{reply:()=>O?.("reply"),replyAll:()=>O?.("reply-all"),forward:()=>O?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||j&&W([j.messageId],!j.isRead)},goFlagged:()=>n({to:"/mail/flagged"}),goSettings:()=>n({to:"/settings"})}}),B=o.useCallback(g=>{if(!g)return;const D=h.find(M=>M.messageId===g);return D?{threadId:D.threadId,messageId:g}:void 0},[h]),Q={selectedMessageId:I,selectedThread:p,conversation:A,onOpenThread:L,onCloseThread:m,nextThread:B(q),previousThread:B(z),actions:N,onReply:T,triage:S,onDeleteMessages:C,handleDeselectIfRemoved:b};return a.jsx(De.Provider,{value:Q,children:s})}function Le(){const{selectedMessageId:e,onOpenThread:s,triage:n,onDeleteMessages:r}=J(),{accounts:d}=G();return a.jsx(bt,{accounts:d,selectedMessageId:e,onOpenThread:s,commandsRef:n.listCommandsRef,onTriageContextChange:n.onTriageContextChange,onDeleteMessages:r})}function yt(){const{conversation:e,selectedThread:s,actions:n,onReply:r,handleDeselectIfRemoved:d}=J(),l=!!e,f=Es(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(Ps,{hasThread:l,intelligenceOpen:f.isShowing,canToggleIntelligence:f.canToggle,onToggleIntelligence:f.toggle,onReply:r?()=>r("reply"):void 0,onReplyAll:r?()=>r("reply-all"):void 0,onForward:r?()=>r("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?a.jsx(Me,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:f.open}):a.jsx(ds,{})})]}),a.jsx(ke,{isOpen:f.drawerOpen,onClose:f.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:d})]})}function St(){const{selectedThread:e,handleDeselectIfRemoved:s}=J(),{onToggleIntelligence:n}=G();return a.jsx(Ls,{onClose:n,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function Ct(){const{selectedThread:e,conversation:s,onOpenThread:n,onCloseThread:r,nextThread:d,previousThread:l,handleDeselectIfRemoved:f}=J(),u=Ds(s?.threadId??null);return s?a.jsxs(a.Fragment,{children:[a.jsx(Me,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:r,onOpenIntelligence:u.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:l?()=>n(l):void 0,mobileIntelligenceOpen:u.isOpen}),a.jsx(ke,{isOpen:u.isOpen,onClose:u.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:f})]}):a.jsx("div",{className:"h-full",children:a.jsx(Le,{})})}const Bt=Object.assign(vt,{List:Le,Reading:yt,Intelligence:St,Phone:Ct});export{Bt as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,e as r}from"./index-
|
|
1
|
+
import{j as t,e as r}from"./index-RG6hjVja.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{d4 as U,r,cq as X,l as H,bb as Y,aF as Z,aG as ee,j as a,m as te}from"./index-RG6hjVja.js";import{u as se,p as ae,R as re}from"./useSearchTokenContext-DtAc62ht.js";import{E as oe,a8 as ne,F as de,au as ie,a9 as le,b as ce,M as ue,ag as ge,av as he,ai as me,q as fe,I as Ie,N as V,L as pe,J as xe,d as Te,X as ve,Y as ye,_ as K,$ as W,a0 as be,a1 as Re,a2 as Ce}from"./MailListHeader-CHNpg6hW.js";import{u as Se,b as we,a as je}from"./MailViewChrome-DMZMXGmb.js";import{f as Fe}from"./ErrorState-B7CjpNr1.js";import{u as Me}from"./useMediaQuery-koJY7-su.js";import{w as Pe}from"./wizard-selection-B1bng5Jq.js";import{o as Oe,f as ke,h as Le,p as Ae,r as Ne}from"./useMessageBodyContent-B4CmbWQa.js";const De=()=>X({query:{starred:!0,order:"desc"}});function _(){const{data:e,isLoading:s,isError:t,error:n,refetch:m,fetchNextPage:d,hasNextPage:l,isFetchingNextPage:c}=Se({queryKey:De(),queryFn:async({pageParam:I})=>{const{data:g}=await U({query:{starred:!0,order:"desc",continuationToken:I},throwOnError:!0});return g},initialPageParam:void 0,getNextPageParam:I=>I.continuationToken,staleTime:6e4});return{threads:r.useMemo(()=>(e?.pages??[]).flatMap(I=>I.items??[]),[e]),isLoading:s,isError:t,error:n,refetch:m,fetchNextPage:d,hasNextPage:l,isFetchingNextPage:c}}const Ee=e=>{const s=new Set;return e.filter(t=>s.has(t.threadId)?!1:(s.add(t.threadId),!0))},qe={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0};function Be({rows:e,verb:s}){const{selectedIds:t,exitSelection:n}=me(),m=r.useMemo(()=>Pe(e,t),[e,t]);return a.jsx(fe,{verb:s,selection:m,selectionRestriction:"spansAccounts",onFinished:n})}function ze({selectedMessageId:e,onOpenThread:s,commandsRef:t,onTriageContextChange:n,onDeleteMessages:m}){const{searchQuery:d,resultFolderIndex:l}=H(),c=se(),M=Me(),I=Y(),[g,f]=r.useState("all"),[R,P]=r.useState(new Set),y=r.useCallback(o=>{P(h=>{const p=new Set(h);return p.has(o)?p.delete(o):p.add(o),p})},[]),C=r.useCallback(()=>{f("all"),P(new Set)},[]),{threads:O,isLoading:T,isError:k,error:q,refetch:L,fetchNextPage:Q,hasNextPage:x,isFetchingNextPage:S}=_(),{freeText:b,tokens:A}=ae(d.trim().toLowerCase(),c),u=r.useMemo(()=>{const o=Array.from(R).map(h=>qe[h]).filter(h=>h!=null);return Ee(O).map(oe).filter(h=>(g==="all"||h.category===g)&&o.every(p=>p(h))&&(!b||ne(h,b))&&de(h,A))},[O,g,R,b,A]),w=r.useCallback((o,h)=>{const p=u.find(J=>J.id===o)?.threadId;p&&s?.({threadId:p,messageId:o},h)},[u,s]),j=r.useCallback(o=>{const h=o.threadId??u.find(p=>p.id===o.id)?.threadId;h&&s?.({threadId:h,messageId:o.id})},[u,s]),B=r.useMemo(()=>ie(),[]),z=r.useMemo(()=>u.map(o=>le(o,l)),[u,l]),N=r.useMemo(()=>u.filter(o=>!o.isRead).length,[u]),D=T?"loading":k?"error":u.length===0?"empty":"ready",i=r.useCallback(()=>{const o=Z(ee());window.open(o,"_blank","noopener,noreferrer")},[]),v=ce(),F=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:u.map(o=>a.jsx(ue,{thread:o,active:o.id===e,onClick:()=>w(o.id)},o.id))}),x?a.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>Q(),disabled:S,children:S?"Loading…":"Load more"}):null]})});return a.jsx(we,{title:"Starred",unreadCount:N,preset:B,selectedCategory:g,activeFilters:R,onSelectCategory:f,onToggleFilter:y,onClearFilters:C,searchResults:z,searchLoading:T,onSelectSearchResult:j,searchResultsInBody:!0,children:a.jsxs(ge,{selectedMessageId:e,rows:u,onOpen:w,onDeleteMessages:m,onSelectionVerb:I.start,wizardOpen:I.isOpen,commandsRef:t,onTriageContextChange:n,children:[a.jsx(je,{listTitle:"Starred",sections:[{id:"flagged",threads:u}],flatList:!0,hideHeader:!0,listState:v.searchResults?"ready":D,searchQuery:b?d:void 0,errorMessage:k?Fe(q):void 0,onRetry:()=>L(),onReportError:i,selectedThreadId:e,onSelectThread:w,isDesktop:M,selectionBar:a.jsx(he,{title:"Starred"}),listBody:v.searchResults??(D==="ready"?F:void 0)}),a.jsx(Be,{rows:u,verb:I.verb})]})})}const $=r.createContext(null);function E(){const e=r.useContext($);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function He({thread:e,children:s}){const t=te(),n=Oe(),{searchInput:m}=H(),d=e?.threadId,l=e?.messageId,{threads:c}=_(),M=r.useMemo(()=>{if(d)return c.find(i=>i.messageId===l)??c.find(i=>i.threadId===d)},[c,d,l]),I=Ie(d,l),g=M??I,f=l??g?.messageId,R=r.useMemo(()=>{if(d)return{threadId:d,mailboxId:g?.mailboxId??"",subject:g?.subject,messageId:f,authenticity:g?.authenticity}},[d,g,f]),P=r.useCallback((i,v)=>{t({to:"/mail/flagged/$threadId/$messageId",params:i,replace:v?.replace,search:F=>({...F,q:m||void 0}),hash:n})},[t,n,m]),y=r.useCallback(()=>{t({to:"/mail/flagged",search:i=>i,hash:n})},[t,n]),C=r.useCallback(i=>{f&&i.includes(f)&&y()},[f,y]),O=V({thread:g,onAfterOptimisticRemove:C}),T=pe(),{deleteMessages:k}=xe({mailboxId:g?.mailboxId??"",messages:c,onAfterOptimisticRemove:C}),{toggleReadFor:q}=Te({mailboxId:g?.mailboxId??"",messages:c}),L=T.focusedMessageId,x=r.useMemo(()=>c.find(i=>i.messageId===L),[c,L])??g,S=V({thread:x}),b=ke(),A=Le(),u=Ae(),w=r.useMemo(()=>Ne(u,d,f),[u,d,f]),j=r.useMemo(()=>{if(x)return i=>u({threadId:x.threadId,messageId:x.messageId,mode:i})},[u,x]),{nextMessageId:B,previousMessageId:z}=ve({context:T,orderedIds:T.orderedIds,selectedMessageId:f,enabled:!b&&!A,onClose:y,handlers:{reply:()=>j?.("reply"),replyAll:()=>j?.("reply-all"),forward:()=>j?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||S.deleteThread()},toggleStar:S.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||x&&q([x.messageId],!x.isRead)},goBrief:()=>t({to:"/mail/brief"}),goSettings:()=>t({to:"/settings"})}}),N=r.useCallback(i=>{if(!i)return;const v=c.find(F=>F.messageId===i);return v?{threadId:v.threadId,messageId:i}:void 0},[c]),D={selectedMessageId:f,selectedThread:g,conversation:R,onOpenThread:P,onCloseThread:y,nextThread:N(B),previousThread:N(z),actions:O,onReply:w,triage:T,onDeleteMessages:k,handleDeselectIfRemoved:C};return a.jsx($.Provider,{value:D,children:s})}function G(){const{selectedMessageId:e,onOpenThread:s,triage:t,onDeleteMessages:n}=E();return a.jsx(ze,{selectedMessageId:e,onOpenThread:s,commandsRef:t.listCommandsRef,onTriageContextChange:t.onTriageContextChange,onDeleteMessages:n})}function Qe(){const{conversation:e,selectedThread:s,actions:t,onReply:n,handleDeselectIfRemoved:m}=E(),d=!!e,l=Re(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(Ce,{hasThread:d,intelligenceOpen:l.isShowing,canToggleIntelligence:l.canToggle,onToggleIntelligence:l.toggle,onReply:n?()=>n("reply"):void 0,onReplyAll:n?()=>n("reply-all"):void 0,onForward:n?()=>n("forward"):void 0,onDelete:d?t.deleteThread:void 0,onToggleStar:d?t.toggleStar:void 0,isStarred:t.isStarred,moveContext:d&&t.accountId&&t.mailboxId?{accountId:t.accountId,currentMailboxId:t.mailboxId,onMove:t.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:l.open}):a.jsx(re,{})})]}),a.jsx(W,{isOpen:l.drawerOpen,onClose:l.closeDrawer,thread:s,mailboxId:s?.mailboxId,accountId:s?.accountId,onAfterOptimisticRemove:m})]})}function Ve(){const{selectedThread:e,handleDeselectIfRemoved:s}=E(),{onToggleIntelligence:t}=H();return a.jsx(be,{onClose:t,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:s})}function Ke(){const{selectedThread:e,conversation:s,onCloseThread:t,onOpenThread:n,nextThread:m,previousThread:d,handleDeselectIfRemoved:l}=E(),c=ye(s?.threadId??null);return s?a.jsxs(a.Fragment,{children:[a.jsx(K,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:t,onOpenIntelligence:c.toggle,onSwipeNext:m?()=>n(m):void 0,onSwipePrevious:d?()=>n(d):void 0,mobileIntelligenceOpen:c.isOpen}),a.jsx(W,{isOpen:c.isOpen,onClose:c.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:l})]}):a.jsx("div",{className:"h-full",children:a.jsx(G,{})})}const Ze=Object.assign(He,{List:G,Reading:Qe,Intelligence:Ve,Phone:Ke});export{Ze as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,s as f,Q as m,j as e,X as N}from"./index-
|
|
1
|
+
import{r as n,s as f,Q as m,j as e,X as N}from"./index-RG6hjVja.js";import{E as u}from"./ErrorState-B7CjpNr1.js";import{D as r,C as x,u as k}from"./index-fTBVdymx.js";import{u as w}from"./useMediaQuery-koJY7-su.js";import{k as p,s as h,t as C}from"./useMessageBodyContent-B4CmbWQa.js";import{C as E}from"./confirm-dialog-D8xOy16a.js";const b=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=p(),i=h(),s=C(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=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:b(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(E,{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:v})]})},q=()=>{const t=p(),i=h(),s=C(),a=w(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({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:b(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(N,{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{q as F};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a4 as ys,ca as yr,r as l,c as de,j as a,C as ut,d as On,B as W,X as Lt,at as Ie,cb as zn,b as _,a as Ye,S as We,aT as kr,cc as jr,ag as Pt,T as Dt,cd as _n,a_ as ks,ce as wr,cf as Un,an as Cr,af as Kn,e as Sr,cg as Nr,as as Bn,ch as Tr,ci as Ir,cj as Er,ck as Mr,cl as Rr,cm as Ar,cn as $r,co as Lr,G as Pr,s as ee,Q as gt,q as bt,cp as Ft,z as Qn,bf as qn,cq as Hn,n as ie,a5 as ge,a7 as pe,K as Xe,bn as Me,cr as Ot,c1 as Dr,cs as Re,ct as Fr,cu as Or,cv as zr,cw as _r,cx as Ur,bN as Kr,cy as Br,p as Qr,aU as qr,m as Gn,aF as Hr,aG as Gr,bU as Vr,k as Vn,bT as Wr,cz as Yr,cA as Xr,cB as Wn,b6 as js,bs as Jr,bj as Gs,cC as Zr,cD as eo,b5 as to,N as so,W as no,D as ao,bg as Vs,aY as ro,cE as oo,cF as io,a8 as Ws,be as lo,cG as co,cH as uo,l as zt,cI as fo,cJ as mo,cK as Ys,cL as po,cM as ho,cN as go,i as Yn,cO as ws,cP as bo,bV as xo,cQ as vo,cR as Xs,g as yo,bW as ko}from"./index-RG6hjVja.js";import{B as jo,l as wo,m as Co,S as Xn,c as Cs,f as So,D as No,b as Nt,a as To,t as it,g as Io,n as Eo,o as Mo,e as Ro,u as Ao,i as $o}from"./search-token-index--lUeNQdC.js";import{K as Lo}from"./kbd-J48_YAed.js";import{P as Jn,f as Po,U as Do,E as Fo,s as Oo}from"./attachment-file-BBxRM9lo.js";import{M as zo}from"./mail-D4IROUAs.js";import{A as ft}from"./avatar-CL1i6pSF.js";import{M as _o,c as Uo,d as Zn,e as Ko,f as ea,g as ta,a as Bo,b as Qo,S as Js,s as sa,u as na,p as qo,r as Ho}from"./useSearchTokenContext-DtAc62ht.js";import{v as Go,w as Vo,o as Wo,x as Yo,y as Xo,p as Jo,N as aa,b as Zo}from"./useMessageBodyContent-B4CmbWQa.js";import{C as ei,D as qe,u as ti}from"./index-fTBVdymx.js";import{E as Oe}from"./ErrorState-B7CjpNr1.js";import{u as Ss}from"./useMediaQuery-koJY7-su.js";import{d as ra,b as Je,a as si,e as ni,c as ze,g as ai}from"./format-D7umvejg.js";import{P as Zs,C as ri,D as es,M as ye}from"./enums-B_igRgfI.js";import{D as oi}from"./download-BOHIxI00.js";import{S as ii}from"./shield-check-VW8L3t2E.js";import{u as oa}from"./useDebouncedValue-CIzVPWhk.js";import{a as ia,u as la,b as ca,f as da}from"./move-options-izqmkqX6.js";import{h as en,u as li,a as ci,i as di,n as ui,o as fi,j as mi,k as pi,S as hi}from"./useFilters-C1t-twQv.js";import{C as Tt}from"./confirm-dialog-D8xOy16a.js";import{C as gi}from"./clock-DI632I1n.js";import{r as bi,b as xi}from"./search-scope-Bw1jfRMO.js";import{M as vi}from"./menu-jalQ9e9M.js";function mt(e){if(yi())e.focus({preventScroll:!0});else{let t=ki(e);e.focus(),ji(t)}}let It=null;function yi(){if(It==null){It=!1;try{document.createElement("div").focus({get preventScroll(){return It=!0,!0}})}catch{}}return It}function ki(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 ji(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 wi(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Ci(e){return wi(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Si=!1;function ua(){return Si}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:Ci(s)?s=s.host:s=s.parentNode}return!1}function Z(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 Ni=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Ti(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 Ii(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 Ni?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Ti(e)&&Ii(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"],Ei=ma.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ma.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function Mi(e,t){return e.matches(Ei)&&!Ri(e)&&(t?.skipVisibilityCheck||fa(e))}function Ri(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"?ys.useLayoutEffect:()=>{};function Ai(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function $i(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Li(e){for(;e&&!Mi(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ee(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=m=>{(Z(m)===s||n)&&m.stopImmediatePropagation()},o=m=>{(Z(m)===s||n)&&(m.stopImmediatePropagation(),!e&&!n&&(n=!0,mt(s),d()))},i=m=>{(Z(m)===e||n)&&m.stopImmediatePropagation()},c=m=>{(Z(m)===e||n)&&(m.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(v),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},v=requestAnimationFrame(d);return d}function _t(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 Rt=Ae(function(){return Ts(/^Mac/i)}),Pi=Ae(function(){return Ts(/^iPhone/i)}),pa=Ae(function(){return Ts(/^iPad/i)||Rt()&&navigator.maxTouchPoints>1}),ha=Ae(function(){return Pi()||pa()}),Di=Ae(function(){return _t(/AppleWebKit/i)&&!Fi()}),Fi=Ae(function(){return _t(/Chrome/i)}),ga=Ae(function(){return _t(/Android/i)}),Oi=Ae(function(){return _t(/Firefox/i)});function zi(e){return e.pointerType===""&&e.isTrusted?!0:ga()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function _i(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;Oi()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(Rt()?n=!0:r=!0);let c=Di()&&Rt()&&!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=Z(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=Z(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 Ui(){for(const[e]of Ne)"isConnected"in e&&!e.isConnected&&Ne.delete(e)}function Ki(e){requestAnimationFrame(()=>{Ui(),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 Bi(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=Bi(o,i):r==="ref"&&o&&i?t.ref=Qi(o,i):t[r]=i!==void 0?i:o}}return t}function qi(e,t){Ns(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Hi=ys.useInsertionEffect??Ns;function ts(e){const t=l.useRef(null);return Hi(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let Ge="default",fs="",Mt=new WeakMap;function Gi(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";Mt.set(e,e.style[t]),e.style[t]="none"}}function nn(e){if(ha()){if(Ge!=="disabled")return;Ge="restoring",setTimeout(()=>{Ki(()=>{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&&Mt.has(e)){let t=Mt.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Mt.delete(e)}}function an(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let ss=new WeakMap;function Vi(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=ys.createContext({register:()=>{}});xa.displayName="PressResponderContext";function va(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let d=c?.once?(...v)=>{e.current.delete(i),i(...v)}: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 Wi(e){let t=l.useContext(xa);if(t){let{register:s,ref:n,...r}=t;e=xt(r,e),s()}return qi(t,e.ref),e}class Et{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,d=0,v,m=null;n.clientX!=null&&n.clientY!=null&&(v=n.clientX,m=n.clientY),i&&(v!=null&&m!=null?(c=v-i.left,d=m-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 Yi(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:d,preventFocusOnPress:v,shouldCancelOnPointerExit:m,allowTextSelectionOnPress:g,ref:p,...b}=Wi(e),[h,u]=l.useState(!1),f=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:C}=va(),y=l.useCallback((k,R)=>{let A=f.current;if(c||A.didFirePressStart)return!1;let S=!0;if(A.isTriggeringEvent=!0,n){let I=new Et("pressstart",R,k);n(I),S=I.shouldStopPropagation}return s&&s(!0),A.isTriggeringEvent=!1,A.didFirePressStart=!0,u(!0),S},[c,n,s]),j=l.useCallback((k,R,A=!0)=>{let S=f.current;if(!S.didFirePressStart)return!1;S.didFirePressStart=!1,S.isTriggeringEvent=!0;let I=!0;if(r){let w=new Et("pressend",R,k);r(w),I=w.shouldStopPropagation}if(s&&s(!1),u(!1),t&&A&&!c){let w=new Et("press",R,k);t(w),I&&=w.shouldStopPropagation}return S.isTriggeringEvent=!1,I},[c,r,s,t]),T=ts(j),M=l.useCallback((k,R)=>{let A=f.current;if(c)return!1;if(o){A.isTriggeringEvent=!0;let S=new Et("pressup",R,k);return o(S),A.isTriggeringEvent=!1,S.shouldStopPropagation}return!0},[c,o]),P=ts(M),E=l.useCallback(k=>{let R=f.current;if(R.isPressed&&R.target){R.didFirePressStart&&R.pointerType!=null&&j(De(R.target,k),R.pointerType,!1),R.isPressed=!1,R.isOverTarget=!1,R.activePointerId=null,R.pointerType=null,C(),g||nn(R.target);for(let A of R.disposables)A();R.disposables=[]}},[g,C,j]),D=ts(E);l.useEffect(()=>{c&&f.current.isPressed&&D({currentTarget:f.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let F=l.useCallback(k=>{m&&E(k)},[m,E]),z=l.useCallback(k=>{c||i?.(k)},[c,i]),O=l.useCallback((k,R)=>{if(!c&&i){let A=new MouseEvent("click",k);$i(A,R),i(Ai(A))}},[c,i]),B=l.useMemo(()=>{let k=f.current,R={onKeyDown(S){if(ns(S.nativeEvent,S.currentTarget)&&he(S.currentTarget,Z(S))){cn(Z(S),S.key)&&S.preventDefault();let I=!0;!k.isPressed&&!S.repeat&&(k.target=S.currentTarget,k.isPressed=!0,k.pointerType="keyboard",I=y(S,"keyboard"));let w=S.currentTarget,L=U=>{ns(U,w)&&!U.repeat&&he(w,Z(U))&&k.target&&P(De(k.target,U),"keyboard")};x(Te(S.currentTarget),"keyup",ba(L,A),!0),I&&S.stopPropagation(),S.metaKey&&Rt()&&k.metaKeyEvents?.set(S.key,S.nativeEvent)}else S.key==="Meta"&&(k.metaKeyEvents=new Map)},onClick(S){if(!(S&&!he(S.currentTarget,Z(S)))&&S&&S.button===0&&!k.isTriggeringEvent&&!pt.isOpening){let I=!0;if(c&&S.preventDefault(),!k.ignoreEmulatedMouseEvents&&!k.isPressed&&(k.pointerType==="virtual"||zi(S.nativeEvent))){let w=y(S,"virtual"),L=P(S,"virtual"),U=T(S,"virtual");z(S),I=w&&L&&U}else if(k.isPressed&&k.pointerType!=="keyboard"){let w=k.pointerType||S.nativeEvent.pointerType||"virtual",L=P(De(S.currentTarget,S),w),U=T(De(S.currentTarget,S),w,!0);I=L&&U,k.isOverTarget=!1,z(S),D(S)}k.ignoreEmulatedMouseEvents=!1,I&&S.stopPropagation()}}},A=S=>{if(k.isPressed&&k.target&&ns(S,k.target)){cn(Z(S),S.key)&&S.preventDefault();let I=Z(S),w=he(k.target,I);T(De(k.target,S),"keyboard",w),w&&O(S,k.target),C(),S.key!=="Enter"&&Is(k.target)&&he(k.target,I)&&!S[rn]&&(S[rn]=!0,pt(k.target,S,!1)),k.isPressed=!1,k.metaKeyEvents?.delete(S.key)}else if(S.key==="Meta"&&k.metaKeyEvents?.size){let I=k.metaKeyEvents;k.metaKeyEvents=void 0;for(let w of I.values())k.target?.dispatchEvent(new KeyboardEvent("keyup",w))}};if(typeof PointerEvent<"u"){R.onPointerDown=w=>{if(w.button!==0||!he(w.currentTarget,Z(w)))return;if(_i(w.nativeEvent)){k.pointerType="virtual";return}k.pointerType=w.pointerType;let L=!0;if(!k.isPressed){k.isPressed=!0,k.isOverTarget=!0,k.activePointerId=w.pointerId,k.target=w.currentTarget,g||Gi(k.target),L=y(w,k.pointerType);let U=Z(w);"releasePointerCapture"in U&&("hasPointerCapture"in U?U.hasPointerCapture(w.pointerId)&&U.releasePointerCapture(w.pointerId):U.releasePointerCapture(w.pointerId)),x(Te(w.currentTarget),"pointerup",S,!1),x(Te(w.currentTarget),"pointercancel",I,!1)}L&&w.stopPropagation()},R.onMouseDown=w=>{if(he(w.currentTarget,Z(w))&&w.button===0){if(v){let L=Li(w.target);L&&k.disposables.push(L)}w.stopPropagation()}},R.onPointerUp=w=>{!he(w.currentTarget,Z(w))||k.pointerType==="virtual"||w.button===0&&!k.isPressed&&P(w,k.pointerType||w.pointerType)},R.onPointerEnter=w=>{w.pointerId===k.activePointerId&&k.target&&!k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!0,y(De(k.target,w),k.pointerType))},R.onPointerLeave=w=>{w.pointerId===k.activePointerId&&k.target&&k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!1,T(De(k.target,w),k.pointerType,!1),F(w))};let S=w=>{if(w.pointerId===k.activePointerId&&k.isPressed&&w.button===0&&k.target){if(he(k.target,Z(w))&&k.pointerType!=null){let L=!1,U=setTimeout(()=>{k.isPressed&&k.target instanceof HTMLElement&&(L?D(w):(mt(k.target),k.target.click()))},80);x(w.currentTarget,"click",()=>L=!0,!0),k.disposables.push(()=>clearTimeout(U))}else D(w);k.isOverTarget=!1}},I=w=>{D(w)};R.onDragStart=w=>{he(w.currentTarget,Z(w))&&D(w)}}return R},[x,c,v,C,g,F,y,z,O]);return l.useEffect(()=>{if(!p)return;const k=Te(p.current);if(!k||!k.head||k.getElementById(on))return;const R=k.createElement("style");R.id=on;let A=Vi(k);A&&(R.nonce=A),R.textContent=`
|
|
2
|
+
@layer {
|
|
3
|
+
[${ln}] {
|
|
4
|
+
touch-action: pan-x pan-y pinch-zoom;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
`.trim(),k.head.prepend(R)},[p]),l.useEffect(()=>{let k=f.current;return()=>{g||nn(k.target??void 0);for(let R of k.disposables)R();k.disposables=[]}},[g]),{isPressed:d||h,pressProps:xt(b,B,{[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&&!ya(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?!ya(e,t):Xi(e)}const Ji=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function ya(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":Ji.has(e.type)}let Zi=0;const as=new Map;function el(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-${Zi++}`;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 tl=500;function sl(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=tl,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:d,removeGlobalListener:v}=va(),{pressProps:m}=Yi({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 b=u=>{u.preventDefault()},h=Ee(p.target);d(p.target,"contextmenu",b,{once:!0}),d(h,"pointerup",()=>{setTimeout(()=>{v(p.target,"contextmenu",b)},30)},{once:!0})}},onPressEnd(p){c.current&&clearTimeout(c.current),n&&(p.pointerType==="mouse"||p.pointerType==="touch")&&n({...p,type:"longpressend"})}}),g=el(r&&!t?i:void 0);return{longPressProps:xt(m,g)}}const Ut=de("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=de("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const ja=de("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 nl=de("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=de("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 al=de("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 rl=de("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Kt=de("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=de("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=de("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=de("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 ol=de("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 il=de("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"}]]),ll=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Ut,{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]})},cl=({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(ll,{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"})})]})},dl={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:_("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 ul({sender:e}){const t=dl[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 fl({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(ii,{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(ol,{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(W,{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:_("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 ml={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:v=!1}){const{sender:m,authenticity:g,category:p,flags:b={},similar:h}=e;return a.jsxs("aside",{className:_("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(W,{variant:"ghost",size:"sm",icon:a.jsx(Lt,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(He,{label:"Sender",children:a.jsx(ul,{sender:m})}),a.jsx(He,{label:"Authenticity",children:a.jsx(fl,{auth:g,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:_("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:b.vip,onClick:n?.onToggleVip}),a.jsx(lt,{icon:a.jsx(jo,{className:"size-3.5"}),label:"Mute",active:b.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(lt,{icon:a.jsx(nl,{className:"size-3.5"}),label:v?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:v}),n?.onReportSpam&&a.jsx(lt,{icon:a.jsx(il,{className:"size-3.5"}),label:d?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:d}),a.jsx(lt,{icon:a.jsx(al,{className:"size-3.5"}),label:"Unsubscribe",active:b.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"||h.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,f)=>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"})]},f))}):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:h.map(u=>{const f="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",x=`Open message from ${u.fromName||"unknown sender"}: ${u.subject}`,C=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:ml[u.matched]})]});return a.jsx("li",{children:o?o({mailboxId:u.mailboxId,threadId:u.threadId,messageId:u.id,className:f,ariaLabel:x,children:C}):a.jsx("div",{className:f,children:C})},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,pl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",hl=(e,t)=>!t&&e>0,gl=(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)},bl=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,xl=(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]},yl=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(f=>{const x=new Set(f);return x.has(u)?x.delete(u):x.add(u),x})},[]),c=l.useCallback(u=>{r(u),s(f=>{if(f.has(u))return f;const x=new Set(f);return x.add(u),x})},[]),d=l.useCallback(u=>{s(f=>{if(!f.has(u))return f;const x=new Set(f);return x.delete(u),x})},[]),v=l.useCallback(u=>{s(new Set(u))},[]),m=l.useCallback(()=>{r(void 0),s(new Set)},[]),g=l.useCallback(u=>{s(f=>u.every(C=>f.has(C))?new Set:new Set(u))},[]),p=l.useCallback(u=>{r(u)},[]),b=l.useCallback(u=>{s(f=>{if(f.size===0)return f;const x=xl(f,u);return x.size===f.size?f:x})},[]),h=l.useCallback((u,f,x)=>{const C=bl(u,n,x,f);s(y=>{const j=gl(u,C,f);if(j.length===0)return y;const T=new Set(y);for(const M of j)T.add(M);return T}),r(C)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:d,selectAll:v,clearSelection:m,toggleAll:g,selectRange:h,setAnchor:p,anchorId:n,intersectWith:b}};function Kf({hints:e=wo,className:t}){return e.length===0?null:a.jsx("footer",{className:_("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(kl,{hint:s},s.label))})}function kl({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(Lo,{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})=>_("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})=>_("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:_("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:_(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(Kt,{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 jl({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:_("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:_("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(Kt,{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(kr,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function wl({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:_("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:_("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(Pt,{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(wl,{thread:e,selection:t}),a.jsx(jl,{thread:e,badge:s,highlightQuery:n})]})}const Ea=e=>({...jr,[Co]:"","data-message-id":e.id});function Bf({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 Qf({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:_("group",Ms({active:t,focused:s})),children:a.jsx(Rs,{thread:e,selection:r})})}let Ve;const Cl=5e3;function Ma(e){e.preventDefault(),At()}function At(){Ve!==void 0&&(clearTimeout(Ve),Ve=void 0,document.removeEventListener("contextmenu",Ma,!0),document.removeEventListener("pointerup",At,!0))}function Sl(){Ve===void 0?(document.addEventListener("contextmenu",Ma,!0),document.addEventListener("pointerup",At,!0)):clearTimeout(Ve),Ve=setTimeout(At,Cl)}function Nl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=sl({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||Sl()},[]);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:v,overflowItems:m=[],onUnavailable:g,unavailableHint:p,className:b}){const h=(f,x)=>()=>{if(!e){g?.(f);return}x?.()},u=d?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(zo,{className:"size-4"}):a.jsx(Es,{className:"size-4"}),onSelect:h("toggleRead",d)}]:[];return a.jsxs("div",{className:_("relative",b),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-5"}),onClick:h("reply",t),"aria-label":"Reply",title:"Reply",className:ct}),s&&a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-5"}),onClick:h("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:ct}),n&&a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(ja,{className:"size-5"}),onClick:h("forward",n),"aria-label":"Forward",title:"Forward",className:ct}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:_("size-5",r&&"fill-warning text-warning")}),onClick:h("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:ct}),v,i&&a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Dt,{className:"size-5"}),onClick:h("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:ct}),a.jsx(Jn,{triggerLabel:"More actions",items:[...u,...m]})]}),!e&&p&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:p})]})}function Tl({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(W,{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:_(e&&"bg-accent-2-soft text-accent-2",n)})}function Il({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:v,moveSlot:m,onMove:g,replyTitle:p="Reply (r)",replyAllTitle:b="Reply all (a)",forwardTitle:h="Forward (f)",deleteTitle:u="Move to Trash (#)",flagTitle:f="Star (s)",children:x,className:C}){const y=(j,T)=>()=>{if(!e||!T){t?.(j);return}T()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:_("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",C),children:[a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Ca,{className:"size-4"}),title:p,"aria-label":"Reply",onClick:y("reply",o)}),a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(wa,{className:"size-4"}),title:b,"aria-label":"Reply all",onClick:y("replyAll",i)}),a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(ja,{className:"size-4"}),title:h,"aria-label":"Forward",onClick:y("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(W,{variant:"ghost",size:"sm",icon:a.jsx(Dt,{className:"size-4"}),title:u,"aria-label":"Move to Trash",onClick:y("delete",d)}),m??a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(ks,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:y("move",g)}),a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:_("size-4",n&&"fill-warning text-warning")}),title:f,"aria-label":"Star",onClick:y("flag",v)})]}),a.jsx("div",{className:"flex-1"}),x]}),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:_("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=_("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=>{wr(c)&&(c.preventDefault(),t())},className:_(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:v,body:m}){const g=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:_("-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:g}):g,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?"})]})]}),v&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:v}),a.jsx(_o,{children:m??a.jsx(Uo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function El({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[d,v]=l.useState(!1),m=r!==void 0,g=m?n??!1:d,p=!!s||m,b=()=>{if(m){r?.();return}v(u=>!u)},h=()=>{if(m){g&&r?.();return}v(!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(W,{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(W,{variant:"ghost",size:"sm",icon:a.jsx(_n,{className:"size-4"}),onClick:b,"aria-label":g?"Hide intelligence panel":"Show intelligence panel","aria-pressed":g,title:"Intelligence",className:_("shrink-0",g&&"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 f=x=>x?()=>x(u.id):void 0;return u.expanded?a.jsx($a,{message:u,warning:e.warning,onHeaderClick:f(o?.onToggleExpand),actionBar:a.jsx(Ra,{hasThread:!0,onReply:f(o?.onReply),onReplyAll:f(o?.onReplyAll),onForward:f(o?.onForward),onToggleStar:f(o?.onToggleStar),onDelete:f(o?.onDelete),onToggleRead:f(o?.onToggleRead),moveSlot:o?.moveSlot?.(u.id)})},u.id):a.jsx(Aa,{message:u,onClick:f(o?.onToggleExpand)},u.id)})}),s&&!m&&a.jsx(Cr,{open:g,onClose:h,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(Sa,{data:s,onClose:h,className:"h-full w-full border-l-0"})})]})}function Ml({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(Sr,{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 Rl({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:_("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(Kt,{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," ·"," ",Po(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(Ml,{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 Al({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Ie,{tone:"accent",className:_("py-1 text-xs",r),children:[a.jsx(Do,{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 $l="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 Ll({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:$l,...i}),a.jsx(Pt,{className:_(fn,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(rl,{className:_(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:_("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 Pl(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 Dl({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?Nr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:_("group",Ms({}),"border-b border-line"),children:a.jsx(Rs,{thread:Pl(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 Fl=e=>e===1?"result":"results";function Ol({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})," ",`${Fl(e)} from Spam`]}),a.jsx(W,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const mn=6,zl={kind:"global"},_l=e=>e.kind==="folder"&&e.role==="junk",Ul=e=>e.folder?.role==="junk";function La(e){const t=[],s=[];for(const n of e)Ul(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:_("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(Tr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(Ir,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function Kl({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,m=!i&&d?e.results.slice(0,mn):e.results,g=e.results.length-m.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:_("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[m.map(p=>a.jsx(Dl,{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 ${g} 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=zl,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(j=>a.jsxs("button",{type:"button",onClick:()=>s?.(j),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(gi,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:j})]},j))]}):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 m=i&&i.length>0&&a.jsx(Er,{tokens:i}),g=d&&a.jsx(Pa,{...d});if(r)return a.jsxs("div",{className:"flex flex-col",children:[g,m,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(j=>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"})]},j))})]});const p=c.kind==="global",b=_l(c)||c.kind==="collection",h=p||c.kind==="collection",u=(n??[]).map(j=>{if(b)return{section:j,spam:[]};const{kept:T,spam:M}=La(j.results);return{section:{...j,results:T},spam:M}}),f=u.map(j=>j.section),x=u.reduce((j,T)=>j+T.spam.length,0),C=c.kind==="global"&&x>0&&c.onScopeToSpam!==void 0?a.jsx(Ol,{count:x,onScopeToSpam:c.onScopeToSpam}):void 0;return f.some(j=>j.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[g,m,C,f.filter(j=>j.results.length>0).map(j=>a.jsx(Kl,{section:j,query:e,showFolder:h,onSelectResult:o},j.id))]}):a.jsxs("div",{className:"flex flex-col",children:[g,m,C,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 Bl({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:v,tokens:m,chips:g,onRemoveChip:p,scope:b,makeFilter:h,suggest:u,suggestList:f}){const x=a.jsx(Da,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:d,onSelectResult:v,tokens:m,scope:b,makeFilter:h});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(Xn,{value:e,onChange:t,onClear:s,chips:g,onRemoveChip:p,globalFocusKey:!1,showClearButton:!1,suggest:u})}),a.jsx(W,{variant:"ghost",size:"sm",icon:a.jsx(Lt,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),f,r&&e.trim().length===0?a.jsx(Mr,{children:a.jsx(Rr,{...r,children:x})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:x})]})}const pn=e=>e.toLocaleString();function hn({selectAll:e,selecting:t,className:s}){return a.jsx(Ll,{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:v,searchSlot:m,searchField:g,idleSlot:p,overflowSlot:b,isBusy:h=!1,isCounting:u=!1,selectAll:f,statusLabel:x,progress:C,notice:y}){const j=t>0||u,T=f?.checked?`All ${pn(t)} loaded selected`:`${pn(t)} ${t===1?"message":"messages"} selected`,M=[];return i&&!h&&!u&&M.push({key:"junk",label:"Junk",icon:a.jsx(Ze,{className:"size-4"}),onSelect:i}),c&&!h&&!u&&M.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:[j?a.jsx(W,{variant:"ghost",size:"touch",icon:a.jsx(Un,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):d,f&&a.jsx(hn,{selectAll:f,selecting:j,className:"hidden shrink-0 pr-2 md:flex"}),j?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:x??T}):g?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:g}):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}),v,m]}),j&&!u&&a.jsxs(a.Fragment,{children:[a.jsx(W,{variant:"ghost",size:"touch",icon:h?a.jsx(Kn,{className:"size-5 animate-spin"}):a.jsx(Dt,{className:"size-5 text-danger"}),onClick:h?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":h||void 0,className:"shrink-0"}),!h&&r&&a.jsx(W,{variant:"ghost",size:"touch",icon:a.jsx(ks,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!h&&o&&a.jsx(W,{variant:"ghost",size:"touch",icon:a.jsx(We,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),j&&a.jsx(Jn,{triggerLabel:"More actions",items:M,className:"shrink-0",children:!h&&!u&&b})]}),!j&&p,j&&f&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(hn,{selectAll:f,selecting:j,className:"w-full"})}),C&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx(Ar,{value:C.value,max:C.max,tone:C.tone})}),y&&a.jsx(Bn,{"data-selection-notice":"",tone:y.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:[y.text&&a.jsx("span",{children:y.text}),y.action&&a.jsx(W,{variant:"ghost",size:"md",onClick:y.action.onClick,className:"-my-1 min-h-11 shrink-0",children:y.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"},ql={id:"flagged",label:"Starred"},Oa={id:"attachment",label:"Has attachment"};function Hl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function qf(e=[]){return{categories:[...As],filters:$r,sources:Hl(e)}}function Hf(){return{categories:[...As],filters:[Fa,ql,Oa]}}function Gf(){return{categories:[...As],filters:[Fa,Oa]}}function Gl(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function Vl(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function Wl(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(Gl(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:Vl(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 f=e.indexOf(":/",n);if(f!==-1){const x=bn(e,n,f);if(x===1)for(i=!0,n=f+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(x===2){i=!0,n=f+1;let C=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&C<2;)n+=1,C+=1;if(C<2)return null}else{for(let C=n;C<f;C+=1){const y=e.charCodeAt(C)|32;if(!(y>=97&&y<=122||y>=48&&y<=57||y===46||y===45||y===43)){const j=e.charCodeAt(C);return j===9||j===10||j===13?dt(e.replace(rs,""),t,s):null}}if(e.charCodeAt(f+2)===47)n=f+3;else return null}}else if(e.charCodeAt(n)!==91){let x=-1;for(let C=n;C<r;C+=1){const y=e.charCodeAt(C);if(y===9||y===10||y===13)return dt(e.replace(rs,""),t,s);if(y===58){x=C;break}if(y===47||y===92||y===63||y===35)break}if(x!==-1){let C=!1;for(let y=x+1;y<r;y+=1){const j=e.charCodeAt(y);if(j===47||j===92||j===63||j===35)break;if(j===64){C=!0;break}}if(!C){let y=!0,j=x+1;for(;j<r;j+=1){const T=e.charCodeAt(j);if(T===47||T===92||T===63||T===35)break;if(T<48||T>57){y=!1;break}}if(j===x+1&&(y=!1),!y){const T=bn(e,n,x);if(T===0){let M=!1;for(let P=x+1;P<r;P+=1){const E=e.charCodeAt(P);if(E===47||E===92||E===63||E===35)break;if(E===58){M=!0;break}}if(!M)return null}else if(i=!0,n=x+1,T===2){let M=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&M<2;)n+=1,M+=1;if(M<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let d=-1,v=-1,m=-1,g=-1,p=!1,b=s,h=n-1,u=-1;if(s&&n<r){const f=e.charCodeAt(n);(!(gn(f)||f===46||f===95)||f===45)&&(b=!1)}for(let f=n;f<r;f+=1){const x=e.charCodeAt(f);if(x<64)if(x===47||x===35||x===63){r=f;break}else x===58?(g===-1&&(g=f),m=f):x===9||x===10||x===13?p=!0:s&&(x===46?((f-h>64||u===46||u===45)&&(b=!1),h=f):(x<48||x>57)&&(x!==45||u===46)&&(b=!1));else if(i&&x===92){r=f;break}else x===64?(d=f,g=-1):x===93?v=f:x>=65&&x<=90?o=!0:s&&!gn(x)&&(b=!1);s&&(u=x)}if(p)return dt(e.replace(rs,""),t,s);if(d!==-1&&d>=n&&d<r&&(n=d+1),e.charCodeAt(n)===91)return v!==-1?e.slice(n+1,v).toLowerCase():null;if(m!==-1&&m>n&&m<r&&g===m&&(r=m),n>=r)return null;s&&b&&d===-1&&m===-1&&v===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-h-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 Yl(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 Jl(e){return Xl(e)||Yl(e)}function xn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function vn(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 Zl({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 ec=Zl({});function tc(e){return ec}function sc(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function nc(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 ac(e,t,s,n,r){const o=tc();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=vn(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=Jl(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!ps&&!vn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Wl(r.publicSuffix,r.hostname,o)),r)}const yn=sc();function rc(e,t){return nc(yn),ac(e,3,Lr,t,yn).domain}const Bt=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},oc=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},za=e=>rc(oc(e.trim())),ic=e=>{const t=Bt(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=ic(e);return t!==null?[{field:"FromDomain",value:t}]:Bt(e).map(s=>({field:"From",value:s}))},lc=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,cc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,dc=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(cc,"");if(s===t)return t.trim();t=s}},uc=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"]),fc=3,os=e=>e.split(" ").filter(t=>t!==""),kn=e=>e.length===0||e.join(" ").length<fc?!1:e.some(t=>!uc.has(t.toLowerCase())),mc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),pc=e=>{const t=e.map(dc).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=>mc(os(d),c)>=0))return c.join(" ")}},hc=(e,t)=>{const s=Qt(e);if(Bt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=pc(t);return n!==void 0?[{field:"Subject",value:n}]:s},gc=({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}`:""},bc=e=>e.clauses.length>0,xc=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(),v=l.useCallback(S=>{d(I=>I===S?I:void 0),i(S)},[]),m=yl({initialSelectedIds:n}),{selectedCount:g,toggle:p,clearSelection:b,selectRange:h,setAnchor:u,selectAll:f}=m,x=hl(g,t),C=l.useRef(null),y=l.useRef(!1),j=l.useCallback(()=>{r?.(),b()},[b,r]),T=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),M=l.useCallback(S=>{if(S<0||S>=e.length)return;const I=e[S];if(x){p(I);return}C.current=I,y.current=!1,d(I),i(I)},[e,x,p]),P=l.useCallback(()=>{e.length!==0&&M(T<0?0:Math.min(T+1,e.length-1))},[e.length,T,M]),E=l.useCallback(()=>{e.length!==0&&M(T<=0?0:T-1)},[e.length,T,M]),D=l.useCallback(()=>M(0),[M]),F=l.useCallback(()=>M(e.length-1),[M,e.length]),z=l.useCallback(()=>{o&&p(o)},[o,p]),O=l.useCallback((S,I)=>{const w=pl(I);return w==="range"?(h(e,S,o),!0):w==="toggle"?(p(S),!0):(j(),u(S),!1)},[e,o,h,p,j,u]),B=l.useCallback(S=>{const I=vl(e,o,S);I!==void 0&&(h(e,I),C.current=I,y.current=!1,d(void 0),i(I))},[e,o,h]),k=l.useCallback(()=>B(-1),[B]),R=l.useCallback(()=>B(1),[B]),A=l.useCallback(()=>{e.length>0&&f(e)},[e,f]);return{focusedMessageId:o,setFocusedMessageId:v,keyboardFocusedMessageId:c,focusIndex:T,pendingDomFocusRef:C,cursorMovedByPointerRef:y,selection:m,isMultiSelectMode:x,exitSelection:j,moveFocusToIndex:M,focusNext:P,focusPrevious:E,focusFirst:D,focusLast:F,toggleFocusedSelection:z,extendRangeUp:k,extendRangeDown:R,selectAllLoaded:A,handleRowSelect:O}};function yc(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 kc(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=yc(e),i=Pr(),{history:c}=i,[d,v]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const m=async g=>{function p(x){const C=i.parseLocation(x),y=i.getMatchedRoutes(C.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:C.pathname,pathname:C.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:C.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}}const b=p(g.currentLocation),h=p(g.nextLocation);if(b.routeId==="__notFound__"&&h.routeId!=="__notFound__")return!1;const u=await s({action:g.action,current:b,next:h});if(!o)return u;if(!u)return!1;const f=await new Promise(x=>{v({status:"blocked",current:b,next:h,action:g.action,proceed:()=>x(!1),reset:()=>x(!0)})});return v({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),f};return r?void 0:c.block({blockerFn:m,enableBeforeUnload:n})},[s,n,r,o,c,i]),d}const $s=e=>{const{data:t,isLoading:s}=ee({...gt(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=Cs({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(m=>m.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},jc=({surface:e})=>{const t=Go(),s=Vo(),{data:n}=ee({...Ft({path:{messageId:e.sourceMessageId}})}),{data:r}=ee({...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(ei,{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})),wc=(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},Cc=(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=>wc(n,t))},Ba=async(e,t,s,n)=>{const r=Cc(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 v=r[d],m=await hs(t(v));if(!m.ok)return c.push(...r.slice(d).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:m.error};i+=v.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)},Sc=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 v=d.value;if(v.ids.length>0){const m=await hs(s(v.ids));if(!m.ok)return{done:o,failedIds:i,cancelled:!1,error:m.error};o+=v.ids.length,n({done:o,total:t})}c=v.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},Nc=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},vt=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),yt=(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})},Tc=3e3,Ic=(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]},$t=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),Ec=(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),Mc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=ie(),{pushError:i}=ge(),c=l.useRef(new Set),d=l.useRef(new Set),{mutate:v}=pe({...Ot(),meta:Dr,onMutate:async p=>{const b=new Set(p.body.messageIds??[]),h=p.body.isRead??!0,u=Re({path:{threadId:s}}),f=ke(Ls(b,e,n));await Promise.all([o.cancelQueries({queryKey:u}),vt(o,f)]);const x=o.getQueriesData({queryKey:u}).filter(y=>y[1]!==void 0).map(([y,j])=>({queryKey:y,data:j})),C=yt(o,f);return o.setQueriesData({queryKey:u},y=>y&&{...y,items:$t(y.items,b,h)}),kt(o,f,y=>$t(y,b,h)),{threadMessagesPrefix:u,listPrefixes:f,previousThreadMessages:x,previousThreadsList:C}},onSuccess:(p,b)=>{const h=b.body.messageIds??[];for(const u of h)c.current.add(u),d.current.delete(u)},onError:(p,b,h)=>{const u=b.body.messageIds??[];for(const x of u)d.current.delete(x);if(h){for(const x of h.previousThreadMessages)o.setQueryData(x.queryKey,x.data);jt(o,h.previousThreadsList)}const f=b.body.isRead??!0;i({title:f?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(p),error:p})},onSettled:(p,b,h,u)=>{u&&(o.invalidateQueries({queryKey:u.threadMessagesPrefix}),je(o,u.listPrefixes),r&&o.invalidateQueries({queryKey:Xe({path:{accountId:r}})}))}}),m=l.useCallback(p=>{const b=p.filter(h=>!c.current.has(h)&&!d.current.has(h));if(b.length!==0){for(const h of b)d.current.add(h);v({body:{messageIds:b,isRead:!0}})}},[v]),g=l.useMemo(()=>Ec(e,t,c.current,d.current),[e,t]);l.useEffect(()=>Ic(g,Tc,m),[g,m]),l.useEffect(()=>{c.current.clear(),d.current.clear()},[s])},Vf=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=ie(),{pushError:o}=ge(),{mutateAsync:i,isPending:c}=pe({...Ot(),onError:(v,m)=>{const g=m.body.isRead??!0;o({title:g?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(v),error:v})},onSettled:(v,m,g)=>{je(r,ke(Ls(g.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((v,m)=>{v.length!==0&&ht(v,g=>i({body:{messageIds:g,isRead:m}}))},[i]),isPending:c}},Rc=60,Ac=1.5,$c=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*Ac?{direction:null}:{direction:e<0?"left":"right"}},Lc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Rc})=>{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 v=n.current;if(n.current=null,!v)return;const{direction:m}=$c(d.clientX-v.x,d.clientY-v.y,s);m==="left"&&e?.(),m==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},Pc=(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=ie(),{pushError:r}=ge(),{mutate:o,isPending:i,variables:c}=pe({...Fr(),onMutate:async v=>{const m=v.path.messageId,g=v.body.isStarred??!1,p=Re({path:{threadId:e}}),b=ke([Pc(m,s,t)]);await Promise.all([n.cancelQueries({queryKey:p}),vt(n,b)]);const h=n.getQueriesData({queryKey:p}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})),u=yt(n,b);return n.setQueriesData({queryKey:p},f=>Ha(f,x=>jn(x,m,g))),kt(n,b,f=>jn(f,m,g)),{threadMessagesPrefix:p,listPrefixes:b,previousThreadMessages:h,previousThreadsList:u}},onError:(v,m,g)=>{if(g){for(const b of g.previousThreadMessages)n.setQueryData(b.queryKey,b.data);jt(n,g.previousThreadsList)}const p=m.body.isStarred??!1;r({title:p?"Couldn't star message":"Couldn't unstar message",detail:Me(v),error:v})},onSettled:(v,m,g,p)=>{p&&(n.invalidateQueries({queryKey:p.threadMessagesPrefix}),je(n,p.listPrefixes))}});return{toggleStar:(v,m)=>{o({path:{messageId:v},body:{isStarred:!m}})},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 Dc={inbox:"Inbox",junk:"Junk"},Ps=e=>e.destinationMailboxId!==void 0,Fc=(e,t)=>{if(Ps(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${Dc[s]??"another folder"} by Remit`},Oc=(e,t)=>{if(e===Zs.MoveToInbox)return t.inboxMailboxId;if(e===Zs.MoveToJunk)return t.junkMailboxId},zc=(e,t,s)=>{if(!e||!t)return!1;const n=Ps(e)?e.destinationMailboxId:Oc(e.action,s);return n!==void 0&&n===t},_c="Reported as spam",Uc=(e,t)=>{if(e){if(Ps(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},qt=(e,t)=>{const{data:s,isLoading:n}=ee({...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}},Wf=e=>{const{mailboxId:t,isLoading:s}=qt(e,"Archive");return{archiveMailboxId:t,isLoading:s}},Yf=e=>{const{mailboxId:t,isLoading:s}=qt(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Kc=e=>{const{mailboxId:t,isLoading:s}=qt(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},Wa=e=>{const{mailboxId:t,isLoading:s}=qt(e,"Junk");return{junkMailboxId:t,isLoading:s}},Bc=()=>{const{data:e,isError:t}=ee({...gt(),staleTime:1/0});return{trashByAccount:l.useMemo(()=>{const n=new Map;for(const r of e?.accounts??[])n.set(r.accountId,r.folderAppointments.find(o=>o.role==="Trash")?.mailboxId);return n},[e]),hasAppointments:e!==void 0,isError:t}},Ya=e=>{const{data:t}=ee({...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=ie(),{pushError:o}=ge(),{mutateAsync:i,isPending:c,isError:d}=pe({...Or(),onMutate:async m=>{const g=new Set(m.body.messageIds??[]),p=t?Re({path:{threadId:t}}):[],b=ke([e,m.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:p})]:[],vt(r,b)]);const h=t?r.getQueriesData({queryKey:p}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})):[],u=yt(r,b);return t&&r.setQueriesData({queryKey:p},f=>f&&{...f,items:Cn(f.items,g)}),kt(r,b,f=>Cn(f,g)),n?.(Array.from(g)),{threadMessagesPrefix:p,listPrefixes:b,previousThreadMessages:h,previousThreadsList:u}},onError:(m,g,p)=>{if(p){for(const h of p.previousThreadMessages)r.setQueryData(h.queryKey,h.data);jt(r,p.previousThreadsList)}const b=g.body.messageIds?.length??0;o({title:b>1?`Couldn't move ${b} messages`:"Couldn't move this message",detail:Me(m),error:m})},onSettled:(m,g,p,b)=>{b&&(t&&r.invalidateQueries({queryKey:b.threadMessagesPrefix}),je(r,b.listPrefixes),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((m,g)=>{m.length!==0&&ht(m,p=>i({body:{messageIds:p,destinationMailboxId:g}}))},[i]),isPending:c,isError:d}},Qc="This message could not be processed. Please try again. If it keeps failing, report it.",qc=(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?qc(s,t.messageId):s;throw new Ur(n,422)};function Xa({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=ie(),{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:Xe({path:{accountId:s}})})},v=()=>(u,f)=>{d(),n?.(f.body.messageIds)},m=u=>(f,x)=>{o({title:u(x.body.messageIds.length),detail:Me(f),error:f})},g=pe({mutationFn:async u=>{const{data:f}=await zr({...u,throwOnError:!0});return Sn(f),f},meta:{softError:!0},onSuccess:v(),onError:m(u=>u>1?`Couldn't report ${u} messages as spam`:"Couldn't report this message as spam")}),p=pe({mutationFn:async u=>{const{data:f}=await _r({...u,throwOnError:!0});return Sn(f),f},meta:{softError:!0},onSuccess:v(),onError:m(u=>u>1?`Couldn't undo the spam report for ${u} messages`:"Couldn't undo the spam report")}),b=l.useCallback(u=>{u.length!==0&&ht(u,f=>g.mutateAsync({body:{messageIds:f}}))},[g.mutateAsync]),h=l.useCallback(u=>{u.length!==0&&ht(u,f=>p.mutateAsync({body:{messageIds:f}}))},[p.mutateAsync]);return{reportSpam:b,notSpam:h,isReporting:g.isPending,isRestoring:p.isPending}}const Hc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=Kc(e),{junkMailboxId:c}=Wa(e),{moveMessages:d,isPending:v}=Ht({mailboxId:n,threadId:s,accountId:e}),{notSpam:m,isRestoring:g}=Xa({mailboxId:n,threadId:s,accountId:e}),{data:p}=ee({...bt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),b={inboxMailboxId:i,junkMailboxId:c},h=Uc(r,b),u=l.useCallback(()=>{h&&d([t],h)},[d,t,h]),f=l.useCallback(()=>{m([t])},[m,t]);if(o)return{show:!0,label:_c,onUndo:f,isUndoing:g};if(!zc(r,n,b)||!r)return{show:!1,label:"",isUndoing:!1};const C=r.fromMailboxId?p?.items.filter(y=>y.mailboxId===r.fromMailboxId).map(y=>Kr(y.fullPath))[0]:void 0;return{show:!0,label:Fc(r,C),onUndo:h?u:void 0,isUndoing:v,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function Gc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Hc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx(Al,{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)),Xf=e=>e.filter(t=>t.isDeleted!==!0),Ds=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=ie(),{pushError:i}=ge(),{mutateAsync:c,isPending:d}=pe({...Br(),onMutate:async m=>{const g=new Set(m.body.messageIds??[]),p=t?Re({path:{threadId:t}}):[],b=ke(Ls(g,n??[],e));await Promise.all([o.cancelQueries({queryKey:p}),vt(o,b)]);const h=t?o.getQueriesData({queryKey:p}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})):[],u=yt(o,b);return t&&o.setQueriesData({queryKey:p},f=>f&&{...f,items:Nn(f.items,g)}),kt(o,b,f=>Nn(f,g)),r?.(Array.from(g)),{threadMessagesPrefix:p,listPrefixes:b,previousThreadMessages:h,previousThreadsList:u}},onError:(m,g,p)=>{if(p){for(const h of p.previousThreadMessages)o.setQueryData(h.queryKey,h.data);jt(o,p.previousThreadsList)}const b=g.body.messageIds?.length??0;i({title:b>1?`Couldn't delete ${b} messages`:"Couldn't delete this message",detail:Me(m),error:m})},onSettled:(m,g,p,b)=>{b&&(t&&o.invalidateQueries({queryKey:b.threadMessagesPrefix}),je(o,b.listPrefixes),s&&o.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}});return{deleteMessages:l.useCallback(m=>{m.length!==0&&ht(m,g=>c({body:{messageIds:g}}))},[c]),isPending:d}},Ja="inline-flex items-center justify-center transition-colors",Vc=_(Ja,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Wc=_(Ja,"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,v]=l.useState(c),[m,g]=l.useState(),p=Ss(),b=l.useRef(null),h=i??"Move to folder",u=l.useId(),{t:f}=Qr("mail",{useSuspense:!1}),x=ia(),{data:C,isLoading:y,isError:j,error:T,refetch:M}=ee({...bt({path:{accountId:e}}),staleTime:1/0,enabled:d}),P=Ya(e),{createFolderIn:E}=la(e),D=l.useMemo(()=>ca({mailboxes:C?.items??[],folderAppointments:P,currentMailboxId:t,translator:x}),[C?.items,P,t,x]),F=da(C?.items??[]),z=D.find(I=>I.id===m),O=l.useCallback(()=>{v(!1),g(void 0)},[]),B=l.useCallback(()=>{z&&(O(),s(z.id))},[z,O,s]);l.useEffect(()=>{if(!d||!p)return;const I=L=>{b.current&&!b.current.contains(L.target)&&O()},w=L=>{L.key==="Escape"&&O()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",w)}},[d,p,O]);const k=n||!!r,R=a.jsxs("button",{type:"button",onClick:I=>{I.stopPropagation(),!k&&v(w=>!w)},"aria-label":h,"aria-haspopup":p?"tree":"dialog","aria-expanded":d,"aria-controls":d?u:void 0,title:r,className:o==="icon-only"?Vc:Wc,children:[a.jsx(ks,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),A=y?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):j?a.jsx("div",{className:"p-3",children:a.jsx(Oe,{variant:"inline",title:"Couldn't load folders",error:T,onRetry:()=>M()})}):a.jsx(qr,{folders:D,selectedId:m,delimiter:F,onSelect:g,onCreateFolder:E,onCancel:O,labels:{filterPlaceholder:f("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:f("move_picker_filter_label",{defaultValue:"Filter folders"})}}),S=z&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(W,{variant:"primary",onClick:B,className:"h-11 w-full font-semibold",children:`Move to ${z.label}`})});return p?a.jsxs("div",{ref:b,className:"relative inline-block",children:[R,d&&a.jsxs("div",{id:u,className:_("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,S]})]}):a.jsxs(a.Fragment,{children:[R,a.jsx(qe.Root,{open:d,onOpenChange:I=>I?v(!0):O(),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}),S]})]})})]})},Yc=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:d})=>{const v=ie(),m=Gn(),g=Wo(),{pushError:p}=ge(),b=So()?.messageId,{mutate:h,isPending:u}=pe({...Ot(),onMutate:async A=>{const S=A.body.isRead??!0,I=new Set(A.body.messageIds??[]),w=Re({path:{threadId:t}}),L=ke([s]);await Promise.all([v.cancelQueries({queryKey:w}),vt(v,L)]);const U=v.getQueriesData({queryKey:w}).filter(Q=>Q[1]!==void 0).map(([Q,ue])=>({queryKey:Q,data:ue})),Y=yt(v,L);return v.setQueriesData({queryKey:w},Q=>Q&&{...Q,items:$t(Q.items,I,S)}),kt(v,L,Q=>$t(Q,I,S)),{threadMessagesPrefix:w,listPrefixes:L,previousThreadMessages:U,previousThreadsList:Y}},onError:(A,S,I)=>{if(I){for(const L of I.previousThreadMessages)v.setQueryData(L.queryKey,L.data);jt(v,I.previousThreadsList)}const w=S.body.isRead??!0;p({title:w?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(A),error:A})},onSettled:(A,S,I,w)=>{w&&(v.invalidateQueries({queryKey:w.threadMessagesPrefix}),je(v,w.listPrefixes))}}),f=l.useCallback(A=>{b&&A.includes(b)&&m({to:"/mail/$mailboxId",params:{mailboxId:s},search:S=>S,hash:g})},[b,s,m,g]),{deleteMessages:x,isPending:C}=Ds({mailboxId:s,threadId:t,onAfterOptimisticRemove:f}),{moveMessages:y,isPending:j}=Ht({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:f}),{toggleTrusted:T,isPending:M,error:P,reset:E}=Zn({messageId:e}),D=()=>{h({body:{messageIds:[e],isRead:!1}})},F=()=>{x([e])},z=()=>{o&&T(o,i)},O=u||C||j||M,B=O||!o,k=l.useCallback(A=>{y([e],A)},[y,e]),R=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:k,disabled:O,label:"Move this message"}),a.jsxs(No,{trigger:a.jsx(Fo,{className:"size-4"}),children:[a.jsxs(Nt,{onClick:z,disabled:B,children:[i?a.jsx(Ut,{className:"size-4 text-positive"}):a.jsx(Pt,{className:"size-4 opacity-0"}),a.jsx("span",{title:R,children:"Trusted sender"})]}),n&&a.jsxs(Nt,{onClick:D,disabled:O,children:[a.jsx(Es,{className:"size-4"}),"Mark as unread"]}),d&&a.jsxs(Nt,{onClick:d,children:[a.jsx(ka,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(To,{}),a.jsxs(Nt,{onClick:F,disabled:O,destructive:!0,children:[a.jsx(Dt,{className:"size-4"}),"Delete"]})]})]}),P&&a.jsx("div",{className:"w-64",children:a.jsx(Oe,{variant:"inline",title:"Couldn't update trust",error:P,onRetry:()=>{E(),z()}})})]})},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 Jc="x-remit-403-reason",Zc="expired",ed=(e,t)=>{if(t?.trim()===Zc)return"link-expired";const s=Yo(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},td=300*1e3,Tn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Vr(e,{headers:s,signal:AbortSignal.timeout(td)});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(ed(r.status,r.headers.get(Jc)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},sd=(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",nd=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",ad=(e,t,s)=>{if(e!=="auth")return Hr(Gr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},rd=(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)},od=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},id=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===ri.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Oo(t.dispositionFilename??"",id(t.mediaSubtype)),typeLabel:od(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),Mn={status:"idle"},ld=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Vn(),o=ie(),[i,c]=l.useState({}),d=l.useMemo(()=>En(t??[]),[t]),v=Wr({path:{messageId:e}}),m=h=>Tn(h.contentUrl,r).catch(u=>{if(!Xc(In(u)))throw u;return o.refetchQueries({queryKey:v}).then(()=>{const f=o.getQueryData(v),x=f?En(f.bodyParts).find(C=>C.bodyPartId===h.bodyPartId):void 0;return Tn(x?.contentUrl??h.contentUrl,r)})}),g=(h,u)=>c(f=>({...f,[h]:u})),p=h=>{const u=d.find(f=>f.bodyPartId===h);if(!u)throw new Error(`No attachment part ${h} on message ${e}`);g(h,{status:"downloading"}),m(u).then(f=>{rd(f,u.filename),g(h,Mn)}).catch(f=>{const x=In(f),C=nd(f),{title:y,detail:j}=sd(x,u.filename,C);g(h,{status:"failed",title:y,detail:j,reportUrl:ad(x,u.filename,C)})})},b=s&&t!==void 0&&d.length===0;return a.jsx(Rl,{className:n,attachments:d.map(h=>({attachmentId:h.bodyPartId,filename:h.filename,typeLabel:h.typeLabel,sizeOctets:h.sizeOctets,download:i[h.bodyPartId]??Mn})),onDownload:p,hasUnlistedAttachment:b})},cd=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:d,showRaw:v,onToggleRaw:m,onReply:g,onReplyAll:p,onForward:b})=>{const h=ie(),{deleteMessages:u}=Ds({mailboxId:s,threadId:t}),{moveMessages:f}=Ht({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:x}=Zn({messageId:e}),{mutate:C}=pe({...Ot(),onSettled:()=>{h.invalidateQueries({queryKey:Re({path:{threadId:t}})}),je(h,ke([s]))}}),y=l.useCallback(P=>{f([e],P)},[f,e]),j=l.useCallback(()=>{u([e])},[u,e]),T=l.useCallback(()=>{C({body:{messageIds:[e],isRead:!r}})},[C,e,r]),M=[];return c&&M.push({key:"trusted",label:d?"Trusted sender":"Mark sender trusted",icon:d?a.jsx(Ut,{className:"size-4 text-positive"}):a.jsx(Pt,{className:"size-4"}),onSelect:()=>x(c,d)}),m&&M.push({key:"raw",label:v?"Show formatted":"Show raw email",icon:a.jsx(ka,{className:"size-4"}),onSelect:m}),a.jsx(Ra,{hasThread:!0,onReply:g,onReplyAll:p,onForward:b,isStarred:o,onToggleStar:i,onDelete:j,isRead:r,onToggleRead:T,overflowItems:M,moveSlot:n?a.jsx(Fs,{accountId:n,currentMailboxId:s,onMove:y,label:"Move this message"}):void 0})},dd=()=>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"})]}),ud=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=ee({...Yr({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(dd,{})});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})})},fd=()=>a.jsx(Ut,{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:_("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":_("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Ye,{className:_("size-3.5",e&&"fill-current")})}),md=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=ra(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(Kt,{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})]})})},pd=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:d,isStarPending:v,accountId:m,showRaw:g,onToggleRaw:p,mobile:b,onReply:h,onReplyAll:u,onForward:f})=>{const x=ra(e.sentDate,"long"),C=!e.isRead,y=t?.envelope.from[0]?.flags?.trusted?.value===!0,j=t?.envelope.from[0]?.addressId,T=Za(e,x),M=e.autoMoved||e.spamReport?a.jsx(Gc,{accountId:m,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx($a,{message:T,isFocused:b?!1:i,onHeaderClick:c,senderBadge:y?a.jsx(fd,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:x}),to:t?a.jsx(cl,{label:"To",addresses:t.envelope.to}):null,indicators:M||!b?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[M,!b&&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:v})}),C&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:b?void 0:a.jsx(Yc,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:m,fromAddressId:j,isTrusted:y,showRaw:g,onToggleRaw:p}),actionBar:b?a.jsx(cd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:m,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:d,fromAddressId:j,isTrusted:y,showRaw:g,onToggleRaw:p,onReply:h,onReplyAll:u,onForward:f}):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&&Xr(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})}):g?a.jsx("div",{className:"mt-3",children:a.jsx(ud,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(Ko,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:y,category:Va(e.category)}),a.jsx(ld,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},hd=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:d,onReplyAll:v,onForward:m})=>{const[g,p]=l.useState(!1),{data:b,isLoading:h,isError:u,error:f,refetch:x}=ee({...Ft({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(pd,{threadMessage:e,messageData:b,isLoading:h,isError:u,error:f,onRetry:()=>x(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:g,onToggleRaw:()=>p(C=>!C),mobile:c,onReply:d,onReplyAll:v,onForward:m}):a.jsx(md,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},gd=()=>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))})]}),Jf=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:d,mobileIntelligenceOpen:v})=>{const m=Ss(),{handlers:g}=Lc({onSwipeLeft:c,onSwipeRight:d}),{accountId:p}=$s(t),{data:b,isLoading:h,isError:u,error:f,refetch:x}=ee({...Wn({path:{threadId:e}})}),C=l.useMemo(()=>b?.items??[],[b?.items]),y=C[C.length-1],j=l.useMemo(()=>[...C].reverse(),[C]),T=l.useRef(new Map),[M,P]=l.useState(new Set),[E,D]=l.useState(null),[F,z]=l.useState(0);l.useEffect(()=>{if(C.length>0&&e!==E){D(e);const K=new Set([C[C.length-1].threadMessageId]);if(n){const q=C.find(J=>J.messageId===n);q&&K.add(q.threadMessageId)}P(K),z(0)}},[e,C,E,n]);const O=l.useCallback(K=>{P(q=>{const J=new Set(q);return J.has(K)?J.delete(K):J.add(K),J})},[]),B=l.useCallback(K=>{const q=j[K];if(!q)return;T.current.get(q.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[j]),k=l.useCallback(()=>{if(j.length===0)return;const K=Math.min(F+1,j.length-1);z(K),B(K)},[j.length,F,B]),R=l.useCallback(()=>{if(j.length===0)return;const K=Math.max(F-1,0);z(K),B(K)},[j.length,F,B]),A=l.useCallback(()=>{const K=j[F];K&&O(K.threadMessageId)},[j,F,O]);Mc({messages:C,expandedIds:M,threadId:e,mailboxId:t,accountId:p});const{toggleStar:S,isPending:I,pendingMessageId:w}=Ga({threadId:e,mailboxId:t,messages:C}),L=Xo(),U=Jo(),Y=n??y?.messageId,Q=l.useCallback((K,q)=>{q&&U({threadId:e,messageId:q,mode:K})},[U,e]),ue=l.useCallback(()=>Q("reply",Y),[Q,Y]),se=l.useCallback(()=>Q("reply-all",Y),[Q,Y]),re=l.useCallback(()=>Q("forward",Y),[Q,Y]),le=l.useRef(null),ne=L?.kind==="reply"?`${L.mode}:${L.sourceMessageId}`:void 0;if(l.useEffect(()=>{ne&&le.current?.scrollIntoView({behavior:"smooth",block:"start"})},[ne]),ti({enabled:!h&&C.length>0&&L===void 0,bindings:[{key:"j",handler:k,preventDefault:!0},{key:"ArrowDown",handler:k,preventDefault:!0},{key:"k",handler:R,preventDefault:!0},{key:"ArrowUp",handler:R,preventDefault:!0},{key:"Enter",handler:A,preventDefault:!0},{key:"o",handler:A,preventDefault:!0},{key:"r",handler:ue,preventDefault:!0},{key:"R",handler:se,noModifiers:!1,preventDefault:!0},{key:"f",handler:re,preventDefault:!0}]}),h)return a.jsx(gd,{});if(u)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(Oe,{title:L?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:f,onRetry:()=>x()})});if(C.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:L?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 fe=s||C[0]?.subject||"(No subject)",ce=C.length,be=K=>a.jsx("div",{"data-testid":"conversation-messages",children:j.map((q,J)=>a.jsx("div",{ref:we=>{we&&T.current.set(q.threadMessageId,we)},children:a.jsx(hd,{threadMessage:q,isExpanded:M.has(q.threadMessageId),isFocused:J===F,onToggle:()=>O(q.threadMessageId),onToggleStar:()=>S(q.messageId,q.hasStars),isStarPending:I&&w===q.messageId,accountId:p,mobile:K,onReply:K?()=>Q("reply",q.messageId):void 0,onReplyAll:K?()=>Q("reply-all",q.messageId):void 0,onForward:K?()=>Q("forward",q.messageId):void 0})},q.threadMessageId))}),V=L&&a.jsx("div",{ref:le,children:L.kind==="reply"?a.jsx(jc,{surface:L}):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:`"${L.segment}" is not reply, reply-all or forward.`})})}),ae=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:fe}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[ce," ",ce===1?"message":"messages"]})]});return m?a.jsxs("article",{className:"h-full flex flex-col",children:[ae,r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[V,be(!1)]})]}):a.jsxs(El,{thread:{subject:fe,messages:[]},onBack:i??(()=>{}),intelligenceOpen:v,onToggleIntelligence:o,touchHandlers:g,children:[r?.dkimMismatch&&a.jsx(wn,{authenticity:r,onOpenIntelligence:o}),V,be(!0)]})},bd=({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 v=p=>{p.key==="Escape"&&(p.preventDefault(),t())};document.addEventListener("keydown",v),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",v),document.body.style.overflow=g,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:_("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(Lt,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},xd=10,tr=e=>({q:e?.toLowerCase()??"",limit:xd}),vd=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function yd(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":si(t,{month:"short",year:"numeric"})}function sr(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const kd="We can't verify the sender of this email, which could mean it's from an insecure source.",jd="We couldn't read this sender's address, so we can't confirm who really sent this message.";function wd(e,t){const s=e.category??"personal";return{value:Zr(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function Cd(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?yd(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:sr(e.fromEmail)}}function Sd(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 Nd(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Td(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=Id(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${Nd(r.slice(0,3))}.`),s}function Id(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Ed(e,t){const s=t>0?t:void 0;if(sr(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:jd,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:kd};if(!n.dkimMismatch){const v=Rn(e),m=Td(n,v);return m.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:v,summary:m.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 Md(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=ee({...js({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:v,error:m}=ee({...Jr({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(x=>x.messageId!==e.messageId).map(x=>({id:x.messageId,threadId:x.threadId,mailboxId:t!=null&&x.mailboxIds.includes(t)?t:x.mailboxIds[0]??"",fromName:x.fromName??"",subject:x.subject??"(No subject)",timeLabel:x.sentDate!=null?Je(x.sentDate*1e3):"",matched:x.matchedChunkType})),b=Cd(e,i),h=Ed(e,p.length),u=wd(e,i),f=Sd(i);return{sender:b,authenticity:h,category:u,flags:f,similar:p}},[e,i,d,t]),isSimilarLoading:v,similarError:m,similarErrorIsFatal:Gs(m),addressErrorIsFatal:Gs(o),addressId:i?.addressId,address:i}}function Rd(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 Ad({addressId:e,senderEmail:t}){const s=ie(),{pushError:n}=ge(),r=eo({query:tr(t)}),{mutate:o,isPending:i}=pe({...to(),onMutate:async d=>{const v=d.body.flags??{};await s.cancelQueries({queryKey:r});const m=s.getQueryData(r);return s.setQueryData(r,g=>g&&{...g,items:g.items.map(p=>p.addressId===d.path.addressId?{...p,flags:Rd(p.flags,v)}:p)}),{previous:m}},onError:(d,v,m)=>{m?.previous!==void 0&&s.setQueryData(r,m.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){so(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 Zf=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",$d=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function em(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function tm(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function sm(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Ld(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Pd=["personal","newsletter","marketing","automated","transactional","social"],Dd=e=>e.spamReport?"notSpam":"reportSpam",Fd=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function Od(){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 zd({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(ao,{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:Pd.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 _d({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:d,similarError:v,similarErrorIsFatal:m}=Md(e,s),[g,p]=l.useState(!1),b=e.fromEmail??void 0,{updateFlags:h}=Ad({addressId:c,senderEmail:b}),{reportSpam:u,notSpam:f,isReporting:x,isRestoring:C}=Xa({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),y=no(),j=Dd(e),T=l.useCallback(()=>{f([e.messageId])},[f,e.messageId]),M=l.useCallback(()=>{Ld(y,{count:1,senderTrust:e.senderTrust,wasRescuable:$d(e)}),u([e.messageId])},[u,e,y]),P=l.useCallback(()=>{},[]),E=l.useCallback(()=>{const A=i?.flags?.vip!==!0;h({vip:{value:A}})},[i?.flags?.vip,h]),D=l.useCallback(()=>{const A=i?.flags?.muted!==!0;h({muted:{value:A}})},[i?.flags?.muted,h]),F=l.useCallback(()=>{const A=i?.flags?.unsubscribed!==!0;h({unsubscribed:{value:A}})},[i?.flags?.unsubscribed,h]),z=l.useCallback(A=>{p(!1),h({category:{value:A}})},[h]),O=c!==void 0,B={onToggleVip:O?E:void 0,onToggleMute:O?D:void 0,onToggleUnsubscribe:O?F:void 0,onReclassify:O?()=>p(!0):void 0,onNotSpam:j==="notSpam"?T:void 0,onReportSpam:j==="reportSpam"?M:void 0},k=({mailboxId:A,threadId:S,messageId:I,className:w,ariaLabel:L,children:U})=>a.jsx(aa,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:A,threadId:S,messageId:I},search:Y=>Y,variant:"row",className:w,"aria-label":L,children:U});if(!i)return a.jsx(Od,{});const R=Fd({similarError:v,similarErrorIsFatal:m,isSimilarLoading:d});return a.jsxs(a.Fragment,{children:[a.jsx(Sa,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:P,actions:B,similarState:R,similarLinkComponent:k,reportSpamPending:x,notSpamPending:C,className:"border-l-0 h-full w-full"}),a.jsx(zd,{isOpen:g,current:i.category.value,onSelect:z,onCancel:()=>p(!1)})]})}const Ud=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(_d,{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 nm({isOpen:e,onClose:t,thread:s,mailboxId:n,accountId:r,onAfterOptimisticRemove:o}){return a.jsx(bd,{isOpen:e,onClose:t,ariaLabel:"Message details",side:"right",children:a.jsx(Ud,{onClose:t,thread:s,mailboxId:n,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:o})})}const Kd=e=>{const{trashByAccount:t,hasAppointments:s,isError:n}=Bc();return l.useMemo(()=>ni({targets:e,trashByAccount:t,hasAppointments:s,isError:n}),[e,t,s,n])},Bd={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],qd={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},Hd={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},Gd={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},am=(e,t,s)=>Bd[e](ze(t),ze(s)),Vd=(e,t,s="trash")=>`${ze(t)} ${nr(e,s)}. Your mail server is still catching up.`,Wd=e=>`Stopped after ${ze(e)}`,Yd=(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 ${qd[e]}`:Hd[e],Jd=e=>Gd[e],rm=e=>e==="delete"?"danger":"info",om=(e,t,s,n)=>s.error!==void 0?null:s.cancelled?{severity:"warning",title:Wd(s.done),detail:Yd(e,s.done,t,n)}:{severity:"info",title:Vd(e,s.done,n)},Zd=100,eu=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],tu=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,d]=l.useState(void 0),[v,m]=l.useState(void 0),g=l.useRef(!1),p=l.useRef(!1),b=ie(),{pushError:h}=ge();l.useEffect(()=>{p.current||(g.current=!0),i({kind:"idle"})},[s,n]);const u=l.useRef(r);u.current=r;const f=l.useCallback(E=>async D=>{const{data:F}=await Vs({path:{mailboxId:e},query:{...E,continuationToken:D,limit:Zd},throwOnError:!0});return{ids:(F.items??[]).map(z=>z.messageId),continuationToken:F.continuationToken}},[e]),x=l.useCallback(async()=>{const{data:E}=await Vs({path:{mailboxId:e},query:{...u.current,count:!0,results:!1},throwOnError:!0});if(E.count===void 0)throw new Error("the search returned no count for the selection");return E.count},[e]),C=l.useCallback(E=>async D=>{if(E.kind==="move"){const{data:z}=await ro({body:{messageIds:D,destinationMailboxId:E.destinationMailboxId},throwOnError:!0});return z}if(E.kind==="markRead"){const{data:z}=await oo({body:{messageIds:D,isRead:!0},throwOnError:!0});return z}const{data:F}=await io({body:{messageIds:D},throwOnError:!0});return F},[]),y=l.useCallback((E,D)=>{je(b,ke(eu(E,e)));const F=new Set;t&&F.add(t);for(const z of D)z.accountId&&F.add(z.accountId);for(const z of F)b.invalidateQueries({queryKey:Xe({path:{accountId:z}})})},[b,e,t]),j=l.useCallback(()=>{g.current=!1,i({kind:"counting"}),x().then(E=>{if(g.current){i({kind:"idle"});return}i({kind:"escalated",total:E})},E=>{h(Ws("Couldn't count matching messages","The count didn't finish.",E)),i({kind:"idle"})})},[x,h]),T=l.useCallback(()=>{g.current=!0},[]),M=l.useCallback(()=>{p.current||(g.current=!0,i({kind:"idle"}))},[]),P=l.useCallback(async(E,D)=>{g.current=!1,p.current=!0,d(E);const F=k=>m(Nc(k)),z=C(E),O=f(u.current);let B;try{B=D!==void 0?await Ba(D,z,F,()=>g.current):await Sc(O,o.kind==="escalated"?o.total:0,z,F,()=>g.current)}finally{p.current=!1}return d(void 0),m(void 0),i({kind:"idle"}),B.error&&h(Ws(Xd(E.kind,B.done),Jd(E.kind),B.error)),B.done>0&&y(E,D??[]),B},[C,f,o,h,y]);return{phase:o,escalate:j,stop:T,clear:M,isRunning:c!==void 0,runningAction:c,progress:v,runAction:P}},su=120,nu=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=su})=>{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.",au="These are already in Junk, so there is nowhere to file them.",ru=(e,t)=>e!==void 0&&e!==t?e:void 0,im=(e,t)=>{if(ru(e,t)===void 0)return e===void 0?ar:au};function ou(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const iu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},bs=l.createContext(iu),rr=()=>l.useContext(bs),lu="/settings/folders",cu=({isOpen:e,count:t,outcome:s,isDeleting:n=!1,onConfirm:r,onCancel:o})=>{const{Account:i}=Vn(),c=ai(t,s);return s==="noTrash"?a.jsx(Tt,{isOpen:e,...c,onConfirm:()=>{window.location.assign(lu)},onCancel:o}):s==="unavailable"?a.jsx(i,{fallback:a.jsx(Tt,{isOpen:e,...c,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:o}),children:({signOut:d})=>a.jsx(Tt,{isOpen:e,...c,onConfirm:()=>d(),onCancel:o})}):a.jsx(Tt,{isOpen:e,...c,destructive:!0,isBusy:n||s==="unknown",onConfirm:r,onCancel:o})},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=oa(n,pu),o=e!==void 0&&ir(e),{data:i}=ee({...js({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:Je(t.date)}},xu=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=ee({...lo({path:{mailboxId:e??""},query:{...t,limit:lr}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(vu),isPending:s&&r}},vu=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Je(e.sentDate)}),yu=e=>Cs({queries:e.slice(0,lr).map(t=>({...Ft({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=pe(co()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),d=l.useMemo(()=>Bt(s),[s]),v=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:en({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),m=l.useCallback(()=>{c(!1),o()},[o]),g=n.data,p=g?.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 b=i||(g?.semanticUnavailable??!1),h=n.isPending||p,u=i?{matchOperator:"Or",literalClauses:Qt(d)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:v,reset:m,matchedCount:h?void 0:g?.matchedCount,messageIds:h?void 0:g?.messageIds,semanticUnavailable:b,senderFallback:i,senders:d,matchPredicate:u,isPending:h,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=ie(),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:ea(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={clauses:[],matchOperator:"any"},Lu={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},Pu=[],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 Du({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:d,onRunEnded:v,step:m,goToStep:g,goBack:p,closeWizard:b}){const[h]=l.useState(()=>c),[u]=l.useState(()=>o),f=h!==void 0,[x,C]=l.useState(f?"properties":"selected"),y=u?"escalated":x,[j,T]=l.useState(()=>h?{clauses:is(h.clauses,"search"),matchOperator:h.matchOperator}:$u),[M,P]=l.useState(void 0),[E,D]=l.useState(void 0),[F,z]=l.useState(!1),[O,B]=l.useState(void 0),[k,R]=l.useState(void 0),[A,S]=l.useState(),I=l.useRef(!1),w=l.useRef(!1),L=l.useMemo(()=>n.map(N=>N.id),[n]),U=l.useMemo(()=>n.map(N=>({id:N.id,accountId:N.accountId})),[n]),Y=l.useMemo(()=>n.map(N=>N.email).filter(Boolean),[n]),Q=L[0],ue=Tu(L),{junkMailboxId:se}=Wa(t),re=ju(u?void 0:t,Q,Y),{preview:le}=re;l.useEffect(()=>{le()},[le]);const ne=y==="similar"||y==="properties",fe=l.useMemo(()=>({matchOperator:j.matchOperator==="all"?"And":"Or",literalClauses:j.clauses.map(N=>({field:N.field,value:N.value}))}),[j.clauses,j.matchOperator]),ce=y==="similar"?re.matchPredicate:fe,{count:be,matchedIds:V}=li(ne?t:void 0,ce),ae=yu(ne?V:[]),K=xu(u?s:void 0,u?.searchQuery),q=u?{status:"ready",count:u.total}:ne?be:{status:"ready",count:n.length},{data:J}=ee({...bt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),we=Ya(t),Gt=ia(),et=l.useMemo(()=>ca({mailboxes:J?.items??[],folderAppointments:we,currentMailboxId:s,translator:Gt}),[J?.items,we,s,Gt]),{createFolderIn:Vt}=la(t),tt=et.find(N=>N.id===j.moveMailboxId)?.label,st=lc(n.map(N=>({normalizedEmail:N.email,displayName:N.sender}))),nt=gc({match:y==="properties"&&j.clauses[0]?.value.trim()||void 0,sender:st?_a(st):void 0,folder:tt}),H=l.useMemo(()=>({...j,name:j.name??nt}),[j,nt]),wt=gu(M?.draft.field,M?.draft.value??"",Y),me=ci(t),xe=di(t),_e=tu({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:Ue}=_e,oe=mo({verb:e,mode:y,scope:j.scope,fromSearch:f}),X=oe[Ys(oe,m)],$e=po(t,r),Ce=(N=>{if(N==="folder")return $e.destination;if(N==="rule")return H.scope==="standing"||H.scope==="until"?$e.rule:void 0})(X)??ho(X,H,q),Le=l.useCallback(()=>is(hc(Y,ue),"seed"),[Y,ue]),Wt=l.useCallback(N=>{C(N),T($=>({...$,widen:N==="similar"&&Q?{anchorCount:Math.max(n.length,1)}:void 0,...N==="properties"&&$.clauses.length===0?{clauses:Le()}:{}}))},[Q,n.length,Le]),Ke=l.useCallback(()=>{z(!0),C("properties"),T(N=>({...N,widen:void 0,clauses:is(Qt(Y),"sender"),matchOperator:"any"})),g("properties")},[Y,g]),Se=re.semanticUnavailable||re.isError;l.useEffect(()=>{X==="match"&&(y!=="similar"||!Se||F||Ke())},[X,y,Se,F,Ke]);const at=l.useCallback(()=>{P({mode:"add",draft:{field:"From",value:""}})},[]),rt=l.useCallback(N=>{const $=j.clauses.find(G=>G.id===N);$&&P({mode:"edit",clauseId:N,draft:{field:$.field,value:$.value}})},[j.clauses]),te=l.useCallback(N=>{T($=>({...$,clauses:$.clauses.filter(G=>G.id!==N)}))},[]),ve=l.useCallback(N=>{P($=>$&&{...$,draft:N})},[]),fr=l.useCallback(()=>{P(N=>{if(!N)return;const $=ui(N.draft.field,N.draft.value),G={...N.draft,value:$};T(Be=>({...Be,clauses:N.clauseId?Be.clauses.map(ot=>ot.id===N.clauseId?{...ot,...G}:ot):[...Be.clauses,{id:crypto.randomUUID(),...G}]}))})},[]),mr=l.useCallback(()=>{if(Ce){D(X);return}D(void 0);const N=oe[Ys(oe,X)+1];N&&g(N)},[Ce,X,oe,g]),Yt=l.useCallback(async N=>{const $=An(e,H.moveMailboxId,se);if(!$){R({matched:N.length,sent:N,failureReason:$n(e)});return}R({matched:N.length,sent:N});const G=await Ue($,N);R({matched:N.length,sent:N,outcome:G}),w.current&&v?.($.kind,N.length,G)},[e,H.moveMailboxId,se,Ue,v]),Xt=l.useCallback(async()=>{if(!u)return;const N=An(e,H.moveMailboxId,se);if(!N){R({matched:u.total,sent:[],failureReason:$n(e)});return}R({matched:u.total,sent:[]});const $=await u.run(N);R({matched:u.total,sent:[],outcome:$}),w.current&&v?.(N.kind,u.total,$)},[u,e,H.moveMailboxId,se,v]),{start:Ct}=me,{createFilterAsync:Us}=xe,St=l.useCallback(()=>{if(u){Xt();return}const N=fi({mode:x,ruleScope:H.scope}),$=mi({mode:x,ruleScope:H.scope,anchorMessageId:Q,clauses:H.clauses,matchOperator:H.matchOperator,moveMailboxId:H.moveMailboxId,until:H.until});if(B(N),N==="standing"||N==="temporary"){const G=pi($)?$:void 0;S(G),Us($,N,(H.name??"").trim()).then(Be=>{Be&&G&&Ct(G)});return}if(N==="all-like-these"&&ls(e)){Ct($);return}Yt(N==="just-these"?U:V.map(G=>({id:G,accountId:t})))},[u,Xt,x,H,Q,e,t,U,V,Us,Ct,Yt]),pr=l.useCallback(()=>{if(Ce){D(X);return}I.current||(I.current=!0,g("run"),St())},[Ce,X,g,St]),Ks=l.useCallback(N=>{const $=me.progress,G=Au({failure:me.failure,isStarting:me.isStarting,isRunning:me.isRunning,isDone:me.isDone,failedCount:$.failedCount,ruleSaved:N});return G==="saving"||G==="commitFailed"||G==="backApplyStartFailed"?{...Fe,state:G}:{state:G,matched:$.matchedCount,applied:$.appliedCount,failed:G==="backApplyFailed"||G==="backApplyRestartFailed"?$.failedCount:0,failures:[]}},[me]),Bs=l.useMemo(()=>{const N=new Map;for(const $ of[...n,...ae.messages,...K.messages])N.set($.id,$);return N},[n,ae.messages,K.messages]),Qs=u?i:_e.progress,qs=l.useCallback(()=>{if(!k)return Fe;const{matched:N,outcome:$,failureReason:G}=k;if(G!==void 0)return{...Fe,state:"commitFailed",failureReason:G};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),vr=$.failedIds.length>0?$.failedIds.length:Math.max(N-$.done,1);return{state:"runStopped",matched:Math.max(N,$.done),applied:$.done,failed:vr,failures:ot}},[k,Qs,Bs]),Pe=u?qs():O==="standing"||O==="temporary"?xe.isError?{...Fe,state:"commitFailed"}:xe.isSuccess?A?Ks(!0):{...Fe,state:"filterSaved"}:Fe:O==="all-like-these"&&ls(e)?Ks(!1):qs(),hr=()=>{if(Pe.state==="statusUnknown"){me.refreshStatus();return}if(u){Xt();return}if(O==="standing"||O==="temporary"){if(xe.isError){xe.reset(),St();return}A&&Ct(A);return}if(O==="all-like-these"&&ls(e)){St();return}const N=new Set(k?.outcome?.failedIds??[]),$=k?.sent??U;Yt(N.size>0?$.filter(G=>N.has(G.id)):$)},gr=l.useCallback(()=>{b(oe,X)},[b,oe,X]),Jt=l.useCallback(()=>{w.current=!0,b(oe,X),d()},[b,oe,X,d]),{stop:Hs}=_e,br=k!==void 0&&k.outcome===void 0&&k.failureReason===void 0,xr=l.useCallback(()=>{if(u){u.stop();return}Hs()},[u,Hs]);kc({shouldBlockFn:({action:N})=>N!=="BACK"?!1:(Jt(),!0),enableBeforeUnload:!1,disabled:X!=="run"});const Zt={messages:u?K.messages:ne?ae.messages:n,count:q,label:y==="selected"?"Your selection":"A sample of what matches",emptyReason:y==="similar"&&Se?"notIndexed":"noMatch",loading:u?K.isPending:ne&&(q.status==="loading"||ae.isPending)};return a.jsx(go,{verb:e,steps:oe,step:X,blockedReason:Ce,nudged:E===X,onBack:p,onExit:X==="run"?Jt:gr,onContinue:mr,onCommit:pr,match:{selectedCount:n.length,mode:y,accountId:$e.accountId,onModeChange:Wt,semanticUnavailable:Se,semanticErrorDetail:re.error instanceof Error?re.error.message:void 0,semanticFallbackTaken:F,onSemanticFallback:Ke,escalatedScope:u?.scope,sample:Zt},properties:{clauses:H.clauses,matchOperator:H.matchOperator,onMatchOperatorChange:N=>T($=>({...$,matchOperator:N})),clauseEdit:M,onStartAddClause:at,onStartEditClause:rt,onRemoveClause:te,onChangeDraft:ve,onSubmitClause:fr,onCancelClause:()=>P(void 0),clauseFields:hi,clauseSuggestions:wt,conversionNotice:h?xc(h):void 0,semanticFallbackTaken:F,sample:{...Zt,label:"What this matches"}},folder:{folders:et,mailboxId:H.moveMailboxId,delimiter:da(J?.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:E===X},review:{verb:e,mode:y,selectedCount:n.length,clauses:H.clauses,matchOperator:H.matchOperator,folder:tt,scope:H.scope,until:H.until,ruleName:oe.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:Jt,onCancelRun:br?xr:void 0}})}function lm(e){const t=uo()==="search",{searchConversion:s}=rr(),{accounts:n}=zt(),{step:r,goToStep:o,goBack:i,closeWizard:c}=fo(t?"properties":"match");if(!r)return null;const d=t?s??Lu:void 0;return a.jsx(Du,{...e,...d?{verb:"organize",accountId:Ru(d,e.accountId,n),selection:Pu,selectionRestriction:void 0,escalated:void 0,searchConversion:d}:{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Fu=[],Os=l.createContext(null),Ou=e=>{const t=l.useContext(Os);return t?t.rowInteraction(e):null},zu=()=>{const e=l.useContext(Os);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},_u="[data-message-id]",Uu=e=>Array.from(e.querySelectorAll(_u)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),Ku=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),Bu=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=Uu(n);s(c=>Ku(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function cm({selectedMessageId:e,rows:t,onOpen:s,onDeleteMessages:n,onSelectionVerb:r,wizardOpen:o=!1,isDeleting:i=!1,commandsRef:c,onTriageContextChange:d,children:v}){const m=Ss(),{pushError:g}=ge(),p=l.useRef(null),b=Bu(p),h=vc({orderedIds:b,isDesktop:m,initialFocusedId:e}),{focusedMessageId:u,setFocusedMessageId:f,pendingDomFocusRef:x,cursorMovedByPointerRef:C,selection:y,isMultiSelectMode:j,exitSelection:T,handleRowSelect:M}=h,{selectedIds:P,selectedCount:E,isSelected:D,toggle:F,select:z,toggleAll:O}=y,B=b.length>0&&b.every(V=>P.has(V)),k=l.useCallback(()=>{b.length>0&&O(b)},[b,O]),{intersectWith:R}=y;l.useEffect(()=>{R(b)},[R,b]),l.useEffect(()=>{const V=x.current;V!==null&&(x.current=null,p.current?.querySelector(`[data-message-id="${V}"]`)?.focus())});const A=l.useCallback(V=>{C.current=!0,f(V)},[C,f]),S=l.useCallback(V=>{m||z(V)},[m,z]),I=l.useCallback(()=>{u&&s(u)},[u,s]),w=l.useCallback(V=>s(V,{replace:!0}),[s]);nu({keyboardFocusedMessageId:h.keyboardFocusedMessageId,openMessageId:e,enabled:m&&E===0,open:w});const[L,U]=l.useState(null),Y=Kd(L?.targets??Fu),Q=l.useCallback(V=>{if(L!==null)return!0;if(E>0)return r(V),!0;if(V!=="delete"||!u)return!1;const ae=t.find(K=>K.id===u);return!ae?.mailboxId||!ae.accountId?(g({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):(U({ids:[u],targets:[{accountId:ae.accountId,mailboxId:ae.mailboxId}]}),!0)},[L,E,r,u,t,g]),ue=l.useCallback(()=>{L!==null&&(n(L.ids),U(null),T())},[L,n,T]),se=l.useCallback(()=>U(null),[]),re=l.useCallback(()=>E===0?!1:(T(),!0),[E,T]),le=b.length>0;l.useEffect(()=>{if(c){if(!le){c.current=null;return}return c.current={focusNext:h.focusNext,focusPrevious:h.focusPrevious,focusFirst:h.focusFirst,focusLast:h.focusLast,openFocused:I,toggleSelect:h.toggleFocusedSelection,extendSelectDown:h.extendRangeDown,extendSelectUp:h.extendRangeUp,selectAll:h.selectAllLoaded,clearSelection:re,requestVerb:Q,toggleDensity:()=>{}},()=>{c.current=null}}},[c,le,h.focusNext,h.focusPrevious,h.focusFirst,h.focusLast,h.toggleFocusedSelection,h.extendRangeDown,h.extendRangeUp,h.selectAllLoaded,I,re,Q]);const ne=l.useMemo(()=>Array.from(P),[P]),fe=L!==null;l.useEffect(()=>{d?.({focusedMessageId:u,selectedIds:ne,orderedIds:b,hasList:le,blocksKeyboard:fe||o})},[d,u,ne,b,le,fe,o]);const ce=ou(b,u),be=l.useMemo(()=>({selectedIds:P,selectedCount:E,exitSelection:T,startSelectionVerb:r,orderedIds:b,allSelected:B,toggleAllLoaded:k,rowInteraction:V=>({focused:V===u,isTabStop:V===ce,isDesktop:m,onFocusRow:A,selection:{isChecked:D(V),onToggleCheck:F,onRowSelect:M,isMultiSelectMode:j,onLongPress:S}})}),[P,E,T,r,b,B,k,u,ce,m,A,D,F,M,j,S]);return a.jsxs(Os.Provider,{value:be,children:[a.jsx("div",{ref:p,className:"contents",children:v}),a.jsx(cu,{isOpen:fe,count:L?.ids.length??0,outcome:Y,isDeleting:i,onConfirm:ue,onCancel:se})]})}function dm({title:e,isDeleting:t}){const s=rr(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:d}=zu();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()},Qu=(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}},qu=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:d=!1,link:v,onClick:m,onFocusRow:g})=>{const p=ie(),b=e.id,h=Ou(b),u=s??h?.focused??!1,f=n??h?.isTabStop??!1,x=c??h?.selection,C=g??h?.onFocusRow,y=o??h?.isDesktop??!0,j=x?.isChecked??!1,T=x?.isMultiSelectMode??!1,M=x?.onToggleCheck,P=x?.onRowSelect,E=x?.onLongPress,D=l.useCallback(w=>{w.preventDefault(),w.stopPropagation(),M?.(b)},[M,b]),F=Qu(b,P),z=l.useCallback(w=>{if(!F.claimClick(w)){if(!y){if(T){w.preventDefault(),w.stopPropagation(),M?.(b);return}m?.();return}P?.(b,ms(w)),m?.()}},[F,y,T,M,P,m,b]),O=l.useCallback(()=>{E?.(b)},[E,b]),{longPressProps:B}=Nl({onLongPress:O,accessibilityDescription:j?"Deselect message":"Select message"}),k=l.useCallback(()=>{p.prefetchQuery(Ft({path:{messageId:b}}))},[p,b]),R=l.useCallback(()=>{k(),C?.(b)},[k,C,b]),A=xt({"data-list-row":"","data-message-row":!0,"data-message-id":b,...d?{role:"option","aria-selected":j}:{},tabIndex:f?0:-1,onClick:z,onMouseDown:F.onMouseDown,onContextMenu:F.onContextMenu,onMouseEnter:k,onFocus:R},y||!x?{}:B),S=_(r==="compact"?Ta({active:t,focused:u}):_("group",Ms({active:t,focused:u})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",j&&"bg-accent-soft",!y&&"min-h-11 select-none [-webkit-touch-callout:none]"),I=r==="compact"?a.jsx(Ia,{thread:e}):a.jsx(Rs,{thread:e,badge:i,selection:x?{checked:j,alwaysVisible:T,onToggle:D}:void 0});return v===void 0?a.jsx("button",{type:"button",...A,className:S,children:I}):a.jsx(aa,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...v,messageId:b},search:w=>w,variant:"row",...A,className:S,children:I})},um=l.memo(qu),Hu="Open a message first",Gu="This conversation hasn't loaded yet",Vu="The mailbox list hasn't loaded yet",Wu="Couldn't find this mailbox's account — reload to try again",Yu={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},fm=({hasThread:e,messageId:t,intelligenceOpen:s,canToggleIntelligence:n,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:d,onToggleStar:v,isStarred:m,moveContext:g,moveContextLoading:p})=>{const[b,h]=l.useState(null),u=t??null,f=E=>e?E==="move"?g?null:p?Vu:Wu:{reply:o,replyAll:i,forward:c,delete:d,flag:v}[E]?null:Gu:Hu,x=b&&b.messageId===u?b:null,C=x?f(x.action):null,y=x?.action==="move"&&x.overThread&&!!g,j=C??(x&&!y?`${Yu[x.action]} is ready — press it again`:null),T=E=>h({action:E,messageId:u,overThread:e}),M=E=>()=>T(E),P=(E,D)=>D?()=>{h(null),D()}:M(E);return a.jsx(Il,{hasThread:e,isStarred:m,onUnavailable:T,unavailableHint:j,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",v),onMove:M("move"),moveSlot:g?a.jsx(Fs,{accountId:g.accountId,currentMailboxId:g.currentMailboxId,onMove:g.onMove,label:"Move to mailbox",defaultOpen:y}):void 0,children:a.jsx(Tl,{open:s,enabled:n,onToggle:r})})};function Xu(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 mm=e=>{const{intelligenceOpen:t,onToggleIntelligence:s}=zt(),n=Yn()?.showIntelligencePane??!1,r=e??null,o=Xu(r),i=!n&&o.isOpen,{open:c,toggle:d}=o,v=l.useCallback(()=>{if(n){s();return}d()},[n,s,d]),m=l.useCallback(()=>{!n||t||s()},[n,t,s]),g=l.useCallback(()=>{if(!n){c();return}m()},[n,c,m]);return{canToggle:r!==null,isShowing:r!==null&&(n?t:i),toggle:v,open:g,drawerOpen:i,closeDrawer:o.close,railFits:n,openRail:m}},pm=(e,{toggle:t,open:s})=>{l.useEffect(()=>(e.current={toggle:t,open:s},()=>{e.current=null}),[e,t,s])},Ju=()=>{const e=ie();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])},hm=({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=Ju(),{deleteMessages:v}=Ds({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{moveMessages:m}=Ht({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{toggleStar:g}=Ga({threadId:e?.threadId??"",mailboxId:r??""}),p=l.useCallback(()=>{e&&v(d(e))},[e,d,v]),b=l.useCallback(u=>{e&&m(d(e),u)},[e,d,m]),h=l.useCallback(()=>{e&&g(e.messageId,e.hasStars)},[e,g]);return{mailboxId:r,accountId:c,isStarred:e?.hasStars,deleteThread:p,moveThread:b,toggleStar:h}},gm=(e,t)=>{const{data:s}=ee({...Wn({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]},bm=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,d]=l.useState(!1),[v,m]=l.useState(!1),g=l.useCallback(p=>{t(p.focusedMessageId),n(p.selectedIds),p.orderedIds&&o(p.orderedIds),d(p.hasList),m(p.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:g,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c,blocksKeyboard:v}},xm=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:d}=e,v=l.useCallback(()=>{i.current?.clearSelection()||s&&r()},[i,s,r]);return Io({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:v,...o}}),{goBack:v,nextMessageId:Ln(t,s,"next")??void 0,previousMessageId:Ln(t,s,"previous")??void 0}},Zu={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function ef(e){return Zu[e]??e}function vm(e,t){const{folder:s}=ws(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:Je(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function ym(e,t){const{folder:s}=ws(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 tf(e,t){const{mailboxId:s,folder:n}=ws(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Je(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:ef(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function km(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(tf(o,s)));return r}function jm(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:Je(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 wm(e){return e.filter(t=>t.muted!==!0)}function Cm(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:ye.personal},{id:"transactional",label:"Transactional",category:ye.transactional},{id:"newsletter",label:"Newsletter",category:ye.newsletter},{id:"marketing",label:"Marketing",category:ye.marketing},{id:"social",label:"Social",category:ye.social},{id:"automated",label:"Automated",category:ye.automated},{id:"uncategorized",label:"Unclassified",category:ye.uncategorized}];function Sm(e){const t=new Map(Pn.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ye.uncategorized;(t.get(r)??t.get(ye.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 Nm(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Tm(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=Bo(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=Qo(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 sf(e,t){const s=zs(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=ta(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const nf={mailbox:"mailboxes",account:"accounts",contact:"contacts"},af=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=nf[e.values];return s?t[s]??[]:[]},rf=(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=rf(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 of(e){const t=e.trim().toLowerCase();if(t==="")return Js.map(Dn);const s=[];for(const n of Js)if(s.push({rank:xs(t,`${n.name}:`,n.label),suggestion:Dn(n)}),n.values==="fixed")for(const r of n.options??[]){const o=sa(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 lf(e,t,s){const n=t.trim().toLowerCase(),r=af(e,s).map(o=>({rank:xs(n,o.value,o.label),suggestion:{value:sa(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return dr(r)}function cf(e,t,s={}){const n=zs(e,t);if(n.name===void 0)return of(n.raw);const r=ta(n.name);return r?lf(r,n.value??"",s):[]}function df(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 uf=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),ff=250,mf=2;function pf({query:e,cursor:t,enabled:s}){const{accounts:n}=zt(),{mailboxesByName:r}=na(),o=r!==void 0,i=s?sf(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",d=oa(c,ff),{data:v}=ee({...js({query:{q:d,limit:cr}}),enabled:d.length>=mf}),m=Cs({queries:n.map(h=>({...bt({path:{accountId:h.accountId}}),staleTime:1/0}))}),g=l.useMemo(()=>o?Eo(m.map(h=>h.data?.items??[]),n):[],[o,m,n]),p=l.useMemo(()=>Mo(n),[n]),b=l.useMemo(()=>(v?.items??[]).map(uf),[v]);return l.useMemo(()=>{if(!s)return[];const h=cf(e,t,{mailboxes:g,accounts:p,contacts:b});return o?h:h.filter(u=>u.value!=="in:")},[s,e,t,g,p,b,o])}const ur="remit.recentSearches",hf=5;function vs(){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 vs();const s=[t,...vs().filter(n=>n!==t)].slice(0,hf);try{localStorage.setItem(ur,JSON.stringify(s))}catch{return s}return s}const gf=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function bf(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 Im({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:d,relatedResults:v,relatedLoading:m,onSelectSearchResult:g,searchResultsLabel:p="Top matches",relatedResultsLabel:b="Related",searchResultsInBody:h=!1,refreshControl:u}){const{accounts:f,resultFolderIndex:x,searchQuery:C,searchInput:y,onSearchChange:j,onSearchClear:T,searchViewKey:M}=zt(),P=na(),E=Gn(),D=Yn(),F=Ro(),[z,O]=l.useState(!1),[B,k]=l.useState(vs),R=bo(),A=l.useRef(M);l.useEffect(()=>{A.current!==M&&(A.current=M,O(!1))},[M]);const[S,I]=l.useState(0),[w,L]=l.useState(!1),[U,Y]=l.useState(void 0),Q=pf({query:y,cursor:S,enabled:w&&y.trim().length>0}),ue=l.useCallback(te=>{const ve=df(y,S,te);j(ve.query),Y({cursor:ve.cursor})},[y,S,j]),se=xo({count:Q.length,onAccept:te=>{const ve=Q[te];ve&&ue(ve)}}),{comboboxProps:re,handleKeyDown:le}=se,ne=l.useMemo(()=>({comboboxProps:re,onKeyDown:le,onCaretChange:I,onFocusChange:L,...U?{caret:U}:{}}),[re,le,U]),fe=se.open?a.jsx(ko,{id:se.listId,suggestions:Q,activeIndex:se.activeIndex,optionId:se.optionId,onPick:ue,onHighlight:se.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,ce=y.trim().length>0,{mailboxesByName:be,accountsByName:V}=P,ae=l.useMemo(()=>qo(y,{mailboxesByName:be,accountsByName:V}),[y,be,V]),K=ae.tokens.map(te=>({label:ea(te),onRemove:()=>j(Ho(y,te))})),q=c??[],J=v??[],we=ce?[{id:"top",label:p,results:q},{id:"related",label:b,results:J}]:[],et=!(q.length+J.length>0)&&(d===!0||m===!0),{scope:Vt}=Ao(f),tt=Zo({select:te=>te.matches}),st=bi(tt),nt=xi(tt,Vt,st?x.get(st)?.role:void 0),H=nt.kind==="global"?bf([...q,...J]):void 0,wt=H?{kind:"global",onScopeToSpam:()=>E({to:"/mail/$mailboxId",params:{mailboxId:H.mailboxId},search:{q:C||void 0}})}:nt,me=J.length>0,xe=l.useMemo(()=>Mu(ae,{searchHadSemanticReach:me}),[ae,me]),_e=ce?xe:void 0,Ue=ce?{onClick:()=>{O(!1),R("properties","search")},blockedReason:bc(xe)?void 0:vo(xe.droppedFacets.map(te=>te.label))}:void 0,oe=Ue?a.jsx(Pa,{...Ue}):null,X=gf({tier:F,hasLiveInput:ce,hasCommittedQuery:C.trim().length>0,bodyRendersCommittedResults:h}),$e=te=>{k(Fn(y)),g?.(te)},_s=a.jsx(Da,{value:y,sections:we,loading:et,onSelectResult:$e,tokens:K,scope:wt}),Ce=n===void 0,Le=X?a.jsx("div",{className:"h-full overflow-y-auto",children:_s}):null,Wt=Le&&!Ce?Le:s,Ke=Le&&Ce?Le:null,Se=$o(F),at=Se&&(z||ce),rt=l.useMemo(()=>({title:e,searchResults:Ke,makeFilterSlot:oe,searchConversion:_e,navSlot:D&&!D.showNavPane&&a.jsx(W,{variant:"ghost",size:"touch",icon:a.jsx(vi,{className:"size-5"}),onClick:()=>D.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(W,{variant:"ghost",size:"touch",icon:a.jsx(yo,{className:"size-5"}),onClick:()=>O(!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(Xn,{value:y,onChange:j,onClear:T,globalFocusKey:!1,showClearButton:!1,suggest:ne})}),a.jsx(W,{variant:"ghost",size:"touch",icon:a.jsx(Lt,{className:"size-5"}),onClick:()=>{T(),O(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(Xs,{})]})}),[e,t,D,Se,at,y,j,T,ne,Ke,oe,_e,u]);if(F==="phone"&&z){const te=ve=>{k(Fn(y)),O(!1),g?.(ve)};return a.jsxs(bs.Provider,{value:rt,children:[a.jsx(Bl,{value:y,onChange:j,onClear:T,onCancel:()=>{O(!1),T()},filter:i,recentSearches:B,onPickRecent:j,makeFilter:Ue,sections:we,loading:et,onSelectResult:te,tokens:K,scope:wt,suggest:ne,suggestList:fe}),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),fe,a.jsx("div",{className:"min-h-0 flex-1",children:Wt}),o,r]})})}export{nm as $,sm as A,Zf as B,Ll as C,cu as D,jm as E,Tm as F,$s as G,Xf as H,gm as I,Ds as J,Ht as K,bm as L,um as M,hm as N,Yf as O,Wf as P,Ju as Q,Ga as R,Ql as S,Md as T,Ad as U,Ld as V,$d as W,xm as X,Xu as Y,pm as Z,Jf as _,jl as a,Ud as a0,mm as a1,fm as a2,Hf as a3,vm as a4,km as a5,wm as a6,Cm as a7,Nm as a8,ym as a9,La as aa,bf as ab,Sm as ac,qf as ad,gf as ae,Ol as af,cm as ag,Kf as ah,zu as ai,Im as aj,je as ak,ke as al,Ls as am,ht as an,Nl as ao,xt as ap,Es as aq,ms as ar,Bf as as,Qf as at,Gf as au,dm as av,rr as b,Ms as c,Vf as d,Wa as e,Kd as f,yl as g,tu as h,nu as i,im as j,Vd as k,kc as l,am as m,vl as n,rm as o,ou as p,lm as q,om as r,hl as s,Va as t,Qu as u,ru as v,Kc as w,Ya as x,em as y,tm as z};
|