@remit/web-client-dist 0.0.430 → 0.0.431

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 (107) hide show
  1. package/assets/{BriefPane-CytP3J7O.js → BriefPane-B_43XrIX.js} +1 -1
  2. package/assets/{ErrorState-B_pp6XjY.js → ErrorState-D5cn-r_g.js} +1 -1
  3. package/assets/{FlaggedPane-BTGAqs21.js → FlaggedPane-BmNKHLJP.js} +1 -1
  4. package/assets/{FullCompose-D8BBZrtI.js → FullCompose-CTBUQaxT.js} +1 -1
  5. package/assets/{MailListHeader-BjsRsJYI.js → MailListHeader-DzjUH8L0.js} +1 -1
  6. package/assets/{MailShell-CvPQWjl1.js → MailShell-8jHD0muk.js} +1 -1
  7. package/assets/{MailViewChrome-ZN5UsScT.js → MailViewChrome-QVpYFxJf.js} +1 -1
  8. package/assets/{MailboxPane-Bca57rKs.js → MailboxPane-DacSDALK.js} +1 -1
  9. package/assets/{NavMenuButton-_aiK1QXb.js → NavMenuButton-C6jexGVY.js} +1 -1
  10. package/assets/{OnboardingWizard-BdBknD3m.js → OnboardingWizard-BLAdynjS.js} +1 -1
  11. package/assets/{OutboxPane-3nlNVjx6.js → OutboxPane-BWql0oaX.js} +1 -1
  12. package/assets/_mailboxId-jkUpvxl1.js +1 -0
  13. package/assets/_messageId-BVpg5Tz8.js +1 -0
  14. package/assets/_messageId-DChgNaxv.js +1 -0
  15. package/assets/_messageId-DCwFpPS8.js +1 -0
  16. package/assets/_outboxMessageId-BYSL9Fet.js +1 -0
  17. package/assets/_threadId-BRDhMSWj.js +1 -0
  18. package/assets/_threadId-CX4aUOdM.js +1 -0
  19. package/assets/_threadId-YwJI-X6V.js +1 -0
  20. package/assets/{accounts-Cji9zFqV.js → accounts-DjxACMQo.js} +1 -1
  21. package/assets/{advanced-BXCAioJN.js → advanced-jOMMCPwe.js} +1 -1
  22. package/assets/{appearance-Dg7qROVT.js → appearance-CJ03-RKV.js} +1 -1
  23. package/assets/{attachment-file-CLrI3kMw.js → attachment-file-C1JZr27N.js} +1 -1
  24. package/assets/{avatar-C8lpjlQO.js → avatar-DVEp71DP.js} +1 -1
  25. package/assets/{bottom-sheet-BuEgZWXh.js → bottom-sheet-RK-XvYz2.js} +1 -1
  26. package/assets/brief-BXf0e4LI.js +1 -0
  27. package/assets/{brief-Dt7lMB8R.js → brief-CyZkzbIP.js} +1 -1
  28. package/assets/{browser-ponyfill-g58jgFl_.js → browser-ponyfill-D2WuVPYo.js} +1 -1
  29. package/assets/{bug-CDU4oK_3.js → bug-DET_KgV6.js} +1 -1
  30. package/assets/{circle-check-BhMyR8BA.js → circle-check-B3vjKaD1.js} +1 -1
  31. package/assets/{circle-check-big-5NMrNFUI.js → circle-check-big-CTk0kr4F.js} +1 -1
  32. package/assets/{circle-help-BAup3nOG.js → circle-help-KBbSqlpB.js} +1 -1
  33. package/assets/{clock-DCdX5E4T.js → clock-sbv7ILkY.js} +1 -1
  34. package/assets/compose._-_outboxMessageId_-BDYHCPIg.js +1 -0
  35. package/assets/compose._-_outboxMessageId_-CLvF9Fqr.js +1 -0
  36. package/assets/compose._-_outboxMessageId_-D3NortXQ.js +1 -0
  37. package/assets/compose._-_outboxMessageId_-vZgnB5-N.js +1 -0
  38. package/assets/{confirm-dialog-BxXd7BDT.js → confirm-dialog-DoFwvjx5.js} +1 -1
  39. package/assets/{download-Br1uSntK.js → download-fhBgd0nR.js} +1 -1
  40. package/assets/{filters-snY8U8V2.js → filters-DYWqI6eB.js} +1 -1
  41. package/assets/{flagged-DBt5871J.js → flagged-3YyL4YcX.js} +1 -1
  42. package/assets/flagged-DAMA5iLe.js +1 -0
  43. package/assets/{folders-BzRKidwZ.js → folders-Doj5qCfC.js} +1 -1
  44. package/assets/{help-copy-D1mikTkH.js → help-copy-sfmab4Nc.js} +1 -1
  45. package/assets/{index-DX5RhVmh.js → index-04bqfNgp.js} +3 -3
  46. package/assets/index-Bp3jNjAb.js +1 -0
  47. package/assets/index-BqjXNy5A.js +1 -0
  48. package/assets/index-CRYLSnkT.js +1 -0
  49. package/assets/index-CkRd65CK.js +1 -0
  50. package/assets/{index-idulIG65.js → index-CrStk0va.js} +4 -4
  51. package/assets/index-DChgNaxv.js +1 -0
  52. package/assets/index-DCwFpPS8.js +1 -0
  53. package/assets/index-DiWdTWAy.js +1 -0
  54. package/assets/index-GQwosZoW.js +1 -0
  55. package/assets/{kbd-eZWvlfcb.js → kbd-CIM88W-i.js} +1 -1
  56. package/assets/{labels-DFa210V0.js → labels-BcDR_MmB.js} +1 -1
  57. package/assets/{mail-Ba7j-n-X.js → mail-CM0Ox199.js} +1 -1
  58. package/assets/{mail-lLnBwPN-.js → mail-LpK0kRr6.js} +1 -1
  59. package/assets/{menu-MXmFQ7m-.js → menu-CVMIxRRy.js} +1 -1
  60. package/assets/{onboarding-BQv4jg_d.js → onboarding-C52bKclx.js} +1 -1
  61. package/assets/outbox-CaV85SHn.js +1 -0
  62. package/assets/{pencil-CFys2EU7.js → pencil-Dwwmy-LK.js} +1 -1
  63. package/assets/{rich-text-DUWqcHC5.js → rich-text-DTviXfBN.js} +1 -1
  64. package/assets/{rich-text-spellcheck-worker-provider-DTxcyJ9W.js → rich-text-spellcheck-worker-provider-CXOEqFHn.js} +1 -1
  65. package/assets/{rotate-ccw-DfGOnKhE.js → rotate-ccw-BdyunlX_.js} +1 -1
  66. package/assets/{row-actions-zVghhE3a.js → row-actions-YLjTr0Pe.js} +1 -1
  67. package/assets/{search-mirror-_pK4jqc8.js → search-mirror-DxvFKHd5.js} +1 -1
  68. package/assets/{search-token-index-C-cpQFN3.js → search-token-index-CRfarw2N.js} +1 -1
  69. package/assets/{senders-Gj8Yentl.js → senders-Cec3QyOb.js} +1 -1
  70. package/assets/settings-DJui7dAr.js +1 -0
  71. package/assets/{settings-screen-B17eDLDl.js → settings-screen-YvTik_VI.js} +1 -1
  72. package/assets/{shield-check-DG9twqa-.js → shield-check-CmdMSuok.js} +1 -1
  73. package/assets/{suggested-vips--KmGV5np.js → suggested-vips-sMNKttKk.js} +1 -1
  74. package/assets/{useDebouncedValue-CntZIoMR.js → useDebouncedValue-DBe8RTdD.js} +1 -1
  75. package/assets/{useFilters-DaiBln2b.js → useFilters-BV7Ur6sx.js} +1 -1
  76. package/assets/{useLabels-amyS-Wph.js → useLabels-77azHAmW.js} +1 -1
  77. package/assets/{useMessageBodyContent-5kw10g9a.js → useMessageBodyContent-D2ppLfqI.js} +1 -1
  78. package/assets/{useRefreshControl-CUTMAyIA.js → useRefreshControl-B_HOBKw6.js} +1 -1
  79. package/assets/{useSearchTokenContext-BxDapNdu.js → useSearchTokenContext-BFF5PFp_.js} +1 -1
  80. package/assets/{useSemanticSearch-BDxoAQSc.js → useSemanticSearch-DVz20iAO.js} +1 -1
  81. package/assets/{useSignature-osTmnWZe.js → useSignature-CZIvmo45.js} +1 -1
  82. package/index.html +1 -1
  83. package/package.json +1 -1
  84. package/assets/_mailboxId-ByYUZV2Y.js +0 -1
  85. package/assets/_messageId-DLU18Mnl.js +0 -1
  86. package/assets/_messageId-DzC6VHu2.js +0 -1
  87. package/assets/_messageId-yJtPeY_Z.js +0 -1
  88. package/assets/_outboxMessageId-AEnONMiY.js +0 -1
  89. package/assets/_threadId-BdblixoD.js +0 -1
  90. package/assets/_threadId-CC5eBVBw.js +0 -1
  91. package/assets/_threadId-Cb8ALPnU.js +0 -1
  92. package/assets/brief-06HoE0GS.js +0 -1
  93. package/assets/compose._-_outboxMessageId_-CyN4sUxa.js +0 -1
  94. package/assets/compose._-_outboxMessageId_-D5_JMiLJ.js +0 -1
  95. package/assets/compose._-_outboxMessageId_-Db3_5Bzx.js +0 -1
  96. package/assets/compose._-_outboxMessageId_-YqQysly2.js +0 -1
  97. package/assets/flagged-DErOl3l4.js +0 -1
  98. package/assets/index--TsBKY5T.js +0 -1
  99. package/assets/index-BG1B897N.js +0 -1
  100. package/assets/index-BIcRfpbR.js +0 -1
  101. package/assets/index-DLU18Mnl.js +0 -1
  102. package/assets/index-DqLBbxu3.js +0 -1
  103. package/assets/index-DwKeNLeB.js +0 -1
  104. package/assets/index-yJtPeY_Z.js +0 -1
  105. package/assets/index-zNCEv1vY.js +0 -1
  106. package/assets/outbox-Dye6uwnb.js +0 -1
  107. package/assets/settings-D96it8Kf.js +0 -1
