@remit/web-client-dist 0.0.298 → 0.0.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/assets/ComposeBody-juaUBP4S.js +29 -0
  2. package/assets/{ConfirmDialog-x_WinEM5.js → ConfirmDialog-ibkpk4-g.js} +1 -1
  3. package/assets/{ErrorState-DgMXA1BY.js → ErrorState-fTSnQm24.js} +1 -1
  4. package/assets/{OnboardingWizard-DkiUcFSm.js → OnboardingWizard-fxENOx3_.js} +1 -1
  5. package/assets/{account-form-helpers-BIwq0CFm.js → account-form-helpers-tzWGkuwE.js} +1 -1
  6. package/assets/accounts-DhTQAW84.js +1 -0
  7. package/assets/{advanced-aIj-4ZxN.js → advanced-T1USmwbt.js} +1 -1
  8. package/assets/{appearance-D3krKHAG.js → appearance-HxmtBphn.js} +1 -1
  9. package/assets/{avatar-CX7bOsD1.js → avatar-CNVLVI-H.js} +1 -1
  10. package/assets/{browser-ponyfill-Bge205Bk.js → browser-ponyfill-vZmAO0yp.js} +2 -2
  11. package/assets/{circle-check-C4qplern.js → circle-check-YlWZv9Mc.js} +1 -1
  12. package/assets/{download-By57JxX8.js → download-BPUwUMyv.js} +1 -1
  13. package/assets/{filters-CSVp_AW8.js → filters-DvBwrQoM.js} +1 -1
  14. package/assets/{flagged-4lYHMqPG.js → flagged-C-GEyHjm.js} +1 -1
  15. package/assets/{folders-BgsIDxnx.js → folders--i3KprM0.js} +1 -1
  16. package/assets/{index-CGItbOSw.js → index-9nXytSEy.js} +1 -1
  17. package/assets/{index-bW4RCdiF.js → index-VdDpazZy.js} +59 -59
  18. package/assets/index-VtPj5yVn.js +1 -0
  19. package/assets/{index-Cr66tnb-.css → index-rCP-8V3i.css} +1 -1
  20. package/assets/{kbd-C5C_2AcW.js → kbd-C_D2WkrL.js} +1 -1
  21. package/assets/{labels-GIRUAoSh.js → labels-CVh5IQqs.js} +1 -1
  22. package/assets/mail-C5gYU3Wn.js +118 -0
  23. package/assets/{move-options-DNUvUPeB.js → move-options-AJw5FKbX.js} +1 -1
  24. package/assets/{onboarding-CZQ0DJ5g.js → onboarding-Tw77yHgF.js} +1 -1
  25. package/assets/{pencil-Daerndfj.js → pencil-QGnkKuCC.js} +1 -1
  26. package/assets/{senders-BW3o0tcC.js → senders-CVxr8qGf.js} +1 -1
  27. package/assets/settings-CYzcIkDy.js +1 -0
  28. package/assets/{settings-screen-CMhBy_N3.js → settings-screen-DT-hrfDz.js} +1 -1
  29. package/assets/{shield-check-B4SpLWDJ.js → shield-check-COYytpct.js} +1 -1
  30. package/assets/{suggested-vips-DVBki8yW.js → suggested-vips-ce9dYb3K.js} +1 -1
  31. package/assets/{useDebouncedValue-CrW9xaZB.js → useDebouncedValue-jZo-6AMN.js} +1 -1
  32. package/assets/{useFilters-CRbqtIL9.js → useFilters-DywOhPbr.js} +1 -1
  33. package/assets/{useLabels-3wBUjUtC.js → useLabels-B-Dlq3rb.js} +1 -1
  34. package/assets/{useSignature-lw54OO-w.js → useSignature-CrZdaMCZ.js} +1 -1
  35. package/index.html +2 -2
  36. package/package.json +1 -1
  37. package/assets/ComposeBody-IY39gbj9.js +0 -29
  38. package/assets/accounts-C5kliEIy.js +0 -1
  39. package/assets/index-BasS0sR4.js +0 -1
  40. package/assets/mail-BaFZoOZu.js +0 -118
  41. package/assets/settings-CewotkR_.js +0 -1
