@remit/web-client-dist 0.0.225 → 0.0.226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/assets/{ComposeBody-Cg-na8KS.js → ComposeBody-DBD5jpce.js} +1 -1
  2. package/assets/{ConfirmDialog-DsUiFE7Y.js → ConfirmDialog-CZmny2o7.js} +1 -1
  3. package/assets/{ErrorState-Dr-9Au1e.js → ErrorState-B6fATjA2.js} +1 -1
  4. package/assets/{OnboardingWizard-C25NdvS5.js → OnboardingWizard-BIOsPq-M.js} +1 -1
  5. package/assets/{account-form-helpers-Dl30OlRp.js → account-form-helpers-D72QoZAl.js} +1 -1
  6. package/assets/{accounts-iJfN5a7o.js → accounts-B_a-kOqn.js} +1 -1
  7. package/assets/{advanced-4XN2OdsO.js → advanced-DazuYbkn.js} +1 -1
  8. package/assets/{appearance-2d1FOq4A.js → appearance-CDgeuRK6.js} +1 -1
  9. package/assets/{avatar-BOgiERKc.js → avatar-CS5srhkE.js} +1 -1
  10. package/assets/{browser-ponyfill-DEYiwZAO.js → browser-ponyfill-BYMbWBga.js} +1 -1
  11. package/assets/{circle-check-MVOFeD-X.js → circle-check-v8xMcFoC.js} +1 -1
  12. package/assets/{download-DIwYdanJ.js → download-DgX7tQ2a.js} +1 -1
  13. package/assets/{filters-BiLMCxSO.js → filters-5mu_Svib.js} +1 -1
  14. package/assets/{flagged-Bbk6xHtR.js → flagged-BbQfL5-E.js} +1 -1
  15. package/assets/folders-C7iV0sc2.js +1 -0
  16. package/assets/index-BpmIZEJh.js +1 -0
  17. package/assets/{index-DX8AgNk2.js → index-CcJzTGF0.js} +1 -1
  18. package/assets/{index-jP3dtoj2.css → index-NuovWRxN.css} +1 -1
  19. package/assets/{index-Cr3QcwUV.js → index-qeQMtEt6.js} +4 -4
  20. package/assets/{kbd-BO3rwTJZ.js → kbd-qXwWyMHG.js} +1 -1
  21. package/assets/{labels-My02t12G.js → labels-CvWNzUwo.js} +1 -1
  22. package/assets/{mail-DNsZgDeY.js → mail-C_3qPIdf.js} +8 -8
  23. package/assets/move-options-B5imAjXx.js +1 -0
  24. package/assets/move-targets-UEcZEj8v.js +1 -0
  25. package/assets/{onboarding-swoCqEIc.js → onboarding-BPUmP6ek.js} +1 -1
  26. package/assets/{senders-Cumki-AV.js → senders-Ch90XRRY.js} +1 -1
  27. package/assets/settings-BUiq7FCZ.js +1 -0
  28. package/assets/{settings-screen-B_DqAJKt.js → settings-screen-CnpUrnqJ.js} +1 -1
  29. package/assets/{shield-check-d7yEFfJW.js → shield-check-C0oDWT-P.js} +1 -1
  30. package/assets/{suggested-vips-C1ZNHBRW.js → suggested-vips-CkJNUBcR.js} +1 -1
  31. package/assets/{useDebouncedValue-T4D9mQTa.js → useDebouncedValue-DF38Ad-5.js} +1 -1
  32. package/assets/{useLabels-BINE1u9c.js → useLabels-5OMPJAr4.js} +1 -1
  33. package/assets/{useRulePreview-Dm899uC9.js → useRulePreview-DHSSGf4M.js} +1 -1
  34. package/assets/{useSignature-BPTcnt5u.js → useSignature-CzOAhZVc.js} +1 -1
  35. package/index.html +2 -2
  36. package/package.json +1 -1
  37. package/assets/folders-08-zfkKJ.js +0 -1
  38. package/assets/index-C-KqFI6f.js +0 -1
  39. package/assets/move-options-CTQ_XIr4.js +0 -1
  40. package/assets/move-targets-BB-EVDC1.js +0 -1
  41. package/assets/settings-BJSdSvuC.js +0 -1
