@remit/web-client-dist 0.0.675 → 0.0.676

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 (181) hide show
  1. package/assets/{AppFrame-R9FR9SH9.js → AppFrame-DSPG81Mk.js} +1 -1
  2. package/assets/{BriefPane-BzlqkW4r.js → BriefPane-Cfl-uWfm.js} +1 -1
  3. package/assets/CalendarEventEditor-COnJXvRd.js +1 -0
  4. package/assets/CalendarEventPopup-CqHE2vrc.js +1 -0
  5. package/assets/CalendarLoadFailed-CxL15r1A.js +1 -0
  6. package/assets/CalendarQuickCreate-DxgU3bNP.js +1 -0
  7. package/assets/CalendarSession-BKwK9s2o.js +1 -0
  8. package/assets/{EmptyState-dD_YhGMH.js → EmptyState-BUOSmldo.js} +1 -1
  9. package/assets/{ErrorState-nA0Ptq3g.js → ErrorState-KjDYblD5.js} +1 -1
  10. package/assets/{FlaggedPane-BwhUf1qN.js → FlaggedPane-Dw-wR4tp.js} +1 -1
  11. package/assets/{FullCompose-dJ4mfUrX.js → FullCompose-Djp_h4BT.js} +1 -1
  12. package/assets/{LabelApplyTrigger-BA7ANeDk.js → LabelApplyTrigger-oS5sxATE.js} +1 -1
  13. package/assets/{MailShell-0sTtK1xD.js → MailShell-LIuV2C3h.js} +1 -1
  14. package/assets/{MailViewChrome-BEx9Dr1Z.js → MailViewChrome-yffBJjbO.js} +1 -1
  15. package/assets/{MailboxPane-DYgnYeOy.js → MailboxPane-DUCZVAx6.js} +1 -1
  16. package/assets/{MessageBody-Deha778B.js → MessageBody-C89PSL_p.js} +1 -1
  17. package/assets/MessageToolbar-UJadqHyA.js +1 -0
  18. package/assets/{NavMenuButton-C-7-t18I.js → NavMenuButton-B-goW-G5.js} +1 -1
  19. package/assets/{OnboardingWizard-hfP07hpw.js → OnboardingWizard-Cvqq2aP_.js} +1 -1
  20. package/assets/{OutboxPane-gEXLW7BJ.js → OutboxPane-ce4uTAzW.js} +1 -1
  21. package/assets/_calendarObjectId-lcrg9Fhc.js +1 -0
  22. package/assets/_mailboxId-BzKo-TnK.js +1 -0
  23. package/assets/_messageId-C7U0TsBv.js +1 -0
  24. package/assets/_messageId-CGB3gt7C.js +1 -0
  25. package/assets/_messageId-D2Qjacn6.js +1 -0
  26. package/assets/_outboxMessageId-FUbJ3RF8.js +1 -0
  27. package/assets/_recurrenceId-DpQOCGAd.js +1 -0
  28. package/assets/_threadId-BmZ2vl5z.js +1 -0
  29. package/assets/_threadId-Bs84eLjr.js +1 -0
  30. package/assets/_threadId-DySupNzi.js +1 -0
  31. package/assets/_view._date-DYujYKtx.js +1 -0
  32. package/assets/{account-service-status-Kz9s3jOk.js → account-service-status-oYDwuPLn.js} +1 -1
  33. package/assets/{accounts-B5C8kCn6.js → accounts-DhSbRlEm.js} +1 -1
  34. package/assets/{advanced-CudHnY-7.js → advanced-B50NfkTy.js} +1 -1
  35. package/assets/{appearance-BTH52atO.js → appearance-CYNOlHLz.js} +1 -1
  36. package/assets/{avatar-vPm9XfmM.js → avatar-uWJajuSb.js} +1 -1
  37. package/assets/{bottom-sheet-BTdseD_6.js → bottom-sheet-Bc0vwv2J.js} +1 -1
  38. package/assets/brief-DPWE6nMF.js +1 -0
  39. package/assets/{brief-DuHUqR8b.js → brief-bdXCpAmW.js} +1 -1
  40. package/assets/{calendar-BQjH3OHS.js → calendar-7SdvLY_h.js} +1 -1
  41. package/assets/calendar-event-popup-DsPmxVye.js +1 -0
  42. package/assets/calendar-event-sidebar-soFGsDRR.js +1 -0
  43. package/assets/{calendar-failure-note-BUFaaizf.js → calendar-failure-note-BtZLcaiZ.js} +1 -1
  44. package/assets/calendar-format-BwCpz-JZ.js +1 -0
  45. package/assets/calendar-guests-BR4hC59z.js +1 -0
  46. package/assets/calendar-suggestion-8jcpefeR.js +1 -0
  47. package/assets/calendar-tMekVEGW.js +1 -0
  48. package/assets/calendars-bLB0g-E-.js +1 -0
  49. package/assets/{card-865cdsJK.js → card-CPL-TrL1.js} +1 -1
  50. package/assets/{checkbox-Qon94b1C.js → checkbox-CGG1nAhQ.js} +1 -1
  51. package/assets/{circle-check-big-CyVG6r7N.js → circle-check-big-BsCwNdJZ.js} +1 -1
  52. package/assets/{circle-check-Db07NpOC.js → circle-check-i3jeyeTf.js} +1 -1
  53. package/assets/{circle-help-CVShnhWn.js → circle-help-CVWHf1ow.js} +1 -1
  54. package/assets/{clock-B9kFW89H.js → clock-NnulNCOv.js} +1 -1
  55. package/assets/compose._-_outboxMessageId_-Be8c22eR.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-BuomqJqQ.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-Bv9hyiuT.js +1 -0
  58. package/assets/compose._-_outboxMessageId_-CvUr9awX.js +1 -0
  59. package/assets/{config-import-C2ovEkHy.js → config-import-DmOMXQ5W.js} +1 -1
  60. package/assets/{confirm-dialog-CgMAaLI3.js → confirm-dialog-q8tbS_22.js} +1 -1
  61. package/assets/{copy-CIKgpUwt.js → copy-LUCWJAE6.js} +1 -1
  62. package/assets/{credential-steps-BWguS0eW.js → credential-steps-DVglyUgf.js} +1 -1
  63. package/assets/{download-A4hq8dWf.js → download-SQdHw0Vd.js} +1 -1
  64. package/assets/draft-Y5XWTm_J.js +1 -0
  65. package/assets/edit-DMorYaTV.js +1 -0
  66. package/assets/edit-Dr5FEVcd.js +1 -0
  67. package/assets/{external-link-DaKTW3eK.js → external-link-BDqA_mVy.js} +1 -1
  68. package/assets/{file-json-DiHW8YBd.js → file-json-DQGozYSr.js} +1 -1
  69. package/assets/{filters-1uKuLkQU.js → filters-DFLdTFEB.js} +1 -1
  70. package/assets/flagged-CCXBAY09.js +1 -0
  71. package/assets/{flagged-BIza20sq.js → flagged-CyMautVT.js} +1 -1
  72. package/assets/{folders-Bd16ltK4.js → folders-DtchKvEA.js} +1 -1
  73. package/assets/{help-copy-N4JgEUmu.js → help-copy-B2iT8EG_.js} +1 -1
  74. package/assets/{import-DJptfpxt.js → import-DqNA5XIM.js} +1 -1
  75. package/assets/index-BaEsIFAV.js +1 -0
  76. package/assets/index-Biz6TlId.js +1 -0
  77. package/assets/index-BkMAx0hv.js +1 -0
  78. package/assets/{index-BzL5-pGT.js → index-CL_fwLHN.js} +88 -88
  79. package/assets/index-CZYy2P_j.js +1 -0
  80. package/assets/index-CqsCZrgd.js +1 -0
  81. package/assets/{index-C8VKP1dT.css → index-Cr6oUxXl.css} +1 -1
  82. package/assets/index-CvDZvwnj.js +1 -0
  83. package/assets/index-D2Qjacn6.js +1 -0
  84. package/assets/{index-BWAq8iOl.js → index-DZb7rV9A.js} +4 -4
  85. package/assets/index-DoTwMLuw.js +1 -0
  86. package/assets/index-DrtbTKeC.js +1 -0
  87. package/assets/index-wVOTkeaF.js +1 -0
  88. package/assets/{kbd-B9MFmWVU.js → kbd-CDJCJUnp.js} +1 -1
  89. package/assets/{labels-DeCZEWet.js → labels-rv-5Xb0f.js} +1 -1
  90. package/assets/{mail-CSUpbRUP.js → mail-SW3rbFnq.js} +1 -1
  91. package/assets/{menu-CGw_RHKl.js → menu-CcLh9Whg.js} +1 -1
  92. package/assets/new-Zmtsd7wU.js +1 -0
  93. package/assets/onboarding-BbZUe6dp.js +1 -0
  94. package/assets/{onboarding-completion-DbgUYeRa.js → onboarding-completion-DoF3_MyG.js} +1 -1
  95. package/assets/outbox-ZJk7VidB.js +1 -0
  96. package/assets/{pencil-DOoqyGzC.js → pencil-LSmMSKiW.js} +1 -1
  97. package/assets/{popover-menu-CNiMANtf.js → popover-menu-fjlAfNO1.js} +1 -1
  98. package/assets/{refresh-cw-D1SQy8O7.js → refresh-cw-5OKnYRBy.js} +1 -1
  99. package/assets/{reply-CQarAZxU.js → reply-DvdgFS16.js} +1 -1
  100. package/assets/{rich-text-DgI7vzll.js → rich-text-BBwYPM6F.js} +1 -1
  101. package/assets/{rich-text-spellcheck-worker-provider-paPOw9As.js → rich-text-spellcheck-worker-provider-Bk8cqxyg.js} +1 -1
  102. package/assets/{rotate-ccw-DPB71584.js → rotate-ccw-CENCKp2Z.js} +1 -1
  103. package/assets/{roving-focus-Coea111y.js → roving-focus-FWOr5tBU.js} +1 -1
  104. package/assets/{row-actions-CiZruXil.js → row-actions-DA6zLLAB.js} +1 -1
  105. package/assets/{search-mirror-_Dap9COg.js → search-mirror-Dri4pWEq.js} +1 -1
  106. package/assets/{search-token-index-DQHE1g7A.js → search-token-index-B1HU1d2-.js} +1 -1
  107. package/assets/{sections-C6oVXjho.js → sections-Rf3k05-_.js} +1 -1
  108. package/assets/{senders-DIVpkzIq.js → senders-ikMjTlbx.js} +1 -1
  109. package/assets/settings-Bk7jziSO.js +1 -0
  110. package/assets/{settings-screen-4md2ibPl.js → settings-screen-DBP3ABLE.js} +1 -1
  111. package/assets/{shield-check-BcUXVpR8.js → shield-check-CdR23I2B.js} +1 -1
  112. package/assets/{sparkles-C1l6GCPT.js → sparkles-Bcn4ZRhZ.js} +1 -1
  113. package/assets/{suggested-vips-iEt-4yp9.js → suggested-vips-D-8cU8GT.js} +1 -1
  114. package/assets/suggestion._suggestionId-D6z0CuYD.js +1 -0
  115. package/assets/task._calendarTaskId-BYRN0yW3.js +1 -0
  116. package/assets/{undo-2-DHJ6nykB.js → undo-2-Bdx8L5xj.js} +1 -1
  117. package/assets/useCalendarData-DXhaM_NM.js +2 -0
  118. package/assets/useCalendarScheduling-BpjmrzdY.js +1 -0
  119. package/assets/useCalendarSuggestions-D3Jza1d7.js +1 -0
  120. package/assets/useCalendarTasks-D_NZ0GM6.js +1 -0
  121. package/assets/{useDebouncedValue-B7157ZPO.js → useDebouncedValue-BTZsNKEh.js} +1 -1
  122. package/assets/{useFilters-C3bLY42W.js → useFilters-CIuC8WLg.js} +1 -1
  123. package/assets/{useLabels-DYdHiHXI.js → useLabels-BZFMPVjT.js} +1 -1
  124. package/assets/useLayoutTier-DrLg7_rq.js +1 -0
  125. package/assets/{useMediaQuery-7Q3jBluO.js → useMediaQuery-DiQ0fGER.js} +1 -1
  126. package/assets/{useMessageBodyContent-CWGtiddz.js → useMessageBodyContent-D-LJBFh4.js} +1 -1
  127. package/assets/{useQueries-Sm8S3Cgh.js → useQueries-hChzM5ru.js} +1 -1
  128. package/assets/{useRefreshControl-bA8HK_j-.js → useRefreshControl-B6YIG0w2.js} +1 -1
  129. package/assets/{useResultFolderIndex-BaqajWHb.js → useResultFolderIndex-6TeGdWgp.js} +1 -1
  130. package/assets/{useSignature-sxHvGfKr.js → useSignature-BkzkUbjz.js} +1 -1
  131. package/assets/{warnings-ByqpxH4J.js → warnings-BdQvV6Kc.js} +1 -1
  132. package/index.html +2 -2
  133. package/package.json +1 -1
  134. package/assets/CalendarEventEditor-BpGmPZ2Z.js +0 -1
  135. package/assets/CalendarEventPopup-Brcgx7tV.js +0 -1
  136. package/assets/CalendarQuickCreate-CwkBXqAB.js +0 -1
  137. package/assets/CalendarSession--XFP5lXS.js +0 -1
  138. package/assets/MessageToolbar-5T47fDWC.js +0 -1
  139. package/assets/_calendarObjectId-Dbrtihva.js +0 -1
  140. package/assets/_mailboxId-B587Zr5T.js +0 -1
  141. package/assets/_messageId-BxlZMqGk.js +0 -1
  142. package/assets/_messageId-CRIBYDCW.js +0 -1
  143. package/assets/_messageId-DTs144Nv.js +0 -1
  144. package/assets/_outboxMessageId-BxdPyrXI.js +0 -1
  145. package/assets/_recurrenceId-QBmk5dbN.js +0 -1
  146. package/assets/_threadId-8Y3P5szz.js +0 -1
  147. package/assets/_threadId-AMQdO9xw.js +0 -1
  148. package/assets/_threadId-mpk_WkaQ.js +0 -1
  149. package/assets/_view._date-BfJq9sBQ.js +0 -1
  150. package/assets/brief-BC_KN7ph.js +0 -1
  151. package/assets/calendar-LLRgZQzl.js +0 -1
  152. package/assets/calendar-event-popup-Mft0N_sd.js +0 -1
  153. package/assets/calendar-event-sidebar-D5vjFGdS.js +0 -1
  154. package/assets/calendar-report-CzeBcU6C.js +0 -1
  155. package/assets/calendar-suggestion-ClsxDTZs.js +0 -1
  156. package/assets/calendars-zYfPB3b8.js +0 -1
  157. package/assets/compose._-_outboxMessageId_-BkKmzR39.js +0 -1
  158. package/assets/compose._-_outboxMessageId_-BnYGu6ez.js +0 -1
  159. package/assets/compose._-_outboxMessageId_-C5Aukg6m.js +0 -1
  160. package/assets/compose._-_outboxMessageId_-Ck-eEtzy.js +0 -1
  161. package/assets/edit-CxVYhmi5.js +0 -1
  162. package/assets/edit-DXN-G3Tu.js +0 -1
  163. package/assets/flagged-DmSptMzm.js +0 -1
  164. package/assets/index-B18BvpkW.js +0 -1
  165. package/assets/index-B4pYEqZI.js +0 -1
  166. package/assets/index-B77HnSA5.js +0 -1
  167. package/assets/index-BZdYp7ae.js +0 -1
  168. package/assets/index-BiCNOLIH.js +0 -1
  169. package/assets/index-CoCVPZ34.js +0 -1
  170. package/assets/index-CroyVnhC.js +0 -1
  171. package/assets/index-DTs144Nv.js +0 -1
  172. package/assets/index-DsgtllX4.js +0 -1
  173. package/assets/index-DupXMcS6.js +0 -1
  174. package/assets/new-DVwQ9Ia3.js +0 -1
  175. package/assets/onboarding-CDWqPDW8.js +0 -1
  176. package/assets/outbox-Ct7VdX2v.js +0 -1
  177. package/assets/settings-Cv257vpL.js +0 -1
  178. package/assets/suggestion._suggestionId-BQw9qGr-.js +0 -1
  179. package/assets/useCalendarData-Bz4EDHDO.js +0 -2
  180. package/assets/useCalendarSuggestions-DcYFtQhb.js +0 -1
  181. package/assets/useLayoutTier-5aJYrTut.js +0 -1