@@ -1 +1 @@
1
- import{j as a,ac as ke,B as ee,a as Ps,X as Ve,ad as ks,ae as Vs,af as ut,r as C,b as Ge,ag as J,x as ft,ah as Ds,D as Xt,a1 as Jt,ai as Cs,aj as Se,ak as Fs,a5 as Ae,al as es,am as Os,an as Is,ao as Rs,ap as ve,aq as At,ar as it,as as Tt,at as Ms,au as Ie,av as be,aw as Et,t as Ls,ax as Us,ay as Hs,az as ts,aA as _t,a0 as zs,aB as Bs,aC as qs,aD as $s,aE as Pt,aF as Ws,aG as kt,aH as Gs,T as Ks}from"./index-idulIG65.js";import{R as Ys}from"./row-actions-zVghhE3a.js";import{S as Qs,A as Zs}from"./settings-screen-B17eDLDl.js";import{g as Vt,P as Xs,s as Be,u as Js,O as er}from"./OnboardingWizard-BdBknD3m.js";import{u as tr}from"./useSignature-osTmnWZe.js";import{c as sr,a as Dt,d as rr}from"./account-form-helpers-DhckT_PN.js";import{D as ar}from"./download-Br1uSntK.js";import{E as ir}from"./ErrorState-B_pp6XjY.js";import{f as nr}from"./format-23Av07Go.js";import{a as or}from"./help-copy-D1mikTkH.js";import"./avatar-C8lpjlQO.js";import"./menu-MXmFQ7m-.js";import"./circle-help-BAup3nOG.js";import"./kbd-eZWvlfcb.js";import"./mail-Ba7j-n-X.js";const lr=e=>{const s=new Set(e.map(ks));return Vs.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 a.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[a.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>a.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:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?a.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ps,{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"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),a.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:[a.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>a.jsx("option",{value:o,children:ke(o)},o))]}),a.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 a.jsxs("div",{className:"rounded-sm border border-danger/50",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[a.jsx(ut,{className:"size-4 text-danger"}),a.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),a.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:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-fg",children:e}),a.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),a.jsx("div",{className:"shrink-0",children:t})]})]})}function Ct({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]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:Ge("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),a.jsxs("div",{className:Ge("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col 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:[a.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[a.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),a.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:a.jsx(Ve,{className:"size-5"})})]}),a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&a.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 mt=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&mt(e)&&!je(e),ur=e=>z(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("."))),ss=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Qe=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(Qe&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&ss(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"},rs="root",pt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const pr=/[.[\]'"]/;var Ze=e=>e.split(pr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const i=Ue(s)?[s]:Ze(s);if(i.some(d=>pt.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]:Ze(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=z(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const hr=J.createContext(null);hr.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=Qe?J.useLayoutEffect:J.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),nt=e=>Y(e)||!mt(e);const Ft=(e,s)=>s.length===0&&!Array.isArray(e)&&!ss(e);function pe(e,s,t=new WeakMap){if(e===s)return!0;if(nt(e)||nt(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(Ft(e,i)||Ft(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)||(z(u)||Array.isArray(u))&&(z(j)||Array.isArray(j))?!pe(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}),st=(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 Me=(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(Me(u,s))break}else if(z(u)&&Me(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,rs,s[t]),F(e,t,o),e},K=e=>z(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Qe)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},gt=e=>e.type==="radio",Ye=e=>e instanceof RegExp,xt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const It={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var as=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:It}return It};const Mt={isValid:!1,value:null};var is=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Mt):Mt;function Lt(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=>z(e)&&!Ye(e)?e:{value:e,message:""},Ut=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:_,min:H,max:M,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=gt(n),re=Le(n),he=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,G=xt.bind(null,f,i,A),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const R=P?k:D;A[f]={type:P?$:w,message:R,ref:n,...G(P?$:w,R)}};if(d?!Array.isArray(N)||!N.length:j&&(!he&&(oe||Y(N))||me(N)&&!N||re&&!as(u).isValid||ne&&!is(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,...G(de.required,k)},!i))return I(k),A}if(!oe&&(!Y(H)||!Y(M))){let P,k;const D=Pe(M),$=Pe(H);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),R=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Z=n.type=="week";Q(D.value)&&N&&(P=le?R(N)>R(D.value):Z?N>D.value:w>new Date(D.value)),Q($.value)&&N&&(k=le?R(N)<R($.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(Ye(P)&&!N.match(P)&&(A[f]={type:de.pattern,message:k,ref:n,...G(de.pattern,k)},!i))return I(k),A}if(T){if(ie(T)){const P=await T(N,t),k=Lt(P,W);if(k&&(A[f]={...k,...G(de.validate,k.message)},!i))return I(k.message),A}else if(z(T)){let P={};for(const k in T){if(!K(P)&&!i)break;const D=Lt(await T[k](N,t),W,k);D&&(P={...D,...G(k,D.message)},I(D.message),i&&(A[f]=P))}if(!K(P)&&(A[f]={ref:W,...P},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],ns=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]:Ze(s);if(t.some(n=>pt.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&&(z(i)&&K(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const os=e=>{const s={};for(const t of Object.keys(e))if(mt(e[t])&&e[t]!==null&&!je(e[t])){const i=os(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=J.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 ls(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&z(o)&&d){const n=ls(o,d);z(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var cs=e=>e.type==="select-multiple",Sr=e=>gt(e)||Le(e),rt=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||z(e)&&!wr(e)}function us(e){return!!(e&&"_f"in e)}function fs(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function ot(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function lt(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];ds(o)&&(!Array.isArray(o)||!us(d))?(s[i]=Array.isArray(o)?[]:{},lt(o,s[i],d),fs(s[i])&&ot(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=lt(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];ds(d)&&(!Array.isArray(d)||!us(n))?(L(s)||nt(t[o])?t[o]=lt(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),fs(t[o])&&ot(t,o)):pe(d,s[o])?ot(t,o):t[o]=!0}return t}var ms=(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 zt(e){const s=e.ref;return ht(s)?s.files:gt(s)?is(e.refs).value:cs(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?as(e.refs).value:ms(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}},Re=e=>L(e)?e:Ye(e)?e.source:z(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var Ar=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===Bt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Bt)return!0}return!1},Tr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function qt(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)=>!ns(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="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=z(s.defaultValues)||z(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,H=qe(s.mode),M=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=(r,l)=>c=>{clearTimeout(E[r]),E[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||r)){const l=++ae;let c;s.resolver?(c=K((await D()).errors),l===ae&&A()):c=await R({fields:i,onlyCheckValid:!0,eventType:_e.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(r,l=[],c,m,p=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,r))){const g=c(y(i,r),m.argA,m.argB);p&&F(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&F(t.errors,r,g),kr(t.errors,r)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&F(t.touchedFields,r,g)}(T.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:Z(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,l)},he=(r,l)=>{F(t.errors,r,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},G=r=>{const l=Ue(r)?[r]:Ze(r);let c=d,m=o;for(let p=0;p<l.length-1;p++){const x=l[p];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(r,l,c,m)=>{const p=y(i,r);if(p){if(G(r))return;const x=L(y(d,r)),g=y(d,r,L(c)?y(o,r):c);L(g)||m&&m.defaultChecked||l?F(d,r,l?g:zt(p._f)):De(r,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,r))&&st(r,u)&&(n.watch=!0))}},P=(r,l,c,m,p)=>{let x=!1,g=!1;const v={name:r};if(!s.disabled||m===!0){if(!c||m){const S=pe(y(o,r),l);(T.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=g!==v.isDirty),g=!!y(t.dirtyFields,r),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,r);S||(F(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&S!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(T.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=W(r,()=>he(r,c)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],c?F(t.errors,r,c):q(t.errors,r),t.errors={...t.errors}),(c?!pe(p,c):p)||!K(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:r};t={...t,...g},b.state.next(g)}},D=async r=>(A(r,!0),await s.resolver(d,s.context,Nr(r||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async r=>{const{errors:l}=await D(r);if(A(r),r){for(const c of r){const m=y(l,c);m?u.array.has(c)&&z(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ot(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:r,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:r,eventType:l});if(z(c))for(const m in c){const p=c[m];p&&ze(`${at}.${m}`,{message:Q(p.message)?p.message:"",type:p.type||de.validate})}else Q(c)||!c?ze(at,{message:c||"",type:de.validate}):Ee(at);return c}return!0},R=async({fields:r,onlyCheckValid:l,name:c,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await w({name:c,eventType:m})&&(p.valid=!1,l)))return p.valid;for(const x in r){const g=r[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),X=g._f&&Ar(g._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?U?Ot(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!K(S)&&await R({context:p,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return p.valid},le=()=>{for(const r of u.unMount){const l=y(i,r);l&&(l._f.refs?l._f.refs.every(c=>!rt(c)):!rt(l._f.ref))&&Je(r)}u.unMount=new Set},Z=(r,l)=>(r&&l&&F(d,r,l),!pe(n.mount?d:o,o)),ge=(r,l,c)=>yr(r,u,{...n.mount?d:L(l)?o:Q(r)?{[r]:l}:l},c,l),Te=r=>ns(y(n.mount?d:o,r,s.shouldUnregister?y(o,r,[]):[])),De=(r,l,c={},m=!1,p=!1)=>{const x=y(i,r);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ms(l,v)),g=Ke(v.ref)&&Y(l)?"":l,cs(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&&!p&&b.state.next({name:r,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(r,g,c.shouldTouch,c.shouldDirty,!p),c.shouldValidate&&fe(r,{delayError:c.delayError})},He=(r,l,c,m=!1,p=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=r+"."+x,S=y(i,v);(u.array.has(r)||z(g)||S&&!S._f)&&!je(g)?He(v,g,c,m,p):De(v,g,c,m,p)}},Xe=(r,l,c,m,p=!1)=>{const x=y(i,r),g=u.array.has(r),v=m?l:B(l),S=y(d,r),U=pe(S,v);if(U||F(d,r,v),g)b.array.next({name:r,values:m?d:B(d)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:Z(r,v)}));else{const X=Array.isArray(v)&&!v.length||K(v);!x||x._f||Y(v)||X?De(r,v,c,m,p):He(r,v,c,m,p)}if(!U&&!p){const X=st(r,u),xe=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Xe(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!pe(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Xe(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,..._?{values:d}:{}}),l.shouldValidate&&I()}},ce=async r=>{n.mount=!0;const l=r.target;let c=l.name,m=!0;const p=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||pe(g,y(d,c,g))};if(p){let g,v;const S=l.type?zt(p._f):ur(r),U=r.type===_e.BLUR||r.type===_e.FOCUS_OUT,X=!Tr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Pr(U,y(t.touchedFields,c),t.isSubmitted,M,H),ye=st(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Oe=j[c];Oe&&Oe(0)}}else p._f.onChange&&p._f.onChange(r);const Fe=P(c,S,U),Es=!K(Fe)||ye;if(!U&&b.state.next({name:c,type:r.type,..._?{values:B(d)}:{}}),xe)return(!X||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),Es&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:r.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(A([c]),x(S),!m){!K(Fe)&&b.state.next(Fe);return}const _s=qt(t.errors,i,c),Nt=qt(Oe,i,_s.name||c);g=Nt.error,c=Nt.name,v=K(Oe)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(S),m&&(g?v=!1:(T.isValid||f.isValid)&&(v=await R({fields:i,onlyCheckValid:!0,name:c,eventType:r.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&fe(p._f.deps),k(c,v,g,Fe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},fe=async(r,l={})=>{let c,m;const p=We(r);if(s.resolver){const x=await $(L(r)?r:p);c=K(x),m=r?!p.some(g=>y(x,g)):c}else r?(m=(await Promise.all(p.map(async x=>{const g=y(i,x);return await R({fields:g&&g._f?{[x]:g}:g,eventType:_e.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await R({fields:i,name:r,eventType:_e.TRIGGER});if(l.delayError&&s.delayError&&Q(r)){const x=y(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({...!Q(r)||(T.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Me(i,se,r?p:u.mount),m},we=(r,l)=>{let c={...n.mount?d:o};return l&&(c=ls(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(r)?c:Q(r)?y(c,r):r.map(m=>y(c,m))},Ce=(r,l)=>({invalid:!!y((l||t).errors,r),isDirty:!!y((l||t).dirtyFields,r),error:y((l||t).errors,r),isValidating:!!y(t.validatingFields,r),isTouched:!!y((l||t).touchedFields,r)}),Ee=r=>{const l=r?We(r):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:{}})},ze=(r,l,c)=>{const m=(y(i,r,{_f:{}})._f||{}).ref,p=y(t.errors,r)||{},{ref:x,message:g,type:v,...S}=p;F(t.errors,r,{...S,...l,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},js=(r,l)=>{if(ie(r)){_++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||ge(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,_--,c())}}}return ge(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&_++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(_r(r.name,x.name,r.exact)&&Er(x,r.formState||T,Ts,r.reRenderRoot)){const g={...d};r.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let p=!1;return()=>{p||(p=!0,_--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Je=(r,l={})=>{for(const c of r?We(r):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()},vt=({disabled:r,name:l})=>{if(me(r)&&n.mount||r||u.disabled.has(l)){const p=u.disabled.has(l)!==!!r;r?u.disabled.add(l):u.disabled.delete(l),p&&n.mount&&!n.action&&I()}},et=(r,l={})=>{let c=y(i,r);const m=me(l.disabled)||me(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return F(i,r,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:r}},name:r,mount:!0,...l}}),u.mount.add(r),c&&!p?vt({disabled:me(l.disabled)?l.disabled:s.disabled,name:r}):te(r,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Re(l.min),max:Re(l.max),minLength:Re(l.minLength),maxLength:Re(l.maxLength),pattern:Re(l.pattern)}:{},name:r,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(r),et(r,l),u.registerName.delete(r),c=y(i,r);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,r,{_f:{...c._f,...v?{refs:[...S.filter(rt),g,...Array.isArray(y(o,r))?[{}]:[]],ref:{type:g.type,name:r}}:{ref:g}}}),te(r,!1,void 0,g)}else c=y(i,r,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Me(i,se,u.mount),ws=r=>{me(r)&&(b.state.next({disabled:r}),Me(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||r}))},0,!1))},bt=(r,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let p=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,p=B(g)}else await R({fields:i,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(p,x);if(q(t.errors,rs),K(t.errors)){b.state.next({errors:{}});try{await r(p,c)}catch(x){m=x}}else l&&await l({...t.errors},c),tt(),setTimeout(tt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ns=(r,l={})=>{y(i,r)&&(L(l.defaultValue)?h(r,B(y(o,r))):(h(r,l.defaultValue),F(o,r,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,r),l.keepDirty||(q(t.dirtyFields,r),t.isDirty=l.defaultValue?Z(r,B(y(o,r))):Z()),l.keepError||(q(t.errors,r),T.isValid&&I()),b.state.next({...t}))},jt=(r,l={})=>{const c=r?B(r):o,m=B(c),p=K(r),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),X=y(d,S),xe=y(x,S);U&&!L(X)?F(x,S,X):!U&&!L(xe)&&h(S,xe)}}else{if(Qe&&L(r))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 X=U.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)h(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&&!K(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:p?!1:l.keepDirty?t.isDirty:l.keepValues?Z():!!(l.keepDefaultValues&&!pe(r,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&r?Ne(o,r,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})},St=(r,l)=>jt(ie(r)?r(d):r,{...s.resetOptions,...l}),As=(r,l={})=>{const c=y(i,r),m=c&&c._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),l.shouldSelect&&ie(p.select)&&p.select()})}},Ts=r=>{const{name:l,type:c,values:m,...p}=r;t={...t,...p}},wt={control:{register:et,unregister:Je,getFieldState:Ce,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:ge,_getDirty:Z,_setValid:I,_setFieldArray:re,_setDisabledField:vt,_setErrors:oe,_getFieldArray:Te,_reset:jt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(r=>{St(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:ws,_subjects:b,_proxyFormState:T,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return o},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},H=qe(s.mode),M=qe(s.reValidateMode)}},subscribe:Ss,trigger:fe,register:et,handleSubmit:bt,watch:js,setValue:h,setValues:V,getValues:we,reset:St,resetField:Ns,resetDefaultValues:(r,l={})=>{if(o=B(r),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!K(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Ee,unregister:Je,setError:ze,setFocus:As,getFieldState:Ce};return{...wt,formControl:wt}}function Cr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),i=J.useRef(e.formControl),[o,d]=J.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]),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!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),J.useEffect(()=>{var u;e.values&&!pe(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(()=>gr(o,n),[n,o]),s.current}const $t=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},ct=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?$t(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>$t(o,t,e))}},Wt=(e,s)=>{s.shouldUseNativeValidation&&ct(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 hs(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 gs(e){return Ir}function Rr(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function ys(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 vs=(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,Rr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{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=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},Ur=Lr(bs),Hr=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=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},zr=Hr(bs);function dt(){return dt=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},dt.apply(null,arguments)}function Kt(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(H){return e.push(H)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=xt(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(H){return H.forEach(function(M){return e.push(dt({},M,{path:[].concat(o.path,M.path)}))})}),s){var E=t[u].types,_=E&&E[o.code];t[u]=xt(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(Kt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Wt(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(Kt(function(){return Promise.resolve((t.mode==="sync"?Ur:zr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Mr})(n))return{values:{},errors:Wt(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=ft(),{pushError:t}=Ds(),{data:i}=Xt({...Jt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Cs(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Ae()})},onError:j=>{t(Fs("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}},Gr=e=>e.authType==="oauthMicrosoft",Kr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Qr=Ms({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:Et.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:Et.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=ft(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[_,H]=C.useState(!1),M=Vt(j),O=!!M&&!_,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 h=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Kr,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:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),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({...Os()}),ae=Se({...Is(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),W=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},I=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},A=f.handleSubmit(h=>{if(!d&&!h.password){f.setError("password",{message:"Password is required"});return}const V=sr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.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??h.smtpHost,se=V?.smtpPort??h.smtpPort,fe=V?.smtpTls??h.smtpTls,we=V?.smtpStartTls??h.smtpStartTls,Ce={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Ee={...Ce,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Ee})}else{const Ee={...Ce,password:h.password};ae.mutate({body:Ee})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:he,isSaving:oe}=tr(t?.accountId),[G,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),a.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const h=T.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{G!==re.plainText&&he(G,G)},[G,re.plainText,he]),R=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",h==="tls"?993:143)},le=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",we)}},Z=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",rr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=h=>{E(h),H(!1);const V=Vt(h);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=M?.passwordHelp.text,De=Dt(b.data?.imapError,Te),He=Dt(b.data?.smtpError,Te);return(t?Gr(t):!1)&&d?a.jsx(Ct,{isOpen:e,onClose:s,title:"Edit Account",footer:a.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),a.jsx("span",{className:"text-fg",children:t?.email})]}),a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),a.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),a.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&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-view",value:G,onChange:h=>te(h.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..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):a.jsx(Ct,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:a.jsxs(a.Fragment,{children:[a.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),a.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:a.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),a.jsxs(Rs,{id:"account-provider",value:j,onChange:h=>ge(h.target.value),children:[a.jsx("option",{value:"",children:"Custom / other"}),Xs.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))]}),a.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."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),a.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),a.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),a.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."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),a.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),a.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&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),M&&a.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[M.passwordHelp.text," ",a.jsx("a",{href:M.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),M&&a.jsx("button",{type:"button",onClick:()=>H(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:_?"Use preset settings":"Advanced"})]}),O&&a.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",M?.label," and locked. Choose Advanced to edit them by hand."]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>R("tls")}),"TLS (Port 993)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>R("starttls")}),"STARTTLS (Port 143)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>R("none")}),"None (Unencrypted)"]})]})]})]}),a.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),a.jsxs("section",{ref:T,"data-testid":"smtp-section",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&a.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"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),a.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),a.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),a.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":He]})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-edit",value:G,onChange:h=>te(h.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..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Yt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),_=Se({...Us(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),H=Se(Hs()),M=()=>{_.isPending||(d(""),u(!1),E(!1),_.reset(),H.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),_.mutate({body:{confirmEmail:o.trim()}})};return a.jsxs(ts,{open:e,onClose:M,title:"Delete your Remit account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),onClick:M,"aria-label":"Cancel"})]}),j?a.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[a.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),a.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),a.jsxs("ul",{className:"space-y-1.5 text-xs",children:[a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),a.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[a.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."]}),a.jsxs("div",{className:"text-xs",children:[a.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:[a.jsx(ar,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&a.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&&a.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",a.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),a.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&&a.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&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:_.error instanceof Error?_.error.message:"Something went wrong. Please try again."})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(ee,{variant:"secondary",size:"sm",onClick:M,children:"Cancel"}),a.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":_.isPending,children:_.isPending?"Deleting…":"Delete everything"})]})]})]})}function Xr(e){const{Account:s}=Ls();return a.jsx(s,{fallback:a.jsx(Yt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>a.jsx(Yt,{...e,accountEmail:t??"",signOut:i})})}function Jr(){const[e,s]=C.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.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:a.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),a.jsx(Xr,{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=nr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Qt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Zt(e){return e.connectionState==="reauth_required"}const aa=()=>a.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>a.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function Sa(){const e=_t.useSearch(),s=zs({from:_t.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[_,H]=C.useState(!1),[M,O]=C.useState(null),[T,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ft(),{data:A,isPending:ne,isError:re,error:he,refetch:oe}=Xt(Jt());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: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]),Js(N!==null,()=>{I.invalidateQueries({queryKey:Ae()})}),C.useEffect(()=>{if(!N||!A)return;const w=A.accounts.find(R=>R.accountId===N);(!w||!Zt(w))&&W(null)},[A,N]);const G=Se({...Bs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...qs(),onSuccess:()=>{I.invalidateQueries({queryKey:Ae()}),O(null)}}),P=A?.accounts.find(w=>w.accountId===M),k=A?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),H(!1)},$=w=>{const R=Gs[w];R&&s({to:R})};return a.jsxs(Qs,{items:$s,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:or,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[T&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:T}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ws,{tone:"neutral",children:ne||re?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(ee,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(aa,{}):re?a.jsx(ir,{title:"Couldn't load accounts",error:he,onRetry:()=>{oe()}}):A.accounts.length===0?a.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[a.jsx("p",{className:"mb-3",children:"No accounts configured."}),a.jsx(ee,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):a.jsx("div",{className:"space-y-3",children:A.accounts.map(w=>{const R=Zt(w),le=w.authType==="oauthMicrosoft",Z=N===w.accountId&&G.isPending,ge=R&&le?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),G.mutate({body:{email:w.email}})}}:Qt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},Te=a.jsx(Ys,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Ks,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return a.jsx(Zs,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Qt(w),errorDetail:R?"Re-authentication required":w.lastError,trailing:Te},w.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(er,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Ae()})},onCancel:()=>u(!1)})}),a.jsx(Zr,{isOpen:o||!!j,account:k,focusSmtp:_,onClose:D}),a.jsxs(ts,{open:!!M,onClose:()=>O(null),title:"Delete account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),a.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&a.jsx("p",{className:"text-center",children:P.email}),a.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[a.jsx("li",{children:"Remove the account from your settings"}),a.jsx("li",{children:"Stop syncing mail for this account"}),a.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),a.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?a.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||M&&te.mutate({path:{accountId:M}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),a.jsx(Jr,{})]})}export{Sa as component,ea as mapOauthError};
1
+ import{j as a,ac as ke,B as ee,a as Ps,X as Ve,ad as ks,ae as Vs,af as ut,r as C,b as Ge,ag as J,x as ft,ah as Ds,D as Xt,a1 as Jt,ai as Cs,aj as Se,ak as Fs,a5 as Ae,al as es,am as Os,an as Is,ao as Rs,ap as ve,aq as At,ar as it,as as Tt,at as Ms,au as Ie,av as be,aw as Et,t as Ls,ax as Us,ay as Hs,az as ts,aA as _t,a0 as zs,aB as Bs,aC as qs,aD as $s,aE as Pt,aF as Ws,aG as kt,aH as Gs,T as Ks}from"./index-CrStk0va.js";import{R as Ys}from"./row-actions-YLjTr0Pe.js";import{S as Qs,A as Zs}from"./settings-screen-YvTik_VI.js";import{g as Vt,P as Xs,s as Be,u as Js,O as er}from"./OnboardingWizard-BLAdynjS.js";import{u as tr}from"./useSignature-CZIvmo45.js";import{c as sr,a as Dt,d as rr}from"./account-form-helpers-DhckT_PN.js";import{D as ar}from"./download-fhBgd0nR.js";import{E as ir}from"./ErrorState-D5cn-r_g.js";import{f as nr}from"./format-23Av07Go.js";import{a as or}from"./help-copy-sfmab4Nc.js";import"./avatar-DVEp71DP.js";import"./menu-CVMIxRRy.js";import"./circle-help-KBbSqlpB.js";import"./kbd-CIM88W-i.js";import"./mail-CM0Ox199.js";const lr=e=>{const s=new Set(e.map(ks));return Vs.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 a.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[a.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>a.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:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:ke(o)}),d===0?a.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ps,{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"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${ke(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),a.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:[a.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>a.jsx("option",{value:o,children:ke(o)},o))]}),a.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 a.jsxs("div",{className:"rounded-sm border border-danger/50",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[a.jsx(ut,{className:"size-4 text-danger"}),a.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),a.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:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-fg",children:e}),a.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),a.jsx("div",{className:"shrink-0",children:t})]})]})}function Ct({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]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:Ge("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),a.jsxs("div",{className:Ge("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col 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:[a.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[a.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),a.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:a.jsx(Ve,{className:"size-5"})})]}),a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&a.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 mt=e=>typeof e=="object";var z=e=>!Y(e)&&!Array.isArray(e)&&mt(e)&&!je(e),ur=e=>z(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("."))),ss=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Qe=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(Qe&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&ss(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"},rs="root",pt=["__proto__","constructor","prototype"],mr=/^\w*$/;var Ue=e=>mr.test(e),L=e=>e===void 0;const pr=/[.[\]'"]/;var Ze=e=>e.split(pr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const i=Ue(s)?[s]:Ze(s);if(i.some(d=>pt.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]:Ze(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=z(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const hr=J.createContext(null);hr.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=Qe?J.useLayoutEffect:J.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),nt=e=>Y(e)||!mt(e);const Ft=(e,s)=>s.length===0&&!Array.isArray(e)&&!ss(e);function pe(e,s,t=new WeakMap){if(e===s)return!0;if(nt(e)||nt(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(Ft(e,i)||Ft(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)||(z(u)||Array.isArray(u))&&(z(j)||Array.isArray(j))?!pe(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}),st=(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 Me=(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(Me(u,s))break}else if(z(u)&&Me(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,rs,s[t]),F(e,t,o),e},K=e=>z(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Qe)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},gt=e=>e.type==="radio",Ye=e=>e instanceof RegExp,xt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const It={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var as=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:It}return It};const Mt={isValid:!1,value:null};var is=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Mt):Mt;function Lt(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=>z(e)&&!Ye(e)?e:{value:e,message:""},Ut=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:_,min:H,max:M,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=gt(n),re=Le(n),he=ne||re,oe=(b||ht(n))&&L(n.value)&&L(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,G=xt.bind(null,f,i,A),te=(P,k,D,$=de.maxLength,w=de.minLength)=>{const R=P?k:D;A[f]={type:P?$:w,message:R,ref:n,...G(P?$:w,R)}};if(d?!Array.isArray(N)||!N.length:j&&(!he&&(oe||Y(N))||me(N)&&!N||re&&!as(u).isValid||ne&&!is(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,...G(de.required,k)},!i))return I(k),A}if(!oe&&(!Y(H)||!Y(M))){let P,k;const D=Pe(M),$=Pe(H);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),R=ge=>new Date(new Date().toDateString()+" "+ge),le=n.type=="time",Z=n.type=="week";Q(D.value)&&N&&(P=le?R(N)>R(D.value):Z?N>D.value:w>new Date(D.value)),Q($.value)&&N&&(k=le?R(N)<R($.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(Ye(P)&&!N.match(P)&&(A[f]={type:de.pattern,message:k,ref:n,...G(de.pattern,k)},!i))return I(k),A}if(T){if(ie(T)){const P=await T(N,t),k=Lt(P,W);if(k&&(A[f]={...k,...G(de.validate,k.message)},!i))return I(k.message),A}else if(z(T)){let P={};for(const k in T){if(!K(P)&&!i)break;const D=Lt(await T[k](N,t),W,k);D&&(P={...D,...G(k,D.message)},I(D.message),i&&(A[f]=P))}if(!K(P)&&(A[f]={ref:W,...P},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],ns=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]:Ze(s);if(t.some(n=>pt.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&&(z(i)&&K(i)||Array.isArray(i)&&br(i))&&q(e,t.slice(0,-1)),e}const os=e=>{const s={};for(const t of Object.keys(e))if(mt(e[t])&&e[t]!==null&&!je(e[t])){const i=os(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},jr=J.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 ls(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&z(o)&&d){const n=ls(o,d);z(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var cs=e=>e.type==="select-multiple",Sr=e=>gt(e)||Le(e),rt=e=>Ke(e)&&e.isConnected,wr=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||z(e)&&!wr(e)}function us(e){return!!(e&&"_f"in e)}function fs(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function ot(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function lt(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];ds(o)&&(!Array.isArray(o)||!us(d))?(s[i]=Array.isArray(o)?[]:{},lt(o,s[i],d),fs(s[i])&&ot(s,i)):L(o)||(s[i]=!0)}return s}function Ne(e,s,t,i){t||(t=lt(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];ds(d)&&(!Array.isArray(d)||!us(n))?(L(s)||nt(t[o])?t[o]=lt(d,Array.isArray(d)?[]:{},n):Ne(d,Y(s)?{}:s[o],t[o],n),fs(t[o])&&ot(t,o)):pe(d,s[o])?ot(t,o):t[o]=!0}return t}var ms=(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 zt(e){const s=e.ref;return ht(s)?s.files:gt(s)?is(e.refs).value:cs(s)?[...s.selectedOptions].map(({value:t})=>t):Le(s)?as(e.refs).value:ms(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}},Re=e=>L(e)?e:Ye(e)?e.source:z(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var Ar=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===Bt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Bt)return!0}return!1},Tr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function qt(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)=>!ns(y(e,s)).length&&q(e,s);const Vr={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="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=z(s.defaultValues)||z(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,H=qe(s.mode),M=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=(r,l)=>c=>{clearTimeout(E[r]),E[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(T.isValid||f.isValid||r)){const l=++ae;let c;s.resolver?(c=K((await D()).errors),l===ae&&A()):c=await R({fields:i,onlyCheckValid:!0,eventType:_e.VALID}),l===ae&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(T.isValidating||T.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):q(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!K(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ne(o,d,void 0,i)},re=(r,l=[],c,m,p=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,r))){const g=c(y(i,r),m.argA,m.argB);p&&F(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&F(t.errors,r,g),kr(t.errors,r)}if((T.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&F(t.touchedFields,r,g)}(T.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:Z(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,l)},he=(r,l)=>{F(t.errors,r,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},G=r=>{const l=Ue(r)?[r]:Ze(r);let c=d,m=o;for(let p=0;p<l.length-1;p++){const x=l[p];if(c=Y(c)?c:c[x],m=Y(m)?m:m[x],c===null&&m!==null)return!0}return!1},te=(r,l,c,m)=>{const p=y(i,r);if(p){if(G(r))return;const x=L(y(d,r)),g=y(d,r,L(c)?y(o,r):c);L(g)||m&&m.defaultChecked||l?F(d,r,l?g:zt(p._f)):De(r,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,r))&&st(r,u)&&(n.watch=!0))}},P=(r,l,c,m,p)=>{let x=!1,g=!1;const v={name:r};if(!s.disabled||m===!0){if(!c||m){const S=pe(y(o,r),l);(T.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!S||Z(),x=g!==v.isDirty),g=!!y(t.dirtyFields,r),S!==t.isDirty?t.dirtyFields=Ne(o,d,void 0,i):S?q(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(T.dirtyFields||f.dirtyFields)&&g!==!S}if(c){const S=y(t.touchedFields,r);S||(F(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(T.touchedFields||f.touchedFields)&&S!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(T.isValid||f.isValid)&&me(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=W(r,()=>he(r,c)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],c?F(t.errors,r,c):q(t.errors,r),t.errors={...t.errors}),(c?!pe(p,c):p)||!K(m)||x){const g={...m,...x&&me(l)?{isValid:l}:{},errors:t.errors,name:r};t={...t,...g},b.state.next(g)}},D=async r=>(A(r,!0),await s.resolver(d,s.context,Nr(r||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),$=async r=>{const{errors:l}=await D(r);if(A(r),r){for(const c of r){const m=y(l,c);m?u.array.has(c)&&z(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ot(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:r,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:r,eventType:l});if(z(c))for(const m in c){const p=c[m];p&&ze(`${at}.${m}`,{message:Q(p.message)?p.message:"",type:p.type||de.validate})}else Q(c)||!c?ze(at,{message:c||"",type:de.validate}):Ee(at);return c}return!0},R=async({fields:r,onlyCheckValid:l,name:c,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await w({name:c,eventType:m})&&(p.valid=!1,l)))return p.valid;for(const x in r){const g=r[x];if(g){const{_f:v,...S}=g;if(v){const U=u.array.has(v.name),X=g._f&&Ar(g._f),xe=T.validatingFields||T.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,U);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?U?Ot(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!K(S)&&await R({context:p,onlyCheckValid:l,fields:S,name:x,eventType:m})}}return p.valid},le=()=>{for(const r of u.unMount){const l=y(i,r);l&&(l._f.refs?l._f.refs.every(c=>!rt(c)):!rt(l._f.ref))&&Je(r)}u.unMount=new Set},Z=(r,l)=>(r&&l&&F(d,r,l),!pe(n.mount?d:o,o)),ge=(r,l,c)=>yr(r,u,{...n.mount?d:L(l)?o:Q(r)?{[r]:l}:l},c,l),Te=r=>ns(y(n.mount?d:o,r,s.shouldUnregister?y(o,r,[]):[])),De=(r,l,c={},m=!1,p=!1)=>{const x=y(i,r);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ms(l,v)),g=Ke(v.ref)&&Y(l)?"":l,cs(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&&!p&&b.state.next({name:r,values:m?d:B(d)})))}(c.shouldDirty||c.shouldTouch)&&P(r,g,c.shouldTouch,c.shouldDirty,!p),c.shouldValidate&&fe(r,{delayError:c.delayError})},He=(r,l,c,m=!1,p=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=r+"."+x,S=y(i,v);(u.array.has(r)||z(g)||S&&!S._f)&&!je(g)?He(v,g,c,m,p):De(v,g,c,m,p)}},Xe=(r,l,c,m,p=!1)=>{const x=y(i,r),g=u.array.has(r),v=m?l:B(l),S=y(d,r),U=pe(S,v);if(U||F(d,r,v),g)b.array.next({name:r,values:m?d:B(d)}),(T.isDirty||T.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:Z(r,v)}));else{const X=Array.isArray(v)&&!v.length||K(v);!x||x._f||Y(v)||X?De(r,v,c,m,p):He(r,v,c,m,p)}if(!U&&!p){const X=st(r,u),xe=m?d:B(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Xe(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!pe(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Xe(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,..._?{values:d}:{}}),l.shouldValidate&&I()}},ce=async r=>{n.mount=!0;const l=r.target;let c=l.name,m=!0;const p=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||pe(g,y(d,c,g))};if(p){let g,v;const S=l.type?zt(p._f):ur(r),U=r.type===_e.BLUR||r.type===_e.FOCUS_OUT,X=!Tr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Pr(U,y(t.touchedFields,c),t.isSubmitted,M,H),ye=st(c,u,U);if(F(d,c,S),U){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Oe=j[c];Oe&&Oe(0)}}else p._f.onChange&&p._f.onChange(r);const Fe=P(c,S,U),Es=!K(Fe)||ye;if(!U&&b.state.next({name:c,type:r.type,..._?{values:B(d)}:{}}),xe)return(!X||!t.isValid)&&(T.isValid||f.isValid)&&(s.mode==="onBlur"?U&&I():U||I()),Es&&b.state.next({name:c,...ye?{}:Fe});if(!s.resolver&&e.validate&&await w({name:c,eventType:r.type}),!U&&ye&&b.state.next({...t}),s.resolver){const{errors:Oe}=await D([c]);if(A([c]),x(S),!m){!K(Fe)&&b.state.next(Fe);return}const _s=qt(t.errors,i,c),Nt=qt(Oe,i,_s.name||c);g=Nt.error,c=Nt.name,v=K(Oe)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(S),m&&(g?v=!1:(T.isValid||f.isValid)&&(v=await R({fields:i,onlyCheckValid:!0,name:c,eventType:r.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&fe(p._f.deps),k(c,v,g,Fe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},fe=async(r,l={})=>{let c,m;const p=We(r);if(s.resolver){const x=await $(L(r)?r:p);c=K(x),m=r?!p.some(g=>y(x,g)):c}else r?(m=(await Promise.all(p.map(async x=>{const g=y(i,x);return await R({fields:g&&g._f?{[x]:g}:g,eventType:_e.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await R({fields:i,name:r,eventType:_e.TRIGGER});if(l.delayError&&s.delayError&&Q(r)){const x=y(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({...!Q(r)||(T.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Me(i,se,r?p:u.mount),m},we=(r,l)=>{let c={...n.mount?d:o};return l&&(c=ls(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),L(r)?c:Q(r)?y(c,r):r.map(m=>y(c,m))},Ce=(r,l)=>({invalid:!!y((l||t).errors,r),isDirty:!!y((l||t).dirtyFields,r),error:y((l||t).errors,r),isValidating:!!y(t.validatingFields,r),isTouched:!!y((l||t).touchedFields,r)}),Ee=r=>{const l=r?We(r):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:{}})},ze=(r,l,c)=>{const m=(y(i,r,{_f:{}})._f||{}).ref,p=y(t.errors,r)||{},{ref:x,message:g,type:v,...S}=p;F(t.errors,r,{...S,...l,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},js=(r,l)=>{if(ie(r)){_++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||ge(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,_--,c())}}}return ge(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&_++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(_r(r.name,x.name,r.exact)&&Er(x,r.formState||T,Ts,r.reRenderRoot)){const g={...d};r.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let p=!1;return()=>{p||(p=!0,_--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Je=(r,l={})=>{for(const c of r?We(r):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()},vt=({disabled:r,name:l})=>{if(me(r)&&n.mount||r||u.disabled.has(l)){const p=u.disabled.has(l)!==!!r;r?u.disabled.add(l):u.disabled.delete(l),p&&n.mount&&!n.action&&I()}},et=(r,l={})=>{let c=y(i,r);const m=me(l.disabled)||me(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return F(i,r,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:r}},name:r,mount:!0,...l}}),u.mount.add(r),c&&!p?vt({disabled:me(l.disabled)?l.disabled:s.disabled,name:r}):te(r,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Re(l.min),max:Re(l.max),minLength:Re(l.minLength),maxLength:Re(l.maxLength),pattern:Re(l.pattern)}:{},name:r,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(r),et(r,l),u.registerName.delete(r),c=y(i,r);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,r,{_f:{...c._f,...v?{refs:[...S.filter(rt),g,...Array.isArray(y(o,r))?[{}]:[]],ref:{type:g.type,name:r}}:{ref:g}}}),te(r,!1,void 0,g)}else c=y(i,r,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(fr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Me(i,se,u.mount),ws=r=>{me(r)&&(b.state.next({disabled:r}),Me(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||r}))},0,!1))},bt=(r,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let p=B(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,p=B(g)}else await R({fields:i,eventType:_e.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(p,x);if(q(t.errors,rs),K(t.errors)){b.state.next({errors:{}});try{await r(p,c)}catch(x){m=x}}else l&&await l({...t.errors},c),tt(),setTimeout(tt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:K(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ns=(r,l={})=>{y(i,r)&&(L(l.defaultValue)?h(r,B(y(o,r))):(h(r,l.defaultValue),F(o,r,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,r),l.keepDirty||(q(t.dirtyFields,r),t.isDirty=l.defaultValue?Z(r,B(y(o,r))):Z()),l.keepError||(q(t.errors,r),T.isValid&&I()),b.state.next({...t}))},jt=(r,l={})=>{const c=r?B(r):o,m=B(c),p=K(r),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),X=y(d,S),xe=y(x,S);U&&!L(X)?F(x,S,X):!U&&!L(xe)&&h(S,xe)}}else{if(Qe&&L(r))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 X=U.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)h(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&&!K(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:p?!1:l.keepDirty?t.isDirty:l.keepValues?Z():!!(l.keepDefaultValues&&!pe(r,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ne(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&r?Ne(o,r,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})},St=(r,l)=>jt(ie(r)?r(d):r,{...s.resetOptions,...l}),As=(r,l={})=>{const c=y(i,r),m=c&&c._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),l.shouldSelect&&ie(p.select)&&p.select()})}},Ts=r=>{const{name:l,type:c,values:m,...p}=r;t={...t,...p}},wt={control:{register:et,unregister:Je,getFieldState:Ce,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:ge,_getDirty:Z,_setValid:I,_setFieldArray:re,_setDisabledField:vt,_setErrors:oe,_getFieldArray:Te,_reset:jt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(r=>{St(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:le,_disableForm:ws,_subjects:b,_proxyFormState:T,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return o},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},H=qe(s.mode),M=qe(s.reValidateMode)}},subscribe:Ss,trigger:fe,register:et,handleSubmit:bt,watch:js,setValue:h,setValues:V,getValues:we,reset:St,resetField:Ns,resetDefaultValues:(r,l={})=>{if(o=B(r),!l.keepDirty){const c=Ne(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!K(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Ee,unregister:Je,setError:ze,setFocus:As,getFieldState:Ce};return{...wt,formControl:wt}}function Cr(e={}){const s=J.useRef(void 0),t=J.useRef(void 0),i=J.useRef(e.formControl),[o,d]=J.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]),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!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),J.useEffect(()=>{var u;e.values&&!pe(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(()=>gr(o,n),[n,o]),s.current}const $t=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},ct=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?$t(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>$t(o,t,e))}},Wt=(e,s)=>{s.shouldUseNativeValidation&&ct(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 hs(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 gs(e){return Ir}function Rr(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function ys(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 vs=(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,Rr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{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=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},Ur=Lr(bs),Hr=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=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},zr=Hr(bs);function dt(){return dt=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},dt.apply(null,arguments)}function Kt(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(H){return e.push(H)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=xt(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(H){return H.forEach(function(M){return e.push(dt({},M,{path:[].concat(o.path,M.path)}))})}),s){var E=t[u].types,_=E&&E[o.code];t[u]=xt(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(Kt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Wt(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(Kt(function(){return Promise.resolve((t.mode==="sync"?Ur:zr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof Mr})(n))return{values:{},errors:Wt(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=ft(),{pushError:t}=Ds(),{data:i}=Xt({...Jt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Cs(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Ae()})},onError:j=>{t(Fs("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}},Gr=e=>e.authType==="oauthMicrosoft",Kr="••••••••••",Yr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},Qr=Ms({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:Et.number().int().min(1).max(65535),imapTls:Ie(),imapStartTls:Ie(),smtpHost:be().optional(),smtpPort:Et.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=ft(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[_,H]=C.useState(!1),M=Vt(j),O=!!M&&!_,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 h=Yr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Kr,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:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),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({...Os()}),ae=Se({...Is(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Ae()}),s()}}),W=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},I=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},A=f.handleSubmit(h=>{if(!d&&!h.password){f.setError("password",{message:"Password is required"});return}const V=sr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.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??h.smtpHost,se=V?.smtpPort??h.smtpPort,fe=V?.smtpTls??h.smtpTls,we=V?.smtpStartTls??h.smtpStartTls,Ce={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:fe,smtpStartTls:we,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Ee={...Ce,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Ee})}else{const Ee={...Ce,password:h.password};ae.mutate({body:Ee})}}),ne=ae.isPending||N.isPending,{signature:re,setSignature:he,isSaving:oe}=tr(t?.accountId),[G,te]=C.useState(re.plainText),{languages:P,setLanguages:k,isSaving:D}=Wr(t?.accountId),$=a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),a.jsx(cr,{value:P,onChange:k,busy:D})]});C.useEffect(()=>{te(re.plainText)},[re.plainText]),C.useEffect(()=>{if(!e||!i)return;const h=T.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const w=C.useCallback(()=>{G!==re.plainText&&he(G,G)},[G,re.plainText,he]),R=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",h==="tls"?993:143)},le=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const we=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",we)}},Z=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",rr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},ge=h=>{E(h),H(!1);const V=Vt(h);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=M?.passwordHelp.text,De=Dt(b.data?.imapError,Te),He=Dt(b.data?.smtpError,Te);return(t?Gr(t):!1)&&d?a.jsx(Ct,{isOpen:e,onClose:s,title:"Edit Account",footer:a.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),a.jsx("span",{className:"text-fg",children:t?.email})]}),a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),a.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),a.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&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-view",value:G,onChange:h=>te(h.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..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})}):a.jsx(Ct,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:a.jsxs(a.Fragment,{children:[a.jsx(ee,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),a.jsx(ee,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:a.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),a.jsxs(Rs,{id:"account-provider",value:j,onChange:h=>ge(h.target.value),children:[a.jsx("option",{value:"",children:"Custom / other"}),Xs.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))]}),a.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."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),a.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),a.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),a.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."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),a.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),a.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&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),M&&a.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[M.passwordHelp.text," ",a.jsx("a",{href:M.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),M&&a.jsx("button",{type:"button",onClick:()=>H(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:_?"Use preset settings":"Advanced"})]}),O&&a.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",M?.label," and locked. Choose Advanced to edit them by hand."]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>R("tls")}),"TLS (Port 993)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>R("starttls")}),"STARTTLS (Port 143)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>R("none")}),"None (Unencrypted)"]})]})]})]}),a.jsx(ee,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":De]})]})]}),a.jsxs("section",{ref:T,"data-testid":"smtp-section",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&a.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"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>le("tls")}),"TLS (Port 465)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>le("starttls")}),"STARTTLS (Port 587)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>le("none")}),"None (Unencrypted)"]})]})]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),a.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),a.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),a.jsx(ee,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ve,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":He]})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-edit",value:G,onChange:h=>te(h.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..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&$]})})};function Yt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),_=Se({...Us(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),H=Se(Hs()),M=()=>{_.isPending||(d(""),u(!1),E(!1),_.reset(),H.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),_.mutate({body:{confirmEmail:o.trim()}})};return a.jsxs(ts,{open:e,onClose:M,title:"Delete your Remit account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),onClick:M,"aria-label":"Cancel"})]}),j?a.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[a.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),a.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),a.jsxs("ul",{className:"space-y-1.5 text-xs",children:[a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),a.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[a.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."]}),a.jsxs("div",{className:"text-xs",children:[a.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:[a.jsx(ar,{className:"size-3.5"}),H.isPending?"Requesting export…":"Export my data first"]}),H.isSuccess&&a.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&&a.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",a.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),a.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&&a.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&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:_.error instanceof Error?_.error.message:"Something went wrong. Please try again."})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(ee,{variant:"secondary",size:"sm",onClick:M,children:"Cancel"}),a.jsx(ee,{variant:"danger",size:"sm",onClick:O,"aria-busy":_.isPending,children:_.isPending?"Deleting…":"Delete everything"})]})]})]})}function Xr(e){const{Account:s}=Ls();return a.jsx(s,{fallback:a.jsx(Yt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>a.jsx(Yt,{...e,accountEmail:t??"",signOut:i})})}function Jr(){const[e,s]=C.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.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:a.jsx(ee,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),a.jsx(Xr,{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=nr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Qt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Zt(e){return e.connectionState==="reauth_required"}const aa=()=>a.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>a.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function Sa(){const e=_t.useSearch(),s=zs({from:_t.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[_,H]=C.useState(!1),[M,O]=C.useState(null),[T,f]=C.useState(null),[b,ae]=C.useState(null),[N,W]=C.useState(null),I=ft(),{data:A,isPending:ne,isError:re,error:he,refetch:oe}=Xt(Jt());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: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]),Js(N!==null,()=>{I.invalidateQueries({queryKey:Ae()})}),C.useEffect(()=>{if(!N||!A)return;const w=A.accounts.find(R=>R.accountId===N);(!w||!Zt(w))&&W(null)},[A,N]);const G=Se({...Bs(),onSuccess:w=>{window.location.assign(w.authorizationUrl)},onError:w=>{ae(w instanceof Error?w.message:"Failed to start reconnect"),W(null)}}),te=Se({...qs(),onSuccess:()=>{I.invalidateQueries({queryKey:Ae()}),O(null)}}),P=A?.accounts.find(w=>w.accountId===M),k=A?.accounts.find(w=>w.accountId===j),D=()=>{d(!1),u(!1),E(null),H(!1)},$=w=>{const R=Gs[w];R&&s({to:R})};return a.jsxs(Qs,{items:$s,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:or,helpOpen:t,onToggleHelp:()=>i(w=>!w),onSelect:$,onBackToMail:()=>{s({to:"/mail"})},children:[T&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:T}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>ae(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ws,{tone:"neutral",children:ne||re?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(ee,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(aa,{}):re?a.jsx(ir,{title:"Couldn't load accounts",error:he,onRetry:()=>{oe()}}):A.accounts.length===0?a.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[a.jsx("p",{className:"mb-3",children:"No accounts configured."}),a.jsx(ee,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):a.jsx("div",{className:"space-y-3",children:A.accounts.map(w=>{const R=Zt(w),le=w.authType==="oauthMicrosoft",Z=N===w.accountId&&G.isPending,ge=R&&le?{label:"Reconnect",variant:"secondary",busy:Z,busyLabel:"Redirecting…",onClick:()=>{W(w.accountId),G.mutate({body:{email:w.email}})}}:Qt(w)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(w.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(w.accountId)},Te=a.jsx(Ys,{actions:[ge],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Ks,{className:"size-3.5"}),onClick:()=>O(w.accountId)}});return a.jsx(Zs,{label:sa(w),email:w.email,connector:le?"Microsoft 365":"IMAP",syncLabel:ra(w),state:Qt(w),errorDetail:R?"Re-authentication required":w.lastError,trailing:Te},w.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(er,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Ae()})},onCancel:()=>u(!1)})}),a.jsx(Zr,{isOpen:o||!!j,account:k,focusSmtp:_,onClose:D}),a.jsxs(ts,{open:!!M,onClose:()=>O(null),title:"Delete account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),a.jsx(ee,{variant:"ghost",size:"sm",icon:a.jsx(Ve,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),a.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),P&&a.jsx("p",{className:"text-center",children:P.email}),a.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[a.jsx("li",{children:"Remove the account from your settings"}),a.jsx("li",{children:"Stop syncing mail for this account"}),a.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),a.jsx(ee,{variant:"danger",size:"sm","aria-busy":te.isPending,icon:te.isPending?a.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{te.isPending||M&&te.mutate({path:{accountId:M}})},children:te.isPending?"Deleting…":"Delete account"})]})]}),a.jsx(Jr,{})]})}export{Sa as component,ea as mapOauthError};
@@ -1,4 +1,4 @@
1
- import{c as b,j as e,az as C,B as i,aK as p,aF as R,aL as V,aM as D,aE as z,af as x,aN as T,r as h,ar as y,aO as g,b as L,aP as O,D as q,aQ as H,aR as S,aS as I,aT as U,$ as F,aU as Q,aV as Y,aW as G,a0 as W,aD as Z,aH as J}from"./index-idulIG65.js";import{S as K}from"./settings-screen-B17eDLDl.js";import{B as A}from"./bug-CDU4oK_3.js";import{C as _}from"./circle-check-BhMyR8BA.js";import{f as X}from"./ErrorState-B_pp6XjY.js";import{D as M}from"./download-Br1uSntK.js";import{R as k}from"./rotate-ccw-DfGOnKhE.js";import{C as ee}from"./clock-DCdX5E4T.js";import{S as se}from"./shield-check-DG9twqa-.js";import{b as ae}from"./help-copy-D1mikTkH.js";import"./avatar-C8lpjlQO.js";import"./menu-MXmFQ7m-.js";import"./circle-help-BAup3nOG.js";import"./kbd-eZWvlfcb.js";const te=b("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 ne=b("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const v=b("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"}]]),re={BodyParse:"The message is built in a way Remit could not read."};function ie(s){return re[s]}function $(s){return s.split(";")[0].trim()}const w=/^[A-Za-z0-9!#$%&'*+._-]+$/,E=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,a){return a.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function le(s){const a=$(s);return E.test(a)?a:JSON.stringify(a)}const N="_not read_";function ce(s){return s.length===0?["(no MIME structure was read)"]:s.map(a=>`${" ".repeat(a.depth)}- ${le(a.contentType)}`)}const oe="_No message content, addresses, subject, attachment names or parser output are included._";function P(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j($(s.contentType),E)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,w)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,w)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{c as b,j as e,az as C,B as i,aK as p,aF as R,aL as V,aM as D,aE as z,af as x,aN as T,r as h,ar as y,aO as g,b as L,aP as O,D as q,aQ as H,aR as S,aS as I,aT as U,$ as F,aU as Q,aV as Y,aW as G,a0 as W,aD as Z,aH as J}from"./index-CrStk0va.js";import{S as K}from"./settings-screen-YvTik_VI.js";import{B as A}from"./bug-DET_KgV6.js";import{C as _}from"./circle-check-B3vjKaD1.js";import{f as X}from"./ErrorState-D5cn-r_g.js";import{D as M}from"./download-fhBgd0nR.js";import{R as k}from"./rotate-ccw-BdyunlX_.js";import{C as ee}from"./clock-sbv7ILkY.js";import{S as se}from"./shield-check-CmdMSuok.js";import{b as ae}from"./help-copy-sfmab4Nc.js";import"./avatar-DVEp71DP.js";import"./menu-CVMIxRRy.js";import"./circle-help-KBbSqlpB.js";import"./kbd-CIM88W-i.js";const te=b("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 ne=b("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const v=b("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"}]]),re={BodyParse:"The message is built in a way Remit could not read."};function ie(s){return re[s]}function $(s){return s.split(";")[0].trim()}const w=/^[A-Za-z0-9!#$%&'*+._-]+$/,E=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function j(s,a){return a.test(s)?`\`${s}\``:`\`${JSON.stringify(s).replace(/`/g,"\\u0060")}\` (malformed)`}function le(s){const a=$(s);return E.test(a)?a:JSON.stringify(a)}const N="_not read_";function ce(s){return s.length===0?["(no MIME structure was read)"]:s.map(a=>`${" ".repeat(a.depth)}- ${le(a.contentType)}`)}const oe="_No message content, addresses, subject, attachment names or parser output are included._";function P(s){return{head:[`### Message quarantined at \`${s.failureStage}\``,"",`- **Failure**: \`${s.failureCode}\``,`- **Folder role**: ${s.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${s.failurePartPath==null?"_whole message_":`\`${s.failurePartPath}\``}`,`- **Attempts before quarantine**: ${s.attempts}`,`- **Worker build**: ${s.workerVersion}`,`- **Message-ID hash**: ${s.messageIdHash==null?"_none declared_":`\`${s.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${s.contentType==null?N:j($(s.contentType),E)}`,`- **Content-Transfer-Encoding**: ${s.transferEncoding==null?N:j(s.transferEncoding,w)}`,`- **Charset**: ${s.charset==null?"_not declared_":j(s.charset,w)}`,`- **Size**: ${s.sizeBytes==null?N:`${s.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:ce(s.structure).join(`
3
3
  `),disclaimer:oe}}function de(s){const{head:a,structure:t,disclaimer:r}=P(s);return[a,"","```",t,"```","",r].join(`
4
4
  `)}function me(s){return`Message quarantined: ${s.failureCode} at ${s.failureStage}`}function xe({entry:s,onClose:a,issueUrl:t,onCopy:r}){if(!s)return null;const n=de(s);return e.jsx(C,{open:!0,onClose:a,title:"Report this message",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.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes the shape of the message — never its contents, addresses, subject, attachment names, or the parser's own error text."})]}),e.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:n}),e.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(i,{variant:"secondary",size:"sm",icon:e.jsx(ne,{className:"size-3.5"}),onClick:()=>r(n),children:"Copy report"}),e.jsx(p,{external:!0,size:"sm",href:t,icon:e.jsx(v,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}function he(s){return new Date(s).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function ue({entry:s,onCutBug:a}){return e.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:ie(s.failureStage)}),e.jsx("p",{className:"truncate text-xs text-fg-muted",title:s.failureMessage,children:s.failureMessage}),e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[s.mailboxRole&&e.jsx(R,{tone:"warning",children:V(s.mailboxRole)}),e.jsx("span",{className:"truncate",title:s.mailboxPath,children:D(s.mailboxPath)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`uid ${s.uid}`}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:he(s.quarantinedAt)}),s.attempts>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:`${s.attempts} attempts`})]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>a(s),children:"Cut a bug"})]})}function pe({entries:s,onCutBug:a}){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:"Messages set aside"}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),s.length===0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[e.jsx(_,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),s.length>1&&e.jsx(z,{tone:"warning",children:e.jsxs("p",{className:"flex items-start gap-2",children:[e.jsx(x,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:`${s.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),s.length>0&&e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:s.map(t=>e.jsx(ue,{entry:t,onCutBug:a},t.quarantineId))})]})}const fe=["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 ge({open:s,currentVersion:a,release:t,appliesSchemaMigration:r=!1,onClose:n,onConfirm:c}){return s?e.jsx(C,{open:!0,onClose:n,title:`Install Remit ${t.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 ",t.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",a,". ",t.version," was released"," ",T(t.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:t.summary}),e.jsxs("ul",{className:"space-y-2",children:[fe.map(l=>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:l})]},l)),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(i,{variant:"ghost",size:"sm",onClick:n,children:"Not now"}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:t.releaseNotesUrl,icon:e.jsx(v,{className:"size-3.5"}),children:"Release notes"}),e.jsx(i,{size:"sm",icon:e.jsx(M,{className:"size-3.5"}),onClick:c,children:"Install and restart"})]})]})}):null}function o({children:s,tone:a}){return e.jsx("div",{className:L("rounded-sm border bg-surface px-row-inset py-3",a==="danger"?"border-danger/50":"border-line"),children:s})}function je({state:s,onCheck:a,onInstall:t,onDismissResult:r,now:n=Date.now()}){const[c,l]=h.useState(null),m=s.status==="checking",d=s.status==="available",u=()=>{if(m){l("Already checking. The result appears here in a moment.");return}l(null),a()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){l("There is no update to install. Check for updates first — if one is found it appears here.");return}l(null),t()},B=(()=>{switch(s.status){case"upToDate":return e.jsx(o,{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(_,{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 ",g(s.checkedAt,n),"."]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"checking":return e.jsx(o,{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(y,{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(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check again"})]})});case"neverChecked":return e.jsx(o,{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(ee,{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"," ",g(s.lastCheckedAt,n),"."]})]})]}),e.jsx(i,{variant:"secondary",size:"sm",className:"shrink-0",onClick:u,children:"Check now"})]})});case"checkFailed":return e.jsx(o,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{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"," ",g(s.lastCheckedAt,n),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(i,{variant:"secondary",size:"sm",onClick:u,children:"Try again"})})]})});case"available":return e.jsx(o,{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 ",T(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(i,{size:"sm",icon:e.jsx(M,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(p,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(v,{className:"size-3.5"}),children:"Release notes"})]})]})});case"applying":return e.jsx(o,{children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(y,{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(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{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(i,{variant:"secondary",size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(i,{variant:"ghost",size:"sm",onClick:r,children:["Stay on ",s.version]})]})]})});case"unreachable":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{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(i,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"rollbackFailed":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{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(i,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})})]})});case"abandoned":return e.jsx(o,{tone:"danger",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{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(i,{variant:"secondary",size:"sm",icon:e.jsx(k,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(i,{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."})]}),B,c&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:c})]})}function Ne(s){return{quarantineId:s.quarantineId,accountId:s.accountId,mailboxId:s.mailboxId,uidValidity:s.uidValidity,uid:s.uid,mailboxRole:s.mailboxRole?O[s.mailboxRole]:void 0,mailboxPath:s.mailboxPath,failureStage:s.failureStage,failureCode:s.failureCode,failureMessage:s.failureMessage,failurePartPath:s.failurePartPath,quarantinedAt:s.quarantinedAt,attempts:s.attempts,sizeBytes:s.sizeBytes,contentType:s.contentType,transferEncoding:s.transferEncoding,charset:s.charset,structure:s.structure,messageIdHash:s.messageIdHash,workerVersion:s.workerVersion}}function be(s){window.open(s,"_blank","noopener,noreferrer")}function ve(s){return S(I({quarantine:P(s),title:me(s)}))}function ye({error:s}){return e.jsxs("section",{role:"alert",className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),e.jsxs("div",{className:"space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-row-inset py-3",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The list of set-aside messages could not be read."}),e.jsx("p",{className:"break-words text-sm text-fg-muted",children:X(s)}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Mail may still have been set aside — this page cannot say either way until it can read the list. Reporting this gets it fixed."}),e.jsx(i,{variant:"secondary",size:"sm",icon:e.jsx(A,{className:"size-3.5"}),onClick:()=>be(S(I())),children:"Report this"})]})]})}function ke({entries:s,isPending:a,error:t}){const[r,n]=h.useState(null),[c,l]=h.useState(!1);if(a)return e.jsx("p",{className:"animate-pulse text-sm text-fg-subtle",children:"Checking for messages set aside…"});if(t)return e.jsx(ye,{error:t});const m=d=>{navigator.clipboard.writeText(d).then(()=>{l(!1),n(null)},()=>{l(!0),n(null)})};return e.jsxs(e.Fragment,{children:[c&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-danger",children:"The report was not copied — this browser refused clipboard access. Cut the bug again and use Open on GitHub, which needs no clipboard."}),e.jsx(pe,{entries:s,onCutBug:n}),e.jsx(xe,{entry:r,issueUrl:r?ve(r):"",onClose:()=>n(null),onCopy:m})]})}function we(){const{data:s,isPending:a,error:t}=q(H());return e.jsx(ke,{entries:(s?.entries??[]).map(Ne),isPending:a,error:t})}function Ce(){const{surface:s,release:a,currentVersion:t,appliesSchemaMigration:r,onCheck:n,install:c,onDismissResult:l}=U(),[m,d]=h.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(je,{state:s.section,onCheck:n,onInstall:()=>d(!0),onDismissResult:l}),a&&t&&e.jsx(ge,{open:m,currentVersion:t,release:a,appliesSchemaMigration:r,onClose:()=>d(!1),onConfirm:()=>{d(!1),c(a.version)}})]})}function Re(){return F().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(p,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(se,{className:"size-3.5"}),children:"Download root certificate"})]})}function ze(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 Te({sha:s=Y,commitUrl:a=Q,buildTime:t=G}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",a?e.jsx("a",{href:a,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 ",ze(t)]})]})}function Ue(){const s=W(),[a,t]=h.useState(!0),r=n=>{const c=J[n];c&&s({to:c})};return e.jsxs(K,{items:Z,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:ae,helpOpen:a,onToggleHelp:()=>t(n=>!n),onSelect:r,onBackToMail:()=>{s({to:"/mail"})},children:[e.jsx(Ce,{}),e.jsx(we,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Notification rules and data export are coming in a future release."})}),e.jsx(Re,{}),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(Te,{})]})]})}export{Ue as component};
@@ -1 +1 @@
1
- import{a0 as x,r as a,aX as g,j as e,aD as S,aY as n,aH as y,aZ as T}from"./index-idulIG65.js";import{S as v}from"./settings-screen-B17eDLDl.js";import{c as b}from"./help-copy-D1mikTkH.js";import"./avatar-C8lpjlQO.js";import"./menu-MXmFQ7m-.js";import"./circle-help-BAup3nOG.js";import"./kbd-eZWvlfcb.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}function H(){const s=x(),[i,r]=a.useState(!0),[c,m]=a.useState(N),[p,d]=a.useState(g),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),T(t)},u=t=>{const l=y[t];l&&s({to:l})};return e.jsx(v,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:b,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:u,onBackToMail:()=>{s({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(n,{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(n,{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{H as component};
1
+ import{a0 as x,r as a,aX as g,j as e,aD as S,aY as n,aH as y,aZ as T}from"./index-CrStk0va.js";import{S as v}from"./settings-screen-YvTik_VI.js";import{c as b}from"./help-copy-sfmab4Nc.js";import"./avatar-DVEp71DP.js";import"./menu-CVMIxRRy.js";import"./circle-help-KBbSqlpB.js";import"./kbd-CIM88W-i.js";const o="remit.density";function N(){return typeof localStorage>"u"?"comfortable":localStorage.getItem(o)??"comfortable"}function H(){const s=x(),[i,r]=a.useState(!0),[c,m]=a.useState(N),[p,d]=a.useState(g),h=t=>{m(t),typeof localStorage<"u"&&localStorage.setItem(o,t)},f=t=>{d(t),T(t)},u=t=>{const l=y[t];l&&s({to:l})};return e.jsx(v,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:b,helpOpen:i,onToggleHelp:()=>r(t=>!t),onSelect:u,onBackToMail:()=>{s({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(n,{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(n,{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{H as component};
@@ -1 +1 @@
1
- import{c as M,r as h,j as i,B as R,b as g,bE as _}from"./index-idulIG65.js";const k=M("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const $=M("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),y=4,E=8;function I(e,t,s){const n=Math.max(E,window.innerWidth-t.width-E),o=s==="end"?e.right-t.width:e.left,r=Math.min(Math.max(o,E),n),l=e.bottom+y,c=e.top-y-t.height,f=l+t.height<=window.innerHeight-E||c<E?l:c;return{left:r,top:f}}function P(e,t,s,n){const[o,r]=h.useState(null),l=h.useRef(n);return l.current=n,h.useLayoutEffect(()=>{if(!t){r(null);return}const c=()=>{const p=e.current,f=l.current();if(!p||!f)return;const a=p.getBoundingClientRect(),x={width:a.right-a.left,height:a.bottom-a.top},d=I(f,x,s);r(m=>m?.left===d.left&&m.top===d.top?m:{position:"fixed",left:d.left,top:d.top})};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[t,s,e]),o}function S({open:e,align:t="start",getAnchor:s,panelRef:n,children:o}){const r=P(n,e,t,s);return e?_.createPortal(i.jsx("div",{style:r??{position:"fixed",visibility:"hidden"},children:o}),document.body):null}function j({label:e,children:t,className:s,ref:n,onKeyDown:o,"data-testid":r}){return i.jsx("div",{ref:n,role:"menu","aria-label":e,tabIndex:-1,onKeyDown:o,"data-testid":r,className:g("z-50 flex max-h-[60dvh] min-w-44 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg outline-none",s),children:t})}function T({label:e,icon:t,onSelect:s,className:n,lang:o,"data-testid":r}){return i.jsxs("button",{type:"button",role:"menuitem",lang:o,onClick:s,"data-testid":r,className:g("flex min-h-11 items-center gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",n),children:[t&&i.jsx("span",{className:"shrink-0 text-fg-subtle",children:t}),e]})}function U({triggerLabel:e,triggerIcon:t,triggerText:s,items:n,align:o="end",touch:r=!0,className:l,triggerClassName:c,nested:p=!1,children:f}){const[a,x]=h.useState(!1),d=h.useRef(null),m=h.useRef(null);return h.useEffect(()=>{if(!a)return;const u=b=>{const v=b.target;d.current?.contains(v)||m.current?.contains(v)||x(!1)},w=b=>{b.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",w)}},[a]),n.length===0&&!f?null:i.jsxs("div",{ref:d,className:g("relative",l),...p?{role:"none"}:{},children:[i.jsx(R,{variant:"ghost",size:"sm",icon:t??i.jsx(k,{className:"size-5"}),onClick:()=>x(u=>!u),"aria-label":e,"aria-haspopup":"menu","aria-expanded":a,...p?{role:"menuitem"}:{},className:g(r&&"min-h-11 min-w-11 px-0",c),children:s}),i.jsx(S,{open:a,align:o,panelRef:m,getAnchor:()=>d.current?.getBoundingClientRect()??null,children:i.jsxs(j,{ref:m,children:[n.map(u=>i.jsx(T,{label:u.label,icon:u.icon,onSelect:()=>{x(!1),u.onSelect()}},u.key)),f]})})]})}const B=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,C=/[<>:"|?*]/g,z=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,A=120,H=12,F="attachment",N=e=>{const t=[...e];if(t.length<=A)return e;const s=e.lastIndexOf("."),n=s>0&&[...e.slice(s)].length<=H?e.slice(s):"",o=A-[...n].length;return t.slice(0,o).join("")+n},G=(e,t=F)=>{const n=e.replace(B,"").split(/[/\\]/),r=(n[n.length-1]??"").replace(C,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(r.length===0)return N(t);const l=z.test(r)?`_${r}`:r;return N(l)},L=["KB","MB","GB","TB"],O=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const s=1023.95;let n=t/1024,o=0;for(;n>=s&&o<L.length-1;)n/=1024,o+=1;return`${n.toFixed(1).replace(/\.0$/,"")} ${L[o]}`};export{k as E,U as P,$ as U,S as a,j as b,T as c,O as f,G as s};
1
+ import{c as M,r as h,j as i,B as R,b as g,bE as _}from"./index-CrStk0va.js";const k=M("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const $=M("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),y=4,E=8;function I(e,t,s){const n=Math.max(E,window.innerWidth-t.width-E),o=s==="end"?e.right-t.width:e.left,r=Math.min(Math.max(o,E),n),l=e.bottom+y,c=e.top-y-t.height,f=l+t.height<=window.innerHeight-E||c<E?l:c;return{left:r,top:f}}function P(e,t,s,n){const[o,r]=h.useState(null),l=h.useRef(n);return l.current=n,h.useLayoutEffect(()=>{if(!t){r(null);return}const c=()=>{const p=e.current,f=l.current();if(!p||!f)return;const a=p.getBoundingClientRect(),x={width:a.right-a.left,height:a.bottom-a.top},d=I(f,x,s);r(m=>m?.left===d.left&&m.top===d.top?m:{position:"fixed",left:d.left,top:d.top})};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[t,s,e]),o}function S({open:e,align:t="start",getAnchor:s,panelRef:n,children:o}){const r=P(n,e,t,s);return e?_.createPortal(i.jsx("div",{style:r??{position:"fixed",visibility:"hidden"},children:o}),document.body):null}function j({label:e,children:t,className:s,ref:n,onKeyDown:o,"data-testid":r}){return i.jsx("div",{ref:n,role:"menu","aria-label":e,tabIndex:-1,onKeyDown:o,"data-testid":r,className:g("z-50 flex max-h-[60dvh] min-w-44 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg outline-none",s),children:t})}function T({label:e,icon:t,onSelect:s,className:n,lang:o,"data-testid":r}){return i.jsxs("button",{type:"button",role:"menuitem",lang:o,onClick:s,"data-testid":r,className:g("flex min-h-11 items-center gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",n),children:[t&&i.jsx("span",{className:"shrink-0 text-fg-subtle",children:t}),e]})}function U({triggerLabel:e,triggerIcon:t,triggerText:s,items:n,align:o="end",touch:r=!0,className:l,triggerClassName:c,nested:p=!1,children:f}){const[a,x]=h.useState(!1),d=h.useRef(null),m=h.useRef(null);return h.useEffect(()=>{if(!a)return;const u=b=>{const v=b.target;d.current?.contains(v)||m.current?.contains(v)||x(!1)},w=b=>{b.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",w)}},[a]),n.length===0&&!f?null:i.jsxs("div",{ref:d,className:g("relative",l),...p?{role:"none"}:{},children:[i.jsx(R,{variant:"ghost",size:"sm",icon:t??i.jsx(k,{className:"size-5"}),onClick:()=>x(u=>!u),"aria-label":e,"aria-haspopup":"menu","aria-expanded":a,...p?{role:"menuitem"}:{},className:g(r&&"min-h-11 min-w-11 px-0",c),children:s}),i.jsx(S,{open:a,align:o,panelRef:m,getAnchor:()=>d.current?.getBoundingClientRect()??null,children:i.jsxs(j,{ref:m,children:[n.map(u=>i.jsx(T,{label:u.label,icon:u.icon,onSelect:()=>{x(!1),u.onSelect()}},u.key)),f]})})]})}const B=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,C=/[<>:"|?*]/g,z=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,A=120,H=12,F="attachment",N=e=>{const t=[...e];if(t.length<=A)return e;const s=e.lastIndexOf("."),n=s>0&&[...e.slice(s)].length<=H?e.slice(s):"",o=A-[...n].length;return t.slice(0,o).join("")+n},G=(e,t=F)=>{const n=e.replace(B,"").split(/[/\\]/),r=(n[n.length-1]??"").replace(C,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(r.length===0)return N(t);const l=z.test(r)?`_${r}`:r;return N(l)},L=["KB","MB","GB","TB"],O=e=>{if(!Number.isFinite(e)||e<0)return"unknown size";const t=Math.round(e);if(t<1024)return t===1?"1 byte":`${t} bytes`;const s=1023.95;let n=t/1024,o=0;for(;n>=s&&o<L.length-1;)n/=1024,o+=1;return`${n.toFixed(1).replace(/\.0$/,"")} ${L[o]}`};export{k as E,U as P,$ as U,S as a,j as b,T as c,O as f,G as s};
@@ -1 +1 @@
1
- import{r as a,j as h,b as u}from"./index-idulIG65.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};
1
+ import{r as a,j as h,b as u}from"./index-CrStk0va.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};
@@ -1 +1 @@
1
- import{r as n,j as o,b as v}from"./index-idulIG65.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};
1
+ import{r as n,j as o,b as v}from"./index-CrStk0va.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,a4 as i}from"./index-CrStk0va.js";import{a as m}from"./MailShell-8jHD0muk.js";import{B as o}from"./BriefPane-B_43XrIX.js";import{g as p}from"./search-token-index-CRfarw2N.js";import{u as e}from"./search-mirror-DxvFKHd5.js";import"./FullCompose-CTBUQaxT.js";import"./ErrorState-D5cn-r_g.js";import"./index-04bqfNgp.js";import"./useMessageBodyContent-D2ppLfqI.js";import"./useSignature-CZIvmo45.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-DBe8RTdD.js";import"./confirm-dialog-DoFwvjx5.js";import"./useSearchTokenContext-BFF5PFp_.js";import"./kbd-CIM88W-i.js";import"./search-scope-DTcpOp3S.js";import"./MailListHeader-DzjUH8L0.js";import"./attachment-file-C1JZr27N.js";import"./mail-CM0Ox199.js";import"./avatar-DVEp71DP.js";import"./format-23Av07Go.js";import"./download-fhBgd0nR.js";import"./shield-check-CmdMSuok.js";import"./useFilters-BV7Ur6sx.js";import"./clock-sbv7ILkY.js";import"./menu-CVMIxRRy.js";import"./useRefreshControl-B_HOBKw6.js";import"./circle-check-big-CTk0kr4F.js";import"./useLabels-77azHAmW.js";import"./useSemanticSearch-DVz20iAO.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-B1bng5Jq.js";function F(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{F as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-idulIG65.js";import{E as t}from"./ErrorState-B_pp6XjY.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};
1
+ import{j as r}from"./index-CrStk0va.js";import{E as t}from"./ErrorState-D5cn-r_g.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};
@@ -1,2 +1,2 @@
1
- import{dK as A,V as $}from"./index-idulIG65.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 J(){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(V)}),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 V(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 z(e){var t=new i,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
1
+ import{dK as A,V as $}from"./index-CrStk0va.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 J(){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(V)}),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 V(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 z(e){var t=new i,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
2
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 G=[301,302,303,307,308];c.redirect=function(e,t){if(G.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:z(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=J();const K=$(S),Q=X({__proto__:null,default:K},[S]);export{Q as b};
@@ -1 +1 @@
1
- import{c as a}from"./index-idulIG65.js";const t=a("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);export{t as B};
1
+ import{c as a}from"./index-CrStk0va.js";const t=a("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);export{t as B};