@remit/web-client-dist 0.0.624 → 0.0.626

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 (167) hide show
  1. package/assets/{BriefPane-BjUmHKNU.js → BriefPane-_14jyTNU.js} +1 -1
  2. package/assets/CalendarComposePane-CvXktapf.js +1 -0
  3. package/assets/{CalendarComposeSeed-CeMPzriy.js → CalendarComposeSeed-CifBLPSk.js} +1 -1
  4. package/assets/{CalendarShell-q8nTThqJ.js → CalendarShell-CQKMfTHS.js} +1 -1
  5. package/assets/{EmptyState-DxHRPzWP.js → EmptyState-DFn4LB7J.js} +1 -1
  6. package/assets/{ErrorState-B7NbYqTc.js → ErrorState-wz9YaOol.js} +1 -1
  7. package/assets/FlaggedPane-CGhj--Hm.js +1 -0
  8. package/assets/{FullCompose-Co7TPnxX.js → FullCompose-ChHG83dJ.js} +1 -1
  9. package/assets/MailListHeader-DfOCZnRx.js +7 -0
  10. package/assets/MailNav-CjfpinUe.js +1 -0
  11. package/assets/{MailShell-CBAHJ7P0.js → MailShell-C1jECwgj.js} +1 -1
  12. package/assets/{MailViewChrome-SWxm38ad.js → MailViewChrome-XZUEJlo5.js} +1 -1
  13. package/assets/{MailboxPane-S4RjLCSn.js → MailboxPane-Czwm70WW.js} +1 -1
  14. package/assets/{NavMenuButton-CRz4o42Z.js → NavMenuButton-DeFLPsFB.js} +1 -1
  15. package/assets/{OnboardingWizard-eRXMySJ0.js → OnboardingWizard-B-CFGg5s.js} +1 -1
  16. package/assets/OpenCalendarEvent-DFERZRRh.js +2 -0
  17. package/assets/{OutboxPane-CXpqcg1M.js → OutboxPane-HIJT_kwS.js} +1 -1
  18. package/assets/_calendarObjectId-CHrSuJ4j.js +1 -0
  19. package/assets/_mailboxId-Cx59NB_O.js +1 -0
  20. package/assets/_messageId-428jqG1g.js +1 -0
  21. package/assets/_messageId-BqS3jo2k.js +1 -0
  22. package/assets/_messageId-DLcoHrvg.js +1 -0
  23. package/assets/_outboxMessageId-DgbOcdNZ.js +1 -0
  24. package/assets/_recurrenceId-BNEK4esm.js +1 -0
  25. package/assets/_threadId-BpGxTAyH.js +1 -0
  26. package/assets/_threadId-DBQCQCIO.js +1 -0
  27. package/assets/_threadId-Li52F0Cd.js +1 -0
  28. package/assets/{_view._date-hlYMd7kn.js → _view._date-CvSVriaI.js} +1 -1
  29. package/assets/accounts-UiS1FK2e.js +1 -0
  30. package/assets/{advanced-CWj1vJ3f.js → advanced-LKQZxDeW.js} +2 -2
  31. package/assets/{appearance-DXdbCOhL.js → appearance-Csl0uD9E.js} +1 -1
  32. package/assets/{attendee-row-Dgh-0GlX.js → attendee-row-BhqXy1fZ.js} +1 -1
  33. package/assets/{avatar-BuiXyp5p.js → avatar-Dq9zVRVl.js} +1 -1
  34. package/assets/{bell-off-PwhHcUK1.js → bell-off-zJIQc-fQ.js} +1 -1
  35. package/assets/{bottom-sheet-BuyceQDS.js → bottom-sheet-CqUVoKvb.js} +1 -1
  36. package/assets/brief-CuAyGW-_.js +1 -0
  37. package/assets/{brief-itwy9KeE.js → brief-i89ZY7Gu.js} +1 -1
  38. package/assets/{browser-ponyfill-XC3MKgZo.js → browser-ponyfill-32LE6w6g.js} +2 -2
  39. package/assets/{bug-CFbZ4o5k.js → bug-BX9QtfhB.js} +1 -1
  40. package/assets/calendar-DLPNVzNq.js +1 -0
  41. package/assets/{calendar-clash-strip-ChVtknHT.js → calendar-clash-strip-Bid2cYhz.js} +1 -1
  42. package/assets/calendar-format-M4S5xU7P.js +1 -0
  43. package/assets/calendar-suggestion-Dz1CYPKE.js +1 -0
  44. package/assets/{calendars-CI4Tye4t.js → calendars-D_kCUTOt.js} +1 -1
  45. package/assets/{card-Dfe50axc.js → card-DgdelB3M.js} +1 -1
  46. package/assets/chevron-left-Dd68kT1Y.js +1 -0
  47. package/assets/{circle-check-DMqAgBOj.js → circle-check-B0R88gmM.js} +1 -1
  48. package/assets/{circle-check-big-CYIqB7G_.js → circle-check-big-DrhQmTbc.js} +1 -1
  49. package/assets/{circle-help-Bn5rsX9v.js → circle-help-Bh3n-6_h.js} +1 -1
  50. package/assets/{clock-zhYrOi0n.js → clock-ByuYhL7c.js} +1 -1
  51. package/assets/compose._-_outboxMessageId_-CJP6aGKp.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-CMXTsNxj.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-DIUaW_Wi.js +1 -0
  54. package/assets/compose._-_outboxMessageId_-ZpGAMi--.js +1 -0
  55. package/assets/{config-import-PZAIf0rl.js → config-import-Bugb2aMh.js} +1 -1
  56. package/assets/{confirm-dialog-BBNecW64.js → confirm-dialog-D0wfxRPd.js} +1 -1
  57. package/assets/{copy-DYN1Qqcn.js → copy-baeOC0XH.js} +1 -1
  58. package/assets/{credential-steps-BvLk_5Sd.js → credential-steps-DOdW-2H8.js} +1 -1
  59. package/assets/{download-DSk-iXt6.js → download-C79uP4C7.js} +1 -1
  60. package/assets/{file-json-CnG7YYof.js → file-json-CGQXrNbO.js} +1 -1
  61. package/assets/{filters-pA2rkirY.js → filters-CAsK70Nx.js} +1 -1
  62. package/assets/flagged-CEg9zmAF.js +1 -0
  63. package/assets/{flagged-0DaGnTzF.js → flagged-uALUxb-O.js} +1 -1
  64. package/assets/folder-failure-CqkVSsrb.js +1 -0
  65. package/assets/folders-Bx3SMw7d.js +1 -0
  66. package/assets/{help-copy-DUM-3tGw.js → help-copy-C9SzNfoi.js} +1 -1
  67. package/assets/{import-iEpa-yKD.js → import-BwX6jaiD.js} +1 -1
  68. package/assets/index-B_wiLLnW.js +1 -0
  69. package/assets/index-BulHQ3Bz.js +1 -0
  70. package/assets/index-Bz3z8-Ud.js +1 -0
  71. package/assets/{index-N25dfLEk.js → index-CLg2znEx.js} +1 -1
  72. package/assets/index-Caogy7TQ.js +1 -0
  73. package/assets/index-Cfb74LIY.js +1 -0
  74. package/assets/index-CvxW8FM1.js +1 -0
  75. package/assets/index-Cy75NEgh.js +1 -0
  76. package/assets/index-D4ZeuNuq.js +55 -0
  77. package/assets/index-DLcoHrvg.js +1 -0
  78. package/assets/index-DmMeuJEG.js +1 -0
  79. package/assets/{index-Cvg1ICmg.js → index-UydO8d8c.js} +69 -69
  80. package/assets/{kbd-CqsQh3Yv.js → kbd-Dr4usi4j.js} +1 -1
  81. package/assets/{labels-d9EnCfKK.js → labels-D22q095l.js} +1 -1
  82. package/assets/mail-CWdYkVJO.js +1 -0
  83. package/assets/{mail-i5djtULt.js → mail-Db9OjHYL.js} +1 -1
  84. package/assets/{map-pin-BNehUfT9.js → map-pin-HJKJCWdt.js} +1 -1
  85. package/assets/{menu-CzfZlboy.js → menu-CbYnJN5U.js} +1 -1
  86. package/assets/new-kq63OZ83.js +1 -0
  87. package/assets/onboarding-DXy2aNhI.js +1 -0
  88. package/assets/{onboarding-completion-LMYPue3i.js → onboarding-completion-BlaYncdL.js} +1 -1
  89. package/assets/outbox-CT3Ok2c-.js +1 -0
  90. package/assets/{pencil-Cbc_bTFZ.js → pencil-u2t1F29A.js} +1 -1
  91. package/assets/{popover-menu-BOPw-RvI.js → popover-menu--AoVAv-y.js} +1 -1
  92. package/assets/{refresh-cw-gehoG8pf.js → refresh-cw-Qp6f0dRu.js} +1 -1
  93. package/assets/{rich-text-DYTexR3K.js → rich-text-D3RBxInX.js} +2 -2
  94. package/assets/{rich-text-spellcheck-worker-provider-Be6BN4oD.js → rich-text-spellcheck-worker-provider-9h-DIyCe.js} +1 -1
  95. package/assets/{rotate-ccw-BUQyyEmS.js → rotate-ccw-SdroQT7m.js} +1 -1
  96. package/assets/{roving-focus-DwDXHttZ.js → roving-focus-BNBmBfAx.js} +1 -1
  97. package/assets/{row-actions-CzWFmX-0.js → row-actions-IPR7z5tr.js} +1 -1
  98. package/assets/{search-mirror-CG0SD5Nw.js → search-mirror-Cv2S0VbB.js} +1 -1
  99. package/assets/{search-token-index-CMfLsCex.js → search-token-index-AOAqpH15.js} +1 -1
  100. package/assets/{sections-DZNHkQyT.js → sections-EqJpt3TQ.js} +1 -1
  101. package/assets/{senders-zOwXF1CW.js → senders-DnFn3aNI.js} +1 -1
  102. package/assets/settings-CNMUput2.js +1 -0
  103. package/assets/{settings-screen-BVNyrrqp.js → settings-screen-WQb7kG5A.js} +1 -1
  104. package/assets/{shield-check-gQitY-yx.js → shield-check-D7EcTf9d.js} +1 -1
  105. package/assets/{suggested-vips-DrD2TuQ1.js → suggested-vips-QYhd7mHg.js} +1 -1
  106. package/assets/undo-2-CveuEJjH.js +1 -0
  107. package/assets/useCalendarData-CMPLRued.js +1 -0
  108. package/assets/{useCalendarWrites--n8KbD7U.js → useCalendarWrites-BASehFYp.js} +1 -1
  109. package/assets/useCalendars-DR1_eTjS.js +1 -0
  110. package/assets/{useDebouncedValue-abnXV_Ax.js → useDebouncedValue-Dt6rAAol.js} +1 -1
  111. package/assets/{useFilters-e6-LOuFX.js → useFilters-Bbcl4di_.js} +1 -1
  112. package/assets/{useLabels-Dm-tUvjJ.js → useLabels-DQs2z0T7.js} +1 -1
  113. package/assets/{useLayoutTier-id3G6JgO.js → useLayoutTier-CF_kWPgV.js} +1 -1
  114. package/assets/{useMessageBodyContent-DK0INN0c.js → useMessageBodyContent-DiiU1g37.js} +1 -1
  115. package/assets/{useQueries-B8LmhXDj.js → useQueries-CJUjXxvq.js} +1 -1
  116. package/assets/{useRefreshControl-BY1Z-PWr.js → useRefreshControl-BUZDaiTn.js} +1 -1
  117. package/assets/{useResultFolderIndex-D442PBpq.js → useResultFolderIndex-D9ADFT-m.js} +1 -1
  118. package/assets/{useSearchTokenContext-8rnAiWTU.js → useSearchTokenContext-CBDSw3gJ.js} +3 -3
  119. package/assets/{useSemanticSearch-CCCY9PAD.js → useSemanticSearch-B7rQKIm8.js} +1 -1
  120. package/assets/{useSignature-BPTjqaqF.js → useSignature-DruMb0cI.js} +1 -1
  121. package/index.html +1 -1
  122. package/package.json +1 -1
  123. package/assets/CalendarComposePane-CQquoIIA.js +0 -1
  124. package/assets/FlaggedPane-C0O-H48H.js +0 -1
  125. package/assets/MailListHeader-C_n4dLUO.js +0 -7
  126. package/assets/MailNav-DsFM4Zbb.js +0 -1
  127. package/assets/OpenCalendarEvent-BgYFqkWO.js +0 -2
  128. package/assets/_calendarObjectId-CAZamn7y.js +0 -1
  129. package/assets/_mailboxId-BmIDt2GW.js +0 -1
  130. package/assets/_messageId-CigPBylW.js +0 -1
  131. package/assets/_messageId-R9ftzZBW.js +0 -1
  132. package/assets/_messageId-Xz7zDM4l.js +0 -1
  133. package/assets/_outboxMessageId-DxrO7cYW.js +0 -1
  134. package/assets/_recurrenceId-C1Ir6dGL.js +0 -1
  135. package/assets/_threadId-CIO_w6bi.js +0 -1
  136. package/assets/_threadId-CjQQJEhB.js +0 -1
  137. package/assets/_threadId-luQhGDWk.js +0 -1
  138. package/assets/accounts-BHBATOBL.js +0 -1
  139. package/assets/attachment-file-rUVfXWEQ.js +0 -1
  140. package/assets/brief-Dl4eEpFB.js +0 -1
  141. package/assets/calendar-Dabme7v4.js +0 -1
  142. package/assets/calendar-format-_D2qlvSu.js +0 -1
  143. package/assets/calendar-suggestion-DoL5BXEv.js +0 -1
  144. package/assets/chevron-left-Cp_sl0gi.js +0 -1
  145. package/assets/compose._-_outboxMessageId_-C7e7F6Id.js +0 -1
  146. package/assets/compose._-_outboxMessageId_-DMdCmVMA.js +0 -1
  147. package/assets/compose._-_outboxMessageId_-O4p9O2gf.js +0 -1
  148. package/assets/compose._-_outboxMessageId_-VcBR_Wg2.js +0 -1
  149. package/assets/flagged-CffT7Fd9.js +0 -1
  150. package/assets/folders-BZ2ei1sV.js +0 -1
  151. package/assets/index-BvAEy50E.js +0 -1
  152. package/assets/index-Bw48MPd4.js +0 -1
  153. package/assets/index-C280EmcF.js +0 -1
  154. package/assets/index-CeB8dMXm.js +0 -1
  155. package/assets/index-CigPBylW.js +0 -1
  156. package/assets/index-ClrSu-J7.js +0 -1
  157. package/assets/index-DDZEuXNA.js +0 -1
  158. package/assets/index-DK4QmBvZ.js +0 -1
  159. package/assets/index-sAVS5SaO.js +0 -1
  160. package/assets/index-yhiT7pf4.js +0 -55
  161. package/assets/mail-DvBCqkl1.js +0 -1
  162. package/assets/new-w9LeiqvV.js +0 -1
  163. package/assets/onboarding-CGyR6f-U.js +0 -1
  164. package/assets/outbox-B7-uw0-A.js +0 -1
  165. package/assets/settings-BJ3vobZ5.js +0 -1
  166. package/assets/useCalendarData-DXephWeP.js +0 -1
  167. package/assets/useCalendars-BiHQwoqg.js +0 -1
