@remit/web-client-dist 0.0.310 → 0.0.312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/BriefPane-CyCnqfV1.js +1 -0
- package/assets/{ErrorState-DiX_zNTK.js → ErrorState-CN4Cwb5A.js} +1 -1
- package/assets/FlaggedPane-MgcE5bKj.js +1 -0
- package/assets/MailListHeader-DX7_Cewa.js +52 -0
- package/assets/MailViewChrome-9cKXCycT.js +1 -0
- package/assets/MailboxPane-Db0hba1S.js +1 -0
- package/assets/NavMenuButton-3t-xq8p6.js +1 -0
- package/assets/{OnboardingWizard-r-N3eGPg.js → OnboardingWizard-BFkNhodP.js} +1 -1
- package/assets/OutboxPane-O18gKLgX.js +1 -0
- package/assets/_mailboxId-DbcIOfsr.js +1 -0
- package/assets/{account-form-helpers-BHUowns0.js → account-form-helpers-D3tfbITU.js} +1 -1
- package/assets/accounts-J2omBETN.js +1 -0
- package/assets/advanced-Cb-Yw4fX.js +1 -0
- package/assets/appearance-BXwFGVL1.js +1 -0
- package/assets/avatar-DTwl3jb1.js +1 -0
- package/assets/bottom-sheet-Bw79dNtH.js +1 -0
- package/assets/brief-Cj9RHZn4.js +1 -0
- package/assets/brief-CrERI6Q7.js +1 -0
- package/assets/browser-ponyfill-Dfl9dHmO.js +2 -0
- package/assets/circle-check-DizPpF0Y.js +1 -0
- package/assets/circle-check-big-ChA18R4j.js +1 -0
- package/assets/circle-help-DPkDkgdF.js +1 -0
- package/assets/clock-uuvA1em-.js +1 -0
- package/assets/confirm-dialog-BTyZAw5R.js +1 -0
- package/assets/conversation-target-B0jE-e47.js +1 -0
- package/assets/{download-Bg6cLSAV.js → download-B3EpkLuL.js} +1 -1
- package/assets/enums-CCxx0t2v.js +1 -0
- package/assets/filters-Dk1yDjyQ.js +1 -0
- package/assets/{flagged-CuV2oZw_.js → flagged-CHfuc_hl.js} +1 -1
- package/assets/flagged-CZrDrTDc.js +1 -0
- package/assets/folders-B8orXsv8.js +1 -0
- package/assets/{format-CKZmh-Ru.js → format-De9HZKjg.js} +1 -1
- package/assets/index-BHkaa_C4.js +1 -0
- package/assets/index-CdMOAANs.js +1 -0
- package/assets/index-DDXDeP1_.js +1 -0
- package/assets/index-DjZFLwif.js +294 -0
- package/assets/index-O_DYWmDx.js +1 -0
- package/assets/index-lDYTJ6Ao.js +1 -0
- package/assets/intelligence-pref-C6lFpj6U.js +1 -0
- package/assets/{kbd-C00o9L4B.js → kbd-C0TyJDqO.js} +1 -1
- package/assets/labels-BzM1g0fg.js +1 -0
- package/assets/mail-oqxsK0QY.js +1 -0
- package/assets/menu-Cpsp0ZMZ.js +1 -0
- package/assets/move-options-CdaX2x7F.js +1 -0
- package/assets/onboarding-BAPCDoFw.js +1 -0
- package/assets/outbox-DQtIjp3h.js +1 -0
- package/assets/outbox-status-CPfNHfUQ.js +1 -0
- package/assets/pencil-Cm8cWZKn.js +1 -0
- package/assets/{rich-text-CoTs3nIc.js → rich-text-CGn1MSzM.js} +2 -2
- package/assets/rotate-ccw-oQ2bjkRm.js +1 -0
- package/assets/row-actions-CN3rJN24.js +1 -0
- package/assets/search-query-Cr_ZXBCp.js +1 -0
- package/assets/search-scope-CFN-gjTv.js +1 -0
- package/assets/search-token-index-CxMDhXuP.js +1 -0
- package/assets/search-view-ClRhrhjK.js +1 -0
- package/assets/senders-C-f6yU99.js +1 -0
- package/assets/settings-BbNYlJXs.js +1 -0
- package/assets/settings-screen-DBHgQU-S.js +1 -0
- package/assets/shield-check-BG5lmiwu.js +1 -0
- package/assets/{suggested-vips-BQoY6-Yl.js → suggested-vips-D0nhcuze.js} +1 -1
- package/assets/{useDebouncedValue-Ck8McJvG.js → useDebouncedValue-BFCY668u.js} +1 -1
- package/assets/useFilters-CxQU6LTN.js +1 -0
- package/assets/useLabels-DdQPlRo8.js +1 -0
- package/assets/useMediaQuery-fUhUpE77.js +1 -0
- package/assets/useRefreshControl-BsKYVbfM.js +1 -0
- package/assets/useSearchMirror-HHNbELBF.js +1 -0
- package/assets/useSearchTokenContext-D5dvdLSW.js +67 -0
- package/assets/useSignature-C6SBu3ql.js +1 -0
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/_mailboxId-DtqBFgK5.js +0 -1
- package/assets/accounts-B4-7wVt4.js +0 -1
- package/assets/advanced-Dlyjnb6l.js +0 -1
- package/assets/appearance-Drfetqy5.js +0 -1
- package/assets/avatar-Ci3CMhdo.js +0 -1
- package/assets/browser-ponyfill-BhnZT7aq.js +0 -2
- package/assets/circle-check-BM6iE_RP.js +0 -1
- package/assets/confirm-dialog-F7nDmx5t.js +0 -1
- package/assets/filters-CsWlycJW.js +0 -1
- package/assets/flagged-DtqBFgK5.js +0 -1
- package/assets/folders-Dg7RilCS.js +0 -1
- package/assets/index-BSJKHoKS.js +0 -1
- package/assets/index-DtqBFgK5.js +0 -1
- package/assets/index-dsr8I39S.js +0 -1
- package/assets/index-xOALrEh8.js +0 -294
- package/assets/labels-pEUVx_Ue.js +0 -1
- package/assets/mail-Chm12_Xz.js +0 -118
- package/assets/move-options-B2c-WWEl.js +0 -1
- package/assets/onboarding-DKy8Q5MV.js +0 -1
- package/assets/outbox-DtqBFgK5.js +0 -1
- package/assets/pencil-CZK87pI9.js +0 -1
- package/assets/senders-p6LBrcYb.js +0 -1
- package/assets/settings-C2TANSwS.js +0 -1
- package/assets/settings-screen-C7xmJsXG.js +0 -1
- package/assets/shield-check-CdES_QdC.js +0 -1
- package/assets/useFilters-DMt8Gx-P.js +0 -1
- package/assets/useLabels-oSXOt6KZ.js +0 -1
- package/assets/useSignature-BQN3IL24.js +0 -1
|
@@ -0,0 +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,bG as le,u as ue,bH as G,br as de,bI as fe,bJ as me,bK as xe,bL as ge,n as he,bs as pe,bM as be}from"./index-DjZFLwif.js";import{R as ve,k as je,l as we}from"./search-token-index-CxMDhXuP.js";import{ao as Ne,ap as ye,c as Pe,b as U,aq as Ce,v as Re,ar as ke,as as Se,at as Me,ae as Ee,ag as Ie}from"./MailListHeader-DX7_Cewa.js";import{A as ze}from"./avatar-DTwl3jb1.js";import{M as Oe}from"./account-form-helpers-D3tfbITU.js";import{M as Le}from"./menu-Cpsp0ZMZ.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(q,{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(q,{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 q({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(U,{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(U,{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:G,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(`${G}[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,bb as Ms,r as l,az as Ft,B as le,S as Ts,b as Be,aA as Gt,C as Rs,d as Es,aV as Os,k as bt,w as Ze,W as Yt,X as As,o as We,q as _t,x as Ns,ae as Lt,bc as Xt,bd as Zt,I as zs,h as Ds,T as Fs,be as _s,bf as Ls,bg as Ps,ac as es,bh as $s,bi as Bs,J as Ws,g as Ks,a0 as Pt,bj as Vs,P as qs,v as Hs,bk as Us,n as ts,bl as Qs,G as Js,V as Gs,af as Ys,i as Xs,bm as Zs,b0 as en}from"./index-DjZFLwif.js";import{u as tn,p as sn,R as nn}from"./useSearchTokenContext-D5dvdLSW.js";import{u as on,a as rn,R as an}from"./useRefreshControl-BsKYVbfM.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 un,d as dn,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 wn,v as In,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 Vt,I as Nn,J as qt,K as zn,L as Dn,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 us,Z as Hn,_ as ds,$ as Un,a0 as hs,a1 as Qn,a2 as Jn}from"./MailListHeader-DX7_Cewa.js";import{S as Gn,M as Yn,a as Xn,u as Zn,b as eo}from"./MailViewChrome-9cKXCycT.js";import{E as fs,f as to}from"./ErrorState-CN4Cwb5A.js";import{D as so,u as ms}from"./useMediaQuery-fUhUpE77.js";import{C as gs}from"./confirm-dialog-BTyZAw5R.js";import{A as $t}from"./avatar-DTwl3jb1.js";import{b as et,c as no,d as oo}from"./format-De9HZKjg.js";import{N as io}from"./NavMenuButton-3t-xq8p6.js";import{a as ro}from"./useLabels-DdQPlRo8.js";import{L as ao,b as lo,u as co}from"./conversation-target-B0jE-e47.js";import{S as vt}from"./shield-check-BG5lmiwu.js";import{B as uo}from"./bottom-sheet-Bw79dNtH.js";import{C as ho}from"./circle-help-DPkDkgdF.js";import{C as fo}from"./circle-check-DizPpF0Y.js";import{a as mo,b as go,f as po}from"./move-options-CdaX2x7F.js";import{d as ps,h as xo,j as bo,e as vo}from"./search-token-index-CxMDhXuP.js";import{M as So}from"./enums-CCxx0t2v.js";import{r as yo}from"./intelligence-pref-C6lFpj6U.js";import{n as Co}from"./search-query-Cr_ZXBCp.js";const wo=e=>{const[n,s]=l.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return l.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);s(t.matches);const o=i=>s(i.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[e]),n},Io=({children:e,onRefresh:n,isRefreshing:s})=>wo(so)?e:r.jsx(Ms,{onRefresh:n,isPullable:!s,children:e}),jo=e=>e===1?"message":"messages";function ko({count:e,onReview:n,onDismiss:s,actionLabel:t="Review & rescue"}){return r.jsx(Ft,{tone:"info",variant:"soft",onDismiss:s,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(vt,{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} ${jo(e)} here`})," ","may not be spam — they're from senders we can verify."]})]}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,className:"self-start",children:t})]})})}const Mo=(e,n)=>e==="vip"?"vip":e==="unknown"&&n==="md"?"unknown-pill":"hidden",xs=({senderTrust:e,size:n="sm",className:s})=>{const t=Mo(e,n);return t==="vip"?r.jsx(Ts,{className:Be("text-warning shrink-0",n==="sm"&&"size-3.5",n==="md"&&"size-4",s),"aria-label":"VIP sender","data-testid":"sender-trust-vip"}):t==="unknown-pill"?r.jsx("span",{className:Be("inline-flex items-center rounded border border-dashed border-fg-subtle/40 font-medium uppercase tracking-wide text-fg-muted/80 shrink-0","px-2 py-0.5 text-xs",s),title:"First message from this sender","aria-label":"First message from this sender","data-testid":"sender-trust-unknown",children:"new"}):null};function To({candidate:e,selected:n,onToggle:s,hideSender:t=!1}){const{senderName:o,senderAddress:i,subject:c,snippet:a,trustReason:u,trustSubReason:d,senderTrust:f}=e;return r.jsxs("label",{className:Be("flex w-full cursor-pointer items-start gap-3 px-3 py-2.5 text-left transition-colors",t&&"pl-11",n?"bg-positive/10":"bg-surface hover:bg-surface-sunken"),children:[r.jsx(ss,{className:"mt-0.5",checked:n,onChange:s,"aria-label":`${n?"Deselect":"Select"} ${t?c:`message from ${o}`}`}),!t&&r.jsx($t,{name:o,email:i,size:"sm"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[!t&&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(xs,{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}),!t&&r.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[r.jsxs(Gt,{tone:"positive",children:[r.jsx(vt,{className:"size-3","aria-hidden":!0}),u]}),r.jsx("span",{className:"text-2xs text-fg-subtle",children:d})]})]})]})}const Ro=e=>{const n=new Map,s=[];for(const t of e){const o=(t.senderAddress||t.senderName).toLowerCase(),i=n.get(o);if(i){i.messages.push(t);continue}n.set(o,{key:o,senderName:t.senderName,senderAddress:t.senderAddress,trustReason:t.trustReason,trustSubReason:t.trustSubReason,senderTrust:t.senderTrust,messages:[t]}),s.push(o)}return s.map(t=>n.get(t)).sort((t,o)=>o.messages.length-t.messages.length)},Eo=(e,n)=>{const s=e.messages.filter(t=>n.has(t.id)).length;return s===0?"none":s===e.messages.length?"all":"some"},Ht=e=>e===1?"message":"messages";function Oo({group:e,selected:n,onToggleGroup:s,onToggleMessage:t}){const[o,i]=l.useState(!1),c=Eo(e,n),a=e.messages.length,u=o?Rs:Es;return r.jsxs("div",{className:Be(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:()=>s(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(xs,{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(vt,{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(d=>!d),"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(u,{className:"size-3.5","aria-hidden":!0})]})]}),o&&r.jsx("div",{className:"divide-y divide-line border-t border-line",children:e.messages.map(d=>r.jsx(To,{candidate:d,selected:n.has(d.id),onToggle:()=>t(d.id),hideSender:!0},d.id))})]})}const Bt=e=>e===1?"message":"messages",Ao=(e,n)=>`Moves ${e===1?"this message":`these ${e} ${Bt(e)}`} out of Spam to ${n} now. Nothing later.`,Dt=(e,n)=>e.find(s=>s.id===n)?.label??"Inbox";function No(){return r.jsx(Ft,{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 zo({candidates:e,selected:n,onToggle:s,onToggleGroup:t,onSelectAll:o,onSelectNone:i,onContinue:c,onCancel:a}){const[u,d]=l.useState(!1),f=n.size,g=l.useMemo(()=>Ro(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(vt,{className:"size-4 text-positive","aria-hidden":!0}),"Rescue from Spam"]}),r.jsx(le,{variant:"ghost",size:"sm",icon:r.jsx(ho,{className:"size-3.5"}),onClick:()=>d(m=>!m),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."}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(No,{})})]}),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 · ${g.length} ${g.length===1?"sender":"senders"}`}),r.jsxs("span",{className:"flex gap-1",children:[r.jsx(le,{variant:"ghost",size:"sm",onClick:o,children:"Select all"}),r.jsx(le,{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:g.map(m=>r.jsx(Oo,{group:m,selected:n,onToggleGroup:t,onToggleMessage:s},m.key))}),r.jsxs("div",{className:"space-y-2 border-t border-line bg-surface px-row-inset py-3",children:[r.jsx(le,{variant:"primary",onClick:c,className:"h-11 w-full font-semibold",children:`Continue with ${f} ${Bt(f)}`}),r.jsx(le,{variant:"ghost",onClick:a,className:"h-11 w-full",children:"Cancel"})]})]})}function Do({count:e,folders:n,delimiter:s,destination:t,onPick:o,onMove:i,onBack:c}){const[a,u]=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(Os,{folders:n,selectedId:t,delimiter:s,onSelect:o,onCancel:()=>u(!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:Dt(n,t)}),r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>u(!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:Ao(e,Dt(n,t))}),r.jsx(le,{variant:"primary",onClick:i,className:"h-11 w-full font-semibold",children:`Move ${e} out of Spam`}),r.jsx(le,{variant:"ghost",onClick:c,className:"h-11 w-full",children:"Back"})]})]})}function Fo({count:e,destinationLabel:n,onClose:s}){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(le,{variant:"primary",onClick:s,className:"h-11 w-full font-semibold",children:"Done"})})]})}function _o({open:e,candidates:n,defaultDestinationId:s,availableFolders:t,delimiter:o,onConfirmMove:i,onCancel:c}){const[a,u]=l.useState("review"),[d,f]=l.useState(()=>e?new Set(n.map(w=>w.id)):new Set),[g,m]=l.useState(s),[y,C]=l.useState(0),I=l.useRef(!1);l.useEffect(()=>{e&&!I.current&&(u("review"),f(new Set(n.map(w=>w.id))),m(s),C(0)),I.current=e},[e,n,s]);const T=d.size,x=w=>{f(j=>{const R=new Set(j);return R.has(w)?R.delete(w):R.add(w),R})},p=(w,j)=>{f(R=>{const E=new Set(R);for(const A of w.messages)j?E.add(A.id):E.delete(A.id);return E})},k=()=>{const w=Array.from(d);C(w.length),i(w,g),u("done")};return r.jsxs(uo,{open:e,onClose:c,dismissLabel:"Close rescue",children:[a==="review"&&r.jsx(zo,{candidates:n,selected:d,onToggle:x,onToggleGroup:p,onSelectAll:()=>f(new Set(n.map(w=>w.id))),onSelectNone:()=>f(new Set),onContinue:()=>u("destination"),onCancel:c}),a==="destination"&&r.jsx(Do,{count:T,folders:t,delimiter:o,destination:g,onPick:m,onMove:k,onBack:()=>u("review")}),a==="done"&&r.jsx(Fo,{count:y,destinationLabel:Dt(t,g),onClose:c})]})}const Lo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},Po=()=>{const e=l.useRef(!1);return l.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",i=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return e.current=s.trim().length>0||i.length>0,e.current},[])},$o=()=>{const{state:e,closeCompose:n}=bt(),s=Po(),[t,o]=l.useState(!1),{isError:i,error:c,refetch:a}=Ze({...Yt(),staleTime:1/0}),u=l.useCallback(m=>{m||(s()?o(!0):n())},[n,s]),d=l.useCallback(()=>{o(!1),n()},[n]),f=l.useCallback(()=>{o(!1)},[]);if(!e.isOpen)return null;const g=Lo[e.mode]??"New Message";return r.jsxs(Pe.Root,{open:e.isOpen,onOpenChange:u,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:g}),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:t,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:d,onCancel:f})]})},Bo={reply:"Reply",reply_all:"Reply All",forward:"Forward",new:"New Message"},bs=()=>{const{state:e,closeCompose:n}=bt(),s=ms(),{isError:t,error:o,refetch:i}=Ze({...Yt(),staleTime:1/0});if(!s)return r.jsx($o,{});if(!e.isOpen)return null;const c=Bo[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(As,{className:"size-5"})})]});return t?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 Wo(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:et(e.updatedAt),isRead:!0}}function Ko(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:et(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0}}function Vo({outboxMessages:e,accountId:n,imapThreads:s}){const t=e.filter(c=>c.status==="draft"&&c.accountId===n).map(Wo),o=s.map(Ko),i=[];return t.length>0&&i.push({id:"remit-drafts",label:"Not yet sent (Remit)",threads:t}),o.length>0&&i.push({id:"imap-drafts",label:"On the server",threads:o}),i}const qo=({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})]}),Ho=({row:e,isSelected:n,onOpen:s,onDelete:t,isDeleting:o})=>r.jsxs("button",{type:"button",onClick:()=>s(e.id),className:Be("group",is({active:n})),children:[r.jsx(Ds,{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(),t(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(Fs,{className:"size-3.5"})})})]}),Uo=({row:e,isSelected:n,onOpen:s})=>{const t=!e.isRead;return r.jsxs("button",{type:"button",onClick:()=>s(e.id),className:Be("group",is({active:n})),children:[t&&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 Qo({mailboxId:e,accountId:n,selectedMessageId:s,imapThreads:t,title:o,unreadCount:i}){const{openCompose:c,state:a}=bt(),u=We(),d=_t(),{data:f}=Ze(Ns()),g=l.useMemo(()=>Vo({outboxMessages:f?.items??[],accountId:n,imapThreads:t}),[f?.items,n,t]),m=Lt({...Zt(),onSuccess:()=>{d.invalidateQueries({queryKey:Xt()})}}),y=x=>{m.mutate({path:{outboxMessageId:x}})},C=x=>{c({mode:"new",outboxMessageId:x})},I=x=>{u({to:"/mail/$mailboxId",params:{mailboxId:e},search:{selectedMessageId:x}})},T=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(io,{}),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:T?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx(zs,{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(qo,{label:x.label,count:x.threads.length}),r.jsx("div",{className:"divide-y divide-line",children:x.threads.map(p=>x.id==="remit-drafts"?r.jsx(Ho,{row:p,isSelected:a.isOpen&&p.id===a.outboxMessageId,onOpen:C,onDelete:y,isDeleting:m.isPending},p.id):r.jsx(Uo,{row:p,isSelected:p.id===s,onOpen:I},p.id))})]},x.id))})]})}function Jo(e,n,s){const t=new Array(e);return new Proxy(t,{get(o,i,c){if(typeof i=="string"){const a=i.charCodeAt(0);if(a>=48&&a<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=n[u*2];d=o[u]={index:u,key:s(u),start:f,size:n[u*2+1],end:f+n[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,c)}})}function $e(e,n,s){let t=s.initialDeps??[],o,i=!0;function c(){const a=e();return(a.length!==t.length||a.some((d,f)=>t[f]!==d))&&(t=a,o=n(...a),s?.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(o),i=!1),o}return c.updateDeps=a=>{t=a},c}function Ut(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Go=(e,n)=>Math.abs(e-n)<1.01,Yo=(e,n,s)=>{let t;return function(...o){e.clearTimeout(t),t=e.setTimeout(()=>n.apply(this,o),s)}};let Xe;const Nt=()=>{if(Xe!==void 0)return Xe;if(typeof navigator>"u")return Xe=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Xe=!0;const e=navigator.maxTouchPoints;return Xe=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Qt=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},Xo=e=>e,Zo=e=>{const n=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,o=new Array(t);for(let i=0;i<t;i++)o[i]=n+i;return o},ei=(e,n)=>{const s=e.scrollElement;if(!s)return;const t=e.targetWindow;if(!t)return;const o=c=>{const{width:a,height:u}=c;n({width:Math.round(a),height:Math.round(u)})};if(o(Qt(s)),!t.ResizeObserver)return()=>{};const i=new t.ResizeObserver(c=>{const a=()=>{const u=c[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Qt(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},xt={passive:!0},ti=typeof window>"u"?!0:"onscrollend"in window,si=(e,n,s)=>{const t=e.scrollElement;if(!t)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&ti;let c=0;const a=i?null:Yo(o,()=>n(c,!1),e.options.isScrollingResetDelay),u=g=>()=>{c=s(t),a?.(),n(c,g)},d=u(!0),f=u(!1);return t.addEventListener("scroll",d,xt),i&&t.addEventListener("scrollend",f,xt),()=>{t.removeEventListener("scroll",d),i&&t.removeEventListener("scrollend",f)}},ni=(e,n)=>si(e,n,s=>{const{horizontal:t,isRtl:o}=e.options;return t?s.scrollLeft*(o&&-1||1):s.scrollTop}),oi=(e,n,s)=>{if(s.options.useCachedMeasurements){const t=s.indexFromElement(e),o=s.options.getItemKey(t);return s.itemSizeCache.get(o)??s.options.estimateSize(t)}if(n?.borderBoxSize){const t=n.borderBoxSize[0];if(t)return Math.round(t[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const t=s.indexFromElement(e),o=s.options.getItemKey(t),i=s.itemSizeCache.get(o);if(i!==void 0)return i}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},ii=(e,{adjustments:n=0,behavior:s},t)=>{var o,i;(i=(o=t.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[t.options.horizontal?"left":"top"]:e+n,behavior:s})},ri=ii;class ai{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 s,t,o;return((o=(t=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:t.now)==null?void 0:o.call(t))??Date.now()},this.observer=(()=>{let s=null;const t=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const c=()=>{const a=i.target,u=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[d,f]of this.elementsCache)if(f===a){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(a,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=t())==null||o.disconnect(),s=null},observe:o=>{var i;return(i=t())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=t())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=s=>{var t,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xo,rangeExtractor:Zo,onChange:()=>{},measureElement:oi,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 m in s){const y=s[m];y!==void 0&&(i[m]=y)}const c=this.options;let a=null,u=null,d=!1;if(c!==void 0&&c.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=c.count,y=i.count,C=this.getMeasurements(),I=m>0?((t=C[0])==null?void 0:t.key)??c.getItemKey(0):null,T=m>0?((o=C[m-1])==null?void 0:o.key)??c.getItemKey(m-1):null;if(y!==m||m>0&&y>0&&(i.getItemKey(0)!==I||i.getItemKey(y-1)!==T)){d=!0;const k=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??C[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const w=i.followOnAppend===!0?"auto":i.followOnAppend||null;w&&y>m&&this.isAtEnd(c.scrollEndThreshold)&&(m===0||i.getItemKey(y-1)!==T)&&(u=w)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(a&&this.scrollOffset!==null){const[m,y]=a,C=this.getMeasurements(),{count:I,getItemKey:T}=this.options;let x=0;for(;x<I&&T(x)!==m;)x++;if(x<I){const p=C[x];if(p){const k=p.start+y;k!==this.scrollOffset&&(g=k-this.scrollOffset,this.scrollOffset=k,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?a[0]:null,f?a[1]:0,u,g])},this.notify=s=>{var t,o;(o=(t=this.options).onChange)==null||o.call(t,this,s)},this.maybeNotify=$e(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(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,!(!Nt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",c,xt),i.addEventListener("touchend",a,xt),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,u]=o;i!==null&&!a&&(Nt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):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 s=this.getScrollOffset(),t=this.getMaxScrollOffset();if(s<0||s>t)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{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],(s,t,o,i,c,a,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:s,paddingStart:t,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=$e(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:t,scrollMargin:o,getItemKey:i,enabled:c,lanes:a,laneAssignmentMode:u,gap:d},f)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const x of this.laneAssignments.keys())x>=s&&this.laneAssignments.delete(x);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(x=>{this.itemSizeCache.set(x.key,x.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),a===1){const x=s*2;let p=this._flatMeasurements;if(!p||p.length<x){const j=new Float64Array(x);p&&m>0&&j.set(p.subarray(0,m*2)),p=j,this._flatMeasurements=p}let k;if(m===0)k=t+o;else{const j=m-1;k=p[j*2]+p[j*2+1]+d}for(let j=m;j<s;j++){const R=i(j),E=g.get(R),A=typeof E=="number"?E:this.options.estimateSize(j);p[j*2]=k,p[j*2+1]=A,k+=A+d}const w=Jo(s,p,i);return this.measurementsCache=w,w}const y=this.measurementsCache.slice(0,m),C=new Array(a).fill(void 0),I=new Float64Array(a);let T=0;for(let x=0;x<m;x++){const p=y[x];p&&(C[p.lane]===void 0&&T++,C[p.lane]=x,I[p.lane]=p.end)}for(let x=m;x<s;x++){const p=i(x),k=this.laneAssignments.get(x);let w,j;const R=u==="estimate"||g.has(p);if(k!==void 0&&this.options.lanes>1){w=k;const _=C[w],N=_!==void 0?y[_]:void 0;j=N?N.end+d:t+o}else if(T===a){let _=0,N=I[0],L=C[0];for(let U=1;U<a;U++){const ee=I[U];(ee<N||ee===N&&C[U]<L)&&(_=U,N=ee,L=C[U])}w=_,j=N+d,R&&this.laneAssignments.set(x,w)}else w=x%this.options.lanes,j=t+o,R&&this.laneAssignments.set(x,w);const E=g.get(p),A=typeof E=="number"?E:this.options.estimateSize(x),z=j+A;y[x]={index:x,start:j,size:A,end:z,key:p,lane:w},C[w]===void 0&&T++,C[w]=x,I[w]=z}return this.measurementsCache=y,y},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$e(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,t,o,i)=>s.length===0||t===0?(this.range=null,null):(this.range=ci(s,t,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$e(()=>{let s=null,t=null;const o=this.calculateRange();return o&&(s=o.startIndex,t=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,t]},(s,t,o,i,c)=>i===null||c===null?[]:s({startIndex:i,endIndex:c,overscan:t,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const t=this.options.indexAttribute,o=s.getAttribute(t);return o?parseInt(o,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var t;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:t.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 s>=c&&s<=a}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((c,a)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(a))});return}const t=this.indexFromElement(s),o=this.options.getItemKey(t),i=this.elementsCache.get(o);i!==s&&(i&&this.observer.unobserve(i),this.observer.observe(s),this.elementsCache.set(o,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,t)=>{var o,i;if(s<0||s>=this.options.count)return;let c,a,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(s),a=d[s*2],c=d[s*2+1];else{const m=this.measurementsCache[s];if(!m)return;u=m.key,a=m.start,c=m.size}const f=this.itemSizeCache.get(u)??c,g=t-f;if(g!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,y=m?this.getTotalSize():0,C=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:u,start:a,size:c,end:a+c,lane:0},g,this):a<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(u,t),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-y):C&&this.applyScrollAdjustment(g),this.notify(!1)}},this.getVirtualItems=$e(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,t)=>{const o=[];for(let i=0,c=s.length;i<c;i++){const a=s[i],u=t[a];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const t=this.getMeasurements();if(t.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,c=vs(0,t.length-1,i?a=>o[a*2]:a=>Ut(t[a]).start,s);return Ut(t[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 s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,t,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),c=this.getScrollOffset();t==="auto"&&(t=s>=c+i?"end":"start"),t==="center"?s+=(o-i)/2:t==="end"&&(s-=i);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,s),0)},this.getOffsetForIndex=(s,t="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),c=this.measurementsCache[s];if(!c)return;if(t==="auto")if(c.end>=i+o-this.options.scrollPaddingEnd)t="end";else if(c.start<=i+this.options.scrollPaddingStart)t="start";else return[i,t];if(t==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),t];const a=t==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,c.size),t]},this.scrollToOffset=(s,{align:t="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(s,t),c=this.now();this.scrollState={index:null,align:t,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:t="auto",behavior:o="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const i=this.getOffsetForIndex(s,t);if(!i)return;const[c,a]=i,u=this.now();this.scrollState={index:s,align:a,behavior:o,startedAt:u,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:t="auto"}={})=>{const o=this.getScrollOffset()+s,i=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const t=this.getMeasurements();let o;if(t.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=t.length-1,c=this._flatMeasurements;c!=null?o=c[i*2]+c[i*2+1]:o=((s=t[i])==null?void 0:s.end)??0}else{const i=Array(this.options.lanes).fill(null);let c=t.length-1;for(;c>=0&&i.some(a=>a===null);){const a=t[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 s=[];if(this.itemSizeCache.size===0)return s;const t=this.getMeasurements();for(const o of t)o&&this.itemSizeCache.has(o.key)&&s.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return s},this._scrollToOffset=(s,{adjustments:t,behavior:o})=>{this._intendedScrollOffset=s+(t??0),this.options.scrollToFn(s,{behavior:o,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(Nt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const t=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=t?t[0]:this.scrollState.lastTargetOffset,i=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Go(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,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>a;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const vs=(e,n,s,t)=>{for(;e<=n;){const o=(e+n)/2|0,i=s(o);if(i<t)e=o+1;else if(i>t)n=o-1;else return o}return e>0?e-1:0};function li(e,n,s){let t=0;for(;t<=n;){const o=(t+n)/2|0,i=e[o*2];if(i<s)t=o+1;else if(i>s)n=o-1;else return o}return t>0?t-1:0}function ci(e,n,s,t,o){const i=e.length-1;if(e.length<=t)return{startIndex:0,endIndex:i};if(t===1&&o!==null){const d=li(o,i,s);let f=d;const g=s+n;for(;f<i&&o[f*2]+o[f*2+1]<g;)f++;return{startIndex:d,endIndex:f}}let a=vs(0,i,d=>e[d].start,s),u=a;if(t===1)for(;u<i&&e[u].end<s+n;)u++;else if(t>1){const d=Array(t).fill(0);for(;u<i&&d.some(g=>g<s+n);){const g=e[u];d[g.lane]=g.end,u++}const f=Array(t).fill(s+n);for(;a>=0&&f.some(g=>g>=s);){const g=e[a];f[g.lane]=g.start,a--}a=Math.max(0,a-a%t),u=Math.min(i,u+(t-1-u%t))}return{startIndex:a,endIndex:u}}const zt=typeof document<"u"?l.useLayoutEffect:l.useEffect;function ui({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...t}){const o=l.useReducer(d=>d+1,0)[1],i=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=n,i.current.mode=s;const c=d=>{const f=i.current;if(!f.enabled||!f.container)return;const g=d.getTotalSize();if(g!==f.lastSize){f.lastSize=g;const x=d.options.horizontal?"width":"height";f.container.style[x]=`${g}px`}const m=!!d.options.horizontal,y=f.mode==="transform",C=m?"left":"top",I=d.options.scrollMargin,T=d.getVirtualItems();for(const x of T){const p=x.start-I,k=d.elementsCache.get(x.key);k&&f.lastPositions.get(k)!==p&&(f.lastPositions.set(k,p),y?k.style.transform=m?`translate3d(${p}px, 0, 0)`:`translate3d(0, ${p}px, 0)`:k.style[C]=`${p}px`)}},a={...t,onChange:(d,f)=>{var g;const m=i.current;let y=!0;if(m.enabled){c(d);const C=d.range,I=m.prevRange;y=!I||I.isScrolling!==d.isScrolling||I.startIndex!==C?.startIndex||I.endIndex!==C?.endIndex,y&&(m.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:d.isScrolling}:null)}y&&(e&&f?_s.flushSync(o):o()),(g=t.onChange)==null||g.call(t,d,f)}},[u]=l.useState(()=>{const d=new ai(a);return Object.assign(d,{containerRef:f=>{const g=i.current;if(g.container=f,g.lastSize=null,f&&g.enabled){const m=d.getTotalSize();g.lastSize=m;const y=d.options.horizontal?"width":"height";f.style[y]=`${m}px`}}})});return u.setOptions(a),zt(()=>u._didMount(),[]),zt(()=>u._willUpdate()),zt(()=>{c(u)}),u}function di(e){return ui({observeElementRect:ei,observeElementOffset:ni,scrollToFn:ri,...e})}const Wt=e=>e.query?`matching "${e.query}"`:e.from?`from "${e.from}"`:"matching your search",hi=e=>`Select all ${Wt(e)}`,fi=(e,n)=>`All ${no(n)} ${Wt(e)} selected`,mi=({verb:e,confirmingDelete:n,hasSelection:s,junkMailboxId:t,currentMailboxId:o,deletableMessageId:i})=>{if(n)return{kind:"withheld"};if(e==="junk"){const c=ln(t,o);if(c!==void 0)return{kind:"unavailable",reason:c}}return s?{kind:"openWizard"}:e!=="delete"||i===void 0?{kind:"declined"}:{kind:"confirmDelete",messageId:i}},gi=(e,n,s)=>e==="BACK"&&n&&s===void 0,pi=(e,n)=>({id:e.messageId,accountId:e.accountId,mailboxId:e.mailboxId,fromName:e.fromName??e.fromEmail??"Unknown",fromEmail:e.fromEmail??"",subject:e.subject??"(No subject)",snippet:e.snippet??"",timeLabel:et(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}),xi=({thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,messageCount:d,isMultiSelectMode:f,onLongPress:g,isDesktop:m,density:y})=>r.jsx(cn,{thread:pi(e,d),linkMailboxId:n,inListbox:!0,active:s,focused:t,isTabStop:o,density:y,isDesktop:m,onFocusRow:i,selection:{isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:f,onLongPress:g}}),bi=l.memo(xi),vi=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:et(e.sentDate),isRead:e.isRead,hasAttachment:e.hasAttachment,starred:e.hasStars===!0,trust:e.senderTrust,category:rs(e.category),suspicious:n}},Si=({thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:g,onDelete:m,onToggleRead:y,density:C})=>{const[I,T]=l.useState("none"),x=We(),p=l.useCallback(E=>{navigator.vibrate?.(10),E==="trailing"?m(e.messageId):y(e.messageId,e.isRead),T("none")},[m,y,e.messageId,e.isRead]),k=l.useCallback(()=>{f(e.messageId)},[f,e.messageId]),w=l.useCallback(()=>{a(e.messageId)},[a,e.messageId]),j=l.useCallback(()=>{x({to:"/mail/$mailboxId",params:{mailboxId:n},search:E=>({...E,selectedMessageId:e.messageId})})},[x,n,e.messageId]),R=un(e.messageId,u);return g||d?r.jsx(bi,{thread:e,mailboxId:n,isSelected:s,isFocused:t,isTabStop:o,onFocusRow:i,isChecked:c,onToggleCheck:a,onRowSelect:u,isMultiSelectMode:d,onLongPress:f,isDesktop:g,density:C}):r.jsx("div",{role:"presentation",onPointerDownCapture:R.onMouseDown,onClickCapture:R.claimClick,onContextMenu:R.onContextMenu,children:r.jsx(Gn,{thread:vi(e),selectionMode:!1,checked:!1,active:s,peek:I,onPeek:T,onToggleCheck:w,onLongPress:k,onOpen:j,onAct:p})})},yi=72,Ci=32,wi=5,Ss="remit:list-density",Ii=()=>{try{const e=localStorage.getItem(Ss);if(e==="compact"||e==="comfortable")return e}catch{}return"comfortable"},ji=({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(Ks,{className:"size-4 text-fg-muted"}),r.jsxs("span",{className:"text-sm text-fg-muted",children:["Results for “",e,"”"]})]}),ki=({mailboxId:e,threads:n,selectedMessageId:s,isLoading:t,isError:o=!1,error:i,onRetry:c,searchQuery:a,searchPredicate:u,onDeleteMessages:d,isDeleting:f=!1,isMoving:g=!1,onLoadMore:m,hasMore:y=!1,isLoadingMore:C=!1,accountId:I,listTitle:T,listMeta:x,listFilter:p,listScopeLabel:k,onTriageContextChange:w,commandsRef:j,hideHeader:R=!1})=>{const E=l.useRef(null),A=We(),z=ms(),_=Ls(),{verb:N,start:L,startFromSearch:U}=_,ee=Ps(),Se=!!a?.trim(),P=dn(),{labels:Ke}=ro(I),{pushError:oe}=es(),[M,ye]=l.useState(s),[Ce,Q]=l.useState(),$=l.useCallback(h=>{Q(b=>b===h?b:void 0),ye(h)},[]),[ge,H]=l.useState(Ii),Re=l.useCallback(()=>{H(h=>{const b=h==="comfortable"?"compact":"comfortable";try{localStorage.setItem(Ss,b)}catch{}return b})},[]),{toggleReadFor:Ee}=as({mailboxId:e}),{junkMailboxId:pe}=ls(I),ie=cs(pe,e),{selectedIds:Y,selectedCount:te,hasSelection:X,isSelected:we,toggle:Z,select:ce,clearSelection:B,selectRange:xe,setAnchor:tt,selectAll:O,toggleAll:st,intersectWith:nt}=hn(),Oe=In(te,z),[D,Ae]=l.useState(null),Ie=Se&&!!u,Ve=`${e}|${JSON.stringify(u??{})}`,v=fn({mailboxId:e,accountId:I,enabled:Ie,predicateKey:Ve,searchQuery:u??{}}),ot=l.useCallback((h,b,ae)=>{if(ae.error===void 0){if(ae.cancelled){oe({severity:"warning",title:gn(ae.done),detail:mn(h,ae.done,b)});return}oe({severity:"info",title:Kt(h,ae.done)})}},[oe]),qe=v.phase.kind,it=v.clear,W=l.useCallback(()=>{qe==="escalated"&&it(),B()},[B,it,qe]),[rt,ue]=l.useState(null),de=l.useRef(null),se=l.useRef(!1),Ne=l.useRef(null),je=!t&&n.length>0,K=D!==null,ke=di({count:n.length,getScrollElement:()=>E.current,estimateSize:()=>ge==="compact"?Ci:yi,overscan:wi}),at=s?n.findIndex(h=>h.messageId===s):-1,ne=M?n.findIndex(h=>h.messageId===M):-1,F=l.useCallback(h=>{if(h<0||h>=n.length)return;const b=n[h];if(Oe){Z(b.messageId);return}de.current=b.messageId,se.current=!1,Q(b.messageId),ye(b.messageId)},[n,Oe,Z]),He=l.useCallback(()=>{if(n.length===0)return;const h=ne<0?0:Math.min(ne+1,n.length-1);F(h)},[n.length,ne,F]),he=l.useCallback(()=>{if(n.length===0)return;const h=ne<=0?0:ne-1;F(h)},[n.length,ne,F]),lt=l.useCallback(()=>F(0),[F]),Ue=l.useCallback(()=>F(n.length-1),[F,n.length]),Qe=l.useCallback(()=>{M&&Z(M)},[M,Z]),V=l.useMemo(()=>n.map(h=>h.messageId),[n]),yt=l.useMemo(()=>{const h=[];for(const b of n)Y.has(b.messageId)&&h.push({id:b.messageId,sender:b.fromName??b.fromEmail??"Unknown",email:b.fromEmail??"",subject:b.subject??"(No subject)",date:et(b.sentDate)});return h},[n,Y]),ct=l.useCallback((h,b)=>b.shiftKey?(xe(V,h,M),!0):b.metaKey||b.ctrlKey?(Z(h),!0):(W(),tt(h),!1),[V,M,xe,Z,W,tt]),ze=l.useCallback(h=>{!d||h.length===0||(Ne.current=M??null,Ae(h))},[d,M]),Me=l.useCallback(h=>{const b=pn(V,M,h);b!==void 0&&(xe(V,b),de.current=b,se.current=!1,Q(void 0),ye(b))},[V,M,xe]),be=l.useCallback(()=>Me(-1),[Me]),Je=l.useCallback(()=>Me(1),[Me]),De=l.useCallback(()=>{V.length>0&&O(V)},[V,O]),ut=l.useCallback(h=>{const b=mi({verb:h,confirmingDelete:D!==null,hasSelection:X,junkMailboxId:pe,currentMailboxId:e,deletableMessageId:d?M:void 0});return b.kind==="openWizard"?(L(h),!0):b.kind==="confirmDelete"?(ze([b.messageId]),!0):b.kind==="unavailable"?(oe({severity:"warning",title:b.reason}),!0):b.kind==="withheld"},[D,d,X,pe,e,L,M,ze,oe]),Ge=l.useCallback(()=>{M&&A({to:"/mail/$mailboxId",params:{mailboxId:e},search:h=>({...h,selectedMessageId:M})})},[M,A,e]),dt=l.useCallback(h=>{A({to:"/mail/$mailboxId",params:{mailboxId:e},search:b=>({...b,selectedMessageId:h}),replace:!0})},[A,e]);xn({keyboardFocusedMessageId:Ce,openMessageId:s,enabled:z&&te===0,open:dt});const fe=v.phase.kind==="escalated"?{scope:Wt(u??{}),total:v.phase.total,searchQuery:u??{},run:h=>v.runAction(h),stop:v.stop}:void 0,Fe=l.useCallback(()=>{if(!D)return;const h=D;if(h.length===0){Ae(null);return}const b=new Set(h),ae=n.findIndex(q=>b.has(q.messageId));let me;for(let q=ae+1;q<n.length;q++)if(!b.has(n[q].messageId)){me=n[q].messageId;break}if(me===void 0){for(let q=ae-1;q>=0;q--)if(!b.has(n[q].messageId)){me=n[q].messageId;break}}d?.(h),W(),Ne.current=null,Ae(null),me!==void 0&&(de.current=me,se.current=!1,$(me),z&&A({to:"/mail/$mailboxId",params:{mailboxId:e},search:q=>({...q,selectedMessageId:me}),replace:!0})),z||ue(Kt("delete",h.length))},[D,n,d,W,A,e,z,$]),_e=l.useCallback(()=>{const h=Ne.current;Ne.current=null,Ae(null),h!==null&&(de.current=h,se.current=!1,$(h))},[$]),re=l.useMemo(()=>{if(te===0)return;const h=new Set;for(const b of n)Y.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"},[te,Y,n]),Ct=l.useCallback(()=>{if(fe){U();return}L("organize")},[fe,U,L]),wt=l.useCallback(h=>{d?.([h])},[d]),It=l.useCallback((h,b)=>{Ee([h],!b)},[Ee]),ve=l.useCallback(h=>{z||ce(h)},[z,ce]),jt=l.useCallback(()=>{if(v.isRunning||v.phase.kind==="counting"){v.stop();return}W()},[v,W]),kt=l.useCallback(()=>{v.clear()},[v]);l.useEffect(()=>{if(se.current||!z&&s)return;const h=ne>=0?ne:at;h>=0&&ke.scrollToIndex(h,{align:"auto"})},[ne,at,ke,z,s]),l.useEffect(()=>{s&&(se.current=!1,$(s))},[s,$]),l.useEffect(()=>{M&&(n.some(h=>h.messageId===M)||$(n[0]?.messageId))},[n,M,$]),l.useEffect(()=>{w?.({focusedMessageId:M,selectedIds:Array.from(Y),hasList:je,blocksKeyboard:K||_.isOpen})},[M,Y,je,K,_.isOpen,w]);const ht=l.useRef(w);ht.current=w,l.useEffect(()=>()=>ht.current?.({focusedMessageId:void 0,selectedIds:[],hasList:!1,blocksKeyboard:!1}),[]),l.useEffect(()=>{v.phase.kind!=="idle"||v.isRunning||nt(n.map(h=>h.messageId))},[n,nt,v.phase,v.isRunning]);const ft=l.useRef(e);l.useEffect(()=>{ft.current!==e&&(ft.current=e,W())},[e,W]),bn({shouldBlockFn:({action:h})=>gi(h,X,ee)?(W(),!0):!1,enableBeforeUnload:!1,disabled:!X||ee!==void 0}),l.useEffect(()=>{const h=E.current;if(!h||!y||!m)return;const b=()=>{if(C)return;const{scrollTop:ae,scrollHeight:me,clientHeight:q}=h;ae+q>=me-200&&m()};return h.addEventListener("scroll",b,{passive:!0}),b(),()=>h.removeEventListener("scroll",b)},[y,C,m]),l.useEffect(()=>{const h=de.current;if(!h)return;const b=E.current?.querySelector(`[data-message-id="${h}"]`);b&&(de.current=null,b.focus({preventScroll:!0}))}),l.useEffect(()=>{if(j){if(!je){j.current=null;return}return j.current={focusNext:He,focusPrevious:he,focusFirst:lt,focusLast:Ue,openFocused:Ge,toggleSelect:Qe,extendSelectDown:Je,extendSelectUp:be,selectAll:De,clearSelection:()=>X?(W(),!0):!1,requestVerb:ut,toggleDensity:Re},()=>{j.current=null}}},[j,je,He,he,lt,Ue,Ge,Qe,Je,be,De,X,W,ut,Re]);const mt=t?"loading":o?"error":n.length===0?"empty":"ready",Mt=o?to(i):void 0,Tt=l.useCallback(()=>{const h=$s(Bs());window.open(h,"_blank","noopener,noreferrer")},[]),Te=[{id:"inbox",threads:[]}],Le=V.length>0&&V.every(h=>Y.has(h)),gt=Ie&&y&&Le&&!f&&!g&&v.phase.kind==="idle"&&!v.isRunning,Rt=f||g||v.isRunning,Ye=v.phase.kind==="escalated"?v.phase.total:te,Et=v.runningAction?vn(v.runningAction.kind,v.progress?.done??0,v.progress?.total??Ye):v.phase.kind==="counting"?"Counting matches…":v.phase.kind==="escalated"?fi(u??{},v.phase.total):void 0,Ot=v.phase.kind!=="escalated"&&V.length>0?{checked:Le,indeterminate:te>0&&!Le,onChange:()=>st(V)}:void 0,At=v.runningAction?{value:v.progress?.done??0,max:v.progress?.total??Ye,tone:Sn(v.runningAction.kind)}:void 0,J=(v.phase.kind==="counting"?{tone:"info",text:"",action:{label:"Stop",onClick:v.stop}}:v.phase.kind==="escalated"&&!v.isRunning?{tone:"info",text:"",action:{label:"Clear selection",onClick:kt}}:gt?{tone:"info",text:"",action:{label:hi(u??{}),onClick:v.escalate}}:void 0)??(re?{tone:"warning",text:re}:void 0),G=r.jsx(yn,{title:P.title||T,navSlot:P.navSlot,titleMeta:P.titleMeta,searchSlot:P.searchSlot,searchField:P.searchField,idleSlot:P.makeFilterSlot,count:Ye,onCancel:jt,onDelete:()=>L("delete"),onMove:()=>L("move"),onOrganize:Ct,onJunk:ie?()=>L("junk"):void 0,onMarkRead:()=>L("markRead"),overflowSlot:I&&e&&te>0&&Ke.length>0?r.jsx(ao,{accountId:I,mailboxId:e,messageIds:Array.from(Y)}):void 0,isBusy:Rt,isCounting:v.phase.kind==="counting",selectAll:Ot,statusLabel:Et,progress:At,notice:J}),Is=Cn(V,M),js=l.useCallback(h=>{se.current=!0,$(h)},[$]),ks=r.jsxs(r.Fragment,{children:[Se&&a&&r.jsx(ji,{query:a}),r.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":T,className:"flex-1 overflow-y-auto",children:[r.jsx("div",{role:"presentation",className:"relative w-full",style:{height:`${ke.getTotalSize()}px`},children:ke.getVirtualItems().map(h=>{const b=n[h.index];return r.jsx("div",{role:"presentation","data-index":h.index,ref:ke.measureElement,className:Ws("absolute left-0 top-0 w-full border-b border-line",v.isRunning&&"pointer-events-none opacity-50"),style:{transform:`translateY(${h.start}px)`},children:r.jsx(Si,{thread:b,mailboxId:e,isSelected:s===b.messageId,isFocused:M===b.messageId,isTabStop:Is===b.messageId,onFocusRow:js,isChecked:we(b.messageId),onToggleCheck:Z,onRowSelect:ct,isMultiSelectMode:Oe,onLongPress:ve,isDesktop:z,onDelete:wt,onToggleRead:It,density:ge})},h.key)})}),C&&r.jsx(Yn,{})]})]});return r.jsxs(r.Fragment,{children:[rt&&!z&&r.jsx(Ft,{tone:"success",variant:"soft",className:"m-2 rounded-md",onDismiss:()=>ue(null),children:rt}),r.jsx(Xn,{listTitle:T,listMeta:x,sections:Te,flatList:!0,listState:P.searchResults?"ready":mt,searchQuery:Se?a:void 0,listFilter:p,listScopeLabel:k,errorMessage:Mt,onRetry:c,onReportError:Tt,density:ge,selectedThreadId:s,onSelectThread:h=>A({to:"/mail/$mailboxId",params:{mailboxId:e},search:b=>({...b,selectedMessageId:h})}),isDesktop:z,hideHeader:R,selectionBar:G,listBody:P.searchResults??(mt==="ready"?ks:void 0)}),r.jsx(gs,{isOpen:D!==null,title:oo(D?.length??0),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash",destructive:!0,isBusy:f,onConfirm:Fe,onCancel:_e}),r.jsx(wn,{verb:N,accountId:I,mailboxId:e,selection:yt,crossAccount:re!==void 0,escalated:fe,escalatedProgress:v.progress,onFinished:W,onRunEnded:ot})]})},Mi=e=>qs({path:{accountId:e}}),Ti=e=>{const n=_t(),s=Pt(),t=Lt({...Vs(),onSuccess:()=>{s.recordEvent("sync.triggered"),n.invalidateQueries({queryKey:Mi(e)})}});return{trigger:()=>{t.mutate({path:{accountId:e}})},triggerAsync:()=>t.mutateAsync({path:{accountId:e}}),isPending:t.isPending,error:t.error,reset:t.reset}},Ri=({accountId:e,children:n})=>{const{triggerAsync:s,isPending:t}=Ti(e);return r.jsx(Io,{onRefresh:s,isRefreshing:t,children:n})};function Ei({accountId:e,currentMailboxId:n,candidates:s,onMove:t,children:o}){const[i,c]=l.useState(!1),a=Pt(),u=mo(),{inboxMailboxId:d}=jn(e),f=kn(e),{data:g}=Ze({...Hs({path:{accountId:e}}),staleTime:1/0}),m=l.useMemo(()=>go({mailboxes:g?.items??[],folderAppointments:f,currentMailboxId:n,translator:u}),[g?.items,f,n,u]),y=l.useMemo(()=>d||(m.find(p=>p.label.toLowerCase()==="inbox")?.id??m.find(p=>!p.isCurrent)?.id??""),[d,m]),C=l.useRef(!1);l.useEffect(()=>{C.current||(C.current=!0,Mn(a,s.length))},[a,s.length]);const I=l.useCallback(()=>{Tn(a,s.length),c(!0)},[a,s.length]),T=l.useCallback((x,p)=>{Rn(a,{selected:x.length,total:s.length,toInbox:p===d}),t(x,p)},[a,s.length,d,t]);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(ko,{count:s.length,onReview:I})}),r.jsx("div",{className:"min-h-0 flex-1",children:o}),r.jsx(_o,{open:i,candidates:s,defaultDestinationId:y,availableFolders:m,delimiter:po(g?.items??[]),onConfirmMove:T,onCancel:()=>c(!1)})]})}const Oi="We can verify this sender";function Ai(e){const{data:n}=Ze({...Us({path:{mailboxId:e??""},query:{senderTrust:["vip","wellknown"],dkimMismatch:!1,results:!0,limit:500}}),enabled:!!e,staleTime:6e4});return{candidates:(n?.items??[]).map(t=>({id:t.messageId,senderName:t.fromName||t.fromEmail||"Unknown sender",senderAddress:t.fromEmail??"",subject:t.subject||"(no subject)",snippet:t.snippet??"",trustReason:Oi,trustSubReason:En(t.senderTrust),senderTrust:t.senderTrust}))}}const Ni=e=>{const n=new Set,s=[];for(const t of e)n.has(t.threadMessageId)||(n.add(t.threadMessageId),s.push(t));return s},zi={unread:"unread",flagged:"starred",attachment:"attachments"},Di=new Set(Object.values(So)),ys=e=>Di.has(e),Fi=e=>ys(e.category)||e.attributes.size>0,_i=e=>{const n={};ys(e.category)&&(n.category=[e.category]);for(const s of e.attributes){const t=zi[s];t&&(n[t]=!0)}return n},Li=e=>(e.senderTrust?.length??0)>0||e.dkimMismatch!==void 0?"loaded-pages":"whole-folder",Pi=["category","unread","starred","attachments"],Jt=e=>JSON.stringify(Pi.map(n=>e?.[n]??null)),$i=e=>{if(!Array.isArray(e))return;const[n]=e;if(typeof n!="object"||n===null)return;const s=n.query;if(!(typeof s!="object"||s===null))return s},Bi=(e,n)=>{const s=$i(e);return s?Jt(s)===Jt(n):!1},Wi=(e,n)=>e!==n,Ki=(e,n,s)=>{if(!(s||!n))return e.find(t=>t.messageId===n)},Vi=(e,n,s,t)=>{if(e)return e;if(!(t||!s))return n?.messageId===s?n:void 0},pt=e=>e[0],qi=e=>{const n=pt(e.filter(a=>a.type==="from").map(a=>a.value)),s=pt(e.filter(a=>a.type==="subject").map(a=>a.value)),t=pt(e.filter(a=>a.type==="category").map(a=>a.category)),o=pt(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}:{},...s!==void 0?{subject:s}:{},...t!==void 0?{category:[t]}:{},...o!==void 0?{unread:o}:{},...i!==void 0?{starred:i}:{},...c!==void 0?{attachments:c}:{}}},Hi=(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 Ui(e,n={}){const s=qi(e),t={...s,...n};return{params:s,residual:e.filter(o=>!Hi(t,o))}}function Qi(e,n,s){if(n.length===0)return e;const t=[...n];return e.filter(o=>{const i=On(o);return An({...i,accountId:i.accountId??s},t)})}const Ji=50,Gi=new Map(hs().categories.filter(e=>e.id!=="all").map(e=>[e.id,e.label])),Cs=l.createContext(null);function St(){const e=l.useContext(Cs);if(!e)throw new Error("MailboxPane.* must be used inside <MailboxPane>");return e}function Yi({mailboxId:e,selectedMessageId:n,children:s}){const t=We(),i=ps()==="desktop",c=Pt(),{accounts:a,searchQuery:u,searchInput:d,intelligenceOpen:f,onToggleIntelligence:g,onSetIntelligenceOpen:m}=ts(),y=tn(),C=Co(u),I=C.length>0,{freeText:T,tokens:x}=sn(C,y),[p,k]=l.useState("all"),[w,j]=l.useState(new Set),R=l.useMemo(()=>({category:p,attributes:w}),[p,w]),E=l.useMemo(()=>_i(R),[R]),A=I||Fi(R),{params:z,residual:_}=Ui(x,E),N={order:"desc",limit:Ji,...T?{query:T}:{},...z,...E},L={category:N.category,unread:N.unread,starred:N.starred,attachments:N.attachments},U=A?Qs({path:{mailboxId:e},query:N}):Js({path:{mailboxId:e},query:{order:"desc"}}),{data:ee,isLoading:Se,isError:P,error:Ke,refetch:oe,fetchNextPage:M,hasNextPage:ye,isFetchingNextPage:Ce}=Zn({queryKey:U,queryFn:async({pageParam:S})=>{if(A){const{data:G}=await Zs({path:{mailboxId:e},query:{...N,continuationToken:S},throwOnError:!0});return G}const{data:J}=await en({path:{mailboxId:e},query:{order:"desc",continuationToken:S},throwOnError:!0});return J},initialPageParam:void 0,getNextPageParam:S=>S.continuationToken,placeholderData:(S,J)=>Bi(J?.queryKey,L)?S:void 0}),Q=l.useCallback(S=>{n&&S.includes(n)&&t({to:"/mail/$mailboxId",params:{mailboxId:e},search:J=>({...J,selectedMessageId:void 0,selectedThreadId:void 0})})},[n,e,t]),{deleteMessages:$,isPending:ge}=Vt({mailboxId:e,onAfterOptimisticRemove:Q}),{accountId:H}=Nn(e),Re=xo({accounts:a}),{moveMessages:Ee,isPending:pe}=qt({mailboxId:e,accountId:H,onAfterOptimisticRemove:Q}),ie=Qi(zn(Ni(ee?.pages.flatMap(S=>S.items??[])??[])),_,H),Y=l.useCallback(S=>{k(S)},[]),te=l.useCallback(S=>{j(J=>{const G=new Set(J);return G.has(S)?G.delete(S):G.add(S),G})},[]),X=l.useCallback(()=>{k("all"),j(new Set)},[]),we=Gi.get(p),Z=we?{label:we,reach:_.length>0?"loaded-pages":Li(N),onClear:X}:void 0,ce=Wi(d,u),B=Ki(ie,n,ce),[xe,tt]=l.useState(void 0);l.useEffect(()=>{B&&tt(B)},[B]);const O=Vi(B,xe,n,ce),{selectedThreadId:st}=Gs({strict:!1}),nt=l.useMemo(()=>lo(O,{messageId:n,threadId:ce?void 0:st,mailboxId:e}),[O,n,st,ce,e]),Oe=Dn(),{listCommandsRef:D,onTriageContextChange:Ae,focusedMessageId:Ie,selectedIds:Ve}=Oe,v=ie.find(S=>S.messageId===Ie)??O,ot=l.useRef(null);l.useEffect(()=>{const S=O?.messageId??null;S&&ot.current!==S&&O?.authenticity?.dkimMismatch&&(ot.current=S,f||g())},[O?.messageId,O?.authenticity?.dkimMismatch,f,g]);const qe=l.useRef(!1);l.useEffect(()=>{qe.current||i&&O?.messageId&&(qe.current=!0,yo()&&!f&&m(!0))},[i,O?.messageId,f,m]);const it=bo({accounts:a})??0,W=_t(),{pushError:rt}=es(),ue=Fn({thread:O,mailboxId:e,accountId:H,onAfterOptimisticRemove:Q}),{draftsMailboxId:de}=_n(H),se=de!==void 0&&de===e,{archiveMailboxId:Ne}=Ln(H),je=Pn(),{requestCompose:K}=ue,ke=l.useCallback(()=>{K("reply")},[K]),at=l.useCallback(()=>{K("reply_all")},[K]),ne=l.useCallback(()=>{K("forward")},[K]),{state:F,openCompose:He,closeCompose:he}=bt(),lt=l.useCallback(()=>{He({mode:"new"})},[He]),Ue=l.useRef(n);l.useEffect(()=>{const S=Ue.current;Ue.current=n,!(!n||n===S)&&he()},[n,he]);const Qe=Lt({...Zt(),onError:S=>{rt(Ys("Couldn't discard draft","The draft wasn't deleted.",S))}}),V=l.useCallback(()=>{const S=F.outboxMessageId;S&&(Qe.mutate({path:{outboxMessageId:S}}),W.invalidateQueries({queryKey:Xt()}),he())},[F.outboxMessageId,Qe,W,he]),yt=l.useCallback(()=>{t({to:"/mail/$mailboxId",params:{mailboxId:e},search:S=>({...S,selectedMessageId:void 0,selectedThreadId:void 0})})},[e,t]),ct=l.useCallback(S=>S?je(S):[],[je]),{toggleStar:ze}=$n({threadId:v?.threadId??"",mailboxId:e}),{toggleReadFor:Me}=as({mailboxId:e,accountId:H}),{junkMailboxId:be}=ls(H),Je=be!=null&&be===e,De=cs(be,e),{candidates:ut}=Ai(Je?be:void 0),{moveMessages:Ge}=qt({mailboxId:e,threadId:v?.threadId,accountId:H,onAfterOptimisticRemove:Q}),{deleteMessages:dt}=Vt({mailboxId:e,threadId:v?.threadId,onAfterOptimisticRemove:Q}),{addressId:fe,address:Fe}=Bn(v),{updateFlags:_e}=Wn({addressId:fe,senderEmail:v?.fromEmail??void 0}),re=l.useCallback(()=>n||!Ie?!1:(t({to:"/mail/$mailboxId",params:{mailboxId:e},search:S=>({...S,selectedMessageId:Ie})}),!0),[n,Ie,e,t]),Ct=l.useCallback(()=>{re()||O&&K("reply")},[re,O,K]),wt=l.useCallback(()=>{re()||O&&K("reply_all")},[re,O,K]),It=l.useCallback(()=>{re()||O&&K("forward")},[re,O,K]),ve=l.useCallback(()=>ct(v),[ct,v]),jt=l.useCallback(()=>{if(D.current?.requestVerb("delete"))return;const S=ve();S.length>0&&dt(S)},[D,ve,dt]),kt=l.useCallback(()=>{if(D.current?.requestVerb("junk")||!De)return;const S=ve();S.length!==0&&(Kn(c,{count:S.length,senderTrust:v?.senderTrust??"unknown",wasRescuable:v?Vn(v):!1}),Ge(S,De))},[D,De,ve,Ge,c,v]),ht=l.useCallback(()=>{if(Ve.length>0){const S=!(v?.hasStars??!1),J=new Set(Ve);for(const G of ie)J.has(G.messageId)&&G.hasStars!==S&&ze(G.messageId,G.hasStars);return}v&&ze(v.messageId,v.hasStars)},[Ve,ie,v,ze]),ft=l.useCallback(()=>{if(D.current?.requestVerb("markRead"))return;const S=ve();if(S.length===0)return;const J=!(v?.isRead??!1);Me(S,J)},[D,ve,v,Me]),mt=l.useCallback(()=>{if(!fe)return;const S=Fe?.flags?.muted?.value!==!0;_e({muted:{value:S}})},[fe,Fe,_e]),Mt=l.useCallback(()=>{if(!fe)return;const S=Fe?.flags?.vip?.value!==!0;_e({vip:{value:S}})},[fe,Fe,_e]),Tt=l.useCallback(()=>{f||g()},[f,g]),Te=l.useCallback(S=>{t({to:S})},[t]),Le=se?"drafts":Ne===e?"archive":be===e?"junk":"inbox",gt=l.useRef("");l.useEffect(()=>{const S=gt.current;gt.current=C,C.length>0&&S.length===0&&c.recordEvent("search.submitted",{mailboxType:Le})},[C,Le,c]);const Rt=se&&F.isOpen&&!!F.outboxMessageId&&!O,{goBack:Ye,nextMessageId:Et,previousMessageId:Ot}=qn({context:Oe,orderedIds:ie.map(S=>S.messageId),selectedMessageId:n,enabled:!F.isOpen,onClose:yt,handlers:{reply:Ct,replyAll:wt,forward:It,delete:jt,toggleStar:ht,toggleRead:ft,muteSender:mt,blockSender:Tt,vipSender:Mt,markJunk:kt,toggleIntelligence:O?g:void 0,compose:lt,goBrief:()=>Te("/mail/brief"),goInbox:()=>Te("/mail/brief"),goSent:()=>Te("/mail/brief"),goFlagged:()=>Te("/mail/flagged"),goSettings:()=>Te("/settings")}});vo({enabled:F.isOpen,bindings:[{key:"Escape",handler:he,preventDefault:!0}]});const At={mailboxId:e,selectedMessageId:n,selectedThread:O,conversation:nt,threads:ie,isLoading:Se,isError:P,error:Ke,mailboxAccountId:H,mailboxName:Re,unreadCount:it,isDraftsMailbox:se,isSpamFolder:Je,rescueCandidates:ut,filterCategory:p,filterAttributes:w,onSelectFilterCategory:Y,onToggleFilterAttribute:te,onClearFilters:X,listFilter:Z,intelligenceOpen:f,onToggleIntelligence:g,handleDeselectIfRemoved:Q,searchPredicate:I&&_.length===0?N:void 0,onDeleteMessages:$,onMoveMessages:Ee,isDeleting:ge,isMoving:pe,onLoadMore:M,hasMore:ye,isLoadingMore:Ce,onTriageContextChange:Ae,listCommandsRef:D,onRetry:()=>oe(),toolbarComposeRequest:ue.composeRequest,onToolbarReply:ke,onToolbarReplyAll:at,onToolbarForward:ne,onClearComposeRequest:ue.clearComposeRequest,onToolbarDelete:ue.deleteThread,onToolbarStar:ue.toggleStar,onToolbarDiscardDraft:V,onToolbarMove:ue.moveThread,composeState:F,closeCompose:he,hasRemitDraftOpen:Rt,onBack:Ye,nextMessageId:Et,previousMessageId:Ot};return r.jsx(Cs.Provider,{value:At,children:s})}function ws(){const{mailboxId:e,selectedMessageId:n,threads:s,isLoading:t,isError:o,error:i,onDeleteMessages:c,onMoveMessages:a,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:g,isLoadingMore:m,mailboxAccountId:y,mailboxName:C,unreadCount:I,isDraftsMailbox:T,isSpamFolder:x,rescueCandidates:p,onTriageContextChange:k,listCommandsRef:w,onRetry:j,filterCategory:R,filterAttributes:E,onSelectFilterCategory:A,onToggleFilterAttribute:z,onClearFilters:_,listFilter:N,searchPredicate:L}=St(),{searchQuery:U,searchInput:ee,accounts:Se,resultFolderIndex:P}=ts(),Ke=ps(),oe=We(),M=C??"Inbox",ye=l.useMemo(()=>hs(),[]),Ce=l.useMemo(()=>y?[y]:[],[y]),{hasNewMail:Q}=on(),{state:$,errorMessage:ge,refresh:H}=rn(Ce,{onSettled:j}),Re=l.useMemo(()=>r.jsx(an,{state:$,onRefresh:H,label:`Refresh ${M}`,errorMessage:ge,hasUpdate:Q(Ce)}),[$,H,M,ge,Q,Ce]),Ee=l.useMemo(()=>s.map(B=>Qn(B,P)),[s,P]),{hits:pe,isLoading:ie}=co({mailboxId:e,filterCategory:R}),Y=l.useMemo(()=>Jn(pe,s.map(B=>B.threadId),P),[pe,s,P]),te=l.useCallback(B=>oe({to:"/mail/$mailboxId",params:{mailboxId:B.mailboxId??e},search:xe=>({...xe,q:ee||void 0,selectedMessageId:B.id,selectedThreadId:B.threadId})}),[e,oe,ee]);if(T&&y)return r.jsx(Qo,{mailboxId:e,accountId:y,selectedMessageId:n,imapThreads:s,title:C??"Drafts",unreadCount:I??void 0});const X=r.jsx(ki,{mailboxId:e,threads:s,selectedMessageId:n,isLoading:t,isError:o,error:i,onRetry:j,searchQuery:U,searchPredicate:L,onDeleteMessages:c,isDeleting:u,isMoving:d,onLoadMore:f,hasMore:g,isLoadingMore:m,accountId:y,listTitle:M,listFilter:N,listScopeLabel:M,hideHeader:!0,onTriageContextChange:k,commandsRef:w}),we=Se[0]?.accountId,Z=Ke==="phone"&&we?r.jsx(Ri,{accountId:we,children:X}):X,ce=x&&p.length>0&&y?r.jsx(Ei,{accountId:y,currentMailboxId:e,candidates:p,onMove:a,children:Z}):Z;return r.jsx(eo,{title:M,unreadCount:I,preset:ye,selectedCategory:R,activeFilters:E,onSelectCategory:A,onToggleFilter:z,onClearFilters:_,searchResults:Ee,searchLoading:t,relatedResults:Y,relatedLoading:ie,onSelectSearchResult:te,searchResultsInBody:!0,refreshControl:Re,children:ce})}function Xi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,conversation:t,hasRemitDraftOpen:o,intelligenceOpen:i,onToggleIntelligence:c,toolbarComposeRequest:a,onToolbarReply:u,onToolbarReplyAll:d,onToolbarForward:f,onClearComposeRequest:g,onToolbarDelete:m,onToolbarStar:y,onToolbarDiscardDraft:C,onToolbarMove:I,composeState:T}=St(),x=Xs()?.showIntelligencePane??!1,p=!!t,k=x&&p,w=T.isOpen&&!t?r.jsx(bs,{}):t?r.jsx(us,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:t.authenticity?.dkimMismatch?c:void 0,composeRequest:a,onComposeClose:g}):r.jsx(nn,{});return r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Un,{hasThread:p,intelligenceOpen:k&&i,canToggleIntelligence:k,onToggleIntelligence:c,onReply:p?u:void 0,onReplyAll:p?d:void 0,onForward:p?f:void 0,canDelete:p||o,onDelete:p?m:o?C:void 0,onToggleStar:p?y:void 0,isStarred:s?.hasStars,moveContext:p&&n?{accountId:n,currentMailboxId:e,onMove:I}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]})}function Zi(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,onToggleIntelligence:t,handleDeselectIfRemoved:o}=St();return r.jsx(ds,{onClose:t,thread:s,mailboxId:e,accountId:n,onAfterOptimisticRemove:o})}function er(){const{mailboxId:e,mailboxAccountId:n,selectedThread:s,conversation:t,intelligenceOpen:o,onToggleIntelligence:i,onBack:c,nextMessageId:a,previousMessageId:u,composeState:d,handleDeselectIfRemoved:f}=St(),g=We();if(t){const m=y=>g({to:"/mail/$mailboxId",params:{mailboxId:e},search:C=>({...C,selectedMessageId:y,selectedThreadId:void 0})});return r.jsxs(r.Fragment,{children:[r.jsx(us,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:c,onOpenIntelligence:i,onSwipeNext:a?()=>m(a):void 0,onSwipePrevious:u?()=>m(u):void 0,mobileIntelligenceOpen:o}),r.jsx(Hn,{isOpen:o,onClose:i,ariaLabel:"Message details",side:"right",children:r.jsx(ds,{onClose:i,thread:s,mailboxId:e,accountId:n,hideCloseButton:!0,onAfterOptimisticRemove:f})})]})}return d.isOpen?r.jsx("div",{className:"h-full",children:r.jsx(bs,{})}):r.jsx(ws,{})}const Ir=Object.assign(Yi,{List:ws,Reading:Xi,Intelligence:Zi,Phone:er});export{Ir as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as n,j as a,B as o}from"./index-DjZFLwif.js";import{M as e}from"./menu-Cpsp0ZMZ.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{a as re,j as e,d as z,cb as V,l as oe,r as i,e as he,cq as I,cc as F,af as xe,aN as Q,c3 as fe,ca as ye,aK as K,az as Y,aS as ne,B as C,L as q,c9 as ge,cd as ve,N as D,cl as be,q as je}from"./index-xOALrEh8.js";import{K as Se}from"./kbd-C00o9L4B.js";import{c as we,M as ke}from"./account-form-helpers-BHUowns0.js";const X=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 $e({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 qe({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(X,{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 De({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}=K(ne()),w=Q({...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(q,{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(X,{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(D,{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(D,{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(X,{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(q,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(D,{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(D,{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=Q({...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 Ke({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=Q({...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}),$=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:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=K({...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}=K({...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(q,{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(q,{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($e,{onStart:h});case"connector":return e.jsx(qe,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(De,{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(Ke,{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,q as xe,ae as X,$ as fe,ai as ye,w as Q,aE as Y,W as ne,B as C,am as D,ah as ge,al as ve,az as q,aw as be,I as je}from"./index-DjZFLwif.js";import{K as we}from"./kbd-C0TyJDqO.js";import{c as Se,M as ke}from"./account-form-helpers-D3tfbITU.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 w=i.useId(),y=i.useId(),S=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:w,children:"Host"}),u?e.jsx(F,{id:w,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:w,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:S,children:"Security"}),c?e.jsx(J,{id:S,value:n,onValueChange:c}):e.jsx(J,{id:S,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(),w=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!w)return null;const S=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:S(v)},smtp:{host:j,port:Number.parseInt(w,10),security:S(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 $e({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(we,{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 De({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 w=i.useRef(new Set),{refetch:y}=Q(ne()),S=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=>!w.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||S.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}w.current=new Set(p.accounts.map(N=>N.accountId)),S.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(D,{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,w]=i.useState(""),[y,S]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){S("Enter a valid email address.");return}S(null),v(!0),w(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),S(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(D,{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),[w,y]=i.useState(()=>He(t)),[S,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(w),m=p!==void 0&&!S,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:w,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,w]=i.useState(null),y=t.split("@")[1]??"",S=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){w("Enter your username and password.");return}w(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),w(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),w(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:S})]})})}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,w]=i.useState(0),y=s.host.trim()!=="",S=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:S.tls,imapStartTls:S.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:()=>w(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:()=>w(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,w]=i.useState(null),y=i.useRef(!1),S=G(s.security),x=G(a.security),f=X({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{w(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=Se({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),$=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:S.tls,imapStartTls:S.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.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,w(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:S.tls,imapStartTls:S.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(D,{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(D,{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]),w=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}))},[]),S=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($e,{onStart:h});case"connector":return e.jsx(De,{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:w,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:S});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 S,e as w,am as k,j as e,b,bP as _,T as H,f as C,o as U,V as K,w as W,x as G,n as J,r as u,u as R,bH as I,bS as V,J as N,q as X,k as Y,ac as Z,bc as ee,ae as v,af as y,cc as se,bd as te}from"./index-DjZFLwif.js";import{u as ne,p as ae,R as p,f as oe}from"./useSearchTokenContext-D5dvdLSW.js";import{C as A}from"./circle-check-big-ChA18R4j.js";import{C as T}from"./clock-uuvA1em-.js";import{R as re}from"./row-actions-CN3rJN24.js";import{R as ie}from"./rotate-ccw-oQ2bjkRm.js";import{N as E}from"./NavMenuButton-3t-xq8p6.js";import{a as g,t as le}from"./format-De9HZKjg.js";import{i as ce,a as L}from"./outbox-status-CPfNHfUQ.js";import{n as de}from"./search-query-Cr_ZXBCp.js";const ue={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:k,label:"Sending…",className:"text-accent-2",spin:!0},sent:{icon:A,label:"Sent",className:"text-positive"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:S,label:"Blocked",className:"text-warning"}};function M({status:s,iconOnly:n,className:a}){const t=ue[s],o=t.icon;return e.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",t.className,a),children:[e.jsx(o,{className:b("size-4",t.spin&&"animate-spin")}),!n&&t.label]})}const xe=(s,n)=>n?"bg-accent-2-soft":s==="failed"?"bg-danger-soft":s==="blocked"?"bg-warning/10":"";function me({recipients:s,subject:n,time:a,status:t,error:o,selected:i,onSelect:c,onRetry:r,retrying:l,onEdit:x,onDelete:m,deleting:d}){const h=t==="failed"||t==="blocked";return e.jsxs("div",{className:b("flex items-start gap-3 border-b border-line px-4 py-3 transition-colors hover:bg-surface-raised",xe(t,i)),children:[e.jsxs("button",{type:"button",..._,onClick:c,className:"flex flex-1 min-w-0 items-start gap-3 text-left",children:[e.jsx("div",{className:"mt-0.5 shrink-0",children:e.jsx(M,{status:t,iconOnly:!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:s}),e.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:a})]}),e.jsx("div",{className:"truncate text-sm",children:n||"No subject"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(M,{status:t}),o&&e.jsxs("span",{className:"truncate text-xs text-fg-muted",children:["— ",o]})]})]})]}),h&&e.jsx("div",{className:"shrink-0",children:e.jsx(re,{actions:[...t==="failed"&&r?[{label:"Retry sending",iconOnly:!0,icon:e.jsx(ie,{className:"size-3.5"}),busy:l,onClick:r}]:[],{label:"Edit as draft",iconOnly:!0,icon:e.jsx(C,{className:"size-3.5"}),onClick:x}],destructive:{label:"Delete message",iconOnly:!0,icon:e.jsx(H,{className:"size-3.5"}),busy:d,confirm:{prompt:"Delete this message?",confirmLabel:"Delete"},onClick:m}})})]})}function fe(s,n){const a=n.trim().toLowerCase();if(a.length===0)return!0;const t=[s.subject,s.fromAddress,s.fromName,...s.toAddresses??[],...s.ccAddresses??[]].filter(o=>typeof o=="string").join(" ").toLowerCase();return a.split(/\s+/).every(o=>o.length===0||t.includes(o))}function he(s){return s.tokens.length>0&&s.freeText.trim().length===0}const Q={queued:{icon:T,label:"Queued",className:"text-warning"},sending:{icon:k,label:"Sending…",className:"text-accent-2"},sent:{icon:A,label:"Sent",className:"text-positive"},failed:{icon:w,label:"Failed",className:"text-danger"},blocked:{icon:S,label:"Blocked",className:"text-warning"}},be=s=>le(s).toDateString()===new Date().toDateString()?g(s,{hour:"numeric",minute:"2-digit"}):g(s,{month:"short",day:"numeric"}),O=s=>g(s,{dateStyle:"medium",timeStyle:"short"}),ge=s=>{const n=s.toAddresses??[];return n.length===0?"No recipients":n.length===1?n[0]:`${n[0]} +${n.length-1}`},D=(s,n)=>n?"The outbox cannot filter on those terms":s?"No matching outbox messages":"No outbox messages",P=u.createContext(null);function j(){const s=u.useContext(P);if(!s)throw new Error("OutboxPane.* must be used inside <OutboxPane>");return s}function pe({children:s}){const n=U(),{selectedOutboxMessageId:a}=K({strict:!1}),{data:t,isLoading:o}=W(G()),{searchQuery:i}=J(),c=ne(),r=de(i),l=ae(r,c),x=r.length>0,m=he(l),d=u.useMemo(()=>m?[]:(t?.items??[]).filter(f=>ce(f.status)).filter(f=>fe(f,l.freeText)),[t,l.freeText,m]),h=u.useMemo(()=>d.find(f=>f.outboxMessageId===a),[d,a]),F=u.useCallback(f=>{n({to:"/mail/outbox",search:q=>({...q,selectedOutboxMessageId:f})})},[n]),$={messages:d,hasQuery:x,unsupportedQuery:m,isLoading:o,selectedMessageId:a,selectedMessage:h,onSelectMessage:F};return e.jsx(P.Provider,{value:$,children:s})}function B({message:s,isSelected:n,onSelect:a}){const t=X(),{openCompose:o}=Y(),{pushError:i}=Z(),c=u.useCallback(()=>{t.invalidateQueries({queryKey:ee()})},[t]),r=v({...se(),onSuccess:c,onError:d=>{i(y("Couldn't resend message","The message wasn't sent.",d))}}),l=v({...te(),onSuccess:c,onError:d=>{i(y("Couldn't delete message","The message wasn't deleted.",d))}}),x=s.status;if(!Q[x])return null;const m=L(s.status);return e.jsx(me,{recipients:ge(s),subject:s.subject||"",time:be(s.sentAt??s.updatedAt),status:x,error:m?s.lastError??void 0:void 0,selected:n,onSelect:a,onRetry:x==="failed"?()=>r.mutate({path:{outboxMessageId:s.outboxMessageId}}):void 0,retrying:r.isPending,onEdit:()=>o({mode:"new",outboxMessageId:s.outboxMessageId}),onDelete:()=>l.mutate({path:{outboxMessageId:s.outboxMessageId}}),deleting:l.isPending})}function z({message:s,onBack:n}){const a=s.status,t=Q[a],o=t?.icon??C,i=s.sentAt?O(s.sentAt):O(s.updatedAt);return e.jsxs("div",{className:"h-full overflow-y-auto bg-canvas",children:[e.jsxs("div",{className:"border-b border-line p-4",children:[n&&e.jsxs("button",{type:"button",onClick:n,className:"mb-3 inline-flex items-center gap-1 text-sm text-fg-muted hover:text-fg",children:[e.jsx(V,{className:"size-4"}),e.jsx("span",{children:"Back"})]}),e.jsx("h1",{className:"text-xl font-semibold mb-3",children:s.subject||"(No subject)"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"From:"}),e.jsx("span",{className:"text-fg",children:s.fromName?`${s.fromName} <${s.fromAddress}>`:s.fromAddress})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"To:"}),e.jsx("span",{className:"text-fg",children:(s.toAddresses??[]).join(", ")})]}),s.ccAddresses&&s.ccAddresses.length>0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Cc:"}),e.jsx("span",{className:"text-fg",children:s.ccAddresses.join(", ")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-fg-muted shrink-0 w-12",children:"Date:"}),e.jsx("span",{className:"text-fg",children:i})]}),t&&e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx(o,{className:N("size-4",t.className,a==="sending"&&"animate-spin")}),e.jsx("span",{className:N("text-xs font-medium",t.className),children:t.label}),L(s.status)&&s.lastError&&e.jsxs("span",{className:"text-xs text-fg-muted",children:["— ",s.lastError]})]})]})]}),e.jsx("div",{className:"p-4",children:e.jsx(oe,{html:s.htmlBody,text:s.textBody})})]})}function je(){const{messages:s,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,onSelectMessage:i}=j(),c=u.useRef(null);return R({containerRef:c,itemSelector:I}),t?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:e.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):s.length===0?e.jsx("div",{className:"flex h-full bg-surface",children:e.jsx(p,{message:D(n,a),showHints:!1})}):e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx(E,{}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),e.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.length," ",s.length===1?"message":"messages"]})]}),e.jsx("div",{ref:c,className:"flex-1 overflow-y-auto",children:s.map(r=>e.jsx(B,{message:r,isSelected:o===r.outboxMessageId,onSelect:()=>i(r.outboxMessageId)},r.outboxMessageId))})]})}function Ne(){const{selectedMessage:s}=j();return e.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[e.jsx("header",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-3"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s?e.jsx(z,{message:s}):e.jsx(p,{message:"Select a message to read",showHints:!1})})]})}function ve(){const{messages:s,hasQuery:n,unsupportedQuery:a,isLoading:t,selectedMessageId:o,selectedMessage:i,onSelectMessage:c}=j(),r=u.useRef(null);return R({containerRef:r,itemSelector:I}),t?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas",children:e.jsx("span",{className:"text-fg-muted",children:"Loading..."})}):i?e.jsx(z,{message:i,onBack:()=>c(void 0)}):s.length===0?e.jsx("div",{className:"flex h-full bg-surface",children:e.jsx(p,{message:D(n,a),showHints:!1})}):e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx(E,{}),e.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:"Outbox"}),e.jsxs("span",{className:"shrink-0 text-2xs text-fg-subtle",children:[s.length," ",s.length===1?"message":"messages"]})]}),e.jsx("div",{ref:r,className:"flex-1 overflow-y-auto",children:s.map(l=>e.jsx(B,{message:l,isSelected:o===l.outboxMessageId,onSelect:()=>c(l.outboxMessageId)},l.outboxMessageId))})]})}const Te=Object.assign(pe,{List:je,Reading:Ne,Phone:ve});export{Te as O};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a1 as m,j as o,_ as p}from"./index-DjZFLwif.js";import{a as e}from"./search-view-ClRhrhjK.js";import{M as r}from"./MailboxPane-Db0hba1S.js";import{u as a}from"./useSearchMirror-HHNbELBF.js";import"./search-scope-CFN-gjTv.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./useRefreshControl-BsKYVbfM.js";import"./circle-check-big-ChA18R4j.js";import"./search-token-index-CxMDhXuP.js";import"./useMediaQuery-fUhUpE77.js";import"./MailListHeader-DX7_Cewa.js";import"./account-form-helpers-D3tfbITU.js";import"./avatar-DTwl3jb1.js";import"./useSignature-C6SBu3ql.js";import"./useDebouncedValue-BFCY668u.js";import"./ErrorState-CN4Cwb5A.js";import"./format-De9HZKjg.js";import"./download-B3EpkLuL.js";import"./shield-check-BG5lmiwu.js";import"./move-options-CdaX2x7F.js";import"./useFilters-CxQU6LTN.js";import"./confirm-dialog-BTyZAw5R.js";import"./clock-uuvA1em-.js";import"./menu-Cpsp0ZMZ.js";import"./MailViewChrome-9cKXCycT.js";import"./NavMenuButton-3t-xq8p6.js";import"./useLabels-DdQPlRo8.js";import"./conversation-target-B0jE-e47.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-Bw79dNtH.js";import"./circle-help-DPkDkgdF.js";import"./circle-check-DizPpF0Y.js";import"./intelligence-pref-C6lFpj6U.js";function H(){const{mailboxId:t}=m.useParams(),{selectedMessageId:i}=m.useSearch();return a({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,selectedMessageId:i,children:o.jsx(e,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{H as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as s}from"./index-DjZFLwif.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};
|