@remit/web-client-dist 0.0.674 → 0.0.675
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/AppFrame-R9FR9SH9.js +1 -0
- package/assets/BriefPane-BzlqkW4r.js +1 -0
- package/assets/CalendarEventEditor-BpGmPZ2Z.js +1 -0
- package/assets/CalendarEventPopup-Brcgx7tV.js +1 -0
- package/assets/CalendarQuickCreate-CwkBXqAB.js +1 -0
- package/assets/CalendarSession--XFP5lXS.js +1 -0
- package/assets/EmptyState-dD_YhGMH.js +1 -0
- package/assets/{ErrorState-Bi4vrhhQ.js → ErrorState-nA0Ptq3g.js} +1 -1
- package/assets/FlaggedPane-BwhUf1qN.js +1 -0
- package/assets/{FullCompose-D6Xef8Ur.js → FullCompose-dJ4mfUrX.js} +1 -1
- package/assets/{LabelApplyTrigger-BnPNejnI.js → LabelApplyTrigger-BA7ANeDk.js} +1 -1
- package/assets/MailShell-0sTtK1xD.js +1 -0
- package/assets/MailViewChrome-BEx9Dr1Z.js +1 -0
- package/assets/MailboxPane-DYgnYeOy.js +1 -0
- package/assets/{MessageBody-AvWIklnv.js → MessageBody-Deha778B.js} +3 -3
- package/assets/MessageToolbar-5T47fDWC.js +1 -0
- package/assets/NavMenuButton-C-7-t18I.js +1 -0
- package/assets/OnboardingWizard-hfP07hpw.js +1 -0
- package/assets/OutboxPane-gEXLW7BJ.js +1 -0
- package/assets/_calendarObjectId-Dbrtihva.js +1 -0
- package/assets/_mailboxId-B587Zr5T.js +1 -0
- package/assets/_messageId-BxlZMqGk.js +1 -0
- package/assets/_messageId-CRIBYDCW.js +1 -0
- package/assets/_messageId-DTs144Nv.js +1 -0
- package/assets/_outboxMessageId-BxdPyrXI.js +1 -0
- package/assets/_recurrenceId-QBmk5dbN.js +1 -0
- package/assets/_threadId-8Y3P5szz.js +1 -0
- package/assets/_threadId-AMQdO9xw.js +1 -0
- package/assets/_threadId-mpk_WkaQ.js +1 -0
- package/assets/_view._date-BfJq9sBQ.js +1 -0
- package/assets/account-service-status-Kz9s3jOk.js +1 -0
- package/assets/accounts-B5C8kCn6.js +1 -0
- package/assets/advanced-CudHnY-7.js +1 -0
- package/assets/appearance-BTH52atO.js +1 -0
- package/assets/{avatar-qD7fcqFf.js → avatar-vPm9XfmM.js} +1 -1
- package/assets/{bottom-sheet-B_7iO-ln.js → bottom-sheet-BTdseD_6.js} +1 -1
- package/assets/brief-BC_KN7ph.js +1 -0
- package/assets/{brief-RK0pe25_.js → brief-DuHUqR8b.js} +1 -1
- package/assets/calendar-BQjH3OHS.js +1 -0
- package/assets/calendar-LLRgZQzl.js +1 -0
- package/assets/calendar-event-popup-Mft0N_sd.js +1 -0
- package/assets/calendar-event-sidebar-D5vjFGdS.js +1 -0
- package/assets/calendar-failure-note-BUFaaizf.js +1 -0
- package/assets/calendar-report-CzeBcU6C.js +1 -0
- package/assets/calendar-suggestion-ClsxDTZs.js +1 -0
- package/assets/calendars-zYfPB3b8.js +1 -0
- package/assets/{card-C9cgHaft.js → card-865cdsJK.js} +1 -1
- package/assets/checkbox-Qon94b1C.js +1 -0
- package/assets/{circle-check-CQPt1U9q.js → circle-check-Db07NpOC.js} +1 -1
- package/assets/{circle-check-big-ZwVj0mbk.js → circle-check-big-CyVG6r7N.js} +1 -1
- package/assets/{circle-help-BtMu5xYr.js → circle-help-CVShnhWn.js} +1 -1
- package/assets/{clock-B-eYdLBT.js → clock-B9kFW89H.js} +1 -1
- package/assets/compose._-_outboxMessageId_-BkKmzR39.js +1 -0
- package/assets/compose._-_outboxMessageId_-BnYGu6ez.js +1 -0
- package/assets/compose._-_outboxMessageId_-C5Aukg6m.js +1 -0
- package/assets/compose._-_outboxMessageId_-Ck-eEtzy.js +1 -0
- package/assets/{config-import-DhLbROIb.js → config-import-C2ovEkHy.js} +1 -1
- package/assets/{confirm-dialog-AppxcVfC.js → confirm-dialog-CgMAaLI3.js} +1 -1
- package/assets/{copy-BCzZpML3.js → copy-CIKgpUwt.js} +1 -1
- package/assets/{credential-steps-DCjuFFo-.js → credential-steps-BWguS0eW.js} +1 -1
- package/assets/{download-C6M2pRs1.js → download-A4hq8dWf.js} +1 -1
- package/assets/edit-CxVYhmi5.js +1 -0
- package/assets/edit-DXN-G3Tu.js +1 -0
- package/assets/{external-link-tmwz3hf0.js → external-link-DaKTW3eK.js} +1 -1
- package/assets/{file-json-BgVPDajK.js → file-json-DiHW8YBd.js} +1 -1
- package/assets/filters-1uKuLkQU.js +1 -0
- package/assets/{flagged-IHM3vv4x.js → flagged-BIza20sq.js} +1 -1
- package/assets/flagged-DmSptMzm.js +1 -0
- package/assets/folders-Bd16ltK4.js +1 -0
- package/assets/{help-copy-BN4-5aIP.js → help-copy-N4JgEUmu.js} +1 -1
- package/assets/{import-BT72aUBc.js → import-DJptfpxt.js} +1 -1
- package/assets/index-B18BvpkW.js +1 -0
- package/assets/index-B4pYEqZI.js +1 -0
- package/assets/index-B77HnSA5.js +1 -0
- package/assets/{index-Cb2UJhnj.js → index-BWAq8iOl.js} +7 -7
- package/assets/index-BZdYp7ae.js +1 -0
- package/assets/index-BiCNOLIH.js +1 -0
- package/assets/index-BzL5-pGT.js +349 -0
- package/assets/{index-C2Hz4y-Q.css → index-C8VKP1dT.css} +1 -1
- package/assets/index-CoCVPZ34.js +1 -0
- package/assets/index-CroyVnhC.js +1 -0
- package/assets/index-DTs144Nv.js +1 -0
- package/assets/index-DsgtllX4.js +1 -0
- package/assets/index-DtqBFgK5.js +1 -0
- package/assets/index-DupXMcS6.js +1 -0
- package/assets/{kbd-DxdiA2Fl.js → kbd-B9MFmWVU.js} +1 -1
- package/assets/labels-DeCZEWet.js +1 -0
- package/assets/mail-CSUpbRUP.js +1 -0
- package/assets/{menu-ouYQ8aI9.js → menu-CGw_RHKl.js} +1 -1
- package/assets/new-DVwQ9Ia3.js +1 -0
- package/assets/onboarding-CDWqPDW8.js +1 -0
- package/assets/{onboarding-completion-h9meGJrm.js → onboarding-completion-DbgUYeRa.js} +1 -1
- package/assets/outbox-Ct7VdX2v.js +1 -0
- package/assets/{pencil-D0Kwpd2W.js → pencil-DOoqyGzC.js} +1 -1
- package/assets/{popover-menu-CTiORP1p.js → popover-menu-CNiMANtf.js} +1 -1
- package/assets/{refresh-cw-aweb7slK.js → refresh-cw-D1SQy8O7.js} +1 -1
- package/assets/reply-CQarAZxU.js +1 -0
- package/assets/{rich-text-BlpPNJ69.js → rich-text-DgI7vzll.js} +14 -14
- package/assets/{rich-text-spellcheck-worker-provider-BVC2WqOs.js → rich-text-spellcheck-worker-provider-paPOw9As.js} +1 -1
- package/assets/{rotate-ccw-cFCdZR4R.js → rotate-ccw-DPB71584.js} +1 -1
- package/assets/{roving-focus-iNw1K_A-.js → roving-focus-Coea111y.js} +1 -1
- package/assets/{row-actions-CsY_49bo.js → row-actions-CiZruXil.js} +1 -1
- package/assets/search-mirror-_Dap9COg.js +1 -0
- package/assets/search-token-index-DQHE1g7A.js +1 -0
- package/assets/{sections-By63r1y_.js → sections-C6oVXjho.js} +1 -1
- package/assets/senders-DIVpkzIq.js +1 -0
- package/assets/settings-Cv257vpL.js +1 -0
- package/assets/settings-screen-4md2ibPl.js +1 -0
- package/assets/{shield-check-C6K5BNfE.js → shield-check-BcUXVpR8.js} +1 -1
- package/assets/sparkles-C1l6GCPT.js +1 -0
- package/assets/{suggested-vips-DnRYIdD0.js → suggested-vips-iEt-4yp9.js} +1 -1
- package/assets/suggestion._suggestionId-BQw9qGr-.js +1 -0
- package/assets/{undo-2-BV0sKXdu.js → undo-2-DHJ6nykB.js} +1 -1
- package/assets/useCalendarData-Bz4EDHDO.js +2 -0
- package/assets/useCalendarSuggestions-DcYFtQhb.js +1 -0
- package/assets/{useDebouncedValue--u19KX6h.js → useDebouncedValue-B7157ZPO.js} +1 -1
- package/assets/{useFilters-Cmf0Cndn.js → useFilters-C3bLY42W.js} +1 -1
- package/assets/{useLabels-CN56tbCw.js → useLabels-DYdHiHXI.js} +1 -1
- package/assets/useLayoutTier-5aJYrTut.js +1 -0
- package/assets/{useMediaQuery-DB2OdJvp.js → useMediaQuery-7Q3jBluO.js} +1 -1
- package/assets/useMessageBodyContent-CWGtiddz.js +1 -0
- package/assets/useQueries-Sm8S3Cgh.js +1 -0
- package/assets/useRefreshControl-bA8HK_j-.js +1 -0
- package/assets/useResultFolderIndex-BaqajWHb.js +1 -0
- package/assets/{useSignature-37xUEwqG.js → useSignature-sxHvGfKr.js} +1 -1
- package/assets/warnings-ByqpxH4J.js +5 -0
- package/index.html +2 -2
- package/package.json +1 -1
- package/assets/BriefPane-zWXuK_Pj.js +0 -1
- package/assets/CalendarComposePane-Bz_-lcWc.js +0 -1
- package/assets/CalendarComposeSeed-DrUkfGTc.js +0 -1
- package/assets/CalendarShell-BATnya1t.js +0 -1
- package/assets/EmptyState-DjcO1Fvj.js +0 -1
- package/assets/FlaggedPane-Doc9iLZn.js +0 -1
- package/assets/MailNav-C8EZGG4u.js +0 -1
- package/assets/MailShell-Dc5V-rLi.js +0 -1
- package/assets/MailViewChrome-CJkUbWPO.js +0 -1
- package/assets/MailboxPane-Bzn-4kym.js +0 -1
- package/assets/MessageToolbar-CvC2dLSg.js +0 -1
- package/assets/NavMenuButton-DSpTQKmQ.js +0 -1
- package/assets/OnboardingWizard-DzR2uArY.js +0 -1
- package/assets/OpenCalendarEvent-DuKGo-jF.js +0 -2
- package/assets/OutboxPane-Bf8T7dxW.js +0 -1
- package/assets/SignInAgain-CCZnH9Mt.js +0 -1
- package/assets/_calendarObjectId-BGZWGcp9.js +0 -1
- package/assets/_mailboxId-GGJA-jVS.js +0 -1
- package/assets/_messageId-C5LRx072.js +0 -1
- package/assets/_messageId-CCba-TdT.js +0 -1
- package/assets/_messageId-TW2iI02X.js +0 -1
- package/assets/_outboxMessageId-BwVgR2h4.js +0 -1
- package/assets/_recurrenceId-pJxBSSXe.js +0 -1
- package/assets/_threadId-B_SsLFXa.js +0 -1
- package/assets/_threadId-CL2HHRtw.js +0 -1
- package/assets/_threadId-DLvgcvlr.js +0 -1
- package/assets/_view._date-wBuxk5kG.js +0 -1
- package/assets/accounts-Dc5147aO.js +0 -1
- package/assets/advanced-C3zdMHK5.js +0 -1
- package/assets/appearance-Df1fh0eu.js +0 -1
- package/assets/attendee-row-r-oUgLyi.js +0 -1
- package/assets/bell-off-DNCJLc9z.js +0 -1
- package/assets/brief-ClYJePmh.js +0 -1
- package/assets/bug-D6xXLRSh.js +0 -1
- package/assets/calendar-Dg7vWWgr.js +0 -1
- package/assets/calendar-clash-strip-C9X1djbQ.js +0 -1
- package/assets/calendar-report-BRGottVJ.js +0 -1
- package/assets/calendar-subscription-B-aAc2Gy.js +0 -1
- package/assets/calendar-suggestion-qEC_UasM.js +0 -1
- package/assets/calendars-DBDN0ptk.js +0 -1
- package/assets/checkbox-CiQllE1Y.js +0 -1
- package/assets/chevron-left-Bt4eJ35K.js +0 -1
- package/assets/compose._-_outboxMessageId_-BMq7tjfo.js +0 -1
- package/assets/compose._-_outboxMessageId_-CbnOP01x.js +0 -1
- package/assets/compose._-_outboxMessageId_-CoBJDS24.js +0 -1
- package/assets/compose._-_outboxMessageId_-Cr5hBZLH.js +0 -1
- package/assets/filters-CwblOGNb.js +0 -1
- package/assets/flagged-DvOlELtX.js +0 -1
- package/assets/folders-lF0pnG5O.js +0 -1
- package/assets/index-BDcVKyir.js +0 -1
- package/assets/index-C5LRx072.js +0 -1
- package/assets/index-CCba-TdT.js +0 -1
- package/assets/index-CVKDJurZ.js +0 -1
- package/assets/index-CXrVnh7V.js +0 -1
- package/assets/index-CXzCthHG.js +0 -349
- package/assets/index-DRT_I4p4.js +0 -1
- package/assets/index-DSNc3rHB.js +0 -1
- package/assets/index-T04Kj7bC.js +0 -1
- package/assets/index-TW2iI02X.js +0 -1
- package/assets/index-u72ANhps.js +0 -1
- package/assets/labels-CTSVGM1M.js +0 -1
- package/assets/mail-BLRLmM-I.js +0 -1
- package/assets/mail-CHopLOA-.js +0 -1
- package/assets/map-pin-DbNUeHlR.js +0 -1
- package/assets/minus-COyPQ5q9.js +0 -1
- package/assets/new-DRfIDZVL.js +0 -1
- package/assets/onboarding-U6yiJPWH.js +0 -1
- package/assets/outbox-DFxDZsE8.js +0 -1
- package/assets/reply-B9-kr45N.js +0 -1
- package/assets/search-mirror-Bg0i4bJE.js +0 -1
- package/assets/search-query-Dq2--dgF.js +0 -1
- package/assets/search-token-index-JnwciDu0.js +0 -1
- package/assets/senders-BollE7le.js +0 -1
- package/assets/settings-aPDqsj-M.js +0 -1
- package/assets/settings-screen-DxN6mICP.js +0 -1
- package/assets/suggestion._suggestionId-m9OzQCaR.js +0 -1
- package/assets/useCalendarData-BQ_jLMR7.js +0 -1
- package/assets/useCalendarEvents-lDPF_B6_.js +0 -1
- package/assets/useCalendarFreeBusy-BFq23gzr.js +0 -1
- package/assets/useCalendarWrites-CIJUCBzo.js +0 -1
- package/assets/useCalendars-BgSJfw8G.js +0 -1
- package/assets/useLayoutTier-CUyuK30O.js +0 -1
- package/assets/useMessageBodyContent-Gq_pdN4f.js +0 -1
- package/assets/useQueries-gpmd3w5y.js +0 -1
- package/assets/useRefreshControl-DdZILsE1.js +0 -1
- package/assets/useResultFolderIndex-EOtkNq1e.js +0 -1
- package/assets/warnings-BYDfjgnx.js +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dN as Ya,b as ie,r as c,j as t,t as ke,v as Is,aa as yn,o as T,w as Za,L as jn,X as Le,aw as ss,e as Ce,dO as Xa,dP as kn,dQ as Cn,dR as Rs,E as er,d as $,T as ts,bX as sr,p as Ms,C as tr,a$ as nr,dM as Ts,dS as Nn,S as Be,dT as wn,by as lt,dU as ar,bf as rr,dV as or,dW as ir,dX as lr,dY as cr,dZ as Sn,dF as dr,aH as ur,d_ as mr,B as In,d$ as fr,e0 as gr,e1 as hr,e2 as pr,e3 as xr,e4 as br,a as te,c as ns,cZ as vr,f as ue,ao as be,g as xe,U as Ne,V as we,a4 as as,cS as Se,e5 as As,e6 as Ze,aE as yr,e7 as rs,e8 as Ie,e9 as os,ea as is,eb as ls,dl as Rn,dm as jr,s as Mn,ec as kr,bH as ct,ed as Cr,ee as Tn,bJ as Nr,ef as Hs,P as cs,G as An,Y as ds,eg as wr,eh as En,ei as Sr,ej as Ir,ek as Rr,bI as Mr,el as Tr,dL as Ar,em as Dn,ds as Es,en as Xe,eo as Er,ep as Dr,c$ as Fn,eq as Ds,er as Mt,es as Fr,et as Lr,aZ as Or,cJ as zr,bg as Ln,bc as On,bh as zn,bi as Pn,bj as Pr,eu as _r,N as _n,d5 as Ur,aC as Br,aD as $r,ev as Kr,b6 as Un,ew as qr,ex as Qr,q as Bn,ey as Hr,ez as Wr,n as Gr,D as Vr,eA as Jr,eB as Yr,cK as Zr,eC as Xr,bK as eo,eD as $n,cL as so,eE as to,eF as no,dr as Tt,bs as ao,eG as ro,eH as oo,aq as io,du as lo,dp as co,a1 as uo,dq as mo,eI as fo,eJ as go,eK as ho,eL as po,eM as xo,eN as bo,eO as At,eP as vo,eQ as yo,eR as jo,eS as ko}from"./index-BzL5-pGT.js";import{u as Co,L as No,a as wo}from"./roving-focus-Coea111y.js";import{B as Kn,j as So,S as qn,c as Io,f as Ro,a as Mo,k as To,l as Ao,m as Eo,u as Do,t as Ge}from"./search-token-index-DQHE1g7A.js";import{K as Fo}from"./kbd-B9MFmWVU.js";import{n as Qn,o as Lo,q as Oo,s as zo,j as Po,N as _o}from"./reply-CQarAZxU.js";import{C as Uo,E as Zs}from"./EmptyState-dD_YhGMH.js";import{E as Fe}from"./ErrorState-nA0Ptq3g.js";import{c as Hn,P as Bo,E as $o}from"./popover-menu-CNiMANtf.js";import{A as es}from"./avatar-vPm9XfmM.js";import{M as Ko,a as qo,b as Wn,c as Gn,s as Vn,d as Qo,e as Ho,S as Et,f as Jn,u as Yn,g as Zn,p as Wo,r as Go}from"./MessageBody-Deha778B.js";import{P as Fs,f as Vo,C as Jo,D as Pe,s as Yo,a as Zo,e as Dt,b as Xo,c as ei,d as si,g as Ft,i as ti,u as ni}from"./index-BWAq8iOl.js";import{u as dt}from"./useQueries-Sm8S3Cgh.js";import{u as ut}from"./useMediaQuery-7Q3jBluO.js";import{U as ai}from"./undo-2-DHJ6nykB.js";import{o as ri,i as Lt,h as oi}from"./useMessageBodyContent-CWGtiddz.js";import{D as ii}from"./download-A4hq8dWf.js";import{s as li,j as ci,Z as di,E as ui,C as mi,n as fi,p as gi,q as Ot,o as zt,u as hi,k as Pt,v as pi,x as xi,t as bi,y as vi,m as yi}from"./calendar-suggestion-ClsxDTZs.js";import{C as Xs}from"./calendar-failure-note-BUFaaizf.js";import{M as ji,C as ki}from"./checkbox-Qon94b1C.js";import{C as mt}from"./clock-B9kFW89H.js";import{M as Ci,a as Ni,b as wi,d as _t}from"./calendar-report-CzeBcU6C.js";import{S as Ue}from"./sparkles-C1l6GCPT.js";import{S as Si,C as Xn}from"./shield-check-BcUXVpR8.js";import{f as Ii,g as Ri,e as Mi}from"./calendar-LLRgZQzl.js";import{j as Ti,b as Ai,i as Ei,k as Di,f as Fi,l as Li,t as Oi,d as zi,r as Pi}from"./useCalendarSuggestions-DcYFtQhb.js";import{u as _i,i as Ui}from"./useLayoutTier-5aJYrTut.js";import{u as ea}from"./useDebouncedValue-B7157ZPO.js";import{r as Bi,a as $i}from"./search-scope-UI1H6AzA.js";import{M as Ki}from"./menu-CGw_RHKl.js";import{u as qi,a as Qi,j as Hi,n as Wi,o as Gi,k as Vi,S as Ji}from"./useFilters-C3bLY42W.js";import{C as xs}from"./confirm-dialog-CgMAaLI3.js";function Yi(...e){return(...s)=>{for(let n of e)typeof n=="function"&&n(...s)}}let et=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{et.delete(e)});function Zi(e,s){if(e===s)return e;let n=et.get(e);if(n)return n.forEach(a=>a.current=s),s;let r=et.get(s);return r?(r.forEach(a=>a.current=e),e):s}function Xi(...e){return e.length===1&&e[0]?e[0]:s=>{let n=!1;const r=e.map(a=>{const o=Ut(a,s);return n||=typeof o=="function",o});if(n)return()=>{r.forEach((a,o)=>{typeof a=="function"?a():Ut(e[o],null)})}}}function Ut(e,s){if(typeof e=="function")return e(s);e!=null&&(e.current=s)}function sa(...e){let s={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let a in r){let o=s[a],i=r[a];typeof o=="function"&&typeof i=="function"&&a[0]==="o"&&a[1]==="n"&&a.charCodeAt(2)>=65&&a.charCodeAt(2)<=90?s[a]=Yi(o,i):(a==="className"||a==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?s[a]=Ya(o,i):a==="id"&&o&&i?s.id=Zi(o,i):a==="ref"&&o&&i?s.ref=Xi(o,i):s[a]=i!==void 0?i:o}}return s}const Ls=ie("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const el=ie("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const sl=ie("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const ta=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const na=ie("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const tl=ie("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const nl=ie("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const ft=ie("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const aa=ie("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const gt=ie("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const $e=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const al=ie("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const rl=ie("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);const ol=ie("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),il=({address:e,showTrustedBadge:s=!1})=>{const n=s?t.jsx(Ls,{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?t.jsxs("span",{children:[t.jsx("span",{className:"text-fg",children:e.displayName}),t.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),n]}):t.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,n]})},ll=({label:e,addresses:s,showTrustedBadge:n=!1})=>{const[r,a]=c.useState(!1);if(s.length===0)return null;const o=s.length>3,i=l=>{const m=n&&l.flags?.trusted?.value===!0;return t.jsx(il,{address:l,showTrustedBadge:m})};return t.jsxs("div",{className:"flex gap-2 text-sm",children:[t.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),t.jsx("div",{className:"flex-1 min-w-0",children:r?t.jsx("div",{className:"flex flex-wrap gap-1",children:s.map((l,m)=>t.jsxs("span",{children:[i(l),m<s.length-1&&", "]},m))}):t.jsx("div",{className:"truncate",children:s.map((l,m)=>t.jsxs("span",{children:[i(l),m<s.length-1&&", "]},m))})}),o&&t.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),a(!r)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":r?"Collapse":"Expand",children:r?t.jsx(ke,{className:"h-4 w-4"}):t.jsx(Is,{className:"h-4 w-4"})})]})};function cl({state:e,onRetry:s}){return t.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:[t.jsx(Za,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-medium text-danger",children:e.title}),t.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:s,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&t.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function Bt({attachment:e}){return t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("bdi",{className:"block truncate text-sm text-fg",title:e.filename,children:e.filename}),t.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[e.typeLabel," · ",Vo(e.sizeOctets)]})]})}function dl({isDownloading:e}){return e?t.jsx(jn,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):t.jsx(ii,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})}function ul({attachments:e,onDownload:s,hasUnlistedAttachment:n=!1,onToggleOpen:r,opened:a,className:o}){return e.length===0&&!n?null:t.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:T("space-y-1.5",o),children:[t.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[t.jsx(Fs,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&t.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(i=>{const l=i.download.status==="downloading",m=i.kind==="message",v=m&&a?.attachmentId===i.attachmentId,b=j=>t.jsxs("button",{type:"button",onClick:()=>s(i.attachmentId),disabled:l,"data-testid":"attachment-download","aria-label":`Download ${i.filename}`,className:T("px-2 py-2 transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",j),children:[m?null:t.jsx(Bt,{attachment:i}),t.jsx(dl,{isDownloading:l})]});return t.jsxs("li",{className:"border-t border-line first:border-t-0",children:[m?t.jsxs("div",{className:"flex items-center",children:[t.jsxs("button",{type:"button",onClick:()=>r(i.attachmentId),"aria-expanded":v,"data-testid":"attachment-open","aria-label":`${v?"Close":"Open"} ${i.filename}`,className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken",children:[v?t.jsx(ke,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}):t.jsx(Is,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),t.jsx(yn,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),t.jsx(Bt,{attachment:i})]}),b("shrink-0")]}):b("flex w-full items-center gap-2 text-left"),v&&a&&t.jsx("section",{"aria-label":`Forwarded message ${i.filename}`,"data-testid":"forwarded-message",className:"border-t border-line px-3 py-3",children:a.content}),i.download.status==="failed"&&t.jsx(cl,{state:i.download,onRetry:()=>s(i.attachmentId)})]},i.attachmentId)})}),n&&t.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."})]})}const ml={accepted:"Coming",tentative:"Maybe",declined:"Not coming",noReply:"No reply"},fl={accepted:"text-positive",tentative:"text-warning",declined:"text-danger",noReply:"text-fg-subtle"},gl={accepted:ss,tentative:mt,declined:Le,noReply:ji};function hl({rsvp:e,className:s}){const n=gl[e];return t.jsxs("span",{className:T("inline-flex items-center gap-1 text-2xs font-medium",fl[e],s),children:[t.jsx(n,{className:"size-3"}),ml[e]]})}function pl({label:e,onUndo:s,undoLabel:n="Undo",filtersHref:r,className:a}){return t.jsxs(Ce,{tone:"accent",className:T("py-1 text-xs",a),children:[t.jsx(ai,{className:"size-3.5 shrink-0","aria-hidden":!0}),t.jsx("span",{children:e}),s&&t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),s()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:n}),r&&t.jsx("a",{href:r,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const $t=10,xl={kind:"unknown"},Ws=e=>e.toLocaleString();function bl({section:e,Row:s,selectedThreadId:n,initialExpanded:r=!1,initialCollapsed:a=!1,onShowAll:o,onRetry:i,onSelectThread:l}){const[m,v]=c.useState(r),[b,j]=c.useState(a),h=e.threads,x=e.loading===!0,p=e.error===!0,g=h.length>$t,u=!m&&g?h.slice(0,$t):h,y=e.total??xl,f=y.kind==="exact"&&(h.length>0||x)&&!p?Ws(y.value):void 0,k=y.kind==="exact"?y.value>u.length:e.atCap===!0,C=o!==void 0&&u.length>0&&k?y.kind==="exact"?`Show all ${Ws(y.value)}`:"Show all":void 0,N=h.length-u.length;return t.jsxs("div",{children:[e.label&&t.jsxs("button",{type:"button","data-section-header":"","aria-expanded":!b,onClick:()=>j(M=>!M),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 outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[t.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),f!==void 0&&t.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:f}),t.jsx(ke,{className:T("size-3 shrink-0 text-fg-subtle transition-transform duration-200",b?"rotate-0":"rotate-180")})]}),!b&&t.jsxs(t.Fragment,{children:[h.length===0?p?t.jsxs("div",{className:"flex flex-col items-center gap-1 border-b border-line px-row-inset py-4 text-center text-2xs text-danger",children:[t.jsx("span",{children:`Couldn't load ${e.label??"these messages"}`}),i&&t.jsx("button",{type:"button",onClick:i,className:"font-medium text-accent underline outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Try again"})]}):x?t.jsx("div",{className:"animate-pulse divide-y divide-line",children:[0,1,2].map(M=>t.jsx("div",{className:"px-row-inset py-3",children:t.jsx("div",{className:"h-3 w-2/3 rounded bg-surface-sunken"})},M))}):t.jsx("p",{className:"border-b border-line px-row-inset py-4 text-center text-2xs text-fg-subtle",children:e.label?`No ${e.label} mail in this brief.`:"No mail in this brief."}):t.jsx("div",{className:"divide-y divide-line",children:u.map(M=>t.jsx(s,{thread:M,active:M.id===n,onClick:()=>l?.(M.id)},M.id))}),C!==void 0?t.jsxs("button",{type:"button",onClick:o,className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[C,t.jsx(Is,{className:"ml-1 size-3"})]}):g&&t.jsxs("button",{type:"button",onClick:()=>v(M=>!M),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent outline-none transition-colors hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[m?"Show less":`Show ${Ws(N)} more`,!m&&t.jsx(ke,{className:"ml-1 size-3"})]})]})]})}function lf({sections:e,briefCategory:s="all",selectedThreadId:n,Row:r,keyboard:a,onSelectThread:o,onShowAllSection:i,onRetrySection:l,flat:m=!1,onSelectBriefCategory:v,sources:b,sourcesNote:j,onSelectSource:h,activeFilters:x,onToggleFilter:p,onClearFilters:g,hideChrome:d,defaultExpanded:u=!1}){const[y,f]=c.useState(u),k=c.useRef(null);Co({containerRef:k,itemSelector:No,enabled:!Xa(a)});const C=!m&&(s==="all"||e.some(A=>A.total!==void 0)),N=e.filter(A=>A.threads.length>0||A.total!==void 0||A.loading===!0||A.error===!0),M=e.flatMap(A=>A.threads),w=Cn,R=C?N.length===0:M.length===0,E=t.jsxs("div",{ref:k,children:[C?N.map(A=>t.jsx(bl,{section:A,Row:r,selectedThreadId:n,onSelectThread:o,onShowAll:i?()=>i(A.id):void 0,onRetry:l?()=>l(A.id):void 0},A.id)):t.jsx("div",{className:"divide-y divide-line",children:M.map(A=>t.jsx(r,{thread:A,active:A.id===n,onClick:()=>o?.(A.id)},A.id))}),R&&t.jsx("div",{className:"px-row-inset py-6 text-center text-2xs text-fg-subtle",children:"No threads match these filters."})]});return t.jsx(kn,{categories:[...Rs],filters:w,sources:b,sourcesNote:j,selectedCategory:s,activeFilters:x,expanded:y,onExpandedChange:f,onSelectCategory:A=>v?.(A),onSelectSource:h,onToggleFilter:A=>p(A),onClear:g,hideChrome:d,children:E})}const vl={ics:"Attached invitation",markup:"Structured markup",pattern:"Read from the words"},yl={ics:er,markup:sl,pattern:ol},jl={ics:"border-positive/50 text-positive",markup:"border-accent-2/50 text-accent-2",pattern:"border-warning/50 text-warning"};function kl({method:e,className:s}){const n=yl[e];return t.jsxs("span",{className:T("inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 text-2xs font-medium",jl[e],s),children:[t.jsx(n,{className:"size-3","aria-hidden":!0}),vl[e]]})}const Cl=["accepted","tentative","declined","noReply"],Nl={accepted:"coming",tentative:"maybe",declined:"not coming",noReply:"no reply"},wl=(e,s)=>e==="dismissed"?"You dismissed this":s==="declined"?"You declined":"On your calendar";function Sl({invite:e,whenText:s,calendarName:n,color:r,clashes:a,rsvp:o,onAdd:i,onTentative:l,onDecline:m,onReopen:v,onOfferOtherTimes:b,mute:j,onRemove:h,onOpenNewer:x,guests:p,busy:g=!1,failure:d="",reportHref:u,addBlocked:y,touch:f,className:k}){const C=sr(r),N=e.state==="superseded"||e.state==="cancelled",M=e.proposed.attendees,w=Cl.map(R=>({state:R,count:M.filter(E=>E.rsvp===R).length})).filter(R=>R.count>0).map(R=>`${R.count} ${Nl[R.state]}`).join(" · ");return t.jsxs("section",{className:T("flex flex-col gap-3 rounded-lg border border-line bg-surface-raised p-3",k),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:T("size-2.5 shrink-0 rounded-full",C.solid)}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-2xs uppercase tracking-wider text-fg-subtle",children:["Invitation from ",e.organizerName," · ",n]}),t.jsx(kl,{method:e.method})]}),t.jsxs("div",{className:T(N&&"opacity-60"),children:[t.jsx("h3",{className:"text-md font-semibold text-fg",children:e.proposed.title}),t.jsxs("p",{className:"mt-1 flex items-center gap-2 text-sm text-fg",children:[t.jsx(mt,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),s]}),e.proposed.location!==""&&t.jsxs("p",{className:"mt-1 flex items-center gap-2 text-sm text-fg-muted",children:[t.jsx(Ci,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.proposed.location]})]}),e.state==="superseded"&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft p-2",children:[t.jsx(tl,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-xs font-semibold text-warning",children:[e.organizerName," has sent a newer version of this."]}),t.jsxs("p",{className:"mt-1 text-xs text-fg",children:["This one is revision ",e.sequence," and is out of date. The newer message carries the one to answer."]}),x&&t.jsx($,{variant:"secondary",size:f?"md":"sm",onClick:x,className:T("mt-2",f&&"min-h-11"),children:"Open the newer invitation"})]})]}),e.state==="cancelled"&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft p-2",children:[t.jsx(Le,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-xs font-semibold text-danger",children:[e.organizerName," cancelled this."]}),t.jsx("p",{className:"mt-1 text-xs text-fg",children:"It is still on your calendar. Nothing comes off it until you say so."}),h&&t.jsxs("div",{className:T("mt-2 flex gap-2",f&&"flex-wrap"),children:[t.jsx($,{variant:"primary",size:f?"md":"sm",icon:t.jsx(ts,{className:"size-3.5"}),onClick:h,disabled:g||y!==void 0,className:T(f&&"min-h-11 flex-1"),children:"Remove from calendar"}),v&&t.jsx($,{variant:"secondary",size:f?"md":"sm",onClick:v,disabled:g,className:T(f&&"min-h-11 flex-1"),children:"Keep it"})]})]})]}),!N&&t.jsx(Uo,{clashes:a}),p??(M.length>0&&t.jsxs("p",{className:"text-2xs uppercase tracking-wider text-fg-subtle",children:[M.length," guests",w===""?"":` · ${w}`]})),d!==""&&t.jsx(Xs,{text:d,reportHref:u}),y!==void 0&&t.jsx("div",{className:"rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg",children:y}),!N&&(o==="noReply"&&e.state!=="dismissed"?t.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[t.jsxs("div",{className:T("flex gap-2",f&&"flex-wrap"),children:[t.jsx($,{variant:"primary",size:f?"md":"sm",icon:t.jsx(el,{className:"size-3.5"}),onClick:i,disabled:g||y!==void 0,className:T(f&&"min-h-11 flex-1"),children:"Add to calendar"}),l&&t.jsx($,{variant:"secondary",size:f?"md":"sm",onClick:l,disabled:g||y!==void 0,className:T(f&&"min-h-11 flex-1"),children:"Maybe"}),t.jsx($,{variant:"secondary",size:f?"md":"sm",icon:t.jsx(Le,{className:"size-3.5"}),onClick:m,disabled:g,className:T(f&&"min-h-11 flex-1"),children:"Decline"})]}),t.jsx($,{variant:"ghost",size:f?"md":"sm",onClick:b,className:T("self-start",f&&"min-h-11 w-full"),children:"Offer other times"}),j&&t.jsx($,{variant:"ghost",size:f?"md":"sm",icon:t.jsx(Kn,{className:"size-3.5"}),onClick:j.onMute,disabled:g,className:T("self-start",f&&"min-h-11 w-full"),children:`Stop offering invitations from ${j.sender}`}),t.jsxs("p",{className:"text-2xs text-fg-subtle",children:[e.organizerName," is not notified. Reader writes this to your calendar and sends no reply — tell them in the thread."]})]}):t.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-fg",children:[wl(e.state,o),e.state!=="dismissed"&&t.jsx(hl,{rsvp:o})]}),v&&t.jsx($,{variant:"ghost",size:f?"md":"sm",onClick:v,disabled:g,className:f?"min-h-11":"",children:"Change"}),o==="declined"&&t.jsx($,{variant:"secondary",size:f?"md":"sm",onClick:b,className:f?"min-h-11":"",children:"Offer other times"})]}),t.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-fg-subtle",children:[t.jsx(ss,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.organizerName," was not notified."]})]}))]})}function Il({slots:e,picked:s,onToggle:n,emptyText:r="Nothing free that day at this length.",touch:a,scroll:o,className:i}){return e.length===0?t.jsx("p",{className:T("text-xs text-fg-muted",i),children:r}):t.jsx("div",{className:T("flex gap-2",o?"overflow-x-auto pb-1":"flex-wrap",i),children:e.map(l=>{const m=s.has(l.startTime);return t.jsxs("button",{type:"button","aria-pressed":m,onClick:()=>n(l),className:T("shrink-0 rounded-md border px-2 text-xs tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",a?"min-h-11 px-3":"h-7",m?"border-accent bg-accent-soft font-semibold text-accent":"border-line bg-surface text-fg-muted hover:border-line-strong hover:text-fg"),children:[l.startTime," – ",l.endTime]},l.startTime)})})}const Rl=({trigger:e,children:s,align:n="right"})=>{const[r,a]=c.useState(!1),o=c.useRef(null),i=c.useCallback(l=>{o.current&&!o.current.contains(l.target)&&a(!1)},[]);return Ms({id:"dropdown-menu",open:r,answers:{back:()=>a(!1)}}),c.useEffect(()=>(r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[r,i]),t.jsxs("div",{ref:o,className:"relative",children:[t.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),a(!r)},className:T("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&t.jsx("div",{className:T("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:s})]})},bs=({onClick:e,disabled:s,destructive:n,children:r})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),s||e()},disabled:s,className:T("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",s&&"opacity-50 cursor-not-allowed",!s&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:r}),Ml=()=>t.jsx("div",{className:"my-1 h-px bg-line"});function ye({label:e,children:s,className:n}){return t.jsxs("section",{className:T("border-b border-line px-row-inset py-3",n),children:[t.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t.jsx("div",{className:"mt-2",children:s})]})}function Tl({data:e,actions:s,selectedEventId:n="",touch:r,className:a}){const{invite:o,prose:i,suggestions:l,day:m,dayLabel:v,suggestionsBusy:b=!1,failure:j="",suggestionsFailure:h="",reportHref:x,addBlocked:p}=e,{onReviewSuggestion:g,onOpenThread:d}=s,[u,y]=c.useState({}),f=l[0],k=f===void 0?"":u[f.suggestion.id]??"",C=f===void 0?void 0:li(f.suggestion,k),N=new Set(i?.picked??[]);return j===""&&o===void 0&&i===void 0&&l.length===0&&m.length===0?t.jsxs("div",{className:T("flex flex-1 flex-col items-center justify-center gap-2 px-row-inset py-10 text-center",a),children:[t.jsx(tr,{className:"size-6 text-fg-subtle","aria-hidden":!0}),t.jsx("p",{className:"text-sm text-fg-muted",children:"Nothing in this message is about a time."}),t.jsx("p",{className:"text-2xs text-fg-subtle",children:"An invitation, a booking or a thread proposing hours would show up here, with the day it lands on."})]}):t.jsxs("div",{className:T("flex flex-col",a),children:[j!==""&&t.jsx(Xs,{text:j,reportHref:x,className:"mx-row-inset mt-3"}),o&&t.jsx(ye,{label:"Invitation",children:t.jsx(Sl,{invite:o.invite,whenText:o.whenText,calendarName:o.calendarName,color:o.color,clashes:o.clashes,rsvp:o.rsvp,busy:o.busy,failure:o.failure,reportHref:o.reportHref,addBlocked:o.addBlocked,mute:s.onMuteInvite&&o.sender?{sender:o.sender,onMute:s.onMuteInvite}:void 0,onAdd:s.onAddInvite,onTentative:s.onTentativeInvite,onDecline:s.onDeclineInvite,onReopen:s.onReopenInvite,onOfferOtherTimes:s.onOfferOtherTimes,onRemove:s.onRemoveInvite,onOpenNewer:s.onOpenNewerInvite,touch:r})}),i&&t.jsxs(ye,{label:i.proposals.length>0?`Times named · ${i.dayLabel}`:`Other times · ${i.dayLabel}`,children:[t.jsx("ul",{className:T("flex flex-col gap-1",i.proposals.length===0&&"hidden"),children:i.proposals.map(w=>t.jsxs("li",{className:"flex items-baseline gap-2 text-xs",children:[t.jsx("span",{className:"w-24 shrink-0 truncate tabular-nums text-fg",children:w.phrase}),w.clashTitle===""?t.jsx("span",{className:"min-w-0 flex-1 truncate text-positive",children:"Nothing booked"}):t.jsxs("span",{className:"min-w-0 flex-1 truncate text-danger",children:[w.clashTitle," is already there"]})]},w.id))}),t.jsx("p",{className:"mt-3 pb-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"Free, half an hour each"}),t.jsx(Il,{slots:i.slots,picked:N,onToggle:s.onToggleSlot,touch:r,scroll:!0}),s.onReplyWithSlots?t.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[t.jsx($,{variant:"secondary",size:r?"md":"sm",icon:t.jsx(gt,{className:"size-3.5"}),onClick:s.onReplyWithSlots,disabled:N.size===0,className:T("self-start",r&&"min-h-11"),children:"Reply with these times"}),t.jsx("p",{className:"text-2xs text-fg-subtle",children:"Picked slots go into the reply as plain text. Nothing is booked."})]}):t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Picked slots go into the reply as plain text. Nothing is booked."})]}),l.length>0&&t.jsxs(ye,{label:"Read out of this thread",children:[t.jsx(ci,{hasCard:f!==void 0,remaining:l.length,blocked:C!==void 0&&!C.settled,blockedReason:di,onConfirm:()=>{f&&C?.settled&&p===void 0&&s.onAddSuggestion(f.suggestion.id,C.timeZone)},onReject:()=>{f&&s.onDismissSuggestion(f.suggestion.id)},children:f&&t.jsx(ui,{suggestion:f.suggestion,whenText:f.whenText,addLabel:"Add to calendar",zoneChoice:k,onZoneChoice:w=>y(R=>({...R,[f.suggestion.id]:w})),onAdd:w=>s.onAddSuggestion(f.suggestion.id,w),onReview:g&&(w=>g(f.suggestion.id,w)),onDismiss:()=>s.onDismissSuggestion(f.suggestion.id),onOpenThread:d&&(()=>d(f.suggestion.threadId)),busy:b,addBlocked:p!==void 0,touch:r})}),p!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg",children:p}),h!==""&&t.jsx(Xs,{text:h,reportHref:x,className:"mt-2"}),t.jsx("p",{className:"mt-2 text-2xs text-fg-subtle",children:"None of this is on your calendar, and none of it will be until you say so."})]}),m.length>0&&t.jsx(ye,{label:v,className:"border-b-0",children:t.jsx("ul",{className:"flex flex-col gap-1",children:m.map(w=>t.jsx("li",{children:t.jsx(mi,{title:w.event.title,timeText:w.timeText,color:w.color,layout:"row",density:"compact",rsvp:w.event.myRsvp,status:w.event.status,hasThread:w.event.threadId!=="",isRecurring:w.event.recurrenceRule!=="",zoneCertainty:w.event.zoneCertainty,selected:w.event.id===n,onClick:()=>s.onSelectEvent(w.event.id)})},w.event.id))})})]})}const Al=[{value:"sender",label:"Sender"},{value:"calendar",label:"Calendar"}],El={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function Dl({sender:e}){const s=El[e.trust],n=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(es,{name:e.name,email:e.email,size:"md"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),t.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),t.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?t.jsx(Ce,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):t.jsx(Ce,{tone:s.tone,dot:!0,children:s.label})}),t.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,n?` · ${n}`:""]})]})}function Fl({auth:e}){if(e.verdict==="aligned")return t.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[t.jsx(Si,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),t.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return t.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[t.jsx(al,{className:"mt-0.5 size-4 shrink-0"}),t.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 t.jsx("div",{className:"rounded-md bg-danger-soft p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx($e,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&t.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",t.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",t.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]})})}function vs({icon:e,label:s,active:n,danger:r,onClick:a,pending:o}){const i=a===void 0||o===!0;return t.jsxs("button",{type:"button",onClick:a,disabled:i,className:T("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",n?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",r&&!n&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,s]})}function ra({data:e,onClose:s,actions:n,className:r,hideCloseButton:a=!1,reportSpamPending:o=!1,notSpamPending:i=!1,calendar:l,tab:m,onTabChange:v,defaultTab:b="sender",touch:j}){const{sender:h,authenticity:x,category:p,flags:g={}}=e,[d,u]=c.useState(b),y=c.useId(),f=m??d,k=l!==void 0&&f==="calendar"?l:void 0;return t.jsxs("aside",{className:T("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",r),children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!a&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(Le,{className:"size-3.5"}),onClick:s,"aria-label":"Collapse intelligence sidebar"})]}),l&&t.jsx("div",{className:"flex shrink-0 justify-center border-b border-line px-row-inset py-2",children:t.jsx(nr,{name:y,"aria-label":"What this panel is showing",size:"sm",options:Al,value:f,onChange:C=>{m===void 0&&u(C),v?.(C)}})}),k&&t.jsx(Tl,{data:k.data,actions:k.actions,selectedEventId:k.selectedEventId,touch:j}),k===void 0&&t.jsxs(t.Fragment,{children:[t.jsx(ye,{label:"Sender",children:t.jsx(Dl,{sender:h})}),t.jsx(ye,{label:"Authenticity",children:t.jsx(Fl,{auth:x})}),t.jsx(ye,{label:"Category",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ce,{tone:Nn[p.value],children:Ts[p.value]}),p.overridden&&t.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),t.jsx("button",{type:"button",className:T("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"})]})}),t.jsxs(ye,{label:"Quick actions",children:[t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsx(vs,{icon:t.jsx(Be,{className:"size-3.5"}),label:"VIP",active:g.vip,onClick:n?.onToggleVip}),t.jsx(vs,{icon:t.jsx(Kn,{className:"size-3.5"}),label:"Mute",active:g.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&t.jsx(vs,{icon:t.jsx(nl,{className:"size-3.5"}),label:i?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:i}),n?.onReportSpam&&t.jsx(vs,{icon:t.jsx(rl,{className:"size-3.5"}),label:o?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:o})]}),n?.onNotSpam&&t.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),t.jsx(ye,{label:"Coming soon",className:"border-b-0 opacity-70",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[t.jsx(Ue,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),t.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[t.jsx(Ue,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),t.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})]})}function Ll({open:e=!1,enabled:s=!0,onToggle:n,className:r}){return t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(wn,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!s,onClick:n,className:T(e&&"bg-accent-2-soft text-accent-2",r)})}function cf({hints:e=So,className:s}){return e.length===0?null:t.jsx("footer",{className:T("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",s),children:e.map(n=>t.jsx(Ol,{hint:n},n.label))})}function Ol({hint:e}){return t.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(s=>t.jsx(Fo,{children:s},s)),t.jsx("span",{children:e.label})]})}function zl({hasThread:e,onUnavailable:s,unavailableHint:n,isStarred:r,showTriage:a=!0,onReply:o,onReplyAll:i,onForward:l,onDelete:m,onToggleStar:v,moveSlot:b,onMove:j,replyTitle:h="Reply (r)",replyAllTitle:x="Reply all (a)",forwardTitle:p="Forward (f)",deleteTitle:g="Move to Trash (#)",flagTitle:d="Star (s)",children:u,className:y}){const f=(k,C)=>()=>{if(!e||!C){s?.(k);return}C()};return t.jsxs("div",{className:"relative",children:[t.jsxs("header",{className:T("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",y),children:[t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(gt,{className:"size-4"}),title:h,"aria-label":"Reply",onClick:f("reply",o)}),t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(aa,{className:"size-4"}),title:x,"aria-label":"Reply all",onClick:f("replyAll",i)}),t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(na,{className:"size-4"}),title:p,"aria-label":"Forward",onClick:f("forward",l)}),a&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(ts,{className:"size-4"}),title:g,"aria-label":"Move to Trash",onClick:f("delete",m)}),b??t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(lt,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:f("move",j)}),t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(Be,{className:T("size-4",r&&"fill-warning text-warning")}),title:d,"aria-label":"Star","aria-pressed":r,onClick:f("flag",v)})]}),t.jsx("div",{className:"flex-1"}),u]}),n&&t.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:n})]})}const st=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),Kt=e=>e.shiftKey||e.metaKey||e.ctrlKey,Pl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",_l=(e,s)=>!s&&e>0,Ul=(e,s,n)=>{const r=e.indexOf(n);if(r===-1)return[];const a=s===void 0?-1:e.indexOf(s);if(a===-1)return[n];const o=Math.min(a,r),i=Math.max(a,r);return e.slice(o,i+1)},Bl=(e,s,n,r)=>s!==void 0&&e.includes(s)?s:n!==void 0&&e.includes(n)?n:r,$l=(e,s)=>{const n=new Set(s),r=new Set;for(const a of e)n.has(a)&&r.add(a);return r},Kl=(e,s,n)=>{if(e.length===0)return;const r=s===void 0?-1:e.indexOf(s);if(r===-1)return n>0?e[0]:e[e.length-1];const a=Math.min(Math.max(r+n,0),e.length-1);return e[a]},ql=e=>{const[s,n]=c.useState(()=>new Set(e?.initialSelectedIds)),[r,a]=c.useState(void 0),o=c.useCallback(g=>s.has(g),[s]),i=c.useCallback(g=>{a(g),n(d=>{const u=new Set(d);return u.has(g)?u.delete(g):u.add(g),u})},[]),l=c.useCallback(g=>{a(g),n(d=>{if(d.has(g))return d;const u=new Set(d);return u.add(g),u})},[]),m=c.useCallback(g=>{n(d=>{if(!d.has(g))return d;const u=new Set(d);return u.delete(g),u})},[]),v=c.useCallback(g=>{n(new Set(g))},[]),b=c.useCallback(()=>{a(void 0),n(new Set)},[]),j=c.useCallback(g=>{n(d=>g.every(y=>d.has(y))?new Set:new Set(g))},[]),h=c.useCallback(g=>{a(g)},[]),x=c.useCallback(g=>{n(d=>{if(d.size===0)return d;const u=$l(d,g);return u.size===d.size?d:u})},[]),p=c.useCallback((g,d,u)=>{const y=Bl(g,r,u,d);n(f=>{const k=Ul(g,y,d);if(k.length===0)return f;const C=new Set(f);for(const N of k)C.add(N);return C}),a(y)},[r]);return{selectedIds:s,selectedCount:s.size,hasSelection:s.size>0,isSelected:o,toggle:i,select:l,deselect:m,selectAll:v,clearSelection:b,toggleAll:j,selectRange:p,setAnchor:h,anchorId:r,intersectWith:x}},Ns={delete_failed:{label:"Not deleted",title:"This message was not deleted",detail:"Remit removed it here first, then refused to finish the delete on the mail server — most often because the Trash folder it was headed for is not there any more. The message is back in this folder because that is where the server still has it.",retryLabel:"Delete again",retryPendingLabel:"Deleting…"},move_failed:{label:"Not moved",title:"This message was not moved",detail:"Remit filed it here first, then could not finish the move on the mail server and stopped trying. The message is back in this folder because that is where the server still has it. The folder you picked is not recorded, so moving it again means choosing one.",retryLabel:"Move again",retryPendingLabel:"Moving…"}};function oa({settlement:e,className:s}){const n=Ns[e];return t.jsxs(Ce,{tone:"danger",className:T("shrink-0",s),title:n.title,"data-settlement":e,children:[t.jsx(Xn,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{children:n.label})]})}function Ql({settlement:e,onRetry:s,action:n,retryPending:r,reportHref:a,className:o}){const i=Ns[e];return t.jsxs("div",{role:"alert","data-testid":"message-settlement-notice","data-settlement":e,className:T("flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",o),children:[t.jsx(Xn,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-medium text-danger",children:i.title}),t.jsx("p",{className:"mt-1 break-words text-fg-muted",children:i.detail}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[n,s&&t.jsx("button",{type:"button",onClick:s,disabled:r,className:"font-medium text-accent hover:underline disabled:opacity-50",children:r?i.retryPendingLabel:i.retryLabel}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const ia="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",la=({active:e,focused:s})=>T("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",ia,e?"bg-accent-2-soft":s?"bg-surface-sunken":"hover:bg-surface-sunken",s&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),ht=({active:e,focused:s})=>T("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",ia,e?"bg-accent-2-soft":s?"bg-surface-sunken":"hover:bg-surface-sunken",s&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function ca({thread:e}){const s=!e.isRead;return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?t.jsx($e,{className:"size-3.5 text-danger"}):e.starred?t.jsx(Be,{className:"size-3 fill-warning text-warning"}):s?t.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),t.jsx("span",{className:T("w-36 shrink-0 truncate text-xs",s?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),t.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[t.jsx("span",{className:T(s?"font-medium text-fg":"text-fg-muted"),children:e.subject}),t.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&t.jsx(Fs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),e.settlement&&t.jsx(oa,{settlement:e.settlement}),t.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function qt(e,s){const n=s?.trim();if(!n)return e;const r=e.toLowerCase(),a=n.toLowerCase(),o=[];let i=0,l=r.indexOf(a,i),m=0;for(;l!==-1;)l>i&&o.push(e.slice(i,l)),o.push(t.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(l,l+a.length)},m++)),i=l+a.length,l=r.indexOf(a,i);return i<e.length&&o.push(e.slice(i)),o}function Hl({thread:e,badge:s,highlightQuery:n}){const r=!e.isRead;return t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[t.jsxs("span",{className:T("flex min-w-0 items-center gap-1.5 truncate text-sm",r?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),t.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&t.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:T("truncate text-sm",r?"text-fg":"text-fg-muted"),children:qt(e.subject,n)}),e.suspicious&&t.jsx($e,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&t.jsx(Be,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&t.jsx(Fs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:qt(e.snippet,n)}),e.category&&e.category!=="personal"&&t.jsx(Ce,{tone:Nn[e.category],className:"shrink-0",children:ar(e.category)}),e.labels?.map(a=>t.jsx(rr,{label:a,className:"max-w-20"},a.labelId)),e.settlement&&t.jsx(oa,{settlement:e.settlement}),s]})]})}function Wl({thread:e,selection:s}){if(!s)return t.jsx(es,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:n,alwaysVisible:r}=s;return t.jsxs("span",{className:"relative size-7 shrink-0",children:[t.jsx(es,{name:e.fromName,email:e.fromEmail,size:"sm",className:T("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(n||r)&&"opacity-0")}),t.jsx("span",{role:"button",tabIndex:-1,onClick:s.onToggle,onKeyDown:a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),a.stopPropagation(),s.onToggle(a))},className:T("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",r?"flex":"hidden sm:flex",n?"bg-accent border-accent text-accent-fg opacity-100":r?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":n?"Deselect message":"Select message",children:n&&t.jsx(ss,{className:"size-3"})})]})}function pt({thread:e,selection:s,badge:n,highlightQuery:r}){const a=!e.isRead;return t.jsxs(t.Fragment,{children:[a&&t.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),t.jsx(Wl,{thread:e,selection:s}),t.jsx(Hl,{thread:e,badge:n,highlightQuery:r})]})}const da=e=>({...wo,[or]:"","data-message-id":e.id});function df({thread:e,active:s,focused:n,tabIndex:r,onClick:a}){return t.jsx("button",{type:"button",...da(e),tabIndex:r,onClick:a,className:la({active:s,focused:n}),children:t.jsx(ca,{thread:e})})}function uf({thread:e,active:s,focused:n,tabIndex:r,selection:a,onClick:o}){return t.jsx("button",{type:"button",...da(e),tabIndex:r,onClick:o,className:T("group",ht({active:s,focused:n})),children:t.jsx(pt,{thread:e,selection:a})})}let _e;const ua=5e3;function ma(e){e.preventDefault(),ws()}function ws(){_e!==void 0&&(clearTimeout(_e),_e=void 0,document.removeEventListener("contextmenu",ma,!0),document.removeEventListener("pointerup",ws,!0))}function Gl(){_e===void 0?(document.addEventListener("contextmenu",ma,!0),document.addEventListener("pointerup",ws,!0)):clearTimeout(_e),_e=setTimeout(ws,ua)}let Cs;function fa(e){e.preventDefault(),e.stopPropagation(),Je()}function Je(){Cs!==void 0&&(clearTimeout(Cs),Cs=void 0,document.removeEventListener("click",fa,!0),document.removeEventListener("pointerdown",Je,!0))}function Vl(){Je(),document.addEventListener("click",fa,!0),document.addEventListener("pointerdown",Je,!0),Cs=setTimeout(Je,ua)}const Jl=500,Yl=36,Zl=e=>({delay:e,threshold:Yl,triggerAllEvents:!0,pointer:{keys:!1}}),Xl=e=>e.event.type==="pointerdown"&&e.first,ec={onPointerDown:e=>{e.pointerType!=="touch"&&e.pointerType!=="pen"||Gl()}};function sc({onLongPress:e,isDisabled:s,delayMs:n=Jl,accessibilityDescription:r}){const a=ir(o=>{Xl(o)&&(Vl(),e())},{...Zl(n),enabled:!s});return{longPressProps:sa(a(),ec,{"aria-description":r})}}const Ve="min-h-11 min-w-11 px-0";function ga({hasThread:e,onReply:s,onReplyAll:n,onForward:r,isStarred:a,onToggleStar:o,onDelete:i,isRead:l,onToggleRead:m,moveSlot:v,overflowItems:b=[],onUnavailable:j,unavailableHint:h,className:x}){const p=(d,u)=>()=>{if(!e){j?.(d);return}u?.()},g=m?[{key:"toggle-read",label:l?"Mark as unread":"Mark as read",icon:l?t.jsx(yn,{className:"size-4"}):t.jsx(ft,{className:"size-4"}),onSelect:p("toggleRead",m)}]:[];return t.jsxs("div",{className:T("relative",x),children:[t.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[s&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(gt,{className:"size-5"}),onClick:p("reply",s),"aria-label":"Reply",title:"Reply",className:Ve}),n&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(aa,{className:"size-5"}),onClick:p("replyAll",n),"aria-label":"Reply all",title:"Reply all",className:Ve}),r&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(na,{className:"size-5"}),onClick:p("forward",r),"aria-label":"Forward",title:"Forward",className:Ve}),t.jsx("div",{className:"flex-1"}),o&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(Be,{className:T("size-5",a&&"fill-warning text-warning")}),onClick:p("star",o),"aria-label":a?"Unstar":"Star","aria-pressed":a,title:a?"Unstar":"Star",className:Ve}),v,i&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(ts,{className:"size-5"}),onClick:p("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:Ve}),t.jsx(Hn,{triggerLabel:"More actions",items:[...g,...b]})]}),!e&&h&&t.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:h})]})}function ha({message:e,onClick:s,isFocused:n,isUnread:r,trailing:a}){const o=t.jsxs(t.Fragment,{children:[t.jsx(Is,{className:"size-3.5 shrink-0 text-fg-subtle"}),t.jsxs("div",{className:"relative shrink-0",children:[t.jsx(es,{name:e.fromName,email:e.fromEmail,size:"md"}),r&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),t.jsx("span",{className:T("w-36 shrink-0 truncate text-sm",r?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),a??t.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=T("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",n&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return s?t.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:s,onKeyDown:l=>{lr(l)&&(l.preventDefault(),s())},className:T(i,"cursor-pointer"),children:o}):t.jsx("div",{className:i,children:o})}function pa({message:e,warning:s,onHeaderClick:n,isFocused:r,senderBadge:a,trailing:o,to:i,indicators:l,actionMenu:m,actionBar:v,body:b}){const j=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,a]}),o??t.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),t.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&t.jsx("div",{className:"text-xs text-fg-subtle",children:i??t.jsxs(t.Fragment,{children:["to ",e.toLabel]})})]});return t.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[t.jsxs("div",{className:T("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",r&&"ring-1 ring-inset ring-accent/30"),children:[n?t.jsx("button",{type:"button",onClick:n,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:t.jsx(ke,{className:"size-3.5"})}):t.jsx(ke,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),t.jsx(es,{name:e.fromName,email:e.fromEmail,size:"md"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[n?t.jsx("button",{type:"button",onClick:n,className:"w-full text-left",children:j}):j,l]}),m&&t.jsx("div",{className:"shrink-0",children:m})]}),s&&t.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[t.jsx($e,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),s," ",t.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),v&&t.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:v}),t.jsx(Ko,{children:b??t.jsx(qo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function tc({thread:e,onBack:s,intelligence:n,intelligenceOpen:r,onToggleIntelligence:a,actions:o,children:i,onSwipeNext:l,onSwipePrevious:m}){const v=cr({onSwipeLeft:l,onSwipeRight:m}),[b,j]=c.useState(!1),h=a!==void 0,x=h?r??!1:b,p=!!n||h,g=()=>{if(h){a?.();return}j(u=>!u)},d=()=>{if(h){x&&a?.();return}j(!1)};return t.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(Sn,{className:"size-4"}),onClick:s,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),t.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),p&&t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(wn,{className:"size-4"}),onClick:g,"aria-label":x?"Hide intelligence panel":"Show intelligence panel","aria-pressed":x,title:"Intelligence",className:T("shrink-0",x&&"bg-accent-2-soft text-accent-2")})]}),t.jsx(dr.Provider,{value:v.enabled,children:t.jsx("div",{ref:v.ref,className:"flex-1 overflow-y-auto",style:{touchAction:v.touchAction},...v.bind(),children:i??[...e.messages].reverse().map(u=>{const y=f=>f?()=>f(u.id):void 0;return u.expanded?t.jsx(pa,{message:u,warning:e.warning,onHeaderClick:y(o?.onToggleExpand),actionBar:t.jsx(ga,{hasThread:!0,onReply:y(o?.onReply),onReplyAll:y(o?.onReplyAll),onForward:y(o?.onForward),onToggleStar:y(o?.onToggleStar),onDelete:y(o?.onDelete),onToggleRead:y(o?.onToggleRead),moveSlot:o?.moveSlot?.(u.id)})},u.id):t.jsx(ha,{message:u,onClick:y(o?.onToggleExpand)},u.id)})})}),n&&!h&&t.jsx(ur,{open:x,onClose:d,title:"Intelligence",anchor:"right",className:"p-0",children:t.jsx(ra,{data:n,onClose:d,className:"h-full w-full border-l-0"})})]})}function nc(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 ac({result:e,onClick:s,query:n,showFolder:r=!0}){const a=r&&e.folder?mr(e.folder):void 0;return t.jsx("button",{type:"button",onClick:s,className:T("group",ht({}),"border-b border-line"),children:t.jsx(pt,{thread:nc(e),highlightQuery:n,badge:t.jsxs(t.Fragment,{children:[a&&t.jsx(Ce,{tone:"neutral",className:"shrink-0",children:a}),e.category&&t.jsx(Ce,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label})]})})})}const rc=e=>e===1?"result":"results";function oc({count:e,onScopeToSpam:s}){return t.jsx(In,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 text-xs text-fg-muted",children:e.kind==="exact"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e.value.toLocaleString()})," ",`${rc(e.value)} from Spam`]}):"Results from Spam"}),t.jsx($,{variant:"ghost",size:"sm",onClick:s,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const Qt=6,ic={kind:"global"},Ht={kind:"unknown"},lc=e=>e.kind==="folder"&&e.role==="junk",cc=e=>e.folder?.role==="junk";function dc(e){const s=[],n=[];for(const r of e)cc(r)?n.push(r):s.push(r);return{kept:s,spam:n}}function xa({onClick:e,blockedReason:s}){const n=c.useId(),[r,a]=c.useState(!1);return t.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{if(s){a(!0);return}e()},"aria-describedby":s?n:void 0,className:T("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",s?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[t.jsx(fr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),t.jsx("span",{children:"Make this a filter"})]}),s&&t.jsx(gr,{id:n,reason:s,nudged:r,className:"px-2 pt-1 text-2xs text-warning"})]})}function uc({section:e,query:s,onSelectResult:n,showFolder:r}){const[a,o]=c.useState(e.initialCollapsed??!1),[i,l]=c.useState(!1),m=e.results.length>Qt,b=!i&&m?e.results.slice(0,Qt):e.results,j=e.results.length-b.length;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","aria-expanded":!a,onClick:()=>o(h=>!h),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:[t.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),t.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),t.jsx(ke,{className:T("size-3 shrink-0 text-fg-subtle transition-transform duration-200",a?"rotate-0":"rotate-180")})]}),!a&&t.jsxs(t.Fragment,{children:[b.map(h=>t.jsx(ac,{result:h,query:s,showFolder:r,onClick:n?()=>n(h):void 0},h.id)),m&&t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),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 ${j} more`,!i&&t.jsx(ke,{className:"ml-1 size-3"})]})]})]})}function ba({value:e,recentSearches:s,onPickRecent:n,sections:r,loading:a,onSelectResult:o,tokens:i,scope:l=ic,makeFilter:m}){if(!(e.trim().length>0))return s&&s.length>0?t.jsxs("div",{className:"flex flex-col",children:[t.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),s.map(R=>t.jsxs("button",{type:"button",onClick:()=>n?.(R),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:[t.jsx(mt,{className:"size-4 shrink-0 text-fg-subtle"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:R})]},R))]}):t.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 b=i&&i.length>0&&t.jsx(hr,{tokens:i}),j=m&&t.jsx(xa,{...m});if(a)return t.jsxs("div",{className:"flex flex-col",children:[j,b,t.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(R=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),t.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),t.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},R))})]});const h=l.kind==="global",x=lc(l)||l.kind==="collection",p=h||l.kind==="collection",g=(r??[]).map(R=>{if(x)return{section:R,spam:[]};const{kept:E,spam:A}=dc(R.results);return{section:{...R,results:E},spam:A}}),d=g.map(R=>R.section),u=g.reduce((R,E)=>R+E.spam.length,0),f=(l.kind==="global"?l.spamCount:void 0)??Ht,k=u>0||f.kind==="exact"&&f.value>0,N=f.kind==="exact"&&f.value===0&&u>0?Ht:f,M=l.kind==="global"&&k&&l.onScopeToSpam!==void 0?t.jsx(oc,{count:N,onScopeToSpam:l.onScopeToSpam}):void 0;return d.some(R=>R.results.length>0)?t.jsxs("div",{className:"flex flex-col",children:[j,b,M,d.filter(R=>R.results.length>0).map(R=>t.jsx(uc,{section:R,query:e,showFolder:p,onSelectResult:o},R.id))]}):t.jsxs("div",{className:"flex flex-col",children:[j,b,M,t.jsxs("div",{className:"px-row-inset py-10 text-center",children:[t.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),t.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function mc({value:e,onChange:s,onClear:n,onCancel:r,filter:a,recentSearches:o,onPickRecent:i,sections:l,loading:m,onSelectResult:v,tokens:b,chips:j,onRemoveChip:h,scope:x,makeFilter:p,suggest:g,suggestList:d}){const u=t.jsx(ba,{value:e,recentSearches:o,onPickRecent:i,sections:l,loading:m,onSelectResult:v,tokens:b,scope:x,makeFilter:p});return t.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(qn,{value:e,onChange:s,onClear:n,chips:j,onRemoveChip:h,globalFocusKey:!1,showClearButton:!1,suggest:g})}),t.jsx($,{variant:"ghost",size:"sm",icon:t.jsx(Le,{className:"size-4"}),onClick:r,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),d,a&&e.trim().length===0?t.jsx(pr,{children:t.jsx(kn,{...a,children:u})}):t.jsx("div",{className:"flex-1 overflow-y-auto",children:u})]})}const Wt=e=>e.toLocaleString();function Gt({selectAll:e,selecting:s,className:n}){return t.jsx(ki,{className:n,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:t.jsx("span",{className:"font-medium text-accent",children:e.checked&&s?"Deselect all":"Select all"})})}function fc({title:e,count:s,onCancel:n,onDelete:r,onMove:a,onOrganize:o,onJunk:i,onMarkRead:l,navSlot:m,titleMeta:v,searchSlot:b,searchField:j,idleSlot:h,overflowSlot:x,isBusy:p=!1,isCounting:g=!1,selectAll:d,statusLabel:u,progress:y,notice:f}){const k=s>0||g,C=d?.checked?`All ${Wt(s)} loaded selected`:`${Wt(s)} ${s===1?"message":"messages"} selected`,N=[];return i&&!p&&!g&&N.push({key:"junk",label:"Junk",icon:t.jsx($e,{className:"size-4"}),onSelect:i}),l&&!p&&!g&&N.push({key:"mark-read",label:"Mark read",icon:t.jsx(ft,{className:"size-4"}),onSelect:l}),t.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[t.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[k?t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(Sn,{className:"size-5"}),onClick:n,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):m,d&&t.jsx(Gt,{selectAll:d,selecting:k,className:"hidden shrink-0 pr-2 md:flex"}),k?t.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:u??C}):j?t.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:j}):t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),v,b]}),k&&!g&&t.jsxs(t.Fragment,{children:[t.jsx($,{variant:"ghost",size:"touch",icon:p?t.jsx(jn,{className:"size-5 animate-spin"}):t.jsx(ts,{className:"size-5 text-danger"}),onClick:p?void 0:r,"aria-label":"Move selected messages to Trash","aria-busy":p||void 0,className:"shrink-0"}),!p&&a&&t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(lt,{className:"size-5"}),onClick:a,"aria-label":"Move selected messages",className:"shrink-0"}),!p&&o&&t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(Ue,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),k&&t.jsx(Hn,{triggerLabel:"More actions",items:N,className:"shrink-0",children:!p&&!g&&x})]}),!k&&h,k&&d&&t.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:t.jsx(Gt,{selectAll:d,selecting:k,className:"w-full"})}),y&&t.jsx("div",{className:"px-row-inset pb-2",children:t.jsx(xr,{value:y.value,max:y.max,tone:y.tone})}),f&&t.jsx(In,{"data-selection-notice":"",tone:f.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.text&&t.jsx("span",{children:f.text}),f.action&&t.jsx($,{variant:"ghost",size:"md",onClick:f.action.onClick,className:"-my-1 min-h-11 shrink-0",children:f.action.label})]})})]})}const va={id:"unread",label:"Unread"},gc={id:"flagged",label:"Starred"},ya={id:"attachment",label:"Has attachment"};function hc(e){if(!(e.length<=1))return e.map(s=>({id:s.id,label:s.label,count:s.count,active:s.active}))}function mf(e=[]){return{categories:[...Rs],filters:Cn,sources:hc(e)}}function ff(){return{categories:[...Rs],filters:[va,gc,ya]}}function gf(){return{categories:[...Rs],filters:[va,ya]}}function pc(e,s){return e.endsWith(s)?e.length===s.length||e[e.length-s.length-1]===".":!1}function xc(e,s){const n=e.length-s.length-2,r=e.lastIndexOf(".",n);return r===-1?e:e.slice(r+1)}function bc(e,s,n){if(n.validHosts!==null){const a=n.validHosts;for(const o of a)if(pc(s,o))return o}let r=0;if(s.startsWith("."))for(;r<s.length&&s[r]===".";)r+=1;return e.length===s.length-r?null:xc(s,e)}const Gs=/[\t\n\r]/g;let tt=!1;function Vt(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function Jt(e,s,n){const r=n-s,a=e.charCodeAt(s)|32;if(r===2)return a===119&&(e.charCodeAt(s+1)|32)===115?1:0;if(r===3){const o=e.charCodeAt(s+1)|32,i=e.charCodeAt(s+2)|32;return a===119&&o===115&&i===115||a===102&&o===116&&i===112?1:0}else if(r===4){const o=e.charCodeAt(s+1)|32,i=e.charCodeAt(s+2)|32,l=e.charCodeAt(s+3)|32;return a===104&&o===116&&i===116&&l===112?1:a===102&&o===105&&i===108&&l===101?2:0}else if(r===5)return a===104&&(e.charCodeAt(s+1)|32)===116&&(e.charCodeAt(s+2)|32)===116&&(e.charCodeAt(s+3)|32)===112&&(e.charCodeAt(s+4)|32)===115?1:0;return 0}function Ye(e,s,n=!1){let r=0,a=e.length,o=!1,i=!1;if(tt=!1,!s){if(e.startsWith("data:"))return null;for(;r<e.length&&e.charCodeAt(r)<=32;)r+=1;for(;a>r+1&&e.charCodeAt(a-1)<=32;)a-=1;if(e.charCodeAt(r)===47&&e.charCodeAt(r+1)===47)r+=2;else{const d=e.indexOf(":/",r);if(d!==-1){const u=Jt(e,r,d);if(u===1)for(i=!0,r=d+2;e.charCodeAt(r)===47||e.charCodeAt(r)===92;)r+=1;else if(u===2){i=!0,r=d+1;let y=0;for(;(e.charCodeAt(r)===47||e.charCodeAt(r)===92)&&y<2;)r+=1,y+=1;if(y<2)return null}else{for(let y=r;y<d;y+=1){const f=e.charCodeAt(y)|32;if(!(f>=97&&f<=122||f>=48&&f<=57||f===46||f===45||f===43)){const k=e.charCodeAt(y);return k===9||k===10||k===13?Ye(e.replace(Gs,""),s,n):null}}if(e.charCodeAt(d+2)===47)r=d+3;else return null}}else if(e.charCodeAt(r)!==91){let u=-1;for(let y=r;y<a;y+=1){const f=e.charCodeAt(y);if(f===9||f===10||f===13)return Ye(e.replace(Gs,""),s,n);if(f===58){u=y;break}if(f===47||f===92||f===63||f===35)break}if(u!==-1){let y=!1;for(let f=u+1;f<a;f+=1){const k=e.charCodeAt(f);if(k===47||k===92||k===63||k===35)break;if(k===64){y=!0;break}}if(!y){let f=!0,k=u+1;for(;k<a;k+=1){const C=e.charCodeAt(k);if(C===47||C===92||C===63||C===35)break;if(C<48||C>57){f=!1;break}}if(k===u+1&&(f=!1),!f){const C=Jt(e,r,u);if(C===0){let N=!1;for(let M=u+1;M<a;M+=1){const w=e.charCodeAt(M);if(w===47||w===92||w===63||w===35)break;if(w===58){N=!0;break}}if(!N)return null}else if(i=!0,r=u+1,C===2){let N=0;for(;(e.charCodeAt(r)===47||e.charCodeAt(r)===92)&&N<2;)r+=1,N+=1;if(N<2)return null}else for(;e.charCodeAt(r)===47||e.charCodeAt(r)===92;)r+=1}}}}}let m=-1,v=-1,b=-1,j=-1,h=!1,x=n,p=r-1,g=-1;if(n&&r<a){const d=e.charCodeAt(r);(!(Vt(d)||d===46||d===95)||d===45)&&(x=!1)}for(let d=r;d<a;d+=1){const u=e.charCodeAt(d);if(u<64)if(u===47||u===35||u===63){a=d;break}else u===58?(j===-1&&(j=d),b=d):u===9||u===10||u===13?h=!0:n&&(u===46?((d-p>64||g===46||g===45)&&(x=!1),p=d):(u<48||u>57)&&(u!==45||g===46)&&(x=!1));else if(i&&u===92){a=d;break}else u===64?(m=d,j=-1):u===93?v=d:u>=65&&u<=90?o=!0:n&&!Vt(u)&&(x=!1);n&&(g=u)}if(h)return Ye(e.replace(Gs,""),s,n);if(m!==-1&&m>=r&&m<a&&(r=m+1),e.charCodeAt(r)===91)return v!==-1?e.slice(r+1,v).toLowerCase():null;if(b!==-1&&b>r&&b<a&&j===b&&(a=b),r>=a)return null;n&&x&&m===-1&&b===-1&&v===-1&&e.charCodeAt(a-1)!==46&&a-r<=255&&a-p-1<=63&&g!==45&&(tt=!0)}for(;a>r+1&&e.charCodeAt(a-1)===46;)a-=1;const l=r!==0||a!==e.length?e.slice(r,a):e;return o?l.toLowerCase():l}function vc(e){if(e.length<7||e.length>15)return!1;let s=0;for(let n=0;n<e.length;n+=1){const r=e.charCodeAt(n);if(r===46)s+=1;else if(r<48||r>57)return!1}return s===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function yc(e){if(e.length<3)return!1;let s=e.startsWith("[")?1:0,n=e.length;if(e[n-1]==="]"&&(n-=1),n-s>39)return!1;let r=!1;for(;s<n;s+=1){const a=e.charCodeAt(s);if(a===58)r=!0;else if(!(a>=48&&a<=57||a>=97&&a<=102||a>=65&&a<=70))return!1}return r}function jc(e){return yc(e)||vc(e)}function Yt(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function Zt(e){if(e.length>255||e.length===0||!Yt(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let s=-1,n=-1;const r=e.length;for(let a=0;a<r;a+=1){const o=e.charCodeAt(a);if(o===46){if(a-s>64||n===46||n===45)return!1;s=a}else if(!(Yt(o)||o===45||o===95)||o===45&&n===46)return!1;n=o}return r-s-1<=63&&n!==45}function kc({allowIcannDomains:e=!0,allowPrivateDomains:s=!1,detectIp:n=!0,detectSpecialUse:r=!1,extractHostname:a=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:l=!0}){return{allowIcannDomains:e,allowPrivateDomains:s,detectIp:n,detectSpecialUse:r,extractHostname:a,mixedInputs:o,validHosts:i,validateHostname:l}}const Cc=kc({});function Nc(e){return Cc}function wc(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function Sc(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 Ic(e,s,n,r,a){const o=Nc();if(typeof e!="string")return a;let i=!1;return o.extractHostname?o.mixedInputs?(i=Zt(e),a.hostname=Ye(e,i,o.validateHostname)):a.hostname=Ye(e,!1,o.validateHostname):a.hostname=e,o.detectIp&&a.hostname!==null&&(a.isIp=jc(a.hostname),a.isIp)?a:o.validateHostname&&o.extractHostname&&a.hostname!==null&&!(i&&a.hostname===e)&&!tt&&!Zt(a.hostname)?(a.hostname=null,a):(a.hostname===null||(n(a.hostname,o,a),a.publicSuffix===null)||(a.domain=bc(a.publicSuffix,a.hostname,o)),a)}const Xt=wc();function Rc(e,s){return Sc(Xt),Ic(e,3,br,s,Xt).domain}const xt=e=>{const s=new Set,n=[];for(const r of e){const a=r.trim();if(a==="")continue;const o=a.toLowerCase();s.has(o)||(s.add(o),n.push(a))}return n},Mc=e=>{const s=e.lastIndexOf("@");return s>=0?e.slice(s+1):e},ja=e=>Rc(Mc(e.trim())),Tc=e=>{const s=xt(e);if(s.length<2)return null;let n=null;for(const r of s){const a=ja(r);if(a===null)return null;if(n===null)n=a;else if(n!==a)return null}return n},Ac=e=>{const s=Tc(e);return s!==null?[{field:"FromDomain",value:s}]:xt(e).map(n=>({field:"From",value:n}))},Ec=e=>{const s=new Map;for(const a of e){const o=a.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=s.get(o);i?i.count+=1:s.set(o,{sender:a,count:1})}let n,r=0;for(const{sender:a,count:o}of s.values())o<=r||(n=a,r=o);return n},ka=e=>e.displayName?.trim()||e.normalizedEmail,Dc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,Fc=e=>{let s=e.replace(/\s+/g," ").trim();for(;;){const n=s.replace(Dc,"");if(n===s)return s.trim();s=n}},Lc=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"]),Oc=3,Vs=e=>e.split(" ").filter(s=>s!==""),en=e=>e.length===0||e.join(" ").length<Oc?!1:e.some(s=>!Lc.has(s.toLowerCase())),zc=(e,s)=>e.findIndex((n,r)=>s.every((a,o)=>e[r+o]?.toLowerCase()===a.toLowerCase())),Pc=e=>{const s=e.map(Fc).filter(o=>o!=="");if(s.length===0)return;const[n,...r]=s;if(r.length===0)return en(Vs(n))?n:void 0;const a=Vs(n);for(let o=a.length;o>0;o-=1)for(let i=0;i+o<=a.length;i+=1){const l=a.slice(i,i+o);if(en(l)&&r.every(m=>zc(Vs(m),l)>=0))return l.join(" ")}},_c=(e,s)=>{const n=Ac(e);if(xt(e).length===1||n.length===1&&n[0].field==="FromDomain")return n;const r=Pc(s);return r!==void 0?[{field:"Subject",value:r}]:n},Uc=({match:e,sender:s,folder:n})=>{const r=e??s;return r?n?`${r} → ${n}`:e?`Mail matching ${e}`:`Mail from ${r}`:n?`Mail to ${n}`:""},Bc=e=>e.clauses.length>0,$c=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(s=>s.label)}),Kc=({orderedIds:e,isDesktop:s,initialFocusedId:n,initialSelectedIds:r,onExitSelection:a})=>{const[o,i]=c.useState(n),[l,m]=c.useState(),v=c.useCallback(F=>{m(z=>z===F?z:void 0),i(F)},[]),b=ql({initialSelectedIds:r}),{selectedCount:j,toggle:h,clearSelection:x,selectRange:p,setAnchor:g,selectAll:d}=b,u=_l(j,s),y=c.useRef(null),f=c.useRef(!1),k=c.useCallback(()=>{a?.(),x()},[x,a]),C=c.useMemo(()=>o?e.indexOf(o):-1,[e,o]),N=c.useCallback(F=>{if(F<0||F>=e.length)return;const z=e[F];if(u){h(z);return}y.current=z,f.current=!1,m(z),i(z)},[e,u,h]),M=c.useCallback(()=>{e.length!==0&&N(C<0?0:Math.min(C+1,e.length-1))},[e.length,C,N]),w=c.useCallback(()=>{e.length!==0&&N(C<=0?0:C-1)},[e.length,C,N]),R=c.useCallback(()=>N(0),[N]),E=c.useCallback(()=>N(e.length-1),[N,e.length]),A=c.useCallback(()=>{o&&h(o)},[o,h]),B=c.useCallback((F,z)=>{const P=Pl(z);return P==="range"?(p(e,F,o),!0):P==="toggle"?(h(F),!0):(k(),g(F),!1)},[e,o,p,h,k,g]),D=c.useCallback(F=>{const z=Kl(e,o,F);z!==void 0&&(p(e,z),y.current=z,f.current=!1,m(void 0),i(z))},[e,o,p]),U=c.useCallback(()=>D(-1),[D]),q=c.useCallback(()=>D(1),[D]),Q=c.useCallback(()=>{e.length>0&&d(e)},[e,d]);return{focusedMessageId:o,setFocusedMessageId:v,keyboardFocusedMessageId:l,focusIndex:C,pendingDomFocusRef:y,cursorMovedByPointerRef:f,selection:b,isMultiSelectMode:u,exitSelection:k,moveFocusToIndex:N,focusNext:M,focusPrevious:w,focusFirst:R,focusLast:E,toggleFocusedSelection:A,extendRangeUp:U,extendRangeDown:q,selectAllLoaded:Q,handleRowSelect:B}},us=(e,s)=>{const{data:n,isLoading:r}=te({...ns(),staleTime:1/0,enabled:!!e});return{mailboxId:c.useMemo(()=>e?n?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===s)?.mailboxId:void 0,[n,e,s]),isLoading:r}},hf=e=>{const{mailboxId:s,isLoading:n}=us(e,"Archive");return{archiveMailboxId:s,isLoading:n}},pf=e=>{const{mailboxId:s,isLoading:n}=us(e,"Drafts");return{draftsMailboxId:s,isLoading:n}},Ca=e=>{const{mailboxId:s,isLoading:n}=us(e,"Inbox");return{inboxMailboxId:s,isLoading:n}},Na=e=>{const{mailboxId:s,isLoading:n}=us(e,"Junk");return{junkMailboxId:s,isLoading:n}},xf=e=>{const{mailboxId:s,isLoading:n}=us(e,"Trash");return{trashMailboxId:s,isLoading:n}},qc=()=>{const{data:e,isError:s}=te({...ns(),staleTime:1/0});return{trashByAccount:c.useMemo(()=>{const r=new Map;for(const a of e?.accounts??[]){const o=a.folderAppointments.find(i=>i.role==="Trash");r.set(a.accountId,{mailboxId:o?.mailboxId,source:o?.source??"None",staleFolderPath:o?.staleAppointmentPath})}return r},[e]),hasAppointments:e!==void 0,isError:s}},wa=e=>{const{data:s}=te({...ns(),staleTime:1/0,enabled:!!e});return c.useMemo(()=>s?.accounts.find(n=>n.accountId===e)?.folderAppointments??[],[s,e])},Qc=new Set(["in_flight"]),sn=(e,s)=>{const n=e?.[s];return typeof n=="string"?n:void 0},Sa=e=>{const s=vr(e);if(s?.code!=="message_placement_unsettled")return;const{details:n}=s;if(!n)return;const r=sn(n,"reason"),a=sn(n,"messageId");if(!(!r||!Qc.has(r)||!a))return{reason:r,messageId:a}},Ia=(e,s,n)=>({severity:"warning",title:s>1?`Couldn't ${n} ${s} messages yet`:`Couldn't ${n} this message yet`,detail:"It is still being moved on the mail server. Try again in a moment."}),Hc=3e3,Wc=(e,s,n)=>{if(e.length===0)return()=>{};const r=setTimeout(()=>n(e),s);return()=>clearTimeout(r)},bt=(e,s,n)=>{const r=new Map(s.map(o=>[o.messageId,o.mailboxId])),a=new Set;for(const o of e)a.add(r.get(o)??n);return[...a]},Ss=(e,s,n)=>e.map(r=>s.has(r.messageId)?{...r,isRead:n}:r),Gc=(e,s,n,r)=>e.filter(a=>!a.isRead&&s.has(a.threadMessageId)&&!n.has(a.messageId)&&!r.has(a.messageId)).map(a=>a.messageId),Vc=({messages:e,expandedIds:s,threadId:n,mailboxId:r,accountId:a})=>{const o=ue(),{pushError:i}=be(),l=c.useRef(new Set),m=c.useRef(new Set),{mutate:v}=xe({...As(),meta:yr,onMutate:async h=>{const x=new Set(h.body.messageIds??[]),p=h.body.isRead??!0,g=Ie({path:{threadId:n}}),d=we(bt(x,e,r));await Promise.all([o.cancelQueries({queryKey:g}),os(o,d)]);const u=o.getQueriesData({queryKey:g}).filter(f=>f[1]!==void 0).map(([f,k])=>({queryKey:f,data:k})),y=is(o,d);return o.setQueriesData({queryKey:g},f=>f&&{...f,items:Ss(f.items,x,p)}),ls(o,d,f=>Ss(f,x,p)),{threadMessagesPrefix:g,listPrefixes:d,previousThreadMessages:u,previousThreadsList:y}},onSuccess:(h,x)=>{const p=x.body.messageIds??[];for(const g of p)l.current.add(g),m.current.delete(g)},onError:(h,x,p)=>{const g=x.body.messageIds??[];for(const u of g)m.current.delete(u);if(p){for(const u of p.previousThreadMessages)o.setQueryData(u.queryKey,u.data);rs(o,p.previousThreadsList)}const d=x.body.isRead??!0;i({title:d?"Couldn't mark as read":"Couldn't mark as unread",detail:Se(h),error:h})},onSettled:(h,x,p,g)=>{g&&(o.invalidateQueries({queryKey:g.threadMessagesPrefix}),Ne(o,g.listPrefixes),a&&o.invalidateQueries({queryKey:as({path:{accountId:a}})}))}}),b=c.useCallback(h=>{const x=h.filter(p=>!l.current.has(p)&&!m.current.has(p));if(x.length!==0){for(const p of x)m.current.add(p);v({body:{messageIds:x,isRead:!0}})}},[v]),j=c.useMemo(()=>Gc(e,s,l.current,m.current),[e,s]);c.useEffect(()=>Wc(j,Hc,b),[j,b]),c.useEffect(()=>{l.current.clear(),m.current.clear()},[n])},bf=e=>{const{mailboxId:s,accountId:n,messages:r}=e,a=ue(),{pushError:o}=be(),{mutateAsync:i,isPending:l}=xe({...As(),onError:(v,b)=>{const j=b.body.isRead??!0;o({title:j?"Couldn't mark as read":"Couldn't mark as unread",detail:Se(v),error:v})},onSettled:(v,b,j)=>{Ne(a,we(bt(j.body.messageIds??[],r??[],s))),n&&a.invalidateQueries({queryKey:as({path:{accountId:n}})})}});return{toggleReadFor:c.useCallback((v,b)=>{v.length!==0&&Ze(v,j=>i({body:{messageIds:j,isRead:b}}))},[i]),isPending:l}},tn=(e,s)=>e.filter(n=>!s.has(n.messageId)),Os=({mailboxId:e,threadId:s,accountId:n,messages:r,onAfterOptimisticRemove:a})=>{const o=ue(),{pushError:i}=be(),{requestAppointment:l}=Rn(),m=c.useRef([]),v=c.useRef(async()=>{}),{mutateAsync:b,isPending:j}=xe({...kr(),meta:Mn(409),onMutate:async p=>{const g=new Set(p.body.messageIds??[]),d=s?Ie({path:{threadId:s}}):[],u=we(bt(g,r??[],e));await Promise.all([o.cancelQueries({queryKey:d}),os(o,u)]);const y=s?o.getQueriesData({queryKey:d}).filter(k=>k[1]!==void 0).map(([k,C])=>({queryKey:k,data:C})):[],f=is(o,u);return s&&o.setQueriesData({queryKey:d},k=>k&&{...k,items:tn(k.items,g)}),ls(o,u,k=>tn(k,g)),a?.(Array.from(g)),{threadMessagesPrefix:d,listPrefixes:u,previousThreadMessages:y,previousThreadsList:f}},onSuccess:(p,g)=>{const d=p?.failureCount??0;if(d===0)return;const u=g.body.messageIds?.length??0;i({severity:"warning",title:d>1?`Couldn't delete ${d} of ${u} messages yet`:"Couldn't delete this message yet",detail:"Something else moved it while the delete was being prepared. It is back where it now sits — try again."})},onError:(p,g,d)=>{if(d){for(const k of d.previousThreadMessages)o.setQueryData(k.queryKey,k.data);rs(o,d.previousThreadsList)}const u=jr(p);if(u){const k=m.current;l({accountId:u.accountId,role:u.role,reason:u.reason,action:{kind:"delete",count:k.length},onAppointed:()=>v.current(k)});return}const y=g.body.messageIds?.length??0,f=Sa(p);if(f){i(Ia(f,y,"delete"));return}i({title:y>1?`Couldn't delete ${y} messages`:"Couldn't delete this message",detail:Se(p),error:p})},onSettled:(p,g,d,u)=>{u&&(s&&o.invalidateQueries({queryKey:u.threadMessagesPrefix}),Ne(o,u.listPrefixes),n&&o.invalidateQueries({queryKey:as({path:{accountId:n}})}))}}),h=c.useCallback(p=>Ze(p,g=>b({body:{messageIds:g}})),[b]);return c.useEffect(()=>{v.current=h},[h]),{deleteMessages:c.useCallback(p=>{p.length!==0&&(m.current=p,h(p))},[h]),isPending:j}},Jc=10,Ra=e=>({q:e?.toLowerCase()??"",limit:Jc}),Yc=(e,s)=>{if(!s)return;const n=s.toLowerCase();return e?.find(r=>r.normalizedEmail===n)};function Zc(e){const s=new Date(e),n=new Date;return s.toDateString()===n.toDateString()?"today":Nr(s,{month:"short",year:"numeric"})}function Ma(e){if(!e)return!0;const[,s]=e.split("@");return s?!s.includes("."):!0}const Xc="We can't verify the sender of this email, which could mean it's from an insecure source.",ed="We couldn't read this sender's address, so we can't confirm who really sent this message.";function sd(e,s){const n=e.category??"personal";return{value:Tn(n)?n:"uncategorized",overridden:s?.flags?.category?.value!=null&&s.flags.category.value!==e.category}}function td(e,s){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:s?Zc(s.createdAt):"unknown",inboundCount:s?.inboundCount,replyCount:s?.replyCount,addressUnverified:Ma(e.fromEmail)}}function nd(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0}:{}}function nn(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function ad(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function rd(e,s){const n=[],r=e.displayNameCorrespondence;s&&(r===Hs.Unrelated?n.push(`The name it shows, "${s}", has nothing to do with ${e.fromDomain}.`):r===Hs.Lookalike?n.push(`The name it shows, "${s}", only looks like ${e.fromDomain}.`):r===Hs.ForeignAddress&&n.push(`The name it shows, "${s}", is an address ${e.fromDomain} cannot send from.`));const a=od(e.offDomainLinkDomains);return a.length>0&&n.push(`Its links go to ${ad(a.slice(0,3))}.`),n}function od(e){return Array.isArray(e)?e.filter(s=>typeof s=="string"&&s.length>0):[]}function id(e){if(Ma(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:ed};const s=e.authenticity;if(!s)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:Xc};if(!s.dkimMismatch){const l=nn(e),m=rd(s,l);return m.length>0?{verdict:"caution",fromDomain:s.fromDomain,dkimDomain:s.dkimDomain,claimedBrand:l,summary:m.join(" ")}:{verdict:"aligned",fromDomain:s.fromDomain,dkimDomain:s.dkimDomain,summary:s.dkimDomain?`This message was signed by ${s.dkimDomain}.`:"Nothing looks unusual about this sender."}}const n=s.fromDomain,r=s.dkimDomain,a=nn(e),o=r?`it was actually sent from ${r}`:"its signature failed to verify",i=a?`The display name claims "${a}", but ${o}${r?` — not ${n}`:""}. Real senders use their own address.`:`This message claims to be from ${n}, but ${o}.`;return{verdict:"mismatch",fromDomain:n,dkimDomain:r,claimedBrand:a,summary:i}}function ld(e){const s=e?.fromEmail??null,{data:n,error:r}=te({...ct({query:Ra(s??void 0)}),enabled:!!s,staleTime:3e4}),a=Yc(n?.items,s??void 0);return{data:c.useMemo(()=>{if(!e)return null;const i=td(e,a),l=id(e),m=sd(e,a),v=nd(a);return{sender:i,authenticity:l,category:m,flags:v}},[e,a]),addressErrorIsFatal:Cr(r),addressId:a?.addressId,address:a}}function cd(e){const[s,n]=c.useState(null);s!==null&&s!==e&&n(null);const r=e!==null&&s===e,a=c.useCallback(()=>n(null),[]),o=c.useCallback(()=>n(e),[e]),i=c.useCallback(()=>n(r?null:e),[r,e]);return{isOpen:r,open:o,close:a,toggle:i}}const vf=e=>{const{intelligenceOpen:s,onToggleIntelligence:n,onRaiseIntelligence:r}=cs(),a=An()?.showIntelligencePane??!1,o=e??null,i=cd(o),l=!a&&i.isOpen,{open:m,toggle:v}=i,b=c.useCallback(()=>{if(a){n();return}v()},[a,n,v]),j=c.useCallback(()=>{!a||s||r()},[a,s,r]),h=c.useCallback(()=>{if(!a){m();return}j()},[a,m,j]);return{canToggle:o!==null,isShowing:o!==null&&(a?s:l),toggle:b,open:h,drawerOpen:l,closeDrawer:i.close,railFits:a,openRail:j}},yf=(e,{toggle:s,open:n})=>{c.useEffect(()=>(e.current={toggle:s,open:n},()=>{e.current=null}),[e,s,n])},zs=e=>{const{data:s,isLoading:n}=te({...ns(),staleTime:1/0,enabled:!!e}),r=c.useMemo(()=>(s?.accounts??[]).map(l=>l.accountId),[s?.accounts]),a=dt({queries:r.map(l=>({...ds({path:{accountId:l}}),staleTime:1/0,enabled:!!e}))}),o=n||a.some(l=>l.isLoading);return{accountId:c.useMemo(()=>{if(e){for(let l=0;l<r.length;l++)if((a[l].data?.items??[]).some(b=>b.mailboxId===e))return r[l]}},[e,r,a]),isLoading:o}},an=(e,s)=>e.filter(n=>!s.has(n.messageId)),ms=({mailboxId:e,threadId:s,accountId:n,onAfterOptimisticRemove:r})=>{const a=ue(),{pushError:o}=be(),{mutateAsync:i,isPending:l,isError:m}=xe({...wr(),meta:Mn(409),onMutate:async b=>{const j=new Set(b.body.messageIds??[]),h=s?Ie({path:{threadId:s}}):[],x=we([e,b.body.destinationMailboxId]);await Promise.all([...s?[a.cancelQueries({queryKey:h})]:[],os(a,x)]);const p=s?a.getQueriesData({queryKey:h}).filter(d=>d[1]!==void 0).map(([d,u])=>({queryKey:d,data:u})):[],g=is(a,x);return s&&a.setQueriesData({queryKey:h},d=>d&&{...d,items:an(d.items,j)}),ls(a,x,d=>an(d,j)),r?.(Array.from(j)),{threadMessagesPrefix:h,listPrefixes:x,previousThreadMessages:p,previousThreadsList:g}},onError:(b,j,h)=>{if(h){for(const g of h.previousThreadMessages)a.setQueryData(g.queryKey,g.data);rs(a,h.previousThreadsList)}const x=j.body.messageIds?.length??0,p=Sa(b);if(p){o(Ia(p,x,"move"));return}o({title:x>1?`Couldn't move ${x} messages`:"Couldn't move this message",detail:Se(b),error:b})},onSettled:(b,j,h,x)=>{x&&(s&&a.invalidateQueries({queryKey:x.threadMessagesPrefix}),Ne(a,x.listPrefixes),n&&a.invalidateQueries({queryKey:as({path:{accountId:n}})}))}});return{moveMessages:c.useCallback((b,j)=>{b.length!==0&&Ze(b,h=>i({body:{messageIds:h,destinationMailboxId:j}}))},[i]),isPending:l,isError:m}},jf=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",dd=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0,ud=()=>{const e=ue();return c.useCallback(s=>{const n=Ie({path:{threadId:s.threadId}}),a=e.getQueriesData({queryKey:n}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return a.length>0?a:[s.messageId]},[e])},md=[],Ta=e=>{const{data:s}=te({...En({path:{threadId:e??""}}),enabled:!!e});return s?.items??md},kf=(e,s)=>{const n=Ta(e),r=s?n.find(o=>o.messageId===s):void 0,a=n.length>0?n[n.length-1]:void 0;return r??a},fd=(e,s,n)=>s?.find(r=>r.messageId===e)?.mailboxId??n,rn=(e,s,n)=>e.map(r=>r.messageId===s?{...r,hasStars:n}:r),Aa=({threadId:e,mailboxId:s,messages:n})=>{const r=ue(),{pushError:a}=be(),{mutate:o,isPending:i,variables:l}=xe({...Ir(),onMutate:async v=>{const b=v.path.messageId,j=v.body.isStarred??!1,h=Ie({path:{threadId:e}}),x=we([fd(b,n,s)]);await Promise.all([r.cancelQueries({queryKey:h}),os(r,x)]);const p=r.getQueriesData({queryKey:h}).filter(d=>d[1]!==void 0).map(([d,u])=>({queryKey:d,data:u})),g=is(r,x);return r.setQueriesData({queryKey:h},d=>Sr(d,u=>rn(u,b,j))),ls(r,x,d=>rn(d,b,j)),{threadMessagesPrefix:h,listPrefixes:x,previousThreadMessages:p,previousThreadsList:g}},onError:(v,b,j)=>{if(j){for(const x of j.previousThreadMessages)r.setQueryData(x.queryKey,x.data);rs(r,j.previousThreadsList)}const h=b.body.isStarred??!1;a({title:h?"Couldn't star message":"Couldn't unstar message",detail:Se(v),error:v})},onSettled:(v,b,j,h)=>{h&&(r.invalidateQueries({queryKey:h.threadMessagesPrefix}),Ne(r,h.listPrefixes))}});return{toggleStar:(v,b)=>{o({path:{messageId:v},body:{isStarred:!b}})},isPending:i,pendingMessageId:i?l?.path.messageId:void 0}},Cf=({thread:e,isOpen:s=!1,mailboxId:n,accountId:r,onAfterOptimisticRemove:a})=>{const o=n??e?.mailboxId,i=r??e?.accountId,{accountId:l}=zs(i?void 0:o),m=i??l,v=ud(),{deleteMessages:b}=Os({mailboxId:o??"",threadId:e?.threadId,accountId:m,onAfterOptimisticRemove:a}),{moveMessages:j}=ms({mailboxId:o??"",threadId:e?.threadId,accountId:m,onAfterOptimisticRemove:a}),h=Ta(s?e?.threadId:void 0),p=h.find(f=>f.messageId===e?.messageId)?.hasStars??e?.hasStars,{toggleStar:g}=Aa({threadId:e?.threadId??"",mailboxId:o??"",messages:h}),d=c.useCallback(()=>{e&&b(v(e))},[e,v,b]),u=c.useCallback(f=>{e&&j(v(e),f)},[e,v,j]),y=c.useCallback(()=>{e&&g(e.messageId,p??!1)},[e,p,g]);return{mailboxId:o,accountId:m,isStarred:p,deleteThread:d,moveThread:u,toggleStar:y}},on=(e,s,n)=>{if(!s)return null;const r=e.indexOf(s);if(r===-1)return null;const a=n==="next"?r+1:r-1;return a<0||a>=e.length?null:e[a]},Nf=()=>{const[e,s]=c.useState(void 0),[n,r]=c.useState([]),[a,o]=c.useState([]),i=c.useRef(null),[l,m]=c.useState(!1),v=c.useCallback(b=>{s(b.focusedMessageId),r(b.selectedIds),b.orderedIds&&o(b.orderedIds),m(b.hasList)},[]);return{listCommandsRef:i,onTriageContextChange:v,focusedMessageId:e,selectedIds:n,orderedIds:a,hasList:l}},wf=({context:e,orderedIds:s,selectedMessageId:n,enabled:r=!0,onClose:a,handlers:o,hasOpenThread:i=!1})=>{const{listCommandsRef:l,hasList:m}=e,v=c.useCallback(()=>{l.current?.clearSelection()||n&&a()},[l,n,a]),{reply:b,replyAll:j,forward:h,...x}=o;return Io({enabled:r,handlers:{...m?{focusNext:()=>l.current?.focusNext(),focusPrevious:()=>l.current?.focusPrevious(),focusFirst:()=>l.current?.focusFirst(),focusLast:()=>l.current?.focusLast(),openFocused:()=>l.current?.openFocused(),toggleSelect:()=>l.current?.toggleSelect(),extendSelectDown:()=>l.current?.extendSelectDown(),extendSelectUp:()=>l.current?.extendSelectUp(),selectAll:()=>l.current?.selectAll(),toggleDensity:()=>l.current?.toggleDensity()}:{},back:v,...x,...i?{}:{reply:b,replyAll:j,forward:h}}}),{goBack:v,nextMessageId:on(s,n,"next")??void 0,previousMessageId:on(s,n,"previous")??void 0}};function gd(e,s,n=[]){const r={...e??{}};for(const[a,o]of Object.entries(s))o==null?delete r[a]:r[a]={...o,setAt:o.setAt??Date.now()};for(const a of n)delete r[a];return r}function hd({addressId:e,senderEmail:s}){const n=ue(),{pushError:r}=be(),a=Rr({query:Ra(s)}),{mutate:o,isPending:i}=xe({...Mr(),onMutate:async b=>{const j=b.body.flags??{},h=b.body.clearFlags??[];await n.cancelQueries({queryKey:a});const x=n.getQueryData(a);return n.setQueryData(a,p=>p&&{...p,items:p.items.map(g=>g.addressId===b.path.addressId?{...g,flags:gd(g.flags,j,h)}:g)}),{previous:x}},onError:(b,j,h)=>{h?.previous!==void 0&&n.setQueryData(a,h.previous),r({title:"Couldn't update sender preference",detail:Se(b),error:b})},onSettled:()=>{n.invalidateQueries({queryKey:a})}}),l=c.useCallback(b=>{if(!e){Tr(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${s??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:b})},[e,o,s]),m=c.useCallback(b=>l({flags:b}),[l]),v=c.useCallback(b=>l({clearFlags:b}),[l]);return{updateFlags:m,clearFlags:v,isPending:i}}const pd={unread:"unread",flagged:"starred",attachment:"attachments"},xd=new Set(Object.values(Ar)),Ea=e=>xd.has(e),Sf=e=>Ea(e.category)||e.attributes.size>0,If=e=>{const s={};Ea(e.category)&&(s.category=[e.category]);for(const n of e.attributes){const r=pd[n];r&&(s[r]=!0)}return s},Rf=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",bd=["category","unread","starred","attachments","accountId","muted"],ln=e=>JSON.stringify(bd.map(s=>e?.[s]??null)),vd=e=>{if(!Array.isArray(e))return;const[s]=e;if(typeof s!="object"||s===null)return;const n=s.query;if(!(typeof n!="object"||n===null))return n},Mf=(e,s)=>{const n=vd(e);return n?ln(n)===ln(s):!1},Tf=e=>Tn(e)?Ts[e]:void 0,Da="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",yd="These are already in Junk, so there is nowhere to file them.",jd=(e,s)=>e!==void 0&&e!==s?e:void 0,Af=(e,s)=>{if(jd(e,s)===void 0)return e===void 0?Da:yd};function Ef(e,s){e.recordEvent("rescue.candidates_surfaced",{count:String(s)})}function Df(e,s){e.recordEvent("rescue.flow_opened",{count:String(s)})}function Ff(e,s){e.recordEvent("rescue.committed",{selected:String(s.selected),total:String(s.total),destination:s.toInbox?"inbox":"other"})}function kd(e,s){e.recordEvent("rescue.sent_to_junk",{count:String(s.count),senderTrust:s.senderTrust,wasRescuable:String(s.wasRescuable)})}function Lf(e,s){const{folder:n}=Dn(s,[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:Es(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...n?{folder:n}:{}}}function Of(e,s){const{folder:n}=Dn(s,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}:{},...n?{folder:n}:{}}}function Fa(e){return e===void 0?"uncategorized":e}const La=e=>e.syncStatus===Er.abandoned?e.abandonedMutation:Xe.none,Cd=e=>{switch(La(e)){case Xe.delete:return{settlement:"delete_failed"};case Xe.move:return{settlement:"move_failed"};default:return{}}};function Nd(e){const s=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:Es(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Fa(e.category),suspicious:s,...Cd(e)}}const wd=Dr;function zf(e){const s=new Map(e.map(r=>[r.category,r])),n=[];for(const r of wd){const a=s.get(r);!a||!(a.loading||a.failed||a.rows.length>0||a.total.kind==="exact"&&a.total.value>0)||n.push({id:r,label:Ts[r],threads:a.rows,total:a.total,atCap:a.atCap,loading:a.loading,error:a.failed})}return n}function Sd(e,s){return s.every(n=>{switch(n.type){case"from":{const r=n.value.toLowerCase();return e.fromEmail.toLowerCase().includes(r)||e.fromName.toLowerCase().includes(r)}case"subject":return e.subject.toLowerCase().includes(n.value.toLowerCase());case"category":return(e.category??"uncategorized")===n.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>=n.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<n.epochSeconds*1e3;case"in":return e.mailboxId===n.mailboxId;case"account":return e.accountId===n.accountId;default:return!1}})}const Id=["from","subject","category","unread","starred","attachments"],ys=e=>e[0],Rd=e=>{const s=ys(e.filter(l=>l.type==="from").map(l=>l.value)),n=ys(e.filter(l=>l.type==="subject").map(l=>l.value)),r=ys(e.filter(l=>l.type==="category").map(l=>l.category)),a=ys(e.filter(l=>l.type==="isUnread"||l.type==="isRead").map(l=>l.type==="isUnread")),o=e.some(l=>l.type==="isStarred")?!0:void 0,i=e.some(l=>l.type==="hasAttachment")?!0:void 0;return{...s!==void 0?{from:s}:{},...n!==void 0?{subject:n}:{},...r!==void 0?{category:[r]}:{},...a!==void 0?{unread:a}:{},...o!==void 0?{starred:o}:{},...i!==void 0?{attachments:i}:{}}},Md=(e,s)=>{switch(s.type){case"from":return e.from?.toLowerCase()===s.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===s.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===s.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}},cn=(e,s)=>Object.fromEntries(Object.entries(e).filter(([n])=>s.includes(n)));function Pf(e,s={},n=Id){const r=cn(Rd(e),n),a={...r,...cn(s,n)};return{params:r,residual:e.filter(o=>!Md(a,o))}}function _f(e,s,n){if(s.length===0)return e;const r=[...s];return e.filter(a=>{const o=Nd(a);return Sd({...o,accountId:o.accountId??n},r)})}function Uf(){const{insertIntoOpenReply:e}=Fn(),s=Qn();return c.useCallback((n,r)=>{e(n.messageId,r)||s({...n,mode:"reply"},{body:r})},[e,s])}const Td=({surface:e})=>{const s=Lo(),n=Oo(),{registerOpenReply:r}=Fn(),[a,o]=c.useState(),i=c.useCallback(h=>o(x=>({version:(x?.version??0)+1,text:h})),[]),l=e.sourceMessageId;c.useEffect(()=>r(l,i),[l,i,r]);const{data:m}=te({...Ds({path:{messageId:e.sourceMessageId}})}),{data:v}=te({...ns(),staleTime:1/0}),{accountId:b}=zs(m?.message.mailboxId),j=v?.accounts?.find(h=>h.accountId===b);return t.jsx("div",{className:"border-b border-line bg-canvas",children:t.jsx(Jo,{layout:"flow",mode:e.mode,account:j,sourceMessage:m,outboxMessageId:e.outboxMessageId,seed:e.seed,insertion:a,onDraftCreated:s,onClose:n},e.sourceMessageId)})};function dn({authenticity:e,onOpenIntelligence:s}){return e.dkimMismatch?t.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:[t.jsx($e,{className:"mt-0.5 size-4 shrink-0 text-danger"}),t.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",t.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",s&&t.jsx("button",{type:"button",onClick:s,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}const Ad={inbox:"Inbox",junk:"Junk"},vt=e=>e.destinationMailboxId!==void 0,Ed=(e,s)=>{if(vt(e))return`Moved from ${s??"another folder"} by Remit`;const n=e.fromPlacement??"";return`Moved from ${Ad[n]??"another folder"} by Remit`},Dd=(e,s)=>{if(e===Mt.MoveToInbox)return s.inboxMailboxId;if(e===Mt.MoveToJunk)return s.junkMailboxId},Fd=(e,s,n)=>{if(!e||!s)return!1;const r=vt(e)?e.destinationMailboxId:Dd(e.action,n);return r!==void 0&&r===s},Ld="Reported as spam",Od=(e,s)=>{if(e){if(vt(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return s.inboxMailboxId;if(e.fromPlacement==="junk")return s.junkMailboxId}},zd="This message could not be processed. Please try again. If it keeps failing, report it.",Pd=(e,s)=>e.replace(`Message ${s}'s`,"This message's"),un=e=>{if(e.failureCount===0)return;const s=e.failures?.[0],n=s?.reason??zd,r=s?Pd(n,s.messageId):n;throw new Or(r,422)};function Oa({mailboxId:e,threadId:s,accountId:n,onAfterOptimisticRemove:r}){const a=ue(),{pushError:o}=be(),i=we([e]),l=s?Ie({path:{threadId:s}}):[],m=()=>{s&&a.invalidateQueries({queryKey:l}),Ne(a,i),n&&a.invalidateQueries({queryKey:as({path:{accountId:n}})})},v=()=>(g,d)=>{m(),r?.(d.body.messageIds)},b=g=>(d,u)=>{o({title:g(u.body.messageIds.length),detail:Se(d),error:d})},j=xe({mutationFn:async g=>{const{data:d}=await Fr({...g,throwOnError:!0});return un(d),d},meta:{softError:!0},onSuccess:v(),onError:b(g=>g>1?`Couldn't report ${g} messages as spam`:"Couldn't report this message as spam")}),h=xe({mutationFn:async g=>{const{data:d}=await Lr({...g,throwOnError:!0});return un(d),d},meta:{softError:!0},onSuccess:v(),onError:b(g=>g>1?`Couldn't undo the spam report for ${g} messages`:"Couldn't undo the spam report")}),x=c.useCallback(g=>{g.length!==0&&Ze(g,d=>j.mutateAsync({body:{messageIds:d}}))},[j.mutateAsync]),p=c.useCallback(g=>{g.length!==0&&Ze(g,d=>h.mutateAsync({body:{messageIds:d}}))},[h.mutateAsync]);return{reportSpam:x,notSpam:p,isReporting:j.isPending,isRestoring:h.isPending}}const _d=({accountId:e,messageId:s,threadId:n,mailboxId:r,autoMoved:a,spamReport:o})=>{const{inboxMailboxId:i}=Ca(e),{junkMailboxId:l}=Na(e),{moveMessages:m,isPending:v}=ms({mailboxId:r,threadId:n,accountId:e}),{notSpam:b,isRestoring:j}=Oa({mailboxId:r,threadId:n,accountId:e}),{data:h}=te({...ds({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&a?.fromMailboxId!==void 0}),x={inboxMailboxId:i,junkMailboxId:l},p=Od(a,x),g=c.useCallback(()=>{p&&m([s],p)},[m,s,p]),d=c.useCallback(()=>{b([s])},[b,s]);if(o)return{show:!0,label:Ld,onUndo:d,isUndoing:j};if(!Fd(a,r,x)||!a)return{show:!1,label:"",isUndoing:!1};const y=a.fromMailboxId?h?.items.filter(f=>f.mailboxId===a.fromMailboxId).map(f=>zr(f))[0]:void 0;return{show:!0,label:Ed(a,y),onUndo:p?g:void 0,isUndoing:v,...a.filterId?{filtersHref:"/settings/filters"}:{}}};function Ud({accountId:e,messageId:s,threadId:n,mailboxId:r,autoMoved:a,spamReport:o}){const i=_d({accountId:e,messageId:s,threadId:n,mailboxId:r,autoMoved:a,spamReport:o});return i.show?t.jsx(pl,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const za="inline-flex items-center justify-center transition-colors",Bd=T(za,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),$d=T(za,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Ps=({accountId:e,currentMailboxId:s,onMove:n,disabled:r=!1,disabledHint:a,variant:o="icon-only",label:i,defaultOpen:l=!1})=>{const[m,v]=c.useState(l),[b,j]=c.useState(),h=ut(),x=c.useRef(null),p=c.useRef(null),g=c.useRef(null),d=i??"Move to folder",u=c.useId(),y=Ln(),{data:f,isLoading:k,isError:C,error:N,refetch:M}=te({...ds({path:{accountId:e}}),staleTime:1/0,enabled:m}),w=wa(e),{createFolderIn:R}=On(e),E=c.useMemo(()=>zn({mailboxes:f?.items??[],folderAppointments:w,currentMailboxId:s,translator:y}),[f?.items,w,s,y]),A=Pn(f?.items??[]),B=E.find(_=>_.id===b),D=c.useCallback(()=>{v(!1),j(void 0);const _=document.activeElement;_&&p.current?.contains(_)&&g.current?.focus()},[]),U=c.useCallback(()=>{B&&(D(),n(B.id))},[B,D,n]);Ms({id:"move-to",open:m,answers:{back:D}}),c.useEffect(()=>{if(!m||!h)return;const _=Y=>{const H=Y.target;x.current?.contains(H)||p.current?.contains(H)||D()};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[m,h,D]);const q=()=>x.current?.getBoundingClientRect()??null,Q=r||!!a,F=t.jsxs("button",{type:"button",ref:g,onClick:_=>{_.stopPropagation(),!Q&&v(Y=>!Y)},"aria-label":d,"aria-haspopup":h?"tree":"dialog","aria-expanded":m,"aria-controls":m?u:void 0,title:a,className:o==="icon-only"?Bd:$d,children:[t.jsx(lt,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&t.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),z=k?t.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):C?t.jsx("div",{className:"p-3",children:t.jsx(Fe,{variant:"inline",title:"Couldn't load folders",error:N,onRetry:()=>M()})}):t.jsx(Pr,{folders:E,selectedId:b,delimiter:A,onSelect:j,onCreateFolder:R,onCancel:D,autoFocusFilter:h,labels:{filterPlaceholder:"Filter folders…",filterAriaLabel:"Filter folders"}}),P=B&&t.jsx("div",{className:"shrink-0 border-t border-line p-2",children:t.jsx($,{variant:"primary",onClick:U,className:"h-11 w-full font-semibold",children:`Move to ${B.label}`})});return h?t.jsxs("div",{ref:x,className:"relative inline-block",children:[F,t.jsx(Bo,{open:m,align:"end",panelRef:p,getAnchor:q,children:t.jsxs("div",{id:u,ref:p,className:T("w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[z,P]})})]}):t.jsxs(t.Fragment,{children:[F,t.jsx(Pe.Root,{open:m,onOpenChange:_=>_?v(!0):D(),children:t.jsxs(Pe.Portal,{children:[t.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),t.jsxs(Pe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{maxHeight:"85dvh"},id:u,children:[t.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),t.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),t.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:z}),P]})]})})]})},Kd=({messageId:e,threadId:s,mailboxId:n,isRead:r,accountId:a,fromAddressId:o,isTrusted:i=!1,showRaw:l=!1,onToggleRaw:m})=>{const v=ue(),b=Ro(),{pushError:j}=be(),h=Mo()?.messageId,{mutate:x,isPending:p}=xe({...As(),onMutate:async q=>{const Q=q.body.isRead??!0,F=new Set(q.body.messageIds??[]),z=Ie({path:{threadId:s}}),P=we([n]);await Promise.all([v.cancelQueries({queryKey:z}),os(v,P)]);const _=v.getQueriesData({queryKey:z}).filter(H=>H[1]!==void 0).map(([H,G])=>({queryKey:H,data:G})),Y=is(v,P);return v.setQueriesData({queryKey:z},H=>H&&{...H,items:Ss(H.items,F,Q)}),ls(v,P,H=>Ss(H,F,Q)),{threadMessagesPrefix:z,listPrefixes:P,previousThreadMessages:_,previousThreadsList:Y}},onError:(q,Q,F)=>{if(F){for(const P of F.previousThreadMessages)v.setQueryData(P.queryKey,P.data);rs(v,F.previousThreadsList)}const z=Q.body.isRead??!0;j({title:z?"Couldn't mark as read":"Couldn't mark as unread",detail:Se(q),error:q})},onSettled:(q,Q,F,z)=>{z&&(v.invalidateQueries({queryKey:z.threadMessagesPrefix}),Ne(v,z.listPrefixes))}}),g=c.useCallback(q=>{h&&q.includes(h)&&b()},[h,b]),{deleteMessages:d,isPending:u}=Os({mailboxId:n,threadId:s,onAfterOptimisticRemove:g}),{moveMessages:y,isPending:f}=ms({mailboxId:n,threadId:s,accountId:a,onAfterOptimisticRemove:g}),{toggleTrusted:k,isPending:C,error:N,reset:M}=Wn({messageId:e}),w=()=>{x({body:{messageIds:[e],isRead:!1}})},R=()=>{d([e])},E=()=>{o&&k(o,i)},A=p||u||f||C,B=A||!o,D=c.useCallback(q=>{y([e],q)},[y,e]),U=o?void 0:"Sender has no parseable address";return t.jsxs("div",{className:"flex flex-col items-end gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[a&&t.jsx(Ps,{accountId:a,currentMailboxId:n,onMove:D,disabled:A,label:"Move this message"}),t.jsxs(Rl,{trigger:t.jsx($o,{className:"size-4"}),children:[t.jsxs(bs,{onClick:E,disabled:B,children:[i?t.jsx(Ls,{className:"size-4 text-positive"}):t.jsx(ss,{className:"size-4 opacity-0"}),t.jsx("span",{title:U,children:"Trusted sender"})]}),r&&t.jsxs(bs,{onClick:w,disabled:A,children:[t.jsx(ft,{className:"size-4"}),"Mark as unread"]}),m&&t.jsxs(bs,{onClick:m,children:[t.jsx(ta,{className:"size-4"}),l?"Show formatted":"Show raw email"]}),t.jsx(Ml,{}),t.jsxs(bs,{onClick:R,disabled:A,destructive:!0,children:[t.jsx(ts,{className:"size-4"}),"Delete"]})]})]}),N&&t.jsx("div",{className:"w-64",children:t.jsx(Fe,{variant:"inline",title:"Couldn't update trust",error:N,onRetry:()=>{M(),E()}})})]})},qd=(e,s)=>{if(e==="message")return"MESSAGE";const n=s.toUpperCase();return n==="OCTET-STREAM"?"FILE":n},Qd=e=>{const s=e.toLowerCase().replace(/[^a-z0-9]/g,"");return s.length>0?`attachment.${s}`:"attachment"},mn=e=>ri(e).filter(s=>!s.isMultipart&&(s.disposition===_r.Attachment||Lt(s))&&s.contentUrl.length>0).map(s=>{const n=Lt(s)?"message":"file";return{bodyPartId:s.bodyPartId,partPath:s.partPath,kind:n,filename:Yo(s.dispositionFilename??"",Qd(s.mediaSubtype)),typeLabel:qd(n,s.mediaSubtype),sizeOctets:s.sizeOctets,contentUrl:s.contentUrl}}),fn={status:"idle"},Pa=({messageId:e,bodyParts:s,hasAttachment:n=!1,className:r})=>{const{getToken:a}=_n(),o=ue(),[i,l]=c.useState({}),[m,v]=c.useState(null),b=c.useMemo(()=>mn(s??[]),[s]),j=Ur({path:{messageId:e}}),h=y=>Ft(y.contentUrl,a).catch(f=>{if(!ti(Dt(f)))throw f;return o.refetchQueries({queryKey:j}).then(()=>{const k=o.getQueryData(j),C=k?mn(k.bodyParts).find(N=>N.bodyPartId===y.bodyPartId):void 0;return Ft(C?.contentUrl??y.contentUrl,a)})}),x=(y,f)=>l(k=>({...k,[y]:f})),p=y=>{const f=b.find(k=>k.bodyPartId===y);if(!f)throw new Error(`No attachment part ${y} on message ${e}`);x(y,{status:"downloading"}),h(f).then(k=>{Zo(k,f.filename),x(y,fn)}).catch(k=>{const C=Dt(k),N=Xo(k),{title:M,detail:w}=ei(C,f.filename,N);x(y,{status:"failed",title:M,detail:w,reportUrl:si(C,f.filename,N)})})},g=n&&s!==void 0&&b.length===0,d=b.find(y=>y.kind==="message"&&y.bodyPartId===m),u=d?oi(s??[],d.partPath):[];return t.jsx(ul,{className:r,attachments:b.map(y=>({attachmentId:y.bodyPartId,kind:y.kind,filename:y.filename,typeLabel:y.typeLabel,sizeOctets:y.sizeOctets,download:i[y.bodyPartId]??fn})),onDownload:p,hasUnlistedAttachment:g,onToggleOpen:y=>v(f=>f===y?null:y),opened:d?{attachmentId:d.bodyPartId,content:t.jsxs(t.Fragment,{children:[t.jsx(Gn,{bodyParts:u,messageId:e}),t.jsx(Pa,{messageId:e,bodyParts:u,className:"mt-4"})]})}:void 0})};function Hd({threadMessage:e,accountId:s,className:n}){const r=La(e),a=r===Xe.delete?"delete_failed":r===Xe.move?"move_failed":void 0,{accountId:o}=zs(a==="move_failed"&&!s?e.mailboxId:void 0),i=s??o,{deleteMessages:l,isPending:m}=Os({mailboxId:e.mailboxId,threadId:e.threadId,accountId:i,messages:[e]}),{moveMessages:v,isPending:b}=ms({mailboxId:e.mailboxId,threadId:e.threadId,accountId:i}),j=c.useCallback(()=>{l([e.messageId])},[l,e.messageId]),h=c.useCallback(p=>{v([e.messageId],p)},[v,e.messageId]),x=c.useMemo(()=>a?Br($r({title:Ns[a].title,errorMessage:`Message ${e.messageId}: status=${e.status} syncStatus=${e.syncStatus} abandonedMutation=${e.abandonedMutation}`})):void 0,[a,e.messageId,e.status,e.syncStatus,e.abandonedMutation]);return a?t.jsx(Ql,{settlement:a,onRetry:a==="delete_failed"?j:void 0,action:a==="move_failed"&&i?t.jsx(Ps,{accountId:i,currentMailboxId:e.mailboxId,onMove:h,disabled:b,variant:"compact",label:Ns.move_failed.retryLabel}):void 0,retryPending:a==="delete_failed"?m:b,reportHref:x,className:n}):null}const Wd=({messageId:e,threadId:s,mailboxId:n,accountId:r,isRead:a,isStarred:o,onToggleStar:i,fromAddressId:l,isTrusted:m,showRaw:v,onToggleRaw:b,onReply:j,onReplyAll:h,onForward:x})=>{const p=ue(),{deleteMessages:g}=Os({mailboxId:n,threadId:s}),{moveMessages:d}=ms({mailboxId:n,threadId:s,accountId:r}),{toggleTrusted:u}=Wn({messageId:e}),{mutate:y}=xe({...As(),onSettled:()=>{p.invalidateQueries({queryKey:Ie({path:{threadId:s}})}),Ne(p,we([n]))}}),f=c.useCallback(M=>{d([e],M)},[d,e]),k=c.useCallback(()=>{g([e])},[g,e]),C=c.useCallback(()=>{y({body:{messageIds:[e],isRead:!a}})},[y,e,a]),N=[];return l&&N.push({key:"trusted",label:m?"Trusted sender":"Mark sender trusted",icon:m?t.jsx(Ls,{className:"size-4 text-positive"}):t.jsx(ss,{className:"size-4"}),onSelect:()=>u(l,m)}),b&&N.push({key:"raw",label:v?"Show formatted":"Show raw email",icon:t.jsx(ta,{className:"size-4"}),onSelect:b}),t.jsx(ga,{hasThread:!0,onReply:j,onReplyAll:h,onForward:x,isStarred:o,onToggleStar:i,onDelete:k,isRead:a,onToggleRead:C,overflowItems:N,moveSlot:r?t.jsx(Ps,{accountId:r,currentMailboxId:n,onMove:f,label:"Move this message"}):void 0})},Gd=()=>t.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),Vd=({messageId:e,enabled:s=!0})=>{const{data:n,isLoading:r,isError:a,error:o,refetch:i}=te({...Kr({path:{messageId:e}}),enabled:s});if(r)return t.jsx("div",{className:"message-body",children:t.jsx(Gd,{})});if(a)return t.jsx("div",{className:"message-body",children:t.jsx(Fe,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const l=n?.raw??"";return l===""?t.jsx("div",{className:"message-body",children:t.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):t.jsx("div",{className:"message-body",children:t.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:l})})},Jd=()=>t.jsx(Ls,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),_a=(e,s)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:s,snippet:e.snippet||"",bodyHtml:""}),Ua=({isStarred:e,onToggleStar:s,isStarPending:n,hoverReveal:r})=>t.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),s()},disabled:n,"aria-label":e?"Remove star":"Add star",className:T("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":T("text-fg-subtle hover:text-warning",r&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),n&&"opacity-50"),children:t.jsx(Be,{className:T("size-3.5",e&&"fill-current")})}),Yd=({threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:a})=>{const o=Un(e.sentDate,"datetime"),i=_a(e,o);return t.jsx(ha,{message:i,onClick:n,isFocused:s,isUnread:!e.isRead,trailing:t.jsxs(t.Fragment,{children:[e.hasAttachment&&t.jsx(Fs,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),t.jsx(Ua,{isStarred:e.hasStars,onToggleStar:r,isStarPending:a,hoverReveal:!0}),t.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},Zd=({threadMessage:e,messageData:s,isLoading:n,isError:r,error:a,onRetry:o,isFocused:i,onToggle:l,onToggleStar:m,isStarPending:v,accountId:b,showRaw:j,onToggleRaw:h,mobile:x,onReply:p,onReplyAll:g,onForward:d})=>{const u=Un(e.sentDate,"long"),y=!e.isRead,f=s?.envelope.from[0]?.flags?.trusted?.value===!0,k=s?.envelope.from[0]?.flags?.blocked?.value===!0,C=s?.envelope.from[0]?.addressId,N=_a(e,u),M=e.autoMoved||e.spamReport?t.jsx(Ud,{accountId:b,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return t.jsx(pa,{message:N,isFocused:x?!1:i,onHeaderClick:l,senderBadge:f&&!k?t.jsx(Jd,{}):void 0,trailing:t.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:u}),to:s?t.jsx(ll,{label:"To",addresses:s.envelope.to}):null,indicators:M||!x?t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[M,!x&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center justify-end gap-1",children:t.jsx(Ua,{isStarred:e.hasStars,onToggleStar:m,isStarPending:v})}),y&&t.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:x?void 0:t.jsx(Kd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:b,fromAddressId:C,isTrusted:f,showRaw:j,onToggleRaw:h}),actionBar:x?t.jsx(Wd,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:b,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:m,fromAddressId:C,isTrusted:f,showRaw:j,onToggleRaw:h,onReply:p,onReplyAll:g,onForward:d}):void 0,body:t.jsxs(t.Fragment,{children:[t.jsx(Hd,{threadMessage:e,accountId:b,className:"mt-3"}),n?t.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):r&&qr(a)?t.jsx("div",{className:"mt-3",children:t.jsx(Zs,{message:"This message is no longer on the mail server. It was moved or deleted in another mail app."})}):r&&Qr(a)?t.jsx("div",{className:"mt-3",children:t.jsx(Zs,{message:"This message has been deleted"})}):r?t.jsx("div",{className:"mt-3",children:t.jsx(Fe,{variant:"inline",title:"Couldn't load this message",error:a,onRetry:o})}):j?t.jsx("div",{className:"mt-3",children:t.jsx(Vd,{messageId:e.messageId})}):t.jsxs("div",{className:"mt-3",children:[t.jsx(Gn,{bodyParts:s?.bodyParts,messageId:e.messageId,fromAddressId:s?.envelope.from[0]?.addressId,isTrusted:f,isBlocked:k,category:Fa(e.category)}),t.jsx(Pa,{messageId:e.messageId,bodyParts:s?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})]})})},Xd=({threadMessage:e,isExpanded:s,isFocused:n,onToggle:r,onToggleStar:a,isStarPending:o,accountId:i,mobile:l,onReply:m,onReplyAll:v,onForward:b})=>{const[j,h]=c.useState(!1),{data:x,isLoading:p,isError:g,error:d,refetch:u}=te({...Ds({path:{messageId:e.messageId}}),enabled:s,meta:{softError:!0}});return s?t.jsx(Zd,{threadMessage:e,messageData:x,isLoading:p,isError:g,error:d,onRetry:()=>u(),isFocused:n,onToggle:r,onToggleStar:a,isStarPending:o,accountId:i,showRaw:j,onToggleRaw:()=>h(y=>!y),mobile:l,onReply:m,onReplyAll:v,onForward:b}):t.jsx(Yd,{threadMessage:e,isFocused:n,onToggle:r,onToggleStar:a,isStarPending:o})},eu=()=>t.jsxs("div",{className:"animate-pulse p-4",children:[t.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),t.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,s)=>t.jsxs("div",{className:"flex gap-3 py-3",children:[t.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),t.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},s))})]}),Bf=({threadId:e,mailboxId:s,subject:n,selectedMessageId:r,authenticity:a,onOpenIntelligence:o,onBack:i,onSwipeNext:l,onSwipePrevious:m,mobileIntelligenceOpen:v,listOnScreen:b=!1})=>{const j=ut(),{accountId:h}=zs(s),{data:x,isLoading:p,isError:g,error:d,refetch:u}=te({...En({path:{threadId:e}})}),y=c.useMemo(()=>x?.items??[],[x?.items]),f=y[y.length-1],k=c.useMemo(()=>[...y].reverse(),[y]),C=c.useRef(new Map),[N,M]=c.useState(new Set),[w,R]=c.useState(null),[E,A]=c.useState(0);c.useEffect(()=>{if(y.length>0&&e!==w){R(e);const I=new Set([y[y.length-1].threadMessageId]);if(r){const O=y.find(J=>J.messageId===r);O&&I.add(O.threadMessageId)}M(I),A(0)}},[e,y,w,r]);const B=c.useCallback(I=>{M(O=>{const J=new Set(O);return J.has(I)?J.delete(I):J.add(I),J})},[]),D=c.useCallback(I=>{const O=k[I];if(!O)return;C.current.get(O.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[k]),U=c.useCallback(()=>{if(k.length===0)return;const I=Math.min(E+1,k.length-1);A(I),D(I)},[k.length,E,D]),q=c.useCallback(()=>{if(k.length===0)return;const I=Math.max(E-1,0);A(I),D(I)},[k.length,E,D]),Q=c.useCallback(()=>{const I=k[E];I&&B(I.threadMessageId)},[k,E,B]);Vc({messages:y,expandedIds:N,threadId:e,mailboxId:s,accountId:h});const{toggleStar:F,isPending:z,pendingMessageId:P}=Aa({threadId:e,mailboxId:s,messages:y}),_=zo(),Y=Qn(),H=r??f?.messageId,G=c.useCallback((I,O)=>{O&&Y({threadId:e,messageId:O,mode:I})},[Y,e]),me=c.useCallback(()=>G("reply",H),[G,H]),he=c.useCallback(()=>G("reply-all",H),[G,H]),ae=c.useCallback(()=>G("forward",H),[G,H]),se=c.useRef(null),X=_?.kind==="reply"?`${_.mode}:${_.sourceMessageId}`:void 0;if(c.useEffect(()=>{X&&se.current?.scrollIntoView({behavior:"smooth",block:"start"})},[X]),ni({enabled:!p&&y.length>0&&_===void 0,bindings:[...b?[]:[{key:"j",action:"focusNext",handler:U,preventDefault:!0},{key:"ArrowDown",action:"focusNext",handler:U,preventDefault:!0},{key:"k",action:"focusPrevious",handler:q,preventDefault:!0},{key:"ArrowUp",action:"focusPrevious",handler:q,preventDefault:!0},{key:"Enter",action:"openFocused",handler:Q,preventDefault:!0},{key:"o",action:"openFocused",handler:Q,preventDefault:!0}],{key:"r",action:"reply",handler:me,preventDefault:!0},{key:"R",action:"replyAll",handler:he,noModifiers:!1,preventDefault:!0},{key:"f",action:"forward",handler:ae,preventDefault:!0}]}),p)return t.jsx(eu,{});if(g)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(Fe,{title:_?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:d,onRetry:()=>u()})});if(y.length===0)return t.jsx("div",{className:"flex h-full items-center justify-center p-4",children:_?t.jsx(Fe,{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."}):t.jsx(Zs,{message:"No messages in this thread"})});const re=n||y[0]?.subject||"(No subject)",ee=y.length,le=I=>t.jsx("div",{"data-testid":"conversation-messages",children:k.map((O,J)=>t.jsx("div",{ref:fe=>{fe&&C.current.set(O.threadMessageId,fe)},children:t.jsx(Xd,{threadMessage:O,isExpanded:N.has(O.threadMessageId),isFocused:J===E,onToggle:()=>B(O.threadMessageId),onToggleStar:()=>F(O.messageId,O.hasStars),isStarPending:z&&P===O.messageId,accountId:h,mobile:I,onReply:I?()=>G("reply",O.messageId):void 0,onReplyAll:I?()=>G("reply-all",O.messageId):void 0,onForward:I?()=>G("forward",O.messageId):void 0})},O.threadMessageId))}),ce=_&&t.jsx("div",{ref:se,children:_.kind==="reply"?t.jsx(Td,{surface:_}):t.jsx("div",{className:"border-b border-line bg-canvas p-4",children:t.jsx(Fe,{variant:"inline",title:"That is not a way to answer a message",error:`"${_.segment}" is not reply, reply-all or forward.`})})}),K=t.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[t.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:re}),t.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[ee," ",ee===1?"message":"messages"]})]});return j?t.jsxs("article",{className:"h-full flex flex-col",children:[K,a?.dkimMismatch&&t.jsx(dn,{authenticity:a,onOpenIntelligence:o}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[ce,le(!1)]})]}):t.jsxs(tc,{thread:{subject:re,messages:[]},onBack:i??(()=>{}),intelligenceOpen:v,onToggleIntelligence:o,onSwipeNext:l,onSwipePrevious:m,children:[a?.dkimMismatch&&t.jsx(dn,{authenticity:a,onOpenIntelligence:o}),ce,le(!0)]})},su=({isOpen:e,onClose:s,children:n,ariaLabel:r="Navigation",side:a="left",widthClassName:o="w-[80vw] max-w-[320px]",answers:i})=>{const l=c.useRef(null);if(Ms({id:"drawer",open:e,answers:{back:s,...i}}),Bn(l,e),c.useEffect(()=>{if(!e)return;const v=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=v}},[e]),!e)return null;const m=a==="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 t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":r,children:[t.jsx("button",{type:"button","aria-label":"Close menu",onClick:s,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),t.jsxs("div",{ref:l,tabIndex:-1,className:T("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,m),children:[t.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:t.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 menu",children:t.jsx(Le,{className:"size-5"})})}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:n})]})]})},js=e=>({messageId:e,tab:void 0,offering:!1,picked:[],answering:"",failure:{suggestionId:"",text:""}}),tu=(e,s)=>{const n=+(s.state==="Pending")-+(e.state==="Pending");return n!==0?n:s.sequence-e.sequence},nu=(e,s)=>s.kind==="refused"?`Couldn't ${e}: ${s.message} Try again, or answer from your calendar app.`:"";function au(e,s,n){const r=e.messageId,{suggestions:a,isLoading:o,error:i}=Ti(r),l=Ai(),{calendars:m,defaultCalendarId:v,colorByCalendarId:b,timeZoneByCalendarId:j}=l,h=fi(l),x=Ei(),p=Ii(),g=Ri(),[d,u]=c.useState(()=>js(r)),y=d.messageId===r?d:js(r),f=c.useRef(r);f.current=r;const k=I=>{f.current===r&&u(O=>({...O.messageId===r?O:js(r),...I}))},C=c.useMemo(()=>a.filter(gi).filter(I=>Ot(I)!==void 0).sort(tu)[0],[a]),N=a.filter(I=>I!==C&&I.state==="Pending"),M=C??N[0],w=M?zt(M):"",R=Hr(w===""?"1970-01-01":w,1),E=Di({...R,calendarIds:[],enabled:w!==""}),A=Fi(w===""?[]:[R]),B={threadId:e.threadId,threadSubject:e.subject??"",calendarId:v},D=e.fromName??e.fromEmail??"",U=Ni(y.failure.text||"the invitations in a message could not be read"),q=yi(h,U),Q=(I,O,J)=>{k({answering:I,failure:{suggestionId:I,text:""}}),J().then(fe=>k({answering:"",failure:{suggestionId:I,text:nu(O,fe)}}))},F=C?.suggestionId??"",z=y.failure.suggestionId===F?y.failure.text:"",P=y.failure.suggestionId===F?"":y.failure.text,_=C?Ot(C):void 0,Y=C&&_?{invite:pi(C,_.state,{...B,senderName:D}),whenText:Pt(C),calendarName:m.find(I=>I.id===v)?.name??"Calendar",color:b[v]??"cal-1",clashes:_.state==="pending"?hi({start:C.dtStart,end:C.dtEnd},A.spans):[],rsvp:_.rsvp,busy:y.answering===C.suggestionId,failure:z,reportHref:U,addBlocked:q,sender:D}:void 0,H=w===""?[]:xi(w,A.spans),G=E.instances.filter(Li).filter(I=>!I.allDay).sort((I,O)=>I.start.localeCompare(O.start)).map(I=>({event:Oi(I,j[I.calendarId]??"",zi()),timeText:wi(I.start),color:b[I.calendarId]??"cal-1"})),me=N.map(I=>({suggestion:bi(I,{...B,sender:D}),whenText:Pt(I)})),he=i===null?"":"Couldn't read the invitations in this message. Reopen it to try again.",ae=C?.method==="Cancel",se=I=>{const O=a.find(J=>J.suggestionId===I);O&&g(zt(O),I)},X=I=>{const O=a.find(J=>J.suggestionId===I);return O?.zoneCertainty==="Ambiguous"&&O.method!=="Cancel"},re=w===""?"":vi(w,H,y.picked),ee=C!==void 0&&C.answerOvertakenBy!==Wr.None,le={onAddInvite:()=>{if(X(F)){se(F);return}Q(F,"add this to your calendar",()=>x.accept(F,v))},onTentativeInvite:ae?void 0:()=>Q(F,"add this as a maybe",()=>x.tentative(F,v)),onDeclineInvite:()=>Q(F,"decline this",()=>x.decline(F)),onMuteInvite:()=>Q(F,"stop these invitations",()=>x.dismiss(F,!0)),onRemoveInvite:ae?()=>Q(F,"take this off your calendar",()=>x.accept(F,v)):void 0,onReopenInvite:ae?()=>Q(F,"keep this on your calendar",()=>x.dismiss(F,!1)):ee?void 0:()=>Q(F,"take this answer back",()=>x.reopen(F)),onOpenNewerInvite:n&&C&&C.supersededByThreadId!==""?()=>n({threadId:C.supersededByThreadId,messageId:C.supersededByMessageId}):void 0,onOfferOtherTimes:()=>k({offering:!0}),onToggleSlot:I=>k({picked:y.picked.includes(I.startTime)?y.picked.filter(O=>O!==I.startTime):[...y.picked,I.startTime]}),onReplyWithSlots:s?()=>s({threadId:e.threadId,messageId:r},re):void 0,onAddSuggestion:I=>{if(X(I)){se(I);return}Q(I,"add this to your calendar",()=>x.accept(I,v))},onReviewSuggestion:N[0]?.method==="Cancel"?void 0:se,onDismissSuggestion:I=>Q(I,"dismiss this",()=>x.dismiss(I,!1)),onSelectEvent:I=>{const{calendarObjectId:O,recurrenceId:J}=Pi(I);p(w,O,J)}},ce=Y!==void 0||me.length>0||i!==null,K=y.tab!==void 0;return c.useEffect(()=>{o||K||u(I=>I.messageId===r&&I.tab!==void 0?I:{...I.messageId===r?I:js(r),tab:ce?"calendar":"sender"})},[o,K,ce,r]),{surface:{data:{invite:Y,prose:y.offering&&w!==""?{dayLabel:_t(w),proposals:[],slots:H,picked:y.picked}:void 0,suggestions:me,day:G,dayLabel:w===""?"":_t(w),suggestionsBusy:y.answering!==""&&!Y?.busy,failure:he,suggestionsFailure:P,reportHref:U,addBlocked:q},actions:le},tab:y.tab??"sender",onTabChange:I=>k({tab:I})}}const ru=e=>e!=="uncategorized",ou=Jr.map(e=>e.category).filter(ru),iu=e=>e.spamReport?"notSpam":"reportSpam";function lu(){return t.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[t.jsx(Ue,{className:"size-3.5 text-fg-subtle"}),t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),t.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsx("div",{className:"h-8 rounded bg-surface"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,s)=>t.jsx("div",{className:"h-6 w-16 rounded bg-surface"},s))})]})]})]})}function cu({isOpen:e,current:s,hasOverride:n,onSelect:r,onClear:a,onCancel:o}){const i=c.useRef(null);return Bn(i,e),e?t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t.jsx(Vr,{label:"Dismiss reclassify sender",onDismiss:o,className:"backdrop-blur-sm"}),t.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",tabIndex:-1,className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),t.jsxs("div",{className:"mt-4 flex flex-col gap-1",children:[ou.map(l=>t.jsxs("button",{type:"button",onClick:()=>r(l),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm transition-colors hover:bg-surface-raised ${l===s?"font-semibold text-accent":"text-fg"}`,children:[Ts[l],l===s&&t.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},l)),n&&t.jsx("button",{type:"button",onClick:a,className:"mt-1 flex min-h-11 items-center rounded border-t border-line px-3 text-left text-sm text-fg transition-colors hover:bg-surface-raised",children:"Remove override — classify automatically again"})]}),t.jsx("div",{className:"mt-6 flex justify-end",children:t.jsx("button",{type:"button",onClick:o,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 du({thread:e,onClose:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:a,onReplyWithText:o,onOpenThread:i}){const{data:l,address:m,addressId:v}=ld(e),b=au(e,o,i),[j,h]=c.useState(!1),x=e.fromEmail??void 0,{updateFlags:p,clearFlags:g}=hd({addressId:v,senderEmail:x}),{reportSpam:d,notSpam:u,isReporting:y,isRestoring:f}=Oa({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:a}),k=Gr(),C=iu(e),N=c.useCallback(()=>{u([e.messageId])},[u,e.messageId]),M=c.useCallback(()=>{kd(k,{count:1,senderTrust:e.senderTrust,wasRescuable:dd(e)}),d([e.messageId])},[d,e,k]),w=c.useCallback(()=>{const U=l?.flags?.vip!==!0;p({vip:{value:U}})},[l?.flags?.vip,p]),R=c.useCallback(()=>{const U=l?.flags?.muted!==!0;p({muted:{value:U}})},[l?.flags?.muted,p]),E=c.useCallback(U=>{h(!1),p({category:{value:U}})},[p]),A=c.useCallback(()=>{h(!1),g(["category"])},[g]),B=v!==void 0,D={onToggleVip:B?w:void 0,onToggleMute:B?R:void 0,onReclassify:B?()=>h(!0):void 0,onNotSpam:C==="notSpam"?N:void 0,onReportSpam:C==="reportSpam"?M:void 0};return l?t.jsxs(t.Fragment,{children:[t.jsx(ra,{data:l,calendar:b.surface,tab:b.tab,onTabChange:b.onTabChange,onClose:s,hideCloseButton:r,actions:D,reportSpamPending:y,notSpamPending:f,className:"border-l-0 h-full w-full"}),t.jsx(cu,{isOpen:j,current:l.category.value,hasOverride:m?.flags?.category?.value!=null,onSelect:E,onClear:A,onCancel:()=>h(!1)})]}):t.jsx(lu,{})}const uu=({onClose:e,thread:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:a,onReplyWithText:o,onOpenThread:i})=>s?t.jsx(du,{thread:s,onClose:e,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:a,onReplyWithText:o,onOpenThread:i}):t.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[t.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[t.jsx(Ue,{className:"size-3.5 text-fg-subtle"}),t.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[t.jsx(Ue,{className:"size-8 text-fg-subtle"}),t.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),t.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust and authenticity will appear here."})]})]});function $f({isOpen:e,onClose:s,thread:n,accountId:r,onAfterOptimisticRemove:a,onReplyWithText:o,onOpenThread:i}){return t.jsx(su,{isOpen:e,onClose:s,ariaLabel:"Message details",side:"right",answers:{toggleIntelligence:s},children:t.jsx(uu,{onClose:s,thread:n,accountId:r,hideCloseButton:!0,onAfterOptimisticRemove:a,onReplyWithText:o,onOpenThread:i})})}const Ba=8;function yt(e,s){const n=Math.max(0,Math.min(s,e.length)),r=Qo(e).find(o=>n>=o.start&&n<=o.end);if(!r)return{start:n,end:n,raw:""};const a=Ho(r.raw);return a?{start:r.start,end:r.end,raw:r.raw,name:a.name,value:a.value}:{start:r.start,end:r.end,raw:r.raw}}function mu(e,s){const n=yt(e,s);if(n.name===void 0)return{kind:"token",query:n.raw};const r=Vn(n.name);if(r)return{kind:"value",token:r.name,source:r.values,query:n.value??""}}const fu={mailbox:"mailboxes",account:"accounts",contact:"contacts"},gu=(e,s)=>{if(e.values==="fixed")return e.options??[];const n=fu[e.values];return n?s[n]??[]:[]},hu=(e,s)=>{if(s==="")return 1;const n=e.toLowerCase();return n.startsWith(s)?0:n.includes(s)?1:-1},nt=(e,...s)=>{let n=-1;for(const r of s){if(r===void 0)continue;const a=hu(r,e);a<0||(n<0||a<n)&&(n=a)}return n},$a=e=>{const s=new Set;return e.filter(n=>n.rank>=0).sort((n,r)=>n.rank-r.rank).filter(n=>{const r=n.suggestion.value.toLowerCase();return s.has(r)?!1:(s.add(r),!0)}).slice(0,Ba).map(n=>n.suggestion)},gn=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function pu(e){const s=e.trim().toLowerCase();if(s==="")return Et.map(gn);const n=[];for(const r of Et)if(n.push({rank:nt(s,`${r.name}:`,r.label),suggestion:gn(r)}),r.values==="fixed")for(const a of r.options??[]){const o=Jn(r.name,a.value);n.push({rank:nt(s,o,a.label),suggestion:{value:o,label:a.label??o,hint:o}})}return $a(n)}function xu(e,s,n){const r=s.trim().toLowerCase(),a=gu(e,n).map(o=>({rank:nt(r,o.value,o.label),suggestion:{value:Jn(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return $a(a)}function bu(e,s,n={}){const r=yt(e,s);if(r.name===void 0)return pu(r.raw);const a=Vn(r.name);return a?xu(a,r.value??"",n):[]}function vu(e,s,n){const r=yt(e,s),a=!n.value.endsWith(":"),o=/\s/.test(e.slice(r.end,r.end+1)),i=a&&!o?`${n.value} `:n.value;return{query:e.slice(0,r.start)+i+e.slice(r.end),cursor:r.start+i.length+(a&&o?1:0)}}const yu=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),ju=250,ku=2;function Cu({query:e,cursor:s,enabled:n}){const{accounts:r}=cs(),{mailboxesByName:a}=Yn(),o=a!==void 0,i=n?mu(e,s):void 0,l=i?.source==="contact"?i.query.trim():"",m=ea(l,ju),{data:v}=te({...ct({query:{q:m,limit:Ba}}),enabled:m.length>=ku}),b=dt({queries:r.map(p=>({...ds({path:{accountId:p.accountId}}),staleTime:1/0}))}),j=c.useMemo(()=>o?To(b.map(p=>p.data?.items??[]),r):[],[o,b,r]),h=c.useMemo(()=>Ao(r),[r]),x=c.useMemo(()=>(v?.items??[]).map(yu),[v]);return c.useMemo(()=>{if(!n)return[];const p=bu(e,s,{mailboxes:j,accounts:h,contacts:x});return o?p:p.filter(g=>g.value!=="in:")},[n,e,s,j,h,x,o])}const Nu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},at=c.createContext(Nu),wu=()=>c.useContext(at),Su=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),Iu=e=>Su.has(e),Ru=e=>{const s=[],n=[];let r,a;for(const l of e.tokens){if(l.type==="from"){s.push({field:"From",value:l.value});continue}if(l.type==="subject"){s.push({field:"Subject",value:l.value});continue}if(l.type==="in"){r={mailboxId:l.mailboxId,label:l.value};continue}if(l.type==="account"){a=l.accountId;continue}Iu(l.type)&&n.push({type:l.type,label:Zn(l)})}const o=e.freeText.trim(),i=o.length>0;return i&&s.push({field:"HasWords",value:o}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:a,keptTerms:i}},Mu=(e,s,n)=>e.targetAccountId??s??n[0]?.accountId,Ka="remit.recentSearches",Tu=5;function rt(){try{const e=localStorage.getItem(Ka);if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s.filter(n=>typeof n=="string"):[]}catch{return[]}}function hn(e){const s=e.trim();if(!s)return rt();const n=[s,...rt().filter(r=>r!==s)].slice(0,Tu);try{localStorage.setItem(Ka,JSON.stringify(n))}catch{return n}return n}const ot=c.createContext(void 0),Au=()=>c.useContext(ot),Eu=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery),it=c.createContext(null);function Du(){const e=c.useContext(it),{searchInput:s,onSearchChange:n,onSearchClear:r}=cs();if(!e)throw new Error("ListHeaderSearchField rendered outside MailListHeader's HeaderSearchContext provider");return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(qn,{value:s,onChange:n,onClear:r,globalFocusKey:!1,showClearButton:!1,suggest:e.suggest})}),t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(Le,{className:"size-5"}),onClick:e.onClose,"aria-label":"Close search",className:"shrink-0"}),t.jsx($n,{})]})}function Kf({title:e,unreadCount:s,children:n,selectionBar:r,paneOverlay:a,footer:o,searchFilter:i,searchResults:l,searchLoading:m,onSelectSearchResult:v,searchResultsLabel:b="Top matches",searchResultsInBody:j=!1,spamOffer:h,refreshControl:x}){const{accounts:p,resultFolderIndex:g,searchQuery:d,searchInput:u,onSearchChange:y,onSearchClear:f,searchViewKey:k}=cs(),C=Yn(),N=Eo(),M=An(),w=_i(),[R,E]=c.useState(!1),[A,B]=c.useState(rt),D=Yr(),U=c.useRef(k);c.useEffect(()=>{U.current!==k&&(U.current=k,E(!1))},[k]);const[q,Q]=c.useState(0),[F,z]=c.useState(!1),[P,_]=c.useState(void 0),Y=Cu({query:u,cursor:q,enabled:F&&u.trim().length>0}),H=c.useCallback(ne=>{const pe=vu(u,q,ne);y(pe.query),_({cursor:pe.cursor})},[u,q,y]),G=Zr({count:Y.length,onAccept:ne=>{const pe=Y[ne];pe&&H(pe)}}),{comboboxProps:me,handleKeyDown:he}=G,ae=c.useMemo(()=>({comboboxProps:me,onKeyDown:he,onCaretChange:Q,onFocusChange:z,...P?{caret:P}:{}}),[me,he,P]),se=c.useCallback(()=>{f(),E(!1)},[f]),X=c.useMemo(()=>({suggest:ae,onClose:se}),[ae,se]),re=G.open?t.jsx(so,{id:G.listId,suggestions:Y,activeIndex:G.activeIndex,optionId:G.optionId,onPick:H,onHighlight:G.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,ee=u.trim().length>0,{mailboxesByName:le,accountsByName:ce}=C,K=c.useMemo(()=>Wo(u,{mailboxesByName:le,accountsByName:ce}),[u,le,ce]),I=c.useMemo(()=>K.tokens.map(ne=>({label:Zn(ne),onRemove:()=>y(Go(u,ne))})),[K,u,y]),O=c.useMemo(()=>l??[],[l]),J=c.useMemo(()=>ee?[{id:"top",label:b,results:O}]:[],[ee,b,O]),fe=O.length===0&&m===!0,{scope:W}=Do(p),Ke=Po(),Re=Bi(Ke),Me=Re?g.get(Re)?.role:void 0,de=c.useMemo(()=>$i(Ke,W,Me),[Ke,W,Me]),ge=de.kind==="global"?h:void 0,Te=c.useMemo(()=>ge?{kind:"global",spamCount:ge.count,onScopeToSpam:()=>N(ge.mailboxId,d)}:de,[ge,de,N,d]),Oe=c.useMemo(()=>Ru(K),[K]),oe=ee?Oe:void 0,Z=c.useCallback(()=>{E(!1),D("properties","search")},[D]),Ae=Bc(Oe)?void 0:Xr(Oe.droppedFacets.map(ne=>ne.label)),Ee=c.useMemo(()=>ee?{onClick:Z,blockedReason:Ae}:void 0,[ee,Ae,Z]),_s=c.useMemo(()=>Ee?t.jsx(xa,{...Ee}):null,[Ee]),je=Eu({tier:w,hasLiveInput:ee,hasCommittedQuery:d.trim().length>0,bodyRendersCommittedResults:j}),qe=c.useCallback(ne=>{B(hn(u)),v?.(ne)},[u,v]),fs=c.useMemo(()=>t.jsx(ba,{value:u,sections:J,loading:fe,onSelectResult:qe,tokens:I,scope:Te}),[u,J,fe,qe,I,Te]),gs=r===void 0,ze=c.useMemo(()=>je?t.jsx("div",{className:"h-full overflow-y-auto",children:fs}):null,[je,fs]),Us=ze&&!gs?ze:n,hs=ze&&gs?ze:null,Qe=Ui(w),He=Qe&&(R||ee),ve=c.useMemo(()=>({title:e,searchResults:hs,makeFilterSlot:_s,navSlot:M&&!M.showNavPane&&t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(Ki,{className:"size-5"}),onClick:()=>M.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:t.jsxs(t.Fragment,{children:[s===null?null:t.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.toLocaleString()," unread"]}),t.jsx($n,{}),x]}),searchSlot:Qe&&!He&&t.jsx($,{variant:"ghost",size:"touch",icon:t.jsx(eo,{className:"size-5"}),onClick:()=>E(!0),"aria-label":"Search",className:"shrink-0"}),searchField:He&&t.jsx(Du,{})}),[e,s,M,Qe,He,hs,_s,x]);if(w==="phone"&&R){const ne=pe=>{B(hn(u)),E(!1),v?.(pe)};return t.jsx(it.Provider,{value:X,children:t.jsx(ot.Provider,{value:oe,children:t.jsxs(at.Provider,{value:ve,children:[t.jsx(mc,{value:u,onChange:y,onClear:f,onCancel:()=>{E(!1),f()},filter:i,recentSearches:A,onPickRecent:y,makeFilter:Ee,sections:J,loading:fe,onSelectResult:ne,tokens:I,scope:Te,suggest:ae,suggestList:re}),a]})})})}return t.jsx(it.Provider,{value:X,children:t.jsx(ot.Provider,{value:oe,children:t.jsx(at.Provider,{value:ve,children:t.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[r?.(ve),re,t.jsx("div",{className:"min-h-0 flex-1",children:Us}),o,a]})})})})}const Fu=e=>{const{trashByAccount:s,hasAppointments:n,isError:r}=qc();return c.useMemo(()=>{const a=to({targets:e,trashByAccount:s,hasAppointments:n,isError:r}),o=i=>i.accountId?s.get(i.accountId):void 0;return{outcome:a,staleFolderLabel:e.map(o).find(i=>i?.source==="Stale")?.staleFolderPath,guessedMailboxId:a==="unconfirmed"?e.find(i=>o(i)?.mailboxId===i.mailboxId)?.mailboxId:void 0}},[e,s,n,r])},Lu=100,Ou=({mailboxId:e,mailboxLabel:s,accountId:n,enabled:r,predicateKey:a,searchQuery:o,reportEnding:i})=>{const[l,m]=c.useState({kind:"idle"}),v=c.useRef(void 0),{run:b,start:j,stop:h}=no(),{pushError:x}=be(),p=b?.mailboxId===e?b:void 0,g=p!==void 0,d=c.useRef(!1);d.current=g,c.useEffect(()=>{v.current?.abort(),m({kind:"idle"})},[r,a]);const u=c.useRef(o);u.current=o;const y=c.useCallback(R=>async(E,A)=>{const{data:B}=await Tt({path:{mailboxId:e},query:{...R,continuationToken:E,limit:Lu},signal:A,throwOnError:!0});return{ids:(B.items??[]).map(D=>D.messageId),continuationToken:B.continuationToken}},[e]),f=c.useCallback(async R=>{const{data:E}=await Tt({path:{mailboxId:e},query:{...u.current,count:!0,results:!1},signal:R,throwOnError:!0});if(E.count===void 0)throw new Error("the search returned no count for the selection");return E.count},[e]),k=c.useCallback(R=>async(E,A)=>{if(R.kind==="move"){const{data:D}=await ao({body:{messageIds:E,destinationMailboxId:R.destinationMailboxId},signal:A,throwOnError:!0});return D}if(R.kind==="markRead"){const{data:D}=await ro({body:{messageIds:E,isRead:!0},signal:A,throwOnError:!0});return D}const{data:B}=await oo({body:{messageIds:E},signal:A,throwOnError:!0});return B},[]),C=c.useCallback(()=>{const R=new AbortController;v.current=R,m({kind:"counting"}),f(R.signal).then(E=>{if(R.signal.aborted){m({kind:"idle"});return}m({kind:"escalated",total:E})},E=>{if(R.signal.aborted){m({kind:"idle"});return}x(io("Couldn't count matching messages","The count didn't finish.",E)),m({kind:"idle"})})},[f,x]),N=c.useCallback(()=>{v.current?.abort(),d.current&&h(e)},[h,e]),M=c.useCallback(()=>{d.current||(v.current?.abort(),m({kind:"idle"}))},[]),w=c.useCallback(async(R,E,A)=>{const B=E?.length??(l.kind==="escalated"?l.total:0),D=E!==void 0?{kind:"targets",targets:E}:{kind:"predicate",fetchPage:y(u.current)},U=await j({action:R,mailboxId:e,mailboxLabel:s,accountId:n,matched:B,source:D,applyBatch:k(R),reportEnding:i,claimEnding:A});return U.kind==="ran"&&m({kind:"idle"}),U},[k,y,l,e,s,n,i,j]);return{phase:l,escalate:C,stop:N,clear:M,isRunning:g,runningAction:p?.action,progress:p?.progress,runAction:w}},zu=120,Pu=({keyboardFocusedMessageId:e,openMessageId:s,enabled:n,open:r,delayMs:a=zu})=>{const o=c.useRef(r);o.current=r;const i=c.useRef(void 0);c.useEffect(()=>{const l=e;if(!n){i.current=l;return}if(l===void 0||l===s)return;if(l===i.current){i.current=void 0;return}const m=setTimeout(()=>o.current(l),a);return()=>clearTimeout(m)},[n,e,s,a])};function _u(e,s){if(e.length!==0)return s!==void 0&&e.includes(s)?s:e[0]}const Uu=({isOpen:e,messageIds:s,outcome:n,accountId:r,trashFolderLabel:a,staleFolderLabel:o,guessedMailboxId:i,isDeleting:l=!1,onConfirm:m,onCancel:v})=>{const{Account:b}=_n(),{requestAppointment:j}=Rn(),h=s.length,x=()=>m([...s]),p=lo(h,n,{trashFolderLabel:a,staleFolderLabel:o});if(n==="noTrash"||n==="staleTrash"||n==="unconfirmed"){const g=n==="noTrash"?"none":n==="staleTrash"?"stale":"unconfirmed";return t.jsx(xs,{isOpen:e,...p,onConfirm:()=>{if(!r)return x();const d=[...s];v(),j({accountId:r,role:"Trash",reason:g,action:{kind:"delete",count:h},staleFolderLabel:o,trashFolderLabel:a,guessedMailboxId:i,onAppointed:async()=>m(d)})},onCancel:v})}return n==="unavailable"?t.jsx(b,{fallback:t.jsx(xs,{isOpen:e,...p,confirmLabel:"Reload reader",onConfirm:()=>window.location.reload(),onCancel:v}),children:({signOut:g})=>t.jsx(xs,{isOpen:e,...p,onConfirm:()=>g(),onCancel:v})}):t.jsx(xs,{isOpen:e,...p,destructive:!0,isBusy:l||n==="unknown",onConfirm:x,onCancel:v})},qa=8,Qa=e=>e==="From"||e==="FromDomain",Bu=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),$u=e=>{const s=ja(e.email);if(s!==null)return{value:s,...e.fromSelection?{source:"selected"}:{}}},Ku=(e,s)=>e.value.toLowerCase().includes(s)||(e.label??"").toLowerCase().includes(s),qu=(e,s,n)=>{if(!Qa(e))return[];const r=s.trim().toLowerCase(),a=new Set,o=[];for(const i of n){if(i.email.trim()==="")continue;const l=e==="From"?Bu(i):$u(i);if(!l)continue;const m=l.value.toLowerCase();if(!(m===""||a.has(m))&&(a.add(m),m!==r&&!(r!==""&&!Ku(l,r))&&(o.push(l),o.length===qa)))break}return o},Qu=250,Hu=2,Wu=(e,s,n)=>{const r=s.trim(),a=ea(r,Qu),o=e!==void 0&&Qa(e),{data:i}=te({...ct({query:{q:a,limit:qa}}),enabled:o&&a.length>=Hu});if(!o||e===void 0)return[];const l=[...n.map(m=>({email:m,fromSelection:!0})),...(i?.items??[]).map(m=>({email:m.normalizedEmail,...m.displayName?{displayName:m.displayName}:{}}))];return qu(e,r,l)},Ha=12,Gu=e=>{const{envelope:s}=e,n=s.from[0];return{id:s.messageId,sender:n?ka({normalizedEmail:n.normalizedEmail,displayName:n.displayName}):"Unknown",subject:s.subject??"(No subject)",date:Es(s.date)}},Vu=(e,s)=>{const n=e!==void 0&&s!==void 0,{data:r,isLoading:a}=te({...co({path:{mailboxId:e??""},query:{...s,limit:Ha}}),enabled:n,staleTime:3e4});return{messages:(r?.items??[]).map(Ju),isPending:n&&a}},Ju=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Es(e.sentDate)}),Yu=e=>dt({queries:e.slice(0,Ha).map(s=>({...Ds({path:{messageId:s}}),staleTime:Number.POSITIVE_INFINITY})),combine:s=>({messages:s.map(n=>n.data).filter(n=>n!==void 0).map(Gu),isPending:s.some(n=>n.isPending)})}),Zu=()=>[uo({path:{mailboxId:""}}),mo({path:{mailboxId:""}}),fo()].map(e=>[{_id:e[0]._id}]),Xu=e=>go(e)?e.pages:ho(e)?[e]:[],em=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",sm=(e,s)=>{const n=new Set(s),r=new Map;for(const a of e)for(const o of Xu(a))for(const i of o.items){if(!em(i)||!n.has(i.messageId))continue;const l=i.subject?.trim();l&&r.set(i.messageId,l)}return s.map(a=>r.get(a)).filter(a=>a!==void 0)},tm=e=>{const s=ue(),n=e.join("\0");return c.useMemo(()=>{const r=Zu().flatMap(a=>s.getQueriesData({queryKey:a}).map(([,o])=>o));return sm(r,e)},[s,n])},pn={matched:0,applied:0,failed:0,failedIds:[]},nm=({matched:e,outcome:s,failureReason:n,progressDone:r})=>{if(n!==void 0)return{...pn,state:"commitFailed",failureReason:n};if(!s)return{state:"backApplyRunning",matched:Math.max(e,r),applied:r,failed:0,failedIds:[]};if(!s.cancelled&&s.error===void 0)return{state:"backApplyComplete",matched:Math.max(e,s.done),applied:s.done,failed:0,failedIds:[]};if(!s.cancelled&&s.done===0)return{...pn,state:"commitFailed"};const a=s.failedIds.length>0?s.failedIds.length:Math.max(e-s.done,1);return{state:"runStopped",matched:Math.max(e,s.done),applied:s.done,failed:a,failedIds:s.failedIds}},am=({failure:e,isStarting:s,isRunning:n,isDone:r,failedCount:a,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":r?a>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":s||n?"backApplyRunning":"saving",rm=e=>{if(e.runState==="statusUnknown")return{kind:"refreshStatus"};if(e.isEscalated)return{kind:"rerunEscalated"};if(e.committedScope==="standing"||e.committedScope==="temporary")return e.createFilterFailed?{kind:"resetAndResend"}:e.backApplyPending?{kind:"startBackApply"}:{kind:"waitOnJob"};if(e.committedScope==="all-like-these"&&e.widenRunsAsJob)return{kind:"resend"};const s=new Set(e.failedIds);return{kind:"rerunBulk",targets:s.size>0?e.sent.filter(n=>s.has(n.id)):e.sent}},om=e=>e!==void 0&&e.outcome===void 0&&e.failureReason===void 0,im=(e,s)=>{if(e){e.stop();return}s()},lm=(e,s)=>e==="run"?s.dismiss:s.cancel,cm={clauses:[],matchOperator:"any"},dm={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1},um=[],mm=(e,s,n)=>({verb:"organize",accountId:Mu(e,s.accountId,n),selection:um,selectionRestriction:void 0,escalated:void 0,searchConversion:e}),ks={state:"saving",matched:0,applied:0,failed:0,failures:[]},xn=(e,s)=>e.map((n,r)=>({...n,id:`${s}-${r}`})),bn=(e,s,n)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const r=e==="junk"?n:s;return r?{kind:"move",destinationMailboxId:r}:void 0},Js=e=>e==="move"||e==="junk"||e==="organize",vn=e=>e==="junk"?Da:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function fm({verb:e,accountId:s,mailboxId:n,mailboxLabel:r,selection:a,selectionRestriction:o,escalated:i,escalatedProgress:l,searchConversion:m,onFinished:v,onRunEnded:b,step:j,goToStep:h,goBack:x,closeWizard:p}){const[g]=c.useState(()=>m),[d]=c.useState(()=>i),u=g!==void 0,[y,f]=c.useState(u?"properties":"selected"),k=d?"escalated":y,[C,N]=c.useState(()=>g?{clauses:xn(g.clauses,"search"),matchOperator:g.matchOperator}:cm),[M,w]=c.useState(void 0),[R,E]=c.useState(void 0),[A,B]=c.useState(void 0),[D,U]=c.useState(void 0),q=c.useRef(!1),Q=c.useMemo(()=>a.map(S=>S.id),[a]),F=c.useMemo(()=>a.map(S=>({id:S.id,accountId:S.accountId})),[a]),z=c.useMemo(()=>a.map(S=>S.email).filter(Boolean),[a]),P=tm(Q),{junkMailboxId:_}=Na(s),{inboxMailboxId:Y}=Ca(s),H=c.useMemo(()=>Y?a.filter(S=>S.mailboxId!==void 0&&S.mailboxId!==Y).map(S=>({id:S.id,accountId:S.accountId})):[],[a,Y]),G=k==="properties",me=c.useMemo(()=>({matchOperator:C.matchOperator==="all"?"And":"Or",literalClauses:C.clauses.map(S=>({field:S.field,value:S.value}))}),[C.clauses,C.matchOperator]),{count:he,matchedIds:ae}=qi(G?s:void 0,me),se=Yu(G?ae:[]),X=Vu(d?n:void 0,d?.searchQuery),re=d?{status:"ready",count:d.total}:G?he:{status:"ready",count:a.length},{data:ee}=te({...ds({path:{accountId:s??""}}),enabled:!!s,staleTime:Number.POSITIVE_INFINITY}),le=wa(s),ce=Ln(),K=c.useMemo(()=>zn({mailboxes:ee?.items??[],folderAppointments:le,currentMailboxId:n,translator:ce}),[ee?.items,le,n,ce]),{createFolderIn:I}=On(s),O=K.find(S=>S.id===C.moveMailboxId)?.label,J=Ec(a.map(S=>({normalizedEmail:S.email,displayName:S.sender}))),fe=Uc({match:k==="properties"&&C.clauses[0]?.value.trim()||void 0,sender:J?ka(J):void 0,folder:O}),W=c.useMemo(()=>({...C,name:C.name??fe}),[C,fe]),Ke=Wu(M?.draft.field,M?.draft.value??"",z),Re=c.useRef(void 0),Me=c.useCallback(S=>{Re.current?.(),Re.current=S},[]);c.useEffect(()=>()=>{Re.current?.(),Re.current=void 0},[]);const de=Qi(s),ge=Hi(s),Te=Ou({mailboxId:n??"",mailboxLabel:r,accountId:s,enabled:!1,predicateKey:"selection-wizard",searchQuery:{},reportEnding:b}),{runAction:Oe}=Te,oe=bo({verb:e,mode:k,scope:C.scope,fromSearch:u}),Z=oe[At(oe,j)],Ae=vo(s,o),Ee=yo(k,Ae),je=(S=>{if(S==="folder")return Ae.destination;if(S==="rule")return W.scope==="standing"||W.scope==="until"?Ee:void 0})(Z)??jo(Z,W,re),qe=c.useCallback(()=>xn(_c(z,P),"seed"),[z,P]),fs=c.useCallback(S=>{f(S),N(L=>S==="properties"&&L.clauses.length===0?{...L,clauses:qe()}:L)},[qe]),gs=c.useCallback(()=>{w({mode:"add",draft:{field:"From",value:""}})},[]),ze=c.useCallback(S=>{const L=C.clauses.find(V=>V.id===S);L&&w({mode:"edit",clauseId:S,draft:{field:L.field,value:L.value}})},[C.clauses]),Us=c.useCallback(S=>{N(L=>({...L,clauses:L.clauses.filter(V=>V.id!==S)}))},[]),hs=c.useCallback(S=>{w(L=>L&&{...L,draft:S})},[]),Qe=c.useCallback(()=>{w(S=>{if(!S)return;const L=Wi(S.draft.field,S.draft.value),V={...S.draft,value:L};N(We=>({...We,clauses:S.clauseId?We.clauses.map(Qs=>Qs.id===S.clauseId?{...Qs,...V}:Qs):[...We.clauses,{id:crypto.randomUUID(),...V}]}))})},[]),He=c.useCallback(()=>{if(je){E(Z);return}E(void 0);const S=oe[At(oe,Z)+1];S&&h(S)},[je,Z,oe,h]),ve=c.useCallback(async S=>{const L=bn(e,W.moveMailboxId,_);if(!L){U({matched:S.length,sent:S,failureReason:vn(e)});return}U({matched:S.length,sent:S});const V=await Oe(L,S,Me);U({matched:S.length,sent:S,outcome:V.kind==="ran"?V.outcome:void 0,failureReason:V.kind==="refused"?V.reason:void 0})},[e,W.moveMailboxId,_,Oe,Me]),ne=c.useCallback(async()=>{if(!d)return;const S=bn(e,W.moveMailboxId,_);if(!S){U({matched:d.total,sent:[],failureReason:vn(e)});return}U({matched:d.total,sent:[]});const L=await d.run(S,Me);U({matched:d.total,sent:[],outcome:L.kind==="ran"?L.outcome:void 0,failureReason:L.kind==="refused"?L.reason:void 0})},[d,e,W.moveMailboxId,_,Me]),{start:pe,watch:kt}=de,{createFilterAsync:Ct}=ge,ps=c.useCallback(()=>{if(d){ne();return}const S=Gi({mode:y,ruleScope:W.scope}),L=Vi({ruleScope:W.scope,clauses:W.clauses,matchOperator:W.matchOperator,moveMailboxId:W.moveMailboxId,until:W.until});if(B(S),S==="standing"||S==="temporary"){Ct(L,S,(W.name??"").trim()).then(V=>{V&&(kt(V.organizeJobId),H.length>0&&ve(H))});return}if(S==="all-like-these"&&Js(e)){pe(L);return}ve(S==="just-these"?F:ae.map(V=>({id:V,accountId:s})))},[d,ne,y,W,e,s,F,ae,Ct,kt,H,pe,ve]),Wa=c.useCallback(()=>{if(je){E(Z);return}q.current||(q.current=!0,h("run"),ps())},[je,Z,h,ps]),Nt=c.useCallback(S=>{const L=de.progress,V=am({failure:de.failure,isStarting:de.isStarting,isRunning:de.isRunning,isDone:de.isDone,failedCount:L.failedCount,ruleSaved:S});return V==="saving"||V==="commitFailed"||V==="backApplyStartFailed"?{...ks,state:V}:{state:V,matched:L.matchedCount,applied:L.appliedCount,failed:V==="backApplyFailed"||V==="backApplyRestartFailed"?L.failedCount:0,failures:[]}},[de]),wt=c.useMemo(()=>{const S=new Map;for(const L of[...a,...se.messages,...X.messages])S.set(L.id,L);return S},[a,se.messages,X.messages]),St=d?l:Te.progress,Bs=c.useCallback(()=>{if(!D)return ks;const S=nm({matched:D.matched,outcome:D.outcome,failureReason:D.failureReason,progressDone:St?.done??0});return{state:S.state,matched:S.matched,applied:S.applied,failed:S.failed,failures:S.failedIds.map(L=>wt.get(L)).filter(L=>L!==void 0),failureReason:S.failureReason}},[D,St,wt]),$s=ge.data,It=D!==void 0&&(D.failureReason!==void 0||(D.outcome?.failedIds.length??0)>0),De=d?Bs():A==="standing"||A==="temporary"?ge.isError?{...ks,state:"commitFailed"}:ge.isSuccess?It?Bs():Nt(!0):ks:A==="all-like-these"&&Js(e)?Nt(!1):Bs(),Ga=()=>{if((A==="standing"||A==="temporary")&&It&&D){const V=new Set(D.outcome?.failedIds??[]);ve(V.size>0?D.sent.filter(We=>V.has(We.id)):D.sent);return}const L=rm({runState:De.state,isEscalated:d!==void 0,committedScope:A,createFilterFailed:ge.isError,backApplyPending:$s!==void 0,widenRunsAsJob:Js(e),failedIds:D?.outcome?.failedIds??[],sent:D?.sent??F});switch(L.kind){case"refreshStatus":de.refreshStatus();return;case"rerunEscalated":ne();return;case"resetAndResend":ge.reset(),ps();return;case"resend":ps();return;case"startBackApply":$s&&de.startForFilter($s.filterId);return;case"waitOnJob":return;case"rerunBulk":ve(L.targets);return}},Va=c.useCallback(()=>{p(oe,Z)},[p,oe,Z]),Ks=c.useCallback(()=>{p(oe,Z),v()},[p,oe,Z,v]),{stop:Rt}=Te,Ja=c.useCallback(()=>{im(d,Rt)},[d,Rt]);Mi({shouldBlockFn:({action:S})=>S!=="BACK"?!1:(Ks(),!0),enableBeforeUnload:!1,disabled:Z!=="run"});const qs={messages:d?X.messages:G?se.messages:a,count:re,label:k==="selected"?"Your selection":"A sample of what matches",loading:d?X.isPending:G&&(re.status==="loading"||se.isPending)};return t.jsx(ko,{verb:e,steps:oe,step:Z,blockedReason:je,nudged:R===Z,onBack:x,onExit:lm(Z,{dismiss:Ks,cancel:Va}),onContinue:He,onCommit:Wa,match:{selectedCount:a.length,mode:k,accountId:Ae.accountId,onModeChange:fs,escalatedScope:d?.scope,sample:qs},properties:{clauses:W.clauses,matchOperator:W.matchOperator,onMatchOperatorChange:S=>N(L=>({...L,matchOperator:S})),clauseEdit:M,onStartAddClause:gs,onStartEditClause:ze,onRemoveClause:Us,onChangeDraft:hs,onSubmitClause:Qe,onCancelClause:()=>w(void 0),clauseFields:Ji,clauseSuggestions:Ke,conversionNotice:g?$c(g):void 0,sample:{...qs,label:"What this matches"}},folder:{folders:K,mailboxId:W.moveMailboxId,delimiter:Pn(ee?.items??[]),onSelect:S=>N(L=>({...L,moveMailboxId:S})),onCreateFolder:s?I:void 0,restriction:Ae.destination},rule:{draft:W,onScopeChange:S=>N(L=>({...L,scope:S})),onUntilChange:S=>N(L=>({...L,until:S})),restriction:Ee},name:{name:W.name??"",onNameChange:S=>N(L=>({...L,name:S})),nudged:R===Z},review:{verb:e,mode:k,selectedCount:a.length,clauses:W.clauses,matchOperator:W.matchOperator,folder:O,scope:W.scope,until:W.until,ruleName:oe.includes("name")?W.name:void 0,escalatedScope:d?.scope,sample:qs},run:{state:De.state,verb:e,scope:W.scope,matched:De.matched,applied:De.applied,failedCount:De.failed,failures:De.failures,failureReason:De.failureReason,onRetry:Ga,onDismiss:Ks,onCancelRun:om(D)?Ja:void 0}})}function qf(e){const s=po()==="search",n=Au(),{accounts:r}=cs(),{step:a,goToStep:o,goBack:i,closeWizard:l}=xo(s?"properties":"match");if(Ms({id:"selection-wizard",open:a!==void 0}),!a)return null;const m=s?n??dm:void 0;return t.jsx(fm,{...e,...m?mm(m,e,r):{},step:a,goToStep:o,goBack:i,closeWizard:l})}const gm=[],jt=c.createContext(null),hm=e=>{const s=c.useContext(jt);return s?s.rowInteraction(e):null},pm=()=>{const e=c.useContext(jt);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},xm="[data-message-id]",bm=e=>Array.from(e.querySelectorAll(xm)).map(s=>s.dataset.messageId).filter(s=>s!==void 0),vm=(e,s)=>e.length===s.length&&e.every((n,r)=>n===s[r]),ym=e=>{const[s,n]=c.useState([]);return c.useEffect(()=>{const r=e.current;if(!r)return;const a=()=>{const i=bm(r);n(l=>vm(l,i)?l:i)};a();const o=new MutationObserver(a);return o.observe(r,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),s};function Qf({selectedMessageId:e,rows:s,onOpen:n,onDeleteMessages:r,onSelectionVerb:a,isDeleting:o=!1,commandsRef:i,onTriageContextChange:l,children:m}){const v=ut(),{pushError:b}=be(),j=c.useRef(null),h=ym(j),x=Kc({orderedIds:h,isDesktop:v,initialFocusedId:e}),{focusedMessageId:p,setFocusedMessageId:g,pendingDomFocusRef:d,cursorMovedByPointerRef:u,selection:y,isMultiSelectMode:f,exitSelection:k,handleRowSelect:C}=x,{selectedIds:N,selectedCount:M,isSelected:w,toggle:R,select:E,toggleAll:A}=y,B=h.length>0&&h.every(K=>N.has(K)),D=c.useCallback(()=>{h.length>0&&A(h)},[h,A]),{intersectWith:U}=y;c.useEffect(()=>{U(h)},[U,h]),c.useEffect(()=>{const K=d.current;K!==null&&(d.current=null,j.current?.querySelector(`[data-message-id="${K}"]`)?.focus())});const q=c.useCallback(K=>{u.current=!0,g(K)},[u,g]),Q=c.useCallback(K=>{v||E(K)},[v,E]),F=c.useCallback(()=>{p&&n(p)},[p,n]),z=c.useCallback(K=>n(K,{replace:!0}),[n]);Pu({keyboardFocusedMessageId:x.keyboardFocusedMessageId,openMessageId:e,enabled:v&&M===0,open:z});const[P,_]=c.useState(null),{outcome:Y,staleFolderLabel:H,guessedMailboxId:G}=Fu(P?.targets??gm),me=c.useCallback(K=>{if(P!==null)return!0;if(M>0)return a(K),!0;if(K!=="delete"||!p)return!1;const I=s.find(O=>O.id===p);return!I?.mailboxId||!I.accountId?(b({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):(_({ids:[p],targets:[{accountId:I.accountId,mailboxId:I.mailboxId}]}),!0)},[P,M,a,p,s,b]),he=c.useCallback(K=>{K.length!==0&&(r(K),_(null),k())},[r,k]),ae=c.useCallback(()=>_(null),[]),se=c.useCallback(()=>M===0?!1:(k(),!0),[M,k]),X=h.length>0;c.useEffect(()=>{if(i){if(!X){i.current=null;return}return i.current={focusNext:x.focusNext,focusPrevious:x.focusPrevious,focusFirst:x.focusFirst,focusLast:x.focusLast,openFocused:F,toggleSelect:x.toggleFocusedSelection,extendSelectDown:x.extendRangeDown,extendSelectUp:x.extendRangeUp,selectAll:x.selectAllLoaded,clearSelection:se,requestVerb:me,toggleDensity:()=>{}},()=>{i.current=null}}},[i,X,x.focusNext,x.focusPrevious,x.focusFirst,x.focusLast,x.toggleFocusedSelection,x.extendRangeDown,x.extendRangeUp,x.selectAllLoaded,F,se,me]);const re=c.useMemo(()=>Array.from(N),[N]),ee=P!==null;c.useEffect(()=>{l?.({focusedMessageId:p,selectedIds:re,orderedIds:h,hasList:X})},[l,p,re,h,X]);const le=_u(h,p),ce=c.useMemo(()=>({selectedIds:N,selectedCount:M,exitSelection:k,startSelectionVerb:a,orderedIds:h,allSelected:B,toggleAllLoaded:D,rowInteraction:K=>({focused:K===p,isTabStop:K===le,isDesktop:v,onFocusRow:q,selection:{isChecked:w(K),onToggleCheck:R,onRowSelect:C,isMultiSelectMode:f,onLongPress:Q}})}),[N,M,k,a,h,B,D,p,le,v,q,w,R,C,f,Q]);return t.jsxs(jt.Provider,{value:ce,children:[t.jsx("div",{ref:j,className:"contents",children:m}),t.jsx(Uu,{isOpen:ee,messageIds:P?.ids??[],outcome:Y,accountId:P?.targets[0]?.accountId,staleFolderLabel:H,guessedMailboxId:G,isDeleting:o,onConfirm:he,onCancel:ae})]})}function Hf({title:e,isDeleting:s}){const n=wu(),{selectedCount:r,exitSelection:a,startSelectionVerb:o,orderedIds:i,allSelected:l,toggleAllLoaded:m}=pm();return t.jsx(fc,{title:n.title||e,navSlot:n.navSlot,titleMeta:n.titleMeta,searchSlot:n.searchSlot,searchField:n.searchField,idleSlot:n.makeFilterSlot,count:r,onCancel:a,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:s,selectAll:i.length>0?{checked:l,indeterminate:r>0&&!l,onChange:m}:void 0})}const Ys=e=>{e.preventDefault(),e.stopPropagation()},jm=(e,s)=>{const n=c.useRef(!1),r=c.useCallback(i=>{if(n.current=!1,i.button!==0)return;const l=st(i);Kt(l)&&s?.(e,l)&&(Ys(i),n.current=!0,i.currentTarget.focus(),l.shiftKey&&window.getSelection()?.removeAllRanges())},[s,e]),a=c.useCallback(i=>{!i.ctrlKey||!s||i.preventDefault()},[s]),o=c.useCallback(i=>{if(n.current)return n.current=!1,Ys(i),!0;const l=st(i);return!Kt(l)||!s?.(e,l)?!1:(Ys(i),l.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[s,e]);return{onMouseDown:r,onContextMenu:a,claimClick:o}},km=({thread:e,active:s=!1,focused:n,isTabStop:r,density:a="comfortable",isDesktop:o,badge:i,selection:l,inListbox:m=!1,link:v,onClick:b,onFocusRow:j})=>{const h=ue(),x=e.id,p=hm(x),g=n??p?.focused??!1,d=r??p?.isTabStop??!1,u=l??p?.selection,y=j??p?.onFocusRow,f=o??p?.isDesktop??!0,k=u?.isChecked??!1,C=u?.isMultiSelectMode??!1,N=u?.onToggleCheck,M=u?.onRowSelect,w=u?.onLongPress,R=c.useCallback(P=>{P.preventDefault(),P.stopPropagation(),N?.(x)},[N,x]),E=jm(x,M),A=c.useCallback(P=>{if(!E.claimClick(P)){if(!f){if(C){P.preventDefault(),P.stopPropagation(),N?.(x);return}b?.();return}M?.(x,st(P)),b?.()}},[E,f,C,N,M,b,x]),B=c.useCallback(()=>{w?.(x)},[w,x]),{longPressProps:D}=sc({onLongPress:B,accessibilityDescription:k?"Deselect message":"Select message"}),U=c.useCallback(()=>{h.prefetchQuery(Ds({path:{messageId:x}}))},[h,x]),q=c.useCallback(()=>{U(),y?.(x)},[U,y,x]),Q=sa({"data-list-row":"","data-message-row":!0,"data-message-id":x,...m?{role:"option","aria-selected":k}:{},tabIndex:d?0:-1,onClick:A,onMouseDown:E.onMouseDown,onContextMenu:E.onContextMenu,onMouseEnter:U,onFocus:q},f||!u?{}:D),F=T(a==="compact"?la({active:s,focused:g}):T("group",ht({active:s,focused:g})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",k&&"bg-accent-soft",!f&&"min-h-11 select-none [-webkit-touch-callout:none]"),z=a==="compact"?t.jsx(ca,{thread:e}):t.jsx(pt,{thread:e,badge:i,selection:u?{checked:k,alwaysVisible:C,onToggle:R}:void 0});return v===void 0?t.jsx("button",{type:"button",...Q,className:F,children:z}):t.jsx(_o,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...v,messageId:x},search:P=>P,variant:"row",...Q,className:F,children:z})},Wf=c.memo(km),Cm="Open a message first",Nm="This conversation hasn't loaded yet",wm="The mailbox list hasn't loaded yet",Sm="Couldn't find this mailbox's account — reload to try again",Im={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},Gf=({hasThread:e,messageId:s,intelligenceOpen:n,canToggleIntelligence:r,onToggleIntelligence:a,onReply:o,onReplyAll:i,onForward:l,onDelete:m,onToggleStar:v,isStarred:b,moveContext:j,moveContextLoading:h})=>{const[x,p]=c.useState(null),g=s??null,d=w=>e?w==="move"?j?null:h?wm:Sm:{reply:o,replyAll:i,forward:l,delete:m,flag:v}[w]?null:Nm:Cm,u=x&&x.messageId===g?x:null,y=u?d(u.action):null,f=u?.action==="move"&&u.overThread&&!!j,k=y??(u&&!f?`${Im[u.action]} is ready — press it again`:null),C=w=>p({action:w,messageId:g,overThread:e}),N=w=>()=>C(w),M=(w,R)=>R?()=>{p(null),R()}:N(w);return t.jsx(zl,{hasThread:e,isStarred:b,onUnavailable:C,unavailableHint:k,replyTitle:`Reply ${Ge("reply")}`,replyAllTitle:`Reply all ${Ge("replyAll")}`,forwardTitle:`Forward ${Ge("forward")}`,deleteTitle:`Move to Trash ${Ge("delete")}`,flagTitle:`Star ${Ge("toggleStar")}`,onReply:M("reply",o),onReplyAll:M("replyAll",i),onForward:M("forward",l),onDelete:M("delete",m),onToggleStar:M("flag",v),onMove:N("move"),moveSlot:j?t.jsx(Ps,{accountId:j.accountId,currentMailboxId:j.currentMailboxId,onMove:j.onMove,label:"Move to mailbox",defaultOpen:f}):void 0,children:t.jsx(Ll,{open:n,enabled:r,onToggle:a})})};export{uu as $,Pf as A,zs as B,Hl as C,Uu as D,_f as E,Rf as F,kf as G,Os as H,ms as I,Nf as J,Cf as K,pf as L,Wf as M,hf as N,ud as O,Aa as P,ld as Q,hd as R,fc as S,kd as T,dd as U,wf as V,Uf as W,cd as X,yf as Y,Bf as Z,$f as _,Cd as a,vf as a0,Gf as a1,ff as a2,xf as a3,Lf as a4,Mf as a5,sa as a6,ft as a7,ec as a8,Zl as a9,Jl as aa,Xl as ab,Vl as ac,st as ad,df as ae,uf as af,lf as ag,cf as ah,Tf as ai,Kf as aj,bt as ak,wd as al,Nd as am,Sd as an,Of as ao,dc as ap,zf as aq,mf as ar,Eu as as,oc as at,Qf as au,$t as av,pm as aw,gf as ax,Hf as ay,jm as b,ht as c,wu as d,bf as e,Na as f,Fu as g,ql as h,Ou as i,Af as j,Pu as k,_u as l,qf as m,Kl as n,_l as o,jd as p,Ca as q,jf as r,wa as s,Fa as t,qc as u,Ef as v,Df as w,Ff as x,If as y,Sf as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,o,G as t,d as i}from"./index-BzL5-pGT.js";import{M as l}from"./menu-CGw_RHKl.js";function u({title:e,leading:a,children:n,className:r}){return s.jsxs("header",{className:o("flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",r),children:[a,e!==void 0&&s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),n]})}const h=e=>e.trim().toLocaleLowerCase();function x(){const e=t();return!e||e.showNavPane?null:s.jsx(i,{variant:"ghost",size:"sm",icon:s.jsx(l,{className:"size-4"}),onClick:e.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{x as N,u as P,h as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as le,r as t,j as e,B as O,f as de,g as te,l as ue,as as me,a as D,aO as Q,c as U,d as C,L as G,aP as W,at as pe,au as q,I as he,aa as fe,m as xe}from"./index-BzL5-pGT.js";import{C as ge}from"./checkbox-Qon94b1C.js";import{K as ye}from"./kbd-B9MFmWVU.js";import{A as ve,c as Se,d as je,s as V,W as R,C as _,g as be,e as K,f as Ce,h as we,a as X,S as ke,b as Ee,R as Ne}from"./credential-steps-BWguS0eW.js";import{c as Ae}from"./account-form-helpers-DhckT_PN.js";import{F as Me}from"./file-json-DiHW8YBd.js";const se=le("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),Ie="Pick at least one. An account has to sync something.",ne=[{id:"Mail",label:"Mail",description:"Messages, folders and sending."},{id:"Calendar",label:"Calendar",description:"This account's provider calendar, read into Remit."}];function Te({providerName:s,offered:i,selected:c,onChange:o,error:u}){const g=t.useId(),r=ne.filter(p=>i.includes(p.id)),f=u?e.jsx(O,{tone:"danger",variant:"soft",className:"mt-2 text-xs",children:u}):null;if(r.length<2)return f;const l=(p,y)=>{if(!y){o(c.filter(a=>a!==p));return}o(r.filter(a=>a.id===p||c.includes(a.id)).map(a=>a.id))};return e.jsxs("fieldset",{"aria-describedby":g,children:[e.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What should Remit sync?"}),e.jsx("div",{className:"mt-1 divide-y divide-line",children:r.map(p=>e.jsx(ge,{label:p.label,description:p.description,checked:c.includes(p.id),onChange:y=>l(p.id,y.target.checked)},p.id))}),e.jsx("p",{id:g,className:"mt-1.5 text-2xs text-fg-subtle",children:`Adding a service later means signing in with ${s} again.`}),f]})}const ae=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}},{id:"gmail",label:"Gmail",username:"full-email",imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},passwordHelp:{text:"Gmail requires an app password, not your Google password. First turn on 2-Step Verification for your Google Account, then create an app password under Security → 2-Step Verification → App passwords.",url:ve["gmail.com"]}}];function Y(s){return ae.find(i=>i.id===s)}const Pe={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail","gmail.com":"gmail","googlemail.com":"gmail"};function Re(s){const i=s.indexOf("@");if(i===-1)return"";const c=s.slice(i+1).toLowerCase();return Pe[c]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],P={connector:0,"microsoft-granted":5,address:1,servers:2,credentials:3,test:4,sync:5},J={host:"",port:993,security:"tls"},Z={host:"",port:587,security:"starttls"};function Fe({onStart:s,onImportConfig:i}){return t.useEffect(()=>{const c=o=>{o.key==="Enter"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),e.jsx(R,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:i?"Set up your first account, or bring the settings from another Reader.":"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[i?e.jsx(C,{variant:"secondary",icon:e.jsx(Me,{className:"size-4"}),onClick:i,children:"Import a config file"}):e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(ye,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:s,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(fe,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."}),i&&e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-relaxed text-fg-muted",children:"A config file carries your accounts, folder roles, rules, flagged senders and appearance from another Reader. It never carries passwords, so you sign in again here."})]})})}function Oe({onContinue:s,onMicrosoft:i,onBack:c,showBack:o}){const[u,g]=t.useState("imap");t.useEffect(()=>{const f=l=>{l.key==="Enter"&&(u==="microsoft"?i():s()),l.key==="Escape"&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,i,c,u]);const r=()=>{u==="microsoft"?i():s()};return e.jsx(R,{steps:M,activeStep:P.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[o?e.jsx(C,{variant:"ghost",onClick:c,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:r,children:u==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(X,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(ke,{className:"size-5"}),selected:u==="imap",onSelect:()=>g("imap")}),e.jsx(X,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(he,{className:"size-5"}),selected:u==="microsoft",onSelect:()=>g("microsoft")})]})})}const ee=["Mail","Calendar"];function Le({refusal:s,onBack:i,onConnected:c}){const[o,u]=t.useState(s?.email??""),[g,r]=t.useState(s?.services??ee),[f,l]=t.useState(!1),[p,y]=t.useState(s?.message??null),[a,w]=t.useState(!1),[N,j]=t.useState(!1),h=t.useRef(!0);t.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const v=t.useRef(new Set),{refetch:b}=D(U()),k=Ee(d=>{if(j(!1),d==="stalled"){w(!1),y(Ne);return}b().then(({data:S,isError:x})=>{if(!h.current)return;if(x||!S){y("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}y(null);const m=S.accounts.find(n=>!v.current.has(n.accountId));m&&c(m.accountId)})}),F=te({...xe(),onSuccess:d=>{h.current&&(k(),w(!0),window.location.assign(d.authorizationUrl))},onError:d=>{j(!1),y(d instanceof Error?d.message:"Failed to start sign-in")}}),I=N||F.isPending,A=()=>{if(!I){if(g.length===0){l(!0);return}y(null),j(!0),b().then(({data:d,isError:S})=>{if(h.current){if(S||!d){j(!1),y("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}v.current=new Set(d.accounts.map(x=>x.accountId)),F.mutate({body:{email:o.trim()||void 0,services:g}})}})}},T=t.useRef(A);return T.current=A,t.useEffect(()=>{const d=S=>{S.key==="Enter"&&T.current(),S.key==="Escape"&&i()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),e.jsx(R,{steps:M,activeStep:P.connector,title:s?.reconnect&&s.email?`Reconnect ${s.email}`:"Sign in with Microsoft",subtitle:"Microsoft is asked for the mail and calendar access you pick here.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:i,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,disabled:I,icon:I?e.jsx(G,{className:"size-4 animate-spin"}):void 0,children:I?"Redirecting…":a?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Te,{providerName:"Microsoft",offered:ee,selected:g,onChange:d=>{r(d),d.length>0&&l(!1)},error:f?Ie:void 0}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(q,{id:"microsoft-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@outlook.com",value:o,onChange:d=>u(d.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),a&&e.jsx(O,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),p&&e.jsx(O,{tone:"danger",children:p})]})})}function _e({accountId:s,onSignInAgain:i,onContinue:c}){const{data:o,isError:u,isFetching:g,refetch:r}=D(U()),f=o?.accounts.find(l=>l.accountId===s);return u?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Couldn't read the new account",subtitle:"Microsoft finished, but this instance did not answer.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{r()},disabled:g,children:"Retry"})]}),children:e.jsx(O,{tone:"danger",children:"Couldn't load the account Microsoft just connected. Check your connection and retry, or open Settings › Accounts to see it."})}):!o||!f&&g?e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"Reading the new account",subtitle:"Checking what Microsoft granted.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Loading…"}),e.jsx("span",{})]}),children:e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Loading the account…"]})}):f?e.jsx(Ge,{account:f,onContinue:c}):e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:"The account is not here",subtitle:"Microsoft sent the sign-in back, but no account was kept.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:i,children:"Sign in again"})]}),children:e.jsx(O,{tone:"danger",children:"This instance holds no account from that sign-in. Sign in with Microsoft again to connect it."})})}function Ge({account:s,onContinue:i}){const c=s.syncedServices.includes("Mail");return e.jsx(R,{steps:M,activeStep:P["microsoft-granted"],title:`Connected ${s.email}`,subtitle:"Microsoft granted access to what you picked.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Change this later in Settings › Accounts"}),e.jsx(C,{variant:"primary",onClick:()=>i(s.accountId),children:c?"Go to inbox":"Continue"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"divide-y divide-line",children:ne.map(o=>s.syncedServices.includes(o.id)?e.jsx(_,{label:o.label,detail:"Access granted — syncing",state:"ok"},o.id):e.jsx(_,{label:o.label,detail:"Not synced. Turn it on in Settings › Accounts; Microsoft asks for access then.",state:"pending"},o.id))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Permissions Microsoft granted"}),e.jsx("code",{className:"mt-1 block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted","data-testid":"granted-scopes",children:s.grantedScopes.join(" ")})]})]})})}function He({initialEmail:s,initialDisplayName:i,onContinue:c,onBack:o}){const[u,g]=t.useState(s),[r,f]=t.useState(i),[l,p]=t.useState(!1),[y,a]=t.useState(""),[w,N]=t.useState(null),j=t.useCallback(async()=>{const h=u.trim();if(!h.includes("@")||!h.includes(".")){N("Enter a valid email address.");return}N(null),p(!0),a(Ce(h));try{const v=await we(h);c(h,r.trim(),v)}finally{p(!1)}},[u,r,c]);return t.useEffect(()=>{const h=v=>{v.key==="Enter"&&!l&&j(),v.key==="Escape"&&o()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[j,l,o]),e.jsx(R,{steps:M,activeStep:P.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:o,children:"Back"}),e.jsx(C,{variant:"primary",disabled:l,onClick:()=>{j()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(q,{id:"onboarding-email",icon:e.jsx(se,{className:"size-4"}),placeholder:"you@example.com",value:u,onChange:h=>{g(h.target.value),N(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(q,{id:"onboarding-display-name",placeholder:"Alice",value:r,onChange:h=>f(h.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),l&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(G,{className:"size-3.5 animate-spin text-accent"}),y]}),w&&!l&&e.jsx("div",{className:"mt-3",children:e.jsx(O,{tone:"danger",children:w})})]})})}function ze({email:s,imapConfig:i,smtpConfig:c,discovered:o,onContinue:u,onBack:g,onChange:r}){const[f,l]=t.useState(i),[p,y]=t.useState(c),[a,w]=t.useState(()=>Re(s)),[N,j]=t.useState(!1),[h,v]=t.useState(null),b=Y(a),k=b!==void 0&&!N,F=t.useCallback(m=>{w(m),j(!1),v(null);const n=Y(m);n&&(l({host:n.imap.host,port:n.imap.port,security:n.imap.security}),y({host:n.smtp.host,port:n.smtp.port,security:n.smtp.security}))},[]);t.useEffect(()=>{r(f,p)},[f,p,r]);const I=f.host.trim()!=="",A=t.useCallback(()=>{if(!I){v("Enter the IMAP host.");return}v(null),u()},[I,u]);t.useEffect(()=>{const m=n=>{n.key==="Enter"&&A(),n.key==="Escape"&&g()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[A,g]);const T=s.split("@")[1]??"your domain",d=b?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":o?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,S=k?{label:"preset",tone:"neutral"}:!b&&o?{label:"detected",tone:"positive"}:void 0,x=b?.passwordHelp.url??be(s);return e.jsx(R,{steps:M,activeStep:P.servers,title:"Confirm server settings",subtitle:d,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:g,children:"Back"}),e.jsx(C,{variant:"primary",onClick:A,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[h&&e.jsx(O,{tone:"danger",children:h}),e.jsxs("div",{children:[e.jsx(W,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(pe,{id:"provider-select",value:a,onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ae.map(m=>e.jsx("option",{value:m.id,children:m.label},m.id))]}),b&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:k?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",b.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>j(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",b.label,"'s settings by hand."]})})]}),e.jsx(K,{legend:"IMAP — incoming",badge:S,readOnly:k,host:f.host,port:String(f.port),security:f.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:m=>{l(n=>({...n,host:m})),v(null)},onPortChange:m=>l(n=>({...n,port:Number(m)})),onSecurityChange:m=>l(n=>({...n,security:m}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(K,{legend:"SMTP — outgoing (optional)",badge:S,readOnly:k,host:p.host,port:String(p.port),security:p.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:m=>{y(n=>({...n,host:m})),v(null)},onPortChange:m=>y(n=>({...n,port:Number(m)})),onSecurityChange:m=>y(n=>({...n,security:m}))}),b&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[b.passwordHelp.text," ",x&&e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}const Be=2e4;function De({email:s,displayName:i,imapConfig:c,smtpConfig:o,username:u,password:g,onGoToInbox:r}){const f=de(),[l,p]=t.useState(null),[y,a]=t.useState(null),w=t.useRef(!1),N=V(c.security),j=V(o.security),h=te({...me(),onSuccess:E=>{p(E.accountId),f.invalidateQueries({queryKey:ue()})},onError:E=>{a(E instanceof Error?E.message:"Failed to create account")}});t.useEffect(()=>{if(w.current)return;w.current=!0;const E=o.host.trim()!=="",z=Ae({imapHost:c.host,smtpHost:o.host,smtpPort:o.port}),B=E?z??{smtpHost:o.host,smtpPort:o.port,smtpTls:j.tls,smtpStartTls:j.startTls}:null;h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:B?.smtpHost||void 0,smtpPort:B?.smtpPort||void 0,smtpTls:B?.smtpTls??!1,smtpStartTls:B?.smtpStartTls??!1}})},[]);const{data:v,isError:b}=D({...Q({path:{accountId:l??""}}),enabled:!!l,refetchInterval:E=>{const z=E.state.data?.syncPhase;return z==="complete"||z==="error"?!1:2e3}}),k=v?.syncPhase==="error",{data:F}=D({...U(),enabled:!!l&&k}),I=F?.accounts.find(E=>E.accountId===l)?.lastError,A=v?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=v?.mailboxCountTotal??0,d=v?.mailboxCountSynced??0,S=A?.messagesTotal??0,x=A?.messagesSynced??0,m=S>0?x/S:0,n=v?.syncPhase,H=k?"failed":n==="idle"||n===void 0||n==="discovering_mailboxes"?"running":T>0?"ok":"running",L=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"?"pending":n==="syncing_inbox"||n==="syncing_others"?"running":"ok",$=k?"failed":!n||n==="idle"||n==="discovering_mailboxes"||n==="syncing_inbox"?"pending":n==="syncing_others"?"running":"ok",ie=x>0||A?.phase==="complete"||n==="complete"||k,[oe,re]=t.useState(!1);t.useEffect(()=>{if(!l)return;const E=setTimeout(()=>re(!0),Be);return()=>clearTimeout(E)},[l]);const ce=!!l&&(ie||b||oe);return y?e.jsx(R,{steps:M,activeStep:P.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{w.current=!1,a(null),h.mutate({body:{email:s,displayName:i||void 0,username:u!==s?u:void 0,password:g,imapHost:c.host,imapPort:c.port,imapTls:N.tls,imapStartTls:N.startTls,smtpHost:o.host||void 0,smtpPort:o.port||void 0,smtpTls:j.tls,smtpStartTls:j.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:y})}):e.jsx(R,{steps:M,activeStep:P.sync,title:`Syncing ${s}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),ce?e.jsx(C,{variant:"primary",onClick:()=>l&&r(l),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(G,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:h.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(G,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[S>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[x.toLocaleString()," / ",S.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,m*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:H}),e.jsx(_,{label:"INBOX",detail:L==="ok"?`${x.toLocaleString()} messages synced`:L==="running"?"Syncing newest first…":"Queued",state:L}),d>1||n==="syncing_others"||n==="complete"?e.jsx(_,{label:"Other mailboxes",detail:$==="ok"?`${d-1} mailboxes synced`:$==="running"?"Syncing…":"Queued",state:$}):null]}),k&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{f.invalidateQueries({queryKey:Q({path:{accountId:l??""}}).queryKey})},children:"retry"})]}),I&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:I})]})]})})}const We=(s,i)=>i?.kind==="connected"?"microsoft-granted":i?.kind==="refused"?"microsoft-email":s?"connector":"welcome";function Xe({skipWelcome:s=!1,onComplete:i,onCancel:c,onImportConfig:o,microsoftReturn:u}){const[g,r]=t.useState(We(s,u)),[f,l]=t.useState(u?.kind==="refused"?u:void 0),[p,y]=t.useState(u?.kind==="connected"?u.accountId:null),[a,w]=t.useState({email:"",displayName:"",imapConfig:J,smtpConfig:Z,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),N=t.useCallback(()=>r("connector"),[]),j=t.useCallback(()=>r("address"),[]),h=t.useCallback(()=>r("microsoft-email"),[]),v=t.useCallback(()=>{s?c?.():r("welcome")},[s,c]),b=t.useCallback((d,S,x)=>{let m=J,n=Z,H=!1;x&&(H=x.source!=="heuristic",m={host:x.imap.host,port:x.imap.port,security:x.imap.security},n={host:x.smtp.host,port:x.smtp.port,security:x.smtp.security}),w(L=>({...L,email:d,displayName:S,imapConfig:m,smtpConfig:n,discoveryResult:x,discovered:H,username:d})),r("servers")},[]),k=t.useCallback((d,S)=>{w(x=>({...x,imapConfig:d,smtpConfig:S}))},[]),F=t.useCallback((d,S)=>{w(x=>({...x,username:d,password:S}))},[]),I=t.useCallback(()=>r("sync"),[]),A=t.useCallback(d=>{i(d)},[i]),T=e.jsx(Le,{refusal:f,onBack:()=>{l(void 0),r("connector")},onConnected:d=>{y(d),r("microsoft-granted")}});switch(g){case"welcome":return e.jsx(Fe,{onStart:N,onImportConfig:o});case"connector":return e.jsx(Oe,{onContinue:j,onMicrosoft:h,onBack:v,showBack:!s});case"microsoft-email":return T;case"microsoft-granted":return p===null?T:e.jsx(_e,{accountId:p,onSignInAgain:()=>r("microsoft-email"),onContinue:A});case"address":return e.jsx(He,{initialEmail:a.email,initialDisplayName:a.displayName,onContinue:b,onBack:()=>r("connector")});case"servers":return e.jsx(ze,{email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,discovered:a.discovered,onContinue:()=>r("credentials"),onBack:()=>r("address"),onChange:k});case"credentials":return e.jsx(je,{steps:M,activeStep:P.credentials,title:`Sign in to ${a.email.split("@")[1]||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",email:a.email,username:a.username,password:a.password,onContinue:()=>r("test"),onBack:()=>r("servers"),onChange:F});case"test":return e.jsx(Se,{steps:M,activeStep:P.test,email:a.email,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onSuccess:I,onBackToCredentials:()=>r("credentials"),onBackToServers:()=>r("servers")});case"sync":return e.jsx(De,{email:a.email,displayName:a.displayName,imapConfig:a.imapConfig,smtpConfig:a.smtpConfig,username:a.username,password:a.password,onGoToInbox:A})}}export{ne as A,Xe as O,ae as P,Y as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ah as b,w,L as C,j as s,o as g,T as q,x as S,J as H,u as _,r as x,cB as U,a as J,Z as K,P as W,dZ as Z,f as G,ao as V,dt as X,g as v,aq as y,d2 as Y,d3 as ee,bJ as p,fD as se}from"./index-BzL5-pGT.js";import{a as te,u as k,L as R}from"./roving-focus-Coea111y.js";import{u as ne,p as ae,R as j,c as oe}from"./MessageBody-Deha778B.js";import{C as D}from"./circle-check-big-CyVG6r7N.js";import{C as I}from"./clock-B9kFW89H.js";import{R as re}from"./row-actions-CiZruXil.js";import{R as ie}from"./rotate-ccw-DPB71584.js";import{n as le,P as L,N as ce}from"./NavMenuButton-C-7-t18I.js";import{i as ue,s as T}from"./outbox-status-BlKn6P0x.js";import{g as de,k as xe}from"./reply-CQarAZxU.js";import{g as fe}from"./useMessageBodyContent-CWGtiddz.js";const me={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:b,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:b,label:"Blocked",className:"text-warning"}};function O({status:e,iconOnly:t,className:a}){const n=me[e],o=n.icon;return s.jsxs("span",{className:g("inline-flex items-center gap-1.5 text-xs font-medium",n.className,a),children:[s.jsx(o,{className:g("size-4",n.spin&&"animate-spin")}),!t&&n.label]})}const he=(e,t)=>t?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"||e==="unfiled"?"bg-warning/10":"";function ge({recipients:e,subject:t,time:a,status:n,error:o,selected:l,onSelect:c,onRetry:r,retrying:u,onEdit:i,onDelete:f,deleting:d}){const m=n==="failed"||n==="blocked"||n==="unfiled";return s.jsxs("div",{className:g("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",he(n,l)),children:[s.jsxs("button",{type:"button",...te,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(O,{status:n,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:t||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(O,{status:n}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),m&&s.jsx("div",{className:"shrink-0",children:s.jsx(re,{actions:[...n==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(ie,{className:"size-3.5"}),busy:u,onClick:r}]:[],...n==="unfiled"?[]:[{label:"Edit as draft",iconOnly:!0,icon:s.jsx(S,{className:"size-3.5"}),onClick:i}]],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(q,{className:"size-3.5"}),busy:d,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function Be(){return H({from:"/mail/outbox/draft/$outboxMessageId",shouldThrow:!1})?.outboxMessageId}function be(){const e=_(),t=de();return x.useCallback(a=>{e({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:a},search:U,hash:t})},[e,t])}function pe(){return xe()}function je(e,t){const a=t.trim().toLowerCase();if(a.length===0)return!0;const n=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||n.includes(o))}function Ne(e){return e.tokens.length>0&&e.freeText.trim().length===0}const A={queued:{icon:I,label:"Queued",className:"text-warning"},sending:{icon:C,label:"Sending…",className:"text-accent-2"},sent:{icon:D,label:"Sent",className:"text-positive"},unfiled:{icon:b,label:"Sent, not filed",className:"text-warning"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:b,label:"Blocked",className:"text-warning"}},ve=e=>se(e).toDateString()===new Date().toDateString()?p(e,{hour:"numeric",minute:"2-digit"}):p(e,{month:"short",day:"numeric"}),M=e=>p(e,{dateStyle:"medium",timeStyle:"short"}),ye=e=>{const t=e.toAddresses??[];return t.length===0?"No recipients":t.length===1?t[0]:`${t[0]} +${t.length-1}`},E=(e,t)=>t?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",P=x.createContext(null);function N(){const e=x.useContext(P);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function Oe({outboxMessageId:e,children:t}){const a=be(),n=pe(),{data:o,isLoading:l}=J(K()),{searchQuery:c}=W(),r=ne(),u=le(c),i=ae(u,r),f=u.length>0,d=Ne(i),m=x.useMemo(()=>d?[]:(o?.items??[]).filter(h=>ue(h.status)).filter(h=>je(h,i.freeText)),[o,i.freeText,d]),F=x.useMemo(()=>m.find(h=>h.outboxMessageId===e),[m,e]),$={messages:m,hasQuery:f,unsupportedQuery:d,isLoading:l,selectedMessageId:e,selectedMessage:F,onOpenMessage:a,onCloseMessage:n};return s.jsx(P.Provider,{value:$,children:t})}function Q({message:e,isSelected:t,onSelect:a}){const n=G(),o=fe(),{pushError:l}=V(),c=x.useCallback(()=>{n.invalidateQueries({queryKey:X()})},[n]),r=v({...Y(),onSuccess:c,onError:d=>{l(y("Couldn't resend message","The message wasn't sent.",d))}}),u=v({...ee(),onSuccess:c,onError:d=>{l(y("Couldn't delete message","The message wasn't deleted.",d))}}),i=e.status;if(!A[i])return null;const f=T(e.status);return s.jsx(ge,{recipients:ye(e),subject:e.subject||"",time:ve(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:t,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o(e.outboxMessageId),onDelete:()=>u.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:u.isPending})}function B({message:e,onBack:t}){const a=e.status,n=A[a],o=n?.icon??S,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[t&&s.jsxs("button",{type:"button",onClick:t,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(Z,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),n&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:g("size-4",n.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:g("text-xs font-medium",n.className),children:n.label}),T(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(oe,{html:e.htmlBody,text:e.textBody})})]})}function Me(){const{messages:e,hasQuery:t,unsupportedQuery:a,isLoading:n,selectedMessageId:o,onOpenMessage:l}=N(),c=x.useRef(null);return k({containerRef:c,itemSelector:R}),n?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(t,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsx(z,{count:e.length}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(Q,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function z({count:e}){return s.jsx(L,{title:"Outbox",leading:s.jsx(ce,{}),children:s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e," ",e===1?"message":"messages"]})})}function we(){const{selectedMessage:e}=N();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx(L,{}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(j,{message:"Select a message to read",showHints:!1})})]})}function Ce(){const{messages:e,hasQuery:t,unsupportedQuery:a,isLoading:n,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=N(),u=x.useRef(null);return k({containerRef:u,itemSelector:R}),n?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(j,{message:E(t,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsx(z,{count:e.length}),s.jsx("div",{ref:u,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(Q,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const ze=Object.assign(Oe,{List:Me,Reading:we,Phone:Ce});export{ze as O,Be as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as o}from"./index-BzL5-pGT.js";const n=o;export{n as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ab as m,j as o,O as p}from"./index-BzL5-pGT.js";import{a}from"./MailShell-0sTtK1xD.js";import{M as r}from"./MailboxPane-DYgnYeOy.js";import"./reply-CQarAZxU.js";import{a as e}from"./search-token-index-DQHE1g7A.js";import{u as s}from"./search-mirror-_Dap9COg.js";import"./useMessageBodyContent-CWGtiddz.js";import"./FullCompose-dJ4mfUrX.js";import"./ErrorState-nA0Ptq3g.js";import"./index-BWAq8iOl.js";import"./useSignature-sxHvGfKr.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B7157ZPO.js";import"./sections-C6oVXjho.js";import"./useMediaQuery-7Q3jBluO.js";import"./confirm-dialog-CgMAaLI3.js";import"./MessageBody-Deha778B.js";import"./kbd-B9MFmWVU.js";import"./search-scope-UI1H6AzA.js";import"./useRefreshControl-bA8HK_j-.js";import"./circle-check-big-CyVG6r7N.js";import"./refresh-cw-D1SQy8O7.js";import"./useQueries-Sm8S3Cgh.js";import"./MessageToolbar-5T47fDWC.js";import"./roving-focus-Coea111y.js";import"./EmptyState-dD_YhGMH.js";import"./popover-menu-CNiMANtf.js";import"./avatar-vPm9XfmM.js";import"./undo-2-DHJ6nykB.js";import"./download-A4hq8dWf.js";import"./calendar-suggestion-ClsxDTZs.js";import"./sparkles-C1l6GCPT.js";import"./useCalendarSuggestions-DcYFtQhb.js";import"./calendar-report-CzeBcU6C.js";import"./calendar-failure-note-BUFaaizf.js";import"./checkbox-Qon94b1C.js";import"./clock-B9kFW89H.js";import"./shield-check-BcUXVpR8.js";import"./calendar-LLRgZQzl.js";import"./useLayoutTier-5aJYrTut.js";import"./menu-CGw_RHKl.js";import"./useFilters-C3bLY42W.js";import"./MailViewChrome-BEx9Dr1Z.js";import"./LabelApplyTrigger-BA7ANeDk.js";import"./useLabels-DYdHiHXI.js";import"./NavMenuButton-C-7-t18I.js";import"./bottom-sheet-BTdseD_6.js";import"./circle-help-CVShnhWn.js";import"./circle-check-Db07NpOC.js";function mo(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{mo as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as r}from"./index-BzL5-pGT.js";import{B as o}from"./BriefPane-BzlqkW4r.js";import"./MessageBody-Deha778B.js";import"./kbd-B9MFmWVU.js";import"./search-scope-UI1H6AzA.js";import"./reply-CQarAZxU.js";import"./useMediaQuery-7Q3jBluO.js";import"./useMessageBodyContent-CWGtiddz.js";import"./MessageToolbar-5T47fDWC.js";import"./roving-focus-Coea111y.js";import"./search-token-index-DQHE1g7A.js";import"./useQueries-Sm8S3Cgh.js";import"./EmptyState-dD_YhGMH.js";import"./ErrorState-nA0Ptq3g.js";import"./popover-menu-CNiMANtf.js";import"./avatar-vPm9XfmM.js";import"./index-BWAq8iOl.js";import"./useSignature-sxHvGfKr.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B7157ZPO.js";import"./sections-C6oVXjho.js";import"./undo-2-DHJ6nykB.js";import"./download-A4hq8dWf.js";import"./calendar-suggestion-ClsxDTZs.js";import"./sparkles-C1l6GCPT.js";import"./useCalendarSuggestions-DcYFtQhb.js";import"./calendar-report-CzeBcU6C.js";import"./calendar-failure-note-BUFaaizf.js";import"./checkbox-Qon94b1C.js";import"./clock-B9kFW89H.js";import"./shield-check-BcUXVpR8.js";import"./calendar-LLRgZQzl.js";import"./useLayoutTier-5aJYrTut.js";import"./menu-CGw_RHKl.js";import"./useFilters-C3bLY42W.js";import"./confirm-dialog-CgMAaLI3.js";import"./useRefreshControl-bA8HK_j-.js";import"./circle-check-big-CyVG6r7N.js";import"./refresh-cw-D1SQy8O7.js";import"./LabelApplyTrigger-BA7ANeDk.js";import"./useLabels-DYdHiHXI.js";import"./wizard-selection-zWa1qc6-.js";function S(){return r.jsx(o.Reading,{})}export{S as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as o}from"./index-BzL5-pGT.js";import{F as r}from"./FlaggedPane-BwhUf1qN.js";import"./MessageBody-Deha778B.js";import"./kbd-B9MFmWVU.js";import"./search-scope-UI1H6AzA.js";import"./reply-CQarAZxU.js";import"./useMediaQuery-7Q3jBluO.js";import"./useMessageBodyContent-CWGtiddz.js";import"./MessageToolbar-5T47fDWC.js";import"./roving-focus-Coea111y.js";import"./search-token-index-DQHE1g7A.js";import"./useQueries-Sm8S3Cgh.js";import"./EmptyState-dD_YhGMH.js";import"./ErrorState-nA0Ptq3g.js";import"./popover-menu-CNiMANtf.js";import"./avatar-vPm9XfmM.js";import"./index-BWAq8iOl.js";import"./useSignature-sxHvGfKr.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B7157ZPO.js";import"./sections-C6oVXjho.js";import"./undo-2-DHJ6nykB.js";import"./download-A4hq8dWf.js";import"./calendar-suggestion-ClsxDTZs.js";import"./sparkles-C1l6GCPT.js";import"./useCalendarSuggestions-DcYFtQhb.js";import"./calendar-report-CzeBcU6C.js";import"./calendar-failure-note-BUFaaizf.js";import"./checkbox-Qon94b1C.js";import"./clock-B9kFW89H.js";import"./shield-check-BcUXVpR8.js";import"./calendar-LLRgZQzl.js";import"./useLayoutTier-5aJYrTut.js";import"./menu-CGw_RHKl.js";import"./useFilters-C3bLY42W.js";import"./confirm-dialog-CgMAaLI3.js";import"./MailViewChrome-BEx9Dr1Z.js";import"./refresh-cw-D1SQy8O7.js";import"./wizard-selection-zWa1qc6-.js";function N(){return o.jsx(r.Reading,{})}export{N as component};
|