@remit/web-client-dist 0.0.379 → 0.0.381

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 (116) hide show
  1. package/assets/{BriefPane-d4hLRBF7.js → BriefPane-pPxpoBvo.js} +1 -1
  2. package/assets/{ErrorState-sMiooGSA.js → ErrorState-C1M66eLl.js} +1 -1
  3. package/assets/{FlaggedPane-B4ZKvyqX.js → FlaggedPane-CVEL3dSv.js} +1 -1
  4. package/assets/{FullCompose-DoaJGxI4.js → FullCompose-Dxa6ZR8u.js} +1 -1
  5. package/assets/MailListHeader-CqEQzbdu.js +7 -0
  6. package/assets/{MailViewChrome-fsejaQTD.js → MailViewChrome-Ctw7cdnR.js} +1 -1
  7. package/assets/MailboxPane-D27Tg1rD.js +1 -0
  8. package/assets/{NavMenuButton-CXZJUaOT.js → NavMenuButton-DfW1H6aU.js} +1 -1
  9. package/assets/{OnboardingWizard-C30-TeDT.js → OnboardingWizard-BHoib2d0.js} +1 -1
  10. package/assets/{OutboxPane-BNcMvFQH.js → OutboxPane-C1JJZ3O8.js} +1 -1
  11. package/assets/_mailboxId-DqsMhRRt.js +1 -0
  12. package/assets/_messageId-BbRCun7m.js +1 -0
  13. package/assets/_messageId-DPWTeebA.js +1 -0
  14. package/assets/_messageId-JXdSCEJ7.js +1 -0
  15. package/assets/_outboxMessageId-BbPyEvLt.js +1 -0
  16. package/assets/_threadId-BR--aLeK.js +1 -0
  17. package/assets/_threadId-BgVfkr4j.js +1 -0
  18. package/assets/_threadId-Cdq13pLV.js +1 -0
  19. package/assets/{accounts-DKcQF1SN.js → accounts-9DfWemQE.js} +1 -1
  20. package/assets/{advanced-Ba5NBBJk.js → advanced-Da7Haef2.js} +1 -1
  21. package/assets/{appearance-DmXGGxCd.js → appearance-Cu01X2cP.js} +1 -1
  22. package/assets/{attachment-file-BeSnYdmP.js → attachment-file-BsIFxUnS.js} +1 -1
  23. package/assets/{avatar-Db3yTewv.js → avatar-BosRyUDx.js} +1 -1
  24. package/assets/{bottom-sheet-Bub8PuiK.js → bottom-sheet-DcSSB9VN.js} +1 -1
  25. package/assets/{brief-BwpPLSvI.js → brief-9ppayR6t.js} +1 -1
  26. package/assets/brief-CnxjQNC8.js +1 -0
  27. package/assets/{browser-ponyfill-B8zHv7ZE.js → browser-ponyfill-J8RE5Xz2.js} +2 -2
  28. package/assets/{bug-BxqG9-bt.js → bug-Dp2Hzou6.js} +1 -1
  29. package/assets/{circle-check-BoKYTqSx.js → circle-check-PX98a4WV.js} +1 -1
  30. package/assets/{circle-check-big-BxRN0KrW.js → circle-check-big-332iqzog.js} +1 -1
  31. package/assets/{circle-help-D_lNt5d7.js → circle-help-CA3mJ370.js} +1 -1
  32. package/assets/{clock-ClbrSNTJ.js → clock-D_rv0tCB.js} +1 -1
  33. package/assets/compose._-_outboxMessageId_-B32NbToI.js +1 -0
  34. package/assets/compose._-_outboxMessageId_-BR9g4uXi.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CvuyTn91.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-gBK7x3Ih.js +1 -0
  37. package/assets/{confirm-dialog-C5ziM6Eg.js → confirm-dialog-Cj58-8wR.js} +1 -1
  38. package/assets/{download-D-8Dl5Uz.js → download-DJvO67nu.js} +1 -1
  39. package/assets/{filters-COteEmYB.js → filters-DtabYDCh.js} +1 -1
  40. package/assets/{flagged-BbQ_u9YJ.js → flagged-DEaJ9F9E.js} +1 -1
  41. package/assets/flagged-QyGEaEHA.js +1 -0
  42. package/assets/{folders-BFFXEq2P.js → folders-Sz7c27v6.js} +1 -1
  43. package/assets/{index-COgYNcrI.js → index-BBlkR2lm.js} +4 -4
  44. package/assets/index-BbRCun7m.js +1 -0
  45. package/assets/index-CITqA9GW.js +1 -0
  46. package/assets/index-CioepYEa.js +1 -0
  47. package/assets/index-DOM5Vq2Y.js +1 -0
  48. package/assets/index-DPWTeebA.js +1 -0
  49. package/assets/index-DgY7oj0G.js +1 -0
  50. package/assets/{index-0PwAlq3y.js → index-DpWfLpb7.js} +3 -3
  51. package/assets/index-DqjfWRpI.js +1 -0
  52. package/assets/index-DzZ7bpbe.js +1 -0
  53. package/assets/{kbd-BUbgeaI4.js → kbd-SiNO_Aua.js} +1 -1
  54. package/assets/{labels-BI0i9mSN.js → labels-Bh5ul3xb.js} +1 -1
  55. package/assets/{mail-Dtw_oNuw.js → mail-BsugoFoQ.js} +1 -1
  56. package/assets/mail-CDmV61sd.js +1 -0
  57. package/assets/{menu-BwTBBgqW.js → menu-BtHNv3F8.js} +1 -1
  58. package/assets/{move-options-DVSXaJim.js → move-options-BOLumMSr.js} +1 -1
  59. package/assets/{onboarding-2rfGU7rJ.js → onboarding-D-OrljoR.js} +1 -1
  60. package/assets/outbox-BPJcsdsu.js +1 -0
  61. package/assets/{pencil-__xMEbiU.js → pencil-CjU_Ekj6.js} +1 -1
  62. package/assets/{rich-text-Cm9ktdKu.js → rich-text-DmtTFEdn.js} +1 -1
  63. package/assets/{rich-text-spellcheck-worker-provider-Dbq1dKQG.js → rich-text-spellcheck-worker-provider-C2sJO4MH.js} +1 -1
  64. package/assets/{rotate-ccw-COGpe9I5.js → rotate-ccw-qUu8sNqY.js} +1 -1
  65. package/assets/{row-actions-BgziRTxR.js → row-actions-DhmbyA2V.js} +1 -1
  66. package/assets/{search-scope-CTXygnZh.js → search-scope-BvS1pMa6.js} +1 -1
  67. package/assets/{search-token-index-aGO9rXGI.js → search-token-index-jGvf0dJ0.js} +1 -1
  68. package/assets/search-view-H09w67ZC.js +1 -0
  69. package/assets/{senders-By7IOTab.js → senders-Bb-8mua8.js} +1 -1
  70. package/assets/settings-jx03ah89.js +1 -0
  71. package/assets/{settings-screen-DcLEPLjv.js → settings-screen-DhcpD_Eu.js} +1 -1
  72. package/assets/{shield-check-DJh_9kf_.js → shield-check-D3e9FJOA.js} +1 -1
  73. package/assets/{suggested-vips-CrVI4Oob.js → suggested-vips-CGUr8fR1.js} +1 -1
  74. package/assets/{useDebouncedValue-BPC6e9sF.js → useDebouncedValue-Bvs_pdKk.js} +1 -1
  75. package/assets/{useFilters-CUlEAEYH.js → useFilters-BDf4e7fG.js} +1 -1
  76. package/assets/{useLabels-C-gzdGpn.js → useLabels-C_Ccg2bp.js} +1 -1
  77. package/assets/{useMediaQuery-DgtQoWHg.js → useMediaQuery-fCnkE4fe.js} +1 -1
  78. package/assets/useMessageBodyContent-1l9msTY_.js +1 -0
  79. package/assets/useRefreshControl-DSz_548v.js +1 -0
  80. package/assets/useSearchMirror-DnymUkKH.js +1 -0
  81. package/assets/{useSearchTokenContext-xo_oKJ65.js → useSearchTokenContext-DqJZZd-6.js} +1 -1
  82. package/assets/{useSemanticSearch-D5g9sUXF.js → useSemanticSearch-C_xD58fg.js} +1 -1
  83. package/assets/{useSignature-DpjLMD5u.js → useSignature-T_jnc_Ys.js} +1 -1
  84. package/index.html +1 -1
  85. package/package.json +1 -1
  86. package/assets/MailListHeader-_wXpu2b0.js +0 -7
  87. package/assets/MailboxPane-Cfu2YE3-.js +0 -1
  88. package/assets/_mailboxId-DqPnEmmA.js +0 -1
  89. package/assets/_messageId-CpDhDemb.js +0 -1
  90. package/assets/_messageId-D8x2sKoO.js +0 -1
  91. package/assets/_messageId-Y8dUMAz9.js +0 -1
  92. package/assets/_outboxMessageId--C4NbN3a.js +0 -1
  93. package/assets/_threadId-BcUE7nfY.js +0 -1
  94. package/assets/_threadId-d2dmfvef.js +0 -1
  95. package/assets/_threadId-mgi_Fyvl.js +0 -1
  96. package/assets/brief-Dp31yv2Q.js +0 -1
  97. package/assets/compose._-_outboxMessageId_-BSb9N4dE.js +0 -1
  98. package/assets/compose._-_outboxMessageId_-D6y_IGhM.js +0 -1
  99. package/assets/compose._-_outboxMessageId_-KwKBQ-ef.js +0 -1
  100. package/assets/compose._-_outboxMessageId_-dBFS6VCY.js +0 -1
  101. package/assets/flagged-BTZtXGG5.js +0 -1
  102. package/assets/index-B59pkCty.js +0 -1
  103. package/assets/index-CeuGkzEs.js +0 -1
  104. package/assets/index-D8x2sKoO.js +0 -1
  105. package/assets/index-DAeduM5o.js +0 -1
  106. package/assets/index-DZOnMOQB.js +0 -1
  107. package/assets/index-Y8dUMAz9.js +0 -1
  108. package/assets/index-aeIICjJ-.js +0 -1
  109. package/assets/index-beerbb12.js +0 -1
  110. package/assets/mail-C-K9xNV9.js +0 -1
  111. package/assets/outbox-CPVmggmA.js +0 -1
  112. package/assets/search-view-Lna0m2Oy.js +0 -1
  113. package/assets/settings-trC1lJFR.js +0 -1
  114. package/assets/useMessageBodyContent-5laqpHgz.js +0 -1
  115. package/assets/useRefreshControl-XhDXg14G.js +0 -1
  116. package/assets/useSearchMirror--35nODM-.js +0 -1