@@ -1 +0,0 @@
1
- import{j as i,U as nt,r as C,d as jt,X as Oe,R as J,ab as Zt,aJ as Ne,bZ as As,bX as Pe,b_ as _s,b$ as Ps,B as se,c0 as Es,c1 as ge,c2 as St,L as et,l as wt,at as Nt,c3 as Vs,c4 as De,c5 as be,c6 as Tt,au as ks,c7 as Ds,c8 as Fs,D as Qt,c9 as At,aq as Cs,aG as Os,aR as Is,ca as Rs,cb as Ms,cc as Us,G as _t,e as Ls,cd as Pt,ce as Hs,T as zs}from"./index-bW4RCdiF.js";import{u as Bs,R as qs}from"./useSignature-lw54OO-w.js";import{S as $s,A as Ws}from"./settings-screen-CMhBy_N3.js";import{g as Et,P as Gs,s as Ue,u as Ks,O as Ys}from"./OnboardingWizard-DkiUcFSm.js";import{c as Zs,b as Vt,d as Qs}from"./account-form-helpers-BIwq0CFm.js";import{D as Xs}from"./download-By57JxX8.js";import{E as Js}from"./ErrorState-DgMXA1BY.js";import{e as er}from"./format-CKZmh-Ru.js";import"./avatar-CX7bOsD1.js";import"./kbd-C5C_2AcW.js";function tr({title:e,description:s,action:t}){return i.jsxs("div",{className:"rounded-sm border border-danger/50",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[i.jsx(nt,{className:"size-4 text-danger"}),i.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),i.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:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-fg",children:e}),i.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),i.jsx("div",{className:"shrink-0",children:t})]})]})}function kt({isOpen:e,onClose:s,title:t,children:a,footer:c}){return C.useEffect(()=>{if(!e)return;const d=n=>{n.key==="Escape"&&s()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:jt("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),i.jsxs("div",{className:jt("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:[i.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-line px-4",children:[i.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),i.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:i.jsx(Oe,{className:"size-5"})})]}),i.jsxs("div",{className:"flex h-[calc(100%-3.5rem)] flex-col",children:[i.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),c&&i.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:c})]})]})]})}var Ie=e=>e.type==="checkbox",je=e=>e instanceof Date,Y=e=>e==null;const ot=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&ot(e)&&!je(e),sr=e=>z(e)&&e.target?Ie(e.target)?e.target.checked:e.target.value:e,rr=(e,s)=>s.split(".").some((t,a,c)=>!isNaN(Number(t))&&e.has(c.slice(0,a).join("."))),Xt=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},$e=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($e&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&Xt(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const c in e)Object.prototype.hasOwnProperty.call(e,c)&&(a[c]=B(e[c]));return a}const Ae={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"},Jt="root",lt=["__proto__","constructor","prototype"],ir=/^\w*$/;var Re=e=>ir.test(e),U=e=>e===void 0;const ar=/[.[\]'"]/;var We=e=>e.split(ar).filter(Boolean),g=(e,s,t)=>{if(!s||!z(e))return t;const a=Re(s)?[s]:We(s);if(a.some(d=>lt.includes(d)))return t;const c=a.reduce((d,n)=>Y(d)?void 0:d[n],e);return U(c)||c===e?U(e[s])?t:e[s]:c},fe=e=>typeof e=="boolean",ne=e=>typeof e=="function",F=(e,s,t)=>{let a=-1;const c=Re(s)?[s]:We(s),d=c.length,n=d-1;for(;++a<d;){const u=c[a];let j=t;if(a!==n){const E=e[u];j=z(E)||Array.isArray(E)?E:isNaN(+c[a+1])?{}:[]}if(lt.includes(u))return;e[u]=j,e=e[u]}};const nr=J.createContext(null);nr.displayName="HookFormControlContext";var or=(e,s,t,a=!0)=>{const c={};for(const d in e)Object.defineProperty(c,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!a||ue.all),e[n]}});return c};const lr=$e?J.useLayoutEffect:J.useEffect;var Z=e=>typeof e=="string",cr=(e,s,t,a,c)=>Z(e)?(a&&s.watch.add(e),g(t,e,c)):Array.isArray(e)?e.map(d=>(a&&s.watch.add(d),g(t,d))):(a&&(s.watchAll=!0),t),tt=e=>Y(e)||!ot(e);const Dt=(e,s)=>s.length===0&&!Array.isArray(e)&&!Xt(e);function me(e,s,t=new WeakMap){if(e===s)return!0;if(tt(e)||tt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),c=Object.keys(s);if(a.length!==c.length)return!1;if(Dt(e,a)||Dt(s,c))return Object.is(e,s);if(!a.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 a){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(z(u)||Array.isArray(u))&&(z(j)||Array.isArray(j))?!me(u,j,t):!Object.is(u,j))return!1}}return!0}var Le=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),Qe=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Ce=(e,s,t,a)=>{for(const c of t||Object.keys(e)){const d=g(e,c);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],c)&&!a)return!0;if(n.ref&&s(n.ref,n.name)&&!a)return!0;if(Ce(u,s))break}else if(z(u)&&Ce(u,s))break}}};var Ft=(e,s,t)=>{const a=g(e,t),c=Array.isArray(a)?a:[];return F(c,Jt,s[t]),F(e,t,c),e},K=e=>z(e)&&!Object.keys(e).length,ct=e=>e.type==="file",Be=e=>{if(!$e)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},dt=e=>e.type==="radio",qe=e=>e instanceof RegExp,ut=(e,s,t,a,c)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:c||!0}}:{};const Ct={value:!1,isValid:!1},Ot={value:!0,isValid:!0};var es=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&&!U(e[0].attributes.value)?U(e[0].value)||e[0].value===""?Ot:{value:e[0].value,isValid:!0}:Ot:Ct}return Ct};const It={isValid:!1,value:null};var ts=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,It):It;function Rt(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||fe(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var _e=e=>z(e)&&!qe(e)?e:{value:e,message:""},Mt=async(e,s,t,a,c,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:V,min:H,max:R,pattern:O,validate:A,name:f,valueAsNumber:b,mount:ie}=e._f,N=g(t,f);if(!ie||s.has(f))return{};const W=u?u[0]:n,I=_=>{if(c&&W.reportValidity){const P=fe(_)?"":_||"";u?u.forEach(D=>D.setCustomValidity(P)):W.setCustomValidity(P),W.reportValidity()}},T={},oe=dt(n),re=Ie(n),he=oe||re,le=(b||ct(n))&&U(n.value)&&U(N)||Be(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,G=ut.bind(null,f,a,T),ee=(_,P,D,$=de.maxLength,w=de.minLength)=>{const M=_?P:D;T[f]={type:_?$:w,message:M,ref:n,...G(_?$:w,M)}};if(d?!Array.isArray(N)||!N.length:j&&(!he&&(le||Y(N))||fe(N)&&!N||re&&!es(u).isValid||oe&&!ts(u).isValid)){const{value:_,message:P}=Z(j)?{value:!!j,message:j}:_e(j);if(_&&(T[f]={type:de.required,message:P,ref:W,...G(de.required,P)},!a))return I(P),T}if(!le&&(!Y(H)||!Y(R))){let _,P;const D=_e(R),$=_e(H);if(!Y(N)&&!isNaN(N)){const w=n.valueAsNumber||N&&+N;Y(D.value)||(_=w>D.value),Y($.value)||(P=w<$.value)}else{const w=n.valueAsDate||new Date(N),M=ve=>new Date(new Date().toDateString()+" "+ve),pe=n.type=="time",Q=n.type=="week";Z(D.value)&&N&&(_=pe?M(N)>M(D.value):Q?N>D.value:w>new Date(D.value)),Z($.value)&&N&&(P=pe?M(N)<M($.value):Q?N<$.value:w<new Date($.value))}if((_||P)&&(ee(!!_,D.message,$.message,de.max,de.min),!a))return I(T[f].message),T}if((E||V)&&!le&&(Z(N)||d&&Array.isArray(N))){const _=_e(E),P=_e(V),D=!Y(_.value)&&N.length>+_.value,$=!Y(P.value)&&N.length<+P.value;if((D||$)&&(ee(D,_.message,P.message),!a))return I(T[f].message),T}if(O&&!le&&Z(N)){const{value:_,message:P}=_e(O);if(qe(_)&&!N.match(_)&&(T[f]={type:de.pattern,message:P,ref:n,...G(de.pattern,P)},!a))return I(P),T}if(A){if(ne(A)){const _=await A(N,t),P=Rt(_,W);if(P&&(T[f]={...P,...G(de.validate,P.message)},!a))return I(P.message),T}else if(z(A)){let _={};for(const P in A){if(!K(_)&&!a)break;const D=Rt(await A[P](N,t),W,P);D&&(_={...D,...G(P,D.message)},I(D.message),a&&(T[f]=_))}if(!K(_)&&(T[f]={ref:W,..._},!a))return T}}return I(!0),T},ze=e=>Array.isArray(e)?e:[e],ss=e=>Array.isArray(e)?e.filter(Boolean):[];function dr(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(Y(e)){e=void 0;break}e=e[s[a]],a++}return e}function ur(e){for(const s in e)if(e.hasOwnProperty(s)&&!U(e[s]))return!1;return!0}function q(e,s){if(Z(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:Re(s)?[s]:We(s);if(t.some(n=>lt.includes(String(n))))return e;const a=t.length===1?e:dr(e,t),c=t.length-1,d=t[c];return a&&delete a[d],c!==0&&(z(a)&&K(a)||Array.isArray(a)&&ur(a))&&q(e,t.slice(0,-1)),e}const rs=e=>{const s={};for(const t of Object.keys(e))if(ot(e[t])&&e[t]!==null&&!je(e[t])){const a=rs(e[t]);for(const c of Object.keys(a))s[`${t}.${c}`]=a[c]}else s[t]=e[t];return s},fr=J.createContext(null);fr.displayName="HookFormContext";var Ut=()=>{let e=[];return{get observers(){return e},next:c=>{for(const d of e)d.next&&d.next(c)},subscribe:c=>(e.push(c),{unsubscribe:()=>{e=e.filter(d=>d!==c)}}),unsubscribe:()=>{e=[]}}};function is(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const c=e[a],d=s[a];if(c&&z(c)&&d){const n=is(c,d);z(n)&&(t[a]=n)}else e[a]&&(t[a]=d)}return t}var as=e=>e.type==="select-multiple",mr=e=>dt(e)||Ie(e),Xe=e=>Be(e)&&e.isConnected,hr=e=>{for(const s in e)if(ne(e[s]))return!0;return!1};function ns(e){return Array.isArray(e)||z(e)&&!hr(e)}function os(e){return!!(e&&"_f"in e)}function ls(e){return Array.isArray(e)?!e.some(s=>!U(s)):!Object.keys(e).length}function st(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function rt(e,s={},t){for(const a in e){const c=e[a],d=t&&t[a];ns(c)&&(!Array.isArray(c)||!os(d))?(s[a]=Array.isArray(c)?[]:{},rt(c,s[a],d),ls(s[a])&&st(s,a)):U(c)||(s[a]=!0)}return s}function we(e,s,t,a){t||(t=rt(s,{},a));for(const c in e){const d=e[c],n=a&&a[c];ns(d)&&(!Array.isArray(d)||!os(n))?(U(s)||tt(t[c])?t[c]=rt(d,Array.isArray(d)?[]:{},n):we(d,Y(s)?{}:s[c],t[c],n),ls(t[c])&&st(t,c)):me(d,s[c])?st(t,c):t[c]=!0}return t}var cs=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>U(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):a?a(e):e;function Lt(e){const s=e.ref;return ct(s)?s.files:dt(s)?ts(e.refs).value:as(s)?[...s.selectedOptions].map(({value:t})=>t):Ie(s)?es(e.refs).value:cs(U(s.value)?e.ref.value:s.value,e)}var pr=(e,s,t,a)=>{const c={};for(const d of e){const n=g(s,d);n&&F(c,d,n._f)}return{criteriaMode:t,names:[...e],fields:c,shouldUseNativeValidation:a}},Fe=e=>U(e)?e:qe(e)?e.source:z(e)?qe(e.value)?e.value.source:e.value:e;const Ht="AsyncFunction";var yr=e=>{if(!e||!e.validate)return!1;if(ne(e.validate))return e.validate.constructor.name===Ht;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Ht)return!0}return!1},xr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function zt(e,s,t){const a=g(e,t);if(a||Re(t))return{error:a,name:t};const c=t.split(".");for(;c.length;){const d=c.join("."),n=g(s,d),u=g(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};c.pop()}return{name:t}}var gr=(e,s,t,a)=>{t(e);const{name:c,...d}=e,n=Object.keys(d);return!n.length||a&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!a||ue.all))},vr=(e,s,t)=>!e||!s||e===s||ze(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),br=(e,s,t,a,c)=>c.isOnAll?!1:!t&&c.isOnTouch?!(s||e):(t?a.isOnBlur:c.isOnBlur)?!e:(t?a.isOnChange:c.isOnChange)?e:!0,jr=(e,s)=>!ss(g(e,s)).length&&q(e,s);const Sr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},Je="form",ds={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function wr(e={}){let s={...Sr,...e},t={...B(ds),isLoading:ne(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},c=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:B(c),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 V=0,H=Le(s.mode),R=Le(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},A={...O};let f={...A};const b={array:Ut(),state:Ut()};let ie=0;const N=s.criteriaMode===ue.all,W=(r,o)=>l=>{clearTimeout(E[r]),E[r]=setTimeout(o,l)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(A.isValid||f.isValid||r)){const o=++ie;let l;s.resolver?(l=K((await D()).errors),o===ie&&T()):l=await M({fields:a,onlyCheckValid:!0,eventType:Ae.VALID}),o===ie&&l!==t.isValid&&b.state.next({isValid:l})}},T=(r,o)=>{!s.disabled&&(A.isValidating||A.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(l=>{l&&(o?F(t.validatingFields,l,o):q(t.validatingFields,l))}),b.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},oe=()=>{t.dirtyFields=we(c,d,void 0,a)},re=(r,o=[],l,m,h=!0,x=!0)=>{if(m&&l&&!s.disabled){if(n.action=!0,x&&Array.isArray(g(a,r))){const y=l(g(a,r),m.argA,m.argB);h&&F(a,r,y)}if(x&&Array.isArray(g(t.errors,r))){const y=l(g(t.errors,r),m.argA,m.argB);h&&F(t.errors,r,y),jr(t.errors,r)}if((A.touchedFields||f.touchedFields)&&x&&Array.isArray(g(t.touchedFields,r))){const y=l(g(t.touchedFields,r),m.argA,m.argB);h&&F(t.touchedFields,r,y)}(A.dirtyFields||f.dirtyFields)&&oe(),b.state.next({name:r,isDirty:Q(r,o),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,o)},he=(r,o)=>{F(t.errors,r,o),t.errors={...t.errors},b.state.next({errors:t.errors})},le=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},G=r=>{const o=Re(r)?[r]:We(r);let l=d,m=c;for(let h=0;h<o.length-1;h++){const x=o[h];if(l=Y(l)?l:l[x],m=Y(m)?m:m[x],l===null&&m!==null)return!0}return!1},ee=(r,o,l,m)=>{const h=g(a,r);if(h){if(G(r))return;const x=U(g(d,r)),y=g(d,r,U(l)?g(c,r):l);U(y)||m&&m.defaultChecked||o?F(d,r,o?y:Lt(h._f)):k(r,y),n.mount&&!n.action&&(I(),x&&t.isDirty&&(A.isDirty||f.isDirty)&&(Q()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!U(g(d,r))&&Qe(r,u)&&(n.watch=!0))}},_=(r,o,l,m,h)=>{let x=!1,y=!1;const v={name:r};if(!s.disabled||m===!0){if(!l||m){const S=me(g(c,r),o);(A.isDirty||f.isDirty)&&(y=t.isDirty,t.isDirty=v.isDirty=!S||Q(),x=y!==v.isDirty),y=!!g(t.dirtyFields,r),S!==t.isDirty?t.dirtyFields=we(c,d,void 0,a):S?q(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(A.dirtyFields||f.dirtyFields)&&y!==!S}if(l){const S=g(t.touchedFields,r);S||(F(t.touchedFields,r,l),v.touchedFields=t.touchedFields,x=x||(A.touchedFields||f.touchedFields)&&S!==l)}x&&h&&b.state.next(v)}return x?v:{}},P=(r,o,l,m)=>{const h=g(t.errors,r),x=(A.isValid||f.isValid)&&fe(o)&&t.isValid!==o;if(s.delayError&&l?(j[r]=W(r,()=>he(r,l)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],l?F(t.errors,r,l):q(t.errors,r),t.errors={...t.errors}),(l?!me(h,l):h)||!K(m)||x){const y={...m,...x&&fe(o)?{isValid:o}:{},errors:t.errors,name:r};t={...t,...y},b.state.next(y)}},D=async r=>(T(r,!0),await s.resolver(d,s.context,pr(r||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async r=>{const{errors:o}=await D(r);if(T(r),r){for(const l of r){const m=g(o,l);m?u.array.has(l)&&z(m)&&!Object.keys(m).some(h=>!Number.isNaN(Number(h)))?Ft(t.errors,{[l]:m},l):F(t.errors,l,m):q(t.errors,l)}t.errors={...t.errors}}else t.errors=o;return o},w=async({name:r,eventType:o})=>{if(e.validate){const l=await e.validate({formValues:d,formState:t,name:r,eventType:o});if(z(l))for(const m in l){const h=l[m];h&&Me(`${Je}.${m}`,{message:Z(h.message)?h.message:"",type:h.type||de.validate})}else Z(l)||!l?Me(Je,{message:l||"",type:de.validate}):mt(Je);return l}return!0},M=async({fields:r,onlyCheckValid:o,name:l,eventType:m,context:h={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(h.runRootValidation=!0,!await w({name:l,eventType:m})&&(h.valid=!1,o)))return h.valid;for(const x in r){const y=r[x];if(y){const{_f:v,...S}=y;if(v){const L=u.array.has(v.name),X=y._f&&yr(y._f),ye=A.validatingFields||A.isValidating||f.validatingFields||f.isValidating;X&&ye&&T([v.name],!0);const xe=await Mt(y,u.disabled,d,N,s.shouldUseNativeValidation&&!o,L);if(X&&ye&&T([v.name]),xe[v.name]&&(h.valid=!1,o)||(!o&&(g(xe,v.name)?L?Ft(t.errors,xe,v.name):F(t.errors,v.name,xe[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&xe[v.name]))break}!K(S)&&await M({context:h,onlyCheckValid:o,fields:S,name:x,eventType:m})}}return h.valid},pe=()=>{for(const r of u.unMount){const o=g(a,r);o&&(o._f.refs?o._f.refs.every(l=>!Xe(l)):!Xe(o._f.ref))&&Ke(r)}u.unMount=new Set},Q=(r,o)=>(r&&o&&F(d,r,o),!me(n.mount?d:c,c)),ve=(r,o,l)=>cr(r,u,{...n.mount?d:U(o)?c:Z(r)?{[r]:o}:o},l,o),p=r=>ss(g(n.mount?d:c,r,s.shouldUnregister?g(c,r,[]):[])),k=(r,o,l={},m=!1,h=!1)=>{const x=g(a,r);let y=o;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,cs(o,v)),y=Be(v.ref)&&Y(o)?"":o,as(v.ref)?[...v.ref.options].forEach(S=>S.selected=y.includes(S.value)):v.refs?Ie(v.ref)?v.refs.forEach(S=>{(!S.defaultChecked||!S.disabled)&&(Array.isArray(y)?S.checked=!!y.find(L=>L===S.value):S.checked=y===S.value||!!y)}):v.refs.forEach(S=>S.checked=S.value===y):ct(v.ref)?v.ref.value="":(v.ref.value=y,!v.ref.type&&!h&&b.state.next({name:r,values:m?d:B(d)})))}(l.shouldDirty||l.shouldTouch)&&_(r,y,l.shouldTouch,l.shouldDirty,!h),l.shouldValidate&&Ge(r,{delayError:l.delayError})},ce=(r,o,l,m=!1,h=!1)=>{for(const x in o){if(!o.hasOwnProperty(x))return;const y=o[x],v=r+"."+x,S=g(a,v);(u.array.has(r)||z(y)||S&&!S._f)&&!je(y)?ce(v,y,l,m,h):k(v,y,l,m,h)}},te=(r,o,l,m,h=!1)=>{const x=g(a,r),y=u.array.has(r),v=m?o:B(o),S=g(d,r),L=me(S,v);if(L||F(d,r,v),y)b.array.next({name:r,values:m?d:B(d)}),(A.isDirty||A.dirtyFields||f.isDirty||f.dirtyFields)&&l.shouldDirty&&(oe(),h||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:Q(r,v)}));else{const X=Array.isArray(v)&&!v.length||K(v);!x||x._f||Y(v)||X?k(r,v,l,m,h):ce(r,v,l,m,h)}if(!L&&!h){const X=Qe(r,u),ye=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:ye})}},ae=(r,o,l={})=>te(r,o,l,!1),Se=(r,o={})=>{const l=ne(r)?r(d):r;if(!me(d,l)){d={...d,...l};const m=rs(l);for(const h of u.mount)h in m&&te(h,m[h],o,!0,!0);b.state.next({...t,name:void 0,type:void 0,...V?{values:d}:{}}),o.shouldValidate&&I()}},Ee=async r=>{n.mount=!0;const o=r.target;let l=o.name,m=!0;const h=g(a,l),x=y=>{m=Number.isNaN(y)||je(y)&&isNaN(y.getTime())||me(y,g(d,l,y))};if(h){let y,v;const S=o.type?Lt(h._f):sr(r),L=r.type===Ae.BLUR||r.type===Ae.FOCUS_OUT,X=!xr(h._f)&&!e.validate&&!s.resolver&&!g(t.errors,l)&&!h._f.deps,ye=X||br(L,g(t.touchedFields,l),t.isSubmitted,R,H),xe=Qe(l,u,L);if(F(d,l,S),L){if(!o||!o.readOnly){h._f.onBlur&&h._f.onBlur(r);const ke=j[l];ke&&ke(0)}}else h._f.onChange&&h._f.onChange(r);const Ve=_(l,S,L),Ns=!K(Ve)||xe;if(!L&&b.state.next({name:l,type:r.type,...V?{values:B(d)}:{}}),ye)return(!X||!t.isValid)&&(A.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),Ns&&b.state.next({name:l,...xe?{}:Ve});if(!s.resolver&&e.validate&&await w({name:l,eventType:r.type}),!L&&xe&&b.state.next({...t}),s.resolver){const{errors:ke}=await D([l]);if(T([l]),x(S),!m){!K(Ve)&&b.state.next(Ve);return}const Ts=zt(t.errors,a,l),bt=zt(ke,a,Ts.name||l);y=bt.error,l=bt.name,v=K(ke)}else T([l],!0),y=(await Mt(h,u.disabled,d,N,s.shouldUseNativeValidation))[l],T([l]),x(S),m&&(y?v=!1:(A.isValid||f.isValid)&&(v=await M({fields:a,onlyCheckValid:!0,name:l,eventType:r.type})));m&&(h._f.deps&&(!Array.isArray(h._f.deps)||h._f.deps.length>0)&&Ge(h._f.deps),P(l,v,y,Ve))}},Te=(r,o)=>{if(g(t.errors,o)&&r.focus)return r.focus(),1},Ge=async(r,o={})=>{let l,m;const h=ze(r);if(s.resolver){const x=await $(U(r)?r:h);l=K(x),m=r?!h.some(y=>g(x,y)):l}else r?(m=(await Promise.all(h.map(async x=>{const y=g(a,x);return await M({fields:y&&y._f?{[x]:y}:y,eventType:Ae.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=l=await M({fields:a,name:r,eventType:Ae.TRIGGER});if(o.delayError&&s.delayError&&Z(r)){const x=g(t.errors,r);x?(q(t.errors,r),j[r]=W(r,()=>he(r,x)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r])}return b.state.next({...!Z(r)||(A.isValid||f.isValid)&&l!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:l}:{},errors:t.errors}),o.shouldFocus&&!m&&Ce(a,Te,r?h:u.mount),m},xs=(r,o)=>{let l={...n.mount?d:c};return o&&(l=is(o.dirtyFields?t.dirtyFields:t.touchedFields,l)),U(r)?l:Z(r)?g(l,r):r.map(m=>g(l,m))},ft=(r,o)=>({invalid:!!g((o||t).errors,r),isDirty:!!g((o||t).dirtyFields,r),error:g((o||t).errors,r),isValidating:!!g(t.validatingFields,r),isTouched:!!g((o||t).touchedFields,r)}),mt=r=>{const o=r?ze(r):void 0;o?.forEach(l=>q(t.errors,l)),o?o.forEach(l=>{b.state.next({name:l,errors:t.errors})}):b.state.next({errors:{}})},Me=(r,o,l)=>{const m=(g(a,r,{_f:{}})._f||{}).ref,h=g(t.errors,r)||{},{ref:x,message:y,type:v,...S}=h;F(t.errors,r,{...S,...o,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),l&&l.shouldFocus&&m&&m.focus&&m.focus()},gs=(r,o)=>{if(ne(r)){V++;const{unsubscribe:l}=b.state.subscribe({next:h=>"values"in h&&r(h.values||ve(void 0,o),h)});let m=!1;return{unsubscribe:()=>{m||(m=!0,V--,l())}}}return ve(r,o,!0)},ht=r=>{var o;const l=!!(!((o=r.formState)===null||o===void 0)&&o.values);l&&V++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(vr(r.name,x.name,r.exact)&&gr(x,r.formState||A,ws,r.reRenderRoot)){const y={...d};r.callback({values:y,...t,...x,defaultValues:c})}}});if(!l)return m;let h=!1;return()=>{h||(h=!0,V--,m())}},vs=r=>(n.mount=!0,f={...f,...r.formState},ht({...r,formState:{...O,...r.formState}})),Ke=(r,o={})=>{for(const l of r?ze(r):u.mount)u.mount.delete(l),u.array.delete(l),o.keepValue||(q(a,l),q(d,l)),!o.keepError&&q(t.errors,l),!o.keepDirty&&q(t.dirtyFields,l),!o.keepTouched&&q(t.touchedFields,l),!o.keepIsValidating&&q(t.validatingFields,l),!s.shouldUnregister&&!o.keepDefaultValue&&q(c,l);b.state.next({values:B(d)}),b.state.next({...t,...o.keepDirty?{isDirty:Q()}:{}}),!o.keepIsValid&&I()},pt=({disabled:r,name:o})=>{if(fe(r)&&n.mount||r||u.disabled.has(o)){const h=u.disabled.has(o)!==!!r;r?u.disabled.add(o):u.disabled.delete(o),h&&n.mount&&!n.action&&I()}},Ye=(r,o={})=>{let l=g(a,r);const m=fe(o.disabled)||fe(s.disabled),h=!u.registerName.has(r)&&l&&l._f&&!l._f.mount;return F(a,r,{...l||{},_f:{...l&&l._f?l._f:{ref:{name:r}},name:r,mount:!0,...o}}),u.mount.add(r),l&&!h?pt({disabled:fe(o.disabled)?o.disabled:s.disabled,name:r}):ee(r,!0,o.value),{...m?{disabled:o.disabled||s.disabled}:{},...s.progressive?{required:!!o.required,min:Fe(o.min),max:Fe(o.max),minLength:Fe(o.minLength),maxLength:Fe(o.maxLength),pattern:Fe(o.pattern)}:{},name:r,onChange:Ee,onBlur:Ee,ref:x=>{if(x){u.registerName.add(r),Ye(r,o),u.registerName.delete(r),l=g(a,r);const y=U(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=mr(y),S=l._f.refs||[];if(v?S.find(L=>L===y):y===l._f.ref)return;F(a,r,{_f:{...l._f,...v?{refs:[...S.filter(Xe),y,...Array.isArray(g(c,r))?[{}]:[]],ref:{type:y.type,name:r}}:{ref:y}}}),ee(r,!1,void 0,y)}else l=g(a,r,{}),l._f&&(l._f.mount=!1),(s.shouldUnregister||o.shouldUnregister)&&!(rr(u.array,r)&&n.action)&&u.unMount.add(r)}}},Ze=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Ce(a,Te,u.mount),bs=r=>{fe(r)&&(b.state.next({disabled:r}),Ce(a,(o,l)=>{const m=g(a,l);m&&(o.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(h=>{h.disabled=m._f.disabled||r}))},0,!1))},yt=(r,o)=>async l=>{let m;l&&(l.preventDefault&&l.preventDefault(),l.persist&&l.persist());let h=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:y}=await D();T(),t.errors=x,h=B(y)}else await M({fields:a,eventType:Ae.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(h,x);if(q(t.errors,Jt),K(t.errors)){b.state.next({errors:{}});try{await r(h,l)}catch(x){m=x}}else o&&await o({...t.errors},l),Ze(),setTimeout(Ze);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},js=(r,o={})=>{g(a,r)&&(U(o.defaultValue)?ae(r,B(g(c,r))):(ae(r,o.defaultValue),F(c,r,B(o.defaultValue))),o.keepTouched||q(t.touchedFields,r),o.keepDirty||(q(t.dirtyFields,r),t.isDirty=o.defaultValue?Q(r,B(g(c,r))):Q()),o.keepError||(q(t.errors,r),A.isValid&&I()),b.state.next({...t}))},xt=(r,o={})=>{const l=r?B(r):c,m=B(l),h=K(r),x=m,y=a;if(o.keepDefaultValues||(c=l),!o.keepValues){if(o.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(we(c,d,void 0,y))]);for(const S of Array.from(v)){const L=g(t.dirtyFields,S),X=g(d,S),ye=g(x,S);L&&!U(X)?F(x,S,X):!L&&!U(ye)&&ae(S,ye)}}else{if($e&&U(r))for(const v of u.mount){const S=g(a,v);if(S&&S._f){const L=Array.isArray(S._f.refs)?S._f.refs[0]:S._f.ref;if(Be(L)){const X=L.closest("form");if(X){X.reset();break}}}}if(o.keepFieldsRef)for(const v of u.mount)ae(v,g(x,v));else a={}}if(s.shouldUnregister){if(d=o.keepDefaultValues?B(c):{},o.keepFieldsRef)for(const v of u.mount)F(d,v,g(x,v))}else d=B(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:o.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=!A.isValid||!!o.keepIsValid||!!o.keepDirtyValues||!s.shouldUnregister&&!K(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!o.keepIsValid,n.action=!1,o.keepErrors||(t.errors={}),b.state.next({submitCount:o.keepSubmitCount?t.submitCount:0,isDirty:h?!1:o.keepDirty?t.isDirty:o.keepValues?Q():!!(o.keepDefaultValues&&!me(r,c)),isSubmitted:o.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:h?{}:o.keepDirtyValues?o.keepDefaultValues&&d?we(c,d,void 0,y):t.dirtyFields:o.keepDefaultValues&&r?we(c,r,void 0,y):o.keepDirty?t.dirtyFields:{},touchedFields:o.keepTouched?t.touchedFields:{},errors:o.keepErrors?t.errors:{},isSubmitSuccessful:o.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:c})},gt=(r,o)=>xt(ne(r)?r(d):r,{...s.resetOptions,...o}),Ss=(r,o={})=>{const l=g(a,r),m=l&&l._f;if(m){const h=m.refs?m.refs[0]:m.ref;h.focus&&setTimeout(()=>{h.focus(),o.shouldSelect&&ne(h.select)&&h.select()})}},ws=r=>{const{name:o,type:l,values:m,...h}=r;t={...t,...h}},vt={control:{register:Ye,unregister:Ke,getFieldState:ft,handleSubmit:yt,setError:Me,_subscribe:ht,_runSchema:D,_updateIsValidating:T,_focusError:Ze,_getWatch:ve,_getDirty:Q,_setValid:I,_setFieldArray:re,_setDisabledField:pt,_setErrors:le,_getFieldArray:p,_reset:xt,_resetDefaultValues:()=>ne(s.defaultValues)&&s.defaultValues().then(r=>{gt(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:pe,_disableForm:bs,_subjects:b,_proxyFormState:A,get _fields(){return a},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return c},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},H=Le(s.mode),R=Le(s.reValidateMode)}},subscribe:vs,trigger:Ge,register:Ye,handleSubmit:yt,watch:gs,setValue:ae,setValues:Se,getValues:xs,reset:gt,resetField:js,resetDefaultValues:(r,o={})=>{if(c=B(r),!o.keepDirty){const l=we(c,d,void 0,a);t.dirtyFields=l,t.isDirty=!K(l)}o.keepIsValid||I(),b.state.next({...t,defaultValues:c})},clearErrors:mt,unregister:Ke,setError:Me,setFocus:Ss,getFieldState:ft};return{...vt,formControl:vt}}function Nr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),a=J.useRef(e.formControl),[c,d]=J.useState(()=>({...B(ds),isLoading:ne(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ne(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:c},e.defaultValues&&!ne(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=wr(e);s.current={...j,formState:c}}const n=s.current.control;return n._options=e,lr(()=>{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]),J.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),J.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),J.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),J.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),J.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==c.isDirty&&n._subjects.state.next({isDirty:u})}},[n,c.isDirty]),J.useEffect(()=>{var u;e.values&&!me(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]),J.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=J.useMemo(()=>or(c,n),[n,c]),s.current}const Bt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=g(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},it=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Bt(a.ref,t,e):a&&a.refs&&a.refs.forEach(c=>Bt(c,t,e))}},qt=(e,s)=>{s.shouldUseNativeValidation&&it(e,s);const t={};for(const a in e){const c=g(s.fields,a),d=Object.assign(e[a]||{},{ref:c&&c.ref});if(Tr(s.names||Object.keys(e),a)){const n=Object.assign({},g(t,a));F(n,"root",d),F(t,a,n)}else F(t,a,d)}return t},Tr=(e,s)=>{const t=$t(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>$t(a).match(`^${t}\\.\\d+`))};function $t(e){return e.replace(/[\[\]]/g,"")}function us(e,s,t){function a(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 V in n.prototype)V in u||Object.defineProperty(u,V,{value:n.prototype[V].bind(u)});u._zod.constr=n,u._zod.def=j}const c=t?.Parent??Object;class d extends c{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const E=t?.Parent?new d:this;a(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const V of E._zod.deferred)V();return E}return Object.defineProperty(n,"init",{value:a}),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 Ar extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const _r={};function fs(e){return _r}function Pr(e,s){return typeof s=="bigint"?s.toString():s}const ms=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e=="string"?e:e?.message}function hs(e,s,t){const a={...e,path:e.path??[]};if(!e.message){const c=He(e.inst?._zod.def?.error?.(e))??He(s?.error?.(e))??He(t.customError?.(e))??He(t.localeError?.(e))??"Invalid input";a.message=c}return delete a.inst,delete a.continue,s?.reportInput||delete a.input,a}const ps=(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,Pr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Er=us("$ZodError",ps),ys=us("$ZodError",ps,{Parent:Error}),Vr=e=>(s,t,a,c)=>{const d=a?Object.assign(a,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Ar;if(n.issues.length){const u=new(c?.Err??e)(n.issues.map(j=>hs(j,d,fs())));throw ms(u,c?.callee),u}return n.value},kr=Vr(ys),Dr=e=>async(s,t,a,c)=>{const d=a?Object.assign(a,{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(c?.Err??e)(n.issues.map(j=>hs(j,d,fs())));throw ms(u,c?.callee),u}return n.value},Fr=Dr(ys);function at(){return at=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},at.apply(null,arguments)}function Wt(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function Cr(e,s){for(var t={};e.length;){var a=e[0],c=a.code,d=a.message,n=a.path.join(".");if(!t[n])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:c};if("unionErrors"in a&&a.unionErrors.forEach(function(V){return V.errors.forEach(function(H){return e.push(H)})}),s){var j=t[n].types,E=j&&j[a.code];t[n]=ut(n,s,t,c,E?[].concat(E,a.message):a.message)}e.shift()}return t}function Or(e,s){for(var t={},a=function(){var c=e[0],d=c.code,n=c.message,u=c.path.join(".");if(!t[u])if(c.code==="invalid_union"&&c.errors.length>0){var j=c.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(c.code==="invalid_union"&&c.errors.forEach(function(H){return H.forEach(function(R){return e.push(at({},R,{path:[].concat(c.path,R.path)}))})}),s){var E=t[u].types,V=E&&E[c.code];t[u]=ut(u,s,t,d,V?[].concat(V,c.message):c.message)}e.shift()};e.length;)a();return t}function Ir(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,c,d){try{return Promise.resolve(Wt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:qt(Cr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,c,d){try{return Promise.resolve(Wt(function(){return Promise.resolve((t.mode==="sync"?kr:Fr)(e,a,s)).then(function(n){return d.shouldUseNativeValidation&&it({},d),{errors:{},values:t.raw?Object.assign({},a):n}})},function(n){if((function(u){return u instanceof Er})(n))return{values:{},errors:qt(Or(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 Rr=e=>e.authType==="oauthMicrosoft",Mr="••••••••••",Ur=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Lr=Vs({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:Tt.number().int().min(1).max(65535),imapTls:De(),imapStartTls:De(),smtpHost:be().optional(),smtpPort:Tt.number().int().min(1).max(65535).optional(),smtpTls:De().optional(),smtpStartTls:De().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:De().optional()}),Hr=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const c=Zt(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[V,H]=C.useState(!1),R=Et(j),O=!!R&&!V,A=C.useRef(null),f=Nr({resolver:Ir(Lr),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=Ur(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Mr,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=Ne({...As()}),ie=Ne({..._s(),onSuccess:()=>{c.invalidateQueries({queryKey:Pe()}),s()}}),N=Ne({...Ps(),onSuccess:()=>{c.invalidateQueries({queryKey:Pe()}),s()}}),W=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?void 0:p.password||void 0,imapHost:p.imapHost,imapPort:Number(p.imapPort),imapTls:p.imapTls,imapStartTls:p.imapStartTls}})},I=()=>{const p=f.getValues(),k=d&&!n;b.mutate({body:{accountId:k?t?.accountId:void 0,username:p.username||p.email,password:k?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}})},T=f.handleSubmit(p=>{if(!d&&!p.password){f.setError("password",{message:"Password is required"});return}const k=Zs({imapHost:p.imapHost,smtpHost:p.smtpHost,smtpPort:p.smtpPort,smtpTls:p.smtpTls,smtpStartTls:p.smtpStartTls});k&&(f.setValue("smtpHost",k.smtpHost),f.setValue("smtpPort",k.smtpPort),f.setValue("smtpTls",k.smtpTls),f.setValue("smtpStartTls",k.smtpStartTls));const ce=k?.smtpHost??p.smtpHost,te=k?.smtpPort??p.smtpPort,ae=k?.smtpTls??p.smtpTls,Se=k?.smtpStartTls??p.smtpStartTls,Ee={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:te?Number(te):void 0,smtpTls:ae,smtpStartTls:Se,smtpUsername:p.useDifferentSmtpCreds&&p.smtpUsername||void 0,smtpPassword:p.useDifferentSmtpCreds&&p.smtpPassword||void 0};if(d&&t){const Te={...Ee,password:n?p.password:void 0};N.mutate({path:{accountId:t.accountId},body:Te})}else{const Te={...Ee,password:p.password};ie.mutate({body:Te})}}),oe=ie.isPending||N.isPending,{signature:re,setSignature:he,isSaving:le}=Bs(t?.accountId),[G,ee]=C.useState(re.plainText);C.useEffect(()=>{ee(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!a)return;const p=A.current;if(!p)return;const k=window.setTimeout(()=>{p.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(k)},[e,a]);const _=C.useCallback(()=>{G!==re.plainText&&he(G,G)},[G,re.plainText,he]),P=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("imapTls",k),f.setValue("imapStartTls",ce);const te=f.getValues("imapPort");(te===993||te===143)&&f.setValue("imapPort",p==="tls"?993:143)},D=p=>{const{tls:k,startTls:ce}=Ue(p);f.setValue("smtpTls",k),f.setValue("smtpStartTls",ce);const te=f.getValues("smtpPort");if(te===465||te===587||te===25){const Se=p==="tls"?465:p==="starttls"?587:25;f.setValue("smtpPort",Se)}},$=()=>{const p=f.getValues("imapHost");f.setValue("smtpHost",Qs(p)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},w=p=>{E(p),H(!1);const k=Et(p);if(!k)return;const ce=Ue(k.imap.security);f.setValue("imapHost",k.imap.host),f.setValue("imapPort",k.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const te=Ue(k.smtp.security);f.setValue("smtpHost",k.smtp.host),f.setValue("smtpPort",k.smtp.port),f.setValue("smtpTls",te.tls),f.setValue("smtpStartTls",te.startTls);const ae=f.getValues("email").trim(),Se=f.getValues("username")?.trim();ae&&!Se&&f.setValue("username",ae)},M=R?.passwordHelp.text,pe=Vt(b.data?.imapError,M),Q=Vt(b.data?.smtpError,M);return(t?Rr(t):!1)&&d?i.jsx(kt,{isOpen:e,onClose:s,title:"Edit Account",footer:i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),i.jsx("span",{className:"text-fg",children:t?.email})]}),i.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[i.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),i.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),i.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&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-view",value:G,onChange:p=>ee(p.target.value),onBlur:_,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..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})}):i.jsx(kt,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:i.jsxs(i.Fragment,{children:[i.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),i.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:oe,children:oe?"Saving...":"Save Account"})]}),children:i.jsxs("form",{id:"account-form",onSubmit:T,className:"space-y-6",children:[i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),i.jsxs(Es,{id:"account-provider",value:j,onChange:p=>w(p.target.value),children:[i.jsx("option",{value:"",children:"Custom / other"}),Gs.map(p=>i.jsx("option",{value:p.id,children:p.label},p.id))]}),i.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."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),i.jsx(ge,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),i.jsx(ge,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),i.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."})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),i.jsx(ge,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),i.jsx(St,{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&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&i.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",i.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&i.jsx("button",{type:"button",onClick:()=>H(p=>!p),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:V?"Use preset settings":"Advanced"})]}),O&&i.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."]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(ge,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&i.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(ge,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>P("tls")}),"TLS (Port 993)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>P("starttls")}),"STARTTLS (Port 143)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>P("none")}),"None (Unencrypted)"]})]})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&i.jsxs("div",{className:Nt("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?i.jsx(wt,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":pe]})]})]}),i.jsxs("section",{ref:A,"data-testid":"smtp-section",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&i.jsx("button",{type:"button",onClick:$,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),i.jsx(ge,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),i.jsx(ge,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),i.jsxs("div",{className:"space-y-1.5 mt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>D("tls")}),"TLS (Port 465)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>D("starttls")}),"STARTTLS (Port 587)"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>D("none")}),"None (Unencrypted)"]})]})]})]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),i.jsx(ge,{id:"smtp-username",...f.register("smtpUsername")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),i.jsx(St,{id:"smtp-password",...f.register("smtpPassword")})]})]}),i.jsx(se,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?i.jsx(et,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&i.jsxs("div",{className:Nt("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?i.jsx(wt,{className:"inline size-4 mr-1"}):i.jsx(Oe,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":Q]})]})]}),d&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),i.jsx("div",{className:"space-y-3",children:i.jsxs("div",{children:[i.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),i.jsx("textarea",{id:"email-sig-edit",value:G,onChange:p=>ee(p.target.value),onBlur:_,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..."}),i.jsx("p",{className:"text-xs text-fg-muted mt-1",children:le?"Saving signature...":"This signature will be appended to new emails."})]})})]})]})})};function Gt({open:e,onClose:s,accountEmail:t,signOut:a}){const[c,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),V=Ne({...Ds(),onSuccess:()=>{E(!0),setTimeout(()=>a(),2e3)}}),H=Ne(Fs()),R=()=>{V.isPending||(d(""),u(!1),E(!1),V.reset(),H.reset(),s())},O=()=>{if(c.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),V.mutate({body:{confirmEmail:c.trim()}})};return i.jsxs(Qt,{open:e,onClose:R,title:"Delete your Remit account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?i.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[i.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),i.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),i.jsxs("ul",{className:"space-y-1.5 text-xs",children:[i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),i.jsxs("li",{className:"flex gap-2",children:[i.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),i.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[i.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."]}),i.jsxs("div",{className:"text-xs",children:[i.jsxs("button",{type:"button",onClick:()=>H.mutate({}),"aria-busy":H.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[i.jsx(Xs,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&i.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."}),H.isError&&i.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",i.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),i.jsx(ge,{id:"confirm-remit-email",type:"email",placeholder:t,value:c,onChange:A=>{d(A.target.value),n&&u(!1),V.isError&&V.reset()},autoComplete:"off"}),n&&i.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."}),V.isError&&i.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:V.error instanceof Error?V.error.message:"Something went wrong. Please try again."})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm",onClick:O,"aria-busy":V.isPending,children:V.isPending?"Deleting…":"Delete everything"})]})]})]})}function zr(e){const{Account:s}=ks();return i.jsx(s,{fallback:i.jsx(Gt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>i.jsx(Gt,{...e,accountEmail:t??"",signOut:a})})}function Br(){const[e,s]=C.useState(!1);return i.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[i.jsx(tr,{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:i.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),i.jsx(zr,{open:e,onClose:()=>s(!1)})]})}function qr(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 $r(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function Wr(e){const s=e.displayName?.trim();return s||$r(e.email)}function Gr(e){if(!e.lastSyncAt)return"never synced";const s=er(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Kt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Yt(e){return e.connectionState==="reauth_required"}const Kr=i.jsxs("div",{className:"space-y-3",children:[i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),i.jsxs("p",{children:[i.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."]}),i.jsxs("p",{children:[i.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),Yr=()=>i.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>i.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),i.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function li(){const e=At.useSearch(),s=Cs({from:At.fullPath}),[t,a]=C.useState(!0),[c,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[V,H]=C.useState(!1),[R,O]=C.useState(null),[A,f]=C.useState(null),[b,ie]=C.useState(null),[N,W]=C.useState(null),I=Zt(),{data:T,isPending:oe,isError:re,error:he,refetch:le}=Os(Is());C.useEffect(()=>{e.editAccountId&&(E(e.editAccountId),H(!!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:Pe()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(ie(qr(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),Ks(N!==null,()=>{I.invalidateQueries({queryKey:Pe()})}),C.useEffect(()=>{if(!N||!T)return;const w=T.accounts.find(M=>M.accountId===N);(!w||!Yt(w))&&W(null)},[T,N]);const G=Ne({...Rs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ie(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),ee=Ne({...Ms(),onSuccess:()=>{I.invalidateQueries({queryKey:Pe()}),O(null)}}),_=T?.accounts.find(w=>w.accountId===R),P=T?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),H(!1)},$=w=>{const M=Hs[w];M&&s({to:M})};return i.jsxs($s,{items:Us,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:Kr,helpOpen:t,onToggleHelp:()=>a(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[A&&i.jsx(_t,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:A}),b&&i.jsx(_t,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ie(null),children:b}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ls,{tone:"neutral",children:oe||re?"accounts":`${T.accounts.length} ${T.accounts.length===1?"account":"accounts"}`}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(Pt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),oe?i.jsx(Yr,{}):re?i.jsx(Js,{title:"Couldn't load accounts",error:he,onRetry:()=>{le()}}):T.accounts.length===0?i.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[i.jsx("p",{className:"mb-3",children:"No accounts configured."}),i.jsx(se,{variant:"primary",size:"sm",icon:i.jsx(Pt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):i.jsx("div",{className:"space-y-3",children:T.accounts.map(w=>{const M=Yt(w),pe=w.authType==="oauthMicrosoft",Q=N===w.accountId&&G.isPending,ve=M&&pe?{label:"Reconnect",variant:"secondary",busy:Q,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),G.mutate({body:{email:w.email}})}}:Kt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},p=i.jsx(qs,{actions:[ve],destructive:{label:"Delete account",iconOnly:!0,icon:i.jsx(zs,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return i.jsx(Ws,{label:Wr(w),email:w.email,connector:pe?"Microsoft 365":"IMAP",syncLabel:Gr(w),state:Kt(w),errorDetail:M?"Re-authentication required":w.lastError,trailing:p},w.accountId)})}),n&&i.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:i.jsx(Ys,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Pe()})},onCancel:()=>u(!1)})}),i.jsx(Hr,{isOpen:c||!!j,account:P,focusSmtp:V,onClose:D}),i.jsxs(Qt,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[i.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[i.jsx(nt,{className:"size-4 shrink-0 text-danger"}),i.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),i.jsx(se,{variant:"ghost",size:"sm",icon:i.jsx(Oe,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),i.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),_&&i.jsx("p",{className:"text-center",children:_.email}),i.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[i.jsx("li",{children:"Remove the account from your settings"}),i.jsx("li",{children:"Stop syncing mail for this account"}),i.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),i.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[i.jsx(se,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),i.jsx(se,{variant:"danger",size:"sm","aria-busy":ee.isPending,icon:ee.isPending?i.jsx(et,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{ee.isPending||R&&ee.mutate({path:{accountId:R}})},children:ee.isPending?"Deleting…":"Delete account"})]})]}),i.jsx(Br,{})]})}export{li as component,qr as mapOauthError};
@@ -1 +0,0 @@
1
- import{j as t,bY as o}from"./index-bW4RCdiF.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};