@remit/web-client-dist 0.0.353 → 0.0.355

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 (109) hide show
  1. package/assets/BriefPane-CYfwVL8Y.js +1 -0
  2. package/assets/{ErrorState-D3orNRU4.js → ErrorState-CJ2aoLG_.js} +1 -1
  3. package/assets/FlaggedPane-Sleye2NB.js +1 -0
  4. package/assets/MailListHeader-CiYx2Ro0.js +52 -0
  5. package/assets/{MailViewChrome-Or_Zfnrd.js → MailViewChrome-4eYgZdUD.js} +1 -1
  6. package/assets/MailboxPane-VSk6AMXL.js +1 -0
  7. package/assets/{NavMenuButton-B1nVcSa5.js → NavMenuButton-DCYDMDv1.js} +1 -1
  8. package/assets/{OnboardingWizard-CkM1UvY8.js → OnboardingWizard-DoBOq2ec.js} +1 -1
  9. package/assets/OutboxPane-D0ChJoAd.js +1 -0
  10. package/assets/_mailboxId-CK7QowXy.js +1 -0
  11. package/assets/_messageId-Bw730qzW.js +1 -0
  12. package/assets/_messageId-DRTnEPcv.js +1 -0
  13. package/assets/_messageId-DeYJ2FsF.js +1 -0
  14. package/assets/_outboxMessageId-CECizJ1R.js +1 -0
  15. package/assets/_threadId-DgtAhuV_.js +1 -0
  16. package/assets/_threadId-Dj8HOsy1.js +1 -0
  17. package/assets/_threadId-I8eJqG4z.js +1 -0
  18. package/assets/{account-form-helpers-BZTGbgn5.js → account-form-helpers-DAuyJa3o.js} +1 -1
  19. package/assets/{accounts-BUqCJgDQ.js → accounts-CeDKOmD9.js} +1 -1
  20. package/assets/{advanced-ChGO6lwb.js → advanced-hybSRTbS.js} +1 -1
  21. package/assets/{appearance-hzG3cLo6.js → appearance-BpvA9O2b.js} +1 -1
  22. package/assets/{avatar-902Ehcia.js → avatar-CmvuzecB.js} +1 -1
  23. package/assets/{bottom-sheet-DSZ-IeLs.js → bottom-sheet-BYOjIdVx.js} +1 -1
  24. package/assets/{brief-B_cGujUH.js → brief-BVPyzhNL.js} +1 -1
  25. package/assets/brief-DF7GfO-r.js +1 -0
  26. package/assets/{browser-ponyfill-D3Qjvj70.js → browser-ponyfill-C0xW0XXl.js} +1 -1
  27. package/assets/{bug-BPy3lhCs.js → bug-JM5TdK6J.js} +1 -1
  28. package/assets/{circle-check-Bd1R3tZl.js → circle-check-DlmySaui.js} +1 -1
  29. package/assets/{circle-check-big-DAvgIk1F.js → circle-check-big-Cj9roMB7.js} +1 -1
  30. package/assets/{circle-help-BG86c5CF.js → circle-help-C_AXwAaV.js} +1 -1
  31. package/assets/{clock-D7o61sW5.js → clock-C4V2tcYN.js} +1 -1
  32. package/assets/{confirm-dialog-CMKEZton.js → confirm-dialog-DPkij3bo.js} +1 -1
  33. package/assets/{download-CtV8eLNc.js → download-ChGh-J5t.js} +1 -1
  34. package/assets/filters-GacN8-tL.js +1 -0
  35. package/assets/{flagged-CvZY9GgJ.js → flagged-D5M0XeA-.js} +1 -1
  36. package/assets/flagged-DRo_foUo.js +1 -0
  37. package/assets/{folders-C68Orza8.js → folders-BrH0h_oC.js} +1 -1
  38. package/assets/index-0RAdsyez.js +1 -0
  39. package/assets/{index-DivxHcM7.css → index-Bn4mOVkF.css} +1 -1
  40. package/assets/{index-Bf6zeV_t.js → index-Bqn7f16e.js} +4 -4
  41. package/assets/index-Csk5-jLk.js +1 -0
  42. package/assets/index-D6wIsDjM.js +1 -0
  43. package/assets/index-DRTnEPcv.js +1 -0
  44. package/assets/index-DeYJ2FsF.js +1 -0
  45. package/assets/index-W1wD_fe0.js +1 -0
  46. package/assets/index-hR0QoOpl.js +1 -0
  47. package/assets/index-u91rwMUb.js +1 -0
  48. package/assets/{kbd-C4MYDwt7.js → kbd-BG1I0chs.js} +1 -1
  49. package/assets/{labels-CxqBtA9B.js → labels-BavFLXMP.js} +1 -1
  50. package/assets/mail-2xAGIPds.js +1 -0
  51. package/assets/{menu-DNUIh6FR.js → menu-vEH9STs_.js} +1 -1
  52. package/assets/{move-options-BPdblyET.js → move-options-k5syuO4O.js} +1 -1
  53. package/assets/nav-link-COOZsOLo.js +1 -0
  54. package/assets/{onboarding-D_iTSaYS.js → onboarding-B28Gihze.js} +1 -1
  55. package/assets/outbox-XuiN4du0.js +1 -0
  56. package/assets/{pencil-j8v7X9GK.js → pencil-CkIitMcy.js} +1 -1
  57. package/assets/{rich-text-D7ibJsSf.js → rich-text-CsEQAreR.js} +1 -1
  58. package/assets/{rich-text-spellcheck-worker-provider-BtCQ4Qwa.js → rich-text-spellcheck-worker-provider-x6rgxHWR.js} +1 -1
  59. package/assets/{rotate-ccw-9aRuc9Yf.js → rotate-ccw-xiByt5L1.js} +1 -1
  60. package/assets/{row-actions-Dq-6Ssz1.js → row-actions-t73y2fxd.js} +1 -1
  61. package/assets/search-token-index-D-3XiS1P.js +1 -0
  62. package/assets/{search-view-B25AYYYV.js → search-view-B6uoqRaE.js} +1 -1
  63. package/assets/{senders-KLHBevDQ.js → senders-cIRRNPpD.js} +1 -1
  64. package/assets/settings-DzfdNeyv.js +1 -0
  65. package/assets/{settings-screen-DSdtzTVA.js → settings-screen-CH2hBhXZ.js} +1 -1
  66. package/assets/{shield-check-CmXHx2Di.js → shield-check-drtxfxOL.js} +1 -1
  67. package/assets/{suggested-vips-3e-ngqqE.js → suggested-vips-CNjxCtfh.js} +1 -1
  68. package/assets/{useDebouncedValue-fVfFWYH1.js → useDebouncedValue-upT4qR9G.js} +1 -1
  69. package/assets/useFilters-SCAefE6U.js +1 -0
  70. package/assets/{useLabels-BMVLGb1c.js → useLabels-EfJaVdWJ.js} +1 -1
  71. package/assets/useMediaQuery-C47DmZA5.js +1 -0
  72. package/assets/{useRefreshControl-Ba6f6ijf.js → useRefreshControl-DMQBrv7r.js} +1 -1
  73. package/assets/{useSearchMirror-Co706q8t.js → useSearchMirror-BaenAzTH.js} +1 -1
  74. package/assets/{useSearchTokenContext-BRWpWSX8.js → useSearchTokenContext-ki2AZ7p9.js} +1 -1
  75. package/assets/{useSemanticSearch-CCTRY7p1.js → useSemanticSearch-DoxylHxn.js} +1 -1
  76. package/assets/{useSignature-BoeZFYk-.js → useSignature-6eMCtb3X.js} +1 -1
  77. package/index.html +2 -2
  78. package/package.json +1 -1
  79. package/assets/BriefPane-fii0IiRa.js +0 -1
  80. package/assets/FlaggedPane-BldHHUxk.js +0 -1
  81. package/assets/MailListHeader-GQfpCdPQ.js +0 -52
  82. package/assets/MailboxPane-CO67RCjZ.js +0 -1
  83. package/assets/OutboxPane-DuBwgi_W.js +0 -1
  84. package/assets/_mailboxId-wOAbngf_.js +0 -1
  85. package/assets/_messageId-B6IwOu5Q.js +0 -1
  86. package/assets/_messageId-BtUwYG-X.js +0 -1
  87. package/assets/_messageId-UZEsQ4vY.js +0 -1
  88. package/assets/_outboxMessageId-5j0cIWqh.js +0 -1
  89. package/assets/_threadId-BGjw3ct6.js +0 -1
  90. package/assets/_threadId-CGxoaeOt.js +0 -1
  91. package/assets/_threadId-HAVKpBa2.js +0 -1
  92. package/assets/brief-BvZofry6.js +0 -1
  93. package/assets/filters-B2v4KYwx.js +0 -1
  94. package/assets/flagged-CW_lAfX7.js +0 -1
  95. package/assets/index-Bf2SuMfv.js +0 -1
  96. package/assets/index-BtUwYG-X.js +0 -1
  97. package/assets/index-Bxl7Z2-H.js +0 -1
  98. package/assets/index-COgExB7k.js +0 -1
  99. package/assets/index-DHerCUmJ.js +0 -1
  100. package/assets/index-Dz9b3zRw.js +0 -1
  101. package/assets/index-UZEsQ4vY.js +0 -1
  102. package/assets/index-aSNWfHw0.js +0 -1
  103. package/assets/mail-CGkMgcnN.js +0 -1
  104. package/assets/nav-link-kGZZQ6tj.js +0 -1
  105. package/assets/outbox-CVWfytDc.js +0 -1
  106. package/assets/search-token-index-ufNaSd81.js +0 -1
  107. package/assets/settings-Cx_7vs48.js +0 -1
  108. package/assets/use-match-media-Cqq5eDbi.js +0 -1
  109. package/assets/useFilters-BfhDojrF.js +0 -1