@@ -0,0 +1,7 @@
1
+ import{a4 as bs,ca as hr,r as l,c as ie,j as a,C as mt,d as Dn,B as H,X as Ft,at as Te,cb as Fn,b as z,a as Ye,S as We,aT as gr,cc as br,ag as Ot,T as zt,cd as On,a_ as xs,ce as xr,cf as zn,an as vr,af as _n,e as yr,cg as kr,as as Un,ch as jr,ci as wr,cj as Cr,ck as Sr,cl as Nr,cm as Tr,cn as Er,co as Mr,G as Ir,s as te,cp as _t,Q as xt,q as vt,z as Kn,bf as Bn,cq as Qn,n as ae,a5 as ke,a7 as de,K as Xe,bn as Me,cr as Ut,c1 as Rr,cs as Ie,ct as Ar,cu as $r,cv as Lr,cw as Pr,cx as Dr,bN as Fr,cy as Or,p as zr,aU as _r,m as qn,aF as Ur,aG as Kr,bU as Br,k as Qr,bT as qr,cz as Hr,cA as Gr,cB as Hn,b6 as vs,bs as Vr,bj as Qs,cC as Wr,cD as Yr,b5 as Xr,N as Jr,W as Zr,D as eo,bg as qs,aY as to,cE as so,cF as no,a8 as Hs,be as ao,cG as ro,cH as oo,l as ys,cI as io,cJ as lo,cK as Gs,cL as co,cM as uo,cN as fo,cO as ks,i as mo,cP as po,bV as ho,cQ as go,cR as Vs,g as bo,bW as xo}from"./index-BBlkR2lm.js";import{B as vo,l as yo,m as ko,S as Gn,c as js,f as jo,D as wo,b as It,a as Co,t as ct,g as So,n as No,o as To,e as Eo,u as Mo,i as Io}from"./search-token-index-jGvf0dJ0.js";import{K as Ro}from"./kbd-SiNO_Aua.js";import{P as Vn,f as Ao,U as $o,E as Lo,s as Po}from"./attachment-file-BsIFxUnS.js";import{M as Do}from"./mail-BsugoFoQ.js";import{A as pt}from"./avatar-BosRyUDx.js";import{M as Fo,c as Oo,d as Wn,e as zo,f as Yn,g as Xn,a as _o,b as Uo,S as Ws,s as Jn,u as Zn,p as Ko,r as Bo}from"./useSearchTokenContext-DqJZZd-6.js";import{v as Qo,w as qo,o as Ho,x as Go,y as Vo,p as Wo,N as ea,b as Yo}from"./useMessageBodyContent-1l9msTY_.js";import{C as Xo,D as qe,u as Jo}from"./index-DpWfLpb7.js";import{E as _e}from"./ErrorState-C1M66eLl.js";import{u as ws}from"./useMediaQuery-fCnkE4fe.js";import{e as ta,b as Je,a as Zo,c as Ue,g as ei}from"./format-HasNd5qT.js";import{P as Ys,C as ti,D as Xs,M as ye}from"./enums-CCxx0t2v.js";import{D as si}from"./download-DJvO67nu.js";import{S as ni}from"./shield-check-D3e9FJOA.js";import{u as sa}from"./useDebouncedValue-Bvs_pdKk.js";import{a as na,u as aa,b as ra,f as oa}from"./move-options-BOLumMSr.js";import{h as Js,u as ai,a as ri,i as oi,n as ii,o as li,j as ci,k as ui,S as di}from"./useFilters-BDf4e7fG.js";import{C as fi}from"./confirm-dialog-Cj58-8wR.js";import{C as mi}from"./clock-D_rv0tCB.js";import{r as pi,b as hi}from"./search-scope-BvS1pMa6.js";import{M as gi}from"./menu-BtHNv3F8.js";function ht(e){if(bi())e.focus({preventScroll:!0});else{let t=xi(e);e.focus(),vi(t)}}let Rt=null;function bi(){if(Rt==null){Rt=!1;try{document.createElement("div").focus({get preventScroll(){return Rt=!0,!0}})}catch{}}return Rt}function xi(e){let t=e.parentNode,s=[],n=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==n;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&s.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return n instanceof HTMLElement&&s.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft}),s}function vi(e){for(let{element:t,scrollTop:s,scrollLeft:n}of e)t.scrollTop=s,t.scrollLeft=n}const Ne=e=>e?.ownerDocument??document,Ee=e=>e&&"window"in e&&e.window===e?e:Ne(e).defaultView||window;function yi(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function ki(e){return yi(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let ji=!1;function ia(){return ji}function pe(e,t){if(!ia())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:ki(s)?s=s.host:s=s.parentNode}return!1}function ee(e){if(ia()&&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 wi=typeof Element<"u"&&"checkVisibility"in Element.prototype;function Ci(e){const t=Ee(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:s,visibility:n}=e.style,r=s!=="none"&&n!=="hidden"&&n!=="collapse";if(r){const{getComputedStyle:o}=Ee(e);let{display:i,visibility:c}=o(e);r=i!=="none"&&c!=="hidden"&&c!=="collapse"}return r}function Si(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 la(e,t){return wi?e.checkVisibility({visibilityProperty:!0})&&!e.closest("[data-react-aria-prevent-focus]"):e.nodeName!=="#comment"&&Ci(e)&&Si(e,t)&&(!e.parentElement||la(e.parentElement,e))}const ca=["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"],Ni=ca.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])";ca.push('[tabindex]:not([tabindex="-1"]):not([disabled])');function Ti(e,t){return e.matches(Ni)&&!Ei(e)&&(t?.skipVisibilityCheck||la(e))}function Ei(e){let t=e;for(;t!=null;){if(t instanceof Ee(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}const Cs=typeof document<"u"?bs.useLayoutEffect:()=>{};function Mi(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Ii(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Ri(e){for(;e&&!Ti(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=Ee(e),s=t.document.activeElement;if(!s||s===e)return;let n=!1,r=h=>{(ee(h)===s||n)&&h.stopImmediatePropagation()},o=h=>{(ee(h)===s||n)&&(h.stopImmediatePropagation(),!e&&!n&&(n=!0,ht(s),u()))},i=h=>{(ee(h)===e||n)&&h.stopImmediatePropagation()},c=h=>{(ee(h)===e||n)&&(h.stopImmediatePropagation(),n||(n=!0,ht(s),u()))};t.addEventListener("blur",r,!0),t.addEventListener("focusout",o,!0),t.addEventListener("focusin",c,!0),t.addEventListener("focus",i,!0);let u=()=>{cancelAnimationFrame(v),t.removeEventListener("blur",r,!0),t.removeEventListener("focusout",o,!0),t.removeEventListener("focusin",c,!0),t.removeEventListener("focus",i,!0),n=!1},v=requestAnimationFrame(u);return u}function Kt(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 Ss(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function Re(e){let t=null;return()=>(t==null&&(t=e()),t)}const Lt=Re(function(){return Ss(/^Mac/i)}),Ai=Re(function(){return Ss(/^iPhone/i)}),ua=Re(function(){return Ss(/^iPad/i)||Lt()&&navigator.maxTouchPoints>1}),da=Re(function(){return Ai()||ua()}),$i=Re(function(){return Kt(/AppleWebKit/i)&&!Li()}),Li=Re(function(){return Kt(/Chrome/i)}),fa=Re(function(){return Kt(/Android/i)}),Pi=Re(function(){return Kt(/Firefox/i)});function Di(e){return e.pointerType===""&&e.isTrusted?!0:fa()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Fi(e){return!fa()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}function gt(e,t,s=!0){let{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}=t;Pi()&&window.event?.type?.startsWith("key")&&e.target==="_blank"&&(Lt()?n=!0:r=!0);let c=$i()&&Lt()&&!ua()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:n,ctrlKey:r,altKey:o,shiftKey:i}):new MouseEvent("click",{metaKey:n,ctrlKey:r,altKey:o,shiftKey:i,detail:1,bubbles:!0,cancelable:!0});gt.isOpening=s,ht(e),e.dispatchEvent(c),gt.isOpening=!1}gt.isOpening=!1;let Se=new Map,is=new Set;function Zs(){if(typeof window>"u")return;function e(n){return"propertyName"in n}let t=n=>{let r=ee(n);if(!e(n)||!r)return;let o=Se.get(r);o||(o=new Set,Se.set(r,o),r.addEventListener("transitioncancel",s,{once:!0})),o.add(n.propertyName)},s=n=>{let r=ee(n);if(!e(n)||!r)return;let o=Se.get(r);if(o&&(o.delete(n.propertyName),o.size===0&&(r.removeEventListener("transitioncancel",s),Se.delete(r)),Se.size===0)){for(let i of is)i();is.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",s)}typeof document<"u"&&(document.readyState!=="loading"?Zs():document.addEventListener("DOMContentLoaded",Zs));function Oi(){for(const[e]of Se)"isConnected"in e&&!e.isConnected&&Se.delete(e)}function zi(e){requestAnimationFrame(()=>{Oi(),Se.size===0?e():is.add(e)})}function ma(...e){return(...t)=>{for(let s of e)typeof s=="function"&&s(...t)}}let ls=new Map;typeof FinalizationRegistry<"u"&&new FinalizationRegistry(e=>{ls.delete(e)});function _i(e,t){if(e===t)return e;let s=ls.get(e);if(s)return s.forEach(r=>r.current=t),t;let n=ls.get(t);return n?(n.forEach(r=>r.current=e),e):t}function Ui(...e){return e.length===1&&e[0]?e[0]:t=>{let s=!1;const n=e.map(r=>{const o=en(r,t);return s||=typeof o=="function",o});if(s)return()=>{n.forEach((r,o)=>{typeof r=="function"?r():en(e[o],null)})}}}function en(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yt(...e){let t={...e[0]};for(let s=1;s<e.length;s++){let n=e[s];for(let r in n){let o=t[r],i=n[r];typeof o=="function"&&typeof i=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=ma(o,i):(r==="className"||r==="UNSAFE_className")&&typeof o=="string"&&typeof i=="string"?t[r]=hr(o,i):r==="id"&&o&&i?t.id=_i(o,i):r==="ref"&&o&&i?t.ref=Ui(o,i):t[r]=i!==void 0?i:o}}return t}function Ki(e,t){Cs(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}const Bi=bs.useInsertionEffect??Cs;function Jt(e){const t=l.useRef(null);return Bi(()=>{t.current=e},[e]),l.useCallback((...s)=>{const n=t.current;return n?.(...s)},[])}let Ge="default",cs="",$t=new WeakMap;function Qi(e){if(da()){if(Ge==="default"){const t=Ne(e);cs=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}Ge="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";$t.set(e,e.style[t]),e.style[t]="none"}}function tn(e){if(da()){if(Ge!=="disabled")return;Ge="restoring",setTimeout(()=>{zi(()=>{if(Ge==="restoring"){const t=Ne(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=cs||""),cs="",Ge="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&$t.has(e)){let t=$t.get(e),s="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[s]==="none"&&(e.style[s]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),$t.delete(e)}}function sn(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}let Zt=new WeakMap;function qi(e){let t=e??(typeof document<"u"?document:void 0);if(!t)return sn(t);if(Zt.has(t))return Zt.get(t);let s=t.querySelector('meta[property="csp-nonce"]'),n=s&&s instanceof Ee(s).HTMLMetaElement&&(s.nonce||s.content)||sn(t)||void 0;return n!==void 0&&Zt.set(t,n),n}const pa=bs.createContext({register:()=>{}});pa.displayName="PressResponderContext";function ha(){let e=l.useRef(new Map),t=l.useCallback((r,o,i,c)=>{let u=c?.once?(...v)=>{e.current.delete(i),i(...v)}:i;e.current.set(i,{type:o,eventTarget:r,fn:u,options:c}),r.addEventListener(o,u,c)},[]),s=l.useCallback((r,o,i,c)=>{let u=e.current.get(i)?.fn||i;r.removeEventListener(o,u,c),e.current.delete(i)},[]),n=l.useCallback(()=>{e.current.forEach((r,o)=>{s(r.eventTarget,r.type,o,r.options)})},[s]);return l.useEffect(()=>n,[n]),{addGlobalListener:t,removeGlobalListener:s,removeAllGlobalListeners:n}}function Hi(e){let t=l.useContext(pa);if(t){let{register:s,ref:n,...r}=t;e=yt(r,e),s()}return Ki(t,e.ref),e}class At{#e;constructor(t,s,n,r){this.#e=!0;const i=(r?.target??n.currentTarget)?.getBoundingClientRect();let c,u=0,v,h=null;n.clientX!=null&&n.clientY!=null&&(v=n.clientX,h=n.clientY),i&&(v!=null&&h!=null?(c=v-i.left,u=h-i.top):(c=i.width/2,u=i.height/2)),this.type=t,this.pointerType=s,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=c,this.y=u,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}}const nn=Symbol("linkClicked"),an="react-aria-pressable-style",rn="data-react-aria-pressable";function Gi(e){let{onPress:t,onPressChange:s,onPressStart:n,onPressEnd:r,onPressUp:o,onClick:i,isDisabled:c,isPressed:u,preventFocusOnPress:v,shouldCancelOnPointerExit:h,allowTextSelectionOnPress:p,ref:f,...g}=Hi(e),[b,d]=l.useState(!1),m=l.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:x,removeAllGlobalListeners:C}=ha(),y=l.useCallback((k,I)=>{let A=m.current;if(c||A.didFirePressStart)return!1;let S=!0;if(A.isTriggeringEvent=!0,n){let E=new At("pressstart",I,k);n(E),S=E.shouldStopPropagation}return s&&s(!0),A.isTriggeringEvent=!1,A.didFirePressStart=!0,d(!0),S},[c,n,s]),j=l.useCallback((k,I,A=!0)=>{let S=m.current;if(!S.didFirePressStart)return!1;S.didFirePressStart=!1,S.isTriggeringEvent=!0;let E=!0;if(r){let w=new At("pressend",I,k);r(w),E=w.shouldStopPropagation}if(s&&s(!1),d(!1),t&&A&&!c){let w=new At("press",I,k);t(w),E&&=w.shouldStopPropagation}return S.isTriggeringEvent=!1,E},[c,r,s,t]),T=Jt(j),M=l.useCallback((k,I)=>{let A=m.current;if(c)return!1;if(o){A.isTriggeringEvent=!0;let S=new At("pressup",I,k);return o(S),A.isTriggeringEvent=!1,S.shouldStopPropagation}return!0},[c,o]),P=Jt(M),R=l.useCallback(k=>{let I=m.current;if(I.isPressed&&I.target){I.didFirePressStart&&I.pointerType!=null&&j(Oe(I.target,k),I.pointerType,!1),I.isPressed=!1,I.isOverTarget=!1,I.activePointerId=null,I.pointerType=null,C(),p||tn(I.target);for(let A of I.disposables)A();I.disposables=[]}},[p,C,j]),D=Jt(R);l.useEffect(()=>{c&&m.current.isPressed&&D({currentTarget:m.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[c]);let F=l.useCallback(k=>{h&&R(k)},[h,R]),_=l.useCallback(k=>{c||i?.(k)},[c,i]),L=l.useCallback((k,I)=>{if(!c&&i){let A=new MouseEvent("click",k);Ii(A,I),i(Mi(A))}},[c,i]),K=l.useMemo(()=>{let k=m.current,I={onKeyDown(S){if(es(S.nativeEvent,S.currentTarget)&&pe(S.currentTarget,ee(S))){on(ee(S),S.key)&&S.preventDefault();let E=!0;!k.isPressed&&!S.repeat&&(k.target=S.currentTarget,k.isPressed=!0,k.pointerType="keyboard",E=y(S,"keyboard"));let w=S.currentTarget,O=U=>{es(U,w)&&!U.repeat&&pe(w,ee(U))&&k.target&&P(Oe(k.target,U),"keyboard")};x(Ne(S.currentTarget),"keyup",ma(O,A),!0),E&&S.stopPropagation(),S.metaKey&&Lt()&&k.metaKeyEvents?.set(S.key,S.nativeEvent)}else S.key==="Meta"&&(k.metaKeyEvents=new Map)},onClick(S){if(!(S&&!pe(S.currentTarget,ee(S)))&&S&&S.button===0&&!k.isTriggeringEvent&&!gt.isOpening){let E=!0;if(c&&S.preventDefault(),!k.ignoreEmulatedMouseEvents&&!k.isPressed&&(k.pointerType==="virtual"||Di(S.nativeEvent))){let w=y(S,"virtual"),O=P(S,"virtual"),U=T(S,"virtual");_(S),E=w&&O&&U}else if(k.isPressed&&k.pointerType!=="keyboard"){let w=k.pointerType||S.nativeEvent.pointerType||"virtual",O=P(Oe(S.currentTarget,S),w),U=T(Oe(S.currentTarget,S),w,!0);E=O&&U,k.isOverTarget=!1,_(S),D(S)}k.ignoreEmulatedMouseEvents=!1,E&&S.stopPropagation()}}},A=S=>{if(k.isPressed&&k.target&&es(S,k.target)){on(ee(S),S.key)&&S.preventDefault();let E=ee(S),w=pe(k.target,E);T(Oe(k.target,S),"keyboard",w),w&&L(S,k.target),C(),S.key!=="Enter"&&Ns(k.target)&&pe(k.target,E)&&!S[nn]&&(S[nn]=!0,gt(k.target,S,!1)),k.isPressed=!1,k.metaKeyEvents?.delete(S.key)}else if(S.key==="Meta"&&k.metaKeyEvents?.size){let E=k.metaKeyEvents;k.metaKeyEvents=void 0;for(let w of E.values())k.target?.dispatchEvent(new KeyboardEvent("keyup",w))}};if(typeof PointerEvent<"u"){I.onPointerDown=w=>{if(w.button!==0||!pe(w.currentTarget,ee(w)))return;if(Fi(w.nativeEvent)){k.pointerType="virtual";return}k.pointerType=w.pointerType;let O=!0;if(!k.isPressed){k.isPressed=!0,k.isOverTarget=!0,k.activePointerId=w.pointerId,k.target=w.currentTarget,p||Qi(k.target),O=y(w,k.pointerType);let U=ee(w);"releasePointerCapture"in U&&("hasPointerCapture"in U?U.hasPointerCapture(w.pointerId)&&U.releasePointerCapture(w.pointerId):U.releasePointerCapture(w.pointerId)),x(Ne(w.currentTarget),"pointerup",S,!1),x(Ne(w.currentTarget),"pointercancel",E,!1)}O&&w.stopPropagation()},I.onMouseDown=w=>{if(pe(w.currentTarget,ee(w))&&w.button===0){if(v){let O=Ri(w.target);O&&k.disposables.push(O)}w.stopPropagation()}},I.onPointerUp=w=>{!pe(w.currentTarget,ee(w))||k.pointerType==="virtual"||w.button===0&&!k.isPressed&&P(w,k.pointerType||w.pointerType)},I.onPointerEnter=w=>{w.pointerId===k.activePointerId&&k.target&&!k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!0,y(Oe(k.target,w),k.pointerType))},I.onPointerLeave=w=>{w.pointerId===k.activePointerId&&k.target&&k.isOverTarget&&k.pointerType!=null&&(k.isOverTarget=!1,T(Oe(k.target,w),k.pointerType,!1),F(w))};let S=w=>{if(w.pointerId===k.activePointerId&&k.isPressed&&w.button===0&&k.target){if(pe(k.target,ee(w))&&k.pointerType!=null){let O=!1,U=setTimeout(()=>{k.isPressed&&k.target instanceof HTMLElement&&(O?D(w):(ht(k.target),k.target.click()))},80);x(w.currentTarget,"click",()=>O=!0,!0),k.disposables.push(()=>clearTimeout(U))}else D(w);k.isOverTarget=!1}},E=w=>{D(w)};I.onDragStart=w=>{pe(w.currentTarget,ee(w))&&D(w)}}return I},[x,c,v,C,p,F,y,_,L]);return l.useEffect(()=>{if(!f)return;const k=Ne(f.current);if(!k||!k.head||k.getElementById(an))return;const I=k.createElement("style");I.id=an;let A=qi(k);A&&(I.nonce=A),I.textContent=`
2
+ @layer {
3
+ [${rn}] {
4
+ touch-action: pan-x pan-y pinch-zoom;
5
+ }
6
+ }
7
+ `.trim(),k.head.prepend(I)},[f]),l.useEffect(()=>{let k=m.current;return()=>{p||tn(k.target??void 0);for(let I of k.disposables)I();k.disposables=[]}},[p]),{isPressed:u||b,pressProps:yt(g,K,{[rn]:!0})}}function Ns(e){return e.tagName==="A"&&e.hasAttribute("href")}function es(e,t){const{key:s,code:n}=e,r=t,o=r.getAttribute("role");return(s==="Enter"||s===" "||s==="Spacebar"||n==="Space")&&!(r instanceof Ee(r).HTMLInputElement&&!ga(r,s)||r instanceof Ee(r).HTMLTextAreaElement||r.isContentEditable)&&!((o==="link"||!o&&Ns(r))&&s!=="Enter")}function Oe(e,t){let s=t.clientX,n=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:s,clientY:n,key:t.key}}function Vi(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!Ns(e)}function on(e,t){return e instanceof HTMLInputElement?!ga(e,t):Vi(e)}const Wi=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function ga(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":Wi.has(e.type)}let Yi=0;const ts=new Map;function Xi(e){let[t,s]=l.useState();return Cs(()=>{if(!e)return;let n=ts.get(e);if(n)s(n.element.id);else{let r=`react-aria-description-${Yi++}`;s(r);let o=document.createElement("div");o.id=r,o.style.display="none",o.textContent=e,document.body.appendChild(o),n={refCount:0,element:o},ts.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),ts.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}const Ji=500;function Zi(e){let{isDisabled:t,onLongPressStart:s,onLongPressEnd:n,onLongPress:r,threshold:o=Ji,accessibilityDescription:i}=e;const c=l.useRef(void 0);let{addGlobalListener:u,removeGlobalListener:v}=ha(),{pressProps:h}=Gi({isDisabled:t,onPressStart(f){if(f.continuePropagation(),(f.pointerType==="mouse"||f.pointerType==="touch")&&(s&&s({...f,type:"longpressstart"}),c.current=setTimeout(()=>{f.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Ne(f.target).activeElement!==f.target&&ht(f.target),r&&r({...f,type:"longpress"}),c.current=void 0},o),f.pointerType==="touch")){let g=d=>{d.preventDefault()},b=Ee(f.target);u(f.target,"contextmenu",g,{once:!0}),u(b,"pointerup",()=>{setTimeout(()=>{v(f.target,"contextmenu",g)},30)},{once:!0})}},onPressEnd(f){c.current&&clearTimeout(c.current),n&&(f.pointerType==="mouse"||f.pointerType==="touch")&&n({...f,type:"longpressend"})}}),p=Xi(r&&!t?i:void 0);return{longPressProps:yt(h,p)}}const Bt=ie("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ba=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const xa=ie("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);const el=ie("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);const Ts=ie("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const tl=ie("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);const sl=ie("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Qt=ie("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);const va=ie("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);const ya=ie("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const Ze=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const nl=ie("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const al=ie("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),rl=({address:e,showTrustedBadge:t=!1})=>{const s=t?a.jsx(Bt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}):null;return e.displayName?a.jsxs("span",{children:[a.jsx("span",{className:"text-fg",children:e.displayName}),a.jsxs("span",{className:"text-fg-muted",children:[" ","<",e.normalizedEmail,">"]}),s]}):a.jsxs("span",{className:"text-fg",children:[e.normalizedEmail,s]})},ol=({label:e,addresses:t,showTrustedBadge:s=!1})=>{const[n,r]=l.useState(!1);if(t.length===0)return null;const o=t.length>3,i=c=>{const u=s&&c.flags?.trusted?.value===!0;return a.jsx(rl,{address:c,showTrustedBadge:u})};return a.jsxs("div",{className:"flex gap-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted shrink-0 w-12",children:[e,":"]}),a.jsx("div",{className:"flex-1 min-w-0",children:n?a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))}):a.jsx("div",{className:"truncate",children:t.map((c,u)=>a.jsxs("span",{children:[i(c),u<t.length-1&&", "]},u))})}),o&&a.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r(!n)},className:"shrink-0 text-fg-muted hover:text-fg transition-colors","aria-label":n?"Collapse":"Expand",children:n?a.jsx(mt,{className:"h-4 w-4"}):a.jsx(Dn,{className:"h-4 w-4"})})]})},il={unknown:{label:"Unknown sender",tone:"neutral"},wellknown:{label:"Known sender",tone:"positive"},vip:{label:"VIP",tone:"accent"}};function He({label:e,children:t,className:s}){return a.jsxs("section",{className:z("border-b border-line px-row-inset py-3",s),children:[a.jsx("h3",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),a.jsx("div",{className:"mt-2",children:t})]})}function ll({sender:e}){const t=il[e.trust],s=e.inboundCount==null?null:(e.replyCount??0)>0?`${e.inboundCount} received · you replied ${e.replyCount}×`:`${e.inboundCount} received · you've never replied`;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(pt,{name:e.name,email:e.email,size:"md"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm font-semibold text-fg",children:e.name}),a.jsx("div",{className:"truncate text-2xs text-fg-subtle",children:e.email})]})]}),a.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.addressUnverified?a.jsx(Te,{tone:"danger",dot:!0,children:"Address couldn't be verified"}):a.jsx(Te,{tone:t.tone,dot:!0,children:t.label})}),a.jsxs("p",{className:"mt-2 text-xs text-fg-muted",children:["First seen ",e.firstSeenLabel,s?` · ${s}`:""]})]})}function cl({auth:e,onShowSimilar:t}){if(e.verdict==="aligned")return a.jsxs("div",{className:"flex items-start gap-2 text-xs text-fg-muted",children:[a.jsx(ni,{className:"mt-0.5 size-3.5 shrink-0 text-positive"}),a.jsx("span",{children:e.summary})]});if(e.verdict==="caution")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning",children:[a.jsx(nl,{className:"mt-0.5 size-4 shrink-0"}),a.jsx("p",{className:"text-xs leading-relaxed",children:e.summary})]});const s=e.addressUnreadable?"This sender can't be verified":"This message may be impersonating someone";return a.jsxs("div",{className:"rounded-md bg-danger-soft p-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-semibold text-danger",children:s}),a.jsx("p",{className:"mt-1 text-xs leading-relaxed text-fg",children:e.summary}),!e.addressUnreadable&&e.dkimDomain&&a.jsxs("p",{className:"mt-1 text-2xs text-fg-muted",children:["Sent from"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.dkimDomain}),", claims to be"," ",a.jsx("code",{className:"rounded bg-surface px-1 py-0.5",children:e.fromDomain})]})]})]}),e.similarCount!=null&&e.similarCount>0&&a.jsxs(H,{variant:"secondary",size:"sm",className:"mt-2 w-full border-danger/30 text-danger hover:bg-danger-soft",onClick:t,children:[e.similarCount," similar messages"]})]})}function ut({icon:e,label:t,active:s,danger:n,onClick:r,pending:o}){const i=r===void 0||o===!0;return a.jsxs("button",{type:"button",onClick:r,disabled:i,className:z("flex items-center gap-2 rounded-md border px-2 py-1 text-xs transition-colors",s?"border-accent-2 bg-accent-2-soft text-accent-2":"border-line text-fg-muted hover:border-line-strong hover:text-fg",n&&!s&&"text-danger hover:bg-danger-soft",i&&"cursor-not-allowed opacity-50 hover:border-line"),children:[e,t]})}const ul={sender:"matched: sender",recipient:"matched: recipient",subject:"matched: subject",attachment:"matched: attachment",body:"matched: body",entities:"matched: entities"};function ka({data:e,onClose:t,onShowSimilar:s,actions:n,similarState:r="ready",similarLinkComponent:o,className:i,hideCloseButton:c=!1,reportSpamPending:u=!1,notSpamPending:v=!1}){const{sender:h,authenticity:p,category:f,flags:g={},similar:b}=e;return a.jsxs("aside",{className:z("flex w-76 shrink-0 flex-col overflow-y-auto border-l border-line bg-surface",i),children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"}),!c&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-3.5"}),onClick:t,"aria-label":"Collapse intelligence sidebar"})]}),a.jsx(He,{label:"Sender",children:a.jsx(ll,{sender:h})}),a.jsx(He,{label:"Authenticity",children:a.jsx(cl,{auth:p,onShowSimilar:s})}),a.jsx(He,{label:"Category",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Te,{tone:Fn[f.value],children:f.value}),f.overridden&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"your override"}),a.jsx("button",{type:"button",className:z("ml-auto text-2xs text-accent hover:underline",!n?.onReclassify&&"cursor-not-allowed opacity-50 hover:no-underline"),disabled:!n?.onReclassify,onClick:n?.onReclassify,children:"reclassify"})]})}),a.jsxs(He,{label:"Quick actions",children:[a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a.jsx(ut,{icon:a.jsx(Ye,{className:"size-3.5"}),label:"VIP",active:g.vip,onClick:n?.onToggleVip}),a.jsx(ut,{icon:a.jsx(vo,{className:"size-3.5"}),label:"Mute",active:g.muted,onClick:n?.onToggleMute}),n?.onNotSpam&&a.jsx(ut,{icon:a.jsx(el,{className:"size-3.5"}),label:v?"Undoing…":"Not spam",active:!0,onClick:n.onNotSpam,pending:v}),n?.onReportSpam&&a.jsx(ut,{icon:a.jsx(al,{className:"size-3.5"}),label:u?"Reporting…":"Report spam",danger:!0,onClick:n.onReportSpam,pending:u}),a.jsx(ut,{icon:a.jsx(tl,{className:"size-3.5"}),label:"Unsubscribe",active:g.unsubscribed,onClick:n?.onToggleUnsubscribe})]}),n?.onNotSpam&&a.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"You reported this message as spam"})]}),(r!=="ready"||b.length>0)&&a.jsx(He,{label:"Similar messages",children:r==="loading"?a.jsx("div",{className:"animate-pulse space-y-2",children:Array.from({length:3}).map((d,m)=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"h-3 w-3/4 rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 rounded bg-surface-sunken"})]},m))}):r==="error"?a.jsx("p",{className:"text-xs text-fg-subtle",children:"Similarity search unavailable"}):a.jsx("ul",{className:"-mx-1 space-y-1",children:b.map(d=>{const m="block w-full rounded-md px-1 py-1 text-left hover:bg-surface-sunken",x=`Open message from ${d.fromName||"unknown sender"}: ${d.subject}`,C=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"truncate text-xs font-medium text-fg",children:d.fromName}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:d.timeLabel})]}),a.jsx("div",{className:"truncate text-xs text-fg-muted",children:d.subject}),a.jsx("span",{className:"mt-1 inline-block rounded-full bg-surface-sunken px-1.5 py-px text-2xs text-fg-subtle",children:ul[d.matched]})]});return a.jsx("li",{children:o?o({mailboxId:d.mailboxId,threadId:d.threadId,messageId:d.id,className:m,ariaLabel:x,children:C}):a.jsx("div",{className:m,children:C})},d.id)})})}),a.jsx(He,{label:"Coming soon",className:"border-b-0 opacity-70",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Suggested actions"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:'"Create a filter for messages like this" — on-device model'})]})]}),a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-dashed border-line p-2",children:[a.jsx(We,{className:"mt-0.5 size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-medium text-fg-muted",children:"Thread summary"}),a.jsx("div",{className:"text-2xs text-fg-subtle",children:"One-paragraph digest — Bedrock"})]})]})]})})]})}const us=e=>({shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey}),ln=e=>e.shiftKey||e.metaKey||e.ctrlKey,dl=e=>e.shiftKey?"range":e.metaKey||e.ctrlKey?"toggle":"open",fl=(e,t)=>!t&&e>0,ml=(e,t,s)=>{const n=e.indexOf(s);if(n===-1)return[];const r=t===void 0?-1:e.indexOf(t);if(r===-1)return[s];const o=Math.min(r,n),i=Math.max(r,n);return e.slice(o,i+1)},pl=(e,t,s,n)=>t!==void 0&&e.includes(t)?t:s!==void 0&&e.includes(s)?s:n,hl=(e,t)=>{const s=new Set(t),n=new Set;for(const r of e)s.has(r)&&n.add(r);return n},gl=(e,t,s)=>{if(e.length===0)return;const n=t===void 0?-1:e.indexOf(t);if(n===-1)return s>0?e[0]:e[e.length-1];const r=Math.min(Math.max(n+s,0),e.length-1);return e[r]},bl=e=>{const[t,s]=l.useState(()=>new Set(e?.initialSelectedIds)),[n,r]=l.useState(void 0),o=l.useCallback(d=>t.has(d),[t]),i=l.useCallback(d=>{r(d),s(m=>{const x=new Set(m);return x.has(d)?x.delete(d):x.add(d),x})},[]),c=l.useCallback(d=>{r(d),s(m=>{if(m.has(d))return m;const x=new Set(m);return x.add(d),x})},[]),u=l.useCallback(d=>{s(m=>{if(!m.has(d))return m;const x=new Set(m);return x.delete(d),x})},[]),v=l.useCallback(d=>{s(new Set(d))},[]),h=l.useCallback(()=>{r(void 0),s(new Set)},[]),p=l.useCallback(d=>{s(m=>d.every(C=>m.has(C))?new Set:new Set(d))},[]),f=l.useCallback(d=>{r(d)},[]),g=l.useCallback(d=>{s(m=>{if(m.size===0)return m;const x=hl(m,d);return x.size===m.size?m:x})},[]),b=l.useCallback((d,m,x)=>{const C=pl(d,n,x,m);s(y=>{const j=ml(d,C,m);if(j.length===0)return y;const T=new Set(y);for(const M of j)T.add(M);return T}),r(C)},[n]);return{selectedIds:t,selectedCount:t.size,hasSelection:t.size>0,isSelected:o,toggle:i,select:c,deselect:u,selectAll:v,clearSelection:h,toggleAll:p,selectRange:b,setAnchor:f,anchorId:n,intersectWith:g}};function Tf({hints:e=yo,className:t}){return e.length===0?null:a.jsx("footer",{className:z("flex items-center gap-2 border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",t),children:e.map(s=>a.jsx(xl,{hint:s},s.label))})}function xl({hint:e}){return a.jsxs("span",{className:"flex items-center gap-1",children:[e.keys.map(t=>a.jsx(Ro,{children:t},t)),a.jsx("span",{children:e.label})]})}const ja="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",wa=({active:e,focused:t})=>z("relative flex h-8 w-full items-center gap-2 px-row-inset text-left",ja,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"),Es=({active:e,focused:t})=>z("relative flex w-full items-start gap-3 py-2 pl-5 pr-row-inset text-left transition-colors",ja,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 Ca({thread:e}){const t=!e.isRead;return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex w-4 shrink-0 items-center justify-center",children:e.suspicious?a.jsx(Ze,{className:"size-3.5 text-danger"}):e.starred?a.jsx(Ye,{className:"size-3 fill-warning text-warning"}):t?a.jsx("span",{className:"size-1.5 rounded-full bg-accent"}):null}),a.jsx("span",{className:z("w-36 shrink-0 truncate text-xs",t?"font-semibold text-fg":"text-fg-muted"),children:e.fromName}),a.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs",children:[a.jsx("span",{className:z(t?"font-medium text-fg":"text-fg-muted"),children:e.subject}),a.jsxs("span",{className:"text-fg-subtle",children:[" — ",e.snippet]})]}),e.hasAttachment&&a.jsx(Qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx("span",{className:"w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]})}function cn(e,t){const s=t?.trim();if(!s)return e;const n=e.toLowerCase(),r=s.toLowerCase(),o=[];let i=0,c=n.indexOf(r,i),u=0;for(;c!==-1;)c>i&&o.push(e.slice(i,c)),o.push(a.jsx("mark",{className:"bg-transparent font-semibold text-fg",children:e.slice(c,c+r.length)},u++)),i=c+r.length,c=n.indexOf(r,i);return i<e.length&&o.push(e.slice(i)),o}function vl({thread:e,badge:t,highlightQuery:s}){const n=!e.isRead;return a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:z("flex min-w-0 items-center gap-1.5 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:[e.trust==="vip"&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-accent-2"}),a.jsx("span",{className:"truncate",children:e.fromName}),e.messageCount!=null&&e.messageCount>1&&a.jsx("span",{className:"shrink-0 text-2xs font-normal text-fg-subtle",children:e.messageCount})]}),a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.timeLabel})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:z("truncate text-sm",n?"text-fg":"text-fg-muted"),children:cn(e.subject,s)}),e.suspicious&&a.jsx(Ze,{className:"size-3.5 shrink-0 text-danger"}),e.starred&&a.jsx(Ye,{className:"size-3 shrink-0 fill-warning text-warning"}),e.hasAttachment&&a.jsx(Qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"})]}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle",children:cn(e.snippet,s)}),e.category&&e.category!=="personal"&&a.jsx(Te,{tone:Fn[e.category],className:"shrink-0",children:e.category}),e.labels?.map(r=>a.jsx(gr,{label:r,className:"max-w-20"},r.labelId)),t]})]})}function yl({thread:e,selection:t}){if(!t)return a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"sm"});const{checked:s,alwaysVisible:n}=t;return a.jsxs("span",{className:"relative size-7 shrink-0",children:[a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"sm",className:z("absolute inset-0 transition-opacity sm:group-hover:opacity-0",(s||n)&&"opacity-0")}),a.jsx("span",{role:"button",tabIndex:-1,onClick:t.onToggle,onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),r.stopPropagation(),t.onToggle(r))},className:z("absolute inset-0 size-7 items-center justify-center rounded-full border transition-opacity",n?"flex":"hidden sm:flex",s?"bg-accent border-accent text-accent-fg opacity-100":n?"border-fg-subtle/40 bg-canvas opacity-100":"border-fg-subtle/40 bg-canvas opacity-0 group-hover:opacity-100"),"aria-label":s?"Deselect message":"Select message",children:s&&a.jsx(Ot,{className:"size-3"})})]})}function Ms({thread:e,selection:t,badge:s,highlightQuery:n}){const r=!e.isRead;return a.jsxs(a.Fragment,{children:[r&&a.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),a.jsx(yl,{thread:e,selection:t}),a.jsx(vl,{thread:e,badge:s,highlightQuery:n})]})}const Sa=e=>({...br,[ko]:"","data-message-id":e.id});function Ef({thread:e,active:t,focused:s,tabIndex:n,onClick:r}){return a.jsx("button",{type:"button",...Sa(e),tabIndex:n,onClick:r,className:wa({active:t,focused:s}),children:a.jsx(Ca,{thread:e})})}function Mf({thread:e,active:t,focused:s,tabIndex:n,selection:r,onClick:o}){return a.jsx("button",{type:"button",...Sa(e),tabIndex:n,onClick:o,className:z("group",Es({active:t,focused:s})),children:a.jsx(Ms,{thread:e,selection:r})})}let Ve;const kl=5e3;function Na(e){e.preventDefault(),Pt()}function Pt(){Ve!==void 0&&(clearTimeout(Ve),Ve=void 0,document.removeEventListener("contextmenu",Na,!0),document.removeEventListener("pointerup",Pt,!0))}function jl(){Ve===void 0?(document.addEventListener("contextmenu",Na,!0),document.addEventListener("pointerup",Pt,!0)):clearTimeout(Ve),Ve=setTimeout(Pt,kl)}function wl({onLongPress:e,isDisabled:t,delayMs:s=500,accessibilityDescription:n}){const{longPressProps:r}=Zi({isDisabled:t,threshold:s,accessibilityDescription:n,onLongPress:e}),o=l.useCallback(i=>{i.pointerType!=="touch"&&i.pointerType!=="pen"||jl()},[]);return{longPressProps:yt(r,{onPointerDown:o})}}const dt="min-h-11 min-w-11 px-0";function Ta({hasThread:e,onReply:t,onReplyAll:s,onForward:n,isStarred:r,onToggleStar:o,onDelete:i,isRead:c,onToggleRead:u,moveSlot:v,overflowItems:h=[],onUnavailable:p,unavailableHint:f,className:g}){const b=(m,x)=>()=>{if(!e){p?.(m);return}x?.()},d=u?[{key:"toggle-read",label:c?"Mark as unread":"Mark as read",icon:c?a.jsx(Do,{className:"size-4"}):a.jsx(Ts,{className:"size-4"}),onSelect:b("toggleRead",u)}]:[];return a.jsxs("div",{className:z("relative",g),children:[a.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-0.5 bg-canvas px-1",children:[t&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(ya,{className:"size-5"}),onClick:b("reply",t),"aria-label":"Reply",title:"Reply",className:dt}),s&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(va,{className:"size-5"}),onClick:b("replyAll",s),"aria-label":"Reply all",title:"Reply all",className:dt}),n&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(xa,{className:"size-5"}),onClick:b("forward",n),"aria-label":"Forward",title:"Forward",className:dt}),a.jsx("div",{className:"flex-1"}),o&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:z("size-5",r&&"fill-warning text-warning")}),onClick:b("star",o),"aria-label":r?"Unstar":"Star","aria-pressed":r,title:r?"Unstar":"Star",className:dt}),v,i&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(zt,{className:"size-5"}),onClick:b("delete",i),"aria-label":"Move to Trash",title:"Move to Trash",className:dt}),a.jsx(Vn,{triggerLabel:"More actions",items:[...d,...h]})]}),!e&&f&&a.jsx("p",{role:"status",className:"bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:f})]})}function Cl({open:e=!1,enabled:t=!0,onToggle:s,className:n}){return a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(On,{className:"size-4"}),title:"Intelligence","aria-label":e?"Hide intelligence sidebar":"Show intelligence sidebar","aria-pressed":e,disabled:!t,onClick:s,className:z(e&&"bg-accent-2-soft text-accent-2",n)})}function Sl({hasThread:e,onUnavailable:t,unavailableHint:s,isStarred:n,showTriage:r=!0,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:v,moveSlot:h,onMove:p,replyTitle:f="Reply (r)",replyAllTitle:g="Reply all (a)",forwardTitle:b="Forward (f)",deleteTitle:d="Move to Trash (#)",flagTitle:m="Star (s)",children:x,className:C}){const y=(j,T)=>()=>{if(!e||!T){t?.(j);return}T()};return a.jsxs("div",{className:"relative",children:[a.jsxs("header",{className:z("flex h-pane-header shrink-0 items-center gap-1 border-b border-line bg-surface px-3",C),children:[a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(ya,{className:"size-4"}),title:f,"aria-label":"Reply",onClick:y("reply",o)}),a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(va,{className:"size-4"}),title:g,"aria-label":"Reply all",onClick:y("replyAll",i)}),a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(xa,{className:"size-4"}),title:b,"aria-label":"Forward",onClick:y("forward",c)}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 h-4 w-px bg-line","aria-hidden":!0}),a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(zt,{className:"size-4"}),title:d,"aria-label":"Move to Trash",onClick:y("delete",u)}),h??a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(xs,{className:"size-4"}),title:"Move to mailbox","aria-label":"Move to mailbox",onClick:y("move",p)}),a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(Ye,{className:z("size-4",n&&"fill-warning text-warning")}),title:m,"aria-label":"Star",onClick:y("flag",v)})]}),a.jsx("div",{className:"flex-1"}),x]}),s&&a.jsx("p",{role:"status",className:"border-b border-line bg-surface-sunken px-3 py-1 text-2xs text-fg-subtle",children:s})]})}function Ea({message:e,onClick:t,isFocused:s,isUnread:n,trailing:r}){const o=a.jsxs(a.Fragment,{children:[a.jsx(Dn,{className:"size-3.5 shrink-0 text-fg-subtle"}),a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"md"}),n&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full border border-canvas bg-accent"})]}),a.jsx("span",{className:z("w-36 shrink-0 truncate text-sm",n?"font-semibold text-fg":"font-medium text-fg-muted"),children:e.fromName}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-subtle",children:e.snippet}),r??a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.dateLabel})]}),i=z("group flex h-section-row w-full items-center gap-3 border-b border-line px-2 text-left transition-colors hover:bg-surface-sunken lg:px-4",s&&"bg-surface-sunken ring-1 ring-inset ring-accent/30");return t?a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":!1,onClick:t,onKeyDown:c=>{xr(c)&&(c.preventDefault(),t())},className:z(i,"cursor-pointer"),children:o}):a.jsx("div",{className:i,children:o})}function Ma({message:e,warning:t,onHeaderClick:s,isFocused:n,senderBadge:r,trailing:o,to:i,indicators:c,actionMenu:u,actionBar:v,body:h}){const p=a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"text-sm font-semibold text-fg",children:[e.fromName,r]}),o??a.jsx("span",{className:"text-2xs text-fg-subtle",children:e.dateLabel})]}),a.jsx("div",{className:"text-xs text-fg-subtle",children:e.fromEmail}),i!==null&&a.jsx("div",{className:"text-xs text-fg-subtle",children:i??a.jsxs(a.Fragment,{children:["to ",e.toLabel]})})]});return a.jsxs("div",{className:"px-2 py-3 lg:px-4",children:[a.jsxs("div",{className:z("-mx-2 -my-1 flex items-start gap-3 rounded-sm px-2 py-1",n&&"ring-1 ring-inset ring-accent/30"),children:[s?a.jsx("button",{type:"button",onClick:s,"aria-expanded":!0,"aria-label":"Collapse message",className:"mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg",children:a.jsx(mt,{className:"size-3.5"})}):a.jsx(mt,{className:"mt-1 size-3.5 shrink-0 text-fg-subtle"}),a.jsx(pt,{name:e.fromName,email:e.fromEmail,size:"md"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[s?a.jsx("button",{type:"button",onClick:s,className:"w-full text-left",children:p}):p,c]}),u&&a.jsx("div",{className:"shrink-0",children:u})]}),t&&a.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-md bg-danger-soft p-3",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("div",{className:"text-sm text-fg",children:[a.jsx("span",{className:"font-semibold text-danger",children:"Caution: "}),t," ",a.jsx("button",{type:"button",className:"text-accent underline",children:"Why?"})]})]}),v&&a.jsx("div",{className:"mt-3 -mx-2 lg:-mx-4",children:v}),a.jsx(Fo,{children:h??a.jsx(Oo,{className:"mt-3",html:e.bodyHtml,category:e.framed?"newsletter":"personal",allowImages:!0})})]})}function Nl({thread:e,onBack:t,intelligence:s,intelligenceOpen:n,onToggleIntelligence:r,actions:o,children:i,touchHandlers:c}){const[u,v]=l.useState(!1),h=r!==void 0,p=h?n??!1:u,f=!!s||h,g=()=>{if(h){r?.();return}v(d=>!d)},b=()=>{if(h){p&&r?.();return}v(!1)};return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(zn,{className:"size-4"}),onClick:t,"aria-label":"Back to messages",className:"-ml-1 shrink-0"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.subject}),f&&a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(On,{className:"size-4"}),onClick:g,"aria-label":p?"Hide intelligence panel":"Show intelligence panel","aria-pressed":p,title:"Intelligence",className:z("shrink-0",p&&"bg-accent-2-soft text-accent-2")})]}),a.jsx("div",{className:"flex-1 overflow-y-auto",style:c?{touchAction:"pan-y"}:void 0,...c,children:i??[...e.messages].reverse().map(d=>{const m=x=>x?()=>x(d.id):void 0;return d.expanded?a.jsx(Ma,{message:d,warning:e.warning,onHeaderClick:m(o?.onToggleExpand),actionBar:a.jsx(Ta,{hasThread:!0,onReply:m(o?.onReply),onReplyAll:m(o?.onReplyAll),onForward:m(o?.onForward),onToggleStar:m(o?.onToggleStar),onDelete:m(o?.onDelete),onToggleRead:m(o?.onToggleRead),moveSlot:o?.moveSlot?.(d.id)})},d.id):a.jsx(Ea,{message:d,onClick:m(o?.onToggleExpand)},d.id)})}),s&&!h&&a.jsx(vr,{open:p,onClose:b,title:"Intelligence",anchor:"right",className:"p-0",children:a.jsx(ka,{data:s,onClose:b,className:"h-full w-full border-l-0"})})]})}function Tl({state:e,onRetry:t}){return a.jsxs("div",{role:"alert","data-testid":"attachment-error",className:"flex items-start gap-2 border-t border-danger/30 bg-danger-soft px-2 py-2 text-xs",children:[a.jsx(yr,{className:"mt-0.5 size-3.5 shrink-0 text-danger","aria-hidden":!0}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-danger",children:e.title}),a.jsx("p",{className:"mt-0.5 text-fg-muted",children:e.detail})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx("button",{type:"button",onClick:t,className:"font-medium text-accent hover:underline",children:"Try again"}),e.reportUrl&&a.jsx("a",{href:e.reportUrl,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report this"})]})]})}function El({attachments:e,onDownload:t,hasUnlistedAttachment:s=!1,className:n}){return e.length===0&&!s?null:a.jsxs("section",{"aria-label":"Attachments","data-testid":"attachment-list",className:z("space-y-1.5",n),children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:[a.jsx(Qt,{className:"size-3","aria-hidden":!0}),e.length===0?"Attachment":e.length===1?"1 attachment":`${e.length} attachments`]}),e.length>0&&a.jsx("ul",{className:"overflow-hidden rounded-sm border border-line bg-surface",children:e.map(r=>{const o=r.download.status==="downloading";return a.jsxs("li",{className:"border-t border-line first:border-t-0",children:[a.jsxs("button",{type:"button",onClick:()=>t(r.attachmentId),disabled:o,"data-testid":"attachment-download","aria-label":`Download ${r.filename}`,className:"flex w-full items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-surface-sunken disabled:cursor-progress disabled:opacity-60",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("bdi",{className:"block truncate text-sm text-fg",title:r.filename,children:r.filename}),a.jsxs("span",{className:"block truncate text-2xs text-fg-subtle",children:[r.typeLabel," ·"," ",Ao(r.sizeOctets)]})]}),o?a.jsx(_n,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}):a.jsx(si,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0})]}),r.download.status==="failed"&&a.jsx(Tl,{state:r.download,onRetry:()=>t(r.attachmentId)})]},r.attachmentId)})}),s&&a.jsx("p",{role:"alert","data-testid":"attachment-unlisted",className:"rounded-sm border border-line bg-surface px-2 py-2 text-xs text-fg-muted",children:"The mail server says this message carries an attachment, but none of its parts describe one. Re-sync the account from Settings; if the attachment still does not appear, the message is worth reporting."})]})}function Ml({label:e,onUndo:t,undoLabel:s="Undo",filtersHref:n,className:r}){return a.jsxs(Te,{tone:"accent",className:z("py-1 text-xs",r),children:[a.jsx($o,{className:"size-3.5 shrink-0","aria-hidden":!0}),a.jsx("span",{children:e}),t&&a.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:s}),n&&a.jsx("a",{href:n,onClick:o=>{o.stopPropagation()},className:"font-semibold underline decoration-dotted underline-offset-2 hover:decoration-solid",children:"Manage filter"})]})}const Il="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",un="pointer-events-none absolute inset-0 m-auto size-3.5 text-accent-fg";function Rl({label:e,description:t,indeterminate:s=!1,checked:n,onChange:r,className:o,...i}){const c=l.useRef(null);l.useEffect(()=>{c.current&&(c.current.indeterminate=s)},[s]);const u=a.jsxs("span",{className:"relative inline-flex",children:[a.jsx("input",{ref:c,type:"checkbox",checked:n,onChange:r,className:Il,...i}),a.jsx(Ot,{className:z(un,"hidden peer-checked:block"),"aria-hidden":!0}),a.jsx(sl,{className:z(un,"hidden peer-indeterminate:block"),"aria-hidden":!0})]});return e===void 0&&t===void 0?a.jsx("span",{className:o,children:u}):a.jsxs("label",{className:z("flex min-h-11 cursor-pointer items-center gap-3 text-left",o),children:[u,a.jsxs("span",{className:"flex min-w-0 flex-col",children:[e!==void 0&&a.jsx("span",{className:"text-sm text-fg",children:e}),t!==void 0&&a.jsx("span",{className:"text-xs text-fg-subtle",children:t})]})]})}function Al(e){return{id:e.id,fromName:e.sender,fromEmail:e.senderEmail??e.sender,subject:e.subject,snippet:e.snippet,timeLabel:e.date,isRead:!e.unread,starred:e.flagged,...e.mailboxId?{mailboxId:e.mailboxId}:{}}}function $l({result:e,onClick:t,query:s,showFolder:n=!0}){const r=n&&e.folder?kr(e.folder):void 0;return a.jsx("button",{type:"button",onClick:t,className:z("group",Es({}),"border-b border-line"),children:a.jsx(Ms,{thread:Al(e),highlightQuery:s,badge:a.jsxs(a.Fragment,{children:[r&&a.jsx(Te,{tone:"neutral",className:"shrink-0",children:r}),e.category&&a.jsx(Te,{tone:e.category.tone??"neutral",className:"shrink-0",children:e.category.label}),e.matchedChunkLabel&&a.jsx(Te,{tone:"neutral",className:"shrink-0",children:`matched: ${e.matchedChunkLabel}`}),e.score!=null&&a.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:e.score.toFixed(2)})]})})})}const Ll=e=>e===1?"result":"results";function Pl({count:e,onScopeToSpam:t}){return a.jsx(Un,{tone:"info",variant:"soft",className:"items-center justify-between gap-3 rounded-none border-b border-line",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"min-w-0 text-xs text-fg-muted",children:[a.jsx("span",{className:"font-semibold text-fg tabular-nums",children:e})," ",`${Ll(e)} from Spam`]}),a.jsx(H,{variant:"ghost",size:"sm",onClick:t,className:"shrink-0 text-accent",children:"Go to Spam"})]})})}const dn=6,Dl={kind:"global"},Fl=e=>e.kind==="folder"&&e.role==="junk",Ol=e=>e.folder?.role==="junk";function Ia(e){const t=[],s=[];for(const n of e)Ol(n)?s.push(n):t.push(n);return{kept:t,spam:s}}function Ra({onClick:e,blockedReason:t}){const s=l.useId(),[n,r]=l.useState(!1);return a.jsxs("div",{className:"border-b border-line px-row-inset py-1.5",children:[a.jsxs("button",{type:"button",onClick:()=>{if(t){r(!0);return}e()},"aria-describedby":t?s:void 0,className:z("flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium transition-colors",t?"text-fg-subtle opacity-55":"text-accent hover:bg-surface-sunken"),children:[a.jsx(jr,{className:"size-3.5 shrink-0","aria-hidden":"true"}),a.jsx("span",{children:"Make this a filter"})]}),t&&a.jsx(wr,{id:s,reason:t,nudged:n,className:"px-2 pt-1 text-2xs text-warning"})]})}function zl({section:e,query:t,onSelectResult:s,showFolder:n}){const[r,o]=l.useState(e.initialCollapsed??!1),[i,c]=l.useState(!1),u=e.results.length>dn,h=!i&&u?e.results.slice(0,dn):e.results,p=e.results.length-h.length;return a.jsxs("div",{children:[a.jsxs("button",{type:"button","aria-expanded":!r,onClick:()=>o(f=>!f),className:"sticky top-0 z-10 flex h-section-row w-full items-center gap-1.5 border-b border-line bg-surface-sunken px-row-inset text-left transition-colors hover:bg-surface",children:[a.jsx("span",{className:"flex-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e.label}),a.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:e.results.length}),a.jsx(mt,{className:z("size-3 shrink-0 text-fg-subtle transition-transform duration-200",r?"rotate-0":"rotate-180")})]}),!r&&a.jsxs(a.Fragment,{children:[h.map(f=>a.jsx($l,{result:f,query:t,showFolder:n,onClick:s?()=>s(f):void 0},f.id)),u&&a.jsxs("button",{type:"button",onClick:()=>c(f=>!f),className:"flex w-full items-center justify-center border-b border-line px-row-inset py-1.5 text-2xs font-medium text-accent transition-colors hover:bg-surface",children:[i?"Show less":`Show ${p} more`,!i&&a.jsx(mt,{className:"ml-1 size-3"})]})]})]})}function Aa({value:e,recentSearches:t,onPickRecent:s,sections:n,loading:r,onSelectResult:o,tokens:i,scope:c=Dl,makeFilter:u}){if(!(e.trim().length>0))return t&&t.length>0?a.jsxs("div",{className:"flex flex-col",children:[a.jsx("h3",{className:"px-row-inset pb-1 pt-3 text-2xs font-semibold uppercase tracking-wide text-fg-subtle",children:"Recent searches"}),t.map(j=>a.jsxs("button",{type:"button",onClick:()=>s?.(j),className:"flex w-full items-center gap-2.5 border-b border-line px-row-inset py-2.5 text-left transition-colors hover:bg-surface-sunken",children:[a.jsx(mi,{className:"size-4 shrink-0 text-fg-subtle"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg-muted",children:j})]},j))]}):a.jsx("p",{className:"px-row-inset py-6 text-center text-sm text-fg-subtle",children:"Search across your mail by sender, subject or words in the message."});const h=i&&i.length>0&&a.jsx(Cr,{tokens:i}),p=u&&a.jsx(Ra,{...u});if(r)return a.jsxs("div",{className:"flex flex-col",children:[p,h,a.jsx("div",{className:"flex flex-col gap-3 px-row-inset py-4",children:[0,1,2,3].map(j=>a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-surface-sunken"}),a.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-surface-sunken"})]},j))})]});const f=c.kind==="global",g=Fl(c)||c.kind==="collection",b=f||c.kind==="collection",d=(n??[]).map(j=>{if(g)return{section:j,spam:[]};const{kept:T,spam:M}=Ia(j.results);return{section:{...j,results:T},spam:M}}),m=d.map(j=>j.section),x=d.reduce((j,T)=>j+T.spam.length,0),C=c.kind==="global"&&x>0&&c.onScopeToSpam!==void 0?a.jsx(Pl,{count:x,onScopeToSpam:c.onScopeToSpam}):void 0;return m.some(j=>j.results.length>0)?a.jsxs("div",{className:"flex flex-col",children:[p,h,C,m.filter(j=>j.results.length>0).map(j=>a.jsx(zl,{section:j,query:e,showFolder:b,onSelectResult:o},j.id))]}):a.jsxs("div",{className:"flex flex-col",children:[p,h,C,a.jsxs("div",{className:"px-row-inset py-10 text-center",children:[a.jsxs("p",{className:"text-sm font-medium text-fg",children:["No matches for “",e,"”"]}),a.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"Try a different word, or adjust the filters above."})]})]})}function _l({value:e,onChange:t,onClear:s,onCancel:n,filter:r,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:v,tokens:h,chips:p,onRemoveChip:f,scope:g,makeFilter:b,suggest:d,suggestList:m}){const x=a.jsx(Aa,{value:e,recentSearches:o,onPickRecent:i,sections:c,loading:u,onSelectResult:v,tokens:h,scope:g,makeFilter:b});return a.jsxs("article",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line bg-surface px-row-inset",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Gn,{value:e,onChange:t,onClear:s,chips:p,onRemoveChip:f,globalFocusKey:!1,showClearButton:!1,suggest:d})}),a.jsx(H,{variant:"ghost",size:"sm",icon:a.jsx(Ft,{className:"size-4"}),onClick:n,"aria-label":"Clear and close search",className:"-mr-1 shrink-0"})]}),m,r&&e.trim().length===0?a.jsx(Sr,{children:a.jsx(Nr,{...r,children:x})}):a.jsx("div",{className:"flex-1 overflow-y-auto",children:x})]})}const fn=e=>e.toLocaleString();function mn({selectAll:e,selecting:t,className:s}){return a.jsx(Rl,{className:s,checked:e.checked,indeterminate:e.indeterminate,onChange:e.onChange,label:a.jsx("span",{className:"font-medium text-accent",children:e.checked&&t?"Deselect all":"Select all"})})}function Ul({title:e,count:t,onCancel:s,onDelete:n,onMove:r,onOrganize:o,onJunk:i,onMarkRead:c,navSlot:u,titleMeta:v,searchSlot:h,searchField:p,idleSlot:f,overflowSlot:g,isBusy:b=!1,isCounting:d=!1,selectAll:m,statusLabel:x,progress:C,notice:y}){const j=t>0||d,T=m?.checked?`All ${fn(t)} loaded selected`:`${fn(t)} ${t===1?"message":"messages"} selected`,M=[];return i&&!b&&!d&&M.push({key:"junk",label:"Junk",icon:a.jsx(Ze,{className:"size-4"}),onSelect:i}),c&&!b&&!d&&M.push({key:"mark-read",label:"Mark read",icon:a.jsx(Ts,{className:"size-4"}),onSelect:c}),a.jsxs("header",{"data-selection-bar":"",className:"flex shrink-0 flex-col border-b border-line bg-surface-sunken",children:[a.jsxs("div",{"data-selection-bar-row":"actions",className:"flex h-pane-header items-center gap-1 px-row-inset",children:[j?a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(zn,{className:"size-5"}),onClick:s,"aria-label":"Cancel selection",className:"-ml-2 shrink-0"}):u,m&&a.jsx(mn,{selectAll:m,selecting:j,className:"hidden shrink-0 pr-2 md:flex"}),j?a.jsx("span",{"data-selection-count":"",className:"min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg",role:"status","aria-live":"polite",children:x??T}):p?a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:p}):a.jsxs(a.Fragment,{children:[a.jsx("h1",{className:"min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg",children:e}),v,h]}),j&&!d&&a.jsxs(a.Fragment,{children:[a.jsx(H,{variant:"ghost",size:"touch",icon:b?a.jsx(_n,{className:"size-5 animate-spin"}):a.jsx(zt,{className:"size-5 text-danger"}),onClick:b?void 0:n,"aria-label":"Move selected messages to Trash","aria-busy":b||void 0,className:"shrink-0"}),!b&&r&&a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(xs,{className:"size-5"}),onClick:r,"aria-label":"Move selected messages",className:"shrink-0"}),!b&&o&&a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(We,{className:"size-5"}),onClick:o,"aria-label":"Organize selected messages",className:"shrink-0"})]}),j&&a.jsx(Vn,{triggerLabel:"More actions",items:M,className:"shrink-0",children:!b&&!d&&g})]}),!j&&f,j&&m&&a.jsx("div",{"data-selection-bar-row":"select-all",className:"px-row-inset pb-2 md:hidden",children:a.jsx(mn,{selectAll:m,selecting:j,className:"w-full"})}),C&&a.jsx("div",{className:"px-row-inset pb-2",children:a.jsx(Tr,{value:C.value,max:C.max,tone:C.tone})}),y&&a.jsx(Un,{"data-selection-notice":"",tone:y.tone,variant:"soft",role:"status","aria-live":"polite",className:"mx-row-inset mb-2",children:a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.text&&a.jsx("span",{children:y.text}),y.action&&a.jsx(H,{variant:"ghost",size:"md",onClick:y.action.onClick,className:"-my-1 min-h-11 shrink-0",children:y.action.label})]})})]})}const Is=[{id:"all",label:"All",tone:"neutral"},{id:"personal",label:"Personal",tone:"accent"},{id:"uncategorized",label:"Unclassified",tone:"neutral"},{id:"transactional",label:"Transactional",tone:"positive"},{id:"newsletter",label:"Newsletter",tone:"neutral"},{id:"marketing",label:"Marketing",tone:"warning"},{id:"social",label:"Social",tone:"warning"},{id:"automated",label:"Automated",tone:"neutral"}],$a={id:"unread",label:"Unread"},Kl={id:"flagged",label:"Starred"},La={id:"attachment",label:"Has attachment"};function Bl(e){if(!(e.length<=1))return e.map(t=>({id:t.id,label:t.label,count:t.count,active:t.active}))}function If(e=[]){return{categories:[...Is],filters:Er,sources:Bl(e)}}function Rf(){return{categories:[...Is],filters:[$a,Kl,La]}}function Af(){return{categories:[...Is],filters:[$a,La]}}function Ql(e,t){return e.endsWith(t)?e.length===t.length||e[e.length-t.length-1]===".":!1}function ql(e,t){const s=e.length-t.length-2,n=e.lastIndexOf(".",s);return n===-1?e:e.slice(n+1)}function Hl(e,t,s){if(s.validHosts!==null){const r=s.validHosts;for(const o of r)if(Ql(t,o))return o}let n=0;if(t.startsWith("."))for(;n<t.length&&t[n]===".";)n+=1;return e.length===t.length-n?null:ql(t,e)}const ss=/[\t\n\r]/g;let ds=!1;function pn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127||e>=65&&e<=90||e===45||e===95}function hn(e,t,s){const n=s-t,r=e.charCodeAt(t)|32;if(n===2)return r===119&&(e.charCodeAt(t+1)|32)===115?1:0;if(n===3){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32;return r===119&&o===115&&i===115||r===102&&o===116&&i===112?1:0}else if(n===4){const o=e.charCodeAt(t+1)|32,i=e.charCodeAt(t+2)|32,c=e.charCodeAt(t+3)|32;return r===104&&o===116&&i===116&&c===112?1:r===102&&o===105&&i===108&&c===101?2:0}else if(n===5)return r===104&&(e.charCodeAt(t+1)|32)===116&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===112&&(e.charCodeAt(t+4)|32)===115?1:0;return 0}function ft(e,t,s=!1){let n=0,r=e.length,o=!1,i=!1;if(ds=!1,!t){if(e.startsWith("data:"))return null;for(;n<e.length&&e.charCodeAt(n)<=32;)n+=1;for(;r>n+1&&e.charCodeAt(r-1)<=32;)r-=1;if(e.charCodeAt(n)===47&&e.charCodeAt(n+1)===47)n+=2;else{const m=e.indexOf(":/",n);if(m!==-1){const x=hn(e,n,m);if(x===1)for(i=!0,n=m+2;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1;else if(x===2){i=!0,n=m+1;let C=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&C<2;)n+=1,C+=1;if(C<2)return null}else{for(let C=n;C<m;C+=1){const y=e.charCodeAt(C)|32;if(!(y>=97&&y<=122||y>=48&&y<=57||y===46||y===45||y===43)){const j=e.charCodeAt(C);return j===9||j===10||j===13?ft(e.replace(ss,""),t,s):null}}if(e.charCodeAt(m+2)===47)n=m+3;else return null}}else if(e.charCodeAt(n)!==91){let x=-1;for(let C=n;C<r;C+=1){const y=e.charCodeAt(C);if(y===9||y===10||y===13)return ft(e.replace(ss,""),t,s);if(y===58){x=C;break}if(y===47||y===92||y===63||y===35)break}if(x!==-1){let C=!1;for(let y=x+1;y<r;y+=1){const j=e.charCodeAt(y);if(j===47||j===92||j===63||j===35)break;if(j===64){C=!0;break}}if(!C){let y=!0,j=x+1;for(;j<r;j+=1){const T=e.charCodeAt(j);if(T===47||T===92||T===63||T===35)break;if(T<48||T>57){y=!1;break}}if(j===x+1&&(y=!1),!y){const T=hn(e,n,x);if(T===0){let M=!1;for(let P=x+1;P<r;P+=1){const R=e.charCodeAt(P);if(R===47||R===92||R===63||R===35)break;if(R===58){M=!0;break}}if(!M)return null}else if(i=!0,n=x+1,T===2){let M=0;for(;(e.charCodeAt(n)===47||e.charCodeAt(n)===92)&&M<2;)n+=1,M+=1;if(M<2)return null}else for(;e.charCodeAt(n)===47||e.charCodeAt(n)===92;)n+=1}}}}}let u=-1,v=-1,h=-1,p=-1,f=!1,g=s,b=n-1,d=-1;if(s&&n<r){const m=e.charCodeAt(n);(!(pn(m)||m===46||m===95)||m===45)&&(g=!1)}for(let m=n;m<r;m+=1){const x=e.charCodeAt(m);if(x<64)if(x===47||x===35||x===63){r=m;break}else x===58?(p===-1&&(p=m),h=m):x===9||x===10||x===13?f=!0:s&&(x===46?((m-b>64||d===46||d===45)&&(g=!1),b=m):(x<48||x>57)&&(x!==45||d===46)&&(g=!1));else if(i&&x===92){r=m;break}else x===64?(u=m,p=-1):x===93?v=m:x>=65&&x<=90?o=!0:s&&!pn(x)&&(g=!1);s&&(d=x)}if(f)return ft(e.replace(ss,""),t,s);if(u!==-1&&u>=n&&u<r&&(n=u+1),e.charCodeAt(n)===91)return v!==-1?e.slice(n+1,v).toLowerCase():null;if(h!==-1&&h>n&&h<r&&p===h&&(r=h),n>=r)return null;s&&g&&u===-1&&h===-1&&v===-1&&e.charCodeAt(r-1)!==46&&r-n<=255&&r-b-1<=63&&d!==45&&(ds=!0)}for(;r>n+1&&e.charCodeAt(r-1)===46;)r-=1;const c=n!==0||r!==e.length?e.slice(n,r):e;return o?c.toLowerCase():c}function Gl(e){if(e.length<7||e.length>15)return!1;let t=0;for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n===46)t+=1;else if(n<48||n>57)return!1}return t===3&&e.charCodeAt(0)!==46&&e.charCodeAt(e.length-1)!==46}function Vl(e){if(e.length<3)return!1;let t=e.startsWith("[")?1:0,s=e.length;if(e[s-1]==="]"&&(s-=1),s-t>39)return!1;let n=!1;for(;t<s;t+=1){const r=e.charCodeAt(t);if(r===58)n=!0;else if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return n}function Wl(e){return Vl(e)||Gl(e)}function gn(e){return e>=97&&e<=122||e>=48&&e<=57||e>127}function bn(e){if(e.length>255||e.length===0||!gn(e.charCodeAt(0))&&e.charCodeAt(0)!==46&&e.charCodeAt(0)!==95)return!1;let t=-1,s=-1;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o===46){if(r-t>64||s===46||s===45)return!1;t=r}else if(!(gn(o)||o===45||o===95)||o===45&&s===46)return!1;s=o}return n-t-1<=63&&s!==45}function Yl({allowIcannDomains:e=!0,allowPrivateDomains:t=!1,detectIp:s=!0,detectSpecialUse:n=!1,extractHostname:r=!0,mixedInputs:o=!0,validHosts:i=null,validateHostname:c=!0}){return{allowIcannDomains:e,allowPrivateDomains:t,detectIp:s,detectSpecialUse:n,extractHostname:r,mixedInputs:o,validHosts:i,validateHostname:c}}const Xl=Yl({});function Jl(e){return Xl}function Zl(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null}}function ec(e){e.domain=null,e.domainWithoutSuffix=null,e.hostname=null,e.isIcann=null,e.isIp=null,e.isPrivate=null,e.isSpecialUse=null,e.publicSuffix=null,e.subdomain=null}function tc(e,t,s,n,r){const o=Jl();if(typeof e!="string")return r;let i=!1;return o.extractHostname?o.mixedInputs?(i=bn(e),r.hostname=ft(e,i,o.validateHostname)):r.hostname=ft(e,!1,o.validateHostname):r.hostname=e,o.detectIp&&r.hostname!==null&&(r.isIp=Wl(r.hostname),r.isIp)?r:o.validateHostname&&o.extractHostname&&r.hostname!==null&&!(i&&r.hostname===e)&&!ds&&!bn(r.hostname)?(r.hostname=null,r):(r.hostname===null||(s(r.hostname,o,r),r.publicSuffix===null)||(r.domain=Hl(r.publicSuffix,r.hostname,o)),r)}const xn=Zl();function sc(e,t){return ec(xn),tc(e,3,Mr,t,xn).domain}const qt=e=>{const t=new Set,s=[];for(const n of e){const r=n.trim();if(r==="")continue;const o=r.toLowerCase();t.has(o)||(t.add(o),s.push(r))}return s},nc=e=>{const t=e.lastIndexOf("@");return t>=0?e.slice(t+1):e},Pa=e=>sc(nc(e.trim())),ac=e=>{const t=qt(e);if(t.length<2)return null;let s=null;for(const n of t){const r=Pa(n);if(r===null)return null;if(s===null)s=r;else if(s!==r)return null}return s},Ht=e=>{const t=ac(e);return t!==null?[{field:"FromDomain",value:t}]:qt(e).map(s=>({field:"From",value:s}))},rc=e=>{const t=new Map;for(const r of e){const o=r.normalizedEmail.trim().toLowerCase();if(o==="")continue;const i=t.get(o);i?i.count+=1:t.set(o,{sender:r,count:1})}let s,n=0;for(const{sender:r,count:o}of t.values())o<=n||(s=r,n=o);return s},Da=e=>e.displayName?.trim()||e.normalizedEmail,oc=/^\s*(?:(?:re|aw|fwd?|vs|sv|antw|res|enc|tr)\s*(?:\[\d+\])?\s*:|\[[^\]]{1,32}\])\s*/i,ic=e=>{let t=e.replace(/\s+/g," ").trim();for(;;){const s=t.replace(oc,"");if(s===t)return t.trim();t=s}},lc=new Set(["a","an","and","are","as","at","be","by","for","from","has","have","in","is","it","me","my","new","of","on","or","our","the","this","to","was","we","with","you","your"]),cc=3,ns=e=>e.split(" ").filter(t=>t!==""),vn=e=>e.length===0||e.join(" ").length<cc?!1:e.some(t=>!lc.has(t.toLowerCase())),uc=(e,t)=>e.findIndex((s,n)=>t.every((r,o)=>e[n+o]?.toLowerCase()===r.toLowerCase())),dc=e=>{const t=e.map(ic).filter(o=>o!=="");if(t.length===0)return;const[s,...n]=t;if(n.length===0)return vn(ns(s))?s:void 0;const r=ns(s);for(let o=r.length;o>0;o-=1)for(let i=0;i+o<=r.length;i+=1){const c=r.slice(i,i+o);if(vn(c)&&n.every(u=>uc(ns(u),c)>=0))return c.join(" ")}},fc=(e,t)=>{const s=Ht(e);if(qt(e).length===1||s.length===1&&s[0].field==="FromDomain")return s;const n=dc(t);return n!==void 0?[{field:"Subject",value:n}]:s},mc=({match:e,sender:t,folder:s})=>{const n=e??t;return n?s?`${n} → ${s}`:e?`Mail matching ${e}`:`Mail from ${n}`:s?`Mail to ${s}`:""},pc=e=>e.clauses.length>0,hc=e=>({scopedOutFolder:e.scopedOut?.label,droppedFacets:e.droppedFacets.map(t=>t.label),droppedSemantic:e.droppedSemantic}),gc=({orderedIds:e,isDesktop:t,initialFocusedId:s,initialSelectedIds:n,onExitSelection:r})=>{const[o,i]=l.useState(s),[c,u]=l.useState(),v=l.useCallback(S=>{u(E=>E===S?E:void 0),i(S)},[]),h=bl({initialSelectedIds:n}),{selectedCount:p,toggle:f,clearSelection:g,selectRange:b,setAnchor:d,selectAll:m}=h,x=fl(p,t),C=l.useRef(null),y=l.useRef(!1),j=l.useCallback(()=>{r?.(),g()},[g,r]),T=l.useMemo(()=>o?e.indexOf(o):-1,[e,o]),M=l.useCallback(S=>{if(S<0||S>=e.length)return;const E=e[S];if(x){f(E);return}C.current=E,y.current=!1,u(E),i(E)},[e,x,f]),P=l.useCallback(()=>{e.length!==0&&M(T<0?0:Math.min(T+1,e.length-1))},[e.length,T,M]),R=l.useCallback(()=>{e.length!==0&&M(T<=0?0:T-1)},[e.length,T,M]),D=l.useCallback(()=>M(0),[M]),F=l.useCallback(()=>M(e.length-1),[M,e.length]),_=l.useCallback(()=>{o&&f(o)},[o,f]),L=l.useCallback((S,E)=>{const w=dl(E);return w==="range"?(b(e,S,o),!0):w==="toggle"?(f(S),!0):(j(),d(S),!1)},[e,o,b,f,j,d]),K=l.useCallback(S=>{const E=gl(e,o,S);E!==void 0&&(b(e,E),C.current=E,y.current=!1,u(void 0),i(E))},[e,o,b]),k=l.useCallback(()=>K(-1),[K]),I=l.useCallback(()=>K(1),[K]),A=l.useCallback(()=>{e.length>0&&m(e)},[e,m]);return{focusedMessageId:o,setFocusedMessageId:v,keyboardFocusedMessageId:c,focusIndex:T,pendingDomFocusRef:C,cursorMovedByPointerRef:y,selection:h,isMultiSelectMode:x,exitSelection:j,moveFocusToIndex:M,focusNext:P,focusPrevious:R,focusFirst:D,focusLast:F,toggleFocusedSelection:_,extendRangeUp:k,extendRangeDown:I,selectAllLoaded:A,handleRowSelect:L}};function bc(e,t){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const s=!!(e.condition??!0),n=e.blockerFn;return{shouldBlockFn:async()=>s&&n!==void 0?await n():s,enableBeforeUnload:s,withResolver:n===void 0}}function xc(e,t){const{shouldBlockFn:s,enableBeforeUnload:n=!0,disabled:r=!1,withResolver:o=!1}=bc(e),i=Ir(),{history:c}=i,[u,v]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{const h=async p=>{function f(x){const C=i.parseLocation(x),y=i.getMatchedRoutes(C.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:C.pathname,pathname:C.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:C.pathname,params:y.routeParams,search:i.options.parseSearch(x.search)}}const g=f(p.currentLocation),b=f(p.nextLocation);if(g.routeId==="__notFound__"&&b.routeId!=="__notFound__")return!1;const d=await s({action:p.action,current:g,next:b});if(!o)return d;if(!d)return!1;const m=await new Promise(x=>{v({status:"blocked",current:g,next:b,action:p.action,proceed:()=>x(!1),reset:()=>x(!0)})});return v({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),m};return r?void 0:c.block({blockerFn:h,enableBeforeUnload:n})},[s,n,r,o,c,i]),u}const $f=({isOpen:e,onClose:t,children:s,ariaLabel:n="Navigation",side:r="left",widthClassName:o="w-[80vw] max-w-[320px]"})=>{const i=l.useRef(null),c=l.useRef(null);if(l.useEffect(()=>{if(!e)return;c.current=document.activeElement;const v=f=>{f.key==="Escape"&&(f.preventDefault(),t())};document.addEventListener("keydown",v),i.current?.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")?.focus();const p=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",v),document.body.style.overflow=p,c.current?.focus()}},[e,t]),!e)return null;const u=r==="left"?"left-0 border-r animate-in slide-in-from-left duration-150":"right-0 border-l animate-in slide-in-from-right duration-150";return a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":n,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:"absolute inset-0 bg-black/40 animate-in fade-in duration-150 cursor-default"}),a.jsxs("div",{ref:i,className:z("safe-area-frame absolute top-0 bottom-0 bg-canvas border-line shadow-xl flex flex-col",o,u),children:[a.jsx("div",{className:"flex items-center justify-end h-12 px-2 border-b border-line shrink-0",children:a.jsx("button",{type:"button",onClick:t,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close menu",children:a.jsx(Ft,{className:"size-5"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s})]})]})},vc=({surface:e})=>{const t=Qo(),s=qo(),{data:n}=te({..._t({path:{messageId:e.sourceMessageId}})}),{data:r}=te({...xt(),staleTime:1/0});return a.jsx("div",{className:"border-b border-line bg-canvas",children:a.jsx(Xo,{layout:"flow",mode:e.mode,account:r?.accounts?.[0],sourceMessage:n,outboxMessageId:e.outboxMessageId,onDraftCreated:t,onClose:s})})},Fa=({message:e,icon:t})=>a.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&a.jsx("div",{className:"mb-4 text-fg-muted",children:t}),a.jsx("p",{className:"text-fg-muted",children:e})]}),Oa=e=>{const{data:t,isLoading:s}=te({...xt(),staleTime:1/0}),n=l.useMemo(()=>(t?.accounts??[]).map(c=>c.accountId),[t?.accounts]),r=js({queries:n.map(c=>({...vt({path:{accountId:c}}),staleTime:1/0,enabled:!!e}))}),o=s||r.some(c=>c.isLoading);return{accountId:l.useMemo(()=>{if(e){for(let c=0;c<n.length;c++)if((r[c].data?.items??[]).some(h=>h.mailboxId===e))return n[c]}},[e,n,r]),isLoading:o}},yc=100,fs=async e=>e.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:t})),kc=(e,t=yc)=>{if(e.length===0)return[];const s=[];for(let n=0;n<e.length;n+=t)s.push(e.slice(n,n+t));return s},za=async(e,t,s,n)=>{const r=kc(e),o=e.length;let i=0;const c=[];for(let u=0;u<r.length;u++){if(n())return c.push(...r.slice(u).flat()),{done:i,failedIds:c,cancelled:!0};const v=r[u],h=await fs(t(v));if(!h.ok)return c.push(...r.slice(u).flat()),s({done:i,total:o}),{done:i,failedIds:c,cancelled:!1,error:h.error};i+=v.length,s({done:i,total:o})}return{done:i,failedIds:c,cancelled:!1}},bt=async(e,t)=>{await za(e,async s=>(await t(s),{successCount:s.length,failureCount:0}),()=>{},()=>!1)},jc=async(e,t,s,n,r)=>{let o=0;const i=[];let c;do{if(r())return{done:o,failedIds:i,cancelled:!0};const u=await fs(e(c));if(!u.ok)return{done:o,failedIds:i,cancelled:!1,error:u.error};const v=u.value;if(v.ids.length>0){const h=await fs(s(v.ids));if(!h.ok)return{done:o,failedIds:i,cancelled:!1,error:h.error};o+=v.ids.length,n({done:o,total:t})}c=v.continuationToken}while(c);return{done:o,failedIds:i,cancelled:!1}},wc=e=>({done:e.done,total:Math.max(e.total,e.done)}),_a=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),Ua=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Ka=(e,t)=>e===void 0?e:_a(e)?{...e,pages:e.pages.map(s=>({...s,items:t(s.items)}))}:Ua(e)?{...e,items:t(e.items)}:e,je=e=>{const t=[];for(const s of new Set(e))t.push(Kn({path:{mailboxId:s}})),t.push(Bn({path:{mailboxId:s}}));return t.push(Qn()),t},kt=(e,t)=>Promise.all(t.map(s=>e.cancelQueries({queryKey:s}))),jt=(e,t)=>t.flatMap(s=>e.getQueriesData({queryKey:s})).filter(s=>s[1]!==void 0).map(([s,n])=>({queryKey:s,data:n})),wt=(e,t,s)=>{const n=r=>Ka(r,s);for(const r of t)e.setQueriesData({queryKey:r},n)},Ct=(e,t)=>{for(const s of t)e.setQueryData(s.queryKey,s.data)},we=(e,t)=>{for(const s of t)e.invalidateQueries({queryKey:s})},Cc=3e3,Sc=(e,t,s)=>{if(e.length===0)return()=>{};const n=setTimeout(()=>s(e),t);return()=>clearTimeout(n)},Rs=(e,t,s)=>{const n=new Map(t.map(o=>[o.messageId,o.mailboxId])),r=new Set;for(const o of e)r.add(n.get(o)??s);return[...r]},Dt=(e,t,s)=>e.map(n=>t.has(n.messageId)?{...n,isRead:s}:n),Nc=(e,t,s,n)=>e.filter(r=>!r.isRead&&t.has(r.threadMessageId)&&!s.has(r.messageId)&&!n.has(r.messageId)).map(r=>r.messageId),Tc=({messages:e,expandedIds:t,threadId:s,mailboxId:n,accountId:r})=>{const o=ae(),{pushError:i}=ke(),c=l.useRef(new Set),u=l.useRef(new Set),{mutate:v}=de({...Ut(),meta:Rr,onMutate:async f=>{const g=new Set(f.body.messageIds??[]),b=f.body.isRead??!0,d=Ie({path:{threadId:s}}),m=je(Rs(g,e,n));await Promise.all([o.cancelQueries({queryKey:d}),kt(o,m)]);const x=o.getQueriesData({queryKey:d}).filter(y=>y[1]!==void 0).map(([y,j])=>({queryKey:y,data:j})),C=jt(o,m);return o.setQueriesData({queryKey:d},y=>y&&{...y,items:Dt(y.items,g,b)}),wt(o,m,y=>Dt(y,g,b)),{threadMessagesPrefix:d,listPrefixes:m,previousThreadMessages:x,previousThreadsList:C}},onSuccess:(f,g)=>{const b=g.body.messageIds??[];for(const d of b)c.current.add(d),u.current.delete(d)},onError:(f,g,b)=>{const d=g.body.messageIds??[];for(const x of d)u.current.delete(x);if(b){for(const x of b.previousThreadMessages)o.setQueryData(x.queryKey,x.data);Ct(o,b.previousThreadsList)}const m=g.body.isRead??!0;i({title:m?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(f),error:f})},onSettled:(f,g,b,d)=>{d&&(o.invalidateQueries({queryKey:d.threadMessagesPrefix}),we(o,d.listPrefixes),r&&o.invalidateQueries({queryKey:Xe({path:{accountId:r}})}))}}),h=l.useCallback(f=>{const g=f.filter(b=>!c.current.has(b)&&!u.current.has(b));if(g.length!==0){for(const b of g)u.current.add(b);v({body:{messageIds:g,isRead:!0}})}},[v]),p=l.useMemo(()=>Nc(e,t,c.current,u.current),[e,t]);l.useEffect(()=>Sc(p,Cc,h),[p,h]),l.useEffect(()=>{c.current.clear(),u.current.clear()},[s])},Lf=e=>{const{mailboxId:t,accountId:s,messages:n}=e,r=ae(),{pushError:o}=ke(),{mutateAsync:i,isPending:c}=de({...Ut(),onError:(v,h)=>{const p=h.body.isRead??!0;o({title:p?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(v),error:v})},onSettled:(v,h,p)=>{we(r,je(Rs(p.body.messageIds??[],n??[],t))),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})})}});return{toggleReadFor:l.useCallback((v,h)=>{v.length!==0&&bt(v,p=>i({body:{messageIds:p,isRead:h}}))},[i]),isPending:c}},Ec=60,Mc=1.5,Ic=(e,t,s)=>{const n=Math.abs(e),r=Math.abs(t);return n<s?{direction:null}:n<r*Mc?{direction:null}:{direction:e<0?"left":"right"}},Rc=({onSwipeLeft:e,onSwipeRight:t,thresholdPx:s=Ec})=>{const n=l.useRef(null),r=l.useCallback(u=>{if(u.pointerType==="mouse"){n.current=null;return}n.current={x:u.clientX,y:u.clientY}},[]),o=l.useCallback(()=>{},[]),i=l.useCallback(u=>{const v=n.current;if(n.current=null,!v)return;const{direction:h}=Ic(u.clientX-v.x,u.clientY-v.y,s);h==="left"&&e?.(),h==="right"&&t?.()},[e,t,s]),c=l.useCallback(()=>{n.current=null},[]);return{handlers:{onPointerDown:r,onPointerMove:o,onPointerUp:i,onPointerCancel:c}}},Ac=(e,t,s)=>t?.find(n=>n.messageId===e)?.mailboxId??s,yn=(e,t,s)=>e.map(n=>n.messageId===t?{...n,hasStars:s}:n),Ba=({threadId:e,mailboxId:t,messages:s})=>{const n=ae(),{pushError:r}=ke(),{mutate:o,isPending:i,variables:c}=de({...Ar(),onMutate:async v=>{const h=v.path.messageId,p=v.body.isStarred??!1,f=Ie({path:{threadId:e}}),g=je([Ac(h,s,t)]);await Promise.all([n.cancelQueries({queryKey:f}),kt(n,g)]);const b=n.getQueriesData({queryKey:f}).filter(m=>m[1]!==void 0).map(([m,x])=>({queryKey:m,data:x})),d=jt(n,g);return n.setQueriesData({queryKey:f},m=>Ka(m,x=>yn(x,h,p))),wt(n,g,m=>yn(m,h,p)),{threadMessagesPrefix:f,listPrefixes:g,previousThreadMessages:b,previousThreadsList:d}},onError:(v,h,p)=>{if(p){for(const g of p.previousThreadMessages)n.setQueryData(g.queryKey,g.data);Ct(n,p.previousThreadsList)}const f=h.body.isStarred??!1;r({title:f?"Couldn't star message":"Couldn't unstar message",detail:Me(v),error:v})},onSettled:(v,h,p,f)=>{f&&(n.invalidateQueries({queryKey:f.threadMessagesPrefix}),we(n,f.listPrefixes))}});return{toggleStar:(v,h)=>{o({path:{messageId:v},body:{isStarred:!h}})},isPending:i,pendingMessageId:i?c?.path.messageId:void 0}};function kn({authenticity:e,onOpenIntelligence:t}){return e.dkimMismatch?a.jsxs("div",{className:"flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm",children:[a.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-danger"}),a.jsxs("p",{className:"flex-1 leading-snug text-fg",children:["This message claims to be from"," ",a.jsx("span",{className:"font-semibold",children:e.fromDomain})," but was sent",e.dkimDomain?` via ${e.dkimDomain}`:" from a different domain","."," ",t&&a.jsx("button",{type:"button",onClick:t,className:"font-medium text-danger hover:underline",children:"Why?"})]})]}):null}function Qa(e){return e===void 0?"uncategorized":e}const $c={inbox:"Inbox",junk:"Junk"},As=e=>e.destinationMailboxId!==void 0,Lc=(e,t)=>{if(As(e))return`Moved from ${t??"another folder"} by Remit`;const s=e.fromPlacement??"";return`Moved from ${$c[s]??"another folder"} by Remit`},Pc=(e,t)=>{if(e===Ys.MoveToInbox)return t.inboxMailboxId;if(e===Ys.MoveToJunk)return t.junkMailboxId},Dc=(e,t,s)=>{if(!e||!t)return!1;const n=As(e)?e.destinationMailboxId:Pc(e.action,s);return n!==void 0&&n===t},Fc="Reported as spam",Oc=(e,t)=>{if(e){if(As(e))return e.fromMailboxId;if(e.fromPlacement==="inbox")return t.inboxMailboxId;if(e.fromPlacement==="junk")return t.junkMailboxId}},St=(e,t)=>{const{data:s,isLoading:n}=te({...xt(),staleTime:1/0,enabled:!!e});return{mailboxId:l.useMemo(()=>e?s?.accounts.find(i=>i.accountId===e)?.folderAppointments.find(i=>i.role===t)?.mailboxId:void 0,[s,e,t]),isLoading:n}},Pf=e=>{const{mailboxId:t,isLoading:s}=St(e,"Archive");return{archiveMailboxId:t,isLoading:s}},Df=e=>{const{mailboxId:t,isLoading:s}=St(e,"Drafts");return{draftsMailboxId:t,isLoading:s}},zc=e=>{const{mailboxId:t,isLoading:s}=St(e,"Inbox");return{inboxMailboxId:t,isLoading:s}},qa=e=>{const{mailboxId:t,isLoading:s}=St(e,"Junk");return{junkMailboxId:t,isLoading:s}},Ff=e=>{const{mailboxId:t,isLoading:s}=St(e,"Trash");return{trashMailboxId:t,isLoading:s}},Ha=e=>{const{data:t}=te({...xt(),staleTime:1/0,enabled:!!e});return l.useMemo(()=>t?.accounts.find(s=>s.accountId===e)?.folderAppointments??[],[t,e])},jn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Gt=({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=ae(),{pushError:o}=ke(),{mutateAsync:i,isPending:c,isError:u}=de({...$r(),onMutate:async h=>{const p=new Set(h.body.messageIds??[]),f=t?Ie({path:{threadId:t}}):[],g=je([e,h.body.destinationMailboxId]);await Promise.all([...t?[r.cancelQueries({queryKey:f})]:[],kt(r,g)]);const b=t?r.getQueriesData({queryKey:f}).filter(m=>m[1]!==void 0).map(([m,x])=>({queryKey:m,data:x})):[],d=jt(r,g);return t&&r.setQueriesData({queryKey:f},m=>m&&{...m,items:jn(m.items,p)}),wt(r,g,m=>jn(m,p)),n?.(Array.from(p)),{threadMessagesPrefix:f,listPrefixes:g,previousThreadMessages:b,previousThreadsList:d}},onError:(h,p,f)=>{if(f){for(const b of f.previousThreadMessages)r.setQueryData(b.queryKey,b.data);Ct(r,f.previousThreadsList)}const g=p.body.messageIds?.length??0;o({title:g>1?`Couldn't move ${g} messages`:"Couldn't move this message",detail:Me(h),error:h})},onSettled:(h,p,f,g)=>{g&&(t&&r.invalidateQueries({queryKey:g.threadMessagesPrefix}),we(r,g.listPrefixes),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}});return{moveMessages:l.useCallback((h,p)=>{h.length!==0&&bt(h,f=>i({body:{messageIds:f,destinationMailboxId:p}}))},[i]),isPending:c,isError:u}},_c="This message could not be processed. Please try again. If it keeps failing, report it.",Uc=(e,t)=>e.replace(`Message ${t}'s`,"This message's"),wn=e=>{if(e.failureCount===0)return;const t=e.failures?.[0],s=t?.reason??_c,n=t?Uc(s,t.messageId):s;throw new Dr(n,422)};function Ga({mailboxId:e,threadId:t,accountId:s,onAfterOptimisticRemove:n}){const r=ae(),{pushError:o}=ke(),i=je([e]),c=t?Ie({path:{threadId:t}}):[],u=()=>{t&&r.invalidateQueries({queryKey:c}),we(r,i),s&&r.invalidateQueries({queryKey:Xe({path:{accountId:s}})})},v=()=>(d,m)=>{u(),n?.(m.body.messageIds)},h=d=>(m,x)=>{o({title:d(x.body.messageIds.length),detail:Me(m),error:m})},p=de({mutationFn:async d=>{const{data:m}=await Lr({...d,throwOnError:!0});return wn(m),m},meta:{softError:!0},onSuccess:v(),onError:h(d=>d>1?`Couldn't report ${d} messages as spam`:"Couldn't report this message as spam")}),f=de({mutationFn:async d=>{const{data:m}=await Pr({...d,throwOnError:!0});return wn(m),m},meta:{softError:!0},onSuccess:v(),onError:h(d=>d>1?`Couldn't undo the spam report for ${d} messages`:"Couldn't undo the spam report")}),g=l.useCallback(d=>{d.length!==0&&bt(d,m=>p.mutateAsync({body:{messageIds:m}}))},[p.mutateAsync]),b=l.useCallback(d=>{d.length!==0&&bt(d,m=>f.mutateAsync({body:{messageIds:m}}))},[f.mutateAsync]);return{reportSpam:g,notSpam:b,isReporting:p.isPending,isRestoring:f.isPending}}const Kc=({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o})=>{const{inboxMailboxId:i}=zc(e),{junkMailboxId:c}=qa(e),{moveMessages:u,isPending:v}=Gt({mailboxId:n,threadId:s,accountId:e}),{notSpam:h,isRestoring:p}=Ga({mailboxId:n,threadId:s,accountId:e}),{data:f}=te({...vt({path:{accountId:e??""}}),staleTime:1/0,enabled:!!e&&r?.fromMailboxId!==void 0}),g={inboxMailboxId:i,junkMailboxId:c},b=Oc(r,g),d=l.useCallback(()=>{b&&u([t],b)},[u,t,b]),m=l.useCallback(()=>{h([t])},[h,t]);if(o)return{show:!0,label:Fc,onUndo:m,isUndoing:p};if(!Dc(r,n,g)||!r)return{show:!1,label:"",isUndoing:!1};const C=r.fromMailboxId?f?.items.filter(y=>y.mailboxId===r.fromMailboxId).map(y=>Fr(y.fullPath))[0]:void 0;return{show:!0,label:Lc(r,C),onUndo:b?d:void 0,isUndoing:v,...r.filterId?{filtersHref:"/settings/filters"}:{}}};function Bc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o}){const i=Kc({accountId:e,messageId:t,threadId:s,mailboxId:n,autoMoved:r,spamReport:o});return i.show?a.jsx(Ml,{label:i.label,onUndo:i.onUndo,undoLabel:i.isUndoing?"Undoing…":"Undo",filtersHref:i.filtersHref}):null}const Cn=(e,t)=>e.filter(s=>!t.has(s.messageId)),Of=e=>e.filter(t=>t.isDeleted!==!0),$s=({mailboxId:e,threadId:t,accountId:s,messages:n,onAfterOptimisticRemove:r})=>{const o=ae(),{pushError:i}=ke(),{mutateAsync:c,isPending:u}=de({...Or(),onMutate:async h=>{const p=new Set(h.body.messageIds??[]),f=t?Ie({path:{threadId:t}}):[],g=je(Rs(p,n??[],e));await Promise.all([o.cancelQueries({queryKey:f}),kt(o,g)]);const b=t?o.getQueriesData({queryKey:f}).filter(m=>m[1]!==void 0).map(([m,x])=>({queryKey:m,data:x})):[],d=jt(o,g);return t&&o.setQueriesData({queryKey:f},m=>m&&{...m,items:Cn(m.items,p)}),wt(o,g,m=>Cn(m,p)),r?.(Array.from(p)),{threadMessagesPrefix:f,listPrefixes:g,previousThreadMessages:b,previousThreadsList:d}},onError:(h,p,f)=>{if(f){for(const b of f.previousThreadMessages)o.setQueryData(b.queryKey,b.data);Ct(o,f.previousThreadsList)}const g=p.body.messageIds?.length??0;i({title:g>1?`Couldn't delete ${g} messages`:"Couldn't delete this message",detail:Me(h),error:h})},onSettled:(h,p,f,g)=>{g&&(t&&o.invalidateQueries({queryKey:g.threadMessagesPrefix}),we(o,g.listPrefixes),s&&o.invalidateQueries({queryKey:Xe({path:{accountId:s}})}))}});return{deleteMessages:l.useCallback(h=>{h.length!==0&&bt(h,p=>c({body:{messageIds:p}}))},[c]),isPending:u}},Va="inline-flex items-center justify-center transition-colors",Qc=z(Va,"min-h-11 min-w-11 rounded hover:bg-surface-raised"),qc=z(Va,"min-h-11 gap-1.5 px-3 rounded text-sm font-medium hover:bg-surface-raised"),Ls=({accountId:e,currentMailboxId:t,onMove:s,disabled:n=!1,disabledHint:r,variant:o="icon-only",label:i,defaultOpen:c=!1})=>{const[u,v]=l.useState(c),[h,p]=l.useState(),f=ws(),g=l.useRef(null),b=i??"Move to folder",d=l.useId(),{t:m}=zr("mail",{useSuspense:!1}),x=na(),{data:C,isLoading:y,isError:j,error:T,refetch:M}=te({...vt({path:{accountId:e}}),staleTime:1/0,enabled:u}),P=Ha(e),{createFolderIn:R}=aa(e),D=l.useMemo(()=>ra({mailboxes:C?.items??[],folderAppointments:P,currentMailboxId:t,translator:x}),[C?.items,P,t,x]),F=oa(C?.items??[]),_=D.find(E=>E.id===h),L=l.useCallback(()=>{v(!1),p(void 0)},[]),K=l.useCallback(()=>{_&&(L(),s(_.id))},[_,L,s]);l.useEffect(()=>{if(!u||!f)return;const E=O=>{g.current&&!g.current.contains(O.target)&&L()},w=O=>{O.key==="Escape"&&L()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",w)}},[u,f,L]);const k=n||!!r,I=a.jsxs("button",{type:"button",onClick:E=>{E.stopPropagation(),!k&&v(w=>!w)},"aria-label":b,"aria-haspopup":f?"tree":"dialog","aria-expanded":u,"aria-controls":u?d:void 0,title:r,className:o==="icon-only"?Qc:qc,children:[a.jsx(xs,{className:o==="icon-only"?"size-5":"size-4"}),o==="compact"&&a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),A=y?a.jsx("div",{className:"px-3 py-5 text-sm text-fg-muted",children:"Loading folders…"}):j?a.jsx("div",{className:"p-3",children:a.jsx(_e,{variant:"inline",title:"Couldn't load folders",error:T,onRetry:()=>M()})}):a.jsx(_r,{folders:D,selectedId:h,delimiter:F,onSelect:p,onCreateFolder:R,onCancel:L,labels:{filterPlaceholder:m("move_picker_filter_placeholder",{defaultValue:"Filter folders…"}),filterAriaLabel:m("move_picker_filter_label",{defaultValue:"Filter folders"})}}),S=_&&a.jsx("div",{className:"shrink-0 border-t border-line p-2",children:a.jsx(H,{variant:"primary",onClick:K,className:"h-11 w-full font-semibold",children:`Move to ${_.label}`})});return f?a.jsxs("div",{ref:g,className:"relative inline-block",children:[I,u&&a.jsxs("div",{id:d,className:z("absolute right-0 mt-1 z-50 w-72 max-h-96 flex flex-col","bg-surface border border-line rounded-md shadow-lg"),children:[A,S]})]}):a.jsxs(a.Fragment,{children:[I,a.jsx(qe.Root,{open:u,onOpenChange:E=>E?v(!0):L(),children:a.jsxs(qe.Portal,{children:[a.jsx(qe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),a.jsxs(qe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{maxHeight:"85dvh"},id:d,children:[a.jsx(qe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-subtle/30"}),a.jsx(qe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:"Move to folder"}),a.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:A}),S]})]})})]})},Hc=({messageId:e,threadId:t,mailboxId:s,isRead:n,accountId:r,fromAddressId:o,isTrusted:i=!1,showRaw:c=!1,onToggleRaw:u})=>{const v=ae(),h=qn(),p=Ho(),{pushError:f}=ke(),g=jo()?.messageId,{mutate:b,isPending:d}=de({...Ut(),onMutate:async A=>{const S=A.body.isRead??!0,E=new Set(A.body.messageIds??[]),w=Ie({path:{threadId:t}}),O=je([s]);await Promise.all([v.cancelQueries({queryKey:w}),kt(v,O)]);const U=v.getQueriesData({queryKey:w}).filter(X=>X[1]!==void 0).map(([X,J])=>({queryKey:X,data:J})),W=jt(v,O);return v.setQueriesData({queryKey:w},X=>X&&{...X,items:Dt(X.items,E,S)}),wt(v,O,X=>Dt(X,E,S)),{threadMessagesPrefix:w,listPrefixes:O,previousThreadMessages:U,previousThreadsList:W}},onError:(A,S,E)=>{if(E){for(const O of E.previousThreadMessages)v.setQueryData(O.queryKey,O.data);Ct(v,E.previousThreadsList)}const w=S.body.isRead??!0;f({title:w?"Couldn't mark as read":"Couldn't mark as unread",detail:Me(A),error:A})},onSettled:(A,S,E,w)=>{w&&(v.invalidateQueries({queryKey:w.threadMessagesPrefix}),we(v,w.listPrefixes))}}),m=l.useCallback(A=>{g&&A.includes(g)&&h({to:"/mail/$mailboxId",params:{mailboxId:s},search:S=>S,hash:p})},[g,s,h,p]),{deleteMessages:x,isPending:C}=$s({mailboxId:s,threadId:t,onAfterOptimisticRemove:m}),{moveMessages:y,isPending:j}=Gt({mailboxId:s,threadId:t,accountId:r,onAfterOptimisticRemove:m}),{toggleTrusted:T,isPending:M,error:P,reset:R}=Wn({messageId:e}),D=()=>{b({body:{messageIds:[e],isRead:!1}})},F=()=>{x([e])},_=()=>{o&&T(o,i)},L=d||C||j||M,K=L||!o,k=l.useCallback(A=>{y([e],A)},[y,e]),I=o?void 0:"Sender has no parseable address";return a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(Ls,{accountId:r,currentMailboxId:s,onMove:k,disabled:L,label:"Move this message"}),a.jsxs(wo,{trigger:a.jsx(Lo,{className:"size-4"}),children:[a.jsxs(It,{onClick:_,disabled:K,children:[i?a.jsx(Bt,{className:"size-4 text-positive"}):a.jsx(Ot,{className:"size-4 opacity-0"}),a.jsx("span",{title:I,children:"Trusted sender"})]}),n&&a.jsxs(It,{onClick:D,disabled:L,children:[a.jsx(Ts,{className:"size-4"}),"Mark as unread"]}),u&&a.jsxs(It,{onClick:u,children:[a.jsx(ba,{className:"size-4"}),c?"Show formatted":"Show raw email"]}),a.jsx(Co,{}),a.jsxs(It,{onClick:F,disabled:L,destructive:!0,children:[a.jsx(zt,{className:"size-4"}),"Delete"]})]})]}),P&&a.jsx("div",{className:"w-64",children:a.jsx(_e,{variant:"inline",title:"Couldn't update trust",error:P,onRetry:()=>{R(),_()}})})]})},Gc=e=>e==="link-expired"||e==="not-ready";class ms extends Error{reason;status;constructor(t,s,n){super(s),this.name="AttachmentFetchError",this.reason=t,this.status=n}}const Vc="x-remit-403-reason",Wc="expired",Yc=(e,t)=>{if(t?.trim()===Wc)return"link-expired";const s=Go(e,t);return s==="auth"?"auth":s==="body-missing"?"missing":"generic"},Xc=300*1e3,Sn=async(e,t)=>{const s={},n=await t();n&&(s.Authorization=`Bearer ${n}`);const r=await Br(e,{headers:s,signal:AbortSignal.timeout(Xc)});if(r.status===202)throw new ms("not-ready","Attachment is still being fetched from the mail server",202);if(!r.ok)throw new ms(Yc(r.status,r.headers.get(Vc)),`Failed to download attachment (${r.status} ${r.statusText})`,r.status);return r.blob()},Jc=(e,t,s)=>{switch(e){case"auth":return{title:"Your session expired",detail:`Sign in again, then download ${t} once more. Other parts of the app may also stop responding until you do.`};case"link-expired":return{title:"This download link expired and could not be renewed",detail:`Reload the page, then download ${t} again. If that keeps failing, this is worth reporting.`};case"missing":return{title:"This attachment is missing from storage",detail:"Remit has the message but not the file. Re-sync the account from Settings, then try again."};case"not-ready":return{title:"Still fetching this attachment",detail:"Remit is downloading it from the mail server now. Try again in a few seconds."};default:return{title:"Couldn't download this attachment",detail:s}}},Nn=e=>e instanceof ms?e.reason:"generic",Zc=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while downloading this attachment.",eu=(e,t,s)=>{if(e!=="auth")return Ur(Kr({title:`Bug: attachment download failed (${e})`,errorMessage:`Downloading "${t}" failed: ${s}`}))},tu=(e,t)=>{const s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,n.rel="noopener",document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),0)},su=e=>{const t=e.toUpperCase();return t==="OCTET-STREAM"?"FILE":t},nu=e=>{const t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return t.length>0?`attachment.${t}`:"attachment"},Tn=e=>e.filter(t=>!t.isMultipart&&t.disposition===ti.Attachment&&t.contentUrl.length>0).map(t=>({bodyPartId:t.bodyPartId,filename:Po(t.dispositionFilename??"",nu(t.mediaSubtype)),typeLabel:su(t.mediaSubtype),sizeOctets:t.sizeOctets,contentUrl:t.contentUrl})),En={status:"idle"},au=({messageId:e,bodyParts:t,hasAttachment:s=!1,className:n})=>{const{getToken:r}=Qr(),o=ae(),[i,c]=l.useState({}),u=l.useMemo(()=>Tn(t??[]),[t]),v=qr({path:{messageId:e}}),h=b=>Sn(b.contentUrl,r).catch(d=>{if(!Gc(Nn(d)))throw d;return o.refetchQueries({queryKey:v}).then(()=>{const m=o.getQueryData(v),x=m?Tn(m.bodyParts).find(C=>C.bodyPartId===b.bodyPartId):void 0;return Sn(x?.contentUrl??b.contentUrl,r)})}),p=(b,d)=>c(m=>({...m,[b]:d})),f=b=>{const d=u.find(m=>m.bodyPartId===b);if(!d)throw new Error(`No attachment part ${b} on message ${e}`);p(b,{status:"downloading"}),h(d).then(m=>{tu(m,d.filename),p(b,En)}).catch(m=>{const x=Nn(m),C=Zc(m),{title:y,detail:j}=Jc(x,d.filename,C);p(b,{status:"failed",title:y,detail:j,reportUrl:eu(x,d.filename,C)})})},g=s&&t!==void 0&&u.length===0;return a.jsx(El,{className:n,attachments:u.map(b=>({attachmentId:b.bodyPartId,filename:b.filename,typeLabel:b.typeLabel,sizeOctets:b.sizeOctets,download:i[b.bodyPartId]??En})),onDownload:f,hasUnlistedAttachment:g})},ru=({messageId:e,threadId:t,mailboxId:s,accountId:n,isRead:r,isStarred:o,onToggleStar:i,fromAddressId:c,isTrusted:u,showRaw:v,onToggleRaw:h,onReply:p,onReplyAll:f,onForward:g})=>{const b=ae(),{deleteMessages:d}=$s({mailboxId:s,threadId:t}),{moveMessages:m}=Gt({mailboxId:s,threadId:t,accountId:n}),{toggleTrusted:x}=Wn({messageId:e}),{mutate:C}=de({...Ut(),onSettled:()=>{b.invalidateQueries({queryKey:Ie({path:{threadId:t}})}),we(b,je([s]))}}),y=l.useCallback(P=>{m([e],P)},[m,e]),j=l.useCallback(()=>{d([e])},[d,e]),T=l.useCallback(()=>{C({body:{messageIds:[e],isRead:!r}})},[C,e,r]),M=[];return c&&M.push({key:"trusted",label:u?"Trusted sender":"Mark sender trusted",icon:u?a.jsx(Bt,{className:"size-4 text-positive"}):a.jsx(Ot,{className:"size-4"}),onSelect:()=>x(c,u)}),h&&M.push({key:"raw",label:v?"Show formatted":"Show raw email",icon:a.jsx(ba,{className:"size-4"}),onSelect:h}),a.jsx(Ta,{hasThread:!0,onReply:p,onReplyAll:f,onForward:g,isStarred:o,onToggleStar:i,onDelete:j,isRead:r,onToggleRead:T,overflowItems:M,moveSlot:n?a.jsx(Ls,{accountId:n,currentMailboxId:s,onMove:y,label:"Move this message"}):void 0})},ou=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading raw email",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}),iu=({messageId:e,enabled:t=!0})=>{const{data:s,isLoading:n,isError:r,error:o,refetch:i}=te({...Hr({path:{messageId:e}}),enabled:t});if(n)return a.jsx("div",{className:"message-body",children:a.jsx(ou,{})});if(r)return a.jsx("div",{className:"message-body",children:a.jsx(_e,{variant:"inline",title:"Couldn't load the raw email",error:o,onRetry:()=>i()})});const c=s?.raw??"";return c===""?a.jsx("div",{className:"message-body",children:a.jsx("p",{className:"text-fg-muted text-sm italic",children:"No raw source available for this message."})}):a.jsx("div",{className:"message-body",children:a.jsx("pre",{className:"email-text whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-sunken rounded-md p-3 max-h-[32rem] overflow-auto",children:c})})},lu=()=>a.jsx(Bt,{className:"inline-block size-4 ml-1 -mt-0.5 text-positive align-middle","aria-label":"Trusted sender","data-testid":"trusted-sender-badge"}),Wa=(e,t)=>({id:e.messageId,fromName:e.fromName??e.fromEmail??"?",fromEmail:e.fromEmail??"",toLabel:"",dateLabel:t,snippet:e.snippet||"",bodyHtml:""}),Ya=({isStarred:e,onToggleStar:t,isStarPending:s,hoverReveal:n})=>a.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t()},disabled:s,"aria-label":e?"Remove star":"Add star",className:z("shrink-0 p-0.5 rounded transition-colors",e?"text-warning":z("text-fg-subtle hover:text-warning",n&&"opacity-0 group-hover:opacity-100 focus:opacity-100"),s&&"opacity-50"),children:a.jsx(Ye,{className:z("size-3.5",e&&"fill-current")})}),cu=({threadMessage:e,isFocused:t,onToggle:s,onToggleStar:n,isStarPending:r})=>{const o=ta(e.sentDate,"datetime"),i=Wa(e,o);return a.jsx(Ea,{message:i,onClick:s,isFocused:t,isUnread:!e.isRead,trailing:a.jsxs(a.Fragment,{children:[e.hasAttachment&&a.jsx(Qt,{className:"size-3 shrink-0 text-fg-subtle",role:"img","aria-label":"Has an attachment"}),a.jsx(Ya,{isStarred:e.hasStars,onToggleStar:n,isStarPending:r,hoverReveal:!0}),a.jsx("span",{"data-testid":"message-date",className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:o})]})})},uu=({threadMessage:e,messageData:t,isLoading:s,isError:n,error:r,onRetry:o,isFocused:i,onToggle:c,onToggleStar:u,isStarPending:v,accountId:h,showRaw:p,onToggleRaw:f,mobile:g,onReply:b,onReplyAll:d,onForward:m})=>{const x=ta(e.sentDate,"long"),C=!e.isRead,y=t?.envelope.from[0]?.flags?.trusted?.value===!0,j=t?.envelope.from[0]?.addressId,T=Wa(e,x),M=e.autoMoved||e.spamReport?a.jsx(Bc,{accountId:h,messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,autoMoved:e.autoMoved,spamReport:e.spamReport}):null;return a.jsx(Ma,{message:T,isFocused:g?!1:i,onHeaderClick:c,senderBadge:y?a.jsx(lu,{}):void 0,trailing:a.jsx("span",{"data-testid":"message-date",className:"text-2xs text-fg-subtle",children:x}),to:t?a.jsx(ol,{label:"To",addresses:t.envelope.to}):null,indicators:M||!g?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-0.5",children:[M,!g&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex items-center justify-end gap-1",children:a.jsx(Ya,{isStarred:e.hasStars,onToggleStar:u,isStarPending:v})}),C&&a.jsx("span",{className:"size-1.5 rounded-full bg-accent","aria-label":"Unread"})]})]}):void 0,actionMenu:g?void 0:a.jsx(Hc,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,isRead:e.isRead,accountId:h,fromAddressId:j,isTrusted:y,showRaw:p,onToggleRaw:f}),actionBar:g?a.jsx(ru,{messageId:e.messageId,threadId:e.threadId,mailboxId:e.mailboxId,accountId:h,isRead:e.isRead,isStarred:e.hasStars,onToggleStar:u,fromAddressId:j,isTrusted:y,showRaw:p,onToggleRaw:f,onReply:b,onReplyAll:d,onForward:m}):void 0,body:s?a.jsxs("div",{className:"mt-3 animate-pulse space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/2"})]}):n&&Gr(r)?a.jsx("div",{className:"mt-3",children:a.jsx(Fa,{message:"This message has been deleted"})}):n?a.jsx("div",{className:"mt-3",children:a.jsx(_e,{variant:"inline",title:"Couldn't load this message",error:r,onRetry:o})}):p?a.jsx("div",{className:"mt-3",children:a.jsx(iu,{messageId:e.messageId})}):a.jsxs("div",{className:"mt-3",children:[a.jsx(zo,{bodyParts:t?.bodyParts,messageId:e.messageId,fromAddressId:t?.envelope.from[0]?.addressId,isTrusted:y,category:Qa(e.category)}),a.jsx(au,{messageId:e.messageId,bodyParts:t?.bodyParts,hasAttachment:e.hasAttachment,className:"mt-4"})]})})},du=({threadMessage:e,isExpanded:t,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,mobile:c,onReply:u,onReplyAll:v,onForward:h})=>{const[p,f]=l.useState(!1),{data:g,isLoading:b,isError:d,error:m,refetch:x}=te({..._t({path:{messageId:e.messageId}}),enabled:t,meta:{softError:!0}});return t?a.jsx(uu,{threadMessage:e,messageData:g,isLoading:b,isError:d,error:m,onRetry:()=>x(),isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o,accountId:i,showRaw:p,onToggleRaw:()=>f(C=>!C),mobile:c,onReply:u,onReplyAll:v,onForward:h}):a.jsx(cu,{threadMessage:e,isFocused:s,onToggle:n,onToggleStar:r,isStarPending:o})},fu=()=>a.jsxs("div",{className:"animate-pulse p-4",children:[a.jsx("div",{className:"h-6 bg-surface-sunken rounded w-3/4 mb-5"}),a.jsx("div",{className:"space-y-4",children:Array.from({length:2}).map((e,t)=>a.jsxs("div",{className:"flex gap-3 py-3",children:[a.jsx("div",{className:"size-10 bg-surface-sunken rounded-full shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-32 mb-2"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"})]})]},t))})]}),zf=({threadId:e,mailboxId:t,subject:s,selectedMessageId:n,authenticity:r,onOpenIntelligence:o,onBack:i,onSwipeNext:c,onSwipePrevious:u,mobileIntelligenceOpen:v})=>{const h=ws(),{handlers:p}=Rc({onSwipeLeft:c,onSwipeRight:u}),{accountId:f}=Oa(t),{data:g,isLoading:b,isError:d,error:m,refetch:x}=te({...Hn({path:{threadId:e}})}),C=l.useMemo(()=>g?.items??[],[g?.items]),y=C[C.length-1],j=l.useMemo(()=>[...C].reverse(),[C]),T=l.useRef(new Map),[M,P]=l.useState(new Set),[R,D]=l.useState(null),[F,_]=l.useState(0);l.useEffect(()=>{if(C.length>0&&e!==R){D(e);const B=new Set([C[C.length-1].threadMessageId]);if(n){const q=C.find(oe=>oe.messageId===n);q&&B.add(q.threadMessageId)}P(B),_(0)}},[e,C,R,n]);const L=l.useCallback(B=>{P(q=>{const oe=new Set(q);return oe.has(B)?oe.delete(B):oe.add(B),oe})},[]),K=l.useCallback(B=>{const q=j[B];if(!q)return;T.current.get(q.threadMessageId)?.scrollIntoView({behavior:"smooth",block:"nearest"})},[j]),k=l.useCallback(()=>{if(j.length===0)return;const B=Math.min(F+1,j.length-1);_(B),K(B)},[j.length,F,K]),I=l.useCallback(()=>{if(j.length===0)return;const B=Math.max(F-1,0);_(B),K(B)},[j.length,F,K]),A=l.useCallback(()=>{const B=j[F];B&&L(B.threadMessageId)},[j,F,L]),{data:S}=te({...xt(),staleTime:1/0}),E=S?.accounts?.[0];Tc({messages:C,expandedIds:M,threadId:e,mailboxId:t,accountId:E?.accountId});const{toggleStar:w,isPending:O,pendingMessageId:U}=Ba({threadId:e,mailboxId:t,messages:C}),W=Vo(),X=Wo(),J=n??y?.messageId,G=l.useCallback((B,q)=>{q&&X({threadId:e,messageId:q,mode:B})},[X,e]),le=l.useCallback(()=>G("reply",J),[G,J]),re=l.useCallback(()=>G("reply-all",J),[G,J]),he=l.useCallback(()=>G("forward",J),[G,J]),V=l.useRef(null),fe=W?.kind==="reply"?`${W.mode}:${W.sourceMessageId}`:void 0;if(l.useEffect(()=>{fe&&V.current?.scrollIntoView({behavior:"smooth",block:"start"})},[fe]),Jo({enabled:!b&&C.length>0&&W===void 0,bindings:[{key:"j",handler:k,preventDefault:!0},{key:"ArrowDown",handler:k,preventDefault:!0},{key:"k",handler:I,preventDefault:!0},{key:"ArrowUp",handler:I,preventDefault:!0},{key:"Enter",handler:A,preventDefault:!0},{key:"o",handler:A,preventDefault:!0},{key:"r",handler:le,preventDefault:!0},{key:"R",handler:re,noModifiers:!1,preventDefault:!0},{key:"f",handler:he,preventDefault:!0}]}),b)return a.jsx(fu,{});if(d)return a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(_e,{title:W?"Couldn't load this conversation, so there is nothing to answer":"Couldn't load this conversation",error:m,onRetry:()=>x()})});if(C.length===0)return a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:W?a.jsx(_e,{variant:"inline",title:"There is nothing here to answer",error:"This conversation has no messages left. Another mail client may have moved or deleted them."}):a.jsx(Fa,{message:"No messages in this thread"})});const ge=s||C[0]?.subject||"(No subject)",me=C.length,ce=B=>a.jsx("div",{"data-testid":"conversation-messages",children:j.map((q,oe)=>a.jsx("div",{ref:Ae=>{Ae&&T.current.set(q.threadMessageId,Ae)},children:a.jsx(du,{threadMessage:q,isExpanded:M.has(q.threadMessageId),isFocused:oe===F,onToggle:()=>L(q.threadMessageId),onToggleStar:()=>w(q.messageId,q.hasStars),isStarPending:O&&U===q.messageId,accountId:f,mobile:B,onReply:B?()=>G("reply",q.messageId):void 0,onReplyAll:B?()=>G("reply-all",q.messageId):void 0,onForward:B?()=>G("forward",q.messageId):void 0})},q.threadMessageId))}),be=W&&a.jsx("div",{ref:V,children:W.kind==="reply"?a.jsx(vc,{surface:W}):a.jsx("div",{className:"border-b border-line bg-canvas p-4",children:a.jsx(_e,{variant:"inline",title:"That is not a way to answer a message",error:`"${W.segment}" is not reply, reply-all or forward.`})})}),xe=a.jsxs("header",{className:"border-b border-line px-5 pt-5 pb-3",children:[a.jsx("h1",{className:"max-w-2xl text-lg font-semibold leading-snug text-fg",children:ge}),a.jsxs("p",{className:"mt-1 text-2xs text-fg-subtle",children:[me," ",me===1?"message":"messages"]})]});return h?a.jsxs("article",{className:"h-full flex flex-col",children:[xe,r?.dkimMismatch&&a.jsx(kn,{authenticity:r,onOpenIntelligence:o}),a.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[be,ce(!1)]})]}):a.jsxs(Nl,{thread:{subject:ge,messages:[]},onBack:i??(()=>{}),intelligenceOpen:v,onToggleIntelligence:o,touchHandlers:p,children:[r?.dkimMismatch&&a.jsx(kn,{authenticity:r,onOpenIntelligence:o}),be,ce(!0)]})},mu=10,Xa=e=>({q:e?.toLowerCase()??"",limit:mu}),pu=(e,t)=>{if(!t)return;const s=t.toLowerCase();return e?.find(n=>n.normalizedEmail===s)};function hu(e){const t=new Date(e),s=new Date;return t.toDateString()===s.toDateString()?"today":Zo(t,{month:"short",year:"numeric"})}function Ja(e){if(!e)return!0;const[,t]=e.split("@");return t?!t.includes("."):!0}const gu="We can't verify the sender of this email, which could mean it's from an insecure source.",bu="We couldn't read this sender's address, so we can't confirm who really sent this message.";function xu(e,t){const s=e.category??"personal";return{value:Wr(s)?s:"uncategorized",overridden:t?.flags?.category?.value!=null&&t.flags.category.value!==e.category}}function vu(e,t){return{name:e.fromName??e.fromEmail??"Unknown",email:e.fromEmail??"",trust:e.senderTrust,firstSeenLabel:t?hu(t.createdAt):"unknown",inboundCount:t?.inboundCount,replyCount:t?.replyCount,addressUnverified:Ja(e.fromEmail)}}function yu(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 Mn(e){if(e.fromName&&e.fromName!==e.fromEmail)return e.fromName}function ku(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function ju(e,t){const s=[],n=e.displayNameCorrespondence;t&&(n===Xs.Unrelated?s.push(`The name it shows, "${t}", has nothing to do with ${e.fromDomain}.`):n===Xs.Lookalike&&s.push(`The name it shows, "${t}", only looks like ${e.fromDomain}.`));const r=wu(e.offDomainLinkDomains);return r.length>0&&s.push(`Its links go to ${ku(r.slice(0,3))}.`),s}function wu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Cu(e,t){const s=t>0?t:void 0;if(Ja(e.fromEmail))return{verdict:"mismatch",fromDomain:"",addressUnreadable:!0,summary:bu,similarCount:s};const n=e.authenticity;if(!n)return{verdict:"caution",fromDomain:e.fromEmail?.split("@")[1]??"",summary:gu};if(!n.dkimMismatch){const v=Mn(e),h=ju(n,v);return h.length>0?{verdict:"caution",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,claimedBrand:v,summary:h.join(" ")}:{verdict:"aligned",fromDomain:n.fromDomain,dkimDomain:n.dkimDomain,summary:n.dkimDomain?`This message was signed by ${n.dkimDomain}.`:"Nothing looks unusual about this sender."}}const r=n.fromDomain,o=n.dkimDomain,i=Mn(e),c=o?`it was actually sent from ${o}`:"its signature failed to verify",u=i?`The display name claims "${i}", but ${c}${o?` — not ${r}`:""}. Real senders use their own address.`:`This message claims to be from ${r}, but ${c}.`;return{verdict:"mismatch",fromDomain:r,dkimDomain:o,claimedBrand:i,summary:u,similarCount:s}}function Su(e,t){const s=e?.fromEmail??null,n=e?.subject??"",{data:r,error:o}=te({...vs({query:Xa(s??void 0)}),enabled:!!s,staleTime:3e4}),i=pu(r?.items,s??void 0),c=[n,s].filter(Boolean).join(" "),{data:u,isLoading:v,error:h}=te({...Vr({query:{query:c,limit:5}}),enabled:!!(e&&c.length>3),staleTime:6e4,retry:1});return{data:l.useMemo(()=>{if(!e)return null;const f=(u?.items??[]).filter(x=>x.messageId!==e.messageId).map(x=>({id:x.messageId,threadId:x.threadId,mailboxId:t!=null&&x.mailboxIds.includes(t)?t:x.mailboxIds[0]??"",fromName:x.fromName??"",subject:x.subject??"(No subject)",timeLabel:x.sentDate!=null?Je(x.sentDate*1e3):"",matched:x.matchedChunkType})),g=vu(e,i),b=Cu(e,f.length),d=xu(e,i),m=yu(i);return{sender:g,authenticity:b,category:d,flags:m,similar:f}},[e,i,u,t]),isSimilarLoading:v,similarError:h,similarErrorIsFatal:Qs(h),addressErrorIsFatal:Qs(o),addressId:i?.addressId,address:i}}function Nu(e,t){const s={...e??{}};for(const[n,r]of Object.entries(t))r==null?delete s[n]:s[n]={...r,setAt:r.setAt??Date.now()};return s}function Tu({addressId:e,senderEmail:t}){const s=ae(),{pushError:n}=ke(),r=Yr({query:Xa(t)}),{mutate:o,isPending:i}=de({...Xr(),onMutate:async u=>{const v=u.body.flags??{};await s.cancelQueries({queryKey:r});const h=s.getQueryData(r);return s.setQueryData(r,p=>p&&{...p,items:p.items.map(f=>f.addressId===u.path.addressId?{...f,flags:Nu(f.flags,v)}:f)}),{previous:h}},onError:(u,v,h)=>{h?.previous!==void 0&&s.setQueryData(r,h.previous),n({title:"Couldn't update sender preference",detail:Me(u),error:u})},onSettled:()=>{s.invalidateQueries({queryKey:r})}});return{updateFlags:l.useCallback(u=>{if(!e){Jr(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 _f=e=>e==="vip"?"A sender you know":e==="wellknown"?"You've emailed them before":"Passed authentication",Eu=e=>e.senderTrust!=="vip"&&e.senderTrust!=="wellknown"?!1:e.authenticity?.dkimMismatch!==!0;function Uf(e,t){e.recordEvent("rescue.candidates_surfaced",{count:String(t)})}function Kf(e,t){e.recordEvent("rescue.flow_opened",{count:String(t)})}function Bf(e,t){e.recordEvent("rescue.committed",{selected:String(t.selected),total:String(t.total),destination:t.toInbox?"inbox":"other"})}function Mu(e,t){e.recordEvent("rescue.sent_to_junk",{count:String(t.count),senderTrust:t.senderTrust,wasRescuable:String(t.wasRescuable)})}const Iu=["personal","newsletter","marketing","automated","transactional","social"],Ru=e=>e.spamReport?"notSpam":"reportSpam",Au=e=>{const{similarError:t,similarErrorIsFatal:s,isSimilarLoading:n}=e;return t&&!s?"error":n?"loading":"ready"};function $u(){return a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex-1 animate-pulse space-y-4 p-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface shrink-0"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:"h-3 rounded bg-surface w-3/4"}),a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/2"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"h-8 rounded bg-surface"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-surface w-1/4"}),a.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Array.from({length:5}).map((e,t)=>a.jsx("div",{className:"h-6 w-16 rounded bg-surface"},t))})]})]})]})}function Lu({isOpen:e,current:t,onSelect:s,onCancel:n}){return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx(eo,{label:"Dismiss reclassify sender",onDismiss:n,className:"backdrop-blur-sm"}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Reclassify sender",className:"relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Reclassify this sender"}),a.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:"Set a category override for future messages from this sender."}),a.jsx("div",{className:"mt-4 flex flex-col gap-1",children:Iu.map(r=>a.jsxs("button",{type:"button",onClick:()=>s(r),className:`flex min-h-11 items-center justify-between rounded px-3 text-left text-sm capitalize transition-colors hover:bg-surface-raised ${r===t?"font-semibold text-accent":"text-fg"}`,children:[r,r===t&&a.jsx("span",{className:"text-2xs text-fg-subtle",children:"current"})]},r))}),a.jsx("div",{className:"mt-6 flex justify-end",children:a.jsx("button",{type:"button",onClick:n,className:"inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised",children:"Cancel"})})]})]}):null}function Pu({thread:e,onClose:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}){const{data:i,addressId:c,isSimilarLoading:u,similarError:v,similarErrorIsFatal:h}=Su(e,s),[p,f]=l.useState(!1),g=e.fromEmail??void 0,{updateFlags:b}=Tu({addressId:c,senderEmail:g}),{reportSpam:d,notSpam:m,isReporting:x,isRestoring:C}=Ga({mailboxId:e.mailboxId,threadId:e.threadId,accountId:n,onAfterOptimisticRemove:o}),y=Zr(),j=Ru(e),T=l.useCallback(()=>{m([e.messageId])},[m,e.messageId]),M=l.useCallback(()=>{Mu(y,{count:1,senderTrust:e.senderTrust,wasRescuable:Eu(e)}),d([e.messageId])},[d,e,y]),P=l.useCallback(()=>{},[]),R=l.useCallback(()=>{const A=i?.flags?.vip!==!0;b({vip:{value:A}})},[i?.flags?.vip,b]),D=l.useCallback(()=>{const A=i?.flags?.muted!==!0;b({muted:{value:A}})},[i?.flags?.muted,b]),F=l.useCallback(()=>{const A=i?.flags?.unsubscribed!==!0;b({unsubscribed:{value:A}})},[i?.flags?.unsubscribed,b]),_=l.useCallback(A=>{f(!1),b({category:{value:A}})},[b]),L=c!==void 0,K={onToggleVip:L?R:void 0,onToggleMute:L?D:void 0,onToggleUnsubscribe:L?F:void 0,onReclassify:L?()=>f(!0):void 0,onNotSpam:j==="notSpam"?T:void 0,onReportSpam:j==="reportSpam"?M:void 0},k=({mailboxId:A,threadId:S,messageId:E,className:w,ariaLabel:O,children:U})=>a.jsx(ea,{to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:A,threadId:S,messageId:E},search:W=>W,variant:"row",className:w,"aria-label":O,children:U});if(!i)return a.jsx($u,{});const I=Au({similarError:v,similarErrorIsFatal:h,isSimilarLoading:u});return a.jsxs(a.Fragment,{children:[a.jsx(ka,{data:i,onClose:t,hideCloseButton:r,onShowSimilar:P,actions:K,similarState:I,similarLinkComponent:k,reportSpamPending:x,notSpamPending:C,className:"border-l-0 h-full w-full"}),a.jsx(Lu,{isOpen:p,current:i.category.value,onSelect:_,onCancel:()=>f(!1)})]})}const Qf=({onClose:e,thread:t,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o})=>t?a.jsx(Pu,{thread:t,onClose:e,mailboxId:s,accountId:n,hideCloseButton:r,onAfterOptimisticRemove:o}):a.jsxs("aside",{className:"flex h-full w-full flex-col bg-surface-sunken",children:[a.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset",children:[a.jsx(We,{className:"size-3.5 text-fg-subtle"}),a.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Intelligence"})]}),a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-row-inset text-center",children:[a.jsx(We,{className:"size-8 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:"Intelligence"}),a.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Sender trust, authenticity and similar messages will appear here."})]})]}),Du={delete:(e,t)=>`Deleting ${e} of ${t}…`,move:(e,t)=>`Moving ${e} of ${t}…`,markRead:(e,t)=>`Marking ${e} of ${t} as read…`},Za={delete:"moved to Trash",move:"moved",markRead:"marked as read"},Fu={delete:"couldn't be deleted",move:"couldn't be moved",markRead:"couldn't be marked as read"},Ou={delete:"Couldn't delete these messages",move:"Couldn't move these messages",markRead:"Couldn't mark these messages as read"},zu={delete:"The delete didn't finish.",move:"The move didn't finish.",markRead:"The update didn't finish."},qf=(e,t,s)=>Du[e](Ue(t),Ue(s)),Hf=(e,t)=>`${Ue(t)} ${Za[e]}. Your mail server is still catching up.`,Gf=e=>`Stopped after ${Ue(e)}`,Vf=(e,t,s)=>`${Ue(t)} of ${Ue(s)} ${Za[e]}. Nothing was sent for the rest, so they are untouched.`,_u=(e,t)=>t>0?`Stopped after ${Ue(t)} — some messages ${Fu[e]}`:Ou[e],Uu=e=>zu[e],Wf=e=>e==="delete"?"danger":"info",Ku=100,Bu=(e,t)=>e.kind==="move"?[t,e.destinationMailboxId]:[t],Qu=({mailboxId:e,accountId:t,enabled:s,predicateKey:n,searchQuery:r})=>{const[o,i]=l.useState({kind:"idle"}),[c,u]=l.useState(void 0),[v,h]=l.useState(void 0),p=l.useRef(!1),f=l.useRef(!1),g=ae(),{pushError:b}=ke();l.useEffect(()=>{f.current||(p.current=!0),i({kind:"idle"})},[s,n]);const d=l.useRef(r);d.current=r;const m=l.useCallback(R=>async D=>{const{data:F}=await qs({path:{mailboxId:e},query:{...R,continuationToken:D,limit:Ku},throwOnError:!0});return{ids:(F.items??[]).map(_=>_.messageId),continuationToken:F.continuationToken}},[e]),x=l.useCallback(async()=>{const{data:R}=await qs({path:{mailboxId:e},query:{...d.current,count:!0,results:!1},throwOnError:!0});if(R.count===void 0)throw new Error("the search returned no count for the selection");return R.count},[e]),C=l.useCallback(R=>async D=>{if(R.kind==="move"){const{data:_}=await to({body:{messageIds:D,destinationMailboxId:R.destinationMailboxId},throwOnError:!0});return _}if(R.kind==="markRead"){const{data:_}=await so({body:{messageIds:D,isRead:!0},throwOnError:!0});return _}const{data:F}=await no({body:{messageIds:D},throwOnError:!0});return F},[]),y=l.useCallback(R=>{we(g,je(Bu(R,e))),t&&g.invalidateQueries({queryKey:Xe({path:{accountId:t}})})},[g,e,t]),j=l.useCallback(()=>{p.current=!1,i({kind:"counting"}),x().then(R=>{if(p.current){i({kind:"idle"});return}i({kind:"escalated",total:R})},R=>{b(Hs("Couldn't count matching messages","The count didn't finish.",R)),i({kind:"idle"})})},[x,b]),T=l.useCallback(()=>{p.current=!0},[]),M=l.useCallback(()=>{f.current||(p.current=!0,i({kind:"idle"}))},[]),P=l.useCallback(async(R,D)=>{p.current=!1,f.current=!0,u(R);const F=k=>h(wc(k)),_=C(R),L=m(d.current);let K;try{K=D!==void 0?await za(D,_,F,()=>p.current):await jc(L,o.kind==="escalated"?o.total:0,_,F,()=>p.current)}finally{f.current=!1}return u(void 0),h(void 0),i({kind:"idle"}),K.error&&b(Hs(_u(R.kind,K.done),Uu(R.kind),K.error)),K.done>0&&y(R),K},[C,m,o,b,y]);return{phase:o,escalate:j,stop:T,clear:M,isRunning:c!==void 0,runningAction:c,progress:v,runAction:P}},qu=120,Hu=({keyboardFocusedMessageId:e,openMessageId:t,enabled:s,open:n,delayMs:r=qu})=>{const o=l.useRef(n);o.current=n;const i=l.useRef(void 0);l.useEffect(()=>{const c=e;if(!s){i.current=c;return}if(c===void 0||c===t)return;if(c===i.current){i.current=void 0;return}const u=setTimeout(()=>o.current(c),r);return()=>clearTimeout(u)},[s,e,t,r])},er="This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folder roles.",Gu="These are already in Junk, so there is nowhere to file them.",Vu=(e,t)=>e!==void 0&&e!==t?e:void 0,Yf=(e,t)=>{if(Vu(e,t)===void 0)return e===void 0?er:Gu};function Wu(e,t){if(e.length!==0)return t!==void 0&&e.includes(t)?t:e[0]}const Yu={title:"",navSlot:null,titleMeta:null,searchSlot:null,searchField:null,searchResults:null,makeFilterSlot:null},ps=l.createContext(Yu),tr=()=>l.useContext(ps),sr=8,nr=e=>e==="From"||e==="FromDomain",Xu=e=>({value:e.email,label:e.displayName??e.email,...e.displayName?{hint:e.email}:{},...e.fromSelection?{source:"selected"}:{}}),Ju=e=>{const t=Pa(e.email);if(t!==null)return{value:t,...e.fromSelection?{source:"selected"}:{}}},Zu=(e,t)=>e.value.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t),ed=(e,t,s)=>{if(!nr(e))return[];const n=t.trim().toLowerCase(),r=new Set,o=[];for(const i of s){if(i.email.trim()==="")continue;const c=e==="From"?Xu(i):Ju(i);if(!c)continue;const u=c.value.toLowerCase();if(!(u===""||r.has(u))&&(r.add(u),u!==n&&!(n!==""&&!Zu(c,n))&&(o.push(c),o.length===sr)))break}return o},td=250,sd=2,nd=(e,t,s)=>{const n=t.trim(),r=sa(n,td),o=e!==void 0&&nr(e),{data:i}=te({...vs({query:{q:r,limit:sr}}),enabled:o&&r.length>=sd});if(!o||e===void 0)return[];const c=[...s.map(u=>({email:u,fromSelection:!0})),...(i?.items??[]).map(u=>({email:u.normalizedEmail,...u.displayName?{displayName:u.displayName}:{}}))];return ed(e,n,c)},ar=12,ad=e=>{const{envelope:t}=e,s=t.from[0];return{id:t.messageId,sender:s?Da({normalizedEmail:s.normalizedEmail,displayName:s.displayName}):"Unknown",subject:t.subject??"(No subject)",date:Je(t.date)}},rd=(e,t)=>{const s=e!==void 0&&t!==void 0,{data:n,isLoading:r}=te({...ao({path:{mailboxId:e??""},query:{...t,limit:ar}}),enabled:s,staleTime:3e4});return{messages:(n?.items??[]).map(od),isPending:s&&r}},od=e=>({id:e.messageId,sender:e.fromName||e.fromEmail||"Unknown",subject:e.subject??"(No subject)",date:Je(e.sentDate)}),id=e=>js({queries:e.slice(0,ar).map(t=>({..._t({path:{messageId:t}}),staleTime:Number.POSITIVE_INFINITY})),combine:t=>({messages:t.map(s=>s.data).filter(s=>s!==void 0).map(ad),isPending:t.some(s=>s.isPending)})}),ld=e=>({matchOperator:"Or",literalClauses:Ht(e)}),cd=(e,t,s)=>{const n=de(ro()),{mutate:r,reset:o}=n,[i,c]=l.useState(!1),u=l.useMemo(()=>qt(s),[s]),v=l.useCallback(()=>{!e||!t||(c(!1),r({path:{accountId:e},body:Js({anchorMessageId:t,matchOperator:"And",literalClauses:[]})}))},[e,t,r]),h=l.useCallback(()=>{c(!1),o()},[o]),p=n.data,f=p?.semanticUnavailable===!0&&!i&&u.length>0;l.useEffect(()=>{!f||!e||(c(!0),r({path:{accountId:e},body:Js(ld(u))}))},[f,e,u,r]);const g=i||(p?.semanticUnavailable??!1),b=n.isPending||f,d=i?{matchOperator:"Or",literalClauses:Ht(u)}:{...t?{anchorMessageId:t}:{},matchOperator:"And",literalClauses:[]};return{preview:v,reset:h,matchedCount:b?void 0:p?.matchedCount,messageIds:b?void 0:p?.messageIds,semanticUnavailable:g,senderFallback:i,senders:u,matchPredicate:d,isPending:b,isError:n.isError,error:n.error}},ud=()=>[Kn({path:{mailboxId:""}}),Bn({path:{mailboxId:""}}),Qn()].map(e=>[{_id:e[0]._id}]),dd=e=>_a(e)?e.pages:Ua(e)?[e]:[],fd=e=>typeof e=="object"&&e!==null&&typeof e.messageId=="string",md=(e,t)=>{const s=new Set(t),n=new Map;for(const r of e)for(const o of dd(r))for(const i of o.items){if(!fd(i)||!s.has(i.messageId))continue;const c=i.subject?.trim();c&&n.set(i.messageId,c)}return t.map(r=>n.get(r)).filter(r=>r!==void 0)},pd=e=>{const t=ae(),s=e.join("\0");return l.useMemo(()=>{const n=ud().flatMap(r=>t.getQueriesData({queryKey:r}).map(([,o])=>o));return md(n,e)},[t,s])},hd=new Set(["hasAttachment","isUnread","isRead","isStarred","category","before","after"]),gd=e=>hd.has(e),bd=(e,{searchHadSemanticReach:t})=>{const s=[],n=[];let r,o;for(const u of e.tokens){if(u.type==="from"){s.push({field:"From",value:u.value});continue}if(u.type==="subject"){s.push({field:"Subject",value:u.value});continue}if(u.type==="in"){r={mailboxId:u.mailboxId,label:u.value};continue}if(u.type==="account"){o=u.accountId;continue}gd(u.type)&&n.push({type:u.type,label:Yn(u)})}const i=e.freeText.trim(),c=i.length>0;return c&&s.push({field:"HasWords",value:i}),{clauses:s,matchOperator:"all",scopedOut:r,droppedFacets:n,targetAccountId:o,keptTerms:c,droppedSemantic:c&&t}},xd=(e,t,s)=>e.targetAccountId??t??s[0]?.accountId,vd=({failure:e,isStarting:t,isRunning:s,isDone:n,failedCount:r,ruleSaved:o})=>e?.kind==="restartFailed"?"backApplyRestartFailed":e?.kind==="startFailed"?o?"backApplyStartFailed":"commitFailed":n?r>0?"backApplyFailed":"backApplyComplete":e?.kind==="statusUnreadable"?"statusUnknown":t||s?"backApplyRunning":"saving",yd={clauses:[],matchOperator:"any"},kd={clauses:[],matchOperator:"all",droppedFacets:[],keptTerms:!1,droppedSemantic:!1},jd=[],ze={state:"saving",matched:0,applied:0,failed:0,failures:[]},as=(e,t)=>e.map((s,n)=>({...s,id:`${t}-${n}`})),In=(e,t,s)=>{if(e==="delete")return{kind:"delete"};if(e==="markRead")return{kind:"markRead"};const n=e==="junk"?s:t;return n?{kind:"move",destinationMailboxId:n}:void 0},rs=e=>e==="move"||e==="junk"||e==="organize",Rn=e=>e==="junk"?er:"No destination was chosen, so there is nowhere to file these. Go back and pick a folder.";function wd({verb:e,accountId:t,mailboxId:s,selection:n,selectionRestriction:r,escalated:o,escalatedProgress:i,searchConversion:c,onFinished:u,onRunEnded:v,step:h,goToStep:p,goBack:f,closeWizard:g}){const[b]=l.useState(()=>c),[d]=l.useState(()=>o),m=b!==void 0,[x,C]=l.useState(m?"properties":"selected"),y=d?"escalated":x,[j,T]=l.useState(()=>b?{clauses:as(b.clauses,"search"),matchOperator:b.matchOperator}:yd),[M,P]=l.useState(void 0),[R,D]=l.useState(void 0),[F,_]=l.useState(!1),[L,K]=l.useState(void 0),[k,I]=l.useState(void 0),[A,S]=l.useState(),E=l.useRef(!1),w=l.useRef(!1),O=l.useMemo(()=>n.map(N=>N.id),[n]),U=l.useMemo(()=>n.map(N=>N.email).filter(Boolean),[n]),W=O[0],X=pd(O),{junkMailboxId:J}=qa(t),G=cd(d?void 0:t,W,U),{preview:le}=G;l.useEffect(()=>{le()},[le]);const re=y==="similar"||y==="properties",he=l.useMemo(()=>({matchOperator:j.matchOperator==="all"?"And":"Or",literalClauses:j.clauses.map(N=>({field:N.field,value:N.value}))}),[j.clauses,j.matchOperator]),V=y==="similar"?G.matchPredicate:he,{count:fe,matchedIds:ge}=ai(re?t:void 0,V),me=id(re?ge:[]),ce=rd(d?s:void 0,d?.searchQuery),be=d?{status:"ready",count:d.total}:re?fe:{status:"ready",count:n.length},{data:xe}=te({...vt({path:{accountId:t??""}}),enabled:!!t,staleTime:Number.POSITIVE_INFINITY}),B=Ha(t),q=na(),oe=l.useMemo(()=>ra({mailboxes:xe?.items??[],folderAppointments:B,currentMailboxId:s,translator:q}),[xe?.items,B,s,q]),{createFolderIn:Ae}=aa(t),Nt=oe.find(N=>N.id===j.moveMailboxId)?.label,et=rc(n.map(N=>({normalizedEmail:N.email,displayName:N.sender}))),tt=mc({match:y==="properties"&&j.clauses[0]?.value.trim()||void 0,sender:et?Da(et):void 0,folder:Nt}),Q=l.useMemo(()=>({...j,name:j.name??tt}),[j,tt]),Tt=nd(M?.draft.field,M?.draft.value??"",U),ue=ri(t),Ce=oi(t),$e=Qu({mailboxId:s??"",accountId:t,enabled:!1,predicateKey:"selection-wizard",searchQuery:{}}),{runAction:st}=$e,ne=lo({verb:e,mode:y,scope:j.scope,fromSearch:m}),Z=ne[Gs(ne,h)],Le=co(t,r),Pe=(N=>{if(N==="folder")return Le.destination;if(N==="rule")return Q.scope==="standing"||Q.scope==="until"?Le.rule:void 0})(Z)??uo(Z,Q,be),nt=l.useCallback(()=>as(fc(U,X),"seed"),[U,X]),Ke=l.useCallback(N=>{C(N),T($=>({...$,widen:N==="similar"&&W?{anchorCount:Math.max(n.length,1)}:void 0,...N==="properties"&&$.clauses.length===0?{clauses:nt()}:{}}))},[W,n.length,nt]),at=l.useCallback(()=>{_(!0),C("properties"),T(N=>({...N,widen:void 0,clauses:as(Ht(U),"sender"),matchOperator:"any"})),p("properties")},[U,p]),De=G.semanticUnavailable||G.isError;l.useEffect(()=>{Z==="match"&&(y!=="similar"||!De||F||at())},[Z,y,De,F,at]);const rt=l.useCallback(()=>{P({mode:"add",draft:{field:"From",value:""}})},[]),ot=l.useCallback(N=>{const $=j.clauses.find(Y=>Y.id===N);$&&P({mode:"edit",clauseId:N,draft:{field:$.field,value:$.value}})},[j.clauses]),it=l.useCallback(N=>{T($=>({...$,clauses:$.clauses.filter(Y=>Y.id!==N)}))},[]),se=l.useCallback(N=>{P($=>$&&{...$,draft:N})},[]),ve=l.useCallback(()=>{P(N=>{if(!N)return;const $=ii(N.draft.field,N.draft.value),Y={...N.draft,value:$};T(Be=>({...Be,clauses:N.clauseId?Be.clauses.map(lt=>lt.id===N.clauseId?{...lt,...Y}:lt):[...Be.clauses,{id:crypto.randomUUID(),...Y}]}))})},[]),lr=l.useCallback(()=>{if(Pe){D(Z);return}D(void 0);const N=ne[Gs(ne,Z)+1];N&&p(N)},[Pe,Z,ne,p]),Vt=l.useCallback(async N=>{const $=In(e,Q.moveMailboxId,J);if(!$){I({matched:N.length,failureReason:Rn(e)});return}I({matched:N.length});const Y=await st($,[...N]);I({matched:N.length,outcome:Y}),w.current&&v?.($.kind,N.length,Y)},[e,Q.moveMailboxId,J,st,v]),Wt=l.useCallback(async()=>{if(!d)return;const N=In(e,Q.moveMailboxId,J);if(!N){I({matched:d.total,failureReason:Rn(e)});return}I({matched:d.total});const $=await d.run(N);I({matched:d.total,outcome:$}),w.current&&v?.(N.kind,d.total,$)},[d,e,Q.moveMailboxId,J,v]),{start:Et}=ue,{createFilterAsync:Os}=Ce,Mt=l.useCallback(()=>{if(d){Wt();return}const N=li({mode:x,ruleScope:Q.scope}),$=ci({mode:x,ruleScope:Q.scope,anchorMessageId:W,clauses:Q.clauses,matchOperator:Q.matchOperator,moveMailboxId:Q.moveMailboxId,until:Q.until});if(K(N),N==="standing"||N==="temporary"){const Y=ui($)?$:void 0;S(Y),Os($,N,(Q.name??"").trim()).then(Be=>{Be&&Y&&Et(Y)});return}if(N==="all-like-these"&&rs(e)){Et($);return}Vt(N==="just-these"?O:ge)},[d,Wt,x,Q,W,e,O,ge,Os,Et,Vt]),cr=l.useCallback(()=>{if(Pe){D(Z);return}E.current||(E.current=!0,p("run"),Mt())},[Pe,Z,p,Mt]),zs=l.useCallback(N=>{const $=ue.progress,Y=vd({failure:ue.failure,isStarting:ue.isStarting,isRunning:ue.isRunning,isDone:ue.isDone,failedCount:$.failedCount,ruleSaved:N});return Y==="saving"||Y==="commitFailed"||Y==="backApplyStartFailed"?{...ze,state:Y}:{state:Y,matched:$.matchedCount,applied:$.appliedCount,failed:Y==="backApplyFailed"||Y==="backApplyRestartFailed"?$.failedCount:0,failures:[]}},[ue]),_s=l.useMemo(()=>{const N=new Map;for(const $ of[...n,...me.messages,...ce.messages])N.set($.id,$);return N},[n,me.messages,ce.messages]),Us=d?i:$e.progress,Ks=l.useCallback(()=>{if(!k)return ze;const{matched:N,outcome:$,failureReason:Y}=k;if(Y!==void 0)return{...ze,state:"commitFailed",failureReason:Y};if(!$){const Qe=Us?.done??0;return{state:"backApplyRunning",matched:Math.max(N,Qe),applied:Qe,failed:0,failures:[]}}if(!($.cancelled||$.error!==void 0))return{state:"backApplyComplete",matched:Math.max(N,$.done),applied:$.done,failed:0,failures:[]};if($.done===0)return{...ze,state:"commitFailed"};const lt=$.failedIds.map(Qe=>_s.get(Qe)).filter(Qe=>Qe!==void 0),pr=$.failedIds.length>0?$.failedIds.length:Math.max(N-$.done,1);return{state:"runStopped",matched:Math.max(N,$.done),applied:$.done,failed:pr,failures:lt}},[k,Us,_s]),Fe=d?Ks():L==="standing"||L==="temporary"?Ce.isError?{...ze,state:"commitFailed"}:Ce.isSuccess?A?zs(!0):{...ze,state:"filterSaved"}:ze:L==="all-like-these"&&rs(e)?zs(!1):Ks(),ur=()=>{if(Fe.state==="statusUnknown"){ue.refreshStatus();return}if(d){Wt();return}if(L==="standing"||L==="temporary"){if(Ce.isError){Ce.reset(),Mt();return}A&&Et(A);return}if(L==="all-like-these"&&rs(e)){Mt();return}const N=k?.outcome?.failedIds??[];Vt(N.length>0?N:O)},dr=l.useCallback(()=>{g(ne,Z)},[g,ne,Z]),Yt=l.useCallback(()=>{w.current=!0,g(ne,Z),u()},[g,ne,Z,u]),{stop:Bs}=$e,fr=k!==void 0&&k.outcome===void 0&&k.failureReason===void 0,mr=l.useCallback(()=>{if(d){d.stop();return}Bs()},[d,Bs]);xc({shouldBlockFn:({action:N})=>N!=="BACK"?!1:(Yt(),!0),enableBeforeUnload:!1,disabled:Z!=="run"});const Xt={messages:d?ce.messages:re?me.messages:n,count:be,label:y==="selected"?"Your selection":"A sample of what matches",emptyReason:y==="similar"&&De?"notIndexed":"noMatch",loading:d?ce.isPending:re&&(be.status==="loading"||me.isPending)};return a.jsx(fo,{verb:e,steps:ne,step:Z,blockedReason:Pe,nudged:R===Z,onBack:f,onExit:Z==="run"?Yt:dr,onContinue:lr,onCommit:cr,match:{selectedCount:n.length,mode:y,accountId:Le.accountId,onModeChange:Ke,semanticUnavailable:De,semanticErrorDetail:G.error instanceof Error?G.error.message:void 0,semanticFallbackTaken:F,onSemanticFallback:at,escalatedScope:d?.scope,sample:Xt},properties:{clauses:Q.clauses,matchOperator:Q.matchOperator,onMatchOperatorChange:N=>T($=>({...$,matchOperator:N})),clauseEdit:M,onStartAddClause:rt,onStartEditClause:ot,onRemoveClause:it,onChangeDraft:se,onSubmitClause:ve,onCancelClause:()=>P(void 0),clauseFields:di,clauseSuggestions:Tt,conversionNotice:b?hc(b):void 0,semanticFallbackTaken:F,sample:{...Xt,label:"What this matches"}},folder:{folders:oe,mailboxId:Q.moveMailboxId,delimiter:oa(xe?.items??[]),onSelect:N=>T($=>({...$,moveMailboxId:N})),onCreateFolder:t?Ae:void 0,restriction:Le.destination},rule:{draft:Q,onScopeChange:N=>T($=>({...$,scope:N})),onUntilChange:N=>T($=>({...$,until:N})),restriction:Le.rule},name:{name:Q.name??"",onNameChange:N=>T($=>({...$,name:N})),nudged:R===Z},review:{verb:e,mode:y,selectedCount:n.length,clauses:Q.clauses,matchOperator:Q.matchOperator,folder:Nt,scope:Q.scope,until:Q.until,ruleName:ne.includes("name")?Q.name:void 0,escalatedScope:d?.scope,sample:Xt},run:{state:Fe.state,verb:e,scope:Q.scope,matched:Fe.matched,applied:Fe.applied,failedCount:Fe.failed,failures:Fe.failures,failureReason:Fe.failureReason,onRetry:ur,onDismiss:Yt,onCancelRun:fr?mr:void 0}})}function Xf(e){const t=oo()==="search",{searchConversion:s}=tr(),{accounts:n}=ys(),{step:r,goToStep:o,goBack:i,closeWizard:c}=io(t?"properties":"match");if(!r)return null;const u=t?s??kd:void 0;return a.jsx(wd,{...e,...u?{verb:"organize",accountId:xd(u,e.accountId,n),selection:jd,selectionRestriction:void 0,escalated:void 0,searchConversion:u}:{},step:r,goToStep:o,goBack:i,closeWizard:c})}const Ps=l.createContext(null),Cd=e=>{const t=l.useContext(Ps);return t?t.rowInteraction(e):null},Sd=()=>{const e=l.useContext(Ps);if(!e)throw new Error("useThreadListSelection must be used inside <ThreadListInteraction>");return e},Nd="[data-message-id]",Td=e=>Array.from(e.querySelectorAll(Nd)).map(t=>t.dataset.messageId).filter(t=>t!==void 0),Ed=(e,t)=>e.length===t.length&&e.every((s,n)=>s===t[n]),Md=e=>{const[t,s]=l.useState([]);return l.useEffect(()=>{const n=e.current;if(!n)return;const r=()=>{const i=Td(n);s(c=>Ed(c,i)?c:i)};r();const o=new MutationObserver(r);return o.observe(n,{childList:!0,subtree:!0}),()=>o.disconnect()},[e]),t};function Jf({selectedMessageId:e,onOpen:t,onDeleteMessages:s,onSelectionVerb:n,wizardOpen:r=!1,isDeleting:o=!1,commandsRef:i,onTriageContextChange:c,children:u}){const v=ws(),h=l.useRef(null),p=Md(h),f=gc({orderedIds:p,isDesktop:v,initialFocusedId:e}),{focusedMessageId:g,setFocusedMessageId:b,pendingDomFocusRef:d,cursorMovedByPointerRef:m,selection:x,isMultiSelectMode:C,exitSelection:y,handleRowSelect:j}=f,{selectedIds:T,selectedCount:M,isSelected:P,toggle:R,select:D,toggleAll:F}=x,_=p.length>0&&p.every(V=>T.has(V)),L=l.useCallback(()=>{p.length>0&&F(p)},[p,F]),{intersectWith:K}=x;l.useEffect(()=>{K(p)},[K,p]),l.useEffect(()=>{const V=d.current;V!==null&&(d.current=null,h.current?.querySelector(`[data-message-id="${V}"]`)?.focus())});const k=l.useCallback(V=>{m.current=!0,b(V)},[m,b]),I=l.useCallback(V=>{v||D(V)},[v,D]),A=l.useCallback(()=>{g&&t(g)},[g,t]),S=l.useCallback(V=>t(V,{replace:!0}),[t]);Hu({keyboardFocusedMessageId:f.keyboardFocusedMessageId,openMessageId:e,enabled:v&&M===0,open:S});const[E,w]=l.useState(null),O=l.useCallback(V=>E!==null?!0:M>0?(n(V),!0):V!=="delete"||!g?!1:(w([g]),!0),[E,M,n,g]),U=l.useCallback(()=>{E!==null&&(s(E),w(null),y())},[E,s,y]),W=l.useCallback(()=>w(null),[]),X=l.useCallback(()=>M===0?!1:(y(),!0),[M,y]),J=p.length>0;l.useEffect(()=>{if(i){if(!J){i.current=null;return}return i.current={focusNext:f.focusNext,focusPrevious:f.focusPrevious,focusFirst:f.focusFirst,focusLast:f.focusLast,openFocused:A,toggleSelect:f.toggleFocusedSelection,extendSelectDown:f.extendRangeDown,extendSelectUp:f.extendRangeUp,selectAll:f.selectAllLoaded,clearSelection:X,requestVerb:O,toggleDensity:()=>{}},()=>{i.current=null}}},[i,J,f.focusNext,f.focusPrevious,f.focusFirst,f.focusLast,f.toggleFocusedSelection,f.extendRangeDown,f.extendRangeUp,f.selectAllLoaded,A,X,O]);const G=l.useMemo(()=>Array.from(T),[T]),le=E!==null;l.useEffect(()=>{c?.({focusedMessageId:g,selectedIds:G,orderedIds:p,hasList:J,blocksKeyboard:le||r})},[c,g,G,p,J,le,r]);const re=Wu(p,g),he=l.useMemo(()=>({selectedIds:T,selectedCount:M,exitSelection:y,startSelectionVerb:n,orderedIds:p,allSelected:_,toggleAllLoaded:L,rowInteraction:V=>({focused:V===g,isTabStop:V===re,isDesktop:v,onFocusRow:k,selection:{isChecked:P(V),onToggleCheck:R,onRowSelect:j,isMultiSelectMode:C,onLongPress:I}})}),[T,M,y,n,p,_,L,g,re,v,k,P,R,j,C,I]);return a.jsxs(Ps.Provider,{value:he,children:[a.jsx("div",{ref:h,className:"contents",children:u}),a.jsx(fi,{isOpen:le,title:ei(E?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:o,onConfirm:U,onCancel:W})]})}function Zf({title:e,isDeleting:t}){const s=tr(),{selectedCount:n,exitSelection:r,startSelectionVerb:o,orderedIds:i,allSelected:c,toggleAllLoaded:u}=Sd();return a.jsx(Ul,{title:s.title||e,navSlot:s.navSlot,titleMeta:s.titleMeta,searchSlot:s.searchSlot,searchField:s.searchField,idleSlot:s.makeFilterSlot,count:n,onCancel:r,onDelete:()=>o("delete"),onMarkRead:()=>o("markRead"),isBusy:t,selectAll:i.length>0?{checked:c,indeterminate:n>0&&!c,onChange:u}:void 0})}const os=e=>{e.preventDefault(),e.stopPropagation()},Id=(e,t)=>{const s=l.useRef(!1),n=l.useCallback(i=>{if(s.current=!1,i.button!==0)return;const c=us(i);ln(c)&&t?.(e,c)&&(os(i),s.current=!0,i.currentTarget.focus(),c.shiftKey&&window.getSelection()?.removeAllRanges())},[t,e]),r=l.useCallback(i=>{!i.ctrlKey||!t||i.preventDefault()},[t]),o=l.useCallback(i=>{if(s.current)return s.current=!1,os(i),!0;const c=us(i);return!ln(c)||!t?.(e,c)?!1:(os(i),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0)},[t,e]);return{onMouseDown:n,onContextMenu:r,claimClick:o}},Rd=({thread:e,active:t=!1,focused:s,isTabStop:n,density:r="comfortable",isDesktop:o,badge:i,selection:c,inListbox:u=!1,link:v,onClick:h,onFocusRow:p})=>{const f=ae(),g=e.id,b=Cd(g),d=s??b?.focused??!1,m=n??b?.isTabStop??!1,x=c??b?.selection,C=p??b?.onFocusRow,y=o??b?.isDesktop??!0,j=x?.isChecked??!1,T=x?.isMultiSelectMode??!1,M=x?.onToggleCheck,P=x?.onRowSelect,R=x?.onLongPress,D=l.useCallback(w=>{w.preventDefault(),w.stopPropagation(),M?.(g)},[M,g]),F=Id(g,P),_=l.useCallback(w=>{if(!F.claimClick(w)){if(!y){if(T){w.preventDefault(),w.stopPropagation(),M?.(g);return}h?.();return}P?.(g,us(w)),h?.()}},[F,y,T,M,P,h,g]),L=l.useCallback(()=>{R?.(g)},[R,g]),{longPressProps:K}=wl({onLongPress:L,accessibilityDescription:j?"Deselect message":"Select message"}),k=l.useCallback(()=>{f.prefetchQuery(_t({path:{messageId:g}}))},[f,g]),I=l.useCallback(()=>{k(),C?.(g)},[k,C,g]),A=yt({"data-list-row":"","data-message-row":!0,"data-message-id":g,...u?{role:"option","aria-selected":j}:{},tabIndex:m?0:-1,onClick:_,onMouseDown:F.onMouseDown,onContextMenu:F.onContextMenu,onMouseEnter:k,onFocus:I},y||!x?{}:K),S=z(r==="compact"?wa({active:t,focused:d}):z("group",Es({active:t,focused:d})),"outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",j&&"bg-accent-soft",!y&&"min-h-11 select-none [-webkit-touch-callout:none]"),E=r==="compact"?a.jsx(Ca,{thread:e}):a.jsx(Ms,{thread:e,badge:i,selection:x?{checked:j,alwaysVisible:T,onToggle:D}:void 0});return v===void 0?a.jsx("button",{type:"button",...A,className:S,children:E}):a.jsx(ea,{to:"/mail/$mailboxId/$threadId/$messageId",params:{...v,messageId:g},search:w=>w,variant:"row",...A,className:S,children:E})},em=l.memo(Rd),Ad="Open a message first",$d="This conversation hasn't loaded yet",Ld="The mailbox list hasn't loaded yet",Pd="Couldn't find this mailbox's account — reload to try again",Dd={reply:"Reply",replyAll:"Reply all",forward:"Forward",delete:"Move to Trash",move:"Move to mailbox",flag:"Star"},tm=({hasThread:e,messageId:t,intelligenceOpen:s,canToggleIntelligence:n,onToggleIntelligence:r,onReply:o,onReplyAll:i,onForward:c,onDelete:u,onToggleStar:v,isStarred:h,moveContext:p,moveContextLoading:f})=>{const[g,b]=l.useState(null),d=t??null,m=R=>e?R==="move"?p?null:f?Ld:Pd:{reply:o,replyAll:i,forward:c,delete:u,flag:v}[R]?null:$d:Ad,x=g&&g.messageId===d?g:null,C=x?m(x.action):null,y=x?.action==="move"&&x.overThread&&!!p,j=C??(x&&!y?`${Dd[x.action]} is ready — press it again`:null),T=R=>b({action:R,messageId:d,overThread:e}),M=R=>()=>T(R),P=(R,D)=>D?()=>{b(null),D()}:M(R);return a.jsx(Sl,{hasThread:e,isStarred:h,onUnavailable:T,unavailableHint:j,replyTitle:`Reply ${ct("reply")}`,replyAllTitle:`Reply all ${ct("replyAll")}`,forwardTitle:`Forward ${ct("forward")}`,deleteTitle:`Move to Trash ${ct("delete")}`,flagTitle:`Star ${ct("toggleStar")}`,onReply:P("reply",o),onReplyAll:P("replyAll",i),onForward:P("forward",c),onDelete:P("delete",u),onToggleStar:P("flag",v),onMove:M("move"),moveSlot:p?a.jsx(Ls,{accountId:p.accountId,currentMailboxId:p.currentMailboxId,onMove:p.onMove,label:"Move to mailbox",defaultOpen:y}):void 0,children:a.jsx(Cl,{open:s,enabled:n,onToggle:r})})};function sm(e){const[t,s]=l.useState(null);t!==null&&t!==e&&s(null);const n=e!==null&&t===e,r=l.useCallback(()=>s(null),[]),o=l.useCallback(()=>s(e),[e]),i=l.useCallback(()=>s(n?null:e),[n,e]);return{isOpen:n,open:o,close:r,toggle:i}}const Fd=()=>{const e=ae();return l.useCallback(t=>{const s=Ie({path:{threadId:t.threadId}}),r=e.getQueriesData({queryKey:s}).flatMap(([,o])=>o?.items.map(i=>i.messageId)??[]);return r.length>0?r:[t.messageId]},[e])},nm=({thread:e,mailboxId:t,accountId:s,onAfterOptimisticRemove:n})=>{const r=t??e?.mailboxId,o=s??e?.accountId,{accountId:i}=Oa(o?void 0:r),c=o??i,u=Fd(),{deleteMessages:v}=$s({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{moveMessages:h}=Gt({mailboxId:r??"",threadId:e?.threadId,accountId:c,onAfterOptimisticRemove:n}),{toggleStar:p}=Ba({threadId:e?.threadId??"",mailboxId:r??""}),f=l.useCallback(()=>{e&&v(u(e))},[e,u,v]),g=l.useCallback(d=>{e&&h(u(e),d)},[e,u,h]),b=l.useCallback(()=>{e&&p(e.messageId,e.hasStars)},[e,p]);return{mailboxId:r,accountId:c,isStarred:e?.hasStars,deleteThread:f,moveThread:g,toggleStar:b}},am=(e,t)=>{const{data:s}=te({...Hn({path:{threadId:e??""}}),enabled:!!e}),n=s?.items??[],r=t?n.find(i=>i.messageId===t):void 0,o=n.length>0?n[n.length-1]:void 0;return r??o},An=(e,t,s)=>{if(!t)return null;const n=e.indexOf(t);if(n===-1)return null;const r=s==="next"?n+1:n-1;return r<0||r>=e.length?null:e[r]},rm=()=>{const[e,t]=l.useState(void 0),[s,n]=l.useState([]),[r,o]=l.useState([]),i=l.useRef(null),[c,u]=l.useState(!1),[v,h]=l.useState(!1),p=l.useCallback(f=>{t(f.focusedMessageId),n(f.selectedIds),f.orderedIds&&o(f.orderedIds),u(f.hasList),h(f.blocksKeyboard)},[]);return{listCommandsRef:i,onTriageContextChange:p,focusedMessageId:e,selectedIds:s,orderedIds:r,hasList:c,blocksKeyboard:v}},om=({context:e,orderedIds:t,selectedMessageId:s,enabled:n=!0,onClose:r,handlers:o})=>{const{listCommandsRef:i,hasList:c,blocksKeyboard:u}=e,v=l.useCallback(()=>{i.current?.clearSelection()||s&&r()},[i,s,r]);return So({enabled:n&&!u,handlers:{...c?{focusNext:()=>i.current?.focusNext(),focusPrevious:()=>i.current?.focusPrevious(),focusFirst:()=>i.current?.focusFirst(),focusLast:()=>i.current?.focusLast(),openFocused:()=>i.current?.openFocused(),toggleSelect:()=>i.current?.toggleSelect(),extendSelectDown:()=>i.current?.extendSelectDown(),extendSelectUp:()=>i.current?.extendSelectUp(),selectAll:()=>i.current?.selectAll(),toggleDensity:()=>i.current?.toggleDensity()}:{},back:v,...o}}),{goBack:v,nextMessageId:An(t,s,"next")??void 0,previousMessageId:An(t,s,"previous")??void 0}},Od={sender:"sender",recipient:"recipient",subject:"subject",attachment:"attachment",body:"body",entities:"entities"};function zd(e){return Od[e]??e}function im(e,t){const{folder:s}=ks(t,[e.mailboxId]);return{id:e.messageId,sender:e.fromName??e.fromEmail??"Unknown",...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject??"(No subject)",snippet:e.snippet??"",date:Je(e.sentDate),unread:!e.isRead,flagged:e.hasStars===!0,threadId:e.threadId,mailboxId:e.mailboxId,...s?{folder:s}:{}}}function lm(e,t){const{folder:s}=ks(t,e.mailboxId?[e.mailboxId]:[]);return{id:e.id,sender:e.fromName,...e.fromEmail?{senderEmail:e.fromEmail}:{},subject:e.subject,snippet:e.snippet,date:e.timeLabel,unread:!e.isRead,flagged:e.starred===!0,...e.threadId?{threadId:e.threadId}:{},...e.mailboxId?{mailboxId:e.mailboxId}:{},...s?{folder:s}:{}}}function _d(e,t){const{mailboxId:s,folder:n}=ks(t,e.mailboxIds);return{id:e.messageId,sender:e.fromName??"Unknown",subject:e.subject??"(No subject)",snippet:"",date:e.sentDate!=null?Je(e.sentDate*1e3):"",threadId:e.threadId,matchedChunkLabel:zd(e.matchedChunkType),score:e.score,...s?{mailboxId:s}:{},...n?{folder:n}:{}}}function cm(e,t,s){const n=new Set(t),r=[];for(const o of[...e].sort((i,c)=>c.score-i.score))n.has(o.threadId)||(n.add(o.threadId),r.push(_d(o,s)));return r}function um(e){const t=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,threadId:e.threadId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:Je(e.sentDate),sentDate:e.sentDate,isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:Qa(e.category),suspicious:t}}function dm(e){return e.filter(t=>t.muted!==!0)}function fm(e,t){const s=new Set,n=[];for(const r of[...e,...t])s.has(r.id)||(s.add(r.id),n.push(r));return n.sort((r,o)=>(o.sentDate??0)-(r.sentDate??0))}const $n=[{id:"personal",label:"Personal",category:ye.personal},{id:"transactional",label:"Transactional",category:ye.transactional},{id:"newsletter",label:"Newsletter",category:ye.newsletter},{id:"marketing",label:"Marketing",category:ye.marketing},{id:"social",label:"Social",category:ye.social},{id:"automated",label:"Automated",category:ye.automated},{id:"uncategorized",label:"Unclassified",category:ye.uncategorized}];function mm(e){const t=new Map($n.map(n=>[n.category,[]]));for(const n of e){const r=n.category??ye.uncategorized;(t.get(r)??t.get(ye.uncategorized))?.push(n)}const s=[];for(const n of $n){const r=t.get(n.category);r&&r.length>0&&s.push({id:n.id,label:n.label,threads:r})}return s}function pm(e,t){return e.fromName.toLowerCase().includes(t)||e.fromEmail.toLowerCase().includes(t)||e.subject.toLowerCase().includes(t)||e.snippet.toLowerCase().includes(t)}function hm(e,t){return t.every(s=>{switch(s.type){case"from":{const n=s.value.toLowerCase();return e.fromEmail.toLowerCase().includes(n)||e.fromName.toLowerCase().includes(n)}case"subject":return e.subject.toLowerCase().includes(s.value.toLowerCase());case"category":return(e.category??"uncategorized")===s.category;case"hasAttachment":return e.hasAttachment===!0;case"isUnread":return!e.isRead;case"isRead":return e.isRead===!0;case"isStarred":return e.starred===!0;case"after":return e.sentDate!=null&&e.sentDate>=s.epochSeconds*1e3;case"before":return e.sentDate!=null&&e.sentDate<s.epochSeconds*1e3;case"in":return e.mailboxId===s.mailboxId;case"account":return e.accountId===s.accountId;default:return!1}})}const rr=8;function Ds(e,t){const s=Math.max(0,Math.min(t,e.length)),n=_o(e).find(o=>s>=o.start&&s<=o.end);if(!n)return{start:s,end:s,raw:""};const r=Uo(n.raw);return r?{start:n.start,end:n.end,raw:n.raw,name:r.name,value:r.value}:{start:n.start,end:n.end,raw:n.raw}}function Ud(e,t){const s=Ds(e,t);if(s.name===void 0)return{kind:"token",query:s.raw};const n=Xn(s.name);if(n)return{kind:"value",token:n.name,source:n.values,query:s.value??""}}const Kd={mailbox:"mailboxes",account:"accounts",contact:"contacts"},Bd=(e,t)=>{if(e.values==="fixed")return e.options??[];const s=Kd[e.values];return s?t[s]??[]:[]},Qd=(e,t)=>{if(t==="")return 1;const s=e.toLowerCase();return s.startsWith(t)?0:s.includes(t)?1:-1},hs=(e,...t)=>{let s=-1;for(const n of t){if(n===void 0)continue;const r=Qd(n,e);r<0||(s<0||r<s)&&(s=r)}return s},or=e=>{const t=new Set;return e.filter(s=>s.rank>=0).sort((s,n)=>s.rank-n.rank).filter(s=>{const n=s.suggestion.value.toLowerCase();return t.has(n)?!1:(t.add(n),!0)}).slice(0,rr).map(s=>s.suggestion)},Ln=e=>({value:`${e.name}:`,label:`${e.name}:`,hint:e.label});function qd(e){const t=e.trim().toLowerCase();if(t==="")return Ws.map(Ln);const s=[];for(const n of Ws)if(s.push({rank:hs(t,`${n.name}:`,n.label),suggestion:Ln(n)}),n.values==="fixed")for(const r of n.options??[]){const o=Jn(n.name,r.value);s.push({rank:hs(t,o,r.label),suggestion:{value:o,label:r.label??o,hint:o}})}return or(s)}function Hd(e,t,s){const n=t.trim().toLowerCase(),r=Bd(e,s).map(o=>({rank:hs(n,o.value,o.label),suggestion:{value:Jn(e.name,o.value),label:o.label??o.value,...o.hint?{hint:o.hint}:{}}}));return or(r)}function Gd(e,t,s={}){const n=Ds(e,t);if(n.name===void 0)return qd(n.raw);const r=Xn(n.name);return r?Hd(r,n.value??"",s):[]}function Vd(e,t,s){const n=Ds(e,t),r=!s.value.endsWith(":"),o=/\s/.test(e.slice(n.end,n.end+1)),i=r&&!o?`${s.value} `:s.value;return{query:e.slice(0,n.start)+i+e.slice(n.end),cursor:n.start+i.length+(r&&o?1:0)}}const Wd=e=>({value:e.normalizedEmail,...e.displayName?{label:e.displayName,hint:e.normalizedEmail}:{}}),Yd=250,Xd=2;function Jd({query:e,cursor:t,enabled:s}){const{accounts:n}=ys(),{mailboxesByName:r}=Zn(),o=r!==void 0,i=s?Ud(e,t):void 0,c=i?.source==="contact"?i.query.trim():"",u=sa(c,Yd),{data:v}=te({...vs({query:{q:u,limit:rr}}),enabled:u.length>=Xd}),h=js({queries:n.map(b=>({...vt({path:{accountId:b.accountId}}),staleTime:1/0}))}),p=l.useMemo(()=>o?No(h.map(b=>b.data?.items??[]),n):[],[o,h,n]),f=l.useMemo(()=>To(n),[n]),g=l.useMemo(()=>(v?.items??[]).map(Wd),[v]);return l.useMemo(()=>{if(!s)return[];const b=Gd(e,t,{mailboxes:p,accounts:f,contacts:g});return o?b:b.filter(d=>d.value!=="in:")},[s,e,t,p,f,g,o])}const ir="remit.recentSearches",Zd=5;function gs(){try{const e=localStorage.getItem(ir);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}function Pn(e){const t=e.trim();if(!t)return gs();const s=[t,...gs().filter(n=>n!==t)].slice(0,Zd);try{localStorage.setItem(ir,JSON.stringify(s))}catch{return s}return s}const ef=e=>e.tier!=="phone"&&e.hasLiveInput&&!(e.bodyRendersCommittedResults&&e.hasCommittedQuery);function tf(e){const{spam:t}=Ia([...e]),s=new Map;for(const r of t)r.mailboxId&&s.set(r.mailboxId,(s.get(r.mailboxId)??0)+1);let n;for(const[r,o]of s)(!n||o>n.count)&&(n={mailboxId:r,count:o});return n}function gm({title:e,unreadCount:t,children:s,selectionBar:n,paneOverlay:r,footer:o,searchFilter:i,searchResults:c,searchLoading:u,relatedResults:v,relatedLoading:h,onSelectSearchResult:p,searchResultsLabel:f="Top matches",relatedResultsLabel:g="Related",searchResultsInBody:b=!1,refreshControl:d}){const{accounts:m,resultFolderIndex:x,searchQuery:C,searchInput:y,onSearchChange:j,onSearchClear:T,searchViewKey:M}=ys(),P=Zn(),R=qn(),D=mo(),F=Eo(),[_,L]=l.useState(!1),[K,k]=l.useState(gs),I=po(),A=l.useRef(M);l.useEffect(()=>{A.current!==M&&(A.current=M,L(!1))},[M]);const[S,E]=l.useState(0),[w,O]=l.useState(!1),[U,W]=l.useState(void 0),X=Jd({query:y,cursor:S,enabled:w&&y.trim().length>0}),J=l.useCallback(se=>{const ve=Vd(y,S,se);j(ve.query),W({cursor:ve.cursor})},[y,S,j]),G=ho({count:X.length,onAccept:se=>{const ve=X[se];ve&&J(ve)}}),{comboboxProps:le,handleKeyDown:re}=G,he=l.useMemo(()=>({comboboxProps:le,onKeyDown:re,onCaretChange:E,onFocusChange:O,...U?{caret:U}:{}}),[le,re,U]),V=G.open?a.jsx(xo,{id:G.listId,suggestions:X,activeIndex:G.activeIndex,optionId:G.optionId,onPick:J,onHighlight:G.setActiveIndex,label:"Search suggestions",className:"mx-row-inset mt-1 shrink-0"}):null,fe=y.trim().length>0,{mailboxesByName:ge,accountsByName:me}=P,ce=l.useMemo(()=>Ko(y,{mailboxesByName:ge,accountsByName:me}),[y,ge,me]),be=ce.tokens.map(se=>({label:Yn(se),onRemove:()=>j(Bo(y,se))})),xe=c??[],B=v??[],q=fe?[{id:"top",label:f,results:xe},{id:"related",label:g,results:B}]:[],Ae=!(xe.length+B.length>0)&&(u===!0||h===!0),{scope:Nt}=Mo(m),et=Yo({select:se=>se.matches}),tt=pi(et),Q=hi(et,Nt,tt?x.get(tt)?.role:void 0),Tt=Q.kind==="global"?tf([...xe,...B]):void 0,ue=Tt?{kind:"global",onScopeToSpam:()=>R({to:"/mail/$mailboxId",params:{mailboxId:Tt.mailboxId},search:{q:C||void 0}})}:Q,Ce=B.length>0,$e=l.useMemo(()=>bd(ce,{searchHadSemanticReach:Ce}),[ce,Ce]),st=fe?$e:void 0,ne=fe?{onClick:()=>{L(!1),I("properties","search")},blockedReason:pc($e)?void 0:go($e.droppedFacets.map(se=>se.label))}:void 0,Z=ne?a.jsx(Ra,{...ne}):null,Le=ef({tier:F,hasLiveInput:fe,hasCommittedQuery:C.trim().length>0,bodyRendersCommittedResults:b}),Fs=se=>{k(Pn(y)),p?.(se)},Pe=a.jsx(Aa,{value:y,sections:q,loading:Ae,onSelectResult:Fs,tokens:be,scope:ue}),nt=n===void 0,Ke=Le?a.jsx("div",{className:"h-full overflow-y-auto",children:Pe}):null,at=Ke&&!nt?Ke:s,De=Ke&&nt?Ke:null,rt=Io(F),ot=rt&&(_||fe),it=l.useMemo(()=>({title:e,searchResults:De,makeFilterSlot:Z,searchConversion:st,navSlot:D&&!D.showNavPane&&a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(gi,{className:"size-5"}),onClick:()=>D.openNav(),"aria-label":"Menu",className:"-ml-2 shrink-0"}),titleMeta:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[t.toLocaleString()," unread"]}),a.jsx(Vs,{}),d]}),searchSlot:rt&&!ot&&a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(bo,{className:"size-5"}),onClick:()=>L(!0),"aria-label":"Search",className:"shrink-0"}),searchField:ot&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(Gn,{value:y,onChange:j,onClear:T,globalFocusKey:!1,showClearButton:!1,suggest:he})}),a.jsx(H,{variant:"ghost",size:"touch",icon:a.jsx(Ft,{className:"size-5"}),onClick:()=>{T(),L(!1)},"aria-label":"Close search",className:"shrink-0"}),a.jsx(Vs,{})]})}),[e,t,D,rt,ot,y,j,T,he,De,Z,st,d]);if(F==="phone"&&_){const se=ve=>{k(Pn(y)),L(!1),p?.(ve)};return a.jsxs(ps.Provider,{value:it,children:[a.jsx(_l,{value:y,onChange:j,onClear:T,onCancel:()=>{L(!1),T()},filter:i,recentSearches:K,onPickRecent:j,makeFilter:ne,sections:q,loading:Ae,onSelectResult:se,tokens:be,scope:ue,suggest:he,suggestList:V}),r]})}return a.jsx(ps.Provider,{value:it,children:a.jsxs("section",{className:"relative flex h-full w-full flex-col bg-surface",children:[n?.(it),V,a.jsx("div",{className:"min-h-0 flex-1",children:at}),o,r]})})}export{Qf as $,Kf as A,Bf as B,Rl as C,_f as D,um as E,hm as F,Oa as G,Of as H,am as I,$s as J,Gt as K,rm as L,em as M,nm as N,Df as O,Pf as P,Fd as Q,Ba as R,Ul as S,Su as T,Tu as U,Mu as V,Eu as W,om as X,sm as Y,zf as Z,$f as _,vl as a,tm as a0,Rf as a1,im as a2,cm as a3,dm as a4,fm as a5,pm as a6,lm as a7,Ia as a8,tf as a9,mm as aa,If as ab,ef as ac,Pl as ad,Jf as ae,Tf as af,Sd as ag,gm as ah,we as ai,je as aj,Rs as ak,bt as al,wl as am,yt as an,Ts as ao,us as ap,Ef as aq,Mf as ar,Af as as,Zf as at,tr as b,Es as c,Lf as d,qa as e,Ff as f,bl as g,Qu as h,Vf as i,Yf as j,Gf as k,Hf as l,Hu as m,gl as n,xc as o,qf as p,Wf as q,Wu as r,Xf as s,Qa as t,Id as u,fl as v,Vu as w,zc as x,Ha as y,Uf as z};
@@ -1 +1 @@
1
- import{j as e,af as re,B as A,e as ie,r as x,b as Q,ag as oe,T as ce,cT as le,u as ue,cU as U,bl as de,bD as fe,cV as me,cW as xe,cX as ge,l as he,bm as pe,cm as be}from"./index-COgYNcrI.js";import{R as ve,l as je,p as we}from"./search-token-index-aGO9rXGI.js";import{am as Ne,an as ye,c as Pe,a as q,ao as Ce,v as Re,ap as ke,aq as Se,ar as Me,af as Ee,ah as Ie}from"./MailListHeader-_wXpu2b0.js";import{A as ze}from"./avatar-Db3yTewv.js";import{M as Oe}from"./mail-Dtw_oNuw.js";import{M as De}from"./menu-BwTBBgqW.js";function Le(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const z=72,V=10,Xe=z/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?z:s==="trailing"?-z:0}function He(s){return s>=z/2?"leading":s<=-z/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>V&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const O=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&O>Xe&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),X=Math.max(-z,Math.min(z,F+u));v(X)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(He(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[J]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),L={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,I=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(q,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(ze,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.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:s.isRead?e.jsx(Oe,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:L,children:T})]})}function We({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,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"})]})}const Ye=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:L,hideHeader:$=!1}){const I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,O=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${U}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[X,Y]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{Y(!0),setTimeout(()=>Y(!1),1400)},_=a?.selectedIds??Ye,D=a?.onToggle,K=a?.onRowSelect,te=Re(_.size,R),H=x.useCallback(t=>{if(D)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),D(t)}}},[_,D]),B=x.useCallback((t,c)=>K?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[K]),ne=x.useCallback(({thread:t,active:c,onClick:W})=>e.jsx(I,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:H(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[I,H,B,u,O]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(De,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(Le,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):L??(F?e.jsx(We,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>D?.(t),onEnterSelection:t=>D?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:X}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.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:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:H(c.id),onClick:W=>{B(c.id,W)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ke=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ke)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(Ie,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};
1
+ import{j as e,af as re,B as A,e as ie,r as x,b as Q,ag as oe,T as ce,cS as le,u as ue,cT as U,bl as de,bD as fe,cU as me,cV as xe,cW as ge,l as he,bm as pe,cl as be}from"./index-BBlkR2lm.js";import{R as ve,l as je,p as we}from"./search-token-index-jGvf0dJ0.js";import{am as Ne,an as ye,c as Pe,a as q,ao as Ce,v as Re,ap as ke,aq as Se,ar as Me,af as Ee,ah as Ie}from"./MailListHeader-CqEQzbdu.js";import{A as ze}from"./avatar-BosRyUDx.js";import{M as Oe}from"./mail-BsugoFoQ.js";import{M as De}from"./menu-BtHNv3F8.js";function Le(){return e.jsx("div",{className:"space-y-0",role:"status","aria-busy":"true","aria-label":"Loading messages",children:Array.from({length:8}).map((s,n)=>e.jsxs("div",{className:"animate-pulse border-b border-line px-3 py-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-16 rounded bg-surface-sunken"})]}),e.jsx("div",{className:"mb-2 h-4 w-48 rounded bg-surface-sunken"}),e.jsx("div",{className:"h-3 w-full rounded bg-surface-sunken"})]},n))})}function Te({filter:s,scopeLabel:n,searchQuery:r}){const f=r?.trim();return s?e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-fg",children:$e(s.label,n,f)}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:_e[s.reach]}),e.jsx(A,{variant:"secondary",size:"sm",className:"mt-4",onClick:s.onClear,children:"Clear filter"})]}):e.jsx(G,{children:e.jsx("p",{className:"text-fg-muted",children:Ae(f,n)})})}const _e={"whole-folder":"Every message in this folder was checked.","loaded-pages":"Only the messages loaded so far were checked."};function Ae(s,n){return s?"No messages match your search":n?`No messages in ${n}`:"No messages in this mailbox"}function $e(s,n,r){return r?`No results for “${r}” in ${s}`:n?`No ${s} mail in ${n}`:`No ${s} mail`}function G({children:s}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center",children:e.jsx("div",{className:"flex max-w-sm flex-col items-center justify-center p-8 text-center",children:s})})}function Ze(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-fg-muted",role:"status","aria-live":"polite",children:[e.jsx(re,{className:"size-4 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading more…"})]})}function Fe({message:s="Something went wrong loading this mailbox.",onRetry:n,onReport:r}){return e.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-4",children:e.jsxs("div",{role:"alert",className:"flex max-w-sm flex-col items-center justify-center gap-3 text-center",children:[e.jsx(ie,{className:"size-8 text-danger","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-danger",children:"Couldn't load messages"}),e.jsx("p",{className:"mt-1 break-words text-sm text-fg-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(A,{variant:"secondary",size:"sm",onClick:n,children:"Retry"}),r&&e.jsx(A,{variant:"ghost",size:"sm",onClick:r,children:"Report a problem"})]})]})})}const z=72,V=10,He=z/2,J="__swipeableRowAxisCancel";function Z(s){return s==="leading"?z:s==="trailing"?-z:0}function Xe(s){return s>=z/2?"leading":s<=-z/2?"trailing":"none"}function Be({thread:s,selectionMode:n,checked:r,active:f,peek:m,onPeek:g,onToggleCheck:y,onLongPress:j,onOpen:h,onAct:p}){const d=x.useRef(null),[b,v]=x.useState(null),{longPressProps:P}=Ne({onLongPress:j,isDisabled:n,accessibilityDescription:"Select message"}),k=i=>{const o=new PointerEvent("pointercancel",{bubbles:!0});o[J]=!0,i.currentTarget.dispatchEvent(o)},a=ye(P,{onPointerDown:i=>{d.current={startX:i.clientX,startY:i.clientY,axis:"none",escaped:!1}},onPointerMove:i=>{if(n)return;const o=d.current;if(!o)return;const u=i.clientX-o.startX,M=i.clientY-o.startY;if(o.axis==="none"&&(Math.abs(M)>V&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>V&&Math.abs(u)>Math.abs(M)&&(o.axis="horizontal",i.currentTarget.setPointerCapture(i.pointerId))),o.axis==="none")return;const O=o.axis==="horizontal"?Math.abs(u):Math.abs(M);if(!o.escaped&&O>He&&(o.escaped=!0,k(i)),o.axis!=="horizontal")return;const F=Z(m),H=Math.max(-z,Math.min(z,F+u));v(H)},onPointerUp:i=>{const o=d.current;d.current=null;const u=b;if(v(null),!!o){if(o.axis!=="none"&&!o.escaped&&k(i),o.axis==="horizontal"){u!==null&&g(Xe(u));return}if(o.axis!=="vertical"){if(n){y();return}if(m!=="none"){g("none");return}h()}}},onPointerCancel:i=>{i.nativeEvent[J]||(d.current=null,v(null))}}),l=b??Z(m),N=l>0?"leading":l<0?"trailing":"none",C=Q("relative touch-pan-y bg-surface","select-none",Pe({active:r||f})),L={transform:l!==0?`translateX(${l}px)`:void 0,transition:b===null?"transform 150ms ease":"none",minHeight:44},$=!s.isRead,I=i=>i.stopPropagation(),T=n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:Q("inline-flex size-7 shrink-0 items-center justify-center rounded-full border",r?"border-accent bg-accent text-accent-fg":"border-line-strong bg-canvas"),children:r&&e.jsx(oe,{className:"size-3.5"})}),e.jsx(q,{thread:s})]}):e.jsxs(e.Fragment,{children:[$&&e.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),e.jsx("span",{role:"checkbox",tabIndex:0,"aria-checked":r,"aria-label":`Select message from ${s.fromName}`,onPointerDown:I,onPointerMove:I,onPointerUp:I,onClick:i=>{i.preventDefault(),i.stopPropagation(),j()},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),i.stopPropagation(),j())},className:"-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full",children:e.jsx(ze,{name:s.fromName,email:s.fromEmail,size:"sm"})}),e.jsx(q,{thread:s})]});return e.jsxs("div",{className:"relative overflow-hidden",children:[N==="leading"&&e.jsx("button",{type:"button",onClick:()=>p("leading"),"aria-label":s.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:s.isRead?e.jsx(Oe,{className:"size-6"}):e.jsx(Ce,{className:"size-6"})}),N==="trailing"&&e.jsx("button",{type:"button",onClick:()=>p("trailing"),"aria-label":"Delete message",className:"absolute inset-y-0 right-0 flex items-center justify-end bg-danger px-6 text-canvas",children:e.jsx(ce,{className:"size-6"})}),e.jsx("button",{type:"button",role:n?"checkbox":void 0,"aria-checked":n?r:void 0,"data-message-row":!0,"data-message-id":s.id,...a,className:C,style:L,children:T})]})}function We({sections:s,selectedThreadId:n,selectionMode:r,checkedIds:f,initialPeek:m,onToggleCheck:g,onEnterSelection:y,onOpenThread:j,onRefresh:h,refreshing:p,busy:d=!1}){const[b,v]=x.useState(new Set),[P,k]=x.useState(new Map),w=s.flatMap(a=>a.threads).filter(a=>!b.has(a.id)).map(a=>{const l=P.get(a.id);return l===void 0?a:{...a,isRead:l}}),[S,R]=x.useState(m&&m!=="none"&&w[1]?{id:w[1].id,side:m}:null),E=(a,l)=>{if(l==="trailing")v(N=>new Set(N).add(a));else{const N=w.find(C=>C.id===a);k(C=>new Map(C).set(a,!N?.isRead))}R(null)};return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 border-b border-line py-3 text-fg-muted",children:[e.jsx(ve,{className:"size-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Checking for new mail…"})]}),e.jsx("div",{className:"divide-y divide-line",children:w.map(a=>e.jsx("div",{className:d?"pointer-events-none opacity-50":void 0,children:e.jsx(Be,{thread:a,selectionMode:r,checked:f.has(a.id),active:a.id===n,peek:S?.id===a.id?S.side:"none",onPeek:l=>R(l==="none"?null:{id:a.id,side:l}),onToggleCheck:()=>g(a.id),onLongPress:()=>y(a.id),onOpen:()=>j(a.id),onAct:l=>E(a.id,l)})},a.id))}),!r&&!p&&!d&&e.jsx("button",{type:"button",onClick:h,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"})]})}const Ye=new Set;function es({listTitle:s,listMeta:n,sections:r,briefFilters:f,flatList:m,listState:g="ready",searchQuery:y,listFilter:j,listScopeLabel:h,errorMessage:p,onRetry:d,onReportError:b,briefFilter:v,selectedThreadId:P,density:k="comfortable",onSelectThread:w,onOpenNav:S,isDesktop:R,initialTouchState:E,selection:a,keyboard:l,selectionBar:N,paneOverlay:C,listBody:L,hideHeader:$=!1}){const I=k==="compact"?Se:Me,T=x.useRef(null),i=x.useRef(null),o=le(l);ue({containerRef:T,itemSelector:U,enabled:!o});const u=o?l.focusedId:void 0,M=o?u??r[0]?.threads[0]?.id:void 0,O=x.useCallback(t=>M===void 0?void 0:t===M?0:-1,[M]);x.useEffect(()=>{if(u===void 0)return;const t=i.current;if(!t)return;const c=t.querySelector(`${U}[data-message-id="${u}"]`);!c||c===t.ownerDocument.activeElement||c.focus({preventScroll:!1})},[u]),x.useEffect(()=>{if(!o)return;const t=i.current;if(!t)return;const c=t.ownerDocument.activeElement;c!==null&&c!==t.ownerDocument.body||t.focus({preventScroll:!0})},[o]);const F=!R&&!f&&g==="ready",[H,Y]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{Y(!0),setTimeout(()=>Y(!1),1400)},_=a?.selectedIds??Ye,D=a?.onToggle,K=a?.onRowSelect,te=Re(_.size,R),X=x.useCallback(t=>{if(D)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),D(t)}}},[_,D]),B=x.useCallback((t,c)=>K?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[K]),ne=x.useCallback(({thread:t,active:c,onClick:W})=>e.jsx(I,{thread:t,active:c,focused:t.id===u,tabIndex:O(t.id),selection:X(t.id),onClick:ae=>{B(t.id,ae)||W?.()}}),[I,X,B,u,O]);return e.jsxs("section",{ref:t=>{i.current=t,l?.ref(t)},tabIndex:o?-1:void 0,className:"relative flex h-full w-full flex-col bg-surface outline-none",children:[N??($?null:e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[S&&e.jsx(A,{variant:"ghost",size:"sm",icon:e.jsx(De,{className:"size-4"}),onClick:S,"aria-label":"Open folders",className:"-ml-1 shrink-0"}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:s}),n&&e.jsx("span",{className:"shrink-0 text-2xs text-fg-subtle",children:n})]})),g==="loading"?e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(Le,{})}):g==="empty"?e.jsx(Te,{filter:j,scopeLabel:h,searchQuery:y}):g==="error"?e.jsx(Fe,{message:p,onRetry:d,onReport:b}):f?e.jsx(de,{...v??{},sections:r,selectedThreadId:P,Row:ne,keyboard:l,onSelectThread:w}):L??(F?e.jsx(We,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>D?.(t),onEnterSelection:t=>D?.(t),onOpenThread:t=>w?.(t),onRefresh:se,refreshing:H}):e.jsx("div",{ref:T,className:"flex-1 overflow-y-auto",children:r.map(t=>e.jsxs("div",{children:[!m&&t.label&&e.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:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:t.label}),e.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:t.threads.length})]}),e.jsx("div",{className:"divide-y divide-line",children:t.threads.map(c=>e.jsx(I,{thread:c,active:c.id===P,focused:c.id===u,tabIndex:O(c.id),selection:X(c.id),onClick:W=>{B(c.id,W)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ke=class extends fe{constructor(s,n){super(s,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(s){s._type="infinite",super.setOptions(s)}getOptimisticResult(s){return s._type="infinite",super.getOptimisticResult(s)}fetchNextPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(s){return this.fetch({...s,meta:{fetchMore:{direction:"backward"}}})}createResult(s,n){const{state:r}=s,f=super.createResult(s,n),{isFetching:m,isRefetching:g,isError:y,isRefetchError:j}=f,h=r.fetchMeta?.fetchMore?.direction,p=y&&h==="forward",d=m&&h==="forward",b=y&&h==="backward",v=m&&h==="backward";return{...f,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(n,r.data),hasPreviousPage:me(n,r.data),isFetchNextPageError:p,isFetchingNextPage:d,isFetchPreviousPageError:b,isFetchingPreviousPage:v,isRefetchError:j&&!p&&!b,isRefetching:g&&!d&&!v}}};function ss(s,n){return ge(s,Ke)}function ts({title:s,unreadCount:n,preset:r,selectedCategory:f,activeFilters:m,onSelectCategory:g,onToggleFilter:y,onSelectSource:j,onClearFilters:h,children:p,footer:d,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a}){const{searchInput:l}=he(),N=l.trim().length>0,C={categories:r.categories,filters:r.filters,sources:r.sources,selectedCategory:f,activeFilters:m,onSelectCategory:g,onSelectSource:j,onToggleFilter:y,onClear:h};return e.jsx(pe,{hasSheet:!N,children:e.jsx(Ie,{title:s,unreadCount:n,footer:d,searchFilter:C,searchResults:b,searchLoading:v,relatedResults:P,relatedLoading:k,onSelectSearchResult:w,searchResultsLabel:S,relatedResultsLabel:R,searchResultsInBody:E,refreshControl:a,children:e.jsx(be,{...C,hideChrome:N,children:p})})})}export{Ze as M,Be as S,es as a,ts as b,ss as u};