@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.
Files changed (98) hide show
  1. package/assets/BriefPane-CyCnqfV1.js +1 -0
  2. package/assets/{ErrorState-DiX_zNTK.js → ErrorState-CN4Cwb5A.js} +1 -1
  3. package/assets/FlaggedPane-MgcE5bKj.js +1 -0
  4. package/assets/MailListHeader-DX7_Cewa.js +52 -0
  5. package/assets/MailViewChrome-9cKXCycT.js +1 -0
  6. package/assets/MailboxPane-Db0hba1S.js +1 -0
  7. package/assets/NavMenuButton-3t-xq8p6.js +1 -0
  8. package/assets/{OnboardingWizard-r-N3eGPg.js → OnboardingWizard-BFkNhodP.js} +1 -1
  9. package/assets/OutboxPane-O18gKLgX.js +1 -0
  10. package/assets/_mailboxId-DbcIOfsr.js +1 -0
  11. package/assets/{account-form-helpers-BHUowns0.js → account-form-helpers-D3tfbITU.js} +1 -1
  12. package/assets/accounts-J2omBETN.js +1 -0
  13. package/assets/advanced-Cb-Yw4fX.js +1 -0
  14. package/assets/appearance-BXwFGVL1.js +1 -0
  15. package/assets/avatar-DTwl3jb1.js +1 -0
  16. package/assets/bottom-sheet-Bw79dNtH.js +1 -0
  17. package/assets/brief-Cj9RHZn4.js +1 -0
  18. package/assets/brief-CrERI6Q7.js +1 -0
  19. package/assets/browser-ponyfill-Dfl9dHmO.js +2 -0
  20. package/assets/circle-check-DizPpF0Y.js +1 -0
  21. package/assets/circle-check-big-ChA18R4j.js +1 -0
  22. package/assets/circle-help-DPkDkgdF.js +1 -0
  23. package/assets/clock-uuvA1em-.js +1 -0
  24. package/assets/confirm-dialog-BTyZAw5R.js +1 -0
  25. package/assets/conversation-target-B0jE-e47.js +1 -0
  26. package/assets/{download-Bg6cLSAV.js → download-B3EpkLuL.js} +1 -1
  27. package/assets/enums-CCxx0t2v.js +1 -0
  28. package/assets/filters-Dk1yDjyQ.js +1 -0
  29. package/assets/{flagged-CuV2oZw_.js → flagged-CHfuc_hl.js} +1 -1
  30. package/assets/flagged-CZrDrTDc.js +1 -0
  31. package/assets/folders-B8orXsv8.js +1 -0
  32. package/assets/{format-CKZmh-Ru.js → format-De9HZKjg.js} +1 -1
  33. package/assets/index-BHkaa_C4.js +1 -0
  34. package/assets/index-CdMOAANs.js +1 -0
  35. package/assets/index-DDXDeP1_.js +1 -0
  36. package/assets/index-DjZFLwif.js +294 -0
  37. package/assets/index-O_DYWmDx.js +1 -0
  38. package/assets/index-lDYTJ6Ao.js +1 -0
  39. package/assets/intelligence-pref-C6lFpj6U.js +1 -0
  40. package/assets/{kbd-C00o9L4B.js → kbd-C0TyJDqO.js} +1 -1
  41. package/assets/labels-BzM1g0fg.js +1 -0
  42. package/assets/mail-oqxsK0QY.js +1 -0
  43. package/assets/menu-Cpsp0ZMZ.js +1 -0
  44. package/assets/move-options-CdaX2x7F.js +1 -0
  45. package/assets/onboarding-BAPCDoFw.js +1 -0
  46. package/assets/outbox-DQtIjp3h.js +1 -0
  47. package/assets/outbox-status-CPfNHfUQ.js +1 -0
  48. package/assets/pencil-Cm8cWZKn.js +1 -0
  49. package/assets/{rich-text-CoTs3nIc.js → rich-text-CGn1MSzM.js} +2 -2
  50. package/assets/rotate-ccw-oQ2bjkRm.js +1 -0
  51. package/assets/row-actions-CN3rJN24.js +1 -0
  52. package/assets/search-query-Cr_ZXBCp.js +1 -0
  53. package/assets/search-scope-CFN-gjTv.js +1 -0
  54. package/assets/search-token-index-CxMDhXuP.js +1 -0
  55. package/assets/search-view-ClRhrhjK.js +1 -0
  56. package/assets/senders-C-f6yU99.js +1 -0
  57. package/assets/settings-BbNYlJXs.js +1 -0
  58. package/assets/settings-screen-DBHgQU-S.js +1 -0
  59. package/assets/shield-check-BG5lmiwu.js +1 -0
  60. package/assets/{suggested-vips-BQoY6-Yl.js → suggested-vips-D0nhcuze.js} +1 -1
  61. package/assets/{useDebouncedValue-Ck8McJvG.js → useDebouncedValue-BFCY668u.js} +1 -1
  62. package/assets/useFilters-CxQU6LTN.js +1 -0
  63. package/assets/useLabels-DdQPlRo8.js +1 -0
  64. package/assets/useMediaQuery-fUhUpE77.js +1 -0
  65. package/assets/useRefreshControl-BsKYVbfM.js +1 -0
  66. package/assets/useSearchMirror-HHNbELBF.js +1 -0
  67. package/assets/useSearchTokenContext-D5dvdLSW.js +67 -0
  68. package/assets/useSignature-C6SBu3ql.js +1 -0
  69. package/index.html +1 -1
  70. package/package.json +1 -1
  71. package/assets/_mailboxId-DtqBFgK5.js +0 -1
  72. package/assets/accounts-B4-7wVt4.js +0 -1
  73. package/assets/advanced-Dlyjnb6l.js +0 -1
  74. package/assets/appearance-Drfetqy5.js +0 -1
  75. package/assets/avatar-Ci3CMhdo.js +0 -1
  76. package/assets/browser-ponyfill-BhnZT7aq.js +0 -2
  77. package/assets/circle-check-BM6iE_RP.js +0 -1
  78. package/assets/confirm-dialog-F7nDmx5t.js +0 -1
  79. package/assets/filters-CsWlycJW.js +0 -1
  80. package/assets/flagged-DtqBFgK5.js +0 -1
  81. package/assets/folders-Dg7RilCS.js +0 -1
  82. package/assets/index-BSJKHoKS.js +0 -1
  83. package/assets/index-DtqBFgK5.js +0 -1
  84. package/assets/index-dsr8I39S.js +0 -1
  85. package/assets/index-xOALrEh8.js +0 -294
  86. package/assets/labels-pEUVx_Ue.js +0 -1
  87. package/assets/mail-Chm12_Xz.js +0 -118
  88. package/assets/move-options-B2c-WWEl.js +0 -1
  89. package/assets/onboarding-DKy8Q5MV.js +0 -1
  90. package/assets/outbox-DtqBFgK5.js +0 -1
  91. package/assets/pencil-CZK87pI9.js +0 -1
  92. package/assets/senders-p6LBrcYb.js +0 -1
  93. package/assets/settings-C2TANSwS.js +0 -1
  94. package/assets/settings-screen-C7xmJsXG.js +0 -1
  95. package/assets/shield-check-CdES_QdC.js +0 -1
  96. package/assets/useFilters-DMt8Gx-P.js +0 -1
  97. package/assets/useLabels-oSXOt6KZ.js +0 -1
  98. package/assets/useSignature-BQN3IL24.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as r,a7 as ke,B as ee,a as ks,X as Ve,a8 as Vs,a9 as Ds,aa as dt,r as C,b as Nt,ab as X,q as ut,ac as Cs,w as Xt,W as es,ad as Fs,ae as Se,af as Os,$ as Ae,ag as ts,ah as Is,ai as Ms,aj as Rs,ak as ve,al as At,am as at,an as Tt,J as Et,ao as Ls,ap as Ie,aq as be,ar as _t,m as Us,as as zs,at as Hs,au as ss,av as Pt,o as Bs,aw as qs,ax as $s,ay as Ws,az as kt,aA as Ks,aB as Vt,aC as Gs,T as Ys}from"./index-DjZFLwif.js";import{R as Qs}from"./row-actions-CN3rJN24.js";import{S as Zs,A as Js}from"./settings-screen-DBHgQU-S.js";import{g as Dt,P as Xs,s as Be,u as er,O as tr}from"./OnboardingWizard-BFkNhodP.js";import{u as sr}from"./useSignature-C6SBu3ql.js";import{c as rr,a as Ct,d as ar}from"./account-form-helpers-D3tfbITU.js";import{D as ir}from"./download-B3EpkLuL.js";import{E as nr}from"./ErrorState-CN4Cwb5A.js";import{f as or}from"./format-De9HZKjg.js";import"./avatar-DTwl3jb1.js";import"./menu-Cpsp0ZMZ.js";import"./circle-help-DPkDkgdF.js";import"./kbd-C0TyJDqO.js";const lr=e=>{const s=new Set(e.map(Vs));return Ds.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>ke(t).localeCompare(ke(i)))},cr=({value:e,onChange:s,busy:t=!1})=>{const i=lr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>r.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(ks,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${ke(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>r.jsx("option",{value:o,children:ke(o)},o))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(dt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Ft({isOpen:e,onClose:s,title:t,children:i,footer:o}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Nt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{className:Nt("safe-area-frame fixed top-0 right-0 z-50 h-full w-full border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",children:[r.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(Ve,{className:"size-5"})})]}),r.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Le=e=>e.type==="checkbox",je=e=>e instanceof Date,Y=e=>e==null;const ft=e=>typeof e=="object";var H=e=>!Y(e)&&!Array.isArray(e)&&ft(e)&&!je(e),ur=e=>H(e)&&e.target?Le(e.target)?e.target.checked:e.target.value:e,fr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),rs=e=>{const s=e.constructor&&e.constructor.prototype;return H(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(H(e)&&rs(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=B(e[o]));return i}const _e={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},as="root",mt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const hr=/[.[\]'"]/;var Qe=e=>e.split(hr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=Ue(s)?[s]:Qe(s);if(i.some(d=>mt.includes(d)))return t;const o=i.reduce((d,n)=>Y(d)?void 0:d[n],e);return L(o)||o===e?L(e[s])?t:e[s]:o},me=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=Ue(s)?[s]:Qe(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const E=e[u];j=H(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(mt.includes(u))return;e[u]=j,e=e[u]}};const pr=X.createContext(null);pr.displayName="HookFormControlContext";var gr=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const xr=Ye?X.useLayoutEffect:X.useEffect;var Q=e=>typeof e=="string",yr=(e,s,t,i,o)=>Q(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),it=e=>Y(e)||!ft(e);const Ot=(e,s)=>s.length===0&&!Array.isArray(e)&&!rs(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(it(e)||it(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ot(e,i)||Ot(s,o))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of i){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(H(u)||Array.isArray(u))&&(H(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),tt=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Re=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Re(u,s))break}else if(H(u)&&Re(u,s))break}}};var It=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,as,s[t]),F(e,t,o),e},G=e=>H(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},pt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,gt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const Mt={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var is=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!L(e[0].attributes.value)?L(e[0].value)||e[0].value===""?Rt:{value:e[0].value,isValid:!0}:Rt:Mt}return Mt};const Lt={isValid:!1,value:null};var ns=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Lt):Lt;function Ut(e,s,t="validate"){if(Q(e)||Array.isArray(e)&&e.every(Q)||me(e)&&!e)return{type:t,message:Q(e)?e:"",ref:s}}var Pe=e=>H(e)&&!Ge(e)?e:{value:e,message:""},zt=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:_,min:z,max:R,pattern:O,validate:T,name:f,valueAsNumber:b,mount:ae}=e._f,N=y(t,f);if(!ae||s.has(f))return{};const W=u?u[0]:n,I=P=>{if(o&&W.reportValidity){const k=me(P)?"":P||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},A={},ne=pt(n),re=Le(n),pe=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,K=gt.bind(null,f,i,A),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const M=P?k:D;A[f]={type:P?$:w,message:M,ref:n,...K(P?$:w,M)}};if(d?!Array.isArray(N)||!N.length:j&&(!pe&&(oe||Y(N))||me(N)&&!N||re&&!is(u).isValid||ne&&!ns(u).isValid)){const{value:P,message:k}=Q(j)?{value:!!j,message:j}:Pe(j);if(P&&(A[f]={type:de.required,message:k,ref:W,...K(de.required,k)},!i))return I(k),A}if(!oe&&(!Y(z)||!Y(R))){let P,k;const D=Pe(R),$=Pe(z);if(!Y(N)&&!isNaN(N)){const w=n.valueAsNumber||N&&+N;Y(D.value)||(P=w>D.value),Y($.value)||(k=w<$.value)}else{const w=n.valueAsDate||new Date(N),M=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Z=n.type=="week";Q(D.value)&&N&&(P=le?M(N)>M(D.value):Z?N>D.value:w>new Date(D.value)),Q($.value)&&N&&(k=le?M(N)<M($.value):Z?N<$.value:w<new Date($.value))}if((P||k)&&(te(!!P,D.message,$.message,de.max,de.min),!i))return I(A[f].message),A}if((E||_)&&!oe&&(Q(N)||d&&Array.isArray(N))){const P=Pe(E),k=Pe(_),D=!Y(P.value)&&N.length>+P.value,$=!Y(k.value)&&N.length<+k.value;if((D||$)&&(te(D,P.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Q(N)){const{value:P,message:k}=Pe(O);if(Ge(P)&&!N.match(P)&&(A[f]={type:de.pattern,message:k,ref:n,...K(de.pattern,k)},!i))return I(k),A}if(T){if(ie(T)){const P=await T(N,t),k=Ut(P,W);if(k&&(A[f]={...k,...K(de.validate,k.message)},!i))return I(k.message),A}else if(H(T)){let P={};for(const k in T){if(!G(P)&&!i)break;const D=Ut(await T[k](N,t),W,k);D&&(P={...D,...K(k,D.message)},I(D.message),i&&(A[f]=P))}if(!G(P)&&(A[f]={ref:W,...P},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],os=e=>Array.isArray(e)?e.filter(Boolean):[];function vr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(Y(e)){e=void 0;break}e=e[s[i]],i++}return e}function br(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Q(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Ue(s)?[s]:Qe(s);if(t.some(n=>mt.includes(String(n))))return e;const i=t.length===1?e:vr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const ls=e=>{const s={};for(const t of Object.keys(e))if(ft(e[t])&&e[t]!==null&&!je(e[t])){const i=ls(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=X.createContext(null);jr.displayName="HookFormContext";var Ht=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function cs(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&H(o)&&d){const n=cs(o,d);H(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var ds=e=>e.type==="select-multiple",Sr=e=>pt(e)||Le(e),st=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function us(e){return Array.isArray(e)||H(e)&&!wr(e)}function fs(e){return!!(e&&"_f"in e)}function ms(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function nt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ot(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];us(o)&&(!Array.isArray(o)||!fs(d))?(s[i]=Array.isArray(o)?[]:{},ot(o,s[i],d),ms(s[i])&&nt(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=ot(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];us(d)&&(!Array.isArray(d)||!fs(n))?(L(s)||it(t[o])?t[o]=ot(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),ms(t[o])&&nt(t,o)):he(d,s[o])?nt(t,o):t[o]=!0}return t}var hs=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Q(e)?new Date(e):i?i(e):e;function Bt(e){const s=e.ref;return ht(s)?s.files:pt(s)?ns(e.refs).value:ds(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?is(e.refs).value:hs(L(s.value)?e.ref.value:s.value,e)}var Nr=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>L(e)?e:Ge(e)?e.source:H(e)?Ge(e.value)?e.value.source:e.value:e;const qt="AsyncFunction";var Ar=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===qt;if(H(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===qt)return!0}return!1},Tr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function $t(e,s,t){const i=y(e,t);if(i||Ue(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};o.pop()}return{name:t}}var Er=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},_r=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Pr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,kr=(e,s)=>!os(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},rt="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Dr(e={}){let s={...Vr,...e},t={...B(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=H(s.defaultValues)||H(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(o),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},E={};let _=0,z=qe(s.mode),R=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},T={...O};let f={...T};const b={array:Ht(),state:Ht()};let ae=0;const N=s.criteriaMode===ue.all,W=(a,l)=>c=>{clearTimeout(E[a]),E[a]=setTimeout(l,c)},I=async a=>{if(!n.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||a)){const l=++ae;let c;s.resolver?(c=G((await D()).errors),l===ae&&A()):c=await M({fields:i,onlyCheckValid:!0,eventType:_e.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},A=(a,l)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((a||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(a,l=[],c,m,h=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,a))){const g=c(y(i,a),m.argA,m.argB);h&&F(i,a,g)}if(x&&Array.isArray(y(t.errors,a))){const g=c(y(t.errors,a),m.argA,m.argB);h&&F(t.errors,a,g),kr(t.errors,a)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,a))){const g=c(y(t.touchedFields,a),m.argA,m.argB);h&&F(t.touchedFields,a,g)}(T.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:a,isDirty:Z(a,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,a,l)},pe=(a,l)=>{F(t.errors,a,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=a=>{t.errors=a,b.state.next({errors:t.errors,isValid:!1})},K=a=>{const l=Ue(a)?[a]:Qe(a);let c=d,m=o;for(let h=0;h<l.length-1;h++){const x=l[h];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(a,l,c,m)=>{const h=y(i,a);if(h){if(K(a))return;const x=L(y(d,a)),g=y(d,a,L(c)?y(o,a):c);L(g)||m&&m.defaultChecked||l?F(d,a,l?g:Bt(h._f)):De(a,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(T.isDirty||f.isDirty)&&(Z()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!L(y(d,a))&&tt(a,u)&&(n.watch=!0))}},P=(a,l,c,m,h)=>{let x=!1,g=!1;const v={name:a};if(!s.disabled||m===!0){if(!c||m){const S=he(y(o,a),l);(T.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=g!==v.isDirty),g=!!y(t.dirtyFields,a),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,a):F(t.dirtyFields,a,!0),v.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,a);S||(F(t.touchedFields,a,c),v.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&S!==c)}x&&h&&b.state.next(v)}return x?v:{}},k=(a,l,c,m)=>{const h=y(t.errors,a),x=(T.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[a]=W(a,()=>pe(a,c)),j[a](s.delayError)):(clearTimeout(E[a]),delete j[a],c?F(t.errors,a,c):q(t.errors,a),t.errors={...t.errors}),(c?!he(h,c):h)||!G(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:a};t={...t,...g},b.state.next(g)}},D=async a=>(A(a,!0),await s.resolver(d,s.context,Nr(a||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async a=>{const{errors:l}=await D(a);if(A(a),a){for(const c of a){const m=y(l,c);m?u.array.has(c)&&H(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?It(t.errors,{[c]:m},c):F(t.errors,c,m):q(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},w=async({name:a,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:a,eventType:l});if(H(c))for(const m in c){const h=c[m];h&&He(`${rt}.${m}`,{message:Q(h.message)?h.message:"",type:h.type||de.validate})}else Q(c)||!c?He(rt,{message:c||"",type:de.validate}):Ee(rt);return c}return!0},M=async({fields:a,onlyCheckValid:l,name:c,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:c,eventType:m})&&(h.valid=!1,l)))return h.valid;for(const x in a){const g=a[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),J=g._f&&Ar(g._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;J&&xe&&A([v.name],!0);const ye=await zt(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(J&&xe&&A([v.name]),ye[v.name]&&(h.valid=!1,l)||(!l&&(y(ye,v.name)?U?It(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(S)&&await M({context:h,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return h.valid},le=()=>{for(const a of u.unMount){const l=y(i,a);l&&(l._f.refs?l._f.refs.every(c=>!st(c)):!st(l._f.ref))&&Je(a)}u.unMount=new Set},Z=(a,l)=>(a&&l&&F(d,a,l),!he(n.mount?d:o,o)),ge=(a,l,c)=>yr(a,u,{...n.mount?d:L(l)?o:Q(a)?{[a]:l}:l},c,l),Te=a=>os(y(n.mount?d:o,a,s.shouldUnregister?y(o,a,[]):[])),De=(a,l,c={},m=!1,h=!1)=>{const x=y(i,a);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,a,hs(l,v)),g=Ke(v.ref)&&Y(l)?"":l,ds(v.ref)?[...v.ref.options].forEach(S=>S.selected=g.includes(S.value)):v.refs?Le(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(g)?S.checked=!!g.find(U=>U===S.value):S.checked=g===S.value||!!g)}):v.refs.forEach(S=>S.checked=S.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!h&&b.state.next({name:a,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(a,g,c.shouldTouch,c.shouldDirty,!h),c.shouldValidate&&fe(a,{delayError:c.delayError})},ze=(a,l,c,m=!1,h=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=a+"."+x,S=y(i,v);(u.array.has(a)||H(g)||S&&!S._f)&&!je(g)?ze(v,g,c,m,h):De(v,g,c,m,h)}},Ze=(a,l,c,m,h=!1)=>{const x=y(i,a),g=u.array.has(a),v=m?l:B(l),S=y(d,a),U=he(S,v);if(U||F(d,a,v),g)b.array.next({name:a,values:m?d:B(d)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),h||b.state.next({name:a,dirtyFields:t.dirtyFields,isDirty:Z(a,v)}));else{const J=Array.isArray(v)&&!v.length||G(v);!x||x._f||Y(v)||J?De(a,v,c,m,h):ze(a,v,c,m,h)}if(!U&&!h){const J=tt(a,u),xe=m?d:B(d);b.state.next({...J&&t,name:n.mount||J?a:void 0,values:xe})}},p=(a,l,c={})=>Ze(a,l,c,!1),V=(a,l={})=>{const c=ie(a)?a(d):a;if(!he(d,c)){d={...d,...c};const m=ls(c);for(const h of u.mount)h in m&&Ze(h,m[h],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,..._?{values:d}:{}}),l.shouldValidate&&I()}},ce=async a=>{n.mount=!0;const l=a.target;let c=l.name,m=!0;const h=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(h){let g,v;const S=l.type?Bt(h._f):ur(a),U=a.type===_e.BLUR||a.type===_e.FOCUS_OUT,J=!Tr(h._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!h._f.deps,xe=J||Pr(U,y(t.touchedFields,c),t.isSubmitted,R,z),ye=tt(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){h._f.onBlur&&h._f.onBlur(a);const Oe=j[c];Oe&&Oe(0)}}else h._f.onChange&&h._f.onChange(a);const Fe=P(c,S,U),_s=!G(Fe)||ye;if(!U&&b.state.next({name:c,type:a.type,..._?{values:B(d)}:{}}),xe)return(!J||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),_s&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:a.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(A([c]),x(S),!m){!G(Fe)&&b.state.next(Fe);return}const Ps=$t(t.errors,i,c),wt=$t(Oe,i,Ps.name||c);g=wt.error,c=wt.name,v=G(Oe)}else A([c],!0),g=(await zt(h,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(S),m&&(g?v=!1:(T.isValid||f.isValid)&&(v=await M({fields:i,onlyCheckValid:!0,name:c,eventType:a.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&fe(h._f.deps),k(c,v,g,Fe))}},se=(a,l)=>{if(y(t.errors,l)&&a.focus)return a.focus(),1},fe=async(a,l={})=>{let c,m;const h=We(a);if(s.resolver){const x=await $(L(a)?a:h);c=G(x),m=a?!h.some(g=>y(x,g)):c}else a?(m=(await Promise.all(h.map(async x=>{const g=y(i,x);return await M({fields:g&&g._f?{[x]:g}:g,eventType:_e.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await M({fields:i,name:a,eventType:_e.TRIGGER});if(l.delayError&&s.delayError&&Q(a)){const x=y(t.errors,a);x?(q(t.errors,a),j[a]=W(a,()=>pe(a,x)),j[a](s.delayError)):(clearTimeout(E[a]),delete j[a])}return b.state.next({...!Q(a)||(T.isValid||f.isValid)&&c!==t.isValid?{}:{name:a},...s.resolver||!a?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Re(i,se,a?h:u.mount),m},we=(a,l)=>{let c={...n.mount?d:o};return l&&(c=cs(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(a)?c:Q(a)?y(c,a):a.map(m=>y(c,m))},Ce=(a,l)=>({invalid:!!y((l||t).errors,a),isDirty:!!y((l||t).dirtyFields,a),error:y((l||t).errors,a),isValidating:!!y(t.validatingFields,a),isTouched:!!y((l||t).touchedFields,a)}),Ee=a=>{const l=a?We(a):void 0;l?.forEach(c=>q(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},He=(a,l,c)=>{const m=(y(i,a,{_f:{}})._f||{}).ref,h=y(t.errors,a)||{},{ref:x,message:g,type:v,...S}=h;F(t.errors,a,{...S,...l,ref:m}),b.state.next({name:a,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},Ss=(a,l)=>{if(ie(a)){_++;const{unsubscribe:c}=b.state.subscribe({next:h=>"values"in h&&a(h.values||ge(void 0,l),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,_--,c())}}}return ge(a,l,!0)},xt=a=>{var l;const c=!!(!((l=a.formState)===null||l===void 0)&&l.values);c&&_++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(_r(a.name,x.name,a.exact)&&Er(x,a.formState||T,Es,a.reRenderRoot)){const g={...d};a.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let h=!1;return()=>{h||(h=!0,_--,m())}},ws=a=>(n.mount=!0,f={...f,...a.formState},xt({...a,formState:{...O,...a.formState}})),Je=(a,l={})=>{for(const c of a?We(a):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(q(i,c),q(d,c)),!l.keepError&&q(t.errors,c),!l.keepDirty&&q(t.dirtyFields,c),!l.keepTouched&&q(t.touchedFields,c),!l.keepIsValidating&&q(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&q(o,c);b.state.next({values:B(d)}),b.state.next({...t,...l.keepDirty?{isDirty:Z()}:{}}),!l.keepIsValid&&I()},yt=({disabled:a,name:l})=>{if(me(a)&&n.mount||a||u.disabled.has(l)){const h=u.disabled.has(l)!==!!a;a?u.disabled.add(l):u.disabled.delete(l),h&&n.mount&&!n.action&&I()}},Xe=(a,l={})=>{let c=y(i,a);const m=me(l.disabled)||me(s.disabled),h=!u.registerName.has(a)&&c&&c._f&&!c._f.mount;return F(i,a,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:a}},name:a,mount:!0,...l}}),u.mount.add(a),c&&!h?yt({disabled:me(l.disabled)?l.disabled:s.disabled,name:a}):te(a,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(l.pattern)}:{},name:a,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(a),Xe(a,l),u.registerName.delete(a),c=y(i,a);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Sr(g),S=c._f.refs||[];if(v?S.find(U=>U===g):g===c._f.ref)return;F(i,a,{_f:{...c._f,...v?{refs:[...S.filter(st),g,...Array.isArray(y(o,a))?[{}]:[]],ref:{type:g.type,name:a}}:{ref:g}}}),te(a,!1,void 0,g)}else c=y(i,a,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,a)&&n.action)&&u.unMount.add(a)}}},et=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Re(i,se,u.mount),Ns=a=>{me(a)&&(b.state.next({disabled:a}),Re(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||a,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||a}))},0,!1))},vt=(a,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,h=B(g)}else await M({fields:i,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,as),G(t.errors)){b.state.next({errors:{}});try{await a(h,c)}catch(x){m=x}}else l&&await l({...t.errors},c),et(),setTimeout(et);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},As=(a,l={})=>{y(i,a)&&(L(l.defaultValue)?p(a,B(y(o,a))):(p(a,l.defaultValue),F(o,a,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,a),l.keepDirty||(q(t.dirtyFields,a),t.isDirty=l.defaultValue?Z(a,B(y(o,a))):Z()),l.keepError||(q(t.errors,a),T.isValid&&I()),b.state.next({...t}))},bt=(a,l={})=>{const c=a?B(a):o,m=B(c),h=G(a),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ne(o,d,void 0,g))]);for(const S of Array.from(v)){const U=y(t.dirtyFields,S),J=y(d,S),xe=y(x,S);U&&!L(J)?F(x,S,J):!U&&!L(xe)&&p(S,xe)}}else{if(Ye&&L(a))for(const v of u.mount){const S=y(i,v);if(S&&S._f){const U=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Ke(U)){const J=U.closest("form");if(J){J.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)p(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?B(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!T.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:h?!1:l.keepDirty?t.isDirty:l.keepValues?Z():!!(l.keepDefaultValues&&!he(a,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&a?Ne(o,a,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},jt=(a,l)=>bt(ie(a)?a(d):a,{...s.resetOptions,...l}),Ts=(a,l={})=>{const c=y(i,a),m=c&&c._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),l.shouldSelect&&ie(h.select)&&h.select()})}},Es=a=>{const{name:l,type:c,values:m,...h}=a;t={...t,...h}},St={control:{register:Xe,unregister:Je,getFieldState:Ce,handleSubmit:vt,setError:He,_subscribe:xt,_runSchema:D,_updateIsValidating:A,_focusError:et,_getWatch:ge,_getDirty:Z,_setValid:I,_setFieldArray:re,_setDisabledField:yt,_setErrors:oe,_getFieldArray:Te,_reset:bt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(a=>{jt(a,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:Ns,_subjects:b,_proxyFormState:T,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(a){n=a},get _defaultValues(){return o},get _names(){return u},set _names(a){u=a},get _formState(){return t},get _options(){return s},set _options(a){s={...s,...a},z=qe(s.mode),R=qe(s.reValidateMode)}},subscribe:ws,trigger:fe,register:Xe,handleSubmit:vt,watch:Ss,setValue:p,setValues:V,getValues:we,reset:jt,resetField:As,resetDefaultValues:(a,l={})=>{if(o=B(a),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Ee,unregister:Je,setError:He,setFocus:Ts,getFieldState:Ce};return{...St,formControl:St}}function Cr(e={}){const s=X.useRef(void 0),t=X.useRef(void 0),i=X.useRef(e.formControl),[o,d]=X.useState(()=>({...B(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Dr(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,xr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),X.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),X.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),X.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),X.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),X.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),X.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),X.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=X.useMemo(()=>gr(o,n),[n,o]),s.current}const Wt=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},lt=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},Kt=(e,s)=>{s.shouldUseNativeValidation&&lt(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Fr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Fr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function gs(e,s,t){function i(u,j){var E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const _ in n.prototype)_ in u||Object.defineProperty(u,_,{value:n.prototype[_].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const E=t?.Parent?new d:this;i(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const _ of E._zod.deferred)_();return E}return Object.defineProperty(n,"init",{value:i}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Or extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ir={};function xs(e){return Ir}function Mr(e,s){return typeof s=="bigint"?s.toString():s}const ys=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function vs(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const bs=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Mr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rr=gs("$ZodError",bs),js=gs("$ZodError",bs,{Parent:Error}),Lr=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Or;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Ur=Lr(js),zr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>vs(j,d,xs())));throw ys(u,o?.callee),u}return n.value},Hr=zr(js);function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ct.apply(null,arguments)}function Yt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Br(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(_){return _.errors.forEach(function(z){return e.push(z)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=gt(n,s,t,o,E?[].concat(E,i.message):i.message)}e.shift()}return t}function qr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(z){return z.forEach(function(R){return e.push(ct({},R,{path:[].concat(o.path,R.path)}))})}),s){var E=t[u].types,_=E&&E[o.code];t[u]=gt(u,s,t,d,_?[].concat(_,o.message):o.message)}e.shift()};e.length;)i();return t}function $r(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&lt({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Kt(Br(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Yt(function(){return Promise.resolve((t.mode==="sync"?Ur:Hr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&lt({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Rr})(n))return{values:{},errors:Kt(qr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Wr=e=>{const s=ut(),{pushError:t}=Cs(),{data:i}=Xt({...es(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Fs(navigator.languages),[o]),n=Se({...ts(),onSuccess:()=>{s.invalidateQueries({queryKey:Ae()})},onError:j=>{t(Os("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Kr=e=>e.authType==="oauthMicrosoft",Gr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Qr=Ls({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:_t.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:_t.number().int().min(1).max(65535).optional(),smtpTls:Ie().optional(),smtpStartTls:Ie().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Ie().optional()}),Zr=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ut(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[_,z]=C.useState(!1),R=Dt(j),O=!!R&&!_,T=C.useRef(null),f=Cr({resolver:$r(Qr),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const p=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Gr,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:p&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:p}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Se({...Is()}),ae=Se({...Ms(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),N=Se({...ts(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),W=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},I=()=>{const p=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:p.username||p.email,password:V?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:p.smtpHost||void 0,smtpPort:p.smtpPort?Number(p.smtpPort):void 0,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls,smtpUsername:p.useDifferentSmtpCreds?p.smtpUsername:void 0,smtpPassword:p.useDifferentSmtpCreds?p.smtpPassword:void 0}})},A=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const V=rr({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??p.smtpHost,se=V?.smtpPort??p.smtpPort,fe=V?.smtpTls??p.smtpTls,we=V?.smtpStartTls??p.smtpStartTls,Ce={email:p.email,displayName:p.displayName?.trim()||void 0,username:p.username||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const Ee={...Ce,password:n?p.password:void 0};N.mutate({path:{accountId:t.accountId},body:Ee})}else{const Ee={...Ce,password:p.password};ae.mutate({body:Ee})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:pe,isSaving:oe}=sr(t?.accountId),[K,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const p=T.current;if(!p)return;const V=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{K!==re.plainText&&pe(K,K)},[K,re.plainText,pe]),M=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",p==="tls"?993:143)},le=p=>{const{tls:V,startTls:ce}=Be(p);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",we)}},Z=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",ar(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=p=>{E(p),z(!1);const V=Dt(p);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const fe=f.getValues("email").trim(),we=f.getValues("username")?.trim();fe&&!we&&f.setValue("username",fe)},Te=R?.passwordHelp.text,De=Ct(b.data?.imapError,Te),ze=Ct(b.data?.smtpError,Te);return(t?Kr(t):!1)&&d?r.jsx(Ft,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:K,onChange:p=>te(p.target.value),onBlur:w,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):r.jsx(Ft,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Rs,{id:"account-provider",value:j,onChange:p=>ge(p.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),Xs.map(p=>r.jsx("option",{value:p.id,children:p.label},p.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(At,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",r.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&r.jsx("button",{type:"button",onClick:()=>z(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:_?"Use preset settings":"Advanced"})]}),O&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",R?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>M("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>M("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>M("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&r.jsxs("div",{className:Et("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?r.jsx(Tt,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),r.jsxs("section",{ref:T,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&r.jsx("button",{type:"button",onClick:Z,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),r.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?r.jsx(at,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Et("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?r.jsx(Tt,{className:"inline size-4 mr-1"}):r.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":ze]})]})]}),d&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:K,onChange:p=>te(p.target.value),onBlur:w,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Qt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),_=Se({...zs(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),z=Se(Hs()),R=()=>{_.isPending||(d(""),u(!1),E(!1),_.reset(),z.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),_.mutate({body:{confirmEmail:o.trim()}})};return r.jsxs(ss,{open:e,onClose:R,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>z.mutate({}),"aria-busy":z.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(ir,{className:"size-3.5"}),z.isPending?"Requesting export…":"Export my data first"]}),z.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),z.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:T=>{d(T.target.value),n&&u(!1),_.isError&&_.reset()},autoComplete:"off"}),n&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),_.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:_.error instanceof Error?_.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":_.isPending,children:_.isPending?"Deleting…":"Delete everything"})]})]})]})}function Jr(e){const{Account:s}=Us();return r.jsx(s,{fallback:r.jsx(Qt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>r.jsx(Qt,{...e,accountEmail:t??"",signOut:i})})}function Xr(){const[e,s]=C.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(dr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(Jr,{open:e,onClose:()=>s(!1)})]})}function ea(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function ta(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function sa(e){const s=e.displayName?.trim();return s||ta(e.email)}function ra(e){if(!e.lastSyncAt)return"never synced";const s=or(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Zt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Jt(e){return e.connectionState==="reauth_required"}const aa=r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),r.jsxs("p",{children:[r.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),ia=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ja(){const e=Pt.useSearch(),s=Bs({from:Pt.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[_,z]=C.useState(!1),[R,O]=C.useState(null),[T,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ut(),{data:A,isPending:ne,isError:re,error:pe,refetch:oe}=Xt(es());C.useEffect(()=>{e.editAccountId&&(E(e.editAccountId),z(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(e.connected),I.invalidateQueries({queryKey:Ae()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ae(ea(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),er(N!==null,()=>{I.invalidateQueries({queryKey:Ae()})}),C.useEffect(()=>{if(!N||!A)return;const w=A.accounts.find(M=>M.accountId===N);(!w||!Jt(w))&&W(null)},[A,N]);const K=Se({...qs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...$s(),onSuccess:()=>{I.invalidateQueries({queryKey:Ae()}),O(null)}}),P=A?.accounts.find(w=>w.accountId===R),k=A?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),z(!1)},$=w=>{const M=Gs[w];M&&s({to:M})};return r.jsxs(Zs,{items:Ws,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:aa,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[T&&r.jsx(kt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:T}),b&&r.jsx(kt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ks,{tone:"neutral",children:ne||re?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?r.jsx(ia,{}):re?r.jsx(nr,{title:"Couldn't load accounts",error:pe,onRetry:()=>{oe()}}):A.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(ee,{variant:"primary",size:"sm",icon:r.jsx(Vt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:A.accounts.map(w=>{const M=Jt(w),le=w.authType==="oauthMicrosoft",Z=N===w.accountId&&K.isPending,ge=M&&le?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),K.mutate({body:{email:w.email}})}}:Zt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},Te=r.jsx(Qs,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(Ys,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return r.jsx(Js,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Zt(w),errorDetail:M?"Re-authentication required":w.lastError,trailing:Te},w.accountId)})}),n&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(tr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Ae()})},onCancel:()=>u(!1)})}),r.jsx(Zr,{isOpen:o||!!j,account:k,focusSmtp:_,onClose:D}),r.jsxs(ss,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(dt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(ee,{variant:"ghost",size:"sm",icon:r.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&r.jsx("p",{className:"text-center",children:P.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),r.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?r.jsx(at,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||R&&te.mutate({path:{accountId:R}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(Xr,{})]})}export{ja as component,ea as mapOauthError};
@@ -0,0 +1 @@
1
+ import{c as v,j as e,au as C,aF as y,B as n,aG as f,r as g,aa as m,az as z,am as j,aA as R,aH as p,b as T,aI as S,U as A,aJ as I,aK as L,aL as M,o as V,ay as _,aC as B}from"./index-DjZFLwif.js";import{S as D}from"./settings-screen-DBHgQU-S.js";import{D as b}from"./download-B3EpkLuL.js";import{R as N}from"./rotate-ccw-oQ2bjkRm.js";import{C as U}from"./clock-uuvA1em-.js";import{C as H}from"./circle-check-DizPpF0Y.js";import{S as E}from"./shield-check-BG5lmiwu.js";import"./avatar-DTwl3jb1.js";import"./menu-Cpsp0ZMZ.js";import"./circle-help-DPkDkgdF.js";const Y=v("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const k=v("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),O=["Remit restarts. Mail stops loading for about a minute and this page will lose its connection while that happens.","Nothing is sent, deleted or moved. Your mail stays at your provider.","If the new version does not come back up, the version you are running now is restored automatically."];function P({open:s,currentVersion:t,release:a,appliesSchemaMigration:r=!1,onClose:i,onConfirm:c}){return s?e.jsx(C,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",t,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[O.map(o=>e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:o})]},o)),r&&e.jsxs("li",{className:"flex gap-2 text-sm text-fg-muted",children:[e.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-fg-subtle"}),e.jsx("span",{children:"This version updates the database while Remit is offline. The step forward cannot be undone by hand, but a failed start is still rolled back to the version and data you have now."})]})]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Good moment for this: when you are not waiting on a message."})]}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"}),e.jsx(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:c,children:"Install and restart"})]})]})}):null}function l({children:s,tone:t}){return e.jsx("div",{className:T("rounded-sm border bg-surface px-row-inset py-3",t==="danger"?"border-danger/50":"border-line"),children:s})}function F({state:s,onCheck:t,onInstall:a,onDismissResult:r,now:i=Date.now()}){const[c,o]=g.useState(null),h=s.status==="checking",d=s.status==="available",x=()=>{if(h){o("Already checking. The result appears here in a moment.");return}o(null),t()},u=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){o("There is no update to install. Check for updates first — if one is found it appears here.");return}o(null),a()},w=(()=>{switch(s.status){case"upToDate":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(H,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"checking":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Looking for a newer version. You are on ",s.version,"."]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check again"})]})});case"neverChecked":return e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(U,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(n,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,children:"Check now"})]})});case"checkFailed":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Y,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"secondary",size:"sm",onClick:x,children:"Try again"})})]})});case"available":return e.jsx(l,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-semibold text-fg",children:["Remit ",s.release.version]}),e.jsx(R,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{size:"sm",icon:e.jsx(b,{className:"size-3.5"}),onClick:u,children:["Install ",s.release.version]}),e.jsx(f,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(k,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(l,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(j,{className:"size-4 shrink-0 animate-spin text-accent-2","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Installing Remit ",s.target,". The restart screen has the details."]})]})});case"succeeded":return e.jsx(z,{tone:"success",onDismiss:r,children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold",children:["Updated to Remit ",s.version,"."]}),e.jsxs("p",{children:["You were on ",s.previousVersion,"."," ",e.jsx("a",{href:s.releaseNotesUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"See what changed"}),"."]})]})});case"rolledBack":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start. Remit reports that it put ",s.version," back."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["You are running ",s.version," again. A failed update can still have changed things on the way — the log below is the only account of what it got as far as doing."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Installing ",s.attemptedVersion," left the server unreachable."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Remit has answered again since, but nothing here can say what happened during the silence."})]})]}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," did not start, and Remit could not put ",s.previousVersion," back."]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"This is the one outcome Remit cannot resolve on its own. The server is in a half-changed state and needs you at a shell. The log below is the only account of where it stopped."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported as the failure"}),e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log on the server:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(n,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"abandoned":return e.jsx(l,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(m,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-fg",children:["Remit ",s.attemptedVersion," was not installed. Nothing changed."]}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["The update stopped before it altered anything. You are still running ",s.version,"."]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"What Remit reported"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.reason})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-fg-subtle",children:"Read the full log before trying again:"}),e.jsx("code",{className:"block rounded-xs bg-surface-sunken px-2 py-1 text-2xs text-fg-muted",children:s.logsCommand})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(n,{variant:"secondary",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(n,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});default:return s}})();return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Updates"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This Remit runs on your own server, so it updates when you say so. Your mail lives at your provider and is never touched by an update."})]}),w,c&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:c})]})}function G(){const{surface:s,release:t,currentVersion:a,appliesSchemaMigration:r,onCheck:i,install:c,onDismissResult:o}=S(),[h,d]=g.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(F,{state:s.section,onCheck:i,onInstall:()=>d(!0),onDismissResult:o}),t&&a&&e.jsx(P,{open:h,currentVersion:a,release:t,appliesSchemaMigration:r,onClose:()=>d(!1),onConfirm:()=>{d(!1),c(t.version)}})]})}function q(){return A().tlsMode!=="internal"?null:e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"TLS root certificate"}),e.jsx("p",{className:"text-sm text-fg-muted mb-2",children:"This deployment signs its own certificate. Import it into the trust store of each device you browse from, and the browser warning stops for good."}),e.jsx(f,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(E,{className:"size-3.5"}),children:"Download root certificate"})]})}function W(s){try{return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function J({sha:s=L,commitUrl:t=I,buildTime:a=M}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-mono hover:text-fg-muted hover:underline",children:s}):e.jsx("span",{className:"font-mono",children:s})," · ",e.jsxs("span",{children:["Built ",W(a)]})]})}const K=e.jsx("div",{className:"space-y-3",children:e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"}),", data export, and per-account diagnostics are coming in a future release."]})});function le(){const s=V(),[t,a]=g.useState(!0),r=i=>{const c=B[i];c&&s({to:c})};return e.jsxs(D,{items:_,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:K,helpOpen:t,onToggleHelp:()=>a(i=>!i),onSelect:r,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(G,{}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules, data export, and raw sync diagnostics are coming in a future release."}),e.jsx(q,{}),e.jsxs("div",{className:"border-t border-line pt-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg mb-1",children:"About"}),e.jsx(J,{})]})]})}export{le as component};
@@ -0,0 +1 @@
1
+ import{o as g,r as s,aM as y,j as e,ay as u,aN as l,aC as S,aO as b}from"./index-DjZFLwif.js";import{S as j}from"./settings-screen-DBHgQU-S.js";import"./avatar-DTwl3jb1.js";import"./menu-Cpsp0ZMZ.js";import"./circle-help-DPkDkgdF.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}const T=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]});function E(){const a=g(),[i,r]=s.useState(!0),[c,m]=s.useState(N),[p,d]=s.useState(y),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),b(t)},x=t=>{const n=S[t];n&&a({to:n})};return e.jsx(j,{items:u,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:T,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:x,onBackToMail:()=>{a({to:"/mail"})},children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Density"}),e.jsx(l,{name:"density","aria-label":"Density",value:c,onChange:h,options:[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Controls the spacing of message rows in the mail list."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Theme"}),e.jsx(l,{name:"theme","aria-label":"Theme",value:p,onChange:f,options:[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Applies immediately. System default follows your OS preference."})]})]})})}export{E as component};
@@ -0,0 +1 @@
1
+ import{r as a,j as h,b as u}from"./index-DjZFLwif.js";const p={sm:"size-7 text-2xs",md:"size-9 text-sm",lg:"size-11 text-md"},n=["oklch(0.6 0.08 150)","oklch(0.6 0.08 185)","oklch(0.6 0.08 215)","oklch(0.6 0.07 250)","oklch(0.6 0.07 310)","oklch(0.62 0.07 110)"],d="oklch(0.97 0.012 90)";function f(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function m({name:e,email:t,size:l="md",className:c}){const i=a.useMemo(()=>{const r=t??e;let s=0;for(let o=0;o<r.length;o++)s=s*31+r.charCodeAt(o)>>>0;return n[s%n.length]},[e,t]);return h.jsx("span",{className:u("inline-flex shrink-0 items-center justify-center rounded-full font-semibold select-none",p[l],c),style:{backgroundColor:i,color:d},"aria-hidden":!0,children:f(e)})}export{m as A};
@@ -0,0 +1 @@
1
+ import{r as n,j as o,b as v}from"./index-DjZFLwif.js";const w=320,I="cubic-bezier(0.32, 0.9, 0.3, 1)",N=.5,k=.4,C=360;function E(r){return Math.sign(r)*Math.sqrt(Math.abs(r))*4}function T({open:r,onClose:c,children:g,dismissLabel:Y="Dismiss"}){const d=n.useRef(null),[i,S]=n.useState(C),[b,u]=n.useState(null);n.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=()=>S(t.offsetHeight);e();const s=new ResizeObserver(e);return s.observe(t),()=>s.disconnect()},[]);const l=n.useRef(null),y=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),l.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),M=n.useCallback(t=>{const e=l.current;if(!e)return;const s=t.timeStamp-e.lastT;s>0&&(e.velocity=(t.clientY-e.lastY)/s),e.lastY=t.clientY,e.lastT=t.timeStamp;const a=t.clientY-e.startY;Math.abs(a)>4&&(e.moved=!0);const j=a<0?E(a):a;u(j)},[]),m=n.useCallback(()=>{const t=l.current;if(l.current=null,!t)return;const e=t.lastY-t.startY,a=t.velocity>N||e>i*k;u(null),a&&c()},[i,c]),x=b!==null,p=r?b??0:i,f=Math.min(Math.max(1-p/i,0),1),h=x?"none":`transform ${w}ms ${I}`;return o.jsxs("div",{className:v("absolute inset-0 z-40 select-none overflow-hidden",r||x?"":"pointer-events-none"),children:[o.jsx("button",{type:"button","aria-label":Y,tabIndex:-1,onClick:c,className:v("absolute inset-0 bg-black/40",f>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:f*.6,transition:h.replace("transform","opacity")}}),o.jsxs("div",{ref:d,className:"absolute inset-x-0 bottom-0 flex max-h-[92%] flex-col rounded-t-3xl border-t border-line bg-surface pb-[env(safe-area-inset-bottom,0px)] shadow-2xl shadow-black/30",style:{transform:`translateY(${p}px)`,transition:h},children:[o.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(f*100),tabIndex:0,onPointerDown:y,onPointerMove:M,onPointerUp:m,onPointerCancel:m,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:o.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:g})]})]})}export{T as B};
@@ -0,0 +1 @@
1
+ import{j as r}from"./index-DjZFLwif.js";import{E as t}from"./ErrorState-CN4Cwb5A.js";const i=({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{i as errorComponent};
@@ -0,0 +1 @@
1
+ import{a2 as i,j as r,_ as m}from"./index-DjZFLwif.js";import{a as p}from"./search-view-ClRhrhjK.js";import{B as o}from"./BriefPane-CyCnqfV1.js";import{u as e}from"./useSearchMirror-HHNbELBF.js";import"./search-scope-CFN-gjTv.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-DX7_Cewa.js";import"./search-token-index-CxMDhXuP.js";import"./useMediaQuery-fUhUpE77.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"./useRefreshControl-BsKYVbfM.js";import"./circle-check-big-ChA18R4j.js";import"./useLabels-DdQPlRo8.js";import"./conversation-target-B0jE-e47.js";import"./search-query-Cr_ZXBCp.js";function z(){const{selectedMessageId:t}=i.useSearch();return e({to:"/mail/brief"}),r.jsx(o,{selectedMessageId:t,children:r.jsx(p,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(m,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{z as component};
@@ -0,0 +1,2 @@
1
+ import{cZ as A,L as $}from"./index-DjZFLwif.js";function X(_,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const l in y)if(l!=="default"&&!(l in _)){const p=Object.getOwnPropertyDescriptor(y,l);p&&Object.defineProperty(_,l,p.get?p:{enumerable:!0,get:()=>y[l]})}}}return Object.freeze(Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}))}var E={exports:{}},H;function Z(){return H||(H=1,(function(_,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof A<"u"&&A,y=(function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p})();(function(p){(function(h){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof A<"u"&&A||{},u={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function F(e){return e&&DataView.prototype.isPrototypeOf(e)}if(u.arrayBuffer)var q=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],C=ArrayBuffer.isView||function(e){return e&&q.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function T(e){return typeof e!="string"&&(e=String(e)),e}function B(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return u.iterable&&(t[Symbol.iterator]=function(){return t}),t}function i(e){this.map={},e instanceof i?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){if(t.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}i.prototype.append=function(e,t){e=v(e),t=T(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},i.prototype.delete=function(e){delete this.map[v(e)]},i.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},i.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},i.prototype.set=function(e,t){this.map[v(e)]=T(t)},i.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},i.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),B(e)},i.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),B(e)},i.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),B(e)},u.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);function O(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}}function D(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function I(e){var t=new FileReader,r=D(t);return t.readAsArrayBuffer(e),r}function M(e){var t=new FileReader,r=D(t),n=/charset=([A-Za-z0-9_-]+)/.exec(e.type),s=n?n[1]:"utf-8";return t.readAsText(e,s),r}function L(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function R(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function U(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:u.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:u.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():u.arrayBuffer&&u.blob&&F(e)?(this._bodyArrayBuffer=R(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||C(e))?this._bodyArrayBuffer=R(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=O(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(u.blob)return this.blob().then(I);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var e=O(this);if(e)return e;if(this._bodyBlob)return M(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(L(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(z)}),this.json=function(){return this.text().then(JSON.parse)},this}var N=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function k(e){var t=e.toUpperCase();return N.indexOf(t)>-1?t:e}function w(e,t){if(!(this instanceof w))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new i(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new i(t.headers)),this.method=k(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||(function(){if("AbortController"in a){var o=new AbortController;return o.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var s=/\?/;this.url+=(s.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})};function z(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),s=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(s),decodeURIComponent(o))}}),t}function G(e){var t=new i,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
2
+ `)===0?n.substr(1,n.length):n}).forEach(function(n){var s=n.split(":"),o=s.shift().trim();if(o){var g=s.join(":").trim();try{t.append(o,g)}catch(x){console.warn("Response "+x.message)}}}),t}U.call(w.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new i(t.headers),this.url=t.url||"",this._initBody(e)}U.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var V=[301,302,303,307,308];c.redirect=function(e,t){if(V.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},h.DOMException=a.DOMException;try{new h.DOMException}catch{h.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},h.DOMException.prototype=Object.create(Error.prototype),h.DOMException.prototype.constructor=h.DOMException}function P(e,t){return new Promise(function(r,n){var s=new w(e,t);if(s.signal&&s.signal.aborted)return n(new h.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function g(){o.abort()}o.onload=function(){var f={statusText:o.statusText,headers:G(o.getAllResponseHeaders()||"")};s.url.indexOf("file://")===0&&(o.status<200||o.status>599)?f.status=200:f.status=o.status,f.url="responseURL"in o?o.responseURL:f.headers.get("X-Request-URL");var m="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(m,f))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},o.onabort=function(){setTimeout(function(){n(new h.DOMException("Aborted","AbortError"))},0)};function x(f){try{return f===""&&a.location.href?a.location.href:f}catch{return f}}if(o.open(s.method,x(s.url),!0),s.credentials==="include"?o.withCredentials=!0:s.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(u.blob?o.responseType="blob":u.arrayBuffer&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof i||a.Headers&&t.headers instanceof a.Headers)){var j=[];Object.getOwnPropertyNames(t.headers).forEach(function(f){j.push(v(f)),o.setRequestHeader(f,T(t.headers[f]))}),s.headers.forEach(function(f,m){j.indexOf(m)===-1&&o.setRequestHeader(m,f)})}else s.headers.forEach(function(f,m){o.setRequestHeader(m,f)});s.signal&&(s.signal.addEventListener("abort",g),o.onreadystatechange=function(){o.readyState===4&&s.signal.removeEventListener("abort",g)}),o.send(typeof s._bodyInit>"u"?null:s._bodyInit)})}return P.polyfill=!0,a.fetch||(a.fetch=P,a.Headers=i,a.Request=w,a.Response=c),h.Headers=i,h.Request=w,h.Response=c,h.fetch=P,h})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var l=b.fetch?b:y;d=l.fetch,d.default=l.fetch,d.fetch=l.fetch,d.Headers=l.Headers,d.Request=l.Request,d.Response=l.Response,_.exports=d})(E,E.exports)),E.exports}var S=Z();const J=$(S),Q=X({__proto__:null,default:J},[S]);export{Q as b};
@@ -0,0 +1 @@
1
+ import{c}from"./index-DjZFLwif.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
@@ -0,0 +1 @@
1
+ import{c}from"./index-DjZFLwif.js";const t=c("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
@@ -0,0 +1 @@
1
+ import{c}from"./index-DjZFLwif.js";const p=c("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
@@ -0,0 +1 @@
1
+ import{c}from"./index-DjZFLwif.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
@@ -0,0 +1 @@
1
+ import{r as n,j as e,H as b,b as o}from"./index-DjZFLwif.js";const h=({isOpen:s,title:i,description:l,confirmLabel:d,cancelLabel:m="Cancel",destructive:u=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=n.useRef(null),a=n.useCallback(t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),r())},[r]);return n.useEffect(()=>{if(s)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[s,a]),n.useEffect(()=>{if(!s)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{t?.isConnected&&t.focus()}},[s]),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:r,className:"backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:m}),e.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",u?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{h as C};
@@ -0,0 +1 @@
1
+ import{q as M,ac as C,ae as L,bt as E,bu as A,r as x,j as p,bv as f,bw as j,bx as k,n as R,w as Q,by as D}from"./index-DjZFLwif.js";import{ah as O,ai as _,aj as q,ak as w,al as z}from"./MailListHeader-DX7_Cewa.js";import{a as N}from"./useLabels-DdQPlRo8.js";import{M as P}from"./enums-CCxx0t2v.js";import{u as U,s as B}from"./search-scope-CFN-gjTv.js";import{n as F}from"./search-query-Cr_ZXBCp.js";import{u as G,p as K}from"./useSearchTokenContext-D5dvdLSW.js";const V=e=>{const{mailboxId:t,messages:i}=e,l=M(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=L({...A(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:E(o),error:o})},onSettled:(o,u,d)=>{O(l,_(q(d.body.messageIds??[],i??[],t)))}});return{applyLabel:x.useCallback((o,u,d)=>{o.length!==0&&w(o,m=>r({body:{messageIds:m,labelId:u,action:d}}))},[r]),isPending:a}};function ne({accountId:e,mailboxId:t,messageIds:i}){const{labels:l}=N(e),{applyLabel:c}=V({mailboxId:t}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${j(a.color)?f[a.color]:f.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(z,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(k,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const $=20,H=new Set(Object.values(P)),J=e=>e!==void 0&&H.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function re({mailboxId:e,filterCategory:t}={}){const{searchQuery:i}=R(),l=G(),c=U({select:s=>s.matches}),r=F(i),{freeText:a,tokens:n}=K(r,l),o=a.length>0,u=n.find(s=>s.type==="category"),d=J(t)??u?.category,m=n.some(s=>s.type==="hasAttachment")?!0:void 0,b=n.some(s=>s.type==="isStarred")?!0:void 0,y=W(n),g=n.find(s=>s.type==="after"),h=n.find(s=>s.type==="before"),I=n.find(s=>s.type==="in"),S=B({matches:c,callerMailboxId:e,inTokenMailboxId:I?.mailboxId}),{data:v,isLoading:T}=Q({...D({query:{query:a,mailboxId:S,limit:$,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...b!==void 0?{hasStars:b}:{},...y!==void 0?{isRead:y}:{},...g?{sentDateFrom:g.epochSeconds}:{},...h?{sentDateTo:h.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:v?.items??[],isLoading:o&&T}}function X(e){return{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,messageId:e.messageId,authenticity:e.authenticity}}function ie(e,t){if(e)return X(e);if(t.messageId&&t.threadId&&t.mailboxId)return{threadId:t.threadId,mailboxId:t.mailboxId,messageId:t.messageId}}export{ne as L,ie as b,re as u};
@@ -1 +1 @@
1
- import{a as o}from"./index-xOALrEh8.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
1
+ import{c as o}from"./index-DjZFLwif.js";const a=o("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
@@ -0,0 +1 @@
1
+ const e={synced:"synced",failed:"failed"},a={uncategorized:"uncategorized",personal:"personal",newsletter:"newsletter",marketing:"marketing",automated:"automated",transactional:"transactional",social:"social"},o={Lookalike:"Lookalike",Unrelated:"Unrelated"},t={MoveToInbox:"MoveToInbox",MoveToJunk:"MoveToJunk"},n={Attachment:"attachment"};export{n as C,o as D,a as M,t as P,e as a};
@@ -0,0 +1 @@
1
+ import{q as X,ae as Z,aP as ee,aQ as te,r as x,j as t,aR as ae,aS as se,am as R,B as N,au as ie,aA as ne,aT as re,aU as oe,T as le,w as P,v as ce,y as de,D as me,o as ue,W as pe,ay as xe,aC as fe}from"./index-DjZFLwif.js";import{S as he}from"./settings-screen-DBHgQU-S.js";import{B as ge}from"./bottom-sheet-Bw79dNtH.js";import{u as ve}from"./useMediaQuery-fUhUpE77.js";import{u as be,a as ye,b as je,f as Ne}from"./move-options-CdaX2x7F.js";import{u as Ce,a as Se}from"./useLabels-DdQPlRo8.js";import{b as Fe,N as S,p as Me,u as Ie,r as we,a as Ee,S as L,c as Oe,n as De,f as Ae,d as Le,e as Te,g as ke}from"./useFilters-CxQU6LTN.js";import{C as A}from"./circle-check-DizPpF0Y.js";import{E as $}from"./ErrorState-CN4Cwb5A.js";import"./avatar-DTwl3jb1.js";import"./menu-Cpsp0ZMZ.js";import"./circle-help-DPkDkgdF.js";import"./enums-CCxx0t2v.js";const Re=(e,a)=>{const r=X(),i=Z({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:Fe(e)}),a&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:a}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!a||c({path:{accountId:e,filterId:a},body:d})},[e,a,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Pe=(e,a=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,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"?$e(e.expiresAt):void 0,name:e.name}),$e=e=>{if(!e)return"";const a=Date.parse(e);if(Number.isNaN(a))return"";const r=new Date(a),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},T=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"}),z=(e,a)=>T(e)!==T(a),k=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),U=(e,a)=>k(e)!==k(a),ze=(e,a)=>{const r={},i=(e.name??"").trim();return i!==(a.name??"").trim()&&(r.name=i),z(e,a)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),U(e,a)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=Me(e.until??""))),r};function Ue({accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>Pe(a,g),[a,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,b]=x.useState(!1),M=x.useRef(0),{count:C}=Ie(e,we(n)),j=Re(e,a.filterId),v=Ee(e),{createFolderIn:F}=be(e),{createLabel:E}=Ce(e),I=async o=>{const s=await E(o);return{id:s.labelId,name:s.name,color:s.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),w=o=>{const s=n.clauses.find(y=>y.id===o);s&&u({mode:"edit",clauseId:o,draft:{field:s.field,value:s.value}})},O=o=>u(s=>s&&{...s,draft:{...s.draft,field:o}}),_=o=>u(s=>s&&{...s,draft:{...s.draft,value:o}}),B=()=>{if(!m)return;const o=m.draft.field,s=De(o,m.draft.value);s!==""&&(l(y=>m.mode==="edit"&&m.clauseId?{...y,clauses:y.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:s}:D)}:(M.current+=1,{...y,clauses:[...y.clauses,{id:`new-${M.current}`,field:o,value:s}]})),u(void 0))},K=o=>l(s=>({...s,clauses:s.clauses.filter(y=>y.id!==o)})),Q=o=>l(s=>({...s,matchOperator:o})),q=o=>l(s=>({...s,moveMailboxId:o||void 0})),G=o=>l(s=>({...s,labelId:o||void 0})),H=o=>l(s=>({...s,name:o})),J=o=>l(s=>({...s,scope:o,until:o==="until"?s.until:void 0})),V=o=>l(s=>({...s,until:o})),W=()=>{const o=z(n,f)||U(n,f),s=ze(n,f);if(Object.keys(s).length===0){d();return}b(o),j.updateFilter(s)},Y=()=>v.start(Oe(n));return v.isStarting||v.isRunning||v.isDone?t.jsx(Qe,{progress:v.progress,isDone:v.isDone,onClose:d}):j.isPending?t.jsx(_e,{}):j.isError?t.jsx(qe,{onRetry:j.reset,onClose:d}):j.isSuccess?h?t.jsx(Ke,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Be,{onClose:d}):t.jsx(se,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:K,onChangeDraftField:O,onChangeDraftValue:_,onSubmitClause:B,onCancelClause:()=>u(void 0),onChangeMatchOperator:Q,onChangeMove:q,onCreateFolder:F,onChangeLabel:G,onCreateLabel:I,onChangeName:H,onChangeScope:J,onChangeUntil:V,onCommit:W,onCancel:d})}function _e(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Be({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function Ke({preview:e,blocked:a,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{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(N,{variant:"primary",onClick:r,disabled:a,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Qe({progress:e,isDone:a,onClose:r}){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(A,{className:"size-8 text-positive"}):t.jsx(R,{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(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function qe({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(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:a,children:"Not now"})]})]})}function Ge({accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=ve(),n=t.jsx(Ue,{accountId:e,filter:a,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(ie,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(ge,{open:!0,onClose:d,dismissLabel:"Dismiss filter rule",children:n})}function He({filters:e,mailboxName:a,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=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(n=>{const l=Ae(n,f),m=l==="Expired",u=n.actionMailboxId!==S?a(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,b=Le(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.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 ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(ne,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&b?m?` · expired ${b}`:` · until ${b}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(re,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(oe,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(le,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const Je=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 Ve({account:e}){const a=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=Te(a),{deleteFilter:f,deletingFilterId:n}=ke(a),[l,m]=x.useState(),{data:u}=P({...ce({path:{accountId:a}}),staleTime:1/0}),h=ye(),b=x.useMemo(()=>de(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const w=u?.items.find(O=>O.mailboxId===p);if(w)return me(w,b.get(p),h)},[u?.items,b,h]),C=x.useMemo(()=>je({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),j=Ne(u?.items??[]),{labels:v}=Se(a),F=x.useMemo(()=>v.map(p=>({id:p.labelId,name:p.name,color:p.color})),[v]),E=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);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(Ge,{accountId:a,filter:I,folders:C,delimiter:j,labels:F,onClose:()=>m(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}`}):c?t.jsx($,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(He,{filters:r,mailboxName:M,labelById:E,onEdit:m,onDelete:f,deletingFilterId:n})]})}function ct(){const e=ue(),[a,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=P(pe()),n=l=>{const m=fe[l];m&&e({to:m})};return t.jsx(he,{items:xe,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Je,helpOpen:a,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx($,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):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(l=>t.jsx(Ve,{account:l},l.accountId))})})}export{Ve as AccountFilters,ct as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-xOALrEh8.js";import{E as o}from"./ErrorState-DiX_zNTK.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-DjZFLwif.js";import{E as o}from"./ErrorState-CN4Cwb5A.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{a3 as i,j as o,_ as e}from"./index-DjZFLwif.js";import{a as m}from"./search-view-ClRhrhjK.js";import{F as t}from"./FlaggedPane-MgcE5bKj.js";import{u as p}from"./useSearchMirror-HHNbELBF.js";import"./search-scope-CFN-gjTv.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./MailListHeader-DX7_Cewa.js";import"./search-token-index-CxMDhXuP.js";import"./useMediaQuery-fUhUpE77.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";function b(){const{selectedMessageId:r}=i.useSearch();return p({to:"/mail/flagged"}),o.jsx(t,{selectedMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(e,{}),intelligence:o.jsx(t.Intelligence,{}),hasThread:!!r})})}export{b as component};
@@ -0,0 +1 @@
1
+ import{j as e,B as j,T as R,aV as G,r as u,au as H,X as V,aD as ie,ak as Y,F as le,aW as W,aX as ce,aj as de,an as me,aY as xe,q as X,P as Z,$ as J,aZ as ue,a_ as he,a$ as fe,b0 as U,D as z,y as ee,am as q,az as se,b1 as pe,aa as ge,o as be,w as te,W as je,ay as ve,aC as ye,v as Ne,ae as B,b2 as Ce,b3 as ke,b4 as Me,b5 as we}from"./index-DjZFLwif.js";import{P as Ie}from"./pencil-Cm8cWZKn.js";import{S as Se}from"./settings-screen-DBHgQU-S.js";import{c as Oe,d as P,e as De,M as Ae,i as K,u as ae,a as re,b as Ee,m as Q,g as Te}from"./move-options-CdaX2x7F.js";import{E as ne}from"./ErrorState-CN4Cwb5A.js";import"./avatar-DTwl3jb1.js";import"./menu-Cpsp0ZMZ.js";import"./circle-help-DPkDkgdF.js";import"./enums-CCxx0t2v.js";const Pe=({label:s,onRename:n,onDelete:t,deleteBlockedReason:i,renameLabel:d=c=>`Rename ${c}`,deleteLabel:r=c=>`Delete ${c}`})=>{const c=i?`${r(s)} — ${i}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Ie,{className:"size-3.5"}),"aria-label":d(s),onClick:n}),e.jsx("span",{title:i,children:e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(R,{className:"size-3.5"}),"aria-label":c,disabled:i!==void 0,onClick:t})})]})},Fe=({folders:s,onRename:n,onDelete:t,onCreateFolder:i,delimiter:d,labels:r})=>{const c=new Map(s.map(o=>[o.id,o]));return e.jsx(G,{folders:s,onCreateFolder:i,delimiter:d,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o,...r},rowActions:o=>{const a=c.get(o.id);return a?e.jsx(Pe,{label:a.label,deleteBlockedReason:a.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>n(a),onDelete:()=>t(a)}):null}})},Re=({open:s,folderLabel:n,defaultLabel:t,name:i,onNameChange:d,onSubmit:r,onClose:c,pending:o=!1,error:a})=>{const l=u.useId(),p=`Rename ${n}`;return s?e.jsxs(H,{open:s,onClose:c,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(j,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:c,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(ie,{htmlFor:l,children:"Folder name"}),e.jsx(Y,{id:l,value:i,placeholder:t,onChange:m=>d(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.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:t}),"."]}),a&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:a})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:c,children:"Cancel"}),e.jsx(j,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},ze=["inbox","drafts","sent","archive","junk","trash"],L="";function Le(s){const n=s.messageCount===1?"msg":"msgs";return`${W(s.providerPath)} · ${s.messageCount} ${n}`}function $e({role:s,folders:n,appointedId:t,displayName:i,onAppoint:d,onRename:r}){const[c,o]=u.useState(i),a=n.find(m=>m.mailboxId===t)??null,l=xe(s),p=a!=null&&c.trim()!==i.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:[ce(s),l]}),e.jsxs(de,{className:"w-56 shrink-0",value:t??L,"aria-label":`Folder for ${l}`,onChange:m=>d(s,m.target.value===L?null:m.target.value),children:[e.jsx("option",{value:L,children:"None"}),n.map(m=>e.jsx("option",{value:m.mailboxId,children:Le(m)},m.mailboxId))]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"flex-1",value:c,placeholder:l,"aria-label":`Display name for ${l}`,onChange:m=>o(m.target.value)}),p&&e.jsx(j,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(me,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(a.mailboxId,c)})]})]}),a&&e.jsxs("span",{className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:a.providerPath,children:[a.providerPath," · ",a.messageCount," ",a.messageCount===1?"message":"messages"]})]})}function _e({accountEmail:s,folders:n,appointments:t,displayNames:i={},onAppoint:d,onRename:r}){const c=new Set(Object.values(t).filter(a=>a!=null)),o=n.filter(a=>!c.has(a.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 — ",s]}),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:ze.map(a=>{const l=t[a]??null;return e.jsx($e,{role:a,folders:n,appointedId:l,displayName:l?i[l]??"":"",onAppoint:d,onRename:r},a)})}),o.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:o.map(a=>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(le,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:W(a.providerPath)}),e.jsxs("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:[a.messageCount," ",a.messageCount===1?"message":"messages"]})]},a.mailboxId))})]})]})}const oe=50,qe=s=>s instanceof Error?s.message:"Something went wrong.",T=s=>s.then(n=>({ok:!0,value:n}),n=>({ok:!1,error:qe(n)})),Be=async(s,n,t,i)=>{const d=[];let r;for(let c=0;c<oe;c+=1){if(i.aborted)return d;const{data:o}=await U({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const a of o.items)if(!a.isDeleted&&!n.has(a.messageId)&&!d.includes(a.messageId)&&(d.push(a.messageId),d.length>=t))return d;if(!o.continuationToken)break;r=o.continuationToken}return d},Ke=async(s,n)=>{let t=0,i;for(let d=0;d<oe;d+=1){if(n.aborted)return t;const{data:r}=await U({path:{mailboxId:s},query:{order:"desc",continuationToken:i},throwOnError:!0});for(const c of r.items)c.isDeleted||(t+=1);if(!r.continuationToken)break;i=r.continuationToken}return t};function Qe({accountId:s,mailboxId:n,onDeleted:t}){const i=X(),[d,r]=u.useState("idle"),[c,o]=u.useState(null),[a,l]=u.useState(),p=u.useRef(null),m=u.useCallback(()=>{i.invalidateQueries({queryKey:Z({path:{accountId:s}})}),i.invalidateQueries({queryKey:J()})},[i,s]),N=u.useCallback(async()=>{r("deleting");const b=await T(ue({path:{accountId:s,mailboxId:n},throwOnError:!0}));if(!b.ok){l(b.error),r("error");return}m(),r("done"),t()},[s,n,m,t]),C=u.useCallback(()=>he({path:{accountId:s},throwOnError:!0}).then(({data:b})=>b.items.find(g=>g.mailboxId===n)?.messageCount??0),[s,n]),E=u.useCallback(()=>{p.current?.abort()},[]),w=u.useCallback(async b=>{const g=new AbortController;p.current=g;const{signal:f}=g;r("moving"),l(void 0);const I=await T(C());if(f.aborted)return;if(!I.ok){l(I.error),r("error");return}let h=Oe(I.value);o(h);const k=new Set;for(;;){if(f.aborted)return;const v=await T(Be(n,k,Ae,f));if(f.aborted)return;if(!v.ok){h=P(h,v.error),o(h),l(v.error),r("error");return}const M=v.value;if(M.length===0)break;const D=await T(fe({body:{messageIds:M,destinationMailboxId:b},throwOnError:!0}));if(f.aborted)return;if(!D.ok){h=P(h,D.error),o(h),l(D.error),r("error");return}for(const S of M)k.add(S);h=De(h,M.length),o(h)}const y=await T(Ke(n,f));if(!f.aborted){if(!y.ok){h=P(h,y.error),o(h),l(y.error),r("error");return}if(y.value>0){const v=`${y.value} ${y.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;h=P(h,v),o(h),l(v),r("error"),m();return}await N()}},[n,C,N,m]),A=u.useCallback(()=>{p.current?.abort(),p.current=null,r("idle"),o(null),l(void 0)},[]);return{phase:d,progress:c,errorMessage:a,deleteMailbox:N,moveThenDelete:w,cancel:E,reset:A}}const F=s=>`${s} ${s===1?"email":"emails"}`;function Ge({open:s,accountId:n,folder:t,mailboxes:i,appointments:d,onClose:r}){const[c,o]=u.useState(()=>K(t.messageCount)),[a,l]=u.useState(),{createFolderIn:p}=ae(n),m=re(),{phase:N,progress:C,errorMessage:E,deleteMailbox:w,moveThenDelete:A,cancel:b,reset:g}=Qe({accountId:n,mailboxId:t.mailboxId,onDeleted:r});u.useEffect(()=>{s&&(o(K(t.messageCount)),g())},[s,t.messageCount,g]),u.useEffect(()=>{s&&l(void 0)},[s]),u.useEffect(()=>b,[b]);const f=u.useCallback(()=>{b(),r()},[b,r]),I=u.useMemo(()=>Ee({mailboxes:i,folderAppointments:d,excludeMailboxId:t.mailboxId,translator:m}),[i,d,t.mailboxId,m]),h=I.find(M=>M.id===a),k=u.useMemo(()=>z(t,ee(d).get(t.mailboxId),m),[t,d,m]);if(!s)return null;const y=`Delete ${k}`,v=N==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(q,{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:C?Q(C):"Moved 0 of 0"})]}):N==="deleting"||N==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):N==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(se,{tone:"danger",variant:"soft",children:E??"Something went wrong. Please try again."}),C&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[Q(C),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:f,children:"Close"})})]}):c==="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:k}),"? 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(j,{variant:"secondary",size:"sm",onClick:f,children:"Cancel"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(R,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder"})]})]}):c==="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:k})," holds"," ",F(t.messageCount),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>o("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(R,{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:()=>o("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(pe,{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(j,{variant:"secondary",size:"sm",onClick:f,children:"Cancel"})})]}):c==="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:k})," and its"," ",F(t.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(j,{variant:"secondary",size:"sm",onClick:()=>o("choose-fate"),children:"Back"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(R,{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 ",F(t.messageCount)," in"," ",e.jsx("strong",{className:"text-fg",children:k})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(G,{folders:I,selectedId:a,delimiter:i[0]?.hierarchyDelimiter??"/",onSelect:l,onCreateFolder:p,onCancel:()=>{l(void 0),o("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),h&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(j,{variant:"danger",onClick:()=>A(h.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${F(t.messageCount)} to ${h.label}`})})})]});return e.jsxs(H,{open:s,onClose:f,title:y,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(ge,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:y}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(V,{className:"size-3.5"}),onClick:f,"aria-label":"Cancel"})]}),v]})}const He=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 Ve({account:s}){const n=X(),t=s.accountId,i=re(),{data:d,isPending:r,isError:c,error:o,refetch:a}=te(Ne({path:{accountId:t}})),{createFolderIn:l}=ae(t),p=B({...Ce(),onSuccess:()=>{n.invalidateQueries({queryKey:J()})}}),m=B({...ke(),onSuccess:()=>{n.invalidateQueries({queryKey:Z({path:{accountId:t}})})}}),[N,C]=u.useState(),[E,w]=u.useState(),[A,b]=u.useState(""),g=u.useMemo(()=>d?.items??[],[d]),f=u.useMemo(()=>ee(s.folderAppointments),[s.folderAppointments]),I=u.useMemo(()=>g.map(x=>({id:x.mailboxId,label:z(x,f.get(x.mailboxId),i),path:x.fullPath,deleteBlockedReason:Te(x,g,s.folderAppointments).message})),[g,f,i,s.folderAppointments]),h=(x,O)=>{p.mutate({path:{accountId:t,role:we[x]},body:{mailboxId:O}})},k=(x,O)=>{const _=O.trim();m.mutate({path:{accountId:t,mailboxId:x},body:{displayNameOverride:_===""?null:_}})};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 ${s.email}`});if(c)return e.jsx(ne,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:o,onRetry:()=>{a()}});const y=g.map(x=>({mailboxId:x.mailboxId,providerPath:x.fullPath,messageCount:x.messageCount})),v={};for(const x of s.folderAppointments){const O=Me[x.role];O&&(v[O]=x.mailboxId??null)}const M={};for(const x of g)x.displayNameOverride&&(M[x.mailboxId]=x.displayNameOverride);const D=x=>g.find(O=>O.mailboxId===x),S=D(E),$=D(N);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||m.isError)&&e.jsx(se,{tone:"danger",variant:"soft",children:"Couldn't save that change. Please try again."}),e.jsx(_e,{accountEmail:s.email,folders:y,appointments:v,displayNames:M,onAppoint:h,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Fe,{folders:I,delimiter:g[0]?.hierarchyDelimiter??"/",onCreateFolder:l,onRename:x=>{w(x.id),b(D(x.id)?.displayNameOverride?.trim()??"")},onDelete:x=>C(x.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),S&&e.jsx(Re,{open:!0,folderLabel:z(S,f.get(S.mailboxId),i),defaultLabel:z({fullPath:S.fullPath},f.get(S.mailboxId),i),name:A,onNameChange:b,pending:m.isPending,error:m.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const x=A.trim();m.mutate({path:{accountId:t,mailboxId:S.mailboxId},body:{displayNameOverride:x===""?null:x}},{onSuccess:()=>w(void 0)})},onClose:()=>w(void 0)}),$&&e.jsx(Ge,{open:!0,accountId:t,folder:$,mailboxes:g,appointments:s.folderAppointments,onClose:()=>C(void 0)})]})}function as(){const s=be(),[n,t]=u.useState(!0),{data:i,isPending:d,isError:r,error:c,refetch:o}=te(je()),a=l=>{const p=ye[l];p&&s({to:p})};return e.jsx(Se,{items:ve,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:He,helpOpen:n,onToggleHelp:()=>t(l=>!l),onSelect:a,onBackToMail:()=>{s({to:"/mail"})},children:d?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(ne,{title:"Couldn't load accounts",error:c,onRetry:()=>{o()}}):i.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:i.accounts.map(l=>e.jsx(Ve,{account:l},l.accountId))})})}export{as as component};
@@ -1 +1 @@
1
- const c=()=>typeof navigator<"u"&&(navigator.language||navigator.languages?.[0])||"en-US",g=(e,t)=>new Intl.NumberFormat(c(),t).format(e),y=/^-?\d+$/,f=e=>{if(e instanceof Date)return e;if(typeof e=="number")return new Date(e);if(typeof e=="string"){const t=e.trim();return y.test(t)?new Date(Number(t)):new Date(t)}return new Date(Number.NaN)},d=e=>Number.isFinite(e.getTime()),o=(e,t)=>{const n=f(e);return d(n)?new Intl.DateTimeFormat(c(),t).format(n):""},D=(e,t)=>o(e,{short:{month:"short",day:"numeric"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"},time:{hour:"numeric",minute:"numeric"},datetime:{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}}[t]),l=e=>{const t=f(e);if(!d(t))return"";const n=new Intl.RelativeTimeFormat(c(),{numeric:"auto"}),m=Date.now(),r=t.getTime()-m,s=Math.round(r/1e3),a=Math.round(r/(1e3*60)),i=Math.round(r/(1e3*60*60)),u=Math.round(r/(1e3*60*60*24)),h=Math.round(r/(1e3*60*60*24*7));return Math.abs(s)<60?n.format(s,"second"):Math.abs(a)<60?n.format(a,"minute"):Math.abs(i)<24?n.format(i,"hour"):Math.abs(u)<7?n.format(u,"day"):Math.abs(h)<4?n.format(h,"week"):D(t,"medium")},w=e=>{const t=f(e);if(!d(t))return"";const n=new Date,m=t.toDateString()===n.toDateString(),r=new Date(n);r.setDate(r.getDate()-1);const s=t.toDateString()===r.toDateString(),a=new Date(n);a.setDate(a.getDate()-6);const i=t>=a&&t<n,u=t.getFullYear()===n.getFullYear();return m?o(t,{hour:"numeric",minute:"numeric"}):s?"Yesterday":i?o(t,{weekday:"long"}):u?o(t,{month:"short",day:"numeric"}):o(t,{month:"short",day:"numeric",year:"numeric"})},T=e=>`Move ${e===1?"1":g(e)} ${e===1?"message":"messages"} to Trash?`;export{w as a,T as b,g as c,o as d,l as e,D as f,f as t};
1
+ const c=()=>typeof navigator<"u"&&(navigator.language||navigator.languages?.[0])||"en-US",g=(e,t)=>new Intl.NumberFormat(c(),t).format(e),y=/^-?\d+$/,f=e=>{if(e instanceof Date)return e;if(typeof e=="number")return new Date(e);if(typeof e=="string"){const t=e.trim();return y.test(t)?new Date(Number(t)):new Date(t)}return new Date(Number.NaN)},d=e=>Number.isFinite(e.getTime()),o=(e,t)=>{const n=f(e);return d(n)?new Intl.DateTimeFormat(c(),t).format(n):""},D=(e,t)=>o(e,{short:{month:"short",day:"numeric"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"},time:{hour:"numeric",minute:"numeric"},datetime:{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}}[t]),l=e=>{const t=f(e);if(!d(t))return"";const n=new Intl.RelativeTimeFormat(c(),{numeric:"auto"}),m=Date.now(),r=t.getTime()-m,s=Math.round(r/1e3),a=Math.round(r/(1e3*60)),i=Math.round(r/(1e3*60*60)),u=Math.round(r/(1e3*60*60*24)),h=Math.round(r/(1e3*60*60*24*7));return Math.abs(s)<60?n.format(s,"second"):Math.abs(a)<60?n.format(a,"minute"):Math.abs(i)<24?n.format(i,"hour"):Math.abs(u)<7?n.format(u,"day"):Math.abs(h)<4?n.format(h,"week"):D(t,"medium")},w=e=>{const t=f(e);if(!d(t))return"";const n=new Date,m=t.toDateString()===n.toDateString(),r=new Date(n);r.setDate(r.getDate()-1);const s=t.toDateString()===r.toDateString(),a=new Date(n);a.setDate(a.getDate()-6);const i=t>=a&&t<n,u=t.getFullYear()===n.getFullYear();return m?o(t,{hour:"numeric",minute:"numeric"}):s?"Yesterday":i?o(t,{weekday:"long"}):u?o(t,{month:"short",day:"numeric"}):o(t,{month:"short",day:"numeric",year:"numeric"})},T=e=>`Move ${e===1?"1":g(e)} ${e===1?"message":"messages"} to Trash?`;export{o as a,w as b,g as c,T as d,D as e,l as f,f as t};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-DjZFLwif.js";import{F as r}from"./FlaggedPane-MgcE5bKj.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./search-scope-CFN-gjTv.js";import"./MailListHeader-DX7_Cewa.js";import"./search-token-index-CxMDhXuP.js";import"./useMediaQuery-fUhUpE77.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";function q(){return o.jsx(r.Reading,{})}export{q as component};
@@ -0,0 +1 @@
1
+ import{j as r}from"./index-DjZFLwif.js";import{B as o}from"./BriefPane-CyCnqfV1.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./search-scope-CFN-gjTv.js";import"./MailListHeader-DX7_Cewa.js";import"./search-token-index-CxMDhXuP.js";import"./useMediaQuery-fUhUpE77.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"./useRefreshControl-BsKYVbfM.js";import"./circle-check-big-ChA18R4j.js";import"./useLabels-DdQPlRo8.js";import"./conversation-target-B0jE-e47.js";import"./search-query-Cr_ZXBCp.js";function z(){return r.jsx(o.Reading,{})}export{z as component};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-DjZFLwif.js";import{M as i}from"./MailboxPane-Db0hba1S.js";import"./useSearchTokenContext-D5dvdLSW.js";import"./kbd-C0TyJDqO.js";import"./enums-CCxx0t2v.js";import"./search-scope-CFN-gjTv.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 G(){return o.jsx(i.Reading,{})}export{G as component};