@@ -1 +1 @@
1
- import{b as e}from"./index-BzL5-pGT.js";const a=e("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),y={Mail:"mail sync off",Calendar:"calendar sync off"};export{y as A,a as C};
1
+ import{b as e}from"./index-CL_fwLHN.js";const a=e("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),y={Mail:"mail sync off",Calendar:"calendar sync off"};export{y as A,a as C};
@@ -1 +1 @@
1
- import{j as r,r as M,o as Pe,ae as Ve,d as se,S as Rs,X as De,af as Is,ag as Ms,ah as mt,p as Os,q as Ls,ai as Us,aj as Hs,ak as te,al as zs,am as $s,an as Bs,f as Ke,ao as qs,a as ns,c as os,ap as Ws,g as he,aq as Gs,l as je,i as ht,ar as Ks,as as Ys,at as Qs,au as ve,av as Ct,L as rt,aw as _t,ax as Zs,ay as Me,az as Ae,aA as Xs,aB as it,B as at,aC as Js,aD as er,aE as Vt,m as ls,N as tr,aF as sr,aG as rr,aH as cs,aI as Pt,u as ir,aJ as ar,aK as nr,e as or,aL as Dt,aM as lr,T as cr,aN as dr}from"./index-BzL5-pGT.js";import{A as nt,g as Ft,P as ur,O as fr}from"./OnboardingWizard-hfP07hpw.js";import{f as Rt,E as mr}from"./ErrorState-nA0Ptq3g.js";import{R as hr}from"./row-actions-CiZruXil.js";import{S as pr,A as gr}from"./settings-screen-4md2ibPl.js";import{s as $e,b as ds,R as us,u as xr}from"./credential-steps-BWguS0eW.js";import{u as yr}from"./useSignature-sxHvGfKr.js";import{c as vr,a as It,d as br}from"./account-form-helpers-DhckT_PN.js";import{C as Sr}from"./confirm-dialog-CgMAaLI3.js";import{D as jr}from"./download-A4hq8dWf.js";import{a as wr}from"./help-copy-N4JgEUmu.js";import"./checkbox-Qon94b1C.js";import"./kbd-B9MFmWVU.js";import"./file-json-DiHW8YBd.js";import"./avatar-vPm9XfmM.js";import"./menu-CGw_RHKl.js";import"./circle-help-CVShnhWn.js";import"./card-865cdsJK.js";const Nr={Mail:"Mail already in Remit stays, and you can keep reading it.",Calendar:"Events already in Remit stay on your calendar."},Ar={Mail:"New mail stops arriving until you turn it back on.",Calendar:"Changes stop arriving until you turn it back on."},Tr={Mail:"mail",Calendar:"calendar"};function kr(e,s){const t=Tr[e.service];return e.kind==="enable"?{title:`Sign in with ${s} to add ${t}?`,description:`This account was never asked for ${t} access. Remit sends you to ${s} to ask for it, and brings you back here when you are done. Nothing changes until you get back.`,confirmLabel:`Continue to ${s}`,cancelLabel:"Cancel",destructive:!1}:e.kind==="last"?{title:`${e.service} is the only thing this account syncs`,description:`An account has to sync something. To stop this one entirely, remove the account — that deletes what Remit stored for it, which switching ${t} off never does.`,confirmLabel:"Remove account",cancelLabel:`Keep syncing ${t}`,destructive:!0}:{title:`Stop syncing ${t} for this account?`,description:`${Nr[e.service]} ${Ar[e.service]} Nothing is deleted.`,confirmLabel:`Stop syncing ${t}`,cancelLabel:"Cancel",destructive:!1}}function Er({change:e,providerName:s,onConfirm:t,onCancel:a,isBusy:n}){if(e===null)return null;const c=kr(e,s);return r.jsx(Sr,{isOpen:!0,title:c.title,description:c.description,confirmLabel:c.confirmLabel,cancelLabel:c.cancelLabel,destructive:c.destructive,isBusy:n??!1,onConfirm:t,onCancel:a})}function Cr({checked:e,label:s,describedBy:t,disabled:a,onToggle:n}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,"aria-describedby":t,disabled:a,onClick:n,className:Pe("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors","outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",e?"border-positive bg-positive":"border-line-strong bg-surface-sunken"),children:r.jsx("span",{"aria-hidden":!0,className:Pe("size-4 rounded-full bg-canvas transition-transform",e?"translate-x-6":"translate-x-1")})})}function _r({providerName:e,offered:s,enabled:t,consented:a,disabled:n=!1,onRequestChange:c}){const o=M.useId(),u=nt.filter(b=>s.includes(b.id));return u.length<2?null:r.jsxs("fieldset",{children:[r.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What this account syncs"}),r.jsx("div",{className:"mt-1 divide-y divide-line",children:u.map(b=>{const w=t.includes(b.id),T=`${o}-${b.id}`,_=!w&&!a.includes(b.id);return r.jsxs("div",{className:"flex min-h-11 items-center gap-3 py-2 text-left",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm text-fg",children:b.label}),r.jsx("span",{id:T,className:"text-xs text-fg-subtle",children:_?`${b.description} Turning this on means signing in with ${e} again.`:b.description})]}),r.jsx(Cr,{checked:w,label:`Sync ${b.label.toLowerCase()}`,describedBy:T,disabled:n,onToggle:()=>c(b.id,w?"off":"on")})]},b.id)})})]})}const Vr=e=>{const s=new Set(e.map(Is));return Ms.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,a)=>Ve(t).localeCompare(Ve(a)))},Pr=({value:e,onChange:s,busy:t=!1})=>{const a=Vr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((n,c)=>r.jsxs("li",{"data-testid":`compose-language-row-${n}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:n,children:Ve(n)}),c===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(Rs,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ve(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(n)}`,onClick:()=>s(e.filter(o=>o!==n))})]},n))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||a.length===0,onChange:n=>{n.target.value!==""&&s([...e,n.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),a.map(n=>r.jsx("option",{value:n,children:Ve(n)},n))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function Dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(mt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Mt({isOpen:e,onClose:s,title:t,children:a,footer:n}){Os({id:"slide-panel",open:e,answers:{back:s}});const c=M.useRef(null);return Ls(c,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Pe("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{ref:c,className:Pe("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",tabIndex:-1,children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(De,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),n&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:n})]})]})]})}function Ot(e){return Us(Hs,e)}var Ue=e=>e.type==="checkbox",we=e=>e instanceof Date,Q=e=>e==null;const pt=e=>typeof e=="object";var z=e=>!Q(e)&&!Array.isArray(e)&&pt(e)&&!we(e),Fr=e=>z(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,Rr=(e,s)=>s.split(".").some((t,a,n)=>!isNaN(Number(t))&&e.has(n.slice(0,a).join("."))),fs=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&fs(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=B(e[n]));return a}const Ce={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"},ms="root",gt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var He=e=>Ir.test(e),L=e=>e===void 0;const Mr=/[.[\]'"]/;var Qe=e=>e.split(Mr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const a=He(s)?[s]:Qe(s);if(a.some(c=>gt.includes(c)))return t;const n=a.reduce((c,o)=>Q(c)?void 0:c[o],e);return L(n)||n===e?L(e[s])?t:e[s]:n},fe=e=>typeof e=="boolean",le=e=>typeof e=="function",O=(e,s,t)=>{let a=-1;const n=He(s)?[s]:Qe(s),c=n.length,o=c-1;for(;++a<c;){const u=n[a];let b=t;if(a!==o){const w=e[u];b=z(w)||Array.isArray(w)?w:isNaN(+n[a+1])?{}:[]}if(gt.includes(u))return;e[u]=b,e=e[u]}};const Or=te.createContext(null);Or.displayName="HookFormControlContext";var Lr=(e,s,t,a=!0)=>{const n={};for(const c in e)Object.defineProperty(n,c,{get:()=>{const o=c;return s._proxyFormState[o]!==ue.all&&(s._proxyFormState[o]=!a||ue.all),e[o]}});return n};const Ur=Ye?te.useLayoutEffect:te.useEffect;var Z=e=>typeof e=="string",Hr=(e,s,t,a,n)=>Z(e)?(a&&s.watch.add(e),y(t,e,n)):Array.isArray(e)?e.map(c=>(a&&s.watch.add(c),y(t,c))):(a&&(s.watchAll=!0),t),ot=e=>Q(e)||!pt(e);const Lt=(e,s)=>s.length===0&&!Array.isArray(e)&&!fs(e);function me(e,s,t=new WeakMap){if(e===s)return!0;if(ot(e)||ot(s))return Object.is(e,s);if(we(e)&&we(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),n=Object.keys(s);if(a.length!==n.length)return!1;if(Lt(e,a)||Lt(s,n))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const c=t.get(e);if(c&&c.has(s))return!0;if(c)c.add(s);else{const o=new WeakSet;o.add(s),t.set(e,o)}for(const o of a){const u=e[o];if(!(o in s))return!1;if(o!=="ref"){const b=s[o];if(we(u)&&we(b)||(z(u)||Array.isArray(u))&&(z(b)||Array.isArray(b))?!me(u,b,t):!Object.is(u,b))return!1}}return!0}var Be=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),et=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Le=(e,s,t,a)=>{for(const n of t||Object.keys(e)){const c=y(e,n);if(c){const{_f:o,...u}=c;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],n)&&!a)return!0;if(o.ref&&s(o.ref,o.name)&&!a)return!0;if(Le(u,s))break}else if(z(u)&&Le(u,s))break}}};var Ut=(e,s,t)=>{const a=y(e,t),n=Array.isArray(a)?a:[];return O(n,ms,s[t]),O(e,t,n),e},Y=e=>z(e)&&!Object.keys(e).length,xt=e=>e.type==="file",We=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},yt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,vt=(e,s,t,a,n)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:n||!0}}:{};const Ht={value:!1,isValid:!1},zt={value:!0,isValid:!0};var hs=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===""?zt:{value:e[0].value,isValid:!0}:zt:Ht}return Ht};const $t={isValid:!1,value:null};var ps=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,$t):$t;function Bt(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||fe(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var _e=e=>z(e)&&!Ge(e)?e:{value:e,message:""},qt=async(e,s,t,a,n,c)=>{const{ref:o,refs:u,required:b,maxLength:w,minLength:T,min:_,max:H,pattern:p,validate:S,name:k,valueAsNumber:A,mount:oe}=e._f,V=y(t,k);if(!oe||s.has(k))return{};const P=u?u[0]:o,C=F=>{if(n&&P.reportValidity){const D=fe(F)?"":F||"";u?u.forEach(R=>R.setCustomValidity(D)):P.setCustomValidity(D),P.reportValidity()}},E={},X=yt(o),W=Ue(o),ae=X||W,re=(A||xt(o))&&L(o.value)&&L(V)||We(o)&&o.value===""||V===""||Array.isArray(V)&&!V.length,ce=vt.bind(null,k,a,E),pe=(F,D,R,$=de.maxLength,K=de.minLength)=>{const G=F?D:R;E[k]={type:F?$:K,message:G,ref:o,...ce(F?$:K,G)}};if(c?!Array.isArray(V)||!V.length:b&&(!ae&&(re||Q(V))||fe(V)&&!V||W&&!hs(u).isValid||X&&!ps(u).isValid)){const{value:F,message:D}=Z(b)?{value:!!b,message:b}:_e(b);if(F&&(E[k]={type:de.required,message:D,ref:P,...ce(de.required,D)},!a))return C(D),E}if(!re&&(!Q(_)||!Q(H))){let F,D;const R=_e(H),$=_e(_);if(!Q(V)&&!isNaN(V)){const K=o.valueAsNumber||V&&+V;Q(R.value)||(F=K>R.value),Q($.value)||(D=K<$.value)}else{const K=o.valueAsDate||new Date(V),G=ie=>new Date(new Date().toDateString()+" "+ie),be=o.type=="time",j=o.type=="week";Z(R.value)&&V&&(F=be?G(V)>G(R.value):j?V>R.value:K>new Date(R.value)),Z($.value)&&V&&(D=be?G(V)<G($.value):j?V<$.value:K<new Date($.value))}if((F||D)&&(pe(!!F,R.message,$.message,de.max,de.min),!a))return C(E[k].message),E}if((w||T)&&!re&&(Z(V)||c&&Array.isArray(V))){const F=_e(w),D=_e(T),R=!Q(F.value)&&V.length>+F.value,$=!Q(D.value)&&V.length<+D.value;if((R||$)&&(pe(R,F.message,D.message),!a))return C(E[k].message),E}if(p&&!re&&Z(V)){const{value:F,message:D}=_e(p);if(Ge(F)&&!V.match(F)&&(E[k]={type:de.pattern,message:D,ref:o,...ce(de.pattern,D)},!a))return C(D),E}if(S){if(le(S)){const F=await S(V,t),D=Bt(F,P);if(D&&(E[k]={...D,...ce(de.validate,D.message)},!a))return C(D.message),E}else if(z(S)){let F={};for(const D in S){if(!Y(F)&&!a)break;const R=Bt(await S[D](V,t),P,D);R&&(F={...R,...ce(D,R.message)},C(R.message),a&&(E[k]=F))}if(!Y(F)&&(E[k]={ref:P,...F},!a))return E}}return C(!0),E},qe=e=>Array.isArray(e)?e:[e],gs=e=>Array.isArray(e)?e.filter(Boolean):[];function zr(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(Q(e)){e=void 0;break}e=e[s[a]],a++}return e}function $r(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Z(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:He(s)?[s]:Qe(s);if(t.some(o=>gt.includes(String(o))))return e;const a=t.length===1?e:zr(e,t),n=t.length-1,c=t[n];return a&&delete a[c],n!==0&&(z(a)&&Y(a)||Array.isArray(a)&&$r(a))&&q(e,t.slice(0,-1)),e}const xs=e=>{const s={};for(const t of Object.keys(e))if(pt(e[t])&&e[t]!==null&&!we(e[t])){const a=xs(e[t]);for(const n of Object.keys(a))s[`${t}.${n}`]=a[n]}else s[t]=e[t];return s},Br=te.createContext(null);Br.displayName="HookFormContext";var Wt=()=>{let e=[];return{get observers(){return e},next:n=>{for(const c of e)c.next&&c.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(c=>c!==n)}}),unsubscribe:()=>{e=[]}}};function ys(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const n=e[a],c=s[a];if(n&&z(n)&&c){const o=ys(n,c);z(o)&&(t[a]=o)}else e[a]&&(t[a]=c)}return t}var vs=e=>e.type==="select-multiple",qr=e=>yt(e)||Ue(e),tt=e=>We(e)&&e.isConnected,Wr=e=>{for(const s in e)if(le(e[s]))return!0;return!1};function bs(e){return Array.isArray(e)||z(e)&&!Wr(e)}function Ss(e){return!!(e&&"_f"in e)}function js(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function lt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ct(e,s={},t){for(const a in e){const n=e[a],c=t&&t[a];bs(n)&&(!Array.isArray(n)||!Ss(c))?(s[a]=Array.isArray(n)?[]:{},ct(n,s[a],c),js(s[a])&&lt(s,a)):L(n)||(s[a]=!0)}return s}function Te(e,s,t,a){t||(t=ct(s,{},a));for(const n in e){const c=e[n],o=a&&a[n];bs(c)&&(!Array.isArray(c)||!Ss(o))?(L(s)||ot(t[n])?t[n]=ct(c,Array.isArray(c)?[]:{},o):Te(c,Q(s)?{}:s[n],t[n],o),js(t[n])&&lt(t,n)):me(c,s[n])?lt(t,n):t[n]=!0}return t}var ws=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):a?a(e):e;function Gt(e){const s=e.ref;return xt(s)?s.files:yt(s)?ps(e.refs).value:vs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?hs(e.refs).value:ws(L(s.value)?e.ref.value:s.value,e)}var Gr=(e,s,t,a)=>{const n={};for(const c of e){const o=y(s,c);o&&O(n,c,o._f)}return{criteriaMode:t,names:[...e],fields:n,shouldUseNativeValidation:a}},Oe=e=>L(e)?e:Ge(e)?e.source:z(e)?Ge(e.value)?e.value.source:e.value:e;const Kt="AsyncFunction";var Kr=e=>{if(!e||!e.validate)return!1;if(le(e.validate))return e.validate.constructor.name===Kt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Kt)return!0}return!1},Yr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Yt(e,s,t){const a=y(e,t);if(a||He(t))return{error:a,name:t};const n=t.split(".");for(;n.length;){const c=n.join("."),o=y(s,c),u=y(e,c);if(o&&!Array.isArray(o)&&t!==c)return{name:t};if(u&&u.type)return{name:c,error:u};if(u&&u.root&&u.root.type)return{name:`${c}.root`,error:u.root};n.pop()}return{name:t}}var Qr=(e,s,t,a)=>{t(e);const{name:n,...c}=e,o=Object.keys(c);return!o.length||a&&o.length>=Object.keys(s).length||o.find(u=>s[u]===(!a||ue.all))},Zr=(e,s,t)=>!e||!s||e===s||qe(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),Xr=(e,s,t,a,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(s||e):(t?a.isOnBlur:n.isOnBlur)?!e:(t?a.isOnChange:n.isOnChange)?e:!0,Jr=(e,s)=>!gs(y(e,s)).length&&q(e,s);const ei={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},st="form",Ns={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function ti(e={}){let s={...ei,...e},t={...B(Ns),isLoading:le(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},c=s.shouldUnregister?{}:B(n),o={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 b={},w={};let T=0,_=Be(s.mode),H=Be(s.reValidateMode);const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={...p};let k={...S};const A={array:Wt(),state:Wt()};let oe=0;const V=s.criteriaMode===ue.all,P=(i,l)=>d=>{clearTimeout(w[i]),w[i]=setTimeout(l,d)},C=async i=>{if(!o.keepIsValid&&!s.disabled&&(S.isValid||k.isValid||i)){const l=++oe;let d;s.resolver?(d=Y((await R()).errors),l===oe&&E()):d=await G({fields:a,onlyCheckValid:!0,eventType:Ce.VALID}),l===oe&&d!==t.isValid&&A.state.next({isValid:d})}},E=(i,l)=>{!s.disabled&&(S.isValidating||S.validatingFields||k.isValidating||k.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(l?O(t.validatingFields,d,l):q(t.validatingFields,d))}),A.state.next({validatingFields:t.validatingFields,isValidating:!Y(t.validatingFields)}))},X=()=>{t.dirtyFields=Te(n,c,void 0,a)},W=(i,l=[],d,f,m=!0,x=!0)=>{if(f&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(y(a,i))){const g=d(y(a,i),f.argA,f.argB);m&&O(a,i,g)}if(x&&Array.isArray(y(t.errors,i))){const g=d(y(t.errors,i),f.argA,f.argB);m&&O(t.errors,i,g),Jr(t.errors,i)}if((S.touchedFields||k.touchedFields)&&x&&Array.isArray(y(t.touchedFields,i))){const g=d(y(t.touchedFields,i),f.argA,f.argB);m&&O(t.touchedFields,i,g)}(S.dirtyFields||k.dirtyFields)&&X(),A.state.next({name:i,isDirty:j(i,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else O(c,i,l)},ae=(i,l)=>{O(t.errors,i,l),t.errors={...t.errors},A.state.next({errors:t.errors})},re=i=>{t.errors=i,A.state.next({errors:t.errors,isValid:!1})},ce=i=>{const l=He(i)?[i]:Qe(i);let d=c,f=n;for(let m=0;m<l.length-1;m++){const x=l[m];if(d=Q(d)?d:d[x],f=Q(f)?f:f[x],d===null&&f!==null)return!0}return!1},pe=(i,l,d,f)=>{const m=y(a,i);if(m){if(ce(i))return;const x=L(y(c,i)),g=y(c,i,L(d)?y(n,i):d);L(g)||f&&f.defaultChecked||l?O(c,i,l?g:Gt(m._f)):Ne(i,g),o.mount&&!o.action&&(C(),x&&t.isDirty&&(S.isDirty||k.isDirty)&&(j()||(t.isDirty=!1,A.state.next({...t}))),e.shouldUnregister&&x&&!L(y(c,i))&&et(i,u)&&(o.watch=!0))}},F=(i,l,d,f,m)=>{let x=!1,g=!1;const v={name:i};if(!s.disabled||f===!0){if(!d||f){const N=me(y(n,i),l);(S.isDirty||k.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!N||j(),x=g!==v.isDirty),g=!!y(t.dirtyFields,i),N!==t.isDirty?t.dirtyFields=Te(n,c,void 0,a):N?q(t.dirtyFields,i):O(t.dirtyFields,i,!0),v.dirtyFields=t.dirtyFields,x=x||(S.dirtyFields||k.dirtyFields)&&g!==!N}if(d){const N=y(t.touchedFields,i);N||(O(t.touchedFields,i,d),v.touchedFields=t.touchedFields,x=x||(S.touchedFields||k.touchedFields)&&N!==d)}x&&m&&A.state.next(v)}return x?v:{}},D=(i,l,d,f)=>{const m=y(t.errors,i),x=(S.isValid||k.isValid)&&fe(l)&&t.isValid!==l;if(s.delayError&&d?(b[i]=P(i,()=>ae(i,d)),b[i](s.delayError)):(clearTimeout(w[i]),delete b[i],d?O(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!me(m,d):m)||!Y(f)||x){const g={...f,...x&&fe(l)?{isValid:l}:{},errors:t.errors,name:i};t={...t,...g},A.state.next(g)}},R=async i=>(E(i,!0),await s.resolver(c,s.context,Gr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async i=>{const{errors:l}=await R(i);if(E(i),i){for(const d of i){const f=y(l,d);f?u.array.has(d)&&z(f)&&!Object.keys(f).some(m=>!Number.isNaN(Number(m)))?Ut(t.errors,{[d]:f},d):O(t.errors,d,f):q(t.errors,d)}t.errors={...t.errors}}else t.errors=l;return l},K=async({name:i,eventType:l})=>{if(e.validate){const d=await e.validate({formValues:c,formState:t,name:i,eventType:l});if(z(d))for(const f in d){const m=d[f];m&&ze(`${st}.${f}`,{message:Z(m.message)?m.message:"",type:m.type||de.validate})}else Z(d)||!d?ze(st,{message:d||"",type:de.validate}):St(st);return d}return!0},G=async({fields:i,onlyCheckValid:l,name:d,eventType:f,context:m={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(m.runRootValidation=!0,!await K({name:d,eventType:f})&&(m.valid=!1,l)))return m.valid;for(const x in i){const g=i[x];if(g){const{_f:v,...N}=g;if(v){const U=u.array.has(v.name),ee=g._f&&Kr(g._f),xe=S.validatingFields||S.isValidating||k.validatingFields||k.isValidating;ee&&xe&&E([v.name],!0);const ye=await qt(g,u.disabled,c,V,s.shouldUseNativeValidation&&!l,U);if(ee&&xe&&E([v.name]),ye[v.name]&&(m.valid=!1,l)||(!l&&(y(ye,v.name)?U?Ut(t.errors,ye,v.name):O(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!Y(N)&&await G({context:m,onlyCheckValid:l,fields:N,name:x,eventType:f})}}return m.valid},be=()=>{for(const i of u.unMount){const l=y(a,i);l&&(l._f.refs?l._f.refs.every(d=>!tt(d)):!tt(l._f.ref))&&Ze(i)}u.unMount=new Set},j=(i,l)=>(i&&l&&O(c,i,l),!me(o.mount?c:n,n)),ie=(i,l,d)=>Hr(i,u,{...o.mount?c:L(l)?n:Z(i)?{[i]:l}:l},d,l),ke=i=>gs(y(o.mount?c:n,i,s.shouldUnregister?y(n,i,[]):[])),Ne=(i,l,d={},f=!1,m=!1)=>{const x=y(a,i);let g=l;if(x){const v=x._f;v&&(!v.disabled&&O(c,i,ws(l,v)),g=We(v.ref)&&Q(l)?"":l,vs(v.ref)?[...v.ref.options].forEach(N=>N.selected=g.includes(N.value)):v.refs?Ue(v.ref)?v.refs.forEach(N=>{(!N.defaultChecked||!N.disabled)&&(Array.isArray(g)?N.checked=!!g.find(U=>U===N.value):N.checked=g===N.value||!!g)}):v.refs.forEach(N=>N.checked=N.value===g):xt(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!m&&A.state.next({name:i,values:f?c:B(c)})))}(d.shouldDirty||d.shouldTouch)&&F(i,g,d.shouldTouch,d.shouldDirty,!m),d.shouldValidate&&Ee(i,{delayError:d.delayError})},h=(i,l,d,f=!1,m=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=i+"."+x,N=y(a,v);(u.array.has(i)||z(g)||N&&!N._f)&&!we(g)?h(v,g,d,f,m):Ne(v,g,d,f,m)}},I=(i,l,d,f,m=!1)=>{const x=y(a,i),g=u.array.has(i),v=f?l:B(l),N=y(c,i),U=me(N,v);if(U||O(c,i,v),g)A.array.next({name:i,values:f?c:B(c)}),(S.isDirty||S.dirtyFields||k.isDirty||k.dirtyFields)&&d.shouldDirty&&(X(),m||A.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:j(i,v)}));else{const ee=Array.isArray(v)&&!v.length||Y(v);!x||x._f||Q(v)||ee?Ne(i,v,d,f,m):h(i,v,d,f,m)}if(!U&&!m){const ee=et(i,u),xe=f?c:B(c);A.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:xe})}},J=(i,l,d={})=>I(i,l,d,!1),ne=(i,l={})=>{const d=le(i)?i(c):i;if(!me(c,d)){c={...c,...d};const f=xs(d);for(const m of u.mount)m in f&&I(m,f[m],l,!0,!0);A.state.next({...t,name:void 0,type:void 0,...T?{values:c}:{}}),l.shouldValidate&&C()}},ge=async i=>{o.mount=!0;const l=i.target;let d=l.name,f=!0;const m=y(a,d),x=g=>{f=Number.isNaN(g)||we(g)&&isNaN(g.getTime())||me(g,y(c,d,g))};if(m){let g,v;const N=l.type?Gt(m._f):Fr(i),U=i.type===Ce.BLUR||i.type===Ce.FOCUS_OUT,ee=!Yr(m._f)&&!e.validate&&!s.resolver&&!y(t.errors,d)&&!m._f.deps,xe=ee||Xr(U,y(t.touchedFields,d),t.isSubmitted,H,_),ye=et(d,u,U);if(O(c,d,N),U){if(!l||!l.readOnly){m._f.onBlur&&m._f.onBlur(i);const Ie=b[d];Ie&&Ie(0)}}else m._f.onChange&&m._f.onChange(i);const Re=F(d,N,U),Ds=!Y(Re)||ye;if(!U&&A.state.next({name:d,type:i.type,...T?{values:B(c)}:{}}),xe)return(!ee||!t.isValid)&&(S.isValid||k.isValid)&&(s.mode==="onBlur"?U&&C():U||C()),Ds&&A.state.next({name:d,...ye?{}:Re});if(!s.resolver&&e.validate&&await K({name:d,eventType:i.type}),!U&&ye&&A.state.next({...t}),s.resolver){const{errors:Ie}=await R([d]);if(E([d]),x(N),!f){!Y(Re)&&A.state.next(Re);return}const Fs=Yt(t.errors,a,d),Et=Yt(Ie,a,Fs.name||d);g=Et.error,d=Et.name,v=Y(Ie)}else E([d],!0),g=(await qt(m,u.disabled,c,V,s.shouldUseNativeValidation))[d],E([d]),x(N),f&&(g?v=!1:(S.isValid||k.isValid)&&(v=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));f&&(m._f.deps&&(!Array.isArray(m._f.deps)||m._f.deps.length>0)&&Ee(m._f.deps),D(d,v,g,Re))}},Se=(i,l)=>{if(y(t.errors,l)&&i.focus)return i.focus(),1},Ee=async(i,l={})=>{let d,f;const m=qe(i);if(s.resolver){const x=await $(L(i)?i:m);d=Y(x),f=i?!m.some(g=>y(x,g)):d}else i?(f=(await Promise.all(m.map(async x=>{const g=y(a,x);return await G({fields:g&&g._f?{[x]:g}:g,eventType:Ce.TRIGGER})}))).every(Boolean),!(!f&&!t.isValid)&&C()):f=d=await G({fields:a,name:i,eventType:Ce.TRIGGER});if(l.delayError&&s.delayError&&Z(i)){const x=y(t.errors,i);x?(q(t.errors,i),b[i]=P(i,()=>ae(i,x)),b[i](s.delayError)):(clearTimeout(w[i]),delete b[i])}return A.state.next({...!Z(i)||(S.isValid||k.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),l.shouldFocus&&!f&&Le(a,Se,i?m:u.mount),f},Fe=(i,l)=>{let d={...o.mount?c:n};return l&&(d=ys(l.dirtyFields?t.dirtyFields:t.touchedFields,d)),L(i)?d:Z(i)?y(d,i):i.map(f=>y(d,f))},bt=(i,l)=>({invalid:!!y((l||t).errors,i),isDirty:!!y((l||t).dirtyFields,i),error:y((l||t).errors,i),isValidating:!!y(t.validatingFields,i),isTouched:!!y((l||t).touchedFields,i)}),St=i=>{const l=i?qe(i):void 0;l?.forEach(d=>q(t.errors,d)),l?l.forEach(d=>{A.state.next({name:d,errors:t.errors})}):A.state.next({errors:{}})},ze=(i,l,d)=>{const f=(y(a,i,{_f:{}})._f||{}).ref,m=y(t.errors,i)||{},{ref:x,message:g,type:v,...N}=m;O(t.errors,i,{...N,...l,ref:f}),A.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&f&&f.focus&&f.focus()},ks=(i,l)=>{if(le(i)){T++;const{unsubscribe:d}=A.state.subscribe({next:m=>"values"in m&&i(m.values||ie(void 0,l),m)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,d())}}}return ie(i,l,!0)},jt=i=>{var l;const d=!!(!((l=i.formState)===null||l===void 0)&&l.values);d&&T++;const{unsubscribe:f}=A.state.subscribe({next:x=>{if(Zr(i.name,x.name,i.exact)&&Qr(x,i.formState||S,Ps,i.reRenderRoot)){const g={...c};i.callback({values:g,...t,...x,defaultValues:n})}}});if(!d)return f;let m=!1;return()=>{m||(m=!0,T--,f())}},Es=i=>(o.mount=!0,k={...k,...i.formState},jt({...i,formState:{...p,...i.formState}})),Ze=(i,l={})=>{for(const d of i?qe(i):u.mount)u.mount.delete(d),u.array.delete(d),l.keepValue||(q(a,d),q(c,d)),!l.keepError&&q(t.errors,d),!l.keepDirty&&q(t.dirtyFields,d),!l.keepTouched&&q(t.touchedFields,d),!l.keepIsValidating&&q(t.validatingFields,d),!s.shouldUnregister&&!l.keepDefaultValue&&q(n,d);A.state.next({values:B(c)}),A.state.next({...t,...l.keepDirty?{isDirty:j()}:{}}),!l.keepIsValid&&C()},wt=({disabled:i,name:l})=>{if(fe(i)&&o.mount||i||u.disabled.has(l)){const m=u.disabled.has(l)!==!!i;i?u.disabled.add(l):u.disabled.delete(l),m&&o.mount&&!o.action&&C()}},Xe=(i,l={})=>{let d=y(a,i);const f=fe(l.disabled)||fe(s.disabled),m=!u.registerName.has(i)&&d&&d._f&&!d._f.mount;return O(a,i,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:i}},name:i,mount:!0,...l}}),u.mount.add(i),d&&!m?wt({disabled:fe(l.disabled)?l.disabled:s.disabled,name:i}):pe(i,!0,l.value),{...f?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Oe(l.min),max:Oe(l.max),minLength:Oe(l.minLength),maxLength:Oe(l.maxLength),pattern:Oe(l.pattern)}:{},name:i,onChange:ge,onBlur:ge,ref:x=>{if(x){u.registerName.add(i),Xe(i,l),u.registerName.delete(i),d=y(a,i);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=qr(g),N=d._f.refs||[];if(v?N.find(U=>U===g):g===d._f.ref)return;O(a,i,{_f:{...d._f,...v?{refs:[...N.filter(tt),g,...Array.isArray(y(n,i))?[{}]:[]],ref:{type:g.type,name:i}}:{ref:g}}}),pe(i,!1,void 0,g)}else d=y(a,i,{}),d._f&&(d._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(Rr(u.array,i)&&o.action)&&u.unMount.add(i)}}},Je=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(a,Se,u.mount),Cs=i=>{fe(i)&&(A.state.next({disabled:i}),Le(a,(l,d)=>{const f=y(a,d);f&&(l.disabled=f._f.disabled||i,Array.isArray(f._f.refs)&&f._f.refs.forEach(m=>{m.disabled=f._f.disabled||i}))},0,!1))},Nt=(i,l)=>async d=>{let f;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let m=B(c);if(A.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await R();E(),t.errors=x,m=B(g)}else await G({fields:a,eventType:Ce.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(m,x);if(q(t.errors,ms),Y(t.errors)){A.state.next({errors:{}});try{await i(m,d)}catch(x){f=x}}else l&&await l({...t.errors},d),Je(),setTimeout(Je);if(A.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Y(t.errors)&&!f,submitCount:t.submitCount+1,errors:t.errors}),f)throw f},_s=(i,l={})=>{y(a,i)&&(L(l.defaultValue)?J(i,B(y(n,i))):(J(i,l.defaultValue),O(n,i,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,i),l.keepDirty||(q(t.dirtyFields,i),t.isDirty=l.defaultValue?j(i,B(y(n,i))):j()),l.keepError||(q(t.errors,i),S.isValid&&C()),A.state.next({...t}))},At=(i,l={})=>{const d=i?B(i):n,f=B(d),m=Y(i),x=f,g=a;if(l.keepDefaultValues||(n=d),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Te(n,c,void 0,g))]);for(const N of Array.from(v)){const U=y(t.dirtyFields,N),ee=y(c,N),xe=y(x,N);U&&!L(ee)?O(x,N,ee):!U&&!L(xe)&&J(N,xe)}}else{if(Ye&&L(i))for(const v of u.mount){const N=y(a,v);if(N&&N._f){const U=Array.isArray(N._f.refs)?N._f.refs[0]:N._f.ref;if(We(U)){const ee=U.closest("form");if(ee){ee.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)J(v,y(x,v));else a={}}if(s.shouldUnregister){if(c=l.keepDefaultValues?B(n):{},l.keepFieldsRef)for(const v of u.mount)O(c,v,y(x,v))}else c=B(x);A.array.next({values:{...x}}),A.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:""},o.mount=!S.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!Y(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!l.keepIsValid,o.action=!1,l.keepErrors||(t.errors={}),A.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:m?!1:l.keepDirty?t.isDirty:l.keepValues?j():!!(l.keepDefaultValues&&!me(i,n)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:m?{}:l.keepDirtyValues?l.keepDefaultValues&&c?Te(n,c,void 0,g):t.dirtyFields:l.keepDefaultValues&&i?Te(n,i,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:n})},Tt=(i,l)=>At(le(i)?i(c):i,{...s.resetOptions,...l}),Vs=(i,l={})=>{const d=y(a,i),f=d&&d._f;if(f){const m=f.refs?f.refs[0]:f.ref;m.focus&&setTimeout(()=>{m.focus(),l.shouldSelect&&le(m.select)&&m.select()})}},Ps=i=>{const{name:l,type:d,values:f,...m}=i;t={...t,...m}},kt={control:{register:Xe,unregister:Ze,getFieldState:bt,handleSubmit:Nt,setError:ze,_subscribe:jt,_runSchema:R,_updateIsValidating:E,_focusError:Je,_getWatch:ie,_getDirty:j,_setValid:C,_setFieldArray:W,_setDisabledField:wt,_setErrors:re,_getFieldArray:ke,_reset:At,_resetDefaultValues:()=>le(s.defaultValues)&&s.defaultValues().then(i=>{Tt(i,s.resetOptions),A.state.next({isLoading:!1})}),_removeUnmounted:be,_disableForm:Cs,_subjects:A,_proxyFormState:S,get _fields(){return a},get _formValues(){return c},get _state(){return o},set _state(i){o=i},get _defaultValues(){return n},get _names(){return u},set _names(i){u=i},get _formState(){return t},get _options(){return s},set _options(i){s={...s,...i},_=Be(s.mode),H=Be(s.reValidateMode)}},subscribe:Es,trigger:Ee,register:Xe,handleSubmit:Nt,watch:ks,setValue:J,setValues:ne,getValues:Fe,reset:Tt,resetField:_s,resetDefaultValues:(i,l={})=>{if(n=B(i),!l.keepDirty){const d=Te(n,c,void 0,a);t.dirtyFields=d,t.isDirty=!Y(d)}l.keepIsValid||C(),A.state.next({...t,defaultValues:n})},clearErrors:St,unregister:Ze,setError:ze,setFocus:Vs,getFieldState:bt};return{...kt,formControl:kt}}function si(e={}){const s=te.useRef(void 0),t=te.useRef(void 0),a=te.useRef(e.formControl),[n,c]=te.useState(()=>({...B(Ns),isLoading:le(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:le(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!le(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...b}=ti(e);s.current={...b,formState:n}}const o=s.current.control;return o._options=e,Ur(()=>{const u=o._subscribe({formState:o._proxyFormState,callback:()=>c({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return c(b=>({...b,isReady:!0})),o._formState.isReady=!0,u},[o]),te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),te.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),te.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),te.useEffect(()=>{if(o._proxyFormState.isDirty){const u=o._getDirty();u!==n.isDirty&&o._subjects.state.next({isDirty:u})}},[o,n.isDirty]),te.useEffect(()=>{var u;e.values&&!me(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((u=o._options.resetOptions)===null||u===void 0)&&u.keepIsValid||o._setValid(),t.current=e.values,c(b=>({...b}))):o._resetDefaultValues()},[o,e.values]),te.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=te.useMemo(()=>Lr(n,o),[o,n]),s.current}const Qt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=y(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},dt=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Qt(a.ref,t,e):a&&a.refs&&a.refs.forEach(n=>Qt(n,t,e))}},Zt=(e,s)=>{s.shouldUseNativeValidation&&dt(e,s);const t={};for(const a in e){const n=y(s.fields,a),c=Object.assign(e[a]||{},{ref:n&&n.ref});if(ri(s.names||Object.keys(e),a)){const o=Object.assign({},y(t,a));O(o,"root",c),O(t,a,o)}else O(t,a,c)}return t},ri=(e,s)=>{const t=Xt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>Xt(a).match(`^${t}\\.\\d+`))};function Xt(e){return e.replace(/[\[\]]/g,"")}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},ut.apply(null,arguments)}function Jt(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function ii(e,s){for(var t={};e.length;){var a=e[0],n=a.code,c=a.message,o=a.path.join(".");if(!t[o])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:c,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(T){return T.errors.forEach(function(_){return e.push(_)})}),s){var b=t[o].types,w=b&&b[a.code];t[o]=vt(o,s,t,n,w?[].concat(w,a.message):a.message)}e.shift()}return t}function ai(e,s){for(var t={},a=function(){var n=e[0],c=n.code,o=n.message,u=n.path.join(".");if(!t[u])if(n.code==="invalid_union"&&n.errors.length>0){var b=n.errors[0][0];t[u]={message:b.message,type:b.code}}else t[u]={message:o,type:c};if(n.code==="invalid_union"&&n.errors.forEach(function(_){return _.forEach(function(H){return e.push(ut({},H,{path:[].concat(n.path,H.path)}))})}),s){var w=t[u].types,T=w&&w[n.code];t[u]=vt(u,s,t,c,T?[].concat(T,n.message):n.message)}e.shift()};e.length;)a();return t}function ni(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,n,c){try{return Promise.resolve(Jt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(o){return c.shouldUseNativeValidation&&dt({},c),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return Array.isArray(u?.issues)})(o))return{values:{},errors:Zt(ii(o.errors,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw o}))}catch(o){return Promise.reject(o)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,n,c){try{return Promise.resolve(Jt(function(){return Promise.resolve((t.mode==="sync"?zs:$s)(e,a,s)).then(function(o){return c.shouldUseNativeValidation&&dt({},c),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return u instanceof Bs})(o))return{values:{},errors:Zt(ai(o.issues,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const oi=e=>{const s=Ke(),{pushError:t}=qs(),{data:a}=ns({...os(),staleTime:1/0}),n=a?.accounts.find(b=>b.accountId===e)?.composeLanguages,c=M.useMemo(()=>n&&n.length>0?[...n]:Ws(navigator.languages),[n]),o=he({...ht(),onSuccess:()=>{s.invalidateQueries({queryKey:je()})},onError:b=>{t(Gs("Couldn't save languages","The writing languages weren't saved.",b))}}),u=M.useCallback(b=>{e&&o.mutate({path:{accountId:e},body:{composeLanguages:b}})},[e,o]);return{languages:c,setLanguages:u,isSaving:o.isPending}},li=e=>e.authType==="oauthMicrosoft",ci=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},di=Zs({email:Xs(),displayName:Ae().optional(),username:Ae().optional(),password:Ae().optional(),imapHost:Ae().min(1,"IMAP host is required"),imapPort:Ot().int().min(1).max(65535),imapTls:Me(),imapStartTls:Me(),smtpHost:Ae().optional(),smtpPort:Ot().int().min(1).max(65535).optional(),smtpTls:Me().optional(),smtpStartTls:Me().optional(),smtpUsername:Ae().optional(),smtpPassword:Ae().optional(),useDifferentSmtpCreds:Me().optional()}),ui=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Ke(),c=!!t,[o,u]=M.useState(""),[b,w]=M.useState(!1),T=Ft(o),_=!!T&&!b,H=M.useRef(null),p=si({resolver:ni(di),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});M.useEffect(()=>{if(t){const h=ci(t);p.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:"",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})}else p.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1})},[t,p]);const S=he({...Ks()}),k=he({...Ys(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),A=he({...ht(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),oe=()=>{const h=p.getValues(),I=c&&!h.password;S.mutate({body:{accountId:I?t?.accountId:void 0,username:h.username||h.email,password:I?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},V=()=>{const h=p.getValues(),I=c&&!h.password;S.mutate({body:{accountId:I?t?.accountId:void 0,username:h.username||h.email,password:I?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}})},P=p.handleSubmit(h=>{if(!c&&!h.password){p.setError("password",{message:"Password is required"});return}const I=vr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});I&&(p.setValue("smtpHost",I.smtpHost),p.setValue("smtpPort",I.smtpPort),p.setValue("smtpTls",I.smtpTls),p.setValue("smtpStartTls",I.smtpStartTls));const J=I?.smtpHost??h.smtpHost,ne=I?.smtpPort??h.smtpPort,ge=I?.smtpTls??h.smtpTls,Se=I?.smtpStartTls??h.smtpStartTls,Ee={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:J||void 0,smtpPort:ne?Number(ne):void 0,smtpTls:ge,smtpStartTls:Se,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(c&&t){const Fe={...Ee,password:h.password||void 0};A.mutate({path:{accountId:t.accountId},body:Fe})}else{const Fe={...Ee,password:h.password};k.mutate({body:Fe})}}),C=k.isPending||A.isPending,{signature:E,setSignature:X,isSaving:W}=yr(t?.accountId),[ae,re]=M.useState(E.plainText),{languages:ce,setLanguages:pe,isSaving:F}=oi(t?.accountId),D=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(Pr,{value:ce,onChange:pe,busy:F})]});M.useEffect(()=>{re(E.plainText)},[E.plainText]),M.useEffect(()=>{if(!e||!a)return;const h=H.current;if(!h)return;const I=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(I)},[e,a]);const R=M.useCallback(()=>{ae!==E.plainText&&X(ae,ae)},[ae,E.plainText,X]),$=h=>{const{tls:I,startTls:J}=$e(h);p.setValue("imapTls",I),p.setValue("imapStartTls",J);const ne=p.getValues("imapPort");(ne===993||ne===143)&&p.setValue("imapPort",h==="tls"?993:143)},K=h=>{const{tls:I,startTls:J}=$e(h);p.setValue("smtpTls",I),p.setValue("smtpStartTls",J);const ne=p.getValues("smtpPort");if(ne===465||ne===587||ne===25){const Se=h==="tls"?465:h==="starttls"?587:25;p.setValue("smtpPort",Se)}},G=()=>{const h=p.getValues("imapHost");p.setValue("smtpHost",br(h)),p.setValue("smtpTls",!1),p.setValue("smtpStartTls",!0),p.setValue("smtpPort",587)},be=h=>{u(h),w(!1);const I=Ft(h);if(!I)return;const J=$e(I.imap.security);p.setValue("imapHost",I.imap.host),p.setValue("imapPort",I.imap.port),p.setValue("imapTls",J.tls),p.setValue("imapStartTls",J.startTls);const ne=$e(I.smtp.security);p.setValue("smtpHost",I.smtp.host),p.setValue("smtpPort",I.smtp.port),p.setValue("smtpTls",ne.tls),p.setValue("smtpStartTls",ne.startTls);const ge=p.getValues("email").trim(),Se=p.getValues("username")?.trim();ge&&!Se&&p.setValue("username",ge)},j=T?.passwordHelp.text,ie=It(S.data?.imapError,j),ke=It(S.data?.smtpError,j);return(t?li(t):!1)&&c?r.jsx(Mt,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),c&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:ae,onChange:h=>re(h.target.value),onBlur:R,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),c&&D]})}):r.jsx(Mt,{isOpen:e,onClose:s,title:c?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:C,children:C?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:P,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Qs,{id:"account-provider",value:o,onChange:h=>be(h.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),ur.map(h=>r.jsx("option",{value:h.id,children:h.label},h.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...p.register("email"),placeholder:"alice@example.com"}),p.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...p.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...p.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Ct,{id:"account-password",...p.register("password"),placeholder:c?"Leave empty to keep current":""}),p.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.password.message}),T&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[T.passwordHelp.text," ",r.jsx("a",{href:T.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),T&&r.jsx("button",{type:"button",onClick:()=>w(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:b?"Use preset settings":"Advanced"})]}),_&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",T?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...p.register("imapHost"),readOnly:_,placeholder:"imap.example.com"}),p.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...p.register("imapPort"),readOnly:_,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:p.watch("imapTls"),onChange:()=>$("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("imapTls")&&p.watch("imapStartTls"),onChange:()=>$("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("imapTls")&&!p.watch("imapStartTls"),onChange:()=>$("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:oe,disabled:S.isPending,className:"w-full",icon:S.isPending?r.jsx(rt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test IMAP Connection"}),S.data&&r.jsxs("div",{className:Pe("p-2 rounded-md text-sm",S.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.imapSuccess?r.jsx(_t,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),S.data.imapSuccess?"IMAP Connected":ie]})]})]}),r.jsxs("section",{ref:H,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!_&&r.jsx("button",{type:"button",onClick:G,disabled:!p.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...p.register("smtpHost"),readOnly:_,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...p.register("smtpPort"),readOnly:_,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:p.watch("smtpTls")===!0,onChange:()=>K("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("smtpTls")&&p.watch("smtpStartTls")===!0,onChange:()=>K("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("smtpTls")&&!p.watch("smtpStartTls"),onChange:()=>K("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...p.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),p.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...p.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Ct,{id:"smtp-password",...p.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:V,disabled:S.isPending||!p.watch("smtpHost"),className:"w-full",icon:S.isPending?r.jsx(rt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test SMTP Connection"}),S.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Pe("p-2 rounded-md text-sm",S.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.smtpSuccess?r.jsx(_t,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),S.data.smtpSuccess?"SMTP Connected":ke]})]})]}),c&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:ae,onChange:h=>re(h.target.value),onBlur:R,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),c&&D]})})},fi="https://graph.microsoft.com/",mi={[it.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[it.Calendar]:[`${fi}Calendars.Read`]},hi=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(it).filter(t=>mi[t].every(a=>s.has(a.toLowerCase())))},ft=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,pi=e=>Js(er({title:`Bug: ${ft(e)}`,errorMessage:`${ft(e)} — ${e.message}`}));function gi({providerName:e,offered:s,enabled:t,consented:a,disabled:n,refusal:c,onRequestChange:o}){return s.length<2?null:r.jsxs("section",{className:"space-y-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[r.jsx(_r,{providerName:e,offered:s,enabled:t,consented:a,disabled:n,onRequestChange:o}),c&&r.jsxs(at,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:ft(c)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:c.message}),r.jsx("a",{href:pi(c),target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-block font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const As=["Mail","Calendar"],es="Microsoft",ts=e=>e.authType==="oauthMicrosoft",ss=(e,s)=>As.filter(t=>t===s||e.includes(t));function xi({account:e,onRemoveAccount:s}){const t=Ke(),[a,n]=M.useState(null),[c,o]=M.useState(null),[u,b]=M.useState(null),w=he({...ht(),meta:Vt,onSuccess:()=>t.invalidateQueries({queryKey:je()})}),T=he({...ls(),meta:Vt}),_=ds(P=>{const C=u;b(null),!(P!=="stalled"||C===null)&&o({service:C,intent:"on",message:us})}),H=w.isPending&&w.variables?.body.syncedServices?w.variables.body.syncedServices:e.syncedServices,p=ts(e)?As:["Mail"],S=ts(e)?hi(e.grantedScopes):p,k=(P,C,E)=>{o(null),w.mutate({path:{accountId:e.accountId},body:{syncedServices:P}},{onError:X=>o({service:C,intent:E,message:Rt(X)})})},A=P=>{o(null),T.mutate({body:{email:e.email,services:ss(H,P)}},{onSuccess:C=>{b(P),_(),window.location.assign(C.authorizationUrl)},onError:C=>o({service:P,intent:"on",message:Rt(C)})})},oe=(P,C)=>{if(C==="off"){n({kind:H.length===1?"last":"disable",service:P});return}if(!S.includes(P)){n({kind:"enable",service:P});return}k(ss(H,P),P,"on")},V=()=>{const P=a;if(n(null),P!==null){if(P.kind==="last"){s();return}if(P.kind==="enable"){A(P.service);return}k(H.filter(C=>C!==P.service),P.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(gi,{providerName:es,offered:p,enabled:H,consented:S,disabled:w.isPending||T.isPending||u!==null,refusal:c,onRequestChange:oe}),r.jsx(Er,{change:a,providerName:es,onConfirm:V,onCancel:()=>n(null)})]})}function rs({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,c]=M.useState(""),[o,u]=M.useState(!1),[b,w]=M.useState(!1),T=he({...sr(),onSuccess:()=>{w(!0),setTimeout(()=>a(),2e3)}}),_=he(rr()),H=()=>{T.isPending||(c(""),u(!1),w(!1),T.reset(),_.reset(),s())},p=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),T.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(cs,{open:e,onClose:H,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(mt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:H,"aria-label":"Cancel"})]}),b?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>_.mutate({}),"aria-busy":_.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(jr,{className:"size-3.5"}),_.isPending?"Requesting export…":"Export my data first"]}),_.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),_.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:S=>{c(S.target.value),o&&u(!1),T.isError&&T.reset()},autoComplete:"off"}),o&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),T.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:T.error instanceof Error?T.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:H,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:p,"aria-busy":T.isPending,children:T.isPending?"Deleting…":"Delete everything"})]})]})]})}function yi(e){const{Account:s}=tr();return r.jsx(s,{fallback:r.jsx(rs,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>r.jsx(rs,{...e,accountEmail:t??"",signOut:a})})}function vi(){const[e,s]=M.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(Dr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(yi,{open:e,onClose:()=>s(!1)})]})}function Ts(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="scope_not_granted"?"Microsoft did not grant access to every service you picked. Sign in again and accept each permission Microsoft asks for.":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.`}const bi=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Si(e,s){const t=(e.missingServices??"").split(","),a=nt.filter(w=>t.includes(w.id)),n=e.oauthEmail,c=n?s.find(w=>w.authType==="oauthMicrosoft"&&w.email.toLowerCase()===n.toLowerCase()):void 0,o=bi(a.map(w=>w.label)),u=a.length===0?Ts("scope_not_granted"):`Microsoft did not grant access to ${o}. Sign in again and accept the ${o} ${a.length>1?"permissions":"permission"} when Microsoft asks.`,b=c?nt.filter(w=>c.syncedServices.includes(w.id)||a.some(T=>T.id===w.id)).map(w=>w.id):void 0;return{kind:"refused",message:u,email:n,services:b,reconnect:!!c}}function ji(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function wi(e){const s=e.displayName?.trim();return s||ji(e.email)}function Ni(e){if(!e.lastSyncAt)return"never synced";const s=dr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function is(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function as(e){return e.connectionState==="reauth_required"}function Ai(e){return e.connectionState==="credentials_missing"}const Ti=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function Gi(){const e=Pt.useSearch(),s=ir({from:Pt.fullPath}),[t,a]=M.useState(!0),[n,c]=M.useState(!1),[o,u]=M.useState(!1),[b,w]=M.useState(void 0),[T,_]=M.useState(null),[H,p]=M.useState(!1),[S,k]=M.useState(null),[A,oe]=M.useState(null),[V,P]=M.useState(null),[C,E]=M.useState(null),X=Ke(),{data:W,isPending:ae,isError:re,error:ce,refetch:pe}=ns(os());M.useEffect(()=>{e.editAccountId&&(_(e.editAccountId),p(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError,oauthEmail:e.oauthEmail,missingServices:e.missingServices},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError,e.oauthEmail,e.missingServices]),M.useEffect(()=>{e.connected&&(w({kind:"connected",accountId:e.connected}),u(!0),X.invalidateQueries({queryKey:je()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,X]),M.useEffect(()=>{if(!e.oauthError)return;const j=e.oauthError==="scope_not_granted";j&&!W&&!re||(E(null),j?(w(Si({oauthEmail:e.oauthEmail,missingServices:e.missingServices},W?.accounts??[])),u(!0)):P(Ts(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,e.oauthEmail,e.missingServices,W,re,s]),xr(C!==null,()=>{X.invalidateQueries({queryKey:je()})}),M.useEffect(()=>{if(!C||!W)return;const j=W.accounts.find(ie=>ie.accountId===C);(!j||!as(j))&&E(null)},[W,C]);const F=ds(j=>{E(null),j==="stalled"&&P(us)}),D=he({...ls(),onSuccess:j=>{F(),window.location.assign(j.authorizationUrl)},onError:j=>{P(j instanceof Error?j.message:"Failed to start reconnect"),E(null)}}),R=he({...ar(),onSuccess:()=>{X.invalidateQueries({queryKey:je()}),k(null)}}),$=W?.accounts.find(j=>j.accountId===S),K=W?.accounts.find(j=>j.accountId===T),G=()=>{c(!1),u(!1),_(null),p(!1)},be=j=>{const ie=lr[j];ie&&s({to:ie})};return r.jsxs(pr,{items:nr,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:wr,helpOpen:t,onToggleHelp:()=>a(j=>!j),onSelect:be,onBackToMail:()=>{s({to:"/mail"})},children:[A&&r.jsx(at,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>oe(null),children:A}),V&&r.jsx(at,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>P(null),children:V}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(or,{tone:"neutral",children:ae||re?"accounts":`${W.accounts.length} ${W.accounts.length===1?"account":"accounts"}`}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Dt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ae?r.jsx(Ti,{}):re?r.jsx(mr,{title:"Couldn't load accounts",error:ce,onRetry:()=>{pe()}}):W.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Dt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:W.accounts.map(j=>{const ie=as(j),ke=Ai(j),Ne=j.authType==="oauthMicrosoft",h=C===j.accountId,I=ie&&Ne?{label:"Reconnect",variant:"secondary",busy:h,busyLabel:"Redirecting…",onClick:()=>{E(j.accountId),D.mutate({body:{email:j.email,services:j.syncedServices}})}}:ke?{label:"Enter password",variant:"secondary",onClick:()=>_(j.accountId)}:is(j)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(j.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(j.accountId)},J=r.jsx(hr,{actions:[I],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(cr,{className:"size-3.5"}),onClick:()=>k(j.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(gr,{label:wi(j),email:j.email,connector:Ne?"Microsoft 365":"IMAP",syncLabel:Ni(j),state:is(j),errorDetail:ie?j.lastError??"Re-authentication required":ke?"Imported from a config file, which carries no password. Enter one to start syncing.":j.lastError,trailing:J}),r.jsx(xi,{account:j,onRemoveAccount:()=>k(j.accountId)})]},j.accountId)})}),o&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(fr,{skipWelcome:!0,microsoftReturn:b,onComplete:()=>{b?.kind==="connected"&&oe("Account connected successfully."),u(!1),w(void 0),X.invalidateQueries({queryKey:je()})},onCancel:()=>{u(!1),w(void 0)}})}),r.jsx(ui,{isOpen:n||!!T,account:K,focusSmtp:H,onClose:G}),r.jsxs(cs,{open:!!S,onClose:()=>k(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(mt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:()=>k(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),$&&r.jsx("p",{className:"text-center",children:$.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:()=>k(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":R.isPending,icon:R.isPending?r.jsx(rt,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{R.isPending||S&&R.mutate({path:{accountId:S}})},children:R.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(vi,{})]})}export{Gi as component,Ts as mapOauthError,Si as scopeRefusalReturn};
1
+ import{j as r,r as M,o as Pe,ae as Ve,d as se,S as Rs,X as De,af as Is,ag as Ms,ah as mt,p as Os,q as Ls,ai as Us,aj as Hs,ak as te,al as zs,am as $s,an as Bs,f as Ke,ao as qs,a as ns,c as os,ap as Ws,g as he,aq as Gs,l as je,i as ht,ar as Ks,as as Ys,at as Qs,au as ve,av as Ct,L as rt,aw as _t,ax as Zs,ay as Me,az as Ae,aA as Xs,aB as it,B as at,aC as Js,aD as er,aE as Vt,m as ls,N as tr,aF as sr,aG as rr,aH as cs,aI as Pt,u as ir,aJ as ar,aK as nr,e as or,aL as Dt,aM as lr,T as cr,aN as dr}from"./index-CL_fwLHN.js";import{A as nt,g as Ft,P as ur,O as fr}from"./OnboardingWizard-Cvqq2aP_.js";import{f as Rt,E as mr}from"./ErrorState-KjDYblD5.js";import{R as hr}from"./row-actions-DA6zLLAB.js";import{S as pr,A as gr}from"./settings-screen-DBP3ABLE.js";import{s as $e,b as ds,R as us,u as xr}from"./credential-steps-DVglyUgf.js";import{u as yr}from"./useSignature-BkzkUbjz.js";import{c as vr,a as It,d as br}from"./account-form-helpers-DhckT_PN.js";import{C as Sr}from"./confirm-dialog-q8tbS_22.js";import{D as jr}from"./download-SQdHw0Vd.js";import{a as wr}from"./help-copy-B2iT8EG_.js";import"./checkbox-CGG1nAhQ.js";import"./kbd-CDJCJUnp.js";import"./file-json-DQGozYSr.js";import"./avatar-uWJajuSb.js";import"./menu-CcLh9Whg.js";import"./circle-help-CVWHf1ow.js";import"./card-CPL-TrL1.js";const Nr={Mail:"Mail already in Remit stays, and you can keep reading it.",Calendar:"Events already in Remit stay on your calendar."},Ar={Mail:"New mail stops arriving until you turn it back on.",Calendar:"Changes stop arriving until you turn it back on."},Tr={Mail:"mail",Calendar:"calendar"};function kr(e,s){const t=Tr[e.service];return e.kind==="enable"?{title:`Sign in with ${s} to add ${t}?`,description:`This account was never asked for ${t} access. Remit sends you to ${s} to ask for it, and brings you back here when you are done. Nothing changes until you get back.`,confirmLabel:`Continue to ${s}`,cancelLabel:"Cancel",destructive:!1}:e.kind==="last"?{title:`${e.service} is the only thing this account syncs`,description:`An account has to sync something. To stop this one entirely, remove the account — that deletes what Remit stored for it, which switching ${t} off never does.`,confirmLabel:"Remove account",cancelLabel:`Keep syncing ${t}`,destructive:!0}:{title:`Stop syncing ${t} for this account?`,description:`${Nr[e.service]} ${Ar[e.service]} Nothing is deleted.`,confirmLabel:`Stop syncing ${t}`,cancelLabel:"Cancel",destructive:!1}}function Er({change:e,providerName:s,onConfirm:t,onCancel:a,isBusy:n}){if(e===null)return null;const c=kr(e,s);return r.jsx(Sr,{isOpen:!0,title:c.title,description:c.description,confirmLabel:c.confirmLabel,cancelLabel:c.cancelLabel,destructive:c.destructive,isBusy:n??!1,onConfirm:t,onCancel:a})}function Cr({checked:e,label:s,describedBy:t,disabled:a,onToggle:n}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,"aria-describedby":t,disabled:a,onClick:n,className:Pe("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors","outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",e?"border-positive bg-positive":"border-line-strong bg-surface-sunken"),children:r.jsx("span",{"aria-hidden":!0,className:Pe("size-4 rounded-full bg-canvas transition-transform",e?"translate-x-6":"translate-x-1")})})}function _r({providerName:e,offered:s,enabled:t,consented:a,disabled:n=!1,onRequestChange:c}){const o=M.useId(),u=nt.filter(b=>s.includes(b.id));return u.length<2?null:r.jsxs("fieldset",{children:[r.jsx("legend",{className:"text-sm font-semibold text-fg",children:"What this account syncs"}),r.jsx("div",{className:"mt-1 divide-y divide-line",children:u.map(b=>{const w=t.includes(b.id),T=`${o}-${b.id}`,_=!w&&!a.includes(b.id);return r.jsxs("div",{className:"flex min-h-11 items-center gap-3 py-2 text-left",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsx("span",{className:"text-sm text-fg",children:b.label}),r.jsx("span",{id:T,className:"text-xs text-fg-subtle",children:_?`${b.description} Turning this on means signing in with ${e} again.`:b.description})]}),r.jsx(Cr,{checked:w,label:`Sync ${b.label.toLowerCase()}`,describedBy:T,disabled:n,onToggle:()=>c(b.id,w?"off":"on")})]},b.id)})})]})}const Vr=e=>{const s=new Set(e.map(Is));return Ms.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,a)=>Ve(t).localeCompare(Ve(a)))},Pr=({value:e,onChange:s,busy:t=!1})=>{const a=Vr(e);return r.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[r.jsx("ul",{className:"space-y-1",children:e.map((n,c)=>r.jsxs("li",{"data-testid":`compose-language-row-${n}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:n,children:Ve(n)}),c===0?r.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(Rs,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${Ve(n)} by default`,onClick:()=>s([n,...e.filter(o=>o!==n)]),children:"Default"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${Ve(n)}`,onClick:()=>s(e.filter(o=>o!==n))})]},n))}),r.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||a.length===0,onChange:n=>{n.target.value!==""&&s([...e,n.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[r.jsx("option",{value:"",children:"Add a language…"}),a.map(n=>r.jsx("option",{value:n,children:Ve(n)},n))]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function Dr({title:e,description:s,action:t}){return r.jsxs("div",{className:"rounded-sm border border-danger/50",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[r.jsx(mt,{className:"size-4 text-danger"}),r.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),r.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-fg",children:e}),r.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),r.jsx("div",{className:"shrink-0",children:t})]})]})}function Mt({isOpen:e,onClose:s,title:t,children:a,footer:n}){Os({id:"slide-panel",open:e,answers:{back:s}});const c=M.useRef(null);return Ls(c,e),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Pe("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),r.jsxs("div",{ref:c,className:Pe("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",tabIndex:-1,children:[r.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[r.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),r.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:r.jsx(De,{className:"size-5"})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsx("div",{className:"flex-1 overflow-auto p-4",children:a}),n&&r.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:n})]})]})]})}function Ot(e){return Us(Hs,e)}var Ue=e=>e.type==="checkbox",we=e=>e instanceof Date,Q=e=>e==null;const pt=e=>typeof e=="object";var z=e=>!Q(e)&&!Array.isArray(e)&&pt(e)&&!we(e),Fr=e=>z(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,Rr=(e,s)=>s.split(".").some((t,a,n)=>!isNaN(Number(t))&&e.has(n.slice(0,a).join("."))),fs=e=>{const s=e.constructor&&e.constructor.prototype;return z(s)&&s.hasOwnProperty("isPrototypeOf")},Ye=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function B(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ye&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(z(e)&&fs(e)))return e;const a=t?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=B(e[n]));return a}const Ce={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"},ms="root",gt=["__proto__","constructor","prototype"],Ir=/^\w*$/;var He=e=>Ir.test(e),L=e=>e===void 0;const Mr=/[.[\]'"]/;var Qe=e=>e.split(Mr).filter(Boolean),y=(e,s,t)=>{if(!s||!z(e))return t;const a=He(s)?[s]:Qe(s);if(a.some(c=>gt.includes(c)))return t;const n=a.reduce((c,o)=>Q(c)?void 0:c[o],e);return L(n)||n===e?L(e[s])?t:e[s]:n},fe=e=>typeof e=="boolean",le=e=>typeof e=="function",O=(e,s,t)=>{let a=-1;const n=He(s)?[s]:Qe(s),c=n.length,o=c-1;for(;++a<c;){const u=n[a];let b=t;if(a!==o){const w=e[u];b=z(w)||Array.isArray(w)?w:isNaN(+n[a+1])?{}:[]}if(gt.includes(u))return;e[u]=b,e=e[u]}};const Or=te.createContext(null);Or.displayName="HookFormControlContext";var Lr=(e,s,t,a=!0)=>{const n={};for(const c in e)Object.defineProperty(n,c,{get:()=>{const o=c;return s._proxyFormState[o]!==ue.all&&(s._proxyFormState[o]=!a||ue.all),e[o]}});return n};const Ur=Ye?te.useLayoutEffect:te.useEffect;var Z=e=>typeof e=="string",Hr=(e,s,t,a,n)=>Z(e)?(a&&s.watch.add(e),y(t,e,n)):Array.isArray(e)?e.map(c=>(a&&s.watch.add(c),y(t,c))):(a&&(s.watchAll=!0),t),ot=e=>Q(e)||!pt(e);const Lt=(e,s)=>s.length===0&&!Array.isArray(e)&&!fs(e);function me(e,s,t=new WeakMap){if(e===s)return!0;if(ot(e)||ot(s))return Object.is(e,s);if(we(e)&&we(s))return Object.is(e.getTime(),s.getTime());const a=Object.keys(e),n=Object.keys(s);if(a.length!==n.length)return!1;if(Lt(e,a)||Lt(s,n))return Object.is(e,s);if(!a.length&&Array.isArray(e)!==Array.isArray(s))return!1;const c=t.get(e);if(c&&c.has(s))return!0;if(c)c.add(s);else{const o=new WeakSet;o.add(s),t.set(e,o)}for(const o of a){const u=e[o];if(!(o in s))return!1;if(o!=="ref"){const b=s[o];if(we(u)&&we(b)||(z(u)||Array.isArray(u))&&(z(b)||Array.isArray(b))?!me(u,b,t):!Object.is(u,b))return!1}}return!0}var Be=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),et=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const a of s.watch)if(e.startsWith(a)&&e.charAt(a.length)===".")return!0;return!1};const Le=(e,s,t,a)=>{for(const n of t||Object.keys(e)){const c=y(e,n);if(c){const{_f:o,...u}=c;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],n)&&!a)return!0;if(o.ref&&s(o.ref,o.name)&&!a)return!0;if(Le(u,s))break}else if(z(u)&&Le(u,s))break}}};var Ut=(e,s,t)=>{const a=y(e,t),n=Array.isArray(a)?a:[];return O(n,ms,s[t]),O(e,t,n),e},Y=e=>z(e)&&!Object.keys(e).length,xt=e=>e.type==="file",We=e=>{if(!Ye)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},yt=e=>e.type==="radio",Ge=e=>e instanceof RegExp,vt=(e,s,t,a,n)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[a]:n||!0}}:{};const Ht={value:!1,isValid:!1},zt={value:!0,isValid:!0};var hs=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===""?zt:{value:e[0].value,isValid:!0}:zt:Ht}return Ht};const $t={isValid:!1,value:null};var ps=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,$t):$t;function Bt(e,s,t="validate"){if(Z(e)||Array.isArray(e)&&e.every(Z)||fe(e)&&!e)return{type:t,message:Z(e)?e:"",ref:s}}var _e=e=>z(e)&&!Ge(e)?e:{value:e,message:""},qt=async(e,s,t,a,n,c)=>{const{ref:o,refs:u,required:b,maxLength:w,minLength:T,min:_,max:H,pattern:p,validate:S,name:k,valueAsNumber:A,mount:oe}=e._f,V=y(t,k);if(!oe||s.has(k))return{};const P=u?u[0]:o,C=F=>{if(n&&P.reportValidity){const D=fe(F)?"":F||"";u?u.forEach(R=>R.setCustomValidity(D)):P.setCustomValidity(D),P.reportValidity()}},E={},X=yt(o),W=Ue(o),ae=X||W,re=(A||xt(o))&&L(o.value)&&L(V)||We(o)&&o.value===""||V===""||Array.isArray(V)&&!V.length,ce=vt.bind(null,k,a,E),pe=(F,D,R,$=de.maxLength,K=de.minLength)=>{const G=F?D:R;E[k]={type:F?$:K,message:G,ref:o,...ce(F?$:K,G)}};if(c?!Array.isArray(V)||!V.length:b&&(!ae&&(re||Q(V))||fe(V)&&!V||W&&!hs(u).isValid||X&&!ps(u).isValid)){const{value:F,message:D}=Z(b)?{value:!!b,message:b}:_e(b);if(F&&(E[k]={type:de.required,message:D,ref:P,...ce(de.required,D)},!a))return C(D),E}if(!re&&(!Q(_)||!Q(H))){let F,D;const R=_e(H),$=_e(_);if(!Q(V)&&!isNaN(V)){const K=o.valueAsNumber||V&&+V;Q(R.value)||(F=K>R.value),Q($.value)||(D=K<$.value)}else{const K=o.valueAsDate||new Date(V),G=ie=>new Date(new Date().toDateString()+" "+ie),be=o.type=="time",j=o.type=="week";Z(R.value)&&V&&(F=be?G(V)>G(R.value):j?V>R.value:K>new Date(R.value)),Z($.value)&&V&&(D=be?G(V)<G($.value):j?V<$.value:K<new Date($.value))}if((F||D)&&(pe(!!F,R.message,$.message,de.max,de.min),!a))return C(E[k].message),E}if((w||T)&&!re&&(Z(V)||c&&Array.isArray(V))){const F=_e(w),D=_e(T),R=!Q(F.value)&&V.length>+F.value,$=!Q(D.value)&&V.length<+D.value;if((R||$)&&(pe(R,F.message,D.message),!a))return C(E[k].message),E}if(p&&!re&&Z(V)){const{value:F,message:D}=_e(p);if(Ge(F)&&!V.match(F)&&(E[k]={type:de.pattern,message:D,ref:o,...ce(de.pattern,D)},!a))return C(D),E}if(S){if(le(S)){const F=await S(V,t),D=Bt(F,P);if(D&&(E[k]={...D,...ce(de.validate,D.message)},!a))return C(D.message),E}else if(z(S)){let F={};for(const D in S){if(!Y(F)&&!a)break;const R=Bt(await S[D](V,t),P,D);R&&(F={...R,...ce(D,R.message)},C(R.message),a&&(E[k]=F))}if(!Y(F)&&(E[k]={ref:P,...F},!a))return E}}return C(!0),E},qe=e=>Array.isArray(e)?e:[e],gs=e=>Array.isArray(e)?e.filter(Boolean):[];function zr(e,s){const t=s.slice(0,-1).length;let a=0;for(;a<t;){if(Q(e)){e=void 0;break}e=e[s[a]],a++}return e}function $r(e){for(const s in e)if(e.hasOwnProperty(s)&&!L(e[s]))return!1;return!0}function q(e,s){if(Z(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:He(s)?[s]:Qe(s);if(t.some(o=>gt.includes(String(o))))return e;const a=t.length===1?e:zr(e,t),n=t.length-1,c=t[n];return a&&delete a[c],n!==0&&(z(a)&&Y(a)||Array.isArray(a)&&$r(a))&&q(e,t.slice(0,-1)),e}const xs=e=>{const s={};for(const t of Object.keys(e))if(pt(e[t])&&e[t]!==null&&!we(e[t])){const a=xs(e[t]);for(const n of Object.keys(a))s[`${t}.${n}`]=a[n]}else s[t]=e[t];return s},Br=te.createContext(null);Br.displayName="HookFormContext";var Wt=()=>{let e=[];return{get observers(){return e},next:n=>{for(const c of e)c.next&&c.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(c=>c!==n)}}),unsubscribe:()=>{e=[]}}};function ys(e,s){const t={};for(const a in e)if(e.hasOwnProperty(a)){const n=e[a],c=s[a];if(n&&z(n)&&c){const o=ys(n,c);z(o)&&(t[a]=o)}else e[a]&&(t[a]=c)}return t}var vs=e=>e.type==="select-multiple",qr=e=>yt(e)||Ue(e),tt=e=>We(e)&&e.isConnected,Wr=e=>{for(const s in e)if(le(e[s]))return!0;return!1};function bs(e){return Array.isArray(e)||z(e)&&!Wr(e)}function Ss(e){return!!(e&&"_f"in e)}function js(e){return Array.isArray(e)?!e.some(s=>!L(s)):!Object.keys(e).length}function lt(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function ct(e,s={},t){for(const a in e){const n=e[a],c=t&&t[a];bs(n)&&(!Array.isArray(n)||!Ss(c))?(s[a]=Array.isArray(n)?[]:{},ct(n,s[a],c),js(s[a])&&lt(s,a)):L(n)||(s[a]=!0)}return s}function Te(e,s,t,a){t||(t=ct(s,{},a));for(const n in e){const c=e[n],o=a&&a[n];bs(c)&&(!Array.isArray(c)||!Ss(o))?(L(s)||ot(t[n])?t[n]=ct(c,Array.isArray(c)?[]:{},o):Te(c,Q(s)?{}:s[n],t[n],o),js(t[n])&&lt(t,n)):me(c,s[n])?lt(t,n):t[n]=!0}return t}var ws=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:a})=>L(e)?e:s?e===""?NaN:e&&+e:t&&Z(e)?new Date(e):a?a(e):e;function Gt(e){const s=e.ref;return xt(s)?s.files:yt(s)?ps(e.refs).value:vs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?hs(e.refs).value:ws(L(s.value)?e.ref.value:s.value,e)}var Gr=(e,s,t,a)=>{const n={};for(const c of e){const o=y(s,c);o&&O(n,c,o._f)}return{criteriaMode:t,names:[...e],fields:n,shouldUseNativeValidation:a}},Oe=e=>L(e)?e:Ge(e)?e.source:z(e)?Ge(e.value)?e.value.source:e.value:e;const Kt="AsyncFunction";var Kr=e=>{if(!e||!e.validate)return!1;if(le(e.validate))return e.validate.constructor.name===Kt;if(z(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Kt)return!0}return!1},Yr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Yt(e,s,t){const a=y(e,t);if(a||He(t))return{error:a,name:t};const n=t.split(".");for(;n.length;){const c=n.join("."),o=y(s,c),u=y(e,c);if(o&&!Array.isArray(o)&&t!==c)return{name:t};if(u&&u.type)return{name:c,error:u};if(u&&u.root&&u.root.type)return{name:`${c}.root`,error:u.root};n.pop()}return{name:t}}var Qr=(e,s,t,a)=>{t(e);const{name:n,...c}=e,o=Object.keys(c);return!o.length||a&&o.length>=Object.keys(s).length||o.find(u=>s[u]===(!a||ue.all))},Zr=(e,s,t)=>!e||!s||e===s||qe(e).some(a=>a&&(t?a===s||a.startsWith(s+"."):a.startsWith(s)||s.startsWith(a))),Xr=(e,s,t,a,n)=>n.isOnAll?!1:!t&&n.isOnTouch?!(s||e):(t?a.isOnBlur:n.isOnBlur)?!e:(t?a.isOnChange:n.isOnChange)?e:!0,Jr=(e,s)=>!gs(y(e,s)).length&&q(e,s);const ei={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},st="form",Ns={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function ti(e={}){let s={...ei,...e},t={...B(Ns),isLoading:le(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},a={},n=z(s.defaultValues)||z(s.values)?B(s.defaultValues||s.values)||{}:{},c=s.shouldUnregister?{}:B(n),o={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 b={},w={};let T=0,_=Be(s.mode),H=Be(s.reValidateMode);const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},S={...p};let k={...S};const A={array:Wt(),state:Wt()};let oe=0;const V=s.criteriaMode===ue.all,P=(i,l)=>d=>{clearTimeout(w[i]),w[i]=setTimeout(l,d)},C=async i=>{if(!o.keepIsValid&&!s.disabled&&(S.isValid||k.isValid||i)){const l=++oe;let d;s.resolver?(d=Y((await R()).errors),l===oe&&E()):d=await G({fields:a,onlyCheckValid:!0,eventType:Ce.VALID}),l===oe&&d!==t.isValid&&A.state.next({isValid:d})}},E=(i,l)=>{!s.disabled&&(S.isValidating||S.validatingFields||k.isValidating||k.validatingFields)&&((i||Array.from(u.mount)).forEach(d=>{d&&(l?O(t.validatingFields,d,l):q(t.validatingFields,d))}),A.state.next({validatingFields:t.validatingFields,isValidating:!Y(t.validatingFields)}))},X=()=>{t.dirtyFields=Te(n,c,void 0,a)},W=(i,l=[],d,f,m=!0,x=!0)=>{if(f&&d&&!s.disabled){if(o.action=!0,x&&Array.isArray(y(a,i))){const g=d(y(a,i),f.argA,f.argB);m&&O(a,i,g)}if(x&&Array.isArray(y(t.errors,i))){const g=d(y(t.errors,i),f.argA,f.argB);m&&O(t.errors,i,g),Jr(t.errors,i)}if((S.touchedFields||k.touchedFields)&&x&&Array.isArray(y(t.touchedFields,i))){const g=d(y(t.touchedFields,i),f.argA,f.argB);m&&O(t.touchedFields,i,g)}(S.dirtyFields||k.dirtyFields)&&X(),A.state.next({name:i,isDirty:j(i,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else O(c,i,l)},ae=(i,l)=>{O(t.errors,i,l),t.errors={...t.errors},A.state.next({errors:t.errors})},re=i=>{t.errors=i,A.state.next({errors:t.errors,isValid:!1})},ce=i=>{const l=He(i)?[i]:Qe(i);let d=c,f=n;for(let m=0;m<l.length-1;m++){const x=l[m];if(d=Q(d)?d:d[x],f=Q(f)?f:f[x],d===null&&f!==null)return!0}return!1},pe=(i,l,d,f)=>{const m=y(a,i);if(m){if(ce(i))return;const x=L(y(c,i)),g=y(c,i,L(d)?y(n,i):d);L(g)||f&&f.defaultChecked||l?O(c,i,l?g:Gt(m._f)):Ne(i,g),o.mount&&!o.action&&(C(),x&&t.isDirty&&(S.isDirty||k.isDirty)&&(j()||(t.isDirty=!1,A.state.next({...t}))),e.shouldUnregister&&x&&!L(y(c,i))&&et(i,u)&&(o.watch=!0))}},F=(i,l,d,f,m)=>{let x=!1,g=!1;const v={name:i};if(!s.disabled||f===!0){if(!d||f){const N=me(y(n,i),l);(S.isDirty||k.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!N||j(),x=g!==v.isDirty),g=!!y(t.dirtyFields,i),N!==t.isDirty?t.dirtyFields=Te(n,c,void 0,a):N?q(t.dirtyFields,i):O(t.dirtyFields,i,!0),v.dirtyFields=t.dirtyFields,x=x||(S.dirtyFields||k.dirtyFields)&&g!==!N}if(d){const N=y(t.touchedFields,i);N||(O(t.touchedFields,i,d),v.touchedFields=t.touchedFields,x=x||(S.touchedFields||k.touchedFields)&&N!==d)}x&&m&&A.state.next(v)}return x?v:{}},D=(i,l,d,f)=>{const m=y(t.errors,i),x=(S.isValid||k.isValid)&&fe(l)&&t.isValid!==l;if(s.delayError&&d?(b[i]=P(i,()=>ae(i,d)),b[i](s.delayError)):(clearTimeout(w[i]),delete b[i],d?O(t.errors,i,d):q(t.errors,i),t.errors={...t.errors}),(d?!me(m,d):m)||!Y(f)||x){const g={...f,...x&&fe(l)?{isValid:l}:{},errors:t.errors,name:i};t={...t,...g},A.state.next(g)}},R=async i=>(E(i,!0),await s.resolver(c,s.context,Gr(i||u.mount,a,s.criteriaMode,s.shouldUseNativeValidation))),$=async i=>{const{errors:l}=await R(i);if(E(i),i){for(const d of i){const f=y(l,d);f?u.array.has(d)&&z(f)&&!Object.keys(f).some(m=>!Number.isNaN(Number(m)))?Ut(t.errors,{[d]:f},d):O(t.errors,d,f):q(t.errors,d)}t.errors={...t.errors}}else t.errors=l;return l},K=async({name:i,eventType:l})=>{if(e.validate){const d=await e.validate({formValues:c,formState:t,name:i,eventType:l});if(z(d))for(const f in d){const m=d[f];m&&ze(`${st}.${f}`,{message:Z(m.message)?m.message:"",type:m.type||de.validate})}else Z(d)||!d?ze(st,{message:d||"",type:de.validate}):St(st);return d}return!0},G=async({fields:i,onlyCheckValid:l,name:d,eventType:f,context:m={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(m.runRootValidation=!0,!await K({name:d,eventType:f})&&(m.valid=!1,l)))return m.valid;for(const x in i){const g=i[x];if(g){const{_f:v,...N}=g;if(v){const U=u.array.has(v.name),ee=g._f&&Kr(g._f),xe=S.validatingFields||S.isValidating||k.validatingFields||k.isValidating;ee&&xe&&E([v.name],!0);const ye=await qt(g,u.disabled,c,V,s.shouldUseNativeValidation&&!l,U);if(ee&&xe&&E([v.name]),ye[v.name]&&(m.valid=!1,l)||(!l&&(y(ye,v.name)?U?Ut(t.errors,ye,v.name):O(t.errors,v.name,ye[v.name]):q(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!Y(N)&&await G({context:m,onlyCheckValid:l,fields:N,name:x,eventType:f})}}return m.valid},be=()=>{for(const i of u.unMount){const l=y(a,i);l&&(l._f.refs?l._f.refs.every(d=>!tt(d)):!tt(l._f.ref))&&Ze(i)}u.unMount=new Set},j=(i,l)=>(i&&l&&O(c,i,l),!me(o.mount?c:n,n)),ie=(i,l,d)=>Hr(i,u,{...o.mount?c:L(l)?n:Z(i)?{[i]:l}:l},d,l),ke=i=>gs(y(o.mount?c:n,i,s.shouldUnregister?y(n,i,[]):[])),Ne=(i,l,d={},f=!1,m=!1)=>{const x=y(a,i);let g=l;if(x){const v=x._f;v&&(!v.disabled&&O(c,i,ws(l,v)),g=We(v.ref)&&Q(l)?"":l,vs(v.ref)?[...v.ref.options].forEach(N=>N.selected=g.includes(N.value)):v.refs?Ue(v.ref)?v.refs.forEach(N=>{(!N.defaultChecked||!N.disabled)&&(Array.isArray(g)?N.checked=!!g.find(U=>U===N.value):N.checked=g===N.value||!!g)}):v.refs.forEach(N=>N.checked=N.value===g):xt(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!m&&A.state.next({name:i,values:f?c:B(c)})))}(d.shouldDirty||d.shouldTouch)&&F(i,g,d.shouldTouch,d.shouldDirty,!m),d.shouldValidate&&Ee(i,{delayError:d.delayError})},h=(i,l,d,f=!1,m=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=i+"."+x,N=y(a,v);(u.array.has(i)||z(g)||N&&!N._f)&&!we(g)?h(v,g,d,f,m):Ne(v,g,d,f,m)}},I=(i,l,d,f,m=!1)=>{const x=y(a,i),g=u.array.has(i),v=f?l:B(l),N=y(c,i),U=me(N,v);if(U||O(c,i,v),g)A.array.next({name:i,values:f?c:B(c)}),(S.isDirty||S.dirtyFields||k.isDirty||k.dirtyFields)&&d.shouldDirty&&(X(),m||A.state.next({name:i,dirtyFields:t.dirtyFields,isDirty:j(i,v)}));else{const ee=Array.isArray(v)&&!v.length||Y(v);!x||x._f||Q(v)||ee?Ne(i,v,d,f,m):h(i,v,d,f,m)}if(!U&&!m){const ee=et(i,u),xe=f?c:B(c);A.state.next({...ee&&t,name:o.mount||ee?i:void 0,values:xe})}},J=(i,l,d={})=>I(i,l,d,!1),ne=(i,l={})=>{const d=le(i)?i(c):i;if(!me(c,d)){c={...c,...d};const f=xs(d);for(const m of u.mount)m in f&&I(m,f[m],l,!0,!0);A.state.next({...t,name:void 0,type:void 0,...T?{values:c}:{}}),l.shouldValidate&&C()}},ge=async i=>{o.mount=!0;const l=i.target;let d=l.name,f=!0;const m=y(a,d),x=g=>{f=Number.isNaN(g)||we(g)&&isNaN(g.getTime())||me(g,y(c,d,g))};if(m){let g,v;const N=l.type?Gt(m._f):Fr(i),U=i.type===Ce.BLUR||i.type===Ce.FOCUS_OUT,ee=!Yr(m._f)&&!e.validate&&!s.resolver&&!y(t.errors,d)&&!m._f.deps,xe=ee||Xr(U,y(t.touchedFields,d),t.isSubmitted,H,_),ye=et(d,u,U);if(O(c,d,N),U){if(!l||!l.readOnly){m._f.onBlur&&m._f.onBlur(i);const Ie=b[d];Ie&&Ie(0)}}else m._f.onChange&&m._f.onChange(i);const Re=F(d,N,U),Ds=!Y(Re)||ye;if(!U&&A.state.next({name:d,type:i.type,...T?{values:B(c)}:{}}),xe)return(!ee||!t.isValid)&&(S.isValid||k.isValid)&&(s.mode==="onBlur"?U&&C():U||C()),Ds&&A.state.next({name:d,...ye?{}:Re});if(!s.resolver&&e.validate&&await K({name:d,eventType:i.type}),!U&&ye&&A.state.next({...t}),s.resolver){const{errors:Ie}=await R([d]);if(E([d]),x(N),!f){!Y(Re)&&A.state.next(Re);return}const Fs=Yt(t.errors,a,d),Et=Yt(Ie,a,Fs.name||d);g=Et.error,d=Et.name,v=Y(Ie)}else E([d],!0),g=(await qt(m,u.disabled,c,V,s.shouldUseNativeValidation))[d],E([d]),x(N),f&&(g?v=!1:(S.isValid||k.isValid)&&(v=await G({fields:a,onlyCheckValid:!0,name:d,eventType:i.type})));f&&(m._f.deps&&(!Array.isArray(m._f.deps)||m._f.deps.length>0)&&Ee(m._f.deps),D(d,v,g,Re))}},Se=(i,l)=>{if(y(t.errors,l)&&i.focus)return i.focus(),1},Ee=async(i,l={})=>{let d,f;const m=qe(i);if(s.resolver){const x=await $(L(i)?i:m);d=Y(x),f=i?!m.some(g=>y(x,g)):d}else i?(f=(await Promise.all(m.map(async x=>{const g=y(a,x);return await G({fields:g&&g._f?{[x]:g}:g,eventType:Ce.TRIGGER})}))).every(Boolean),!(!f&&!t.isValid)&&C()):f=d=await G({fields:a,name:i,eventType:Ce.TRIGGER});if(l.delayError&&s.delayError&&Z(i)){const x=y(t.errors,i);x?(q(t.errors,i),b[i]=P(i,()=>ae(i,x)),b[i](s.delayError)):(clearTimeout(w[i]),delete b[i])}return A.state.next({...!Z(i)||(S.isValid||k.isValid)&&d!==t.isValid?{}:{name:i},...s.resolver||!i?{isValid:d}:{},errors:t.errors}),l.shouldFocus&&!f&&Le(a,Se,i?m:u.mount),f},Fe=(i,l)=>{let d={...o.mount?c:n};return l&&(d=ys(l.dirtyFields?t.dirtyFields:t.touchedFields,d)),L(i)?d:Z(i)?y(d,i):i.map(f=>y(d,f))},bt=(i,l)=>({invalid:!!y((l||t).errors,i),isDirty:!!y((l||t).dirtyFields,i),error:y((l||t).errors,i),isValidating:!!y(t.validatingFields,i),isTouched:!!y((l||t).touchedFields,i)}),St=i=>{const l=i?qe(i):void 0;l?.forEach(d=>q(t.errors,d)),l?l.forEach(d=>{A.state.next({name:d,errors:t.errors})}):A.state.next({errors:{}})},ze=(i,l,d)=>{const f=(y(a,i,{_f:{}})._f||{}).ref,m=y(t.errors,i)||{},{ref:x,message:g,type:v,...N}=m;O(t.errors,i,{...N,...l,ref:f}),A.state.next({name:i,errors:t.errors,isValid:!1}),d&&d.shouldFocus&&f&&f.focus&&f.focus()},ks=(i,l)=>{if(le(i)){T++;const{unsubscribe:d}=A.state.subscribe({next:m=>"values"in m&&i(m.values||ie(void 0,l),m)});let f=!1;return{unsubscribe:()=>{f||(f=!0,T--,d())}}}return ie(i,l,!0)},jt=i=>{var l;const d=!!(!((l=i.formState)===null||l===void 0)&&l.values);d&&T++;const{unsubscribe:f}=A.state.subscribe({next:x=>{if(Zr(i.name,x.name,i.exact)&&Qr(x,i.formState||S,Ps,i.reRenderRoot)){const g={...c};i.callback({values:g,...t,...x,defaultValues:n})}}});if(!d)return f;let m=!1;return()=>{m||(m=!0,T--,f())}},Es=i=>(o.mount=!0,k={...k,...i.formState},jt({...i,formState:{...p,...i.formState}})),Ze=(i,l={})=>{for(const d of i?qe(i):u.mount)u.mount.delete(d),u.array.delete(d),l.keepValue||(q(a,d),q(c,d)),!l.keepError&&q(t.errors,d),!l.keepDirty&&q(t.dirtyFields,d),!l.keepTouched&&q(t.touchedFields,d),!l.keepIsValidating&&q(t.validatingFields,d),!s.shouldUnregister&&!l.keepDefaultValue&&q(n,d);A.state.next({values:B(c)}),A.state.next({...t,...l.keepDirty?{isDirty:j()}:{}}),!l.keepIsValid&&C()},wt=({disabled:i,name:l})=>{if(fe(i)&&o.mount||i||u.disabled.has(l)){const m=u.disabled.has(l)!==!!i;i?u.disabled.add(l):u.disabled.delete(l),m&&o.mount&&!o.action&&C()}},Xe=(i,l={})=>{let d=y(a,i);const f=fe(l.disabled)||fe(s.disabled),m=!u.registerName.has(i)&&d&&d._f&&!d._f.mount;return O(a,i,{...d||{},_f:{...d&&d._f?d._f:{ref:{name:i}},name:i,mount:!0,...l}}),u.mount.add(i),d&&!m?wt({disabled:fe(l.disabled)?l.disabled:s.disabled,name:i}):pe(i,!0,l.value),{...f?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Oe(l.min),max:Oe(l.max),minLength:Oe(l.minLength),maxLength:Oe(l.maxLength),pattern:Oe(l.pattern)}:{},name:i,onChange:ge,onBlur:ge,ref:x=>{if(x){u.registerName.add(i),Xe(i,l),u.registerName.delete(i),d=y(a,i);const g=L(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=qr(g),N=d._f.refs||[];if(v?N.find(U=>U===g):g===d._f.ref)return;O(a,i,{_f:{...d._f,...v?{refs:[...N.filter(tt),g,...Array.isArray(y(n,i))?[{}]:[]],ref:{type:g.type,name:i}}:{ref:g}}}),pe(i,!1,void 0,g)}else d=y(a,i,{}),d._f&&(d._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(Rr(u.array,i)&&o.action)&&u.unMount.add(i)}}},Je=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(a,Se,u.mount),Cs=i=>{fe(i)&&(A.state.next({disabled:i}),Le(a,(l,d)=>{const f=y(a,d);f&&(l.disabled=f._f.disabled||i,Array.isArray(f._f.refs)&&f._f.refs.forEach(m=>{m.disabled=f._f.disabled||i}))},0,!1))},Nt=(i,l)=>async d=>{let f;d&&(d.preventDefault&&d.preventDefault(),d.persist&&d.persist());let m=B(c);if(A.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await R();E(),t.errors=x,m=B(g)}else await G({fields:a,eventType:Ce.SUBMIT});if(u.disabled.size)for(const x of u.disabled)q(m,x);if(q(t.errors,ms),Y(t.errors)){A.state.next({errors:{}});try{await i(m,d)}catch(x){f=x}}else l&&await l({...t.errors},d),Je(),setTimeout(Je);if(A.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Y(t.errors)&&!f,submitCount:t.submitCount+1,errors:t.errors}),f)throw f},_s=(i,l={})=>{y(a,i)&&(L(l.defaultValue)?J(i,B(y(n,i))):(J(i,l.defaultValue),O(n,i,B(l.defaultValue))),l.keepTouched||q(t.touchedFields,i),l.keepDirty||(q(t.dirtyFields,i),t.isDirty=l.defaultValue?j(i,B(y(n,i))):j()),l.keepError||(q(t.errors,i),S.isValid&&C()),A.state.next({...t}))},At=(i,l={})=>{const d=i?B(i):n,f=B(d),m=Y(i),x=f,g=a;if(l.keepDefaultValues||(n=d),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Te(n,c,void 0,g))]);for(const N of Array.from(v)){const U=y(t.dirtyFields,N),ee=y(c,N),xe=y(x,N);U&&!L(ee)?O(x,N,ee):!U&&!L(xe)&&J(N,xe)}}else{if(Ye&&L(i))for(const v of u.mount){const N=y(a,v);if(N&&N._f){const U=Array.isArray(N._f.refs)?N._f.refs[0]:N._f.ref;if(We(U)){const ee=U.closest("form");if(ee){ee.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)J(v,y(x,v));else a={}}if(s.shouldUnregister){if(c=l.keepDefaultValues?B(n):{},l.keepFieldsRef)for(const v of u.mount)O(c,v,y(x,v))}else c=B(x);A.array.next({values:{...x}}),A.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:""},o.mount=!S.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!Y(x),o.watch=!!s.shouldUnregister,o.keepIsValid=!!l.keepIsValid,o.action=!1,l.keepErrors||(t.errors={}),A.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:m?!1:l.keepDirty?t.isDirty:l.keepValues?j():!!(l.keepDefaultValues&&!me(i,n)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:m?{}:l.keepDirtyValues?l.keepDefaultValues&&c?Te(n,c,void 0,g):t.dirtyFields:l.keepDefaultValues&&i?Te(n,i,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:n})},Tt=(i,l)=>At(le(i)?i(c):i,{...s.resetOptions,...l}),Vs=(i,l={})=>{const d=y(a,i),f=d&&d._f;if(f){const m=f.refs?f.refs[0]:f.ref;m.focus&&setTimeout(()=>{m.focus(),l.shouldSelect&&le(m.select)&&m.select()})}},Ps=i=>{const{name:l,type:d,values:f,...m}=i;t={...t,...m}},kt={control:{register:Xe,unregister:Ze,getFieldState:bt,handleSubmit:Nt,setError:ze,_subscribe:jt,_runSchema:R,_updateIsValidating:E,_focusError:Je,_getWatch:ie,_getDirty:j,_setValid:C,_setFieldArray:W,_setDisabledField:wt,_setErrors:re,_getFieldArray:ke,_reset:At,_resetDefaultValues:()=>le(s.defaultValues)&&s.defaultValues().then(i=>{Tt(i,s.resetOptions),A.state.next({isLoading:!1})}),_removeUnmounted:be,_disableForm:Cs,_subjects:A,_proxyFormState:S,get _fields(){return a},get _formValues(){return c},get _state(){return o},set _state(i){o=i},get _defaultValues(){return n},get _names(){return u},set _names(i){u=i},get _formState(){return t},get _options(){return s},set _options(i){s={...s,...i},_=Be(s.mode),H=Be(s.reValidateMode)}},subscribe:Es,trigger:Ee,register:Xe,handleSubmit:Nt,watch:ks,setValue:J,setValues:ne,getValues:Fe,reset:Tt,resetField:_s,resetDefaultValues:(i,l={})=>{if(n=B(i),!l.keepDirty){const d=Te(n,c,void 0,a);t.dirtyFields=d,t.isDirty=!Y(d)}l.keepIsValid||C(),A.state.next({...t,defaultValues:n})},clearErrors:St,unregister:Ze,setError:ze,setFocus:Vs,getFieldState:bt};return{...kt,formControl:kt}}function si(e={}){const s=te.useRef(void 0),t=te.useRef(void 0),a=te.useRef(e.formControl),[n,c]=te.useState(()=>({...B(Ns),isLoading:le(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:le(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&a.current!==e.formControl)if(a.current=e.formControl,e.formControl)s.current={...e.formControl,formState:n},e.defaultValues&&!le(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...b}=ti(e);s.current={...b,formState:n}}const o=s.current.control;return o._options=e,Ur(()=>{const u=o._subscribe({formState:o._proxyFormState,callback:()=>c({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return c(b=>({...b,isReady:!0})),o._formState.isReady=!0,u},[o]),te.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),te.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),te.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),te.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),te.useEffect(()=>{if(o._proxyFormState.isDirty){const u=o._getDirty();u!==n.isDirty&&o._subjects.state.next({isDirty:u})}},[o,n.isDirty]),te.useEffect(()=>{var u;e.values&&!me(e.values,t.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((u=o._options.resetOptions)===null||u===void 0)&&u.keepIsValid||o._setValid(),t.current=e.values,c(b=>({...b}))):o._resetDefaultValues()},[o,e.values]),te.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=te.useMemo(()=>Lr(n,o),[o,n]),s.current}const Qt=(e,s,t)=>{if(e&&"reportValidity"in e){const a=y(t,s);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},dt=(e,s)=>{for(const t in s.fields){const a=s.fields[t];a&&a.ref&&"reportValidity"in a.ref?Qt(a.ref,t,e):a&&a.refs&&a.refs.forEach(n=>Qt(n,t,e))}},Zt=(e,s)=>{s.shouldUseNativeValidation&&dt(e,s);const t={};for(const a in e){const n=y(s.fields,a),c=Object.assign(e[a]||{},{ref:n&&n.ref});if(ri(s.names||Object.keys(e),a)){const o=Object.assign({},y(t,a));O(o,"root",c),O(t,a,o)}else O(t,a,c)}return t},ri=(e,s)=>{const t=Xt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(a=>Xt(a).match(`^${t}\\.\\d+`))};function Xt(e){return e.replace(/[\[\]]/g,"")}function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var a in t)({}).hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},ut.apply(null,arguments)}function Jt(e,s){try{var t=e()}catch(a){return s(a)}return t&&t.then?t.then(void 0,s):t}function ii(e,s){for(var t={};e.length;){var a=e[0],n=a.code,c=a.message,o=a.path.join(".");if(!t[o])if("unionErrors"in a){var u=a.unionErrors[0].errors[0];t[o]={message:u.message,type:u.code}}else t[o]={message:c,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(T){return T.errors.forEach(function(_){return e.push(_)})}),s){var b=t[o].types,w=b&&b[a.code];t[o]=vt(o,s,t,n,w?[].concat(w,a.message):a.message)}e.shift()}return t}function ai(e,s){for(var t={},a=function(){var n=e[0],c=n.code,o=n.message,u=n.path.join(".");if(!t[u])if(n.code==="invalid_union"&&n.errors.length>0){var b=n.errors[0][0];t[u]={message:b.message,type:b.code}}else t[u]={message:o,type:c};if(n.code==="invalid_union"&&n.errors.forEach(function(_){return _.forEach(function(H){return e.push(ut({},H,{path:[].concat(n.path,H.path)}))})}),s){var w=t[u].types,T=w&&w[n.code];t[u]=vt(u,s,t,c,T?[].concat(T,n.message):n.message)}e.shift()};e.length;)a();return t}function ni(e,s,t){if(t===void 0&&(t={}),(function(a){return"_def"in a&&typeof a._def=="object"&&"typeName"in a._def})(e))return function(a,n,c){try{return Promise.resolve(Jt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](a,s)).then(function(o){return c.shouldUseNativeValidation&&dt({},c),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return Array.isArray(u?.issues)})(o))return{values:{},errors:Zt(ii(o.errors,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw o}))}catch(o){return Promise.reject(o)}};if((function(a){return"_zod"in a&&typeof a._zod=="object"})(e))return function(a,n,c){try{return Promise.resolve(Jt(function(){return Promise.resolve((t.mode==="sync"?zs:$s)(e,a,s)).then(function(o){return c.shouldUseNativeValidation&&dt({},c),{errors:{},values:t.raw?Object.assign({},a):o}})},function(o){if((function(u){return u instanceof Bs})(o))return{values:{},errors:Zt(ai(o.issues,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const oi=e=>{const s=Ke(),{pushError:t}=qs(),{data:a}=ns({...os(),staleTime:1/0}),n=a?.accounts.find(b=>b.accountId===e)?.composeLanguages,c=M.useMemo(()=>n&&n.length>0?[...n]:Ws(navigator.languages),[n]),o=he({...ht(),onSuccess:()=>{s.invalidateQueries({queryKey:je()})},onError:b=>{t(Gs("Couldn't save languages","The writing languages weren't saved.",b))}}),u=M.useCallback(b=>{e&&o.mutate({path:{accountId:e},body:{composeLanguages:b}})},[e,o]);return{languages:c,setLanguages:u,isSaving:o.isPending}},li=e=>e.authType==="oauthMicrosoft",ci=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},di=Zs({email:Xs(),displayName:Ae().optional(),username:Ae().optional(),password:Ae().optional(),imapHost:Ae().min(1,"IMAP host is required"),imapPort:Ot().int().min(1).max(65535),imapTls:Me(),imapStartTls:Me(),smtpHost:Ae().optional(),smtpPort:Ot().int().min(1).max(65535).optional(),smtpTls:Me().optional(),smtpStartTls:Me().optional(),smtpUsername:Ae().optional(),smtpPassword:Ae().optional(),useDifferentSmtpCreds:Me().optional()}),ui=({isOpen:e,onClose:s,account:t,focusSmtp:a})=>{const n=Ke(),c=!!t,[o,u]=M.useState(""),[b,w]=M.useState(!1),T=Ft(o),_=!!T&&!b,H=M.useRef(null),p=si({resolver:ni(di),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});M.useEffect(()=>{if(t){const h=ci(t);p.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:"",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})}else p.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1})},[t,p]);const S=he({...Ks()}),k=he({...Ys(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),A=he({...ht(),onSuccess:()=>{n.invalidateQueries({queryKey:je()}),s()}}),oe=()=>{const h=p.getValues(),I=c&&!h.password;S.mutate({body:{accountId:I?t?.accountId:void 0,username:h.username||h.email,password:I?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},V=()=>{const h=p.getValues(),I=c&&!h.password;S.mutate({body:{accountId:I?t?.accountId:void 0,username:h.username||h.email,password:I?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}})},P=p.handleSubmit(h=>{if(!c&&!h.password){p.setError("password",{message:"Password is required"});return}const I=vr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});I&&(p.setValue("smtpHost",I.smtpHost),p.setValue("smtpPort",I.smtpPort),p.setValue("smtpTls",I.smtpTls),p.setValue("smtpStartTls",I.smtpStartTls));const J=I?.smtpHost??h.smtpHost,ne=I?.smtpPort??h.smtpPort,ge=I?.smtpTls??h.smtpTls,Se=I?.smtpStartTls??h.smtpStartTls,Ee={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:J||void 0,smtpPort:ne?Number(ne):void 0,smtpTls:ge,smtpStartTls:Se,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(c&&t){const Fe={...Ee,password:h.password||void 0};A.mutate({path:{accountId:t.accountId},body:Fe})}else{const Fe={...Ee,password:h.password};k.mutate({body:Fe})}}),C=k.isPending||A.isPending,{signature:E,setSignature:X,isSaving:W}=yr(t?.accountId),[ae,re]=M.useState(E.plainText),{languages:ce,setLanguages:pe,isSaving:F}=oi(t?.accountId),D=r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),r.jsx(Pr,{value:ce,onChange:pe,busy:F})]});M.useEffect(()=>{re(E.plainText)},[E.plainText]),M.useEffect(()=>{if(!e||!a)return;const h=H.current;if(!h)return;const I=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(I)},[e,a]);const R=M.useCallback(()=>{ae!==E.plainText&&X(ae,ae)},[ae,E.plainText,X]),$=h=>{const{tls:I,startTls:J}=$e(h);p.setValue("imapTls",I),p.setValue("imapStartTls",J);const ne=p.getValues("imapPort");(ne===993||ne===143)&&p.setValue("imapPort",h==="tls"?993:143)},K=h=>{const{tls:I,startTls:J}=$e(h);p.setValue("smtpTls",I),p.setValue("smtpStartTls",J);const ne=p.getValues("smtpPort");if(ne===465||ne===587||ne===25){const Se=h==="tls"?465:h==="starttls"?587:25;p.setValue("smtpPort",Se)}},G=()=>{const h=p.getValues("imapHost");p.setValue("smtpHost",br(h)),p.setValue("smtpTls",!1),p.setValue("smtpStartTls",!0),p.setValue("smtpPort",587)},be=h=>{u(h),w(!1);const I=Ft(h);if(!I)return;const J=$e(I.imap.security);p.setValue("imapHost",I.imap.host),p.setValue("imapPort",I.imap.port),p.setValue("imapTls",J.tls),p.setValue("imapStartTls",J.startTls);const ne=$e(I.smtp.security);p.setValue("smtpHost",I.smtp.host),p.setValue("smtpPort",I.smtp.port),p.setValue("smtpTls",ne.tls),p.setValue("smtpStartTls",ne.startTls);const ge=p.getValues("email").trim(),Se=p.getValues("username")?.trim();ge&&!Se&&p.setValue("username",ge)},j=T?.passwordHelp.text,ie=It(S.data?.imapError,j),ke=It(S.data?.smtpError,j);return(t?li(t):!1)&&c?r.jsx(Mt,{isOpen:e,onClose:s,title:"Edit Account",footer:r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),r.jsx("span",{className:"text-fg",children:t?.email})]}),r.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[r.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),r.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),r.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),c&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-view",value:ae,onChange:h=>re(h.target.value),onBlur:R,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),c&&D]})}):r.jsx(Mt,{isOpen:e,onClose:s,title:c?"Edit Account":"Add Account",footer:r.jsxs(r.Fragment,{children:[r.jsx(se,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),r.jsx(se,{type:"submit",form:"account-form",variant:"primary",disabled:C,children:C?"Saving...":"Save Account"})]}),children:r.jsxs("form",{id:"account-form",onSubmit:P,className:"space-y-6",children:[r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),r.jsxs(Qs,{id:"account-provider",value:o,onChange:h=>be(h.target.value),children:[r.jsx("option",{value:"",children:"Custom / other"}),ur.map(h=>r.jsx("option",{value:h.id,children:h.label},h.id))]}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),r.jsx(ve,{id:"account-email",...p.register("email"),placeholder:"alice@example.com"}),p.formState.errors.email&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.email.message})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),r.jsx(ve,{id:"account-displayName",...p.register("displayName"),placeholder:"Alice"}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),r.jsx(ve,{id:"account-username",...p.register("username"),placeholder:"Same as email if empty"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),r.jsx(Ct,{id:"account-password",...p.register("password"),placeholder:c?"Leave empty to keep current":""}),p.formState.errors.password&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.password.message}),T&&r.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[T.passwordHelp.text," ",r.jsx("a",{href:T.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),T&&r.jsx("button",{type:"button",onClick:()=>w(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:b?"Use preset settings":"Advanced"})]}),_&&r.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",T?.label," and locked. Choose Advanced to edit them by hand."]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"imap-host",...p.register("imapHost"),readOnly:_,placeholder:"imap.example.com"}),p.formState.errors.imapHost&&r.jsx("p",{className:"text-sm text-danger mt-1",children:p.formState.errors.imapHost.message})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"imap-port",...p.register("imapPort"),readOnly:_,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:p.watch("imapTls"),onChange:()=>$("tls")}),"TLS (Port 993)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("imapTls")&&p.watch("imapStartTls"),onChange:()=>$("starttls")}),"STARTTLS (Port 143)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("imapTls")&&!p.watch("imapStartTls"),onChange:()=>$("none")}),"None (Unencrypted)"]})]})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:oe,disabled:S.isPending,className:"w-full",icon:S.isPending?r.jsx(rt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test IMAP Connection"}),S.data&&r.jsxs("div",{className:Pe("p-2 rounded-md text-sm",S.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.imapSuccess?r.jsx(_t,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),S.data.imapSuccess?"IMAP Connected":ie]})]})]}),r.jsxs("section",{ref:H,"data-testid":"smtp-section",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!_&&r.jsx("button",{type:"button",onClick:G,disabled:!p.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),r.jsx(ve,{id:"smtp-host",...p.register("smtpHost"),readOnly:_,placeholder:"smtp.example.com"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),r.jsx(ve,{id:"smtp-port",...p.register("smtpPort"),readOnly:_,type:"number"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),r.jsxs("div",{className:"space-y-1.5 mt-2",children:[r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:p.watch("smtpTls")===!0,onChange:()=>K("tls")}),"TLS (Port 465)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("smtpTls")&&p.watch("smtpStartTls")===!0,onChange:()=>K("starttls")}),"STARTTLS (Port 587)"]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"radio",disabled:_,checked:!p.watch("smtpTls")&&!p.watch("smtpStartTls"),onChange:()=>K("none")}),"None (Unencrypted)"]})]})]})]}),r.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[r.jsx("input",{type:"checkbox",...p.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),p.watch("useDifferentSmtpCreds")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),r.jsx(ve,{id:"smtp-username",...p.register("smtpUsername")})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),r.jsx(Ct,{id:"smtp-password",...p.register("smtpPassword")})]})]}),r.jsx(se,{type:"button",variant:"secondary",onClick:V,disabled:S.isPending||!p.watch("smtpHost"),className:"w-full",icon:S.isPending?r.jsx(rt,{className:"size-4 animate-spin"}):void 0,children:S.isPending?"Testing...":"Test SMTP Connection"}),S.data?.smtpSuccess!==void 0&&r.jsxs("div",{className:Pe("p-2 rounded-md text-sm",S.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[S.data.smtpSuccess?r.jsx(_t,{className:"inline size-4 mr-1"}):r.jsx(De,{className:"inline size-4 mr-1"}),S.data.smtpSuccess?"SMTP Connected":ke]})]})]}),c&&r.jsxs("section",{children:[r.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),r.jsx("div",{className:"space-y-3",children:r.jsxs("div",{children:[r.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),r.jsx("textarea",{id:"email-sig-edit",value:ae,onChange:h=>re(h.target.value),onBlur:R,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),r.jsx("p",{className:"text-xs text-fg-muted mt-1",children:W?"Saving signature...":"This signature will be appended to new emails."})]})})]}),c&&D]})})},fi="https://graph.microsoft.com/",mi={[it.Mail]:["https://outlook.office.com/IMAP.AccessAsUser.All","https://outlook.office.com/SMTP.Send"],[it.Calendar]:[`${fi}Calendars.Read`]},hi=e=>{const s=new Set(e.map(t=>t.toLowerCase()));return Object.values(it).filter(t=>mi[t].every(a=>s.has(a.toLowerCase())))},ft=e=>`Couldn't turn ${e.service.toLowerCase()} ${e.intent}`,pi=e=>Js(er({title:`Bug: ${ft(e)}`,errorMessage:`${ft(e)} — ${e.message}`}));function gi({providerName:e,offered:s,enabled:t,consented:a,disabled:n,refusal:c,onRequestChange:o}){return s.length<2?null:r.jsxs("section",{className:"space-y-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[r.jsx(_r,{providerName:e,offered:s,enabled:t,consented:a,disabled:n,onRequestChange:o}),c&&r.jsxs(at,{tone:"danger",variant:"soft",children:[r.jsx("p",{className:"font-medium",children:ft(c)}),r.jsx("p",{className:"mt-0.5 break-words text-fg-muted",children:c.message}),r.jsx("a",{href:pi(c),target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-block font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const As=["Mail","Calendar"],es="Microsoft",ts=e=>e.authType==="oauthMicrosoft",ss=(e,s)=>As.filter(t=>t===s||e.includes(t));function xi({account:e,onRemoveAccount:s}){const t=Ke(),[a,n]=M.useState(null),[c,o]=M.useState(null),[u,b]=M.useState(null),w=he({...ht(),meta:Vt,onSuccess:()=>t.invalidateQueries({queryKey:je()})}),T=he({...ls(),meta:Vt}),_=ds(P=>{const C=u;b(null),!(P!=="stalled"||C===null)&&o({service:C,intent:"on",message:us})}),H=w.isPending&&w.variables?.body.syncedServices?w.variables.body.syncedServices:e.syncedServices,p=ts(e)?As:["Mail"],S=ts(e)?hi(e.grantedScopes):p,k=(P,C,E)=>{o(null),w.mutate({path:{accountId:e.accountId},body:{syncedServices:P}},{onError:X=>o({service:C,intent:E,message:Rt(X)})})},A=P=>{o(null),T.mutate({body:{email:e.email,services:ss(H,P)}},{onSuccess:C=>{b(P),_(),window.location.assign(C.authorizationUrl)},onError:C=>o({service:P,intent:"on",message:Rt(C)})})},oe=(P,C)=>{if(C==="off"){n({kind:H.length===1?"last":"disable",service:P});return}if(!S.includes(P)){n({kind:"enable",service:P});return}k(ss(H,P),P,"on")},V=()=>{const P=a;if(n(null),P!==null){if(P.kind==="last"){s();return}if(P.kind==="enable"){A(P.service);return}k(H.filter(C=>C!==P.service),P.service,"off")}};return r.jsxs(r.Fragment,{children:[r.jsx(gi,{providerName:es,offered:p,enabled:H,consented:S,disabled:w.isPending||T.isPending||u!==null,refusal:c,onRequestChange:oe}),r.jsx(Er,{change:a,providerName:es,onConfirm:V,onCancel:()=>n(null)})]})}function rs({open:e,onClose:s,accountEmail:t,signOut:a}){const[n,c]=M.useState(""),[o,u]=M.useState(!1),[b,w]=M.useState(!1),T=he({...sr(),onSuccess:()=>{w(!0),setTimeout(()=>a(),2e3)}}),_=he(rr()),H=()=>{T.isPending||(c(""),u(!1),w(!1),T.reset(),_.reset(),s())},p=()=>{if(n.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),T.mutate({body:{confirmEmail:n.trim()}})};return r.jsxs(cs,{open:e,onClose:H,title:"Delete your Remit account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(mt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:H,"aria-label":"Cancel"})]}),b?r.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[r.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),r.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),r.jsxs("ul",{className:"space-y-1.5 text-xs",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),r.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[r.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),r.jsxs("div",{className:"text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>_.mutate({}),"aria-busy":_.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[r.jsx(jr,{className:"size-3.5"}),_.isPending?"Requesting export…":"Export my data first"]}),_.isSuccess&&r.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),_.isError&&r.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",r.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),r.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:n,onChange:S=>{c(S.target.value),o&&u(!1),T.isError&&T.reset()},autoComplete:"off"}),o&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),T.isError&&r.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:T.error instanceof Error?T.error.message:"Something went wrong. Please try again."})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:H,children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm",onClick:p,"aria-busy":T.isPending,children:T.isPending?"Deleting…":"Delete everything"})]})]})]})}function yi(e){const{Account:s}=tr();return r.jsx(s,{fallback:r.jsx(rs,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:a})=>r.jsx(rs,{...e,accountEmail:t??"",signOut:a})})}function vi(){const[e,s]=M.useState(!1);return r.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[r.jsx(Dr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:r.jsx(se,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),r.jsx(yi,{open:e,onClose:()=>s(!1)})]})}function Ts(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="scope_not_granted"?"Microsoft did not grant access to every service you picked. Sign in again and accept each permission Microsoft asks for.":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.`}const bi=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"";function Si(e,s){const t=(e.missingServices??"").split(","),a=nt.filter(w=>t.includes(w.id)),n=e.oauthEmail,c=n?s.find(w=>w.authType==="oauthMicrosoft"&&w.email.toLowerCase()===n.toLowerCase()):void 0,o=bi(a.map(w=>w.label)),u=a.length===0?Ts("scope_not_granted"):`Microsoft did not grant access to ${o}. Sign in again and accept the ${o} ${a.length>1?"permissions":"permission"} when Microsoft asks.`,b=c?nt.filter(w=>c.syncedServices.includes(w.id)||a.some(T=>T.id===w.id)).map(w=>w.id):void 0;return{kind:"refused",message:u,email:n,services:b,reconnect:!!c}}function ji(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function wi(e){const s=e.displayName?.trim();return s||ji(e.email)}function Ni(e){if(!e.lastSyncAt)return"never synced";const s=dr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function is(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function as(e){return e.connectionState==="reauth_required"}function Ai(e){return e.connectionState==="credentials_missing"}const Ti=()=>r.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>r.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function Gi(){const e=Pt.useSearch(),s=ir({from:Pt.fullPath}),[t,a]=M.useState(!0),[n,c]=M.useState(!1),[o,u]=M.useState(!1),[b,w]=M.useState(void 0),[T,_]=M.useState(null),[H,p]=M.useState(!1),[S,k]=M.useState(null),[A,oe]=M.useState(null),[V,P]=M.useState(null),[C,E]=M.useState(null),X=Ke(),{data:W,isPending:ae,isError:re,error:ce,refetch:pe}=ns(os());M.useEffect(()=>{e.editAccountId&&(_(e.editAccountId),p(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError,oauthEmail:e.oauthEmail,missingServices:e.missingServices},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError,e.oauthEmail,e.missingServices]),M.useEffect(()=>{e.connected&&(w({kind:"connected",accountId:e.connected}),u(!0),X.invalidateQueries({queryKey:je()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,X]),M.useEffect(()=>{if(!e.oauthError)return;const j=e.oauthError==="scope_not_granted";j&&!W&&!re||(E(null),j?(w(Si({oauthEmail:e.oauthEmail,missingServices:e.missingServices},W?.accounts??[])),u(!0)):P(Ts(e.oauthError)),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,e.oauthEmail,e.missingServices,W,re,s]),xr(C!==null,()=>{X.invalidateQueries({queryKey:je()})}),M.useEffect(()=>{if(!C||!W)return;const j=W.accounts.find(ie=>ie.accountId===C);(!j||!as(j))&&E(null)},[W,C]);const F=ds(j=>{E(null),j==="stalled"&&P(us)}),D=he({...ls(),onSuccess:j=>{F(),window.location.assign(j.authorizationUrl)},onError:j=>{P(j instanceof Error?j.message:"Failed to start reconnect"),E(null)}}),R=he({...ar(),onSuccess:()=>{X.invalidateQueries({queryKey:je()}),k(null)}}),$=W?.accounts.find(j=>j.accountId===S),K=W?.accounts.find(j=>j.accountId===T),G=()=>{c(!1),u(!1),_(null),p(!1)},be=j=>{const ie=lr[j];ie&&s({to:ie})};return r.jsxs(pr,{items:nr,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:wr,helpOpen:t,onToggleHelp:()=>a(j=>!j),onSelect:be,onBackToMail:()=>{s({to:"/mail"})},children:[A&&r.jsx(at,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>oe(null),children:A}),V&&r.jsx(at,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>P(null),children:V}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(or,{tone:"neutral",children:ae||re?"accounts":`${W.accounts.length} ${W.accounts.length===1?"account":"accounts"}`}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Dt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ae?r.jsx(Ti,{}):re?r.jsx(mr,{title:"Couldn't load accounts",error:ce,onRetry:()=>{pe()}}):W.accounts.length===0?r.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[r.jsx("p",{className:"mb-3",children:"No accounts configured."}),r.jsx(se,{variant:"primary",size:"sm",icon:r.jsx(Dt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):r.jsx("div",{className:"space-y-3",children:W.accounts.map(j=>{const ie=as(j),ke=Ai(j),Ne=j.authType==="oauthMicrosoft",h=C===j.accountId,I=ie&&Ne?{label:"Reconnect",variant:"secondary",busy:h,busyLabel:"Redirecting…",onClick:()=>{E(j.accountId),D.mutate({body:{email:j.email,services:j.syncedServices}})}}:ke?{label:"Enter password",variant:"secondary",onClick:()=>_(j.accountId)}:is(j)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(j.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(j.accountId)},J=r.jsx(hr,{actions:[I],destructive:{label:"Delete account",iconOnly:!0,icon:r.jsx(cr,{className:"size-3.5"}),onClick:()=>k(j.accountId)}});return r.jsxs("div",{className:"space-y-2",children:[r.jsx(gr,{label:wi(j),email:j.email,connector:Ne?"Microsoft 365":"IMAP",syncLabel:Ni(j),state:is(j),errorDetail:ie?j.lastError??"Re-authentication required":ke?"Imported from a config file, which carries no password. Enter one to start syncing.":j.lastError,trailing:J}),r.jsx(xi,{account:j,onRemoveAccount:()=>k(j.accountId)})]},j.accountId)})}),o&&r.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:r.jsx(fr,{skipWelcome:!0,microsoftReturn:b,onComplete:()=>{b?.kind==="connected"&&oe("Account connected successfully."),u(!1),w(void 0),X.invalidateQueries({queryKey:je()})},onCancel:()=>{u(!1),w(void 0)}})}),r.jsx(ui,{isOpen:n||!!T,account:K,focusSmtp:H,onClose:G}),r.jsxs(cs,{open:!!S,onClose:()=>k(null),title:"Delete account",children:[r.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[r.jsx(mt,{className:"size-4 shrink-0 text-danger"}),r.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),r.jsx(se,{variant:"ghost",size:"sm",icon:r.jsx(De,{className:"size-3.5"}),onClick:()=>k(null),"aria-label":"Cancel"})]}),r.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[r.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),$&&r.jsx("p",{className:"text-center",children:$.email}),r.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[r.jsx("li",{children:"Remove the account from your settings"}),r.jsx("li",{children:"Stop syncing mail for this account"}),r.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),r.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[r.jsx(se,{variant:"secondary",size:"sm",onClick:()=>k(null),children:"Cancel"}),r.jsx(se,{variant:"danger",size:"sm","aria-busy":R.isPending,icon:R.isPending?r.jsx(rt,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{R.isPending||S&&R.mutate({path:{accountId:S}})},children:R.isPending?"Deleting…":"Delete account"})]})]}),r.jsx(vi,{})]})}export{Gi as component,Ts as mapOauthError,Si as scopeRefusalReturn};
@@ -1 +1 @@
1
- import{j as e,aH as T,aQ as y,d as l,aR as j,r as h,ah as u,B as S,L as g,e as k,aS as p,o as I,f as A,aT as U,aU as D,a8 as w,aV as L,aW as O,aX as B,u as E,aK as V,aM as _}from"./index-BzL5-pGT.js";import{S as M}from"./settings-screen-4md2ibPl.js";import{e as H}from"./config-import-C2ovEkHy.js";import"./reply-CQarAZxU.js";import{u as F}from"./sections-C6oVXjho.js";import{C as P,a as Y,b as G,c as J}from"./card-865cdsJK.js";import{D as N}from"./download-A4hq8dWf.js";import{F as W}from"./file-json-DiHW8YBd.js";import{E as C}from"./external-link-DaKTW3eK.js";import{R as v}from"./rotate-ccw-DPB71584.js";import{C as b}from"./circle-check-Db07NpOC.js";import{C as Q,S as q}from"./shield-check-BcUXVpR8.js";import{C as $}from"./clock-B9kFW89H.js";import{b as K}from"./help-copy-N4JgEUmu.js";import"./avatar-vPm9XfmM.js";import"./menu-CGw_RHKl.js";import"./circle-help-CVShnhWn.js";import"./useMediaQuery-7Q3jBluO.js";import"./kbd-B9MFmWVU.js";const X=["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 Z({open:s,currentVersion:n,release:a,appliesSchemaMigration:t=!1,onClose:i,onConfirm:r}){return s?e.jsx(T,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",n,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[X.map(c=>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:c})]},c)),t&&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(l,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(C,{className:"size-3.5"}),children:"Release notes"}),e.jsx(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:r,children:"Install and restart"})]})]})}):null}function o({children:s,tone:n}){return e.jsx("div",{className:I("rounded-sm border bg-surface px-row-inset py-3",n==="danger"?"border-danger/50":"border-line"),children:s})}function ee({state:s,onCheck:n,onInstall:a,onDismissResult:t,now:i=Date.now()}){const[r,c]=h.useState(null),m=s.status==="checking",d=s.status==="available",x=()=>{if(m){c("Already checking. The result appears here in a moment.");return}c(null),n()},z=()=>{t(),x()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){c("There is no update to install. Check for updates first — if one is found it appears here.");return}c(null),a()},R=(()=>{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(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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(g,{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(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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($,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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(Q,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"secondary",size:"sm",onClick:x,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(k,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(C,{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(g,{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.jsxs(e.Fragment,{children:[e.jsx(S,{tone:"success",onDismiss:t,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"}),"."]})]})}),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(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is running."]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:z,children:"Check for updates"})]})})]});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(u,{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(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,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."})]}),R,r&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:r})]})}function se({fileName:s,state:n="ready",error:a,onDownload:t,onImport:i}){const r=n==="downloading";return e.jsxs(P,{className:"max-w-xl",children:[e.jsx(Y,{children:e.jsx(G,{children:"Configuration file"})}),e.jsxs(J,{children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"One versioned JSON document carrying every setting this instance holds: accounts and their servers, folder roles, rules, labels, flagged senders and appearance. No passwords and no OAuth tokens — you sign in again wherever you import it."}),n==="failed"&&e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The config file could not be written."}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Nothing was downloaded. Try again — if it keeps failing, use"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on the host in the meantime."]}),a&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:a})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(l,{variant:"secondary",size:"sm",disabled:r,icon:r?e.jsx(g,{className:"size-3.5 animate-spin"}):e.jsx(N,{className:"size-3.5"}),onClick:t,children:r?"Preparing…":`Download ${s}`}),e.jsx(k,{tone:"neutral",children:"no passwords"})]}),e.jsxs("p",{className:"mt-3 text-2xs text-fg-subtle",children:["On the host, the same file comes from"," ",e.jsxs("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:["remit config save ~/",s]}),"."]}),e.jsxs("div",{className:"mt-5 border-t border-line pt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Import a config file"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Read a file from another Reader into this one. It shows what will change before anything is written, and asks for each account's credentials afterwards."}),e.jsx(l,{className:"mt-3",variant:"secondary",size:"sm",icon:e.jsx(W,{className:"size-3.5"}),onClick:i,children:"Import a config file"})]})]})]})}const ae=(s,n)=>{const a=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),t=document.createElement("a");t.href=a,t.download=s,t.click(),URL.revokeObjectURL(a)};function te(){const s=A(),n=F(),[a,t]=h.useState("ready"),[i,r]=h.useState(void 0),c=H(new Date),m=()=>{a!=="downloading"&&(t("downloading"),r(void 0),s.fetchQuery(U()).then(d=>{ae(c,d.document),t("ready")}).catch(d=>{t("failed"),r(d instanceof Error?d.message:"GET /config/export did not answer with a configuration.")}))};return e.jsx(se,{fileName:c,state:a,error:i,onDownload:m,onImport:()=>n("importConfig")})}function ne(){const{surface:s,release:n,currentVersion:a,appliesSchemaMigration:t,onCheck:i,install:r,onDismissResult:c}=D(),[m,d]=h.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(ee,{state:s.section,onCheck:i,onInstall:()=>d(!0),onDismissResult:c}),n&&a&&e.jsx(Z,{open:m,currentVersion:a,release:n,appliesSchemaMigration:t,onClose:()=>d(!1),onConfirm:()=>{d(!1),r(n.version)}})]})}function ie(){return w().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(j,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(q,{className:"size-3.5"}),children:"Download root certificate"})]})}function re(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 le({sha:s=O,commitUrl:n=L,buildTime:a=B}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",n?e.jsx("a",{href:n,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 ",re(a)]})]})}function Te(){const s=E(),[n,a]=h.useState(!0),t=i=>{const r=_[i];r&&s({to:r})};return e.jsxs(M,{items:V,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:K,helpOpen:n,onToggleHelp:()=>a(i=>!i),onSelect:t,onBackToMail:()=>{s({to:"/mail"})},children:[w().updateMode==="self"&&e.jsx(ne,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx(te,{})}),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 are coming in a future release."})}),e.jsx(ie,{}),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(le,{})]})]})}export{Te as component};
1
+ import{j as e,aH as T,aQ as y,d as l,aR as j,r as h,ah as u,B as S,L as g,e as k,aS as p,o as I,f as A,aT as U,aU as D,a8 as w,aV as L,aW as O,aX as B,u as E,aK as V,aM as _}from"./index-CL_fwLHN.js";import{S as M}from"./settings-screen-DBP3ABLE.js";import{e as H}from"./config-import-DmOMXQ5W.js";import"./reply-DvdgFS16.js";import{u as F}from"./sections-Rf3k05-_.js";import{C as P,a as Y,b as G,c as J}from"./card-CPL-TrL1.js";import{D as N}from"./download-SQdHw0Vd.js";import{F as W}from"./file-json-DQGozYSr.js";import{E as C}from"./external-link-BDqA_mVy.js";import{R as v}from"./rotate-ccw-CENCKp2Z.js";import{C as b}from"./circle-check-i3jeyeTf.js";import{C as Q,S as q}from"./shield-check-CdR23I2B.js";import{C as $}from"./clock-NnulNCOv.js";import{b as K}from"./help-copy-B2iT8EG_.js";import"./avatar-uWJajuSb.js";import"./menu-CcLh9Whg.js";import"./circle-help-CVWHf1ow.js";import"./useMediaQuery-DiQ0fGER.js";import"./kbd-CDJCJUnp.js";const X=["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 Z({open:s,currentVersion:n,release:a,appliesSchemaMigration:t=!1,onClose:i,onConfirm:r}){return s?e.jsx(T,{open:!0,onClose:i,title:`Install Remit ${a.version}`,children:e.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[e.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Install Remit ",a.version,"?"]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["You are on ",n,". ",a.version," was released"," ",y(a.releasedAt),"."]})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-auto px-4 py-3",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:a.summary}),e.jsxs("ul",{className:"space-y-2",children:[X.map(c=>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:c})]},c)),t&&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(l,{variant:"ghost",size:"sm",onClick:i,children:"Not now"}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:a.releaseNotesUrl,icon:e.jsx(C,{className:"size-3.5"}),children:"Release notes"}),e.jsx(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:r,children:"Install and restart"})]})]})}):null}function o({children:s,tone:n}){return e.jsx("div",{className:I("rounded-sm border bg-surface px-row-inset py-3",n==="danger"?"border-danger/50":"border-line"),children:s})}function ee({state:s,onCheck:n,onInstall:a,onDismissResult:t,now:i=Date.now()}){const[r,c]=h.useState(null),m=s.status==="checking",d=s.status==="available",x=()=>{if(m){c("Already checking. The result appears here in a moment.");return}c(null),n()},z=()=>{t(),x()},f=()=>{if(!d&&s.status!=="rolledBack"&&s.status!=="abandoned"){c("There is no update to install. Check for updates first — if one is found it appears here.");return}c(null),a()},R=(()=>{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(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is the latest version.",e.jsxs("span",{className:"text-fg-subtle",children:[" ","Checked ",p(s.checkedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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(g,{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(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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($,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["No update check has run yet. Remit checks for updates on its own in the background.",s.lastCheckedAt!==void 0&&e.jsxs("span",{className:"text-fg-subtle",children:[" ","Last checked"," ",p(s.lastCheckedAt,i),"."]})]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:x,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(Q,{className:"mt-0.5 size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm text-fg",children:"Could not reach the update source."}),e.jsx("p",{className:"text-xs text-fg-muted",children:s.reason}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You are still on ",s.version," and it keeps working.",s.lastCheckedAt!==void 0&&e.jsxs(e.Fragment,{children:[" ","Last successful check"," ",p(s.lastCheckedAt,i),"."]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(l,{variant:"secondary",size:"sm",onClick:x,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(k,{tone:"accent",children:"update available"}),e.jsxs("span",{className:"text-2xs text-fg-subtle",children:["released ",y(s.release.releasedAt)," · you are on ",s.version]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.release.summary}),e.jsx("p",{className:"text-xs text-fg-subtle",children:"Installing restarts Remit, so mail stops loading for about a minute. If the new version does not come back up, the one you are running now is restored on its own."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(l,{size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:f,children:["Install ",s.release.version]}),e.jsx(j,{variant:"secondary",size:"sm",external:!0,href:s.release.releaseNotesUrl,icon:e.jsx(C,{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(g,{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.jsxs(e.Fragment,{children:[e.jsx(S,{tone:"success",onDismiss:t,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"}),"."]})]})}),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(b,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),e.jsxs("p",{className:"text-sm text-fg",children:["Remit ",s.version," is running."]})]}),e.jsx(l,{variant:"secondary",size:"sm",className:"shrink-0",onClick:z,children:"Check for updates"})]})})]});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(u,{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(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"ghost",size:"sm",onClick:t,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(u,{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(l,{variant:"secondary",size:"sm",icon:e.jsx(v,{className:"size-3.5"}),onClick:f,children:["Try ",s.attemptedVersion," again"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:t,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."})]}),R,r&&e.jsx("p",{role:"status",className:"text-xs text-fg-muted",children:r})]})}function se({fileName:s,state:n="ready",error:a,onDownload:t,onImport:i}){const r=n==="downloading";return e.jsxs(P,{className:"max-w-xl",children:[e.jsx(Y,{children:e.jsx(G,{children:"Configuration file"})}),e.jsxs(J,{children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"One versioned JSON document carrying every setting this instance holds: accounts and their servers, folder roles, rules, labels, flagged senders and appearance. No passwords and no OAuth tokens — you sign in again wherever you import it."}),n==="failed"&&e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-danger/40 bg-danger-soft px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-danger",children:"The config file could not be written."}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Nothing was downloaded. Try again — if it keeps failing, use"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on the host in the meantime."]}),a&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:a})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(l,{variant:"secondary",size:"sm",disabled:r,icon:r?e.jsx(g,{className:"size-3.5 animate-spin"}):e.jsx(N,{className:"size-3.5"}),onClick:t,children:r?"Preparing…":`Download ${s}`}),e.jsx(k,{tone:"neutral",children:"no passwords"})]}),e.jsxs("p",{className:"mt-3 text-2xs text-fg-subtle",children:["On the host, the same file comes from"," ",e.jsxs("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:["remit config save ~/",s]}),"."]}),e.jsxs("div",{className:"mt-5 border-t border-line pt-4",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Import a config file"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Read a file from another Reader into this one. It shows what will change before anything is written, and asks for each account's credentials afterwards."}),e.jsx(l,{className:"mt-3",variant:"secondary",size:"sm",icon:e.jsx(W,{className:"size-3.5"}),onClick:i,children:"Import a config file"})]})]})]})}const ae=(s,n)=>{const a=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),t=document.createElement("a");t.href=a,t.download=s,t.click(),URL.revokeObjectURL(a)};function te(){const s=A(),n=F(),[a,t]=h.useState("ready"),[i,r]=h.useState(void 0),c=H(new Date),m=()=>{a!=="downloading"&&(t("downloading"),r(void 0),s.fetchQuery(U()).then(d=>{ae(c,d.document),t("ready")}).catch(d=>{t("failed"),r(d instanceof Error?d.message:"GET /config/export did not answer with a configuration.")}))};return e.jsx(se,{fileName:c,state:a,error:i,onDownload:m,onImport:()=>n("importConfig")})}function ne(){const{surface:s,release:n,currentVersion:a,appliesSchemaMigration:t,onCheck:i,install:r,onDismissResult:c}=D(),[m,d]=h.useState(!1);return s.status!=="ready"?null:e.jsxs(e.Fragment,{children:[e.jsx(ee,{state:s.section,onCheck:i,onInstall:()=>d(!0),onDismissResult:c}),n&&a&&e.jsx(Z,{open:m,currentVersion:a,release:n,appliesSchemaMigration:t,onClose:()=>d(!1),onConfirm:()=>{d(!1),r(n.version)}})]})}function ie(){return w().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(j,{href:"/tls-root-ca.crt",download:!0,variant:"secondary",size:"sm",icon:e.jsx(q,{className:"size-3.5"}),children:"Download root certificate"})]})}function re(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 le({sha:s=O,commitUrl:n=L,buildTime:a=B}){return e.jsxs("p",{className:"text-xs text-fg-subtle",children:["Version"," ",n?e.jsx("a",{href:n,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 ",re(a)]})]})}function Te(){const s=E(),[n,a]=h.useState(!0),t=i=>{const r=_[i];r&&s({to:r})};return e.jsxs(M,{items:V,activeId:"advanced",title:"Advanced",description:"Notification rules, export, and diagnostics.",help:K,helpOpen:n,onToggleHelp:()=>a(i=>!i),onSelect:t,onBackToMail:()=>{s({to:"/mail"})},children:[w().updateMode==="self"&&e.jsx(ne,{}),e.jsx("div",{className:"mt-6 border-t border-line pt-4",children:e.jsx(te,{})}),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 are coming in a future release."})}),e.jsx(ie,{}),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(le,{})]})]})}export{Te as component};
@@ -1 +1 @@
1
- import{u as x,r as a,a_ as g,j as e,aK as S,a$ as n,aM as y,b0 as T}from"./index-BzL5-pGT.js";import{S as b}from"./settings-screen-4md2ibPl.js";import{c as v}from"./help-copy-N4JgEUmu.js";import"./avatar-vPm9XfmM.js";import"./menu-CGw_RHKl.js";import"./circle-help-CVShnhWn.js";import"./kbd-B9MFmWVU.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(b,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,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{u as x,r as a,a_ as g,j as e,aK as S,a$ as n,aM as y,b0 as T}from"./index-CL_fwLHN.js";import{S as b}from"./settings-screen-DBP3ABLE.js";import{c as v}from"./help-copy-B2iT8EG_.js";import"./avatar-uWJajuSb.js";import"./menu-CcLh9Whg.js";import"./circle-help-CVWHf1ow.js";import"./kbd-CDJCJUnp.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(b,{items:S,activeId:"appearance",title:"Appearance",description:"Display density and colour theme — instant-apply.",help:v,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{r as a,j as h,o as u}from"./index-BzL5-pGT.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,o as u}from"./index-CL_fwLHN.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{p as N,r as n,q as k,j as a,o as g}from"./index-BzL5-pGT.js";const R=320,C="cubic-bezier(0.32, 0.9, 0.3, 1)",E=.5,P=.4,T=360;function A(s){return Math.sign(s)*Math.sqrt(Math.abs(s))*4}function L({open:s,onClose:l,children:S,label:Y,dismissLabel:y="Dismiss"}){N({id:"bottom-sheet",open:s,answers:{back:l}});const b=n.useRef(null),f=n.useRef(null),[i,M]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>M(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),j=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=n.useCallback(t=>{const e=c.current;if(!e)return;const r=t.timeStamp-e.lastT;r>0&&(e.velocity=(t.clientY-e.lastY)/r),e.lastY=t.clientY,e.lastT=t.timeStamp;const o=t.clientY-e.startY;Math.abs(o)>4&&(e.moved=!0);const I=o<0?A(o):o;u(I)},[]),h=n.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,o=t.velocity>E||e>i*P;u(null),o&&l()},[i,l]),x=m!==null,p=s?m??0:i,d=Math.min(Math.max(1-p/i,0),1),v=x?"none":`transform ${R}ms ${C}`;return a.jsxs("div",{className:g("absolute inset-0 z-40 select-none overflow-hidden",s||x?"":"pointer-events-none"),children:[a.jsx("button",{type:"button","aria-label":y,tabIndex:-1,onClick:l,className:g("absolute inset-0 bg-black/40",d>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:d*.6,transition:v.replace("transform","opacity")}}),a.jsxs("div",{ref:b,role:"dialog","aria-modal":"true","aria-labelledby":"bottom-sheet-title","aria-hidden":!s,inert:!s,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:v},children:[a.jsx("h2",{id:"bottom-sheet-title",className:"sr-only",children:Y}),a.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),tabIndex:-1,onPointerDown:j,onPointerMove:w,onPointerUp:h,onPointerCancel:h,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:a.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),a.jsx("div",{ref:f,tabIndex:-1,className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:S})]})]})}export{L as B};
1
+ import{p as N,r as n,q as k,j as a,o as g}from"./index-CL_fwLHN.js";const R=320,C="cubic-bezier(0.32, 0.9, 0.3, 1)",E=.5,P=.4,T=360;function A(s){return Math.sign(s)*Math.sqrt(Math.abs(s))*4}function L({open:s,onClose:l,children:S,label:Y,dismissLabel:y="Dismiss"}){N({id:"bottom-sheet",open:s,answers:{back:l}});const b=n.useRef(null),f=n.useRef(null),[i,M]=n.useState(T),[m,u]=n.useState(null);k(f,s),n.useLayoutEffect(()=>{const t=b.current;if(!t)return;const e=()=>M(t.offsetHeight);e();const r=new ResizeObserver(e);return r.observe(t),()=>r.disconnect()},[]);const c=n.useRef(null),j=n.useCallback(t=>{t.currentTarget.setPointerCapture(t.pointerId),c.current={startY:t.clientY,lastY:t.clientY,lastT:t.timeStamp,velocity:0,moved:!1},u(0)},[]),w=n.useCallback(t=>{const e=c.current;if(!e)return;const r=t.timeStamp-e.lastT;r>0&&(e.velocity=(t.clientY-e.lastY)/r),e.lastY=t.clientY,e.lastT=t.timeStamp;const o=t.clientY-e.startY;Math.abs(o)>4&&(e.moved=!0);const I=o<0?A(o):o;u(I)},[]),h=n.useCallback(()=>{const t=c.current;if(c.current=null,!t)return;const e=t.lastY-t.startY,o=t.velocity>E||e>i*P;u(null),o&&l()},[i,l]),x=m!==null,p=s?m??0:i,d=Math.min(Math.max(1-p/i,0),1),v=x?"none":`transform ${R}ms ${C}`;return a.jsxs("div",{className:g("absolute inset-0 z-40 select-none overflow-hidden",s||x?"":"pointer-events-none"),children:[a.jsx("button",{type:"button","aria-label":y,tabIndex:-1,onClick:l,className:g("absolute inset-0 bg-black/40",d>0?"pointer-events-auto":"pointer-events-none"),style:{opacity:d*.6,transition:v.replace("transform","opacity")}}),a.jsxs("div",{ref:b,role:"dialog","aria-modal":"true","aria-labelledby":"bottom-sheet-title","aria-hidden":!s,inert:!s,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:v},children:[a.jsx("h2",{id:"bottom-sheet-title",className:"sr-only",children:Y}),a.jsx("div",{role:"slider","aria-label":"Drag down to dismiss","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),tabIndex:-1,onPointerDown:j,onPointerMove:w,onPointerUp:h,onPointerCancel:h,className:"flex cursor-grab touch-none justify-center pb-1 pt-2.5 active:cursor-grabbing",children:a.jsx("div",{className:"h-1 w-10 rounded-full bg-fg-subtle/40"})}),a.jsx("div",{ref:f,tabIndex:-1,className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:S})]})]})}export{L as B};
@@ -0,0 +1 @@
1
+ import{j as r,O as i}from"./index-CL_fwLHN.js";import{a as m}from"./MailShell-LIuV2C3h.js";import{B as o}from"./BriefPane-Cfl-uWfm.js";import"./reply-DvdgFS16.js";import{a as p}from"./search-token-index-B1HU1d2-.js";import{u as e}from"./search-mirror-Dri4pWEq.js";import"./useMessageBodyContent-D-LJBFh4.js";import"./FullCompose-Djp_h4BT.js";import"./ErrorState-KjDYblD5.js";import"./index-DZb7rV9A.js";import"./useSignature-BkzkUbjz.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-BTZsNKEh.js";import"./sections-Rf3k05-_.js";import"./useMediaQuery-DiQ0fGER.js";import"./confirm-dialog-q8tbS_22.js";import"./MessageBody-C89PSL_p.js";import"./kbd-CDJCJUnp.js";import"./search-scope-UI1H6AzA.js";import"./MessageToolbar-UJadqHyA.js";import"./roving-focus-FWOr5tBU.js";import"./EmptyState-BUOSmldo.js";import"./popover-menu-fjlAfNO1.js";import"./avatar-uWJajuSb.js";import"./useQueries-hChzM5ru.js";import"./undo-2-Bdx8L5xj.js";import"./download-SQdHw0Vd.js";import"./calendar-suggestion-8jcpefeR.js";import"./sparkles-Bcn4ZRhZ.js";import"./useCalendarSuggestions-D3Jza1d7.js";import"./calendar-format-BwCpz-JZ.js";import"./calendar-failure-note-BtZLcaiZ.js";import"./checkbox-CGG1nAhQ.js";import"./clock-NnulNCOv.js";import"./shield-check-CdR23I2B.js";import"./calendar-tMekVEGW.js";import"./useLayoutTier-DrLg7_rq.js";import"./menu-CcLh9Whg.js";import"./useFilters-CIuC8WLg.js";import"./useRefreshControl-B6YIG0w2.js";import"./circle-check-big-BsCwNdJZ.js";import"./refresh-cw-5OKnYRBy.js";import"./LabelApplyTrigger-oS5sxATE.js";import"./useLabels-BZFMPVjT.js";import"./wizard-selection-zWa1qc6-.js";function _(){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{_ as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-BzL5-pGT.js";import{E as t}from"./ErrorState-nA0Ptq3g.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-CL_fwLHN.js";import{E as t}from"./ErrorState-KjDYblD5.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 +1 @@
1
- import{u,a as p,c as l,r as m,j as t,A as f,O as g}from"./index-BzL5-pGT.js";import{E as d}from"./ErrorState-nA0Ptq3g.js";import{A as x}from"./AppFrame-R9FR9SH9.js";import"./reply-CQarAZxU.js";import{u as h}from"./calendar-LLRgZQzl.js";import"./roving-focus-Coea111y.js";import"./useLayoutTier-5aJYrTut.js";import"./useMediaQuery-7Q3jBluO.js";function N(){const e=u(),s=h(),{data:o,isLoading:a,isError:n,error:i,refetch:c}=p({...l(),staleTime:1/0}),r=!!(o&&(o.accounts?.length??0)===0);return m.useEffect(()=>{r&&e({to:"/onboarding",replace:!0})},[r,e]),n?t.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:t.jsx(d,{title:"Couldn't load your account",error:i,onRetry:()=>{c()}})}):t.jsx(x,{hideTabBar:s,children:a||r?t.jsx(f,{}):t.jsx(g,{})})}export{N as component};
1
+ import{u,a as p,c as l,r as m,j as t,A as f,O as g}from"./index-CL_fwLHN.js";import{E as d}from"./ErrorState-KjDYblD5.js";import{A as x}from"./AppFrame-DSPG81Mk.js";import"./reply-DvdgFS16.js";import{u as h}from"./calendar-tMekVEGW.js";import"./roving-focus-FWOr5tBU.js";import"./useLayoutTier-DrLg7_rq.js";import"./useMediaQuery-DiQ0fGER.js";function N(){const e=u(),s=h(),{data:o,isLoading:a,isError:n,error:i,refetch:c}=p({...l(),staleTime:1/0}),r=!!(o&&(o.accounts?.length??0)===0);return m.useEffect(()=>{r&&e({to:"/onboarding",replace:!0})},[r,e]),n?t.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:t.jsx(d,{title:"Couldn't load your account",error:i,onRetry:()=>{c()}})}):t.jsx(x,{hideTabBar:s,children:a||r?t.jsx(f,{}):t.jsx(g,{})})}export{N as component};
@@ -0,0 +1 @@
1
+ import{j as e,T as g,X as j,o as N,C as v,bX as C}from"./index-CL_fwLHN.js";import{P as y}from"./pencil-LSmMSKiW.js";import{M as k}from"./useCalendarSuggestions-D3Jza1d7.js";function z({failure:s,focusRef:a}){return e.jsxs("div",{ref:a,role:"alert",tabIndex:-1,className:"flex flex-col gap-2 rounded-md border border-danger/40 bg-danger-soft p-3 text-sm outline-none",children:[e.jsx("p",{className:"text-danger",children:s.text}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:s.onRetry,className:"rounded-md border border-line bg-surface px-3 py-1 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:s.retryLabel??"Try again"}),e.jsx("a",{href:s.reportHref,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-accent hover:underline",children:"Report an issue"})]})]})}const l="flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";function T({headingId:s,headingRef:a,title:n,color:o,when:c,location:r,calendarName:x,availability:m,onEdit:t,onDelete:i,deleting:u=!1,onClose:f,failure:d,failureRef:b,children:h}){const p=C(o);return e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsxs("div",{className:"flex justify-end gap-1",children:[t&&e.jsx("button",{type:"button","aria-label":"Edit",onClick:t,className:l,children:e.jsx(y,{className:"size-4"})}),i&&e.jsx("button",{type:"button","aria-label":"Delete",onClick:i,disabled:u,className:l,children:e.jsx(g,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:f,className:l,children:e.jsx(j,{className:"size-4"})})]}),e.jsxs("div",{className:"flex gap-3 px-2",children:[e.jsx("span",{className:N("mt-1.5 size-3.5 shrink-0 rounded-sm",p.solid),"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{id:s,ref:a,tabIndex:-1,className:"text-xl font-normal break-words text-fg outline-none",children:n===""?"(No title)":n}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:c})]})]}),e.jsxs("dl",{className:"flex flex-col gap-2 px-2 text-sm",children:[r!==""&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(k,{className:"size-4 text-fg-subtle","aria-label":"Location"})}),e.jsx("dd",{className:"min-w-0 break-words",children:r})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("dt",{children:e.jsx(v,{className:"size-4 text-fg-subtle","aria-label":"Calendar"})}),e.jsxs("dd",{children:[x," · ",m]})]})]}),h,d&&e.jsx(z,{failure:d,focusRef:b})]})}function E({headingId:s,onClose:a,closeRef:n}){return e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("h2",{id:s,className:"text-base font-medium text-fg",children:"This event was deleted or moved"}),e.jsx("button",{ref:n,type:"button",onClick:a,className:"self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Close"})]})}export{z as C,E as a,T as b};