@@ -1 +1 @@
1
- import{a6 as X,aA as Z,cg as ee,ch as te,r as f,j as t,ci as ae,cj as se,L as T,B as C,D as ie,d as ne,ck as re,i as oe,T as le,al as ce,ax as A,aI as de,c2 as me,c4 as ue,am as xe,aY as O}from"./index-Cr3QcwUV.js";import{S as pe}from"./settings-screen-B_DqAJKt.js";import{h as fe,N as S,p as he,c as ge,r as ve,d as be,S as D,i as je,n as ye,u as Ne,B as Ce,j as Se,k as Ie,l as Fe,m as we}from"./useRulePreview-Dm899uC9.js";import{u as Ee,b as Me}from"./move-targets-BB-EVDC1.js";import{a as Oe,u as De}from"./useLabels-BINE1u9c.js";import{C as M}from"./circle-check-MVOFeD-X.js";import{E as R}from"./ErrorState-Dr-9Au1e.js";import"./avatar-BOgiERKc.js";const ke=(e,a)=>{const n=X(),i=Z({...te(),onSuccess:()=>{e&&(n.invalidateQueries({queryKey:fe(e)}),a&&n.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:a}})}))}}),{mutate:l}=i;return{updateFilter:f.useCallback(p=>{!e||!a||l({path:{accountId:e,filterId:a},body:p})},[e,a,l]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Le=(e,a=!1)=>({clauses:e.literalClauses.map((i,l)=>({id:`clause-${l}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...a?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Te(e.expiresAt):void 0,name:e.name}),Te=e=>{if(!e)return"";const a=Date.parse(e);if(Number.isNaN(a))return"";const n=new Date(a),i=l=>String(l).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())}`},k=e=>JSON.stringify({clauses:e.clauses.map(a=>[a.field,a.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),P=(e,a)=>k(e)!==k(a),L=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),$=(e,a)=>L(e)!==L(a),Ae=(e,a)=>{const n={},i=(e.name??"").trim();return i!==(a.name??"").trim()&&(n.name=i),P(e,a)&&(n.matchOperator=e.matchOperator==="all"?"And":"Or",n.literalClauses=e.clauses.map(l=>({field:l.field,value:l.value})),n.actionMailboxId=e.moveMailboxId??S,n.actionLabelId=e.labelId??S),$(e,a)&&(n.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(n.expiresAt=he(e.until??""))),n};function Re({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l=!1,onClose:d}){const p=f.useMemo(()=>Le(a,l),[a,l]),[m,r]=f.useState(p),[c,u]=f.useState(),[h,g]=f.useState(!1),b=f.useRef(0),{count:N}=ge(e,ve(m)),v=ke(e,a.filterId),j=be(e),{createFolder:I}=Ee(e),{createLabel:x}=Oe(e),F=async o=>{const s=await x(o);return{id:s.labelId,name:s.name,color:s.color}},w=()=>u({mode:"add",draft:{field:D[0],value:""}}),z=o=>{const s=m.clauses.find(y=>y.id===o);s&&u({mode:"edit",clauseId:o,draft:{field:s.field,value:s.value}})},_=o=>u(s=>s&&{...s,draft:{...s.draft,field:o}}),B=o=>u(s=>s&&{...s,draft:{...s.draft,value:o}}),U=()=>{if(!c)return;const o=c.draft.field,s=ye(o,c.draft.value);s!==""&&(r(y=>c.mode==="edit"&&c.clauseId?{...y,clauses:y.clauses.map(E=>E.id===c.clauseId?{id:E.id,field:o,value:s}:E)}:(b.current+=1,{...y,clauses:[...y.clauses,{id:`new-${b.current}`,field:o,value:s}]})),u(void 0))},K=o=>r(s=>({...s,clauses:s.clauses.filter(y=>y.id!==o)})),Q=o=>r(s=>({...s,matchOperator:o})),G=o=>r(s=>({...s,moveMailboxId:o||void 0})),H=o=>r(s=>({...s,labelId:o||void 0})),J=o=>r(s=>({...s,name:o})),V=o=>r(s=>({...s,scope:o,until:o==="until"?s.until:void 0})),q=o=>r(s=>({...s,until:o})),Y=()=>{const o=P(m,p)||$(m,p),s=Ae(m,p);if(Object.keys(s).length===0){d();return}g(o),v.updateFilter(s)},W=()=>j.start(je(m));return j.isStarting||j.isRunning||j.isDone?t.jsx(_e,{progress:j.progress,isDone:j.isDone,onClose:d}):v.isPending?t.jsx(Pe,{}):v.isError?t.jsx(Be,{onRetry:v.reset,onClose:d}):v.isSuccess?h?t.jsx(ze,{preview:ae(N),blocked:N.status!=="ready"||N.stale===!0,onReapply:W,onClose:d}):t.jsx($e,{onClose:d}):t.jsx(se,{rule:m,folders:n,labels:i,preview:N,semanticAvailable:!1,clauseFields:D,anchorLocked:!0,clauseEdit:c,onStartAddClause:w,onStartEditClause:z,onRemoveClause:K,onChangeDraftField:_,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:Q,onChangeMove:G,onCreateFolder:I,onChangeLabel:H,onCreateLabel:F,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:Y,onCancel:d})}function Pe(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(T,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function $e({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(C,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function ze({preview:e,blocked:a,onReapply:n,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:n,disabled:a,children:"Move existing mail"}),t.jsx(C,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function _e({progress:e,isDone:a,onClose:n}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[a?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(M,{className:"size-8 text-positive"}):t.jsx(T,{className:"size-8 animate-spin text-accent-2"}),!a&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),a&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),a&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),a&&t.jsx(C,{variant:"primary",onClick:n,className:"mt-2",children:"Done"})]})}function Be({onRetry:e,onClose:a}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(C,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function Ue({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d}){const p=Ne(),m=t.jsx(Re,{accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d});return p?t.jsx(ie,{open:!0,onClose:d,title:"Filter rule",children:m}):t.jsx(Ce,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:m})}function Ke({filters:e,mailboxName:a,labelById:n,onEdit:i,onDelete:l,deletingFilterId:d,semanticUnavailable:p=!1,now:m=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(r=>{const c=Se(r,m),u=c==="Expired",h=r.actionMailboxId!==S?a(r.actionMailboxId):void 0,g=r.actionLabelId!==S?n.get(r.actionLabelId):void 0,b=Ie(r.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(r.filterId),"aria-label":`Edit filter ${r.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${u?"text-fg-muted":"text-fg"}`,children:r.name}),t.jsx(ne,{tone:u?"neutral":"positive",dot:!0,children:c})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[h?`Moves matches to ${h}`:"No move action",r.scope==="Temporary"&&b?u?` · expired ${b}`:` · until ${b}`:r.scope==="Standing"?" · always":""]}),(r.hasAnchor||g)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[r.hasAnchor&&t.jsx(re,{widen:{anchorCount:1,...p?{inactive:!0}:{}}}),g&&t.jsx(oe,{label:{labelId:g.id,name:g.name,color:g.color}})]})]}),t.jsx(C,{variant:"ghost",size:"sm",icon:t.jsx(le,{className:"size-4 text-danger"}),onClick:()=>l(r.filterId),disabled:d===r.filterId,"aria-label":`Delete filter ${r.name}`})]},r.filterId)})})}const Qe=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function Ge({account:e}){const a=e.accountId,{filters:n,isPending:i,isError:l,error:d,refetch:p}=Fe(a),{deleteFilter:m,deletingFilterId:r}=we(a),[c,u]=f.useState(),{data:h}=A({...xe({path:{accountId:a}}),staleTime:1/0}),g=f.useCallback(x=>{const F=h?.items.find(w=>w.mailboxId===x);return F?O(F.fullPath):void 0},[h?.items]),b=f.useMemo(()=>Me(h?.items??[]).map(x=>({id:x.mailboxId,label:O(x.fullPath)})),[h?.items]),{labels:N}=De(a),v=f.useMemo(()=>N.map(x=>({id:x.labelId,name:x.name,color:x.color})),[N]),j=f.useMemo(()=>new Map(v.map(x=>[x.id,x])),[v]),I=n.find(x=>x.filterId===c);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Ue,{accountId:a,filter:I,folders:b,labels:v,onClose:()=>u(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):l?t.jsx(R,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:d,onRetry:()=>{p()}}):t.jsx(Ke,{filters:n,mailboxName:g,labelById:j,onEdit:u,onDelete:m,deletingFilterId:r})]})}function et(){const e=ce(),[a,n]=f.useState(!0),{data:i,isPending:l,isError:d,error:p,refetch:m}=A(de()),r=c=>{const u=ue[c];u&&e({to:u})};return t.jsx(pe,{items:me,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Qe,helpOpen:a,onToggleHelp:()=>n(c=>!c),onSelect:r,onBackToMail:()=>{e({to:"/mail"})},children:l?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):d?t.jsx(R,{title:"Couldn't load accounts",error:p,onRetry:()=>{m()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(c=>t.jsx(Ge,{account:c},c.accountId))})})}export{et as component};
1
+ import{a6 as X,aA as Z,cg as ee,ch as te,r as f,j as t,ci as ae,cj as se,L as T,B as C,D as ie,d as ne,ck as re,i as oe,T as le,al as ce,ax as A,aI as de,c2 as me,c4 as ue,am as xe,aY as O}from"./index-qeQMtEt6.js";import{S as pe}from"./settings-screen-CnpUrnqJ.js";import{h as fe,N as S,p as he,c as ge,r as ve,d as be,S as D,i as je,n as ye,u as Ne,B as Ce,j as Se,k as Ie,l as Fe,m as we}from"./useRulePreview-DHSSGf4M.js";import{u as Ee,b as Me}from"./move-targets-UEcZEj8v.js";import{a as Oe,u as De}from"./useLabels-5OMPJAr4.js";import{C as M}from"./circle-check-v8xMcFoC.js";import{E as R}from"./ErrorState-B6fATjA2.js";import"./avatar-CS5srhkE.js";const ke=(e,a)=>{const n=X(),i=Z({...te(),onSuccess:()=>{e&&(n.invalidateQueries({queryKey:fe(e)}),a&&n.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:a}})}))}}),{mutate:l}=i;return{updateFilter:f.useCallback(p=>{!e||!a||l({path:{accountId:e,filterId:a},body:p})},[e,a,l]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Le=(e,a=!1)=>({clauses:e.literalClauses.map((i,l)=>({id:`clause-${l}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...a?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?Te(e.expiresAt):void 0,name:e.name}),Te=e=>{if(!e)return"";const a=Date.parse(e);if(Number.isNaN(a))return"";const n=new Date(a),i=l=>String(l).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())}`},k=e=>JSON.stringify({clauses:e.clauses.map(a=>[a.field,a.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),P=(e,a)=>k(e)!==k(a),L=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),$=(e,a)=>L(e)!==L(a),Ae=(e,a)=>{const n={},i=(e.name??"").trim();return i!==(a.name??"").trim()&&(n.name=i),P(e,a)&&(n.matchOperator=e.matchOperator==="all"?"And":"Or",n.literalClauses=e.clauses.map(l=>({field:l.field,value:l.value})),n.actionMailboxId=e.moveMailboxId??S,n.actionLabelId=e.labelId??S),$(e,a)&&(n.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(n.expiresAt=he(e.until??""))),n};function Re({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l=!1,onClose:d}){const p=f.useMemo(()=>Le(a,l),[a,l]),[m,r]=f.useState(p),[c,u]=f.useState(),[h,g]=f.useState(!1),b=f.useRef(0),{count:N}=ge(e,ve(m)),v=ke(e,a.filterId),j=be(e),{createFolder:I}=Ee(e),{createLabel:x}=Oe(e),F=async o=>{const s=await x(o);return{id:s.labelId,name:s.name,color:s.color}},w=()=>u({mode:"add",draft:{field:D[0],value:""}}),z=o=>{const s=m.clauses.find(y=>y.id===o);s&&u({mode:"edit",clauseId:o,draft:{field:s.field,value:s.value}})},_=o=>u(s=>s&&{...s,draft:{...s.draft,field:o}}),B=o=>u(s=>s&&{...s,draft:{...s.draft,value:o}}),U=()=>{if(!c)return;const o=c.draft.field,s=ye(o,c.draft.value);s!==""&&(r(y=>c.mode==="edit"&&c.clauseId?{...y,clauses:y.clauses.map(E=>E.id===c.clauseId?{id:E.id,field:o,value:s}:E)}:(b.current+=1,{...y,clauses:[...y.clauses,{id:`new-${b.current}`,field:o,value:s}]})),u(void 0))},K=o=>r(s=>({...s,clauses:s.clauses.filter(y=>y.id!==o)})),Q=o=>r(s=>({...s,matchOperator:o})),G=o=>r(s=>({...s,moveMailboxId:o||void 0})),H=o=>r(s=>({...s,labelId:o||void 0})),J=o=>r(s=>({...s,name:o})),V=o=>r(s=>({...s,scope:o,until:o==="until"?s.until:void 0})),q=o=>r(s=>({...s,until:o})),Y=()=>{const o=P(m,p)||$(m,p),s=Ae(m,p);if(Object.keys(s).length===0){d();return}g(o),v.updateFilter(s)},W=()=>j.start(je(m));return j.isStarting||j.isRunning||j.isDone?t.jsx(_e,{progress:j.progress,isDone:j.isDone,onClose:d}):v.isPending?t.jsx(Pe,{}):v.isError?t.jsx(Be,{onRetry:v.reset,onClose:d}):v.isSuccess?h?t.jsx(ze,{preview:ae(N),blocked:N.status!=="ready"||N.stale===!0,onReapply:W,onClose:d}):t.jsx($e,{onClose:d}):t.jsx(se,{rule:m,folders:n,labels:i,preview:N,semanticAvailable:!1,clauseFields:D,anchorLocked:!0,clauseEdit:c,onStartAddClause:w,onStartEditClause:z,onRemoveClause:K,onChangeDraftField:_,onChangeDraftValue:B,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:Q,onChangeMove:G,onCreateFolder:I,onChangeLabel:H,onCreateLabel:F,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:Y,onCancel:d})}function Pe(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(T,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function $e({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(C,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function ze({preview:e,blocked:a,onReapply:n,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(M,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:n,disabled:a,children:"Move existing mail"}),t.jsx(C,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function _e({progress:e,isDone:a,onClose:n}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[a?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(M,{className:"size-8 text-positive"}):t.jsx(T,{className:"size-8 animate-spin text-accent-2"}),!a&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),a&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),a&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),a&&t.jsx(C,{variant:"primary",onClick:n,className:"mt-2",children:"Done"})]})}function Be({onRetry:e,onClose:a}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(C,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(C,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function Ue({accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d}){const p=Ne(),m=t.jsx(Re,{accountId:e,filter:a,folders:n,labels:i,semanticUnavailable:l,onClose:d});return p?t.jsx(ie,{open:!0,onClose:d,title:"Filter rule",children:m}):t.jsx(Ce,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:m})}function Ke({filters:e,mailboxName:a,labelById:n,onEdit:i,onDelete:l,deletingFilterId:d,semanticUnavailable:p=!1,now:m=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(r=>{const c=Se(r,m),u=c==="Expired",h=r.actionMailboxId!==S?a(r.actionMailboxId):void 0,g=r.actionLabelId!==S?n.get(r.actionLabelId):void 0,b=Ie(r.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(r.filterId),"aria-label":`Edit filter ${r.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${u?"text-fg-muted":"text-fg"}`,children:r.name}),t.jsx(ne,{tone:u?"neutral":"positive",dot:!0,children:c})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[h?`Moves matches to ${h}`:"No move action",r.scope==="Temporary"&&b?u?` · expired ${b}`:` · until ${b}`:r.scope==="Standing"?" · always":""]}),(r.hasAnchor||g)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[r.hasAnchor&&t.jsx(re,{widen:{anchorCount:1,...p?{inactive:!0}:{}}}),g&&t.jsx(oe,{label:{labelId:g.id,name:g.name,color:g.color}})]})]}),t.jsx(C,{variant:"ghost",size:"sm",icon:t.jsx(le,{className:"size-4 text-danger"}),onClick:()=>l(r.filterId),disabled:d===r.filterId,"aria-label":`Delete filter ${r.name}`})]},r.filterId)})})}const Qe=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function Ge({account:e}){const a=e.accountId,{filters:n,isPending:i,isError:l,error:d,refetch:p}=Fe(a),{deleteFilter:m,deletingFilterId:r}=we(a),[c,u]=f.useState(),{data:h}=A({...xe({path:{accountId:a}}),staleTime:1/0}),g=f.useCallback(x=>{const F=h?.items.find(w=>w.mailboxId===x);return F?O(F.fullPath):void 0},[h?.items]),b=f.useMemo(()=>Me(h?.items??[]).map(x=>({id:x.mailboxId,label:O(x.fullPath)})),[h?.items]),{labels:N}=De(a),v=f.useMemo(()=>N.map(x=>({id:x.labelId,name:x.name,color:x.color})),[N]),j=f.useMemo(()=>new Map(v.map(x=>[x.id,x])),[v]),I=n.find(x=>x.filterId===c);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Ue,{accountId:a,filter:I,folders:b,labels:v,onClose:()=>u(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):l?t.jsx(R,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:d,onRetry:()=>{p()}}):t.jsx(Ke,{filters:n,mailboxName:g,labelById:j,onEdit:u,onDelete:m,deletingFilterId:r})]})}function et(){const e=ce(),[a,n]=f.useState(!0),{data:i,isPending:l,isError:d,error:p,refetch:m}=A(de()),r=c=>{const u=ue[c];u&&e({to:u})};return t.jsx(pe,{items:me,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Qe,helpOpen:a,onToggleHelp:()=>n(c=>!c),onSelect:r,onBackToMail:()=>{e({to:"/mail"})},children:l?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):d?t.jsx(R,{title:"Couldn't load accounts",error:p,onRetry:()=>{m()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(c=>t.jsx(Ge,{account:c},c.accountId))})})}export{et as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-Cr3QcwUV.js";import{E as o}from"./ErrorState-Dr-9Au1e.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
1
+ import{j as r}from"./index-qeQMtEt6.js";import{E as o}from"./ErrorState-B6fATjA2.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
@@ -0,0 +1 @@
1
+ import{a as _e,j as e,B as M,T as Q,b as q,k as de,r as u,c5 as ue,bT as G,cs as qe,t as Be,D as me,X as fe,ct as he,cu as Ke,bS as Qe,cv as He,a6 as xe,aT as pe,bN as be,cw as Ge,cx as Ve,bf as We,bC as ge,au as H,an as ve,L as re,l as je,F as Ye,J as Xe,al as Ze,ax as Ne,aI as Je,c2 as Ue,c4 as et,am as tt,aA as ne,cy as st,cz as at,cA as rt,cB as nt}from"./index-qeQMtEt6.js";import{P as ot,C as lt,F as ye,a as it,f as K,c as ct,M as dt,i as oe,u as ke,b as ut,m as le,g as mt}from"./move-options-B5imAjXx.js";import{S as ft}from"./settings-screen-CnpUrnqJ.js";import{u as we}from"./move-targets-UEcZEj8v.js";import{E as Ce}from"./ErrorState-B6fATjA2.js";import"./avatar-CS5srhkE.js";const ht=_e("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),xt=({label:t,onRename:s,onDelete:a,deleteBlockedReason:n,renameLabel:i=l=>`Rename ${l}`,deleteLabel:r=l=>`Delete ${l}`})=>{const l=n?`${r(t)} — ${n}`:r(t);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(M,{variant:"ghost",size:"sm",icon:e.jsx(ot,{className:"size-3.5"}),"aria-label":i(t),onClick:s}),e.jsx("span",{title:n,children:e.jsx(M,{variant:"ghost",size:"sm",icon:e.jsx(Q,{className:"size-3.5"}),"aria-label":l,disabled:n!==void 0,onClick:a})})]})},B=(t,s)=>{const a=t.lastIndexOf(s);return a===-1?"":t.slice(0,a)},Se=(t,s)=>t.split(s).length-1,V=(t,s)=>{const a=[];let n=B(t,s);for(;n;)a.push(n),n=B(n,s);return a},pt=(t,s)=>{const a=new Set(t.map(l=>l.path)),n=new Set,i=[],r=l=>{if(!n.has(l.path)){n.add(l.path),i.push(l);for(const c of t)B(c.path,s)===l.path&&r(c)}};for(const l of t){const c=B(l.path,s);c&&a.has(c)||r(l)}return i},De=(t,s)=>t.label.toLowerCase().includes(s)||t.path.toLowerCase().includes(s),bt=(t,s,a)=>{const n=new Set;if(!s)return n;for(const i of t)if(De(i,s))for(const r of V(i.path,a))n.add(r);return n},gt=(t,s,a,n=new Set)=>{const i=(c,o)=>({folder:c,depth:Se(c.path,a),context:o,expanded:n.has(c.path)});if(!s)return t.map(c=>i(c,!1));const r=new Set;for(const c of t)De(c,s)&&r.add(c.path);const l=new Set(r);for(const c of r)for(const o of V(c,a))l.add(o);return t.filter(c=>l.has(c.path)).map(c=>i(c,!r.has(c.path)))},vt=(t,s,a)=>{const n=new Set(t.map(i=>i.path));return t.filter(i=>V(i.path,a).every(r=>!n.has(r)||s.has(r))).map(i=>({folder:i,depth:Se(i.path,a),context:!1,expanded:s.has(i.path)}))},jt=(t,s)=>{const a=[],n=[],i=r=>{for(;n.length>0;){const l=n[n.length-1];if(!l||r?.startsWith(`${l.folder.path}${s}`))break;n.pop(),a.push({kind:"create",parent:l.folder,depth:l.depth+1})}};return t.forEach((r,l)=>{i(r.folder.path),a.push({kind:"folder",row:r,index:l}),r.expanded&&n.push(r)}),i(null),a},z=t=>t!==void 0&&!t.context,Y=t=>t!==void 0&&!t.folder.isCurrent&&!t.context,X=t=>{for(let s=0;s<t.length;s+=1)if(z(t[s]))return s;return-1},Nt=t=>{for(let s=t.length-1;s>=0;s-=1)if(z(t[s]))return s;return-1},ie=(t,s,a)=>{const n=t.length;if(n<=0)return-1;const i=s<0?a===1?-1:n:s;for(let r=1;r<=n;r+=1){const l=((i+a*r)%n+n)%n;if(z(t[l]))return l}return-1},yt=(t,s,a)=>{const n=t[s];if(!n)return-1;const i=B(n.folder.path,a);if(!i)return-1;for(let r=s-1;r>=0;r-=1)if(t[r]?.folder.path===i)return z(t[r])?r:-1;return-1},U="flex min-h-11 min-w-0 flex-1 items-center gap-2 px-3 py-2.5 text-left text-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Me=14,kt=60,ee=({depth:t})=>t>0?e.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:t*Me}}):null,te=({depth:t})=>e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute right-0 bottom-0 h-px bg-line",style:{left:kt+t*Me}}),wt=({label:t,depth:s,expanded:a,ariaLabel:n,selected:i=!1,context:r=!1,current:l=!1,currentTag:c,separated:o=!1,actions:f,tabIndex:p,onActivate:h,onFocus:k,ref:w})=>{const R=e.jsx(lt,{className:q("size-4 shrink-0 text-fg-subtle transition-transform",a&&"rotate-90"),"aria-hidden":"true"}),C=e.jsx(ye,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":"true"});return r?e.jsxs("div",{className:"relative flex items-center",children:[e.jsxs("div",{role:"treeitem","aria-level":s+1,"aria-selected":!1,"aria-expanded":a,"aria-label":n,className:q(U,"opacity-60"),children:[e.jsx(ee,{depth:s}),R,C,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),f,o&&e.jsx(te,{depth:s})]}):e.jsxs("div",{className:"relative flex items-center",children:[e.jsxs("button",{ref:w,type:"button",role:"treeitem","aria-level":s+1,"aria-selected":i,"aria-expanded":a,"aria-current":l?"true":void 0,"aria-label":n,tabIndex:p,onClick:h,onFocus:k,className:q(U,"hover:bg-surface-raised active:bg-surface-sunken",l&&"text-fg-muted"),children:[e.jsx(ee,{depth:s}),R,C,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),l&&c&&e.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:c}),i&&e.jsx(de,{className:"size-4 shrink-0 text-accent","aria-hidden":"true"})]}),f,o&&e.jsx(te,{depth:s})]})},ce=({label:t,ariaLabel:s,depth:a=0,prominence:n="prominent",separated:i=!1,onOpen:r})=>e.jsxs("div",{className:q("relative",n==="prominent"&&"p-2"),children:[e.jsxs("button",{type:"button",onClick:r,"aria-label":s,"data-prominence":n,className:q(U,"w-full active:bg-surface-sunken",n==="prominent"?"rounded-lg border border-line-strong border-dashed font-medium text-fg-muted hover:border-accent-2 hover:text-accent-2":"text-fg-subtle hover:bg-surface-raised hover:text-fg-muted"),children:[e.jsx(ee,{depth:a}),e.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}),e.jsx(ht,{className:"size-4 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t})]}),i&&e.jsx(te,{depth:a})]}),Ee={nameLabel:"Folder name",namePlaceholder:"Hotels",insideLabel:"Inside",create:"Create folder",cancel:"Cancel",createPending:"Creating folder…"},Ct=({parentLabel:t,name:s,onNameChange:a,onSubmit:n,onCancel:i,pending:r=!1,error:l,labels:c})=>{const o={...Ee,...c},f=u.useId(),p=u.useRef(null),h=u.useRef(null);return u.useEffect(()=>{p.current?.focus({preventScroll:!0}),h.current?.scrollIntoView({block:"nearest"})},[]),e.jsxs("div",{ref:h,className:"space-y-3 border-y border-line bg-surface-sunken px-3 py-3",children:[e.jsxs("div",{children:[e.jsx(ue,{htmlFor:f,children:o.nameLabel}),e.jsx(G,{id:f,ref:p,value:s,placeholder:o.namePlaceholder,onChange:k=>a(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),n()),k.key==="Escape"&&(k.preventDefault(),i())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:[o.insideLabel," ",e.jsx("span",{className:"font-medium text-fg",children:t})]}),l&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:l}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{variant:"ghost",size:"md",onClick:i,className:"min-h-11 shrink-0",children:o.cancel}),e.jsx(M,{variant:"secondary",size:"md",onClick:n,disabled:r,className:"min-h-11 shrink-0",children:r?o.createPending:o.create})]})]})},St={...Ee,filterPlaceholder:"Filter folders…",filterAriaLabel:"Filter folders",treeAriaLabel:"Destination folders",currentSuffix:"(current folder)",currentTag:"current",contextSuffix:"(containing folder)",emptyMessage:t=>`No folders match "${t}"`,optionLabel:t=>`Move to ${t}`,newFolder:"New folder",newSubfolder:t=>`New folder inside ${t}`,topLevel:"Top level",nameRequired:"Give the folder a name.",createError:"Couldn't create that folder. Please try again."},Ie=({folders:t,selectedId:s,onSelect:a,rowActions:n,onCreateFolder:i,onCancel:r,delimiter:l="/",labels:c})=>{const o={...St,...c},[f,p]=u.useState(""),[h,k]=u.useState(new Set),[w,R]=u.useState(null),[C,O]=u.useState(""),[S,v]=u.useState(),[j,E]=u.useState(!1),[x,A]=u.useState(-1),y=u.useRef([]),D=u.useRef(!1),L=u.useRef(null);u.useEffect(()=>()=>L.current?.abort(),[]);const F=f.trim().toLowerCase(),I=u.useMemo(()=>pt(t,l),[t,l]),$=u.useMemo(()=>{const d=bt(I,F,l);return d.size===0?h:new Set([...h,...d])},[I,h,F,l]),m=u.useMemo(()=>F?gt(I,F,l,$):vt(I,$,l),[I,F,l,$]),P=u.useMemo(()=>i?jt(m,l):void 0,[m,l,i]);u.useEffect(()=>{A(d=>z(m[d])?d:X(m))},[m]),u.useEffect(()=>{D.current&&(D.current=!1,!(x<0)&&y.current[x]?.focus())},[x]);const T=u.useCallback((d,g)=>{k(N=>{if(g)return new Set([...V(d,l),d]);const b=new Set(N);return b.delete(d),b})},[l]),W=u.useCallback(d=>{Y(d)&&a?.(d.folder.id),T(d.folder.path,!d.expanded)},[a,T]),Le=u.useCallback(()=>{L.current?.abort(),R(null),O(""),v(void 0),E(!1)},[]),se=u.useCallback(d=>{L.current?.abort(),R({anchorId:d?.id??null,parentPath:d?.path??"",parentLabel:d?.label??o.topLevel}),O(""),v(void 0),E(!1)},[o.topLevel]),Fe=u.useCallback(()=>{if(!i||!w||j)return;const d=C.trim();if(d===""){v(o.nameRequired);return}E(!0),v(void 0),L.current?.abort();const g=new AbortController;L.current=g;const N=w.parentPath;i(d,N,g.signal).then(b=>{E(!1),R(null),O(""),N&&T(N,!0),a?.(b.id)}).catch(b=>{qe(b)||(v(b instanceof Error?b.message:o.createError),E(!1))})},[i,w,j,C,a,T,o.nameRequired,o.createError]),Re=u.useCallback(d=>{const g=b=>{d.preventDefault(),D.current=!0,A(b)},N=m[x];switch(d.key){case"ArrowDown":return g(ie(m,x,1));case"ArrowUp":return g(ie(m,x,-1));case"Home":return g(X(m));case"End":return g(Nt(m));case"ArrowRight":{if(!z(N)||!N)return;if(d.preventDefault(),!N.expanded){T(N.folder.path,!0);return}const b=x+1;z(m[b])&&g(b);return}case"ArrowLeft":{if(!z(N)||!N)return;if(d.preventDefault(),N.expanded){T(N.folder.path,!1);return}const b=yt(m,x,l);b>=0&&g(b);return}case"Enter":case" ":{if(!z(N)||!N)return;d.preventDefault(),W(N);return}case"Escape":d.preventDefault(),r?.();return;default:return}},[m,x,l,W,T,r]),ae=w&&e.jsx(Ct,{parentLabel:w.parentLabel,name:C,onNameChange:d=>{O(d),v(void 0)},onSubmit:Fe,onCancel:Le,pending:j,error:S,labels:o}),Oe=d=>d.context?`${d.folder.label} ${o.contextSuffix}`:Y(d)?o.optionLabel(d.folder.label):`${d.folder.label} ${o.currentSuffix}`,Pe=(d,g,N)=>{const{folder:b,depth:Te}=d,ze=Y(d);return e.jsx(wt,{ref:$e=>{y.current[g]=$e},label:b.label,depth:Te,expanded:d.expanded,context:d.context,current:b.isCurrent,currentTag:o.currentTag,selected:ze&&b.id===s,separated:N,actions:n?.(b),ariaLabel:Oe(d),tabIndex:g===x?0:-1,onActivate:()=>W(d),onFocus:()=>A(g)})};return e.jsxs("div",{className:"flex min-h-0 w-full min-w-0 flex-col",children:[e.jsx(G,{variant:"inline",className:"border-b border-line px-3 py-2",icon:e.jsx(Be,{className:"size-4","aria-hidden":"true"}),type:"search",value:f,onChange:d=>p(d.target.value),onKeyDown:d=>{if(d.key==="Escape"){d.preventDefault(),r?.();return}if(d.key!=="ArrowDown")return;d.preventDefault();const g=z(m[x])?x:X(m);g<0||(D.current=!0,A(g),y.current[g]?.focus())},placeholder:o.filterPlaceholder,"aria-label":o.filterAriaLabel}),i&&e.jsx("div",{className:"shrink-0 border-b border-line","data-create-anchor":"top",children:w?.anchorId===null?ae:e.jsx(ce,{label:o.newFolder,ariaLabel:o.newFolder,prominence:"prominent",onOpen:()=>se(null)})}),m.length===0?e.jsx("p",{className:"px-3 py-3 text-sm text-fg-muted","aria-live":"polite",children:o.emptyMessage(f)}):e.jsx("div",{role:"tree","aria-label":o.treeAriaLabel,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden pb-24",onKeyDown:Re,children:(P??m.map((d,g)=>({kind:"folder",row:d,index:g}))).map((d,g,N)=>{const b=g<N.length-1;return d.kind==="create"?e.jsx("div",{role:"none","data-create-anchor":d.parent.id,children:w?.anchorId===d.parent.id?ae:e.jsx(ce,{label:o.newFolder,ariaLabel:o.newSubfolder(d.parent.label),depth:d.depth,prominence:"quiet",separated:b,onOpen:()=>se(d.parent)})},`new:${d.parent.id}`):e.jsx("div",{role:"none",children:Pe(d.row,d.index,b)},d.row.folder.id)})})]})},Dt=({folders:t,onRename:s,onDelete:a,onCreateFolder:n,delimiter:i,labels:r})=>{const l=new Map(t.map(c=>[c.id,c]));return e.jsx(Ie,{folders:t,onCreateFolder:n,delimiter:i,labels:{treeAriaLabel:"Your folders",optionLabel:c=>c,...r},rowActions:c=>{const o=l.get(c.id);return o?e.jsx(xt,{label:o.label,deleteBlockedReason:o.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>s(o),onDelete:()=>a(o)}):null}})},Mt=({open:t,folderLabel:s,defaultLabel:a,name:n,onNameChange:i,onSubmit:r,onClose:l,pending:c=!1,error:o})=>{const f=u.useId(),p=`Rename ${s}`;return t?e.jsxs(me,{open:t,onClose:l,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(M,{variant:"ghost",size:"sm",icon:e.jsx(fe,{className:"size-3.5"}),onClick:l,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(ue,{htmlFor:f,children:"Folder name"}),e.jsx(G,{id:f,value:n,placeholder:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),o&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:o})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(M,{variant:"secondary",size:"sm",onClick:l,children:"Cancel"}),e.jsx(M,{variant:"primary",size:"sm",onClick:r,disabled:c,children:c?"Saving…":"Save name"})]})]}):null},Et=["inbox","drafts","sent","archive","junk","trash"],Z="";function It(t){const s=t.messageCount===1?"msg":"msgs";return`${he(t.providerPath)} · ${t.messageCount} ${s}`}function At({role:t,folders:s,appointedId:a,displayName:n,onAppoint:i,onRename:r}){const[l,c]=u.useState(n),o=s.find(h=>h.mailboxId===a)??null,f=He(t),p=o!=null&&l.trim()!==n.trim();return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[Ke(t),f]}),e.jsxs(Qe,{className:"w-56 shrink-0",value:a??Z,"aria-label":`Folder for ${f}`,onChange:h=>i(t,h.target.value===Z?null:h.target.value),children:[e.jsx("option",{value:Z,children:"None"}),s.map(h=>e.jsx("option",{value:h.mailboxId,children:It(h)},h.mailboxId))]}),o&&e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"flex-1",value:l,placeholder:f,"aria-label":`Display name for ${f}`,onChange:h=>c(h.target.value)}),p&&e.jsx(M,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(de,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(o.mailboxId,l)})]})]}),o&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:o.providerPath,children:[o.providerPath," · ",o.messageCount," ",o.messageCount===1?"message":"messages"]})]})}function Lt({accountEmail:t,folders:s,appointments:a,displayNames:n={},onAppoint:i,onRename:r}){const l=new Set(Object.values(a).filter(o=>o!=null)),c=s.filter(o=>!l.has(o.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",t]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each role points to one folder. Pick the folder that holds the mail — the counts help you tell real folders from empty look-alikes. Appointing a folder here removes it from any other role."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Et.map(o=>{const f=a[o]??null;return e.jsx(At,{role:o,folders:s,appointedId:f,displayName:f?n[f]??"":"",onAppoint:i,onRename:r},o)})}),c.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:c.map(o=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(ye,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:he(o.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[o.messageCount," ",o.messageCount===1?"message":"messages"]})]},o.mailboxId))})]})]})}const Ae=50,Ft=t=>t instanceof Error?t.message:"Something went wrong.",_=t=>t.then(s=>({ok:!0,value:s}),s=>({ok:!1,error:Ft(s)})),Rt=async(t,s,a,n)=>{const i=[];let r;for(let l=0;l<Ae;l+=1){if(n.aborted)return i;const{data:c}=await ge({path:{mailboxId:t},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const o of c.items)if(!o.isDeleted&&!s.has(o.messageId)&&!i.includes(o.messageId)&&(i.push(o.messageId),i.length>=a))return i;if(!c.continuationToken)break;r=c.continuationToken}return i},Ot=async(t,s)=>{let a=0,n;for(let i=0;i<Ae;i+=1){if(s.aborted)return a;const{data:r}=await ge({path:{mailboxId:t},query:{order:"desc",continuationToken:n},throwOnError:!0});for(const l of r.items)l.isDeleted||(a+=1);if(!r.continuationToken)break;n=r.continuationToken}return a};function Pt({accountId:t,mailboxId:s,onDeleted:a}){const n=xe(),[i,r]=u.useState("idle"),[l,c]=u.useState(null),[o,f]=u.useState(),p=u.useRef(null),h=u.useCallback(()=>{n.invalidateQueries({queryKey:pe({path:{accountId:t}})}),n.invalidateQueries({queryKey:be()})},[n,t]),k=u.useCallback(async()=>{r("deleting");const S=await _(Ge({path:{accountId:t,mailboxId:s},throwOnError:!0}));if(!S.ok){f(S.error),r("error");return}h(),r("done"),a()},[t,s,h,a]),w=u.useCallback(()=>Ve({path:{accountId:t},throwOnError:!0}).then(({data:S})=>S.items.find(v=>v.mailboxId===s)?.messageCount??0),[t,s]),R=u.useCallback(()=>{p.current?.abort()},[]),C=u.useCallback(async S=>{const v=new AbortController;p.current=v;const{signal:j}=v;r("moving"),f(void 0);const E=await _(w());if(j.aborted)return;if(!E.ok){f(E.error),r("error");return}let x=it(E.value);c(x);const A=new Set;for(;;){if(j.aborted)return;const D=await _(Rt(s,A,dt,j));if(j.aborted)return;if(!D.ok){x=K(x,D.error),c(x),f(D.error),r("error");return}const L=D.value;if(L.length===0)break;const F=await _(We({body:{messageIds:L,destinationMailboxId:S},throwOnError:!0}));if(j.aborted)return;if(!F.ok){x=K(x,F.error),c(x),f(F.error),r("error");return}for(const I of L)A.add(I);x=ct(x,L.length),c(x)}const y=await _(Ot(s,j));if(!j.aborted){if(!y.ok){x=K(x,y.error),c(x),f(y.error),r("error");return}if(y.value>0){const D=`${y.value} ${y.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=K(x,D),c(x),f(D),r("error"),h();return}await k()}},[s,w,k,h]),O=u.useCallback(()=>{p.current?.abort(),p.current=null,r("idle"),c(null),f(void 0)},[]);return{phase:i,progress:l,errorMessage:o,deleteMailbox:k,moveThenDelete:C,cancel:R,reset:O}}const J=t=>`${t} ${t===1?"email":"emails"}`;function Tt({open:t,accountId:s,folder:a,mailboxes:n,appointments:i,onClose:r}){const[l,c]=u.useState(()=>oe(a.messageCount)),{createFolderIn:o}=we(s),f=ke(),{phase:p,progress:h,errorMessage:k,deleteMailbox:w,moveThenDelete:R,cancel:C,reset:O}=Pt({accountId:s,mailboxId:a.mailboxId,onDeleted:r});u.useEffect(()=>{t&&(c(oe(a.messageCount)),O())},[t,a.messageCount,O]),u.useEffect(()=>C,[C]);const S=u.useCallback(()=>{C(),r()},[C,r]),v=u.useMemo(()=>{const A=new Map(n.map(y=>[y.mailboxId,y.fullPath]));return ut({mailboxes:n,folderAppointments:i,excludeMailboxId:a.mailboxId,translator:f}).map(y=>({id:y.id,label:y.label,path:A.get(y.id)??y.label}))},[n,i,a.mailboxId,f]),j=u.useMemo(()=>H(a,ve(i).get(a.mailboxId),f),[a,i,f]);if(!t)return null;const E=`Delete ${j}`,x=p==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(re,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:h?le(h):"Moved 0 of 0"})]}):p==="deleting"||p==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(re,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):p==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(je,{tone:"danger",variant:"soft",children:k??"Something went wrong. Please try again."}),h&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[le(h),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(M,{variant:"secondary",size:"sm",onClick:S,children:"Close"})})]}):l==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:j}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(M,{variant:"secondary",size:"sm",onClick:S,children:"Cancel"}),e.jsx(M,{variant:"danger",size:"sm",icon:e.jsx(Q,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder"})]})]}):l==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:j})," holds"," ",J(a.messageCount),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>c("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Q,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>c("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ye,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(M,{variant:"secondary",size:"sm",onClick:S,children:"Cancel"})})]}):l==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:j})," and its"," ",J(a.messageCount),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>c("choose-fate"),children:"Back"}),e.jsx(M,{variant:"danger",size:"sm",icon:e.jsx(Q,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",J(a.messageCount)," in"," ",e.jsx("strong",{className:"text-fg",children:j})," to:"]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Ie,{folders:v,delimiter:n[0]?.hierarchyDelimiter??"/",onSelect:A=>R(A),onCreateFolder:o,onCancel:()=>c("choose-fate"),labels:{filterPlaceholder:"Move emails to…"}})})]});return e.jsxs(me,{open:t,onClose:S,title:E,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(Xe,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:E}),e.jsx(M,{variant:"ghost",size:"sm",icon:e.jsx(fe,{className:"size-3.5"}),onClick:S,"aria-label":"Cancel"})]}),x]})}const zt=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]});function $t({account:t}){const s=xe(),a=t.accountId,n=ke(),{data:i,isPending:r,isError:l,error:c,refetch:o}=Ne(tt({path:{accountId:a}})),{createFolderIn:f}=we(a),p=ne({...st(),onSuccess:()=>{s.invalidateQueries({queryKey:be()})}}),h=ne({...at(),onSuccess:()=>{s.invalidateQueries({queryKey:pe({path:{accountId:a}})})}}),[k,w]=u.useState(),[R,C]=u.useState(),[O,S]=u.useState(""),v=u.useMemo(()=>i?.items??[],[i]),j=u.useMemo(()=>ve(t.folderAppointments),[t.folderAppointments]),E=u.useMemo(()=>v.map(m=>({id:m.mailboxId,label:H(m,j.get(m.mailboxId),n),path:m.fullPath,deleteBlockedReason:mt(m,v,t.folderAppointments).message})),[v,j,n,t.folderAppointments]),x=(m,P)=>{p.mutate({path:{accountId:a,role:nt[m]},body:{mailboxId:P}})},A=(m,P)=>{const T=P.trim();h.mutate({path:{accountId:a,mailboxId:m},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${t.email}`});if(l)return e.jsx(Ce,{variant:"inline",title:`Couldn't load folders for ${t.email}`,error:c,onRetry:()=>{o()}});const y=v.map(m=>({mailboxId:m.mailboxId,providerPath:m.fullPath,messageCount:m.messageCount})),D={};for(const m of t.folderAppointments){const P=rt[m.role];P&&(D[P]=m.mailboxId??null)}const L={};for(const m of v)m.displayNameOverride&&(L[m.mailboxId]=m.displayNameOverride);const F=m=>v.find(P=>P.mailboxId===m),I=F(R),$=F(k);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||h.isError)&&e.jsx(je,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(Lt,{accountEmail:t.email,folders:y,appointments:D,displayNames:L,onAppoint:x,onRename:A}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",t.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Dt,{folders:E,delimiter:v[0]?.hierarchyDelimiter??"/",onCreateFolder:f,onRename:m=>{C(m.id),S(F(m.id)?.displayNameOverride?.trim()??"")},onDelete:m=>w(m.id),labels:{treeAriaLabel:`All folders for ${t.email}`}})})]}),I&&e.jsx(Mt,{open:!0,folderLabel:H(I,j.get(I.mailboxId),n),defaultLabel:H({fullPath:I.fullPath},j.get(I.mailboxId),n),name:O,onNameChange:S,pending:h.isPending,error:h.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const m=O.trim();h.mutate({path:{accountId:a,mailboxId:I.mailboxId},body:{displayNameOverride:m===""?null:m}},{onSuccess:()=>C(void 0)})},onClose:()=>C(void 0)}),$&&e.jsx(Tt,{open:!0,accountId:a,folder:$,mailboxes:v,appointments:t.folderAppointments,onClose:()=>w(void 0)})]})}function Gt(){const t=Ze(),[s,a]=u.useState(!0),{data:n,isPending:i,isError:r,error:l,refetch:c}=Ne(Je()),o=f=>{const p=et[f];p&&t({to:p})};return e.jsx(ft,{items:Ue,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:zt,helpOpen:s,onToggleHelp:()=>a(f=>!f),onSelect:o,onBackToMail:()=>{t({to:"/mail"})},children:i?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(Ce,{title:"Couldn't load accounts",error:l,onRetry:()=>{c()}}):n.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:n.accounts.map(f=>e.jsx($t,{account:f},f.accountId))})})}export{Gt as component};
@@ -0,0 +1 @@
1
+ import{j as t,bO as o}from"./index-qeQMtEt6.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-Cr3QcwUV.js";import{E as t}from"./ErrorState-Dr-9Au1e.js";const n=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{n as errorComponent};
1
+ import{j as r}from"./index-qeQMtEt6.js";import{E as t}from"./ErrorState-B6fATjA2.js";const n=({error:e,reset:o})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(t,{title:"Couldn't load your mailboxes",error:e,onRetry:o})});export{n as errorComponent};