@remit/web-client-dist 0.0.358 → 0.0.359
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/BriefPane-CtQ__4rW.js +1 -0
- package/assets/{ErrorState-BnG-HaD4.js → ErrorState-eMOlBfIV.js} +1 -1
- package/assets/FlaggedPane-CtT4pW1A.js +1 -0
- package/assets/FullCompose-BZ0Enn9I.js +1 -0
- package/assets/MailListHeader-BXdL6PZE.js +7 -0
- package/assets/{MailViewChrome-BJ4q1GXR.js → MailViewChrome-C4KeVspC.js} +1 -1
- package/assets/MailboxPane-Xp15g3fz.js +1 -0
- package/assets/{NavMenuButton-O8AaZTpY.js → NavMenuButton-BXjID2LC.js} +1 -1
- package/assets/{OnboardingWizard-CEm3zOtV.js → OnboardingWizard-C7KAfYmq.js} +1 -1
- package/assets/OutboxPane-C9G6yi-O.js +1 -0
- package/assets/_mailboxId-BIBSxF-E.js +1 -0
- package/assets/_messageId-CY4bgXOY.js +1 -0
- package/assets/_messageId-CtueS4H5.js +1 -0
- package/assets/_messageId-DnJEGG2N.js +1 -0
- package/assets/_outboxMessageId-BfdM6H4-.js +1 -0
- package/assets/_threadId-B3tWBLSG.js +1 -0
- package/assets/_threadId-DZQHrmp9.js +1 -0
- package/assets/_threadId-DaxMqmjN.js +1 -0
- package/assets/{accounts-Bp1UvtHI.js → accounts-BMowAy8J.js} +1 -1
- package/assets/{advanced-JyuqGV4K.js → advanced-BriHDMMN.js} +1 -1
- package/assets/{appearance-CJPxo4Dl.js → appearance-BQWqzSY1.js} +1 -1
- package/assets/{attachment-file-CMfx3CcW.js → attachment-file-B6idyO8B.js} +1 -1
- package/assets/{avatar-DqkGERXB.js → avatar-BA2RXTDI.js} +1 -1
- package/assets/{bottom-sheet-CNBsemxY.js → bottom-sheet-DDpdzJg1.js} +1 -1
- package/assets/{brief-DMSyXbnZ.js → brief-Bt9VukKS.js} +1 -1
- package/assets/brief-C1tXNG83.js +1 -0
- package/assets/{browser-ponyfill-D4nvYSFj.js → browser-ponyfill-A4iyNg9e.js} +1 -1
- package/assets/{bug-BZM7jlIN.js → bug-Rs-29jam.js} +1 -1
- package/assets/{circle-check-BsPPl8Vd.js → circle-check-BvII-ksS.js} +1 -1
- package/assets/{circle-check-big-Cn33pldS.js → circle-check-big-DPA5LcMX.js} +1 -1
- package/assets/{circle-help-DWpn0l-r.js → circle-help-pT1YKg_z.js} +1 -1
- package/assets/{clock-60QzMefl.js → clock-Cq-y4Ofh.js} +1 -1
- package/assets/compose._-_outboxMessageId_-B5n3en0_.js +1 -0
- package/assets/compose._-_outboxMessageId_-BdyPvleS.js +1 -0
- package/assets/compose._-_outboxMessageId_-CCXfgPlt.js +1 -0
- package/assets/compose._-_outboxMessageId_-CHVV-SvJ.js +1 -0
- package/assets/{confirm-dialog-53Vs8qdX.js → confirm-dialog-B6lZSCEM.js} +1 -1
- package/assets/{download-D1wer2rZ.js → download-CSf0lEDY.js} +1 -1
- package/assets/{filters-CMw41CNL.js → filters-C69m9PhI.js} +1 -1
- package/assets/flagged-BQ7cNAQz.js +1 -0
- package/assets/{flagged-Cru9TjXl.js → flagged-Dei1zYcV.js} +1 -1
- package/assets/{folders-YVFNTyHN.js → folders-DVVTDsJd.js} +1 -1
- package/assets/{index-35SwEY68.js → index-BEyl0d8i.js} +57 -57
- package/assets/index-BP53GtG2.js +1 -0
- package/assets/{index-BdqDBo3X.js → index-CAiNnkB0.js} +13 -13
- package/assets/index-CY4bgXOY.js +1 -0
- package/assets/index-C_iKScVo.js +1 -0
- package/assets/index-D4bBzZTg.js +1 -0
- package/assets/index-DGKguLDU.js +1 -0
- package/assets/index-DbBAJiCH.js +1 -0
- package/assets/index-DnJEGG2N.js +1 -0
- package/assets/index-DzQ32fcu.js +1 -0
- package/assets/{kbd-DRG84K0I.js → kbd-uGbHAKde.js} +1 -1
- package/assets/{labels-9XIJbNPF.js → labels-DmLCvGYD.js} +1 -1
- package/assets/mail-C-TDrqf-.js +1 -0
- package/assets/{mail-Dt38b6by.js → mail-VetUziho.js} +1 -1
- package/assets/{menu-DhWodGKO.js → menu-BmGtg6yi.js} +1 -1
- package/assets/{move-options-DQMo_1sS.js → move-options-CPfUgc6V.js} +1 -1
- package/assets/{onboarding-DELVHzq-.js → onboarding-IKY1kzpt.js} +1 -1
- package/assets/outbox-n_yFwu3F.js +1 -0
- package/assets/{pencil-D_5c_wk2.js → pencil-DsJcl1vg.js} +1 -1
- package/assets/{rich-text-DP-h8BHT.js → rich-text-BUPj5pN8.js} +1 -1
- package/assets/{rich-text-spellcheck-worker-provider-GExspSVN.js → rich-text-spellcheck-worker-provider-CuE6qJCh.js} +1 -1
- package/assets/{rotate-ccw-DZMpRbI3.js → rotate-ccw-CuIPaHN2.js} +1 -1
- package/assets/{row-actions-D0SH67tM.js → row-actions-CX4I9NkX.js} +1 -1
- package/assets/{search-scope-D8eDCx--.js → search-scope-DwTzWX9q.js} +1 -1
- package/assets/{search-token-index-BUcol5TC.js → search-token-index-CQQGbw7m.js} +1 -1
- package/assets/search-view-BaOWm1XY.js +1 -0
- package/assets/{senders-TcrlfWI1.js → senders-Hq7mP6fW.js} +1 -1
- package/assets/settings-CWrTUDSR.js +1 -0
- package/assets/{settings-screen-DhSJUsiq.js → settings-screen-DNu8idS1.js} +1 -1
- package/assets/{shield-check-CCXTGJKT.js → shield-check-sn-UZZVv.js} +1 -1
- package/assets/{suggested-vips-t25EFcuR.js → suggested-vips-D8wBl0qr.js} +1 -1
- package/assets/{useDebouncedValue-BWx5HMb8.js → useDebouncedValue-D0CZV2a8.js} +1 -1
- package/assets/{useFilters-CWfk6Iq3.js → useFilters-3cmqs9Eg.js} +1 -1
- package/assets/{useLabels-BngSwTS5.js → useLabels-DouRODjU.js} +1 -1
- package/assets/{useMediaQuery-DXxjKaoU.js → useMediaQuery-Cjj26W9X.js} +1 -1
- package/assets/useMessageBodyContent-DN1BB_sF.js +1 -0
- package/assets/{useRefreshControl-Rijlvzuj.js → useRefreshControl-81MoE9n0.js} +1 -1
- package/assets/useSearchMirror-C59IlnkH.js +1 -0
- package/assets/{useSearchTokenContext-Cbnmmy2v.js → useSearchTokenContext-ClnpCWt9.js} +1 -1
- package/assets/{useSemanticSearch-_Eo5DA7X.js → useSemanticSearch-DYkRo4Qk.js} +1 -1
- package/assets/{useSignature-Bm--1yAp.js → useSignature-DAKxkpyQ.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-YxP0nBcU.js +0 -1
- package/assets/FlaggedPane-C9Tl8Sgb.js +0 -1
- package/assets/FullCompose-CPdM2XxU.js +0 -1
- package/assets/MailListHeader-Trtc8lfx.js +0 -7
- package/assets/MailboxPane-DUPDvxrK.js +0 -1
- package/assets/OutboxPane-ZalnkqRY.js +0 -1
- package/assets/_mailboxId-DXY2DcuZ.js +0 -1
- package/assets/_messageId-ByR6_bo3.js +0 -1
- package/assets/_messageId-DJaF3SkN.js +0 -1
- package/assets/_messageId-YRdjdIfb.js +0 -1
- package/assets/_outboxMessageId-CkQCgzpt.js +0 -1
- package/assets/_threadId-Bd2uE3xH.js +0 -1
- package/assets/_threadId-BpRvUgZ7.js +0 -1
- package/assets/_threadId-CPMLmOLx.js +0 -1
- package/assets/brief-citXjdnu.js +0 -1
- package/assets/compose-CqHqZWHD.js +0 -1
- package/assets/compose._-_outboxMessageId_-ByFahrZS.js +0 -1
- package/assets/compose._-_outboxMessageId_-C2HJn-2W.js +0 -1
- package/assets/compose._-_outboxMessageId_-CxA7rvH-.js +0 -1
- package/assets/compose._-_outboxMessageId_-oxU0Mfa7.js +0 -1
- package/assets/flagged-CY2Fx9HR.js +0 -1
- package/assets/index-B-qT49RY.js +0 -1
- package/assets/index-B3RVTIK6.js +0 -1
- package/assets/index-ByR6_bo3.js +0 -1
- package/assets/index-C7e45zc3.js +0 -1
- package/assets/index-DIOW99Bl.js +0 -1
- package/assets/index-DJaF3SkN.js +0 -1
- package/assets/index-Hzw2sya0.js +0 -1
- package/assets/index-VU4NiHyS.js +0 -1
- package/assets/mail-C6L5FwL2.js +0 -1
- package/assets/outbox-DH9yQHIF.js +0 -1
- package/assets/search-view-gS47hGhs.js +0 -1
- package/assets/settings-Esp4eIvp.js +0 -1
- package/assets/useMessageBodyContent-BZp02vgj.js +0 -1
- package/assets/useSearchMirror-DcLrKu1Z.js +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{a4 as xs,ca as gr,r as l,c as le,j as a,C as mt,d as Fn,B as q,X as Pt,at as Me,cb as On,b as D,a as Xe,S as Je,aT as br,cc as xr,ag as Dt,T as Ft,cd as zn,a_ as vs,ce as vr,cf as _n,an as yr,af as Un,e as kr,cg as jr,as as Kn,ch as wr,ci as Cr,cj as Sr,ck as Nr,cl as Tr,cm as Er,cn as Mr,co as Ir,bO as Rr,s as ee,Q as Ot,q as xt,z as Bn,bf as Qn,cp as qn,n as oe,a5 as je,a7 as de,J as Ze,bn as Re,cq as zt,cr as Ae,cs as Ar,ct as $r,cu as Lr,cv as Pr,cw as Dr,bN as Fr,cx as Or,p as zr,aU as _r,m as Hn,aF as Ur,aG as Kr,bV as Br,k as Qr,bU as qr,cy as Hr,cz as _t,cA as Vr,cB as Vn,b6 as ys,bs as Gr,bj as qs,cC as Wr,cD as Yr,b5 as Jr,L as Xr,W as Zr,D as eo,bg as Hs,aY as to,cE as so,cF as no,a8 as Vs,be as ao,cG as ro,cH as oo,l as ks,cI as io,cJ as lo,cK as Gs,cL as co,cM as uo,cN as fo,cO as js,i as mo,cP as po,bW as ho,cQ as go,cR as Ws,g as bo,bX as xo}from"./index-35SwEY68.js";import{B as vo,l as yo,m as ko,S as Gn,c as ws,f as jo,D as wo,b as Et,a as Co,t as ct,g as So,n as No,o as To,e as Eo,u as Mo,i as Io}from"./search-token-index-BUcol5TC.js";import{K as Ro}from"./kbd-DRG84K0I.js";import{P as Wn,f as Ao,U as $o,E as Lo,s as Po}from"./attachment-file-CMfx3CcW.js";import{M as Do}from"./mail-Dt38b6by.js";import{A as pt}from"./avatar-DqkGERXB.js";import{M as Fo,c as Oo,d as Yn,e as zo,f as Jn,g as Xn,a as _o,b as Uo,S as Ys,s as Zn,u as ea,p as Ko,r as Bo}from"./useSearchTokenContext-Cbnmmy2v.js";import{C as Qo,D as Ve,u as qo}from"./index-BdqDBo3X.js";import{E as vt}from"./ErrorState-BnG-HaD4.js";import{u as Cs}from"./useMediaQuery-DXxjKaoU.js";import{e as ta,b as et,a as Ho,c as Ue,d as Vo}from"./format-De9HZKjg.js";import{P as Js,C as Go,D as Xs,M as ke}from"./enums-CCxx0t2v.js";import{f as Wo,h as Yo,N as sa,c as Jo}from"./useMessageBodyContent-BZp02vgj.js";import{D as Xo}from"./download-D1wer2rZ.js";import{S as Zo}from"./shield-check-CCXTGJKT.js";import{u as na}from"./useDebouncedValue-BWx5HMb8.js";import{a as aa,u as ra,b as oa,f as ia}from"./move-options-DQMo_1sS.js";import{h as Zs,u as ei,a as ti,i as si,n as ni,o as ai,j as ri,k as oi,S as ii}from"./useFilters-CWfk6Iq3.js";import{C as li}from"./confirm-dialog-53Vs8qdX.js";import{C as ci}from"./clock-60QzMefl.js";import{r as ui,b as di}from"./search-scope-D8eDCx--.js";import{M as fi}from"./menu-DhWodGKO.js";function ht(e){if(mi())e.focus({preventScroll:!0});else{let t=pi(e);e.focus(),hi(t)}}let Mt=null;function mi(){if(Mt==null){Mt=!1;try{document.createElement("div").focus({get preventScroll(){return Mt=!0,!0}})}catch{}}return Mt}function pi(e){let t=e.parentNode,s=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&s.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),s}function hi(e){for(let{element:t,scrollTop:s,scrollLeft:n}of e)t.scrollTop=s,t.scrollLeft=n}const Ee=e=>e?.ownerDocument??document,Ie=e=>e&&"window"in e&&e.window===e?e:Ee(e).defaultView||window;function gi(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function bi(e){return gi(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let xi=!1;function la(){return xi}function be(e,t){if(!la())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let s=t;for(;s!==null;){if(s===e)return!0;s.tagName==="SLOT"&&s.assignedSlot?s=s.assignedSlot.parentNode:bi(s)?s=s.host:s=s.parentNode}return!1}function Z(e){if(la()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}const vi=typeof Element<"u"&&"checkVisibility"in Element.prototype;function yi(e){const t=Ie(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:n}=e.style,r=s!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:o}=Ie(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function ki(e,t){return!e.hasAttribute("hidden")&&!e.hasAttribute("data-react-aria-prevent-focus")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function ca(e,t){return vi?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&yi(e)&&ki(e,t)&&(!e.parentElement||ca(e.parentElement,e))}const ua=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable^="false"])',"permission"],ji=ua.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ua.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function wi(e,t){return e.matches(ji)&&!Ci(e)&&(t?.skipVisibilityCheck||ca(e))}function Ci(e){let t=e;for(;t!=null;){if(t instanceof Ie(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Ss=typeof document<"u"?xs.useLayoutEffect:()=>{};function Si(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Ni(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Ti(e){for(;e&&!wi(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ie(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=h=>{(Z(h)===s||n)&&h.stopImmediatePropagation()},o=h=>{(Z(h)===s||n)&&(h.stopImmediatePropagation(),!e&&!n&&(n=!0,ht(s),u()))},i=h=>{(Z(h)===e||n)&&h.stopImmediatePropagation()},c=h=>{(Z(h)===e||n)&&(h.stopImmediatePropagation(),n||(n=!0,ht(s),u()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(v),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},v=requestAnimationFrame(u);return u}function Ut(e){if(typeof window>"u"||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(s=>e.test(s.brand))||e.test(window.navigator.userAgent)}function Ns(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function $e(e){let t=null;return()=>(t==null&&(t=e()),t)}const At=$e(function(){return Ns(/^Mac/i)}),Ei=$e(function(){return Ns(/^iPhone/i)}),da=$e(function(){return Ns(/^iPad/i)||At()&&navigator.maxTouchPoints>1}),fa=$e(function(){return Ei()||da()}),Mi=$e(function(){return Ut(/AppleWebKit/i)&&!Ii()}),Ii=$e(function(){return Ut(/Chrome/i)}),ma=$e(function(){return Ut(/Android/i)}),Ri=$e(function(){return Ut(/Firefox/i)});function Ai(e){return e.pointerType===""&&e.isTrusted?!0:ma()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function $i(e){return!ma()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function gt(e,t,s=!0){let{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}=t;Ri()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(At()?n=!0:r=!0);let c=Mi()&&At()&&!da()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});gt.isOpening=s,ht(e),e.dispatchEvent(c),gt.isOpening=!1}gt.isOpening=!1;let Te=new Map,ls=new Set;function en(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{let r=Z(n);if(!e(n)||!r)return;let o=Te.get(r);o||(o=new Set,Te.set(r,o),r.addEventListener("transitioncancel",s,{once:!0})),o.add(n.propertyName)},s=n=>{let r=Z(n);if(!e(n)||!r)return;let o=Te.get(r);if(o&&(o.delete(n.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",s),Te.delete(r)),Te.size===0)){for(let i of ls)i();ls.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?en():document.addEventListener("DOMContentLoaded",en));function Li(){for(const[e]of Te)"isConnected"in e&&!e.isConnected&&Te.delete(e)}function Pi(e){requestAnimationFrame(()=>{Li(),Te.size===0?e():ls.add(e)})}function pa(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let cs=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{cs.delete(e)});function Di(e,t){if(e===t)return e;let s=cs.get(e);if(s)return s.forEach(r=>r.current=t),t;let n=cs.get(t);return n?(n.forEach(r=>r.current=e),e):t}function Fi(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const n=e.map(r=>{const o=tn(r,t);return s||=typeof o=="function",o});if(s)return()=>{n.forEach((r,o)=>{typeof r=="function"?r():tn(e[o],null)})}}}function tn(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yt(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let n=e[s];for(let r in n){let o=t[r],i=n[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=pa(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=gr(o,i):r==="id"&&o&&i?t.id=Di(o,i):r==="ref"&&o&&i?t.ref=Fi(o,i):t[r]=i!==void 0?i:o}}return t}function Oi(e,t){Ss(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const zi=xs.useInsertionEffect??Ss;function Xt(e){const t=l.useRef(null);return zi(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let We="default",us="",Rt=new WeakMap;function _i(e){if(fa()){if(We==="default"){const t=Ee(e);us=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}We="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Rt.set(e,e.style[t]),e.style[t]="none"}}function sn(e){if(fa()){if(We!=="disabled")return;We="restoring",setTimeout(()=>{Pi(()=>{if(We==="restoring"){const t=Ee(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=us||""),us="",We="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Rt.has(e)){let t=Rt.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Rt.delete(e)}}function nn(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let Zt=new WeakMap;function Ui(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return nn(t);if(Zt.has(t))return Zt.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),n=s&&s instanceof Ie(s).HTMLMetaElement&&(s.nonce||s.content)||nn(t)||void 0;return n!==void 0&&Zt.set(t,n),n}const ha=xs.createContext({register:()=>{}});ha.displayName="PressResponderContext";function ga(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let u=c?.once?(...v)=>{e.current.delete(i),i(...v)}:i;e.current.set(i,{type:o,eventTarget:r,fn:u,options:c}),r.addEventListener(o,u,c)},[]),s=l.useCallback((r,o,i,c)=>{let u=e.current.get(i)?.fn||i;r.removeEventListener(o,u,c),e.current.delete(i)},[]),n=l.useCallback(()=>{e.current.forEach((r,o)=>{s(r.eventTarget,r.type,o,r.options)})},[s]);return l.useEffect(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:n}}function Ki(e){let t=l.useContext(ha);if(t){let{register:s,ref:n,...r}=t;e=yt(r,e),s()}return Oi(t,e.ref),e}class It{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,u=0,v,h=null;n.clientX!=null&&n.clientY!=null&&(v=n.clientX,h=n.clientY),i&&(v!=null&&h!=null?(c=v-i.left,u=h-i.top):(c=i.width/2,u=i.height/2)),this.type=t,this.pointerType=s,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=c,this.y=u,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const an=Symbol("linkClicked"),rn="react-aria-pressable-style",on="data-react-aria-pressable";function Bi(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:u,preventFocusOnPress:v,shouldCancelOnPointerExit:h,allowTextSelectionOnPress:p,ref:m,...b}=Ki(e),[g,d]=l.useState(!1),f=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:S}=ga(),y=l.useCallback((k,I)=>{let R=f.current;if(c||R.didFirePressStart)return!1;let w=!0;if(R.isTriggeringEvent=!0,n){let M=new It("pressstart",I,k);n(M),w=M.shouldStopPropagation}return s&&s(!0),R.isTriggeringEvent=!1,R.didFirePressStart=!0,d(!0),w},[c,n,s]),j=l.useCallback((k,I,R=!0)=>{let w=f.current;if(!w.didFirePressStart)return!1;w.didFirePressStart=!1,w.isTriggeringEvent=!0;let M=!0;if(r){let C=new It("pressend",I,k);r(C),M=C.shouldStopPropagation}if(s&&s(!1),d(!1),t&&R&&!c){let C=new It("press",I,k);t(C),M&&=C.shouldStopPropagation}return w.isTriggeringEvent=!1,M},[c,r,s,t]),E=Xt(j),T=l.useCallback((k,I)=>{let R=f.current;if(c)return!1;if(o){R.isTriggeringEvent=!0;let w=new It("pressup",I,k);return o(w),R.isTriggeringEvent=!1,w.shouldStopPropagation}return!0},[c,o]),O=Xt(T),$=l.useCallback(k=>{let I=f.current;if(I.isPressed&&I.target){I.didFirePressStart&&I.pointerType!=null&&j(ze(I.target,k),I.pointerType,!1),I.isPressed=!1,I.isOverTarget=!1,I.activePointerId=null,I.pointerType=null,S(),p||sn(I.target);for(let R of I.disposables)R();I.disposables=[]}},[p,S,j]),F=Xt($);l.useEffect(()=>{c&&f.current.isPressed&&F({currentTarget:f.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let P=l.useCallback(k=>{h&&$(k)},[h,$]),z=l.useCallback(k=>{c||i?.(k)},[c,i]),L=l.useCallback((k,I)=>{if(!c&&i){let R=new MouseEvent("click",k);Ni(R,I),i(Si(R))}},[c,i]),K=l.useMemo(()=>{let k=f.current,I={onKeyDown(w){if(es(w.nativeEvent,w.currentTarget)&&be(w.currentTarget,Z(w))){ln(Z(w),w.key)&&w.preventDefault();let M=!0;!k.isPressed&&!w.repeat&&(k.target=w.currentTarget,k.isPressed=!0,k.pointerType="keyboard",M=y(w,"keyboard"));let C=w.currentTarget,_=U=>{es(U,C)&&!U.repeat&&be(C,Z(U))&&k.target&&O(ze(k.target,U),"keyboard")};x(Ee(w.currentTarget),"keyup",pa(_,R),!0),M&&w.stopPropagation(),w.metaKey&&At()&&k.metaKeyEvents?.set(w.key,w.nativeEvent)}else w.key==="Meta"&&(k.metaKeyEvents=new Map)},onClick(w){if(!(w&&!be(w.currentTarget,Z(w)))&&w&&w.button===0&&!k.isTriggeringEvent&&!gt.isOpening){let M=!0;if(c&&w.preventDefault(),!k.ignoreEmulatedMouseEvents&&!k.isPressed&&(k.pointerType==="virtual"||Ai(w.nativeEvent))){let C=y(w,"virtual"),_=O(w,"virtual"),U=E(w,"virtual");z(w),M=C&&_&&U}else if(k.isPressed&&k.pointerType!=="keyboard"){let C=k.pointerType||w.nativeEvent.pointerType||"virtual",_=O(ze(w.currentTarget,w),C),U=E(ze(w.currentTarget,w),C,!0);M=_&&U,k.isOverTarget=!1,z(w),F(w)}k.ignoreEmulatedMouseEvents=!1,M&&w.stopPropagation()}}},R=w=>{if(k.isPressed&&k.target&&es(w,k.target)){ln(Z(w),w.key)&&w.preventDefault();let M=Z(w),C=be(k.target,M);E(ze(k.target,w),"keyboard",C),C&&L(w,k.target),S(),w.key!=="Enter"&&Ts(k.target)&&be(k.target,M)&&!w[an]&&(w[an]=!0,gt(k.target,w,!1)),k.isPressed=!1,k.metaKeyEvents?.delete(w.key)}else if(w.key==="Meta"&&k.metaKeyEvents?.size){let M=k.metaKeyEvents;k.metaKeyEvents=void 0;for(let C of M.values())k.target?.dispatchEvent(new KeyboardEvent("keyup",C))}};if(typeof PointerEvent<"u"){I.onPointerDown=C=>{if(C.button!==0||!be(C.currentTarget,Z(C)))return;if($i(C.nativeEvent)){k.pointerType="virtual";return}k.pointerType=C.pointerType;let _=!0;if(!k.isPressed){k.isPressed=!0,k.isOverTarget=!0,k.activePointerId=C.pointerId,k.target=C.currentTarget,p||_i(k.target),_=y(C,k.pointerType);let U=Z(C);"releasePointerCapture"in U&&("hasPointerCapture"in U?U.hasPointerCapture(C.pointerId)&&U.releasePointerCapture(C.pointerId):U.releasePointerCapture(C.pointerId)),x(Ee(C.currentTarget),"pointerup",w,!1),x(Ee(C.currentTarget),"pointercancel",M,!1)}_&&C.stopPropagation()},I.onMouseDown=C=>{if(be(C.currentTarget,Z(C))&&C.button===0){if(v){let _=Ti(C.target);_&&k.disposables.push(_)}C.stopPropagation()}},I.onPointerUp=C=>{!be(C.currentTarget,Z(C))||k.pointerType==="virtual"||C.button===0&&!k.isPressed&&O(C,k.pointerType||C.pointerType)},I.onPointerEnter=C=>{C.pointerId===k.activePointerId&&k.target&&!k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!0,y(ze(k.target,C),k.pointerType))},I.onPointerLeave=C=>{C.pointerId===k.activePointerId&&k.target&&k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!1,E(ze(k.target,C),k.pointerType,!1),P(C))};let w=C=>{if(C.pointerId===k.activePointerId&&k.isPressed&&C.button===0&&k.target){if(be(k.target,Z(C))&&k.pointerType!=null){let _=!1,U=setTimeout(()=>{k.isPressed&&k.target instanceof HTMLElement&&(_?F(C):(ht(k.target),k.target.click()))},80);x(C.currentTarget,"click",()=>_=!0,!0),k.disposables.push(()=>clearTimeout(U))}else F(C);k.isOverTarget=!1}},M=C=>{F(C)};I.onDragStart=C=>{be(C.currentTarget,Z(C))&&F(C)}}return I},[x,c,v,S,p,P,y,z,L]);return l.useEffect(()=>{if(!m)return;const k=Ee(m.current);if(!k||!k.head||k.getElementById(rn))return;const I=k.createElement("style");I.id=rn;let R=Ui(k);R&&(I.nonce=R),I.textContent=`
|
|
2
|
-
@layer {
|
|
3
|
-
[${on}] {
|
|
4
|
-
touch-action: pan-x pan-y pinch-zoom;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
`.trim(),k.head.prepend(I)},[m]),l.useEffect(()=>{let k=f.current;return()=>{p||sn(k.target??void 0);for(let I of k.disposables)I();k.disposables=[]}},[p]),{isPressed:u||g,pressProps:yt(b,K,{[on]:!0})}}function Ts(e){return e.tagName==="A"&&e.hasAttribute("href")}function es(e,t){const{key:s,code:n}=e,r=t,o=r.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||n==="Space")&&!(r instanceof Ie(r).HTMLInputElement&&!ba(r,s)||r instanceof Ie(r).HTMLTextAreaElement||r.isContentEditable)&&!((o==="link"||!o&&Ts(r))&&s!=="Enter")}function ze(e,t){let s=t.clientX,n=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:n,key:t.key}}function Qi(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Ts(e)}function ln(e,t){return e instanceof HTMLInputElement?!ba(e,t):Qi(e)}const qi=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function ba(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":qi.has(e.type)}let Hi=0;const ts=new Map;function Vi(e){let[t,s]=l.useState();return Ss(()=>{if(!e)return;let n=ts.get(e);if(n)s(n.element.id);else{let r=`react-aria-description-${Hi++}`;s(r);let o=document.createElement("div");o.id=r,o.style.display="none",o.textContent=e,document.body.appendChild(o),n={refCount:0,element:o},ts.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),ts.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const Gi=500;function Wi(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=Gi,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:u,removeGlobalListener:v}=ga(),{pressProps:h}=Bi({isDisabled:t,onPressStart(m){if(m.continuePropagation(),(m.pointerType==="mouse"||m.pointerType==="touch")&&(s&&s({...m,type:"longpressstart"}),c.current=setTimeout(()=>{m.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Ee(m.target).activeElement!==m.target&&ht(m.target),r&&r({...m,type:"longpress"}),c.current=void 0},o),m.pointerType==="touch")){let b=d=>{d.preventDefault()},g=Ie(m.target);u(m.target,"contextmenu",b,{once:!0}),u(g,"pointerup",()=>{setTimeout(()=>{v(m.target,"contextmenu",b)},30)},{once:!0})}},onPressEnd(m){c.current&&clearTimeout(c.current),n&&(m.pointerType==="mouse"||m.pointerType==="touch")&&n({...m,type:"longpressend"})}}),p=Vi(r&&!t?i:void 0);return{longPressProps:yt(h,p)}}const Kt=le("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 xa=le("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const va=le("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 Yi=le("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const Es=le("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 Ji=le("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);const Xi=le("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Bt=le("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);const ya=le("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 ka=le("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 tt=le("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 Zi=le("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 el=le("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"}]]),tl=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?a.jsxs("span",{children:[a.jsx("span",{className:"text-fg",children:e.displayName}),a.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):a.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},sl=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[n,r]=l.useState(!1);if(t.length===0)return null;const o=t.length>3,i=c=>{const u=s&&c.flags?.trusted?.value===!0;return a.jsx(tl,{address:c,showTrustedBadge:u})};return a.jsxs("div",{className:"flex gap-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),a.jsx("div",{className:"flex-1 min-w-0",children:n?a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))}):a.jsx("div",{className:"truncate",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))})}),o&&a.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!n)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":n?"Collapse":"Expand",children:n?a.jsx(mt,{className:"h-4 w-4"}):a.jsx(Fn,{className:"h-4 w-4"})})]})},nl={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function Ge({label:e,children:t,className:s}){return a.jsxs("section",{className:D("border-b border-line px-row-inset py-3",s),children:[a.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),a.jsx("div",{className:"mt-2",children:t})]})}function al({sender:e}){const t=nl[e.trust],s=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(pt,{name:e.name,email:e.email,size:"md"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),a.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?a.jsx(Me,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):a.jsx(Me,{tone:t.tone,dot:!0,children:t.label})}),a.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function rl({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return a.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[a.jsx(Zo,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),a.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[a.jsx(Zi,{className:"mt-0.5 size-4 shrink-0"}),a.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const s=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return a.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),a.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&a.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&a.jsxs(q,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:t,children:[e.similarCount," similar messages"]})]})}function ut({icon:e,label:t,active:s,danger:n,onClick:r,pending:o}){const i=r===void 0||o===!0;return a.jsxs("button",{type:"button",onClick:r,disabled:i,className:D("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",s?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",n&&!s&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const ol={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function ja({data:e,onClose:t,onShowSimilar:s,actions:n,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:u=!1,notSpamPending:v=!1}){const{sender:h,authenticity:p,category:m,flags:b={},similar:g}=e;return a.jsxs("aside",{className:D("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(Ge,{label:"Sender",children:a.jsx(al,{sender:h})}),a.jsx(Ge,{label:"Authenticity",children:a.jsx(rl,{auth:p,onShowSimilar:s})}),a.jsx(Ge,{label:"Category",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{tone:On[m.value],children:m.value}),m.overridden&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),a.jsx("button",{type:"button",className:D("ml-auto text-2xs text-accent hover:underline",!n?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!n?.onReclassify,onClick:n?.onReclassify,children:"reclassify"})]})}),a.jsxs(Ge,{label:"Quick actions",children:[a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a.jsx(ut,{icon:a.jsx(Xe,{className:"size-3.5"}),label:"VIP",active:b.vip,onClick:n?.onToggleVip}),a.jsx(ut,{icon:a.jsx(vo,{className:"size-3.5"}),label:"Mute",active:b.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(ut,{icon:a.jsx(Yi,{className:"size-3.5"}),label:v?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:v}),n?.onReportSpam&&a.jsx(ut,{icon:a.jsx(el,{className:"size-3.5"}),label:u?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:u}),a.jsx(ut,{icon:a.jsx(Ji,{className:"size-3.5"}),label:"Unsubscribe",active:b.unsubscribed,onClick:n?.onToggleUnsubscribe})]}),n?.onNotSpam&&a.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||g.length>0)&&a.jsx(Ge,{label:"Similar messages",children:r==="loading"?a.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((d,f)=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},f))}):r==="error"?a.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):a.jsx("ul",{className:"-mx-1 space-y-1",children:g.map(d=>{const f="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",x=`Open message from ${d.fromName||"unknown sender"}: ${d.subject}`,S=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"truncate text-xs font-medium text-fg",children:d.fromName}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:d.timeLabel})]}),a.jsx("div",{className:"truncate text-xs text-fg-muted",children:d.subject}),a.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:ol[d.matched]})]});return a.jsx("li",{children:o?o({mailboxId:d.mailboxId,threadId:d.threadId,messageId:d.id,className:f,ariaLabel:x,children:S}):a.jsx("div",{className:f,children:S})},d.id)})})}),a.jsx(Ge,{label:"Coming soon",className:"border-b-0 opacity-70",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(Je,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(Je,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const ds=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),cn=e=>e.shiftKey||e.metaKey||e.ctrlKey,il=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",ll=(e,t)=>!t&&e>0,cl=(e,t,s)=>{const n=e.indexOf(s);if(n===-1)return[];const r=t===void 0?-1:e.indexOf(t);if(r===-1)return[s];const o=Math.min(r,n),i=Math.max(r,n);return e.slice(o,i+1)},ul=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,dl=(e,t)=>{const s=new Set(t),n=new Set;for(const r of e)s.has(r)&&n.add(r);return n},fl=(e,t,s)=>{if(e.length===0)return;const n=t===void 0?-1:e.indexOf(t);if(n===-1)return s>0?e[0]:e[e.length-1];const r=Math.min(Math.max(n+s,0),e.length-1);return e[r]},ml=e=>{const[t,s]=l.useState(()=>new Set(e?.initialSelectedIds)),[n,r]=l.useState(void 0),o=l.useCallback(d=>t.has(d),[t]),i=l.useCallback(d=>{r(d),s(f=>{const x=new Set(f);return x.has(d)?x.delete(d):x.add(d),x})},[]),c=l.useCallback(d=>{r(d),s(f=>{if(f.has(d))return f;const x=new Set(f);return x.add(d),x})},[]),u=l.useCallback(d=>{s(f=>{if(!f.has(d))return f;const x=new Set(f);return x.delete(d),x})},[]),v=l.useCallback(d=>{s(new Set(d))},[]),h=l.useCallback(()=>{r(void 0),s(new Set)},[]),p=l.useCallback(d=>{s(f=>d.every(S=>f.has(S))?new Set:new Set(d))},[]),m=l.useCallback(d=>{r(d)},[]),b=l.useCallback(d=>{s(f=>{if(f.size===0)return f;const x=dl(f,d);return x.size===f.size?f:x})},[]),g=l.useCallback((d,f,x)=>{const S=ul(d,n,x,f);s(y=>{const j=cl(d,S,f);if(j.length===0)return y;const E=new Set(y);for(const T of j)E.add(T);return E}),r(S)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:u,selectAll:v,clearSelection:h,toggleAll:p,selectRange:g,setAnchor:m,anchorId:n,intersectWith:b}};function xf({hints:e=yo,className:t}){return e.length===0?null:a.jsx("footer",{className:D("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>a.jsx(pl,{hint:s},s.label))})}function pl({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(Ro,{children:t},t)),a.jsx("span",{children:e.label})]})}const wa="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ca=({active:e,focused:t})=>D("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",wa,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2"),Ms=({active:e,focused:t})=>D("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",wa,e?"bg-accent-2-soft":t?"bg-surface-sunken":"hover:bg-surface-sunken",t&&!e&&"before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent-2");function Sa({thread:e}){const t=!e.isRead;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?a.jsx(tt,{className:"size-3.5 text-danger"}):e.starred?a.jsx(Xe,{className:"size-3 fill-warning text-warning"}):t?a.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),a.jsx("span",{className:D("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[a.jsx("span",{className:D(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),a.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function un(e,t){const s=t?.trim();if(!s)return e;const n=e.toLowerCase(),r=s.toLowerCase(),o=[];let i=0,c=n.indexOf(r,i),u=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(a.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},u++)),i=c+r.length,c=n.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function hl({thread:e,badge:t,highlightQuery:s}){const n=!e.isRead;return a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:D("flex min-w-0 items-center gap-1.5 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),a.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&a.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:D("truncate text-sm",n?"text-fg":"text-fg-muted"),children:un(e.subject,s)}),e.suspicious&&a.jsx(tt,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&a.jsx(Xe,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:un(e.snippet,s)}),e.category&&e.category!=="personal"&&a.jsx(Me,{tone:On[e.category],className:"shrink-0",children:e.category}),e.labels?.map(r=>a.jsx(br,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function gl({thread:e,selection:t}){if(!t)return a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:n}=t;return a.jsxs("span",{className:"relative size-7 shrink-0",children:[a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"sm",className:D("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||n)&&"opacity-0")}),a.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),t.onToggle(r))},className:D("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",n?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":n?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&a.jsx(Dt,{className:"size-3"})})]})}function Is({thread:e,selection:t,badge:s,highlightQuery:n}){const r=!e.isRead;return a.jsxs(a.Fragment,{children:[r&&a.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),a.jsx(gl,{thread:e,selection:t}),a.jsx(hl,{thread:e,badge:s,highlightQuery:n})]})}const Na=e=>({...xr,[ko]:"","data-message-id":e.id});function vf({thread:e,active:t,focused:s,tabIndex:n,onClick:r}){return a.jsx("button",{type:"button",...Na(e),tabIndex:n,onClick:r,className:Ca({active:t,focused:s}),children:a.jsx(Sa,{thread:e})})}function yf({thread:e,active:t,focused:s,tabIndex:n,selection:r,onClick:o}){return a.jsx("button",{type:"button",...Na(e),tabIndex:n,onClick:o,className:D("group",Ms({active:t,focused:s})),children:a.jsx(Is,{thread:e,selection:r})})}let Ye;const bl=5e3;function Ta(e){e.preventDefault(),$t()}function $t(){Ye!==void 0&&(clearTimeout(Ye),Ye=void 0,document.removeEventListener("contextmenu",Ta,!0),document.removeEventListener("pointerup",$t,!0))}function xl(){Ye===void 0?(document.addEventListener("contextmenu",Ta,!0),document.addEventListener("pointerup",$t,!0)):clearTimeout(Ye),Ye=setTimeout($t,bl)}function vl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=Wi({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||xl()},[]);return{longPressProps:yt(r,{onPointerDown:o})}}const dt="min-h-11 min-w-11 px-0";function Ea({hasThread:e,onReply:t,onReplyAll:s,onForward:n,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:u,moveSlot:v,overflowItems:h=[],onUnavailable:p,unavailableHint:m,className:b}){const g=(f,x)=>()=>{if(!e){p?.(f);return}x?.()},d=u?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(Do,{className:"size-4"}):a.jsx(Es,{className:"size-4"}),onSelect:g("toggleRead",u)}]:[];return a.jsxs("div",{className:D("relative",b),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(ka,{className:"size-5"}),onClick:g("reply",t),"aria-label":"Reply",title:"Reply",className:dt}),s&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(ya,{className:"size-5"}),onClick:g("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:dt}),n&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(va,{className:"size-5"}),onClick:g("forward",n),"aria-label":"Forward",title:"Forward",className:dt}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Xe,{className:D("size-5",r&&"fill-warning text-warning")}),onClick:g("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:dt}),v,i&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-5"}),onClick:g("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:dt}),a.jsx(Wn,{triggerLabel:"More actions",items:[...d,...h]})]}),!e&&m&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:m})]})}function yl({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(zn,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:D(e&&"bg-accent-2-soft text-accent-2",n)})}function kl({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:v,moveSlot:h,onMove:p,replyTitle:m="Reply (r)",replyAllTitle:b="Reply all (a)",forwardTitle:g="Forward (f)",deleteTitle:d="Move to Trash (#)",flagTitle:f="Star (s)",children:x,className:S}){const y=(j,E)=>()=>{if(!e){t?.(j);return}E?.()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:D("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",S),children:[a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(ka,{className:"size-4"}),title:m,"aria-label":"Reply",onClick:y("reply",o)}),a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(ya,{className:"size-4"}),title:b,"aria-label":"Reply all",onClick:y("replyAll",i)}),a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(va,{className:"size-4"}),title:g,"aria-label":"Forward",onClick:y("forward",c)}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-4"}),title:d,"aria-label":"Move to Trash",onClick:y("delete",u)}),h??a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(vs,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:y("move",p)}),a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Xe,{className:D("size-4",n&&"fill-warning text-warning")}),title:f,"aria-label":"Star",onClick:y("flag",v)})]}),a.jsx("div",{className:"flex-1"}),x]}),!e&&s&&a.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}function Ma({message:e,onClick:t,isFocused:s,isUnread:n,trailing:r}){const o=a.jsxs(a.Fragment,{children:[a.jsx(Fn,{className:"size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"md"}),n&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),a.jsx("span",{className:D("w-36 shrink-0 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=D("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",s&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return t?a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:c=>{vr(c)&&(c.preventDefault(),t())},className:D(i,"cursor-pointer"),children:o}):a.jsx("div",{className:i,children:o})}function Ia({message:e,warning:t,onHeaderClick:s,isFocused:n,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:u,actionBar:v,body:h}){const p=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??a.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),a.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&a.jsx("div",{className:"text-xs text-fg-subtle",children:i??a.jsxs(a.Fragment,{children:["to ",e.toLabel]})})]});return a.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[a.jsxs("div",{className:D("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",n&&"ring-1 ring-inset ring-accent/30"),children:[s?a.jsx("button",{type:"button",onClick:s,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:a.jsx(mt,{className:"size-3.5"})}):a.jsx(mt,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"md"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[s?a.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:p}):p,c]}),u&&a.jsx("div",{className:"shrink-0",children:u})]}),t&&a.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[a.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"text-sm text-fg",children:[a.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",a.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),v&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:v}),a.jsx(Fo,{children:h??a.jsx(Oo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function jl({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[u,v]=l.useState(!1),h=r!==void 0,p=h?n??!1:u,m=!!s||h,b=()=>{if(h){r?.();return}v(d=>!d)},g=()=>{if(h){p&&r?.();return}v(!1)};return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(_n,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),m&&a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(zn,{className:"size-4"}),onClick:b,"aria-label":p?"Hide intelligence panel":"Show intelligence panel","aria-pressed":p,title:"Intelligence",className:D("shrink-0",p&&"bg-accent-2-soft text-accent-2")})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",style:c?{touchAction:"pan-y"}:void 0,...c,children:i??[...e.messages].reverse().map(d=>{const f=x=>x?()=>x(d.id):void 0;return d.expanded?a.jsx(Ia,{message:d,warning:e.warning,onHeaderClick:f(o?.onToggleExpand),actionBar:a.jsx(Ea,{hasThread:!0,onReply:f(o?.onReply),onReplyAll:f(o?.onReplyAll),onForward:f(o?.onForward),onToggleStar:f(o?.onToggleStar),onDelete:f(o?.onDelete),onToggleRead:f(o?.onToggleRead),moveSlot:o?.moveSlot?.(d.id)})},d.id):a.jsx(Ma,{message:d,onClick:f(o?.onToggleExpand)},d.id)})}),s&&!h&&a.jsx(yr,{open:p,onClose:g,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(ja,{data:s,onClose:g,className:"h-full w-full border-l-0"})})]})}function wl({state:e,onRetry:t}){return a.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[a.jsx(kr,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-danger",children:e.title}),a.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx("button",{type:"button",onClick:t,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&a.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function Cl({attachments:e,onDownload:t,hasUnlistedAttachment:s=!1,className:n}){return e.length===0&&!s?null:a.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:D("space-y-1.5",n),children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[a.jsx(Bt,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&a.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return a.jsxs("li",{className:"border-t border-line first:border-t-0",children:[a.jsxs("button",{type:"button",onClick:()=>t(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),a.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",Ao(r.sizeOctets)]})]}),o?a.jsx(Un,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):a.jsx(Xo,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&a.jsx(wl,{state:r.download,onRetry:()=>t(r.attachmentId)})]},r.attachmentId)})}),s&&a.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function Sl({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Me,{tone:"accent",className:D("py-1 text-xs",r),children:[a.jsx($o,{className:"size-3.5 shrink-0","aria-hidden":!0}),a.jsx("span",{children:e}),t&&a.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:s}),n&&a.jsx("a",{href:n,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const Nl="peer relative size-5 shrink-0 cursor-pointer appearance-none rounded-md border border-line-strong bg-surface outline-none transition-colors checked:border-positive checked:bg-positive indeterminate:border-positive indeterminate:bg-positive focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",dn="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function Tl({label:e,description:t,indeterminate:s=!1,checked:n,onChange:r,className:o,...i}){const c=l.useRef(null);l.useEffect(()=>{c.current&&(c.current.indeterminate=s)},[s]);const u=a.jsxs("span",{className:"relative inline-flex",children:[a.jsx("input",{ref:c,type:"checkbox",checked:n,onChange:r,className:Nl,...i}),a.jsx(Dt,{className:D(dn,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(Xi,{className:D(dn,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?a.jsx("span",{className:o,children:u}):a.jsxs("label",{className:D("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[u,a.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&a.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&a.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}function El(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 Ml({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?jr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:D("group",Ms({}),"border-b border-line"),children:a.jsx(Is,{thread:El(e),highlightQuery:s,badge:a.jsxs(a.Fragment,{children:[r&&a.jsx(Me,{tone:"neutral",className:"shrink-0",children:r}),e.category&&a.jsx(Me,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&a.jsx(Me,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const Il=e=>e===1?"result":"results";function Rl({count:e,onScopeToSpam:t}){return a.jsx(Kn,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[a.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${Il(e)} from Spam`]}),a.jsx(q,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const fn=6,Al={kind:"global"},$l=e=>e.kind==="folder"&&e.role==="junk",Ll=e=>e.folder?.role==="junk";function Ra(e){const t=[],s=[];for(const n of e)Ll(n)?s.push(n):t.push(n);return{kept:t,spam:s}}function Aa({onClick:e,blockedReason:t}){const s=l.useId(),[n,r]=l.useState(!1);return a.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[a.jsxs("button",{type:"button",onClick:()=>{if(t){r(!0);return}e()},"aria-describedby":t?s:void 0,className:D("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",t?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[a.jsx(wr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(Cr,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function Pl({section:e,query:t,onSelectResult:s,showFolder:n}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),u=e.results.length>fn,h=!i&&u?e.results.slice(0,fn):e.results,p=e.results.length-h.length;return a.jsxs("div",{children:[a.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(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 transition-colors hover:bg-surface",children:[a.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),a.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),a.jsx(mt,{className:D("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[h.map(m=>a.jsx(Ml,{result:m,query:t,showFolder:n,onClick:s?()=>s(m):void 0},m.id)),u&&a.jsxs("button",{type:"button",onClick:()=>c(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 transition-colors hover:bg-surface",children:[i?"Show less":`Show ${p} more`,!i&&a.jsx(mt,{className:"ml-1 size-3"})]})]})]})}function $a({value:e,recentSearches:t,onPickRecent:s,sections:n,loading:r,onSelectResult:o,tokens:i,scope:c=Al,makeFilter:u}){if(!(e.trim().length>0))return t&&t.length>0?a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),t.map(j=>a.jsxs("button",{type:"button",onClick:()=>s?.(j),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[a.jsx(ci,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:j})]},j))]}):a.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const h=i&&i.length>0&&a.jsx(Sr,{tokens:i}),p=u&&a.jsx(Aa,{...u});if(r)return a.jsxs("div",{className:"flex flex-col",children:[p,h,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(j=>a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},j))})]});const m=c.kind==="global",b=$l(c)||c.kind==="collection",g=m||c.kind==="collection",d=(n??[]).map(j=>{if(b)return{section:j,spam:[]};const{kept:E,spam:T}=Ra(j.results);return{section:{...j,results:E},spam:T}}),f=d.map(j=>j.section),x=d.reduce((j,E)=>j+E.spam.length,0),S=c.kind==="global"&&x>0&&c.onScopeToSpam!==void 0?a.jsx(Rl,{count:x,onScopeToSpam:c.onScopeToSpam}):void 0;return f.some(j=>j.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[p,h,S,f.filter(j=>j.results.length>0).map(j=>a.jsx(Pl,{section:j,query:e,showFolder:g,onSelectResult:o},j.id))]}):a.jsxs("div",{className:"flex flex-col",children:[p,h,S,a.jsxs("div",{className:"px-row-inset py-10 text-center",children:[a.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),a.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function Dl({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:v,tokens:h,chips:p,onRemoveChip:m,scope:b,makeFilter:g,suggest:d,suggestList:f}){const x=a.jsx($a,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:v,tokens:h,scope:b,makeFilter:g});return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Gn,{value:e,onChange:t,onClear:s,chips:p,onRemoveChip:m,globalFocusKey:!1,showClearButton:!1,suggest:d})}),a.jsx(q,{variant:"ghost",size:"sm",icon:a.jsx(Pt,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),f,r&&e.trim().length===0?a.jsx(Nr,{children:a.jsx(Tr,{...r,children:x})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:x})]})}const mn=e=>e.toLocaleString();function pn({selectAll:e,selecting:t,className:s}){return a.jsx(Tl,{className:s,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:a.jsx("span",{className:"font-medium text-accent",children:e.checked&&t?"Deselect all":"Select all"})})}function Fl({title:e,count:t,onCancel:s,onDelete:n,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:u,titleMeta:v,searchSlot:h,searchField:p,idleSlot:m,overflowSlot:b,isBusy:g=!1,isCounting:d=!1,selectAll:f,statusLabel:x,progress:S,notice:y}){const j=t>0||d,E=f?.checked?`All ${mn(t)} loaded selected`:`${mn(t)} ${t===1?"message":"messages"} selected`,T=[];return i&&!g&&!d&&T.push({key:"junk",label:"Junk",icon:a.jsx(tt,{className:"size-4"}),onSelect:i}),c&&!g&&!d&&T.push({key:"mark-read",label:"Mark read",icon:a.jsx(Es,{className:"size-4"}),onSelect:c}),a.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[a.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[j?a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(_n,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):u,f&&a.jsx(pn,{selectAll:f,selecting:j,className:"hidden shrink-0 pr-2 md:flex"}),j?a.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:x??E}):p?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:p}):a.jsxs(a.Fragment,{children:[a.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),v,h]}),j&&!d&&a.jsxs(a.Fragment,{children:[a.jsx(q,{variant:"ghost",size:"touch",icon:g?a.jsx(Un,{className:"size-5 animate-spin"}):a.jsx(Ft,{className:"size-5 text-danger"}),onClick:g?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":g||void 0,className:"shrink-0"}),!g&&r&&a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(vs,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!g&&o&&a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(Je,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),j&&a.jsx(Wn,{triggerLabel:"More actions",items:T,className:"shrink-0",children:!g&&!d&&b})]}),!j&&m,j&&f&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(pn,{selectAll:f,selecting:j,className:"w-full"})}),S&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx(Er,{value:S.value,max:S.max,tone:S.tone})}),y&&a.jsx(Kn,{"data-selection-notice":"",tone:y.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.text&&a.jsx("span",{children:y.text}),y.action&&a.jsx(q,{variant:"ghost",size:"md",onClick:y.action.onClick,className:"-my-1 min-h-11 shrink-0",children:y.action.label})]})})]})}const Rs=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{id:"uncategorized",label:"Unclassified",tone:"neutral"},{id:"transactional",label:"Transactional",tone:"positive"},{id:"newsletter",label:"Newsletter",tone:"neutral"},{id:"marketing",label:"Marketing",tone:"warning"},{id:"social",label:"Social",tone:"warning"},{id:"automated",label:"Automated",tone:"neutral"}],La={id:"unread",label:"Unread"},Ol={id:"flagged",label:"Starred"},Pa={id:"attachment",label:"Has attachment"};function zl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function kf(e=[]){return{categories:[...Rs],filters:Mr,sources:zl(e)}}function jf(){return{categories:[...Rs],filters:[La,Ol,Pa]}}function wf(){return{categories:[...Rs],filters:[La,Pa]}}function _l(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function Ul(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function Kl(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(_l(t,o))return o}let n=0;if(t.startsWith("."))for(;n<t.length&&t[n]===".";)n+=1;return e.length===t.length-n?null:Ul(t,e)}const ss=/[\t\n\r]/g;let fs=!1;function hn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function gn(e,t,s){const n=s-t,r=e.charCodeAt(t)|32;if(n===2)return r===119&&(e.charCodeAt(t+1)|32)===115?1:0;if(n===3){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(n===4){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32,c=e.charCodeAt(t+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(n===5)return r===104&&(e.charCodeAt(t+1)|32)===116&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===112&&(e.charCodeAt(t+4)|32)===115?1:0;return 0}function ft(e,t,s=!1){let n=0,r=e.length,o=!1,i=!1;if(fs=!1,!t){if(e.startsWith("data:"))return null;for(;n<e.length&&e.charCodeAt(n)<=32;)n+=1;for(;r>n+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47)n+=2;else{const f=e.indexOf(":/",n);if(f!==-1){const x=gn(e,n,f);if(x===1)for(i=!0,n=f+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(x===2){i=!0,n=f+1;let S=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&S<2;)n+=1,S+=1;if(S<2)return null}else{for(let S=n;S<f;S+=1){const y=e.charCodeAt(S)|32;if(!(y>=97&&y<=122||y>=48&&y<=57||y===46||y===45||y===43)){const j=e.charCodeAt(S);return j===9||j===10||j===13?ft(e.replace(ss,""),t,s):null}}if(e.charCodeAt(f+2)===47)n=f+3;else return null}}else if(e.charCodeAt(n)!==91){let x=-1;for(let S=n;S<r;S+=1){const y=e.charCodeAt(S);if(y===9||y===10||y===13)return ft(e.replace(ss,""),t,s);if(y===58){x=S;break}if(y===47||y===92||y===63||y===35)break}if(x!==-1){let S=!1;for(let y=x+1;y<r;y+=1){const j=e.charCodeAt(y);if(j===47||j===92||j===63||j===35)break;if(j===64){S=!0;break}}if(!S){let y=!0,j=x+1;for(;j<r;j+=1){const E=e.charCodeAt(j);if(E===47||E===92||E===63||E===35)break;if(E<48||E>57){y=!1;break}}if(j===x+1&&(y=!1),!y){const E=gn(e,n,x);if(E===0){let T=!1;for(let O=x+1;O<r;O+=1){const $=e.charCodeAt(O);if($===47||$===92||$===63||$===35)break;if($===58){T=!0;break}}if(!T)return null}else if(i=!0,n=x+1,E===2){let T=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&T<2;)n+=1,T+=1;if(T<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let u=-1,v=-1,h=-1,p=-1,m=!1,b=s,g=n-1,d=-1;if(s&&n<r){const f=e.charCodeAt(n);(!(hn(f)||f===46||f===95)||f===45)&&(b=!1)}for(let f=n;f<r;f+=1){const x=e.charCodeAt(f);if(x<64)if(x===47||x===35||x===63){r=f;break}else x===58?(p===-1&&(p=f),h=f):x===9||x===10||x===13?m=!0:s&&(x===46?((f-g>64||d===46||d===45)&&(b=!1),g=f):(x<48||x>57)&&(x!==45||d===46)&&(b=!1));else if(i&&x===92){r=f;break}else x===64?(u=f,p=-1):x===93?v=f:x>=65&&x<=90?o=!0:s&&!hn(x)&&(b=!1);s&&(d=x)}if(m)return ft(e.replace(ss,""),t,s);if(u!==-1&&u>=n&&u<r&&(n=u+1),e.charCodeAt(n)===91)return v!==-1?e.slice(n+1,v).toLowerCase():null;if(h!==-1&&h>n&&h<r&&p===h&&(r=h),n>=r)return null;s&&b&&u===-1&&h===-1&&v===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-g-1<=63&&d!==45&&(fs=!0)}for(;r>n+1&&e.charCodeAt(r-1)===46;)r-=1;const c=n!==0||r!==e.length?e.slice(n,r):e;return o?c.toLowerCase():c}function Bl(e){if(e.length<7||e.length>15)return!1;let t=0;for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n===46)t+=1;else if(n<48||n>57)return!1}return t===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function Ql(e){if(e.length<3)return!1;let t=e.startsWith("[")?1:0,s=e.length;if(e[s-1]==="]"&&(s-=1),s-t>39)return!1;let n=!1;for(;t<s;t+=1){const r=e.charCodeAt(t);if(r===58)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return n}function ql(e){return Ql(e)||Bl(e)}function bn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function xn(e){if(e.length>255||e.length===0||!bn(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let t=-1,s=-1;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-t>64||s===46||s===45)return!1;t=r}else if(!(bn(o)||o===45||o===95)||o===45&&s===46)return!1;s=o}return n-t-1<=63&&s!==45}function Hl({allowIcannDomains:e=!0,allowPrivateDomains:t=!1,detectIp:s=!0,detectSpecialUse:n=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:t,detectIp:s,detectSpecialUse:n,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const Vl=Hl({});function Gl(e){return Vl}function Wl(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function Yl(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 Jl(e,t,s,n,r){const o=Gl();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=xn(e),r.hostname=ft(e,i,o.validateHostname)):r.hostname=ft(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=ql(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!fs&&!xn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Kl(r.publicSuffix,r.hostname,o)),r)}const vn=Wl();function Xl(e,t){return Yl(vn),Jl(e,3,Ir,t,vn).domain}const Qt=e=>{const t=new Set,s=[];for(const n of e){const r=n.trim();if(r==="")continue;const o=r.toLowerCase();t.has(o)||(t.add(o),s.push(r))}return s},Zl=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},Da=e=>Xl(Zl(e.trim())),ec=e=>{const t=Qt(e);if(t.length<2)return null;let s=null;for(const n of t){const r=Da(n);if(r===null)return null;if(s===null)s=r;else if(s!==r)return null}return s},qt=e=>{const t=ec(e);return t!==null?[{field:"FromDomain",value:t}]:Qt(e).map(s=>({field:"From",value:s}))},tc=e=>{const t=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=t.get(o);i?i.count+=1:t.set(o,{sender:r,count:1})}let s,n=0;for(const{sender:r,count:o}of t.values())o<=n||(s=r,n=o);return s},Fa=e=>e.displayName?.trim()||e.normalizedEmail,sc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,nc=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(sc,"");if(s===t)return t.trim();t=s}},ac=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"]),rc=3,ns=e=>e.split(" ").filter(t=>t!==""),yn=e=>e.length===0||e.join(" ").length<rc?!1:e.some(t=>!ac.has(t.toLowerCase())),oc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),ic=e=>{const t=e.map(nc).filter(o=>o!=="");if(t.length===0)return;const[s,...n]=t;if(n.length===0)return yn(ns(s))?s:void 0;const r=ns(s);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(yn(c)&&n.every(u=>oc(ns(u),c)>=0))return c.join(" ")}},lc=(e,t)=>{const s=qt(e);if(Qt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=ic(t);return n!==void 0?[{field:"Subject",value:n}]:s},cc=({match:e,sender:t,folder:s})=>{const n=e??t;return n?s?`${n} → ${s}`:e?`Mail matching ${e}`:`Mail from ${n}`:s?`Mail to ${s}`:""},uc=e=>e.clauses.length>0,dc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(t=>t.label),droppedSemantic:e.droppedSemantic}),fc=({orderedIds:e,isDesktop:t,initialFocusedId:s,initialSelectedIds:n,onExitSelection:r})=>{const[o,i]=l.useState(s),[c,u]=l.useState(),v=l.useCallback(w=>{u(M=>M===w?M:void 0),i(w)},[]),h=ml({initialSelectedIds:n}),{selectedCount:p,toggle:m,clearSelection:b,selectRange:g,setAnchor:d,selectAll:f}=h,x=ll(p,t),S=l.useRef(null),y=l.useRef(!1),j=l.useCallback(()=>{r?.(),b()},[b,r]),E=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),T=l.useCallback(w=>{if(w<0||w>=e.length)return;const M=e[w];if(x){m(M);return}S.current=M,y.current=!1,u(M),i(M)},[e,x,m]),O=l.useCallback(()=>{e.length!==0&&T(E<0?0:Math.min(E+1,e.length-1))},[e.length,E,T]),$=l.useCallback(()=>{e.length!==0&&T(E<=0?0:E-1)},[e.length,E,T]),F=l.useCallback(()=>T(0),[T]),P=l.useCallback(()=>T(e.length-1),[T,e.length]),z=l.useCallback(()=>{o&&m(o)},[o,m]),L=l.useCallback((w,M)=>{const C=il(M);return C==="range"?(g(e,w,o),!0):C==="toggle"?(m(w),!0):(j(),d(w),!1)},[e,o,g,m,j,d]),K=l.useCallback(w=>{const M=fl(e,o,w);M!==void 0&&(g(e,M),S.current=M,y.current=!1,u(void 0),i(M))},[e,o,g]),k=l.useCallback(()=>K(-1),[K]),I=l.useCallback(()=>K(1),[K]),R=l.useCallback(()=>{e.length>0&&f(e)},[e,f]);return{focusedMessageId:o,setFocusedMessageId:v,keyboardFocusedMessageId:c,focusIndex:E,pendingDomFocusRef:S,cursorMovedByPointerRef:y,selection:h,isMultiSelectMode:x,exitSelection:j,moveFocusToIndex:T,focusNext:O,focusPrevious:$,focusFirst:F,focusLast:P,toggleFocusedSelection:z,extendRangeUp:k,extendRangeDown:I,selectAllLoaded:R,handleRowSelect:L}};function mc(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const s=!!(e.condition??!0),n=e.blockerFn;return{shouldBlockFn:async()=>s&&n!==void 0?await n():s,enableBeforeUnload:s,withResolver:n===void 0}}function pc(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=mc(e),i=Rr(),{history:c}=i,[u,v]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const h=async p=>{function m(x){const S=i.parseLocation(x),y=i.getMatchedRoutes(S.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:S.pathname,pathname:S.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:S.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}}const b=m(p.currentLocation),g=m(p.nextLocation);if(b.routeId==="__notFound__"&&g.routeId!=="__notFound__")return!1;const d=await s({action:p.action,current:b,next:g});if(!o)return d;if(!d)return!1;const f=await new Promise(x=>{v({status:"blocked",current:b,next:g,action:p.action,proceed:()=>x(!1),reset:()=>x(!0)})});return v({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),f};return r?void 0:c.block({blockerFn:h,enableBeforeUnload:n})},[s,n,r,o,c,i]),u}const Cf=({isOpen:e,onClose:t,children:s,ariaLabel:n="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]"})=>{const i=l.useRef(null),c=l.useRef(null);if(l.useEffect(()=>{if(!e)return;c.current=document.activeElement;const v=m=>{m.key==="Escape"&&(m.preventDefault(),t())};document.addEventListener("keydown",v),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const p=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",v),document.body.style.overflow=p,c.current?.focus()}},[e,t]),!e)return null;const u=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":n,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),a.jsxs("div",{ref:i,className:D("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,u),children:[a.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:a.jsx("button",{type:"button",onClick:t,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close menu",children:a.jsx(Pt,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},hc=({mode:e,account:t,sourceMessage:s,onClose:n})=>{const[r,o]=l.useState();return a.jsx("div",{className:"border-b border-line bg-canvas",children:a.jsx(Qo,{layout:"flow",mode:e,account:t,sourceMessage:s,outboxMessageId:r,onDraftCreated:o,onClose:n})})},Oa=({message:e,icon:t})=>a.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&a.jsx("div",{className:"mb-4 text-fg-muted",children:t}),a.jsx("p",{className:"text-fg-muted",children:e})]}),za=e=>{const{data:t,isLoading:s}=ee({...Ot(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=ws({queries:n.map(c=>({...xt({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=s||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<n.length;c++)if((r[c].data?.items??[]).some(h=>h.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},gc=100,ms=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),bc=(e,t=gc)=>{if(e.length===0)return[];const s=[];for(let n=0;n<e.length;n+=t)s.push(e.slice(n,n+t));return s},_a=async(e,t,s,n)=>{const r=bc(e),o=e.length;let i=0;const c=[];for(let u=0;u<r.length;u++){if(n())return c.push(...r.slice(u).flat()),{done:i,failedIds:c,cancelled:!0};const v=r[u],h=await ms(t(v));if(!h.ok)return c.push(...r.slice(u).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:h.error};i+=v.length,s({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},bt=async(e,t)=>{await _a(e,async s=>(await t(s),{successCount:s.length,failureCount:0}),()=>{},()=>!1)},xc=async(e,t,s,n,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const u=await ms(e(c));if(!u.ok)return{done:o,failedIds:i,cancelled:!1,error:u.error};const v=u.value;if(v.ids.length>0){const h=await ms(s(v.ids));if(!h.ok)return{done:o,failedIds:i,cancelled:!1,error:h.error};o+=v.ids.length,n({done:o,total:t})}c=v.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},vc=e=>({done:e.done,total:Math.max(e.total,e.done)}),Ua=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),Ka=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Ba=(e,t)=>e===void 0?e:Ua(e)?{...e,pages:e.pages.map(s=>({...s,items:t(s.items)}))}:Ka(e)?{...e,items:t(e.items)}:e,we=e=>{const t=[];for(const s of new Set(e))t.push(Bn({path:{mailboxId:s}})),t.push(Qn({path:{mailboxId:s}}));return t.push(qn()),t},kt=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),jt=(e,t)=>t.flatMap(s=>e.getQueriesData({queryKey:s})).filter(s=>s[1]!==void 0).map(([s,n])=>({queryKey:s,data:n})),wt=(e,t,s)=>{const n=r=>Ba(r,s);for(const r of t)e.setQueriesData({queryKey:r},n)},Ct=(e,t)=>{for(const s of t)e.setQueryData(s.queryKey,s.data)},Ce=(e,t)=>{for(const s of t)e.invalidateQueries({queryKey:s})},yc=3e3,kc=(e,t,s)=>{if(e.length===0)return()=>{};const n=setTimeout(()=>s(e),t);return()=>clearTimeout(n)},As=(e,t,s)=>{const n=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(n.get(o)??s);return[...r]},Lt=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),jc=(e,t,s,n)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!s.has(r.messageId)&&!n.has(r.messageId)).map(r=>r.messageId),wc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=oe(),{pushError:i}=je(),c=l.useRef(new Set),u=l.useRef(new Set),{mutate:v}=de({...zt(),onMutate:async m=>{const b=new Set(m.body.messageIds??[]),g=m.body.isRead??!0,d=Ae({path:{threadId:s}}),f=we(As(b,e,n));await Promise.all([o.cancelQueries({queryKey:d}),kt(o,f)]);const x=o.getQueriesData({queryKey:d}).filter(y=>y[1]!==void 0).map(([y,j])=>({queryKey:y,data:j})),S=jt(o,f);return o.setQueriesData({queryKey:d},y=>y&&{...y,items:Lt(y.items,b,g)}),wt(o,f,y=>Lt(y,b,g)),{threadMessagesPrefix:d,listPrefixes:f,previousThreadMessages:x,previousThreadsList:S}},onSuccess:(m,b)=>{const g=b.body.messageIds??[];for(const d of g)c.current.add(d),u.current.delete(d)},onError:(m,b,g)=>{const d=b.body.messageIds??[];for(const x of d)u.current.delete(x);if(g){for(const x of g.previousThreadMessages)o.setQueryData(x.queryKey,x.data);Ct(o,g.previousThreadsList)}const f=b.body.isRead??!0;i({title:f?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(m),error:m})},onSettled:(m,b,g,d)=>{d&&(o.invalidateQueries({queryKey:d.threadMessagesPrefix}),Ce(o,d.listPrefixes),r&&o.invalidateQueries({queryKey:Ze({path:{accountId:r}})}))}}),h=l.useCallback(m=>{const b=m.filter(g=>!c.current.has(g)&&!u.current.has(g));if(b.length!==0){for(const g of b)u.current.add(g);v({body:{messageIds:b,isRead:!0}})}},[v]),p=l.useMemo(()=>jc(e,t,c.current,u.current),[e,t]);l.useEffect(()=>kc(p,yc,h),[p,h]),l.useEffect(()=>{c.current.clear(),u.current.clear()},[s])},Sf=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=oe(),{pushError:o}=je(),{mutateAsync:i,isPending:c}=de({...zt(),onError:(v,h)=>{const p=h.body.isRead??!0;o({title:p?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(v),error:v})},onSettled:(v,h,p)=>{Ce(r,we(As(p.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Ze({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((v,h)=>{v.length!==0&&bt(v,p=>i({body:{messageIds:p,isRead:h}}))},[i]),isPending:c}},Cc=60,Sc=1.5,Nc=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*Sc?{direction:null}:{direction:e<0?"left":"right"}},Tc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Cc})=>{const n=l.useRef(null),r=l.useCallback(u=>{if(u.pointerType==="mouse"){n.current=null;return}n.current={x:u.clientX,y:u.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(u=>{const v=n.current;if(n.current=null,!v)return;const{direction:h}=Nc(u.clientX-v.x,u.clientY-v.y,s);h==="left"&&e?.(),h==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},Ec=(e,t,s)=>t?.find(n=>n.messageId===e)?.mailboxId??s,kn=(e,t,s)=>e.map(n=>n.messageId===t?{...n,hasStars:s}:n),Qa=({threadId:e,mailboxId:t,messages:s})=>{const n=oe(),{pushError:r}=je(),{mutate:o,isPending:i,variables:c}=de({...Ar(),onMutate:async v=>{const h=v.path.messageId,p=v.body.isStarred??!1,m=Ae({path:{threadId:e}}),b=we([Ec(h,s,t)]);await Promise.all([n.cancelQueries({queryKey:m}),kt(n,b)]);const g=n.getQueriesData({queryKey:m}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})),d=jt(n,b);return n.setQueriesData({queryKey:m},f=>Ba(f,x=>kn(x,h,p))),wt(n,b,f=>kn(f,h,p)),{threadMessagesPrefix:m,listPrefixes:b,previousThreadMessages:g,previousThreadsList:d}},onError:(v,h,p)=>{if(p){for(const b of p.previousThreadMessages)n.setQueryData(b.queryKey,b.data);Ct(n,p.previousThreadsList)}const m=h.body.isStarred??!1;r({title:m?"Couldn't star message":"Couldn't unstar message",detail:Re(v),error:v})},onSettled:(v,h,p,m)=>{m&&(n.invalidateQueries({queryKey:m.threadMessagesPrefix}),Ce(n,m.listPrefixes))}});return{toggleStar:(v,h)=>{o({path:{messageId:v},body:{isStarred:!h}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function jn({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?a.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[a.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",a.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",t&&a.jsx("button",{type:"button",onClick:t,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function qa(e){return e===void 0?"uncategorized":e}const Mc={inbox:"Inbox",junk:"Junk"},$s=e=>e.destinationMailboxId!==void 0,Ic=(e,t)=>{if($s(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${Mc[s]??"another folder"} by Remit`},Rc=(e,t)=>{if(e===Js.MoveToInbox)return t.inboxMailboxId;if(e===Js.MoveToJunk)return t.junkMailboxId},Ac=(e,t,s)=>{if(!e||!t)return!1;const n=$s(e)?e.destinationMailboxId:Rc(e.action,s);return n!==void 0&&n===t},$c="Reported as spam",Lc=(e,t)=>{if(e){if($s(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},Ht=(e,t)=>{const{data:s,isLoading:n}=ee({...Ot(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:n}},Nf=e=>{const{mailboxId:t,isLoading:s}=Ht(e,"Archive");return{archiveMailboxId:t,isLoading:s}},Tf=e=>{const{mailboxId:t,isLoading:s}=Ht(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Pc=e=>{const{mailboxId:t,isLoading:s}=Ht(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},Ha=e=>{const{mailboxId:t,isLoading:s}=Ht(e,"Junk");return{junkMailboxId:t,isLoading:s}},Va=e=>{const{data:t}=ee({...Ot(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},wn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Vt=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=oe(),{pushError:o}=je(),{mutateAsync:i,isPending:c,isError:u}=de({...$r(),onMutate:async h=>{const p=new Set(h.body.messageIds??[]),m=t?Ae({path:{threadId:t}}):[],b=we([e,h.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:m})]:[],kt(r,b)]);const g=t?r.getQueriesData({queryKey:m}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})):[],d=jt(r,b);return t&&r.setQueriesData({queryKey:m},f=>f&&{...f,items:wn(f.items,p)}),wt(r,b,f=>wn(f,p)),n?.(Array.from(p)),{threadMessagesPrefix:m,listPrefixes:b,previousThreadMessages:g,previousThreadsList:d}},onError:(h,p,m)=>{if(m){for(const g of m.previousThreadMessages)r.setQueryData(g.queryKey,g.data);Ct(r,m.previousThreadsList)}const b=p.body.messageIds?.length??0;o({title:b>1?`Couldn't move ${b} messages`:"Couldn't move this message",detail:Re(h),error:h})},onSettled:(h,p,m,b)=>{b&&(t&&r.invalidateQueries({queryKey:b.threadMessagesPrefix}),Ce(r,b.listPrefixes),s&&r.invalidateQueries({queryKey:Ze({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((h,p)=>{h.length!==0&&bt(h,m=>i({body:{messageIds:m,destinationMailboxId:p}}))},[i]),isPending:c,isError:u}},Dc="This message could not be processed. Please try again.",Fc=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),Cn=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],s=t?.reason??Dc,n=t?Fc(s,t.messageId):s;throw new Dr(n,422)};function Ga({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=oe(),{pushError:o}=je(),i=we([e]),c=t?Ae({path:{threadId:t}}):[],u=()=>{t&&r.invalidateQueries({queryKey:c}),Ce(r,i),s&&r.invalidateQueries({queryKey:Ze({path:{accountId:s}})})},v=()=>(d,f)=>{u(),n?.(f.body.messageIds)},h=d=>(f,x)=>{o({title:d(x.body.messageIds.length),detail:Re(f),error:f})},p=de({mutationFn:async d=>{const{data:f}=await Lr({...d,throwOnError:!0});return Cn(f),f},meta:{softError:!0},onSuccess:v(),onError:h(d=>d>1?`Couldn't report ${d} messages as spam`:"Couldn't report this message as spam")}),m=de({mutationFn:async d=>{const{data:f}=await Pr({...d,throwOnError:!0});return Cn(f),f},meta:{softError:!0},onSuccess:v(),onError:h(d=>d>1?`Couldn't undo the spam report for ${d} messages`:"Couldn't undo the spam report")}),b=l.useCallback(d=>{d.length!==0&&bt(d,f=>p.mutateAsync({body:{messageIds:f}}))},[p.mutateAsync]),g=l.useCallback(d=>{d.length!==0&&bt(d,f=>m.mutateAsync({body:{messageIds:f}}))},[m.mutateAsync]);return{reportSpam:b,notSpam:g,isReporting:p.isPending,isRestoring:m.isPending}}const Oc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=Pc(e),{junkMailboxId:c}=Ha(e),{moveMessages:u,isPending:v}=Vt({mailboxId:n,threadId:s,accountId:e}),{notSpam:h,isRestoring:p}=Ga({mailboxId:n,threadId:s,accountId:e}),{data:m}=ee({...xt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),b={inboxMailboxId:i,junkMailboxId:c},g=Lc(r,b),d=l.useCallback(()=>{g&&u([t],g)},[u,t,g]),f=l.useCallback(()=>{h([t])},[h,t]);if(o)return{show:!0,label:$c,onUndo:f,isUndoing:p};if(!Ac(r,n,b)||!r)return{show:!1,label:"",isUndoing:!1};const S=r.fromMailboxId?m?.items.filter(y=>y.mailboxId===r.fromMailboxId).map(y=>Fr(y.fullPath))[0]:void 0;return{show:!0,label:Ic(r,S),onUndo:g?d:void 0,isUndoing:v,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function zc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Oc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx(Sl,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const Sn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Ef=e=>e.filter(t=>t.isDeleted!==!0),Ls=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=oe(),{pushError:i}=je(),{mutateAsync:c,isPending:u}=de({...Or(),onMutate:async h=>{const p=new Set(h.body.messageIds??[]),m=t?Ae({path:{threadId:t}}):[],b=we(As(p,n??[],e));await Promise.all([o.cancelQueries({queryKey:m}),kt(o,b)]);const g=t?o.getQueriesData({queryKey:m}).filter(f=>f[1]!==void 0).map(([f,x])=>({queryKey:f,data:x})):[],d=jt(o,b);return t&&o.setQueriesData({queryKey:m},f=>f&&{...f,items:Sn(f.items,p)}),wt(o,b,f=>Sn(f,p)),r?.(Array.from(p)),{threadMessagesPrefix:m,listPrefixes:b,previousThreadMessages:g,previousThreadsList:d}},onError:(h,p,m)=>{if(m){for(const g of m.previousThreadMessages)o.setQueryData(g.queryKey,g.data);Ct(o,m.previousThreadsList)}const b=p.body.messageIds?.length??0;i({title:b>1?`Couldn't delete ${b} messages`:"Couldn't delete this message",detail:Re(h),error:h})},onSettled:(h,p,m,b)=>{b&&(t&&o.invalidateQueries({queryKey:b.threadMessagesPrefix}),Ce(o,b.listPrefixes),s&&o.invalidateQueries({queryKey:Ze({path:{accountId:s}})}))}});return{deleteMessages:l.useCallback(h=>{h.length!==0&&bt(h,p=>c({body:{messageIds:p}}))},[c]),isPending:u}},Wa="inline-flex items-center justify-center transition-colors",_c=D(Wa,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Uc=D(Wa,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Ps=({accountId:e,currentMailboxId:t,onMove:s,disabled:n=!1,disabledHint:r,variant:o="icon-only",label:i})=>{const[c,u]=l.useState(!1),[v,h]=l.useState(),p=Cs(),m=l.useRef(null),b=i??"Move to folder",g=l.useId(),{t:d}=zr("mail",{useSuspense:!1}),f=aa(),{data:x,isLoading:S,isError:y,error:j,refetch:E}=ee({...xt({path:{accountId:e}}),staleTime:1/0,enabled:c}),T=Va(e),{createFolderIn:O}=ra(e),$=l.useMemo(()=>oa({mailboxes:x?.items??[],folderAppointments:T,currentMailboxId:t,translator:f}),[x?.items,T,t,f]),F=ia(x?.items??[]),P=$.find(w=>w.id===v),z=l.useCallback(()=>{u(!1),h(void 0)},[]),L=l.useCallback(()=>{P&&(z(),s(P.id))},[P,z,s]);l.useEffect(()=>{if(!c||!p)return;const w=C=>{m.current&&!m.current.contains(C.target)&&z()},M=C=>{C.key==="Escape"&&z()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",M)}},[c,p,z]);const K=n||!!r,k=a.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),!K&&u(M=>!M)},"aria-label":b,"aria-haspopup":p?"tree":"dialog","aria-expanded":c,"aria-controls":c?g:void 0,title:r,className:o==="icon-only"?_c:Uc,children:[a.jsx(vs,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),I=S?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):y?a.jsx("div",{className:"p-3",children:a.jsx(vt,{variant:"inline",title:"Couldn't load folders",error:j,onRetry:()=>E()})}):a.jsx(_r,{folders:$,selectedId:v,delimiter:F,onSelect:h,onCreateFolder:O,onCancel:z,labels:{filterPlaceholder:d("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:d("move_picker_filter_label",{defaultValue:"Filter folders"})}}),R=P&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(q,{variant:"primary",onClick:L,className:"h-11 w-full font-semibold",children:`Move to ${P.label}`})});return p?a.jsxs("div",{ref:m,className:"relative inline-block",children:[k,c&&a.jsxs("div",{id:g,className:D("absolute right-0 mt-1 z-50 w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[I,R]})]}):a.jsxs(a.Fragment,{children:[k,a.jsx(Ve.Root,{open:c,onOpenChange:w=>w?u(!0):z(),children:a.jsxs(Ve.Portal,{children:[a.jsx(Ve.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(Ve.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:g,children:[a.jsx(Ve.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(Ve.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),a.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:I}),R]})]})})]})},Kc=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:u})=>{const v=oe(),h=Hn(),p=Wo(),{pushError:m}=je(),b=jo()?.messageId,{mutate:g,isPending:d}=de({...zt(),onMutate:async R=>{const w=R.body.isRead??!0,M=new Set(R.body.messageIds??[]),C=Ae({path:{threadId:t}}),_=we([s]);await Promise.all([v.cancelQueries({queryKey:C}),kt(v,_)]);const U=v.getQueriesData({queryKey:C}).filter(W=>W[1]!==void 0).map(([W,Y])=>({queryKey:W,data:Y})),ne=jt(v,_);return v.setQueriesData({queryKey:C},W=>W&&{...W,items:Lt(W.items,M,w)}),wt(v,_,W=>Lt(W,M,w)),{threadMessagesPrefix:C,listPrefixes:_,previousThreadMessages:U,previousThreadsList:ne}},onError:(R,w,M)=>{if(M){for(const _ of M.previousThreadMessages)v.setQueryData(_.queryKey,_.data);Ct(v,M.previousThreadsList)}const C=w.body.isRead??!0;m({title:C?"Couldn't mark as read":"Couldn't mark as unread",detail:Re(R),error:R})},onSettled:(R,w,M,C)=>{C&&(v.invalidateQueries({queryKey:C.threadMessagesPrefix}),Ce(v,C.listPrefixes))}}),f=l.useCallback(R=>{b&&R.includes(b)&&h({to:"/mail/$mailboxId",params:{mailboxId:s},search:w=>w,hash:p})},[b,s,h,p]),{deleteMessages:x,isPending:S}=Ls({mailboxId:s,threadId:t,onAfterOptimisticRemove:f}),{moveMessages:y,isPending:j}=Vt({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:f}),{toggleTrusted:E,isPending:T,error:O,reset:$}=Yn({messageId:e}),F=()=>{g({body:{messageIds:[e],isRead:!1}})},P=()=>{x([e])},z=()=>{o&&E(o,i)},L=d||S||j||T,K=L||!o,k=l.useCallback(R=>{y([e],R)},[y,e]),I=o?void 0:"Sender has no parseable address";return a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(Ps,{accountId:r,currentMailboxId:s,onMove:k,disabled:L,label:"Move this message"}),a.jsxs(wo,{trigger:a.jsx(Lo,{className:"size-4"}),children:[a.jsxs(Et,{onClick:z,disabled:K,children:[i?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4 opacity-0"}),a.jsx("span",{title:I,children:"Trusted sender"})]}),n&&a.jsxs(Et,{onClick:F,disabled:L,children:[a.jsx(Es,{className:"size-4"}),"Mark as unread"]}),u&&a.jsxs(Et,{onClick:u,children:[a.jsx(xa,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(Co,{}),a.jsxs(Et,{onClick:P,disabled:L,destructive:!0,children:[a.jsx(Ft,{className:"size-4"}),"Delete"]})]})]}),O&&a.jsx("div",{className:"w-64",children:a.jsx(vt,{variant:"inline",title:"Couldn't update trust",error:O,onRetry:()=>{$(),z()}})})]})},Bc=e=>e==="link-expired"||e==="not-ready";class ps extends Error{reason;status;constructor(t,s,n){super(s),this.name="AttachmentFetchError",this.reason=t,this.status=n}}const Qc="x-remit-403-reason",qc="expired",Hc=(e,t)=>{if(t?.trim()===qc)return"link-expired";const s=Yo(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},Vc=300*1e3,Nn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Br(e,{headers:s,signal:AbortSignal.timeout(Vc)});if(r.status===202)throw new ps("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new ps(Hc(r.status,r.headers.get(Qc)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},Gc=(e,t,s)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:s}}},Tn=e=>e instanceof ps?e.reason:"generic",Wc=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",Yc=(e,t,s)=>{if(e!=="auth")return Ur(Kr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},Jc=(e,t)=>{const s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,n.rel="noopener",document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)},Xc=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},Zc=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},En=e=>e.filter(t=>!t.isMultipart&&t.disposition===Go.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Po(t.dispositionFilename??"",Zc(t.mediaSubtype)),typeLabel:Xc(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),Mn={status:"idle"},eu=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Qr(),o=oe(),[i,c]=l.useState({}),u=l.useMemo(()=>En(t??[]),[t]),v=qr({path:{messageId:e}}),h=g=>Nn(g.contentUrl,r).catch(d=>{if(!Bc(Tn(d)))throw d;return o.refetchQueries({queryKey:v}).then(()=>{const f=o.getQueryData(v),x=f?En(f.bodyParts).find(S=>S.bodyPartId===g.bodyPartId):void 0;return Nn(x?.contentUrl??g.contentUrl,r)})}),p=(g,d)=>c(f=>({...f,[g]:d})),m=g=>{const d=u.find(f=>f.bodyPartId===g);if(!d)throw new Error(`No attachment part ${g} on message ${e}`);p(g,{status:"downloading"}),h(d).then(f=>{Jc(f,d.filename),p(g,Mn)}).catch(f=>{const x=Tn(f),S=Wc(f),{title:y,detail:j}=Gc(x,d.filename,S);p(g,{status:"failed",title:y,detail:j,reportUrl:Yc(x,d.filename,S)})})},b=s&&t!==void 0&&u.length===0;return a.jsx(Cl,{className:n,attachments:u.map(g=>({attachmentId:g.bodyPartId,filename:g.filename,typeLabel:g.typeLabel,sizeOctets:g.sizeOctets,download:i[g.bodyPartId]??Mn})),onDownload:m,hasUnlistedAttachment:b})},tu=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:u,showRaw:v,onToggleRaw:h,onReply:p,onReplyAll:m,onForward:b})=>{const g=oe(),{deleteMessages:d}=Ls({mailboxId:s,threadId:t}),{moveMessages:f}=Vt({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:x}=Yn({messageId:e}),{mutate:S}=de({...zt(),onSettled:()=>{g.invalidateQueries({queryKey:Ae({path:{threadId:t}})}),Ce(g,we([s]))}}),y=l.useCallback(O=>{f([e],O)},[f,e]),j=l.useCallback(()=>{d([e])},[d,e]),E=l.useCallback(()=>{S({body:{messageIds:[e],isRead:!r}})},[S,e,r]),T=[];return c&&T.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?a.jsx(Kt,{className:"size-4 text-positive"}):a.jsx(Dt,{className:"size-4"}),onSelect:()=>x(c,u)}),h&&T.push({key:"raw",label:v?"Show formatted":"Show raw email",icon:a.jsx(xa,{className:"size-4"}),onSelect:h}),a.jsx(Ea,{hasThread:!0,onReply:p,onReplyAll:m,onForward:b,isStarred:o,onToggleStar:i,onDelete:j,isRead:r,onToggleRead:E,overflowItems:T,moveSlot:n?a.jsx(Ps,{accountId:n,currentMailboxId:s,onMove:y,label:"Move this message"}):void 0})},su=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),nu=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=ee({...Hr({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(su,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(vt,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=s?.raw??"";return c===""?a.jsx("div",{className:"message-body",children:a.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):a.jsx("div",{className:"message-body",children:a.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},au=()=>a.jsx(Kt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),Ya=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),Ja=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:n})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:D("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":D("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Xe,{className:D("size-3.5",e&&"fill-current")})}),ru=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=ta(e.sentDate,"datetime"),i=Ya(e,o);return a.jsx(Ma,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(Bt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(Ja,{isStarred:e.hasStars,onToggleStar:n,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},ou=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:u,isStarPending:v,accountId:h,showRaw:p,onToggleRaw:m,mobile:b,onReply:g,onReplyAll:d,onForward:f})=>{const x=ta(e.sentDate,"long"),S=!e.isRead,y=t?.envelope.from[0]?.flags?.trusted?.value===!0,j=t?.envelope.from[0]?.addressId,E=Ya(e,x),T=e.autoMoved||e.spamReport?a.jsx(zc,{accountId:h,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx(Ia,{message:E,isFocused:b?!1:i,onHeaderClick:c,senderBadge:y?a.jsx(au,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:x}),to:t?a.jsx(sl,{label:"To",addresses:t.envelope.to}):null,indicators:T||!b?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[T,!b&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(Ja,{isStarred:e.hasStars,onToggleStar:u,isStarPending:v})}),S&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:b?void 0:a.jsx(Kc,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:h,fromAddressId:j,isTrusted:y,showRaw:p,onToggleRaw:m}),actionBar:b?a.jsx(tu,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:h,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:j,isTrusted:y,showRaw:p,onToggleRaw:m,onReply:g,onReplyAll:d,onForward:f}):void 0,body:s?a.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):n&&Vr(r)?a.jsx("div",{className:"mt-3",children:a.jsx(Oa,{message:"This message has been deleted"})}):n?a.jsx("div",{className:"mt-3",children:a.jsx(vt,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):p?a.jsx("div",{className:"mt-3",children:a.jsx(nu,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(zo,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:y,category:qa(e.category)}),a.jsx(eu,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},iu=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:u,onReplyAll:v,onForward:h})=>{const[p,m]=l.useState(!1),{data:b,isLoading:g,isError:d,error:f,refetch:x}=ee({..._t({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(ou,{threadMessage:e,messageData:b,isLoading:g,isError:d,error:f,onRetry:()=>x(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:p,onToggleRaw:()=>m(S=>!S),mobile:c,onReply:u,onReplyAll:v,onForward:h}):a.jsx(ru,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},lu=()=>a.jsxs("div",{className:"animate-pulse p-4",children:[a.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),a.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>a.jsxs("div",{className:"flex gap-3 py-3",children:[a.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]}),Mf=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,composeRequest:c,onComposeClose:u,onSwipeNext:v,onSwipePrevious:h,mobileIntelligenceOpen:p})=>{const m=Cs(),{handlers:b}=Tc({onSwipeLeft:v,onSwipeRight:h}),{accountId:g}=za(t),{data:d,isLoading:f,isError:x,error:S,refetch:y}=ee({...Vn({path:{threadId:e}})}),j=l.useMemo(()=>d?.items??[],[d?.items]),E=j[j.length-1],T=l.useMemo(()=>[...j].reverse(),[j]),O=l.useRef(new Map),[$,F]=l.useState(new Set),[P,z]=l.useState(null),[L,K]=l.useState(0);l.useEffect(()=>{if(j.length>0&&e!==P){z(e);const Q=new Set([j[j.length-1].threadMessageId]);if(n){const V=j.find(ae=>ae.messageId===n);V&&Q.add(V.threadMessageId)}F(Q),K(0)}},[e,j,P,n]);const k=l.useCallback(Q=>{F(V=>{const ae=new Set(V);return ae.has(Q)?ae.delete(Q):ae.add(Q),ae})},[]),I=l.useCallback(Q=>{const V=T[Q];if(!V)return;O.current.get(V.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[T]),R=l.useCallback(()=>{if(T.length===0)return;const Q=Math.min(L+1,T.length-1);K(Q),I(Q)},[T.length,L,I]),w=l.useCallback(()=>{if(T.length===0)return;const Q=Math.max(L-1,0);K(Q),I(Q)},[T.length,L,I]),M=l.useCallback(()=>{const Q=T[L];Q&&k(Q.threadMessageId)},[T,L,k]),{data:C}=ee({...Ot(),staleTime:1/0}),_=C?.accounts?.[0];wc({messages:j,expandedIds:$,threadId:e,mailboxId:t,accountId:_?.accountId});const{toggleStar:U,isPending:ne,pendingMessageId:W}=Qa({threadId:e,mailboxId:t,messages:j}),[Y,X]=l.useState(null),[ce,ie]=l.useState(0),te=l.useCallback(Q=>{X(Q),ie(V=>V+1)},[]);l.useEffect(()=>{c&&c!=="new"&&(te(c),u?.())},[c,u,te]);const{data:H}=ee({..._t({path:{messageId:E?.messageId??""}}),enabled:!!E&&Y!==null}),fe=l.useCallback(()=>te("reply"),[te]),xe=l.useCallback(()=>te("reply_all"),[te]),me=l.useCallback(()=>te("forward"),[te]),pe=l.useCallback(()=>{X(null),u?.()},[u]),ve=l.useRef(null);if(l.useEffect(()=>{Y===null||ce===0||ve.current?.scrollIntoView({behavior:"smooth",block:"start"})},[ce,Y]),qo({enabled:!f&&j.length>0&&Y===null,bindings:[{key:"j",handler:R,preventDefault:!0},{key:"ArrowDown",handler:R,preventDefault:!0},{key:"k",handler:w,preventDefault:!0},{key:"ArrowUp",handler:w,preventDefault:!0},{key:"Enter",handler:M,preventDefault:!0},{key:"o",handler:M,preventDefault:!0},{key:"r",handler:fe,preventDefault:!0},{key:"R",handler:xe,noModifiers:!1,preventDefault:!0},{key:"f",handler:me,preventDefault:!0}]}),f)return a.jsx(lu,{});if(x)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(vt,{title:"Couldn't load this conversation",error:S,onRetry:()=>y()})});if(j.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(Oa,{message:"No messages in this thread"})});const he=s||j[0]?.subject||"(No subject)",ge=j.length,Se=Q=>a.jsx("div",{"data-testid":"conversation-messages",children:T.map((V,ae)=>a.jsx("div",{ref:B=>{B&&O.current.set(V.threadMessageId,B)},children:a.jsx(iu,{threadMessage:V,isExpanded:$.has(V.threadMessageId),isFocused:ae===L,onToggle:()=>k(V.threadMessageId),onToggleStar:()=>U(V.messageId,V.hasStars),isStarPending:ne&&W===V.messageId,accountId:g,mobile:Q,onReply:Q?fe:void 0,onReplyAll:Q?xe:void 0,onForward:Q?me:void 0})},V.threadMessageId))}),Ke=Y!==null&&a.jsx("div",{ref:ve,children:a.jsx(hc,{mode:Y,account:_,sourceMessage:H,onClose:pe})}),Be=a.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[a.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:he}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[ge," ",ge===1?"message":"messages"]})]});return m?a.jsxs("article",{className:"h-full flex flex-col",children:[Be,r?.dkimMismatch&&a.jsx(jn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[Ke,Se(!1)]})]}):a.jsxs(jl,{thread:{subject:he,messages:[]},onBack:i??(()=>{}),intelligenceOpen:p,onToggleIntelligence:o,touchHandlers:b,children:[r?.dkimMismatch&&a.jsx(jn,{authenticity:r,onOpenIntelligence:o}),Ke,Se(!0)]})},cu=10,Xa=e=>({q:e?.toLowerCase()??"",limit:cu}),uu=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function du(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":Ho(t,{month:"short",year:"numeric"})}function Za(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const fu="We can't verify the sender of this email, which could mean it's from an insecure source.",mu="We couldn't read this sender's address, so we can't confirm who really sent this message.";function pu(e,t){const s=e.category??"personal";return{value:Wr(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function hu(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?du(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:Za(e.fromEmail)}}function gu(e){return e?.flags?{vip:e.flags.vip?.value===!0,muted:e.flags.muted?.value===!0,blocked:e.flags.blocked?.value===!0,unsubscribed:e.flags.unsubscribed?.value===!0}:{}}function In(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function bu(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function xu(e,t){const s=[],n=e.displayNameCorrespondence;t&&(n===Xs.Unrelated?s.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):n===Xs.Lookalike&&s.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`));const r=vu(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${bu(r.slice(0,3))}.`),s}function vu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function yu(e,t){const s=t>0?t:void 0;if(Za(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:mu,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:fu};if(!n.dkimMismatch){const v=In(e),h=xu(n,v);return h.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:v,summary:h.join(" ")}:{verdict:"aligned",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,summary:n.dkimDomain?`This message was signed by ${n.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=n.fromDomain,o=n.dkimDomain,i=In(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",u=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:u,similarCount:s}}function ku(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=ee({...ys({query:Xa(s??void 0)}),enabled:!!s,staleTime:3e4}),i=uu(r?.items,s??void 0),c=[n,s].filter(Boolean).join(" "),{data:u,isLoading:v,error:h}=ee({...Gr({query:{query:c,limit:5}}),enabled:!!(e&&c.length>3),staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const m=(u?.items??[]).filter(x=>x.messageId!==e.messageId).map(x=>({id:x.messageId,threadId:x.threadId,mailboxId:t!=null&&x.mailboxIds.includes(t)?t:x.mailboxIds[0]??"",fromName:x.fromName??"",subject:x.subject??"(No subject)",timeLabel:x.sentDate!=null?et(x.sentDate*1e3):"",matched:x.matchedChunkType})),b=hu(e,i),g=yu(e,m.length),d=pu(e,i),f=gu(i);return{sender:b,authenticity:g,category:d,flags:f,similar:m}},[e,i,u,t]),isSimilarLoading:v,similarError:h,similarErrorIsFatal:qs(h),addressErrorIsFatal:qs(o),addressId:i?.addressId,address:i}}function ju(e,t){const s={...e??{}};for(const[n,r]of Object.entries(t))r==null?delete s[n]:s[n]={...r,setAt:r.setAt??Date.now()};return s}function wu({addressId:e,senderEmail:t}){const s=oe(),{pushError:n}=je(),r=Yr({query:Xa(t)}),{mutate:o,isPending:i}=de({...Jr(),onMutate:async u=>{const v=u.body.flags??{};await s.cancelQueries({queryKey:r});const h=s.getQueryData(r);return s.setQueryData(r,p=>p&&{...p,items:p.items.map(m=>m.addressId===u.path.addressId?{...m,flags:ju(m.flags,v)}:m)}),{previous:h}},onError:(u,v,h)=>{h?.previous!==void 0&&s.setQueryData(r,h.previous),n({title:"Couldn't update sender preference",detail:Re(u),error:u})},onSettled:()=>{s.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(u=>{if(!e){Xr(new Error(`Quick action fired but the sender's address record did not resolve (sender: ${t??"unknown"}). This should never happen — the address row exists.`));return}o({path:{addressId:e},body:{flags:u}})},[e,o,t]),isPending:i}}const If=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Cu=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function Rf(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function Af(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function $f(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Su(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Nu=["personal","newsletter","marketing","automated","transactional","social"],Tu=e=>e.spamReport?"notSpam":"reportSpam",Eu=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function Mu(){return a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(Je,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"h-8 rounded bg-surface"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>a.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function Iu({isOpen:e,current:t,onSelect:s,onCancel:n}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(eo,{label:"Dismiss reclassify sender",onDismiss:n,className:"backdrop-blur-sm"}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),a.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),a.jsx("div",{className:"mt-4 flex flex-col gap-1",children:Nu.map(r=>a.jsxs("button",{type:"button",onClick:()=>s(r),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${r===t?"font-semibold text-accent":"text-fg"}`,children:[r,r===t&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},r))}),a.jsx("div",{className:"mt-6 flex justify-end",children:a.jsx("button",{type:"button",onClick:n,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function Ru({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:u,similarError:v,similarErrorIsFatal:h}=ku(e,s),[p,m]=l.useState(!1),b=e.fromEmail??void 0,{updateFlags:g}=wu({addressId:c,senderEmail:b}),{reportSpam:d,notSpam:f,isReporting:x,isRestoring:S}=Ga({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),y=Zr(),j=Tu(e),E=l.useCallback(()=>{f([e.messageId])},[f,e.messageId]),T=l.useCallback(()=>{Su(y,{count:1,senderTrust:e.senderTrust,wasRescuable:Cu(e)}),d([e.messageId])},[d,e,y]),O=l.useCallback(()=>{},[]),$=l.useCallback(()=>{const R=i?.flags?.vip!==!0;g({vip:{value:R}})},[i?.flags?.vip,g]),F=l.useCallback(()=>{const R=i?.flags?.muted!==!0;g({muted:{value:R}})},[i?.flags?.muted,g]),P=l.useCallback(()=>{const R=i?.flags?.unsubscribed!==!0;g({unsubscribed:{value:R}})},[i?.flags?.unsubscribed,g]),z=l.useCallback(R=>{m(!1),g({category:{value:R}})},[g]),L=c!==void 0,K={onToggleVip:L?$:void 0,onToggleMute:L?F:void 0,onToggleUnsubscribe:L?P:void 0,onReclassify:L?()=>m(!0):void 0,onNotSpam:j==="notSpam"?E:void 0,onReportSpam:j==="reportSpam"?T:void 0},k=({mailboxId:R,threadId:w,messageId:M,className:C,ariaLabel:_,children:U})=>a.jsx(sa,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:R,threadId:w,messageId:M},search:ne=>ne,variant:"row",className:C,"aria-label":_,children:U});if(!i)return a.jsx(Mu,{});const I=Eu({similarError:v,similarErrorIsFatal:h,isSimilarLoading:u});return a.jsxs(a.Fragment,{children:[a.jsx(ja,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:O,actions:K,similarState:I,similarLinkComponent:k,reportSpamPending:x,notSpamPending:S,className:"border-l-0 h-full w-full"}),a.jsx(Iu,{isOpen:p,current:i.category.value,onSelect:z,onCancel:()=>m(!1)})]})}const Lf=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(Ru,{thread:t,onClose:e,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}):a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(Je,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[a.jsx(Je,{className:"size-8 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),a.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]}),Au={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},er={delete:"moved to Trash",move:"moved",markRead:"marked as read"},$u={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},Lu={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},Pu={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},Pf=(e,t,s)=>Au[e](Ue(t),Ue(s)),Df=(e,t)=>`${Ue(t)} ${er[e]}. Your mail server is still catching up.`,Ff=e=>`Stopped after ${Ue(e)}`,Of=(e,t,s)=>`${Ue(t)} of ${Ue(s)} ${er[e]}. Nothing was sent for the rest, so they are untouched.`,Du=(e,t)=>t>0?`Stopped after ${Ue(t)} — some messages ${$u[e]}`:Lu[e],Fu=e=>Pu[e],zf=e=>e==="delete"?"danger":"info",Ou=100,zu=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],_u=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,u]=l.useState(void 0),[v,h]=l.useState(void 0),p=l.useRef(!1),m=l.useRef(!1),b=oe(),{pushError:g}=je();l.useEffect(()=>{m.current||(p.current=!0),i({kind:"idle"})},[s,n]);const d=l.useRef(r);d.current=r;const f=l.useCallback($=>async F=>{const{data:P}=await Hs({path:{mailboxId:e},query:{...$,continuationToken:F,limit:Ou},throwOnError:!0});return{ids:(P.items??[]).map(z=>z.messageId),continuationToken:P.continuationToken}},[e]),x=l.useCallback(async()=>{const{data:$}=await Hs({path:{mailboxId:e},query:{...d.current,count:!0,results:!1},throwOnError:!0});if($.count===void 0)throw new Error("the search returned no count for the selection");return $.count},[e]),S=l.useCallback($=>async F=>{if($.kind==="move"){const{data:z}=await to({body:{messageIds:F,destinationMailboxId:$.destinationMailboxId},throwOnError:!0});return z}if($.kind==="markRead"){const{data:z}=await so({body:{messageIds:F,isRead:!0},throwOnError:!0});return z}const{data:P}=await no({body:{messageIds:F},throwOnError:!0});return P},[]),y=l.useCallback($=>{Ce(b,we(zu($,e))),t&&b.invalidateQueries({queryKey:Ze({path:{accountId:t}})})},[b,e,t]),j=l.useCallback(()=>{p.current=!1,i({kind:"counting"}),x().then($=>{if(p.current){i({kind:"idle"});return}i({kind:"escalated",total:$})},$=>{g(Vs("Couldn't count matching messages","The count didn't finish.",$)),i({kind:"idle"})})},[x,g]),E=l.useCallback(()=>{p.current=!0},[]),T=l.useCallback(()=>{m.current||(p.current=!0,i({kind:"idle"}))},[]),O=l.useCallback(async($,F)=>{p.current=!1,m.current=!0,u($);const P=k=>h(vc(k)),z=S($),L=f(d.current);let K;try{K=F!==void 0?await _a(F,z,P,()=>p.current):await xc(L,o.kind==="escalated"?o.total:0,z,P,()=>p.current)}finally{m.current=!1}return u(void 0),h(void 0),i({kind:"idle"}),K.error&&g(Vs(Du($.kind,K.done),Fu($.kind),K.error)),K.done>0&&y($),K},[S,f,o,g,y]);return{phase:o,escalate:j,stop:E,clear:T,isRunning:c!==void 0,runningAction:c,progress:v,runAction:O}},Uu=120,Ku=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=Uu})=>{const o=l.useRef(n);o.current=n;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!s){i.current=c;return}if(c===void 0||c===t)return;if(c===i.current){i.current=void 0;return}const u=setTimeout(()=>o.current(c),r);return()=>clearTimeout(u)},[s,e,t,r])},tr="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folders.",Bu="These are already in Junk, so there is nowhere to file them.",Qu=(e,t)=>e!==void 0&&e!==t?e:void 0,_f=(e,t)=>{if(Qu(e,t)===void 0)return e===void 0?tr:Bu};function qu(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const Hu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},hs=l.createContext(Hu),sr=()=>l.useContext(hs),nr=8,ar=e=>e==="From"||e==="FromDomain",Vu=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),Gu=e=>{const t=Da(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},Wu=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),Yu=(e,t,s)=>{if(!ar(e))return[];const n=t.trim().toLowerCase(),r=new Set,o=[];for(const i of s){if(i.email.trim()==="")continue;const c=e==="From"?Vu(i):Gu(i);if(!c)continue;const u=c.value.toLowerCase();if(!(u===""||r.has(u))&&(r.add(u),u!==n&&!(n!==""&&!Wu(c,n))&&(o.push(c),o.length===nr)))break}return o},Ju=250,Xu=2,Zu=(e,t,s)=>{const n=t.trim(),r=na(n,Ju),o=e!==void 0&&ar(e),{data:i}=ee({...ys({query:{q:r,limit:nr}}),enabled:o&&r.length>=Xu});if(!o||e===void 0)return[];const c=[...s.map(u=>({email:u,fromSelection:!0})),...(i?.items??[]).map(u=>({email:u.normalizedEmail,...u.displayName?{displayName:u.displayName}:{}}))];return Yu(e,n,c)},rr=12,ed=e=>{const{envelope:t}=e,s=t.from[0];return{id:t.messageId,sender:s?Fa({normalizedEmail:s.normalizedEmail,displayName:s.displayName}):"Unknown",subject:t.subject??"(No subject)",date:et(t.date)}},td=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=ee({...ao({path:{mailboxId:e??""},query:{...t,limit:rr}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(sd),isPending:s&&r}},sd=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:et(e.sentDate)}),nd=e=>ws({queries:e.slice(0,rr).map(t=>({..._t({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(s=>s.data).filter(s=>s!==void 0).map(ed),isPending:t.some(s=>s.isPending)})}),ad=e=>({matchOperator:"Or",literalClauses:qt(e)}),rd=(e,t,s)=>{const n=de(ro()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),u=l.useMemo(()=>Qt(s),[s]),v=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:Zs({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),h=l.useCallback(()=>{c(!1),o()},[o]),p=n.data,m=p?.semanticUnavailable===!0&&!i&&u.length>0;l.useEffect(()=>{!m||!e||(c(!0),r({path:{accountId:e},body:Zs(ad(u))}))},[m,e,u,r]);const b=i||(p?.semanticUnavailable??!1),g=n.isPending||m,d=i?{matchOperator:"Or",literalClauses:qt(u)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:v,reset:h,matchedCount:g?void 0:p?.matchedCount,messageIds:g?void 0:p?.messageIds,semanticUnavailable:b,senderFallback:i,senders:u,matchPredicate:d,isPending:g,isError:n.isError,error:n.error}},od=()=>[Bn({path:{mailboxId:""}}),Qn({path:{mailboxId:""}}),qn()].map(e=>[{_id:e[0]._id}]),id=e=>Ua(e)?e.pages:Ka(e)?[e]:[],ld=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",cd=(e,t)=>{const s=new Set(t),n=new Map;for(const r of e)for(const o of id(r))for(const i of o.items){if(!ld(i)||!s.has(i.messageId))continue;const c=i.subject?.trim();c&&n.set(i.messageId,c)}return t.map(r=>n.get(r)).filter(r=>r!==void 0)},ud=e=>{const t=oe(),s=e.join("\0");return l.useMemo(()=>{const n=od().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return cd(n,e)},[t,s])},dd=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),fd=e=>dd.has(e),md=(e,{searchHadSemanticReach:t})=>{const s=[],n=[];let r,o;for(const u of e.tokens){if(u.type==="from"){s.push({field:"From",value:u.value});continue}if(u.type==="subject"){s.push({field:"Subject",value:u.value});continue}if(u.type==="in"){r={mailboxId:u.mailboxId,label:u.value};continue}if(u.type==="account"){o=u.accountId;continue}fd(u.type)&&n.push({type:u.type,label:Jn(u)})}const i=e.freeText.trim(),c=i.length>0;return c&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},pd=(e,t,s)=>e.targetAccountId??t??s[0]?.accountId,hd=({failure:e,isStarting:t,isRunning:s,isDone:n,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":n?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||s?"backApplyRunning":"saving",gd={clauses:[],matchOperator:"any"},bd={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},xd=[],_e={state:"saving",matched:0,applied:0,failed:0,failures:[]},as=(e,t)=>e.map((s,n)=>({...s,id:`${t}-${n}`})),Rn=(e,t,s)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const n=e==="junk"?s:t;return n?{kind:"move",destinationMailboxId:n}:void 0},rs=e=>e==="move"||e==="junk"||e==="organize",An=e=>e==="junk"?tr:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function vd({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:u,onRunEnded:v,step:h,goToStep:p,goBack:m,closeWizard:b}){const[g]=l.useState(()=>c),[d]=l.useState(()=>o),f=g!==void 0,[x,S]=l.useState(f?"properties":"selected"),y=d?"escalated":x,[j,E]=l.useState(()=>g?{clauses:as(g.clauses,"search"),matchOperator:g.matchOperator}:gd),[T,O]=l.useState(void 0),[$,F]=l.useState(void 0),[P,z]=l.useState(!1),[L,K]=l.useState(void 0),[k,I]=l.useState(void 0),[R,w]=l.useState(),M=l.useRef(!1),C=l.useRef(!1),_=l.useMemo(()=>n.map(N=>N.id),[n]),U=l.useMemo(()=>n.map(N=>N.email).filter(Boolean),[n]),ne=_[0],W=ud(_),{junkMailboxId:Y}=Ha(t),X=rd(d?void 0:t,ne,U),{preview:ce}=X;l.useEffect(()=>{ce()},[ce]);const ie=y==="similar"||y==="properties",te=l.useMemo(()=>({matchOperator:j.matchOperator==="all"?"And":"Or",literalClauses:j.clauses.map(N=>({field:N.field,value:N.value}))}),[j.clauses,j.matchOperator]),H=y==="similar"?X.matchPredicate:te,{count:fe,matchedIds:xe}=ei(ie?t:void 0,H),me=nd(ie?xe:[]),pe=td(d?s:void 0,d?.searchQuery),ve=d?{status:"ready",count:d.total}:ie?fe:{status:"ready",count:n.length},{data:he}=ee({...xt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),ge=Va(t),Se=aa(),Ke=l.useMemo(()=>oa({mailboxes:he?.items??[],folderAppointments:ge,currentMailboxId:s,translator:Se}),[he?.items,ge,s,Se]),{createFolderIn:Be}=ra(t),Q=Ke.find(N=>N.id===j.moveMailboxId)?.label,V=tc(n.map(N=>({normalizedEmail:N.email,displayName:N.sender}))),ae=cc({match:y==="properties"&&j.clauses[0]?.value.trim()||void 0,sender:V?Fa(V):void 0,folder:Q}),B=l.useMemo(()=>({...j,name:j.name??ae}),[j,ae]),St=Zu(T?.draft.field,T?.draft.value??"",U),ue=ti(t),Ne=si(t),Le=_u({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:st}=Le,re=lo({verb:e,mode:y,scope:j.scope,fromSearch:f}),J=re[Gs(re,h)],Pe=co(t,r),De=(N=>{if(N==="folder")return Pe.destination;if(N==="rule")return B.scope==="standing"||B.scope==="until"?Pe.rule:void 0})(J)??uo(J,B,ve),nt=l.useCallback(()=>as(lc(U,W),"seed"),[U,W]),Qe=l.useCallback(N=>{S(N),E(A=>({...A,widen:N==="similar"&&ne?{anchorCount:Math.max(n.length,1)}:void 0,...N==="properties"&&A.clauses.length===0?{clauses:nt()}:{}}))},[ne,n.length,nt]),at=l.useCallback(()=>{z(!0),S("properties"),E(N=>({...N,widen:void 0,clauses:as(qt(U),"sender"),matchOperator:"any"})),p("properties")},[U,p]),Fe=X.semanticUnavailable||X.isError;l.useEffect(()=>{J==="match"&&(y!=="similar"||!Fe||P||at())},[J,y,Fe,P,at]);const rt=l.useCallback(()=>{O({mode:"add",draft:{field:"From",value:""}})},[]),ot=l.useCallback(N=>{const A=j.clauses.find(G=>G.id===N);A&&O({mode:"edit",clauseId:N,draft:{field:A.field,value:A.value}})},[j.clauses]),it=l.useCallback(N=>{E(A=>({...A,clauses:A.clauses.filter(G=>G.id!==N)}))},[]),se=l.useCallback(N=>{O(A=>A&&{...A,draft:N})},[]),ye=l.useCallback(()=>{O(N=>{if(!N)return;const A=ni(N.draft.field,N.draft.value),G={...N.draft,value:A};E(qe=>({...qe,clauses:N.clauseId?qe.clauses.map(lt=>lt.id===N.clauseId?{...lt,...G}:lt):[...qe.clauses,{id:crypto.randomUUID(),...G}]}))})},[]),cr=l.useCallback(()=>{if(De){F(J);return}F(void 0);const N=re[Gs(re,J)+1];N&&p(N)},[De,J,re,p]),Gt=l.useCallback(async N=>{const A=Rn(e,B.moveMailboxId,Y);if(!A){I({matched:N.length,failureReason:An(e)});return}I({matched:N.length});const G=await st(A,[...N]);I({matched:N.length,outcome:G}),C.current&&v?.(A.kind,N.length,G)},[e,B.moveMailboxId,Y,st,v]),Wt=l.useCallback(async()=>{if(!d)return;const N=Rn(e,B.moveMailboxId,Y);if(!N){I({matched:d.total,failureReason:An(e)});return}I({matched:d.total});const A=await d.run(N);I({matched:d.total,outcome:A}),C.current&&v?.(N.kind,d.total,A)},[d,e,B.moveMailboxId,Y,v]),{start:Nt}=ue,{createFilterAsync:zs}=Ne,Tt=l.useCallback(()=>{if(d){Wt();return}const N=ai({mode:x,ruleScope:B.scope}),A=ri({mode:x,ruleScope:B.scope,anchorMessageId:ne,clauses:B.clauses,matchOperator:B.matchOperator,moveMailboxId:B.moveMailboxId,until:B.until});if(K(N),N==="standing"||N==="temporary"){const G=oi(A)?A:void 0;w(G),zs(A,N,(B.name??"").trim()).then(qe=>{qe&&G&&Nt(G)});return}if(N==="all-like-these"&&rs(e)){Nt(A);return}Gt(N==="just-these"?_:xe)},[d,Wt,x,B,ne,e,_,xe,zs,Nt,Gt]),ur=l.useCallback(()=>{if(De){F(J);return}M.current||(M.current=!0,p("run"),Tt())},[De,J,p,Tt]),_s=l.useCallback(N=>{const A=ue.progress,G=hd({failure:ue.failure,isStarting:ue.isStarting,isRunning:ue.isRunning,isDone:ue.isDone,failedCount:A.failedCount,ruleSaved:N});return G==="saving"||G==="commitFailed"||G==="backApplyStartFailed"?{..._e,state:G}:{state:G,matched:A.matchedCount,applied:A.appliedCount,failed:G==="backApplyFailed"||G==="backApplyRestartFailed"?A.failedCount:0,failures:[]}},[ue]),Us=l.useMemo(()=>{const N=new Map;for(const A of[...n,...me.messages,...pe.messages])N.set(A.id,A);return N},[n,me.messages,pe.messages]),Ks=d?i:Le.progress,Bs=l.useCallback(()=>{if(!k)return _e;const{matched:N,outcome:A,failureReason:G}=k;if(G!==void 0)return{..._e,state:"commitFailed",failureReason:G};if(!A){const He=Ks?.done??0;return{state:"backApplyRunning",matched:Math.max(N,He),applied:He,failed:0,failures:[]}}if(!(A.cancelled||A.error!==void 0))return{state:"backApplyComplete",matched:Math.max(N,A.done),applied:A.done,failed:0,failures:[]};if(A.done===0)return{..._e,state:"commitFailed"};const lt=A.failedIds.map(He=>Us.get(He)).filter(He=>He!==void 0),hr=A.failedIds.length>0?A.failedIds.length:Math.max(N-A.done,1);return{state:"runStopped",matched:Math.max(N,A.done),applied:A.done,failed:hr,failures:lt}},[k,Ks,Us]),Oe=d?Bs():L==="standing"||L==="temporary"?Ne.isError?{..._e,state:"commitFailed"}:Ne.isSuccess?R?_s(!0):{..._e,state:"filterSaved"}:_e:L==="all-like-these"&&rs(e)?_s(!1):Bs(),dr=()=>{if(Oe.state==="statusUnknown"){ue.refreshStatus();return}if(d){Wt();return}if(L==="standing"||L==="temporary"){if(Ne.isError){Ne.reset(),Tt();return}R&&Nt(R);return}if(L==="all-like-these"&&rs(e)){Tt();return}const N=k?.outcome?.failedIds??[];Gt(N.length>0?N:_)},fr=l.useCallback(()=>{b(re,J)},[b,re,J]),Yt=l.useCallback(()=>{C.current=!0,b(re,J),u()},[b,re,J,u]),{stop:Qs}=Le,mr=k!==void 0&&k.outcome===void 0&&k.failureReason===void 0,pr=l.useCallback(()=>{if(d){d.stop();return}Qs()},[d,Qs]);pc({shouldBlockFn:({action:N})=>N!=="BACK"?!1:(Yt(),!0),enableBeforeUnload:!1,disabled:J!=="run"});const Jt={messages:d?pe.messages:ie?me.messages:n,count:ve,label:y==="selected"?"Your selection":"A sample of what matches",emptyReason:y==="similar"&&Fe?"notIndexed":"noMatch",loading:d?pe.isPending:ie&&(ve.status==="loading"||me.isPending)};return a.jsx(fo,{verb:e,steps:re,step:J,blockedReason:De,nudged:$===J,onBack:m,onExit:J==="run"?Yt:fr,onContinue:cr,onCommit:ur,match:{selectedCount:n.length,mode:y,accountId:Pe.accountId,onModeChange:Qe,semanticUnavailable:Fe,semanticErrorDetail:X.error instanceof Error?X.error.message:void 0,semanticFallbackTaken:P,onSemanticFallback:at,escalatedScope:d?.scope,sample:Jt},properties:{clauses:B.clauses,matchOperator:B.matchOperator,onMatchOperatorChange:N=>E(A=>({...A,matchOperator:N})),clauseEdit:T,onStartAddClause:rt,onStartEditClause:ot,onRemoveClause:it,onChangeDraft:se,onSubmitClause:ye,onCancelClause:()=>O(void 0),clauseFields:ii,clauseSuggestions:St,conversionNotice:g?dc(g):void 0,semanticFallbackTaken:P,sample:{...Jt,label:"What this matches"}},folder:{folders:Ke,mailboxId:B.moveMailboxId,delimiter:ia(he?.items??[]),onSelect:N=>E(A=>({...A,moveMailboxId:N})),onCreateFolder:t?Be:void 0,restriction:Pe.destination},rule:{draft:B,onScopeChange:N=>E(A=>({...A,scope:N})),onUntilChange:N=>E(A=>({...A,until:N})),restriction:Pe.rule},name:{name:B.name??"",onNameChange:N=>E(A=>({...A,name:N})),nudged:$===J},review:{verb:e,mode:y,selectedCount:n.length,clauses:B.clauses,matchOperator:B.matchOperator,folder:Q,scope:B.scope,until:B.until,ruleName:re.includes("name")?B.name:void 0,escalatedScope:d?.scope,sample:Jt},run:{state:Oe.state,verb:e,scope:B.scope,matched:Oe.matched,applied:Oe.applied,failedCount:Oe.failed,failures:Oe.failures,failureReason:Oe.failureReason,onRetry:dr,onDismiss:Yt,onCancelRun:mr?pr:void 0}})}function Uf(e){const t=oo()==="search",{searchConversion:s}=sr(),{accounts:n}=ks(),{step:r,goToStep:o,goBack:i,closeWizard:c}=io(t?"properties":"match");if(!r)return null;const u=t?s??bd:void 0;return a.jsx(vd,{...e,...u?{verb:"organize",accountId:pd(u,e.accountId,n),selection:xd,selectionRestriction:void 0,escalated:void 0,searchConversion:u}:{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Ds=l.createContext(null),yd=e=>{const t=l.useContext(Ds);return t?t.rowInteraction(e):null},kd=()=>{const e=l.useContext(Ds);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},jd="[data-message-id]",wd=e=>Array.from(e.querySelectorAll(jd)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),Cd=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),Sd=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=wd(n);s(c=>Cd(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function Kf({selectedMessageId:e,onOpen:t,onDeleteMessages:s,onSelectionVerb:n,wizardOpen:r=!1,isDeleting:o=!1,commandsRef:i,onTriageContextChange:c,children:u}){const v=Cs(),h=l.useRef(null),p=Sd(h),m=fc({orderedIds:p,isDesktop:v,initialFocusedId:e}),{focusedMessageId:b,setFocusedMessageId:g,pendingDomFocusRef:d,cursorMovedByPointerRef:f,selection:x,isMultiSelectMode:S,exitSelection:y,handleRowSelect:j}=m,{selectedIds:E,selectedCount:T,isSelected:O,toggle:$,select:F,toggleAll:P}=x,z=p.length>0&&p.every(H=>E.has(H)),L=l.useCallback(()=>{p.length>0&&P(p)},[p,P]),{intersectWith:K}=x;l.useEffect(()=>{K(p)},[K,p]),l.useEffect(()=>{const H=d.current;H!==null&&(d.current=null,h.current?.querySelector(`[data-message-id="${H}"]`)?.focus())});const k=l.useCallback(H=>{f.current=!0,g(H)},[f,g]),I=l.useCallback(H=>{v||F(H)},[v,F]),R=l.useCallback(()=>{b&&t(b)},[b,t]),w=l.useCallback(H=>t(H,{replace:!0}),[t]);Ku({keyboardFocusedMessageId:m.keyboardFocusedMessageId,openMessageId:e,enabled:v&&T===0,open:w});const[M,C]=l.useState(null),_=l.useCallback(H=>M!==null?!0:T>0?(n(H),!0):H!=="delete"||!b?!1:(C([b]),!0),[M,T,n,b]),U=l.useCallback(()=>{M!==null&&(s(M),C(null),y())},[M,s,y]),ne=l.useCallback(()=>C(null),[]),W=l.useCallback(()=>T===0?!1:(y(),!0),[T,y]),Y=p.length>0;l.useEffect(()=>{if(i){if(!Y){i.current=null;return}return i.current={focusNext:m.focusNext,focusPrevious:m.focusPrevious,focusFirst:m.focusFirst,focusLast:m.focusLast,openFocused:R,toggleSelect:m.toggleFocusedSelection,extendSelectDown:m.extendRangeDown,extendSelectUp:m.extendRangeUp,selectAll:m.selectAllLoaded,clearSelection:W,requestVerb:_,toggleDensity:()=>{}},()=>{i.current=null}}},[i,Y,m.focusNext,m.focusPrevious,m.focusFirst,m.focusLast,m.toggleFocusedSelection,m.extendRangeDown,m.extendRangeUp,m.selectAllLoaded,R,W,_]);const X=l.useMemo(()=>Array.from(E),[E]),ce=M!==null;l.useEffect(()=>{c?.({focusedMessageId:b,selectedIds:X,orderedIds:p,hasList:Y,blocksKeyboard:ce||r})},[c,b,X,p,Y,ce,r]);const ie=qu(p,b),te=l.useMemo(()=>({selectedIds:E,selectedCount:T,exitSelection:y,startSelectionVerb:n,orderedIds:p,allSelected:z,toggleAllLoaded:L,rowInteraction:H=>({focused:H===b,isTabStop:H===ie,isDesktop:v,onFocusRow:k,selection:{isChecked:O(H),onToggleCheck:$,onRowSelect:j,isMultiSelectMode:S,onLongPress:I}})}),[E,T,y,n,p,z,L,b,ie,v,k,O,$,j,S,I]);return a.jsxs(Ds.Provider,{value:te,children:[a.jsx("div",{ref:h,className:"contents",children:u}),a.jsx(li,{isOpen:ce,title:Vo(M?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:o,onConfirm:U,onCancel:ne})]})}function Bf({title:e,isDeleting:t}){const s=sr(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:u}=kd();return a.jsx(Fl,{title:s.title||e,navSlot:s.navSlot,titleMeta:s.titleMeta,searchSlot:s.searchSlot,searchField:s.searchField,idleSlot:s.makeFilterSlot,count:n,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:n>0&&!c,onChange:u}:void 0})}const os=e=>{e.preventDefault(),e.stopPropagation()},Nd=(e,t)=>{const s=l.useRef(!1),n=l.useCallback(i=>{if(s.current=!1,i.button!==0)return;const c=ds(i);cn(c)&&t?.(e,c)&&(os(i),s.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[t,e]),r=l.useCallback(i=>{!i.ctrlKey||!t||i.preventDefault()},[t]),o=l.useCallback(i=>{if(s.current)return s.current=!1,os(i),!0;const c=ds(i);return!cn(c)||!t?.(e,c)?!1:(os(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:n,onContextMenu:r,claimClick:o}},Td=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:u=!1,link:v,onClick:h,onFocusRow:p})=>{const m=oe(),b=e.id,g=yd(b),d=s??g?.focused??!1,f=n??g?.isTabStop??!1,x=c??g?.selection,S=p??g?.onFocusRow,y=o??g?.isDesktop??!0,j=x?.isChecked??!1,E=x?.isMultiSelectMode??!1,T=x?.onToggleCheck,O=x?.onRowSelect,$=x?.onLongPress,F=l.useCallback(C=>{C.preventDefault(),C.stopPropagation(),T?.(b)},[T,b]),P=Nd(b,O),z=l.useCallback(C=>{if(!P.claimClick(C)){if(!y){if(E){C.preventDefault(),C.stopPropagation(),T?.(b);return}h?.();return}O?.(b,ds(C)),h?.()}},[P,y,E,T,O,h,b]),L=l.useCallback(()=>{$?.(b)},[$,b]),{longPressProps:K}=vl({onLongPress:L,accessibilityDescription:j?"Deselect message":"Select message"}),k=l.useCallback(()=>{m.prefetchQuery(_t({path:{messageId:b}}))},[m,b]),I=l.useCallback(()=>{k(),S?.(b)},[k,S,b]),R=yt({"data-list-row":"","data-message-row":!0,"data-message-id":b,...u?{role:"option","aria-selected":j}:{},tabIndex:f?0:-1,onClick:z,onMouseDown:P.onMouseDown,onContextMenu:P.onContextMenu,onMouseEnter:k,onFocus:I},y||!x?{}:K),w=D(r==="compact"?Ca({active:t,focused:d}):D("group",Ms({active:t,focused:d})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",j&&"bg-accent-soft",!y&&"min-h-11 select-none [-webkit-touch-callout:none]"),M=r==="compact"?a.jsx(Sa,{thread:e}):a.jsx(Is,{thread:e,badge:i,selection:x?{checked:j,alwaysVisible:E,onToggle:F}:void 0});return v===void 0?a.jsx("button",{type:"button",...R,className:w,children:M}):a.jsx(sa,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...v,messageId:b},search:C=>C,variant:"row",...R,className:w,children:M})},Qf=l.memo(Td),is="Open a message first",qf=({hasThread:e,intelligenceOpen:t,canToggleIntelligence:s,onToggleIntelligence:n,onReply:r,onReplyAll:o,onForward:i,onDelete:c,canDelete:u,onToggleStar:v,isStarred:h,moveContext:p})=>{const[m,b]=l.useState(null),g=u??e,d=f=>()=>b(f);return a.jsx(kl,{hasThread:e,isStarred:h,onUnavailable:f=>b(is),unavailableHint:m,replyTitle:`Reply ${ct("reply")}`,replyAllTitle:`Reply all ${ct("replyAll")}`,forwardTitle:`Forward ${ct("forward")}`,deleteTitle:`Move to Trash ${ct("delete")}`,flagTitle:`Star ${ct("toggleStar")}`,onReply:r,onReplyAll:o,onForward:i,onDelete:g?c:d(is),onToggleStar:v,onMove:d(is),moveSlot:p?a.jsx(Ps,{accountId:p.accountId,currentMailboxId:p.currentMailboxId,onMove:p.onMove,label:"Move to mailbox"}):void 0,children:a.jsx(yl,{open:t,enabled:s,onToggle:n})})},Ed=()=>{const e=oe();return l.useCallback(t=>{const s=Ae({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},Hf=({thread:e,mailboxId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=t??e?.mailboxId,o=s??e?.accountId,{accountId:i}=za(o?void 0:r),c=o??i,u=Ed(),{deleteMessages:v}=Ls({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{moveMessages:h}=Vt({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{toggleStar:p}=Qa({threadId:e?.threadId??"",mailboxId:r??""}),m=l.useCallback(()=>{e&&v(u(e))},[e,u,v]),b=l.useCallback(S=>{e&&h(u(e),S)},[e,u,h]),g=l.useCallback(()=>{e&&p(e.messageId,e.hasStars)},[e,p]),[d,f]=l.useState(null),x=l.useCallback(()=>f(null),[]);return{mailboxId:r,accountId:c,isStarred:e?.hasStars,deleteThread:m,moveThread:b,toggleStar:g,composeRequest:d,requestCompose:f,clearComposeRequest:x}},Vf=(e,t)=>{const{data:s}=ee({...Vn({path:{threadId:e??""}}),enabled:!!e}),n=s?.items??[],r=t?n.find(i=>i.messageId===t):void 0,o=n.length>0?n[n.length-1]:void 0;return r??o},$n=(e,t,s)=>{if(!t)return null;const n=e.indexOf(t);if(n===-1)return null;const r=s==="next"?n+1:n-1;return r<0||r>=e.length?null:e[r]},Gf=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,u]=l.useState(!1),[v,h]=l.useState(!1),p=l.useCallback(m=>{t(m.focusedMessageId),n(m.selectedIds),m.orderedIds&&o(m.orderedIds),u(m.hasList),h(m.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:p,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c,blocksKeyboard:v}},Wf=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:u}=e,v=l.useCallback(()=>{i.current?.clearSelection()||s&&r()},[i,s,r]);return So({enabled:n&&!u,handlers:{...c?{focusNext:()=>i.current?.focusNext(),focusPrevious:()=>i.current?.focusPrevious(),focusFirst:()=>i.current?.focusFirst(),focusLast:()=>i.current?.focusLast(),openFocused:()=>i.current?.openFocused(),toggleSelect:()=>i.current?.toggleSelect(),extendSelectDown:()=>i.current?.extendSelectDown(),extendSelectUp:()=>i.current?.extendSelectUp(),selectAll:()=>i.current?.selectAll(),toggleDensity:()=>i.current?.toggleDensity()}:{},back:v,...o}}),{goBack:v,nextMessageId:$n(t,s,"next")??void 0,previousMessageId:$n(t,s,"previous")??void 0}},Md={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function Id(e){return Md[e]??e}function Yf(e,t){const{folder:s}=js(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:et(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function Jf(e,t){const{folder:s}=js(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function Rd(e,t){const{mailboxId:s,folder:n}=js(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?et(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:Id(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function Xf(e,t,s){const n=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))n.has(o.threadId)||(n.add(o.threadId),r.push(Rd(o,s)));return r}function Zf(e){const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:et(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:qa(e.category),suspicious:t}}function em(e){return e.filter(t=>t.muted!==!0)}function tm(e,t){const s=new Set,n=[];for(const r of[...e,...t])s.has(r.id)||(s.add(r.id),n.push(r));return n.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const Ln=[{id:"personal",label:"Personal",category:ke.personal},{id:"transactional",label:"Transactional",category:ke.transactional},{id:"newsletter",label:"Newsletter",category:ke.newsletter},{id:"marketing",label:"Marketing",category:ke.marketing},{id:"social",label:"Social",category:ke.social},{id:"automated",label:"Automated",category:ke.automated},{id:"uncategorized",label:"Unclassified",category:ke.uncategorized}];function sm(e){const t=new Map(Ln.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ke.uncategorized;(t.get(r)??t.get(ke.uncategorized))?.push(n)}const s=[];for(const n of Ln){const r=t.get(n.category);r&&r.length>0&&s.push({id:n.id,label:n.label,threads:r})}return s}function nm(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function am(e,t){return t.every(s=>{switch(s.type){case"from":{const n=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(n)||e.fromName.toLowerCase().includes(n)}case"subject":return e.subject.toLowerCase().includes(s.value.toLowerCase());case"category":return(e.category??"uncategorized")===s.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=s.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<s.epochSeconds*1e3;case"in":return e.mailboxId===s.mailboxId;case"account":return e.accountId===s.accountId;default:return!1}})}const or=8;function Fs(e,t){const s=Math.max(0,Math.min(t,e.length)),n=_o(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=Uo(n.raw);return r?{start:n.start,end:n.end,raw:n.raw,name:r.name,value:r.value}:{start:n.start,end:n.end,raw:n.raw}}function Ad(e,t){const s=Fs(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=Xn(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const $d={mailbox:"mailboxes",account:"accounts",contact:"contacts"},Ld=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=$d[e.values];return s?t[s]??[]:[]},Pd=(e,t)=>{if(t==="")return 1;const s=e.toLowerCase();return s.startsWith(t)?0:s.includes(t)?1:-1},gs=(e,...t)=>{let s=-1;for(const n of t){if(n===void 0)continue;const r=Pd(n,e);r<0||(s<0||r<s)&&(s=r)}return s},ir=e=>{const t=new Set;return e.filter(s=>s.rank>=0).sort((s,n)=>s.rank-n.rank).filter(s=>{const n=s.suggestion.value.toLowerCase();return t.has(n)?!1:(t.add(n),!0)}).slice(0,or).map(s=>s.suggestion)},Pn=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function Dd(e){const t=e.trim().toLowerCase();if(t==="")return Ys.map(Pn);const s=[];for(const n of Ys)if(s.push({rank:gs(t,`${n.name}:`,n.label),suggestion:Pn(n)}),n.values==="fixed")for(const r of n.options??[]){const o=Zn(n.name,r.value);s.push({rank:gs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return ir(s)}function Fd(e,t,s){const n=t.trim().toLowerCase(),r=Ld(e,s).map(o=>({rank:gs(n,o.value,o.label),suggestion:{value:Zn(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return ir(r)}function Od(e,t,s={}){const n=Fs(e,t);if(n.name===void 0)return Dd(n.raw);const r=Xn(n.name);return r?Fd(r,n.value??"",s):[]}function zd(e,t,s){const n=Fs(e,t),r=!s.value.endsWith(":"),o=/\s/.test(e.slice(n.end,n.end+1)),i=r&&!o?`${s.value} `:s.value;return{query:e.slice(0,n.start)+i+e.slice(n.end),cursor:n.start+i.length+(r&&o?1:0)}}const _d=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),Ud=250,Kd=2;function Bd({query:e,cursor:t,enabled:s}){const{accounts:n}=ks(),{mailboxesByName:r}=ea(),o=r!==void 0,i=s?Ad(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",u=na(c,Ud),{data:v}=ee({...ys({query:{q:u,limit:or}}),enabled:u.length>=Kd}),h=ws({queries:n.map(g=>({...xt({path:{accountId:g.accountId}}),staleTime:1/0}))}),p=l.useMemo(()=>o?No(h.map(g=>g.data?.items??[]),n):[],[o,h,n]),m=l.useMemo(()=>To(n),[n]),b=l.useMemo(()=>(v?.items??[]).map(_d),[v]);return l.useMemo(()=>{if(!s)return[];const g=Od(e,t,{mailboxes:p,accounts:m,contacts:b});return o?g:g.filter(d=>d.value!=="in:")},[s,e,t,p,m,b,o])}const lr="remit.recentSearches",Qd=5;function bs(){try{const e=localStorage.getItem(lr);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Dn(e){const t=e.trim();if(!t)return bs();const s=[t,...bs().filter(n=>n!==t)].slice(0,Qd);try{localStorage.setItem(lr,JSON.stringify(s))}catch{return s}return s}const qd=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function Hd(e){const{spam:t}=Ra([...e]),s=new Map;for(const r of t)r.mailboxId&&s.set(r.mailboxId,(s.get(r.mailboxId)??0)+1);let n;for(const[r,o]of s)(!n||o>n.count)&&(n={mailboxId:r,count:o});return n}function rm({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:u,relatedResults:v,relatedLoading:h,onSelectSearchResult:p,searchResultsLabel:m="Top matches",relatedResultsLabel:b="Related",searchResultsInBody:g=!1,refreshControl:d}){const{accounts:f,resultFolderIndex:x,searchQuery:S,searchInput:y,onSearchChange:j,onSearchClear:E,searchViewKey:T}=ks(),O=ea(),$=Hn(),F=mo(),P=Eo(),[z,L]=l.useState(!1),[K,k]=l.useState(bs),I=po(),R=l.useRef(T);l.useEffect(()=>{R.current!==T&&(R.current=T,L(!1))},[T]);const[w,M]=l.useState(0),[C,_]=l.useState(!1),[U,ne]=l.useState(void 0),W=Bd({query:y,cursor:w,enabled:C&&y.trim().length>0}),Y=l.useCallback(se=>{const ye=zd(y,w,se);j(ye.query),ne({cursor:ye.cursor})},[y,w,j]),X=ho({count:W.length,onAccept:se=>{const ye=W[se];ye&&Y(ye)}}),{comboboxProps:ce,handleKeyDown:ie}=X,te=l.useMemo(()=>({comboboxProps:ce,onKeyDown:ie,onCaretChange:M,onFocusChange:_,...U?{caret:U}:{}}),[ce,ie,U]),H=X.open?a.jsx(xo,{id:X.listId,suggestions:W,activeIndex:X.activeIndex,optionId:X.optionId,onPick:Y,onHighlight:X.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,fe=y.trim().length>0,{mailboxesByName:xe,accountsByName:me}=O,pe=l.useMemo(()=>Ko(y,{mailboxesByName:xe,accountsByName:me}),[y,xe,me]),ve=pe.tokens.map(se=>({label:Jn(se),onRemove:()=>j(Bo(y,se))})),he=c??[],ge=v??[],Se=fe?[{id:"top",label:m,results:he},{id:"related",label:b,results:ge}]:[],Be=!(he.length+ge.length>0)&&(u===!0||h===!0),{scope:Q}=Mo(f),V=Jo({select:se=>se.matches}),ae=ui(V),B=di(V,Q,ae?x.get(ae)?.role:void 0),St=B.kind==="global"?Hd([...he,...ge]):void 0,ue=St?{kind:"global",onScopeToSpam:()=>$({to:"/mail/$mailboxId",params:{mailboxId:St.mailboxId},search:{q:S||void 0}})}:B,Ne=ge.length>0,Le=l.useMemo(()=>md(pe,{searchHadSemanticReach:Ne}),[pe,Ne]),st=fe?Le:void 0,re=fe?{onClick:()=>{L(!1),I("properties","search")},blockedReason:uc(Le)?void 0:go(Le.droppedFacets.map(se=>se.label))}:void 0,J=re?a.jsx(Aa,{...re}):null,Pe=qd({tier:P,hasLiveInput:fe,hasCommittedQuery:S.trim().length>0,bodyRendersCommittedResults:g}),Os=se=>{k(Dn(y)),p?.(se)},De=a.jsx($a,{value:y,sections:Se,loading:Be,onSelectResult:Os,tokens:ve,scope:ue}),nt=n===void 0,Qe=Pe?a.jsx("div",{className:"h-full overflow-y-auto",children:De}):null,at=Qe&&!nt?Qe:s,Fe=Qe&&nt?Qe:null,rt=Io(P),ot=rt&&(z||fe),it=l.useMemo(()=>({title:e,searchResults:Fe,makeFilterSlot:J,searchConversion:st,navSlot:F&&!F.showNavPane&&a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(fi,{className:"size-5"}),onClick:()=>F.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[t.toLocaleString()," unread"]}),a.jsx(Ws,{}),d]}),searchSlot:rt&&!ot&&a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(bo,{className:"size-5"}),onClick:()=>L(!0),"aria-label":"Search",className:"shrink-0"}),searchField:ot&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Gn,{value:y,onChange:j,onClear:E,globalFocusKey:!1,showClearButton:!1,suggest:te})}),a.jsx(q,{variant:"ghost",size:"touch",icon:a.jsx(Pt,{className:"size-5"}),onClick:()=>{E(),L(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(Ws,{})]})}),[e,t,F,rt,ot,y,j,E,te,Fe,J,st,d]);if(P==="phone"&&z){const se=ye=>{k(Dn(y)),L(!1),p?.(ye)};return a.jsxs(hs.Provider,{value:it,children:[a.jsx(Dl,{value:y,onChange:j,onClear:E,onCancel:()=>{L(!1),E()},filter:i,recentSearches:K,onPickRecent:j,makeFilter:re,sections:Se,loading:Be,onSelectResult:se,tokens:ve,scope:ue,suggest:te,suggestList:H}),r]})}return a.jsx(hs.Provider,{value:it,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[n?.(it),H,a.jsx("div",{className:"min-h-0 flex-1",children:at}),o,r]})})}export{jf as $,$f as A,If as B,Tl as C,Zf as D,am as E,za as F,Ef as G,Vf as H,Ls as I,Vt as J,Gf as K,Hf as L,Qf as M,Tf as N,Nf as O,Ed as P,Qa as Q,ku as R,Fl as S,wu as T,Su as U,Cu as V,Wf as W,Mf as X,Cf as Y,Lf as Z,qf as _,hl as a,Yf as a0,Xf as a1,em as a2,tm as a3,nm as a4,Jf as a5,Ra as a6,Hd as a7,sm as a8,kf as a9,qd as aa,Rl as ab,Kf as ac,xf as ad,kd as ae,rm as af,Ce as ag,we as ah,As as ai,bt as aj,vl as ak,yt as al,Es as am,ds as an,vf as ao,yf as ap,wf as aq,Bf as ar,sr as b,Ms as c,Sf as d,Ha as e,ml as f,_u as g,Of as h,Ff as i,_f as j,Df as k,Ku as l,pc as m,fl as n,Pf as o,zf as p,qu as q,Uf as r,ll as s,qa as t,Nd as u,Qu as v,Pc as w,Va as x,Rf as y,Af as z};
|