@remit/web-client-dist 0.0.133 → 0.0.135

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.
Files changed (39) hide show
  1. package/assets/{ComposeBody-4TZWUog_.js → ComposeBody-CXluR0mJ.js} +3 -3
  2. package/assets/{ErrorState-Qyr85Xyz.js → ErrorState-xuU2Ycex.js} +1 -1
  3. package/assets/{OnboardingWizard-DKci22gI.js → OnboardingWizard-DlBawZQa.js} +1 -1
  4. package/assets/{account-form-helpers-BYqkWlDo.js → account-form-helpers-C-R-t-TP.js} +1 -1
  5. package/assets/{accounts-CxuS8UEA.js → accounts-ADCcmorB.js} +1 -1
  6. package/assets/{advanced-owsjRzM5.js → advanced-CRu4UqDe.js} +1 -1
  7. package/assets/{appearance-ClCRIT2m.js → appearance-DDoSefIs.js} +1 -1
  8. package/assets/{avatar-C9jCQUO-.js → avatar-DO7vnPxY.js} +1 -1
  9. package/assets/{browser-ponyfill-DrrIHcTp.js → browser-ponyfill-FuWjKEd5.js} +1 -1
  10. package/assets/{circle-check-BKQBncbL.js → circle-check-C86Aiiep.js} +1 -1
  11. package/assets/{download-CkHRsDqJ.js → download-C1F8f8Cm.js} +1 -1
  12. package/assets/filters-B-QK-_x9.js +1 -0
  13. package/assets/{flagged-Bfbt5YNc.js → flagged-dNLl7pSz.js} +1 -1
  14. package/assets/{folder-BqRohEKt.js → folder-AERC-jiq.js} +1 -1
  15. package/assets/folders-D_SSE4kH.js +1 -0
  16. package/assets/index-CA8m1jib.js +1 -0
  17. package/assets/{index-ChxiTmNG.css → index-CIEsBq5i.css} +1 -1
  18. package/assets/index-DccQqmHT.js +295 -0
  19. package/assets/{index-xpekyoor.js → index-Ds6rm6WR.js} +1 -1
  20. package/assets/{kbd-0K2ewyTX.js → kbd-CJm0PdtR.js} +1 -1
  21. package/assets/mail-CGtAo1Ry.js +118 -0
  22. package/assets/{onboarding-D8K6TW2Z.js → onboarding-Dd5aSsGp.js} +1 -1
  23. package/assets/{rotate-ccw-0vqgrfBM.js → rotate-ccw-Vwe0kY7O.js} +1 -1
  24. package/assets/{senders-n4d8Kq6e.js → senders-d0E-TE0w.js} +1 -1
  25. package/assets/settings-epL7Dplk.js +1 -0
  26. package/assets/{settings-screen-BpTHue4P.js → settings-screen-CGcJfaFe.js} +1 -1
  27. package/assets/{suggested-vips-DCaVHu50.js → suggested-vips-DzhuY5XT.js} +1 -1
  28. package/assets/useCreateMailbox-C4OH6qHD.js +1 -0
  29. package/assets/{useDebouncedValue-Dv0RGxEO.js → useDebouncedValue-DZZtIlXe.js} +1 -1
  30. package/assets/{useRulePreview-3nagP4N4.js → useRulePreview-B7LWIphh.js} +1 -1
  31. package/assets/{useSignature-G8PIr3OM.js → useSignature-BuMCTh1I.js} +1 -1
  32. package/index.html +2 -2
  33. package/package.json +1 -1
  34. package/assets/filters-CeTEyrxS.js +0 -1
  35. package/assets/folders-DKp7WD2J.js +0 -1
  36. package/assets/index-CA0QigtD.js +0 -1
  37. package/assets/index-Do5QkG4r.js +0 -295
  38. package/assets/mail-CyYDTHI8.js +0 -118
  39. package/assets/settings-C00EEdZT.js +0 -1
@@ -0,0 +1,118 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ComposeBody-CXluR0mJ.js","assets/index-DccQqmHT.js","assets/index-CIEsBq5i.css","assets/useDebouncedValue-DZZtIlXe.js","assets/avatar-DO7vnPxY.js","assets/kbd-CJm0PdtR.js","assets/account-form-helpers-C-R-t-TP.js","assets/useSignature-BuMCTh1I.js","assets/useRulePreview-B7LWIphh.js","assets/ErrorState-xuU2Ycex.js","assets/format-B6Elex-n.js","assets/useCreateMailbox-C4OH6qHD.js","assets/rotate-ccw-Vwe0kY7O.js","assets/circle-check-C86Aiiep.js","assets/folder-AERC-jiq.js"])))=>i.map(i=>d[i]);
2
+ import{R as W,c as Od,r as c,a as ce,j as n,C as It,X as We,b as q,B as Y,d as it,S as Rt,e as ut,f as Gt,L as aa,g as Pd,h as Qs,i as st,T as nt,k as Xt,u as Kn,l as oa,m as Yi,I as ia,p as Gi,n as la,o as Ld,D as ca,q as Ys,O as $d,M as Fd,A as zd,F as Xi,s as _d,t as Bd,v as Kd,w as Ud,x as ua,y as Ji,z as da,P as qd,E as Hd,G as fa,H as ma,_ as kt,J as Zi,K as Wd,Q as ha,N as Vd,U as Qd,V as Yd,W as Br,Y as Gd,Z as Xd,$ as we,a0 as Jd,a1 as Zd,a2 as ef,a3 as tf,a4 as sf,a5 as nf,a6 as yo,a7 as rf,a8 as af,a9 as of,aa as pa,ab as el,ac as tl,ad as Mt,ae as Oe,af as ze,ag as Gs,ah as xe,ai as ga,aj as xa,ak as ba,al as va,am as Un,an as bs,ao as Ce,ap as Xs,aq as de,ar as sl,as as lf,at as ye,au as nl,av as cf,aw as qn,ax as rl,ay as xt,az as Je,aA as uf,aB as lt,aC as al,aD as Vt,aE as Hn,aF as df,aG as ya,aH as ol,aI as il,aJ as Jt,aK as Wn,aL as Zt,aM as ff,aN as mf,aO as Vn,aP as hf,aQ as ll,aR as vs,aS as pf,aT as wa,aU as gf,aV as xf,aW as cl,aX as ja,aY as ul,aZ as dl,a_ as Ss,a$ as pt,b0 as Kr,b1 as Ur,b2 as bf,b3 as fl,b4 as vf,b5 as Sa,b6 as ml,b7 as yf,b8 as wf,b9 as jf,ba as Sf,bb as kf,bc as Cf,bd as Nf,be as Ef,bf as If,bg as Tf,bh as Rf,bi as Mf,bj as Af,bk as Df,bl as jt,bm as ht,bn as Of}from"./index-DccQqmHT.js";import{S as Js,u as hl}from"./useDebouncedValue-DZZtIlXe.js";import{A as dt,M as ka,C as Pf}from"./avatar-DO7vnPxY.js";import{K as ps}from"./kbd-CJm0PdtR.js";import{M as pl,a as Lf}from"./account-form-helpers-C-R-t-TP.js";import{R as $f,u as Ff}from"./useSignature-BuMCTh1I.js";import{B as gl,u as At,b as Zs,a as wo,c as qr,n as zf,S as Ca,d as xl,r as Na,e as bl,f as vl,g as yl,h as _f,i as Bf,j as Kf,k as Uf}from"./useRulePreview-B7LWIphh.js";import{E as Dt,f as wl}from"./ErrorState-xuU2Ycex.js";import{f as jl,a as Ot,b as Sl,c as Pn,d as ct,t as qf}from"./format-B6Elex-n.js";import{u as kl}from"./useCreateMailbox-C4OH6qHD.js";import{C as Ea,R as Hf}from"./rotate-ccw-Vwe0kY7O.js";import{C as Ia}from"./circle-check-C86Aiiep.js";import{F as Wf}from"./folder-AERC-jiq.js";function Ks(e){if(Vf())e.focus({preventScroll:!0});else{let t=Qf(e);e.focus(),Yf(t)}}let xn=null;function Vf(){if(xn==null){xn=!1;try{document.createElement("div").focus({get preventScroll(){return xn=!0,!0}})}catch{}}return xn}function Qf(e){let t=e.parentNode,s=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&s.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),s}function Yf(e){for(let{element:t,scrollTop:s,scrollLeft:r}of e)t.scrollTop=s,t.scrollLeft=r}const Nt=e=>e?.ownerDocument??document,Tt=e=>e&&"window"in e&&e.window===e?e:Nt(e).defaultView||window;function Gf(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function Xf(e){return Gf(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Jf=!1;function Cl(){return Jf}function at(e,t){if(!Cl())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:Xf(s)?s=s.host:s=s.parentNode}return!1}function Me(e){if(Cl()&&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 Zf=typeof Element<"u"&&"checkVisibility"in Element.prototype;function em(e){const t=Tt(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:r}=e.style,a=s!=="none"&&r!=="hidden"&&r!=="collapse";if(a){const{getComputedStyle:o}=Tt(e);let{display:i,visibility:l}=o(e);a=i!=="none"&&l!=="hidden"&&l!=="collapse"}return a}function tm(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 Nl(e,t){return Zf?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&em(e)&&tm(e,t)&&(!e.parentElement||Nl(e.parentElement,e))}const El=["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"],sm=El.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";El.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function nm(e,t){return e.matches(sm)&&!rm(e)&&(t?.skipVisibilityCheck||Nl(e))}function rm(e){let t=e;for(;t!=null;){if(t instanceof Tt(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Ta=typeof document<"u"?W.useLayoutEffect:()=>{};function am(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function om(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function im(e){for(;e&&!nm(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Tt(e),s=t.document.activeElement;if(!s||s===e)return;let r=!1,a=d=>{(Me(d)===s||r)&&d.stopImmediatePropagation()},o=d=>{(Me(d)===s||r)&&(d.stopImmediatePropagation(),!e&&!r&&(r=!0,Ks(s),u()))},i=d=>{(Me(d)===e||r)&&d.stopImmediatePropagation()},l=d=>{(Me(d)===e||r)&&(d.stopImmediatePropagation(),r||(r=!0,Ks(s),u()))};t.addEventListener("blur",a,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",l,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(f),t.removeEventListener("blur",a,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",l,!0),t.removeEventListener("focus",i,!0),r=!1},f=requestAnimationFrame(u);return u}function Qn(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 Ra(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Pt(e){let t=null;return()=>(t==null&&(t=e()),t)}const Ln=Pt(function(){return Ra(/^Mac/i)}),lm=Pt(function(){return Ra(/^iPhone/i)}),Il=Pt(function(){return Ra(/^iPad/i)||Ln()&&navigator.maxTouchPoints>1}),Tl=Pt(function(){return lm()||Il()}),cm=Pt(function(){return Qn(/AppleWebKit/i)&&!um()}),um=Pt(function(){return Qn(/Chrome/i)}),Rl=Pt(function(){return Qn(/Android/i)}),dm=Pt(function(){return Qn(/Firefox/i)});function fm(e){return e.pointerType===""&&e.isTrusted?!0:Rl()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function mm(e){return!Rl()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function Us(e,t,s=!0){let{metaKey:r,ctrlKey:a,altKey:o,shiftKey:i}=t;dm()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(Ln()?r=!0:a=!0);let l=cm()&&Ln()&&!Il()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:a,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:r,ctrlKey:a,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});Us.isOpening=s,Ks(e),e.dispatchEvent(l),Us.isOpening=!1}Us.isOpening=!1;let Ct=new Map,Hr=new Set;function jo(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{let a=Me(r);if(!e(r)||!a)return;let o=Ct.get(a);o||(o=new Set,Ct.set(a,o),a.addEventListener("transitioncancel",s,{once:!0})),o.add(r.propertyName)},s=r=>{let a=Me(r);if(!e(r)||!a)return;let o=Ct.get(a);if(o&&(o.delete(r.propertyName),o.size===0&&(a.removeEventListener("transitioncancel",s),Ct.delete(a)),Ct.size===0)){for(let i of Hr)i();Hr.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?jo():document.addEventListener("DOMContentLoaded",jo));function hm(){for(const[e]of Ct)"isConnected"in e&&!e.isConnected&&Ct.delete(e)}function pm(e){requestAnimationFrame(()=>{hm(),Ct.size===0?e():Hr.add(e)})}function Ml(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let Wr=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{Wr.delete(e)});function gm(e,t){if(e===t)return e;let s=Wr.get(e);if(s)return s.forEach(a=>a.current=t),t;let r=Wr.get(t);return r?(r.forEach(a=>a.current=e),e):t}function xm(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const r=e.map(a=>{const o=So(a,t);return s||=typeof o=="function",o});if(s)return()=>{r.forEach((a,o)=>{typeof a=="function"?a():So(e[o],null)})}}}function So(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function en(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let r=e[s];for(let a in r){let o=t[a],i=r[a];typeof o=="function"&&typeof i=="function"&&a[0]==="o"&&a[1]==="n"&&a.charCodeAt(2)>=65&&a.charCodeAt(2)<=90?t[a]=Ml(o,i):(a==="className"||a==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[a]=Od(o,i):a==="id"&&o&&i?t.id=gm(o,i):a==="ref"&&o&&i?t.ref=xm(o,i):t[a]=i!==void 0?i:o}}return t}function bm(e,t){Ta(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const vm=W.useInsertionEffect??Ta;function br(e){const t=c.useRef(null);return vm(()=>{t.current=e},[e]),c.useCallback((...s)=>{const r=t.current;return r?.(...s)},[])}let ms="default",Vr="",Rn=new WeakMap;function ym(e){if(Tl()){if(ms==="default"){const t=Nt(e);Vr=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}ms="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";Rn.set(e,e.style[t]),e.style[t]="none"}}function ko(e){if(Tl()){if(ms!=="disabled")return;ms="restoring",setTimeout(()=>{pm(()=>{if(ms==="restoring"){const t=Nt(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=Vr||""),Vr="",ms="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Rn.has(e)){let t=Rn.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),Rn.delete(e)}}function Co(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let vr=new WeakMap;function wm(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return Co(t);if(vr.has(t))return vr.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),r=s&&s instanceof Tt(s).HTMLMetaElement&&(s.nonce||s.content)||Co(t)||void 0;return r!==void 0&&vr.set(t,r),r}const Al=W.createContext({register:()=>{}});Al.displayName="PressResponderContext";function Dl(){let e=c.useRef(new Map),t=c.useCallback((a,o,i,l)=>{let u=l?.once?(...f)=>{e.current.delete(i),i(...f)}:i;e.current.set(i,{type:o,eventTarget:a,fn:u,options:l}),a.addEventListener(o,u,l)},[]),s=c.useCallback((a,o,i,l)=>{let u=e.current.get(i)?.fn||i;a.removeEventListener(o,u,l),e.current.delete(i)},[]),r=c.useCallback(()=>{e.current.forEach((a,o)=>{s(a.eventTarget,a.type,o,a.options)})},[s]);return c.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:r}}function jm(e){let t=c.useContext(Al);if(t){let{register:s,ref:r,...a}=t;e=en(a,e),s()}return bm(t,e.ref),e}class bn{#s;constructor(t,s,r,a){this.#s=!0;const i=(a?.target??r.currentTarget)?.getBoundingClientRect();let l,u=0,f,d=null;r.clientX!=null&&r.clientY!=null&&(f=r.clientX,d=r.clientY),i&&(f!=null&&d!=null?(l=f-i.left,u=d-i.top):(l=i.width/2,u=i.height/2)),this.type=t,this.pointerType=s,this.target=r.currentTarget,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.x=l,this.y=u,this.key=r.key}continuePropagation(){this.#s=!1}get shouldStopPropagation(){return this.#s}}const No=Symbol("linkClicked"),Eo="react-aria-pressable-style",Io="data-react-aria-pressable";function Sm(e){let{onPress:t,onPressChange:s,onPressStart:r,onPressEnd:a,onPressUp:o,onClick:i,isDisabled:l,isPressed:u,preventFocusOnPress:f,shouldCancelOnPointerExit:d,allowTextSelectionOnPress:m,ref:h,...g}=jm(e),[b,p]=c.useState(!1),v=c.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:y}=Dl(),j=c.useCallback((S,A)=>{let L=v.current;if(l||L.didFirePressStart)return!1;let T=!0;if(L.isTriggeringEvent=!0,r){let F=new bn("pressstart",A,S);r(F),T=F.shouldStopPropagation}return s&&s(!0),L.isTriggeringEvent=!1,L.didFirePressStart=!0,p(!0),T},[l,r,s]),w=c.useCallback((S,A,L=!0)=>{let T=v.current;if(!T.didFirePressStart)return!1;T.didFirePressStart=!1,T.isTriggeringEvent=!0;let F=!0;if(a){let M=new bn("pressend",A,S);a(M),F=M.shouldStopPropagation}if(s&&s(!1),p(!1),t&&L&&!l){let M=new bn("press",A,S);t(M),F&&=M.shouldStopPropagation}return T.isTriggeringEvent=!1,F},[l,a,s,t]),N=br(w),E=c.useCallback((S,A)=>{let L=v.current;if(l)return!1;if(o){L.isTriggeringEvent=!0;let T=new bn("pressup",A,S);return o(T),L.isTriggeringEvent=!1,T.shouldStopPropagation}return!0},[l,o]),C=br(E),k=c.useCallback(S=>{let A=v.current;if(A.isPressed&&A.target){A.didFirePressStart&&A.pointerType!=null&&w(Ut(A.target,S),A.pointerType,!1),A.isPressed=!1,A.isOverTarget=!1,A.activePointerId=null,A.pointerType=null,y(),m||ko(A.target);for(let L of A.disposables)L();A.disposables=[]}},[m,y,w]),R=br(k);c.useEffect(()=>{l&&v.current.isPressed&&R({currentTarget:v.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[l]);let O=c.useCallback(S=>{d&&k(S)},[d,k]),D=c.useCallback(S=>{l||i?.(S)},[l,i]),P=c.useCallback((S,A)=>{if(!l&&i){let L=new MouseEvent("click",S);om(L,A),i(am(L))}},[l,i]),I=c.useMemo(()=>{let S=v.current,A={onKeyDown(T){if(yr(T.nativeEvent,T.currentTarget)&&at(T.currentTarget,Me(T))){To(Me(T),T.key)&&T.preventDefault();let F=!0;!S.isPressed&&!T.repeat&&(S.target=T.currentTarget,S.isPressed=!0,S.pointerType="keyboard",F=j(T,"keyboard"));let M=T.currentTarget,$=K=>{yr(K,M)&&!K.repeat&&at(M,Me(K))&&S.target&&C(Ut(S.target,K),"keyboard")};x(Nt(T.currentTarget),"keyup",Ml($,L),!0),F&&T.stopPropagation(),T.metaKey&&Ln()&&S.metaKeyEvents?.set(T.key,T.nativeEvent)}else T.key==="Meta"&&(S.metaKeyEvents=new Map)},onClick(T){if(!(T&&!at(T.currentTarget,Me(T)))&&T&&T.button===0&&!S.isTriggeringEvent&&!Us.isOpening){let F=!0;if(l&&T.preventDefault(),!S.ignoreEmulatedMouseEvents&&!S.isPressed&&(S.pointerType==="virtual"||fm(T.nativeEvent))){let M=j(T,"virtual"),$=C(T,"virtual"),K=N(T,"virtual");D(T),F=M&&$&&K}else if(S.isPressed&&S.pointerType!=="keyboard"){let M=S.pointerType||T.nativeEvent.pointerType||"virtual",$=C(Ut(T.currentTarget,T),M),K=N(Ut(T.currentTarget,T),M,!0);F=$&&K,S.isOverTarget=!1,D(T),R(T)}S.ignoreEmulatedMouseEvents=!1,F&&T.stopPropagation()}}},L=T=>{if(S.isPressed&&S.target&&yr(T,S.target)){To(Me(T),T.key)&&T.preventDefault();let F=Me(T),M=at(S.target,F);N(Ut(S.target,T),"keyboard",M),M&&P(T,S.target),y(),T.key!=="Enter"&&Ma(S.target)&&at(S.target,F)&&!T[No]&&(T[No]=!0,Us(S.target,T,!1)),S.isPressed=!1,S.metaKeyEvents?.delete(T.key)}else if(T.key==="Meta"&&S.metaKeyEvents?.size){let F=S.metaKeyEvents;S.metaKeyEvents=void 0;for(let M of F.values())S.target?.dispatchEvent(new KeyboardEvent("keyup",M))}};if(typeof PointerEvent<"u"){A.onPointerDown=M=>{if(M.button!==0||!at(M.currentTarget,Me(M)))return;if(mm(M.nativeEvent)){S.pointerType="virtual";return}S.pointerType=M.pointerType;let $=!0;if(!S.isPressed){S.isPressed=!0,S.isOverTarget=!0,S.activePointerId=M.pointerId,S.target=M.currentTarget,m||ym(S.target),$=j(M,S.pointerType);let K=Me(M);"releasePointerCapture"in K&&("hasPointerCapture"in K?K.hasPointerCapture(M.pointerId)&&K.releasePointerCapture(M.pointerId):K.releasePointerCapture(M.pointerId)),x(Nt(M.currentTarget),"pointerup",T,!1),x(Nt(M.currentTarget),"pointercancel",F,!1)}$&&M.stopPropagation()},A.onMouseDown=M=>{if(at(M.currentTarget,Me(M))&&M.button===0){if(f){let $=im(M.target);$&&S.disposables.push($)}M.stopPropagation()}},A.onPointerUp=M=>{!at(M.currentTarget,Me(M))||S.pointerType==="virtual"||M.button===0&&!S.isPressed&&C(M,S.pointerType||M.pointerType)},A.onPointerEnter=M=>{M.pointerId===S.activePointerId&&S.target&&!S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!0,j(Ut(S.target,M),S.pointerType))},A.onPointerLeave=M=>{M.pointerId===S.activePointerId&&S.target&&S.isOverTarget&&S.pointerType!=null&&(S.isOverTarget=!1,N(Ut(S.target,M),S.pointerType,!1),O(M))};let T=M=>{if(M.pointerId===S.activePointerId&&S.isPressed&&M.button===0&&S.target){if(at(S.target,Me(M))&&S.pointerType!=null){let $=!1,K=setTimeout(()=>{S.isPressed&&S.target instanceof HTMLElement&&($?R(M):(Ks(S.target),S.target.click()))},80);x(M.currentTarget,"click",()=>$=!0,!0),S.disposables.push(()=>clearTimeout(K))}else R(M);S.isOverTarget=!1}},F=M=>{R(M)};A.onDragStart=M=>{at(M.currentTarget,Me(M))&&R(M)}}return A},[x,l,f,y,m,O,j,D,P]);return c.useEffect(()=>{if(!h)return;const S=Nt(h.current);if(!S||!S.head||S.getElementById(Eo))return;const A=S.createElement("style");A.id=Eo;let L=wm(S);L&&(A.nonce=L),A.textContent=`
3
+ @layer {
4
+ [${Io}] {
5
+ touch-action: pan-x pan-y pinch-zoom;
6
+ }
7
+ }
8
+ `.trim(),S.head.prepend(A)},[h]),c.useEffect(()=>{let S=v.current;return()=>{m||ko(S.target??void 0);for(let A of S.disposables)A();S.disposables=[]}},[m]),{isPressed:u||b,pressProps:en(g,I,{[Io]:!0})}}function Ma(e){return e.tagName==="A"&&e.hasAttribute("href")}function yr(e,t){const{key:s,code:r}=e,a=t,o=a.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||r==="Space")&&!(a instanceof Tt(a).HTMLInputElement&&!Ol(a,s)||a instanceof Tt(a).HTMLTextAreaElement||a.isContentEditable)&&!((o==="link"||!o&&Ma(a))&&s!=="Enter")}function Ut(e,t){let s=t.clientX,r=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:r,key:t.key}}function km(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Ma(e)}function To(e,t){return e instanceof HTMLInputElement?!Ol(e,t):km(e)}const Cm=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Ol(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":Cm.has(e.type)}let Nm=0;const wr=new Map;function Em(e){let[t,s]=c.useState();return Ta(()=>{if(!e)return;let r=wr.get(e);if(r)s(r.element.id);else{let a=`react-aria-description-${Nm++}`;s(a);let o=document.createElement("div");o.id=a,o.style.display="none",o.textContent=e,document.body.appendChild(o),r={refCount:0,element:o},wr.set(e,r)}return r.refCount++,()=>{r&&--r.refCount===0&&(r.element.remove(),wr.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const Im=500;function Tm(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:r,onLongPress:a,threshold:o=Im,accessibilityDescription:i}=e;const l=c.useRef(void 0);let{addGlobalListener:u,removeGlobalListener:f}=Dl(),{pressProps:d}=Sm({isDisabled:t,onPressStart(h){if(h.continuePropagation(),(h.pointerType==="mouse"||h.pointerType==="touch")&&(s&&s({...h,type:"longpressstart"}),l.current=setTimeout(()=>{h.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Nt(h.target).activeElement!==h.target&&Ks(h.target),a&&a({...h,type:"longpress"}),l.current=void 0},o),h.pointerType==="touch")){let g=p=>{p.preventDefault()},b=Tt(h.target);u(h.target,"contextmenu",g,{once:!0}),u(b,"pointerup",()=>{setTimeout(()=>{f(h.target,"contextmenu",g)},30)},{once:!0})}},onPressEnd(h){l.current&&clearTimeout(l.current),r&&(h.pointerType==="mouse"||h.pointerType==="touch")&&r({...h,type:"longpressend"})}}),m=Em(a&&!t?i:void 0);return{longPressProps:en(d,m)}}const Pl=ce("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const Rm=ce("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const Mm=ce("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const Yn=ce("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 Am=ce("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);const Ll=ce("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);const Dm=ce("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);const Ro=ce("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);const ys=ce("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Om=ce("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const $l=ce("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const Fl=ce("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const zl=ce("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const Pm=ce("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);const Aa=ce("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);const _l=ce("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 Bl=ce("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const Lm=ce("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 ks=ce("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 $m=ce("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 Fm=ce("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Gn=ce("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 zm=ce("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const Kl=ce("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const Ul=ce("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 ql=ce("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 Da=ce("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Cs=ce("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 tn=ce("ShieldCheck",[["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 12 2 2 4-4",key:"dzmm74"}]]);const _m=ce("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 Bm=ce("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);const Km=ce("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const Um=ce("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),qm=({address:e,showTrustedBadge:t=!1})=>{const s=t?n.jsx(Yn,{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?n.jsxs("span",{children:[n.jsx("span",{className:"text-fg",children:e.displayName}),n.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):n.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},Hm=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[r,a]=c.useState(!1);if(t.length===0)return null;const o=t.length>3,i=l=>{const u=s&&l.flags?.trusted?.value===!0;return n.jsx(qm,{address:l,showTrustedBadge:u})};return n.jsxs("div",{className:"flex gap-2 text-sm",children:[n.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),n.jsx("div",{className:"flex-1 min-w-0",children:r?n.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((l,u)=>n.jsxs("span",{children:[i(l),u<t.length-1&&", "]},u))}):n.jsx("div",{className:"truncate",children:t.map((l,u)=>n.jsxs("span",{children:[i(l),u<t.length-1&&", "]},u))})}),o&&n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),a(!r)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":r?"Collapse":"Expand",children:r?n.jsx(It,{className:"h-4 w-4"}):n.jsx(ys,{className:"h-4 w-4"})})]})},Wm=({email:e,displayName:t,onRemove:s,className:r})=>n.jsxs("span",{className:q("inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent-2-soft text-sm max-w-[200px]",r),children:[n.jsx("span",{className:"truncate",children:t||e}),n.jsx("button",{type:"button",onClick:s,className:"shrink-0 p-0.5 rounded-full hover:bg-fg-muted/20 transition-colors","aria-label":`Remove ${e}`,children:n.jsx(We,{className:"size-3"})})]}),Vm={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function as({label:e,children:t,className:s}){return n.jsxs("section",{className:q("border-b border-line px-row-inset py-3",s),children:[n.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),n.jsx("div",{className:"mt-2",children:t})]})}function Qm({sender:e}){const t=Vm[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 n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(dt,{name:e.name,email:e.email,size:"md"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),n.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),n.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?n.jsx(it,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):n.jsx(it,{tone:t.tone,dot:!0,children:t.label})}),n.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function Ym({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return n.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[n.jsx(tn,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),n.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return n.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[n.jsx(_m,{className:"mt-0.5 size-4 shrink-0"}),n.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 n.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Cs,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),n.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&n.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",n.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",n.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&n.jsxs(Y,{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 os({icon:e,label:t,active:s,danger:r,onClick:a}){const o=a===void 0;return n.jsxs("button",{type:"button",onClick:a,disabled:o,className:q("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",r&&!s&&"text-danger hover:bg-danger-soft",o&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const Gm={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function Hl({data:e,onClose:t,onShowSimilar:s,actions:r,similarState:a="ready",similarLinkComponent:o,className:i,hideCloseButton:l=!1}){const{sender:u,authenticity:f,category:d,flags:m={},similar:h}=e,g=f.verdict==="mismatch";return n.jsxs("aside",{className:q("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!l&&n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(We,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),n.jsx(as,{label:"Sender",children:n.jsx(Qm,{sender:u})}),n.jsx(as,{label:"Authenticity",children:n.jsx(Ym,{auth:f,onShowSimilar:s})}),n.jsx(as,{label:"Category",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(it,{tone:g?"danger":"neutral",children:d.value}),d.overridden&&n.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),n.jsx("button",{type:"button",className:q("ml-auto text-2xs text-accent hover:underline",!r?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!r?.onReclassify,onClick:r?.onReclassify,children:"reclassify"})]})}),n.jsx(as,{label:"Quick actions",children:n.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[n.jsx(os,{icon:n.jsx(Rt,{className:"size-3.5"}),label:"VIP",active:m.vip,onClick:r?.onToggleVip}),n.jsx(os,{icon:n.jsx(Ll,{className:"size-3.5"}),label:"Mute",active:m.muted,onClick:r?.onToggleMute}),n.jsx(os,{icon:n.jsx(Am,{className:"size-3.5"}),label:"Block",active:m.blocked,danger:!0,onClick:r?.onToggleBlock}),n.jsx(os,{icon:n.jsx($m,{className:"size-3.5"}),label:"Unsubscribe",active:m.unsubscribed,onClick:r?.onToggleUnsubscribe}),r?.onNotSpam&&n.jsx(os,{icon:n.jsx(Lm,{className:"size-3.5"}),label:"Not spam",onClick:r.onNotSpam}),r?.onMarkSpam&&n.jsx(os,{icon:n.jsx(Bm,{className:"size-3.5"}),label:"Mark spam",danger:!0,onClick:r.onMarkSpam})]})}),(a!=="ready"||h.length>0)&&n.jsx(as,{label:"Similar messages",children:a==="loading"?n.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((b,p)=>n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),n.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},p))}):a==="error"?n.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):n.jsx("ul",{className:"-mx-1 space-y-1",children:h.map(b=>{const p="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",v=`Open message from ${b.fromName||"unknown sender"}: ${b.subject}`,x=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("span",{className:"truncate text-xs font-medium text-fg",children:b.fromName}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:b.timeLabel})]}),n.jsx("div",{className:"truncate text-xs text-fg-muted",children:b.subject}),n.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:Gm[b.matched]})]});return n.jsx("li",{children:o?o({mailboxId:b.mailboxId,messageId:b.id,className:p,ariaLabel:v,children:x}):n.jsx("div",{className:p,children:x})},b.id)})})}),n.jsx(as,{label:"Coming soon",className:"border-b-0 opacity-70",children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[n.jsx(ut,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),n.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),n.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[n.jsx(ut,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),n.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const Xm=[{keys:["j","k"],label:"navigate"},{keys:["m"],label:"mute"},{keys:["?"],label:"all shortcuts"}];function Wl({hints:e=Xm,className:t}){return n.jsx("footer",{className:q("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>n.jsx(Jm,{hint:s},s.label))})}function Jm({hint:e}){return n.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>n.jsx(ps,{children:t},t)),n.jsx("span",{children:e.label})]})}function Zm(){return n.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((e,t)=>n.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),n.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),n.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),n.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},t))})}function eh({searchQuery:e}){const t=!!e?.trim();return n.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:n.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:n.jsx("p",{className:"text-fg-muted",children:t?"No messages match your search":"No messages in this mailbox"})})})}function th({message:e="Something went wrong loading this mailbox.",onRetry:t,onReport:s}){return n.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:n.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[n.jsx(Gt,{className:"size-8 text-danger","aria-hidden":"true"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),n.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:e})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[t&&n.jsx(Y,{variant:"secondary",size:"sm",onClick:t,children:"Retry"}),s&&n.jsx(Y,{variant:"ghost",size:"sm",onClick:s,children:"Report a problem"})]})]})})}const Vl="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ql=({active:e,focused:t})=>q("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",Vl,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"),sn=({active:e,focused:t})=>q("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",Vl,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 Yl({thread:e}){const t=!e.isRead;return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?n.jsx(Cs,{className:"size-3.5 text-danger"}):e.starred?n.jsx(Rt,{className:"size-3 fill-warning text-warning"}):t?n.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),n.jsx("span",{className:q("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),n.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[n.jsx("span",{className:q(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),n.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&n.jsx(Gn,{className:"size-3 shrink-0 text-fg-subtle"}),n.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function qs({thread:e,badge:t}){const s=!e.isRead;return n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[n.jsxs("span",{className:q("flex min-w-0 items-center gap-1.5 truncate text-sm",s?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&n.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),n.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&n.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:q("truncate text-sm",s?"text-fg":"text-fg-muted"),children:e.subject}),e.suspicious&&n.jsx(Cs,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&n.jsx(Rt,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&n.jsx(Gn,{className:"size-3 shrink-0 text-fg-subtle"})]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:e.snippet}),e.category&&e.category!=="personal"&&n.jsx(it,{tone:Pd[e.category],className:"shrink-0",children:e.category}),t]})]})}function sh({thread:e,selection:t}){if(!t)return n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:r}=t;return n.jsxs("span",{className:"relative size-7 shrink-0",children:[n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"sm",className:q("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||r)&&"opacity-0")}),n.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),a.stopPropagation(),t.onToggle(a))},className:q("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",r?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":r?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&n.jsx(Qs,{className:"size-3"})})]})}function Gl({thread:e,selection:t,badge:s}){const r=!e.isRead;return n.jsxs(n.Fragment,{children:[r&&n.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),n.jsx(sh,{thread:e,selection:t}),n.jsx(qs,{thread:e,badge:s})]})}function nh({thread:e,active:t,focused:s,onClick:r}){return n.jsx("button",{type:"button",...aa,onClick:r,className:Ql({active:t,focused:s}),children:n.jsx(Yl,{thread:e})})}function rh({thread:e,active:t,focused:s,selection:r,onClick:a}){return n.jsx("button",{type:"button",...aa,onClick:a,className:q("group",sn({active:t,focused:s})),children:n.jsx(Gl,{thread:e,selection:r})})}const ah="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",Mo="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function nn({label:e,description:t,indeterminate:s=!1,checked:r,onChange:a,className:o,...i}){const l=c.useRef(null);c.useEffect(()=>{l.current&&(l.current.indeterminate=s)},[s]);const u=n.jsxs("span",{className:"relative inline-flex",children:[n.jsx("input",{ref:l,type:"checkbox",checked:r,onChange:a,className:ah,...i}),n.jsx(Qs,{className:q(Mo,"hidden peer-checked:block"),"aria-hidden":!0}),n.jsx(Fm,{className:q(Mo,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?n.jsx("span",{className:o,children:u}):n.jsxs("label",{className:q("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[u,n.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&n.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&n.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}const oh={info:"bg-accent-2",success:"bg-positive",warning:"bg-warning",danger:"bg-danger"};function Oa({value:e,max:t,tone:s="info",indeterminate:r=!1,className:a}){const o=r?100:t<=0?0:Math.min(100,Math.max(0,e/t*100));return n.jsx("div",{role:"progressbar","aria-valuenow":r?void 0:e,"aria-valuemin":r?void 0:0,"aria-valuemax":r?void 0:t,className:q("h-1.5 w-full overflow-hidden rounded-full bg-surface-sunken",a),children:n.jsx("div",{className:q("h-full rounded-full transition-[width] duration-300 ease-out",oh[s],r&&"w-1/3 animate-pulse"),style:r?void 0:{width:`${o}%`}})})}const Ao=e=>e.toLocaleString();function ih({count:e,onCancel:t,onMarkRead:s,onDelete:r,moveSlot:a,isBusy:o=!1,isCounting:i=!1,selectAll:l,statusLabel:u,progress:f,notice:d}){const m=l?.checked?`All ${Ao(e)} loaded selected`:`${Ao(e)} ${e===1?"message":"messages"} selected`;return n.jsxs("header",{className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[n.jsxs("div",{className:"flex h-pane-header items-center gap-2 px-row-inset",children:[n.jsx(Y,{variant:"ghost",size:"touch",icon:n.jsx(We,{className:"size-4"}),onClick:t,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}),l&&n.jsx("label",{className:"-ml-1.5 flex size-11 shrink-0 cursor-pointer items-center justify-center",children:n.jsx(nn,{"aria-label":"Select all",checked:l.checked,indeterminate:l.indeterminate,onChange:l.onChange})}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-fg",role:"status","aria-live":"polite",children:u??m}),s&&!o&&n.jsx(Y,{variant:"ghost",size:"touch",icon:n.jsx(ks,{className:"size-4"}),onClick:s,"aria-label":"Mark as read",className:"shrink-0"}),a,!i&&n.jsx(Y,{variant:"ghost",size:"touch",icon:o?n.jsx(st,{className:"size-4 animate-spin"}):n.jsx(nt,{className:"size-4 text-danger"}),onClick:o?void 0:r,"aria-label":"Move selected messages to Trash","aria-busy":o||void 0,className:"ml-4 shrink-0"})]}),f&&n.jsx("div",{className:"px-row-inset pb-2",children:n.jsx(Oa,{value:f.value,max:f.max,tone:f.tone})}),d&&n.jsx(Xt,{tone:d.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.text&&n.jsx("span",{children:d.text}),d.action&&n.jsx(Y,{variant:"ghost",size:"md",onClick:d.action.onClick,className:"-my-1 min-h-11 shrink-0",children:d.action.label})]})})]})}function Xl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:r}){return Tm({isDisabled:t,threshold:s,accessibilityDescription:r,onLongPress:e})}const ws=72,Do=10,Oo="__swipeableRowAxisCancel";function Po(e){return e==="leading"?ws:e==="trailing"?-ws:0}function lh(e){return e>=ws/2?"leading":e<=-ws/2?"trailing":"none"}function Jl({thread:e,selectionMode:t,checked:s,active:r,peek:a,onPeek:o,onToggleCheck:i,onLongPress:l,onOpen:u,onAct:f,linkComponent:d}){const m=c.useRef(null),[h,g]=c.useState(null),{longPressProps:b}=Xl({onLongPress:l,isDisabled:t,accessibilityDescription:"Select message"}),p=I=>{const S=new PointerEvent("pointercancel",{bubbles:!0});S[Oo]=!0,I.currentTarget.dispatchEvent(S)},w=en(b,{onPointerDown:I=>{m.current={startX:I.clientX,startY:I.clientY,axis:"none",moved:!1}},onPointerMove:I=>{if(t)return;const S=m.current;if(!S)return;const A=I.clientX-S.startX,L=I.clientY-S.startY;if(S.axis==="none"){if(Math.abs(L)>Do&&Math.abs(L)>Math.abs(A)){S.axis="vertical",p(I),m.current=null;return}Math.abs(A)>Do&&(S.axis="horizontal",S.moved=!0,p(I),I.currentTarget.setPointerCapture(I.pointerId))}if(S.axis!=="horizontal")return;const T=Po(a),F=Math.max(-ws,Math.min(ws,T+A));g(F)},onPointerUp:()=>{const I=m.current;m.current=null;const S=h;if(g(null),!!I){if(I.axis==="horizontal"&&S!==null){o(lh(S));return}if(t){i();return}if(a!=="none"){o("none");return}d||u()}},onPointerCancel:I=>{I.nativeEvent[Oo]||(m.current=null,g(null))}}),N=I=>{a!=="none"&&I.preventDefault()},E=h??Po(a),C=E>0?"leading":E<0?"trailing":"none",k=q("relative touch-pan-y bg-surface","select-none [-webkit-touch-callout:none]",sn({active:s||r})),R={transform:E!==0?`translateX(${E}px)`:void 0,transition:h===null?"transform 150ms ease":"none",minHeight:44},O=!e.isRead,D=I=>I.stopPropagation(),P=t?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",s?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:s&&n.jsx(Qs,{className:"size-3.5"})}),n.jsx(qs,{thread:e})]}):n.jsxs(n.Fragment,{children:[O&&n.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),n.jsx("button",{type:"button",role:"checkbox","aria-checked":s,"aria-label":`Select message from ${e.fromName}`,onPointerDown:D,onPointerMove:D,onPointerUp:D,onClick:I=>{I.preventDefault(),I.stopPropagation(),l()},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"sm"})}),n.jsx(qs,{thread:e})]});return n.jsxs("div",{className:"relative overflow-hidden",children:[C==="leading"&&n.jsx("button",{type:"button",onClick:()=>f("leading"),"aria-label":e.isRead?"Mark as unread":"Mark as read",className:"absolute inset-y-0 left-0 flex items-center justify-start bg-accent-2 px-6 text-accent-fg",children:e.isRead?n.jsx(pl,{className:"size-6"}):n.jsx(ks,{className:"size-6"})}),C==="trailing"&&n.jsx("button",{type:"button",onClick:()=>f("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:n.jsx(nt,{className:"size-6"})}),d&&!t?d({...w,className:k,style:R,onOpenClick:N,children:P}):n.jsx("button",{type:"button",role:t?"checkbox":void 0,"aria-checked":t?s:void 0,...w,className:k,style:R,children:P})]})}function ch({sections:e,selectedThreadId:t,selectionMode:s,checkedIds:r,initialPeek:a,onToggleCheck:o,onEnterSelection:i,onOpenThread:l,onRefresh:u,refreshing:f,busy:d=!1}){const[m,h]=c.useState(()=>e.flatMap(v=>v.threads)),[g,b]=c.useState(a&&a!=="none"&&m[1]?{id:m[1].id,side:a}:null),p=(v,x)=>{h(x==="trailing"?y=>y.filter(j=>j.id!==v):y=>y.map(j=>j.id===v?{...j,isRead:!j.isRead}:j)),b(null)};return n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[f&&n.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[n.jsx(Kl,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),n.jsx("div",{className:"divide-y divide-line",children:m.map(v=>n.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:n.jsx(Jl,{thread:v,selectionMode:s,checked:r.has(v.id),active:v.id===t,peek:g?.id===v.id?g.side:"none",onPeek:x=>b(x==="none"?null:{id:v.id,side:x}),onToggleCheck:()=>o(v.id),onLongPress:()=>i(v.id),onOpen:()=>l(v.id),onAct:x=>p(v.id,x)})},v.id))}),!s&&!f&&!d&&n.jsx("button",{type:"button",onClick:u,className:"w-full border-t border-line py-2 text-center text-2xs text-fg-subtle transition-colors hover:bg-surface-sunken",children:"Pull to refresh"})]})}function Zl({listTitle:e,listMeta:t,sections:s,briefFilters:r,flatList:a,listState:o="ready",searchQuery:i,errorMessage:l,onRetry:u,onReportError:f,briefCategory:d,selectedThreadId:m,density:h="comfortable",onSelectThread:g,onSelectBriefCategory:b,onOpenNav:p,isDesktop:v,initialTouchState:x,selectionBar:y,selectionSheet:j,listBody:w,hideHeader:N=!1}){const E=h==="compact"?nh:rh,C=c.useRef(null);Kn({containerRef:C,itemSelector:oa});const k=!v&&!r&&o==="ready",R=s.flatMap(B=>B.threads),[O,D]=c.useState(x==="selection"),[P,I]=c.useState(()=>x==="selection"?new Set(R.slice(0,2).map(B=>B.id)):new Set),[S,A]=c.useState(!1),L=x==="peek-trailing"?"trailing":x==="peek-leading"?"leading":void 0,T=B=>{I(J=>{const ee=new Set(J);return ee.has(B)?ee.delete(B):ee.add(B),ee.size===0&&D(!1),ee})},F=B=>{D(!0),I(new Set([B]))},M=()=>{D(!1),I(new Set)},$=()=>{A(!0),setTimeout(()=>A(!1),1400)},K=!y&&k&&O&&P.size>0;return n.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[y??(K?n.jsx(ih,{count:P.size,onCancel:M,onMarkRead:M,onDelete:M}):N?null:n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[p&&n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ka,{className:"size-4"}),onClick:p,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),t&&n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:t})]})),o==="loading"?n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Zm,{})}):o==="empty"?n.jsx(eh,{searchQuery:i}):o==="error"?n.jsx(th,{message:l,onRetry:u,onReport:f}):r?n.jsx(Yi,{sections:s,briefCategory:d,selectedThreadId:m,Row:E,onSelectThread:g,onSelectBriefCategory:b}):w??(k?n.jsx(ch,{sections:s,selectedThreadId:m,selectionMode:O,checkedIds:P,initialPeek:L,onToggleCheck:T,onEnterSelection:F,onOpenThread:B=>g?.(B),onRefresh:$,refreshing:S}):n.jsx("div",{ref:C,className:"flex-1 overflow-y-auto",children:s.map(B=>n.jsxs("div",{children:[!a&&B.label&&n.jsxs("div",{className:"sticky top-0 flex h-section-row items-center justify-between border-b border-line bg-surface-sunken px-row-inset",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:B.label}),n.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:B.threads.length})]}),n.jsx("div",{className:"divide-y divide-line",children:B.threads.map(J=>n.jsx(E,{thread:J,active:J.id===m,onClick:()=>g?.(J.id)},J.id))})]},B.id))})),v&&n.jsx(Wl,{}),j]})}function uh({triggerLabel:e,triggerIcon:t,items:s,align:r="end",touch:a=!0,className:o}){const[i,l]=c.useState(!1),u=c.useRef(null);return c.useEffect(()=>{if(!i)return;const f=m=>{u.current&&!u.current.contains(m.target)&&l(!1)},d=m=>{m.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",d)}},[i]),s.length===0?null:n.jsxs("div",{ref:u,className:q("relative",o),children:[n.jsx(Y,{variant:"ghost",size:"sm",icon:t??n.jsx(zl,{className:"size-5"}),onClick:()=>l(f=>!f),"aria-label":e,"aria-haspopup":"menu","aria-expanded":i,className:q(a&&"min-h-11 min-w-11 px-0")}),i&&n.jsx("div",{role:"menu",className:q("absolute top-full z-50 mt-1 flex min-w-44 flex-col rounded-md border border-line bg-surface py-1 shadow-lg",r==="end"?"right-0":"left-0"),children:s.map(f=>n.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{l(!1),f.onSelect()},className:"flex min-h-11 items-center gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",children:[f.icon&&n.jsx("span",{className:"shrink-0 text-fg-subtle",children:f.icon}),f.label]},f.key))})]})}const As="min-h-11 min-w-11 px-0";function ec({hasThread:e,onReply:t,onReplyAll:s,onForward:r,isStarred:a,onToggleStar:o,onDelete:i,isRead:l,onToggleRead:u,moveSlot:f,overflowItems:d=[],onUnavailable:m,unavailableHint:h,className:g}){const b=(v,x)=>()=>{if(!e){m?.(v);return}x?.()},p=u?[{key:"toggle-read",label:l?"Mark as unread":"Mark as read",icon:l?n.jsx(pl,{className:"size-4"}):n.jsx(ks,{className:"size-4"}),onSelect:b("toggleRead",u)}]:[];return n.jsxs("div",{className:q("relative",g),children:[n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ql,{className:"size-5"}),onClick:b("reply",t),"aria-label":"Reply",title:"Reply",className:As}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Ul,{className:"size-5"}),onClick:b("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:As}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(_l,{className:"size-5"}),onClick:b("forward",r),"aria-label":"Forward",title:"Forward",className:As}),n.jsx("div",{className:"flex-1"}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Rt,{className:q("size-5",a&&"fill-warning text-warning")}),onClick:b("star",o),"aria-label":a?"Unstar":"Star","aria-pressed":a,title:a?"Unstar":"Star",className:As}),f,n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(nt,{className:"size-5"}),onClick:b("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:As}),n.jsx(uh,{triggerLabel:"More actions",items:[...p,...d]})]}),!e&&h&&n.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:h})]})}function dh({open:e=!1,enabled:t=!0,onToggle:s,className:r}){return n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ia,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:q(e&&"bg-accent-2-soft text-accent-2",r)})}function fh({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:r,showTriage:a=!0,onReply:o,onReplyAll:i,onForward:l,onDelete:u,onToggleStar:f,moveSlot:d,onMove:m,replyTitle:h="Reply (r)",replyAllTitle:g="Reply all (a)",forwardTitle:b="Forward (f)",deleteTitle:p="Move to Trash (#)",flagTitle:v="Star (s)",children:x,className:y}){const j=(w,N)=>()=>{if(!e){t?.(w);return}N?.()};return n.jsxs("div",{className:"relative",children:[n.jsxs("header",{className:q("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",y),children:[n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ql,{className:"size-4"}),title:h,"aria-label":"Reply",onClick:j("reply",o)}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Ul,{className:"size-4"}),title:g,"aria-label":"Reply all",onClick:j("replyAll",i)}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(_l,{className:"size-4"}),title:b,"aria-label":"Forward",onClick:j("forward",l)}),a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(nt,{className:"size-4"}),title:p,"aria-label":"Move to Trash",onClick:j("delete",u)}),d??n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Aa,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:j("move",m)}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Rt,{className:q("size-4",r&&"fill-warning text-warning")}),title:v,"aria-label":"Star",onClick:j("flag",f)})]}),n.jsx("div",{className:"flex-1"}),x]}),!e&&s&&n.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}const mh=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},hh=()=>`
9
+ /* Zero the UA default body margin and clamp the document to the iframe width so
10
+ wide author markup can't push the body (and the page) past the viewport. */
11
+ html, body {
12
+ margin: 0;
13
+ padding: 0;
14
+ max-width: 100%;
15
+ }
16
+ body {
17
+ overflow-wrap: anywhere;
18
+ word-break: break-word;
19
+ }
20
+ /* Media never wider than the frame; keep aspect ratio when width is capped. */
21
+ img, video, iframe, svg, canvas {
22
+ max-width: 100% !important;
23
+ height: auto;
24
+ }
25
+ /* Fixed-width author tables (\`<table width="600">\`) collapse to fit. */
26
+ table {
27
+ max-width: 100% !important;
28
+ table-layout: auto;
29
+ }
30
+ /* Cells carry the fixed widths in real newsletters (\`<td width="600">\`);
31
+ cap them too or the table can't actually shrink. */
32
+ td, th {
33
+ max-width: 100% !important;
34
+ }
35
+ /* \`max-width\` alone can't beat an inline \`min-width\`; zeroing the min lets
36
+ flex / grid / table children actually collapse to the clamped width. */
37
+ * {
38
+ min-width: 0;
39
+ }
40
+ /* Long unbroken strings (URLs, tokens) wrap instead of forcing a wide line. */
41
+ pre, code {
42
+ white-space: pre-wrap;
43
+ overflow-wrap: anywhere;
44
+ word-break: break-word;
45
+ }
46
+ `,ph=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},gh=/^(none|transparent|inherit|initial|unset)\s*$/i,xh=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},bh=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!gh.test(r))return!0;s=t.exec(e)}return!1},vh=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of xh(e))if(bh(t))return!0;return!1},yh=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],wh=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],jh="data:image/svg+xml,"+encodeURIComponent(`
47
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
48
+ <rect fill="#f0f0f0" width="100" height="100"/>
49
+ <text x="50" y="50" text-anchor="middle" dy=".3em" fill="#999" font-size="12">
50
+ Image blocked
51
+ </text>
52
+ </svg>
53
+ `),Sh=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),kh=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),Ch=(e={})=>{const t=Gi(),s={FORBID_TAGS:yh,FORBID_ATTR:wh,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const a=r.getAttribute("src")||"";if(a.startsWith("data:"))return;if(a.startsWith("cid:")){const i=a.slice(4).replace(/^<|>$/g,""),l=e.resolveCid?.(i);l&&(r.setAttribute("src",l),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",a),r.setAttribute("src",jh),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const a=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(a)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const a=r.getAttribute("style")||"";r.setAttribute("style",Sh(a))}}),t.addHook("uponSanitizeElement",(r,a)=>{if(a.tagName==="style"){const o=r.textContent||"";r.textContent=kh(o)}}),r=>{const a=vh(r),o=t.sanitize(r,s);return{html:`<style>${hh()}</style>${o}`,hasAuthorBackground:a}}},Nh='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',Lo={light:{fg:"oklch(0.3 0.025 235)",surface:"oklch(0.975 0.012 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",surface:"oklch(0.25 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Eh=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,$o='<meta name="viewport" content="width=device-width, initial-scale=1">',Ih=e=>{const t=e?Lo.dark:Lo.light;return`
54
+ /* Plain-email base: UI font-stack + theme-aware colors (#424) */
55
+ html, body {
56
+ font-family: ${Nh};
57
+ font-size: 14px;
58
+ line-height: 1.6;
59
+ color: ${t.fg};
60
+ background-color: ${t.surface};
61
+ margin: 0;
62
+ padding: 0;
63
+ }
64
+ /* Strip author unreadable text colors and element backgrounds, scoped to body
65
+ descendants so the themed html/body surface above survives this reset. */
66
+ body * {
67
+ color: inherit !important;
68
+ background-color: transparent !important;
69
+ }
70
+ a, a:visited {
71
+ color: ${t.accent} !important;
72
+ text-decoration: underline;
73
+ }
74
+ `},Th=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",Rh=(e,t,s)=>{if(t==="plain")return`${$o}<style>${Ih(s)}</style>${e}`;const r=Eh.test(e);return`${$o}<style>${Th(s,r)}</style>${e}`},Mh=5e4,Ah=1e4,Dh="(max-width: 640px)",Oh=.4,Ph="allow-same-origin allow-popups allow-popups-to-escape-sandbox",Fo=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Lh=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Oh,t/e),$h=e=>{const[t,s]=c.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return c.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const a=o=>s(o.matches);return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t},Fh=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),zh=e=>e===" "?!1:e.length===1?!0:Fh.has(e),zo=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!zh(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},_o=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const a=c.useRef(null),o=c.useRef(null),[i,l]=c.useState(0),[u,f]=c.useState(0),[d,m]=c.useState(0),h=$h(Dh),g=c.useMemo(()=>Rh(e,t,s),[e,t,s]);c.useEffect(()=>{const j=a.current;if(!j)return;const w=()=>m(E=>E===j.clientWidth?E:j.clientWidth);w();const N=new ResizeObserver(w);return N.observe(j),()=>N.disconnect()},[]),c.useEffect(()=>{const j=o.current;if(!j)return;const w=()=>{const k=j.contentDocument;if(!k?.body)return;const R=k.documentElement,O=Fo(k.body.scrollHeight,R?.scrollHeight??0,Mh);l(P=>P===O?P:O);const D=Fo(k.body.scrollWidth,R?.scrollWidth??0,Ah);f(P=>P===D?P:D)};let N,E;const C=()=>{w();const k=j.contentDocument;k?.body&&(N=new ResizeObserver(w),N.observe(k.body),k.documentElement&&N.observe(k.documentElement),k.addEventListener("keydown",zo),E=k)};return j.addEventListener("load",C),()=>{j.removeEventListener("load",C),E?.removeEventListener("keydown",zo),N?.disconnect()}},[]);const b=h?Lh(u,d):1,p=b<1,v=p?`${u}px`:h?"100%":t==="framed"&&u>0?`max(100%, ${u}px)`:u===0?"100%":`${u}px`,x=i===0?"1px":`${i}px`,y=n.jsx("iframe",{ref:o,title:"Email content",sandbox:Ph,srcDoc:g,className:p?void 0:r,scrolling:"no",style:{width:v,maxWidth:p?"none":void 0,border:"none",display:"block",height:x,overflow:"hidden",transform:p?`scale(${b})`:void 0,transformOrigin:p?"top left":void 0,colorScheme:"normal"}});return n.jsx("div",{ref:a,className:p?r:void 0,children:p?n.jsx("div",{style:{width:"100%",height:`${Math.ceil(i*b)}px`,overflow:"hidden"},children:y}):y})},Bo=()=>n.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),tc=({html:e,text:t,isDark:s=!1,category:r,allowImages:a=!1,resolveCid:o,className:i,renderBlockedNotice:l})=>{const u=c.useMemo(()=>!e||typeof document>"u"?null:Ch({allowExternalImages:a,resolveCid:o})(e),[e,a,o]),f=u?.html??null,{framed:d,isPlain:m}=mh(r,u?.hasAuthorBackground??!1),h=c.useMemo(()=>!f||a?0:(f.match(/data-blocked-src/g)||[]).length,[f,a]);return!f&&!t?n.jsx("div",{className:q("message-body",i),children:n.jsx(Bo,{})}):n.jsxs("div",{className:q("message-body",i),children:[h>0&&n.jsx("div",{className:"message-body-notice",children:l?.(h)}),f?d?n.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:n.jsx(_o,{html:f,variant:"framed",isDark:s})}):n.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:n.jsx(_o,{html:f,variant:m?"plain":"framed",isDark:s})}):t?n.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):n.jsx(Bo,{})]})};function Ns({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return n.jsxs("div",{className:q("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??n.jsx(la,{className:"size-10 text-fg-subtle"}),n.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&n.jsxs("p",{className:"text-2xs text-fg-subtle",children:[n.jsx(ps,{children:"j"})," / ",n.jsx(ps,{children:"k"})," to move, ",n.jsx(ps,{children:"Enter"})," to open"]})]})}function sc({message:e,onClick:t,isFocused:s,isUnread:r,trailing:a}){const o=n.jsxs(n.Fragment,{children:[n.jsx(ys,{className:"size-3.5 shrink-0 text-fg-subtle"}),n.jsxs("div",{className:"relative shrink-0",children:[n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"md"}),r&&n.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),n.jsx("span",{className:q("w-36 shrink-0 truncate text-sm",r?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),a??n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=q("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?n.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:l=>{Ld(l)&&(l.preventDefault(),t())},className:q(i,"cursor-pointer"),children:o}):n.jsx("div",{className:i,children:o})}function nc({message:e,warning:t,onHeaderClick:s,isFocused:r,senderBadge:a,trailing:o,to:i,indicators:l,actionMenu:u,actionBar:f,body:d}){const m=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,a]}),o??n.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),n.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&n.jsx("div",{className:"text-xs text-fg-subtle",children:i??n.jsxs(n.Fragment,{children:["to ",e.toLabel]})})]});return n.jsxs("div",{className:q("px-2 py-3 lg:px-4",r&&"ring-1 ring-inset ring-accent/30"),children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(It,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"md"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[s?n.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:m}):m,l]}),u&&n.jsx("div",{className:"shrink-0",children:u})]}),t&&n.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[n.jsx(Cs,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n.jsxs("div",{className:"text-sm text-fg",children:[n.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",n.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),f&&n.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:f}),n.jsx("div",{className:"-mx-2 [&_.message-body-notice]:px-2 lg:mx-0 lg:[&_.message-body-notice]:px-0",children:d??n.jsx(tc,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function _h({thread:e,onBack:t,intelligence:s,intelligenceOpen:r,onToggleIntelligence:a,actions:o,children:i,touchHandlers:l}){const[u,f]=c.useState(!1),d=a!==void 0,m=d?r??!1:u,h=!!s||d,g=()=>{if(d){a?.();return}f(p=>!p)},b=()=>{if(d){m&&a?.();return}f(!1)};return n.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Pl,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),n.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),h&&n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ia,{className:"size-4"}),onClick:g,"aria-label":m?"Hide intelligence panel":"Show intelligence panel","aria-pressed":m,title:"Intelligence",className:q("shrink-0",m&&"bg-accent-2-soft text-accent-2")})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",style:l?{touchAction:"pan-y"}:void 0,...l,children:i??e.messages.map(p=>{const v=x=>x?()=>x(p.id):void 0;return p.expanded?n.jsx(nc,{message:p,warning:e.warning,onHeaderClick:v(o?.onToggleExpand),actionBar:n.jsx(ec,{hasThread:!0,onReply:v(o?.onReply),onReplyAll:v(o?.onReplyAll),onForward:v(o?.onForward),onToggleStar:v(o?.onToggleStar),onDelete:v(o?.onDelete),onToggleRead:v(o?.onToggleRead),moveSlot:o?.moveSlot?.(p.id)})},p.id):n.jsx(sc,{message:p,onClick:v(o?.onToggleExpand)},p.id)})}),s&&!d&&n.jsx(ca,{open:m,onClose:b,title:"Intelligence",anchor:"right",className:"p-0",children:n.jsx(Hl,{data:s,onClose:b,className:"h-full w-full border-l-0"})})]})}const Bh="button:not([disabled]), a[href]",Wt="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-sunken";function Kh({active:e,dimmed:t,indent:s}){return q("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors",Wt,s&&"pl-7",e?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg",t&&"opacity-55")}function Uh({icon:e,label:t,count:s,active:r}){return n.jsxs(n.Fragment,{children:[e&&n.jsx("span",{className:q("shrink-0",r?"text-accent-2":"text-fg-subtle"),children:e}),n.jsx("span",{className:"flex-1 truncate",children:t}),s!=null&&s>0&&n.jsx("span",{className:q("text-2xs tabular-nums",r?"text-accent-2":"text-fg-subtle"),children:s})]})}function gs({icon:e,label:t,count:s,active:r,dimmed:a,indent:o,navId:i,linkComponent:l,ariaLabel:u,title:f,onClick:d}){const m=Kh({active:r,dimmed:a,indent:o}),h=n.jsx(Uh,{icon:e,label:t,count:s,active:r});return i&&l?l({navId:i,className:m,ariaLabel:u??t,title:f,onClick:d,children:h}):n.jsx("button",{type:"button",onClick:d,className:m,"aria-label":u,title:f,children:h})}const Ko={inbox:0,flagged:1,drafts:2,sent:3,archive:4,all:5,junk:6,trash:7};function qh(e){switch(e){case"inbox":return n.jsx(la,{className:"size-4"});case"flagged":return n.jsx(Rt,{className:"size-4"});case"drafts":return n.jsx(Xi,{className:"size-4"});case"sent":return n.jsx(Ys,{className:"size-4"});case"archive":return n.jsx(zd,{className:"size-4"});case"all":return n.jsx(Fd,{className:"size-4"});case"junk":return n.jsx($d,{className:"size-4"});case"trash":return n.jsx(nt,{className:"size-4"})}}const Uo=e=>e.role!=null,jr=8,qo="remit.nav.folders.open.",Ho="remit.nav.account.open.";function Wo(e,t,s){if(typeof localStorage>"u")return s;const r=localStorage.getItem(e+t);return r===null?s:r!=="0"}function Vo(e,t,s){typeof localStorage>"u"||localStorage.setItem(e+t,s?"1":"0")}function Hh({query:e,onSelect:t,onRemove:s}){return n.jsxs("div",{className:"group flex w-full items-center gap-1 rounded-md pr-1 hover:bg-surface",children:[n.jsxs("button",{type:"button",onClick:t,className:q("flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left text-sm text-fg-muted transition-colors hover:text-fg",Wt),children:[n.jsx(Js,{className:"size-4 shrink-0 text-fg-subtle"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:e})]}),s&&n.jsx("button",{type:"button",onClick:s,"aria-label":`Remove saved search: ${e}`,className:q("shrink-0 rounded-full p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-sunken hover:text-fg group-hover:opacity-100 focus-visible:opacity-100",Wt),children:n.jsx(We,{className:"size-3.5"})})]})}function Wh({savedSearches:e,saveableQuery:t,onSelectSavedSearch:s,onRemoveSavedSearch:r,onSaveCurrentSearch:a}){return e.length===0&&!t?null:n.jsxs("div",{className:"mt-3",children:[n.jsx("div",{className:"px-2 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Saved searches"}),t&&n.jsxs("button",{type:"button",onClick:a,className:q("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-accent transition-colors hover:bg-surface",Wt),children:[n.jsx(Dm,{className:"size-4 shrink-0"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Save “",t,"”"]})]}),e.map(o=>n.jsx(Hh,{query:o,onSelect:()=>s?.(o),onRemove:r?()=>r(o):void 0},o))]})}function Vh({account:e,selectedNavId:t,onSelectNav:s,linkComponent:r}){const[a,o]=c.useState(()=>Wo(Ho,e.id,!0)),[i,l]=c.useState(()=>Wo(qo,e.id,!0)),[u,f]=c.useState(!1),d=()=>{o(y=>{const j=!y;return Vo(Ho,e.id,j),j})},m=()=>{l(y=>{const j=!y;return Vo(qo,e.id,j),j})},h=e.mailboxes.filter(Uo).sort((y,j)=>Ko[y.role]-Ko[j.role]),g=e.mailboxes.filter(y=>!Uo(y)),b=u||g.length<=jr?g:g.slice(0,jr),p=g.length-b.length,v=e.status??"ready",x=v==="ready"&&h.length===0&&g.length===0;return n.jsxs("div",{className:"mt-3",children:[n.jsxs("button",{type:"button",onClick:d,"aria-expanded":a,className:q("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg",Wt,e.muted&&"opacity-55"),children:[a?n.jsx(It,{className:"size-3 shrink-0 text-fg-subtle"}):n.jsx(ys,{className:"size-3 shrink-0 text-fg-subtle"}),n.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),e.muted&&n.jsxs(n.Fragment,{children:[n.jsx(Ll,{className:"size-3 shrink-0 text-fg-subtle"}),n.jsx("span",{className:"text-2xs text-fg-subtle",children:"muted"})]})]}),a&&n.jsxs(n.Fragment,{children:[v==="loading"&&n.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"Loading…"}),v==="error"&&n.jsxs("div",{role:"alert",className:"mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm",children:[n.jsx(Gt,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("p",{className:"font-medium text-danger",children:"Couldn't load mailboxes"})}),e.onRetry&&n.jsx("button",{type:"button",onClick:e.onRetry,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}),x&&n.jsx("div",{className:"px-2 py-1 text-sm text-fg-muted",children:"No mailboxes"}),v==="ready"&&n.jsxs(n.Fragment,{children:[h.map(y=>n.jsx(gs,{navId:y.id,linkComponent:r,icon:qh(y.role),label:y.name,ariaLabel:y.name,title:y.fullPath??y.name,count:y.unseen,active:t===y.id,dimmed:e.muted,onClick:()=>s?.(y.id)},y.id)),e.outboxPending!==void 0&&n.jsx(gs,{navId:"outbox",linkComponent:r,icon:n.jsx(Ys,{className:"size-4"}),label:"Outbox",ariaLabel:"Outbox",count:e.outboxPending>0?e.outboxPending:void 0,active:t==="outbox",dimmed:e.muted,onClick:()=>s?.("outbox")}),g.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",onClick:m,"aria-expanded":i,className:q("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg",Wt),children:[i?n.jsx(It,{className:"size-3 shrink-0"}):n.jsx(ys,{className:"size-3 shrink-0"}),n.jsx("span",{className:"flex-1",children:"Folders"}),n.jsx("span",{className:"tabular-nums opacity-70",children:g.length})]}),i&&n.jsxs(n.Fragment,{children:[b.map(y=>n.jsx(gs,{navId:y.id,linkComponent:r,icon:n.jsx(Wf,{className:"size-4"}),label:y.name,ariaLabel:y.name,title:y.fullPath??y.name,count:y.unseen,active:t===y.id,dimmed:e.muted,onClick:()=>s?.(y.id)},y.id)),(p>0||u)&&g.length>jr&&n.jsx("button",{type:"button",onClick:()=>f(y=>!y),className:q("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline",Wt),children:u?"Show less":`Show all (${g.length})`})]})]})]})]})]})}function Qh({accounts:e,selectedNavId:t,briefUnseen:s,onSelectNav:r,variant:a="desktop",linkComponent:o,savedSearches:i=[],saveableQuery:l,onSelectSavedSearch:u,onRemoveSavedSearch:f,onSaveCurrentSearch:d}){const m=c.useRef(null);Kn({containerRef:m,itemSelector:Bh});const h=a==="drawer",g=n.jsxs("nav",{ref:h?m:void 0,className:h?"px-2 py-2":"flex-1 overflow-y-auto px-2 py-2","aria-label":"Mailboxes",children:[n.jsx(gs,{navId:"brief",linkComponent:o,icon:n.jsx(ut,{className:"size-4"}),label:"Daily brief",ariaLabel:"Daily brief",count:s,active:t==="brief",onClick:()=>r?.("brief")}),n.jsx(gs,{navId:"flagged",linkComponent:o,icon:n.jsx(Rt,{className:"size-4"}),label:"Starred",ariaLabel:"Starred",active:t==="flagged",onClick:()=>r?.("flagged")}),n.jsx(Wh,{savedSearches:i,saveableQuery:l,onSelectSavedSearch:u,onRemoveSavedSearch:f,onSaveCurrentSearch:d}),e.length===0?n.jsx("div",{className:"px-2 py-4 text-center text-sm text-fg-muted",children:"No accounts configured"}):e.map(b=>n.jsx(Vh,{account:b,selectedNavId:t,onSelectNav:r,linkComponent:o},b.id))]});return h?g:n.jsxs("aside",{ref:m,className:"flex h-full w-full flex-col bg-surface-sunken",children:[g,n.jsx("div",{className:"border-t border-line px-2 py-2",children:n.jsx(gs,{navId:"settings",linkComponent:o,icon:n.jsx(Da,{className:"size-4"}),label:"Settings",ariaLabel:"Settings",active:t==="settings",onClick:()=>r?.("settings")})})]})}function Yh({search:e,actions:t,className:s}){return n.jsxs("header",{className:q("flex min-h-16 w-full shrink-0 items-center gap-3 border-b border-line bg-canvas px-3 py-2",s),children:[n.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:n.jsx("div",{className:"w-full max-w-2xl",children:e})}),t&&n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:t})]})}function Gh({label:e,size:t="sm",onUndo:s,undoLabel:r="Undo",filtersHref:a,manageLabel:o="Manage filter",className:i}){return n.jsxs(it,{tone:"accent",className:q(t==="md"&&"py-1 text-xs",i),children:[n.jsx(Um,{className:q(t==="sm"?"size-3":"size-3.5","shrink-0"),"aria-hidden":!0}),n.jsx("span",{children:e}),s&&n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),s()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:r}),a&&n.jsx("a",{href:a,onClick:l=>{l.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:o})]})}const Xh=({status:e})=>e==="saving"?n.jsx("span",{className:"animate-pulse text-xs text-fg-muted",children:"Saving..."}):e==="saved"?n.jsx("span",{className:"text-xs text-fg-muted",children:"Draft saved"}):e==="error"?n.jsx("span",{className:"text-xs text-danger",children:"Save failed"}):null;function Jh({onSend:e,onDiscard:t,sending:s,canSend:r,saveStatus:a="idle",unavailableReason:o,onUnavailable:i}){return n.jsxs("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Y,{variant:"primary",size:"md","aria-busy":s,title:r?void 0:o,className:"min-h-11 rounded-full px-4",icon:s?n.jsx(st,{className:"size-4 animate-spin"}):n.jsx(Ys,{className:"size-4"}),onClick:()=>{if(!s){if(!r){o&&i?.(o);return}e()}},children:"Send"}),n.jsx(Xh,{status:a})]}),n.jsx(Y,{variant:"ghost",size:"md","aria-busy":s,"aria-label":"Discard",className:"min-h-11 min-w-11 px-2 hover:text-danger",icon:n.jsx(nt,{className:"size-4"}),onClick:()=>{s||t()}})]})}function Zh({banner:e,header:t,children:s,quoted:r,actionBar:a}){return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e,t,n.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[s,r&&n.jsx("div",{className:"px-3 pb-2",children:r})]}),a]})}function ep({key:e,shiftKey:t=!1,repeat:s=!1,caretAtStart:r,hasValue:a,chipCount:o}){const i=o-1;return e==="Escape"?a?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?o===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!r||o===0?{type:"none"}:s?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function tp({key:e,repeat:t=!1,index:s,chipCount:r}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:s}:e==="ArrowLeft"?s===0?{type:"none"}:{type:"focusChip",index:s-1}:e==="ArrowRight"?s>=r-1?{type:"focusInput"}:{type:"focusChip",index:s+1}:e==="Enter"||e===" "?{type:"activateChip",index:s}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function sp(e,t){const s=t-1;return s<=0?null:e<s?e:s-1}const np=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,rp=({chips:e=[],onRemoveChip:t,onActivateChip:s,value:r,onChange:a,onClear:o,onClearQuery:i,placeholder:l="Search mail...",globalFocusKey:u=!0,showClearButton:f=!0,size:d="sm",inputId:m,chipsLabel:h="Search filters",className:g})=>{const b=c.useId(),p=m??b,v=c.useRef(null),x=c.useRef([]),y=i??o,[j,w]=c.useState(null),N=c.useRef(void 0),[E,C]=c.useState(""),k=e.length>0;c.useEffect(()=>{w(S=>S!==null&&S>=e.length?null:S)},[e.length]),c.useEffect(()=>{const S=N.current;if(S!==void 0){if(N.current=void 0,S===null){v.current?.focus();return}x.current[S]?.focus()}});const R=c.useCallback(S=>{w(S),N.current=S},[]),O=c.useCallback(S=>{const A=e[S];A&&t&&(R(sp(S,e.length)),C(`${A.label} removed`),t(A.id))},[e,t,R]),D=c.useCallback(()=>{R(null),o()},[o,R]),P=c.useCallback(S=>{const A=S.currentTarget,L=ep({key:S.key,shiftKey:S.shiftKey,repeat:S.repeat,caretAtStart:A.selectionStart===0&&A.selectionEnd===0,hasValue:r.length>0,chipCount:e.length});switch(L.type){case"focusChip":S.preventDefault(),R(L.index);return;case"clearQuery":y();return;case"blur":A.blur();return;case"none":return}},[e.length,r,y,R]),I=c.useCallback(S=>A=>{const L=tp({key:A.key,repeat:A.repeat,index:S,chipCount:e.length});switch(L.type!=="none"&&A.preventDefault(),L.type){case"removeChip":O(L.index);return;case"focusChip":R(L.index);return;case"focusInput":R(null);return;case"activateChip":{const T=e[L.index];T&&s&&s(T.id);return}case"none":return}},[e,O,R,s]);return c.useEffect(()=>{if(!u)return;const S=A=>{A.key!=="/"||A.metaKey||A.ctrlKey||A.altKey||np(A.target)||(A.preventDefault(),v.current?.focus())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[u]),n.jsxs("label",{htmlFor:p,className:q("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",d==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",g),children:[n.jsx(Js,{className:q("shrink-0 text-fg-muted pointer-events-none",d==="lg"?"size-5":"size-4")}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[k&&n.jsx("div",{role:"grid","aria-label":h,className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((S,A)=>n.jsx(_d,{ref:L=>{x.current[A]=L},label:S.label,tone:S.tone,focused:j===A,onFocusLabel:()=>w(A),onKeyDown:I(A),onRemove:()=>O(A),onActivate:s?()=>s(S.id):void 0},S.id))}),n.jsx("input",{ref:v,id:p,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:r,tabIndex:j===null?0:-1,onChange:S=>a(S.target.value),onKeyDown:P,onFocus:()=>w(null),placeholder:k?void 0:l,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(r||k)&&f&&n.jsx("button",{type:"button",onClick:D,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:n.jsx(We,{className:q("text-fg-muted",d==="lg"?"size-5":"size-4")})}),n.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:E})]})},Pa=({value:e,onChange:t,onClear:s,onClearQuery:r,chips:a,onRemoveChip:o,placeholder:i="Search mail...",globalFocusKey:l=!0,showClearButton:u=!0,size:f,inputId:d,className:m})=>n.jsx(rp,{value:e,onChange:t,onClear:s,onClearQuery:r,chips:a,onRemoveChip:o,placeholder:i,globalFocusKey:l,showClearButton:u,size:f,inputId:d,className:m});function ap({title:e,unreadCount:t,isDesktop:s,onMenuClick:r,searchValue:a,onSearchChange:o,onSearchClear:i,searchOpen:l,onSearchOpenChange:u,showSearch:f=!0}){const d=`${t.toLocaleString()} unread`,m=i??(()=>o("")),h=()=>{m(),u(!1)},g=p=>n.jsx(Pa,{value:a,onChange:o,onClear:m,globalFocusKey:!1,showClearButton:p}),b=n.jsx(Y,{variant:"ghost",icon:n.jsx(ka,{className:"size-5"}),onClick:r,"aria-label":"Menu",className:"min-h-11 min-w-11 shrink-0 px-0"});return n.jsx("header",{className:"flex shrink-0 flex-col bg-canvas",children:n.jsx("div",{className:"flex h-12 items-center gap-2 px-row-inset",children:f?s?n.jsxs(n.Fragment,{children:[b,n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:d}),n.jsx("div",{className:"w-64 max-w-[40%] shrink-0",children:g(!0)})]}):l||a.trim().length>0?n.jsxs("div",{className:"flex flex-1 items-center gap-1",children:[n.jsx("div",{className:"flex-1",children:g(!1)}),n.jsx(Y,{variant:"ghost",icon:n.jsx(We,{className:"size-5"}),onClick:h,"aria-label":"Close search",className:"min-h-11 min-w-11 shrink-0 px-0"})]}):n.jsxs(n.Fragment,{children:[b,n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:d}),n.jsx(Y,{variant:"ghost",icon:n.jsx(Js,{className:"size-5"}),onClick:()=>u(!0),"aria-label":"Search",className:"min-h-11 min-w-11 shrink-0 px-0"})]}):n.jsxs(n.Fragment,{children:[b,n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:d})]})})})}const op=(e,t)=>e==="vip"?"vip":e==="unknown"&&t==="md"?"unknown-pill":"hidden",rc=({senderTrust:e,size:t="sm",className:s})=>{const r=op(e,t);return r==="vip"?n.jsx(ut,{className:q("text-warning shrink-0",t==="sm"&&"size-3.5",t==="md"&&"size-4",s),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):r==="unknown-pill"?n.jsx("span",{className:q("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",s),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Qo(e,t){const s=t?.trim();if(!s)return e;const r=e.toLowerCase(),a=s.toLowerCase(),o=[];let i=0,l=r.indexOf(a,i),u=0;for(;l!==-1;)l>i&&o.push(e.slice(i,l)),o.push(n.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(l,l+a.length)},u++)),i=l+a.length,l=r.indexOf(a,i);return i<e.length&&o.push(e.slice(i)),o}function ip({result:e,onClick:t,query:s,showFolder:r=!0}){const a=r&&e.folder?Bd(e.folder):void 0;return n.jsxs("button",{type:"button",onClick:t,className:"flex w-full flex-col gap-0.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("span",{className:q("min-w-0 flex-1 truncate text-sm",e.unread?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.sender}),n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.date})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:q("min-w-0 flex-1 truncate text-sm",e.unread?"text-fg":"text-fg-muted"),children:Qo(e.subject,s)}),e.flagged&&n.jsx(Pm,{className:"size-3.5 shrink-0 fill-warning text-warning"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:Qo(e.snippet,s)}),a&&n.jsx(it,{tone:"neutral",className:"shrink-0",children:a}),e.category&&n.jsx(it,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&n.jsx(it,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&n.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})]})}const lp=e=>e===1?"result":"results";function cp({count:e,onScopeToSpam:t}){return n.jsx(Xt,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[n.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${lp(e)} from Spam`]}),n.jsx(Y,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const Yo=6,up={kind:"global"},dp=e=>e.kind==="folder"&&e.role==="junk",fp=e=>e.folder?.role==="junk";function ac(e){const t=[],s=[];for(const r of e)fp(r)?s.push(r):t.push(r);return{kept:t,spam:s}}function mp({onClick:e,disabledReason:t}){const s=t!==void 0;return n.jsx("div",{className:"border-b border-line px-row-inset py-1.5",children:n.jsxs("button",{type:"button",onClick:e,disabled:s,title:t,className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",s?"cursor-not-allowed text-fg-subtle":"text-accent hover:bg-surface-sunken"),children:[n.jsx(Ud,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:"Make this a filter"}),s&&n.jsx("span",{className:"ml-auto truncate text-2xs font-normal text-fg-subtle",children:t})]})})}function hp({section:e,query:t,onSelectResult:s,showFolder:r}){const[a,o]=c.useState(e.initialCollapsed??!1),[i,l]=c.useState(!1),u=e.results.length>Yo,d=!i&&u?e.results.slice(0,Yo):e.results,m=e.results.length-d.length;return n.jsxs("div",{children:[n.jsxs("button",{type:"button","aria-expanded":!a,onClick:()=>o(h=>!h),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[n.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),n.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),n.jsx(It,{className:q("size-3 shrink-0 text-fg-subtle transition-transform duration-200",a?"rotate-0":"rotate-180")})]}),!a&&n.jsxs(n.Fragment,{children:[d.map(h=>n.jsx(ip,{result:h,query:t,showFolder:r,onClick:s?()=>s(h):void 0},h.id)),u&&n.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${m} more`,!i&&n.jsx(It,{className:"ml-1 size-3"})]})]})]})}function oc({value:e,recentSearches:t,onPickRecent:s,sections:r,loading:a,onSelectResult:o,tokens:i,scope:l=up,makeFilter:u}){if(!(e.trim().length>0))return t&&t.length>0?n.jsxs("div",{className:"flex flex-col",children:[n.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(w=>n.jsxs("button",{type:"button",onClick:()=>s?.(w),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:[n.jsx(Ea,{className:"size-4 shrink-0 text-fg-subtle"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:w})]},w))]}):n.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 d=i&&i.length>0&&n.jsx(Kd,{tokens:i}),m=u&&n.jsx(mp,{onClick:u.onClick,disabledReason:u.disabledReason});if(a)return n.jsxs("div",{className:"flex flex-col",children:[m,d,n.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(w=>n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),n.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),n.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},w))})]});const h=l.kind==="global",g=dp(l)||l.kind==="collection",b=h||l.kind==="collection",p=(r??[]).map(w=>{if(g)return{section:w,spam:[]};const{kept:N,spam:E}=ac(w.results);return{section:{...w,results:N},spam:E}}),v=p.map(w=>w.section),x=p.reduce((w,N)=>w+N.spam.length,0),y=l.kind==="global"&&x>0&&l.onScopeToSpam!==void 0?n.jsx(cp,{count:x,onScopeToSpam:l.onScopeToSpam}):void 0;return v.some(w=>w.results.length>0)?n.jsxs("div",{className:"flex flex-col",children:[m,d,y,v.filter(w=>w.results.length>0).map(w=>n.jsx(hp,{section:w,query:e,showFolder:b,onSelectResult:o},w.id))]}):n.jsxs("div",{className:"flex flex-col",children:[m,d,y,n.jsxs("div",{className:"px-row-inset py-10 text-center",children:[n.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),n.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function pp({value:e,onChange:t,onClear:s,onCancel:r,filter:a,recentSearches:o,onPickRecent:i,sections:l,loading:u,onSelectResult:f,tokens:d,chips:m,onRemoveChip:h,scope:g,makeFilter:b}){const p=n.jsx(oc,{value:e,recentSearches:o,onPickRecent:i,sections:l,loading:u,onSelectResult:f,tokens:d,scope:g,makeFilter:b});return n.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx(Pa,{value:e,onChange:t,onClear:s,chips:m,onRemoveChip:h,globalFocusKey:!1,showClearButton:!1})}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(We,{className:"size-4"}),onClick:r,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),a?n.jsx(ua,{...a,children:p}):n.jsx("div",{className:"flex-1 overflow-y-auto",children:p})]})}const Sr="w-full text-left px-3 py-2.5 min-h-11 flex items-center gap-2 transition-colors text-sm rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-canvas",gp={searchPlaceholder:"Move to…",searchAriaLabel:"Filter folders",listAriaLabel:"Destination folders",currentSuffix:"(current folder)",currentTag:"current",emptyMessage:e=>`No folders match "${e}"`,optionLabel:e=>`Move to ${e}`,createLabel:e=>`Create "${e}"`,createPending:"Creating folder…",createError:"Couldn't create that folder. Please try again."},kr=e=>{for(let t=0;t<e.length;t+=1)if(!e[t]?.isCurrent)return t;return-1},xp=e=>{for(let t=e.length-1;t>=0;t-=1)if(!e[t]?.isCurrent)return t;return-1},Go=(e,t,s)=>{const r=e.length;if(r<=0)return-1;const a=t<0?s===1?-1:r:t;for(let o=1;o<=r;o+=1){const i=((a+s*o)%r+r)%r;if(!e[i]?.isCurrent)return i}return-1},bp=(e,t)=>e.label.toLowerCase().includes(t)?!0:e.searchValue?.toLowerCase().includes(t)??!1,ic=({mailboxes:e,onSelect:t,onCreateFolder:s,onCancel:r,autoFocus:a=!1,labels:o})=>{const i={...gp,...o},[l,u]=c.useState(""),[f,d]=c.useState(!1),[m,h]=c.useState(),[g,b]=c.useState(()=>kr(e)),p=c.useRef(null),v=c.useRef([]);c.useEffect(()=>{a&&p.current?.focus()},[a]);const x=l.trim().toLowerCase(),y=c.useMemo(()=>x?e.filter(k=>bp(k,x)):[...e],[e,x]);c.useEffect(()=>{b(k=>k>=0&&k<y.length&&!y[k]?.isCurrent?k:kr(y))},[y]),c.useEffect(()=>{if(g<0)return;const k=v.current[g];k&&document.activeElement!==p.current&&k.focus()},[g]);const j=c.useCallback(()=>{if(g<0)return;const k=y[g];!k||k.isCurrent||t(k.id)},[g,y,t]),w=!!s&&x.length>0&&!e.some(k=>k.label.toLowerCase()===x),N=c.useCallback(()=>{if(!s)return;const k=l.trim();k!==""&&(d(!0),h(void 0),s(k).then(R=>{t(R.id),d(!1)}).catch(R=>{h(R instanceof Error?R.message:i.createError),d(!1)}))},[s,l,t,i.createError]),E=c.useCallback(k=>{switch(k.key){case"ArrowDown":k.preventDefault(),b(R=>Go(y,R,1));return;case"ArrowUp":k.preventDefault(),b(R=>Go(y,R,-1));return;case"Home":k.preventDefault(),b(kr(y));return;case"End":k.preventDefault(),b(xp(y));return;case"Enter":case" ":k.preventDefault(),j();return;case"Escape":k.preventDefault(),r?.();return;default:return}},[y,j,r]),C=c.useCallback(k=>{if(k.key==="ArrowDown"){if(k.preventDefault(),y.length===0)return;v.current[g>=0?g:0]?.focus();return}k.key==="Escape"&&(k.preventDefault(),r?.())},[y.length,g,r]);return n.jsxs("div",{className:"flex flex-col",children:[n.jsx(Ji,{variant:"inline",className:"border-b border-line px-3 py-2",icon:n.jsx(Js,{className:"size-4","aria-hidden":"true"}),ref:p,type:"search",value:l,onChange:k=>u(k.target.value),onKeyDown:C,placeholder:i.searchPlaceholder,"aria-label":i.searchAriaLabel}),n.jsx("div",{className:"flex-1 overflow-y-auto py-1",role:"listbox","aria-label":i.listAriaLabel,onKeyDown:E,children:y.length===0?n.jsx("div",{className:"px-3 py-3 text-sm text-fg-muted","aria-live":"polite",children:i.emptyMessage(l)}):y.map((k,R)=>{const O=k.isCurrent??!1,D=R===g;return O?n.jsx("div",{children:n.jsxs("div",{role:"option","aria-selected":!1,"aria-current":"true","aria-label":`${k.label} ${i.currentSuffix}`,className:q(Sr,"opacity-60 bg-surface-sunken/40"),children:[n.jsx("span",{className:"truncate flex-1",children:k.label}),n.jsx("span",{className:"text-xs text-fg-muted shrink-0",children:i.currentTag})]})},k.id):n.jsx("div",{children:n.jsx("button",{ref:P=>{v.current[R]=P},type:"button",role:"option","aria-selected":!1,tabIndex:D?0:-1,onClick:()=>t(k.id),onFocus:()=>b(R),"aria-label":i.optionLabel(k.label),className:q(Sr,"hover:bg-surface-raised"),children:n.jsx("span",{className:"truncate flex-1",children:k.label})})},k.id)})}),w&&n.jsxs("div",{className:"border-t border-line p-1",children:[n.jsx("button",{type:"button",onClick:N,disabled:f,className:q(Sr,"font-medium text-accent-2 hover:bg-surface-raised disabled:opacity-60"),children:n.jsx("span",{className:"truncate",children:f?i.createPending:i.createLabel(l.trim())})}),m&&n.jsx("p",{className:"px-3 py-1 text-xs text-danger",role:"alert",children:m})]})]})},vp={queued:{icon:Ea,label:"Queued",className:"text-warning"},sending:{icon:st,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:$l,label:"Sent",className:"text-positive"},failed:{icon:Gt,label:"Failed",className:"text-danger"},blocked:{icon:da,label:"Blocked",className:"text-warning"}};function Xo({status:e,iconOnly:t,className:s}){const r=vp[e],a=r.icon;return n.jsxs("span",{className:q("inline-flex items-center gap-1.5 text-xs font-medium",r.className,s),children:[n.jsx(a,{className:q("size-4",r.spin&&"animate-spin")}),!t&&r.label]})}const yp=(e,t)=>t?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"?"bg-warning/10":"";function wp({recipients:e,subject:t,time:s,status:r,error:a,selected:o,onSelect:i,onRetry:l,retrying:u,onEdit:f,onDelete:d,deleting:m}){const h=r==="failed"||r==="blocked";return n.jsxs("div",{className:q("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",yp(r,o)),children:[n.jsxs("button",{type:"button",...aa,onClick:i,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[n.jsx("div",{className:"mt-0.5 shrink-0",children:n.jsx(Xo,{status:r,iconOnly:!0})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"truncate text-sm font-medium",children:e}),n.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:s})]}),n.jsx("div",{className:"truncate text-sm",children:t||"No subject"}),n.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[n.jsx(Xo,{status:r}),a&&n.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",a]})]})]})]}),h&&n.jsx("div",{className:"shrink-0",children:n.jsx($f,{actions:[...r==="failed"&&l?[{label:"Retry sending",iconOnly:!0,icon:n.jsx(Hf,{className:"size-3.5"}),busy:u,onClick:l}]:[],{label:"Edit as draft",iconOnly:!0,icon:n.jsx(Ys,{className:"size-3.5"}),onClick:f}],destructive:{label:"Delete message",iconOnly:!0,icon:n.jsx(nt,{className:"size-3.5"}),busy:m,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:d}})})]})}const jp=e=>{const[t,s]=c.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return c.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const a=o=>s(o.matches);return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t},Sp=({children:e,onRefresh:t,isRefreshing:s})=>jp("(min-width: 1024px)")?e:n.jsx(qd,{onRefresh:t,isPullable:!s,children:e}),kp=({text:e,html:t,senderName:s,date:r})=>{const[a,o]=c.useState(!1);if(!e&&!t)return null;const i=[s,r].filter(Boolean).join(" on ");return n.jsxs("div",{className:"mt-2 px-3 pb-2",children:[n.jsxs("button",{type:"button",onClick:()=>o(!a),"aria-expanded":a,className:"flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors",children:[a?n.jsx(It,{className:"size-3"}):n.jsx(ys,{className:"size-3"}),i?`${i} wrote:`:"Show quoted text"]}),a&&n.jsx("blockquote",{className:"mt-2 pl-3 border-l-2 border-fg-subtle/30 text-sm text-fg-muted [&_a]:text-accent [&_a]:underline [&_blockquote]:pl-3 [&_blockquote]:border-l-2 [&_blockquote]:border-fg-subtle/30",children:t?n.jsx("div",{dangerouslySetInnerHTML:{__html:t}}):e.split(`
75
+ `).map((l,u)=>n.jsx("p",{className:"min-h-[1.2em]",children:l},u))})]})},Cp=e=>e===1?"message":"messages";function Np({count:e,onReview:t,onDismiss:s,actionLabel:r="Review & rescue"}){return n.jsx(Xt,{tone:"info",variant:"soft",onDismiss:s,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[n.jsx(tn,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),n.jsxs("span",{children:[n.jsx("span",{className:"font-semibold text-fg",children:`${e} ${Cp(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),n.jsx(Y,{variant:"primary",size:"sm",onClick:t,className:"self-start",children:r})]})})}function Ep({candidate:e,selected:t,onToggle:s,hideSender:r=!1}){const{senderName:a,senderAddress:o,subject:i,snippet:l,trustReason:u,trustSubReason:f,senderTrust:d}=e;return n.jsxs("label",{className:q("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",r&&"pl-11",t?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[n.jsx(nn,{className:"mt-0.5",checked:t,onChange:s,"aria-label":`${t?"Deselect":"Select"} ${r?i:`message from ${a}`}`}),!r&&n.jsx(dt,{name:a,email:o,size:"sm"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[!r&&n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-sm font-medium text-fg",children:a}),d&&n.jsx(rc,{senderTrust:d,size:"sm"}),n.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:o})]}),n.jsx("span",{className:"block truncate text-sm text-fg-muted",children:i}),n.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:l}),!r&&n.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[n.jsxs(it,{tone:"positive",children:[n.jsx(tn,{className:"size-3","aria-hidden":!0}),u]}),n.jsx("span",{className:"text-2xs text-fg-subtle",children:f})]})]})]})}const Ip=e=>{const t=new Map,s=[];for(const r of e){const a=(r.senderAddress||r.senderName).toLowerCase(),o=t.get(a);if(o){o.messages.push(r);continue}t.set(a,{key:a,senderName:r.senderName,senderAddress:r.senderAddress,trustReason:r.trustReason,trustSubReason:r.trustSubReason,senderTrust:r.senderTrust,messages:[r]}),s.push(a)}return s.map(r=>t.get(r)).sort((r,a)=>a.messages.length-r.messages.length)},Tp=(e,t)=>{const s=e.messages.filter(r=>t.has(r.id)).length;return s===0?"none":s===e.messages.length?"all":"some"},Jo=e=>e===1?"message":"messages";function Rp({group:e,selected:t,onToggleGroup:s,onToggleMessage:r}){const[a,o]=c.useState(!1),i=Tp(e,t),l=e.messages.length,u=a?It:ys;return n.jsxs("div",{className:q(i!=="none"?"bg-positive/10":"bg-surface"),children:[n.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[n.jsx(nn,{className:"mt-0.5",checked:i==="all",indeterminate:i==="some",onChange:()=>s(e,i!=="all"),"aria-label":`${i==="all"?"Deselect":"Select"} all ${l} ${Jo(l)} from ${e.senderName}`}),n.jsx(dt,{name:e.senderName,email:e.senderAddress,size:"sm"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&n.jsx(rc,{senderTrust:e.senderTrust,size:"sm"}),n.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),n.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[n.jsxs(it,{tone:"positive",children:[n.jsx(tn,{className:"size-3","aria-hidden":!0}),e.trustReason]}),n.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),n.jsxs("button",{type:"button",onClick:()=>o(f=>!f),"aria-expanded":a,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${l} ${Jo(l)}`,n.jsx(u,{className:"size-3.5","aria-hidden":!0})]})]}),a&&n.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(f=>n.jsx(Ep,{candidate:f,selected:t.has(f.id),onToggle:()=>r(f.id),hideSender:!0},f.id))})]})}const La=e=>e===1?"message":"messages",Mp=(e,t)=>`Moves ${e===1?"this message":`these ${e} ${La(e)}`} out of Spam to ${t} now. Nothing later.`,Qr=(e,t)=>e.find(s=>s.id===t)?.label??"Inbox";function Ap(){return n.jsx(Xt,{tone:"info",variant:"soft",children:n.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function Dp({candidates:e,selected:t,onToggle:s,onToggleGroup:r,onSelectAll:a,onSelectNone:o,onContinue:i,onCancel:l}){const[u,f]=c.useState(!1),d=t.size,m=c.useMemo(()=>Ip(e),[e]);return n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[n.jsx(tn,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Pf,{className:"size-3.5"}),onClick:()=>f(h=>!h),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),n.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),u&&n.jsx("div",{className:"mt-2",children:n.jsx(Ap,{})})]}),n.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[n.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${d} of ${e.length} selected · ${m.length} ${m.length===1?"sender":"senders"}`}),n.jsxs("span",{className:"flex gap-1",children:[n.jsx(Y,{variant:"ghost",size:"sm",onClick:a,children:"Select all"}),n.jsx(Y,{variant:"ghost",size:"sm",onClick:o,children:"Select none"})]})]}),n.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:m.map(h=>n.jsx(Rp,{group:h,selected:t,onToggleGroup:r,onToggleMessage:s},h.key))}),n.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[n.jsx(Y,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Continue with ${d} ${La(d)}`}),n.jsx(Y,{variant:"ghost",onClick:l,className:"h-11 w-full",children:"Cancel"})]})]})}function Op({count:e,folders:t,destination:s,onPick:r,onMove:a,onBack:o}){const[i,l]=c.useState(!1);return n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[n.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),n.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-2",children:i?n.jsx("div",{className:"overflow-hidden rounded-xl border border-line bg-surface",children:n.jsx(ic,{mailboxes:t,autoFocus:!0,onSelect:u=>{r(u),l(!1)},onCancel:()=>l(!1)})}):n.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[n.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),n.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:Qr(t,s)}),n.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>l(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),n.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[n.jsx("p",{className:"text-2xs text-fg-subtle",children:Mp(e,Qr(t,s))}),n.jsx(Y,{variant:"primary",onClick:a,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),n.jsx(Y,{variant:"ghost",onClick:o,className:"h-11 w-full",children:"Back"})]})]})}function Pp({count:e,destinationLabel:t,onClose:s}){return n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[n.jsx(Ia,{className:"size-10 text-positive","aria-hidden":!0}),n.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${La(e)} out of Spam.`}),n.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${t}.`})]}),n.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:n.jsx(Y,{variant:"primary",onClick:s,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Lp({open:e,candidates:t,defaultDestinationId:s,availableFolders:r,onConfirmMove:a,onCancel:o}){const[i,l]=c.useState("review"),[u,f]=c.useState(()=>e?new Set(t.map(j=>j.id)):new Set),[d,m]=c.useState(s),[h,g]=c.useState(0),b=c.useRef(!1);c.useEffect(()=>{e&&!b.current&&(l("review"),f(new Set(t.map(j=>j.id))),m(s),g(0)),b.current=e},[e,t,s]);const p=u.size,v=j=>{f(w=>{const N=new Set(w);return N.has(j)?N.delete(j):N.add(j),N})},x=(j,w)=>{f(N=>{const E=new Set(N);for(const C of j.messages)w?E.add(C.id):E.delete(C.id);return E})},y=()=>{const j=Array.from(u);g(j.length),a(j,d),l("done")};return n.jsxs(gl,{open:e,onClose:o,dismissLabel:"Close rescue",children:[i==="review"&&n.jsx(Dp,{candidates:t,selected:u,onToggle:v,onToggleGroup:x,onSelectAll:()=>f(new Set(t.map(j=>j.id))),onSelectNone:()=>f(new Set),onContinue:()=>l("destination"),onCancel:o}),i==="destination"&&n.jsx(Op,{count:p,folders:r,destination:d,onPick:m,onMove:y,onBack:()=>l("review")}),i==="done"&&n.jsx(Pp,{count:h,destinationLabel:Qr(r,d),onClose:o})]})}function $p(e){return e.scopedOutFolder!==void 0||(e.droppedFacets?.length??0)>0||e.droppedSemantic===!0}function Fp(e){return`Your search was limited to ${e}. This filter matches these messages in any folder — it can't be pinned to one.`}const zp=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;function _p(e){const t=e.length===1?"a filter condition":"filter conditions",s=e.length===1?"isn't":"aren't";return`${zp(e)} ${s} ${t}, so ${e.length===1?"it was":"they were"} left out — the filter still matches everything else you searched for.`}const Bp="The filter matches these words literally. Your search also found similar mail by meaning — a filter can't carry that, so it won't catch mail that means the same thing without these words.";function Cr({icon:e,children:t}){return n.jsxs("li",{className:"flex items-start gap-2",children:[n.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle","aria-hidden":"true",children:e}),n.jsx("span",{children:t})]})}function Kp({notice:e}){return $p(e)?n.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5",children:[n.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"From your search"}),n.jsxs("ul",{className:"mt-1.5 space-y-1.5 text-xs text-fg-muted",children:[e.scopedOutFolder!==void 0&&n.jsx(Cr,{icon:n.jsx(Aa,{className:"size-3.5"}),children:Fp(e.scopedOutFolder)}),e.droppedFacets&&e.droppedFacets.length>0&&n.jsx(Cr,{icon:n.jsx(ia,{className:"size-3.5"}),children:_p(e.droppedFacets)}),e.droppedSemantic&&n.jsx(Cr,{icon:n.jsx(ut,{className:"size-3.5"}),children:Bp})]})]}):null}const Zo=e=>e.toLocaleString(),Bs=56,ei=320,Up=320,qp="cubic-bezier(0.32, 0.9, 0.3, 1)",Hp=.5;function vn(e){return Math.sign(e)*Math.sqrt(Math.abs(e))*4}function Wp({expanded:e,delta:t,velocity:s,expandedHeight:r,teaserHeight:a,flickVelocity:o=Hp}){if(Math.abs(s)>o)return s<0;const i=(r-a)/2;return e?t<i:t<-i}function Vp({count:e,mode:t="idle",onCancel:s,onDelete:r,onJunk:a,onMarkRead:o,onSelectSimilar:i,onSomethingElse:l,moveSlot:u,isBusy:f=!1,selectAll:d,statusLabel:m,progress:h,notice:g,startExpanded:b=!1}){const[p,v]=c.useState(b),x=c.useRef(null),[y,j]=c.useState(ei),w=t==="counting"||t==="running";c.useEffect(()=>{w&&v(!0)},[w]),c.useLayoutEffect(()=>{const $=x.current;if(!$)return;const K=()=>j($.offsetHeight);K();const B=new ResizeObserver(K);return B.observe($),()=>B.disconnect()},[]);const[N,E]=c.useState(null),C=c.useRef(null),k=c.useRef(!1),R=c.useCallback($=>{w||($.currentTarget.setPointerCapture($.pointerId),C.current={startY:$.clientY,lastY:$.clientY,lastT:$.timeStamp,velocity:0},k.current=!1,E(0))},[w]),O=c.useCallback($=>{const K=C.current;if(!K)return;const B=$.timeStamp-K.lastT;B>0&&(K.velocity=($.clientY-K.lastY)/B),K.lastY=$.clientY,K.lastT=$.timeStamp;const J=$.clientY-K.startY;Math.abs(J)>4&&(k.current=!0);const ee=y-Bs,X=p?J<0?vn(J):Math.min(J,ee+vn(Math.max(0,J-ee))):J>0?vn(J):Math.max(J,-ee+vn(Math.min(0,J+ee)));E(X)},[p,y]),D=c.useCallback(()=>{const $=C.current;C.current=null,$&&(E(null),v(Wp({expanded:p,delta:$.lastY-$.startY,velocity:$.velocity,expandedHeight:y,teaserHeight:Bs})))},[p,y]),P=y-Bs,I=p?0:P,S=N!==null,A=I+(N??0),L=S?"none":`transform ${Up}ms ${qp}`,T=d?.checked?`All ${Zo(e)} loaded selected`:`${Zo(e)} ${e===1?"message":"messages"} selected`,F=t==="idle"||t==="escalated",M=t==="idle";return n.jsxs("div",{ref:x,"data-selection-sheet":"",className:"absolute inset-x-0 bottom-0 z-30 flex select-none flex-col rounded-t-2xl border-t border-line bg-surface shadow-2xl shadow-black/40",style:{maxHeight:`min(${ei}px, 38dvh)`,minHeight:`${Bs}px`,transform:`translateY(${A}px)`,transition:L},children:[n.jsxs("div",{role:"slider","aria-label":p?"Collapse selection actions":"Expand selection actions","aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":p?1:0,tabIndex:0,onPointerDown:R,onPointerMove:O,onPointerUp:D,onPointerCancel:D,onClick:()=>{if(k.current){k.current=!1;return}!S&&!w&&v($=>!$)},className:q("flex touch-none flex-col items-center pt-2",w?"":"cursor-grab active:cursor-grabbing"),children:[n.jsx("div",{className:"mb-1.5 h-1 w-10 rounded-full bg-fg-subtle/40"}),n.jsxs("div",{className:"flex w-full items-center gap-2 px-4 pb-3",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",role:"status","aria-live":"polite",children:m??T}),p?n.jsxs(n.Fragment,{children:[o&&!f&&t!=="counting"&&n.jsx(Y,{variant:"ghost",size:"touch",icon:n.jsx(ks,{className:"size-4"}),onPointerDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),o()},"aria-label":"Mark as read",className:"-my-2 shrink-0"}),n.jsx(Y,{variant:"ghost",size:"touch",icon:n.jsx(We,{className:"size-4"}),onPointerDown:$=>$.stopPropagation(),onClick:$=>{$.stopPropagation(),s()},"aria-label":"Cancel selection",className:"-my-2 -mr-2 shrink-0"})]}):n.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-fg-subtle",children:[n.jsx("span",{children:"Swipe up for actions"}),n.jsx(Om,{className:"size-4"})]})]})]}),n.jsxs("div",{inert:p?void 0:!0,className:"flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4",children:[h&&n.jsx("div",{className:"mb-3",children:n.jsx(Oa,{value:h.value,max:h.max,tone:h.tone})}),d&&t!=="running"&&n.jsxs("label",{className:"mb-3 flex min-h-11 cursor-pointer items-center gap-3 text-sm font-medium text-fg-muted",children:[n.jsx(nn,{"aria-label":"Select all",checked:d.checked,indeterminate:d.indeterminate,onChange:d.onChange}),"Select all loaded"]}),F&&n.jsxs("div",{className:"mb-3 flex items-stretch justify-around gap-1 border-b border-line pb-3",children:[n.jsx(Y,{variant:"ghost",onClick:r,icon:f?n.jsx(st,{className:"size-5 animate-spin"}):n.jsx(nt,{className:"size-5 text-danger"}),"aria-label":"Move selected messages to Trash","aria-busy":f||void 0,className:"h-auto flex-1 flex-col gap-1 px-0 py-1.5 text-[11px]",children:"Delete"}),u&&n.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1",children:[u,n.jsx("span",{"aria-hidden":"true",className:"text-[11px] text-fg-muted",children:"Move"})]}),a&&n.jsx(Y,{variant:"ghost",onClick:a,icon:n.jsx(Cs,{className:"size-5"}),"aria-label":"Move selected messages to Junk",className:"h-auto flex-1 flex-col gap-1 px-0 py-1.5 text-[11px]",children:"Junk"})]}),M&&(i||l)&&n.jsxs("div",{className:"flex flex-col gap-2",children:[i&&n.jsxs(Y,{variant:"primary",onClick:i,className:"h-auto flex-col items-start gap-0 px-4 py-2.5 text-left",children:[n.jsx("span",{className:"text-sm font-semibold leading-tight",children:"Select similar messages"}),n.jsx("span",{className:"text-xs opacity-80",children:"find more like these"})]}),l&&n.jsxs(Y,{variant:"secondary",onClick:l,className:"h-auto flex-col items-start gap-0 px-4 py-2.5 text-left",children:[n.jsx("span",{className:"text-sm font-medium leading-tight",children:"Something else"}),n.jsx("span",{className:"text-xs text-fg-subtle",children:"just deal with these"})]})]}),g&&n.jsx(Xt,{tone:g.tone,variant:"soft",role:"status","aria-live":"polite",className:q(F||h?"mt-1":"mt-0"),children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.text&&n.jsx("span",{children:g.text}),g.action&&n.jsx(Y,{variant:"ghost",size:"md",onClick:g.action.onClick,className:"-my-1 min-h-11 shrink-0",children:g.action.label})]})})]})]})}const $a=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{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"}],lc={id:"unread",label:"Unread"},Qp={id:"flagged",label:"Starred"},cc={id:"attachment",label:"Has attachment"};function Yp(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function Gp(e=[]){return{categories:[...$a],filters:Hd,sources:Yp(e)}}function Xp(){return{categories:[...$a],filters:[lc,Qp,cc]}}function Jp(){return{categories:[...$a],filters:[lc,cc]}}function Et(e,t,{checkForDefaultPrevented:s=!0}={}){return function(a){if(e?.(a),s===!1||!a||!a.defaultPrevented)return t?.(a)}}function ti(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Zp(...e){return t=>{let s=!1;const r=e.map(a=>{const o=ti(a,t);return!s&&typeof o=="function"&&(s=!0),o});if(s)return()=>{for(let a=0;a<r.length;a++){const o=r[a];typeof o=="function"?o():ti(e[a],null)}}}}function es(...e){return c.useCallback(Zp(...e),e)}function eg(e,t=[]){let s=[];function r(o,i){const l=c.createContext(i);l.displayName=o+"Context";const u=s.length;s=[...s,i];const f=m=>{const{scope:h,children:g,...b}=m,p=h?.[e]?.[u]||l,v=c.useMemo(()=>b,Object.values(b));return n.jsx(p.Provider,{value:v,children:g})};f.displayName=o+"Provider";function d(m,h,g={}){const{optional:b=!1}=g,p=h?.[e]?.[u]||l,v=c.useContext(p);if(v)return v;if(i!==void 0)return i;if(!b)throw new Error(`\`${m}\` must be used within \`${o}\``)}return[f,d]}const a=()=>{const o=s.map(i=>c.createContext(i));return function(l){const u=l?.[e]||o;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return a.scopeName=e,[r,tg(a,...t)]}function tg(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const i=r.reduce((l,{useScope:u,scopeName:f})=>{const m=u(o)[`__scope${f}`];return{...l,...m}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return s.scopeName=t.scopeName,s}var Hs=globalThis?.document?c.useLayoutEffect:()=>{},sg=fa[" useInsertionEffect ".trim().toString()]||Hs;function ng({prop:e,defaultProp:t,onChange:s=()=>{},caller:r}){const[a,o,i]=rg({defaultProp:t,onChange:s}),l=e!==void 0,u=l?e:a;{const d=c.useRef(e!==void 0);c.useEffect(()=>{const m=d.current;m!==l&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,r])}const f=c.useCallback(d=>{if(l){const m=ag(d)?d(e):d;m!==e&&i.current?.(m)}else o(d)},[l,e,o,i]);return[u,f]}function rg({defaultProp:e,onChange:t}){const[s,r]=c.useState(e),a=c.useRef(s),o=c.useRef(t);return sg(()=>{o.current=t},[t]),c.useEffect(()=>{a.current!==s&&(o.current?.(s),a.current=s)},[s,a]),[s,r,o]}function ag(e){return typeof e=="function"}function Fa(e){const t=c.forwardRef((s,r)=>{let{children:a,...o}=s,i=null,l=!1;const u=[];si(a)&&typeof yn=="function"&&(a=yn(a._payload)),c.Children.forEach(a,h=>{if(ug(h)){l=!0;const g=h;let b="child"in g.props?g.props.child:g.props.children;si(b)&&typeof yn=="function"&&(b=yn(b._payload)),i=ig(g,b),u.push(i?.props?.children)}else u.push(h)}),i?i=c.cloneElement(i,void 0,u):!l&&c.Children.count(a)===1&&c.isValidElement(a)&&(i=a);const f=i?cg(i):void 0,d=es(r,f);if(!i){if(a||a===0)throw new Error(l?hg(e):mg(e));return a}const m=lg(o,i.props??{});return i.type!==c.Fragment&&(m.ref=r?d:f),c.cloneElement(i,m)});return t.displayName=`${e}.Slot`,t}var Gj=Fa("Slot"),og=Symbol.for("radix.slottable"),ig=(e,t)=>{if("child"in e.props){const s=e.props.child;return c.isValidElement(s)?c.cloneElement(s,void 0,e.props.children(s.props.children)):null}return c.isValidElement(t)?t:null};function lg(e,t){const s={...t};for(const r in t){const a=e[r],o=t[r];/^on[A-Z]/.test(r)?a&&o?s[r]=(...l)=>{const u=o(...l);return a(...l),u}:a&&(s[r]=a):r==="style"?s[r]={...a,...o}:r==="className"&&(s[r]=[a,o].filter(Boolean).join(" "))}return{...e,...s}}function cg(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function ug(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===og}var dg=Symbol.for("react.lazy");function si(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===dg&&"_payload"in e&&fg(e._payload)}function fg(e){return typeof e=="object"&&e!==null&&"then"in e}var mg=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,hg=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,yn=fa[" use ".trim().toString()],pg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bt=pg.reduce((e,t)=>{const s=Fa(`Primitive.${t}`),r=c.forwardRef((a,o)=>{const{asChild:i,...l}=a,u=i?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(u,{...l,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function gg(e,t){e&&ma.flushSync(()=>e.dispatchEvent(t))}function Ws(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>((...s)=>t.current?.(...s)),[])}var xg="DismissableLayer",Yr="dismissableLayer.update",bg="dismissableLayer.pointerDownOutside",vg="dismissableLayer.focusOutside",ni,za=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),uc=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:l,onDismiss:u,...f}=e,d=c.useContext(za),[m,h]=c.useState(null),g=m?.ownerDocument??globalThis?.document,[,b]=c.useState({}),p=es(t,h),v=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=x?v.indexOf(x):-1,j=m?v.indexOf(m):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,N=j>=y,E=c.useRef(!1),C=kg(D=>{o?.(D),l?.(D),D.defaultPrevented||u?.()},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:c.useCallback(D=>{if(!(D instanceof Node))return!1;const P=[...d.branches].some(I=>I.contains(D));return N&&!P},[d.branches,N])}),k=Cg(D=>{if(r&&E.current)return;const P=D.target;[...d.branches].some(S=>S.contains(P))||(i?.(D),l?.(D),D.defaultPrevented||u?.())},g),R=m?j===v.length-1:!1,O=Ws(D=>{D.key==="Escape"&&(a?.(D),!D.defaultPrevented&&u&&(D.preventDefault(),u()))});return c.useEffect(()=>{if(R)return g.addEventListener("keydown",O,{capture:!0}),()=>g.removeEventListener("keydown",O,{capture:!0})},[g,R,O]),c.useEffect(()=>{if(m)return s&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(ni=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),ri(),()=>{s&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=ni))}},[m,g,s,d]),c.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),ri())},[m,d]),c.useEffect(()=>{const D=()=>b({});return document.addEventListener(Yr,D),()=>document.removeEventListener(Yr,D)},[]),n.jsx(bt.div,{...f,ref:p,style:{pointerEvents:w?N?"auto":"none":void 0,...e.style},onFocusCapture:Et(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Et(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Et(e.onPointerDownCapture,C.onPointerDownCapture)})});uc.displayName=xg;var yg="DismissableLayerBranch",wg=c.forwardRef((e,t)=>{const s=c.useContext(za),r=c.useRef(null),a=es(t,r);return c.useEffect(()=>{const o=r.current;if(o)return s.branches.add(o),()=>{s.branches.delete(o)}},[s.branches]),n.jsx(bt.div,{...e,ref:a})});wg.displayName=yg;function jg(){const e=c.useContext(za),[t,s]=c.useState(null);return c.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}var Sg=()=>!0;function kg(e,t){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=Sg}=t,l=Ws(e),u=c.useRef(!1),f=c.useRef(!1),d=c.useRef(new Map),m=c.useRef(()=>{});return c.useEffect(()=>{function h(){f.current=!1,a.current=!1,d.current.clear()}function g(){return Array.from(d.current.values()).some(Boolean)}function b(j){if(!f.current)return;const w=j.target;w instanceof Node&&[...o].some(E=>E.contains(w))||d.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{f.current&&m.current()},0)}function p(j){f.current&&d.current.set(j.type,!1)}const v=j=>{if(j.target&&!u.current){let w=function(){s.removeEventListener("click",m.current);const E=g();h(),E||dc(bg,l,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",m.current),h(),u.current=!1;return}const N={originalEvent:j};f.current=!0,a.current=r&&j.button===0,d.current.clear(),!r||j.button!==0?w():(s.removeEventListener("click",m.current),m.current=w,s.addEventListener("click",m.current,{once:!0}))}else s.removeEventListener("click",m.current),h();u.current=!1},x=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of x)s.addEventListener(j,b,!0),s.addEventListener(j,p);const y=window.setTimeout(()=>{s.addEventListener("pointerdown",v)},0);return()=>{window.clearTimeout(y),s.removeEventListener("pointerdown",v),s.removeEventListener("click",m.current);for(const j of x)s.removeEventListener(j,b,!0),s.removeEventListener(j,p)}},[s,l,r,a,o,i]),{onPointerDownCapture:()=>u.current=!0}}function Cg(e,t=globalThis?.document){const s=Ws(e),r=c.useRef(!1);return c.useEffect(()=>{const a=o=>{o.target&&!r.current&&dc(vg,s,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,s]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ri(){const e=new CustomEvent(Yr);document.dispatchEvent(e)}function dc(e,t,s,{discrete:r}){const a=s.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&a.addEventListener(e,t,{once:!0}),r?gg(a,o):a.dispatchEvent(o)}var wn=0,is=null;function Ng(){c.useEffect(()=>{is||(is={start:ai(),end:ai()});const{start:e,end:t}=is;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),wn++,()=>{wn===1&&(is?.start.remove(),is?.end.remove(),is=null),wn=Math.max(0,wn-1)}},[])}function ai(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Nr="focusScope.autoFocusOnMount",Er="focusScope.autoFocusOnUnmount",oi={bubbles:!1,cancelable:!0},Eg="FocusScope",fc=c.forwardRef((e,t)=>{const{loop:s=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...i}=e,[l,u]=c.useState(null),f=Ws(a),d=Ws(o),m=c.useRef(null),h=es(t,u),g=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let p=function(j){if(g.paused||!l)return;const w=j.target;l.contains(w)?m.current=w:St(m.current,{select:!0})},v=function(j){if(g.paused||!l)return;const w=j.relatedTarget;w!==null&&(l.contains(w)||St(m.current,{select:!0}))},x=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&St(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(x);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[r,l,g.paused]),c.useEffect(()=>{if(l){li.add(g);const p=document.activeElement;if(!l.contains(p)){const x=new CustomEvent(Nr,oi);l.addEventListener(Nr,f),l.dispatchEvent(x),x.defaultPrevented||(Ig(Dg(mc(l)),{select:!0}),document.activeElement===p&&St(l))}return()=>{l.removeEventListener(Nr,f),setTimeout(()=>{const x=new CustomEvent(Er,oi);l.addEventListener(Er,d),l.dispatchEvent(x),x.defaultPrevented||St(p??document.body,{select:!0}),l.removeEventListener(Er,d),li.remove(g)},0)}}},[l,f,d,g]);const b=c.useCallback(p=>{if(!s&&!r||g.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,x=document.activeElement;if(v&&x){const y=p.currentTarget,[j,w]=Tg(y);j&&w?!p.shiftKey&&x===w?(p.preventDefault(),s&&St(j,{select:!0})):p.shiftKey&&x===j&&(p.preventDefault(),s&&St(w,{select:!0})):x===y&&p.preventDefault()}},[s,r,g.paused]);return n.jsx(bt.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});fc.displayName=Eg;function Ig(e,{select:t=!1}={}){const s=document.activeElement;for(const r of e)if(St(r,{select:t}),document.activeElement!==s)return}function Tg(e){const t=mc(e),s=ii(t,e),r=ii(t.reverse(),e);return[s,r]}function mc(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)t.push(s.currentNode);return t}function ii(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):Rg(r,{upTo:t})))return r}function Rg(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Mg(e){return e instanceof HTMLInputElement&&"select"in e}function St(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Mg(e)&&t&&e.select()}}var li=Ag();function Ag(){let e=[];return{add(t){const s=e[0];t!==s&&s?.pause(),e=ci(e,t),e.unshift(t)},remove(t){e=ci(e,t),e[0]?.resume()}}}function ci(e,t){const s=[...e],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s}function Dg(e){return e.filter(t=>t.tagName!=="A")}var Og=fa[" useId ".trim().toString()]||(()=>{}),Pg=0;function Ir(e){const[t,s]=c.useState(Og());return Hs(()=>{s(r=>r??String(Pg++))},[e]),e||(t?`radix-${t}`:"")}var Lg="Portal",hc=c.forwardRef((e,t)=>{const{container:s,...r}=e,[a,o]=c.useState(!1);Hs(()=>o(!0),[]);const i=s||a&&globalThis?.document?.body;return i?ma.createPortal(n.jsx(bt.div,{...r,ref:t}),i):null});hc.displayName=Lg;function $g(e,t){return c.useReducer((s,r)=>t[s][r]??s,e)}var Xn=e=>{const{present:t,children:s}=e,r=Fg(t),a=typeof s=="function"?s({present:r.isPresent}):c.Children.only(s),o=zg(r.ref,_g(a));return typeof s=="function"||r.isPresent?c.cloneElement(a,{ref:o}):null};Xn.displayName="Presence";function Fg(e){const[t,s]=c.useState(),r=c.useRef(null),a=c.useRef(e),o=c.useRef("none"),i=c.useRef(void 0),l=e?"mounted":"unmounted",[u,f]=$g(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{u==="mounted"?(o.current=i.current??Ds(r.current),i.current=void 0):o.current="none"},[u]),Hs(()=>{const d=r.current,m=a.current;if(m!==e){const g=o.current,b=Ds(d);e?(i.current=b,f("MOUNT")):b==="none"||d?.display==="none"?f("UNMOUNT"):f(m&&g!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),Hs(()=>{if(t){let d;const m=t.ownerDocument.defaultView??window,h=b=>{const v=Ds(r.current).includes(CSS.escape(b.animationName));if(b.target===t&&v&&(f("ANIMATION_END"),!a.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",d=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},g=b=>{b.target===t&&(o.current=Ds(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{m.clearTimeout(d),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:c.useCallback(d=>{if(d){const m=getComputedStyle(d);r.current=m,i.current=Ds(m)}else r.current=null;s(d)},[])}}function ui(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function zg(...e){const t=c.useRef(e);return t.current=e,c.useCallback(s=>{const r=t.current;let a=!1;const o=r.map(i=>{const l=ui(i,s);return!a&&typeof l=="function"&&(a=!0),l});if(a)return()=>{for(let i=0;i<o.length;i++){const l=o[i];typeof l=="function"?l():ui(r[i],null)}}},[])}function Ds(e){return e?.animationName||"none"}function _g(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Bg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ls=new WeakMap,jn=new WeakMap,Sn={},Tr=0,pc=function(e){return e&&(e.host||pc(e.parentNode))},Kg=function(e,t){return t.map(function(s){if(e.contains(s))return s;var r=pc(s);return r&&e.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},Ug=function(e,t,s,r){var a=Kg(t,Array.isArray(e)?e:[e]);Sn[s]||(Sn[s]=new WeakMap);var o=Sn[s],i=[],l=new Set,u=new Set(a),f=function(m){!m||l.has(m)||(l.add(m),f(m.parentNode))};a.forEach(f);var d=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(h){if(l.has(h))d(h);else try{var g=h.getAttribute(r),b=g!==null&&g!=="false",p=(ls.get(h)||0)+1,v=(o.get(h)||0)+1;ls.set(h,p),o.set(h,v),i.push(h),p===1&&b&&jn.set(h,!0),v===1&&h.setAttribute(s,"true"),b||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),l.clear(),Tr++,function(){i.forEach(function(m){var h=ls.get(m)-1,g=o.get(m)-1;ls.set(m,h),o.set(m,g),h||(jn.has(m)||m.removeAttribute(r),jn.delete(m)),g||m.removeAttribute(s)}),Tr--,Tr||(ls=new WeakMap,ls=new WeakMap,jn=new WeakMap,Sn={})}},qg=function(e,t,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),a=Bg(e);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),Ug(r,a,s,"aria-hidden")):function(){return null}},Mn="right-scroll-bar-position",An="width-before-scroll-bar",Hg="with-scroll-bars-hidden",Wg="--removed-body-scroll-bar-size";function Rr(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Vg(e,t){var s=c.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(r){var a=s.value;a!==r&&(s.value=r,s.callback(r,a))}}}})[0];return s.callback=t,s.facade}var Qg=typeof window<"u"?c.useLayoutEffect:c.useEffect,di=new WeakMap;function Yg(e,t){var s=Vg(null,function(r){return e.forEach(function(a){return Rr(a,r)})});return Qg(function(){var r=di.get(s);if(r){var a=new Set(r),o=new Set(e),i=s.current;a.forEach(function(l){o.has(l)||Rr(l,null)}),o.forEach(function(l){a.has(l)||Rr(l,i)})}di.set(s,e)},[e]),s}function Gg(e){return e}function Xg(e,t){t===void 0&&(t=Gg);var s=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(o){var i=t(o,r);return s.push(i),function(){s=s.filter(function(l){return l!==i})}},assignSyncMedium:function(o){for(r=!0;s.length;){var i=s;s=[],i.forEach(o)}s={push:function(l){return o(l)},filter:function(){return s}}},assignMedium:function(o){r=!0;var i=[];if(s.length){var l=s;s=[],l.forEach(o),i=s}var u=function(){var d=i;i=[],d.forEach(o)},f=function(){return Promise.resolve().then(u)};f(),s={push:function(d){i.push(d),f()},filter:function(d){return i=i.filter(d),s}}}};return a}function Jg(e){e===void 0&&(e={});var t=Xg(null);return t.options=kt({async:!0,ssr:!1},e),t}var gc=function(e){var t=e.sideCar,s=Zi(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return c.createElement(r,kt({},s))};gc.isSideCarExport=!0;function Zg(e,t){return e.useMedium(t),gc}var xc=Jg(),Mr=function(){},Jn=c.forwardRef(function(e,t){var s=c.useRef(null),r=c.useState({onScrollCapture:Mr,onWheelCapture:Mr,onTouchMoveCapture:Mr}),a=r[0],o=r[1],i=e.forwardProps,l=e.children,u=e.className,f=e.removeScrollBar,d=e.enabled,m=e.shards,h=e.sideCar,g=e.noRelative,b=e.noIsolation,p=e.inert,v=e.allowPinchZoom,x=e.as,y=x===void 0?"div":x,j=e.gapMode,w=Zi(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=h,E=Yg([s,t]),C=kt(kt({},w),a);return c.createElement(c.Fragment,null,d&&c.createElement(N,{sideCar:xc,removeScrollBar:f,shards:m,noRelative:g,noIsolation:b,inert:p,setCallbacks:o,allowPinchZoom:!!v,lockRef:s,gapMode:j}),i?c.cloneElement(c.Children.only(l),kt(kt({},C),{ref:E})):c.createElement(y,kt({},C,{className:u,ref:E}),l))});Jn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Jn.classNames={fullWidth:An,zeroRight:Mn};var ex=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tx(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ex();return t&&e.setAttribute("nonce",t),e}function sx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function nx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var rx=function(){var e=0,t=null;return{add:function(s){e==0&&(t=tx())&&(sx(t,s),nx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ax=function(){var e=rx();return function(t,s){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},bc=function(){var e=ax(),t=function(s){var r=s.styles,a=s.dynamic;return e(r,a),null};return t},ox={left:0,top:0,right:0,gap:0},Ar=function(e){return parseInt(e||"",10)||0},ix=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[Ar(s),Ar(r),Ar(a)]},lx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ox;var t=ix(e),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-s+t[2]-t[0])}},cx=bc(),xs="data-scroll-locked",ux=function(e,t,s,r){var a=e.left,o=e.top,i=e.right,l=e.gap;return s===void 0&&(s="margin"),`
76
+ .`.concat(Hg,` {
77
+ overflow: hidden `).concat(r,`;
78
+ padding-right: `).concat(l,"px ").concat(r,`;
79
+ }
80
+ body[`).concat(xs,`] {
81
+ overflow: hidden `).concat(r,`;
82
+ overscroll-behavior: contain;
83
+ `).concat([t&&"position: relative ".concat(r,";"),s==="margin"&&`
84
+ padding-left: `.concat(a,`px;
85
+ padding-top: `).concat(o,`px;
86
+ padding-right: `).concat(i,`px;
87
+ margin-left:0;
88
+ margin-top:0;
89
+ margin-right: `).concat(l,"px ").concat(r,`;
90
+ `),s==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
91
+ }
92
+
93
+ .`).concat(Mn,` {
94
+ right: `).concat(l,"px ").concat(r,`;
95
+ }
96
+
97
+ .`).concat(An,` {
98
+ margin-right: `).concat(l,"px ").concat(r,`;
99
+ }
100
+
101
+ .`).concat(Mn," .").concat(Mn,` {
102
+ right: 0 `).concat(r,`;
103
+ }
104
+
105
+ .`).concat(An," .").concat(An,` {
106
+ margin-right: 0 `).concat(r,`;
107
+ }
108
+
109
+ body[`).concat(xs,`] {
110
+ `).concat(Wg,": ").concat(l,`px;
111
+ }
112
+ `)},fi=function(){var e=parseInt(document.body.getAttribute(xs)||"0",10);return isFinite(e)?e:0},dx=function(){c.useEffect(function(){return document.body.setAttribute(xs,(fi()+1).toString()),function(){var e=fi()-1;e<=0?document.body.removeAttribute(xs):document.body.setAttribute(xs,e.toString())}},[])},fx=function(e){var t=e.noRelative,s=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;dx();var o=c.useMemo(function(){return lx(a)},[a]);return c.createElement(cx,{styles:ux(o,!t,a,s?"":"!important")})},Gr=!1;if(typeof window<"u")try{var kn=Object.defineProperty({},"passive",{get:function(){return Gr=!0,!0}});window.addEventListener("test",kn,kn),window.removeEventListener("test",kn,kn)}catch{Gr=!1}var cs=Gr?{passive:!1}:!1,mx=function(e){return e.tagName==="TEXTAREA"},vc=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!mx(e)&&s[t]==="visible")},hx=function(e){return vc(e,"overflowY")},px=function(e){return vc(e,"overflowX")},mi=function(e,t){var s=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=yc(e,r);if(a){var o=wc(e,r),i=o[1],l=o[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},gx=function(e){var t=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[t,s,r]},xx=function(e){var t=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[t,s,r]},yc=function(e,t){return e==="v"?hx(t):px(t)},wc=function(e,t){return e==="v"?gx(t):xx(t)},bx=function(e,t){return e==="h"&&t==="rtl"?-1:1},vx=function(e,t,s,r,a){var o=bx(e,window.getComputedStyle(t).direction),i=o*r,l=s.target,u=t.contains(l),f=!1,d=i>0,m=0,h=0;do{if(!l)break;var g=wc(e,l),b=g[0],p=g[1],v=g[2],x=p-v-o*b;(b||x)&&yc(e,l)&&(m+=x,h+=b);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(d&&Math.abs(m)<1||!d&&Math.abs(h)<1)&&(f=!0),f},Cn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},hi=function(e){return[e.deltaX,e.deltaY]},pi=function(e){return e&&"current"in e?e.current:e},yx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wx=function(e){return`
113
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
114
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
115
+ `)},jx=0,us=[];function Sx(e){var t=c.useRef([]),s=c.useRef([0,0]),r=c.useRef(),a=c.useState(jx++)[0],o=c.useState(bc)[0],i=c.useRef(e);c.useEffect(function(){i.current=e},[e]),c.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var p=Wd([e.lockRef.current],(e.shards||[]).map(pi),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=c.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var x=Cn(p),y=s.current,j="deltaX"in p?p.deltaX:y[0]-x[0],w="deltaY"in p?p.deltaY:y[1]-x[1],N,E=p.target,C=Math.abs(j)>Math.abs(w)?"h":"v";if("touches"in p&&C==="h"&&E.type==="range")return!1;var k=window.getSelection(),R=k&&k.anchorNode,O=R?R===E||R.contains(E):!1;if(O)return!1;var D=mi(C,E);if(!D)return!0;if(D?N=C:(N=C==="v"?"h":"v",D=mi(C,E)),!D)return!1;if(!r.current&&"changedTouches"in p&&(j||w)&&(r.current=N),!N)return!0;var P=r.current||N;return vx(P,v,p,P==="h"?j:w)},[]),u=c.useCallback(function(p){var v=p;if(!(!us.length||us[us.length-1]!==o)){var x="deltaY"in v?hi(v):Cn(v),y=t.current.filter(function(N){return N.name===v.type&&(N.target===v.target||v.target===N.shadowParent)&&yx(N.delta,x)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var j=(i.current.shards||[]).map(pi).filter(Boolean).filter(function(N){return N.contains(v.target)}),w=j.length>0?l(v,j[0]):!i.current.noIsolation;w&&v.cancelable&&v.preventDefault()}}},[]),f=c.useCallback(function(p,v,x,y){var j={name:p,delta:v,target:x,should:y,shadowParent:kx(x)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(w){return w!==j})},1)},[]),d=c.useCallback(function(p){s.current=Cn(p),r.current=void 0},[]),m=c.useCallback(function(p){f(p.type,hi(p),p.target,l(p,e.lockRef.current))},[]),h=c.useCallback(function(p){f(p.type,Cn(p),p.target,l(p,e.lockRef.current))},[]);c.useEffect(function(){return us.push(o),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",u,cs),document.addEventListener("touchmove",u,cs),document.addEventListener("touchstart",d,cs),function(){us=us.filter(function(p){return p!==o}),document.removeEventListener("wheel",u,cs),document.removeEventListener("touchmove",u,cs),document.removeEventListener("touchstart",d,cs)}},[]);var g=e.removeScrollBar,b=e.inert;return c.createElement(c.Fragment,null,b?c.createElement(o,{styles:wx(a)}):null,g?c.createElement(fx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function kx(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Cx=Zg(xc,Sx);var jc=c.forwardRef(function(e,t){return c.createElement(Jn,kt({},e,{ref:t,sideCar:Cx}))});jc.classNames=Jn.classNames;var Nx=class extends ha{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,r=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:i,isRefetchError:l}=r,u=s.fetchMeta?.fetchMore?.direction,f=i&&u==="forward",d=a&&u==="forward",m=i&&u==="backward",h=a&&u==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Qd(t,s.data),hasPreviousPage:Vd(t,s.data),isFetchNextPageError:f,isFetchingNextPage:d,isFetchPreviousPageError:m,isFetchingPreviousPage:h,isRefetchError:l&&!f&&!m,isRefetching:o&&!d&&!h}}};function gi(e,t){const s=new Set(t);return e.filter(r=>!s.has(r))}function Ex(e,t,s){const r=e.slice(0);return r[t]=s,r}var Ix=class extends Yd{#s;#e;#a;#r;#t;#n;#o;#i;#l;#c=[];constructor(e,t,s){super(),this.#s=e,this.#r=s,this.#a=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#a=e,this.#r=t,Br.batch(()=>{const s=this.#t,r=this.#f(this.#a);r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const a=r.map(d=>d.observer),o=a.map(d=>d.getCurrentResult()),i=s.length!==a.length,l=a.some((d,m)=>d!==s[m]),u=i||l,f=u?!0:o.some((d,m)=>{const h=this.#e[m];return!h||!Gd(d,h)});!u&&!f||(u&&(this.#c=r,this.#t=a),this.#e=o,this.hasListeners()&&(u&&(gi(s,a).forEach(d=>{d.destroy()}),gi(a,s).forEach(d=>{d.subscribe(m=>{this.#m(d,m)})})),this.#h()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const s=this.#f(e),r=s.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),a=s.map(o=>o.defaultedQueryOptions.queryHash);return[r,o=>this.#d(o??r,t,a),()=>this.#u(r,s)]}#u(e,t){return t.map((s,r)=>{const a=e[r];return s.defaultedQueryOptions.notifyOnChangeProps?a:s.observer.trackResult(a,o=>{t.forEach(i=>{i.observer.trackProp(o)})})})}#d(e,t,s){if(t){const r=this.#l,a=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((o,i)=>o!==r[i]));return(!this.#n||this.#e!==this.#i||a||t!==this.#o)&&(this.#o=t,this.#i=this.#e,s!==void 0&&(this.#l=s),this.#n=Xd(this.#n,t(e))),this.#n}return e}#p(){return this.#r?.combine!==void 0&&this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#f(e){const t=new Map;this.#t.forEach(r=>{const a=r.options.queryHash;if(!a)return;const o=t.get(a);o?o.push(r):t.set(a,[r])});const s=[];return e.forEach(r=>{const a=this.#s.defaultQueryOptions(r),i=t.get(a.queryHash)?.shift()??new ha(this.#s,a);s.push({defaultedQueryOptions:a,observer:i})}),s}#m(e,t){const s=this.#t.indexOf(e);s!==-1&&(this.#e=Ex(this.#e,s,t),this.#h())}#h(){if(this.hasListeners()){const e=this.#u(this.#e,this.#c),t=this.#p(),s=this.#n,r=t?s:this.#d(e,this.#r?.combine);(t||s!==r)&&Br.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function Lt({queries:e,...t},s){const r=we(),a=Jd(),o=Zd(),i=c.useMemo(()=>e.map(p=>{const v=r.defaultQueryOptions(p);return v._optimisticResults=a?"isRestoring":"optimistic",v}),[e,r,a]);i.forEach(p=>{ef(p);const v=r.getQueryCache().get(p.queryHash);tf(p,o,v)}),sf(o);const[l]=c.useState(()=>new Ix(r,i,t)),[u,f,d]=l.getOptimisticResult(i,t.combine),m=!a&&t.subscribed!==!1;c.useSyncExternalStore(c.useCallback(p=>m?l.subscribe(Br.batchCalls(p)):nf,[l,m]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),c.useEffect(()=>{l.setQueries(i,t)},[i,t,l]);const g=u.some((p,v)=>yo(i[v],p))?u.flatMap((p,v)=>{const x=i[v];if(x&&yo(x,p)){const y=new ha(r,x);return rf(x,y,o)}return[]}):[];if(g.length>0)throw Promise.all(g);const b=u.find((p,v)=>{const x=i[v];return x&&af({result:p,errorResetBoundary:o,throwOnError:x.throwOnError,query:r.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(b?.error)throw b.error;return f(d())}function Sc(e,t){return of(e,Nx)}function Tx(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),r=e.blockerFn;return{shouldBlockFn:async()=>s&&r!==void 0?await r():s,enableBeforeUnload:s,withResolver:r===void 0}}function Rx(e,t){const{shouldBlockFn:s,enableBeforeUnload:r=!0,disabled:a=!1,withResolver:o=!1}=Tx(e),i=pa(),{history:l}=i,[u,f]=c.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return c.useEffect(()=>{const d=async m=>{function h(x){const y=i.parseLocation(x),j=i.getMatchedRoutes(y.pathname);return j.foundRoute===void 0?{routeId:"__notFound__",fullPath:y.pathname,pathname:y.pathname,params:j.routeParams,search:i.options.parseSearch(x.search)}:{routeId:j.foundRoute.id,fullPath:j.foundRoute.fullPath,pathname:y.pathname,params:j.routeParams,search:i.options.parseSearch(x.search)}}const g=h(m.currentLocation),b=h(m.nextLocation);if(g.routeId==="__notFound__"&&b.routeId!=="__notFound__")return!1;const p=await s({action:m.action,current:g,next:b});if(!o)return p;if(!p)return!1;const v=await new Promise(x=>{f({status:"blocked",current:g,next:b,action:m.action,proceed:()=>x(!1),reset:()=>x(!0)})});return f({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),v};return a?void 0:l.block({blockerFn:d,enableBeforeUnload:r})},[s,r,a,o,l,i]),u}function gt(e){const t=pa({warn:e?.router===void 0}),s=e?.router||t;return el(s.stores.__store,tl(e,s))}function Zn(e){const t=pa();return el(t.stores.location,tl(e,t))}const Mx=new Set(["outbox","flagged"]),Ax=e=>{const[,t,s]=e.split(/[?#]/)[0].split("/");return t!=="mail"||!s?!1:!Mx.has(s)};function Dx(e){const t=Lt({queries:e.map(s=>({...ze({path:{accountId:s.accountId}}),staleTime:1/0}))});for(const[s,r]of e.entries()){const a=t[s];if(!a||a.isPending)return;const o=a.data?.items??[];if(o.length===0)continue;const i=Gs(r.folderAppointments);return(o.find(u=>i.get(u.mailboxId)==="inbox")??o[0])?.mailboxId}}function kc(e){const{openCompose:t}=Mt(),s=Oe(),r=Zn(),a=Dx(e);return c.useCallback(()=>{if(Ax(r.pathname)){c.startTransition(()=>{t({mode:"new"})});return}a&&(c.startTransition(()=>{t({mode:"new"})}),s({to:"/mail/$mailboxId",params:{mailboxId:a}}))},[t,s,r.pathname,a])}const Ox=e=>e.startsWith("/mail")||e.startsWith("/settings"),Px=({accounts:e})=>{const{state:t}=Mt(),s=Zn(),r=kc(e),a=s.search,o=typeof a?.selectedMessageId=="string"&&a.selectedMessageId.length>0;return!Ox(s.pathname)||t.isOpen||o?null:n.jsx("button",{type:"button",onClick:r,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(env(safe-area-inset-bottom, 0) + 1rem)"},children:n.jsx(zm,{className:"size-6"})})},Cc=({trigger:e,children:t,align:s="right"})=>{const[r,a]=c.useState(!1),o=c.useRef(null),i=c.useCallback(u=>{o.current&&!o.current.contains(u.target)&&a(!1)},[]),l=c.useCallback(u=>{u.key==="Escape"&&a(!1)},[]);return c.useEffect(()=>(r&&(document.addEventListener("mousedown",i),document.addEventListener("keydown",l)),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}),[r,i,l]),n.jsxs("div",{ref:o,className:"relative",children:[n.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),a(!r)},className:xe("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&n.jsx("div",{className:xe("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",s==="right"?"right-0":"left-0"),children:t})]})},hs=({onClick:e,disabled:t,destructive:s,children:r})=>n.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t||e()},disabled:t,className:xe("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",s&&"text-danger hover:text-danger"),children:r}),Xr=()=>n.jsx("div",{className:"my-1 h-px bg-line"}),Nc=({children:e})=>{const{Account:t}=ga();return n.jsx(t,{children:e})},Lx=({email:e,onSignOut:t})=>{const s=Oe(),r=e??"Account";return n.jsxs(Cc,{trigger:n.jsx(dt,{name:r,email:e??void 0,size:"sm"}),align:"right",children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"px-3 py-2 text-xs text-fg-muted truncate",title:e,"data-testid":"account-menu-email",children:e}),n.jsx(Xr,{})]}),n.jsxs(hs,{onClick:()=>s({to:"/settings/accounts"}),children:[n.jsx(Da,{className:"size-4"}),"Settings"]}),n.jsx(Xr,{}),n.jsxs(hs,{onClick:t,children:[n.jsx(Bl,{className:"size-4"}),"Sign out"]})]})},$x=()=>n.jsx(Nc,{children:({email:e,signOut:t})=>n.jsx(Lx,{email:e,onSignOut:t})}),xi=()=>{const e=xa(),t=ba(e);window.open(t,"_blank","noopener,noreferrer")};function Ec({variant:e="icon"}){return e==="drawer"?n.jsxs("button",{type:"button",onClick:xi,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[n.jsx(Ro,{className:"size-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate text-left",children:"Report a bug"})]}):n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Ro,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:xi})}const Ic="/mail/",_a="/mail/$mailboxId",Tc="/mail/outbox",Rc="/mail/flagged";function Ba(e){return e.some(t=>t.routeId===Ic)}function rn(e){return e.some(t=>t.routeId===Rc)}function er(e){return e.some(t=>t.routeId===Tc)}function Mc(e){return e.some(t=>t.routeId===_a)}function Fx(e){const t=e.find(s=>s.params?.mailboxId)?.params?.mailboxId;return t?`${_a}:${t}`:rn(e)?Rc:er(e)?Tc:Ba(e)?Ic:""}const Dn="search-scope";function zx(e){const t=e.trim().replace(/\s+/g," ").toLowerCase();return/\s/.test(t)?`in:"${t}"`:`in:${t}`}function Ac(e){return rn(e)||er(e)||Mc(e)}function Dc(e){return e.find(t=>t.routeId===_a)?.params?.mailboxId}function _x(e){const t=Dc(e.matches);return t||(Ac(e.matches)?e.callerMailboxId:e.callerMailboxId??e.inTokenMailboxId)}function Bx(e,t){return Ba(e)?{kind:"global"}:rn(e)?{kind:"scoped",chip:{id:Dn,label:"is:starred"}}:er(e)?{kind:"scoped",chip:{id:Dn,label:"in:outbox"}}:Mc(e)?t?{kind:"scoped",chip:{id:Dn,label:zx(t)}}:{kind:"pending"}:{kind:"global"}}function Kx(e,t,s){return t.kind==="global"?{kind:"global"}:rn(e)?{kind:"collection"}:{kind:"folder",...s?{role:s}:{}}}const Oc=({accounts:e})=>{const t=va({strict:!1}),s=Zn(),r=t.mailboxId,{t:a}=Un("mail",{useSuspense:!1}),o=c.useCallback((l,u)=>a(l,{defaultValue:u}),[a]),i=Lt({queries:e.map(l=>({...ze({path:{accountId:l.accountId}}),staleTime:1/0}))});if(s.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let l=0;l<e.length;l++){const u=i[l]?.data?.items;if(!u)continue;const f=u.find(m=>m.mailboxId===r);if(!f)continue;const d=Gs(e[l].folderAppointments);return bs(f,d.get(r),o)}return null},Ux=({accounts:e})=>{const s=va({strict:!1}).mailboxId,r=Lt({queries:e.map(a=>({...ze({path:{accountId:a.accountId}}),staleTime:1/0}))});if(!s)return null;for(const a of r){const o=a.data?.items;if(!o)continue;const i=o.find(l=>l.mailboxId===s);if(i)return i.unseenCount}return null};function Pc(e){const t=Oe(),{searchInput:s}=Ce(),r=Oc({accounts:e}),a=gt({select:l=>l.matches}),o=Bx(a,r),i=c.useCallback(l=>{l===Dn&&t({to:"/mail",search:{q:s||void 0,selectedMessageId:void 0}})},[t,s]);return{scope:o,clearScope:i}}const Lc=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus next message"},{action:"focusPrevious",keys:["k"],description:"Focus previous message"},{action:"focusNext",keys:["↓"],description:"Focus next message"},{action:"focusPrevious",keys:["↑"],description:"Focus previous message"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function qx(e){for(const t of Lc){const s=t.hints.find(r=>r.action===e);if(s)return s.keys}}function fs(e){const t=qx(e);return!t||t.length===0?"":t.length===1?`(${t[0]})`:t[0]==="g"?`(${t.join(" then ")})`:`(${t.join("")})`}const Hx={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function Wx({accounts:e}){const{searchInput:t,onSearchChange:s,onSearchClear:r,onSearchClearQuery:a}=Ce(),o=kc(e),{scope:i,clearScope:l}=Pc(e),u=i.kind==="scoped"?[{id:i.chip.id,label:i.chip.label,tone:"scope"}]:void 0,f=Hx[i.kind];return n.jsx(Yh,{search:n.jsx(Pa,{value:t,onChange:s,onClear:r,onClearQuery:a,chips:u,onRemoveChip:l,placeholder:f,size:"lg"}),actions:n.jsxs(n.Fragment,{children:[n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(Km,{className:"size-4"}),title:`Compose ${fs("compose")}`,"aria-label":"Compose",onClick:o}),n.jsx(Ec,{}),n.jsx($x,{})]})})}const Ka=({isOpen:e,onClose:t,children:s,ariaLabel:r="Navigation",side:a="left",widthClassName:o="w-[80vw] max-w-[320px]"})=>{const i=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{if(!e)return;l.current=document.activeElement;const f=h=>{h.key==="Escape"&&(h.preventDefault(),t())};document.addEventListener("keydown",f),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",f),document.body.style.overflow=m,l.current?.focus()}},[e,t]),!e)return null;const u=a==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return n.jsxs("div",{className:"fixed inset-0 z-50 lg:hidden",role:"dialog","aria-modal":"true","aria-label":r,children:[n.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"}),n.jsxs("div",{ref:i,className:xe("absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,u),children:[n.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:n.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:n.jsx(We,{className:"size-5"})})}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},Vx=e=>{const t=e.filter(a=>!a.isMultipart&&a.disposition!=="attachment"&&a.mediaType==="TEXT"&&a.contentUrl.length>0),s=t.find(a=>a.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(a=>a.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},Jr={all:["messages"],detail:e=>[...Jr.all,"detail",e],body:e=>[...Jr.detail(e),"body"]};class Ht extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,a){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=a}}const Qx=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},Yx=8,Gx="x-remit-403-reason",Xx=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Jx=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,Zx=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},eb=async(e,t,s=async()=>null)=>{const r={},a=await s();a&&(r.Authorization=`Bearer ${a}`);const o=await lf(e,{headers:r});if(o.status===202)throw new Ht("not-ready","Message body is still syncing",202,Qx(o.headers.get("Retry-After")));if(!o.ok){const u=o.headers.get(Gx),f=Xx(o.status,u);throw new Ht(f,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const i=o.headers.get("content-type");if(Zx(t,i))throw new Ht("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${i}`);const l=await o.text();if(Jx(l,i))throw new Ht("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return l},tb=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),$c=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?Vx(t):null,a=Xs(),{getToken:o}=ga(),i=c.useRef(null),l=we(),u=c.useRef(!1),f=c.useRef(null),d=e&&r?`${e}:${r.contentUrl}`:null;f.current!==d&&(f.current=d,u.current=!1);const m=de({queryKey:e?[...Jr.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const b=u.current;return u.current=!1,tb({fetchContent:(p,v)=>eb(p,v,o),refetchDescribeMessage:()=>l.refetchQueries({queryKey:sl({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:b})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(b,p)=>p instanceof Ht&&p.reason==="not-ready"?b<Yx:b<1,retryDelay:(b,p)=>p instanceof Ht&&p.reason==="not-ready"?(u.current=!0,(p.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),h=m.isLoading&&!!r;c.useEffect(()=>{h&&(i.current=performance.now())},[h]),c.useEffect(()=>{m.isSuccess&&i.current!==null&&(a.recordTiming("message.body.load",Math.round(performance.now()-i.current)),i.current=null)},[m.isSuccess,a]);const g=m.data&&r?{kind:r.kind,body:m.data}:void 0;return{picked:r,data:g,isLoading:h,isError:m.isError,error:m.error,refetch:m.refetch}},sb=({outboxMessageId:e,onDraftCreated:t})=>{const[s,r]=c.useState("idle"),[a,o]=c.useState(null),i=c.useRef(void 0),l=we(),u=ye(nl()),f=ye(cf()),d=c.useCallback(async b=>{if(r("saving"),o(null),e){const v=await f.mutateAsync({path:{outboxMessageId:e},body:{toAddresses:b.toAddresses,ccAddresses:b.ccAddresses,bccAddresses:b.bccAddresses,subject:b.subject,textBody:b.textBody,htmlBody:b.htmlBody,inReplyTo:b.inReplyTo,references:b.references}});return r("saved"),v}const p=await u.mutateAsync({body:{...b,sendImmediately:!1}});return t(p.outboxMessageId),r("saved"),l.invalidateQueries({queryKey:qn().queryKey}),p},[e,u,f,t,l]),m=c.useCallback(b=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{d(b).catch(p=>{o(p),r("error")})},2e3)},[d]),h=c.useCallback(b=>(i.current&&clearTimeout(i.current),d(b)),[d]),g=c.useCallback(()=>{i.current&&clearTimeout(i.current)},[]);return{saveStatus:s,saveError:a,saveDraft:m,saveImmediately:h,cancelAutoSave:g}},Fc=e=>"text"in e&&!("children"in e),zc=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),nb=e=>{let t=zc(e.text);return e.bold&&(t=`<strong>${t}</strong>`),e.italic&&(t=`<em>${t}</em>`),t},_c=e=>{const t=e.children.map(s=>Fc(s)?nb(s):_c(s)).join("");switch(e.type){case"blockquote":return`<blockquote>${t}</blockquote>`;case"a":{const s=e.url??"";return`<a href="${zc(s)}">${t}</a>`}default:return`<p>${t}</p>`}},bi=e=>e.map(_c).join(""),Bc=e=>Fc(e)?e.text:e.children.map(Bc).join(""),Zr=e=>e.map(Bc).join(`
116
+ `),rb=e=>e.displayName?`${e.displayName} <${e.normalizedEmail}>`:e.normalizedEmail,vi=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()),ab=e=>{const t=e.trim();if(!t)return;const s=t.match(/^(.+?)\s*<([^>]+)>$/);if(s){const r=s[1].trim(),a=s[2].trim();if(vi(a))return{email:a,displayName:r}}if(vi(t))return{email:t}},Dr=({label:e,addresses:t,onChange:s,placeholder:r})=>{const[a,o]=c.useState(""),[i,l]=c.useState(-1),[u,f]=c.useState(!1),d=c.useRef(null),m=c.useRef(null),h=hl(a,200),{data:g}=de({...rl({query:{q:h,limit:8}}),enabled:h.length>=2}),b=g?.items??[],p=new Set(t.map(C=>C.email.toLowerCase())),v=b.filter(C=>!p.has(C.normalizedEmail.toLowerCase()));c.useEffect(()=>{l(-1),f(v.length>0&&a.length>=2)},[v.length,a.length]);const x=c.useCallback(C=>{p.has(C.email.toLowerCase())||(s([...t,C]),o(""),f(!1))},[t,p,s]),y=c.useCallback(C=>{s(t.filter((k,R)=>R!==C))},[t,s]),j=c.useCallback(C=>{x({email:C.normalizedEmail,displayName:C.displayName}),d.current?.focus()},[x]),w=c.useCallback(()=>{const C=ab(a);C&&x(C)},[a,x]),N=c.useCallback(C=>{if(C.key==="Backspace"&&a===""&&t.length>0){y(t.length-1);return}if(C.key==="Enter"||C.key==="Tab"||C.key===","){if(i>=0&&v[i]){C.preventDefault(),j(v[i]);return}a.trim()&&(C.preventDefault(),w());return}if(C.key==="ArrowDown"&&u){C.preventDefault(),l(k=>k<v.length-1?k+1:0);return}if(C.key==="ArrowUp"&&u){C.preventDefault(),l(k=>k>0?k-1:v.length-1);return}C.key==="Escape"&&(f(!1),l(-1))},[a,t.length,i,v,u,y,j,w]),E=c.useCallback(()=>{setTimeout(()=>{w(),f(!1)},150)},[w]);return n.jsxs("div",{className:"relative",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("label",{htmlFor:`address-field-${e}`,className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:[e,":"]}),n.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-1 min-h-[36px] px-2 py-1 border rounded-md bg-canvas cursor-text",onClick:()=>d.current?.focus(),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&d.current?.focus()},children:[t.map((C,k)=>n.jsx(Wm,{email:C.email,displayName:C.displayName,onRemove:()=>y(k)},C.email)),n.jsx("input",{ref:d,id:`address-field-${e}`,type:"text",value:a,onChange:C=>o(C.target.value),onKeyDown:N,onBlur:E,placeholder:t.length===0?r:"",className:"flex-1 min-w-[120px] bg-transparent outline-none text-sm py-0.5"})]})]}),u&&v.length>0&&n.jsx("ul",{ref:m,className:"absolute left-12 right-0 mt-1 bg-surface border border-line rounded-md shadow-lg z-50 max-h-[200px] overflow-auto",children:v.map((C,k)=>n.jsx("li",{className:xe("px-3 py-2 text-sm cursor-pointer transition-colors",k===i&&"bg-accent-2-soft"),onMouseDown:R=>{R.preventDefault(),j(C)},onMouseEnter:()=>l(k),children:rb(C)},C.addressId))})]})},ob=({accountId:e})=>{const t=Oe();return n.jsxs("div",{role:"alert","data-testid":"compose-smtp-missing-banner",className:"flex items-start gap-3 border-b border-warning/50 bg-warning/10 px-3 py-2",children:[n.jsx(da,{className:"size-5 shrink-0 mt-0.5 text-warning","aria-hidden":"true"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium text-warning",children:"This account can't send mail until SMTP is configured."}),n.jsxs("button",{type:"button",onClick:()=>{t({to:"/settings/accounts",search:{editAccountId:e,focusSmtp:!0}})},className:"mt-1 inline-flex items-center gap-1 text-xs font-medium text-warning hover:underline",children:["Configure SMTP",n.jsx(Rm,{className:"size-3","aria-hidden":"true"})]})]})]})},yi=150,ib=()=>{const[e,t]=c.useState(()=>{if(typeof window>"u"||!window.visualViewport)return{viewportHeight:0,isKeyboardOpen:!1};const s=window.visualViewport.height;return{viewportHeight:s,isKeyboardOpen:window.innerHeight-s>yi}});return c.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const s=window.visualViewport,r=()=>{const a=s.height;t({viewportHeight:a,isKeyboardOpen:window.innerHeight-a>yi})};return r(),s.addEventListener("resize",r),()=>s.removeEventListener("resize",r)},[]),e},lb=({selectedAccountId:e,onSelect:t})=>{const{data:s}=de({...xt(),staleTime:1/0}),r=s?.accounts??[];if(c.useEffect(()=>{!e&&r.length===1&&r[0]&&t(r[0])},[e,r,t]),r.length<=1){const a=r[0];return a?n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),n.jsx("div",{className:"text-sm py-1.5",children:a.email})]}):null}return n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("label",{htmlFor:"from-account-selector",className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"From:"}),n.jsx("select",{id:"from-account-selector",value:e??"",onChange:a=>{const o=r.find(i=>i.accountId===a.target.value);o&&t(o)},className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",children:r.map(a=>n.jsx("option",{value:a.accountId,children:a.email},a.accountId))})]})},cb=({value:e,onChange:t})=>n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("label",{className:"text-sm text-fg-muted shrink-0 w-12 pt-1.5",children:"Subj:"}),n.jsx("input",{type:"text",value:e,onChange:s=>t(s.target.value),className:"flex-1 px-2 py-1.5 border rounded-md bg-canvas text-sm",placeholder:"Subject","data-subject-field":!0})]}),ub=["p","br","strong","b","em","i","a","blockquote","ul","ol","li"],db=["href"],fb=e=>Gi.sanitize(e,{ALLOWED_TAGS:ub,ALLOWED_ATTR:db}),mb=c.lazy(()=>df(()=>import("./ComposeBody-CXluR0mJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(e=>({default:e.ComposeBody}))),hb=()=>n.jsxs("div",{className:"min-h-[120px] px-3 py-2",children:[n.jsx("div",{className:"h-8 mb-2 rounded bg-surface-sunken animate-pulse"}),n.jsx("div",{className:"min-h-[80px] rounded bg-surface-sunken/50 animate-pulse"})]}),Kc=[{type:"p",children:[{text:""}]}],pb=[{type:"p",children:[{text:""}]},{type:"p",children:[{text:"-- "}]}],gb=e=>e?[...pb,{type:"p",children:[{text:e}]}]:Kc,xb=e=>e?/^re:\s/i.test(e)?e:`Re: ${e}`:"Re: ",bb=e=>e?/^fwd?:\s/i.test(e)?e:`Fwd: ${e}`:"Fwd: ",vb=(e,t,s)=>{const{envelope:r}=e,o=(r.replyTo.length>0?r.replyTo:r.from).map(f=>({email:f.normalizedEmail,displayName:f.displayName}));if(t!=="reply_all")return{to:o,cc:[]};const i=s?.toLowerCase(),l=new Set(o.map(f=>f.email.toLowerCase())),u=[...r.to,...r.cc].filter(f=>f.normalizedEmail.toLowerCase()!==i&&!l.has(f.normalizedEmail.toLowerCase())).map(f=>({email:f.normalizedEmail,displayName:f.displayName}));return{to:o,cc:u}},yb=e=>{const t=e.envelope.messageIdValue,r=[...e.references.filter(a=>a.referenceType==="references").sort((a,o)=>a.referenceOrder-o.referenceOrder).map(a=>a.messageIdValue)];return t&&!r.includes(t)&&r.push(t),{inReplyTo:t,references:r}},wb=(e,t,s,r,a)=>e.length===0&&t.length===0&&s.length===0&&r.trim()===""&&Zr(a).trim()==="",jb=({selectedAccountId:e,onAccountChange:t,toAddresses:s,setToAddresses:r,ccAddresses:a,setCcAddresses:o,bccAddresses:i,setBccAddresses:l,showCc:u,setShowCc:f,showBcc:d,setShowBcc:m,subject:h,setSubject:g})=>{const b=At(),{isKeyboardOpen:p}=ib();if(!b&&p){const x=[];return s.length>0&&x.push(`To: ${s.map(y=>y.displayName??y.email).join(", ")}`),a.length>0&&x.push(`Cc: ${a.length}`),i.length>0&&x.push(`Bcc: ${i.length}`),h&&x.push(h),n.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-line overflow-hidden","data-testid":"compose-header-collapsed",children:[n.jsx("span",{className:"truncate text-xs text-fg-muted",children:x.length>0?x.join(" · "):"…"}),n.jsx("span",{className:"shrink-0 inline-flex items-center justify-center rounded bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-muted",children:"…"})]})}return n.jsxs("div",{className:"space-y-1 px-3 py-2 border-b border-line",children:[n.jsx(lb,{selectedAccountId:e,onSelect:t}),n.jsx(Dr,{label:"To",addresses:s,onChange:r,placeholder:"Recipients"}),u?n.jsx(Dr,{label:"Cc",addresses:a,onChange:o}):n.jsxs("div",{className:"flex gap-2 pl-14",children:[n.jsx("button",{type:"button",onClick:()=>f(!0),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:"Cc"}),n.jsx("button",{type:"button",onClick:()=>m(!0),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:"Bcc"})]}),u&&!d&&n.jsx("div",{className:"pl-14",children:n.jsx("button",{type:"button",onClick:()=>m(!0),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:"Bcc"})}),d&&n.jsx(Dr,{label:"Bcc",addresses:i,onChange:l}),n.jsx(cb,{value:h,onChange:g})]})},Ua=({mode:e,account:t,sourceMessage:s,onClose:r,onAccountChange:a})=>{const{state:o,setOutboxMessageId:i,startSendPolling:l}=Mt(),{pushError:u}=Je(),{outboxMessageId:f}=o,[d,m]=c.useState([]),[h,g]=c.useState([]),[b,p]=c.useState([]),[v,x]=c.useState(""),[y,j]=c.useState(!1),[w,N]=c.useState(!1),[E,C]=c.useState(t?.accountId),[k,R]=c.useState(!1),O=c.useRef(f);c.useEffect(()=>{O.current!==f&&(O.current=f,f&&(m([]),g([]),p([]),x(""),j(!1),N(!1),I(Kc),R(!1)))},[f]);const{signature:D}=Ff(E),[P,I]=c.useState(()=>gb(D.plainText)),{data:S}=de({...uf({path:{outboxMessageId:f??""}}),enabled:!!f&&!k});c.useEffect(()=>{!S||k||(m(S.toAddresses.map(G=>({email:G,displayName:void 0}))),S.ccAddresses&&S.ccAddresses.length>0&&(g(S.ccAddresses.map(G=>({email:G,displayName:void 0}))),j(!0)),S.bccAddresses&&S.bccAddresses.length>0&&(p(S.bccAddresses.map(G=>({email:G,displayName:void 0}))),N(!0)),S.subject&&x(S.subject),S.textBody&&I([{type:"p",children:[{text:S.textBody}]}]),C(S.accountId),R(!0))},[S,k]),c.useEffect(()=>{if(s){if(e==="reply"||e==="reply_all"){const{to:G,cc:ae}=vb(s,e,t?.email);m(G),g(ae),ae.length>0&&j(!0),x(xb(s.envelope.subject))}e==="forward"&&x(bb(s.envelope.subject))}},[e,s,t?.email]);const A=e==="reply"||e==="reply_all"||e==="forward",{data:L}=$c({messageId:s?.message.messageId,bodyParts:s?.bodyParts,enabled:A&&!!s}),T=L?.kind==="text"?L.body:"",F=L?.kind==="html"?fb(L.body):void 0,M=s?.envelope.from[0]?.displayName??s?.envelope.from[0]?.normalizedEmail,{saveStatus:$,saveError:K,saveDraft:B,cancelAutoSave:J}=sb({outboxMessageId:f,onDraftCreated:i});c.useEffect(()=>{K&&u({title:"Couldn't save draft",detail:lt(K)??"Saving the draft failed.",error:K})},[K,u]);const ee=ye(nl()),X=ye(al()),me=ye({...Hn(),onError:G=>{u(Vt("Couldn't discard draft","The draft wasn't discarded.",G))}}),{data:ue}=de({...xt(),staleTime:1/0}),te=ue?.accounts.find(G=>G.accountId===E),U=te?Lf(te):!1,H=ee.isPending||X.isPending,re=d.length>0&&!!E&&!U;c.useEffect(()=>{if(!E||f&&!k||wb(d,h,b,v,P))return;const G=Zr(P),ae=bi(P);B({accountId:E,toAddresses:d.map(le=>le.email),ccAddresses:h.length>0?h.map(le=>le.email):void 0,bccAddresses:b.length>0?b.map(le=>le.email):void 0,subject:v||void 0,textBody:G||void 0,htmlBody:ae||void 0})},[E,f,k,d,h,b,v,P,B]);const Ie=c.useCallback(async()=>{if(!E||d.length===0)return;J();const G=s&&(e==="reply"||e==="reply_all")?yb(s):{};let ae=f,le=!1;if(!ae){const Fe=Zr(P),pe=bi(P),ge=await ee.mutateAsync({body:{accountId:E,toAddresses:d.map(Se=>Se.email),ccAddresses:h.length>0?h.map(Se=>Se.email):void 0,bccAddresses:b.length>0?b.map(Se=>Se.email):void 0,subject:v||void 0,textBody:Fe||void 0,htmlBody:pe||void 0,sendImmediately:!0,...G}}).catch(Se=>(u({title:"Couldn't send message",detail:lt(Se)??"Saving the draft failed.",error:Se}),null));if(ge===null)return;ae=ge.outboxMessageId,le=!0,i(ae)}await X.mutateAsync({path:{outboxMessageId:ae}}).catch(Fe=>(u({title:"Couldn't send message",detail:lt(Fe)??(le?"The draft was saved but the send request failed. Try again from the Outbox.":"The send request failed. Try again."),error:Fe}),null))!==null&&(l(ae),r())},[E,d,h,b,v,P,e,s,f,ee,X,J,l,i,u,r]),je=c.useCallback(()=>{J(),f&&me.mutate({path:{outboxMessageId:f}}),r()},[J,f,me,r]),V=c.useCallback(G=>{C(G.accountId),a?.(G)},[a]);return n.jsx(Zh,{banner:te&&U?n.jsx(ob,{accountId:te.accountId}):void 0,header:n.jsx(jb,{selectedAccountId:E,onAccountChange:V,toAddresses:d,setToAddresses:m,ccAddresses:h,setCcAddresses:g,bccAddresses:b,setBccAddresses:p,showCc:y,setShowCc:j,showBcc:w,setShowBcc:N,subject:v,setSubject:x}),quoted:T||F?n.jsx(kp,{text:T,html:F,senderName:M}):void 0,actionBar:n.jsx(Jh,{onSend:Ie,onDiscard:je,sending:H,canSend:re,saveStatus:$,unavailableReason:U?"SMTP not configured":void 0,onUnavailable:G=>u({title:"Can't send yet",detail:G})}),children:n.jsx(c.Suspense,{fallback:n.jsx(hb,{}),children:n.jsx(mb,{value:P,onChange:I,onSubmit:Ie,autoFocus:e==="new"})})})},wi=({mode:e,account:t,sourceMessage:s,onClose:r})=>n.jsx("div",{className:"border-t border-line bg-canvas max-h-[400px] flex flex-col",children:n.jsx(Ua,{mode:e,account:t,sourceMessage:s,onClose:r})}),Uc=({message:e,icon:t})=>n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&n.jsx("div",{className:"mb-4 text-fg-muted",children:t}),n.jsx("p",{className:"text-fg-muted",children:e})]}),qa=({enabled:e=!0,bindings:t,capture:s=!1})=>{const r=c.useCallback(a=>{const o=a.target;if(!(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable))for(const i of t){if(!(a.key.toLowerCase()===i.key.toLowerCase())||i.requireShift!==void 0&&i.requireShift!==a.shiftKey)continue;const u=a.ctrlKey||a.metaKey;if(i.requireMeta!==void 0){if(i.requireMeta!==u)continue}else{const f=i.noModifiers??!0,d=u||a.altKey||i.requireShift===void 0&&a.shiftKey;if(f&&d)continue}i.preventDefault&&a.preventDefault(),i.stopPropagation&&(a.stopPropagation(),a.stopImmediatePropagation()),i.handler(a);return}},[t]);c.useEffect(()=>{if(e)return window.addEventListener("keydown",r,s),()=>window.removeEventListener("keydown",r,s)},[e,r,s])},qc=e=>{const{data:t,isLoading:s}=de({...xt(),staleTime:1/0}),r=c.useMemo(()=>(t?.accounts??[]).map(l=>l.accountId),[t?.accounts]),a=Lt({queries:r.map(l=>({...ze({path:{accountId:l}}),staleTime:1/0,enabled:!!e}))}),o=s||a.some(l=>l.isLoading);return{accountId:c.useMemo(()=>{if(e){for(let l=0;l<r.length;l++)if((a[l].data?.items??[]).some(d=>d.mailboxId===e))return r[l]}},[e,r,a]),isLoading:o}},Sb=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),kb=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Hc=(e,t)=>e===void 0?e:Sb(e)?{...e,pages:e.pages.map(s=>({...s,items:t(s.items)}))}:kb(e)?{...e,items:t(e.items)}:e,$t=e=>{const t=[];for(const s of new Set(e))t.push(ya({path:{mailboxId:s}})),t.push(ol({path:{mailboxId:s}}));return t.push(il()),t},an=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),on=(e,t)=>t.flatMap(s=>e.getQueriesData({queryKey:s})).filter(s=>s[1]!==void 0).map(([s,r])=>({queryKey:s,data:r})),ln=(e,t,s)=>{const r=a=>Hc(a,s);for(const a of t)e.setQueriesData({queryKey:a},r)},cn=(e,t)=>{for(const s of t)e.setQueryData(s.queryKey,s.data)},Ft=(e,t)=>{for(const s of t)e.invalidateQueries({queryKey:s})},Cb=3e3,Nb=(e,t,s)=>{if(e.length===0)return()=>{};const r=setTimeout(()=>s(e),t);return()=>clearTimeout(r)},Ha=(e,t,s)=>{const r=new Map(t.map(o=>[o.messageId,o.mailboxId])),a=new Set;for(const o of e)a.add(r.get(o)??s);return[...a]},$n=(e,t,s)=>e.map(r=>t.has(r.messageId)?{...r,isRead:s}:r),Eb=(e,t,s,r)=>e.filter(a=>!a.isRead&&t.has(a.threadMessageId)&&!s.has(a.messageId)&&!r.has(a.messageId)).map(a=>a.messageId),Ib=({messages:e,expandedIds:t,threadId:s,mailboxId:r,accountId:a})=>{const o=we(),{pushError:i}=Je(),l=c.useRef(new Set),u=c.useRef(new Set),{mutate:f}=ye({...Wn(),onMutate:async h=>{const g=new Set(h.body.messageIds??[]),b=h.body.isRead??!0,p=Zt({path:{threadId:s}}),v=$t(Ha(g,e,r));await Promise.all([o.cancelQueries({queryKey:p}),an(o,v)]);const x=o.getQueriesData({queryKey:p}).filter(j=>j[1]!==void 0).map(([j,w])=>({queryKey:j,data:w})),y=on(o,v);return o.setQueriesData({queryKey:p},j=>j&&{...j,items:$n(j.items,g,b)}),ln(o,v,j=>$n(j,g,b)),{threadMessagesPrefix:p,listPrefixes:v,previousThreadMessages:x,previousThreadsList:y}},onSuccess:(h,g)=>{const b=g.body.messageIds??[];for(const p of b)l.current.add(p),u.current.delete(p)},onError:(h,g,b)=>{const p=g.body.messageIds??[];for(const x of p)u.current.delete(x);if(b){for(const x of b.previousThreadMessages)o.setQueryData(x.queryKey,x.data);cn(o,b.previousThreadsList)}const v=g.body.isRead??!0;i({title:v?"Couldn't mark as read":"Couldn't mark as unread",detail:lt(h),error:h})},onSettled:(h,g,b,p)=>{p&&(o.invalidateQueries({queryKey:p.threadMessagesPrefix}),Ft(o,p.listPrefixes),a&&o.invalidateQueries({queryKey:Jt({path:{accountId:a}})}))}}),d=c.useCallback(h=>{const g=h.filter(b=>!l.current.has(b)&&!u.current.has(b));if(g.length!==0){for(const b of g)u.current.add(b);f({body:{messageIds:g,isRead:!0}})}},[f]),m=c.useMemo(()=>Eb(e,t,l.current,u.current),[e,t]);c.useEffect(()=>Nb(m,Cb,d),[m,d]),c.useEffect(()=>{l.current.clear(),u.current.clear()},[s])},tr=e=>{const{mailboxId:t,accountId:s,messages:r}=e,a=we(),{pushError:o}=Je(),{mutate:i,isPending:l}=ye({...Wn(),onError:(f,d)=>{const m=d.body.isRead??!0;o({title:m?"Couldn't mark as read":"Couldn't mark as unread",detail:lt(f),error:f})},onSettled:(f,d,m)=>{Ft(a,$t(Ha(m.body.messageIds??[],r??[],t))),s&&a.invalidateQueries({queryKey:Jt({path:{accountId:s}})})}});return{toggleReadFor:c.useCallback((f,d)=>{f.length!==0&&i({body:{messageIds:f,isRead:d}})},[i]),isPending:l}},Tb=60,Rb=1.5,Mb=(e,t,s)=>{const r=Math.abs(e),a=Math.abs(t);return r<s?{direction:null}:r<a*Rb?{direction:null}:{direction:e<0?"left":"right"}},Ab=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Tb})=>{const r=c.useRef(null),a=c.useCallback(u=>{if(u.pointerType==="mouse"){r.current=null;return}r.current={x:u.clientX,y:u.clientY}},[]),o=c.useCallback(()=>{},[]),i=c.useCallback(u=>{const f=r.current;if(r.current=null,!f)return;const{direction:d}=Mb(u.clientX-f.x,u.clientY-f.y,s);d==="left"&&e?.(),d==="right"&&t?.()},[e,t,s]),l=c.useCallback(()=>{r.current=null},[]);return{handlers:{onPointerDown:a,onPointerMove:o,onPointerUp:i,onPointerCancel:l}}},Db=(e,t,s)=>t?.find(r=>r.messageId===e)?.mailboxId??s,ji=(e,t,s)=>e.map(r=>r.messageId===t?{...r,hasStars:s}:r),Wa=({threadId:e,mailboxId:t,messages:s})=>{const r=we(),{pushError:a}=Je(),{mutate:o,isPending:i,variables:l}=ye({...ff(),onMutate:async f=>{const d=f.path.messageId,m=f.body.isStarred??!1,h=Zt({path:{threadId:e}}),g=$t([Db(d,s,t)]);await Promise.all([r.cancelQueries({queryKey:h}),an(r,g)]);const b=r.getQueriesData({queryKey:h}).filter(v=>v[1]!==void 0).map(([v,x])=>({queryKey:v,data:x})),p=on(r,g);return r.setQueriesData({queryKey:h},v=>Hc(v,x=>ji(x,d,m))),ln(r,g,v=>ji(v,d,m)),{threadMessagesPrefix:h,listPrefixes:g,previousThreadMessages:b,previousThreadsList:p}},onError:(f,d,m)=>{if(m){for(const g of m.previousThreadMessages)r.setQueryData(g.queryKey,g.data);cn(r,m.previousThreadsList)}const h=d.body.isStarred??!1;a({title:h?"Couldn't star message":"Couldn't unstar message",detail:lt(f),error:f})},onSettled:(f,d,m,h)=>{h&&(r.invalidateQueries({queryKey:h.threadMessagesPrefix}),Ft(r,h.listPrefixes))}});return{toggleStar:(f,d)=>{o({path:{messageId:f},body:{isStarred:!d}})},isPending:i,pendingMessageId:i?l?.path.messageId:void 0}};function sr(e){return e===void 0?"uncategorized":e}const ot={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},Si={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},Ob={inbox:"Inbox",junk:"Junk"},Va=e=>e.destinationMailboxId!==void 0,Pb=(e,t)=>{if(Va(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${Ob[s]??"another folder"} by Remit`},Lb=(e,t)=>{if(e===Si.MoveToInbox)return t.inboxMailboxId;if(e===Si.MoveToJunk)return t.junkMailboxId},$b=(e,t,s)=>{if(!e||!t)return!1;const r=Va(e)?e.destinationMailboxId:Lb(e.action,s);return r!==void 0&&r===t},Fb=(e,t)=>{if(e){if(Va(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},nr=(e,t)=>{const{data:s,isLoading:r}=de({...xt(),staleTime:1/0,enabled:!!e});return{mailboxId:c.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:r}},zb=e=>{const{mailboxId:t,isLoading:s}=nr(e,"Archive");return{archiveMailboxId:t,isLoading:s}},_b=e=>{const{mailboxId:t,isLoading:s}=nr(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},Qa=e=>{const{mailboxId:t,isLoading:s}=nr(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},rr=e=>{const{mailboxId:t,isLoading:s}=nr(e,"Junk");return{junkMailboxId:t,isLoading:s}},Wc=e=>{const{data:t}=de({...xt(),staleTime:1/0,enabled:!!e});return c.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},ki=(e,t)=>e.filter(s=>!t.has(s.messageId)),Qt=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:r})=>{const a=we(),{pushError:o}=Je(),{mutate:i,isPending:l}=ye({...mf(),onMutate:async f=>{const d=new Set(f.body.messageIds??[]),m=t?Zt({path:{threadId:t}}):[],h=$t([e,f.body.destinationMailboxId]);await Promise.all([...t?[a.cancelQueries({queryKey:m})]:[],an(a,h)]);const g=t?a.getQueriesData({queryKey:m}).filter(p=>p[1]!==void 0).map(([p,v])=>({queryKey:p,data:v})):[],b=on(a,h);return t&&a.setQueriesData({queryKey:m},p=>p&&{...p,items:ki(p.items,d)}),ln(a,h,p=>ki(p,d)),r?.(Array.from(d)),{threadMessagesPrefix:m,listPrefixes:h,previousThreadMessages:g,previousThreadsList:b}},onError:(f,d,m)=>{if(m){for(const g of m.previousThreadMessages)a.setQueryData(g.queryKey,g.data);cn(a,m.previousThreadsList)}const h=d.body.messageIds?.length??0;o({title:h>1?`Couldn't move ${h} messages`:"Couldn't move this message",detail:lt(f),error:f})},onSettled:(f,d,m,h)=>{h&&(t&&a.invalidateQueries({queryKey:h.threadMessagesPrefix}),Ft(a,h.listPrefixes),s&&a.invalidateQueries({queryKey:Jt({path:{accountId:s}})}))}});return{moveMessages:c.useCallback((f,d)=>{f.length!==0&&i({body:{messageIds:f,destinationMailboxId:d}})},[i]),isPending:l}},Bb=({accountId:e,messageId:t,threadId:s,mailboxId:r,autoMoved:a})=>{const{inboxMailboxId:o}=Qa(e),{junkMailboxId:i}=rr(e),{moveMessages:l,isPending:u}=Qt({mailboxId:r,threadId:s,accountId:e}),{data:f}=de({...ze({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&a?.fromMailboxId!==void 0}),d={inboxMailboxId:o,junkMailboxId:i},m=$b(a,r,d),h=Fb(a,d),g=c.useCallback(()=>{h&&l([t],h)},[l,t,h]);if(!m||!a)return{show:!1,label:"",isUndoing:!1};const b=a.fromMailboxId?f?.items.filter(p=>p.mailboxId===a.fromMailboxId).map(p=>Vn(p.fullPath))[0]:void 0;return{show:!0,label:Pb(a,b),onUndo:h?g:void 0,isUndoing:u,...a.filterId?{filtersHref:"/settings/filters"}:{}}};function Vc({accountId:e,messageId:t,threadId:s,mailboxId:r,autoMoved:a,size:o="sm"}){const i=Bb({accountId:e,messageId:t,threadId:s,mailboxId:r,autoMoved:a});return i.show?n.jsx(Gh,{label:i.label,size:o,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:o==="md"?i.filtersHref:void 0}):null}const Ci=(e,t)=>e.filter(s=>!t.has(s.messageId)),Kb=e=>e.filter(t=>t.isDeleted!==!0),Yt=({mailboxId:e,threadId:t,accountId:s,messages:r,onAfterOptimisticRemove:a})=>{const o=we(),{pushError:i}=Je(),{mutate:l,isPending:u}=ye({...hf(),onMutate:async d=>{const m=new Set(d.body.messageIds??[]),h=t?Zt({path:{threadId:t}}):[],g=$t(Ha(m,r??[],e));await Promise.all([o.cancelQueries({queryKey:h}),an(o,g)]);const b=t?o.getQueriesData({queryKey:h}).filter(v=>v[1]!==void 0).map(([v,x])=>({queryKey:v,data:x})):[],p=on(o,g);return t&&o.setQueriesData({queryKey:h},v=>v&&{...v,items:Ci(v.items,m)}),ln(o,g,v=>Ci(v,m)),a?.(Array.from(m)),{threadMessagesPrefix:h,listPrefixes:g,previousThreadMessages:b,previousThreadsList:p}},onError:(d,m,h)=>{if(h){for(const b of h.previousThreadMessages)o.setQueryData(b.queryKey,b.data);cn(o,h.previousThreadsList)}const g=m.body.messageIds?.length??0;i({title:g>1?`Couldn't delete ${g} messages`:"Couldn't delete this message",detail:lt(d),error:d})},onSettled:(d,m,h,g)=>{g&&(t&&o.invalidateQueries({queryKey:g.threadMessagesPrefix}),Ft(o,g.listPrefixes),s&&o.invalidateQueries({queryKey:Jt({path:{accountId:s}})}))}});return{deleteMessages:c.useCallback(d=>{d.length!==0&&l({body:{messageIds:d}})},[l]),isPending:u}},Qc=(e,t=Date.now())=>({value:e,setAt:t}),Ub=(e,t,s,r)=>{if(e.addressId!==t)return e;const a={...e.flags??{}};return s?a.trusted=Qc(!0,r):delete a.trusted,{...e,flags:a}},qb=(e,t,s,r)=>{const a=o=>o.map(i=>Ub(i,t,s,r));return{...e,envelope:{...e.envelope,from:a(e.envelope.from),to:a(e.envelope.to),cc:a(e.envelope.cc),bcc:a(e.envelope.bcc),replyTo:a(e.envelope.replyTo)}}},Ya=({messageId:e})=>{const t=we(),{pushError:s}=Je(),{mutate:r,isPending:a,error:o,reset:i}=ye({...ll(),onMutate:async u=>{const f=u.path.addressId,m=u.body.flags?.trusted?.value===!0,h=sl({path:{messageId:e}});await t.cancelQueries({queryKey:h});const g=t.getQueriesData({queryKey:h}).filter(b=>b[1]!==void 0).map(([b,p])=>({queryKey:b,data:p}));return t.setQueriesData({queryKey:h},b=>b&&qb(b,f,m)),{describePrefix:h,previous:g}},onError:(u,f,d)=>{if(d)for(const m of d.previous)t.setQueryData(m.queryKey,m.data);s(Vt("Couldn't trust sender","The change wasn't saved.",u))},onSettled:(u,f,d,m)=>{m&&t.invalidateQueries({queryKey:m.describePrefix})}});return{toggleTrusted:(u,f)=>{r({path:{addressId:u},body:{flags:{trusted:Qc(!f)}}})},isPending:a,error:o,reset:i}};var ar="Dialog",[Yc]=eg(ar),[Hb,rt]=Yc(ar),Gc=e=>{const{__scopeDialog:t,children:s,open:r,defaultOpen:a,onOpenChange:o,modal:i=!0}=e,l=c.useRef(null),u=c.useRef(null),[f,d]=ng({prop:r,defaultProp:a??!1,onChange:o,caller:ar});return n.jsx(Hb,{scope:t,triggerRef:l,contentRef:u,contentId:Ir(),titleId:Ir(),descriptionId:Ir(),open:f,onOpenChange:d,onOpenToggle:c.useCallback(()=>d(m=>!m),[d]),modal:i,children:s})};Gc.displayName=ar;var Xc="DialogTrigger",Wb=c.forwardRef((e,t)=>{const{__scopeDialog:s,...r}=e,a=rt(Xc,s),o=es(t,a.triggerRef);return n.jsx(bt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Xa(a.open),...r,ref:o,onClick:Et(e.onClick,a.onOpenToggle)})});Wb.displayName=Xc;var Ga="DialogPortal",[Vb,Jc]=Yc(Ga,{forceMount:void 0}),Zc=e=>{const{__scopeDialog:t,forceMount:s,children:r,container:a}=e,o=rt(Ga,t);return n.jsx(Vb,{scope:t,forceMount:s,children:c.Children.map(r,i=>n.jsx(Xn,{present:s||o.open,children:n.jsx(hc,{asChild:!0,container:a,children:i})}))})};Zc.displayName=Ga;var Fn="DialogOverlay",eu=c.forwardRef((e,t)=>{const s=Jc(Fn,e.__scopeDialog),{forceMount:r=s.forceMount,...a}=e,o=rt(Fn,e.__scopeDialog);return o.modal?n.jsx(Xn,{present:r||o.open,children:n.jsx(Yb,{...a,ref:t})}):null});eu.displayName=Fn;var Qb=Fa("DialogOverlay.RemoveScroll"),Yb=c.forwardRef((e,t)=>{const{__scopeDialog:s,...r}=e,a=rt(Fn,s),o=jg(),i=es(t,o);return n.jsx(jc,{as:Qb,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(bt.div,{"data-state":Xa(a.open),...r,ref:i,style:{pointerEvents:"auto",...r.style}})})}),js="DialogContent",tu=c.forwardRef((e,t)=>{const s=Jc(js,e.__scopeDialog),{forceMount:r=s.forceMount,...a}=e,o=rt(js,e.__scopeDialog);return n.jsx(Xn,{present:r||o.open,children:o.modal?n.jsx(Gb,{...a,ref:t}):n.jsx(Xb,{...a,ref:t})})});tu.displayName=js;var Gb=c.forwardRef((e,t)=>{const s=rt(js,e.__scopeDialog),r=c.useRef(null),a=es(t,s.contentRef,r);return c.useEffect(()=>{const o=r.current;if(o)return qg(o)},[]),n.jsx(su,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:Et(e.onCloseAutoFocus,o=>{o.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:Et(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&o.preventDefault()}),onFocusOutside:Et(e.onFocusOutside,o=>o.preventDefault())})}),Xb=c.forwardRef((e,t)=>{const s=rt(js,e.__scopeDialog),r=c.useRef(!1),a=c.useRef(!1);return n.jsx(su,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||s.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const i=o.target;s.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),su=c.forwardRef((e,t)=>{const{__scopeDialog:s,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,...i}=e,l=rt(js,s);return Ng(),n.jsx(n.Fragment,{children:n.jsx(fc,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:n.jsx(uc,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Xa(l.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),nu="DialogTitle",ru=c.forwardRef((e,t)=>{const{__scopeDialog:s,...r}=e,a=rt(nu,s);return n.jsx(bt.h2,{id:a.titleId,...r,ref:t})});ru.displayName=nu;var au="DialogDescription",Jb=c.forwardRef((e,t)=>{const{__scopeDialog:s,...r}=e,a=rt(au,s);return n.jsx(bt.p,{id:a.descriptionId,...r,ref:t})});Jb.displayName=au;var ou="DialogClose",Zb=c.forwardRef((e,t)=>{const{__scopeDialog:s,...r}=e,a=rt(ou,s);return n.jsx(bt.button,{type:"button",...r,ref:t,onClick:Et(e.onClick,()=>a.onOpenChange(!1))})});Zb.displayName=ou;function Xa(e){return e?"open":"closed"}function ev(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}const iu=W.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),un=()=>{const e=W.useContext(iu);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};ev(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
117
+ [data-state=closed]
118
+ ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function tv(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function sv(){return Ja(/^Mac/)}function nv(){return Ja(/^iPhone/)}function Ni(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function rv(){return Ja(/^iPad/)||sv()&&navigator.maxTouchPoints>1}function lu(){return nv()||rv()}function Ja(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const av=24,ov=typeof window<"u"?c.useLayoutEffect:c.useEffect;function Ei(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}const Or=typeof document<"u"&&window.visualViewport;function Ii(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function cu(e){for(Ii(e)&&(e=e.parentElement);e&&!Ii(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const iv=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let Nn=0,Pr;function lv(e={}){let{isDisabled:t}=e;ov(()=>{if(!t)return Nn++,Nn===1&&lu()&&(Pr=cv()),()=>{Nn--,Nn===0&&Pr?.()}},[t])}function cv(){let e,t=0,s=m=>{e=cu(m.target),!(e===document.documentElement&&e===document.body)&&(t=m.changedTouches[0].pageY)},r=m=>{if(!e||e===document.documentElement||e===document.body){m.preventDefault();return}let h=m.changedTouches[0].pageY,g=e.scrollTop,b=e.scrollHeight-e.clientHeight;b!==0&&((g<=0&&h>t||g>=b&&h<t)&&m.preventDefault(),t=h)},a=m=>{let h=m.target;ea(h)&&h!==document.activeElement&&(m.preventDefault(),h.style.transform="translateY(-2000px)",h.focus(),requestAnimationFrame(()=>{h.style.transform=""}))},o=m=>{let h=m.target;ea(h)&&(h.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{h.style.transform="",Or&&(Or.height<window.innerHeight?requestAnimationFrame(()=>{Ti(h)}):Or.addEventListener("resize",()=>Ti(h),{once:!0}))}))},i=()=>{window.scrollTo(0,0)},l=window.pageXOffset,u=window.pageYOffset,f=Ei(uv(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let d=Ei(Os(document,"touchstart",s,{passive:!1,capture:!0}),Os(document,"touchmove",r,{passive:!1,capture:!0}),Os(document,"touchend",a,{passive:!1,capture:!0}),Os(document,"focus",o,!0),Os(window,"scroll",i));return()=>{f(),d(),window.scrollTo(l,u)}}function uv(e,t,s){let r=e.style[t];return e.style[t]=s,()=>{e.style[t]=r}}function Os(e,t,s,r){return e.addEventListener(t,s,r),()=>{e.removeEventListener(t,s,r)}}function Ti(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let s=cu(e);if(s!==document.documentElement&&s!==document.body&&s!==e){let r=s.getBoundingClientRect().top,a=e.getBoundingClientRect().top,o=e.getBoundingClientRect().bottom;const i=s.getBoundingClientRect().bottom+av;o>i&&(s.scrollTop+=a-r)}e=s.parentElement}}function ea(e){return e instanceof HTMLInputElement&&!iv.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function dv(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function fv(...e){return t=>e.forEach(s=>dv(s,t))}function uu(...e){return c.useCallback(fv(...e),e)}const du=new WeakMap;function Ee(e,t,s=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([a,o])=>{if(a.startsWith("--")){e.style.setProperty(a,o);return}r[a]=e.style[a],e.style[a]=o}),!s&&du.set(e,r)}function mv(e,t){if(!e||!(e instanceof HTMLElement))return;let s=du.get(e);s&&(e.style[t]=s[t])}const ke=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function En(e,t){if(!e)return null;const s=window.getComputedStyle(e),r=s.transform||s.webkitTransform||s.mozTransform;let a=r.match(/^matrix3d\((.+)\)$/);return a?parseFloat(a[1].split(", ")[ke(t)?13:12]):(a=r.match(/^matrix\((.+)\)$/),a?parseFloat(a[1].split(", ")[ke(t)?5:4]):null)}function hv(e){return 8*(Math.log(e+1)-2)}function Lr(e,t){if(!e)return()=>{};const s=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=s}}function pv(...e){return(...t)=>{for(const s of e)typeof s=="function"&&s(...t)}}const be={DURATION:.5,EASE:[.32,.72,0,1]},fu=.4,gv=.25,xv=100,mu=8,qt=16,ta=26,$r="vaul-dragging";function hu(e){const t=W.useRef(e);return W.useEffect(()=>{t.current=e}),W.useMemo(()=>(...s)=>t.current==null?void 0:t.current.call(t,...s),[])}function bv({defaultProp:e,onChange:t}){const s=W.useState(e),[r]=s,a=W.useRef(r),o=hu(t);return W.useEffect(()=>{a.current!==r&&(o(r),a.current=r)},[r,a,o]),s}function pu({prop:e,defaultProp:t,onChange:s=()=>{}}){const[r,a]=bv({defaultProp:t,onChange:s}),o=e!==void 0,i=o?e:r,l=hu(s),u=W.useCallback(f=>{if(o){const m=typeof f=="function"?f(e):f;m!==e&&l(m)}else a(f)},[o,e,a,l]);return[i,u]}function vv({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:s,drawerRef:r,overlayRef:a,fadeFromIndex:o,onSnapPointChange:i,direction:l="bottom",container:u,snapToSequentialPoint:f}){const[d,m]=pu({prop:e,defaultProp:s?.[0],onChange:t}),[h,g]=W.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);W.useEffect(()=>{function C(){g({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[]);const b=W.useMemo(()=>d===s?.[s.length-1]||null,[s,d]),p=W.useMemo(()=>{var C;return(C=s?.findIndex(k=>k===d))!=null?C:null},[s,d]),v=s&&s.length>0&&(o||o===0)&&!Number.isNaN(o)&&s[o]===d||!s,x=W.useMemo(()=>{const C=u?{width:u.getBoundingClientRect().width,height:u.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var k;return(k=s?.map(R=>{const O=typeof R=="string";let D=0;if(O&&(D=parseInt(R,10)),ke(l)){const I=O?D:h?R*C.height:0;return h?l==="bottom"?C.height-I:-C.height+I:I}const P=O?D:h?R*C.width:0;return h?l==="right"?C.width-P:-C.width+P:P}))!=null?k:[]},[s,h,u]),y=W.useMemo(()=>p!==null?x?.[p]:null,[x,p]),j=W.useCallback(C=>{var k;const R=(k=x?.findIndex(O=>O===C))!=null?k:null;i(R),Ee(r.current,{transition:`transform ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,transform:ke(l)?`translate3d(0, ${C}px, 0)`:`translate3d(${C}px, 0, 0)`}),x&&R!==x.length-1&&o!==void 0&&R!==o&&R<o?Ee(a.current,{transition:`opacity ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,opacity:"0"}):Ee(a.current,{transition:`opacity ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,opacity:"1"}),m(s?.[Math.max(R,0)])},[r.current,s,x,o,a,m]);W.useEffect(()=>{if(d||e){var C;const k=(C=s?.findIndex(R=>R===e||R===d))!=null?C:-1;x&&k!==-1&&typeof x[k]=="number"&&j(x[k])}},[d,e,s,x,j]);function w({draggedDistance:C,closeDrawer:k,velocity:R,dismissible:O}){if(o===void 0)return;const D=l==="bottom"||l==="right"?(y??0)-C:(y??0)+C,P=p===o-1,I=p===0,S=C>0;if(P&&Ee(a.current,{transition:`opacity ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`}),!f&&R>2&&!S){O?k():j(x[0]);return}if(!f&&R>2&&S&&x&&s){j(x[s.length-1]);return}const A=x?.reduce((T,F)=>typeof T!="number"||typeof F!="number"?T:Math.abs(F-D)<Math.abs(T-D)?F:T),L=ke(l)?window.innerHeight:window.innerWidth;if(R>fu&&Math.abs(C)<L*.4){const T=S?1:-1;if(T>0&&b&&s){j(x[s.length-1]);return}if(I&&T<0&&O&&k(),p===null)return;j(x[p+T]);return}j(A)}function N({draggedDistance:C}){if(y===null)return;const k=l==="bottom"||l==="right"?y-C:y+C;(l==="bottom"||l==="right")&&k<x[x.length-1]||(l==="top"||l==="left")&&k>x[x.length-1]||Ee(r.current,{transform:ke(l)?`translate3d(0, ${k}px, 0)`:`translate3d(${k}px, 0, 0)`})}function E(C,k){if(!s||typeof p!="number"||!x||o===void 0)return null;const R=p===o-1;if(p>=o&&k)return 0;if(R&&!k)return 1;if(!v&&!R)return null;const D=R?p+1:p-1,P=R?x[D]-x[D-1]:x[D+1]-x[D],I=C/Math.abs(P);return R?1-I:I}return{isLastSnapPoint:b,activeSnapPoint:d,shouldFade:v,getPercentageDragged:E,setActiveSnapPoint:m,activeSnapPointIndex:p,onRelease:w,onDrag:N,snapPointsOffset:x}}const yv=()=>()=>{};function wv(){const{direction:e,isOpen:t,shouldScaleBackground:s,setBackgroundColorOnScale:r,noBodyStyles:a}=un(),o=W.useRef(null),i=c.useMemo(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-ta)/window.innerWidth}W.useEffect(()=>{if(t&&s){o.current&&clearTimeout(o.current);const u=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!u)return;pv(r&&!a?Lr(document.body,{background:"black"}):yv,Lr(u,{transformOrigin:ke(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${be.DURATION}s`,transitionTimingFunction:`cubic-bezier(${be.EASE.join(",")})`}));const f=Lr(u,{borderRadius:`${mu}px`,overflow:"hidden",...ke(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{f(),o.current=window.setTimeout(()=>{i?document.body.style.background=i:document.body.style.removeProperty("background")},be.DURATION*1e3)}}},[t,s,i])}let Ps=null;function jv({isOpen:e,modal:t,nested:s,hasBeenOpened:r,preventScrollRestoration:a,noBodyStyles:o}){const[i,l]=W.useState(()=>typeof window<"u"?window.location.href:""),u=W.useRef(0),f=W.useCallback(()=>{if(Ni()&&Ps===null&&e&&!o){Ps={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:m,innerHeight:h}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-u.current}px`,left:`${-m}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const g=h-window.innerHeight;g&&u.current>=h&&(document.body.style.top=`${-(u.current+g)}px`)}),300)}},[e]),d=W.useCallback(()=>{if(Ni()&&Ps!==null&&!o){const m=-parseInt(document.body.style.top,10),h=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Ps),window.requestAnimationFrame(()=>{if(a&&i!==window.location.href){l(window.location.href);return}window.scrollTo(h,m)}),Ps=null}},[i]);return W.useEffect(()=>{function m(){u.current=window.scrollY}return m(),window.addEventListener("scroll",m),()=>{window.removeEventListener("scroll",m)}},[]),W.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||d()}},[t,d]),W.useEffect(()=>{s||!r||(e?(!window.matchMedia("(display-mode: standalone)").matches&&f(),t||window.setTimeout(()=>{d()},500)):d())},[e,r,i,t,s,f,d]),{restorePositionSetting:d}}function Sv({open:e,onOpenChange:t,children:s,onDrag:r,onRelease:a,snapPoints:o,shouldScaleBackground:i=!1,setBackgroundColorOnScale:l=!0,closeThreshold:u=gv,scrollLockTimeout:f=xv,dismissible:d=!0,handleOnly:m=!1,fadeFromIndex:h=o&&o.length-1,activeSnapPoint:g,setActiveSnapPoint:b,fixed:p,modal:v=!0,onClose:x,nested:y,noBodyStyles:j=!1,direction:w="bottom",defaultOpen:N=!1,disablePreventScroll:E=!0,snapToSequentialPoint:C=!1,preventScrollRestoration:k=!1,repositionInputs:R=!0,onAnimationEnd:O,container:D,autoFocus:P=!1}){var I,S;const[A=!1,L]=pu({defaultProp:N,prop:e,onChange:Z=>{t?.(Z),!Z&&!y&&Be(),setTimeout(()=>{O?.(Z)},be.DURATION*1e3),Z&&!v&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),Z||(document.body.style.pointerEvents="auto")}}),[T,F]=W.useState(!1),[M,$]=W.useState(!1),[K,B]=W.useState(!1),J=W.useRef(null),ee=W.useRef(null),X=W.useRef(null),me=W.useRef(null),ue=W.useRef(null),te=W.useRef(!1),U=W.useRef(null),H=W.useRef(0),re=W.useRef(!1),Ie=W.useRef(!N),je=W.useRef(0),V=W.useRef(null),G=W.useRef(((I=V.current)==null?void 0:I.getBoundingClientRect().height)||0),ae=W.useRef(((S=V.current)==null?void 0:S.getBoundingClientRect().width)||0),le=W.useRef(0),_=W.useCallback(Z=>{o&&Z===Ve.length-1&&(ee.current=new Date)},[]),{activeSnapPoint:Fe,activeSnapPointIndex:pe,setActiveSnapPoint:ge,onRelease:Se,snapPointsOffset:Ve,onDrag:ts,shouldFade:_e,getPercentageDragged:Ze}=vv({snapPoints:o,activeSnapPointProp:g,setActiveSnapPointProp:b,drawerRef:V,fadeFromIndex:h,overlayRef:J,onSnapPointChange:_,direction:w,container:D,snapToSequentialPoint:C});lv({isDisabled:!A||M||!v||K||!T||!R||!E});const{restorePositionSetting:Be}=jv({isOpen:A,modal:v,nested:y??!1,hasBeenOpened:T,preventScrollRestoration:k,noBodyStyles:j});function Ke(){return(window.innerWidth-ta)/window.innerWidth}function ft(Z){var ie,ne;!d&&!o||V.current&&!V.current.contains(Z.target)||(G.current=((ie=V.current)==null?void 0:ie.getBoundingClientRect().height)||0,ae.current=((ne=V.current)==null?void 0:ne.getBoundingClientRect().width)||0,$(!0),X.current=new Date,lu()&&window.addEventListener("touchend",()=>te.current=!1,{once:!0}),Z.target.setPointerCapture(Z.pointerId),H.current=ke(w)?Z.pageY:Z.pageX)}function Te(Z,ie){var ne;let oe=Z;const he=(ne=window.getSelection())==null?void 0:ne.toString(),fe=V.current?En(V.current,w):null,ve=new Date;if(oe.tagName==="SELECT"||oe.hasAttribute("data-vaul-no-drag")||oe.closest("[data-vaul-no-drag]"))return!1;if(w==="right"||w==="left")return!0;if(ee.current&&ve.getTime()-ee.current.getTime()<500)return!1;if(fe!==null&&(w==="bottom"?fe>0:fe<0))return!0;if(he&&he.length>0)return!1;if(ue.current&&ve.getTime()-ue.current.getTime()<f&&fe===0||ie)return ue.current=ve,!1;for(;oe;){if(oe.scrollHeight>oe.clientHeight){if(oe.scrollTop!==0)return ue.current=new Date,!1;if(oe.getAttribute("role")==="dialog")return!0}oe=oe.parentNode}return!0}function ss(Z){if(V.current&&M){const ie=w==="bottom"||w==="right"?1:-1,ne=(H.current-(ke(w)?Z.pageY:Z.pageX))*ie,oe=ne>0,he=o&&!d&&!oe;if(he&&pe===0)return;const fe=Math.abs(ne),ve=document.querySelector("[data-vaul-drawer-wrapper]"),Pe=w==="bottom"||w==="top"?G.current:ae.current;let Ae=fe/Pe;const He=Ze(fe,oe);if(He!==null&&(Ae=He),he&&Ae>=1||!te.current&&!Te(Z.target,oe))return;if(V.current.classList.add($r),te.current=!0,Ee(V.current,{transition:"none"}),Ee(J.current,{transition:"none"}),o&&ts({draggedDistance:ne}),oe&&!o){const Re=hv(ne),Qe=Math.min(Re*-1,0)*ie;Ee(V.current,{transform:ke(w)?`translate3d(0, ${Qe}px, 0)`:`translate3d(${Qe}px, 0, 0)`});return}const De=1-Ae;if((_e||h&&pe===h-1)&&(r?.(Z,Ae),Ee(J.current,{opacity:`${De}`,transition:"none"},!0)),ve&&J.current&&i){const Re=Math.min(Ke()+Ae*(1-Ke()),1),Qe=8-Ae*8,Ye=Math.max(0,14-Ae*14);Ee(ve,{borderRadius:`${Qe}px`,transform:ke(w)?`scale(${Re}) translate3d(0, ${Ye}px, 0)`:`scale(${Re}) translate3d(${Ye}px, 0, 0)`,transition:"none"},!0)}if(!o){const Re=fe*ie;Ee(V.current,{transform:ke(w)?`translate3d(0, ${Re}px, 0)`:`translate3d(${Re}px, 0, 0)`})}}}W.useEffect(()=>{window.requestAnimationFrame(()=>{Ie.current=!0})},[]),W.useEffect(()=>{var Z;function ie(){if(!V.current||!R)return;const ne=document.activeElement;if(ea(ne)||re.current){var oe;const he=((oe=window.visualViewport)==null?void 0:oe.height)||0,fe=window.innerHeight;let ve=fe-he;const Pe=V.current.getBoundingClientRect().height||0,Ae=Pe>fe*.8;le.current||(le.current=Pe);const He=V.current.getBoundingClientRect().top;if(Math.abs(je.current-ve)>60&&(re.current=!re.current),o&&o.length>0&&Ve&&pe){const De=Ve[pe]||0;ve+=De}if(je.current=ve,Pe>he||re.current){const De=V.current.getBoundingClientRect().height;let Re=De;De>he&&(Re=he-(Ae?He:ta)),p?V.current.style.height=`${De-Math.max(ve,0)}px`:V.current.style.height=`${Math.max(Re,he-He)}px`}else tv()||(V.current.style.height=`${le.current}px`);o&&o.length>0&&!re.current?V.current.style.bottom="0px":V.current.style.bottom=`${Math.max(ve,0)}px`}}return(Z=window.visualViewport)==null||Z.addEventListener("resize",ie),()=>{var ne;return(ne=window.visualViewport)==null?void 0:ne.removeEventListener("resize",ie)}},[pe,o,Ve]);function Ue(Z){Ne(),x?.(),Z||L(!1),setTimeout(()=>{o&&ge(o[0])},be.DURATION*1e3)}function zt(){if(!V.current)return;const Z=document.querySelector("[data-vaul-drawer-wrapper]"),ie=En(V.current,w);Ee(V.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`}),Ee(J.current,{transition:`opacity ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,opacity:"1"}),i&&ie&&ie>0&&A&&Ee(Z,{borderRadius:`${mu}px`,overflow:"hidden",...ke(w)?{transform:`scale(${Ke()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${Ke()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${be.DURATION}s`,transitionTimingFunction:`cubic-bezier(${be.EASE.join(",")})`},!0)}function Ne(){!M||!V.current||(V.current.classList.remove($r),te.current=!1,$(!1),me.current=new Date)}function qe(Z){if(!M||!V.current)return;V.current.classList.remove($r),te.current=!1,$(!1),me.current=new Date;const ie=En(V.current,w);if(!Z||!Te(Z.target,!1)||!ie||Number.isNaN(ie)||X.current===null)return;const ne=me.current.getTime()-X.current.getTime(),oe=H.current-(ke(w)?Z.pageY:Z.pageX),he=Math.abs(oe)/ne;if(he>.05&&(B(!0),setTimeout(()=>{B(!1)},200)),o){Se({draggedDistance:oe*(w==="bottom"||w==="right"?1:-1),closeDrawer:Ue,velocity:he,dismissible:d}),a?.(Z,!0);return}if(w==="bottom"||w==="right"?oe>0:oe<0){zt(),a?.(Z,!0);return}if(he>fu){Ue(),a?.(Z,!1);return}var fe;const ve=Math.min((fe=V.current.getBoundingClientRect().height)!=null?fe:0,window.innerHeight);var Pe;const Ae=Math.min((Pe=V.current.getBoundingClientRect().width)!=null?Pe:0,window.innerWidth),He=w==="left"||w==="right";if(Math.abs(ie)>=(He?Ae:ve)*u){Ue(),a?.(Z,!1);return}a?.(Z,!0),zt()}W.useEffect(()=>(A&&(Ee(document.documentElement,{scrollBehavior:"auto"}),ee.current=new Date),()=>{mv(document.documentElement,"scrollBehavior")}),[A]);function mt(Z){const ie=Z?(window.innerWidth-qt)/window.innerWidth:1,ne=Z?-qt:0;U.current&&window.clearTimeout(U.current),Ee(V.current,{transition:`transform ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,transform:ke(w)?`scale(${ie}) translate3d(0, ${ne}px, 0)`:`scale(${ie}) translate3d(${ne}px, 0, 0)`}),!Z&&V.current&&(U.current=setTimeout(()=>{const oe=En(V.current,w);Ee(V.current,{transition:"none",transform:ke(w)?`translate3d(0, ${oe}px, 0)`:`translate3d(${oe}px, 0, 0)`})},500))}function ns(Z,ie){if(ie<0)return;const ne=(window.innerWidth-qt)/window.innerWidth,oe=ne+ie*(1-ne),he=-qt+ie*qt;Ee(V.current,{transform:ke(w)?`scale(${oe}) translate3d(0, ${he}px, 0)`:`scale(${oe}) translate3d(${he}px, 0, 0)`,transition:"none"})}function _t(Z,ie){const ne=ke(w)?window.innerHeight:window.innerWidth,oe=ie?(ne-qt)/ne:1,he=ie?-qt:0;ie&&Ee(V.current,{transition:`transform ${be.DURATION}s cubic-bezier(${be.EASE.join(",")})`,transform:ke(w)?`scale(${oe}) translate3d(0, ${he}px, 0)`:`scale(${oe}) translate3d(${he}px, 0, 0)`})}return W.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),W.createElement(Gc,{defaultOpen:N,onOpenChange:Z=>{!d&&!Z||(Z?F(!0):Ue(!0),L(Z))},open:A},W.createElement(iu.Provider,{value:{activeSnapPoint:Fe,snapPoints:o,setActiveSnapPoint:ge,drawerRef:V,overlayRef:J,onOpenChange:t,onPress:ft,onRelease:qe,onDrag:ss,dismissible:d,shouldAnimate:Ie,handleOnly:m,isOpen:A,isDragging:M,shouldFade:_e,closeDrawer:Ue,onNestedDrag:ns,onNestedOpenChange:mt,onNestedRelease:_t,keyboardIsOpen:re,modal:v,snapPointsOffset:Ve,activeSnapPointIndex:pe,direction:w,shouldScaleBackground:i,setBackgroundColorOnScale:l,noBodyStyles:j,container:D,autoFocus:P}},s))}const gu=W.forwardRef(function({...e},t){const{overlayRef:s,snapPoints:r,onRelease:a,shouldFade:o,isOpen:i,modal:l,shouldAnimate:u}=un(),f=uu(t,s),d=r&&r.length>0;if(!l)return null;const m=W.useCallback(h=>a(h),[a]);return W.createElement(eu,{onMouseUp:m,ref:f,"data-vaul-overlay":"","data-vaul-snap-points":i&&d?"true":"false","data-vaul-snap-points-overlay":i&&o?"true":"false","data-vaul-animate":u?.current?"true":"false",...e})});gu.displayName="Drawer.Overlay";const xu=W.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:s,...r},a){const{drawerRef:o,onPress:i,onRelease:l,onDrag:u,keyboardIsOpen:f,snapPointsOffset:d,activeSnapPointIndex:m,modal:h,isOpen:g,direction:b,snapPoints:p,container:v,handleOnly:x,shouldAnimate:y,autoFocus:j}=un(),[w,N]=W.useState(!1),E=uu(a,o),C=W.useRef(null),k=W.useRef(null),R=W.useRef(!1),O=p&&p.length>0;wv();const D=(I,S,A=0)=>{if(R.current)return!0;const L=Math.abs(I.y),T=Math.abs(I.x),F=T>L,M=["bottom","right"].includes(S)?1:-1;if(S==="left"||S==="right"){if(!(I.x*M<0)&&T>=0&&T<=A)return F}else if(!(I.y*M<0)&&L>=0&&L<=A)return!F;return R.current=!0,!0};W.useEffect(()=>{O&&window.requestAnimationFrame(()=>{N(!0)})},[]);function P(I){C.current=null,R.current=!1,l(I)}return W.createElement(tu,{"data-vaul-drawer-direction":b,"data-vaul-drawer":"","data-vaul-delayed-snap-points":w?"true":"false","data-vaul-snap-points":g&&O?"true":"false","data-vaul-custom-container":v?"true":"false","data-vaul-animate":y?.current?"true":"false",...r,ref:E,style:d&&d.length>0?{"--snap-point-height":`${d[m??0]}px`,...t}:t,onPointerDown:I=>{x||(r.onPointerDown==null||r.onPointerDown.call(r,I),C.current={x:I.pageX,y:I.pageY},i(I))},onOpenAutoFocus:I=>{s?.(I),j||I.preventDefault()},onPointerDownOutside:I=>{if(e?.(I),!h||I.defaultPrevented){I.preventDefault();return}f.current&&(f.current=!1)},onFocusOutside:I=>{if(!h){I.preventDefault();return}},onPointerMove:I=>{if(k.current=I,x||(r.onPointerMove==null||r.onPointerMove.call(r,I),!C.current))return;const S=I.pageY-C.current.y,A=I.pageX-C.current.x,L=I.pointerType==="touch"?10:2;D({x:A,y:S},b,L)?u(I):(Math.abs(A)>L||Math.abs(S)>L)&&(C.current=null)},onPointerUp:I=>{r.onPointerUp==null||r.onPointerUp.call(r,I),C.current=null,R.current=!1,l(I)},onPointerOut:I=>{r.onPointerOut==null||r.onPointerOut.call(r,I),P(k.current)},onContextMenu:I=>{r.onContextMenu==null||r.onContextMenu.call(r,I),k.current&&P(k.current)}})});xu.displayName="Drawer.Content";const kv=250,Cv=120,bu=W.forwardRef(function({preventCycle:e=!1,children:t,...s},r){const{closeDrawer:a,isDragging:o,snapPoints:i,activeSnapPoint:l,setActiveSnapPoint:u,dismissible:f,handleOnly:d,isOpen:m,onPress:h,onDrag:g}=un(),b=W.useRef(null),p=W.useRef(!1);function v(){if(p.current){j();return}window.setTimeout(()=>{x()},Cv)}function x(){if(o||e||p.current){j();return}if(j(),!i||i.length===0){f||a();return}if(l===i[i.length-1]&&f){a();return}const N=i.findIndex(C=>C===l);if(N===-1)return;const E=i[N+1];u(E)}function y(){b.current=window.setTimeout(()=>{p.current=!0},kv)}function j(){b.current&&window.clearTimeout(b.current),p.current=!1}return W.createElement("div",{onClick:v,onPointerCancel:j,onPointerDown:w=>{d&&h(w),y()},onPointerMove:w=>{d&&g(w)},ref:r,"data-vaul-drawer-visible":m?"true":"false","data-vaul-handle":"","aria-hidden":"true",...s},W.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});bu.displayName="Drawer.Handle";function Nv(e){const t=un(),{container:s=t.container,...r}=e;return W.createElement(Zc,{container:s,...r})}const Xe={Root:Sv,Content:xu,Overlay:gu,Portal:Nv,Handle:bu,Title:ru},vu="inline-flex items-center justify-center transition-colors",Ev=xe(vu,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),Iv=xe(vu,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),dn=({accountId:e,currentMailboxId:t,onMove:s,disabled:r=!1,disabledHint:a,variant:o="icon-only",label:i})=>{const[l,u]=c.useState(!1),f=At(),d=c.useRef(null),m=i??"Move to folder",h=c.useId(),{t:g}=Un("mail",{useSuspense:!1}),b=c.useCallback((P,I)=>g(P,{defaultValue:I}),[g]),{data:p,isLoading:v,isError:x,error:y,refetch:j}=de({...ze({path:{accountId:e}}),staleTime:1/0,enabled:l}),w=Wc(e),{createFolder:N}=kl(e),E=c.useMemo(()=>{const P=Zs(p?.items??[],w),I=Gs(w);return P.map(S=>({id:S.mailboxId,label:bs(S,I.get(S.mailboxId),b),searchValue:S.fullPath,isCurrent:S.mailboxId===t}))},[p?.items,w,t,b]),C=c.useCallback(P=>{u(!1),s(P)},[s]),k=c.useCallback(async P=>{const I=await N(P);return{id:I.id,label:I.label}},[N]);c.useEffect(()=>{if(!l||!f)return;const P=S=>{d.current&&!d.current.contains(S.target)&&u(!1)},I=S=>{S.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",P),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",I)}},[l,f]);const R=r||!!a,O=n.jsxs("button",{type:"button",onClick:P=>{P.stopPropagation(),!R&&u(I=>!I)},"aria-label":m,"aria-haspopup":f?"listbox":"dialog","aria-expanded":l,"aria-controls":l?h:void 0,title:a,className:o==="icon-only"?Ev:Iv,children:[n.jsx(Aa,{className:"size-4"}),o==="compact"&&n.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),D=v?n.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):x?n.jsx("div",{className:"p-3",children:n.jsx(Dt,{variant:"inline",title:"Couldn't load folders",error:y,onRetry:()=>j()})}):n.jsx(ic,{mailboxes:E,onSelect:C,onCreateFolder:k,onCancel:()=>u(!1),autoFocus:!f,labels:{createLabel:P=>`Create "${P}"`,searchPlaceholder:g("move_picker_placeholder",{defaultValue:"Move to…"}),searchAriaLabel:g("move_picker_filter_label",{defaultValue:"Filter folders"}),optionLabel:P=>`Move to ${P}`,currentSuffix:"(current folder)",currentTag:"current",emptyMessage:P=>`No folders match "${P}"`}});return f?n.jsxs("div",{ref:d,className:"relative inline-block",children:[O,l&&n.jsx("div",{id:h,className:xe("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:D})]}):n.jsxs(n.Fragment,{children:[O,n.jsx(Xe.Root,{open:l,onOpenChange:u,children:n.jsxs(Xe.Portal,{children:[n.jsx(Xe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),n.jsxs(Xe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col bg-canvas rounded-t-lg",style:{maxHeight:"85dvh"},id:h,children:[n.jsx(Xe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),n.jsx(Xe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),n.jsx("div",{className:"flex-1 overflow-hidden",children:D})]})]})})]})},Tv=({messageId:e,threadId:t,mailboxId:s,isRead:r,accountId:a,fromAddressId:o,isTrusted:i=!1,showRaw:l=!1,onToggleRaw:u})=>{const f=we(),d=Oe(),{pushError:m}=Je(),{selectedMessageId:h}=vs({strict:!1}),{mutate:g,isPending:b}=ye({...Wn(),onMutate:async A=>{const L=A.body.isRead??!0,T=new Set(A.body.messageIds??[]),F=Zt({path:{threadId:t}}),M=$t([s]);await Promise.all([f.cancelQueries({queryKey:F}),an(f,M)]);const $=f.getQueriesData({queryKey:F}).filter(B=>B[1]!==void 0).map(([B,J])=>({queryKey:B,data:J})),K=on(f,M);return f.setQueriesData({queryKey:F},B=>B&&{...B,items:$n(B.items,T,L)}),ln(f,M,B=>$n(B,T,L)),{threadMessagesPrefix:F,listPrefixes:M,previousThreadMessages:$,previousThreadsList:K}},onError:(A,L,T)=>{if(T){for(const M of T.previousThreadMessages)f.setQueryData(M.queryKey,M.data);cn(f,T.previousThreadsList)}const F=L.body.isRead??!0;m({title:F?"Couldn't mark as read":"Couldn't mark as unread",detail:lt(A),error:A})},onSettled:(A,L,T,F)=>{F&&(f.invalidateQueries({queryKey:F.threadMessagesPrefix}),Ft(f,F.listPrefixes))}}),p=c.useCallback(A=>{h&&A.includes(h)&&d({to:"/mail/$mailboxId",params:{mailboxId:s},search:L=>({...L,selectedMessageId:void 0})})},[h,s,d]),{deleteMessages:v,isPending:x}=Yt({mailboxId:s,threadId:t,onAfterOptimisticRemove:p}),{moveMessages:y,isPending:j}=Qt({mailboxId:s,threadId:t,accountId:a,onAfterOptimisticRemove:p}),{toggleTrusted:w,isPending:N,error:E,reset:C}=Ya({messageId:e}),k=()=>{g({body:{messageIds:[e],isRead:!1}})},R=()=>{v([e])},O=()=>{o&&w(o,i)},D=b||x||j||N,P=D||!o,I=c.useCallback(A=>{y([e],A)},[y,e]),S=o?void 0:"Sender has no parseable address";return n.jsxs("div",{className:"flex flex-col items-end gap-1",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[a&&n.jsx(dn,{accountId:a,currentMailboxId:s,onMove:I,disabled:D,label:"Move this message"}),n.jsxs(Cc,{trigger:n.jsx(zl,{className:"size-4"}),children:[n.jsxs(hs,{onClick:O,disabled:P,children:[i?n.jsx(Yn,{className:"size-4 text-positive"}):n.jsx(Qs,{className:"size-4 opacity-0"}),n.jsx("span",{title:S,children:"Trusted sender"})]}),r&&n.jsxs(hs,{onClick:k,disabled:D,children:[n.jsx(ks,{className:"size-4"}),"Mark as unread"]}),u&&n.jsxs(hs,{onClick:u,children:[n.jsx(Fl,{className:"size-4"}),l?"Show formatted":"Show raw email"]}),n.jsx(Xr,{}),n.jsxs(hs,{onClick:R,disabled:D,destructive:!0,children:[n.jsx(nt,{className:"size-4"}),"Delete"]})]})]}),E&&n.jsx("div",{className:"w-64",children:n.jsx(Dt,{variant:"inline",title:"Couldn't update trust",error:E,onRetry:()=>{C(),O()}})})]})},Rv=()=>{const[e,t]=c.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return c.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},Mv=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:a})=>n.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[n.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&n.jsx("button",{type:"button",onClick:a,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),Av=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},Dv=e=>e instanceof Ht?e.reason:"generic",Ov=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",Pv=({error:e,onRetry:t})=>{const s=Dv(e),r=Ov(e),{title:a,detail:o}=Av(s,r),[i,l]=c.useState(!1),{Account:u}=ga();return i?null:n.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(Gt,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"font-medium text-danger",children:a}),n.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&n.jsx(u,{children:({signOut:f})=>n.jsx("button",{type:"button",onClick:()=>f(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&n.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),n.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:n.jsx(We,{className:"size-4","aria-hidden":"true"})})]})]})},Lv=()=>n.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),Ri=()=>n.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),yu=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:a,fromAddressId:o,category:i,className:l})=>{const[u,f]=c.useState(!1),d=r||u,m=Rv(),{toggleTrusted:h,isPending:g}=Ya({messageId:a??""}),b=!!e&&e.length>0,{picked:p,data:v,isLoading:x,isError:y,error:j,refetch:w}=$c({messageId:a,bodyParts:e,enabled:b}),N=c.useMemo(()=>ph(e??[]),[e]),E=b&&v?.kind==="html"?v.body:t,C=b&&v?.kind==="text"?v.body:s;if(b){if(x)return n.jsx("div",{className:xe("message-body",l),children:n.jsx(Lv,{})});if(y)return n.jsx("div",{className:xe("message-body",l),children:n.jsx(Pv,{error:j,onRetry:()=>w()})});if(!p)return n.jsx("div",{className:xe("message-body",l),children:n.jsx(Ri,{})})}else if(!t&&!s)return n.jsx("div",{className:xe("message-body",l),children:n.jsx(Ri,{})});const k=!!(o&&a),R=()=>{!o||g||(f(!0),h(o,!1))};return n.jsx(tc,{className:l,html:E,text:C,isDark:m,category:i,allowImages:d,resolveCid:N,renderBlockedNotice:O=>n.jsx(Mv,{blockedImageCount:O,canAlwaysTrust:k,isTrustPending:g,onLoadOnce:()=>f(!0),onAlwaysTrust:R})})},$v=({messageId:e,threadId:t,mailboxId:s,accountId:r,isRead:a,isStarred:o,onToggleStar:i,fromAddressId:l,isTrusted:u,showRaw:f,onToggleRaw:d,onReply:m,onReplyAll:h,onForward:g})=>{const b=we(),{deleteMessages:p}=Yt({mailboxId:s,threadId:t}),{moveMessages:v}=Qt({mailboxId:s,threadId:t,accountId:r}),{toggleTrusted:x}=Ya({messageId:e}),{mutate:y}=ye({...Wn(),onSettled:()=>{b.invalidateQueries({queryKey:Zt({path:{threadId:t}})}),Ft(b,$t([s]))}}),j=c.useCallback(C=>{v([e],C)},[v,e]),w=c.useCallback(()=>{p([e])},[p,e]),N=c.useCallback(()=>{y({body:{messageIds:[e],isRead:!a}})},[y,e,a]),E=[];return l&&E.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?n.jsx(Yn,{className:"size-4 text-positive"}):n.jsx(Qs,{className:"size-4"}),onSelect:()=>x(l,u)}),d&&E.push({key:"raw",label:f?"Show formatted":"Show raw email",icon:n.jsx(Fl,{className:"size-4"}),onSelect:d}),n.jsx(ec,{hasThread:!0,onReply:m,onReplyAll:h,onForward:g,isStarred:o,onToggleStar:i,onDelete:w,isRead:a,onToggleRead:N,overflowItems:E,moveSlot:r?n.jsx(dn,{accountId:r,currentMailboxId:s,onMove:j,label:"Move this message"}):void 0})},Fv=()=>n.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),zv=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:r,isError:a,error:o,refetch:i}=de({...pf({path:{messageId:e}}),enabled:t});if(r)return n.jsx("div",{className:"message-body",children:n.jsx(Fv,{})});if(a)return n.jsx("div",{className:"message-body",children:n.jsx(Dt,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const l=s?.raw??"";return l===""?n.jsx("div",{className:"message-body",children:n.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):n.jsx("div",{className:"message-body",children:n.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:l})})},_v=()=>n.jsx(Yn,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),wu=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),ju=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:r})=>n.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:xe("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":xe("text-fg-subtle hover:text-warning",r&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:n.jsx(Rt,{className:xe("size-3.5",e&&"fill-current")})}),Bv=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:r,isStarPending:a})=>{const o=jl(e.sentDate,"datetime"),i=wu(e,o);return n.jsx(sc,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:n.jsxs(n.Fragment,{children:[e.hasAttachment&&n.jsx(Gn,{className:"size-3 shrink-0 text-fg-subtle"}),n.jsx(ju,{isStarred:e.hasStars,onToggleStar:r,isStarPending:a,hoverReveal:!0}),n.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},Kv=({threadMessage:e,messageData:t,isLoading:s,isError:r,error:a,onRetry:o,isFocused:i,onToggle:l,onToggleStar:u,isStarPending:f,accountId:d,showRaw:m,onToggleRaw:h,mobile:g,onReply:b,onReplyAll:p,onForward:v})=>{const x=jl(e.sentDate,"long"),y=!e.isRead,j=t?.envelope.from[0]?.flags?.trusted?.value===!0,w=t?.envelope.from[0]?.addressId,N=wu(e,x),E=e.autoMoved?n.jsx(Vc,{accountId:d,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,size:"md"}):null;return n.jsx(nc,{message:N,isFocused:g?!1:i,onHeaderClick:l,senderBadge:j?n.jsx(_v,{}):void 0,trailing:n.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:x}),to:t?n.jsx(Hm,{label:"To",addresses:t.envelope.to}):null,indicators:E||!g?n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[E,!g&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(ju,{isStarred:e.hasStars,onToggleStar:u,isStarPending:f}),e.hasAttachment&&n.jsx("span",{className:"text-fg-subtle p-0.5",children:n.jsx(Gn,{className:"size-3.5"})})]}),y&&n.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:g?void 0:n.jsx(Tv,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:d,fromAddressId:w,isTrusted:j,showRaw:m,onToggleRaw:h}),actionBar:g?n.jsx($v,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:d,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:w,isTrusted:j,showRaw:m,onToggleRaw:h,onReply:b,onReplyAll:p,onForward:v}):void 0,body:s?n.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):r&&gf(a)?n.jsx("div",{className:"mt-3",children:n.jsx(Uc,{message:"This message has been deleted"})}):r?n.jsx("div",{className:"mt-3",children:n.jsx(Dt,{variant:"inline",title:"Couldn't load this message",error:a,onRetry:o})}):m?n.jsx("div",{className:"mt-3",children:n.jsx(zv,{messageId:e.messageId})}):n.jsx("div",{className:"mt-3",children:n.jsx(yu,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:j,category:sr(e.category)})})})},Uv=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:r,onToggleStar:a,isStarPending:o,accountId:i,mobile:l,onReply:u,onReplyAll:f,onForward:d})=>{const[m,h]=c.useState(!1),{data:g,isLoading:b,isError:p,error:v,refetch:x}=de({...wa({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?n.jsx(Kv,{threadMessage:e,messageData:g,isLoading:b,isError:p,error:v,onRetry:()=>x(),isFocused:s,onToggle:r,onToggleStar:a,isStarPending:o,accountId:i,showRaw:m,onToggleRaw:()=>h(y=>!y),mobile:l,onReply:u,onReplyAll:f,onForward:d}):n.jsx(Bv,{threadMessage:e,isFocused:s,onToggle:r,onToggleStar:a,isStarPending:o})},qv=()=>n.jsxs("div",{className:"animate-pulse p-4",children:[n.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),n.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>n.jsxs("div",{className:"flex gap-3 py-3",children:[n.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]});function Mi({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?n.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:[n.jsx(Cs,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",n.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."]}),t&&n.jsx("button",{type:"button",onClick:t,className:"shrink-0 text-2xs font-medium text-danger hover:underline",children:"Why?"})]}):null}const Es=({threadId:e,mailboxId:t,subject:s,selectedMessageId:r,authenticity:a,onOpenIntelligence:o,onBack:i,composeRequest:l,onComposeClose:u,onSwipeNext:f,onSwipePrevious:d,mobileIntelligenceOpen:m})=>{const h=At(),{handlers:g}=Ab({onSwipeLeft:f,onSwipeRight:d}),{accountId:b}=qc(t),{data:p,isLoading:v,isError:x,error:y,refetch:j}=de({...xf({path:{threadId:e}})}),w=c.useMemo(()=>p?.items??[],[p?.items]),N=w[w.length-1],E=c.useRef(new Map),[C,k]=c.useState(new Set),[R,O]=c.useState(null),[D,P]=c.useState(0);c.useEffect(()=>{if(w.length>0&&e!==R){O(e);const G=new Set([w[w.length-1].threadMessageId]);if(r){const ae=w.find(le=>le.messageId===r);ae&&G.add(ae.threadMessageId)}k(G),P(w.length-1)}},[e,w,R,r]);const I=c.useCallback(G=>{k(ae=>{const le=new Set(ae);return le.has(G)?le.delete(G):le.add(G),le})},[]),S=c.useCallback(G=>{const ae=w[G];if(!ae)return;E.current.get(ae.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[w]),A=c.useCallback(()=>{if(w.length===0)return;const G=Math.min(D+1,w.length-1);P(G),S(G)},[w.length,D,S]),L=c.useCallback(()=>{if(w.length===0)return;const G=Math.max(D-1,0);P(G),S(G)},[w.length,D,S]),T=c.useCallback(()=>{const G=w[D];G&&I(G.threadMessageId)},[w,D,I]),{data:F}=de({...xt(),staleTime:1/0}),M=F?.accounts?.[0],$=!!M?.smtpHost;Ib({messages:w,expandedIds:C,threadId:e,mailboxId:t,accountId:M?.accountId});const{toggleStar:K,isPending:B,pendingMessageId:J}=Wa({threadId:e,mailboxId:t,messages:w}),[ee,X]=c.useState(null);c.useEffect(()=>{l&&l!=="new"&&(X(l),u?.())},[l,u]);const{data:me}=de({...wa({path:{messageId:N?.messageId??""}}),enabled:!!N&&ee!==null}),ue=c.useCallback(()=>{X("reply")},[]),te=c.useCallback(()=>{X("reply_all")},[]),U=c.useCallback(()=>{X("forward")},[]),H=c.useCallback(()=>{X(null),u?.()},[u]);if(qa({enabled:!v&&w.length>0&&ee===null,bindings:[{key:"j",handler:A,preventDefault:!0},{key:"ArrowDown",handler:A,preventDefault:!0},{key:"k",handler:L,preventDefault:!0},{key:"ArrowUp",handler:L,preventDefault:!0},{key:"Enter",handler:T,preventDefault:!0},{key:"o",handler:T,preventDefault:!0},...$?[{key:"r",handler:ue,preventDefault:!0},{key:"R",handler:te,noModifiers:!1,preventDefault:!0},{key:"f",handler:U,preventDefault:!0}]:[]]}),v)return n.jsx(qv,{});if(x)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(Dt,{title:"Couldn't load this conversation",error:y,onRetry:()=>j()})});if(w.length===0)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(Uc,{message:"No messages in this thread"})});const re=s||w[0]?.subject||"(No subject)",Ie=w.length,je=G=>n.jsx("div",{children:w.map((ae,le)=>n.jsx("div",{ref:_=>{_&&E.current.set(ae.threadMessageId,_)},children:n.jsx(Uv,{threadMessage:ae,isExpanded:C.has(ae.threadMessageId),isFocused:le===D,onToggle:()=>I(ae.threadMessageId),onToggleStar:()=>K(ae.messageId,ae.hasStars),isStarPending:B&&J===ae.messageId,accountId:b,mobile:G,onReply:G&&$?ue:void 0,onReplyAll:G&&$?te:void 0,onForward:G&&$?U:void 0})},ae.threadMessageId))}),V=n.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[n.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:re}),n.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[Ie," ",Ie===1?"message":"messages"]})]});return h?n.jsxs("article",{className:"h-full flex flex-col",children:[V,a?.dkimMismatch&&n.jsx(Mi,{authenticity:a,onOpenIntelligence:o}),n.jsx("div",{className:"flex-1 overflow-auto",children:je(!1)}),ee!==null&&n.jsx(wi,{mode:ee,account:M,sourceMessage:me,onClose:H})]}):n.jsxs(_h,{thread:{subject:re,messages:[]},onBack:i??(()=>{}),intelligenceOpen:m,onToggleIntelligence:o,touchHandlers:g,children:[a?.dkimMismatch&&n.jsx(Mi,{authenticity:a,onOpenIntelligence:o}),je(!0),ee!==null&&n.jsx(wi,{mode:ee,account:M,sourceMessage:me,onClose:H})]})};function Is(){const{mailboxNameIndex:e,accountNameIndex:t}=Ce();return{...gt({select:r=>Ac(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}const Za=e=>e.trim().toLocaleLowerCase(),Hv=/^\d{4}-\d{2}-\d{2}$/;function Ai(e,t,s){if(!Hv.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function Wv(e,t){const s=e.toLowerCase();if(s.startsWith("from:")&&e.length>5)return{type:"from",raw:e,value:e.slice(5)};if(s==="has:attachment")return{type:"hasAttachment",raw:e};if(s==="is:unread")return{type:"isUnread",raw:e};if(s.startsWith("before:")&&e.length>7)return Ai("before",e,e.slice(7));if(s.startsWith("after:")&&e.length>6)return Ai("after",e,e.slice(6));if(s.startsWith("in:")&&e.length>3){const r=e.slice(3),a=t.mailboxesByName?.get(r.toLowerCase());return a?{type:"in",raw:e,value:r,mailboxId:a}:void 0}if(s.startsWith("account:")&&e.length>8){const r=e.slice(8),a=t.accountsByName?.get(r.toLowerCase());return a?{type:"account",raw:e,value:r,accountId:a}:void 0}}function Ts(e,t={}){const s=e.split(/\s+/).filter(o=>o.length>0),r=[],a=[];for(const o of s){const i=Wv(o,t);i?r.push(i):a.push(o)}return{freeText:a.join(" "),tokens:r}}function Vv(e,t){return e.split(/\s+/).filter(s=>s.length>0&&s!==t.raw).join(" ")}function Su(e){switch(e.type){case"from":return`From: ${e.value}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}const Qv=20,Yv=new Set(Object.values(ot)),Gv=e=>e!==void 0&&Yv.has(e)?e:void 0;function ku({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=Ce(),r=Is(),a=gt({select:y=>y.matches}),o=Za(s),{freeText:i,tokens:l}=Ts(o,r),u=i.length>0,f=Gv(t),d=l.some(y=>y.type==="hasAttachment")?!0:void 0,m=l.some(y=>y.type==="isUnread")?!1:void 0,h=l.find(y=>y.type==="after"),g=l.find(y=>y.type==="before"),b=l.find(y=>y.type==="in"),p=_x({matches:a,callerMailboxId:e,inTokenMailboxId:b?.mailboxId}),{data:v,isLoading:x}=de({...cl({query:{query:i,mailboxId:p,limit:Qv,...f!==void 0?{category:f}:{},...d!==void 0?{hasAttachment:d}:{},...m!==void 0?{isRead:m}:{},...h?{sentDateFrom:h.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:u,staleTime:6e4});return{hits:v?.items??[],isLoading:u&&x}}const Xv=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),Jv=e=>[...e].sort(Xv);function sa(e){const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId??e.accountConfigId,mailboxId:e.mailboxId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ot(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:sr(e.category),suspicious:t}}function Zv(e,t){const s=new Set,r=[];for(const a of[...e,...t])s.has(a.id)||(s.add(a.id),r.push(a));return r.sort((a,o)=>(o.sentDate??0)-(a.sentDate??0))}const Di=[{id:"personal",label:"Personal",category:ot.personal},{id:"transactional",label:"Transactional",category:ot.transactional},{id:"newsletter",label:"Newsletter",category:ot.newsletter},{id:"marketing",label:"Marketing",category:ot.marketing},{id:"social",label:"Social",category:ot.social},{id:"automated",label:"Automated",category:ot.automated},{id:"uncategorized",label:"Unclassified",category:ot.uncategorized}];function ey(e){const t=new Map(Di.map(r=>[r.category,[]]));for(const r of e){const a=r.category??ot.uncategorized;(t.get(a)??t.get(ot.uncategorized))?.push(r)}const s=[];for(const r of Di){const a=t.get(r.category);a&&a.length>0&&s.push({id:r.id,label:r.label,threads:a})}return s}function Cu(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function Nu(e,t){return t.every(s=>{switch(s.type){case"from":{const r=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(r)||e.fromName.toLowerCase().includes(r)}case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;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 ty={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function sy(e){return ty[e]??e}function ny(e,t){const{folder:s}=ja(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Ot(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function Eu(e,t){const{folder:s}=ja(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function ry(e,t){const{mailboxId:s,folder:r}=ja(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Ot(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:sy(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...r?{folder:r}:{}}}function Iu(e,t,s){const r=new Set(t),a=[];for(const o of[...e].sort((i,l)=>l.score-i.score))r.has(o.threadId)||(r.add(o.threadId),a.push(ry(o,s)));return a}const ay=768,oy=1024,Tu=e=>e!=="desktop",or=()=>{const e=wo(`(min-width: ${ay}px)`);return wo(`(min-width: ${oy}px)`)?"desktop":e?"tablet":"phone"},iy=new Set(["hasAttachment","isUnread","before","after"]),Ru=(e,{searchHadSemanticReach:t})=>{const s=[],r=[];let a,o;for(const u of e.tokens){if(u.type==="from"){s.push({field:"From",value:u.value});continue}if(u.type==="in"){a={mailboxId:u.mailboxId,label:u.value};continue}if(u.type==="account"){o=u.accountId;continue}iy.has(u.type)&&r.push({type:u.type,label:Su(u)})}const i=e.freeText.trim(),l=i.length>0;return l&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:a,droppedFacets:r,targetAccountId:o,keptTerms:l,droppedSemantic:l&&t}},ly=e=>e.clauses.length>0,Mu=(e,{scope:t="standing",moveMailboxId:s}={})=>({clauses:e.clauses.map((r,a)=>({id:`search-${a}`,field:r.field,value:r.value})),matchOperator:e.matchOperator,moveMailboxId:s,scope:t,name:""}),Au="remit.recentSearches",cy=5;function na(){try{const e=localStorage.getItem(Au);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Oi(e){const t=e.trim();if(!t)return na();const s=[t,...na().filter(r=>r!==t)].slice(0,cy);try{localStorage.setItem(Au,JSON.stringify(s))}catch{return s}return s}const uy=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function dy(e){const{spam:t}=ac([...e]),s=new Map;for(const a of t)a.mailboxId&&s.set(a.mailboxId,(s.get(a.mailboxId)??0)+1);let r;for(const[a,o]of s)(!r||o>r.count)&&(r={mailboxId:a,count:o});return r}const fy=(e,t)=>{const s=ye(ul()),{mutate:r,reset:a}=s,o=c.useCallback(()=>{e&&(a(),r({path:{accountId:e},body:qr({matchOperator:t.matchOperator,literalClauses:t.literalClauses})}))},[e,t.matchOperator,t.literalClauses,r,a]);return c.useEffect(()=>{o()},[o]),{seedCount:s.data?.matchedCount,isPending:s.isPending||s.data===void 0,isError:s.isError,error:s.error,retry:o}},Du=({initialRule:e,widenAnchorCount:t=1})=>{const[s,r]=c.useState(e),[a,o]=c.useState(),i=c.useRef(0);return{rule:s,setRule:N=>r(N),handlers:{clauseEdit:a,onStartAddClause:()=>o({mode:"add",draft:{field:Ca[0],value:""}}),onStartEditClause:N=>{const E=s.clauses.find(C=>C.id===N);E&&o({mode:"edit",clauseId:N,draft:{field:E.field,value:E.value}})},onRemoveClause:N=>r(E=>({...E,clauses:E.clauses.filter(C=>C.id!==N)})),onChangeDraftField:N=>o(E=>E&&{...E,draft:{...E.draft,field:N}}),onChangeDraftValue:N=>o(E=>E&&{...E,draft:{...E.draft,value:N}}),onSubmitClause:()=>{if(!a)return;const N=a.draft.field,E=zf(N,a.draft.value);E!==""&&(r(C=>a.mode==="edit"&&a.clauseId?{...C,clauses:C.clauses.map(k=>k.id===a.clauseId?{id:k.id,field:N,value:E}:k)}:(i.current+=1,{...C,clauses:[...C.clauses,{id:`clause-${i.current}`,field:N,value:E}]})),o(void 0))},onCancelClause:()=>o(void 0),onAddWiden:()=>r(N=>({...N,widen:{anchorCount:Math.max(t,1)}})),onRemoveWiden:()=>r(N=>({...N,widen:void 0})),onChangeMatchOperator:N=>r(E=>({...E,matchOperator:N})),onChangeMove:N=>r(E=>({...E,moveMailboxId:N||void 0})),onChangeScope:N=>r(E=>({...E,scope:N})),onChangeName:N=>r(E=>({...E,name:N})),onChangeUntil:N=>r(E=>({...E,until:N}))}}};function Ou({progress:e,isDone:t,runningLabel:s,onClose:r}){const a=e.state==="Failed";return n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t?a?n.jsx("span",{className:"text-sm font-semibold text-danger",children:"Organize failed"}):n.jsx(Ia,{className:"size-8 text-positive"}):n.jsx(st,{className:"size-8 animate-spin text-accent-2"}),!t&&n.jsx("p",{className:"text-sm font-medium text-fg",children:s}),t&&!a&&n.jsxs("div",{className:"text-sm text-fg",children:[n.jsx("p",{className:"font-medium",children:"Done"}),n.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),t&&a&&n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),t&&n.jsx(Y,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Pu(){return n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[n.jsx(st,{className:"size-8 animate-spin text-accent-2"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving rule…"})]})}function Lu({onClose:e}){return n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[n.jsx(Ia,{className:"size-8 text-positive"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter saved"}),n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"You can see it, and when it expires, under Settings › Filters."}),n.jsx(Y,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function $u({onRetry:e,onClose:t}){return n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save the rule"}),n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),n.jsxs("div",{className:"mt-2 flex gap-2",children:[n.jsx(Y,{variant:"primary",onClick:e,children:"Try again"}),n.jsx(Y,{variant:"ghost",onClick:t,children:"Not now"})]})]})}function my({accountId:e,conversion:t,seedCount:s,onClose:r}){const[a]=c.useState(()=>Mu(t)),{rule:o,handlers:i}=Du({initialRule:a}),{data:l}=de({...ze({path:{accountId:e}}),staleTime:Number.POSITIVE_INFINITY}),u=c.useMemo(()=>Zs(l?.items??[]).map(g=>({id:g.mailboxId,label:Vn(g.fullPath)})),[l?.items]),f=xl(e,Na(o),s),d=bl(e),m=vl(e),h=()=>{const g=yl(o);if(o.scope==="once"){d.start(g);return}m.createFilter(g,o.scope==="standing"?"standing":"temporary",(o.name??"").trim())};return d.isStarting||d.isRunning||d.isDone?n.jsx(Ou,{progress:d.progress,isDone:d.isDone,runningLabel:"Organizing your mail…",onClose:r}):m.isPending?n.jsx(Pu,{}):m.isSuccess?n.jsx(Lu,{onClose:r}):m.isError?n.jsx($u,{onRetry:m.reset,onClose:r}):n.jsx(dl,{rule:o,folders:u,preview:f,notice:n.jsx(Kp,{notice:{scopedOutFolder:t.scopedOut?.label,droppedFacets:t.droppedFacets.map(g=>g.label),droppedSemantic:t.droppedSemantic}}),semanticAvailable:!1,clauseFields:Ca,...i,onCommit:h,onCancel:r})}function hy({open:e,accountId:t,parsed:s,searchHadSemanticReach:r,onClose:a}){const o=c.useMemo(()=>Ru(s,{searchHadSemanticReach:r}),[s,r]),i=c.useMemo(()=>Na(Mu(o)),[o]),{seedCount:l,isPending:u,isError:f,retry:d}=fy(e?t:void 0,i);return e?n.jsx(ca,{open:e,onClose:a,title:"Filter rule",children:f?n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't build the filter"}),n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),n.jsxs("div",{className:"mt-2 flex gap-2",children:[n.jsx(Y,{variant:"primary",onClick:d,children:"Try again"}),n.jsx(Y,{variant:"ghost",onClick:a,children:"Not now"})]})]}):u||l===void 0?n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[n.jsx(st,{className:"size-8 animate-spin text-accent-2"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Turning your search into a filter…"})]}):n.jsx(my,{accountId:t,conversion:o,seedCount:l,onClose:a})}):null}function Fu({title:e,unreadCount:t,children:s,footer:r,searchFilter:a,searchResults:o,searchLoading:i,relatedResults:l,relatedLoading:u,onSelectSearchResult:f,searchResultsLabel:d="Top matches",relatedResultsLabel:m="Related",searchResultsInBody:h=!1}){const{accounts:g,resultFolderIndex:b,searchQuery:p,searchInput:v,onSearchChange:x,onSearchClear:y,searchViewKey:j}=Ce(),w=Is(),N=Oe(),E=Ss(),C=or(),[k,R]=c.useState(!1),[O,D]=c.useState(na),[P,I]=c.useState(!1),S=c.useRef(j);c.useEffect(()=>{S.current!==j&&(S.current=j,R(!1))},[j]);const A=v.trim().length>0,{mailboxesByName:L,accountsByName:T}=w,F=c.useMemo(()=>Ts(v,{mailboxesByName:L,accountsByName:T}),[v,L,T]),M=F.tokens.map(pe=>({label:Su(pe),onRemove:()=>x(Vv(v,pe))})),$=o??[],K=l??[],B=A?[{id:"top",label:d,results:$},{id:"related",label:m,results:K}]:[],ee=!($.length+K.length>0)&&(i===!0||u===!0),{scope:X}=Pc(g),me=gt({select:pe=>pe.matches}),ue=Dc(me),te=Kx(me,X,ue?b.get(ue)?.role:void 0),U=te.kind==="global"?dy([...$,...K]):void 0,H=U?{kind:"global",onScopeToSpam:()=>N({to:"/mail/$mailboxId",params:{mailboxId:U.mailboxId},search:{q:p||void 0,selectedMessageId:void 0,selectedThreadId:void 0}})}:te,Ie=F.tokens.find(pe=>pe.type==="account")?.accountId??g[0]?.accountId,je=K.length>0,V=A&&Ie?{onClick:()=>I(!0),disabledReason:ly(Ru(F,{searchHadSemanticReach:je}))?void 0:"Add a sender or words to filter on"}:void 0,G=P&&Ie?n.jsx(hy,{open:P,accountId:Ie,parsed:F,searchHadSemanticReach:je,onClose:()=>I(!1)}):null;if(C==="phone"&&k){const pe=ge=>{D(Oi(v)),R(!1),f?.(ge)};return n.jsxs(n.Fragment,{children:[n.jsx(pp,{value:v,onChange:x,onClear:y,onCancel:()=>{R(!1),y()},filter:a,recentSearches:O,onPickRecent:x,makeFilter:V,sections:B,loading:ee,onSelectResult:pe,tokens:M,scope:H}),G]})}const ae=uy({tier:C,hasLiveInput:A,hasCommittedQuery:p.trim().length>0,bodyRendersCommittedResults:h}),le=pe=>{D(Oi(v)),f?.(pe)},_=n.jsx(oc,{value:v,sections:B,loading:ee,onSelectResult:le,tokens:M,scope:H,makeFilter:V}),Fe=ae?a?n.jsx(ua,{...a,children:_}):n.jsx("div",{className:"h-full overflow-y-auto",children:_}):s;return n.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[n.jsx(ap,{title:e,unreadCount:t,isDesktop:!1,showSearch:Tu(C),onMenuClick:()=>E?.openNav(),searchValue:v,onSearchChange:x,onSearchClear:y,searchOpen:k,onSearchOpenChange:R}),n.jsx("div",{className:"min-h-0 flex-1",children:Fe}),r,G]})}const eo=({isOpen:e,title:t,description:s,confirmLabel:r,cancelLabel:a="Cancel",destructive:o=!1,isBusy:i=!1,onConfirm:l,onCancel:u})=>{const f=c.useRef(null),d=c.useCallback(m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation(),u())},[u]);return c.useEffect(()=>{if(e)return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e,d]),c.useEffect(()=>{e&&f.current?.focus()},[e]),e?n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[n.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm","aria-hidden":"true",onClick:u}),n.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":t,className:xe("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),children:[n.jsx("h2",{className:"text-lg font-semibold",children:t}),s&&n.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:s}),n.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[n.jsx("button",{ref:f,type:"button",onClick:u,className:xe("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:a}),n.jsx("button",{type:"button",onClick:l,disabled:i,className:xe("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",o?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:r})]})]})]}):null},py=(e,t,s)=>{const r=e.indexOf(s);if(r===-1)return[];const a=t===void 0?-1:e.indexOf(t);if(a===-1)return[s];const o=Math.min(a,r),i=Math.max(a,r);return e.slice(o,i+1)},gy=(e,t,s,r)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:r,xy=(e,t)=>{const s=new Set(t),r=new Set;for(const a of e)s.has(a)&&r.add(a);return r},zu=(e,t,s)=>{if(e.length===0)return;const r=t===void 0?-1:e.indexOf(t);if(r===-1)return s>0?e[0]:e[e.length-1];const a=Math.min(Math.max(r+s,0),e.length-1);return e[a]},_u=e=>{const[t,s]=c.useState(new Set),[r,a]=c.useState(void 0),o=c.useCallback(p=>t.has(p),[t]),i=c.useCallback(p=>{a(p),s(v=>{const x=new Set(v);return x.has(p)?x.delete(p):x.add(p),x})},[]),l=c.useCallback(p=>{a(p),s(v=>{if(v.has(p))return v;const x=new Set(v);return x.add(p),x})},[]),u=c.useCallback(p=>{s(v=>{if(!v.has(p))return v;const x=new Set(v);return x.delete(p),x})},[]),f=c.useCallback(p=>{s(new Set(p))},[]),d=c.useCallback(()=>{a(void 0),s(new Set)},[]),m=c.useCallback(p=>{s(v=>p.every(y=>v.has(y))?new Set:new Set(p))},[]),h=c.useCallback(p=>{a(p)},[]),g=c.useCallback(p=>{s(v=>{if(v.size===0)return v;const x=xy(v,p);return x.size===v.size?v:x})},[]),b=c.useCallback((p,v,x)=>{const y=gy(p,r,x,v);s(j=>{const w=py(p,y,v);if(w.length===0)return j;const N=new Set(j);for(const E of w)N.add(E);return N}),a(y)},[r]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:l,deselect:u,selectAll:f,clearSelection:d,toggleAll:m,selectRange:b,setAnchor:h,anchorId:r,intersectWith:g}},Bu=(e,t)=>!t&&e>0,by=(e,t)=>e==="BACK"&&t,vy=({orderedIds:e,isDesktop:t,initialFocusedId:s,onExitSelection:r})=>{const[a,o]=c.useState(s),i=_u(),{selectedCount:l,toggle:u,clearSelection:f,selectRange:d,setAnchor:m,selectAll:h}=i,g=Bu(l,t),b=c.useRef(null),p=c.useRef(!1),v=c.useCallback(()=>{r?.(),f()},[f,r]),x=c.useMemo(()=>a?e.indexOf(a):-1,[e,a]),y=c.useCallback(I=>{if(I<0||I>=e.length)return;const S=e[I];if(g){u(S);return}b.current=S,p.current=!1,o(S)},[e,g,u]),j=c.useCallback(()=>{e.length!==0&&y(x<0?0:Math.min(x+1,e.length-1))},[e.length,x,y]),w=c.useCallback(()=>{e.length!==0&&y(x<=0?0:x-1)},[e.length,x,y]),N=c.useCallback(()=>y(0),[y]),E=c.useCallback(()=>y(e.length-1),[y,e.length]),C=c.useCallback(()=>{a&&u(a)},[a,u]),k=c.useCallback((I,S)=>S.shiftKey?(d(e,I,a),!0):S.metaKey||S.ctrlKey?(u(I),!0):(v(),m(I),!1),[e,a,d,u,v,m]),R=c.useCallback(I=>{const S=zu(e,a,I);S!==void 0&&(d(e,S),b.current=S,p.current=!1,o(S))},[e,a,d]),O=c.useCallback(()=>R(-1),[R]),D=c.useCallback(()=>R(1),[R]),P=c.useCallback(()=>{e.length>0&&h(e)},[e,h]);return{focusedMessageId:a,setFocusedMessageId:o,focusIndex:x,pendingDomFocusRef:b,cursorMovedByPointerRef:p,selection:i,isMultiSelectMode:g,exitSelection:v,moveFocusToIndex:y,focusNext:j,focusPrevious:w,focusFirst:N,focusLast:E,toggleFocusedSelection:C,extendRangeUp:O,extendRangeDown:D,selectAllLoaded:P,handleRowSelect:k}};function Ku(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const Uu=({selectedCount:e,onDelete:t,onClearSelection:s,onMarkAsRead:r,onMove:a,onOrganize:o,isDeleting:i=!1,isMoving:l=!1,accountId:u,currentMailboxId:f,moveDisabledHint:d,selectAll:m,statusLabel:h,isCounting:g=!1,progress:b,notice:p})=>{if(e===0)return null;const v=b!==void 0,x=i||l||v,y=!v&&!g,j=!!a&&!!u&&!!f,w=!!o&&!!u&&!!f&&!d&&!h,N=m?.checked?`All ${e} loaded selected`:`${e} ${e===1?"message":"messages"} selected`;return n.jsxs("div",{className:"sticky top-0 z-10 flex flex-col bg-surface-sunken border-b border-line",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{type:"button",onClick:s,className:"min-h-11 min-w-11 inline-flex items-center justify-center rounded hover:bg-surface-raised transition-colors","aria-label":"Clear selection",children:n.jsx(We,{className:"size-4 text-fg-muted"})}),m&&n.jsx("label",{className:"flex size-11 shrink-0 cursor-pointer items-center justify-center",children:n.jsx(nn,{"aria-label":"Select all",checked:m.checked,indeterminate:m.indeterminate,onChange:m.onChange})}),n.jsx("span",{className:"text-sm font-medium",children:h??N}),d&&!p&&n.jsx("span",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:d})]}),n.jsxs("div",{className:"flex items-center gap-1",children:[w&&o&&n.jsxs("button",{type:"button",onClick:x?void 0:o,className:"min-h-11 inline-flex items-center justify-center gap-1.5 px-3 rounded text-sm font-medium transition-colors hover:bg-surface-raised","aria-label":"Organize similar messages",children:[n.jsx(ut,{className:"size-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Organize"})]}),y&&r&&n.jsx("button",{type:"button",onClick:x?void 0:r,className:"min-h-11 min-w-11 inline-flex items-center justify-center rounded text-sm font-medium transition-colors hover:bg-surface-raised","aria-label":"Mark as read","aria-busy":x,children:n.jsx(ks,{className:"size-4"})}),y&&j&&a&&u&&f&&n.jsx(dn,{accountId:u,currentMailboxId:f,onMove:x?()=>{}:a,disabledHint:d,variant:"icon-only",label:"Move selected messages"}),y&&n.jsxs("button",{type:"button",onClick:x?void 0:t,className:xe("min-h-11 min-w-11 inline-flex items-center justify-center gap-1.5 px-3 rounded text-sm font-medium transition-colors","bg-danger text-canvas hover:bg-danger/90"),"aria-label":"Delete selected messages","aria-busy":i,children:[i?n.jsx(st,{className:"size-4 animate-spin"}):n.jsx(nt,{className:"size-4"}),n.jsx("span",{className:"hidden sm:inline",children:i?"Deleting...":"Delete"})]})]})]}),b&&n.jsx("div",{className:"px-3 pb-2",children:n.jsx(Oa,{value:b.value,max:b.max,tone:b.tone})}),p&&n.jsx(Xt,{tone:p.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-3 mb-2",children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.text&&n.jsx("span",{children:p.text}),p.action&&n.jsx("button",{type:"button",onClick:p.action.onClick,className:"-my-1 min-h-11 shrink-0 inline-flex items-center px-3 rounded text-sm font-medium transition-colors hover:bg-surface-raised",children:p.action.label})]})})]})},to=c.createContext(null),yy=e=>{const t=c.useContext(to);return t?t.rowInteraction(e):null},wy=()=>{const e=c.useContext(to);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},jy="[data-message-id]",Sy=e=>Array.from(e.querySelectorAll(jy)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),ky=(e,t)=>e.length===t.length&&e.every((s,r)=>s===t[r]),Cy=e=>{const[t,s]=c.useState([]);return c.useEffect(()=>{const r=e.current;if(!r)return;const a=()=>{const i=Sy(r);s(l=>ky(l,i)?l:i)};a();const o=new MutationObserver(a);return o.observe(r,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function qu({selectedMessageId:e,onOpen:t,onDeleteMessages:s,isDeleting:r=!1,commandsRef:a,onTriageContextChange:o,children:i}){const l=At(),u=c.useRef(null),f=Cy(u),d=vy({orderedIds:f,isDesktop:l,initialFocusedId:e}),{focusedMessageId:m,setFocusedMessageId:h,pendingDomFocusRef:g,cursorMovedByPointerRef:b,selection:p,isMultiSelectMode:v,exitSelection:x,handleRowSelect:y}=d,{selectedIds:j,selectedCount:w,isSelected:N,toggle:E,select:C}=p,{intersectWith:k}=p;c.useEffect(()=>{k(f)},[k,f]),c.useEffect(()=>{const X=g.current;X!==null&&(g.current=null,u.current?.querySelector(`[data-message-id="${X}"]`)?.focus())});const R=c.useCallback(X=>{b.current=!0,h(X)},[b,h]),O=c.useCallback(X=>{l||C(X)},[l,C]),D=c.useCallback(()=>{m&&t(m)},[m,t]),[P,I]=c.useState(null),S=c.useCallback(X=>!s||X.length===0?!1:(I(X),!0),[s]),A=c.useCallback(()=>{S(Array.from(j))},[S,j]),L=c.useCallback(()=>P!==null?!0:w>0?S(Array.from(j)):m?S([m]):!1,[P,w,j,m,S]),T=c.useCallback(()=>{P!==null&&(s?.(P),I(null),x())},[P,s,x]),F=c.useCallback(()=>I(null),[]),M=c.useCallback(()=>w===0?!1:(x(),!0),[w,x]),$=f.length>0;c.useEffect(()=>{if(a){if(!$){a.current=null;return}return a.current={focusNext:d.focusNext,focusPrevious:d.focusPrevious,focusFirst:d.focusFirst,focusLast:d.focusLast,openFocused:D,toggleSelect:d.toggleFocusedSelection,extendSelectDown:d.extendRangeDown,extendSelectUp:d.extendRangeUp,selectAll:d.selectAllLoaded,clearSelection:M,requestDelete:L,toggleDensity:()=>{}},()=>{a.current=null}}},[a,$,d.focusNext,d.focusPrevious,d.focusFirst,d.focusLast,d.toggleFocusedSelection,d.extendRangeDown,d.extendRangeUp,d.selectAllLoaded,D,M,L]);const K=c.useMemo(()=>Array.from(j),[j]),B=P!==null;c.useEffect(()=>{o?.({focusedMessageId:m,selectedIds:K,orderedIds:f,hasList:$,blocksKeyboard:B})},[o,m,K,f,$,B]);const J=Ku(f,m),ee=c.useMemo(()=>({selectedIds:j,selectedCount:w,exitSelection:x,requestDeleteSelection:A,rowInteraction:X=>({focused:X===m,isTabStop:X===J,isDesktop:l,onFocusRow:R,selection:{isChecked:N(X),onToggleCheck:E,onRowSelect:y,isMultiSelectMode:v,onLongPress:O}})}),[j,w,x,A,m,J,l,R,N,E,y,v,O]);return n.jsxs(to.Provider,{value:ee,children:[n.jsx("div",{ref:u,className:"contents",children:i}),n.jsx(eo,{isOpen:B,title:Sl(P?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:r,onConfirm:T,onCancel:F})]})}function Hu({onMarkAsRead:e,isDeleting:t}){const{selectedIds:s,selectedCount:r,exitSelection:a,requestDeleteSelection:o}=wy(),i=c.useCallback(()=>{e?.(Array.from(s)),a()},[e,s,a]);return n.jsx(Uu,{selectedCount:r,onDelete:o,onClearSelection:a,onMarkAsRead:e?i:void 0,isDeleting:t})}const Ny=({thread:e,active:t=!1,focused:s,isTabStop:r,density:a="comfortable",isDesktop:o,badge:i,selection:l,inListbox:u=!1,linkMailboxId:f,onClick:d,onFocusRow:m})=>{const h=we(),g=e.id,b=yy(g),p=s??b?.focused??!1,v=r??b?.isTabStop??!1,x=l??b?.selection,y=m??b?.onFocusRow,j=o??b?.isDesktop??!0,w=x?.isChecked??!1,N=x?.isMultiSelectMode??!1,E=x?.onToggleCheck,C=x?.onRowSelect,k=x?.onLongPress,R=c.useCallback(M=>{M.preventDefault(),M.stopPropagation(),E?.(g)},[E,g]),O=c.useCallback(M=>{if(!j){if(N){M.preventDefault(),M.stopPropagation(),E?.(g);return}d?.();return}const $={shiftKey:M.shiftKey,metaKey:M.metaKey,ctrlKey:M.ctrlKey};if(C?.(g,$)){M.preventDefault(),M.stopPropagation(),$.shiftKey&&window.getSelection()?.removeAllRanges();return}d?.()},[j,N,E,C,d,g]),D=c.useCallback(M=>{j&&M.shiftKey&&M.preventDefault()},[j]),P=c.useCallback(()=>{k?.(g)},[k,g]),{longPressProps:I}=Xl({onLongPress:P,delayMs:500,accessibilityDescription:w?"Deselect message":"Select message"}),S=c.useCallback(()=>{h.prefetchQuery(wa({path:{messageId:g}}))},[h,g]),A=c.useCallback(()=>{S(),y?.(g)},[S,y,g]),L=en({"data-list-row":"","data-message-row":!0,"data-message-id":g,...u?{role:"option","aria-selected":w}:{},tabIndex:v?0:-1,onClick:O,onMouseDown:D,onMouseEnter:S,onFocus:A},j||!x?{}:I),T=xe(a==="compact"?Ql({active:t,focused:p}):xe("group",sn({active:t,focused:p})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",w&&"bg-accent-soft",!j&&"min-h-11 select-none [-webkit-touch-callout:none]"),F=a==="compact"?n.jsx(Yl,{thread:e}):n.jsx(Gl,{thread:e,badge:i,selection:x?{checked:w,alwaysVisible:N,onToggle:R}:void 0});return f===void 0?n.jsx("button",{type:"button",...L,className:T,children:F}):n.jsx(pt,{to:"/mail/$mailboxId",params:{mailboxId:f},search:M=>({...M,selectedMessageId:g}),...L,className:T,children:F})},so=c.memo(Ny),Ey=200,Iy={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0,contacts:e=>e.trust==="vip"||e.trust==="wellknown",today:e=>e.sentDate!=null&&new Date(e.sentDate).toDateString()===new Date().toDateString()},Pi=()=>n.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[n.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),n.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),n.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),Ty=({accountEmail:e})=>{const t=Oe();return n.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[n.jsx(Gt,{className:"size-3.5 shrink-0"}),n.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),n.jsx("button",{type:"button",onClick:()=>t({to:"/settings/accounts"}),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})};function Ry({accounts:e,selectedMessageId:t,onSelectMessage:s,onSelectSearchResult:r,commandsRef:a,onTriageContextChange:o,onDeleteMessages:i,onMarkMessagesRead:l}){const{searchQuery:u,resultFolderIndex:f}=Ce(),d=Is(),m=At(),h=c.useMemo(()=>Jv(e.filter(U=>!U.muted?.value)),[e]),[g,b]=c.useState("all"),[p,v]=c.useState("all"),[x,y]=c.useState(new Set),[j,w]=c.useState(!1),N=c.useCallback(U=>{y(H=>{const re=new Set(H);return re.has(U)?re.delete(U):re.add(U),re})},[]),{data:E,isLoading:C,isError:k,refetch:R}=de({...Kr(),staleTime:6e4}),O=Lt({queries:h.map(U=>({...ze({path:{accountId:U.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),D=c.useMemo(()=>{const U=new Map;for(let H=0;H<h.length;H++){const re=h[H].accountId,je=(O[H]?.data?.items??[]).reduce((V,G)=>V+(G.unseenCount??0),0);U.set(re,je)}return U},[h,O]),P=c.useMemo(()=>h.filter((U,H)=>{const re=O[H];return re?.isError?!Ur(re.error):!1}),[h,O]),{freeText:I,tokens:S}=Ts(u.trim().toLowerCase(),d),{data:A,isFetching:L}=de({...Kr({query:{query:I,limit:Ey}}),enabled:I.length>0,staleTime:3e4}),T=c.useMemo(()=>{const U=(E?.items??[]).map(sa);return(I?Zv(U.filter(re=>Cu(re,I)),(A?.items??[]).map(sa)):U).filter(re=>(g==="all"||re.accountId===g)&&Nu(re,S))},[E,A,g,I,S]),F=c.useMemo(()=>ey(T),[T]),M=c.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:g==="all"},...h.map(U=>({id:U.accountId,label:U.email.split("@")[0]??U.email,count:D.get(U.accountId),active:g===U.accountId}))],[h,D,g]),$=c.useMemo(()=>e.filter(U=>U.muted?.value).length,[e]),K=c.useMemo(()=>Array.from(D.values()).reduce((U,H)=>U+H,0),[D]),B=c.useMemo(()=>{const U=Array.from(x).map(H=>Iy[H]).filter(H=>H!=null);return T.filter(H=>(p==="all"||H.category===p)&&U.every(re=>re(H))).map(H=>Eu(H,f))},[T,p,x,f]),{hits:J,isLoading:ee}=ku(),X=c.useMemo(()=>{const U=new Map;for(const re of E?.items??[])U.set(re.messageId,re.threadId);const H=B.map(re=>U.get(re.id)).filter(re=>re!=null);return Iu(J,H,f)},[J,B,E,f]),me=c.useMemo(()=>{const U=Gp(M.map(H=>({id:H.id,label:H.label,count:H.count,active:H.active})));return{categories:U.categories,filters:U.filters,sources:U.sources,sourcesNote:$>0?`+${$} muted`:void 0,selectedCategory:p,activeFilters:x,expanded:j,onExpandedChange:w,onSelectCategory:H=>v(H),onSelectSource:b,onToggleFilter:N,onClear:()=>{v("all"),b("all"),y(new Set)}}},[M,$,p,x,j,N]),ue=F.length===0&&g==="all"&&I.length===0,te=C?n.jsxs("div",{className:"h-full overflow-y-auto",children:[n.jsx(Pi,{}),n.jsx(Pi,{})]}):k?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[n.jsx(Gt,{className:"size-8 text-danger"}),n.jsx("p",{children:"Couldn't load your messages"}),n.jsxs("button",{type:"button",onClick:()=>R(),className:"flex items-center gap-1 text-accent underline text-xs",children:[n.jsx(Kl,{className:"size-3.5"}),"Try again"]})]}):ue?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[n.jsx(ut,{className:"size-8 text-fg-subtle"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]}):n.jsx(qu,{selectedMessageId:t,onOpen:U=>s?.(U),onDeleteMessages:i,commandsRef:a,onTriageContextChange:o,children:n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i?n.jsx(Hu,{onMarkAsRead:l}):null,n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Yi,{sections:F,Row:so,manageFocus:!1,briefCategory:p,onSelectBriefCategory:v,sources:M,sourcesNote:$>0?`+${$} muted`:void 0,onSelectSource:b,selectedThreadId:t,onSelectThread:s})})]})});return n.jsx(Fu,{title:"Daily brief",unreadCount:K,footer:m?n.jsx(Wl,{}):void 0,searchFilter:me,searchResults:B,searchLoading:C||L,relatedResults:X,relatedLoading:ee,onSelectSearchResult:r,children:n.jsxs("div",{className:"flex h-full flex-col",children:[P.map(U=>n.jsx(Ty,{accountEmail:U.email,accountId:U.accountId},U.accountId)),n.jsx("div",{className:"min-h-0 flex-1",children:te})]})})}const My=10,Wu=e=>({q:e?.toLowerCase()??"",limit:My}),Ay=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(r=>r.normalizedEmail===s)};function Dy(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":Pn(t,{month:"short",year:"numeric"})}function Vu(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const Oy="We can't verify the sender of this email, which could mean it's from an insecure source.",Py="We couldn't read this sender's address, so we can't confirm who really sent this message.";function Ly(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?Dy(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:Vu(e.fromEmail)}}function $y(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 Fy(e,t){const s=t>0?t:void 0;if(Vu(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:Py,similarCount:s};const r=e.authenticity;if(!r)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:Oy};if(!r.dkimMismatch)return{verdict:"aligned",fromDomain:r.fromDomain,dkimDomain:r.dkimDomain,summary:r.dkimDomain?`We verified this message was really sent by ${r.fromDomain}.`:"Nothing looks unusual about this sender."};const a=r.fromDomain,o=r.dkimDomain,i=e.fromName&&e.fromName!==e.fromEmail?e.fromName:void 0,l=i?`The display name claims "${i}", but this message was actually sent from ${o??"another sender"} — not ${a}. Real senders use their own address.`:`This message claims to be from ${a}, but it was actually sent from ${o??"a different sender"}.`;return{verdict:"mismatch",fromDomain:a,dkimDomain:o,claimedBrand:i,summary:l,similarCount:s}}function Qu(e,t){const s=e?.fromEmail??null,r=e?.subject??"",{data:a,error:o}=de({...rl({query:Wu(s??void 0)}),enabled:!!s,staleTime:3e4}),i=Ay(a?.items,s??void 0),l=[r,s].filter(Boolean).join(" "),{data:u,isLoading:f,error:d}=de({...cl({query:{query:l,limit:5}}),enabled:!!(e&&l.length>3),staleTime:6e4,retry:1});return{data:c.useMemo(()=>{if(!e)return null;const h=(u?.items??[]).filter(x=>x.messageId!==e.messageId).map(x=>({id:x.messageId,mailboxId:t!=null&&x.mailboxIds.includes(t)?t:x.mailboxIds[0]??"",fromName:x.fromName??"",subject:x.subject??"(No subject)",timeLabel:x.sentDate!=null?Ot(x.sentDate*1e3):"",matched:x.matchedChunkType})),g=Ly(e,i),b=Fy(e,h.length),p={value:e.category??"personal",overridden:i?.flags?.category?.value!=null&&i.flags.category.value!==e.category},v=$y(i);return{sender:g,authenticity:b,category:p,flags:v,similar:h}},[e,i,u,t]),isSimilarLoading:f,similarError:d,similarErrorIsFatal:Ur(d),addressErrorIsFatal:Ur(o),addressId:i?.addressId,address:i}}function zy(e,t){const s={...e??{}};for(const[r,a]of Object.entries(t))a==null?delete s[r]:s[r]={...a,setAt:a.setAt??Date.now()};return s}function Yu({addressId:e,senderEmail:t}){const s=we(),{pushError:r}=Je(),a=bf({query:Wu(t)}),{mutate:o,isPending:i}=ye({...ll(),onMutate:async u=>{const f=u.body.flags??{};await s.cancelQueries({queryKey:a});const d=s.getQueryData(a);return s.setQueryData(a,m=>m&&{...m,items:m.items.map(h=>h.addressId===u.path.addressId?{...h,flags:zy(h.flags,f)}:h)}),{previous:d}},onError:(u,f,d)=>{d?.previous!==void 0&&s.setQueryData(a,d.previous),r({title:"Couldn't update sender preference",detail:lt(u),error:u})},onSettled:()=>{s.invalidateQueries({queryKey:a})}});return{updateFlags:c.useCallback(u=>{if(!e){fl(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 _y=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Gu=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function By(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function Ky(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function Uy(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Xu(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const qy=["personal","newsletter","marketing","automated","transactional","social"],Hy=e=>{const{mailboxId:t,junkMailboxId:s,inboxMailboxId:r}=e;return t?s&&t===s?r?"notSpam":null:s?"markSpam":null:null},Wy=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:r}=e;return t&&!s?"error":r?"loading":"ready"};function Vy(){return n.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[n.jsx(ut,{className:"size-3.5 text-fg-subtle"}),n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),n.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),n.jsxs("div",{className:"flex-1 space-y-1.5",children:[n.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),n.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),n.jsx("div",{className:"h-8 rounded bg-surface"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),n.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>n.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function Qy({isOpen:e,current:t,onSelect:s,onCancel:r}){return e?n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center","aria-hidden":"true",onClick:r,children:[n.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm"}),n.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",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),n.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),n.jsx("div",{className:"mt-4 flex flex-col gap-1",children:qy.map(a=>n.jsxs("button",{type:"button",onClick:()=>s(a),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${a===t?"font-semibold text-accent":"text-fg"}`,children:[a,a===t&&n.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},a))}),n.jsx("div",{className:"mt-6 flex justify-end",children:n.jsx("button",{type:"button",onClick:r,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 Yy({thread:e,onClose:t,mailboxId:s,accountId:r,hideCloseButton:a}){const{data:o,addressId:i,isSimilarLoading:l,similarError:u,similarErrorIsFatal:f}=Qu(e,s),[d,m]=c.useState(!1),[h,g]=c.useState(!1),b=e.fromEmail??void 0,{updateFlags:p,isPending:v}=Yu({addressId:i,senderEmail:b}),{junkMailboxId:x}=rr(r),{inboxMailboxId:y}=Qa(r),{moveMessages:j}=Qt({mailboxId:s??"",threadId:e.threadId,accountId:r}),w=Xs(),N=Hy({mailboxId:s,junkMailboxId:x,inboxMailboxId:y}),E=c.useCallback(()=>{y&&j([e.messageId],y)},[y,j,e.messageId]),C=c.useCallback(()=>{x&&(Xu(w,{count:1,senderTrust:e.senderTrust,wasRescuable:Gu(e)}),j([e.messageId],x))},[x,j,e,w]),k=c.useCallback(()=>{},[]),R=c.useCallback(()=>{const M=o?.flags?.vip!==!0;p({vip:{value:M}})},[o?.flags?.vip,p]),O=c.useCallback(()=>{const M=o?.flags?.muted!==!0;p({muted:{value:M}})},[o?.flags?.muted,p]),D=c.useCallback(()=>{o?.flags?.blocked===!0?p({blocked:{value:!1}}):m(!0)},[o?.flags?.blocked,p]),P=c.useCallback(()=>{m(!1),p({blocked:{value:!0}})},[p]),I=c.useCallback(()=>{const M=o?.flags?.unsubscribed!==!0;p({unsubscribed:{value:M}})},[o?.flags?.unsubscribed,p]),S=c.useCallback(M=>{g(!1),p({category:{value:M}})},[p]),A=i!==void 0,L={onToggleVip:A?R:void 0,onToggleMute:A?O:void 0,onToggleBlock:A?D:void 0,onToggleUnsubscribe:A?I:void 0,onReclassify:A?()=>g(!0):void 0,onNotSpam:N==="notSpam"?E:void 0,onMarkSpam:N==="markSpam"?C:void 0},T=({mailboxId:M,messageId:$,className:K,ariaLabel:B,children:J})=>n.jsx(pt,{to:"/mail/$mailboxId",params:{mailboxId:M},search:ee=>({...ee,selectedMessageId:$}),className:K,"aria-label":B,children:J});if(!o)return n.jsx(Vy,{});const F=Wy({similarError:u,similarErrorIsFatal:f,isSimilarLoading:l});return n.jsxs(n.Fragment,{children:[n.jsx(Hl,{data:o,onClose:t,hideCloseButton:a,onShowSimilar:k,actions:L,similarState:F,similarLinkComponent:T,className:"border-l-0 h-full w-full"}),n.jsx(eo,{isOpen:d,title:"Block this sender?",description:`Messages from ${b??"this sender"} will never load images and will be flagged. You can undo this in Settings → Senders.`,confirmLabel:"Block sender",destructive:!0,isBusy:v,onConfirm:P,onCancel:()=>m(!1)}),n.jsx(Qy,{isOpen:h,current:o.category.value,onSelect:S,onCancel:()=>g(!1)})]})}const Rs=({onClose:e,thread:t,mailboxId:s,accountId:r,hideCloseButton:a})=>t?n.jsx(Yy,{thread:t,onClose:e,mailboxId:s,accountId:r,hideCloseButton:a}):n.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[n.jsx(ut,{className:"size-3.5 text-fg-subtle"}),n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[n.jsx(ut,{className:"size-8 text-fg-subtle"}),n.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),n.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]}),Fr="Open a message first",no=({hasThread:e,intelligenceOpen:t,canToggleIntelligence:s,onToggleIntelligence:r,onReply:a,onReplyAll:o,onForward:i,onDelete:l,canDelete:u,onToggleStar:f,isStarred:d,moveContext:m})=>{const[h,g]=c.useState(null),b=u??e,p=v=>()=>g(v);return n.jsx(fh,{hasThread:e,isStarred:d,onUnavailable:v=>g(Fr),unavailableHint:h,replyTitle:`Reply ${fs("reply")}`,replyAllTitle:`Reply all ${fs("replyAll")}`,forwardTitle:`Forward ${fs("forward")}`,deleteTitle:`Move to Trash ${fs("delete")}`,flagTitle:`Star ${fs("toggleStar")}`,onReply:a,onReplyAll:o,onForward:i,onDelete:b?l:p(Fr),onToggleStar:f,onMove:p(Fr),moveSlot:m?n.jsx(dn,{accountId:m.accountId,currentMailboxId:m.currentMailboxId,onMove:m.onMove,label:"Move to mailbox"}):void 0,children:n.jsx(dh,{open:t,enabled:s,onToggle:r})})},Ju=()=>{const e=we();return c.useCallback(t=>{const s=Zt({path:{threadId:t.threadId}}),a=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return a.length>0?a:[t.messageId]},[e])},Vs=({thread:e,mailboxId:t,accountId:s,onAfterOptimisticRemove:r})=>{const a=t??e?.mailboxId,o=s??e?.accountConfigId,i=Ju(),{deleteMessages:l}=Yt({mailboxId:a??"",threadId:e?.threadId,accountId:o,onAfterOptimisticRemove:r}),{moveMessages:u}=Qt({mailboxId:a??"",threadId:e?.threadId,accountId:o,onAfterOptimisticRemove:r}),{toggleStar:f}=Wa({threadId:e?.threadId??"",mailboxId:a??""}),d=c.useCallback(()=>{e&&l(i(e))},[e,i,l]),m=c.useCallback(v=>{e&&u(i(e),v)},[e,i,u]),h=c.useCallback(()=>{e&&f(e.messageId,e.hasStars)},[e,f]),[g,b]=c.useState(null),p=c.useCallback(()=>b(null),[]);return{mailboxId:a,accountId:o,isStarred:e?.hasStars,deleteThread:d,moveThread:m,toggleStar:h,composeRequest:g,requestCompose:b,clearComposeRequest:p}},Ls={action:null,nextPrefix:null,preventDefault:!1},Gy={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},Xy={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function Jy(e,t){const s=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...Ls,nextPrefix:t==="g"?null:t};if(e.onControl&&(s==="enter"||s===" "))return{...Ls,nextPrefix:t==="g"?null:t};if(r&&s==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&s==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...Ls,nextPrefix:t==="g"?null:t};if(s==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const i=Gy[s===","?",":s]??null;return{action:i,nextPrefix:null,preventDefault:i!==null}}if(s==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const o=s==="j"||s==="arrowdown";if(o||(s==="k"||s==="arrowup"))return{action:o?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const a=Xy[s];if(a){const o=a.requireShift===!0,i=s.length===1&&!/[a-z0-9]/.test(s);return!o&&e.shiftKey&&!i?Ls:{action:a.action,nextPrefix:null,preventDefault:!0}}return Ls}function Zy(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const e0="data-message-row",t0='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function s0(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(t0);return t?!t.hasAttribute(e0):!1}function n0({handlers:e,enabled:t=!0,sequenceTimeoutMs:s=1e3}){const r=c.useRef(e);r.current=e;const a=c.useRef(null),o=c.useRef(null);c.useEffect(()=>{if(!t)return;const i=()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},l=u=>{const f=Jy({key:u.key,shiftKey:u.shiftKey,metaKey:u.metaKey,ctrlKey:u.ctrlKey,altKey:u.altKey,inEditable:Zy(u.target),onControl:s0(u.target)},a.current);if(i(),a.current=f.nextPrefix,f.nextPrefix!==null&&(o.current=setTimeout(()=>{a.current=null,o.current=null},s)),f.action===null)return;const d=r.current[f.action];d&&(f.preventDefault&&u.preventDefault(),d())};return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),i(),a.current=null}},[t,s])}const Li=(e,t,s)=>{if(!t)return null;const r=e.indexOf(t);if(r===-1)return null;const a=s==="next"?r+1:r-1;return a<0||a>=e.length?null:e[a]},ro=()=>{const[e,t]=c.useState(void 0),[s,r]=c.useState([]),[a,o]=c.useState([]),i=c.useRef(null),[l,u]=c.useState(!1),[f,d]=c.useState(!1),m=c.useCallback(h=>{t(h.focusedMessageId),r(h.selectedIds),h.orderedIds&&o(h.orderedIds),u(h.hasList),d(h.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:m,focusedMessageId:e,selectedIds:s,orderedIds:a,hasList:l,blocksKeyboard:f}},ao=({context:e,orderedIds:t,selectedMessageId:s,enabled:r=!0,onClose:a,handlers:o})=>{const{listCommandsRef:i,hasList:l,blocksKeyboard:u}=e,f=c.useCallback(()=>{i.current?.clearSelection()||s&&a()},[i,s,a]);return n0({enabled:r&&!u,handlers:{...l?{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:f,...o}}),{goBack:f,nextMessageId:Li(t,s,"next")??void 0,previousMessageId:Li(t,s,"previous")??void 0}};function r0(e){return{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,messageId:e.messageId,authenticity:e.authenticity}}function Zu(e,t){if(e)return r0(e);if(t.messageId&&t.threadId&&t.mailboxId)return{threadId:t.threadId,mailboxId:t.mailboxId,messageId:t.messageId}}const ed=c.createContext(null);function ir(){const e=c.useContext(ed);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function a0({selectedMessageId:e,children:t}){const s=Oe(),{searchInput:r}=Ce(),{selectedThreadId:a,selectedMailboxId:o}=vs({strict:!1}),{data:i}=de({...Kr(),staleTime:6e4}),l=c.useMemo(()=>{if(e)return i?.items.find(O=>O.messageId===e)},[i,e]),u=c.useMemo(()=>Zu(l,{messageId:e,threadId:a,mailboxId:o}),[l,e,a,o]),f=c.useCallback(O=>{s({to:"/mail",search:D=>({...D,selectedMessageId:O,selectedThreadId:void 0,selectedMailboxId:void 0})})},[s]),d=c.useCallback(O=>{s({to:"/mail",search:D=>({...D,q:r||void 0,selectedMessageId:O.id,selectedThreadId:O.threadId,selectedMailboxId:O.mailboxId})})},[s,r]),m=c.useCallback(O=>{e&&O.includes(e)&&s({to:"/mail",search:D=>({...D,selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0})})},[e,s]),h=Vs({thread:l,onAfterOptimisticRemove:m}),g=c.useCallback(()=>{s({to:"/mail",search:O=>({...O,selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0})})},[s]),b=ro(),p=c.useMemo(()=>i?.items??[],[i]),{deleteMessages:v}=Yt({mailboxId:l?.mailboxId??"",messages:p,onAfterOptimisticRemove:m}),{toggleReadFor:x}=tr({mailboxId:l?.mailboxId??"",messages:p}),y=c.useCallback(O=>x(O,!0),[x]),j=b.focusedMessageId,N=c.useMemo(()=>i?.items.find(O=>O.messageId===j),[i,j])??l,E=Vs({thread:N}),{nextMessageId:C,previousMessageId:k}=ao({context:b,orderedIds:b.orderedIds,selectedMessageId:e,onClose:g,handlers:{reply:()=>h.requestCompose("reply"),replyAll:()=>h.requestCompose("reply_all"),forward:()=>h.requestCompose("forward"),delete:()=>{b.listCommandsRef.current?.requestDelete()||E.deleteThread()},toggleStar:E.toggleStar,toggleRead:()=>{const O=b.selectedIds.length>0?b.selectedIds:N?[N.messageId]:[];O.length!==0&&x(O,!(N?.isRead??!1))},goFlagged:()=>s({to:"/mail/flagged"}),goSettings:()=>s({to:"/settings"})}}),R={selectedMessageId:e,selectedThread:l,conversation:u,onSelectMessage:f,onSelectSearchResult:d,onCloseThread:g,actions:h,triage:b,onDeleteMessages:v,onMarkMessagesRead:y,nextMessageId:C,previousMessageId:k};return n.jsx(ed.Provider,{value:R,children:t})}function td(){const{selectedMessageId:e,onSelectMessage:t,onSelectSearchResult:s,triage:r,onDeleteMessages:a,onMarkMessagesRead:o}=ir(),{accounts:i}=Ce();return n.jsx(Ry,{accounts:i,selectedMessageId:e,onSelectMessage:t,onSelectSearchResult:s,commandsRef:r.listCommandsRef,onTriageContextChange:r.onTriageContextChange,onDeleteMessages:a,onMarkMessagesRead:o})}function o0(){const{conversation:e,actions:t}=ir(),{intelligenceOpen:s,onToggleIntelligence:r}=Ce(),a=Ss()?.showIntelligencePane??!1,o=!!e,i=a&&o;return n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(no,{hasThread:o,intelligenceOpen:i&&s,canToggleIntelligence:i,onToggleIntelligence:r,onReply:o?()=>t.requestCompose("reply"):void 0,onReplyAll:o?()=>t.requestCompose("reply_all"):void 0,onForward:o?()=>t.requestCompose("forward"):void 0,onDelete:o?t.deleteThread:void 0,onToggleStar:o?t.toggleStar:void 0,isStarred:t.isStarred,moveContext:o&&t.accountId&&t.mailboxId?{accountId:t.accountId,currentMailboxId:t.mailboxId,onMove:t.moveThread}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?n.jsx(Es,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,composeRequest:t.composeRequest,onComposeClose:t.clearComposeRequest}):n.jsx(Ns,{})})]})}function i0(){const{selectedThread:e}=ir(),{onToggleIntelligence:t}=Ce();return n.jsx(Rs,{onClose:t,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId})}function l0(){const{selectedThread:e,conversation:t,onSelectMessage:s,onCloseThread:r,nextMessageId:a,previousMessageId:o}=ir(),{intelligenceOpen:i,onToggleIntelligence:l}=Ce();return t?n.jsxs(n.Fragment,{children:[n.jsx(Es,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:r,onOpenIntelligence:l,onSwipeNext:a?()=>s(a):void 0,onSwipePrevious:o?()=>s(o):void 0,mobileIntelligenceOpen:i}),n.jsx(Ka,{isOpen:i,onClose:l,ariaLabel:"Message details",side:"right",children:n.jsx(Rs,{onClose:l,thread:e,hideCloseButton:!0})})]}):n.jsx("div",{className:"h-full",children:n.jsx(td,{})})}const $s=Object.assign(a0,{List:td,Reading:o0,Intelligence:i0,Phone:l0}),c0=()=>il({query:{starred:!0,order:"desc"}});function sd(){const{data:e,isLoading:t,isError:s,error:r,refetch:a,fetchNextPage:o,hasNextPage:i,isFetchingNextPage:l}=Sc({queryKey:c0(),queryFn:async({pageParam:f})=>{const{data:d}=await vf({query:{starred:!0,order:"desc",continuationToken:f},throwOnError:!0});return d},initialPageParam:void 0,getNextPageParam:f=>f.continuationToken,staleTime:6e4});return{threads:c.useMemo(()=>(e?.pages??[]).flatMap(f=>f.items??[]),[e]),isLoading:t,isError:s,error:r,refetch:a,fetchNextPage:o,hasNextPage:i,isFetchingNextPage:l}}const u0=e=>{const t=new Set;return e.filter(s=>t.has(s.threadId)?!1:(t.add(s.threadId),!0))};function nd({title:e,unreadCount:t,preset:s,selectedCategory:r,activeFilters:a,onSelectCategory:o,onToggleFilter:i,onSelectSource:l,onClearFilters:u,children:f,footer:d,searchResults:m,searchLoading:h,relatedResults:g,relatedLoading:b,onSelectSearchResult:p,searchResultsLabel:v,relatedResultsLabel:x,searchResultsInBody:y}){const[j,w]=c.useState(!1),N={categories:s.categories,filters:s.filters,sources:s.sources,selectedCategory:r,activeFilters:a,expanded:j,onExpandedChange:w,onSelectCategory:o,onSelectSource:l,onToggleFilter:i,onClear:u};return n.jsx(Fu,{title:e,unreadCount:t,footer:d,searchFilter:N,searchResults:m,searchLoading:h,relatedResults:g,relatedLoading:b,onSelectSearchResult:p,searchResultsLabel:v,relatedResultsLabel:x,searchResultsInBody:y,children:n.jsx(ua,{...N,children:f})})}const d0={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0};function f0({selectedMessageId:e,onSelectMessage:t,commandsRef:s,onTriageContextChange:r,onDeleteMessages:a,onMarkMessagesRead:o}){const{searchQuery:i,resultFolderIndex:l}=Ce(),u=Is(),f=At(),[d,m]=c.useState("all"),[h,g]=c.useState(new Set),b=c.useCallback(T=>{g(F=>{const M=new Set(F);return M.has(T)?M.delete(T):M.add(T),M})},[]),p=c.useCallback(()=>{m("all"),g(new Set)},[]),{threads:v,isLoading:x,isError:y,error:j,refetch:w,fetchNextPage:N,hasNextPage:E,isFetchingNextPage:C}=sd(),{freeText:k,tokens:R}=Ts(i.trim().toLowerCase(),u),O=c.useMemo(()=>{const T=Array.from(h).map(F=>d0[F]).filter(F=>F!=null);return u0(v).map(sa).filter(F=>(d==="all"||F.category===d)&&T.every(M=>M(F))&&(!k||Cu(F,k))&&Nu(F,R))},[v,d,h,k,R]),D=c.useMemo(()=>Jp(),[]),P=c.useMemo(()=>O.map(T=>Eu(T,l)),[O,l]),I=c.useMemo(()=>O.filter(T=>!T.isRead).length,[O]),S=x?"loading":y?"error":O.length===0?"empty":"ready",A=c.useCallback(()=>{const T=ba(xa());window.open(T,"_blank","noopener,noreferrer")},[]),L=n.jsx(qu,{selectedMessageId:e,onOpen:T=>t?.(T),onDeleteMessages:a,commandsRef:s,onTriageContextChange:r,children:n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a?n.jsx(Hu,{onMarkAsRead:o}):null,n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("div",{className:"divide-y divide-line",children:O.map(T=>n.jsx(so,{thread:T,active:T.id===e,onClick:()=>t?.(T.id)},T.id))}),E?n.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>N(),disabled:C,children:C?"Loading…":"Load more"}):null]})]})});return n.jsx(nd,{title:"Starred",unreadCount:I,preset:D,selectedCategory:d,activeFilters:h,onSelectCategory:m,onToggleFilter:b,onClearFilters:p,searchResults:P,searchLoading:x,onSelectSearchResult:T=>t?.(T.id),children:n.jsx(Zl,{listTitle:"Starred",sections:[{id:"flagged",threads:O}],flatList:!0,hideHeader:!0,listState:S,searchQuery:k?i:void 0,errorMessage:y?wl(j):void 0,onRetry:()=>w(),onReportError:A,selectedThreadId:e,onSelectThread:t,onSelectBriefCategory:()=>{},isDesktop:f,listBody:S==="ready"?L:void 0})})}const rd=c.createContext(null);function lr(){const e=c.useContext(rd);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function m0({selectedMessageId:e,children:t}){const s=Oe(),{threads:r}=sd(),a=c.useMemo(()=>{if(e)return r.find(w=>w.messageId===e)},[r,e]),o=c.useCallback(w=>{s({to:"/mail/flagged",search:N=>({...N,selectedMessageId:w})})},[s]),i=c.useCallback(()=>{s({to:"/mail/flagged",search:w=>({...w,selectedMessageId:void 0})})},[s]),l=c.useCallback(w=>{e&&w.includes(e)&&i()},[e,i]),u=Vs({thread:a,onAfterOptimisticRemove:l}),f=ro(),{deleteMessages:d}=Yt({mailboxId:a?.mailboxId??"",messages:r,onAfterOptimisticRemove:l}),{toggleReadFor:m}=tr({mailboxId:a?.mailboxId??"",messages:r}),h=c.useCallback(w=>m(w,!0),[m]),g=f.focusedMessageId,p=c.useMemo(()=>r.find(w=>w.messageId===g),[r,g])??a,v=Vs({thread:p}),{nextMessageId:x,previousMessageId:y}=ao({context:f,orderedIds:f.orderedIds,selectedMessageId:e,onClose:i,handlers:{reply:()=>u.requestCompose("reply"),replyAll:()=>u.requestCompose("reply_all"),forward:()=>u.requestCompose("forward"),delete:()=>{f.listCommandsRef.current?.requestDelete()||v.deleteThread()},toggleStar:v.toggleStar,toggleRead:()=>{const w=f.selectedIds.length>0?f.selectedIds:p?[p.messageId]:[];w.length!==0&&m(w,!(p?.isRead??!1))},goBrief:()=>s({to:"/mail"}),goSettings:()=>s({to:"/settings"})}}),j={selectedMessageId:e,selectedThread:a,onSelectMessage:o,onCloseThread:i,actions:u,triage:f,onDeleteMessages:d,onMarkMessagesRead:h,nextMessageId:x,previousMessageId:y};return n.jsx(rd.Provider,{value:j,children:t})}function ad(){const{selectedMessageId:e,onSelectMessage:t,triage:s,onDeleteMessages:r,onMarkMessagesRead:a}=lr();return n.jsx(f0,{selectedMessageId:e,onSelectMessage:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:r,onMarkMessagesRead:a})}function h0(){const{selectedThread:e,actions:t}=lr(),{intelligenceOpen:s,onToggleIntelligence:r}=Ce(),a=Ss()?.showIntelligencePane??!1,o=!!e,i=a&&o;return n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(no,{hasThread:o,intelligenceOpen:i&&s,canToggleIntelligence:i,onToggleIntelligence:r,onReply:o?()=>t.requestCompose("reply"):void 0,onReplyAll:o?()=>t.requestCompose("reply_all"):void 0,onForward:o?()=>t.requestCompose("forward"):void 0,onDelete:o?t.deleteThread:void 0,onToggleStar:o?t.toggleStar:void 0,isStarred:t.isStarred,moveContext:o&&t.accountId&&t.mailboxId?{accountId:t.accountId,currentMailboxId:t.mailboxId,onMove:t.moveThread}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?n.jsx(Es,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,authenticity:e.authenticity,composeRequest:t.composeRequest,onComposeClose:t.clearComposeRequest}):n.jsx(Ns,{})})]})}function p0(){const{selectedThread:e}=lr(),{onToggleIntelligence:t}=Ce();return n.jsx(Rs,{onClose:t,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId})}function g0(){const{selectedThread:e,onCloseThread:t,onSelectMessage:s,nextMessageId:r,previousMessageId:a}=lr(),{intelligenceOpen:o,onToggleIntelligence:i}=Ce();return e?n.jsxs(n.Fragment,{children:[n.jsx(Es,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,authenticity:e.authenticity,onBack:t,onOpenIntelligence:i,onSwipeNext:r?()=>s(r):void 0,onSwipePrevious:a?()=>s(a):void 0,mobileIntelligenceOpen:o}),n.jsx(Ka,{isOpen:o,onClose:i,ariaLabel:"Message details",side:"right",children:n.jsx(Rs,{onClose:i,thread:e,hideCloseButton:!0})})]}):n.jsx("div",{className:"h-full",children:n.jsx(ad,{})})}const Fs=Object.assign(m0,{List:ad,Reading:h0,Intelligence:p0,Phone:g0}),x0={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},b0=()=>{const e=c.useRef(!1);return c.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector("[data-slate-editor]")?.textContent??"").replace(/--\s*/g,"").trim();return e.current=s.trim().length>0||o.length>0,e.current},[])},v0=()=>{const{state:e,closeCompose:t}=Mt(),s=b0(),[r,a]=c.useState(!1),{isError:o,error:i,refetch:l}=de({...xt(),staleTime:1/0}),u=c.useCallback(h=>{h||(s()?a(!0):t())},[t,s]),f=c.useCallback(()=>{a(!1),t()},[t]),d=c.useCallback(()=>{a(!1)},[]);if(!e.isOpen)return null;const m=x0[e.mode]??"New Message";return n.jsxs(Xe.Root,{open:e.isOpen,onOpenChange:u,children:[n.jsxs(Xe.Portal,{children:[n.jsx(Xe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),n.jsxs(Xe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col bg-canvas rounded-t-lg",style:{height:"95dvh"},children:[n.jsx(Xe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),n.jsx(Xe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:m}),o?n.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:n.jsx(Dt,{title:"Couldn't load compose",error:i,onRetry:()=>{l()}})}):n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Ua,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:t})})]})]}),r&&n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50",children:n.jsxs("div",{className:"mx-4 w-full max-w-sm rounded-xl bg-canvas p-6 shadow-xl",children:[n.jsx("h3",{className:"text-lg font-semibold",children:"Discard draft?"}),n.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Your message has unsaved content. Are you sure you want to discard it?"}),n.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:d,className:"rounded-md px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Keep editing"}),n.jsx("button",{type:"button",onClick:f,className:"rounded-md bg-danger px-4 py-2 text-sm font-medium text-canvas hover:bg-danger/90 transition-colors",children:"Discard"})]})]})})]})},y0={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},od=()=>{const{state:e,closeCompose:t}=Mt(),s=At(),{isError:r,error:a,refetch:o}=de({...xt(),staleTime:1/0});if(!s)return n.jsx(v0,{});if(!e.isOpen)return null;const i=y0[e.mode]??"New Message",l=n.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[n.jsx("div",{className:"flex items-center gap-2 min-w-0",children:n.jsx("h2",{className:"text-lg font-semibold truncate",children:i})}),n.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",children:n.jsx(We,{className:"size-5"})})]});return r?n.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[l,n.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:n.jsx(Dt,{title:"Couldn't load compose",error:a,onRetry:()=>{o()}})})]}):n.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[l,n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:n.jsx(Ua,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:t},e.outboxMessageId??"new")})]})};function w0(e){const t=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:t?`To: ${t}`:"(No recipients)",timeLabel:Ot(e.updatedAt),isRead:!0}}function j0(e){return{id:e.messageId,accountId:e.accountConfigId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ot(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function S0({outboxMessages:e,accountId:t,imapThreads:s}){const r=e.filter(i=>i.status==="draft"&&i.accountId===t).map(w0),a=s.map(j0),o=[];return r.length>0&&o.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:r}),a.length>0&&o.push({id:"imap-drafts",label:"On the server",threads:a}),o}function oo(){const e=Ss();return!e||e.showNavPane?null:n.jsx(Y,{variant:"ghost",size:"sm",icon:n.jsx(ka,{className:"size-4"}),onClick:e.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}const k0=({label:e,count:t})=>n.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),n.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t})]}),C0=({row:e,isSelected:t,onOpen:s,onDelete:r,isDeleting:a})=>n.jsxs("button",{type:"button",onClick:()=>s(e.id),className:q("group",sn({active:t})),children:[n.jsx(Xi,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),n.jsx(qs,{thread:e}),n.jsx("div",{className:"flex items-center gap-1 shrink-0",children:n.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),r(e.id)},disabled:a,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:n.jsx(nt,{className:"size-3.5"})})})]}),N0=({row:e,isSelected:t,onOpen:s})=>{const r=!e.isRead;return n.jsxs("button",{type:"button",onClick:()=>s(e.id),className:q("group",sn({active:t})),children:[r&&n.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),n.jsx(dt,{name:e.fromName,email:e.fromEmail,size:"sm"}),n.jsx(qs,{thread:e})]})};function E0({mailboxId:e,accountId:t,selectedMessageId:s,imapThreads:r,title:a,unreadCount:o}){const{openCompose:i,state:l}=Mt(),u=Oe(),f=we(),{data:d}=de(qn()),m=c.useMemo(()=>S0({outboxMessages:d?.items??[],accountId:t,imapThreads:r}),[d?.items,t,r]),h=ye({...Hn(),onSuccess:()=>{f.invalidateQueries({queryKey:Sa()})}}),g=x=>{h.mutate({path:{outboxMessageId:x}})},b=x=>{s&&u({to:"/mail/$mailboxId",params:{mailboxId:e},search:{selectedMessageId:void 0}}),i({mode:"new",outboxMessageId:x})},p=x=>{u({to:"/mail/$mailboxId",params:{mailboxId:e},search:{selectedMessageId:x}})},v=m.length===0;return n.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx(oo,{}),n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:a}),(o??0)>0&&n.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[o," unread"]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:v?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[n.jsx(la,{className:"size-8 text-fg-subtle"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),n.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):m.map(x=>n.jsxs("div",{children:[x.label&&n.jsx(k0,{label:x.label,count:x.threads.length}),n.jsx("div",{className:"divide-y divide-line",children:x.threads.map(y=>x.id==="remit-drafts"?n.jsx(C0,{row:y,isSelected:l.isOpen&&y.id===l.outboxMessageId,onOpen:b,onDelete:g,isDeleting:h.isPending},y.id):n.jsx(N0,{row:y,isSelected:y.id===s,onOpen:p},y.id))})]},x.id))})]})}function I0(e,t,s){const r=new Array(e);return new Proxy(r,{get(a,o,i){if(typeof o=="string"){const l=o.charCodeAt(0);if(l>=48&&l<=57){const u=+o;if(Number.isInteger(u)&&u>=0&&u<e){let f=a[u];if(!f){const d=t[u*2];f=a[u]={index:u,key:s(u),start:d,size:t[u*2+1],end:d+t[u*2+1],lane:0}}return f}}if(o==="length")return e}return Reflect.get(a,o,i)}})}function ds(e,t,s){let r=s.initialDeps??[],a,o=!0;function i(){const l=e();return(l.length!==r.length||l.some((f,d)=>r[d]!==f))&&(r=l,a=t(...l),s?.onChange&&!(o&&s.skipInitialOnChange)&&s.onChange(a),o=!1),a}return i.updateDeps=l=>{r=l},i}function $i(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const T0=(e,t)=>Math.abs(e-t)<1.01,R0=(e,t,s)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),s)}};let zs;const zr=()=>{if(zs!==void 0)return zs;if(typeof navigator>"u")return zs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return zs=!0;const e=navigator.maxTouchPoints;return zs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Fi=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},M0=e=>e,A0=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,a=new Array(r);for(let o=0;o<r;o++)a[o]=t+o;return a},D0=(e,t)=>{const s=e.scrollElement;if(!s)return;const r=e.targetWindow;if(!r)return;const a=i=>{const{width:l,height:u}=i;t({width:Math.round(l),height:Math.round(u)})};if(a(Fi(s)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const l=()=>{const u=i[0];if(u?.borderBoxSize){const f=u.borderBoxSize[0];if(f){a({width:f.inlineSize,height:f.blockSize});return}}a(Fi(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return o.observe(s,{box:"border-box"}),()=>{o.unobserve(s)}},zn={passive:!0},O0=typeof window>"u"?!0:"onscrollend"in window,P0=(e,t,s)=>{const r=e.scrollElement;if(!r)return;const a=e.targetWindow;if(!a)return;const o=e.options.useScrollendEvent&&O0;let i=0;const l=o?null:R0(a,()=>t(i,!1),e.options.isScrollingResetDelay),u=m=>()=>{i=s(r),l?.(),t(i,m)},f=u(!0),d=u(!1);return r.addEventListener("scroll",f,zn),o&&r.addEventListener("scrollend",d,zn),()=>{r.removeEventListener("scroll",f),o&&r.removeEventListener("scrollend",d)}},L0=(e,t)=>P0(e,t,s=>{const{horizontal:r,isRtl:a}=e.options;return r?s.scrollLeft*(a&&-1||1):s.scrollTop}),$0=(e,t,s)=>{if(s.options.useCachedMeasurements){const r=s.indexFromElement(e),a=s.options.getItemKey(r);return s.itemSizeCache.get(a)??s.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=s.indexFromElement(e),a=s.options.getItemKey(r),o=s.itemSizeCache.get(a);if(o!==void 0)return o}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},F0=(e,{adjustments:t=0,behavior:s},r)=>{var a,o;(o=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||o.call(a,{[r.options.horizontal?"left":"top"]:e+t,behavior:s})},z0=F0;class _0{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,r,a;return((a=(r=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let s=null;const r=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(a=>{a.forEach(o=>{const i=()=>{const l=o.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[f,d]of this.elementsCache)if(d===l){this.elementsCache.delete(f);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),s=null},observe:a=>{var o;return(o=r())==null?void 0:o.observe(a,{box:"border-box"})},unobserve:a=>{var o;return(o=r())==null?void 0:o.unobserve(a)}}})(),this.range=null,this.setOptions=s=>{var r,a;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:M0,rangeExtractor:A0,onChange:()=>{},measureElement:$0,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const h in s){const g=s[h];g!==void 0&&(o[h]=g)}const i=this.options;let l=null,u=null,f=!1;if(i!==void 0&&i.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const h=i.count,g=o.count,b=this.getMeasurements(),p=h>0?((r=b[0])==null?void 0:r.key)??i.getItemKey(0):null,v=h>0?((a=b[h-1])==null?void 0:a.key)??i.getItemKey(h-1):null;if(g!==h||h>0&&g>0&&(o.getItemKey(0)!==p||o.getItemKey(g-1)!==v)){f=!0;const j=h>0?this.getVirtualItemForOffset(this.getScrollOffset())??b[0]:null;j&&(l=[j.key,this.getScrollOffset()-j.start]);const w=o.followOnAppend===!0?"auto":o.followOnAppend||null;w&&g>h&&this.isAtEnd(i.scrollEndThreshold)&&(h===0||o.getItemKey(g-1)!==v)&&(u=w)}}this.options=o,f&&(this.pendingMin=0,this.itemSizeCacheVersion++);let d=!1,m=0;if(l&&this.scrollOffset!==null){const[h,g]=l,b=this.getMeasurements(),{count:p,getItemKey:v}=this.options;let x=0;for(;x<p&&v(x)!==h;)x++;if(x<p){const y=b[x];if(y){const j=y.start+g;j!==this.scrollOffset&&(m=j-this.scrollOffset,this.scrollOffset=j,d=!0)}}}(d||u)&&(this.pendingScrollAnchor=[d?l[0]:null,d?l[1]:0,u,m])},this.notify=s=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,s)},this.maybeNotify=ds(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,i)=>{if(i&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=i?l===o?this.scrollDirection:l<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!zr()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",i,zn),o.addEventListener("touchend",l,zn),this.unsubs.push(()=>{o.removeEventListener("touchstart",i),o.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[o,i,l,u]=a;o!==null&&!l&&(zr()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),r=this.getMaxScrollOffset();if(s<0||s>r)return;const a=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=a,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=ds(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,r,a,o,i,l,u,f)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:s,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:l,laneAssignmentMode:u,gap:f}),{key:!1}),this.getMeasurements=ds(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:l,laneAssignmentMode:u,gap:f},d)=>{const m=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const x of this.laneAssignments.keys())x>=s&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),l===1){const x=s*2;let y=this._flatMeasurements;if(!y||y.length<x){const N=new Float64Array(x);y&&h>0&&N.set(y.subarray(0,h*2)),y=N,this._flatMeasurements=y}let j;if(h===0)j=r+a;else{const N=h-1;j=y[N*2]+y[N*2+1]+f}for(let N=h;N<s;N++){const E=o(N),C=m.get(E),k=typeof C=="number"?C:this.options.estimateSize(N);y[N*2]=j,y[N*2+1]=k,j+=k+f}const w=I0(s,y,o);return this.measurementsCache=w,w}const g=this.measurementsCache.slice(0,h),b=new Array(l).fill(void 0),p=new Float64Array(l);let v=0;for(let x=0;x<h;x++){const y=g[x];y&&(b[y.lane]===void 0&&v++,b[y.lane]=x,p[y.lane]=y.end)}for(let x=h;x<s;x++){const y=o(x),j=this.laneAssignments.get(x);let w,N;const E=u==="estimate"||m.has(y);if(j!==void 0&&this.options.lanes>1){w=j;const O=b[w],D=O!==void 0?g[O]:void 0;N=D?D.end+f:r+a}else if(v===l){let O=0,D=p[0],P=b[0];for(let I=1;I<l;I++){const S=p[I];(S<D||S===D&&b[I]<P)&&(O=I,D=S,P=b[I])}w=O,N=D+f,E&&this.laneAssignments.set(x,w)}else w=x%this.options.lanes,N=r+a,E&&this.laneAssignments.set(x,w);const C=m.get(y),k=typeof C=="number"?C:this.options.estimateSize(x),R=N+k;g[x]={index:x,start:N,size:k,end:R,key:y,lane:w},b[w]===void 0&&v++,b[w]=x,p[w]=R}return this.measurementsCache=g,g},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ds(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,r,a,o)=>s.length===0||r===0?(this.range=null,null):(this.range=K0(s,r,a,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ds(()=>{let s=null,r=null;const a=this.calculateRange();return a&&(s=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,r]},(s,r,a,o,i)=>o===null||i===null?[]:s({startIndex:o,endIndex:i,overscan:r,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const r=this.options.indexAttribute,a=s.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,a-o),l=Math.min(this.options.count-1,a+o);return s>=i&&s<=l}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((i,l)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(l))});return}const r=this.indexFromElement(s),a=this.options.getItemKey(r),o=this.elementsCache.get(a);o!==s&&(o&&this.observer.unobserve(o),this.observer.observe(s),this.elementsCache.set(a,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,r)=>{var a,o;if(s<0||s>=this.options.count)return;let i,l,u;const f=this._flatMeasurements;if(this.options.lanes===1&&f!==null)u=this.options.getItemKey(s),l=f[s*2],i=f[s*2+1];else{const h=this.measurementsCache[s];if(!h)return;u=h.key,l=h.start,i=h.size}const d=this.itemSizeCache.get(u)??i,m=r-d;if(m!==0){const h=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,g=h?this.getTotalSize():0,b=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:u,start:l,size:i,end:l+i,lane:0},m,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(u,r),this.itemSizeCacheVersion++,h?this.applyScrollAdjustment(this.getTotalSize()-g):b&&this.applyScrollAdjustment(m),this.notify(!1)}},this.getVirtualItems=ds(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,r)=>{const a=[];for(let o=0,i=s.length;o<i;o++){const l=s[o],u=r[l];a.push(u)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const r=this.getMeasurements();if(r.length===0)return;const a=this._flatMeasurements,o=this.options.lanes===1&&a!=null,i=id(0,r.length-1,o?l=>a[l*2]:l=>$i(r[l]).start,s);return $i(r[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,r,a=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=s>=i+o?"end":"start"),r==="center"?s+=(a-o)/2:r==="end"&&(s-=o);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,s),0)},this.getOffsetForIndex=(s,r="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getSize(),o=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(r==="auto")if(i.end>=o+a-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,i.size),r]},this.scrollToOffset=(s,{align:r="start",behavior:a="auto"}={})=>{const o=this.getOffsetForAlignment(s,r),i=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:r="auto",behavior:a="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getOffsetForIndex(s,r);if(!o)return;const[i,l]=o,u=this.now();this.scrollState={index:s,align:l,behavior:a,startedAt:u,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+s,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,i=this._flatMeasurements;i!=null?a=i[o*2]+i[o*2+1]:a=((s=r[o])==null?void 0:s.end)??0}else{const o=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&o.some(l=>l===null);){const l=r[i];o[l.lane]===null&&(o[l.lane]=l.end),i--}a=Math.max(...o.filter(l=>l!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const r=this.getMeasurements();for(const a of r)a&&this.itemSizeCache.has(a.key)&&s.push({index:a.index,key:a.key,start:a.start,size:a.size,end:a.end,lane:a.lane});return s},this._scrollToOffset=(s,{adjustments:r,behavior:a})=>{this._intendedScrollOffset=s+(r??0),this.options.scrollToFn(s,{behavior:a,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,s){t!==0&&(zr()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,o=1,i=a!==this.scrollState.lastTargetOffset;if(!i&&T0(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==a&&this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const l=this.getSize()||600,u=Math.abs(a-this.getScrollOffset()),f=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=a,f||(this.scrollState.behavior="auto"),this._scrollToOffset(a,{adjustments:void 0,behavior:f?"smooth":"auto"})}this.scheduleScrollReconcile()}}const id=(e,t,s,r)=>{for(;e<=t;){const a=(e+t)/2|0,o=s(a);if(o<r)e=a+1;else if(o>r)t=a-1;else return a}return e>0?e-1:0};function B0(e,t,s){let r=0;for(;r<=t;){const a=(r+t)/2|0,o=e[a*2];if(o<s)r=a+1;else if(o>s)t=a-1;else return a}return r>0?r-1:0}function K0(e,t,s,r,a){const o=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:o};if(r===1&&a!==null){const f=B0(a,o,s);let d=f;const m=s+t;for(;d<o&&a[d*2]+a[d*2+1]<m;)d++;return{startIndex:f,endIndex:d}}let l=id(0,o,f=>e[f].start,s),u=l;if(r===1)for(;u<o&&e[u].end<s+t;)u++;else if(r>1){const f=Array(r).fill(0);for(;u<o&&f.some(m=>m<s+t);){const m=e[u];f[m.lane]=m.end,u++}const d=Array(r).fill(s+t);for(;l>=0&&d.some(m=>m>=s);){const m=e[l];d[m.lane]=m.start,l--}l=Math.max(0,l-l%r),u=Math.min(o,u+(r-1-u%r))}return{startIndex:l,endIndex:u}}const _r=typeof document<"u"?c.useLayoutEffect:c.useEffect;function U0({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...r}){const a=c.useReducer(f=>f+1,0)[1],o=c.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=s;const i=f=>{const d=o.current;if(!d.enabled||!d.container)return;const m=f.getTotalSize();if(m!==d.lastSize){d.lastSize=m;const x=f.options.horizontal?"width":"height";d.container.style[x]=`${m}px`}const h=!!f.options.horizontal,g=d.mode==="transform",b=h?"left":"top",p=f.options.scrollMargin,v=f.getVirtualItems();for(const x of v){const y=x.start-p,j=f.elementsCache.get(x.key);j&&d.lastPositions.get(j)!==y&&(d.lastPositions.set(j,y),g?j.style.transform=h?`translate3d(${y}px, 0, 0)`:`translate3d(0, ${y}px, 0)`:j.style[b]=`${y}px`)}},l={...r,onChange:(f,d)=>{var m;const h=o.current;let g=!0;if(h.enabled){i(f);const b=f.range,p=h.prevRange;g=!p||p.isScrolling!==f.isScrolling||p.startIndex!==b?.startIndex||p.endIndex!==b?.endIndex,g&&(h.prevRange=b?{startIndex:b.startIndex,endIndex:b.endIndex,isScrolling:f.isScrolling}:null)}g&&(e&&d?ma.flushSync(a):a()),(m=r.onChange)==null||m.call(r,f,d)}},[u]=c.useState(()=>{const f=new _0(l);return Object.assign(f,{containerRef:d=>{const m=o.current;if(m.container=d,m.lastSize=null,d&&m.enabled){const h=f.getTotalSize();m.lastSize=h;const g=f.options.horizontal?"width":"height";d.style[g]=`${h}px`}}})});return u.setOptions(l),_r(()=>u._didMount(),[]),_r(()=>u._willUpdate()),_r(()=>{i(u)}),u}function q0(e){return U0({observeElementRect:D0,observeElementOffset:L0,scrollToFn:z0,...e})}const H0={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},ld={delete:"moved to Trash",move:"moved",markRead:"marked as read"},cd={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},W0={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},V0={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},Q0=(e,t,s)=>H0[e](ct(t),ct(s)),zi=(e,t)=>`${ct(t)} ${ld[e]}. Your mail server is still catching up.`,Y0=(e,t,s)=>`${ct(t)} ${ld[e]}. ${ct(s)} ${cd[e]}.`,G0=(e,t)=>t>0?`Stopped after ${ct(t)} — some messages ${cd[e]}`:W0[e],X0=e=>V0[e],J0=e=>e==="delete"?"danger":"info",ud=100,_n=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),Z0=(e,t=ud)=>{if(e.length===0)return[];const s=[];for(let r=0;r<e.length;r+=t)s.push(e.slice(r,r+t));return s},ew=async(e,t,s,r)=>{const a=Z0(e),o=e.length;let i=0;const l=[];for(let u=0;u<a.length;u++){if(r())return l.push(...a.slice(u).flat()),{done:i,failedIds:l,cancelled:!0};const f=a[u],d=await _n(t(f));if(!d.ok)return l.push(...a.slice(u).flat()),s({done:i,total:o}),{done:i,failedIds:l,cancelled:!1,error:d.error};i+=f.length,s({done:i,total:o})}return{done:i,failedIds:l,cancelled:!1}},tw=async(e,t,s,r,a)=>{let o=0;const i=[];let l;do{if(a())return{done:o,failedIds:i,cancelled:!0};const u=await _n(e(l));if(!u.ok)return{done:o,failedIds:i,cancelled:!1,error:u.error};const f=u.value;if(f.ids.length>0){const d=await _n(s(f.ids));if(!d.ok)return{done:o,failedIds:i,cancelled:!1,error:d.error};o+=f.ids.length,r({done:o,total:t})}l=f.continuationToken}while(l);return{done:o,failedIds:i,cancelled:!1}},sw=e=>({done:e.done,total:Math.max(e.total,e.done)}),nw=async(e,t,s)=>{let r=0,a;do{if(s())return{total:r,cancelled:!0};const o=await _n(e(a));if(!o.ok)return{total:r,cancelled:!1,error:o.error};const i=o.value;r+=i.ids.length,t(r),a=i.continuationToken}while(a);return{total:r,cancelled:!1}},rw=e=>e.failedIds.length>0?{exit:!1,retryIds:e.failedIds}:e.cancelled||e.error?{exit:!1,retryIds:[]}:{exit:!0,retryIds:[]},aw=100,ow=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],iw=({mailboxId:e,accountId:t,enabled:s,predicateKey:r,searchQuery:a})=>{const[o,i]=c.useState({kind:"idle"}),[l,u]=c.useState(void 0),[f,d]=c.useState(void 0),m=c.useRef(!1),h=we(),{pushError:g}=Je();c.useEffect(()=>{m.current=!0,i({kind:"idle"})},[s,r]);const b=c.useRef(a);b.current=a;const p=c.useCallback(async E=>{const{data:C}=await ml({path:{mailboxId:e},query:{...b.current,continuationToken:E,limit:aw},throwOnError:!0});return{ids:(C.items??[]).map(k=>k.messageId),continuationToken:C.continuationToken}},[e]),v=c.useCallback(E=>async C=>{if(E.kind==="move"){const{data:R}=await yf({body:{messageIds:C,destinationMailboxId:E.destinationMailboxId},throwOnError:!0});return R}if(E.kind==="markRead"){const{data:R}=await wf({body:{messageIds:C,isRead:!0},throwOnError:!0});return R}const{data:k}=await jf({body:{messageIds:C},throwOnError:!0});return k},[]),x=c.useCallback(E=>{Ft(h,$t(ow(E,e))),t&&h.invalidateQueries({queryKey:Jt({path:{accountId:t}})})},[h,e,t]),y=c.useCallback(()=>{m.current=!1,i({kind:"counting",countSoFar:0}),nw(p,E=>i({kind:"counting",countSoFar:E}),()=>m.current).then(E=>{if(E.error){g(Vt("Couldn't count matching messages","The count didn't finish.",E.error)),i({kind:"idle"});return}if(E.cancelled){i({kind:"idle"});return}i({kind:"escalated",total:E.total})})},[p,g]),j=c.useCallback(()=>{m.current=!0},[]),w=c.useCallback(()=>{m.current=!0,i({kind:"idle"})},[]),N=c.useCallback(async(E,C)=>{m.current=!1,u(E);const k=D=>d(sw(D)),R=v(E),O=C!==void 0?await ew(C,R,k,()=>m.current):await tw(p,o.kind==="escalated"?o.total:0,R,k,()=>m.current);return u(void 0),d(void 0),i({kind:"idle"}),O.error&&g(Vt(G0(E.kind,O.done),X0(E.kind),O.error)),O.done>0&&x(E),O},[v,p,o,g,x]);return{phase:o,escalate:y,stop:j,clear:w,isRunning:l!==void 0,runningAction:l,progress:f,runAction:N}},dd=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",lw=e=>`Select all ${dd(e)}`,cw=(e,t)=>`All ${ct(t)} ${dd(e)} selected`,uw=e=>e.isRunning?"running":e.isCounting?"counting":e.isEscalated?"escalated":"idle",dw=2,fw=(e,t,s=!1)=>e>=dw||t!=="idle"||s,fd=(e,t,s)=>{const r=ye(ul()),{mutate:a,reset:o}=r,[i,l]=c.useState(!1),u=c.useMemo(()=>_f(s),[s]),f=c.useCallback(()=>{!e||!t||(l(!1),a({path:{accountId:e},body:qr({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,a]),d=c.useCallback(()=>{l(!1),o()},[o]),m=r.data,h=m?.semanticUnavailable===!0&&!i&&u.length>0;c.useEffect(()=>{!h||!e||(l(!0),a({path:{accountId:e},body:qr(Bf(u))}))},[h,e,u,a]);const g=i||(m?.semanticUnavailable??!1),b=r.isPending||h,p=i?{matchOperator:"Or",literalClauses:Kf(u)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:f,reset:d,matchedCount:b?void 0:m?.matchedCount,messageIds:b?void 0:m?.messageIds,semanticUnavailable:g,senderFallback:i,senders:u,matchPredicate:p,isPending:b,isError:r.isError,error:r.error}},mw=({entry:e,hasSeed:t,previewStatus:s,matchedCount:r})=>{if(e==="something-else"&&!t)return{kind:"something-else"};if(s==="error")return{kind:"error"};if(s!=="success")return{kind:"widening"};const a=r??0;return{kind:"organize",matchedCount:a,fallback:a===0}};function md({accountId:e,selectedMessageIds:t,seedCount:s,semanticUnavailable:r=!1,senders:a=[],seedMailboxId:o,seedScope:i,onClose:l}){const u=t[0],f=r&&a.length>0,[d]=c.useState(()=>Uf({anchorMessageId:u,semanticUnavailable:r,senders:a,selectionCount:t.length,seedMailboxId:o,seedScope:i})),{rule:m,handlers:h}=Du({initialRule:d,widenAnchorCount:t.length}),{data:g}=de({...ze({path:{accountId:e}}),staleTime:Number.POSITIVE_INFINITY}),b=c.useMemo(()=>Zs(g?.items??[]).map(w=>({id:w.mailboxId,label:Vn(w.fullPath)})),[g?.items]),p=xl(e,Na(m,u),s),v=bl(e),x=vl(e),{createFolder:y}=kl(e),j=()=>{const w=yl(m,u);if(m.scope==="once"){v.start(w);return}x.createFilter(w,m.scope==="standing"?"standing":"temporary",(m.name??"").trim())};return v.isStarting||v.isRunning||v.isDone?n.jsx(Ou,{progress:v.progress,isDone:v.isDone,runningLabel:f?"Organizing mail from these senders…":"Organizing similar mail…",onClose:l}):x.isPending?n.jsx(Pu,{}):x.isSuccess?n.jsx(Lu,{onClose:l}):x.isError?n.jsx($u,{onRetry:x.reset,onClose:l}):n.jsx(dl,{rule:m,folders:b,preview:p,semanticAvailable:!r,clauseFields:Ca,...h,onCreateFolder:y,onCommit:j,onCancel:l})}const _i=(e,t)=>e.find(s=>s.label.toLowerCase()===t),hw=(e,t)=>{const s=[],r=_i(e,"inbox");r&&s.push({id:"keep-inbox",label:"Always keep in Inbox",seed:{moveMailboxId:r.id,scope:"standing"}});const a=_i(e,"archive");a&&s.push({id:"file-archive",label:"File in Archive",seed:{moveMailboxId:a.id}});const o=t?e.find(i=>i.id===t):void 0;return o&&s.push({id:"move-junk",label:`Move to ${o.label}`,seed:{moveMailboxId:o.id}}),s},pw=(e,t)=>{const s=e.toLowerCase(),r=t.find(o=>s.includes(o.label.toLowerCase())),a=/\b(always|keep|future|from now)\b/.test(s);return{moveMailboxId:r?.id,scope:a?"standing":void 0}};function gw({folderOptions:e,junkMailboxId:t,onSeed:s}){const[r,a]=c.useState(""),o=c.useMemo(()=>hw(e,t),[e,t]),i=()=>{const l=r.trim();l&&s(pw(l,e))};return n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"border-b border-line px-5 py-3",children:[n.jsx("h2",{className:"text-sm font-semibold text-fg",children:"What should Remit do?"}),n.jsx("p",{className:"mt-0.5 text-xs text-fg-muted",children:"Pick a shortcut or say it in your own words."})]}),n.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto px-5 py-4",children:o.map(l=>n.jsx(Y,{variant:"secondary",onClick:()=>s(l.seed),className:"h-12 w-full justify-start px-4",children:l.label},l.id))}),n.jsxs("div",{className:"flex items-center gap-2 border-t border-line px-5 py-3",children:[n.jsx(Ji,{value:r,onChange:l=>a(l.target.value),onKeyDown:l=>l.key==="Enter"&&i(),placeholder:"Tell Remit what to do…","aria-label":"Tell Remit what to do",className:"flex-1"}),n.jsx(Y,{variant:"primary","aria-label":"Send",onClick:i,disabled:!r.trim(),icon:n.jsx(Mm,{className:"size-4"}),className:"size-9 shrink-0 px-0"})]})]})}const xw=e=>e?.scope==="standing"?"standing":void 0,bw=(e,t,s)=>e?"error":t?"pending":s!==void 0?"success":"idle";function vw({entry:e,accountId:t,selectedMessageIds:s,selectedSenders:r,junkMailboxId:a,onClose:o}){const i=s[0],[l,u]=c.useState(),{preview:f,matchedCount:d,semanticUnavailable:m,senders:h,isPending:g,isError:b,error:p}=fd(t,i,r);c.useEffect(()=>{f()},[f]);const{data:v}=de({...ze({path:{accountId:t}}),staleTime:Number.POSITIVE_INFINITY}),x=c.useMemo(()=>Zs(v?.items??[]).map(j=>({id:j.mailboxId,label:Vn(j.fullPath)})),[v?.items]),y=mw({entry:e,hasSeed:l!==void 0,previewStatus:bw(b,g,d),matchedCount:d});return n.jsxs(gl,{open:!0,onClose:o,dismissLabel:"Dismiss organize",children:[y.kind==="something-else"&&n.jsx(gw,{folderOptions:x,junkMailboxId:a,onSeed:u}),y.kind==="widening"&&n.jsx(yw,{}),y.kind==="error"&&n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[n.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't find similar messages"}),n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:p instanceof Error?p.message:"Please try again."}),n.jsx(Y,{variant:"ghost",onClick:o,className:"mt-2",children:"Close"})]}),y.kind==="organize"&&n.jsx(md,{accountId:t,selectedMessageIds:s,seedCount:y.matchedCount,seedScope:xw(l),seedMailboxId:l?.moveMailboxId,semanticUnavailable:m,senders:h,onClose:o})]})}function yw(){return n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[n.jsx(st,{className:"size-8 animate-spin text-accent-2"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Finding similar messages…"})]})}function ww({open:e,accountId:t,selectedMessageIds:s,selectedSenders:r,onClose:a}){const o=s[0],{preview:i,reset:l,matchedCount:u,semanticUnavailable:f,senders:d,isPending:m,isError:h,error:g}=fd(t,o,r);c.useEffect(()=>{e&&i()},[e,i]);const b=()=>{l(),a()};return e?n.jsx(ca,{open:e,onClose:b,title:"Filter rule",children:m||u===void 0?h?n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't find similar messages"}),n.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:g instanceof Error?g.message:"Please try again."}),n.jsx(Y,{variant:"ghost",onClick:b,className:"mt-2",children:"Close"})]}):n.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[n.jsx(st,{className:"size-8 animate-spin text-accent-2"}),n.jsx("p",{className:"text-sm font-medium text-fg",children:"Finding similar messages…"})]}):n.jsx(md,{accountId:t,selectedMessageIds:s,seedCount:u,semanticUnavailable:f,senders:d,onClose:b})}):null}const jw=(e,t)=>({id:e.messageId,accountId:e.accountConfigId,mailboxId:e.mailboxId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ot(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:sr(e.category),messageCount:t,suspicious:e.authenticity?.dkimMismatch===!0}),Sw=({thread:e,mailboxId:t,accountId:s,isSelected:r,isFocused:a,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:u,onRowSelect:f,messageCount:d,isMultiSelectMode:m,onLongPress:h,isDesktop:g,density:b})=>n.jsx(so,{thread:jw(e,d),linkMailboxId:t,inListbox:!0,active:r,focused:a,isTabStop:o,density:b,isDesktop:g,onFocusRow:i,selection:{isChecked:l,onToggleCheck:u,onRowSelect:f,isMultiSelectMode:m,onLongPress:h},badge:e.autoMoved?n.jsx(Vc,{accountId:s,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,size:"sm"}):void 0}),kw=c.memo(Sw),Cw=e=>{const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountConfigId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Ot(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:sr(e.category),suspicious:t}},Nw=({thread:e,mailboxId:t,accountId:s,isSelected:r,isFocused:a,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:u,onRowSelect:f,isMultiSelectMode:d,onLongPress:m,isDesktop:h,onDelete:g,onToggleRead:b,density:p})=>{const[v,x]=c.useState("none"),y=c.useCallback(N=>{navigator.vibrate?.(10),N==="trailing"?g(e.messageId):b(e.messageId,e.isRead),x("none")},[g,b,e.messageId,e.isRead]),j=c.useCallback(()=>{m(e.messageId)},[m,e.messageId]),w=c.useCallback(()=>{u(e.messageId)},[u,e.messageId]);return h||d?n.jsx(kw,{thread:e,mailboxId:t,accountId:s,isSelected:r,isFocused:a,isTabStop:o,onFocusRow:i,isChecked:l,onToggleCheck:u,onRowSelect:f,isMultiSelectMode:d,onLongPress:m,isDesktop:h,density:p}):n.jsx(Jl,{thread:Cw(e),selectionMode:!1,checked:!1,active:r,peek:v,onPeek:x,onToggleCheck:w,onLongPress:j,onOpen:()=>{},onAct:y,linkComponent:({onOpenClick:N,children:E,...C})=>n.jsx(pt,{...C,to:"/mail/$mailboxId",params:{mailboxId:t},search:k=>({...k,selectedMessageId:e.messageId}),"data-message-row":!0,onClick:N,children:E})})},Ew=72,Iw=32,Tw=5,hd="remit:list-density",Rw={kind:"delete"},Bi={kind:"markRead"},Mw=()=>{try{const e=localStorage.getItem(hd);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},Aw=({query:e,count:t})=>n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[n.jsx(Js,{className:"size-4 text-fg-muted"}),n.jsxs("span",{className:"text-sm text-fg-muted",children:[t," ",t===1?"result":"results"," for “",e,"”"]})]}),Dw=({mailboxId:e,threads:t,selectedMessageId:s,isLoading:r,isError:a=!1,error:o,onRetry:i,searchQuery:l,searchPredicate:u,onDeleteMessages:f,onMoveMessages:d,isDeleting:m=!1,isMoving:h=!1,onLoadMore:g,hasMore:b=!1,isLoadingMore:p=!1,accountId:v,listTitle:x,listMeta:y,onTriageContextChange:j,commandsRef:w,hideHeader:N=!1})=>{const E=c.useRef(null),C=Oe(),k=At(),[R,O]=c.useState(!1),[D,P]=c.useState(null),I=!!l?.trim(),[S,A]=c.useState(s),[L,T]=c.useState(Mw),F=c.useCallback(()=>{T(z=>{const se=z==="comfortable"?"compact":"comfortable";try{localStorage.setItem(hd,se)}catch{}return se})},[]),{toggleReadFor:M}=tr({mailboxId:e}),{junkMailboxId:$}=rr(v),{selectedIds:K,selectedCount:B,hasSelection:J,isSelected:ee,toggle:X,select:me,clearSelection:ue,selectRange:te,setAnchor:U,selectAll:H,toggleAll:re,intersectWith:Ie}=_u(),je=Bu(B,k);c.useEffect(()=>{B===0&&P(null)},[B]);const[V,G]=c.useState(null),ae=I&&!!u,le=`${e}|${JSON.stringify(u??{})}`,_=iw({mailboxId:e,accountId:v,enabled:ae,predicateKey:le,searchQuery:u??{}}),Fe=_.phase.kind,pe=_.clear,ge=c.useCallback(()=>{Fe==="escalated"&&pe(),ue()},[ue,pe,Fe]),[Se,Ve]=c.useState(null),[ts,_e]=c.useState(null),Ze=c.useRef(null),Be=c.useRef(!1),Ke=c.useRef(null),ft=!r&&t.length>0,Te=V!==null,ss=c.useCallback((z,se)=>{const{exit:wt,retryIds:Ge}=rw(se);if(wt){_e(zi(z.kind,se.done)),Ve(null),ge();return}if(Ge.length>0){Ve({action:z,succeeded:se.done}),H(Ge);return}Ve(null)},[ge,H]),Ue=q0({count:t.length,getScrollElement:()=>E.current,estimateSize:()=>L==="compact"?Iw:Ew,overscan:Tw}),zt=s?t.findIndex(z=>z.messageId===s):-1,Ne=S?t.findIndex(z=>z.messageId===S):-1,qe=c.useCallback(z=>{if(z<0||z>=t.length)return;const se=t[z];if(je){X(se.messageId);return}Ze.current=se.messageId,Be.current=!1,A(se.messageId)},[t,je,X]),mt=c.useCallback(()=>{if(t.length===0)return;const z=Ne<0?0:Math.min(Ne+1,t.length-1);qe(z)},[t.length,Ne,qe]),ns=c.useCallback(()=>{if(t.length===0)return;const z=Ne<=0?0:Ne-1;qe(z)},[t.length,Ne,qe]),_t=c.useCallback(()=>qe(0),[qe]),Z=c.useCallback(()=>qe(t.length-1),[qe,t.length]),ie=c.useCallback(()=>{S&&X(S)},[S,X]),ne=c.useMemo(()=>t.map(z=>z.messageId),[t]),oe=c.useMemo(()=>{const z=[];for(const se of t)K.has(se.messageId)&&se.fromEmail&&z.push(se.fromEmail);return z},[t,K]),he=c.useCallback((z,se)=>se.shiftKey?(te(ne,z,S),!0):se.metaKey||se.ctrlKey?(X(z),!0):(ge(),U(z),!1),[ne,S,te,X,ge,U]),fe=c.useCallback(z=>{!f||z.length===0||(Ke.current=S??null,G({source:"ids",ids:z}))},[f,S]),ve=c.useCallback(()=>{_.phase.kind==="escalated"&&(Ke.current=S??null,G({source:"predicate",total:_.phase.total}))},[_.phase,S]),Pe=c.useCallback(z=>{const se=zu(ne,S,z);se!==void 0&&(te(ne,se),Ze.current=se,Be.current=!1,A(se))},[ne,S,te]),Ae=c.useCallback(()=>Pe(-1),[Pe]),He=c.useCallback(()=>Pe(1),[Pe]),De=c.useCallback(()=>{ne.length>0&&H(ne)},[ne,H]),Re=c.useCallback(()=>V!==null?!0:f?B>0?(fe(Array.from(K)),!0):S?(fe([S]),!0):!1:!1,[V,f,B,K,S,fe]),Qe=c.useCallback(()=>{S&&C({to:"/mail/$mailboxId",params:{mailboxId:e},search:z=>({...z,selectedMessageId:S})})},[S,C,e]),Ye=c.useCallback(()=>{B>0&&fe(Array.from(K))},[fe,B,K]),et=c.useCallback(async(z,se)=>{const wt=await _.runAction(z,se);ss(z,wt)},[_,ss]),Bt=c.useCallback(async z=>{G(null),Ke.current=null,await et(Rw,z)},[et]),ur=c.useCallback(()=>{if(!V)return;if(V.source==="predicate"){Bt(void 0);return}const{ids:z}=V;if(z.length===0){G(null);return}if(z.length>ud){Bt(z);return}const se=new Set(z),wt=t.findIndex($e=>se.has($e.messageId));let Ge;for(let $e=wt+1;$e<t.length;$e++)if(!se.has(t[$e].messageId)){Ge=t[$e].messageId;break}if(Ge===void 0){for(let $e=wt-1;$e>=0;$e--)if(!se.has(t[$e].messageId)){Ge=t[$e].messageId;break}}f?.(z),ge(),Ke.current=null,G(null),Ge!==void 0&&(Ze.current=Ge,Be.current=!1,A(Ge),k&&C({to:"/mail/$mailboxId",params:{mailboxId:e},search:$e=>({...$e,selectedMessageId:Ge}),replace:!0})),k||_e(zi("delete",z.length))},[V,t,f,ge,C,e,k,Bt]),vt=c.useCallback(()=>{const z=Ke.current;Ke.current=null,G(null),z!==null&&(Ze.current=z,Be.current=!1,A(z))},[]),fn=c.useCallback(()=>{if(_.phase.kind==="escalated"){et(Bi);return}B!==0&&et(Bi,Array.from(K))},[_.phase,et,B,K]),rs=c.useCallback(z=>{if(_.phase.kind==="escalated"){et({kind:"move",destinationMailboxId:z});return}!d||B===0||(d(Array.from(K),z),ge())},[_.phase,et,d,B,K,ge]),dr=c.useCallback(()=>{$&&rs($)},[$,rs]),Kt=c.useMemo(()=>{if(B===0)return;const z=new Set;for(const se of t)K.has(se.messageId)&&z.add(se.accountConfigId);if(z.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[B,K,t]),fr=c.useCallback(z=>{f?.([z])},[f]),mr=c.useCallback((z,se)=>{M([z],!se)},[M]),hr=c.useCallback(z=>{k||me(z)},[k,me]),yt=c.useCallback(()=>{if(_.phase.kind==="escalated"){ve();return}Ye()},[_.phase,ve,Ye]),Ms=c.useCallback(()=>{if(_.isRunning||_.phase.kind==="counting"){_.stop();return}ge()},[_,ge]),mn=c.useCallback(()=>{_.clear()},[_]),pr=c.useCallback(()=>{if(!Se)return;const z=Array.from(K);if(Se.action.kind==="delete"){Bt(z);return}et(Se.action,z)},[Se,Bt,et,K]);c.useEffect(()=>{if(Be.current||!k&&s)return;const z=Ne>=0?Ne:zt;z>=0&&Ue.scrollToIndex(z,{align:"auto"})},[Ne,zt,Ue,k,s]),c.useEffect(()=>{s&&(Be.current=!1,A(s))},[s]),c.useEffect(()=>{S&&(t.some(z=>z.messageId===S)||A(t[0]?.messageId))},[t,S]),c.useEffect(()=>{j?.({focusedMessageId:S,selectedIds:Array.from(K),hasList:ft,blocksKeyboard:Te})},[S,K,ft,Te,j]);const hn=c.useRef(j);hn.current=j,c.useEffect(()=>()=>hn.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),c.useEffect(()=>{_.phase.kind!=="idle"||_.isRunning||Ie(t.map(z=>z.messageId))},[t,Ie,_.phase,_.isRunning]);const pn=c.useRef(e);c.useEffect(()=>{pn.current!==e&&(pn.current=e,ge())},[e,ge]),Rx({shouldBlockFn:({action:z})=>by(z,J)?(ge(),!0):!1,enableBeforeUnload:!1,disabled:!J}),c.useEffect(()=>{const z=E.current;if(!z||!b||!g)return;const se=()=>{if(p)return;const{scrollTop:wt,scrollHeight:Ge,clientHeight:$e}=z;wt+$e>=Ge-200&&g()};return z.addEventListener("scroll",se,{passive:!0}),se(),()=>z.removeEventListener("scroll",se)},[b,p,g]),c.useEffect(()=>{const z=Ze.current;if(!z)return;const se=E.current?.querySelector(`[data-message-id="${z}"]`);se&&(Ze.current=null,se.focus({preventScroll:!0}))}),c.useEffect(()=>{if(w){if(!ft){w.current=null;return}return w.current={focusNext:mt,focusPrevious:ns,focusFirst:_t,focusLast:Z,openFocused:Qe,toggleSelect:ie,extendSelectDown:He,extendSelectUp:Ae,selectAll:De,clearSelection:()=>J?(ge(),!0):!1,requestDelete:Re,toggleDensity:F},()=>{w.current=null}}},[w,ft,mt,ns,_t,Z,Qe,ie,He,Ae,De,J,ge,Re,F]);const gn=r?"loading":a?"error":t.length===0?"empty":"ready",gr=a?wl(o):void 0,Q=c.useCallback(()=>{const z=ba(xa());window.open(z,"_blank","noopener,noreferrer")},[]),tt=[{id:"inbox",threads:[]}],Le=ne.length>0&&ne.every(z=>K.has(z)),Cd=ae&&b&&Le&&!m&&!h&&_.phase.kind==="idle"&&!_.isRunning,Nd=m||h||_.isRunning,xr=_.phase.kind==="escalated"?_.phase.total:B,co=_.runningAction?Q0(_.runningAction.kind,_.progress?.done??0,_.progress?.total??0):_.phase.kind==="counting"?_.phase.countSoFar>=5e3?`Counting… ${ct(_.phase.countSoFar)} so far. This is a big result set.`:`Counting… ${ct(_.phase.countSoFar)} so far`:_.phase.kind==="escalated"?cw(u??{},_.phase.total):void 0,uo=_.phase.kind!=="escalated"&&ne.length>0?{checked:Le,indeterminate:B>0&&!Le,onChange:()=>re(ne)}:void 0,fo=_.runningAction&&_.progress?{value:_.progress.done,max:_.progress.total,tone:J0(_.runningAction.kind)}:void 0,mo=_.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:_.stop}}:_.phase.kind==="escalated"&&!_.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:mn}}:Cd?{tone:"info",text:"",action:{label:lw(u??{}),onClick:_.escalate}}:Se!==null&&B>0?{tone:"danger",text:Y0(Se.action.kind,Se.succeeded,B),action:{label:`Retry ${ct(B)}`,onClick:pr}}:void 0,ho=mo??(Kt?{tone:"warning",text:Kt}:void 0),po=uw({isRunning:_.isRunning,isCounting:_.phase.kind==="counting",isEscalated:_.phase.kind==="escalated"}),go=!k&&je&&fw(xr,po,ho!==void 0),Ed=(d||_.phase.kind==="escalated")&&v&&e?n.jsx(dn,{accountId:v,currentMailboxId:e,onMove:m||h?()=>{}:rs,disabledHint:Kt,label:"Move selected messages"}):void 0,xo=D&&v&&!k&&B>0?n.jsx(vw,{entry:D,accountId:v,selectedMessageIds:Array.from(K),selectedSenders:oe,junkMailboxId:$,onClose:()=>{P(null),ge()}}):void 0,bo=go?n.jsx(Vp,{count:xr,mode:po,onCancel:Ms,onDelete:yt,onJunk:$&&$!==e&&!Kt?dr:void 0,onMarkRead:fn,onSelectSimilar:v?()=>P("select-similar"):void 0,onSomethingElse:v?()=>P("something-else"):void 0,moveSlot:Ed,isBusy:Nd,selectAll:uo,statusLabel:co,progress:fo,notice:ho}):void 0,Id=bo||xo?n.jsxs(n.Fragment,{children:[bo,xo]}):void 0,Td=J&&k?n.jsx(Uu,{selectedCount:xr,onDelete:yt,onClearSelection:Ms,onMarkAsRead:fn,onMove:d?rs:void 0,onOrganize:()=>O(!0),isDeleting:m,isMoving:h,accountId:v,currentMailboxId:e,moveDisabledHint:Kt,selectAll:ae?uo:void 0,statusLabel:co,isCounting:_.phase.kind==="counting",progress:fo,notice:mo}):void 0,Rd=Ku(ne,S),Md=c.useCallback(z=>{Be.current=!0,A(z)},[]),Ad=n.jsxs(n.Fragment,{children:[I&&l&&n.jsx(Aw,{query:l,count:t.length}),n.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":x,className:"flex-1 overflow-y-auto",style:go?{paddingBottom:Bs}:void 0,children:[n.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Ue.getTotalSize()}px`},children:Ue.getVirtualItems().map(z=>{const se=t[z.index];return n.jsx("div",{role:"presentation","data-index":z.index,ref:Ue.measureElement,className:xe("absolute left-0 top-0 w-full border-b border-line",_.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${z.start}px)`},children:n.jsx(Nw,{thread:se,mailboxId:e,accountId:v,isSelected:s===se.messageId,isFocused:S===se.messageId,isTabStop:Rd===se.messageId,onFocusRow:Md,isChecked:ee(se.messageId),onToggleCheck:X,onRowSelect:he,isMultiSelectMode:je,onLongPress:hr,isDesktop:k,onDelete:fr,onToggleRead:mr,density:L})},z.key)})}),p&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-fg-muted border-t-transparent"})})]})]}),Dd=V?V.source==="ids"?V.ids.length:V.total:0,vo=V?.source==="predicate";return n.jsxs(n.Fragment,{children:[ts&&!k&&n.jsx(Xt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>_e(null),children:ts}),n.jsx(Zl,{listTitle:x,listMeta:y,sections:tt,flatList:!0,listState:gn,searchQuery:I?l:void 0,errorMessage:gr,onRetry:i,onReportError:Q,density:L,selectedThreadId:s,onSelectThread:z=>C({to:"/mail/$mailboxId",params:{mailboxId:e},search:se=>({...se,selectedMessageId:z})}),onSelectBriefCategory:()=>{},isDesktop:k,hideHeader:N,selectionBar:Td,selectionSheet:Id,listBody:gn==="ready"?Ad:void 0}),n.jsx(eo,{isOpen:V!==null,title:Sl(Dd,vo),description:vo?"This count is a snapshot — new mail arriving during the delete won't be included. You can restore what's deleted from Trash later.":"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:m,onConfirm:ur,onCancel:vt}),R&&v&&n.jsx(ww,{open:R,accountId:v,selectedMessageIds:Array.from(K),selectedSenders:oe,onClose:()=>O(!1)})]})},Ow=e=>Jt({path:{accountId:e}}),Pw=e=>{const t=we(),s=Xs(),r=ye({...Sf(),onSuccess:()=>{s.recordEvent("sync.triggered"),t.invalidateQueries({queryKey:Ow(e)})}});return{trigger:()=>{r.mutate({path:{accountId:e}})},triggerAsync:()=>r.mutateAsync({path:{accountId:e}}),isPending:r.isPending,error:r.error,reset:r.reset}},Lw=({accountId:e,children:t})=>{const{triggerAsync:s,isPending:r}=Pw(e);return n.jsx(Sp,{onRefresh:s,isRefreshing:r,children:t})};function $w({accountId:e,currentMailboxId:t,candidates:s,onMove:r,children:a}){const[o,i]=c.useState(!1),l=Xs(),{t:u}=Un("mail",{useSuspense:!1}),f=c.useCallback((y,j)=>u(y,{defaultValue:j}),[u]),{inboxMailboxId:d}=Qa(e),m=Wc(e),{data:h}=de({...ze({path:{accountId:e}}),staleTime:1/0}),g=c.useMemo(()=>{const y=Zs(h?.items??[],m),j=Gs(m);return y.map(w=>({id:w.mailboxId,label:bs(w,j.get(w.mailboxId),f),searchValue:w.fullPath,isCurrent:w.mailboxId===t}))},[h?.items,m,t,f]),b=c.useMemo(()=>d||(g.find(j=>j.label.toLowerCase()==="inbox")?.id??g.find(j=>!j.isCurrent)?.id??""),[d,g]),p=c.useRef(!1);c.useEffect(()=>{p.current||(p.current=!0,By(l,s.length))},[l,s.length]);const v=c.useCallback(()=>{Ky(l,s.length),i(!0)},[l,s.length]),x=c.useCallback((y,j)=>{Uy(l,{selected:y.length,total:s.length,toInbox:j===d}),r(y,j)},[l,s.length,d,r]);return n.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[n.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:n.jsx(Np,{count:s.length,onReview:v})}),n.jsx("div",{className:"min-h-0 flex-1",children:a}),n.jsx(Lp,{open:o,candidates:s,defaultDestinationId:b,availableFolders:g,onConfirmMove:x,onCancel:()=>i(!1)})]})}const Fw="We can verify this sender";function zw(e){const{data:t}=de({...kf({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(t?.items??[]).map(r=>({id:r.messageId,senderName:r.fromName||r.fromEmail||"Unknown sender",senderAddress:r.fromEmail??"",subject:r.subject||"(no subject)",snippet:r.snippet??"",trustReason:Fw,trustSubReason:_y(r.senderTrust),senderTrust:r.senderTrust}))}}const _w=e=>{const t=new Set,s=[];for(const r of e)t.has(r.threadMessageId)||(t.add(r.threadMessageId),s.push(r));return s},pd="remit:intelligence-open";function Bw(){try{return localStorage.getItem(pd)!=="closed"}catch{return!0}}function Ki(e){try{localStorage.setItem(pd,e?"open":"closed")}catch{}}const Kw=(e,t)=>e!==t,Uw=(e,t,s)=>{if(!(s||!t))return e.find(r=>r.messageId===t)},qw={unread:e=>!e.isRead,flagged:e=>e.hasStars===!0,attachment:e=>!!e.hasAttachment};function Hw(e,t,s){const r=Array.from(s).map(a=>qw[a]).filter(a=>a!=null);return t==="all"&&r.length===0?e:e.filter(a=>(t==="all"||a.category===t)&&r.every(o=>o(a)))}const gd=c.createContext(null);function cr(){const e=c.useContext(gd);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Ww({mailboxId:e,selectedMessageId:t,children:s}){const r=Oe(),o=or()==="desktop",i=Xs(),{accounts:l,searchQuery:u,searchInput:f,intelligenceOpen:d,onToggleIntelligence:m,onSetIntelligenceOpen:h}=Ce(),g=Is(),b=Za(u),p=b.length>0,{freeText:v,tokens:x}=Ts(b,g),y=x.find(Q=>Q.type==="from"),j={order:"desc",...v?{query:v}:{},...y?{from:y.value}:{},...x.some(Q=>Q.type==="hasAttachment")?{attachments:!0}:{},...x.some(Q=>Q.type==="isUnread")?{unread:!0}:{}},w=p?ol({path:{mailboxId:e},query:j}):ya({path:{mailboxId:e},query:{order:"desc"}}),{data:N,isLoading:E,isError:C,error:k,refetch:R,fetchNextPage:O,hasNextPage:D,isFetchingNextPage:P}=Sc({queryKey:w,queryFn:async({pageParam:Q})=>{if(p){const{data:Le}=await ml({path:{mailboxId:e},query:{...j,continuationToken:Q},throwOnError:!0});return Le}const{data:tt}=await Nf({path:{mailboxId:e},query:{order:"desc",continuationToken:Q},throwOnError:!0});return tt},initialPageParam:void 0,getNextPageParam:Q=>Q.continuationToken,enabled:p?b.length>0:!0,placeholderData:Cf}),I=c.useCallback(Q=>{t&&Q.includes(t)&&r({to:"/mail/$mailboxId",params:{mailboxId:e},search:tt=>({...tt,selectedMessageId:void 0,selectedThreadId:void 0})})},[t,e,r]),{deleteMessages:S,isPending:A}=Yt({mailboxId:e,onAfterOptimisticRemove:I}),{accountId:L}=qc(e),T=Oc({accounts:l}),{moveMessages:F,isPending:M}=Qt({mailboxId:e,accountId:L,onAfterOptimisticRemove:I}),$=Kb(_w(N?.pages.flatMap(Q=>Q.items??[])??[])),[K,B]=c.useState("all"),[J,ee]=c.useState(new Set),X=c.useMemo(()=>Hw($,K,J),[$,K,J]),me=c.useCallback(Q=>{B(Q)},[]),ue=c.useCallback(Q=>{ee(tt=>{const Le=new Set(tt);return Le.has(Q)?Le.delete(Q):Le.add(Q),Le})},[]),te=c.useCallback(()=>{B("all"),ee(new Set)},[]),U=Kw(f,u),H=Uw($,t,U),{selectedThreadId:re}=vs({strict:!1}),Ie=c.useMemo(()=>Zu(H,{messageId:t,threadId:U?void 0:re,mailboxId:e}),[H,t,re,U,e]),je=ro(),{listCommandsRef:V,onTriageContextChange:G,focusedMessageId:ae,selectedIds:le}=je,_=X.find(Q=>Q.messageId===ae)??H,Fe=c.useRef(null);c.useEffect(()=>{const Q=H?.messageId??null;Q&&Fe.current!==Q&&H?.authenticity?.dkimMismatch&&(Fe.current=Q,d||m())},[H?.messageId,H?.authenticity?.dkimMismatch,d,m]);const pe=c.useRef(!1);c.useEffect(()=>{pe.current||o&&H?.messageId&&(pe.current=!0,Bw()&&!d&&h(!0))},[o,H?.messageId,d,h]);const Se=Ux({accounts:l})??$.filter(Q=>!Q.isRead).length,Ve=we(),{pushError:ts}=Je(),_e=Vs({thread:H,mailboxId:e,accountId:L,onAfterOptimisticRemove:I}),{draftsMailboxId:Ze}=_b(L),Be=Ze!==void 0&&Ze===e,{archiveMailboxId:Ke}=zb(L),ft=Ju(),{requestCompose:Te}=_e,ss=c.useCallback(()=>{Te("reply")},[Te]),Ue=c.useCallback(()=>{Te("reply_all")},[Te]),zt=c.useCallback(()=>{Te("forward")},[Te]),{state:Ne,openCompose:qe,closeCompose:mt}=Mt(),ns=c.useCallback(()=>{qe({mode:"new"})},[qe]),_t=ye({...Hn(),onError:Q=>{ts(Vt("Couldn't discard draft","The draft wasn't deleted.",Q))}}),Z=c.useCallback(()=>{const Q=Ne.outboxMessageId;Q&&(_t.mutate({path:{outboxMessageId:Q}}),Ve.invalidateQueries({queryKey:Sa()}),mt())},[Ne.outboxMessageId,_t,Ve,mt]),ie=c.useCallback(()=>{r({to:"/mail/$mailboxId",params:{mailboxId:e},search:Q=>({...Q,selectedMessageId:void 0,selectedThreadId:void 0})})},[e,r]),ne=c.useCallback(Q=>Q?ft(Q):[],[ft]),{toggleStar:oe}=Wa({threadId:_?.threadId??"",mailboxId:e}),{toggleReadFor:he}=tr({mailboxId:e,accountId:L}),{junkMailboxId:fe}=rr(L),ve=fe!=null&&fe===e,{candidates:Pe}=zw(ve?fe:void 0),{moveMessages:Ae}=Qt({mailboxId:e,threadId:_?.threadId,accountId:L,onAfterOptimisticRemove:I}),{deleteMessages:He}=Yt({mailboxId:e,threadId:_?.threadId,onAfterOptimisticRemove:I}),{addressId:De,address:Re}=Qu(_),{updateFlags:Qe}=Yu({addressId:De,senderEmail:_?.fromEmail??void 0}),Ye=c.useCallback(()=>t||!ae?!1:(r({to:"/mail/$mailboxId",params:{mailboxId:e},search:Q=>({...Q,selectedMessageId:ae})}),!0),[t,ae,e,r]),et=c.useCallback(()=>{Ye()||H&&Te("reply")},[Ye,H,Te]),Bt=c.useCallback(()=>{Ye()||H&&Te("reply_all")},[Ye,H,Te]),ur=c.useCallback(()=>{Ye()||H&&Te("forward")},[Ye,H,Te]),vt=c.useCallback(()=>le.length>0?le:ne(_),[le,ne,_]),fn=c.useCallback(()=>{if(V.current?.requestDelete())return;const Q=vt();Q.length>0&&He(Q)},[V,vt,He]),rs=c.useCallback(()=>{if(!fe)return;const Q=vt();Q.length!==0&&(Xu(i,{count:Q.length,senderTrust:_?.senderTrust??"unknown",wasRescuable:_?Gu(_):!1}),Ae(Q,fe))},[fe,vt,Ae,i,_]),dr=c.useCallback(()=>{if(le.length>0){const Q=!(_?.hasStars??!1),tt=new Set(le);for(const Le of X)tt.has(Le.messageId)&&Le.hasStars!==Q&&oe(Le.messageId,Le.hasStars);return}_&&oe(_.messageId,_.hasStars)},[le,X,_,oe]),Kt=c.useCallback(()=>{const Q=vt();if(Q.length===0)return;const tt=!(_?.isRead??!1);he(Q,tt)},[vt,_,he]),fr=c.useCallback(()=>{if(!De)return;const Q=Re?.flags?.muted?.value!==!0;Qe({muted:{value:Q}})},[De,Re,Qe]),mr=c.useCallback(()=>{if(!De)return;const Q=Re?.flags?.vip?.value!==!0;Qe({vip:{value:Q}})},[De,Re,Qe]),hr=c.useCallback(()=>{d||m()},[d,m]),yt=c.useCallback(Q=>{r({to:Q})},[r]),Ms=Be?"drafts":Ke===e?"archive":fe===e?"junk":"inbox",mn=c.useRef("");c.useEffect(()=>{const Q=mn.current;mn.current=b,b.length>0&&Q.length===0&&i.recordEvent("search.submitted",{mailboxType:Ms})},[b,Ms,i]);const pr=Be&&Ne.isOpen&&!!Ne.outboxMessageId&&!H,{goBack:hn,nextMessageId:pn,previousMessageId:gn}=ao({context:je,orderedIds:X.map(Q=>Q.messageId),selectedMessageId:t,enabled:!Ne.isOpen,onClose:ie,handlers:{reply:et,replyAll:Bt,forward:ur,delete:fn,toggleStar:dr,toggleRead:Kt,muteSender:fr,blockSender:hr,vipSender:mr,markJunk:rs,toggleIntelligence:H?m:void 0,compose:ns,goBrief:()=>yt("/mail"),goInbox:()=>yt("/mail"),goSent:()=>yt("/mail"),goFlagged:()=>yt("/mail/flagged"),goSettings:()=>yt("/settings")}});qa({enabled:Ne.isOpen,bindings:[{key:"Escape",handler:mt,preventDefault:!0}]});const gr={mailboxId:e,selectedMessageId:t,selectedThread:H,conversation:Ie,threads:X,isLoading:E,isError:C,error:k,mailboxAccountId:L,mailboxName:T,unreadCount:Se,isDraftsMailbox:Be,isSpamFolder:ve,rescueCandidates:Pe,filterCategory:K,filterAttributes:J,onSelectFilterCategory:me,onToggleFilterAttribute:ue,onClearFilters:te,intelligenceOpen:d,onToggleIntelligence:m,searchPredicate:p?j:void 0,onDeleteMessages:S,onMoveMessages:F,isDeleting:A,isMoving:M,onLoadMore:O,hasMore:D,isLoadingMore:P,onTriageContextChange:G,listCommandsRef:V,onRetry:()=>R(),toolbarComposeRequest:_e.composeRequest,onToolbarReply:ss,onToolbarReplyAll:Ue,onToolbarForward:zt,onClearComposeRequest:_e.clearComposeRequest,onToolbarDelete:_e.deleteThread,onToolbarStar:_e.toggleStar,onToolbarDiscardDraft:Z,onToolbarMove:_e.moveThread,composeState:Ne,closeCompose:mt,hasRemitDraftOpen:pr,onBack:hn,nextMessageId:pn,previousMessageId:gn};return n.jsx(gd.Provider,{value:gr,children:s})}function xd(){const{mailboxId:e,selectedMessageId:t,threads:s,isLoading:r,isError:a,error:o,onDeleteMessages:i,onMoveMessages:l,isDeleting:u,isMoving:f,onLoadMore:d,hasMore:m,isLoadingMore:h,mailboxAccountId:g,mailboxName:b,unreadCount:p,isDraftsMailbox:v,isSpamFolder:x,rescueCandidates:y,onTriageContextChange:j,listCommandsRef:w,onRetry:N,filterCategory:E,filterAttributes:C,onSelectFilterCategory:k,onToggleFilterAttribute:R,onClearFilters:O,searchPredicate:D}=cr(),{searchQuery:P,searchInput:I,accounts:S,resultFolderIndex:A}=Ce(),L=or(),T=Oe(),F=b??"Inbox",M=c.useMemo(()=>Xp(),[]),$=c.useMemo(()=>s.map(U=>ny(U,A)),[s,A]),{hits:K,isLoading:B}=ku({mailboxId:e,filterCategory:E}),J=c.useMemo(()=>Iu(K,s.map(U=>U.threadId),A),[K,s,A]),ee=c.useCallback(U=>T({to:"/mail/$mailboxId",params:{mailboxId:U.mailboxId??e},search:H=>({...H,q:I||void 0,selectedMessageId:U.id,selectedThreadId:U.threadId})}),[e,T,I]);if(v&&g)return n.jsx(E0,{mailboxId:e,accountId:g,selectedMessageId:t,imapThreads:s,title:b??"Drafts",unreadCount:p??void 0});const X=n.jsx(Dw,{mailboxId:e,threads:s,selectedMessageId:t,isLoading:r,isError:a,error:o,onRetry:N,searchQuery:P,searchPredicate:D,onDeleteMessages:i,onMoveMessages:l,isDeleting:u,isMoving:f,onLoadMore:d,hasMore:m,isLoadingMore:h,accountId:g,listTitle:F,hideHeader:!0,onTriageContextChange:j,commandsRef:w}),me=S[0]?.accountId,ue=L==="phone"&&me?n.jsx(Lw,{accountId:me,children:X}):X,te=x&&y.length>0&&g?n.jsx($w,{accountId:g,currentMailboxId:e,candidates:y,onMove:l,children:ue}):ue;return n.jsx(nd,{title:F,unreadCount:p,preset:M,selectedCategory:E,activeFilters:C,onSelectCategory:k,onToggleFilter:R,onClearFilters:O,searchResults:$,searchLoading:r,relatedResults:J,relatedLoading:B,onSelectSearchResult:ee,searchResultsInBody:!0,children:te})}function Vw(){const{mailboxId:e,mailboxAccountId:t,selectedThread:s,conversation:r,hasRemitDraftOpen:a,intelligenceOpen:o,onToggleIntelligence:i,toolbarComposeRequest:l,onToolbarReply:u,onToolbarReplyAll:f,onToolbarForward:d,onClearComposeRequest:m,onToolbarDelete:h,onToolbarStar:g,onToolbarDiscardDraft:b,onToolbarMove:p,composeState:v}=cr(),x=Ss()?.showIntelligencePane??!1,y=!!r,j=x&&y,w=v.isOpen&&!r?n.jsx(od,{}):r?n.jsx(Es,{threadId:r.threadId,mailboxId:r.mailboxId,subject:r.subject,selectedMessageId:r.messageId,authenticity:r.authenticity,onOpenIntelligence:r.authenticity?.dkimMismatch?i:void 0,composeRequest:l,onComposeClose:m}):n.jsx(Ns,{});return n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx(no,{hasThread:y,intelligenceOpen:j&&o,canToggleIntelligence:j,onToggleIntelligence:i,onReply:y?u:void 0,onReplyAll:y?f:void 0,onForward:y?d:void 0,canDelete:y||a,onDelete:y?h:a?b:void 0,onToggleStar:y?g:void 0,isStarred:s?.hasStars,moveContext:y&&t?{accountId:t,currentMailboxId:e,onMove:p}:void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]})}function Qw(){const{mailboxId:e,mailboxAccountId:t,selectedThread:s,onToggleIntelligence:r}=cr();return n.jsx(Rs,{onClose:r,thread:s,mailboxId:e,accountId:t})}function Yw(){const{mailboxId:e,selectedThread:t,conversation:s,intelligenceOpen:r,onToggleIntelligence:a,onBack:o,nextMessageId:i,previousMessageId:l,composeState:u}=cr(),f=Oe();if(s){const d=m=>f({to:"/mail/$mailboxId",params:{mailboxId:e},search:h=>({...h,selectedMessageId:m,selectedThreadId:void 0})});return n.jsxs(n.Fragment,{children:[n.jsx(Es,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:o,onOpenIntelligence:a,onSwipeNext:i?()=>d(i):void 0,onSwipePrevious:l?()=>d(l):void 0,mobileIntelligenceOpen:r}),n.jsx(Ka,{isOpen:r,onClose:a,ariaLabel:"Message details",side:"right",children:n.jsx(Rs,{onClose:a,thread:t,hideCloseButton:!0})})]})}return u.isOpen?n.jsx("div",{className:"h-full",children:n.jsx(od,{})}):n.jsx(xd,{})}const _s=Object.assign(Ww,{List:xd,Reading:Vw,Intelligence:Qw,Phone:Yw}),bd=e=>e==="failed"||e==="blocked",vd=e=>e!=="draft"&&e!=="sent",io="remit.savedSearches",Gw=25;function Bn(){try{const e=localStorage.getItem(io);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Xw(e){const t=e.trim();if(!t)return Bn();const s=[t,...Bn().filter(r=>r!==t)].slice(0,Gw);try{localStorage.setItem(io,JSON.stringify(s))}catch{return s}return s}function Jw(e){const t=Bn().filter(s=>s!==e);try{localStorage.setItem(io,JSON.stringify(t))}catch{return t}return t}const Ui=e=>/^\d/.test(e),Zw=(e,t)=>{const s=Ui(e),r=Ui(t);return s&&!r?-1:!s&&r?1:e.localeCompare(t,void 0,{sensitivity:"base",numeric:!0})};function ej(e,t,s){const r=[],a=[];for(const o of e)t.has(o.mailboxId)?r.push(o):a.push(o);return a.sort((o,i)=>Zw(bs(o,void 0,s),bs(i,void 0,s))),{system:r,labels:a}}function tj(e,t,s){const r=Ef(t)&&e.unseenCount>0;return{id:e.mailboxId,name:bs(e,t,s),unseen:r?e.unseenCount:void 0,role:t,fullPath:e.fullPath}}function sj(){const e=Zn(),t=va({strict:!1});return e.pathname.startsWith("/settings")?"settings":e.pathname.startsWith("/mail/outbox")?"outbox":e.pathname.startsWith("/mail/flagged")?"flagged":t.mailboxId?t.mailboxId:e.pathname==="/mail"||e.pathname==="/mail/"?"brief":""}function qi({accounts:e,onMailboxSelect:t,variant:s="desktop"}){const r=we(),a=Oe(),o=sj(),{searchInput:i,onSearchChange:l}=Ce(),[u,f]=c.useState(Bn),{t:d}=Un("mail",{useSuspense:!1}),m=c.useCallback((k,R)=>d(k,{defaultValue:R}),[d]),h=Lt({queries:e.map(k=>({...ze({path:{accountId:k.accountId}}),staleTime:1/0}))}),{data:g}=de(qn()),b=c.useMemo(()=>(g?.items??[]).filter(k=>vd(k.status)).length,[g?.items]),p=c.useMemo(()=>e.map((k,R)=>{const O=h[R],D=O?.data?.items??[],P=Gs(k.folderAppointments),{system:I,labels:S}=ej(D,P,m),A=O?.isError?"error":O?.isLoading?"loading":"ready";return{id:k.accountId,label:k.email,email:k.email,muted:!!k.muted,outboxPending:b,status:A,onRetry:()=>O?.refetch(),mailboxes:[...I,...S].map(L=>tj(L,P.get(L.mailboxId),m))}}),[e,h,b,m]),v=k=>{r.invalidateQueries({queryKey:ya({path:{mailboxId:k},query:{order:"desc"}})})},x=({navId:k,className:R,ariaLabel:O,title:D,children:P,onClick:I})=>k==="brief"?n.jsx(pt,{to:"/mail",search:{q:void 0,selectedMessageId:void 0},onClick:()=>I?.(),className:R,"aria-label":O,title:D,children:P}):k==="outbox"?n.jsx(pt,{to:"/mail/outbox",search:{q:void 0,selectedOutboxMessageId:void 0},onClick:()=>I?.(),className:R,"aria-label":O,title:D,children:P}):k==="flagged"?n.jsx(pt,{to:"/mail/flagged",search:{q:void 0,selectedMessageId:void 0},onClick:()=>I?.(),className:R,"aria-label":O,title:D,children:P}):k==="settings"?n.jsx(pt,{to:"/settings/accounts",onClick:()=>I?.(),className:R,"aria-label":O,title:D,children:P}):n.jsx(pt,{to:"/mail/$mailboxId",params:{mailboxId:k},search:{q:void 0,selectedMessageId:void 0},onClick:()=>{v(k),I?.()},className:R,"aria-label":O,title:D,children:P}),y=()=>{l(""),t?.()},j=i.trim(),w=j.length>0&&!u.includes(j)?j:void 0,N=c.useCallback(()=>{w&&f(Xw(w))},[w]),E=c.useCallback(k=>{f(Jw(k))},[]),C=c.useCallback(k=>{l(k),a({to:"/mail",search:{q:k,selectedMessageId:void 0}}),t?.()},[l,a,t]);return n.jsx(Qh,{accounts:p,selectedNavId:o,onSelectNav:y,linkComponent:x,variant:s,savedSearches:u,saveableQuery:w,onSaveCurrentSearch:N,onSelectSavedSearch:C,onRemoveSavedSearch:E})}function nj({accounts:e,onMailboxSelect:t}){return Ss()?.showNavPane??!0?n.jsx(qi,{accounts:e}):n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(qi,{accounts:e,onMailboxSelect:t,variant:"drawer"})}),n.jsxs("div",{className:"border-t border-line px-2 py-2",children:[n.jsxs(pt,{to:"/settings/accounts",onClick:t,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg",children:[n.jsx(Da,{className:"size-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate text-left",children:"Settings"})]}),n.jsx(Ec,{variant:"drawer"}),n.jsx(Nc,{children:({signOut:a})=>n.jsxs("button",{type:"button",onClick:()=>{t?.(),a()},className:"flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-muted transition-colors hover:bg-surface hover:text-fg","data-testid":"sign-out-button",children:[n.jsx(Bl,{className:"size-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate text-left",children:"Sign out"})]})})]})]})}function rj(e,t){const s=t.trim().toLowerCase();if(s.length===0)return!0;const r=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(a=>typeof a=="string").join(" ").toLowerCase();return s.split(/\s+/).every(a=>a.length===0||r.includes(a))}function aj(e){return e.tokens.length>0&&e.freeText.trim().length===0}const yd={queued:{icon:Ea,label:"Queued",className:"text-warning"},sending:{icon:st,label:"Sending…",className:"text-accent-2"},sent:{icon:$l,label:"Sent",className:"text-positive"},failed:{icon:Gt,label:"Failed",className:"text-danger"},blocked:{icon:da,label:"Blocked",className:"text-warning"}},oj=e=>qf(e).toDateString()===new Date().toDateString()?Pn(e,{hour:"numeric",minute:"2-digit"}):Pn(e,{month:"short",day:"numeric"}),Hi=e=>Pn(e,{dateStyle:"medium",timeStyle:"short"}),ij=e=>{const t=e.toAddresses??[];return t.length===0?"No recipients":t.length===1?t[0]:`${t[0]} +${t.length-1}`},wd=(e,t)=>t?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",jd=c.createContext(null);function lo(){const e=c.useContext(jd);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function lj({children:e}){const t=Oe(),{selectedOutboxMessageId:s}=vs({strict:!1}),{data:r,isLoading:a}=de(qn()),{searchQuery:o}=Ce(),i=Is(),l=Za(o),u=Ts(l,i),f=l.length>0,d=aj(u),m=c.useMemo(()=>d?[]:(r?.items??[]).filter(p=>vd(p.status)).filter(p=>rj(p,u.freeText)),[r,u.freeText,d]),h=c.useMemo(()=>m.find(p=>p.outboxMessageId===s),[m,s]),g=c.useCallback(p=>{t({to:"/mail/outbox",search:v=>({...v,selectedOutboxMessageId:p})})},[t]),b={messages:m,hasQuery:f,unsupportedQuery:d,isLoading:a,selectedMessageId:s,selectedMessage:h,onSelectMessage:g};return n.jsx(jd.Provider,{value:b,children:e})}function Sd({message:e,isSelected:t,onSelect:s}){const r=we(),{openCompose:a}=Mt(),{pushError:o}=Je(),i=c.useCallback(()=>{r.invalidateQueries({queryKey:Sa()})},[r]),l=ye({...al(),onSuccess:i,onError:m=>{o(Vt("Couldn't resend message","The message wasn't sent.",m))}}),u=ye({...Hn(),onSuccess:i,onError:m=>{o(Vt("Couldn't delete message","The message wasn't deleted.",m))}}),f=e.status;if(!yd[f])return null;const d=bd(e.status);return n.jsx(wp,{recipients:ij(e),subject:e.subject||"",time:oj(e.sentAt??e.updatedAt),status:f,error:d?e.lastError??void 0:void 0,selected:t,onSelect:s,onRetry:f==="failed"?()=>l.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:l.isPending,onEdit:()=>a({mode:"new",outboxMessageId:e.outboxMessageId}),onDelete:()=>u.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:u.isPending})}function kd({message:e,onBack:t}){const s=e.status,r=yd[s],a=r?.icon??Ys,o=e.sentAt?Hi(e.sentAt):Hi(e.updatedAt);return n.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[n.jsxs("div",{className:"border-b border-line p-4",children:[t&&n.jsxs("button",{type:"button",onClick:t,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[n.jsx(Pl,{className:"size-4"}),n.jsx("span",{children:"Back"})]}),n.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),n.jsxs("div",{className:"space-y-1 text-sm",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),n.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),n.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),n.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),n.jsx("span",{className:"text-fg",children:o})]}),r&&n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(a,{className:xe("size-4",r.className,s==="sending"&&"animate-spin")}),n.jsx("span",{className:xe("text-xs font-medium",r.className),children:r.label}),bd(e.status)&&e.lastError&&n.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),n.jsx("div",{className:"p-4",children:n.jsx(yu,{html:e.htmlBody,text:e.textBody})})]})}function cj(){const{messages:e,hasQuery:t,unsupportedQuery:s,isLoading:r,selectedMessageId:a,onSelectMessage:o}=lo(),i=c.useRef(null);return Kn({containerRef:i,itemSelector:oa}),r?n.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:n.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?n.jsx("div",{className:"flex h-full bg-surface",children:n.jsx(Ns,{message:wd(t,s),showHints:!1})}):n.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx(oo,{}),n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),n.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),n.jsx("div",{ref:i,className:"flex-1 overflow-y-auto",children:e.map(l=>n.jsx(Sd,{message:l,isSelected:a===l.outboxMessageId,onSelect:()=>o(l.outboxMessageId)},l.outboxMessageId))})]})}function uj(){const{selectedMessage:e}=lo();return n.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[n.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?n.jsx(kd,{message:e}):n.jsx(Ns,{message:"Select a message to read",showHints:!1})})]})}function dj(){const{messages:e,hasQuery:t,unsupportedQuery:s,isLoading:r,selectedMessageId:a,selectedMessage:o,onSelectMessage:i}=lo(),l=c.useRef(null);return Kn({containerRef:l,itemSelector:oa}),r?n.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:n.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):o?n.jsx(kd,{message:o,onBack:()=>i(void 0)}):e.length===0?n.jsx("div",{className:"flex h-full bg-surface",children:n.jsx(Ns,{message:wd(t,s),showHints:!1})}):n.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx(oo,{}),n.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),n.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),n.jsx("div",{ref:l,className:"flex-1 overflow-y-auto",children:e.map(u=>n.jsx(Sd,{message:u,isSelected:a===u.outboxMessageId,onSelect:()=>i(u.outboxMessageId)},u.outboxMessageId))})]})}const In=Object.assign(lj,{List:cj,Reading:uj,Phone:dj}),fj=({isOpen:e,onClose:t})=>{const s=c.useCallback(r=>{r.key==="Escape"&&(r.preventDefault(),t())},[t]);return c.useEffect(()=>{if(e)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,s]),e?n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",onClick:t,onKeyDown:r=>r.key==="Escape"&&t(),children:[n.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm"}),n.jsxs("div",{className:xe("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),onClick:r=>r.stopPropagation(),onKeyDown:r=>{r.key!=="Escape"&&r.stopPropagation()},children:[n.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),n.jsx("button",{type:"button",onClick:t,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:n.jsx(We,{className:"size-5"})})]}),n.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:Lc.map(r=>n.jsxs("div",{children:[n.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:r.title}),n.jsx("div",{className:"space-y-2",children:r.hints.map(a=>n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx("span",{className:"text-sm",children:a.description}),n.jsx("span",{className:"flex shrink-0 items-center gap-1",children:a.keys.map((o,i)=>n.jsxs(c.Fragment,{children:[i>0&&a.keys[0]==="g"&&n.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),n.jsx(ps,{children:o})]},o))})]},`${a.action}-${a.keys.join("+")}`))})]},r.title))}),n.jsx("div",{className:"mt-6 border-t border-line pt-4",children:n.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",n.jsx(ps,{children:"Esc"})," to close"]})})]})]}):null};function mj(e){const t=new Map;for(const s of e){const r=s.email.toLowerCase(),a=r.split("@")[0];a&&!t.has(a)&&t.set(a,s.accountId),t.has(r)||t.set(r,s.accountId)}return t}function hj(e){const t=new Map;for(const s of e)for(const r of s){const a=r.fullPath?.toLowerCase();if(!a)continue;const o=a.split("/").pop();t.has(a)||t.set(a,r.mailboxId),o&&!t.has(o)&&t.set(o,r.mailboxId)}return t}function pj(e){const t=Lt({queries:e.map(s=>({...ze({path:{accountId:s.accountId}}),staleTime:1/0}))});return c.useMemo(()=>hj(t.map(s=>s.data?.items??[])),[t])}const gj=e=>e.map(t=>t.data?.items??[]);function xj(e){const t=Lt({queries:e.map(s=>({...ze({path:{accountId:s.accountId}}),staleTime:1/0})),combine:gj});return c.useMemo(()=>If(e.map((s,r)=>({folderAppointments:s.folderAppointments,mailboxes:t[r]??[]}))),[e,t])}var Tn={exports:{}},Wi;function bj(){if(Wi)return Tn.exports;Wi=1;const e=(t,s,r)=>new Promise((a,o)=>{if(r=Object.assign({concurrency:1/0},r),typeof s!="function")throw new TypeError("Mapper function is required");const{concurrency:i}=r;if(!(typeof i=="number"&&i>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${i}\` (${typeof i})`);const l=[],u=t[Symbol.iterator]();let f=!1,d=!1,m=0,h=0;const g=()=>{if(f)return;const b=u.next(),p=h;if(h++,b.done){d=!0,m===0&&a(l);return}m++,Promise.resolve(b.value).then(v=>s(v,p)).then(v=>{l[p]=v,m--,g()},v=>{f=!0,o(v)})};for(let b=0;b<i&&(g(),!d);b++);});return Tn.exports=e,Tn.exports.default=e,Tn.exports}var vj=bj();const yj=Tf(vj),wj=900*1e3,jj=300,Sj=(e,t)=>{if(!e)return t;const s=Number.parseInt(e,10);return Number.isFinite(s)&&s>0?s:t},kj=60*1e3,Cj=e=>Math.max(Sj(e,jj)*1e3,kj),On=Cj(Af().mailboxPollIntervalSeconds),Nj=5,ra=new Set,Ej=(e,t,s=wj)=>e.filter(r=>{const a=r.lastSyncAt;return a==null?!0:t-a>s}).map(r=>r.accountId),Ij=(e,t,s=On)=>e-t>=s,Tj=(e,t)=>e.filter(s=>!t.has(s)),Vi=(e,t)=>{if(ra.delete(e),Mf(t,{softError:!0})){fl(t);return}console.warn("[remit] background mailbox sync failed",{accountId:e,error:t})},Qi=(e,t)=>Rf({path:{accountId:e},throwOnError:!0}).then(()=>{t.invalidateQueries({queryKey:Jt({path:{accountId:e}})})}),Rj=e=>{const t=we(),s=c.useRef(e);s.current=e;const r=e.map(a=>a.accountId).join(",");c.useEffect(()=>{const a=Date.now(),i=Ej(s.current,a).filter(l=>!ra.has(l));if(i.length!==0)for(const l of i)ra.add(l),Qi(l,t).catch(u=>{Vi(l,u)})},[r,t]),c.useEffect(()=>{let a=Date.now(),o;const i=new Set,l=()=>{a=Date.now();const d=Tj(s.current.map(m=>m.accountId),i);for(const m of d)i.add(m);yj(d,m=>Qi(m,t).catch(h=>{Vi(m,h)}).finally(()=>{i.delete(m)}),{concurrency:Nj})},u=()=>{if(document.visibilityState==="visible"){l(),o=setTimeout(u,On);return}},f=()=>{document.visibilityState==="visible"&&Ij(Date.now(),a)&&(o!==void 0&&clearTimeout(o),l(),o=setTimeout(u,On))};return o=setTimeout(u,On),document.addEventListener("visibilitychange",f),()=>{o!==void 0&&clearTimeout(o),document.removeEventListener("visibilitychange",f)}},[r,t])};function Mj(e,t,s){if(e!==t)return s}function Aj(e,t){return e===""?"":t}function Dj(e,t,s){return t!==e?!1:t!==s}function Oj(){const{q:e=""}=vs({from:"/mail"}),t=Oe(),s=or(),r=Tu(s),[a,o]=c.useState(!1),[i,l]=c.useState(!1),[u,f]=c.useState(!1),d=c.useCallback(te=>{f(te),Ki(te)},[]),[m,h]=c.useState(e),g=hl(m,200),b=Aj(m,g),p=c.useRef(e);p.current=e;const v=gt({select:te=>Fx(te.matches)}),[x,y]=c.useState(v);if(x!==v){const te=Mj(x,v,e);y(v),te!==void 0&&h(te)}c.useEffect(()=>{Dj(m,b,p.current)&&t({to:".",search:te=>{const U=te.q===b;return{...te,q:b||void 0,...b&&!U?{selectedMessageId:void 0,selectedThreadId:void 0,selectedMailboxId:void 0}:{}}},replace:!0})},[m,b,t]);const{data:j,isLoading:w,isError:N,error:E,refetch:C}=de({...xt(),staleTime:1/0}),k=!!(j&&(j.accounts?.length??0)===0);c.useEffect(()=>{k&&t({to:"/onboarding",replace:!0})},[k,t]),qa({enabled:!a,bindings:[{key:"?",handler:()=>o(!0),noModifiers:!1,preventDefault:!0}]});const R=c.useCallback(te=>{h(te)},[]),O=c.useCallback(()=>{h("")},[]),D=c.useCallback(()=>{h("")},[]),P=c.useCallback(()=>{f(te=>{const U=!te;return Ki(U),U})},[]),I=j?.accounts??[],S=pj(I),A=xj(I),L=c.useMemo(()=>mj(I),[I]),T=gt({select:te=>te.matches.find(H=>"mailboxId"in H.params)?.params.mailboxId}),{selectedMessageId:F}=vs({strict:!1}),M=gt({select:te=>Ba(te.matches)}),$=gt({select:te=>rn(te.matches)}),K=gt({select:te=>er(te.matches)});Rj(I);const B=c.useCallback(()=>{l(!1)},[]),J={accounts:I,mailboxNameIndex:S,accountNameIndex:L,resultFolderIndex:A,searchQuery:b,searchInput:m,searchViewKey:v,onSearchChange:R,onSearchClear:O,onSearchClearQuery:D,intelligenceOpen:u,onToggleIntelligence:P,onSetIntelligenceOpen:d},ee=n.jsx(nj,{accounts:I,onMailboxSelect:B}),X=r?n.jsx(Px,{accounts:I}):void 0,me=r?void 0:n.jsx(Wx,{accounts:I}),ue={navOpen:i,onOpenNav:()=>l(!0),onCloseNav:()=>l(!1)};return n.jsxs(Df.Provider,{value:J,children:[N?n.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:n.jsx(Dt,{title:"Couldn't load your account",error:E,onRetry:()=>{C()}})}):M?n.jsx($s,{selectedMessageId:F,children:r?n.jsx(jt,{nav:ee,list:n.jsx($s.Phone,{}),intelligenceOpen:u,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue}):n.jsx(jt,{nav:ee,topBar:me,list:n.jsx($s.List,{}),reading:n.jsx($s.Reading,{}),intelligence:n.jsx($s.Intelligence,{}),intelligenceOpen:u,hasThread:!!F,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue})}):$?n.jsx(Fs,{selectedMessageId:F,children:r?n.jsx(jt,{nav:ee,list:n.jsx(Fs.Phone,{}),intelligenceOpen:u,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue}):n.jsx(jt,{nav:ee,topBar:me,list:n.jsx(Fs.List,{}),reading:n.jsx(Fs.Reading,{}),intelligence:n.jsx(Fs.Intelligence,{}),intelligenceOpen:u,hasThread:!!F,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue})}):T?n.jsx(_s,{mailboxId:T,selectedMessageId:F,children:r?n.jsx(jt,{nav:ee,list:n.jsx(_s.Phone,{}),intelligenceOpen:u,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue}):n.jsx(jt,{nav:ee,topBar:me,list:n.jsx(_s.List,{}),reading:n.jsx(_s.Reading,{}),intelligence:n.jsx(_s.Intelligence,{}),intelligenceOpen:u,hasThread:!!F,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue})}):K?n.jsx(In,{children:r?n.jsx(jt,{nav:ee,list:n.jsx(In.Phone,{}),intelligenceOpen:!1,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue}):n.jsx(jt,{nav:ee,topBar:me,list:n.jsx(In.List,{}),reading:n.jsx(In.Reading,{}),intelligenceOpen:!1,overlay:X,skeleton:n.jsx(ht,{}),isLoading:w||k,...ue})}):n.jsx(ht,{}),n.jsx(fj,{isOpen:a,onClose:()=>o(!1)}),n.jsx(Of,{})]})}const Xj=Object.freeze(Object.defineProperty({__proto__:null,component:Oj,useMailContext:Ce},Symbol.toStringTag,{value:"Module"}));export{Gj as S,Um as U,Xj as m};