@@ -1 +1 @@
1
- import{j as e,am as re,B as A,e as ie,r as x,b as Q,an as oe,T as ce,bH as le,u as ue,bI as U,bs as de,bJ as fe,bK as me,bL as xe,bM as ge,o as he,bt as pe,bN as be}from"./index-Bf6zeV_t.js";import{R as ve,l as je,m as we}from"./search-token-index-ufNaSd81.js";import{ap as Ne,aq as ye,c as Pe,b as q,ar as Ce,v as Re,as as ke,at as Se,au as Me,af as Ee,ah as Ie}from"./MailListHeader-GQfpCdPQ.js";import{A as ze}from"./avatar-902Ehcia.js";import{M as Oe}from"./account-form-helpers-BZTGbgn5.js";import{M as Le}from"./menu-DNUIh6FR.js";function De(){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,J=10,He=z/2,V="__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[V]=!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)>J&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>J&&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[V]||(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})),D={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:D,children:T})]})}function Ke({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 We=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:D,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,W]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{W(!0),setTimeout(()=>W(!1),1400)},_=a?.selectedIds??We,L=a?.onToggle,Y=a?.onRowSelect,te=Re(_.size,R),X=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>Y?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),ne=x.useCallback(({thread:t,active:c,onClick:K})=>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)||K?.()}}),[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(Le,{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(De,{})}):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}):D??(F?e.jsx(Ke,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(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:K=>{B(c.id,K)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ye=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,Ye)}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,am as re,B as A,e as ie,r as x,b as Q,an as oe,T as ce,bH as le,u as ue,bI as U,bs as de,bJ as fe,bK as me,bL as xe,bM as ge,o as he,bt as pe,bN as be}from"./index-Bqn7f16e.js";import{R as ve,l as je,m as we}from"./search-token-index-D-3XiS1P.js";import{ap as Ne,aq as ye,c as Pe,b as q,ar as Ce,v as Re,as as ke,at as Se,au as Me,af as Ee,ah as Ie}from"./MailListHeader-CiYx2Ro0.js";import{A as ze}from"./avatar-CmvuzecB.js";import{M as Oe}from"./account-form-helpers-DAuyJa3o.js";import{M as Le}from"./menu-vEH9STs_.js";function De(){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,J=10,He=z/2,V="__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[V]=!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)>J&&Math.abs(M)>Math.abs(u)?o.axis="vertical":Math.abs(u)>J&&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[V]||(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})),D={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:D,children:T})]})}function Ke({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 We=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:D,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,W]=x.useState(!1),ee=E==="peek-trailing"?"trailing":E==="peek-leading"?"leading":void 0,se=()=>{W(!0),setTimeout(()=>W(!1),1400)},_=a?.selectedIds??We,L=a?.onToggle,Y=a?.onRowSelect,te=Re(_.size,R),X=x.useCallback(t=>{if(L)return{checked:_.has(t),onToggle:c=>{c.preventDefault(),c.stopPropagation(),L(t)}}},[_,L]),B=x.useCallback((t,c)=>Y?.(t,ke(c))?(c.preventDefault(),c.shiftKey&&window.getSelection()?.removeAllRanges(),!0):!1,[Y]),ne=x.useCallback(({thread:t,active:c,onClick:K})=>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)||K?.()}}),[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(Le,{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(De,{})}):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}):D??(F?e.jsx(Ke,{sections:r,selectedThreadId:P,selectionMode:te,checkedIds:_,initialPeek:ee,onToggleCheck:t=>L?.(t),onEnterSelection:t=>L?.(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:K=>{B(c.id,K)||w?.(c.id)}},c.id))})]},t.id))})),R&&e.jsx(Ee,{hints:l?we(l.handlers):je}),C]})}var Ye=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,Ye)}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};
@@ -0,0 +1 @@
1
+ import{j as r,be as Rs,az as Dt,B as ue,S as Es,b as Re,aA as Gt,r as l,C as Os,d as As,a$ as Ns,k as xt,x as tt,Y as Yt,X as zs,p as st,s as Ft,y as Ds,ae as _t,bf as Xt,bg as Zt,I as Fs,h as _s,T as Ls,bh as Ps,bi as $s,bj as Bs,ac as es,aM as Ws,aN as Ks,g as Vs,a1 as Lt,bk as qs,P as Hs,w as Us,bl as Qs,o as ts,bm as Js,H as Gs,af as Ys,i as Xs,bn as Zs,b4 as en}from"./index-Bqn7f16e.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-ki2AZ7p9.js";import{u as on,a as rn,R as an}from"./useRefreshControl-DMQBrv7r.js";import{C as ss,D as Pe,a as ns,b as os,c as is,j as ln,M as cn,t as rs,u as dn,d as un,e as as,f as ls,g as hn,h as fn,i as mn,k as gn,l as Kt,n as pn,m as xn,o as bn,p as vn,q as Sn,S as yn,r as Cn,s as In,v as wn,w as cs,x as jn,y as kn,z as Mn,A as Tn,B as Rn,E as En,F as On,G as An,H as Nn,I as zn,J as Dn,K as Vt,L as qt,N as Fn,O as _n,P as Ln,Q as Pn,R as $n,T as Bn,U as Wn,V as Kn,W as Vn,X as qn,Y as Hn,Z as ds,_ as us,$ as Pt,a0 as Un,a1 as hs,a2 as Qn,a3 as Jn}from"./MailListHeader-CiYx2Ro0.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-4eYgZdUD.js";import{E as fs,f as to}from"./ErrorState-CJ2aoLG_.js";import{a as so,D as no,u as ms}from"./useMediaQuery-C47DmZA5.js";import{C as gs}from"./confirm-dialog-DPkij3bo.js";import{A as $t}from"./avatar-CmvuzecB.js";import{b as nt,c as oo,d as io}from"./format-De9HZKjg.js";import{c as ot}from"./nav-link-COOZsOLo.js";import{N as ro}from"./NavMenuButton-DCYDMDv1.js";import{a as ao}from"./useLabels-EfJaVdWJ.js";import{L as lo,u as co}from"./useSemanticSearch-DoxylHxn.js";import{S as bt}from"./shield-check-drtxfxOL.js";import{B as uo}from"./bottom-sheet-BYOjIdVx.js";import{C as ho}from"./circle-help-C_AXwAaV.js";import{C as fo}from"./circle-check-DlmySaui.js";import{a as mo,b as go,f as po}from"./move-options-k5syuO4O.js";import{j as xo,k as bo,f as vo,d as So}from"./search-token-index-D-3XiS1P.js";import{M as yo}from"./enums-CCxx0t2v.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const Io=({children:e,onRefresh:n,isRefreshing:t})=>so(no)?e:r.jsx(Rs,{onRefresh:n,isPullable:!t,children:e}),wo=e=>e===1?"message":"messages";function jo({count:e,onReview:n,onDismiss:t,actionLabel:s="Review & rescue"}){return r.jsx(Dt,{tone:"info",variant:"soft",onDismiss:t,children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("p",{className:"flex items-start gap-2 text-sm text-fg",children:[r.jsx(bt,{className:"mt-0.5 size-4 shrink-0 text-positive","aria-hidden":!0}),r.jsxs("span",{children:[r.jsx("span",{className:"font-semibold text-fg",children:`${e} ${wo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(ue,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:s})]})})}const ko=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",ps=({senderTrust:e,size:n="sm",className:t})=>{const s=ko(e,n);return s==="vip"?r.jsx(Es,{className:Re("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",t),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):s==="unknown-pill"?r.jsx("span",{className:Re("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",t),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function Mo({candidate:e,selected:n,onToggle:t,hideSender:s=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:d,trustSubReason:u,senderTrust:f}=e;return r.jsxs("label",{className:Re("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",s&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ss,{className:"mt-0.5",checked:n,onChange:t,"aria-label":`${n?"Deselect":"Select"} ${s?c:`message from ${o}`}`}),!s&&r.jsx($t,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!s&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:o}),f&&r.jsx(ps,{senderTrust:f,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:i})]}),r.jsx("span",{className:"block truncate text-sm text-fg-muted",children:c}),r.jsx("span",{className:"block line-clamp-1 text-xs text-fg-subtle",children:a}),!s&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Gt,{tone:"positive",children:[r.jsx(bt,{className:"size-3","aria-hidden":!0}),d]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:u})]})]})]})}const To=e=>{const n=new Map,t=[];for(const s of e){const o=(s.senderAddress||s.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(s);continue}n.set(o,{key:o,senderName:s.senderName,senderAddress:s.senderAddress,trustReason:s.trustReason,trustSubReason:s.trustSubReason,senderTrust:s.senderTrust,messages:[s]}),t.push(o)}return t.map(s=>n.get(s)).sort((s,o)=>o.messages.length-s.messages.length)},Ro=(e,n)=>{const t=e.messages.filter(s=>n.has(s.id)).length;return t===0?"none":t===e.messages.length?"all":"some"},Ht=e=>e===1?"message":"messages";function Eo({group:e,selected:n,onToggleGroup:t,onToggleMessage:s}){const[o,i]=l.useState(!1),c=Ro(e,n),a=e.messages.length,d=o?Os:As;return r.jsxs("div",{className:Re(c!=="none"?"bg-positive/10":"bg-surface"),children:[r.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-2.5",children:[r.jsx(ss,{className:"mt-0.5",checked:c==="all",indeterminate:c==="some",onChange:()=>t(e,c!=="all"),"aria-label":`${c==="all"?"Deselect":"Select"} all ${a} ${Ht(a)} from ${e.senderName}`}),r.jsx($t,{name:e.senderName,email:e.senderAddress,size:"sm"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"truncate text-sm font-medium text-fg",children:e.senderName}),e.senderTrust&&r.jsx(ps,{senderTrust:e.senderTrust,size:"sm"}),r.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:e.senderAddress})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Gt,{tone:"positive",children:[r.jsx(bt,{className:"size-3","aria-hidden":!0}),e.trustReason]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:e.trustSubReason})]})]}),r.jsxs("button",{type:"button",onClick:()=>i(u=>!u),"aria-expanded":o,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-2xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg",children:[`${a} ${Ht(a)}`,r.jsx(d,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(u=>r.jsx(Mo,{candidate:u,selected:n.has(u.id),onToggle:()=>s(u.id),hideSender:!0},u.id))})]})}const Bt=e=>e===1?"message":"messages",Oo=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Bt(e)}`} out of Spam to ${n} now. Nothing later.`,zt=(e,n)=>e.find(t=>t.id===n)?.label??"Inbox";function Ao(){return r.jsx(Dt,{tone:"info",variant:"soft",children:r.jsx("p",{className:"text-2xs text-fg-muted",children:"We list a message here only when we can confirm the sender is who they say — usually someone you've emailed before, write to often, or a service that consistently checks out. We never guess from words in the subject. Anything we can't confirm stays in Spam."})})}function No({candidates:e,selected:n,onToggle:t,onToggleGroup:s,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[d,u]=l.useState(!1),f=n.size,m=l.useMemo(()=>To(e),[e]);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("h2",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r.jsx(bt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(ue,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>u(g=>!g),className:"-mr-1.5 -mt-0.5",children:"Why these?"})]}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"These look safe — from senders we can verify. Uncheck any sender that belongs in Spam, or open a sender to pick individual messages."}),d&&r.jsx("div",{className:"mt-2",children:r.jsx(Ao,{})})]}),r.jsxs("div",{className:"flex items-center justify-between px-row-inset pb-1.5",children:[r.jsx("span",{className:"text-2xs font-medium text-fg-muted",children:`${f} of ${e.length} selected · ${m.length} ${m.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(ue,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(ue,{variant:"ghost",size:"sm",onClick:i,children:"Select none"})]})]}),r.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto border-y border-line",children:m.map(g=>r.jsx(Eo,{group:g,selected:n,onToggleGroup:s,onToggleMessage:t},g.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(ue,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Bt(f)}`}),r.jsx(ue,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function zo({count:e,folders:n,delimiter:t,destination:s,onPick:o,onMove:i,onBack:c}){const[a,d]=l.useState(!1);return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"px-row-inset pb-2 pt-1",children:[r.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Where should they go?"}),r.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:"Pick a folder, then we move them out of Spam."})]}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-row-inset py-2",children:a?r.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden rounded-xl border border-line bg-surface",children:r.jsx(Ns,{folders:n,selectedId:s,delimiter:t,onSelect:o,onCancel:()=>d(!1)})}):r.jsxs("div",{className:"rounded-xl border border-line bg-surface-sunken p-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:"Destination"}),r.jsx("p",{className:"mt-0.5 text-sm font-medium text-fg",children:zt(n,s)}),r.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>d(!0),className:"mt-2 px-0",children:"Move to a different folder"})]})}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx("p",{className:"text-2xs text-fg-subtle",children:Oo(e,zt(n,s))}),r.jsx(ue,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(ue,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Do({count:e,destinationLabel:n,onClose:t}){return r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-row-inset py-10 text-center",children:[r.jsx(fo,{className:"size-10 text-positive","aria-hidden":!0}),r.jsx("p",{className:"text-base font-semibold text-fg",children:`Moved ${e} ${Bt(e)} out of Spam.`}),r.jsx("p",{className:"text-2xs text-fg-subtle",children:`You'll find them in ${n}.`})]}),r.jsx("div",{className:"border-t border-line bg-surface px-row-inset py-3",children:r.jsx(ue,{variant:"primary",onClick:t,className:"h-11 w-full font-semibold",children:"Done"})})]})}function Fo({open:e,candidates:n,defaultDestinationId:t,availableFolders:s,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,d]=l.useState("review"),[u,f]=l.useState(()=>e?new Set(n.map(C=>C.id)):new Set),[m,g]=l.useState(t),[v,I]=l.useState(0),k=l.useRef(!1);l.useEffect(()=>{e&&!k.current&&(d("review"),f(new Set(n.map(C=>C.id))),g(t),I(0)),k.current=e},[e,n,t]);const E=u.size,S=C=>{f(j=>{const O=new Set(j);return O.has(C)?O.delete(C):O.add(C),O})},x=(C,j)=>{f(O=>{const A=new Set(O);for(const z of C.messages)j?A.add(z.id):A.delete(z.id);return A})},y=()=>{const C=Array.from(u);I(C.length),i(C,m),d("done")};return r.jsxs(uo,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(No,{candidates:n,selected:u,onToggle:S,onToggleGroup:x,onSelectAll:()=>f(new Set(n.map(C=>C.id))),onSelectNone:()=>f(new Set),onContinue:()=>d("destination"),onCancel:c}),a==="destination"&&r.jsx(zo,{count:E,folders:s,delimiter:o,destination:m,onPick:g,onMove:y,onBack:()=>d("review")}),a==="done"&&r.jsx(Do,{count:v,destinationLabel:zt(s,m),onClose:c})]})}const _o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Lo=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const t=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=t.trim().length>0||i.length>0,e.current},[])},Po=()=>{const{state:e,closeCompose:n}=xt(),t=Lo(),[s,o]=l.useState(!1),{isError:i,error:c,refetch:a}=tt({...Yt(),staleTime:1/0}),d=l.useCallback(g=>{g||(t()?o(!0):n())},[n,t]),u=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const m=_o[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:d,children:[r.jsxs(Pe.Portal,{children:[r.jsx(Pe.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),r.jsxs(Pe.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[r.jsx(Pe.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),r.jsx(Pe.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:m}),i?r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(fs,{title:"Couldn't load compose",error:c,onRetry:()=>{a()}})}):r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(ns,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n})})]})]}),r.jsx(gs,{isOpen:s,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:u,onCancel:f})]})},$o={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},xs=()=>{const{state:e,closeCompose:n}=xt(),t=ms(),{isError:s,error:o,refetch:i}=tt({...Yt(),staleTime:1/0});if(!t)return r.jsx(Po,{});if(!e.isOpen)return null;const c=$o[e.mode]??"New Message",a=r.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2 min-w-0",children:r.jsx("h2",{className:"text-lg font-semibold truncate",children:c})}),r.jsx("button",{type:"button",onClick:n,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:r.jsx(zs,{className:"size-5"})})]});return s?r.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[a,r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsx(fs,{title:"Couldn't load compose",error:o,onRetry:()=>{i()}})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[a,r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(ns,{mode:e.mode,account:e.account,sourceMessage:e.sourceMessage,onClose:n},e.outboxMessageId??"new")})]})};function Bo(e){const n=e.toAddresses.join(", ");return{id:e.outboxMessageId,accountId:e.accountId,fromName:e.fromName??e.fromAddress??"Me",fromEmail:e.fromAddress??"",subject:e.subject??"(No subject)",snippet:n?`To: ${n}`:"(No recipients)",timeLabel:nt(e.updatedAt),isRead:!0}}function Wo(e){return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Ko({outboxMessages:e,accountId:n,imapThreads:t}){const s=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Bo),o=t.map(Wo),i=[];return s.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:s}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const Vo=({label:e,count:n})=>r.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline justify-between border-b border-line bg-surface-sunken px-row-inset py-1",children:[r.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),r.jsx("span",{className:"text-2xs text-fg-subtle tabular-nums",children:n})]}),qo=({row:e,isSelected:n,onOpen:t,onDelete:s,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",is({active:n})),children:[r.jsx(_s,{className:"size-7 shrink-0 text-fg-muted mt-0.5"}),r.jsx(os,{thread:e}),r.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),s(e.id)},disabled:o,className:"p-1.5 rounded-md text-fg-muted hover:text-danger hover:bg-surface-raised transition-colors opacity-0 group-hover:opacity-100 focus:opacity-100",title:"Delete draft",children:r.jsx(Ls,{className:"size-3.5"})})})]}),Ho=({row:e,isSelected:n,onOpen:t})=>{const s=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>t(e.id),className:Re("group",is({active:n})),children:[s&&r.jsx("span",{className:"absolute left-1.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full bg-accent"}),r.jsx($t,{name:e.fromName,email:e.fromEmail,size:"sm"}),r.jsx(os,{thread:e})]})};function Uo({mailboxId:e,accountId:n,selectedMessageId:t,imapThreads:s,title:o,unreadCount:i}){const{openCompose:c,state:a}=xt(),d=st(),u=ot(),f=Ft(),{data:m}=tt(Ds()),g=l.useMemo(()=>Ko({outboxMessages:m?.items??[],accountId:n,imapThreads:s}),[m?.items,n,s]),v=_t({...Zt(),onSuccess:()=>{f.invalidateQueries({queryKey:Xt()})}}),I=x=>{v.mutate({path:{outboxMessageId:x}})},k=x=>{c({mode:"new",outboxMessageId:x})},E=x=>{const y=s.find(C=>C.messageId===x)?.threadId;y&&d({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:y,messageId:x},search:C=>C,hash:u})},S=g.length===0;return r.jsxs("section",{className:"flex h-full w-full flex-col bg-surface",children:[r.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[r.jsx(ro,{}),r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:o}),(i??0)>0&&r.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle tabular-nums",children:[i," unread"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:S?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(Fs,{className:"size-8 text-fg-subtle"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"No drafts"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Messages you start composing will appear here."})]}):g.map(x=>r.jsxs("div",{children:[x.label&&r.jsx(Vo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(y=>x.id==="remit-drafts"?r.jsx(qo,{row:y,isSelected:a.isOpen&&y.id===a.outboxMessageId,onOpen:k,onDelete:I,isDeleting:v.isPending},y.id):r.jsx(Ho,{row:y,isSelected:y.id===t,onOpen:E},y.id))})]},x.id))})]})}function Qo(e,n,t){const s=new Array(e);return new Proxy(s,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<e){let u=o[d];if(!u){const f=n[d*2];u=o[d]={index:d,key:t(d),start:f,size:n[d*2+1],end:f+n[d*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,t){let s=t.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==s.length||a.some((u,f)=>s[f]!==u))&&(s=a,o=n(...a),t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(o),i=!1),o}return c.updateDeps=a=>{s=a},c}function Ut(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Jo=(e,n)=>Math.abs(e-n)<1.01,Go=(e,n,t)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>n.apply(this,o),t)}};let et;const At=()=>{if(et!==void 0)return et;if(typeof navigator>"u")return et=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return et=!0;const e=navigator.maxTouchPoints;return et=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Qt=e=>{const{offsetWidth:n,offsetHeight:t}=e;return{width:n,height:t}},Yo=e=>e,Xo=e=>{const n=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=n+i;return o},Zo=(e,n)=>{const t=e.scrollElement;if(!t)return;const s=e.targetWindow;if(!s)return;const o=c=>{const{width:a,height:d}=c;n({width:Math.round(a),height:Math.round(d)})};if(o(Qt(t)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(c=>{const a=()=>{const d=c[0];if(d?.borderBoxSize){const u=d.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Qt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},pt={passive:!0},ei=typeof window>"u"?!0:"onscrollend"in window,ti=(e,n,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ei;let c=0;const a=i?null:Go(o,()=>n(c,!1),e.options.isScrollingResetDelay),d=m=>()=>{c=t(s),a?.(),n(c,m)},u=d(!0),f=d(!1);return s.addEventListener("scroll",u,pt),i&&s.addEventListener("scrollend",f,pt),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",f)}},si=(e,n)=>ti(e,n,t=>{const{horizontal:s,isRtl:o}=e.options;return s?t.scrollLeft*(o&&-1||1):t.scrollTop}),ni=(e,n,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(e),o=t.options.getItemKey(s);return t.itemSizeCache.get(o)??t.options.estimateSize(s)}if(n?.borderBoxSize){const s=n.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!n){const s=t.indexFromElement(e),o=t.options.getItemKey(s),i=t.itemSizeCache.get(o);if(i!==void 0)return i}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},oi=(e,{adjustments:n=0,behavior:t},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+n,behavior:t})},ii=oi;class ri{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const c=()=>{const a=i.target,d=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,f]of this.elementsCache)if(f===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Yo,rangeExtractor:Xo,onChange:()=>{},measureElement:ni,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const g in t){const v=t[g];v!==void 0&&(i[g]=v)}const c=this.options;let a=null,d=null,u=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const g=c.count,v=i.count,I=this.getMeasurements(),k=g>0?((s=I[0])==null?void 0:s.key)??c.getItemKey(0):null,E=g>0?((o=I[g-1])==null?void 0:o.key)??c.getItemKey(g-1):null;if(v!==g||g>0&&v>0&&(i.getItemKey(0)!==k||i.getItemKey(v-1)!==E)){u=!0;const y=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??I[0]:null;y&&(a=[y.key,this.getScrollOffset()-y.start]);const C=i.followOnAppend===!0?"auto":i.followOnAppend||null;C&&v>g&&this.isAtEnd(c.scrollEndThreshold)&&(g===0||i.getItemKey(v-1)!==E)&&(d=C)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,m=0;if(a&&this.scrollOffset!==null){const[g,v]=a,I=this.getMeasurements(),{count:k,getItemKey:E}=this.options;let S=0;for(;S<k&&E(S)!==g;)S++;if(S<k){const x=I[S];if(x){const y=x.start+v;y!==this.scrollOffset&&(m=y-this.scrollOffset,this.scrollOffset=y,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,d,m])},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=$e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,c)=>{if(c&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const a=this.getScrollOffset();this.scrollDirection=c?a===i?this.scrollDirection:a<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!At()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,pt),i.addEventListener("touchend",a,pt),this.unsubs.push(()=>{i.removeEventListener("touchstart",c),i.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,c,a,d]=o;i!==null&&!a&&(At()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=$e(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,o,i,c,a,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:d,gap:u},f)=>{const m=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const S of this.laneAssignments.keys())S>=t&&this.laneAssignments.delete(S);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(S=>{this.itemSizeCache.set(S.key,S.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),a===1){const S=t*2;let x=this._flatMeasurements;if(!x||x.length<S){const j=new Float64Array(S);x&&g>0&&j.set(x.subarray(0,g*2)),x=j,this._flatMeasurements=x}let y;if(g===0)y=s+o;else{const j=g-1;y=x[j*2]+x[j*2+1]+u}for(let j=g;j<t;j++){const O=i(j),A=m.get(O),z=typeof A=="number"?A:this.options.estimateSize(j);x[j*2]=y,x[j*2+1]=z,y+=z+u}const C=Qo(t,x,i);return this.measurementsCache=C,C}const v=this.measurementsCache.slice(0,g),I=new Array(a).fill(void 0),k=new Float64Array(a);let E=0;for(let S=0;S<g;S++){const x=v[S];x&&(I[x.lane]===void 0&&E++,I[x.lane]=S,k[x.lane]=x.end)}for(let S=g;S<t;S++){const x=i(S),y=this.laneAssignments.get(S);let C,j;const O=d==="estimate"||m.has(x);if(y!==void 0&&this.options.lanes>1){C=y;const M=I[C],P=M!==void 0?v[M]:void 0;j=P?P.end+u:s+o}else if(E===a){let M=0,P=k[0],re=I[0];for(let D=1;D<a;D++){const ne=k[D];(ne<P||ne===P&&I[D]<re)&&(M=D,P=ne,re=I[D])}C=M,j=P+u,O&&this.laneAssignments.set(S,C)}else C=S%this.options.lanes,j=s+o,O&&this.laneAssignments.set(S,C);const A=m.get(x),z=typeof A=="number"?A:this.options.estimateSize(S),J=j+z;v[S]={index:S,start:j,size:z,end:J,key:x,lane:C},I[C]===void 0&&E++,I[C]=S,k[C]=J}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,i)=>t.length===0||s===0?(this.range=null,null):(this.range=li(t,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$e(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,i,c)=>i===null||c===null?[]:t({startIndex:i,endIndex:c,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,o-i),a=Math.min(this.options.count-1,o+i);return t>=c&&t<=a}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(a))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o,i;if(t<0||t>=this.options.count)return;let c,a,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(t),a=u[t*2],c=u[t*2+1];else{const g=this.measurementsCache[t];if(!g)return;d=g.key,a=g.start,c=g.size}const f=this.itemSizeCache.get(d)??c,m=s-f;if(m!==0){const g=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=g?this.getTotalSize():0,I=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:d,start:a,size:c,end:a+c,lane:0},m,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++,g?this.applyScrollAdjustment(this.getTotalSize()-v):I&&this.applyScrollAdjustment(m),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let i=0,c=t.length;i<c;i++){const a=t[i],d=s[a];o.push(d)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,c=bs(0,s.length-1,i?a=>o[a*2]:a=>Ut(s[a]).start,t);return Ut(s[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),c=this.getScrollOffset();s==="auto"&&(s=t>=c+i?"end":"start"),s==="center"?t+=(o-i)/2:s==="end"&&(t-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),c=this.measurementsCache[t];if(!c)return;if(s==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(c.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const a=s==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,s,c.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(t,s),c=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,s);if(!i)return;const[c,a]=i,d=this.now();this.scrollState={index:t,align:a,behavior:o,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((t=s[i])==null?void 0:t.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=s.length-1;for(;c>=0&&i.some(a=>a===null);){const a=s[c];i[a.lane]===null&&(i[a.lane]=a.end),c--}o=Math.max(...i.filter(a=>a!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&t.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,t){n!==0&&(At()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Jo(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const a=this.getSize()||600,d=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const bs=(e,n,t,s)=>{for(;e<=n;){const o=(e+n)/2|0,i=t(o);if(i<s)e=o+1;else if(i>s)n=o-1;else return o}return e>0?e-1:0};function ai(e,n,t){let s=0;for(;s<=n;){const o=(s+n)/2|0,i=e[o*2];if(i<t)s=o+1;else if(i>t)n=o-1;else return o}return s>0?s-1:0}function li(e,n,t,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const u=ai(o,i,t);let f=u;const m=t+n;for(;f<i&&o[f*2]+o[f*2+1]<m;)f++;return{startIndex:u,endIndex:f}}let a=bs(0,i,u=>e[u].start,t),d=a;if(s===1)for(;d<i&&e[d].end<t+n;)d++;else if(s>1){const u=Array(s).fill(0);for(;d<i&&u.some(m=>m<t+n);){const m=e[d];u[m.lane]=m.end,d++}const f=Array(s).fill(t+n);for(;a>=0&&f.some(m=>m>=t);){const m=e[a];f[m.lane]=m.start,a--}a=Math.max(0,a-a%s),d=Math.min(i,d+(s-1-d%s))}return{startIndex:a,endIndex:d}}const Nt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function ci({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:t="transform",...s}){const o=l.useReducer(u=>u+1,0)[1],i=l.useRef({enabled:n,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=t;const c=u=>{const f=i.current;if(!f.enabled||!f.container)return;const m=u.getTotalSize();if(m!==f.lastSize){f.lastSize=m;const S=u.options.horizontal?"width":"height";f.container.style[S]=`${m}px`}const g=!!u.options.horizontal,v=f.mode==="transform",I=g?"left":"top",k=u.options.scrollMargin,E=u.getVirtualItems();for(const S of E){const x=S.start-k,y=u.elementsCache.get(S.key);y&&f.lastPositions.get(y)!==x&&(f.lastPositions.set(y,x),v?y.style.transform=g?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:y.style[I]=`${x}px`)}},a={...s,onChange:(u,f)=>{var m;const g=i.current;let v=!0;if(g.enabled){c(u);const I=u.range,k=g.prevRange;v=!k||k.isScrolling!==u.isScrolling||k.startIndex!==I?.startIndex||k.endIndex!==I?.endIndex,v&&(g.prevRange=I?{startIndex:I.startIndex,endIndex:I.endIndex,isScrolling:u.isScrolling}:null)}v&&(e&&f?Ps.flushSync(o):o()),(m=s.onChange)==null||m.call(s,u,f)}},[d]=l.useState(()=>{const u=new ri(a);return Object.assign(u,{containerRef:f=>{const m=i.current;if(m.container=f,m.lastSize=null,f&&m.enabled){const g=u.getTotalSize();m.lastSize=g;const v=u.options.horizontal?"width":"height";f.style[v]=`${g}px`}}})});return d.setOptions(a),Nt(()=>d._didMount(),[]),Nt(()=>d._willUpdate()),Nt(()=>{c(d)}),d}function di(e){return ci({observeElementRect:Zo,observeElementOffset:si,scrollToFn:ii,...e})}const Wt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",ui=e=>`Select all ${Wt(e)}`,hi=(e,n)=>`All ${oo(n)} ${Wt(e)} selected`,fi=({verb:e,confirmingDelete:n,hasSelection:t,junkMailboxId:s,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=ln(s,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return t?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},mi=(e,n,t)=>e==="BACK"&&n&&t===void 0,gi=(e,n)=>({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:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:rs(e.category),messageCount:n,suspicious:e.authenticity?.dkimMismatch===!0,labels:e.labels}),pi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,messageCount:u,isMultiSelectMode:f,onLongPress:m,isDesktop:g,density:v})=>r.jsx(cn,{thread:gi(e,u),link:{mailboxId:n,threadId:e.threadId},inListbox:!0,active:t,focused:s,isTabStop:o,density:v,isDesktop:g,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:f,onLongPress:m}}),xi=l.memo(pi),bi=e=>{const n=e.authenticity?.dkimMismatch===!0;return{id:e.messageId,accountId:e.accountId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:nt(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:rs(e.category),suspicious:n}},vi=({thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:m,onDelete:g,onToggleRead:v,density:I})=>{const[k,E]=l.useState("none"),S=st(),x=ot(),y=l.useCallback(z=>{navigator.vibrate?.(10),z==="trailing"?g(e.messageId):v(e.messageId,e.isRead),E("none")},[g,v,e.messageId,e.isRead]),C=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),j=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),O=l.useCallback(()=>{S({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:n,threadId:e.threadId,messageId:e.messageId},search:z=>z,hash:x})},[S,x,n,e.threadId,e.messageId]),A=dn(e.messageId,d);return m||u?r.jsx(xi,{thread:e,mailboxId:n,isSelected:t,isFocused:s,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:d,isMultiSelectMode:u,onLongPress:f,isDesktop:m,density:I}):r.jsx("div",{role:"presentation",onPointerDownCapture:A.onMouseDown,onClickCapture:A.claimClick,onContextMenu:A.onContextMenu,children:r.jsx(Gn,{thread:bi(e),selectionMode:!1,checked:!1,active:t,peek:k,onPeek:E,onToggleCheck:j,onLongPress:C,onOpen:O,onAct:y})})},Si=72,yi=32,Ci=5,vs="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(vs);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},wi=({query:e})=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line bg-surface-sunken/30",children:[r.jsx(Vs,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ji=({mailboxId:e,threads:n,selectedMessageId:t,isLoading:s,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:d,onDeleteMessages:u,isDeleting:f=!1,isMoving:m=!1,onLoadMore:g,hasMore:v=!1,isLoadingMore:I=!1,accountId:k,listTitle:E,listMeta:S,listFilter:x,listScopeLabel:y,onTriageContextChange:C,commandsRef:j,hideHeader:O=!1})=>{const A=l.useRef(null),z=st(),J=ot(),M=ms(),P=$s(),{verb:re,start:D,startFromSearch:ne}=P,Ee=Bs(),ae=!!a?.trim(),te=un(),{labels:Oe}=ao(k),{pushError:le}=es(),[T,K]=l.useState(t),[we,$]=l.useState(),V=l.useCallback(h=>{$(b=>b===h?b:void 0),K(h)},[]),[pe,je]=l.useState(Ii),ke=l.useCallback(()=>{je(h=>{const b=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(vs,b)}catch{}return b})},[]),{toggleReadFor:Ae}=as({mailboxId:e}),{junkMailboxId:xe}=ls(k),Be=cs(xe,e),{selectedIds:R,selectedCount:N,hasSelection:oe,isSelected:be,toggle:U,select:ie,clearSelection:G,selectRange:he,setAnchor:ve,selectAll:it,toggleAll:rt,intersectWith:ce}=hn(),We=wn(N,M),[Q,Se]=l.useState(null),F=ae&&!!d,at=`${e}|${JSON.stringify(d??{})}`,w=fn({mailboxId:e,accountId:k,enabled:F,predicateKey:at,searchQuery:d??{}}),lt=l.useCallback((h,b,X)=>{if(X.error===void 0){if(X.cancelled){le({severity:"warning",title:gn(X.done),detail:mn(h,X.done,b)});return}le({severity:"info",title:Kt(h,X.done)})}},[le]),ct=w.phase.kind,fe=w.clear,q=l.useCallback(()=>{ct==="escalated"&&fe(),G()},[G,fe,ct]),[Ne,dt]=l.useState(null),me=l.useRef(null),_=l.useRef(!1),ze=l.useRef(null),De=!s&&n.length>0,ut=Q!==null,Y=di({count:n.length,getScrollElement:()=>A.current,estimateSize:()=>pe==="compact"?yi:Si,overscan:Ci}),Ke=t?n.findIndex(h=>h.messageId===t):-1,B=T?n.findIndex(h=>h.messageId===T):-1,de=l.useCallback(h=>{if(h<0||h>=n.length)return;const b=n[h];if(We){U(b.messageId);return}me.current=b.messageId,_.current=!1,$(b.messageId),K(b.messageId)},[n,We,U]),Ve=l.useCallback(()=>{if(n.length===0)return;const h=B<0?0:Math.min(B+1,n.length-1);de(h)},[n.length,B,de]),qe=l.useCallback(()=>{if(n.length===0)return;const h=B<=0?0:B-1;de(h)},[n.length,B,de]),ht=l.useCallback(()=>de(0),[de]),He=l.useCallback(()=>de(n.length-1),[de,n.length]),Fe=l.useCallback(()=>{T&&U(T)},[T,U]),W=l.useMemo(()=>n.map(h=>h.messageId),[n]),Me=l.useMemo(()=>{const h=[];for(const b of n)R.has(b.messageId)&&h.push({id:b.messageId,sender:b.fromName??b.fromEmail??"Unknown",email:b.fromEmail??"",subject:b.subject??"(No subject)",date:nt(b.sentDate)});return h},[n,R]),ft=l.useCallback((h,b)=>b.shiftKey?(he(W,h,T),!0):b.metaKey||b.ctrlKey?(U(h),!0):(q(),ve(h),!1),[W,T,he,U,q,ve]),_e=l.useCallback(h=>{!u||h.length===0||(ze.current=T??null,Se(h))},[u,T]),Le=l.useCallback(h=>{const b=pn(W,T,h);b!==void 0&&(he(W,b),me.current=b,_.current=!1,$(void 0),K(b))},[W,T,he]),Ue=l.useCallback(()=>Le(-1),[Le]),Qe=l.useCallback(()=>Le(1),[Le]),ye=l.useCallback(()=>{W.length>0&&it(W)},[W,it]),Te=l.useCallback(h=>{const b=fi({verb:h,confirmingDelete:Q!==null,hasSelection:oe,junkMailboxId:xe,currentMailboxId:e,deletableMessageId:u?T:void 0});return b.kind==="openWizard"?(D(h),!0):b.kind==="confirmDelete"?(_e([b.messageId]),!0):b.kind==="unavailable"?(le({severity:"warning",title:b.reason}),!0):b.kind==="withheld"},[Q,u,oe,xe,e,D,T,_e,le]),se=l.useCallback((h,b)=>{const X=n.find(Z=>Z.messageId===h)?.threadId;X&&z({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,threadId:X,messageId:h},search:Z=>Z,hash:J,replace:b?.replace})},[z,J,e,n]),ge=l.useCallback(()=>{T&&se(T)},[T,se]),St=l.useCallback(h=>se(h,{replace:!0}),[se]);xn({keyboardFocusedMessageId:we,openMessageId:t,enabled:M&&N===0,open:St});const Je=w.phase.kind==="escalated"?{scope:Wt(d??{}),total:w.phase.total,searchQuery:d??{},run:h=>w.runAction(h),stop:w.stop}:void 0,yt=l.useCallback(()=>{if(!Q)return;const h=Q;if(h.length===0){Se(null);return}const b=new Set(h),X=n.findIndex(ee=>b.has(ee.messageId));let Z;for(let ee=X+1;ee<n.length;ee++)if(!b.has(n[ee].messageId)){Z=n[ee].messageId;break}if(Z===void 0){for(let ee=X-1;ee>=0;ee--)if(!b.has(n[ee].messageId)){Z=n[ee].messageId;break}}u?.(h),q(),ze.current=null,Se(null),Z!==void 0&&(me.current=Z,_.current=!1,V(Z),M&&se(Z,{replace:!0})),M||dt(Kt("delete",h.length))},[Q,n,u,q,se,M,V]),Ce=l.useCallback(()=>{const h=ze.current;ze.current=null,Se(null),h!==null&&(me.current=h,_.current=!1,V(h))},[V]),Ge=l.useMemo(()=>{if(N===0)return;const h=new Set;for(const b of n)R.has(b.messageId)&&h.add(b.accountConfigId);if(h.size>1)return"Move only works within one account — clear selection or pick messages from a single account"},[N,R,n]),Ct=l.useCallback(()=>{if(Je){ne();return}D("organize")},[Je,ne,D]),It=l.useCallback(h=>{u?.([h])},[u]),wt=l.useCallback((h,b)=>{Ae([h],!b)},[Ae]),jt=l.useCallback(h=>{M||ie(h)},[M,ie]),kt=l.useCallback(()=>{if(w.isRunning||w.phase.kind==="counting"){w.stop();return}q()},[w,q]),Mt=l.useCallback(()=>{w.clear()},[w]);l.useEffect(()=>{if(_.current||!M&&t)return;const h=B>=0?B:Ke;h>=0&&Y.scrollToIndex(h,{align:"auto"})},[B,Ke,Y,M,t]),l.useEffect(()=>{t&&(_.current=!1,V(t))},[t,V]),l.useEffect(()=>{T&&(n.some(h=>h.messageId===T)||V(n[0]?.messageId))},[n,T,V]),l.useEffect(()=>{C?.({focusedMessageId:T,selectedIds:Array.from(R),hasList:De,blocksKeyboard:ut||P.isOpen})},[T,R,De,ut,P.isOpen,C]);const Ie=l.useRef(C);Ie.current=C,l.useEffect(()=>()=>Ie.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{w.phase.kind!=="idle"||w.isRunning||ce(n.map(h=>h.messageId))},[n,ce,w.phase,w.isRunning]);const Ye=l.useRef(e);l.useEffect(()=>{Ye.current!==e&&(Ye.current=e,q())},[e,q]),bn({shouldBlockFn:({action:h})=>mi(h,oe,Ee)?(q(),!0):!1,enableBeforeUnload:!1,disabled:!oe||Ee!==void 0}),l.useEffect(()=>{const h=A.current;if(!h||!v||!g)return;const b=()=>{if(I)return;const{scrollTop:X,scrollHeight:Z,clientHeight:ee}=h;X+ee>=Z-200&&g()};return h.addEventListener("scroll",b,{passive:!0}),b(),()=>h.removeEventListener("scroll",b)},[v,I,g]),l.useEffect(()=>{const h=me.current;if(!h)return;const b=A.current?.querySelector(`[data-message-id="${h}"]`);b&&(me.current=null,b.focus({preventScroll:!0}))}),l.useEffect(()=>{if(j){if(!De){j.current=null;return}return j.current={focusNext:Ve,focusPrevious:qe,focusFirst:ht,focusLast:He,openFocused:ge,toggleSelect:Fe,extendSelectDown:Qe,extendSelectUp:Ue,selectAll:ye,clearSelection:()=>oe?(q(),!0):!1,requestVerb:Te,toggleDensity:ke},()=>{j.current=null}}},[j,De,Ve,qe,ht,He,ge,Fe,Qe,Ue,ye,oe,q,Te,ke]);const Xe=s?"loading":o?"error":n.length===0?"empty":"ready",Tt=o?to(i):void 0,Rt=l.useCallback(()=>{const h=Ws(Ks());window.open(h,"_blank","noopener,noreferrer")},[]),Et=[{id:"inbox",threads:[]}],Ze=W.length>0&&W.every(h=>R.has(h)),mt=F&&v&&Ze&&!f&&!m&&w.phase.kind==="idle"&&!w.isRunning,Ot=f||m||w.isRunning,p=w.phase.kind==="escalated"?w.phase.total:N,L=w.runningAction?vn(w.runningAction.kind,w.progress?.done??0,w.progress?.total??p):w.phase.kind==="counting"?"Counting matches…":w.phase.kind==="escalated"?hi(d??{},w.phase.total):void 0,H=w.phase.kind!=="escalated"&&W.length>0?{checked:Ze,indeterminate:N>0&&!Ze,onChange:()=>rt(W)}:void 0,Is=w.runningAction?{value:w.progress?.done??0,max:w.progress?.total??p,tone:Sn(w.runningAction.kind)}:void 0,ws=(w.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:w.stop}}:w.phase.kind==="escalated"&&!w.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:Mt}}:mt?{tone:"info",text:"",action:{label:ui(d??{}),onClick:w.escalate}}:void 0)??(Ge?{tone:"warning",text:Ge}:void 0),js=r.jsx(yn,{title:te.title||E,navSlot:te.navSlot,titleMeta:te.titleMeta,searchSlot:te.searchSlot,searchField:te.searchField,idleSlot:te.makeFilterSlot,count:p,onCancel:kt,onDelete:()=>D("delete"),onMove:()=>D("move"),onOrganize:Ct,onJunk:Be?()=>D("junk"):void 0,onMarkRead:()=>D("markRead"),overflowSlot:k&&e&&N>0&&Oe.length>0?r.jsx(lo,{accountId:k,mailboxId:e,messageIds:Array.from(R)}):void 0,isBusy:Ot,isCounting:w.phase.kind==="counting",selectAll:H,statusLabel:L,progress:Is,notice:ws}),ks=Cn(W,T),Ms=l.useCallback(h=>{_.current=!0,V(h)},[V]),Ts=r.jsxs(r.Fragment,{children:[ae&&a&&r.jsx(wi,{query:a}),r.jsxs("div",{ref:A,role:"listbox","aria-multiselectable":!0,"aria-label":E,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${Y.getTotalSize()}px`},children:Y.getVirtualItems().map(h=>{const b=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:Y.measureElement,className:Re("absolute left-0 top-0 w-full border-b border-line",w.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(vi,{thread:b,mailboxId:e,isSelected:t===b.messageId,isFocused:T===b.messageId,isTabStop:ks===b.messageId,onFocusRow:Ms,isChecked:be(b.messageId),onToggleCheck:U,onRowSelect:ft,isMultiSelectMode:We,onLongPress:jt,isDesktop:M,onDelete:It,onToggleRead:wt,density:pe})},h.key)})}),I&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[Ne&&!M&&r.jsx(Dt,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>dt(null),children:Ne}),r.jsx(Xn,{listTitle:E,listMeta:S,sections:Et,flatList:!0,listState:te.searchResults?"ready":Xe,searchQuery:ae?a:void 0,listFilter:x,listScopeLabel:y,errorMessage:Tt,onRetry:c,onReportError:Rt,density:pe,selectedThreadId:t,onSelectThread:h=>se(h),isDesktop:M,hideHeader:O,selectionBar:js,listBody:te.searchResults??(Xe==="ready"?Ts:void 0)}),r.jsx(gs,{isOpen:Q!==null,title:io(Q?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:yt,onCancel:Ce}),r.jsx(In,{verb:re,accountId:k,mailboxId:e,selection:Me,selectionRestriction:Ge?"spansAccounts":void 0,escalated:Je,escalatedProgress:w.progress,onFinished:q,onRunEnded:lt})]})},ki=e=>Hs({path:{accountId:e}}),Mi=e=>{const n=Ft(),t=Lt(),s=_t({...qs(),onSuccess:()=>{t.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:ki(e)})}});return{trigger:()=>{s.mutate({path:{accountId:e}})},triggerAsync:()=>s.mutateAsync({path:{accountId:e}}),isPending:s.isPending,error:s.error,reset:s.reset}},Ti=({accountId:e,children:n})=>{const{triggerAsync:t,isPending:s}=Mi(e);return r.jsx(Io,{onRefresh:t,isRefreshing:s,children:n})};function Ri({accountId:e,currentMailboxId:n,candidates:t,onMove:s,children:o}){const[i,c]=l.useState(!1),a=Lt(),d=mo(),{inboxMailboxId:u}=jn(e),f=kn(e),{data:m}=tt({...Us({path:{accountId:e}}),staleTime:1/0}),g=l.useMemo(()=>go({mailboxes:m?.items??[],folderAppointments:f,currentMailboxId:n,translator:d}),[m?.items,f,n,d]),v=l.useMemo(()=>u||(g.find(x=>x.label.toLowerCase()==="inbox")?.id??g.find(x=>!x.isCurrent)?.id??""),[u,g]),I=l.useRef(!1);l.useEffect(()=>{I.current||(I.current=!0,Mn(a,t.length))},[a,t.length]);const k=l.useCallback(()=>{Tn(a,t.length),c(!0)},[a,t.length]),E=l.useCallback((S,x)=>{Rn(a,{selected:S.length,total:t.length,toInbox:x===u}),s(S,x)},[a,t.length,u,s]);return r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"shrink-0 px-row-inset pt-2",children:r.jsx(jo,{count:t.length,onReview:k})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(Fo,{open:i,candidates:t,defaultDestinationId:v,availableFolders:g,delimiter:po(m?.items??[]),onConfirmMove:E,onCancel:()=>c(!1)})]})}const Ei="We can verify this sender";function Oi(e){const{data:n}=tt({...Qs({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(s=>({id:s.messageId,senderName:s.fromName||s.fromEmail||"Unknown sender",senderAddress:s.fromEmail??"",subject:s.subject||"(no subject)",snippet:s.snippet??"",trustReason:Ei,trustSubReason:En(s.senderTrust),senderTrust:s.senderTrust}))}}const Ai=e=>{const n=new Set,t=[];for(const s of e)n.has(s.threadMessageId)||(n.add(s.threadMessageId),t.push(s));return t},Ni={unread:"unread",flagged:"starred",attachment:"attachments"},zi=new Set(Object.values(yo)),Ss=e=>zi.has(e),Di=e=>Ss(e.category)||e.attributes.size>0,Fi=e=>{const n={};Ss(e.category)&&(n.category=[e.category]);for(const t of e.attributes){const s=Ni[t];s&&(n[s]=!0)}return n},_i=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Li=["category","unread","starred","attachments"],Jt=e=>JSON.stringify(Li.map(n=>e?.[n]??null)),Pi=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const t=n.query;if(!(typeof t!="object"||t===null))return t},$i=(e,n)=>{const t=Pi(e);return t?Jt(t)===Jt(n):!1},gt=e=>e[0],Bi=e=>{const n=gt(e.filter(a=>a.type==="from").map(a=>a.value)),t=gt(e.filter(a=>a.type==="subject").map(a=>a.value)),s=gt(e.filter(a=>a.type==="category").map(a=>a.category)),o=gt(e.filter(a=>a.type==="isUnread"||a.type==="isRead").map(a=>a.type==="isUnread")),i=e.some(a=>a.type==="isStarred")?!0:void 0,c=e.some(a=>a.type==="hasAttachment")?!0:void 0;return{...n!==void 0?{from:n}:{},...t!==void 0?{subject:t}:{},...s!==void 0?{category:[s]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Wi=(e,n)=>{switch(n.type){case"from":return e.from?.toLowerCase()===n.value.toLowerCase();case"subject":return e.subject?.toLowerCase()===n.value.toLowerCase();case"category":return e.category?.length===1&&e.category[0]===n.category;case"isUnread":return e.unread===!0;case"isRead":return e.unread===!1;case"isStarred":return e.starred===!0;case"hasAttachment":return e.attachments===!0;case"before":case"after":case"in":case"account":return!1}};function Ki(e,n={}){const t=Bi(e),s={...t,...n};return{params:t,residual:e.filter(o=>!Wi(s,o))}}function Vi(e,n,t){if(n.length===0)return e;const s=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??t},s)})}const qi=50,Hi=new Map(hs().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),ys=l.createContext(null);function vt(){const e=l.useContext(ys);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Ui({mailboxId:e,thread:n,children:t}){const s=st(),o=ot(),i=n?.threadId,c=n?.messageId,a=Lt(),{accounts:d,searchQuery:u,intelligenceOpen:f,onToggleIntelligence:m}=ts(),g=tn(),v=Co(u),I=v.length>0,{freeText:k,tokens:E}=sn(v,g),[S,x]=l.useState("all"),[y,C]=l.useState(new Set),j=l.useMemo(()=>({category:S,attributes:y}),[S,y]),O=l.useMemo(()=>Fi(j),[j]),A=I||Di(j),{params:z,residual:J}=Ki(E,O),M={order:"desc",limit:qi,...k?{query:k}:{},...z,...O},P={category:M.category,unread:M.unread,starred:M.starred,attachments:M.attachments},re=A?Js({path:{mailboxId:e},query:M}):Gs({path:{mailboxId:e},query:{order:"desc"}}),{data:D,isLoading:ne,isError:Ee,error:ae,refetch:te,fetchNextPage:Oe,hasNextPage:le,isFetchingNextPage:T}=Zn({queryKey:re,queryFn:async({pageParam:p})=>{if(A){const{data:H}=await Zs({path:{mailboxId:e},query:{...M,continuationToken:p},throwOnError:!0});return H}const{data:L}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:p},throwOnError:!0});return L},initialPageParam:void 0,getNextPageParam:p=>p.continuationToken,placeholderData:(p,L)=>$i(L?.queryKey,P)?p:void 0}),{accountId:K}=Nn(e),we=xo({accounts:d}),$=Vi(zn(Ai(D?.pages.flatMap(p=>p.items??[])??[])),J,K),V=l.useCallback(p=>{x(p)},[]),pe=l.useCallback(p=>{C(L=>{const H=new Set(L);return H.has(p)?H.delete(p):H.add(p),H})},[]),je=l.useCallback(()=>{x("all"),C(new Set)},[]),ke=Hi.get(S),Ae=ke?{label:ke,reach:J.length>0?"loaded-pages":_i(M),onClear:je}:void 0,xe=i?$.find(p=>p.messageId===c)??$.find(p=>p.threadId===i):void 0,Be=Dn(i,c),R=xe??Be,N=c??R?.messageId,oe=l.useMemo(()=>{if(i)return{threadId:i,mailboxId:R?.mailboxId??e,subject:R?.subject,messageId:N,authenticity:R?.authenticity}},[i,R,N,e]),be=l.useCallback(()=>{s({to:"/mail/$mailboxId",params:{mailboxId:e},search:p=>p,hash:o})},[e,s,o]),U=l.useCallback(p=>{s({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:e,...p},search:L=>L,hash:o})},[e,s,o]),ie=l.useCallback(p=>{N&&p.includes(N)&&be()},[N,be]),{deleteMessages:G,isPending:he}=Vt({mailboxId:e,onAfterOptimisticRemove:ie}),{moveMessages:ve,isPending:it}=qt({mailboxId:e,accountId:K,onAfterOptimisticRemove:ie}),rt=Fn(),{listCommandsRef:ce,onTriageContextChange:We,focusedMessageId:Q,selectedIds:Se}=rt,F=$.find(p=>p.messageId===Q)??R,at=l.useRef(null);l.useEffect(()=>{const p=R?.messageId??null;p&&at.current!==p&&R?.authenticity?.dkimMismatch&&(at.current=p,f||m())},[R?.messageId,R?.authenticity?.dkimMismatch,f,m]);const w=bo({accounts:d})??0,lt=Ft(),{pushError:ct}=es(),fe=_n({thread:R,mailboxId:e,accountId:K,onAfterOptimisticRemove:ie}),{draftsMailboxId:q}=Ln(K),Ne=q!==void 0&&q===e,{archiveMailboxId:dt}=Pn(K),me=$n(),{requestCompose:_}=fe,ze=l.useCallback(()=>{_("reply")},[_]),De=l.useCallback(()=>{_("reply_all")},[_]),ut=l.useCallback(()=>{_("forward")},[_]),{state:Y,openCompose:Ke,closeCompose:B}=xt(),de=l.useCallback(()=>{Ke({mode:"new"})},[Ke]),Ve=l.useRef(N);l.useEffect(()=>{const p=Ve.current;Ve.current=N,!(!N||N===p)&&B()},[N,B]);const qe=_t({...Zt(),onError:p=>{ct(Ys("Couldn't discard draft","The draft wasn't deleted.",p))}}),ht=l.useCallback(()=>{const p=Y.outboxMessageId;p&&(qe.mutate({path:{outboxMessageId:p}}),lt.invalidateQueries({queryKey:Xt()}),B())},[Y.outboxMessageId,qe,lt,B]),He=l.useCallback(p=>p?me(p):[],[me]),{toggleStar:Fe}=Bn({threadId:F?.threadId??"",mailboxId:e}),{toggleReadFor:W}=as({mailboxId:e,accountId:K}),{junkMailboxId:Me}=ls(K),ft=Me!=null&&Me===e,_e=cs(Me,e),{candidates:Le}=Oi(ft?Me:void 0),{moveMessages:Ue}=qt({mailboxId:e,threadId:F?.threadId,accountId:K,onAfterOptimisticRemove:ie}),{deleteMessages:Qe}=Vt({mailboxId:e,threadId:F?.threadId,onAfterOptimisticRemove:ie}),{addressId:ye,address:Te}=Wn(F),{updateFlags:se}=Kn({addressId:ye,senderEmail:F?.fromEmail??void 0}),ge=l.useCallback(()=>{if(N||!Q)return!1;const p=$.find(L=>L.messageId===Q);return p?(U({threadId:p.threadId,messageId:Q}),!0):!1},[N,Q,$,U]),St=l.useCallback(()=>{ge()||R&&_("reply")},[ge,R,_]),Je=l.useCallback(()=>{ge()||R&&_("reply_all")},[ge,R,_]),yt=l.useCallback(()=>{ge()||R&&_("forward")},[ge,R,_]),Ce=l.useCallback(()=>He(F),[He,F]),Ge=l.useCallback(()=>{if(ce.current?.requestVerb("delete"))return;const p=Ce();p.length>0&&Qe(p)},[ce,Ce,Qe]),Ct=l.useCallback(()=>{if(ce.current?.requestVerb("junk")||!_e)return;const p=Ce();p.length!==0&&(Vn(a,{count:p.length,senderTrust:F?.senderTrust??"unknown",wasRescuable:F?qn(F):!1}),Ue(p,_e))},[ce,_e,Ce,Ue,a,F]),It=l.useCallback(()=>{if(Se.length>0){const p=!(F?.hasStars??!1),L=new Set(Se);for(const H of $)L.has(H.messageId)&&H.hasStars!==p&&Fe(H.messageId,H.hasStars);return}F&&Fe(F.messageId,F.hasStars)},[Se,$,F,Fe]),wt=l.useCallback(()=>{if(ce.current?.requestVerb("markRead"))return;const p=Ce();if(p.length===0)return;const L=!(F?.isRead??!1);W(p,L)},[ce,Ce,F,W]),jt=l.useCallback(()=>{if(!ye)return;const p=Te?.flags?.muted?.value!==!0;se({muted:{value:p}})},[ye,Te,se]),kt=l.useCallback(()=>{if(!ye)return;const p=Te?.flags?.vip?.value!==!0;se({vip:{value:p}})},[ye,Te,se]),Mt=l.useCallback(()=>{f||m()},[f,m]),Ie=l.useCallback(p=>{s({to:p})},[s]),Ye=Ne?"drafts":dt===e?"archive":Me===e?"junk":"inbox",Xe=l.useRef("");l.useEffect(()=>{const p=Xe.current;Xe.current=v,v.length>0&&p.length===0&&a.recordEvent("search.submitted",{mailboxType:Ye})},[v,Ye,a]);const Tt=Ne&&Y.isOpen&&!!Y.outboxMessageId&&!R,{goBack:Rt,nextMessageId:Et,previousMessageId:Ze}=Hn({context:rt,orderedIds:$.map(p=>p.messageId),selectedMessageId:N,enabled:!Y.isOpen,onClose:be,handlers:{reply:St,replyAll:Je,forward:yt,delete:Ge,toggleStar:It,toggleRead:wt,muteSender:jt,blockSender:Mt,vipSender:kt,markJunk:Ct,toggleIntelligence:R?m:void 0,compose:de,goBrief:()=>Ie("/mail/brief"),goInbox:()=>Ie("/mail/brief"),goSent:()=>Ie("/mail/brief"),goFlagged:()=>Ie("/mail/flagged"),goSettings:()=>Ie("/settings")}});vo({enabled:Y.isOpen,bindings:[{key:"Escape",handler:B,preventDefault:!0}]});const mt=p=>{if(!p)return;const L=$.find(H=>H.messageId===p);return L?{threadId:L.threadId,messageId:p}:void 0},Ot={mailboxId:e,selectedMessageId:N,selectedThread:R,conversation:oe,onOpenThread:U,threads:$,isLoading:ne,isError:Ee,error:ae,mailboxAccountId:K,mailboxName:we,unreadCount:w,isDraftsMailbox:Ne,isSpamFolder:ft,rescueCandidates:Le,filterCategory:S,filterAttributes:y,onSelectFilterCategory:V,onToggleFilterAttribute:pe,onClearFilters:je,listFilter:Ae,intelligenceOpen:f,onToggleIntelligence:m,handleDeselectIfRemoved:ie,searchPredicate:I&&J.length===0?M:void 0,onDeleteMessages:G,onMoveMessages:ve,isDeleting:he,isMoving:it,onLoadMore:Oe,hasMore:le,isLoadingMore:T,onTriageContextChange:We,listCommandsRef:ce,onRetry:()=>te(),toolbarComposeRequest:fe.composeRequest,onToolbarReply:ze,onToolbarReplyAll:De,onToolbarForward:ut,onClearComposeRequest:fe.clearComposeRequest,onToolbarDelete:fe.deleteThread,onToolbarStar:fe.toggleStar,onToolbarDiscardDraft:ht,onToolbarMove:fe.moveThread,composeState:Y,closeCompose:B,hasRemitDraftOpen:Tt,onBack:Rt,nextThread:mt(Et),previousThread:mt(Ze)};return r.jsx(ys.Provider,{value:Ot,children:t})}function Cs(){const{mailboxId:e,selectedMessageId:n,threads:t,isLoading:s,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:m,isLoadingMore:g,mailboxAccountId:v,mailboxName:I,unreadCount:k,isDraftsMailbox:E,isSpamFolder:S,rescueCandidates:x,onTriageContextChange:y,listCommandsRef:C,onRetry:j,filterCategory:O,filterAttributes:A,onSelectFilterCategory:z,onToggleFilterAttribute:J,onClearFilters:M,listFilter:P,searchPredicate:re}=vt(),{searchQuery:D,searchInput:ne,accounts:Ee,resultFolderIndex:ae}=ts(),te=So(),Oe=st(),le=ot(),T=I??"Inbox",K=l.useMemo(()=>hs(),[]),we=l.useMemo(()=>v?[v]:[],[v]),{hasNewMail:$}=on(),{state:V,errorMessage:pe,refresh:je}=rn(we,{onSettled:j}),ke=l.useMemo(()=>r.jsx(an,{state:V,onRefresh:je,label:`Refresh ${T}`,errorMessage:pe,hasUpdate:$(we)}),[V,je,T,pe,$,we]),Ae=l.useMemo(()=>t.map(G=>Qn(G,ae)),[t,ae]),{hits:xe,isLoading:Be}=co({mailboxId:e,filterCategory:O}),R=l.useMemo(()=>Jn(xe,t.map(G=>G.threadId),ae),[xe,t,ae]),N=l.useCallback(G=>{const he=G.threadId??t.find(ve=>ve.messageId===G.id)?.threadId;he&&Oe({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:G.mailboxId??e,threadId:he,messageId:G.id},search:ve=>({...ve,q:ne||void 0}),hash:le})},[e,Oe,le,ne,t]);if(E&&v)return r.jsx(Uo,{mailboxId:e,accountId:v,selectedMessageId:n,imapThreads:t,title:I??"Drafts",unreadCount:k??void 0});const oe=r.jsx(ji,{mailboxId:e,threads:t,selectedMessageId:n,isLoading:s,isError:o,error:i,onRetry:j,searchQuery:D,searchPredicate:re,onDeleteMessages:c,isDeleting:d,isMoving:u,onLoadMore:f,hasMore:m,isLoadingMore:g,accountId:v,listTitle:T,listFilter:P,listScopeLabel:T,hideHeader:!0,onTriageContextChange:y,commandsRef:C}),be=Ee[0]?.accountId,U=te==="phone"&&be?r.jsx(Ti,{accountId:be,children:oe}):oe,ie=S&&x.length>0&&v?r.jsx(Ri,{accountId:v,currentMailboxId:e,candidates:x,onMove:a,children:U}):U;return r.jsx(eo,{title:T,unreadCount:k,preset:K,selectedCategory:O,activeFilters:A,onSelectCategory:z,onToggleFilter:J,onClearFilters:M,searchResults:Ae,searchLoading:s,relatedResults:R,relatedLoading:Be,onSelectSearchResult:N,searchResultsInBody:!0,refreshControl:ke,children:ie})}function Qi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:d,onToolbarReplyAll:u,onToolbarForward:f,onClearComposeRequest:m,onToolbarDelete:g,onToolbarStar:v,onToolbarDiscardDraft:I,onToolbarMove:k,composeState:E,handleDeselectIfRemoved:S}=vt(),x=Xs()?.showIntelligencePane??!1,y=!!s,[C,j]=l.useState(null),O=s?.threadId??null,A=!x&&O!==null&&C===O,z=l.useCallback(()=>j(null),[]),J=l.useCallback(()=>j(O),[O]),M=x?c:J,P=l.useCallback(()=>{if(x){c();return}j(A?null:O)},[x,c,A,O]),re=y&&(x?i:A),D=E.isOpen&&!s?r.jsx(xs,{}):s?r.jsx(ds,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onOpenIntelligence:s.authenticity?.dkimMismatch?M:void 0,composeRequest:a,onComposeClose:m}):r.jsx(nn,{});return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:y,intelligenceOpen:re,canToggleIntelligence:y,onToggleIntelligence:P,onReply:y?d:void 0,onReplyAll:y?u:void 0,onForward:y?f:void 0,canDelete:y||o,onDelete:y?g:o?I:void 0,onToggleStar:y?v:void 0,isStarred:t?.hasStars,moveContext:y&&n?{accountId:n,currentMailboxId:e,onMove:k}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:D})]}),r.jsx(us,{isOpen:A,onClose:z,ariaLabel:"Message details",side:"right",children:r.jsx(Pt,{onClose:z,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:S})})]})}function Ji(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,onToggleIntelligence:s,handleDeselectIfRemoved:o}=vt();return r.jsx(Pt,{onClose:s,thread:t,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function Gi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:t,conversation:s,onOpenThread:o,intelligenceOpen:i,onToggleIntelligence:c,onBack:a,nextThread:d,previousThread:u,composeState:f,handleDeselectIfRemoved:m}=vt();return s?r.jsxs(r.Fragment,{children:[r.jsx(ds,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:c,onSwipeNext:d?()=>o(d):void 0,onSwipePrevious:u?()=>o(u):void 0,mobileIntelligenceOpen:i}),r.jsx(us,{isOpen:i,onClose:c,ariaLabel:"Message details",side:"right",children:r.jsx(Pt,{onClose:c,thread:t,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:m})})]}):f.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(xs,{})}):r.jsx(Cs,{})}const yr=Object.assign(Ui,{List:Cs,Reading:Qi,Intelligence:Ji,Phone:Gi});export{yr as M};
@@ -1 +1 @@
1
- import{i as n,j as a,B as o}from"./index-Bf6zeV_t.js";import{M as e}from"./menu-DNUIh6FR.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
1
+ import{i as n,j as a,B as o}from"./index-Bqn7f16e.js";import{M as e}from"./menu-vEH9STs_.js";function i(){const s=n();return!s||s.showNavPane?null:a.jsx(o,{variant:"ghost",size:"sm",icon:a.jsx(e,{className:"size-4"}),onClick:s.openNav,"aria-label":"Open folders",className:"-ml-1 shrink-0"})}export{i as N};
@@ -1 +1 @@
1
- import{c as re,j as e,b as z,aj as V,an as oe,r as i,aA as he,aD as I,ak as F,s as xe,ae as X,a0 as fe,ai as ye,x as Q,aE as Y,Y as ne,B as C,am as $,ah as ge,al as ve,az as q,aw as be,I as je}from"./index-Bf6zeV_t.js";import{K as Se}from"./kbd-C4MYDwt7.js";import{c as we,M as ke}from"./account-form-helpers-BZTGbgn5.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function De({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function $e({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=Q(ne()),w=X({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx($,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx($,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=X({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Qe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=X({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),D=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:D?.smtpHost||void 0,smtpPort:D?.smtpPort||void 0,smtpTls:D?.smtpTls??!1,smtpStartTls:D?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=Q({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx($,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx($,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx(De,{onStart:h});case"connector":return e.jsx($e,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Qe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
1
+ import{c as re,j as e,b as z,aj as V,an as oe,r as i,aA as he,aD as I,ak as F,s as xe,ae as X,a0 as fe,ai as ye,x as Q,aE as Y,Y as ne,B as C,am as $,ah as ge,al as ve,az as q,aw as be,I as je}from"./index-Bqn7f16e.js";import{K as Se}from"./kbd-BG1I0chs.js";import{c as we,M as ke}from"./account-form-helpers-DAuyJa3o.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function De({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function $e({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=Q(ne()),w=X({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx($,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx($,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=X({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Qe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=X({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),D=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:D?.smtpHost||void 0,smtpPort:D?.smtpPort||void 0,smtpTls:D?.smtpTls??!1,smtpStartTls:D?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=Q({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx($,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx($,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx(De,{onStart:h});case"connector":return e.jsx($e,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Qe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
@@ -0,0 +1 @@
1
+ import{aa as O,e as C,am as w,j as s,b,bQ as U,T as H,f as k,p as K,x as W,y as G,o as J,r as m,u as S,bI as R,bT as V,s as X,k as Y,ac as Z,bf as ee,ae as N,af as v,ce as se,bg as te}from"./index-Bqn7f16e.js";import{u as ne,p as ae,R as p,g as oe}from"./useSearchTokenContext-ki2AZ7p9.js";import{C as I}from"./circle-check-big-Cj9roMB7.js";import{C as T}from"./clock-C4V2tcYN.js";import{R as re}from"./row-actions-t73y2fxd.js";import{R as ie}from"./rotate-ccw-xiByt5L1.js";import{N as A}from"./NavMenuButton-DCYDMDv1.js";import{a as g,t as le}from"./format-De9HZKjg.js";import{i as ce,a as E}from"./outbox-status-CPfNHfUQ.js";import{n as de}from"./search-query-Cr_ZXBCp.js";import{c as ue}from"./nav-link-COOZsOLo.js";const xe={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:w,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:I,label:"Sent",className:"text-positive"},failed:{icon:C,label:"Failed",className:"text-danger"},blocked:{icon:O,label:"Blocked",className:"text-warning"}};function y({status:e,iconOnly:n,className:a}){const t=xe[e],o=t.icon;return s.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[s.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const me=(e,n)=>n?"bg-accent-2-soft":e==="failed"?"bg-danger-soft":e==="blocked"?"bg-warning/10":"";function fe({recipients:e,subject:n,time:a,status:t,error:o,selected:l,onSelect:c,onRetry:r,retrying:d,onEdit:i,onDelete:f,deleting:u}){const h=t==="failed"||t==="blocked";return s.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",me(t,l)),children:[s.jsxs("button",{type:"button",...U,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(y,{status:t,iconOnly:!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium",children:e}),s.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),s.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),s.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[s.jsx(y,{status:t}),o&&s.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),h&&s.jsx("div",{className:"shrink-0",children:s.jsx(re,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:s.jsx(ie,{className:"size-3.5"}),busy:d,onClick:r}]:[],{label:"Edit as draft",iconOnly:!0,icon:s.jsx(k,{className:"size-3.5"}),onClick:i}],destructive:{label:"Delete message",iconOnly:!0,icon:s.jsx(H,{className:"size-3.5"}),busy:u,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:f}})})]})}function he(e,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[e.subject,e.fromAddress,e.fromName,...e.toAddresses??[],...e.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function be(e){return e.tokens.length>0&&e.freeText.trim().length===0}const L={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:w,label:"Sending…",className:"text-accent-2"},sent:{icon:I,label:"Sent",className:"text-positive"},failed:{icon:C,label:"Failed",className:"text-danger"},blocked:{icon:O,label:"Blocked",className:"text-warning"}},ge=e=>le(e).toDateString()===new Date().toDateString()?g(e,{hour:"numeric",minute:"2-digit"}):g(e,{month:"short",day:"numeric"}),M=e=>g(e,{dateStyle:"medium",timeStyle:"short"}),pe=e=>{const n=e.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},Q=(e,n)=>n?"The outbox cannot filter on those terms":e?"No matching outbox messages":"No outbox messages",D=m.createContext(null);function j(){const e=m.useContext(D);if(!e)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return e}function je({outboxMessageId:e,children:n}){const a=K(),t=ue(),{data:o,isLoading:l}=W(G()),{searchQuery:c}=J(),r=ne(),d=de(c),i=ae(d,r),f=d.length>0,u=be(i),h=m.useMemo(()=>u?[]:(o?.items??[]).filter(x=>ce(x.status)).filter(x=>he(x,i.freeText)),[o,i.freeText,u]),z=m.useMemo(()=>h.find(x=>x.outboxMessageId===e),[h,e]),F=m.useCallback(x=>{a({to:"/mail/outbox/draft/$outboxMessageId",params:{outboxMessageId:x},search:q=>q,hash:t})},[a,t]),$=m.useCallback(()=>{a({to:"/mail/outbox",search:x=>x,hash:t})},[a,t]),_={messages:h,hasQuery:f,unsupportedQuery:u,isLoading:l,selectedMessageId:e,selectedMessage:z,onOpenMessage:F,onCloseMessage:$};return s.jsx(D.Provider,{value:_,children:n})}function P({message:e,isSelected:n,onSelect:a}){const t=X(),{openCompose:o}=Y(),{pushError:l}=Z(),c=m.useCallback(()=>{t.invalidateQueries({queryKey:ee()})},[t]),r=N({...se(),onSuccess:c,onError:u=>{l(v("Couldn't resend message","The message wasn't sent.",u))}}),d=N({...te(),onSuccess:c,onError:u=>{l(v("Couldn't delete message","The message wasn't deleted.",u))}}),i=e.status;if(!L[i])return null;const f=E(e.status);return s.jsx(fe,{recipients:pe(e),subject:e.subject||"",time:ge(e.sentAt??e.updatedAt),status:i,error:f?e.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:i==="failed"?()=>r.mutate({path:{outboxMessageId:e.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o({mode:"new",outboxMessageId:e.outboxMessageId}),onDelete:()=>d.mutate({path:{outboxMessageId:e.outboxMessageId}}),deleting:d.isPending})}function B({message:e,onBack:n}){const a=e.status,t=L[a],o=t?.icon??k,l=e.sentAt?M(e.sentAt):M(e.updatedAt);return s.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[s.jsxs("div",{className:"border-b border-line p-4",children:[n&&s.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[s.jsx(V,{className:"size-4"}),s.jsx("span",{children:"Back"})]}),s.jsx("h1",{className:"text-xl font-semibold mb-3",children:e.subject||"(No subject)"}),s.jsxs("div",{className:"space-y-1 text-sm",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),s.jsx("span",{className:"text-fg",children:e.fromName?`${e.fromName} <${e.fromAddress}>`:e.fromAddress})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),s.jsx("span",{className:"text-fg",children:(e.toAddresses??[]).join(", ")})]}),e.ccAddresses&&e.ccAddresses.length>0&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),s.jsx("span",{className:"text-fg",children:e.ccAddresses.join(", ")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),s.jsx("span",{className:"text-fg",children:l})]}),t&&s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsx(o,{className:b("size-4",t.className,a==="sending"&&"animate-spin")}),s.jsx("span",{className:b("text-xs font-medium",t.className),children:t.label}),E(e.status)&&e.lastError&&s.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",e.lastError]})]})]})]}),s.jsx("div",{className:"p-4",children:s.jsx(oe,{html:e.htmlBody,text:e.textBody})})]})}function Ne(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onOpenMessage:l}=j(),c=m.useRef(null);return S({containerRef:c,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(p,{message:Q(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(A,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:e.map(r=>s.jsx(P,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>l(r.outboxMessageId)},r.outboxMessageId))})]})}function ve(){const{selectedMessage:e}=j();return s.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[s.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?s.jsx(B,{message:e}):s.jsx(p,{message:"Select a message to read",showHints:!1})})]})}function ye(){const{messages:e,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:l,onOpenMessage:c,onCloseMessage:r}=j(),d=m.useRef(null);return S({containerRef:d,itemSelector:R}),t?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:s.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):l?s.jsx(B,{message:l,onBack:r}):e.length===0?s.jsx("div",{className:"flex h-full bg-surface",children:s.jsx(p,{message:Q(n,a),showHints:!1})}):s.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[s.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[s.jsx(A,{}),s.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),s.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[e.length," ",e.length===1?"message":"messages"]})]}),s.jsx("div",{ref:d,className:"flex-1 overflow-y-auto",children:e.map(i=>s.jsx(P,{message:i,isSelected:o===i.outboxMessageId,onSelect:()=>c(i.outboxMessageId)},i.outboxMessageId))})]})}const Le=Object.assign(je,{List:Ne,Reading:ve,Phone:ye});export{Le as O};
@@ -0,0 +1 @@
1
+ import{a2 as m,j as o,$ as p}from"./index-Bqn7f16e.js";import{a}from"./search-view-B6uoqRaE.js";import{M as r}from"./MailboxPane-VSk6AMXL.js";import{u as e}from"./useSearchMirror-BaenAzTH.js";import"./nav-link-COOZsOLo.js";import{e as s}from"./search-token-index-D-3XiS1P.js";import"./useSearchTokenContext-ki2AZ7p9.js";import"./kbd-BG1I0chs.js";import"./enums-CCxx0t2v.js";import"./useRefreshControl-DMQBrv7r.js";import"./circle-check-big-Cj9roMB7.js";import"./MailListHeader-CiYx2Ro0.js";import"./account-form-helpers-DAuyJa3o.js";import"./avatar-CmvuzecB.js";import"./useSignature-6eMCtb3X.js";import"./useDebouncedValue-upT4qR9G.js";import"./useMediaQuery-C47DmZA5.js";import"./ErrorState-CJ2aoLG_.js";import"./format-De9HZKjg.js";import"./download-ChGh-J5t.js";import"./shield-check-drtxfxOL.js";import"./move-options-k5syuO4O.js";import"./useFilters-SCAefE6U.js";import"./confirm-dialog-DPkij3bo.js";import"./clock-C4V2tcYN.js";import"./menu-vEH9STs_.js";import"./MailViewChrome-4eYgZdUD.js";import"./NavMenuButton-DCYDMDv1.js";import"./useLabels-EfJaVdWJ.js";import"./useSemanticSearch-DoxylHxn.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BYOjIdVx.js";import"./circle-help-C_AXwAaV.js";import"./circle-check-DlmySaui.js";function J(){const{mailboxId:t}=m.useParams(),i=s();return e({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{J as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-Bqn7f16e.js";import{M as r}from"./MailboxPane-VSk6AMXL.js";import"./useSearchTokenContext-ki2AZ7p9.js";import"./kbd-BG1I0chs.js";import"./enums-CCxx0t2v.js";import"./nav-link-COOZsOLo.js";import"./useMediaQuery-C47DmZA5.js";import"./useRefreshControl-DMQBrv7r.js";import"./circle-check-big-Cj9roMB7.js";import"./search-token-index-D-3XiS1P.js";import"./MailListHeader-CiYx2Ro0.js";import"./account-form-helpers-DAuyJa3o.js";import"./avatar-CmvuzecB.js";import"./useSignature-6eMCtb3X.js";import"./useDebouncedValue-upT4qR9G.js";import"./ErrorState-CJ2aoLG_.js";import"./format-De9HZKjg.js";import"./download-ChGh-J5t.js";import"./shield-check-drtxfxOL.js";import"./move-options-k5syuO4O.js";import"./useFilters-SCAefE6U.js";import"./confirm-dialog-DPkij3bo.js";import"./clock-C4V2tcYN.js";import"./menu-vEH9STs_.js";import"./MailViewChrome-4eYgZdUD.js";import"./NavMenuButton-DCYDMDv1.js";import"./useLabels-EfJaVdWJ.js";import"./useSemanticSearch-DoxylHxn.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BYOjIdVx.js";import"./circle-help-C_AXwAaV.js";import"./circle-check-DlmySaui.js";function F(){return o.jsx(r.Reading,{})}export{F as component};
@@ -0,0 +1 @@
1
+ import{j as r}from"./index-Bqn7f16e.js";import{B as o}from"./BriefPane-CYfwVL8Y.js";import"./useSearchTokenContext-ki2AZ7p9.js";import"./kbd-BG1I0chs.js";import"./enums-CCxx0t2v.js";import"./nav-link-COOZsOLo.js";import"./useMediaQuery-C47DmZA5.js";import"./MailListHeader-CiYx2Ro0.js";import"./search-token-index-D-3XiS1P.js";import"./account-form-helpers-DAuyJa3o.js";import"./avatar-CmvuzecB.js";import"./useSignature-6eMCtb3X.js";import"./useDebouncedValue-upT4qR9G.js";import"./ErrorState-CJ2aoLG_.js";import"./format-De9HZKjg.js";import"./download-ChGh-J5t.js";import"./shield-check-drtxfxOL.js";import"./move-options-k5syuO4O.js";import"./useFilters-SCAefE6U.js";import"./confirm-dialog-DPkij3bo.js";import"./clock-C4V2tcYN.js";import"./menu-vEH9STs_.js";import"./useRefreshControl-DMQBrv7r.js";import"./circle-check-big-Cj9roMB7.js";import"./useLabels-EfJaVdWJ.js";import"./useSemanticSearch-DoxylHxn.js";import"./search-query-Cr_ZXBCp.js";function y(){return r.jsx(o.Reading,{})}export{y as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-Bqn7f16e.js";import{F as r}from"./FlaggedPane-Sleye2NB.js";import"./useSearchTokenContext-ki2AZ7p9.js";import"./kbd-BG1I0chs.js";import"./enums-CCxx0t2v.js";import"./nav-link-COOZsOLo.js";import"./useMediaQuery-C47DmZA5.js";import"./MailListHeader-CiYx2Ro0.js";import"./search-token-index-D-3XiS1P.js";import"./account-form-helpers-DAuyJa3o.js";import"./avatar-CmvuzecB.js";import"./useSignature-6eMCtb3X.js";import"./useDebouncedValue-upT4qR9G.js";import"./ErrorState-CJ2aoLG_.js";import"./format-De9HZKjg.js";import"./download-ChGh-J5t.js";import"./shield-check-drtxfxOL.js";import"./move-options-k5syuO4O.js";import"./useFilters-SCAefE6U.js";import"./confirm-dialog-DPkij3bo.js";import"./clock-C4V2tcYN.js";import"./menu-vEH9STs_.js";import"./MailViewChrome-4eYgZdUD.js";function k(){return o.jsx(r.Reading,{})}export{k as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-Bqn7f16e.js";import{O as t}from"./OutboxPane-D0ChJoAd.js";import"./useSearchTokenContext-ki2AZ7p9.js";import"./kbd-BG1I0chs.js";import"./enums-CCxx0t2v.js";import"./nav-link-COOZsOLo.js";import"./useMediaQuery-C47DmZA5.js";import"./circle-check-big-Cj9roMB7.js";import"./clock-C4V2tcYN.js";import"./row-actions-t73y2fxd.js";import"./rotate-ccw-xiByt5L1.js";import"./NavMenuButton-DCYDMDv1.js";import"./menu-vEH9STs_.js";import"./format-De9HZKjg.js";import"./outbox-status-CPfNHfUQ.js";import"./search-query-Cr_ZXBCp.js";function R(){return o.jsx(t.Reading,{})}export{R as component};
@@ -0,0 +1 @@
1
+ import{$ as o}from"./index-Bqn7f16e.js";const n=o;export{n as component};
@@ -0,0 +1 @@
1
+ import{$ as o}from"./index-Bqn7f16e.js";const n=o;export{n as component};
@@ -0,0 +1 @@
1
+ import{$ as o}from"./index-Bqn7f16e.js";const n=o;export{n as component};
@@ -1 +1 @@
1
- import{c as s}from"./index-Bf6zeV_t.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,l as a,d as b,a as c,c as d};
1
+ import{c as s}from"./index-Bqn7f16e.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,l as a,d as b,a as c,c as d};