@@ -1,2 +0,0 @@
1
- import{j as e,t as h,f as T,a3 as _,X as Q,c as V,eT as X,s as H,Y as J,a0 as K,r as w}from"./index-Cvg1ICmg.js";import{u as $,e as ee,t as se,C as te,d as ae,p as ne}from"./CalendarComposePane-CQquoIIA.js";import{c as re,R as ie,I as Z,u as le,n as oe}from"./calendar-format-_D2qlvSu.js";import{R as ce,A as de}from"./attendee-row-Dgh-0GlX.js";import{C as xe}from"./clock-zhYrOi0n.js";import{G as B,M as fe}from"./map-pin-BNehUfT9.js";import{M as me}from"./mail-i5djtULt.js";import{P as ue}from"./pencil-Cbc_bTFZ.js";import{u as he,c as pe,U as ge}from"./useCalendars-BiHQwoqg.js";import{a as ve}from"./useCalendarWrites--n8KbD7U.js";import{b as be}from"./useCalendarData-DXephWeP.js";function v({icon:s,children:t}){return e.jsxs("div",{className:"flex items-start gap-2.5 py-1",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-fg-subtle",children:s}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-fg",children:t})]})}function je({event:s,calendar:t,whenText:i,onEdit:a,onDelete:l,onOpenThread:o,onClose:c,activeAttendee:x="",onActivateAttendee:b,renderAttendeeContext:k,touch:y=!1,chrome:E="header",className:n}){const R=re(t.color),d=e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s.title}),e.jsxs("div",{className:"mt-3 flex flex-col border-b border-line pb-3",children:[e.jsx(v,{icon:e.jsx(xe,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[i,s.attendees.length>0&&e.jsx(ce,{rsvp:s.myRsvp})]})}),s.zoneCertainty==="ambiguous"?e.jsx(v,{icon:e.jsx(B,{className:"size-4 text-warning"}),children:e.jsx("span",{className:"text-warning",children:"The mail said a time but never a zone. Shown in your own; confirm before you travel for it."})}):s.timeZone!==""&&e.jsx(v,{icon:e.jsx(B,{className:"size-4"}),children:s.timeZone}),s.recurrenceRule!==""&&e.jsx(v,{icon:e.jsx(ie,{className:"size-4"}),children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[s.recurrenceRule,s.seriesException&&e.jsx("span",{className:"rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning",children:"Moved out of the series"})]})}),s.location!==""&&e.jsx(v,{icon:e.jsx(fe,{className:"size-4"}),children:s.location})]}),s.threadId!==""&&o&&e.jsxs("button",{type:"button",onClick:o,className:"mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(me,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:"From this thread"}),e.jsx("span",{className:"block truncate text-sm text-fg",children:s.threadSubject})]})]}),s.attendees.length>0&&e.jsx(de,{attendees:s.attendees,activeEmail:x,onActivate:b,renderContext:k,touch:y,className:"mt-3"}),s.notes!==""&&e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-fg-muted",children:s.notes})]});return E==="bare"?e.jsx("div",{className:h("flex flex-col",n),children:d}):e.jsxs("article",{className:h("flex h-full w-full flex-col bg-surface",n),children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[e.jsx("span",{className:h("size-2.5 shrink-0 rounded-full",R.solid)}),e.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:[t.name," · ",t.accountLabel]}),a&&e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(ue,{className:"size-3.5"}),onClick:a,children:"Edit"}),l&&e.jsx(T,{variant:"ghost",size:"sm",icon:e.jsx(_,{className:"size-3.5"}),onClick:l,className:"text-danger",children:"Delete"}),c&&e.jsx("button",{type:"button","aria-label":"Close event",onClick:c,className:"flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(Q,{className:"size-4"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-3",children:d})]})}const Ne=[{scope:"this",label:"This event",note:"Leaves the rest of the series alone"},{scope:"following",label:"This and everything after",note:"Splits the series here"},{scope:"all",label:"The whole series",note:"Rewrites the rule itself"}];function Ce({title:s,ruleText:t,instanceText:i,onChoose:a,onCancel:l,touch:o,className:c}){return e.jsxs("div",{className:h("flex flex-col gap-3",c),children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-md font-semibold text-fg",children:[s," repeats"]}),e.jsx("p",{className:"text-xs text-fg-muted",children:t}),e.jsxs("p",{className:"text-xs text-fg-subtle",children:["You clicked ",i,"."]})]}),e.jsx("p",{className:"text-sm text-fg",children:"What should the change apply to?"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:Ne.map(x=>e.jsxs("button",{type:"button",onClick:()=>a(x.scope),className:h("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11 justify-center"),children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:x.label}),e.jsx("span",{className:"text-2xs text-fg-subtle",children:x.note})]},x.scope))}),e.jsx(T,{variant:"ghost",size:o?"md":"sm",onClick:l,className:h("self-start",o&&"min-h-11"),children:"Cancel"})]})}const we=s=>s.replace(/\r?\n[ \t]/g,""),U=s=>s.replace(/\\n/gi,`
2
- `).replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\\\/g,"\\");function ke(s,t){let i=!1;for(let a=t.length;a<s.length;a+=1){const l=s[a];if(a===t.length&&l!==";"&&l!==":")return;if(l==='"'){i=!i;continue}if(!i&&l===":")return s.slice(a+1).trim()}}function D(s,t){for(const i of we(s).split(/\r?\n/)){if(!i.startsWith(t))continue;const a=ke(i,t);if(a!==void 0)return a}return""}const ye=s=>D(s,"RRULE"),Ee=s=>({location:U(D(s,"LOCATION")),description:U(D(s,"DESCRIPTION"))}),Re=H(404);function ze(s,t){const{data:i,isLoading:a,error:l,refetch:o}=V({...X({path:{calendarObjectId:s},query:{calendarId:t}}),meta:Re,enabled:s!==""&&t!==""});return{resource:i,isLoading:a,error:l,refetch:()=>{o()}}}function Te({event:s,calendar:t,isOccurrence:i,problem:a="",onEdit:l,onDelete:o,onClose:c}){return!s||!t?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 bg-surface p-8 text-center",children:[e.jsx(J,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"That event isn't on this week"}),e.jsx("p",{className:"max-w-xs text-sm text-fg-muted",children:"The address names an event the calendar doesn't have here."}),e.jsx("button",{type:"button",onClick:c,className:"rounded-md border border-line px-2.5 py-1 text-sm font-medium text-fg outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring",children:"Back to the calendar"})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[i&&e.jsx("p",{className:"shrink-0 border-b border-line bg-surface-sunken px-row-inset py-1.5 text-2xs uppercase tracking-wider text-fg-subtle",children:"One occurrence of a repeating event"}),a!==""&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 border-b border-danger/40 bg-danger-soft px-row-inset py-2 text-sm",children:[e.jsx(K,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:a})]}),e.jsx(je,{event:s,calendar:t,whenText:Z(s),onEdit:l,onDelete:o,onClose:c,className:"min-h-0 flex-1"})]})}const De="This event changed somewhere else — over CalDAV, or in another tab. Nothing was saved. Close it and open it again to see the version that's stored now.";function Ze({calendarObjectId:s,recurrenceId:t}){const{view:i,date:a,calendarIds:l}=le(),{events:o}=be({view:i,date:a,calendarIds:l}),{calendars:c,timeZoneByCalendarId:x}=he(),{closeEvent:b}=oe(),{updateEvent:k,deleteEvent:y,isWriting:E}=ve(),n=o.find(r=>r.id===pe(s,t??"")),R=c.find(r=>r.id===n?.calendarId),{resource:d}=ze(s,n?.calendarId??""),[S,p]=w.useState(void 0),[m,z]=w.useState(void 0),[u,j]=w.useState(void 0),[A,g]=w.useState(""),G=$(u??ee("",""),s),N=d?Ee(d.icalData):void 0,I=d?ye(d.icalData):"",q=n&&!n.allDay?n.start.slice(11,16):"",C=I===""?"":se(I,q)??"Repeats",L=n!==void 0&&n.seriesId!==""&&t!==void 0&&t!=="",P=n!==void 0&&d!==void 0,F=(r,f)=>{if(r.kind==="written"){g(""),f();return}g(r.kind==="conflict"?De:r.message)},O=r=>({calendarObjectId:s,calendarId:n?.calendarId??"",recurrenceId:t??"",scope:r,etag:d?.etag??""}),M=r=>{if(!n)return;const f=ae(n,{repeat:C,location:N?.location??"",notes:N?.description??""});p(void 0),z({before:f,scope:r}),j(f),g("")},W=r=>{p(void 0),y(O(r)).then(f=>F(f,b))},Y=()=>{if(!m||!u)return;const r=ne(m.before,u,x[u.calendarId]??ge);if(!r.ok){g(r.problem);return}k(O(m.scope),r.patch).then(f=>F(f,()=>{z(void 0),j(void 0)}))};return S!==void 0&&n?e.jsx("div",{className:"flex h-full flex-col justify-center bg-surface px-row-inset",children:e.jsx(Ce,{className:"mx-auto w-full max-w-md",title:n.title,ruleText:C===""?"It repeats":C,instanceText:Z(n),onChoose:S==="edit"?M:W,onCancel:()=>p(void 0)})}):m&&u?e.jsx(te,{title:"Edit event",subtitle:m.scope==="this"?"This occurrence only":u.date,calendars:c,draft:u,onChange:j,problem:A,saveLabel:"Save",isSaving:E,repeatEditable:m.scope===void 0||m.scope==="all",calendarEditable:!1,clashes:G,onSave:Y,onCancel:()=>{z(void 0),j(void 0),g("")}}):e.jsx(Te,{event:n&&{...n,location:N?.location??"",notes:N?.description??"",recurrenceRule:C},calendar:R,isOccurrence:t!==void 0,problem:A,onEdit:P?()=>L?p("edit"):M(void 0):void 0,onDelete:P?()=>L?p("delete"):W(void 0):void 0,onClose:b})}export{Ze as O};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Cvg1ICmg.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{aj as m,j as o,O as p}from"./index-Cvg1ICmg.js";import{a}from"./MailShell-CBAHJ7P0.js";import{M as r}from"./MailboxPane-S4RjLCSn.js";import{a as e}from"./search-token-index-CMfLsCex.js";import{u as s}from"./search-mirror-CG0SD5Nw.js";import"./FullCompose-Co7TPnxX.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useQueries-B8LmhXDj.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./EmptyState-DxHRPzWP.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./NavMenuButton-CRz4o42Z.js";import"./useLabels-Dm-tUvjJ.js";import"./useSemanticSearch-CCCY9PAD.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BuyceQDS.js";import"./circle-help-Bn5rsX9v.js";import"./circle-check-DMqAgBOj.js";function po(){const{mailboxId:t}=m.useParams(),i=e();return s({to:"/mail/$mailboxId",params:{mailboxId:t}}),o.jsx(r,{mailboxId:t,thread:i,children:o.jsx(a,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(p,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!i})})}export{po as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{M as r}from"./MailboxPane-S4RjLCSn.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useQueries-B8LmhXDj.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./NavMenuButton-CRz4o42Z.js";import"./useLabels-Dm-tUvjJ.js";import"./useSemanticSearch-CCCY9PAD.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BuyceQDS.js";import"./circle-help-Bn5rsX9v.js";import"./circle-check-DMqAgBOj.js";function X(){return o.jsx(r.Reading,{})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-Cvg1ICmg.js";import{B as o}from"./BriefPane-BjUmHKNU.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useSemanticSearch-CCCY9PAD.js";import"./useLabels-Dm-tUvjJ.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function T(){return r.jsx(o.Reading,{})}export{T as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{F as r}from"./FlaggedPane-C0O-H48H.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./refresh-cw-gehoG8pf.js";import"./wizard-selection-DxUM65kM.js";function N(){return o.jsx(r.Reading,{})}export{N as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{O as t}from"./OutboxPane-CXpqcg1M.js";import"./roving-focus-DwDXHttZ.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-CYIqB7G_.js";import"./clock-zhYrOi0n.js";import"./row-actions-CzWFmX-0.js";import"./rotate-ccw-BUQyyEmS.js";import"./NavMenuButton-CRz4o42Z.js";import"./menu-CzfZlboy.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function P(){return o.jsx(t.Reading,{})}export{P as component};
@@ -1 +0,0 @@
1
- import{eU as o,j as m}from"./index-Cvg1ICmg.js";import{O as p}from"./OpenCalendarEvent-BgYFqkWO.js";import"./CalendarComposePane-CQquoIIA.js";import"./calendar-format-_D2qlvSu.js";import"./useQueries-B8LmhXDj.js";import"./useCalendars-BiHQwoqg.js";import"./calendar-clash-strip-ChVtknHT.js";import"./attendee-row-Dgh-0GlX.js";import"./avatar-BuiXyp5p.js";import"./clock-zhYrOi0n.js";import"./map-pin-BNehUfT9.js";import"./mail-i5djtULt.js";import"./pencil-Cbc_bTFZ.js";import"./useCalendarWrites--n8KbD7U.js";import"./ErrorState-B7NbYqTc.js";import"./useCalendarData-DXephWeP.js";function I(){const{calendarObjectId:r,recurrenceId:t}=o.useParams();return m.jsx(p,{calendarObjectId:r,recurrenceId:t})}export{I as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Cvg1ICmg.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Cvg1ICmg.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{O as o}from"./index-Cvg1ICmg.js";const n=o;export{n as component};
@@ -1 +0,0 @@
1
- import{j as a,ao as De,f as te,Z as Ps,X as Ce,ap as ks,aq as Vs,ar as ut,G as Ds,r as C,H as Cs,t as Ge,as as ee,h as ft,at as Fs,c as Jt,d as Xt,au as Os,i as Se,av as Is,o as Te,l as es,aw as Rs,ax as Ms,ay as Ls,az as ve,aA as At,L as it,aB as Tt,aC as Us,aD as Re,aE as be,aF as _t,ab as Hs,aG as zs,aH as Bs,aI as ts,aJ as Et,u as qs,n as $s,aK as Ws,aL as Gs,B as Pt,g as Ks,aM as kt,aN as Ys,a3 as Zs,aO as Qs}from"./index-Cvg1ICmg.js";import{R as Js}from"./row-actions-CzWFmX-0.js";import{S as Xs,A as er}from"./settings-screen-BVNyrrqp.js";import{g as Vt,P as tr,O as sr}from"./OnboardingWizard-eRXMySJ0.js";import{s as Be,u as rr,b as ar,R as ir}from"./credential-steps-BvLk_5Sd.js";import{u as nr}from"./useSignature-BPTjqaqF.js";import{c as or,a as Dt,d as lr}from"./account-form-helpers-DhckT_PN.js";import{D as cr}from"./download-DSk-iXt6.js";import{E as dr}from"./ErrorState-B7NbYqTc.js";import{a as ur}from"./help-copy-DUM-3tGw.js";import"./avatar-BuiXyp5p.js";import"./chevron-left-Cp_sl0gi.js";import"./menu-CzfZlboy.js";import"./circle-help-Bn5rsX9v.js";import"./kbd-CqsQh3Yv.js";import"./mail-i5djtULt.js";import"./file-json-CnG7YYof.js";import"./card-Dfe50axc.js";const fr=e=>{const s=new Set(e.map(ks));return Vs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>De(t).localeCompare(De(i)))},mr=({value:e,onChange:s,busy:t=!1})=>{const i=fr(e);return a.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[a.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>a.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:De(o)}),d===0?a.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ps,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${De(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${De(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),a.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[a.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>a.jsx("option",{value:o,children:De(o)},o))]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function pr({title:e,description:s,action:t}){return a.jsxs("div",{className:"rounded-sm border border-danger/50",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[a.jsx(ut,{className:"size-4 text-danger"}),a.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),a.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-fg",children:e}),a.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),a.jsx("div",{className:"shrink-0",children:t})]})]})}function Ct({isOpen:e,onClose:s,title:t,children:i,footer:o}){Ds({id:"slide-panel",open:e,answers:{back:s}});const d=C.useRef(null);return Cs(d,e),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:Ge("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),a.jsxs("div",{ref:d,className:Ge("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",tabIndex:-1,children:[a.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[a.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),a.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:a.jsx(Ce,{className:"size-5"})})]}),a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&a.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Ue=e=>e.type==="checkbox",je=e=>e instanceof Date,K=e=>e==null;const mt=e=>typeof e=="object";var H=e=>!K(e)&&!Array.isArray(e)&&mt(e)&&!je(e),hr=e=>H(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,gr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),ss=e=>{const s=e.constructor&&e.constructor.prototype;return H(s)&&s.hasOwnProperty("isPrototypeOf")},Ze=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function z(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Ze&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(H(e)&&ss(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=z(e[o]));return i}const ke={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},rs="root",pt=["__proto__","constructor","prototype"],xr=/^\w*$/;var He=e=>xr.test(e),M=e=>e===void 0;const yr=/[.[\]'"]/;var Qe=e=>e.split(yr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=He(s)?[s]:Qe(s);if(i.some(d=>pt.includes(d)))return t;const o=i.reduce((d,n)=>K(d)?void 0:d[n],e);return M(o)||o===e?M(e[s])?t:e[s]:o},pe=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=He(s)?[s]:Qe(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const _=e[u];j=H(_)||Array.isArray(_)?_:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const vr=ee.createContext(null);vr.displayName="HookFormControlContext";var br=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const jr=Ze?ee.useLayoutEffect:ee.useEffect;var Y=e=>typeof e=="string",Sr=(e,s,t,i,o)=>Y(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),nt=e=>K(e)||!mt(e);const Ft=(e,s)=>s.length===0&&!Array.isArray(e)&&!ss(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(nt(e)||nt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ft(e,i)||Ft(s,o))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of i){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(H(u)||Array.isArray(u))&&(H(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),st=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Le=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Le(u,s))break}else if(H(u)&&Le(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,rs,s[t]),F(e,t,o),e},G=e=>H(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Ze)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},gt=e=>e.type==="radio",Ye=e=>e instanceof RegExp,xt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const It={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var as=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!M(e[0].attributes.value)?M(e[0].value)||e[0].value===""?Rt:{value:e[0].value,isValid:!0}:Rt:It}return It};const Mt={isValid:!1,value:null};var is=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Mt):Mt;function Lt(e,s,t="validate"){if(Y(e)||Array.isArray(e)&&e.every(Y)||pe(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ve=e=>H(e)&&!Ye(e)?e:{value:e,message:""},Ut=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:_,minLength:P,min:U,max:R,pattern:O,validate:E,name:f,valueAsNumber:b,mount:re}=e._f,N=y(t,f);if(!re||s.has(f))return{};const $=u?u[0]:n,I=T=>{if(o&&$.reportValidity){const k=pe(T)?"":T||"";u?u.forEach(D=>D.setCustomValidity(k)):$.setCustomValidity(k),$.reportValidity()}},A={},ne=gt(n),ae=Ue(n),ge=ne||ae,oe=(b||ht(n))&&M(n.value)&&M(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,Z=xt.bind(null,f,i,A),le=(T,k,D,q=de.maxLength,Q=de.minLength)=>{const S=T?k:D;A[f]={type:T?q:Q,message:S,ref:n,...Z(T?q:Q,S)}};if(d?!Array.isArray(N)||!N.length:j&&(!ge&&(oe||K(N))||pe(N)&&!N||ae&&!as(u).isValid||ne&&!is(u).isValid)){const{value:T,message:k}=Y(j)?{value:!!j,message:j}:Ve(j);if(T&&(A[f]={type:de.required,message:k,ref:$,...Z(de.required,k)},!i))return I(k),A}if(!oe&&(!K(U)||!K(R))){let T,k;const D=Ve(R),q=Ve(U);if(!K(N)&&!isNaN(N)){const Q=n.valueAsNumber||N&&+N;K(D.value)||(T=Q>D.value),K(q.value)||(k=Q<q.value)}else{const Q=n.valueAsDate||new Date(N),S=fe=>new Date(new Date().toDateString()+" "+fe),J=n.type=="time",W=n.type=="week";Y(D.value)&&N&&(T=J?S(N)>S(D.value):W?N>D.value:Q>new Date(D.value)),Y(q.value)&&N&&(k=J?S(N)<S(q.value):W?N<q.value:Q<new Date(q.value))}if((T||k)&&(le(!!T,D.message,q.message,de.max,de.min),!i))return I(A[f].message),A}if((_||P)&&!oe&&(Y(N)||d&&Array.isArray(N))){const T=Ve(_),k=Ve(P),D=!K(T.value)&&N.length>+T.value,q=!K(k.value)&&N.length<+k.value;if((D||q)&&(le(D,T.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Y(N)){const{value:T,message:k}=Ve(O);if(Ye(T)&&!N.match(T)&&(A[f]={type:de.pattern,message:k,ref:n,...Z(de.pattern,k)},!i))return I(k),A}if(E){if(ie(E)){const T=await E(N,t),k=Lt(T,$);if(k&&(A[f]={...k,...Z(de.validate,k.message)},!i))return I(k.message),A}else if(H(E)){let T={};for(const k in E){if(!G(T)&&!i)break;const D=Lt(await E[k](N,t),$,k);D&&(T={...D,...Z(k,D.message)},I(D.message),i&&(A[f]=T))}if(!G(T)&&(A[f]={ref:$,...T},!i))return A}}return I(!0),A},We=e=>Array.isArray(e)?e:[e],ns=e=>Array.isArray(e)?e.filter(Boolean):[];function wr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(K(e)){e=void 0;break}e=e[s[i]],i++}return e}function Nr(e){for(const s in e)if(e.hasOwnProperty(s)&&!M(e[s]))return!1;return!0}function B(e,s){if(Y(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(n=>pt.includes(String(n))))return e;const i=t.length===1?e:wr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&Nr(i))&&B(e,t.slice(0,-1)),e}const os=e=>{const s={};for(const t of Object.keys(e))if(mt(e[t])&&e[t]!==null&&!je(e[t])){const i=os(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},Ar=ee.createContext(null);Ar.displayName="HookFormContext";var Ht=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function ls(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&H(o)&&d){const n=ls(o,d);H(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var cs=e=>e.type==="select-multiple",Tr=e=>gt(e)||Ue(e),rt=e=>Ke(e)&&e.isConnected,_r=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||H(e)&&!_r(e)}function us(e){return!!(e&&"_f"in e)}function fs(e){return Array.isArray(e)?!e.some(s=>!M(s)):!Object.keys(e).length}function ot(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function lt(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];ds(o)&&(!Array.isArray(o)||!us(d))?(s[i]=Array.isArray(o)?[]:{},lt(o,s[i],d),fs(s[i])&&ot(s,i)):M(o)||(s[i]=!0)}return s}function Ae(e,s,t,i){t||(t=lt(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];ds(d)&&(!Array.isArray(d)||!us(n))?(M(s)||nt(t[o])?t[o]=lt(d,Array.isArray(d)?[]:{},n):Ae(d,K(s)?{}:s[o],t[o],n),fs(t[o])&&ot(t,o)):he(d,s[o])?ot(t,o):t[o]=!0}return t}var ms=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>M(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):i?i(e):e;function zt(e){const s=e.ref;return ht(s)?s.files:gt(s)?is(e.refs).value:cs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?as(e.refs).value:ms(M(s.value)?e.ref.value:s.value,e)}var Er=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>M(e)?e:Ye(e)?e.source:H(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var Pr=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===Bt;if(H(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Bt)return!0}return!1},kr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function qt(e,s,t){const i=y(e,t);if(i||He(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};o.pop()}return{name:t}}var Vr=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},Dr=(e,s,t)=>!e||!s||e===s||We(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Cr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,Fr=(e,s)=>!ns(y(e,s)).length&&B(e,s);const Or={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Ir(e={}){let s={...Or,...e},t={...z(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=H(s.defaultValues)||H(s.values)?z(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:z(o),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},_={};let P=0,U=qe(s.mode),R=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},E={...O};let f={...E};const b={array:Ht(),state:Ht()};let re=0;const N=s.criteriaMode===ue.all,$=(r,l)=>c=>{clearTimeout(_[r]),_[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(E.isValid||f.isValid||r)){const l=++re;let c;s.resolver?(c=G((await D()).errors),l===re&&A()):c=await S({fields:i,onlyCheckValid:!0,eventType:ke.VALID}),l===re&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(E.isValidating||E.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):B(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ae(o,d,void 0,i)},ae=(r,l=[],c,m,p=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,r))){const g=c(y(i,r),m.argA,m.argB);p&&F(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&F(t.errors,r,g),Fr(t.errors,r)}if((E.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&F(t.touchedFields,r,g)}(E.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:W(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,l)},ge=(r,l)=>{F(t.errors,r,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},Z=r=>{const l=He(r)?[r]:Qe(r);let c=d,m=o;for(let p=0;p<l.length-1;p++){const x=l[p];if(c=K(c)?c:c[x],m=K(m)?m:m[x],c===null&&m!==null)return!0}return!1},le=(r,l,c,m)=>{const p=y(i,r);if(p){if(Z(r))return;const x=M(y(d,r)),g=y(d,r,M(c)?y(o,r):c);M(g)||m&&m.defaultChecked||l?F(d,r,l?g:zt(p._f)):we(r,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(E.isDirty||f.isDirty)&&(W()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!M(y(d,r))&&st(r,u)&&(n.watch=!0))}},T=(r,l,c,m,p)=>{let x=!1,g=!1;const v={name:r};if(!s.disabled||m===!0){if(!c||m){const w=he(y(o,r),l);(E.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!w||W(),x=g!==v.isDirty),g=!!y(t.dirtyFields,r),w!==t.isDirty?t.dirtyFields=Ae(o,d,void 0,i):w?B(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(E.dirtyFields||f.dirtyFields)&&g!==!w}if(c){const w=y(t.touchedFields,r);w||(F(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(E.touchedFields||f.touchedFields)&&w!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(E.isValid||f.isValid)&&pe(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=$(r,()=>ge(r,c)),j[r](s.delayError)):(clearTimeout(_[r]),delete j[r],c?F(t.errors,r,c):B(t.errors,r),t.errors={...t.errors}),(c?!he(p,c):p)||!G(m)||x){const g={...m,...x&&pe(l)?{isValid:l}:{},errors:t.errors,name:r};t={...t,...g},b.state.next(g)}},D=async r=>(A(r,!0),await s.resolver(d,s.context,Er(r||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),q=async r=>{const{errors:l}=await D(r);if(A(r),r){for(const c of r){const m=y(l,c);m?u.array.has(c)&&H(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ot(t.errors,{[c]:m},c):F(t.errors,c,m):B(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},Q=async({name:r,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:r,eventType:l});if(H(c))for(const m in c){const p=c[m];p&&ze(`${at}.${m}`,{message:Y(p.message)?p.message:"",type:p.type||de.validate})}else Y(c)||!c?ze(at,{message:c||"",type:de.validate}):Pe(at);return c}return!0},S=async({fields:r,onlyCheckValid:l,name:c,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await Q({name:c,eventType:m})&&(p.valid=!1,l)))return p.valid;for(const x in r){const g=r[x];if(g){const{_f:v,...w}=g;if(v){const L=u.array.has(v.name),X=g._f&&Pr(g._f),xe=E.validatingFields||E.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,L);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?L?Ot(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):B(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(w)&&await S({context:p,onlyCheckValid:l,fields:w,name:x,eventType:m})}}return p.valid},J=()=>{for(const r of u.unMount){const l=y(i,r);l&&(l._f.refs?l._f.refs.every(c=>!rt(c)):!rt(l._f.ref))&&Xe(r)}u.unMount=new Set},W=(r,l)=>(r&&l&&F(d,r,l),!he(n.mount?d:o,o)),fe=(r,l,c)=>Sr(r,u,{...n.mount?d:M(l)?o:Y(r)?{[r]:l}:l},c,l),_e=r=>ns(y(n.mount?d:o,r,s.shouldUnregister?y(o,r,[]):[])),we=(r,l,c={},m=!1,p=!1)=>{const x=y(i,r);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ms(l,v)),g=Ke(v.ref)&&K(l)?"":l,cs(v.ref)?[...v.ref.options].forEach(w=>w.selected=g.includes(w.value)):v.refs?Ue(v.ref)?v.refs.forEach(w=>{(!w.defaultChecked||!w.disabled)&&(Array.isArray(g)?w.checked=!!g.find(L=>L===w.value):w.checked=g===w.value||!!g)}):v.refs.forEach(w=>w.checked=w.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!p&&b.state.next({name:r,values:m?d:z(d)})))}(c.shouldDirty||c.shouldTouch)&&T(r,g,c.shouldTouch,c.shouldDirty,!p),c.shouldValidate&&me(r,{delayError:c.delayError})},Ee=(r,l,c,m=!1,p=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=r+"."+x,w=y(i,v);(u.array.has(r)||H(g)||w&&!w._f)&&!je(g)?Ee(v,g,c,m,p):we(v,g,c,m,p)}},Je=(r,l,c,m,p=!1)=>{const x=y(i,r),g=u.array.has(r),v=m?l:z(l),w=y(d,r),L=he(w,v);if(L||F(d,r,v),g)b.array.next({name:r,values:m?d:z(d)}),(E.isDirty||E.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:W(r,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||K(v)||X?we(r,v,c,m,p):Ee(r,v,c,m,p)}if(!L&&!p){const X=st(r,u),xe=m?d:z(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Je(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!he(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Je(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...P?{values:d}:{}}),l.shouldValidate&&I()}},ce=async r=>{n.mount=!0;const l=r.target;let c=l.name,m=!0;const p=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(p){let g,v;const w=l.type?zt(p._f):hr(r),L=r.type===ke.BLUR||r.type===ke.FOCUS_OUT,X=!kr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Cr(L,y(t.touchedFields,c),t.isSubmitted,R,U),ye=st(c,u,L);if(F(d,c,w),L){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Ie=j[c];Ie&&Ie(0)}}else p._f.onChange&&p._f.onChange(r);const Oe=T(c,w,L),_s=!G(Oe)||ye;if(!L&&b.state.next({name:c,type:r.type,...P?{values:z(d)}:{}}),xe)return(!X||!t.isValid)&&(E.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),_s&&b.state.next({name:c,...ye?{}:Oe});if(!s.resolver&&e.validate&&await Q({name:c,eventType:r.type}),!L&&ye&&b.state.next({...t}),s.resolver){const{errors:Ie}=await D([c]);if(A([c]),x(w),!m){!G(Oe)&&b.state.next(Oe);return}const Es=qt(t.errors,i,c),Nt=qt(Ie,i,Es.name||c);g=Nt.error,c=Nt.name,v=G(Ie)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(w),m&&(g?v=!1:(E.isValid||f.isValid)&&(v=await S({fields:i,onlyCheckValid:!0,name:c,eventType:r.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&me(p._f.deps),k(c,v,g,Oe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},me=async(r,l={})=>{let c,m;const p=We(r);if(s.resolver){const x=await q(M(r)?r:p);c=G(x),m=r?!p.some(g=>y(x,g)):c}else r?(m=(await Promise.all(p.map(async x=>{const g=y(i,x);return await S({fields:g&&g._f?{[x]:g}:g,eventType:ke.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await S({fields:i,name:r,eventType:ke.TRIGGER});if(l.delayError&&s.delayError&&Y(r)){const x=y(t.errors,r);x?(B(t.errors,r),j[r]=$(r,()=>ge(r,x)),j[r](s.delayError)):(clearTimeout(_[r]),delete j[r])}return b.state.next({...!Y(r)||(E.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Le(i,se,r?p:u.mount),m},Ne=(r,l)=>{let c={...n.mount?d:o};return l&&(c=ls(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),M(r)?c:Y(r)?y(c,r):r.map(m=>y(c,m))},Fe=(r,l)=>({invalid:!!y((l||t).errors,r),isDirty:!!y((l||t).dirtyFields,r),error:y((l||t).errors,r),isValidating:!!y(t.validatingFields,r),isTouched:!!y((l||t).touchedFields,r)}),Pe=r=>{const l=r?We(r):void 0;l?.forEach(c=>B(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},ze=(r,l,c)=>{const m=(y(i,r,{_f:{}})._f||{}).ref,p=y(t.errors,r)||{},{ref:x,message:g,type:v,...w}=p;F(t.errors,r,{...w,...l,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},js=(r,l)=>{if(ie(r)){P++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||fe(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,P--,c())}}}return fe(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&P++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Dr(r.name,x.name,r.exact)&&Vr(x,r.formState||E,Ts,r.reRenderRoot)){const g={...d};r.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let p=!1;return()=>{p||(p=!0,P--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Xe=(r,l={})=>{for(const c of r?We(r):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(B(i,c),B(d,c)),!l.keepError&&B(t.errors,c),!l.keepDirty&&B(t.dirtyFields,c),!l.keepTouched&&B(t.touchedFields,c),!l.keepIsValidating&&B(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&B(o,c);b.state.next({values:z(d)}),b.state.next({...t,...l.keepDirty?{isDirty:W()}:{}}),!l.keepIsValid&&I()},vt=({disabled:r,name:l})=>{if(pe(r)&&n.mount||r||u.disabled.has(l)){const p=u.disabled.has(l)!==!!r;r?u.disabled.add(l):u.disabled.delete(l),p&&n.mount&&!n.action&&I()}},et=(r,l={})=>{let c=y(i,r);const m=pe(l.disabled)||pe(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return F(i,r,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:r}},name:r,mount:!0,...l}}),u.mount.add(r),c&&!p?vt({disabled:pe(l.disabled)?l.disabled:s.disabled,name:r}):le(r,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(l.pattern)}:{},name:r,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(r),et(r,l),u.registerName.delete(r),c=y(i,r);const g=M(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Tr(g),w=c._f.refs||[];if(v?w.find(L=>L===g):g===c._f.ref)return;F(i,r,{_f:{...c._f,...v?{refs:[...w.filter(rt),g,...Array.isArray(y(o,r))?[{}]:[]],ref:{type:g.type,name:r}}:{ref:g}}}),le(r,!1,void 0,g)}else c=y(i,r,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(gr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(i,se,u.mount),ws=r=>{pe(r)&&(b.state.next({disabled:r}),Le(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||r}))},0,!1))},bt=(r,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let p=z(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,p=z(g)}else await S({fields:i,eventType:ke.SUBMIT});if(u.disabled.size)for(const x of u.disabled)B(p,x);if(B(t.errors,rs),G(t.errors)){b.state.next({errors:{}});try{await r(p,c)}catch(x){m=x}}else l&&await l({...t.errors},c),tt(),setTimeout(tt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ns=(r,l={})=>{y(i,r)&&(M(l.defaultValue)?h(r,z(y(o,r))):(h(r,l.defaultValue),F(o,r,z(l.defaultValue))),l.keepTouched||B(t.touchedFields,r),l.keepDirty||(B(t.dirtyFields,r),t.isDirty=l.defaultValue?W(r,z(y(o,r))):W()),l.keepError||(B(t.errors,r),E.isValid&&I()),b.state.next({...t}))},jt=(r,l={})=>{const c=r?z(r):o,m=z(c),p=G(r),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ae(o,d,void 0,g))]);for(const w of Array.from(v)){const L=y(t.dirtyFields,w),X=y(d,w),xe=y(x,w);L&&!M(X)?F(x,w,X):!L&&!M(xe)&&h(w,xe)}}else{if(Ze&&M(r))for(const v of u.mount){const w=y(i,v);if(w&&w._f){const L=Array.isArray(w._f.refs)?w._f.refs[0]:w._f.ref;if(Ke(L)){const X=L.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)h(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?z(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=z(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!E.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:p?!1:l.keepDirty?t.isDirty:l.keepValues?W():!!(l.keepDefaultValues&&!he(r,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ae(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&r?Ae(o,r,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},St=(r,l)=>jt(ie(r)?r(d):r,{...s.resetOptions,...l}),As=(r,l={})=>{const c=y(i,r),m=c&&c._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),l.shouldSelect&&ie(p.select)&&p.select()})}},Ts=r=>{const{name:l,type:c,values:m,...p}=r;t={...t,...p}},wt={control:{register:et,unregister:Xe,getFieldState:Fe,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:fe,_getDirty:W,_setValid:I,_setFieldArray:ae,_setDisabledField:vt,_setErrors:oe,_getFieldArray:_e,_reset:jt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(r=>{St(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:ws,_subjects:b,_proxyFormState:E,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return o},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},U=qe(s.mode),R=qe(s.reValidateMode)}},subscribe:Ss,trigger:me,register:et,handleSubmit:bt,watch:js,setValue:h,setValues:V,getValues:Ne,reset:St,resetField:Ns,resetDefaultValues:(r,l={})=>{if(o=z(r),!l.keepDirty){const c=Ae(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Pe,unregister:Xe,setError:ze,setFocus:As,getFieldState:Fe};return{...wt,formControl:wt}}function Rr(e={}){const s=ee.useRef(void 0),t=ee.useRef(void 0),i=ee.useRef(e.formControl),[o,d]=ee.useState(()=>({...z(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Ir(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,jr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),ee.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),ee.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),ee.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),ee.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),ee.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),ee.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),ee.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=ee.useMemo(()=>br(o,n),[n,o]),s.current}const $t=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},ct=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?$t(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>$t(o,t,e))}},Wt=(e,s)=>{s.shouldUseNativeValidation&&ct(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Mr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Mr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function hs(e,s,t){function i(u,j){var _;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(_=u._zod).traits??(_.traits=new Set),u._zod.traits.add(e),s(u,j);for(const P in n.prototype)P in u||Object.defineProperty(u,P,{value:n.prototype[P].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const _=t?.Parent?new d:this;i(_,u),(j=_._zod).deferred??(j.deferred=[]);for(const P of _._zod.deferred)P();return _}return Object.defineProperty(n,"init",{value:i}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ur={};function gs(e){return Ur}function Hr(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $e(e){return typeof e=="string"?e:e?.message}function ys(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=$e(e.inst?._zod.def?.error?.(e))??$e(s?.error?.(e))??$e(t.customError?.(e))??$e(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const vs=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Hr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{Parent:Error}),Br=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Lr;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},qr=Br(bs),$r=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},Wr=$r(bs);function dt(){return dt=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},dt.apply(null,arguments)}function Kt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Gr(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(P){return P.errors.forEach(function(U){return e.push(U)})}),s){var j=t[n].types,_=j&&j[i.code];t[n]=xt(n,s,t,o,_?[].concat(_,i.message):i.message)}e.shift()}return t}function Kr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(U){return U.forEach(function(R){return e.push(dt({},R,{path:[].concat(o.path,R.path)}))})}),s){var _=t[u].types,P=_&&_[o.code];t[u]=xt(u,s,t,d,P?[].concat(P,o.message):o.message)}e.shift()};e.length;)i();return t}function Yr(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:Wt(Gr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve((t.mode==="sync"?qr:Wr)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof zr})(n))return{values:{},errors:Wt(Kr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Zr=e=>{const s=ft(),{pushError:t}=Fs(),{data:i}=Jt({...Xt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Os(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Is("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Qr=e=>e.authType==="oauthMicrosoft",Jr="••••••••••",Xr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},ea=Us({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:_t.number().int().min(1).max(65535),imapTls:Re(),imapStartTls:Re(),smtpHost:be().optional(),smtpPort:_t.number().int().min(1).max(65535).optional(),smtpTls:Re().optional(),smtpStartTls:Re().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Re().optional()}),ta=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ft(),d=!!t,[n,u]=C.useState(!1),[j,_]=C.useState(""),[P,U]=C.useState(!1),R=Vt(j),O=!!R&&!P,E=C.useRef(null),f=Rr({resolver:Yr(ea),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const h=Xr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Jr,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Se({...Rs()}),re=Se({...Ms(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),$=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},I=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},A=f.handleSubmit(h=>{if(!d&&!h.password){f.setError("password",{message:"Password is required"});return}const V=or({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??h.smtpHost,se=V?.smtpPort??h.smtpPort,me=V?.smtpTls??h.smtpTls,Ne=V?.smtpStartTls??h.smtpStartTls,Fe={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:me,smtpStartTls:Ne,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Pe={...Fe,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Pe})}else{const Pe={...Fe,password:h.password};re.mutate({body:Pe})}}),ne=re.isPending||N.isPending,{signature:ae,setSignature:ge,isSaving:oe}=nr(t?.accountId),[Z,le]=C.useState(ae.plainText),{languages:T,setLanguages:k,isSaving:D}=Zr(t?.accountId),q=a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),a.jsx(mr,{value:T,onChange:k,busy:D})]});C.useEffect(()=>{le(ae.plainText)},[ae.plainText]),C.useEffect(()=>{if(!e||!i)return;const h=E.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const Q=C.useCallback(()=>{Z!==ae.plainText&&ge(Z,Z)},[Z,ae.plainText,ge]),S=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",h==="tls"?993:143)},J=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const Ne=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Ne)}},W=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",lr(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},fe=h=>{_(h),U(!1);const V=Vt(h);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const me=f.getValues("email").trim(),Ne=f.getValues("username")?.trim();me&&!Ne&&f.setValue("username",me)},_e=R?.passwordHelp.text,we=Dt(b.data?.imapError,_e),Ee=Dt(b.data?.smtpError,_e);return(t?Qr(t):!1)&&d?a.jsx(Ct,{isOpen:e,onClose:s,title:"Edit Account",footer:a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),a.jsx("span",{className:"text-fg",children:t?.email})]}),a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),a.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-view",value:Z,onChange:h=>le(h.target.value),onBlur:Q,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})}):a.jsx(Ct,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:a.jsxs(a.Fragment,{children:[a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),a.jsx(te,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:a.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),a.jsxs(Ls,{id:"account-provider",value:j,onChange:h=>fe(h.target.value),children:[a.jsx("option",{value:"",children:"Custom / other"}),tr.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))]}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),a.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),a.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),a.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),a.jsx(At,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&a.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",a.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&a.jsx("button",{type:"button",onClick:()=>U(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:P?"Use preset settings":"Advanced"})]}),O&&a.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",R?.label," and locked. Choose Advanced to edit them by hand."]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>S("tls")}),"TLS (Port 993)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>S("starttls")}),"STARTTLS (Port 143)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>S("none")}),"None (Unencrypted)"]})]})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:$,disabled:b.isPending,className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ce,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":we]})]})]}),a.jsxs("section",{ref:E,"data-testid":"smtp-section",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&a.jsx("button",{type:"button",onClick:W,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>J("tls")}),"TLS (Port 465)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>J("starttls")}),"STARTTLS (Port 587)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>J("none")}),"None (Unencrypted)"]})]})]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),a.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),a.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ce,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":Ee]})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-edit",value:Z,onChange:h=>le(h.target.value),onBlur:Q,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})})};function Yt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,_]=C.useState(!1),P=Se({...zs(),onSuccess:()=>{_(!0),setTimeout(()=>i(),2e3)}}),U=Se(Bs()),R=()=>{P.isPending||(d(""),u(!1),_(!1),P.reset(),U.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),P.mutate({body:{confirmEmail:o.trim()}})};return a.jsxs(ts,{open:e,onClose:R,title:"Delete your Remit account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?a.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[a.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),a.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),a.jsxs("ul",{className:"space-y-1.5 text-xs",children:[a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),a.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[a.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),a.jsxs("div",{className:"text-xs",children:[a.jsxs("button",{type:"button",onClick:()=>U.mutate({}),"aria-busy":U.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[a.jsx(cr,{className:"size-3.5"}),U.isPending?"Requesting export…":"Export my data first"]}),U.isSuccess&&a.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),U.isError&&a.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",a.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),a.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:E=>{d(E.target.value),n&&u(!1),P.isError&&P.reset()},autoComplete:"off"}),n&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),P.isError&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:P.error instanceof Error?P.error.message:"Something went wrong. Please try again."})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm",onClick:O,"aria-busy":P.isPending,children:P.isPending?"Deleting…":"Delete everything"})]})]})]})}function sa(e){const{Account:s}=Hs();return a.jsx(s,{fallback:a.jsx(Yt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>a.jsx(Yt,{...e,accountEmail:t??"",signOut:i})})}function ra(){const[e,s]=C.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.jsx(pr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:a.jsx(te,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),a.jsx(sa,{open:e,onClose:()=>s(!1)})]})}function aa(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.`}function ia(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function na(e){const s=e.displayName?.trim();return s||ia(e.email)}function oa(e){if(!e.lastSyncAt)return"never synced";const s=Qs(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Zt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Qt(e){return e.connectionState==="reauth_required"}function la(e){return e.connectionState==="credentials_missing"}const ca=()=>a.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>a.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function ka(){const e=Et.useSearch(),s=qs({from:Et.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,_]=C.useState(null),[P,U]=C.useState(!1),[R,O]=C.useState(null),[E,f]=C.useState(null),[b,re]=C.useState(null),[N,$]=C.useState(null),I=ft(),{data:A,isPending:ne,isError:ae,error:ge,refetch:oe}=Jt(Xt());C.useEffect(()=>{e.editAccountId&&(_(e.editAccountId),U(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),_(e.connected),I.invalidateQueries({queryKey:Te()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(re(aa(e.oauthError)),$(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),rr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),C.useEffect(()=>{if(!N||!A)return;const S=A.accounts.find(J=>J.accountId===N);(!S||!Qt(S))&&$(null)},[A,N]);const Z=ar(S=>{$(null),S==="stalled"&&re(ir)}),le=Se({...$s(),onSuccess:S=>{Z(),window.location.assign(S.authorizationUrl)},onError:S=>{re(S instanceof Error?S.message:"Failed to start reconnect"),$(null)}}),T=Se({...Ws(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),k=A?.accounts.find(S=>S.accountId===R),D=A?.accounts.find(S=>S.accountId===j),q=()=>{d(!1),u(!1),_(null),U(!1)},Q=S=>{const J=Ys[S];J&&s({to:J})};return a.jsxs(Xs,{items:Gs,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:ur,helpOpen:t,onToggleHelp:()=>i(S=>!S),onSelect:Q,onBackToMail:()=>{s({to:"/mail"})},children:[E&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:E}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>re(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ks,{tone:"neutral",children:ne||ae?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(ca,{}):ae?a.jsx(dr,{title:"Couldn't load accounts",error:ge,onRetry:()=>{oe()}}):A.accounts.length===0?a.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[a.jsx("p",{className:"mb-3",children:"No accounts configured."}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):a.jsx("div",{className:"space-y-3",children:A.accounts.map(S=>{const J=Qt(S),W=la(S),fe=S.authType==="oauthMicrosoft",_e=N===S.accountId,we=J&&fe?{label:"Reconnect",variant:"secondary",busy:_e,busyLabel:"Redirecting…",onClick:()=>{$(S.accountId),le.mutate({body:{email:S.email,services:S.syncedServices}})}}:W?{label:"Enter password",variant:"secondary",onClick:()=>_(S.accountId)}:Zt(S)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>_(S.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>_(S.accountId)},Ee=a.jsx(Js,{actions:[we],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Zs,{className:"size-3.5"}),onClick:()=>O(S.accountId)}});return a.jsx(er,{label:na(S),email:S.email,connector:fe?"Microsoft 365":"IMAP",syncLabel:oa(S),state:Zt(S),errorDetail:J?S.lastError??"Re-authentication required":W?"Imported from a config file, which carries no password. Enter one to start syncing.":S.lastError,trailing:Ee},S.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(sr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),a.jsx(ta,{isOpen:o||!!j,account:D,focusSmtp:P,onClose:q}),a.jsxs(ts,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),a.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),k&&a.jsx("p",{className:"text-center",children:k.email}),a.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[a.jsx("li",{children:"Remove the account from your settings"}),a.jsx("li",{children:"Stop syncing mail for this account"}),a.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm","aria-busy":T.isPending,icon:T.isPending?a.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{T.isPending||R&&T.mutate({path:{accountId:R}})},children:T.isPending?"Deleting…":"Delete account"})]})]}),a.jsx(ra,{})]})}export{ka as component,aa as mapOauthError};
@@ -1 +0,0 @@
1
- import{e as l}from"./index-Cvg1ICmg.js";const _=l("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),E=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g,d=/[<>:"|?*]/g,f=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,r=120,h=12,A="attachment",u=t=>{const e=[...t];if(e.length<=r)return t;const s=t.lastIndexOf("."),n=s>0&&[...t.slice(s)].length<=h?t.slice(s):"",c=r-[...n].length;return e.slice(0,c).join("")+n},g=(t,e=A)=>{const n=t.replace(E,"").split(/[/\\]/),o=(n[n.length-1]??"").replace(d,"_").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"");if(o.length===0)return u(e);const i=f.test(o)?`_${o}`:o;return u(i)},a=["KB","MB","GB","TB"],N=t=>{if(!Number.isFinite(t)||t<0)return"unknown size";const e=Math.round(t);if(e<1024)return e===1?"1 byte":`${e} bytes`;const s=1023.95;let n=e/1024,c=0;for(;n>=s&&c<a.length-1;)n/=1024,c+=1;return`${n.toFixed(1).replace(/\.0$/,"")} ${a[c]}`};export{_ as U,N as f,g as s};
@@ -1 +0,0 @@
1
- import{j as r,O as i}from"./index-Cvg1ICmg.js";import{a as m}from"./MailShell-CBAHJ7P0.js";import{B as o}from"./BriefPane-BjUmHKNU.js";import{a as p}from"./search-token-index-CMfLsCex.js";import{u as e}from"./search-mirror-CG0SD5Nw.js";import"./FullCompose-Co7TPnxX.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./EmptyState-DxHRPzWP.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./useQueries-B8LmhXDj.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useSemanticSearch-CCCY9PAD.js";import"./useLabels-Dm-tUvjJ.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.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 +0,0 @@
1
- import{u as g,a as x,b as h,r as i,p as O,c as j,d as y,j as e,O as C}from"./index-Cvg1ICmg.js";import{C as N}from"./CalendarShell-q8nTThqJ.js";import{M as P}from"./MailNav-DsFM4Zbb.js";import{E}from"./ErrorState-B7NbYqTc.js";import{i as S,u as b}from"./useLayoutTier-id3G6JgO.js";import"./roving-focus-DwDXHttZ.js";import"./bell-off-PwhHcUK1.js";import"./useQueries-B8LmhXDj.js";import"./outbox-status-BlKn6P0x.js";import"./bug-CFbZ4o5k.js";function Q(){const t=g(),c=S(b()),a=x(),r=h(),l=a.includes("nav"),n=i.useCallback(v=>{r(O(a,v?"nav":void 0))},[a,r]),{data:s,isLoading:u,isError:p,error:m,refetch:f}=j({...y(),staleTime:1/0}),o=!!(s&&(s.accounts?.length??0)===0);i.useEffect(()=>{o&&t({to:"/onboarding",replace:!0})},[o,t]);const d=s?.accounts??[];return p?e.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:e.jsx(E,{title:"Couldn't load your account",error:m,onRetry:()=>{f()}})}):e.jsx(N,{chrome:{isSinglePane:c,isLoading:u||o,nav:e.jsx(P,{accounts:d,onMailboxSelect:()=>n(!1)}),navOpen:l,onOpenNav:()=>n(!0),onCloseNav:()=>n(!1)},children:e.jsx(C,{})})}export{Q as component};
@@ -1 +0,0 @@
1
- import{e as F,u as I,r as f,a9 as D,ex as B,ey as z,bZ as x,cm as G,ez as A,c as P,eA as C,h as Y,s as q}from"./index-Cvg1ICmg.js";import{u as Z}from"./useQueries-B8LmhXDj.js";const pt=F("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),y=480,m=1320,N=90;function v(t){return Number(t.slice(11,13))*60+Number(t.slice(14,16))}function yt(t){const e=Math.max(0,Math.min(1440,Math.round(t)));return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function Dt(t){const e=Math.round(t);if(e<60)return`${e}m`;const n=Math.floor(e/60),a=e%60;return a===0?`${n}h`:`${n}h ${a}m`}function L(t,e){const n=new Date(`${t}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+e),n.toISOString().slice(0,10)}function gt(t,e){return Math.round((Date.parse(`${e}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/864e5)}function $t(t){const e=t.start.slice(0,10),n=t.end.slice(0,10);if(!t.allDay)return n;const a=L(n,-1);return a<e?e:a}function bt(t,e){const n=[];for(let a=t;a<=e;a=L(a,1))n.push(a);return n}function wt(t){const[e,n,a]=t.split("-").map(Number);return new Date(e,n-1,a).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function Tt(t){const[e,n,a]=t.split("-").map(Number);return new Date(e,n-1,a).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Mt(t){const[e,n,a]=t.split("-").map(Number);return new Date(e,n-1,a).toLocaleDateString("en-GB",{weekday:"long"})}function vt(t,e){const[n,a,o]=t.split("-").map(Number),[r,s,c]=e.split("-").map(Number),u=new Date(n,a-1,o),l=new Date(r,s-1,c),i=u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",...a===s?{}:{month:"short"}}),w=l.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return`${i} – ${w}`}function Q(t){const[e,n,a]=t.split("-").map(Number);return new Date(e,n-1,a).toLocaleDateString("en-GB",{weekday:"short"})}function d(t){return new Date(t).getTime()}function K(t,e){return t.allDay?e>=t.start.slice(0,10)&&e<t.end.slice(0,10):t.start.slice(0,10)===e}function V(t,e){return d(t.start)<d(e.end)&&d(e.start)<d(t.end)}function H(t){const e=t.map(r=>[d(r.start),d(r.end)]).sort((r,s)=>r[0]-s[0]);let n=0,a=0,o=0;for(const[r,s]of e){if(r>o){n+=o-a,a=r,o=s;continue}o=Math.max(o,s)}return n+=o-a,Math.round(n/6e4)}function J(t){const e=[];for(const n of t){const a=t.filter(r=>r.id===n.id||V(n,r)).map(r=>r.id).sort();if(a.length<2)continue;const o=a.join("|");e.some(r=>r.join("|")===o)||e.push(a)}return e.filter(n=>!e.some(a=>a!==n&&n.every(o=>a.includes(o))))}function Ct(t,e,n){const a=e.filter(r=>K(r,t)),o=a.filter(r=>!r.allDay).sort((r,s)=>d(r.start)-d(s.start));return{date:t,weekdayLabel:Q(t),dayNumber:Number(t.slice(8)),isToday:t===n,timed:o,allDay:a.filter(r=>r.allDay),busyMinutes:H(o),conflicts:J(o)}}function X(t){return t.timed.length===0&&t.allDay.length===0}function tt(t){return U(t.timed.map(e=>({from:v(e.start),to:v(e.end)})))}function U(t){const e=[...t].sort((a,o)=>a.from-o.from),n=[];for(const a of e){const o=n[n.length-1];if(o&&a.from<=o.to){o.to=Math.max(o.to,a.to);continue}n.push({...a})}return n}function k(t){return Math.min(Math.max(t,y),m)}function et(t,e,n=N){const a=U(e);if(a.length===0)return[{date:t,startMinute:y,endMinute:m,minutes:m-y,wholeDay:!0}];const o=[];let r=y;for(const s of a){const c=k(s.from),u=k(s.to);c-r>=n&&o.push({date:t,startMinute:r,endMinute:c,minutes:c-r,wholeDay:!1}),r=Math.max(r,c,u)}return m-r>=n&&o.push({date:t,startMinute:r,endMinute:m,minutes:m-r,wholeDay:!1}),o}function nt(t,e=N){return et(t.date,tt(t),e)}function Nt(t,e,{ignoreIds:n=[]}={}){const a=Date.parse(t.start),o=Date.parse(t.end);return e.filter(r=>r.allDay||r.myRsvp==="declined"||n.includes(r.id)?!1:Date.parse(r.start)<o&&a<Date.parse(r.end))}function Ot(t,e){const n=[];let a=[];const o=()=>{a.length!==0&&(a.length===1?n.push({kind:"day",key:a[0].date,day:a[0]}):n.push({kind:"run",key:`run_${a[0].date}`,from:a[0].date,to:a[a.length-1].date,days:a.length}),a=[])};for(const r of t){if(X(r)&&!e.includes(r.date)){a.push(r);continue}o(),n.push({kind:"day",key:r.date,day:r})}return o(),n}function Et(t){const e=[];for(const n of t){const a=e[e.length-1],o=a?Math.max(...a.map(r=>Date.parse(r.end))):0;if(a&&Date.parse(n.start)<o){a.push(n);continue}e.push([n])}return e}function kt(t,e){const n=Date.parse(e),a=e.slice(0,10),o=t.flatMap(l=>l.timed).sort((l,i)=>Date.parse(l.start)-Date.parse(i.start)),r=o.filter(l=>Date.parse(l.start)<=n&&Date.parse(l.end)>n),s=o.filter(l=>Date.parse(l.start)>n),c=s[0],u=r.filter(l=>l.start.slice(0,10)===a).length+s.filter(l=>l.start.slice(0,10)===a).length;return{running:r,next:c,minutesUntilNext:c?Math.round((Date.parse(c.start)-n)/6e4):0,after:s[1],restOfDay:u,free:at(t,e,1)[0]}}function at(t,e,n){const a=e.slice(0,10),o=v(e),r=[];for(const s of t)if(!(s.date<a))for(const c of nt(s)){if(s.date>a)r.push(c);else{const u=Math.max(c.startMinute,o);if(c.endMinute-u<N)continue;r.push({...c,startMinute:u,minutes:c.endMinute-u,wholeDay:c.wholeDay&&u===c.startMinute})}if(r.length===n)return r}return r}const rt={"cal-1":{solid:"bg-cal-1",soft:"bg-cal-1-soft",text:"text-cal-1",border:"border-cal-1",rail:"border-l-cal-1"},"cal-2":{solid:"bg-cal-2",soft:"bg-cal-2-soft",text:"text-cal-2",border:"border-cal-2",rail:"border-l-cal-2"},"cal-3":{solid:"bg-cal-3",soft:"bg-cal-3-soft",text:"text-cal-3",border:"border-cal-3",rail:"border-l-cal-3"},"cal-4":{solid:"bg-cal-4",soft:"bg-cal-4-soft",text:"text-cal-4",border:"border-cal-4",rail:"border-l-cal-4"},"cal-5":{solid:"bg-cal-5",soft:"bg-cal-5-soft",text:"text-cal-5",border:"border-cal-5",rail:"border-l-cal-5"},"cal-6":{solid:"bg-cal-6",soft:"bg-cal-6-soft",text:"text-cal-6",border:"border-cal-6",rail:"border-l-cal-6"}};function St(t){return rt[t]}const g="/calendar/$view/$date";function ot(){const t=D({from:g,shouldThrow:!1}),e=B({from:g,shouldThrow:!1}),n=t?.view??"",a=t?.date??"",o=e?.calendarId;return f.useMemo(()=>({...z({view:n,date:a},x(new Date)),calendarIds:o??[]}),[n,a,o])}function It(){const t=D({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),e=D({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),n=t?.calendarObjectId,a=e?.recurrenceId;return f.useMemo(()=>n?{calendarObjectId:n,recurrenceId:a}:void 0,[n,a])}function xt(){return D({from:"/calendar/$view/$date/new",shouldThrow:!1})!==void 0}function At(){const t=I(),e=G(),{view:n,date:a}=ot(),o=f.useCallback(r=>{t({to:g,params:r,search:!0,hash:e})},[t,e]);return f.useMemo(()=>({goToView:r=>o({view:r,date:a}),step:r=>o({view:n,date:A(a,n,r)}),goToToday:()=>o({view:n,date:x(new Date)}),setAnchorDate:r=>t({to:g,params:{view:n,date:r},search:!0,hash:e,replace:!0}),zoomToDay:r=>o({view:"day",date:r}),openEvent:(r,s)=>t(s===void 0||s===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:n,date:a,calendarObjectId:r},search:!0,hash:e}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:n,date:a,calendarObjectId:r,recurrenceId:s},search:!0,hash:e}),closeEvent:()=>o({view:n,date:a}),openComposer:()=>t({to:"/calendar/$view/$date/new",params:{view:n,date:a},search:!0,hash:e})}),[o,t,e,n,a])}function Lt(){const t=I();return f.useCallback((e,n,a)=>{if(a===""){t({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:e,calendarObjectId:n}});return}t({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:e,calendarObjectId:n,recurrenceId:a}})},[t])}const p=t=>String(t).padStart(2,"0"),st=t=>`${t.getUTCFullYear()}-${p(t.getUTCMonth()+1)}-${p(t.getUTCDate())}`,R=t=>{const e=t<0?"-":"+",n=Math.abs(t);return`${e}${p(Math.floor(n/60))}:${p(n%60)}`};function _(t,e){const n=new Date(`${t}T${e}:00`);return`${t}T${e}:00${R(-n.getTimezoneOffset())}`}const T=new Map;function ct(t){if(T.has(t))return T.get(t);let e;try{e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{e=void 0}return T.set(t,e),e}function S(t,e){const n=ct(t);if(!n)return Number.NaN;const a=n.formatToParts(new Date(e)),o=c=>Number(a.find(u=>u.type===c)?.value),r=o("hour")%24;return(Date.UTC(o("year"),o("month")-1,o("day"),r,o("minute"),o("second"))-e)/6e4}function Ut(t,e,n){if(n==="")return`${t}T${e}:00+00:00`;const a=Date.parse(`${t}T${e}:00Z`),o=S(n,a);if(Number.isNaN(o))return _(t,e);const r=S(n,a-o*6e4);return`${t}T${e}:00${R(Number.isNaN(r)?o:r)}`}const $=t=>_(t,"00:00");function b(t,e){const[n,a,o]=t.split("-").map(Number);return st(new Date(Date.UTC(n,a-1,o+e)))}function it(t){const[e,n,a]=t.split("-").map(Number),o=new Date(Date.UTC(e,n-1,a));return b(t,-((o.getUTCDay()+6)%7))}function ut(t,e){const[n,a]=e.split("-").map(Number);if(t==="year")return[`${n}-01-01`,`${n+1}-01-01`];if(t==="month"){const r=`${n}-${p(a)}-01`,s=a===12?`${n+1}-01-01`:`${n}-${p(a+1)}-01`;return[r,s]}if(t==="day")return[e,b(e,1)];const o=it(e);return[o,b(o,7)]}function lt(t,e){const[n,a]=ut(t,e);return{from:$(n),to:$(a)}}function Rt(t,e){return{from:$(t),to:$(b(t,e))}}const j=q(400,404),O=5*6e4,E=({from:t,to:e,calendarIds:n})=>({query:n.length===0?{from:t,to:e}:{from:t,to:e,calendarId:[...n]}});function _t(t){const{data:e,isLoading:n,error:a,refetch:o}=P({...C(E(t)),meta:j,staleTime:O,enabled:t.enabled??!0});return{instances:e?.items??[],isLoading:n,error:a,refetch:()=>{o()}}}function jt(t,e,n){const a=Z({queries:t.map(i=>({...C(E({...i,calendarIds:e})),meta:j,staleTime:O,enabled:n}))}),o=t.map(i=>i.from).join("|"),r=a.map(i=>i.data),s=a.map(i=>i.isPending).join("|"),c=a.find(i=>i.error)?.error??null,u=f.useMemo(()=>r.flatMap(i=>i?.items??[]),[o,s]),l=f.useMemo(()=>{const i=new Set;return t.forEach((w,W)=>{a[W]?.isPending&&i.add(w.from)}),i},[o,s]);return{instances:u,pendingWindows:l,error:c,refetch:()=>{for(const i of a)i.error&&i.refetch()}}}function Wt(t,e,n,a){const o=Y(),r=[...n].join(",");f.useEffect(()=>{if(!a)return;const s=r===""?[]:r.split(",");for(const c of[-1,1]){const u=lt(t,A(e,t,c));o.prefetchQuery({...C(E({...u,calendarIds:s})),staleTime:O})}},[o,t,e,r,a])}const M=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),dt=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}),ft=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long",timeZone:"UTC"});function Ft(t){return ft.format(new Date(`${t}T00:00:00Z`))}function Bt(t){const e=new Date(t.start),n=new Date(t.end),a=M.format(e);return t.allDay?`${a}, all day`:M.format(n)===a?`${a}, ${h.format(e)} – ${h.format(n)}`:`${a}, ${h.format(e)} – ${M.format(n)}, ${h.format(n)}`}function zt(t){return dt.format(new Date(`${t}T00:00:00Z`))}function Gt(t){return h.format(new Date(`1970-01-01T${t}:00`))}function Pt(t){return h.format(new Date(t))}export{b as A,U as B,bt as C,y as D,lt as E,et as F,O as G,Ft as H,Bt as I,Gt as J,Wt as K,gt as L,Ut as M,$t as N,Nt as O,pt as R,vt as a,Ot as b,St as c,v as d,yt as e,nt as f,Et as g,tt as h,m as i,Dt as j,L as k,Tt as l,wt as m,At as n,It as o,jt as p,Ct as q,kt as r,xt as s,Lt as t,ot as u,Rt as v,Mt as w,_t as x,Pt as y,zt as z};
@@ -1 +0,0 @@
1
- import{e as V,t as f,j as s,ar as $,r as p,W as ee,X as te,dk as se,f as R,aM as ne,ah as ae,bZ as k,er as re,s as W,c as U,es as ie,h as oe,i as A,et as le,eu as ce,ev as de,ew as ue,aZ as me,a_ as fe}from"./index-Cvg1ICmg.js";import{c as xe,R as pe,A as y,B as he,C as ge,E as G,F as q,G as ye,y as F,H as I,I as be,e as _,J as L,z as ve}from"./calendar-format-_D2qlvSu.js";import{M as O}from"./mail-i5djtULt.js";import{G as H}from"./map-pin-BNehUfT9.js";import{u as Ne}from"./useQueries-B8LmhXDj.js";import{f as je}from"./ErrorState-B7NbYqTc.js";const Ce=V("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function Se(e){const t=xe(e.color),n=e.rsvp==="tentative"||e.status==="tentative";return f("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",t.soft,t.text,t.rail,e.layout==="column"||e.stacked?"flex-col":"items-center gap-1.5",n&&"border-y border-r border-dashed",n&&t.border,e.rsvp==="declined"&&"opacity-60",e.selected&&"ring-2 ring-ring",e.density==="compact"?"text-2xs":"text-xs")}function ke({title:e,timeText:t,layout:n,rsvp:a,hasThread:i,isRecurring:l,zoneCertainty:c,trailing:r,detail:u}){const o=n==="column",d=c==="ambiguous",m=!o&&u!==void 0,x=s.jsxs("span",{className:f("flex min-w-0 items-center gap-1",o&&"w-full",a==="declined"&&"line-through"),children:[t!==""&&s.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:t}),s.jsx("span",{className:"truncate font-medium",children:e})]}),g=(l||i||d)&&s.jsxs("span",{className:f("flex shrink-0 items-center gap-1",o&&"mt-0.5",!o&&r===void 0&&"ml-auto"),children:[l&&s.jsx(pe,{className:"size-2.5","aria-label":"Repeats"}),i&&s.jsx(O,{className:"size-2.5","aria-label":"From mail"}),d&&s.jsx(H,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),b=r!==void 0&&s.jsx("span",{className:f("shrink-0 opacity-80",!o&&"ml-auto"),children:r});return s.jsxs(s.Fragment,{children:[m?s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,g,b]}):s.jsxs(s.Fragment,{children:[x,g,b]}),u]})}function Ve({title:e,timeText:t,color:n,layout:a,density:i,rsvp:l,status:c,hasThread:r,isRecurring:u,zoneCertainty:o,selected:d,onClick:m,leading:x,trailing:g,detail:b}){const j=a==="column";return s.jsxs("button",{type:"button",onClick:m,"aria-pressed":d,className:f("group flex w-full min-w-0 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",j?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,s.jsx("span",{className:f(Se({color:n,layout:a,density:i,rsvp:l,status:c,selected:d,stacked:b!==void 0}),"flex-1",j&&"h-full"),children:s.jsx(ke,{title:e,timeText:t,layout:a,rsvp:l,hasThread:r,isRecurring:u,zoneCertainty:o,trailing:g,detail:b})})]})}function et({text:e,reportHref:t,className:n}){return s.jsxs("div",{role:"alert",className:f("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",n),children:[s.jsx($,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),s.jsxs("p",{className:"min-w-0 flex-1",children:[e,t&&s.jsxs(s.Fragment,{children:[" ",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const P=96;function tt({children:e,hasCard:t,onConfirm:n,onReject:a,blocked:i,blockedReason:l,remaining:c,confirmLabel:r="Add",emptyText:u="Nothing in your mail is waiting on a decision about time.",className:o}){const[d,m]=p.useState(0),[x,g]=p.useState(null);if(!t)return s.jsxs("div",{className:f("flex flex-col items-center gap-2 p-6 text-center",o),children:[s.jsx(ee,{className:"size-6 text-fg-subtle","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:u})]});const b=Math.abs(d)>P,j=d>0;return s.jsxs("div",{className:f("flex flex-col gap-3",o),children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${d}px) rotate(${d/40}deg)`,transition:x===null?"transform 180ms ease-out":"none"},onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),g(v.clientX)},onPointerMove:v=>{x!==null&&m(v.clientX-x)},onPointerUp:()=>{Math.abs(d)>P&&(d>0&&!i&&n(),d<0&&a()),g(null),m(0)},onPointerCancel:()=>{g(null),m(0)},children:e}),b&&s.jsx("span",{className:f("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold",j?"right-3 bg-accent-soft text-accent":"left-3 bg-danger-soft text-danger"),children:j?i?l:r:"Not this"})]}),s.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[c," left · swipe right to accept, left to drop, or use the buttons"]})]})}const Ee="Pick a clock first. The mail never said, and the reader will not choose for you.";function we(e,t){const n=e.zoneOptions;return n===void 0?{settled:!0,timeZone:""}:n.some(a=>a.timeZone===t)?{settled:!0,timeZone:t}:{settled:!1,reason:Ee}}function B(e){return e.threadSubject===""?e.sender:`${e.sender} — ${e.threadSubject}`}function De(e){return e>=.85?"Read cleanly":e>=.6?"Read with gaps":"Barely read"}function st({suggestion:e,whenText:t,onAdd:n,onReview:a,onDismiss:i,onOpenThread:l,busy:c=!1,addBlocked:r=!1,zoneChoice:u,onZoneChoice:o,addLabel:d="Add",touch:m,className:x}){const[g,b]=p.useState(""),[j,v]=p.useState(!1),w=p.useId(),D=u??g,J=h=>{v(!1),o?o(h):b(h)},N=we(e,D),T=h=>()=>{if(!N.settled){v(!0);return}h(N.timeZone)};return s.jsxs("article",{"aria-label":e.title,className:f("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",De(e.confidence)]}),s.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:e.title}),s.jsx("span",{className:"block text-xs text-fg-muted",children:t}),e.location!==""&&s.jsx("span",{className:"block truncate text-xs text-fg-muted",children:e.location})]}),s.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:i,disabled:c,className:f("flex shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",m?"size-11":"size-7"),children:s.jsx(te,{className:"size-4"})})]}),e.ambiguity!==""&&s.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[s.jsx($,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.ambiguity]}),l?s.jsxs("button",{type:"button",onClick:l,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm text-left text-2xs text-accent-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:[s.jsx(O,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:B(e)})]}):s.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[s.jsx(O,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:B(e)})]}),e.zoneOptions&&s.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[s.jsx(H,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),e.zoneOptions.map(h=>s.jsxs("button",{type:"button","aria-pressed":D===h.timeZone,onClick:()=>J(h.timeZone),className:f("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",m&&"min-h-11",D===h.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[s.jsx("span",{className:"block text-xs font-medium text-fg",children:h.label}),s.jsx("span",{className:"block text-2xs text-fg-subtle",children:h.note})]},h.timeZone))]}),!N.settled&&s.jsx(se,{id:w,reason:N.reason,nudged:j,className:"text-2xs text-warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(R,{variant:"primary",size:m?"md":"sm",icon:s.jsx(ne,{className:"size-3.5"}),onClick:T(n),disabled:c||r,"aria-describedby":N.settled?void 0:w,className:f(m&&"min-h-11 flex-1",!N.settled&&"opacity-55"),children:d}),a&&s.jsx(R,{variant:"secondary",size:m?"md":"sm",icon:s.jsx(Ce,{className:"size-3.5"}),onClick:T(a),disabled:c,"aria-describedby":N.settled?void 0:w,className:f(m&&"min-h-11",!N.settled&&"opacity-55"),children:"Change first"})]})]})}function nt(e){return e.defaultCalendarId!==""?"ready":e.error!==null?"failed":e.isLoading?"loading":"none"}function at(e,t){if(e!=="ready")return e==="loading"?"Reading your calendars…":e==="failed"?s.jsxs(s.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):s.jsxs(s.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",s.jsx(ae,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Ae=24,Q=7,Ie=52,E=Ie*7,ze=e=>({from:y(e,-10),to:y(e,Ae),floor:y(e,-E),ceiling:y(e,E)}),Me=e=>e.from<=e.floor,Oe=e=>e.to>=e.ceiling,Te=(e,t)=>e>t?e:t,Re=(e,t)=>e<t?e:t,Fe=e=>Me(e)?e:{...e,from:Te(y(e.from,-Q),e.floor)},_e=e=>Oe(e)?e:{...e,to:Re(y(e.to,Q),e.ceiling)},rt=e=>Fe({...e,floor:y(e.from,-E)}),it=e=>_e({...e,ceiling:y(e.to,E)});function ot(e,t){return t>=e.from&&t<=e.to?e:ze(t)}function lt(e){const t=new Map;for(const n of e){const a=G("week",n);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const ct=e=>G("week",e).from,Le=1440,Z=e=>e.getHours()*60+e.getMinutes();function K(e,t){const n=new Set(e),a=new Map;for(const i of t){const l=new Date(i.start),c=new Date(i.end);if(Number.isNaN(l.getTime())||Number.isNaN(c.getTime())||c.getTime()<=l.getTime())continue;const r=k(l),u=k(new Date(c.getTime()-1));for(let o=r;o<=u;o=y(o,1)){if(!n.has(o))continue;const d=o===r?Z(l):0,m=k(c)===o?Z(c):Le;if(m<=d)continue;const x=a.get(o);x?x.push({from:d,to:m}):a.set(o,[{from:d,to:m}])}}for(const[i,l]of a)a.set(i,he(l));return a}function dt(e,t){const n=K(e,t);return new Map(e.map(a=>[a,q(a,n.get(a)??[])]))}const ut=e=>ge(e.from,e.to),Pe=W(400,404);function mt(e){const t=Ne({queries:e.map(r=>({...re({query:{from:r.from,to:r.to}}),meta:Pe,staleTime:ye}))}),n=e.map(r=>r.from).join("|"),a=t.map(r=>r.data),i=t.map(r=>r.isPending).join("|"),l=p.useMemo(()=>a.flatMap(r=>r?.items??[]),[n,i]),c=p.useMemo(()=>{const r=new Set;return e.forEach((u,o)=>{t[o]?.isPending&&r.add(u.from)}),r},[n,i]);return{spans:l,pendingWindows:c,error:t.find(r=>r.error)?.error??null,refetch:()=>{for(const r of t)r.error&&r.refetch()}}}const C=W(400,404),Be=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),Ze=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&Be.has(a)}});function ft(e){const{data:t,isLoading:n,error:a}=U({...ie({path:{messageId:e}}),meta:C});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function xt(){const{data:e,isLoading:t,error:n}=U({...ue({query:{state:"Pending"}}),meta:C});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const z={kind:"answered"},M=e=>({kind:"refused",message:je(e)});function pt(){const e=oe(),t=p.useCallback(()=>Ze(e),[e]),n=A({...le(),meta:C,onSuccess:t}),a=A({...ce(),meta:C,onSuccess:t}),i=A({...de(),meta:C,onSuccess:t}),l=p.useCallback((u,o)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:o}}).then(()=>z).catch(M),[n]),c=p.useCallback(u=>a.mutateAsync({path:{suggestionId:u}}).then(()=>z).catch(M),[a]),r=p.useCallback((u,o)=>i.mutateAsync({path:{suggestionId:u},body:{muteSender:o}}).then(()=>z).catch(M),[i]);return p.useMemo(()=>({accept:l,decline:c,dismiss:r,isAnswering:n.isPending||a.isPending||i.isPending}),[l,c,r,n.isPending,a.isPending,i.isPending])}function ht(e){return me(fe({title:`Calendar invitation: ${e}`,errorMessage:e}))}const S=30,$e=6,X={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},We="The invitation named a time zone nothing could resolve, so this time may be hours out.";function gt(e){if(e.state!=="Dismissed")return e.method==="Cancel"?e.state==="Pending"?{state:"cancelled",rsvp:"noReply"}:void 0:e.state==="Superseded"?{state:"superseded",rsvp:"noReply"}:e.state==="Accepted"?{state:"answered",rsvp:"accepted"}:e.state==="Declined"?{state:"answered",rsvp:"declined"}:e.state==="Tentative"?{state:"answered",rsvp:"tentative"}:{state:"pending",rsvp:"noReply"}}const Ue=e=>e.source!=="TextHeuristic";function yt(e){return e.allDay?e.dtStart.slice(0,10):k(new Date(e.dtStart))}const Y=e=>e.summary===""?"Untitled event":e.summary;function bt(e){if(e.allDay){const t=e.dtStart.slice(0,10),n=e.dtEnd.slice(0,10),a=n>t?y(n,-1):t;return a===t?`${I(t)}, all day`:`${I(t)} – ${I(a)}, all day`}return be({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function Ge(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:Y(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,notes:"",attendees:[],myRsvp:"noReply",threadId:t.threadId,threadSubject:t.threadSubject,timeZone:"",zoneCertainty:X[e.zoneCertainty],recurrenceRule:"",seriesId:"",seriesException:!1,status:"confirmed"}}function vt(e,t,n){const a=e.organizer===""?n.senderName:e.organizer;return{id:e.suggestionId,threadId:n.threadId,proposed:Ge(e,n),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function Nt(e,t){return{id:e.suggestionId,title:Y(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,threadId:t.threadId,threadSubject:t.threadSubject,sender:t.sender,senderAddress:e.organizer,confidence:Ue(e)?1:.6,ambiguity:e.zoneCertainty==="Ambiguous"?We:"",suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:X[e.zoneCertainty]}}const qe=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function jt(e,t){return t.filter(n=>qe(e,n)).map(n=>({id:`${n.start}/${n.end}`,label:`Busy ${F(n.start)} – ${F(n.end)}`}))}function Ct(e,t){const n=K([e],t).get(e)??[],a=[];for(const i of q(e,n,S))for(let l=i.startMinute;l+S<=i.endMinute&&a.length<$e;l+=S)a.push({date:e,endDate:e,startTime:_(l),endTime:_(l+S),allDay:!1});return a}function St(e,t,n){const a=t.filter(i=>n.includes(i.startTime)).map(i=>`${L(i.startTime)} – ${L(i.endTime)}`);return`${ve(e)}: ${a.join(", ")}`}export{Ue as A,gt as B,Ve as C,yt as D,st as E,jt as F,vt as G,Ct as H,St as I,Ee as Z,ke as a,ot as b,Se as c,ut as d,ct as e,dt as f,Fe as g,_e as h,it as i,Oe as j,Me as k,rt as l,et as m,tt as n,xt as o,pt as p,bt as q,ze as r,we as s,Nt as t,mt as u,ht as v,lt as w,at as x,nt as y,ft as z};
@@ -1 +0,0 @@
1
- import{e}from"./index-Cvg1ICmg.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-Co7TPnxX.js";import"./index-Cvg1ICmg.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-Co7TPnxX.js";import"./index-Cvg1ICmg.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-Co7TPnxX.js";import"./index-Cvg1ICmg.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{F as o}from"./FullCompose-Co7TPnxX.js";import"./index-Cvg1ICmg.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";const c=o;export{c as component};
@@ -1 +0,0 @@
1
- import{j as o,O as i}from"./index-Cvg1ICmg.js";import{a as m}from"./MailShell-CBAHJ7P0.js";import{F as r}from"./FlaggedPane-C0O-H48H.js";import{a as p}from"./search-token-index-CMfLsCex.js";import{u as e}from"./search-mirror-CG0SD5Nw.js";import"./FullCompose-Co7TPnxX.js";import"./ErrorState-B7NbYqTc.js";import"./index-yhiT7pf4.js";import"./useMessageBodyContent-DK0INN0c.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./confirm-dialog-BBNecW64.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./EmptyState-DxHRPzWP.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./useQueries-B8LmhXDj.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./refresh-cw-gehoG8pf.js";import"./wizard-selection-DxUM65kM.js";function X(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as e,f as j,a3 as B,bv as X,r as c,aI as Y,X as W,aQ as he,az as J,a2 as xe,aT as G,bw as fe,ay as pe,aB as ge,B as z,aS as be,bx as ve,h as Z,Q as ee,o as se,by as ye,bz as je,aP as Ne,P as ke,bA as Ce,bB as _,bC as we,bD as Se,bE as te,bF as Ie,bG as H,bm as ae,bs as re,bt as Me,af as K,ae as ne,L as Q,bH as q,bI as Ee,ar as De,bJ as Ae,u as Oe,c as ie,d as Te,aL as Re,aN as Pe,K as Fe,i as V,s as $e,bK as Le,bL as ze,bM as _e,aX as Be,bN as Ke,bO as Qe}from"./index-Cvg1ICmg.js";import{P as Ge}from"./pencil-Cbc_bTFZ.js";import{S as He}from"./settings-screen-BVNyrrqp.js";import{E as oe}from"./ErrorState-B7NbYqTc.js";import"./avatar-BuiXyp5p.js";import"./chevron-left-Cp_sl0gi.js";import"./menu-CzfZlboy.js";import"./circle-help-Bn5rsX9v.js";const qe=({label:s,onRename:t,onDelete:a,deleteBlockedReason:o,renameLabel:m=u=>`Rename ${u}`,deleteLabel:r=u=>`Delete ${u}`})=>{const u=o?`${r(s)} — ${o}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Ge,{className:"size-3.5"}),"aria-label":m(s),onClick:t}),e.jsx("span",{title:o,children:e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-label":u,disabled:o!==void 0,onClick:a})})]})},Ve=({folders:s,onRename:t,onDelete:a,onCreateFolder:o,delimiter:m,labels:r})=>{const u=new Map(s.map(l=>[l.id,l]));return e.jsx(X,{folders:s,onCreateFolder:o,delimiter:m,labels:{treeAriaLabel:"Your folders",optionLabel:l=>l.label,...r},rowActions:l=>{const i=u.get(l.id);return i?e.jsx(qe,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},Ue=({open:s,folderLabel:t,defaultLabel:a,name:o,onNameChange:m,onSubmit:r,onClose:u,pending:l=!1,error:i})=>{const d=c.useId(),p=`Rename ${t}`;return s?e.jsxs(Y,{open:s,onClose:u,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(W,{className:"size-3.5"}),onClick:u,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(J,{id:d,value:o,placeholder:a,onChange:g=>m(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(j,{variant:"primary",size:"sm",onClick:r,disabled:l,children:l?"Saving…":"Save name"})]})]}):null},Xe=["inbox","drafts","sent","archive","junk","trash"],U="",Ye={mailboxId:null,source:"None"};function We(s){const t=s.messageCount===1?"msg":"msgs";return`${G(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Je=(s,t)=>s==="Appointed"?"Chosen by you":s==="Flagged"?`The mail server marks it as ${t}`:s==="Reserved"?"The account's own INBOX":"Matched by name, not confirmed";function Ze({role:s,folders:t,appointment:a,displayName:o,onAppoint:m,onRename:r}){const[u,l]=c.useState(o),i=c.useRef(null),d=c.useRef(!1),p=c.useId(),{mailboxId:g,source:v,staleFolderPath:y}=a,h=t.find(N=>N.mailboxId===g)??null,f=be(s),O=h!=null&&u.trim()!==o.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const M=(()=>{if(v==="None"){const N=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:p,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${f}.${N}`})}return v==="Stale"||!h?null:e.jsx("span",{id:p,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:h.providerPath,children:`${Je(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${G(h.providerPath,h.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${f}${y?` — ${y} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:h?.mailboxId??U,"aria-label":`Folder for ${f}`,"aria-describedby":M||v==="Stale"?p:void 0,onChange:N=>m(s,N.target.value),children:[!h&&e.jsx("option",{value:U,disabled:!0,children:"Choose a folder"}),t.map(N=>e.jsx("option",{value:N.mailboxId,children:We(N)},N.mailboxId))]}),v==="Proposed"&&h&&e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,m(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:N=>l(N.target.value)}),O&&e.jsx(j,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,u)})]})]}),M,v==="Stale"&&e.jsx(z,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:p,className:"flex-1",children:A}),e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function es(){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]})}function ss({accountEmail:s,folders:t,appointments:a,displayNames:o={},onAppoint:m,onRename:r}){const u=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),l=t.filter(i=>!u.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Xe.map(i=>{const d=a[i]??Ye;return e.jsx(Ze,{role:i,folders:t,appointment:d,displayName:d.mailboxId?o[d.mailboxId]??"":"",onAppoint:m,onRename:r},i)})}),l.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:l.map(i=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(xe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:G(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const ts=12e4,as=2e3,rs="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(o=>o.mailboxId===t);if(!a)throw new Error(rs);return a},ns=(s,t)=>ce(s,t).lastSyncedAt??0;async function is({readMailboxes:s,mailboxId:t,since:a,signal:o,segmentMs:m=ts,pollIntervalMs:r=as,delay:u=ve,now:l=Date.now}){const i=l()+m;for(;;){o?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(l()>=i)return{status:"pending"};await u(r,o)}}const de=50,os=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:os(t)})),ls=async(s,t,a,o)=>{const m=[];let r;for(let u=0;u<de;u+=1){if(o.aborted)return m;const{data:l}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of l.items)if(!i.isDeleted&&!t.has(i.messageId)&&!m.includes(i.messageId)&&(m.push(i.messageId),m.length>=a))return m;if(!l.continuationToken)break;r=l.continuationToken}return m},cs=async(s,t)=>{let a=0,o;for(let m=0;m<de;m+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const u of r.items)u.isDeleted||(a+=1);if(!r.continuationToken)break;o=r.continuationToken}return a};function ds({accountId:s,mailboxId:t,onDeleted:a}){const o=Z(),[m,r]=c.useState("idle"),[u,l]=c.useState(null),[i,d]=c.useState(),[p,g]=c.useState(),v=c.useRef(null),y=c.useRef(void 0),h=c.useCallback(()=>{o.invalidateQueries({queryKey:ee({path:{accountId:s}})}),o.invalidateQueries({queryKey:se()})},[o,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(ye({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),M=c.useCallback(()=>o.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[o,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const I=y.current!==void 0,C=await $((async()=>(I||(S.throwIfAborted(),y.current=ns(await M(),t),S.throwIfAborted(),g(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),is({readMailboxes:M,mailboxId:t,since:y.current??0,signal:S})))());return S.aborted?(r("idle"),y.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(y.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(y.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,M,f,h]),A=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:I}=S;r("moving"),d(void 0);const C=await $(O());if(I.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);l(x);const E=new Set;for(;;){if(I.aborted)return;const n=await $(ls(t,E,Ie,I));if(I.aborted)return;if(!n.ok){x=_(x,n.error),l(x),d(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(we({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(I.aborted)return;if(!T.ok){x=_(x,T.error),l(x),d(T.error),r("error");return}for(const F of b)E.add(F);x=Se(x,b.length),l(x)}const D=await $(cs(t,I));if(!I.aborted){if(!D.ok){x=_(x,D.error),l(x),d(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),l(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,y.current=void 0,r("idle"),l(null),d(void 0),g(void 0)},[]);return{phase:m,progress:u,errorMessage:i,checkStartedAt:p,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:N,cancel:A,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function ms({open:s,accountId:t,folder:a,mailboxes:o,appointments:m,onClose:r}){const[u,l]=c.useState(()=>H(a.messageCount)),[i,d]=c.useState(),[p,g]=c.useState(),{createFolderIn:v}=ae(t),y=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:N,cancel:R,reset:k}=ds({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,I]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||M===void 0)return;const P=()=>I(Ae(Date.now()-M));P();const ue=setInterval(P,1e3);return()=>clearInterval(ue)},[C,M]),c.useEffect(()=>{s&&(l(H(a.messageCount)),d(void 0),k())},[s,k]),c.useEffect(()=>{s&&g(void 0)},[s]),c.useEffect(()=>R,[R]);const x=c.useCallback(()=>{R(),r()},[R,r]),E=c.useCallback(async()=>{const P=await A();P.status==="blocked"&&(d(P.messageCount),l("choose-fate"))},[A]),D=c.useMemo(()=>Me({mailboxes:o,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:y}),[o,m,a.mailboxId,y]),n=D.find(P=>P.id===p),b=c.useMemo(()=>K(a,ne(m).get(a.mailboxId),y),[a,m,y]);if(!s)return null;const T=`Delete ${b}`,F=i??a.messageCount,me=h==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(Q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:f?q(f):"Moved 0 of 0"})]}):h==="checking"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(Q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(Q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[q(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):u==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):u==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i!==void 0&&e.jsx(z,{tone:"warning",variant:"soft",children:`This folder is not empty: the mail server reports ${L(i)} in it. Nothing was deleted.`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:b})," holds"," ",L(F),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>l("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(B,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):u==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b})," and its"," ",L(F),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>l("choose-fate"),children:"Back"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",L(F)," in"," ",e.jsx("strong",{className:"text-fg",children:b})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(X,{folders:D,selectedId:p,delimiter:o[0]?.hierarchyDelimiter??"/",onSelect:g,onCreateFolder:v,onCancel:()=>{g(void 0),l("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(j,{variant:"danger",onClick:()=>N(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${L(F)} to ${n.label}`})})})]});return e.jsxs(Y,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(De,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(W,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}function us({account:s}){const t=Z(),a=s.accountId,o=re(),{data:m,isPending:r,isError:u,error:l,refetch:i}=ie(Fe({path:{accountId:a}})),{createFolderIn:d}=ae(a),p=V({...Le(),meta:$e(409),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),g=V({...ze(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,y]=c.useState(),[h,f]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:K(n,A.get(n.mailboxId),o),path:n.fullPath,deleteBlockedReason:_e(n,w,s.folderAppointments).message})),[w,A,o,s.folderAppointments]),R=(n,b)=>{p.mutate({path:{accountId:a,role:Qe[n]},body:{mailboxId:b}})},k=(n,b)=>{const T=b.trim();g.mutate({path:{accountId:a,mailboxId:n},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(u)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:l,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),I={};for(const n of s.folderAppointments){const b=Be[n.role];b&&(I[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:Ke(p.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(ss,{accountEmail:s.email,folders:S,appointments:I,displayNames:C,onAppoint:R,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Ve,{folders:N,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),M(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>y(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ue,{open:!0,folderLabel:K(E,A.get(E.mailboxId),o),defaultLabel:K({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.get(E.mailboxId),o),name:O,onNameChange:M,pending:g.isPending,error:g.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();g.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),D&&e.jsx(ms,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>y(void 0)})]})}function js(){const s=Oe(),[t,a]=c.useState(!0),{data:o,isPending:m,isError:r,error:u,refetch:l}=ie(Te()),i=d=>{const p=Pe[d];p&&s({to:p})};return e.jsx(He,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(es,{}),helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(oe,{title:"Couldn't load accounts",error:u,onRetry:()=>{l()}}):o.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:o.accounts.map(d=>e.jsx(us,{account:d},d.accountId))})})}export{js as component};
@@ -1 +0,0 @@
1
- import{eS as o,j as r}from"./index-Cvg1ICmg.js";import{O as m}from"./OpenCalendarEvent-BgYFqkWO.js";import"./CalendarComposePane-CQquoIIA.js";import"./calendar-format-_D2qlvSu.js";import"./useQueries-B8LmhXDj.js";import"./useCalendars-BiHQwoqg.js";import"./calendar-clash-strip-ChVtknHT.js";import"./attendee-row-Dgh-0GlX.js";import"./avatar-BuiXyp5p.js";import"./clock-zhYrOi0n.js";import"./map-pin-BNehUfT9.js";import"./mail-i5djtULt.js";import"./pencil-Cbc_bTFZ.js";import"./useCalendarWrites--n8KbD7U.js";import"./ErrorState-B7NbYqTc.js";import"./useCalendarData-DXephWeP.js";function v(){const{calendarObjectId:t}=o.useParams();return r.jsx(m,{calendarObjectId:t})}export{v as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{M as i}from"./MailboxPane-S4RjLCSn.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useQueries-B8LmhXDj.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./NavMenuButton-CRz4o42Z.js";import"./useLabels-Dm-tUvjJ.js";import"./useSemanticSearch-CCCY9PAD.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BuyceQDS.js";import"./circle-help-Bn5rsX9v.js";import"./circle-check-DMqAgBOj.js";function X(){return o.jsx(i.Reading,{})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-Cvg1ICmg.js";import{B as o}from"./BriefPane-BjUmHKNU.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useSemanticSearch-CCCY9PAD.js";import"./useLabels-Dm-tUvjJ.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function T(){return r.jsx(o.Reading,{})}export{T as component};
@@ -1 +0,0 @@
1
- import{j as r}from"./index-Cvg1ICmg.js";import{B as o}from"./BriefPane-BjUmHKNU.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useSemanticSearch-CCCY9PAD.js";import"./useLabels-Dm-tUvjJ.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function S(){return r.jsx(o.Reading,{})}export{S as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{M as r}from"./MailboxPane-S4RjLCSn.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-BY1Z-PWr.js";import"./circle-check-big-CYIqB7G_.js";import"./refresh-cw-gehoG8pf.js";import"./useQueries-B8LmhXDj.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./NavMenuButton-CRz4o42Z.js";import"./useLabels-Dm-tUvjJ.js";import"./useSemanticSearch-CCCY9PAD.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BuyceQDS.js";import"./circle-help-Bn5rsX9v.js";import"./circle-check-DMqAgBOj.js";function X(){return o.jsx(r.Reading,{})}export{X as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{F as r}from"./FlaggedPane-C0O-H48H.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./refresh-cw-gehoG8pf.js";import"./wizard-selection-DxUM65kM.js";function N(){return o.jsx(r.Reading,{})}export{N as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{O as t}from"./OutboxPane-CXpqcg1M.js";import"./roving-focus-DwDXHttZ.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-CYIqB7G_.js";import"./clock-zhYrOi0n.js";import"./row-actions-CzWFmX-0.js";import"./rotate-ccw-BUQyyEmS.js";import"./NavMenuButton-CRz4o42Z.js";import"./menu-CzfZlboy.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function c(){return o.jsx(t.Reading,{})}export{c as component};
@@ -1 +0,0 @@
1
- import{j as t,an as o}from"./index-Cvg1ICmg.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-Cvg1ICmg.js";import{F as r}from"./FlaggedPane-C0O-H48H.js";import"./useSearchTokenContext-8rnAiWTU.js";import"./kbd-CqsQh3Yv.js";import"./useMessageBodyContent-DK0INN0c.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-C_n4dLUO.js";import"./roving-focus-DwDXHttZ.js";import"./search-token-index-CMfLsCex.js";import"./useQueries-B8LmhXDj.js";import"./popover-menu-BOPw-RvI.js";import"./mail-i5djtULt.js";import"./avatar-BuiXyp5p.js";import"./index-yhiT7pf4.js";import"./useSignature-BPTjqaqF.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-abnXV_Ax.js";import"./sections-DZNHkQyT.js";import"./EmptyState-DxHRPzWP.js";import"./ErrorState-B7NbYqTc.js";import"./attachment-file-rUVfXWEQ.js";import"./download-DSk-iXt6.js";import"./calendar-suggestion-DoL5BXEv.js";import"./calendar-format-_D2qlvSu.js";import"./map-pin-BNehUfT9.js";import"./attendee-row-Dgh-0GlX.js";import"./clock-zhYrOi0n.js";import"./calendar-clash-strip-ChVtknHT.js";import"./bell-off-PwhHcUK1.js";import"./copy-DYN1Qqcn.js";import"./shield-check-gQitY-yx.js";import"./useCalendars-BiHQwoqg.js";import"./useFilters-e6-LOuFX.js";import"./confirm-dialog-BBNecW64.js";import"./useLayoutTier-id3G6JgO.js";import"./menu-CzfZlboy.js";import"./MailViewChrome-SWxm38ad.js";import"./refresh-cw-gehoG8pf.js";import"./wizard-selection-DxUM65kM.js";function M(){return o.jsx(r.Reading,{})}export{M as component};