@remit/web-client-dist 0.0.564 → 0.0.566

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 (168) hide show
  1. package/assets/BriefPane-BSJc4ufm.js +1 -0
  2. package/assets/CalendarComposePane-DAQHpMrQ.js +1 -0
  3. package/assets/{CalendarComposeSeed-DNwuCKpr.js → CalendarComposeSeed-BoJ25Z4n.js} +1 -1
  4. package/assets/{CalendarShell-CGVvcfrA.js → CalendarShell-t1-2Y_Mx.js} +1 -1
  5. package/assets/{EmptyState-BTKm9F6Q.js → EmptyState-aKocWGoA.js} +1 -1
  6. package/assets/ErrorState-LP7AwW_p.js +1 -0
  7. package/assets/FlaggedPane-BBHVAfeU.js +1 -0
  8. package/assets/{FullCompose-AEoBq77L.js → FullCompose-BGRUJh6v.js} +1 -1
  9. package/assets/MailListHeader-sHAZiuvt.js +7 -0
  10. package/assets/MailNav-CJLhcbFk.js +1 -0
  11. package/assets/{MailShell-DX1zBcaU.js → MailShell-1bk-N22N.js} +1 -1
  12. package/assets/MailViewChrome-DXBi4P0H.js +1 -0
  13. package/assets/MailboxPane-DG81nhZp.js +1 -0
  14. package/assets/{NavMenuButton-CgziJeDD.js → NavMenuButton-BfJ2z8-p.js} +1 -1
  15. package/assets/{OnboardingWizard-Cq8ycceQ.js → OnboardingWizard-CmZ01AQi.js} +1 -1
  16. package/assets/OpenCalendarEvent-B7sk8Y9D.js +2 -0
  17. package/assets/OutboxPane-DffQA6-a.js +1 -0
  18. package/assets/_calendarObjectId-CZhe2ZOn.js +1 -0
  19. package/assets/_mailboxId-CeGv_4X5.js +1 -0
  20. package/assets/_messageId-Brtone_a.js +1 -0
  21. package/assets/_messageId-CjcRJFc4.js +1 -0
  22. package/assets/_messageId-CsrcFMPz.js +1 -0
  23. package/assets/_outboxMessageId-Ct60rh-G.js +1 -0
  24. package/assets/_recurrenceId-BEl7wwCo.js +1 -0
  25. package/assets/_threadId-B2k2md9Y.js +1 -0
  26. package/assets/_threadId-B9wrJ2nR.js +1 -0
  27. package/assets/_threadId-C181ZJF2.js +1 -0
  28. package/assets/_view._date-CvsLA6jP.js +1 -0
  29. package/assets/accounts-Bvb71cuD.js +1 -0
  30. package/assets/{advanced-D2ikJQGg.js → advanced-DFF0GBZN.js} +3 -3
  31. package/assets/{appearance-DsXwlVTk.js → appearance-COIu5SBk.js} +1 -1
  32. package/assets/{attachment-file-BRLoj6sG.js → attachment-file-Dpl8hNc0.js} +1 -1
  33. package/assets/{attendee-row-OHoLTo23.js → attendee-row-C4aifNUr.js} +1 -1
  34. package/assets/{avatar-BuUa_-Ae.js → avatar-C4qRFeeX.js} +1 -1
  35. package/assets/{bottom-sheet-BUcSDGQJ.js → bottom-sheet-A__0esXP.js} +1 -1
  36. package/assets/brief-CnRsQwJb.js +1 -0
  37. package/assets/{brief--NWfZGeB.js → brief-e1MDqt0Y.js} +1 -1
  38. package/assets/{browser-ponyfill-C1Yxcmyx.js → browser-ponyfill-DIGDHadX.js} +2 -2
  39. package/assets/{bug-C0Ms2LYI.js → bug-DTaMGe9c.js} +1 -1
  40. package/assets/{calendar-Bx2owKH5.js → calendar-B3bdWTl1.js} +1 -1
  41. package/assets/{calendar-color-PMGOIawE.js → calendar-color-C1HATGvz.js} +1 -1
  42. package/assets/{calendar-event-chip-CX0GIGM0.js → calendar-event-chip-CNYRAKOE.js} +1 -1
  43. package/assets/calendars-DRiWSSoo.js +1 -0
  44. package/assets/{card-Drp0FnU2.js → card-CgowAhQY.js} +1 -1
  45. package/assets/chevron-left-k4hHGFxU.js +1 -0
  46. package/assets/{circle-check-8G_6IWKh.js → circle-check-C6InBO6B.js} +1 -1
  47. package/assets/{circle-check-big-CVRDL2A5.js → circle-check-big-BrbWEiEZ.js} +1 -1
  48. package/assets/{circle-help-Ck_g9Pip.js → circle-help-CXIkMdfH.js} +1 -1
  49. package/assets/{clock-KUoHWkrr.js → clock-Dm6u_ukU.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-B8MenUoB.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-B_gpxVdz.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-C4Ava6lK.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-DY2D7fpo.js +1 -0
  54. package/assets/{config-import-DJqfxqLZ.js → config-import-CfF4lyQV.js} +1 -1
  55. package/assets/{confirm-dialog-BVXTDPyQ.js → confirm-dialog-CABiCtGp.js} +1 -1
  56. package/assets/{copy-D_J7-xdX.js → copy-BIEy2UO-.js} +1 -1
  57. package/assets/{credential-steps-CuyQQqOh.js → credential-steps-DM1fuM06.js} +1 -1
  58. package/assets/{download-cdI2QZPl.js → download-1tA41rYM.js} +1 -1
  59. package/assets/{file-json-CxdRqoDn.js → file-json-CCwrBIYv.js} +1 -1
  60. package/assets/{filters-CVrzif88.js → filters-BEDbiXL6.js} +1 -1
  61. package/assets/flagged-CtYcd1p3.js +1 -0
  62. package/assets/{flagged-CaNZehgH.js → flagged-KaUU5BlX.js} +1 -1
  63. package/assets/folders-CltOBBCV.js +1 -0
  64. package/assets/{help-copy-CbN-pFZa.js → help-copy-DmIwayFx.js} +1 -1
  65. package/assets/{import-CmBHI3PY.js → import-DXciaSb6.js} +1 -1
  66. package/assets/{index-BsL3dqbS.js → index-2ffnljAr.js} +7 -7
  67. package/assets/{index-BSMLcnNv.js → index-B2JlIrVH.js} +80 -80
  68. package/assets/index-BHbbifX5.js +1 -0
  69. package/assets/index-C1bmRGl4.js +1 -0
  70. package/assets/index-CEbjxa0F.js +1 -0
  71. package/assets/index-CFa_ITEH.js +1 -0
  72. package/assets/index-CjcRJFc4.js +1 -0
  73. package/assets/index-CsrcFMPz.js +1 -0
  74. package/assets/{index-qHz-C81K.js → index-D1lrZZom.js} +1 -1
  75. package/assets/index-DhG8aWpV.js +1 -0
  76. package/assets/index-TiiA2WZz.js +1 -0
  77. package/assets/index-iHWlHwnx.js +1 -0
  78. package/assets/{kbd-MeQzj_AS.js → kbd-TVUw5dQH.js} +1 -1
  79. package/assets/{labels-DIjqFgrM.js → labels-CTevNzRb.js} +1 -1
  80. package/assets/{mail-zfMejK7g.js → mail-BQ0Xqoj_.js} +1 -1
  81. package/assets/mail-DRM5ncN9.js +1 -0
  82. package/assets/{map-pin-DHhEILKJ.js → map-pin-Dc-USzX4.js} +1 -1
  83. package/assets/{menu-D4SB6ohG.js → menu-CTvIK5Qx.js} +1 -1
  84. package/assets/{new-CEVTgWfF.js → new-DV2drXW-.js} +1 -1
  85. package/assets/onboarding-BPSBX3tT.js +1 -0
  86. package/assets/{onboarding-completion-Dr1hm10w.js → onboarding-completion-BhqyiyYl.js} +1 -1
  87. package/assets/outbox-DxSSQPiK.js +1 -0
  88. package/assets/{pencil-BSemJDIl.js → pencil-C__8PZQ-.js} +1 -1
  89. package/assets/{refresh-cw-Bdx0EEOe.js → refresh-cw-CijD9tc5.js} +1 -1
  90. package/assets/{rich-text-C_I7yglD.js → rich-text-DJQbTsPr.js} +15 -15
  91. package/assets/{rich-text-spellcheck-worker-provider-fakJuGkh.js → rich-text-spellcheck-worker-provider-sncBwGVt.js} +1 -1
  92. package/assets/{rotate-ccw-rjesddf9.js → rotate-ccw-BhqDWKvR.js} +1 -1
  93. package/assets/{roving-focus-JRZm8Nsl.js → roving-focus-BWokg8ha.js} +1 -1
  94. package/assets/{row-actions-BAj0uoQs.js → row-actions-CdfQhGZT.js} +1 -1
  95. package/assets/{search-mirror-CD8ms6aC.js → search-mirror-B1Zf9cCU.js} +1 -1
  96. package/assets/search-token-index-27XVZbA6.js +1 -0
  97. package/assets/{sections-B3k1IUqe.js → sections-Clno-i5j.js} +1 -1
  98. package/assets/senders-ClVGlZzf.js +1 -0
  99. package/assets/settings-CYdqGIm_.js +1 -0
  100. package/assets/{settings-screen-CX00GQZz.js → settings-screen-X-U5v_Fa.js} +1 -1
  101. package/assets/{shield-check-B34-2hLP.js → shield-check-BGc8_VeV.js} +1 -1
  102. package/assets/suggested-vips-B5a-Xv9j.js +1 -0
  103. package/assets/{useCalendarData-BtwJetQk.js → useCalendarData-CrF9X78_.js} +1 -1
  104. package/assets/{useCalendars-D7gapaJ1.js → useCalendars-Dzvxbs9C.js} +1 -1
  105. package/assets/{useDebouncedValue--1NwWG_J.js → useDebouncedValue-B2LCK_pq.js} +1 -1
  106. package/assets/{useFilters-BYL5dTX8.js → useFilters-A9SedagU.js} +1 -1
  107. package/assets/{useLabels-BTBI_l7Q.js → useLabels-5zE8gASV.js} +1 -1
  108. package/assets/{useLayoutTier-C5sdkyR7.js → useLayoutTier-DcOqI0AI.js} +1 -1
  109. package/assets/{useMessageBodyContent-BuyQJK-3.js → useMessageBodyContent-D2Bi044R.js} +1 -1
  110. package/assets/{useQueries-hzIIiVUF.js → useQueries-Cf2uvzGz.js} +1 -1
  111. package/assets/useRefreshControl-C7RXJa78.js +1 -0
  112. package/assets/{useResultFolderIndex-DfM23jXb.js → useResultFolderIndex-DjdYfjMq.js} +1 -1
  113. package/assets/{useSearchTokenContext-BOZY3WZQ.js → useSearchTokenContext-C0dIvEKK.js} +3 -3
  114. package/assets/useSemanticSearch-DyTFmiDr.js +1 -0
  115. package/assets/{useSignature-B3bSZUlR.js → useSignature-KOdqyay3.js} +1 -1
  116. package/assets/{window-ZjseaC3I.js → window-C_72cp1d.js} +1 -1
  117. package/index.html +1 -1
  118. package/package.json +1 -1
  119. package/assets/BriefPane-DojIZDdy.js +0 -1
  120. package/assets/CalendarComposePane-B3fOrTrG.js +0 -1
  121. package/assets/ErrorState-jZhKH-Aj.js +0 -1
  122. package/assets/FlaggedPane-Gh0sDSpK.js +0 -1
  123. package/assets/MailListHeader-CP5Mrq7I.js +0 -7
  124. package/assets/MailNav-_b1NBnYa.js +0 -1
  125. package/assets/MailViewChrome-WyEJa7LW.js +0 -1
  126. package/assets/MailboxPane-B0QAN8MQ.js +0 -1
  127. package/assets/OpenCalendarEvent-CWAwJawV.js +0 -2
  128. package/assets/OutboxPane-CQ3uaHpb.js +0 -1
  129. package/assets/_calendarObjectId-CCinxQsA.js +0 -1
  130. package/assets/_mailboxId-BLTbspU-.js +0 -1
  131. package/assets/_messageId-BdFNsbyK.js +0 -1
  132. package/assets/_messageId-DGh1GohX.js +0 -1
  133. package/assets/_messageId-Rx6VPRb8.js +0 -1
  134. package/assets/_outboxMessageId-Ds-AxAdc.js +0 -1
  135. package/assets/_recurrenceId-CnuWP_v3.js +0 -1
  136. package/assets/_threadId-14e9BvEq.js +0 -1
  137. package/assets/_threadId-CaHK3QT7.js +0 -1
  138. package/assets/_threadId-zRV3tTyF.js +0 -1
  139. package/assets/_view._date-CzvdNpZJ.js +0 -1
  140. package/assets/accounts-BZE9IR6B.js +0 -1
  141. package/assets/brief-BzLBKBJb.js +0 -1
  142. package/assets/calendars-CJ1pdgeL.js +0 -1
  143. package/assets/chevron-left-BW6j5W1b.js +0 -1
  144. package/assets/compose._-_outboxMessageId_-BT5t9O9p.js +0 -1
  145. package/assets/compose._-_outboxMessageId_-DVisJU-4.js +0 -1
  146. package/assets/compose._-_outboxMessageId_-PDyjMj_y.js +0 -1
  147. package/assets/compose._-_outboxMessageId_-kk1Oxbpv.js +0 -1
  148. package/assets/flagged-DgBi4zNy.js +0 -1
  149. package/assets/folders-D6pNCcVN.js +0 -1
  150. package/assets/format-bkonYesy.js +0 -1
  151. package/assets/index-B5pFel5d.js +0 -1
  152. package/assets/index-BeGGBd6V.js +0 -1
  153. package/assets/index-CRC7JV7N.js +0 -1
  154. package/assets/index-CdtVuvhW.js +0 -1
  155. package/assets/index-CwgKXaQc.js +0 -1
  156. package/assets/index-CyAwBGa1.js +0 -1
  157. package/assets/index-DGh1GohX.js +0 -1
  158. package/assets/index-DIINe8ie.js +0 -1
  159. package/assets/index-aVEEHAqm.js +0 -1
  160. package/assets/mail-DNGMGkWt.js +0 -1
  161. package/assets/onboarding-CHzcHHo-.js +0 -1
  162. package/assets/outbox-BQPbQr6w.js +0 -1
  163. package/assets/search-token-index-srRTXc29.js +0 -1
  164. package/assets/senders-BorZpOXg.js +0 -1
  165. package/assets/settings-BV8meyD4.js +0 -1
  166. package/assets/suggested-vips-C60kF2rS.js +0 -1
  167. package/assets/useRefreshControl-D15eEjeE.js +0 -1
  168. package/assets/useSemanticSearch-DT9Nt957.js +0 -1
@@ -0,0 +1 @@
1
+ import{e as N,r as i,j as e,f as m,B as j,g as T,ba as v,a4 as F,aC as M,h as A,bb as E,c as R,bc as O,i as y,bd as C,be as D,bf as P,bg as z,s as $,u as _,aM as H,aO as I}from"./index-B2JlIrVH.js";import{S as L}from"./settings-screen-X-U5v_Fa.js";import{C as G,a as B,b as Q,c as U}from"./card-CgowAhQY.js";import{C as K}from"./confirm-dialog-CABiCtGp.js";import{E as X,f as V}from"./ErrorState-LP7AwW_p.js";import{R as J}from"./refresh-cw-CijD9tc5.js";import{C as W}from"./copy-BIEy2UO-.js";import{u as Y}from"./useCalendars-Dzvxbs9C.js";import"./avatar-C4qRFeeX.js";import"./chevron-left-k4hHGFxU.js";import"./menu-CTvIK5Qx.js";import"./circle-help-CXIkMdfH.js";const Z=N("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),q=s=>({title:`Replace the address for ${s}?`,description:"Every client already subscribed to the current address stops updating and has to be pointed at the new one. The new address is shown once."}),ee=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function se({calendarName:s,url:a,onDismiss:t}){const[n,o]=i.useState(!1),[r,c]=i.useState(!1),u=i.useRef(0);i.useEffect(()=>()=>window.clearTimeout(u.current),[]);const l=()=>{navigator.clipboard.writeText(a).then(()=>{c(!1),o(!0),u.current=window.setTimeout(()=>o(!1),2e3)}).catch(()=>c(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:a,"aria-label":`Subscription address for ${s}`,onFocus:d=>d.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(m,{variant:"primary",size:"sm",icon:n?e.jsx(M,{className:"size-3.5"}):e.jsx(W,{className:"size-3.5"}),onClick:l,children:n?"Copied":"Copy address"})]}),r&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(m,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function te({createdAt:s,rotatedAt:a,isBusy:t,onRotate:n,onRevoke:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(T,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",v(s,"medium"),a>0?`, last replaced ${v(a,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(m,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(J,{className:"size-3.5"}),onClick:n,children:"Replace address"}),e.jsx(m,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(F,{className:"size-3.5"}),onClick:o,children:"Stop sharing"})]})]})}function ae({calendarName:s,state:a,mintedUrl:t,isBusy:n,actionError:o,onMint:r,onRevoke:c,onDismissMinted:u,onRetry:l}){const[d,p]=i.useState("none"),h=i.useId(),f=()=>{const b=d;p("none"),b==="rotate"&&r(),b==="revoke"&&c()},x=d==="revoke"?ee(s):q(s);return e.jsxs(G,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(B,{children:e.jsx(Q,{id:h,children:s})}),e.jsxs(U,{children:[a.status==="loading"&&t===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),a.status==="unreadable"&&t===""&&e.jsx(X,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:a.error,onRetry:l}),a.status==="absent"&&t===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(m,{variant:"primary",size:"sm",disabled:n,icon:e.jsx(Z,{className:"size-3.5"}),onClick:r,children:n?"Creating…":"Create subscription address"})]}),a.status==="active"&&e.jsx(te,{createdAt:a.createdAt,rotatedAt:a.rotatedAt,isBusy:n,onRotate:()=>p("rotate"),onRevoke:()=>p("revoke")}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:V(o)})]}),t!==""&&e.jsx(se,{calendarName:s,url:t,onDismiss:u})]}),e.jsx(K,{isOpen:d!=="none",title:x.title,description:x.description,confirmLabel:d==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:f,onCancel:()=>p("none")})]})}const ne="/feeds/calendar/",re=".ics",ie=(s,a)=>`webcal://${s}${ne}${a}${re}`;function oe(s){const a=A(),[t,n]=i.useState(""),o=E({path:{calendarId:s}}),r=R({...O({path:{calendarId:s}}),meta:$(404,403),retry:!1}),c=()=>{a.invalidateQueries({queryKey:o})},u=i.useRef(()=>{}),l=y({...D(),meta:C,onMutate:()=>{u.current()},onSuccess:()=>{n(""),c()}}),d=y({...P(),meta:C,gcTime:0,onMutate:()=>{l.reset()},onSuccess:S=>{n(ie(window.location.host,S.feedToken)),c()}});u.current=d.reset;const{mutate:p,reset:h}=d,{mutate:f}=l,x=i.useCallback(()=>{p({path:{calendarId:s}})},[s,p]),b=i.useCallback(()=>{f({path:{calendarId:s}})},[s,f]),k=i.useCallback(()=>{n(""),h()},[h]),{refetch:g}=r,w=i.useCallback(()=>{g()},[g]);return{state:de(r),mintedUrl:t,isBusy:d.isPending||l.isPending,actionError:d.error??l.error,mint:x,revoke:b,dismissMinted:k,retry:w}}function de(s){return s.error?z(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}function ce({calendarId:s,calendarName:a}){const t=oe(s);return e.jsx(ae,{calendarName:a,state:t.state,mintedUrl:t.mintedUrl,isBusy:t.isBusy,actionError:t.actionError,onMint:t.mint,onRevoke:t.revoke,onDismissMinted:t.dismissMinted,onRetry:t.retry})}const le=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."})]});function ke(){const s=_(),[a,t]=i.useState(!0),{calendars:n,isLoading:o}=Y();return e.jsx(L,{items:H,activeId:"calendars",title:"Calendars",description:"Share a calendar with any client that can subscribe to a URL.",help:le,helpOpen:a,onToggleHelp:()=>t(r=>!r),onSelect:r=>{const c=I[r];c&&s({to:c})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):n.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No calendars yet."}):e.jsx("div",{className:"space-y-4",children:n.map(r=>e.jsx(ce,{calendarId:r.id,calendarName:r.name},r.id))})})}export{ke as component};
@@ -1 +1 @@
1
- import{j as r,t}from"./index-BSMLcnNv.js";function n({raised:s,className:e,...a}){return r.jsx("div",{className:t("rounded-sm border border-line bg-surface",s?"bg-surface-raised shadow-sm":"",e),...a})}function o({className:s,...e}){return r.jsx("div",{className:t("px-4 pt-3 pb-2",s),...e})}function i({className:s,...e}){return r.jsx("h3",{className:t("text-md font-semibold text-fg",s),...e})}function m({className:s,...e}){return r.jsx("div",{className:t("px-4 pb-3 text-sm text-fg-muted",s),...e})}export{n as C,o as a,i as b,m as c};
1
+ import{j as r,t}from"./index-B2JlIrVH.js";function n({raised:s,className:e,...a}){return r.jsx("div",{className:t("rounded-sm border border-line bg-surface",s?"bg-surface-raised shadow-sm":"",e),...a})}function o({className:s,...e}){return r.jsx("div",{className:t("px-4 pt-3 pb-2",s),...e})}function i({className:s,...e}){return r.jsx("h3",{className:t("text-md font-semibold text-fg",s),...e})}function m({className:s,...e}){return r.jsx("div",{className:t("px-4 pb-3 text-sm text-fg-muted",s),...e})}export{n as C,o as a,i as b,m as c};
@@ -0,0 +1 @@
1
+ import{e}from"./index-B2JlIrVH.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
@@ -1 +1 @@
1
- import{e as c}from"./index-BSMLcnNv.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
1
+ import{e as c}from"./index-B2JlIrVH.js";const r=c("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{r as C};
@@ -1 +1 @@
1
- import{e}from"./index-BSMLcnNv.js";const t=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
1
+ import{e}from"./index-B2JlIrVH.js";const t=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);export{t as C};
@@ -1 +1 @@
1
- import{e}from"./index-BSMLcnNv.js";const p=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
1
+ import{e}from"./index-B2JlIrVH.js";const p=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);export{p as C};
@@ -1 +1 @@
1
- import{e as c}from"./index-BSMLcnNv.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
1
+ import{e as c}from"./index-B2JlIrVH.js";const o=c("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);export{o as C};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-BGRUJh6v.js";import"./index-B2JlIrVH.js";import"./ErrorState-LP7AwW_p.js";import"./index-2ffnljAr.js";import"./useMessageBodyContent-D2Bi044R.js";import"./useSignature-KOdqyay3.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B2LCK_pq.js";import"./sections-Clno-i5j.js";import"./confirm-dialog-CABiCtGp.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-BGRUJh6v.js";import"./index-B2JlIrVH.js";import"./ErrorState-LP7AwW_p.js";import"./index-2ffnljAr.js";import"./useMessageBodyContent-D2Bi044R.js";import"./useSignature-KOdqyay3.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B2LCK_pq.js";import"./sections-Clno-i5j.js";import"./confirm-dialog-CABiCtGp.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-BGRUJh6v.js";import"./index-B2JlIrVH.js";import"./ErrorState-LP7AwW_p.js";import"./index-2ffnljAr.js";import"./useMessageBodyContent-D2Bi044R.js";import"./useSignature-KOdqyay3.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B2LCK_pq.js";import"./sections-Clno-i5j.js";import"./confirm-dialog-CABiCtGp.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-BGRUJh6v.js";import"./index-B2JlIrVH.js";import"./ErrorState-LP7AwW_p.js";import"./index-2ffnljAr.js";import"./useMessageBodyContent-D2Bi044R.js";import"./useSignature-KOdqyay3.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B2LCK_pq.js";import"./sections-Clno-i5j.js";import"./confirm-dialog-CABiCtGp.js";const c=o;export{c as component};
@@ -1 +1 @@
1
- import{b1 as v,b2 as T}from"./index-BSMLcnNv.js";const k=e=>new Promise(n=>{n(JSON.parse(e))}),l=["accounts","labels","filters","addressFlags","settings"],g={accounts:"Accounts",labels:"Labels",filters:"Rules & filters",addressFlags:"Senders",settings:"Folders & appearance"},S=["created","updated","unchanged","skipped","rejected"],$={created:"positive",updated:"accent",unchanged:"neutral",skipped:"warning",rejected:"danger"},m=e=>S.includes(e)?e:"rejected",h="unknown",p=e=>l.includes(e)?e:void 0,I=e=>{const n=new Map;return e.forEach((t,i)=>{const a=p(t.section)??h,r=n.get(a)??[];r.push({id:`${a}-${t.key}-${i}`,label:t.key,verdict:m(t.verdict),reason:a===h?t.reason??`This instance does not know the "${t.section}" section, so it cannot say what this entry does.`:t.reason}),n.set(a,r)}),[...l,h].filter(t=>n.has(t)).map(t=>({id:t,title:t===h?"Not recognised":g[t],entries:n.get(t)??[]}))},j=e=>{const n={created:0,updated:0,unchanged:0,skipped:0,rejected:0};for(const o of e)n[m(o.verdict)]+=1;return n},E={NotAnObject:()=>({title:"That is not a Reader config file",explanation:"The file was read, but it is not a configuration document — a Reader config is a JSON object carrying a kind and a schemaVersion.",fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host."}),WrongKind:()=>({title:"That is not a Reader config file",explanation:"The file parses as JSON but does not declare itself a Reader configuration, so nothing here can be trusted to mean what it looks like.",fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host."}),UnsupportedVersion:e=>({title:"This file was written by a newer Reader",explanation:e.message||"The file declares a schema version this instance does not read, so importing it would drop settings it cannot understand.",fix:"Update this Reader, then import again. The file is unchanged and safe to keep."}),UnknownKeys:e=>({title:"The file contains settings this version does not know",explanation:"An unknown key is refused rather than quietly dropped: losing configuration without saying so is exactly what this feature exists to prevent.",fix:`Update this Reader, or remove the named keys from the file and import again. ${e.message}`}),CredentialPresent:()=>({title:"The file carries a credential",explanation:"A configuration document describes which credential an account needs; it never carries one. Reader refuses the file rather than importing around it — the secret may now be in your backups, your chat history, or a pull request.",fix:"Delete the field from the file and import again, then change that mailbox's password. Exports written by Reader never contain one."}),Malformed:e=>({title:"The file does not match the configuration format",explanation:"Every part of the document has to validate before anything is written, and this one does not.",fix:`Re-export it from the instance you are moving from. ${e.message}`}),duplicate_key:e=>({title:"The file names something twice",explanation:"A configuration names each account, label and filter once, so a document with two of the same key has no single answer to import.",fix:`Remove the duplicate and import again. ${e.message}`}),unknown_label:e=>({title:"A rule points at a label that is not here",explanation:"The file applies a label neither it nor this instance carries, so the rule would land doing nothing.",fix:`Add the label to the file, or create it here first, then import again. ${e.message}`}),unknown_account:e=>({title:"A rule points at an account that is not here",explanation:"The file files mail into a folder on an account it does not carry, so the rule has no destination to bind to.",fix:`Export the configuration again from an instance that holds both, then import that file. ${e.message}`})},R=e=>({title:"The file could not be imported",explanation:e.message||"The import was refused and nothing was written.",fix:"Re-export the configuration from the instance you are moving from and try again. If it keeps failing, report it with the line below."}),x="import_write_failed",N="config_not_empty",F=e=>{const n=v(e);if(n!==void 0&&n!==409)return;const o=e instanceof T?e.body:e;if(typeof o!="object"||o===null)return;const t=o;if(t.code===N)return{message:typeof t.message=="string"?t.message:"",details:typeof t.details=="object"&&t.details!==null?t.details:void 0}},C=e=>{const n=e.errors.find(t=>t.code!==x);return n?{...(E[n.code]??R)(n),raw:`${n.code}: ${n.message}`}:void 0},O=e=>e.errors.find(n=>n.code===x),w="Nothing from this section was written.",D=e=>{const n=O(e),o=n?.details?.section,t=o?p(o):void 0,i=!e.applied,a=new Map;for(const s of e.items){if(m(s.verdict)==="rejected")continue;const c=p(s.section);c&&a.set(c,(a.get(c)??0)+1)}const r=(s,c)=>l.map(d=>({section:d,title:g[d],state:s,detail:c}));if(!t){if(i)return r("not-landed",w);const s=o?`The import stopped in "${o}", which this instance does not recognise, so it cannot say whether this section was written.`:"The import stopped without naming where, so it cannot say whether this section was written. Open Settings to see what is here.";return r("unknown",s)}const f=l.indexOf(t);return l.map((s,c)=>{const d=g[s];if(s===t)return{section:s,title:d,state:"failed",detail:n?.message??"This section could not be written."};if(c>f)return{section:s,title:d,state:"not-attempted",detail:"Not attempted — the import stopped before this section."};if(i)return{section:s,title:d,state:"not-landed",detail:w};const u=a.get(s)??0;return{section:s,title:d,state:"landed",detail:u===0?"Nothing in the file for this section.":`${u} ${u===1?"entry":"entries"} written.`}})},_="folder_not_found_yet",L=e=>{const n=new Set,o=[];for(const t of e.warnings){if(t.code!==_)continue;const i=t.details?.folderPath;if(!i)continue;const a=t.details?.filter,r=t.details?.accountId,f=`${r??""}:${i}:${a??""}`;n.has(f)||(n.add(f),o.push({path:i,accountId:r,waitingFor:a?`Rule “${a}”`:"A folder role or a folder's own settings"}))}return o},y=2*1024*1024,b=Symbol("not json"),J=async(e,n,o)=>{if(n>y)return{ok:!1,failure:{title:"That file is too large to be a config file",explanation:`${e} is ${Math.round(n/1024)} kB. A Reader configuration is tens of kilobytes; a file this size is something else.`,fix:"Pick the .json file written by Settings › Advanced, or by remit config save.",raw:`${n} bytes > ${y} byte limit`}};let t="";const i=await k(o).catch(a=>(t=a instanceof Error?a.message:String(a),b));return i===b?{ok:!1,failure:{title:"That file is not JSON",explanation:`${e} could not be read as JSON at all, so there is nothing in it to import.`,fix:"Pick the .json file written by Settings › Advanced, or by remit config save.",raw:t}}:typeof i!="object"||i===null||Array.isArray(i)?{ok:!1,failure:{title:"That is not a Reader config file",explanation:`${e} is valid JSON but not a configuration document — a Reader config is a JSON object carrying a kind and a schemaVersion.`,fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host.",raw:`expected a JSON object, found ${Array.isArray(i)?"an array":typeof i}`}}:{ok:!0,document:i}},P=e=>`reader-config.${e.toISOString().slice(0,10)}.json`,U=e=>e<1024?`${e} B`:`${Math.round(e/1024)} kB`;export{x as W,F as a,C as b,j as c,P as e,U as f,I as g,L as p,J as r,D as s,$ as v,O as w};
1
+ import{b4 as v,b5 as T}from"./index-B2JlIrVH.js";const k=e=>new Promise(n=>{n(JSON.parse(e))}),l=["accounts","labels","filters","addressFlags","settings"],g={accounts:"Accounts",labels:"Labels",filters:"Rules & filters",addressFlags:"Senders",settings:"Folders & appearance"},S=["created","updated","unchanged","skipped","rejected"],$={created:"positive",updated:"accent",unchanged:"neutral",skipped:"warning",rejected:"danger"},m=e=>S.includes(e)?e:"rejected",h="unknown",p=e=>l.includes(e)?e:void 0,I=e=>{const n=new Map;return e.forEach((t,i)=>{const a=p(t.section)??h,r=n.get(a)??[];r.push({id:`${a}-${t.key}-${i}`,label:t.key,verdict:m(t.verdict),reason:a===h?t.reason??`This instance does not know the "${t.section}" section, so it cannot say what this entry does.`:t.reason}),n.set(a,r)}),[...l,h].filter(t=>n.has(t)).map(t=>({id:t,title:t===h?"Not recognised":g[t],entries:n.get(t)??[]}))},j=e=>{const n={created:0,updated:0,unchanged:0,skipped:0,rejected:0};for(const o of e)n[m(o.verdict)]+=1;return n},E={NotAnObject:()=>({title:"That is not a Reader config file",explanation:"The file was read, but it is not a configuration document — a Reader config is a JSON object carrying a kind and a schemaVersion.",fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host."}),WrongKind:()=>({title:"That is not a Reader config file",explanation:"The file parses as JSON but does not declare itself a Reader configuration, so nothing here can be trusted to mean what it looks like.",fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host."}),UnsupportedVersion:e=>({title:"This file was written by a newer Reader",explanation:e.message||"The file declares a schema version this instance does not read, so importing it would drop settings it cannot understand.",fix:"Update this Reader, then import again. The file is unchanged and safe to keep."}),UnknownKeys:e=>({title:"The file contains settings this version does not know",explanation:"An unknown key is refused rather than quietly dropped: losing configuration without saying so is exactly what this feature exists to prevent.",fix:`Update this Reader, or remove the named keys from the file and import again. ${e.message}`}),CredentialPresent:()=>({title:"The file carries a credential",explanation:"A configuration document describes which credential an account needs; it never carries one. Reader refuses the file rather than importing around it — the secret may now be in your backups, your chat history, or a pull request.",fix:"Delete the field from the file and import again, then change that mailbox's password. Exports written by Reader never contain one."}),Malformed:e=>({title:"The file does not match the configuration format",explanation:"Every part of the document has to validate before anything is written, and this one does not.",fix:`Re-export it from the instance you are moving from. ${e.message}`}),duplicate_key:e=>({title:"The file names something twice",explanation:"A configuration names each account, label and filter once, so a document with two of the same key has no single answer to import.",fix:`Remove the duplicate and import again. ${e.message}`}),unknown_label:e=>({title:"A rule points at a label that is not here",explanation:"The file applies a label neither it nor this instance carries, so the rule would land doing nothing.",fix:`Add the label to the file, or create it here first, then import again. ${e.message}`}),unknown_account:e=>({title:"A rule points at an account that is not here",explanation:"The file files mail into a folder on an account it does not carry, so the rule has no destination to bind to.",fix:`Export the configuration again from an instance that holds both, then import that file. ${e.message}`})},R=e=>({title:"The file could not be imported",explanation:e.message||"The import was refused and nothing was written.",fix:"Re-export the configuration from the instance you are moving from and try again. If it keeps failing, report it with the line below."}),x="import_write_failed",N="config_not_empty",F=e=>{const n=v(e);if(n!==void 0&&n!==409)return;const o=e instanceof T?e.body:e;if(typeof o!="object"||o===null)return;const t=o;if(t.code===N)return{message:typeof t.message=="string"?t.message:"",details:typeof t.details=="object"&&t.details!==null?t.details:void 0}},C=e=>{const n=e.errors.find(t=>t.code!==x);return n?{...(E[n.code]??R)(n),raw:`${n.code}: ${n.message}`}:void 0},O=e=>e.errors.find(n=>n.code===x),w="Nothing from this section was written.",D=e=>{const n=O(e),o=n?.details?.section,t=o?p(o):void 0,i=!e.applied,a=new Map;for(const s of e.items){if(m(s.verdict)==="rejected")continue;const c=p(s.section);c&&a.set(c,(a.get(c)??0)+1)}const r=(s,c)=>l.map(d=>({section:d,title:g[d],state:s,detail:c}));if(!t){if(i)return r("not-landed",w);const s=o?`The import stopped in "${o}", which this instance does not recognise, so it cannot say whether this section was written.`:"The import stopped without naming where, so it cannot say whether this section was written. Open Settings to see what is here.";return r("unknown",s)}const f=l.indexOf(t);return l.map((s,c)=>{const d=g[s];if(s===t)return{section:s,title:d,state:"failed",detail:n?.message??"This section could not be written."};if(c>f)return{section:s,title:d,state:"not-attempted",detail:"Not attempted — the import stopped before this section."};if(i)return{section:s,title:d,state:"not-landed",detail:w};const u=a.get(s)??0;return{section:s,title:d,state:"landed",detail:u===0?"Nothing in the file for this section.":`${u} ${u===1?"entry":"entries"} written.`}})},_="folder_not_found_yet",L=e=>{const n=new Set,o=[];for(const t of e.warnings){if(t.code!==_)continue;const i=t.details?.folderPath;if(!i)continue;const a=t.details?.filter,r=t.details?.accountId,f=`${r??""}:${i}:${a??""}`;n.has(f)||(n.add(f),o.push({path:i,accountId:r,waitingFor:a?`Rule “${a}”`:"A folder role or a folder's own settings"}))}return o},y=2*1024*1024,b=Symbol("not json"),J=async(e,n,o)=>{if(n>y)return{ok:!1,failure:{title:"That file is too large to be a config file",explanation:`${e} is ${Math.round(n/1024)} kB. A Reader configuration is tens of kilobytes; a file this size is something else.`,fix:"Pick the .json file written by Settings › Advanced, or by remit config save.",raw:`${n} bytes > ${y} byte limit`}};let t="";const i=await k(o).catch(a=>(t=a instanceof Error?a.message:String(a),b));return i===b?{ok:!1,failure:{title:"That file is not JSON",explanation:`${e} could not be read as JSON at all, so there is nothing in it to import.`,fix:"Pick the .json file written by Settings › Advanced, or by remit config save.",raw:t}}:typeof i!="object"||i===null||Array.isArray(i)?{ok:!1,failure:{title:"That is not a Reader config file",explanation:`${e} is valid JSON but not a configuration document — a Reader config is a JSON object carrying a kind and a schemaVersion.`,fix:"Export one from Settings › Advanced on the instance you are moving from, or run remit config save on its host.",raw:`expected a JSON object, found ${Array.isArray(i)?"an array":typeof i}`}}:{ok:!0,document:i}},P=e=>`reader-config.${e.toISOString().slice(0,10)}.json`,U=e=>e<1024?`${e} B`:`${Math.round(e/1024)} kB`;export{x as W,F as a,C as b,j as c,P as e,U as f,I as g,L as p,J as r,D as s,$ as v,O as w};
@@ -1 +1 @@
1
- import{r as u,E as x,F as f,j as e,G as b,t as a}from"./index-BSMLcnNv.js";const h=({isOpen:s,title:r,description:i,confirmLabel:l,cancelLabel:o="Cancel",destructive:c=!1,isBusy:d=!1,onConfirm:m,onCancel:t})=>{const n=u.useRef(null);return x({id:"confirm-dialog",open:s,answers:{back:t}}),f(n,s),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:t,className:"backdrop-blur-sm"}),e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,className:a("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:r}),i&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:i}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:a("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:o}),e.jsx("button",{type:"button",onClick:m,disabled:d,className:a("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",c?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:l})]})]})]}):null};export{h as C};
1
+ import{r as u,G as x,H as f,j as e,J as b,t as a}from"./index-B2JlIrVH.js";const h=({isOpen:s,title:r,description:i,confirmLabel:l,cancelLabel:o="Cancel",destructive:c=!1,isBusy:d=!1,onConfirm:m,onCancel:t})=>{const n=u.useRef(null);return x({id:"confirm-dialog",open:s,answers:{back:t}}),f(n,s),s?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx(b,{label:"Dismiss confirmation",onDismiss:t,className:"backdrop-blur-sm"}),e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,className:a("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),children:[e.jsx("h2",{className:"text-lg font-semibold",children:r}),i&&e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:i}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:t,className:a("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:o}),e.jsx("button",{type:"button",onClick:m,disabled:d,className:a("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",c?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:l})]})]})]}):null};export{h as C};
@@ -1 +1 @@
1
- import{e}from"./index-BSMLcnNv.js";const t=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);export{t as C};
1
+ import{e}from"./index-B2JlIrVH.js";const t=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);export{t as C};
@@ -1 +1 @@
1
- import{e as W,j as t,ax as F,aA as _,t as E,r as n,g as B,aO as R,ay as C,i as G,av as X,B as J,az as K,f as N}from"./index-BSMLcnNv.js";import{C as Q}from"./card-Drp0FnU2.js";const ut=W("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Y({url:r}){return t.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",r?t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):t.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function M({value:r,defaultValue:i,onValueChange:s,...e}){return s?t.jsxs(F,{value:r,onChange:a=>s(a.target.value),...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]}):t.jsxs(F,{defaultValue:i??r,...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]})}function D(r){return{tls:r==="tls",startTls:r==="starttls"}}function Z({steps:r,activeStep:i}){return t.jsx("ol",{className:"flex items-center gap-1",children:r.map((s,e)=>{const a=e<i,o=e===i;return t.jsxs("li",{className:"flex items-center gap-1",children:[e>0&&t.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:E("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",o&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!o&&"bg-surface-sunken text-fg-subtle"),children:a?t.jsx(_,{className:"size-3"}):e+1}),t.jsx("span",{className:E("hidden text-2xs sm:inline",o?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function H({steps:r,activeStep:i,title:s,subtitle:e,children:a,footer:o,hideSteps:c}){return t.jsxs("div",{className:"flex h-dvh w-full flex-col items-center overflow-hidden bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg",children:[t.jsx("div",{className:"hidden shrink-[9999] basis-[30vh] sm:block"}),!c&&t.jsx("div",{className:"mb-5 w-full max-w-xl shrink-0",children:t.jsx(Z,{steps:r,activeStep:i})}),t.jsxs(Q,{raised:!0,className:"flex w-full min-h-0 max-w-xl flex-col",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-5",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),e&&t.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:e})]}),t.jsx("div",{"data-testid":"wizard-body",className:"min-h-0 overflow-y-auto px-5 py-5",children:a}),o&&t.jsx("div",{"data-testid":"wizard-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-3",children:o})]})]})}const tt="Coming soon — use IMAP for now.";function pt({name:r,description:i,icon:s,comingSoon:e,selected:a,onSelect:o}){const[c,l]=n.useState(!1),m=()=>{if(o){o();return}e&&l(!0)};return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("button",{type:"button",onClick:m,"aria-disabled":e||void 0,className:E("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",e&&"opacity-55"),children:[t.jsx("span",{className:E("text-fg-muted",a&&"text-accent-2"),children:s}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-fg",children:r}),e&&t.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),t.jsx("span",{className:"text-xs text-fg-subtle",children:i})]}),c&&t.jsx("p",{className:"text-2xs text-fg-subtle",children:tt})]})}function dt({legend:r,badge:i,host:s,port:e,security:a,readOnly:o,onHostChange:c,onPortChange:l,onSecurityChange:m,hostPlaceholder:x,portPlaceholder:g}){const v=n.useId(),b=n.useId(),h=n.useId();return t.jsxs("fieldset",{children:[t.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r,i&&t.jsx(B,{tone:i.tone,children:i.label})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[t.jsxs("div",{children:[t.jsx(R,{htmlFor:v,children:"Host"}),c?t.jsx(C,{id:v,readOnly:o,value:s,onChange:p=>c(p.target.value),placeholder:x}):t.jsx(C,{id:v,readOnly:o,defaultValue:s,placeholder:x})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:b,children:"Port"}),l?t.jsx(C,{id:b,readOnly:o,value:e,onChange:p=>l(p.target.value),placeholder:g}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:g})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,value:a,onValueChange:m}):t.jsx(M,{id:h,defaultValue:a})]})]})]})}function q({label:r,detail:i,state:s}){return t.jsxs("div",{className:"flex items-start gap-3 py-2",children:[t.jsxs("span",{className:E("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&t.jsx(_,{className:"size-3"}),s==="failed"&&"!",s==="running"&&t.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:E("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:r}),i&&t.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:i})]})]})}const et=(r,i)=>{const s=n.useRef(i);s.current=i,n.useEffect(()=>{if(!r)return;const e=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pageshow",e)}},[r])},st=2e4,ht="Couldn't open Microsoft's sign-in page. Check your connection, and anything blocking redirects, then try again.",xt=r=>{const i=n.useRef(!1),s=n.useRef(!1),e=n.useRef(null),a=n.useRef(r);a.current=r;const o=n.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),c=n.useCallback(()=>{!i.current||!s.current||(o(),s.current=!1,a.current("returned"))},[o]);return n.useEffect(()=>{const l=()=>{s.current=!0,o()},m=()=>{document.visibilityState==="hidden"&&l()},x=g=>{g.persisted&&(l(),c())};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",l),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",l),window.removeEventListener("pageshow",x),o()}},[c,o]),et(!0,c),n.useCallback(()=>{i.current=!0,s.current=!1,o(),e.current=setTimeout(()=>{e.current=null,i.current=!1,s.current=!1,a.current("stalled")},st)},[o])},rt={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},ot={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function O(r){try{const s=new DOMParser().parseFromString(r,"application/xml");if(s.querySelector("parsererror"))return null;const e=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!e.length||!a.length)return null;const o=e[0],c=a[0],l=o.querySelector("hostname")?.textContent?.trim(),m=o.querySelector("port")?.textContent?.trim(),x=o.querySelector("socketType")?.textContent?.trim().toUpperCase(),g=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!g||!v)return null;const h=p=>p==="SSL"||p==="TLS"||p==="SSL/TLS"?"tls":p==="STARTTLS"?"starttls":"none";return{imap:{host:l,port:Number.parseInt(m,10),security:h(x)},smtp:{host:g,port:Number.parseInt(v,10),security:h(b)},source:"mozilla-autoconfig"}}catch{return null}}async function it(r,i){try{const s=`https://autoconfig.thunderbird.net/v1.1/${r}`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=O(a);return o||null}catch{return null}}async function at(r,i){try{const s=`https://autoconfig.${r}/mail/config-v1.1.xml`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=O(a);return o?{...o,source:"domain-autoconfig"}:null}catch{return null}}function nt(r){return{imap:{host:`imap.${r}`,port:993,security:"tls"},smtp:{host:`smtp.${r}`,port:587,security:"starttls"},source:"heuristic"}}async function ft(r,i=1500){const s=r.indexOf("@");if(s===-1)return null;const e=r.slice(s+1).toLowerCase();if(!e)return null;const a=rt[e];if(a)return a;const o=new AbortController,c=setTimeout(()=>o.abort(),i);try{const l=await it(e,o.signal);if(l)return l;const m=await at(e,o.signal);if(m)return m}finally{clearTimeout(c)}return nt(e)}function yt(r){const i=r.indexOf("@");return i===-1?"Looking up server settings…":`Looking up settings for ${r.slice(i+1)}…`}function ct(r){const i=r.indexOf("@");if(i===-1)return;const s=r.slice(i+1).toLowerCase();return ot[s]}function gt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:g="Back",onContinue:v,onBack:b,onChange:h}){const[p,z]=n.useState(o||a),[S,w]=n.useState(c),[T,k]=n.useState(null),I=ct(a),y=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!y){k("Enter your username and password.");return}k(null),v()},[y,v]);return n.useEffect(()=>{const u=j=>{j.key==="Enter"&&L(),j.key==="Escape"&&b()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[L,b]),t.jsx(H,{steps:r,activeStep:i,title:s,subtitle:e,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:b,children:g}),t.jsx(N,{variant:"primary",onClick:L,children:x})]}),children:t.jsxs("div",{className:"space-y-3",children:[m&&t.jsx(J,{tone:"danger",children:m}),T&&t.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:T}),l,t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-username",children:"Username"}),t.jsx(C,{id:"credentials-username",value:p,onChange:u=>{z(u.target.value),k(null)},autoComplete:"username"})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-password",children:"Password or app password"}),t.jsx(K,{id:"credentials-password",value:S,onChange:u=>{w(u.target.value),k(null)},autoComplete:"current-password"})]}),t.jsx(Y,{url:I})]})})}function vt({steps:r,activeStep:i,email:s,imapConfig:e,smtpConfig:a,username:o,password:c,onSuccess:l,onBackToCredentials:m,onBackToServers:x,credentialsBackLabel:g="Back to credentials",serversBackLabel:v="Back to servers",successLabel:b="Start syncing"}){const[h,p]=n.useState({imapState:"running",smtpState:"pending",phase:"running"}),[z,S]=n.useState(0),w=a.host.trim()!=="",T=D(e.security),k=D(a.security),I=G({...X()});n.useEffect(()=>{let u=!1;const j=[];return p({imapState:"running",smtpState:"pending",phase:"running"}),I.mutate({body:{username:o,password:c,imapHost:e.host,imapPort:e.port,imapTls:T.tls,imapStartTls:T.startTls,smtpHost:a.host,smtpPort:a.port,smtpTls:k.tls,smtpStartTls:k.startTls}},{onSuccess:d=>{if(u)return;const f=d.imapSuccess,P=w?d.smtpSuccess:!0;p({imapState:f?"ok":"failed",smtpState:w?"running":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,phase:"running"}),j.push(window.setTimeout(()=>{if(u)return;const $=V=>{const A=V?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},U=!f&&$(d.imapError)||f&&w&&!d.smtpSuccess&&$(d.smtpError);p({imapState:f?"ok":"failed",smtpState:w?d.smtpSuccess?"ok":"failed":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,smtpDetail:w?d.smtpSuccess?`Connected — ${a.host}:${a.port}`:d.smtpError:"Not set up — receive-only",rawError:f?w&&!d.smtpSuccess?d.smtpError:void 0:d.imapError,phase:f&&P?"success":U?"auth-failure":"network-failure"}),f&&P&&j.push(window.setTimeout(()=>{u||l()},800))},400))},onError:d=>{if(u)return;const f=d instanceof Error?d.message:"Connection failed";p({imapState:"failed",smtpState:"failed",imapDetail:f,smtpDetail:f,rawError:f,phase:"network-failure"})}}),()=>{u=!0;for(const d of j)window.clearTimeout(d)}},[z]);const{phase:y}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(y==="auth-failure"?m():y==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[y,m,x]);const L=y==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:g}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):y==="network-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:x,children:v}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):y==="success"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),t.jsx(N,{variant:"primary",onClick:l,children:b})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),t.jsx("span",{})]});return t.jsx(H,{steps:r,activeStep:i,title:"Testing the connection",subtitle:`Checking ${s}`,footer:L,children:t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(q,{label:`IMAP — ${e.host}:${e.port}`,detail:h.imapDetail,state:h.imapState}),t.jsx(q,{label:w?`SMTP — ${a.host}:${a.port}`:"SMTP — sending",detail:w?h.smtpDetail:"Not set up — you can add sending later in Settings",state:h.smtpState}),(y==="auth-failure"||y==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[y==="auth-failure"&&t.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:h.rawError})]})]})})}export{q as C,ht as R,ut as S,H as W,pt as a,xt as b,vt as c,gt as d,dt as e,yt as f,ct as g,ft as h,D as s,et as u};
1
+ import{e as W,j as t,az as F,aC as _,t as E,r as n,g as B,aR as R,aA as C,i as G,ax as X,B as J,aB as K,f as N}from"./index-B2JlIrVH.js";import{C as Q}from"./card-CgowAhQY.js";const ut=W("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Y({url:r}){return t.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",r?t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):t.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function M({value:r,defaultValue:i,onValueChange:s,...e}){return s?t.jsxs(F,{value:r,onChange:a=>s(a.target.value),...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]}):t.jsxs(F,{defaultValue:i??r,...e,children:[t.jsx("option",{value:"tls",children:"TLS/SSL"}),t.jsx("option",{value:"starttls",children:"STARTTLS"}),t.jsx("option",{value:"none",children:"None (insecure)"})]})}function D(r){return{tls:r==="tls",startTls:r==="starttls"}}function Z({steps:r,activeStep:i}){return t.jsx("ol",{className:"flex items-center gap-1",children:r.map((s,e)=>{const a=e<i,o=e===i;return t.jsxs("li",{className:"flex items-center gap-1",children:[e>0&&t.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:E("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",a&&"bg-accent text-accent-fg",o&&"bg-accent-soft text-accent ring-1 ring-accent",!a&&!o&&"bg-surface-sunken text-fg-subtle"),children:a?t.jsx(_,{className:"size-3"}):e+1}),t.jsx("span",{className:E("hidden text-2xs sm:inline",o?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function H({steps:r,activeStep:i,title:s,subtitle:e,children:a,footer:o,hideSteps:c}){return t.jsxs("div",{className:"flex h-dvh w-full flex-col items-center overflow-hidden bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg",children:[t.jsx("div",{className:"hidden shrink-[9999] basis-[30vh] sm:block"}),!c&&t.jsx("div",{className:"mb-5 w-full max-w-xl shrink-0",children:t.jsx(Z,{steps:r,activeStep:i})}),t.jsxs(Q,{raised:!0,className:"flex w-full min-h-0 max-w-xl flex-col",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-5",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),e&&t.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:e})]}),t.jsx("div",{"data-testid":"wizard-body",className:"min-h-0 overflow-y-auto px-5 py-5",children:a}),o&&t.jsx("div",{"data-testid":"wizard-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-3",children:o})]})]})}const tt="Coming soon — use IMAP for now.";function pt({name:r,description:i,icon:s,comingSoon:e,selected:a,onSelect:o}){const[c,l]=n.useState(!1),m=()=>{if(o){o();return}e&&l(!0)};return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("button",{type:"button",onClick:m,"aria-disabled":e||void 0,className:E("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",a?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",e&&"opacity-55"),children:[t.jsx("span",{className:E("text-fg-muted",a&&"text-accent-2"),children:s}),t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-fg",children:r}),e&&t.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),t.jsx("span",{className:"text-xs text-fg-subtle",children:i})]}),c&&t.jsx("p",{className:"text-2xs text-fg-subtle",children:tt})]})}function dt({legend:r,badge:i,host:s,port:e,security:a,readOnly:o,onHostChange:c,onPortChange:l,onSecurityChange:m,hostPlaceholder:x,portPlaceholder:g}){const v=n.useId(),b=n.useId(),h=n.useId();return t.jsxs("fieldset",{children:[t.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[r,i&&t.jsx(B,{tone:i.tone,children:i.label})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[t.jsxs("div",{children:[t.jsx(R,{htmlFor:v,children:"Host"}),c?t.jsx(C,{id:v,readOnly:o,value:s,onChange:p=>c(p.target.value),placeholder:x}):t.jsx(C,{id:v,readOnly:o,defaultValue:s,placeholder:x})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:b,children:"Port"}),l?t.jsx(C,{id:b,readOnly:o,value:e,onChange:p=>l(p.target.value),placeholder:g}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:g})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,value:a,onValueChange:m}):t.jsx(M,{id:h,defaultValue:a})]})]})]})}function q({label:r,detail:i,state:s}){return t.jsxs("div",{className:"flex items-start gap-3 py-2",children:[t.jsxs("span",{className:E("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&t.jsx(_,{className:"size-3"}),s==="failed"&&"!",s==="running"&&t.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:E("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:r}),i&&t.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:i})]})]})}const et=(r,i)=>{const s=n.useRef(i);s.current=i,n.useEffect(()=>{if(!r)return;const e=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pageshow",e)}},[r])},st=2e4,ht="Couldn't open Microsoft's sign-in page. Check your connection, and anything blocking redirects, then try again.",xt=r=>{const i=n.useRef(!1),s=n.useRef(!1),e=n.useRef(null),a=n.useRef(r);a.current=r;const o=n.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=null)},[]),c=n.useCallback(()=>{!i.current||!s.current||(o(),s.current=!1,a.current("returned"))},[o]);return n.useEffect(()=>{const l=()=>{s.current=!0,o()},m=()=>{document.visibilityState==="hidden"&&l()},x=g=>{g.persisted&&(l(),c())};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",l),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",l),window.removeEventListener("pageshow",x),o()}},[c,o]),et(!0,c),n.useCallback(()=>{i.current=!0,s.current=!1,o(),e.current=setTimeout(()=>{e.current=null,i.current=!1,s.current=!1,a.current("stalled")},st)},[o])},rt={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},ot={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function O(r){try{const s=new DOMParser().parseFromString(r,"application/xml");if(s.querySelector("parsererror"))return null;const e=s.querySelectorAll("incomingServer[type='imap']"),a=s.querySelectorAll("outgoingServer[type='smtp']");if(!e.length||!a.length)return null;const o=e[0],c=a[0],l=o.querySelector("hostname")?.textContent?.trim(),m=o.querySelector("port")?.textContent?.trim(),x=o.querySelector("socketType")?.textContent?.trim().toUpperCase(),g=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!g||!v)return null;const h=p=>p==="SSL"||p==="TLS"||p==="SSL/TLS"?"tls":p==="STARTTLS"?"starttls":"none";return{imap:{host:l,port:Number.parseInt(m,10),security:h(x)},smtp:{host:g,port:Number.parseInt(v,10),security:h(b)},source:"mozilla-autoconfig"}}catch{return null}}async function it(r,i){try{const s=`https://autoconfig.thunderbird.net/v1.1/${r}`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=O(a);return o||null}catch{return null}}async function at(r,i){try{const s=`https://autoconfig.${r}/mail/config-v1.1.xml`,e=await fetch(s,{signal:i});if(!e.ok)return null;const a=await e.text(),o=O(a);return o?{...o,source:"domain-autoconfig"}:null}catch{return null}}function nt(r){return{imap:{host:`imap.${r}`,port:993,security:"tls"},smtp:{host:`smtp.${r}`,port:587,security:"starttls"},source:"heuristic"}}async function ft(r,i=1500){const s=r.indexOf("@");if(s===-1)return null;const e=r.slice(s+1).toLowerCase();if(!e)return null;const a=rt[e];if(a)return a;const o=new AbortController,c=setTimeout(()=>o.abort(),i);try{const l=await it(e,o.signal);if(l)return l;const m=await at(e,o.signal);if(m)return m}finally{clearTimeout(c)}return nt(e)}function yt(r){const i=r.indexOf("@");return i===-1?"Looking up server settings…":`Looking up settings for ${r.slice(i+1)}…`}function ct(r){const i=r.indexOf("@");if(i===-1)return;const s=r.slice(i+1).toLowerCase();return ot[s]}function gt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:g="Back",onContinue:v,onBack:b,onChange:h}){const[p,z]=n.useState(o||a),[S,w]=n.useState(c),[T,k]=n.useState(null),I=ct(a),y=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!y){k("Enter your username and password.");return}k(null),v()},[y,v]);return n.useEffect(()=>{const u=j=>{j.key==="Enter"&&L(),j.key==="Escape"&&b()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[L,b]),t.jsx(H,{steps:r,activeStep:i,title:s,subtitle:e,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:b,children:g}),t.jsx(N,{variant:"primary",onClick:L,children:x})]}),children:t.jsxs("div",{className:"space-y-3",children:[m&&t.jsx(J,{tone:"danger",children:m}),T&&t.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:T}),l,t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-username",children:"Username"}),t.jsx(C,{id:"credentials-username",value:p,onChange:u=>{z(u.target.value),k(null)},autoComplete:"username"})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:"credentials-password",children:"Password or app password"}),t.jsx(K,{id:"credentials-password",value:S,onChange:u=>{w(u.target.value),k(null)},autoComplete:"current-password"})]}),t.jsx(Y,{url:I})]})})}function vt({steps:r,activeStep:i,email:s,imapConfig:e,smtpConfig:a,username:o,password:c,onSuccess:l,onBackToCredentials:m,onBackToServers:x,credentialsBackLabel:g="Back to credentials",serversBackLabel:v="Back to servers",successLabel:b="Start syncing"}){const[h,p]=n.useState({imapState:"running",smtpState:"pending",phase:"running"}),[z,S]=n.useState(0),w=a.host.trim()!=="",T=D(e.security),k=D(a.security),I=G({...X()});n.useEffect(()=>{let u=!1;const j=[];return p({imapState:"running",smtpState:"pending",phase:"running"}),I.mutate({body:{username:o,password:c,imapHost:e.host,imapPort:e.port,imapTls:T.tls,imapStartTls:T.startTls,smtpHost:a.host,smtpPort:a.port,smtpTls:k.tls,smtpStartTls:k.startTls}},{onSuccess:d=>{if(u)return;const f=d.imapSuccess,P=w?d.smtpSuccess:!0;p({imapState:f?"ok":"failed",smtpState:w?"running":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,phase:"running"}),j.push(window.setTimeout(()=>{if(u)return;const $=V=>{const A=V?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},U=!f&&$(d.imapError)||f&&w&&!d.smtpSuccess&&$(d.smtpError);p({imapState:f?"ok":"failed",smtpState:w?d.smtpSuccess?"ok":"failed":"ok",imapDetail:f?`Connected — ${e.host}:${e.port}`:d.imapError,smtpDetail:w?d.smtpSuccess?`Connected — ${a.host}:${a.port}`:d.smtpError:"Not set up — receive-only",rawError:f?w&&!d.smtpSuccess?d.smtpError:void 0:d.imapError,phase:f&&P?"success":U?"auth-failure":"network-failure"}),f&&P&&j.push(window.setTimeout(()=>{u||l()},800))},400))},onError:d=>{if(u)return;const f=d instanceof Error?d.message:"Connection failed";p({imapState:"failed",smtpState:"failed",imapDetail:f,smtpDetail:f,rawError:f,phase:"network-failure"})}}),()=>{u=!0;for(const d of j)window.clearTimeout(d)}},[z]);const{phase:y}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(y==="auth-failure"?m():y==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[y,m,x]);const L=y==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:g}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):y==="network-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:x,children:v}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):y==="success"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),t.jsx(N,{variant:"primary",onClick:l,children:b})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),t.jsx("span",{})]});return t.jsx(H,{steps:r,activeStep:i,title:"Testing the connection",subtitle:`Checking ${s}`,footer:L,children:t.jsxs("div",{className:"divide-y divide-line",children:[t.jsx(q,{label:`IMAP — ${e.host}:${e.port}`,detail:h.imapDetail,state:h.imapState}),t.jsx(q,{label:w?`SMTP — ${a.host}:${a.port}`:"SMTP — sending",detail:w?h.smtpDetail:"Not set up — you can add sending later in Settings",state:h.smtpState}),(y==="auth-failure"||y==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[y==="auth-failure"&&t.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),t.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:h.rawError})]})]})})}export{q as C,ht as R,ut as S,H as W,pt as a,xt as b,vt as c,gt as d,dt as e,yt as f,ct as g,ft as h,D as s,et as u};
@@ -1 +1 @@
1
- import{e}from"./index-BSMLcnNv.js";const a=e("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
1
+ import{e}from"./index-B2JlIrVH.js";const a=e("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);export{a as D};
@@ -1 +1 @@
1
- import{e as a}from"./index-BSMLcnNv.js";const o=a("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);export{o as F};
1
+ import{e as a}from"./index-B2JlIrVH.js";const o=a("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);export{o as F};
@@ -1 +1 @@
1
- import{h as X,i as Z,bd as ee,be as te,r as x,bf as se,j as t,bg as ae,bh as ie,L as R,f as N,bi as ne,aH as re,g as oe,bj as le,bk as ce,a2 as de,c as P,H as me,bl as ue,ad as pe,ae as xe,bm as fe,bn as he,u as ge,d as be,aK as ve,aM as je}from"./index-BSMLcnNv.js";import{S as ye}from"./settings-screen-CX00GQZz.js";import{B as Ne}from"./bottom-sheet-BUcSDGQJ.js";import{u as Ce,a as Se}from"./useLabels-BTBI_l7Q.js";import{b as Fe,N as S,p as Me,u as Ie,r as we,a as Ee,S as L,c as Oe,n as De,f as Ae,d as Le,e as ke,g as Te}from"./useFilters-BYL5dTX8.js";import{C as A}from"./circle-check-8G_6IWKh.js";import{E as $}from"./ErrorState-jZhKH-Aj.js";import"./avatar-BuUa_-Ae.js";import"./chevron-left-BW6j5W1b.js";import"./menu-D4SB6ohG.js";import"./circle-help-Ck_g9Pip.js";const Re=(e,s)=>{const r=X(),i=Z({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:Fe(e)}),s&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:s}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!s||c({path:{accountId:e,filterId:s},body:d})},[e,s,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Pe=(e,s=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...s?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?$e(e.expiresAt):void 0,name:e.name}),$e=e=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=new Date(s),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},k=e=>JSON.stringify({clauses:e.clauses.map(s=>[s.field,s.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),z=(e,s)=>k(e)!==k(s),T=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),_=(e,s)=>T(e)!==T(s),ze=(e,s)=>{const r={},i=(e.name??"").trim();return i!==(s.name??"").trim()&&(r.name=i),z(e,s)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),_(e,s)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=Me(e.until??""))),r};function _e({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>Pe(s,g),[s,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,v]=x.useState(!1),M=x.useRef(0),{count:C}=Ie(e,we(n)),y=Re(e,s.filterId),b=Ee(e),{createFolderIn:F}=se(e),{createLabel:E}=Ce(e),I=async o=>{const a=await E(o);return{id:a.labelId,name:a.name,color:a.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),w=o=>{const a=n.clauses.find(j=>j.id===o);a&&u({mode:"edit",clauseId:o,draft:{field:a.field,value:a.value}})},O=o=>u(a=>a&&{...a,draft:{...a.draft,field:o}}),K=o=>u(a=>a&&{...a,draft:{...a.draft,value:o}}),U=()=>{if(!m)return;const o=m.draft.field,a=De(o,m.draft.value);a!==""&&(l(j=>m.mode==="edit"&&m.clauseId?{...j,clauses:j.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(M.current+=1,{...j,clauses:[...j.clauses,{id:`new-${M.current}`,field:o,value:a}]})),u(void 0))},B=o=>l(a=>({...a,clauses:a.clauses.filter(j=>j.id!==o)})),H=o=>l(a=>({...a,matchOperator:o})),Q=o=>l(a=>({...a,moveMailboxId:o||void 0})),G=o=>l(a=>({...a,labelId:o||void 0})),J=o=>l(a=>({...a,name:o})),V=o=>l(a=>({...a,scope:o,until:o==="until"?a.until:void 0})),q=o=>l(a=>({...a,until:o})),W=()=>{const o=z(n,f)||_(n,f),a=ze(n,f);if(Object.keys(a).length===0){d();return}v(o),y.updateFilter(a)},Y=()=>b.start(Oe(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(He,{progress:b.progress,isDone:b.isDone,onClose:d}):y.isPending?t.jsx(Ke,{}):y.isError?t.jsx(Qe,{onRetry:y.reset,onClose:d}):y.isSuccess?h?t.jsx(Be,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Ue,{onClose:d}):t.jsx(ie,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:B,onChangeDraftField:O,onChangeDraftValue:K,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:H,onChangeMove:Q,onCreateFolder:F,onChangeLabel:G,onCreateLabel:I,onChangeName:J,onChangeScope:V,onChangeUntil:q,onCommit:W,onCancel:d})}function Ke(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Ue({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function Be({preview:e,blocked:s,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:r,disabled:s,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function He({progress:e,isDone:s,onClose:r}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(A,{className:"size-8 text-positive"}):t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),!s&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),s&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),s&&t.jsx(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Qe({onRetry:e,onClose:s}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function Ge({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=ne(),n=t.jsx(_e,{accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(re,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(Ne,{open:!0,onClose:d,label:"Filter rule",dismissLabel:"Dismiss filter rule",children:n})}function Je({filters:e,mailboxName:s,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(n=>{const l=Ae(n,f),m=l==="Expired",u=n.actionMailboxId!==S?s(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,v=Le(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(oe,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&v?m?` · expired ${v}`:` · until ${v}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(le,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(ce,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(de,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const Ve=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function qe({account:e}){const s=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=ke(s),{deleteFilter:f,deletingFilterId:n}=Te(s),[l,m]=x.useState(),{data:u}=P({...me({path:{accountId:s}}),staleTime:1/0}),h=ue(),v=x.useMemo(()=>pe(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const w=u?.items.find(O=>O.mailboxId===p);if(w)return xe(w,v.get(p),h)},[u?.items,v,h]),C=x.useMemo(()=>fe({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),y=he(u?.items??[]),{labels:b}=Se(s),F=x.useMemo(()=>b.map(p=>({id:p.labelId,name:p.name,color:p.color})),[b]),E=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(Ge,{accountId:s,filter:I,folders:C,delimiter:y,labels:F,onClose:()=>m(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx($,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(Je,{filters:r,mailboxName:M,labelById:E,onEdit:m,onDelete:f,deletingFilterId:n})]})}function ot(){const e=ge(),[s,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=P(be()),n=l=>{const m=je[l];m&&e({to:m})};return t.jsx(ye,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Ve,helpOpen:s,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx($,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(qe,{account:l},l.accountId))})})}export{qe as AccountFilters,ot as component};
1
+ import{h as X,i as Z,bh as ee,bi as te,r as x,bj as se,j as t,bk as ae,bl as ie,L as R,f as N,bm as ne,aJ as re,g as oe,bn as le,bo as ce,a4 as de,c as P,K as me,bp as ue,af as pe,ag as xe,bq as fe,br as he,u as ge,d as be,aM as ve,aO as je}from"./index-B2JlIrVH.js";import{S as ye}from"./settings-screen-X-U5v_Fa.js";import{B as Ne}from"./bottom-sheet-A__0esXP.js";import{u as Ce,a as Se}from"./useLabels-5zE8gASV.js";import{b as Fe,N as S,p as Me,u as Ie,r as Oe,a as we,S as L,c as Ee,n as De,f as Ae,d as Le,e as ke,g as Te}from"./useFilters-A9SedagU.js";import{C as A}from"./circle-check-C6InBO6B.js";import{E as $}from"./ErrorState-LP7AwW_p.js";import"./avatar-C4qRFeeX.js";import"./chevron-left-k4hHGFxU.js";import"./menu-CTvIK5Qx.js";import"./circle-help-CXIkMdfH.js";const Re=(e,s)=>{const r=X(),i=Z({...te(),onSuccess:()=>{e&&(r.invalidateQueries({queryKey:Fe(e)}),s&&r.invalidateQueries({queryKey:ee({path:{accountId:e,filterId:s}})}))}}),{mutate:c}=i;return{updateFilter:x.useCallback(d=>{!e||!s||c({path:{accountId:e,filterId:s},body:d})},[e,s,c]),isPending:i.isPending,isSuccess:i.isSuccess,isError:i.isError,error:i.error,reset:i.reset}},Pe=(e,s=!1)=>({clauses:e.literalClauses.map((i,c)=>({id:`clause-${c}`,field:i.field,value:i.value})),matchOperator:e.matchOperator==="And"?"all":"any",widen:e.hasAnchor?{anchorCount:1,...s?{inactive:!0}:{}}:void 0,moveMailboxId:e.actionMailboxId!==S?e.actionMailboxId:void 0,labelId:e.actionLabelId!==S?e.actionLabelId:void 0,scope:e.scope==="Temporary"?"until":"standing",until:e.scope==="Temporary"?$e(e.expiresAt):void 0,name:e.name}),$e=e=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=new Date(s),i=c=>String(c).padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`},k=e=>JSON.stringify({clauses:e.clauses.map(s=>[s.field,s.value]),operator:e.matchOperator,move:e.moveMailboxId??null,label:e.labelId??null,widen:e.widen?e.widen.inactive?"inactive":"active":"none"}),z=(e,s)=>k(e)!==k(s),T=e=>JSON.stringify({scope:e.scope==="until"?"until":"standing",until:e.scope==="until"?e.until??"":""}),_=(e,s)=>T(e)!==T(s),ze=(e,s)=>{const r={},i=(e.name??"").trim();return i!==(s.name??"").trim()&&(r.name=i),z(e,s)&&(r.matchOperator=e.matchOperator==="all"?"And":"Or",r.literalClauses=e.clauses.map(c=>({field:c.field,value:c.value})),r.actionMailboxId=e.moveMailboxId??S,r.actionLabelId=e.labelId??S),_(e,s)&&(r.scope=e.scope==="until"?"Temporary":"Standing",e.scope==="until"&&(r.expiresAt=Me(e.until??""))),r};function _e({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g=!1,onClose:d}){const f=x.useMemo(()=>Pe(s,g),[s,g]),[n,l]=x.useState(f),[m,u]=x.useState(),[h,v]=x.useState(!1),M=x.useRef(0),{count:C}=Ie(e,Oe(n)),y=Re(e,s.filterId),b=we(e),{createFolderIn:F}=se(e),{createLabel:w}=Ce(e),I=async o=>{const a=await w(o);return{id:a.labelId,name:a.name,color:a.color}},p=()=>u({mode:"add",draft:{field:L[0],value:""}}),O=o=>{const a=n.clauses.find(j=>j.id===o);a&&u({mode:"edit",clauseId:o,draft:{field:a.field,value:a.value}})},E=o=>u(a=>a&&{...a,draft:{...a.draft,field:o}}),K=o=>u(a=>a&&{...a,draft:{...a.draft,value:o}}),U=()=>{if(!m)return;const o=m.draft.field,a=De(o,m.draft.value);a!==""&&(l(j=>m.mode==="edit"&&m.clauseId?{...j,clauses:j.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(M.current+=1,{...j,clauses:[...j.clauses,{id:`new-${M.current}`,field:o,value:a}]})),u(void 0))},B=o=>l(a=>({...a,clauses:a.clauses.filter(j=>j.id!==o)})),J=o=>l(a=>({...a,matchOperator:o})),Q=o=>l(a=>({...a,moveMailboxId:o||void 0})),q=o=>l(a=>({...a,labelId:o||void 0})),G=o=>l(a=>({...a,name:o})),H=o=>l(a=>({...a,scope:o,until:o==="until"?a.until:void 0})),V=o=>l(a=>({...a,until:o})),W=()=>{const o=z(n,f)||_(n,f),a=ze(n,f);if(Object.keys(a).length===0){d();return}v(o),y.updateFilter(a)},Y=()=>b.start(Ee(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(Je,{progress:b.progress,isDone:b.isDone,onClose:d}):y.isPending?t.jsx(Ke,{}):y.isError?t.jsx(Qe,{onRetry:y.reset,onClose:d}):y.isSuccess?h?t.jsx(Be,{preview:ae(C),blocked:C.status!=="ready"||C.stale===!0,onReapply:Y,onClose:d}):t.jsx(Ue,{onClose:d}):t.jsx(ie,{rule:n,folders:r,delimiter:i,labels:c,preview:C,semanticAvailable:!1,clauseFields:L,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:O,onRemoveClause:B,onChangeDraftField:E,onChangeDraftValue:K,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:J,onChangeMove:Q,onCreateFolder:F,onChangeLabel:q,onCreateLabel:I,onChangeName:G,onChangeScope:H,onChangeUntil:V,onCommit:W,onCancel:d})}function Ke(){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Saving changes…"})]})}function Ue({onClose:e}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Filter updated"}),t.jsx(N,{variant:"primary",onClick:e,className:"mt-2",children:"Done"})]})}function Be({preview:e,blocked:s,onReapply:r,onClose:i}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx(A,{className:"size-8 text-positive"}),t.jsx("p",{className:"text-sm font-medium text-fg",children:"Rule saved"}),t.jsxs("p",{className:"max-w-xs text-xs text-fg-muted",children:["New mail follows the rule automatically. ",e," — move the mail already in your mailbox too?"]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:r,disabled:s,children:"Move existing mail"}),t.jsx(N,{variant:"ghost",onClick:i,children:"Not now"})]})]})}function Je({progress:e,isDone:s,onClose:r}){const i=e.state==="Failed";return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[s?i?t.jsx("span",{className:"text-sm font-semibold text-danger",children:"Move failed"}):t.jsx(A,{className:"size-8 text-positive"}):t.jsx(R,{className:"size-8 animate-spin text-accent-2"}),!s&&t.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving existing mail…"}),s&&!i&&t.jsxs("div",{className:"text-sm text-fg",children:[t.jsx("p",{className:"font-medium",children:"Done"}),t.jsxs("p",{className:"mt-1 text-xs text-fg-muted",children:[e.appliedCount," of ",e.matchedCount," moved",e.failedCount>0?` · ${e.failedCount} failed`:"","."]})]}),s&&i&&t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:e.errorMessage||"Something went wrong. Please try again."}),s&&t.jsx(N,{variant:"primary",onClick:r,className:"mt-2",children:"Done"})]})}function Qe({onRetry:e,onClose:s}){return t.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-8 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-danger",children:"Couldn't save changes"}),t.jsx("p",{className:"max-w-xs text-xs text-fg-muted",children:"Please try again."}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx(N,{variant:"primary",onClick:e,children:"Try again"}),t.jsx(N,{variant:"ghost",onClick:s,children:"Not now"})]})]})}function qe({accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d}){const f=ne(),n=t.jsx(_e,{accountId:e,filter:s,folders:r,delimiter:i,labels:c,semanticUnavailable:g,onClose:d});return f?t.jsx(re,{open:!0,onClose:d,title:"Filter rule",children:n}):t.jsx(Ne,{open:!0,onClose:d,label:"Filter rule",dismissLabel:"Dismiss filter rule",children:n})}function Ge({filters:e,mailboxName:s,labelById:r,onEdit:i,onDelete:c,deletingFilterId:g,semanticUnavailable:d=!1,now:f=Date.now()}){return e.length===0?t.jsx("p",{className:"py-6 text-sm text-fg-muted",children:"No filters yet. Select a few messages in the inbox and choose Organize to make one."}):t.jsx("ul",{className:"divide-y divide-line rounded-md border border-line",children:e.map(n=>{const l=Ae(n,f),m=l==="Expired",u=n.actionMailboxId!==S?s(n.actionMailboxId):void 0,h=n.actionLabelId!==S?r.get(n.actionLabelId):void 0,v=Le(n.expiresAt);return t.jsxs("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[t.jsxs("button",{type:"button",onClick:()=>i(n.filterId),"aria-label":`Edit filter ${n.name}`,className:"min-w-0 flex-1 rounded-sm text-left hover:opacity-80",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`truncate text-sm font-medium ${m?"text-fg-muted":"text-fg"}`,children:n.name}),t.jsx(oe,{tone:m?"neutral":"positive",dot:!0,children:l})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[u?`Moves matches to ${u}`:"No move action",n.scope==="Temporary"&&v?m?` · expired ${v}`:` · until ${v}`:n.scope==="Standing"?" · always":""]}),(n.hasAnchor||h)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[n.hasAnchor&&t.jsx(le,{widen:{anchorCount:1,...d?{inactive:!0}:{}}}),h&&t.jsx(ce,{label:{labelId:h.id,name:h.name,color:h.color}})]})]}),t.jsx(N,{variant:"ghost",size:"sm",icon:t.jsx(de,{className:"size-4 text-danger"}),onClick:()=>c(n.filterId),disabled:g===n.filterId,"aria-label":`Delete filter ${n.name}`})]},n.filterId)})})}const He=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:["Filters are the standing rules Organize creates. A"," ",t.jsx("strong",{children:"Standing"})," filter keeps working on new mail; a"," ",t.jsx("strong",{children:"Temporary"})," one stops on its own at the date you picked."]}),t.jsx("p",{children:"An expired filter isn't deleted the instant it lapses — it stays here, marked Expired, so you can see what it did and when it stopped."})]});function Ve({account:e}){const s=e.accountId,{filters:r,isPending:i,isError:c,error:g,refetch:d}=ke(s),{deleteFilter:f,deletingFilterId:n}=Te(s),[l,m]=x.useState(),{data:u}=P({...me({path:{accountId:s}}),staleTime:1/0}),h=ue(),v=x.useMemo(()=>pe(e.folderAppointments),[e.folderAppointments]),M=x.useCallback(p=>{const O=u?.items.find(E=>E.mailboxId===p);if(O)return xe(O,v.get(p),h)},[u?.items,v,h]),C=x.useMemo(()=>fe({mailboxes:u?.items??[],folderAppointments:e.folderAppointments,translator:h}),[u?.items,e.folderAppointments,h]),y=he(u?.items??[]),{labels:b}=Se(s),F=x.useMemo(()=>b.map(p=>({id:p.labelId,name:p.name,color:p.color})),[b]),w=x.useMemo(()=>new Map(F.map(p=>[p.id,p])),[F]),I=r.find(p=>p.filterId===l);return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-fg",children:e.email}),I&&t.jsx(qe,{accountId:s,filter:I,folders:C,delimiter:y,labels:F,onClose:()=>m(void 0)}),i?t.jsx("div",{className:"h-16 animate-pulse rounded-md border border-line bg-surface","aria-busy":"true","aria-label":`Loading filters for ${e.email}`}):c?t.jsx($,{variant:"inline",title:`Couldn't load filters for ${e.email}`,error:g,onRetry:()=>{d()}}):t.jsx(Ge,{filters:r,mailboxName:M,labelById:w,onEdit:m,onDelete:f,deletingFilterId:n})]})}function ot(){const e=ge(),[s,r]=x.useState(!0),{data:i,isPending:c,isError:g,error:d,refetch:f}=P(be()),n=l=>{const m=je[l];m&&e({to:m})};return t.jsx(ye,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:He,helpOpen:s,onToggleHelp:()=>r(l=>!l),onSelect:n,onBackToMail:()=>{e({to:"/mail"})},children:c?t.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):g?t.jsx($,{title:"Couldn't load accounts",error:d,onRetry:()=>{f()}}):i.accounts.length===0?t.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):t.jsx("div",{className:"space-y-8",children:i.accounts.map(l=>t.jsx(Ve,{account:l},l.accountId))})})}export{Ve as AccountFilters,ot as component};
@@ -0,0 +1 @@
1
+ import{j as o,O as i}from"./index-B2JlIrVH.js";import{a as m}from"./MailShell-1bk-N22N.js";import{F as r}from"./FlaggedPane-BBHVAfeU.js";import{d as p}from"./search-token-index-27XVZbA6.js";import{u as e}from"./search-mirror-B1Zf9cCU.js";import"./FullCompose-BGRUJh6v.js";import"./ErrorState-LP7AwW_p.js";import"./index-2ffnljAr.js";import"./useMessageBodyContent-D2Bi044R.js";import"./useSignature-KOdqyay3.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-B2LCK_pq.js";import"./sections-Clno-i5j.js";import"./confirm-dialog-CABiCtGp.js";import"./useSearchTokenContext-C0dIvEKK.js";import"./kbd-TVUw5dQH.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-sHAZiuvt.js";import"./roving-focus-BWokg8ha.js";import"./attachment-file-Dpl8hNc0.js";import"./mail-BQ0Xqoj_.js";import"./avatar-C4qRFeeX.js";import"./EmptyState-aKocWGoA.js";import"./download-1tA41rYM.js";import"./calendar-event-chip-CNYRAKOE.js";import"./calendar-color-C1HATGvz.js";import"./map-pin-Dc-USzX4.js";import"./attendee-row-C4aifNUr.js";import"./clock-Dm6u_ukU.js";import"./useLayoutTier-DcOqI0AI.js";import"./shield-check-BGc8_VeV.js";import"./useFilters-A9SedagU.js";import"./useQueries-Cf2uvzGz.js";import"./menu-CTvIK5Qx.js";import"./MailViewChrome-DXBi4P0H.js";import"./refresh-cw-CijD9tc5.js";import"./wizard-selection-DxUM65kM.js";function N(){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{N as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-BSMLcnNv.js";import{E as o}from"./ErrorState-jZhKH-Aj.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
1
+ import{j as r}from"./index-B2JlIrVH.js";import{E as o}from"./ErrorState-LP7AwW_p.js";const l=({error:t,reset:e})=>r.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:r.jsx(o,{title:"Couldn't load your starred mail",error:t,onRetry:e})});export{l as errorComponent};
@@ -0,0 +1 @@
1
+ import{j as e,f as y,a4 as B,bs as Y,r as c,aJ as J,X as W,aR as he,aA as X,a2 as xe,aU as G,bt as fe,az as pe,aC as ge,B as z,aT as be,bu as ve,h as Z,Q as ee,o as se,bv as je,bw as ye,aQ as Ne,P as ke,bx as Ce,by as _,bz as we,bA as Se,bB as te,bC as Ie,bD as H,bj as ae,bp as re,bq as Me,ag as K,af as ne,L as Q,bE as q,bF as Ee,as as Ae,bG as De,u as Oe,c as ie,d as Te,aM as Re,aO as Fe,K as Pe,i as V,s as $e,bH as Le,bI as ze,bJ as _e,aY as Be,bK as Ke,bL as Qe}from"./index-B2JlIrVH.js";import{P as Ge}from"./pencil-C__8PZQ-.js";import{S as He}from"./settings-screen-X-U5v_Fa.js";import{E as oe}from"./ErrorState-LP7AwW_p.js";import"./avatar-C4qRFeeX.js";import"./chevron-left-k4hHGFxU.js";import"./menu-CTvIK5Qx.js";import"./circle-help-CXIkMdfH.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(y,{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(y,{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(Y,{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(J,{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(y,{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(X,{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(y,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(y,{variant:"primary",size:"sm",onClick:r,disabled:l,children:l?"Saving…":"Save name"})]})]}):null},Ye=["inbox","drafts","sent","archive","junk","trash"],U="",Je={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"}`,Xe=(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:j}=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:`${Xe(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.`:"",D=`The folder you chose for ${f}${j?` — ${j} —`:""} 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(y,{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(X,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:N=>l(N.target.value)}),O&&e.jsx(y,{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:D}),e.jsx(y,{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:Ye.map(i=>{const d=a[i]??Je;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),j=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 $(je({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(()=>ye({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=j.current!==void 0,C=await $((async()=>(I||(S.throwIfAborted(),j.current=ns(await M(),t),S.throwIfAborted(),g(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),is({readMailboxes:M,mailboxId:t,since:j.current??0,signal:S})))());return S.aborted?(r("idle"),j.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(j.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(j.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,M,f,h]),D=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 P of b)E.add(P);x=Se(x,b.length),l(x)}const A=await $(cs(t,I));if(!I.aborted){if(!A.ok){x=_(x,A.error),l(x),d(A.error),r("error");return}if(A.value>0){const n=`${A.value} ${A.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,j.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:D,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),j=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:M,deleteMailbox:w,deleteIfEmpty:D,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 F=()=>I(De(Date.now()-M));F();const ue=setInterval(F,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 F=await D();F.status==="blocked"&&(d(F.messageCount),l("choose-fate"))},[D]),A=c.useMemo(()=>Me({mailboxes:o,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:j}),[o,m,a.mailboxId,j]),n=A.find(F=>F.id===p),b=c.useMemo(()=>K(a,ne(m).get(a.mailboxId),j),[a,m,j]);if(!s)return null;const T=`Delete ${b}`,P=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(y,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(y,{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(y,{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(y,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(y,{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(P),". 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(y,{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(P),"? 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(y,{variant:"secondary",size:"sm",onClick:()=>l("choose-fate"),children:"Back"}),e.jsx(y,{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(P)," 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(Y,{folders:A,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(y,{variant:"danger",onClick:()=>N(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${L(P)} to ${n.label}`})})})]});return e.jsxs(J,{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(Ae,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(y,{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(Pe({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,j]=c.useState(),[h,f]=c.useState(),[O,M]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),D=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:K(n,D.get(n.mailboxId),o),path:n.fullPath,deleteBlockedReason:_e(n,w,s.folderAppointments).message})),[w,D,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),A=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=>j(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ue,{open:!0,folderLabel:K(E,D.get(E.mailboxId),o),defaultLabel:K({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},D.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)}),A&&e.jsx(ms,{open:!0,accountId:a,folder:A,mailboxes:w,appointments:s.folderAppointments,onClose:()=>j(void 0)})]})}function ys(){const s=Oe(),[t,a]=c.useState(!0),{data:o,isPending:m,isError:r,error:u,refetch:l}=ie(Te()),i=d=>{const p=Fe[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{ys as component};
@@ -1 +1 @@
1
- import{j as e}from"./index-BSMLcnNv.js";import{K as s}from"./kbd-MeQzj_AS.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]})]});export{r as a,i as b,c,a as s};
1
+ import{j as e}from"./index-B2JlIrVH.js";import{K as s}from"./kbd-TVUw5dQH.js";const a=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(s,{children:"v"})," VIP,"," ",e.jsx(s,{children:"m"})," mute, ",e.jsx(s,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]}),r=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Sync health"})," shows the IMAP connection state and the last successful sync per account."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Error"})," means the last connection attempt failed — the raw server response is shown on the card. Reconnect re-runs the connection test from the add-account wizard."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," accounts keep syncing but stay out of the daily brief and unified counts."]})]}),c=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Density"})," controls how much information fits on screen. Compact is great on smaller displays; Comfortable gives each item more breathing room."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Theme"})," switches between light, dark, and system-preference modes instantly. The change takes effect across the whole app immediately."]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Preferences are stored locally in this browser. Server-side sync is coming soon."})]}),i=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Notification rules"})," and data export are coming in a future release."]}),e.jsxs("p",{children:["A message Remit cannot read is"," ",e.jsx("strong",{className:"text-fg",children:"set aside"})," rather than skipped, and the folder keeps syncing. Setting one aside is a defect in Remit, so every entry can be reported with the diagnostics already attached."]})]});export{r as a,i as b,c,a as s};
@@ -1 +1 @@
1
- import{e as H,j as e,B as x,f,L as _,X as Ee,r,I as Oe,g as O,h as pe,c as ze,d as Be,i as q,s as de,k as $e,l as Pe,m as De,n as Le,o as J,q as qe}from"./index-BSMLcnNv.js";import{W as k,C as fe,a as le,u as We,b as He,c as _e,d as Ke,S as Qe,R as Ue}from"./credential-steps-CuyQQqOh.js";import{c as ge,f as Ve,v as xe,r as Ge,a as Je,b as ue,w as me,p as Xe,W as Ye,s as Ze,g as et}from"./config-import-DJqfxqLZ.js";import{F as tt}from"./file-json-CxdRqoDn.js";import{c as st}from"./onboarding-completion-Dr1hm10w.js";import"./card-Drp0FnU2.js";const nt=H("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);const it=H("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const at=H("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);const rt=H("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),y=["File","Review","Credentials","Folders"];function Y({children:t}){return e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:t})}function ot({state:t="idle",file:n,ready:i=!1,failure:s,onChoose:d,onDragStateChange:l,onNext:h}){const w=r.useId(),u=r.useRef(null),p=t==="dragging",j=t==="reading",S=t==="checking",R=j||S,N=m=>{m.preventDefault(),l?.(!1);const b=m.dataTransfer.files.item(0);b&&d?.(b)};return e.jsx(k,{steps:y,activeStep:0,title:"Import a config file",subtitle:"Accounts, folder roles, rules, senders and appearance — everything except passwords.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Nothing is written until you have seen what will change."}),e.jsx(f,{variant:"primary",disabled:R||!i,icon:R?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:h,children:j?"Reading…":S?"Checking…":"Check the file"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{tone:"danger",children:s.title}),e.jsx("p",{className:"text-sm text-fg",children:s.explanation}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.fix}),e.jsx(Y,{children:s.raw})]}),e.jsxs("div",{onDragOver:m=>{m.preventDefault(),l?.(!0)},onDragLeave:()=>l?.(!1),onDrop:N,className:p?"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-accent bg-accent-soft px-4 py-9 text-center":"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-line px-4 py-9 text-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-md bg-surface-sunken",children:e.jsx(rt,{className:"size-5 text-fg-muted"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:p?"Drop it here":"Drop a config file here, or choose one"}),e.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"A .json file written by Reader — up to 2 MB."})]}),e.jsx("input",{ref:u,id:w,type:"file",accept:"application/json,.json",className:"sr-only",onChange:m=>{const b=m.target.files?.item(0);b&&d?.(b)}}),e.jsx(f,{variant:"secondary",size:"sm",onClick:()=>u.current?.click(),children:"Choose file"})]}),n&&e.jsxs("div",{className:"flex items-start gap-3 rounded-sm border border-line px-3 py-2.5",children:[e.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-fg-muted"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-fg",children:n.name}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[Ve(n.size)," ·"," ",j?"reading it from disk":S?"checking it against this instance":i?"ready to check — nothing has been sent yet":"not a configuration this instance can read"]})]})]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Export one from Settings → Advanced on the instance you are moving from, or run"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on its host."]})]})})}function ct({sections:t}){const n=ge(t.flatMap(i=>i.entries.map(s=>({section:i.id,key:s.label,verdict:s.verdict}))));return e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["created","updated","unchanged","skipped","rejected"].filter(i=>n[i]>0).map(i=>e.jsxs(O,{tone:xe[i],dot:!0,children:[n[i]," ",i]},i))})}function dt({section:t}){return e.jsxs("section",{children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.title}),e.jsx("ul",{className:"mt-1.5 divide-y divide-line",children:t.entries.map(n=>e.jsxs("li",{className:"flex items-start gap-3 py-2",children:[e.jsx(O,{tone:xe[n.verdict],className:"mt-0.5 shrink-0",children:n.verdict}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-fg",children:n.label}),n.reason&&e.jsx("p",{className:n.verdict==="rejected"?"mt-1 text-xs text-danger":"mt-1 text-xs text-warning",children:n.reason})]})]},n.id))})]})}function lt({sections:t,fileName:n,warnings:i=[],applying:s=!1,onBack:d,onNext:l}){const h=ge(t.flatMap(p=>p.entries.map(j=>({section:p.id,key:j.label,verdict:j.verdict})))),w=h.created+h.updated,u=h.skipped+h.rejected;return e.jsx(k,{steps:y,activeStep:1,title:"What this file will change",subtitle:`${n} · nothing has been written yet.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:s,icon:s?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:l,children:s?"Importing…":`Import ${w} changes`})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(ct,{sections:t}),u>0&&e.jsxs(x,{tone:"warning",children:[u," entries will not be imported. Each says why below — read them before you continue, because nothing here retries on its own."]}),i.length>0&&e.jsx("ul",{className:"space-y-1 text-xs text-warning",children:i.map(p=>e.jsx("li",{children:p},p))}),t.map(p=>e.jsx(dt,{section:p},p.id))]})})}function ut({choice:t,held:n,onChoose:i,onBack:s,onNext:d}){return e.jsx(k,{steps:y,activeStep:1,title:"This instance already has configuration",subtitle:n,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:s,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:!t,onClick:d,children:t==="merge"?"Continue with merge":"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"warning",children:"An import into a configured instance can only add and update — it never deletes what is here. Pick how the two should meet."}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(le,{name:"Stop, keep this instance",description:"Nothing is written. Use this if you meant to import into a fresh instance.",icon:e.jsx(Ee,{className:"size-5"}),selected:t==="abort",onSelect:()=>i?.("abort")}),e.jsx(le,{name:"Merge the file in",description:"Adds what is missing and updates what differs. Existing accounts keep their server settings.",icon:e.jsx(at,{className:"size-5"}),selected:t==="merge",onSelect:()=>i?.("merge")})]}),t==="merge"&&e.jsx("p",{className:"text-xs text-fg-muted",children:"The next screen lists every add and update before anything is written."})]})})}function mt(t){return t==="entered"?e.jsx(O,{tone:"positive",children:"ready"}):t==="failed"?e.jsx(O,{tone:"danger",children:"sign-in failed"}):e.jsx(O,{tone:"danger",children:"credentials needed"})}function ht({accounts:t,busyAccountId:n,onOpen:i}){return e.jsx("ul",{className:"divide-y divide-line",children:t.map(s=>e.jsxs("li",{className:s.state==="entered"?"flex flex-wrap items-start justify-between gap-3 py-3":"flex flex-wrap items-start justify-between gap-3 border-l-2 border-danger bg-danger-soft py-3 pl-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:s.address}),mt(s.state)]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[s.displayName," ·"," ",s.connector==="microsoft"?"Microsoft 365":"IMAP / SMTP"," ","· ",s.server]}),s.state!=="entered"&&e.jsx("p",{className:"mt-1 text-xs text-danger",children:s.failure??(s.connector==="microsoft"?"Config files never carry OAuth tokens. Reconnect with Microsoft to start syncing this account.":"Config files never carry passwords. Enter this mailbox's password to start syncing.")})]}),s.state!=="entered"&&e.jsx(f,{variant:"primary",size:"sm",disabled:n===s.accountId,icon:n===s.accountId?e.jsx(_,{className:"size-3.5 animate-spin"}):s.connector==="microsoft"?e.jsx(Oe,{className:"size-3.5"}):e.jsx(it,{className:"size-3.5"}),onClick:()=>i?.(s),children:n===s.accountId?"Redirecting…":s.connector==="microsoft"?"Reconnect":s.state==="failed"?"Try again":"Enter password"})]},s.accountId))})}function pt({accounts:t,busyAccountId:n,error:i,onOpen:s,onNext:d}){const l=t.filter(h=>h.state!=="entered").length;return e.jsx(k,{steps:y,activeStep:2,title:"These accounts need credentials",subtitle:"The config file carries servers and settings. Passwords and Microsoft sign-ins it deliberately leaves out.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:l>0?"Settings › Accounts keeps asking until every account is signed in.":"Every account can sync."}),e.jsx(f,{variant:"primary",onClick:d,children:l>0?"Finish later":"All accounts connected"})]}),children:e.jsxs("div",{className:"space-y-4",children:[i&&e.jsx(x,{tone:"danger",children:i}),l>0&&e.jsxs(x,{tone:"danger",children:[l," of ",t.length," accounts cannot sync yet. They stay listed in Settings, marked like this, until you sign in — no mail arrives for them in the meantime."]}),e.jsx(ht,{accounts:t,busyAccountId:n,onOpen:s})]})})}function ft({account:t,position:n,total:i,error:s,busy:d=!1,onBack:l,onNext:h}){return e.jsx(k,{steps:y,activeStep:2,title:`Reconnect ${t.address}`,subtitle:`Account ${n} of ${i} · Microsoft 365`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:l,children:"Back"}),e.jsx(f,{variant:"primary",disabled:d,icon:d?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:h,children:d?"Redirecting…":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsx(x,{tone:"danger",children:s}),e.jsx(x,{tone:"info",children:"A config file never carries an OAuth token — one only works for the instance it was granted to. Signing in here mints a fresh one for this instance."}),e.jsxs("div",{className:"rounded-sm border border-line px-3 py-2.5",children:[e.jsx("p",{className:"text-sm text-fg",children:t.displayName}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[t.address," · ",t.server]})]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"You will be sent to Microsoft and returned here. If your organisation requires admin approval, the sign-in stops there and this account keeps waiting."})]})})}function gt({folders:t,onNext:n}){return e.jsx(k,{steps:y,activeStep:3,title:t.length>0?"Waiting on folders":"Import finished",subtitle:t.length>0?"The config names folders this server has not shown us yet.":"Everything in the file landed, and every folder it named resolved.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Folder discovery runs with every sync."}),e.jsx(f,{variant:"primary",onClick:n,children:"Go to inbox"})]}),children:e.jsx("div",{className:"space-y-4",children:t.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(x,{tone:"warning",children:[t.length," settings are imported but switched off. Each turns itself on the moment its folder appears — nothing was dropped. If a folder never appears, create it in your mail client, or edit the setting in Settings → Senders & Rules."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(nt,{className:"size-4"}),"Folder discovery runs with every sync of the account."]}),e.jsx("div",{className:"divide-y divide-line",children:t.map(i=>e.jsx(fe,{label:i.path,detail:i.waitingFor,state:"pending"},`${i.accountId??""}-${i.path}-${i.waitingFor}`))})]}):e.jsx(x,{tone:"success",children:"Every account, rule, label and sender in the file is live on this instance."})})})}function xt({failure:t,onBack:n}){return e.jsx(k,{steps:y,activeStep:0,title:t.title,subtitle:"Nothing was imported.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"This instance is unchanged."}),e.jsx(f,{variant:"primary",onClick:n,children:"Choose another file"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(x,{tone:"danger",children:t.explanation}),e.jsx("p",{className:"text-sm text-fg",children:t.fix}),e.jsx(Y,{children:t.raw})]})})}function jt(t){return t==="landed"?"ok":t==="failed"||t==="unknown"?"failed":"pending"}function vt({results:t,message:n,raw:i,nothingLanded:s,onBack:d,onNext:l}){const h=t.filter(u=>u.state==="landed").length,w=t.some(u=>u.state==="unknown");return e.jsx(k,{steps:y,activeStep:1,title:s?"The import stopped, and nothing landed":"The import stopped part-way",subtitle:s?"No section of the file was written.":w?"It did not say how far it got, so check Settings before importing again.":`${h} of ${t.length} sections landed.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",onClick:l,children:s?"Try the import again":"Retry the rest"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"danger",children:n}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Retrying is safe: an import folds into what is already here rather than replacing it, so what landed is recognised and left alone."}),e.jsx("div",{className:"divide-y divide-line",children:t.map(u=>e.jsx(fe,{label:u.title,detail:u.detail,state:jt(u.state)},u.section))}),e.jsx(Y,{children:i})]})})}const je=(t,n)=>t?"tls":n?"starttls":"none",yt=t=>({host:t.imapHost,port:t.imapPort,security:je(t.imapTls,t.imapStartTls)}),wt=t=>({host:t.smtpEnabled?t.smtpHost:"",port:t.smtpPort,security:je(t.smtpTls,t.smtpStartTls)}),he=(t,n,i)=>{const s=t.authType==="oauthMicrosoft"?"microsoft":"imap",d=!i&&(s==="microsoft"?t.connectionState==="reauth_required":t.connectionState==="credentials_missing");return{accountId:t.accountId,address:t.email,displayName:t.displayName?.trim()||t.email,connector:s,server:`${t.imapHost}:${t.imapPort}`,state:n?"failed":d?"needed":"entered",failure:n}},bt=t=>{if(!t)return"This instance already holds configuration of its own.";const n=[["accounts","account"],["labels","label"],["filters","rule"],["addressFlags","flagged sender"]].map(([i,s])=>({count:Number(t[i]??0),noun:s})).filter(i=>i.count>0).map(i=>`${i.count} ${i.noun}${i.count===1?"":"s"}`);return n.length===0?"This instance already holds configuration of its own.":`${n.join(", ")} are set up here already.`},W=(t,n)=>{if(t instanceof Error)return t.message;if(typeof t=="object"&&t!==null){const i=t.message;if(typeof i=="string")return i}return n};function kt({onDone:t}){const n=pe(),[i,s]=r.useState("file"),[d,l]=r.useState(!1),[h,w]=r.useState(!1),[u,p]=r.useState(void 0),[j,S]=r.useState(void 0),[R,N]=r.useState(void 0),[m,b]=r.useState(void 0),[Z,ee]=r.useState("abort"),[te,se]=r.useState(void 0),[ye,K]=r.useState(void 0),[C,we]=r.useState([]),[Q,be]=r.useState([]),[g,I]=r.useState(null),[T,U]=r.useState({username:"",password:""}),[F,V]=r.useState({}),[ke,ne]=r.useState(void 0),[G,z]=r.useState(null),[B,Se]=r.useState([]),{data:$}=ze({...Be(),enabled:C.length>0||i==="folders"}),A=r.useMemo(()=>{const a=new Map;for(const o of $?.accounts??[])a.set(o.accountId,o);return a},[$]),Ne=r.useMemo(()=>C.map(a=>A.get(a)).filter(a=>!!a).map(a=>he(a,F[a.accountId],Q.includes(a.accountId))),[C,A,F,Q]),c=g?A.get(g):void 0,ie=g?C.indexOf(g)+1:0,P=q({...$e(),meta:de(409)}),ae=q({...Pe(),meta:de(403,404)}),re=q(De()),oe=q(Le());We(G!==null,()=>{n.invalidateQueries({queryKey:J()}),z(null)});const ce=He(a=>{z(null),a==="stalled"&&ne(Ue)}),Ce=r.useCallback(a=>{l(!1),w(!0),p({name:a.name,size:a.size}),N(void 0),S(void 0),a.text().then(o=>Ge(a.name,a.size,o)).then(o=>{if(w(!1),!o.ok){N(o.failure);return}S(o.document)}).catch(o=>{w(!1),N({title:"That file could not be read",explanation:`The browser could not read ${a.name} from disk, so nothing was sent.`,fix:"Check the file is still there and try again.",raw:W(o,"the file read was refused")})})},[]),D=r.useCallback((a,o)=>{j&&(K(void 0),P.mutate({body:{mode:a,onExisting:o,document:j}},{onSuccess:v=>{if(b(v),ue(v)){s("rejected");return}if(me(v)){s("partial");return}if(a==="validate"){s("review");return}if(Se(Xe(v)),n.invalidateQueries({queryKey:J()}),v.accountsNeedingCredentials.length>0){we([...v.accountsNeedingCredentials]),s("credentials");return}s("folders")},onError:v=>{const L=Je(v);if(L){K(L),se(void 0),s("conflict");return}N({title:"The import could not be sent",explanation:"The request to this instance failed before it produced a report, so nothing was written.",fix:"Check your connection and try again.",raw:W(v,"POST /config/import failed")}),s("file")}}))},[j,P,n]),Ie=r.useCallback(a=>{if(I(a.accountId),ne(void 0),a.connector==="microsoft"){s("account-oauth");return}const o=A.get(a.accountId);U({username:o?.username||a.address,password:""}),s("account-password")},[A]),Te=r.useCallback(()=>{g&&ae.mutate({path:{accountId:g},body:{password:T.password,isActive:!0}},{onSuccess:()=>{re.mutate({path:{accountId:g}}),be(a=>a.includes(g)?a:[...a,g]),V(a=>{const o={...a};return delete o[g],o}),n.invalidateQueries({queryKey:J()}),U({username:"",password:""}),I(null),s("credentials")},onError:a=>{V(o=>({...o,[g]:W(a,"The password was verified but could not be stored. Try again.")})),I(null),s("credentials")}})},[g,T.password,n,re,ae]),Re=r.useCallback(()=>{c&&(z(c.accountId),oe.mutate({body:{email:c.email}},{onSuccess:a=>{ce(),window.location.assign(a.authorizationUrl)},onError:a=>{z(null),V(o=>({...o,[c.accountId]:W(a,"Microsoft sign-in could not be started.")})),I(null),s("credentials")}}))},[c,ce,oe]),Fe=r.useCallback((a,o)=>U({username:a,password:o}),[]),Ae=r.useMemo(()=>{const a=$?.pendingImport?.folderPaths;if(!a)return B;const o=new Set(a),v=B.filter(E=>o.has(E.path)),L=a.filter(E=>!B.some(Me=>Me.path===E)).map(E=>({path:E,waitingFor:"An imported setting"}));return[...v,...L]},[$,B]),M=r.useCallback(()=>{b(void 0),K(void 0),N(void 0),p(void 0),S(void 0),ee("abort"),s("file")},[]);switch(i){case"file":return e.jsx(ot,{state:h?"reading":P.isPending?"checking":d?"dragging":"idle",file:u,ready:j!==void 0,failure:R,onChoose:Ce,onDragStateChange:l,onNext:()=>D("validate",Z)});case"rejected":return e.jsx(xt,{failure:(m&&ue(m))??R??{title:"The file could not be imported",explanation:"The import was refused and nothing was written.",fix:"Re-export the configuration and try again.",raw:"no error was reported"},onBack:M});case"conflict":return e.jsx(ut,{choice:te,held:bt(ye?.details),onChoose:se,onBack:M,onNext:()=>{if(te==="abort"){t("abandoned");return}ee("merge"),D("validate","merge")}});case"review":return e.jsx(lt,{sections:et(m?.items??[]),fileName:u?.name??"the config file",warnings:(m?.warnings??[]).map(a=>a.message),applying:P.isPending,onBack:M,onNext:()=>D("apply",Z)});case"partial":{if(!m)return e.jsx(St,{onBack:M});const a=me(m);return e.jsx(vt,{results:Ze(m),message:a?.message??"The import stopped before it finished.",raw:`${a?.code??Ye}: ${a?.message??"no message"}`,nothingLanded:!m.applied,onBack:M,onNext:()=>D("apply","merge")})}case"credentials":return e.jsx(pt,{accounts:Ne,busyAccountId:G??void 0,error:ke,onOpen:Ie,onNext:()=>s("folders")});case"account-password":return c?e.jsx(Ke,{steps:y,activeStep:2,title:`Sign in to ${c.email}`,subtitle:`Account ${ie} of ${C.length} · ${c.imapHost}:${c.imapPort}`,email:c.email,username:T.username,password:T.password,error:F[c.accountId],continueLabel:"Test and continue",notice:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(Qe,{className:"size-3.5"}),"Server settings came from the config file — edit them in Settings if they are wrong."]}),onContinue:()=>s("account-test"),onBack:()=>{I(null),s("credentials")},onChange:Fe}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-test":return c?e.jsx(_e,{steps:y,activeStep:2,email:c.email,imapConfig:yt(c),smtpConfig:wt(c),username:T.username,password:T.password,credentialsBackLabel:"Back to the password",serversBackLabel:"Back to the password",successLabel:"Save and continue",onSuccess:Te,onBackToCredentials:()=>s("account-password"),onBackToServers:()=>s("account-password")}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-oauth":return c?e.jsx(ft,{account:he(c,F[c.accountId],Q.includes(c.accountId)),position:ie,total:C.length,error:F[c.accountId],busy:G===c.accountId,onBack:()=>{I(null),s("credentials")},onNext:Re}):e.jsx(X,{onBack:()=>t("abandoned")});case"folders":return e.jsx(gt,{folders:Ae,onNext:()=>t("imported")})}}function ve({children:t,label:n,onBack:i}){return e.jsxs("div",{className:"mx-auto max-w-lg p-6",children:[e.jsx(x,{tone:"danger",children:t}),e.jsx("button",{type:"button",className:"mt-3 text-sm text-accent underline",onClick:i,children:n})]})}function X({onBack:t}){return e.jsx(ve,{label:"Go to inbox",onBack:t,children:"That account is no longer in this instance's configuration, so there is nothing left to sign in to. Open Settings › Accounts to see what is here."})}function St({onBack:t}){return e.jsx(ve,{label:"Choose another file",onBack:t,children:"The import stopped but produced no report, so nothing here can say what it wrote. Open Settings to see what this instance holds before importing again."})}function At(){const t=qe(),n=pe(),i=r.useCallback(s=>{st({queryClient:n,recordCompleted:()=>{s==="imported"&&t.recordEvent("config.imported")},navigateToInbox:()=>{window.location.assign("/mail")}})},[t,n]);return e.jsx(kt,{onDone:i})}export{At as component};
1
+ import{e as H,j as e,B as x,f,L as _,X as Ee,r,I as Oe,g as O,h as pe,c as ze,d as Be,i as q,s as de,k as $e,l as Pe,m as De,n as Le,o as J,q as qe}from"./index-B2JlIrVH.js";import{W as k,C as fe,a as le,u as We,b as He,c as _e,d as Ke,S as Qe,R as Ue}from"./credential-steps-DM1fuM06.js";import{c as ge,f as Ve,v as xe,r as Ge,a as Je,b as ue,w as me,p as Xe,W as Ye,s as Ze,g as et}from"./config-import-CfF4lyQV.js";import{F as tt}from"./file-json-CCwrBIYv.js";import{c as st}from"./onboarding-completion-BhqyiyYl.js";import"./card-CgowAhQY.js";const nt=H("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);const it=H("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const at=H("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);const rt=H("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),y=["File","Review","Credentials","Folders"];function Y({children:t}){return e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:t})}function ot({state:t="idle",file:n,ready:i=!1,failure:s,onChoose:d,onDragStateChange:l,onNext:h}){const w=r.useId(),u=r.useRef(null),p=t==="dragging",j=t==="reading",S=t==="checking",R=j||S,N=m=>{m.preventDefault(),l?.(!1);const b=m.dataTransfer.files.item(0);b&&d?.(b)};return e.jsx(k,{steps:y,activeStep:0,title:"Import a config file",subtitle:"Accounts, folder roles, rules, senders and appearance — everything except passwords.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Nothing is written until you have seen what will change."}),e.jsx(f,{variant:"primary",disabled:R||!i,icon:R?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:h,children:j?"Reading…":S?"Checking…":"Check the file"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{tone:"danger",children:s.title}),e.jsx("p",{className:"text-sm text-fg",children:s.explanation}),e.jsx("p",{className:"text-sm text-fg-muted",children:s.fix}),e.jsx(Y,{children:s.raw})]}),e.jsxs("div",{onDragOver:m=>{m.preventDefault(),l?.(!0)},onDragLeave:()=>l?.(!1),onDrop:N,className:p?"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-accent bg-accent-soft px-4 py-9 text-center":"flex flex-col items-center gap-3 rounded-sm border-2 border-dashed border-line px-4 py-9 text-center",children:[e.jsx("span",{className:"flex size-11 items-center justify-center rounded-md bg-surface-sunken",children:e.jsx(rt,{className:"size-5 text-fg-muted"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:p?"Drop it here":"Drop a config file here, or choose one"}),e.jsx("p",{className:"mt-1 text-xs text-fg-subtle",children:"A .json file written by Reader — up to 2 MB."})]}),e.jsx("input",{ref:u,id:w,type:"file",accept:"application/json,.json",className:"sr-only",onChange:m=>{const b=m.target.files?.item(0);b&&d?.(b)}}),e.jsx(f,{variant:"secondary",size:"sm",onClick:()=>u.current?.click(),children:"Choose file"})]}),n&&e.jsxs("div",{className:"flex items-start gap-3 rounded-sm border border-line px-3 py-2.5",children:[e.jsx(tt,{className:"mt-0.5 size-4 shrink-0 text-fg-muted"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-fg",children:n.name}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[Ve(n.size)," ·"," ",j?"reading it from disk":S?"checking it against this instance":i?"ready to check — nothing has been sent yet":"not a configuration this instance can read"]})]})]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Export one from Settings → Advanced on the instance you are moving from, or run"," ",e.jsx("code",{className:"rounded bg-surface-sunken px-1 py-0.5",children:"remit config save"})," ","on its host."]})]})})}function ct({sections:t}){const n=ge(t.flatMap(i=>i.entries.map(s=>({section:i.id,key:s.label,verdict:s.verdict}))));return e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["created","updated","unchanged","skipped","rejected"].filter(i=>n[i]>0).map(i=>e.jsxs(O,{tone:xe[i],dot:!0,children:[n[i]," ",i]},i))})}function dt({section:t}){return e.jsxs("section",{children:[e.jsx("h2",{className:"text-sm font-semibold text-fg",children:t.title}),e.jsx("ul",{className:"mt-1.5 divide-y divide-line",children:t.entries.map(n=>e.jsxs("li",{className:"flex items-start gap-3 py-2",children:[e.jsx(O,{tone:xe[n.verdict],className:"mt-0.5 shrink-0",children:n.verdict}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-fg",children:n.label}),n.reason&&e.jsx("p",{className:n.verdict==="rejected"?"mt-1 text-xs text-danger":"mt-1 text-xs text-warning",children:n.reason})]})]},n.id))})]})}function lt({sections:t,fileName:n,warnings:i=[],applying:s=!1,onBack:d,onNext:l}){const h=ge(t.flatMap(p=>p.entries.map(j=>({section:p.id,key:j.label,verdict:j.verdict})))),w=h.created+h.updated,u=h.skipped+h.rejected;return e.jsx(k,{steps:y,activeStep:1,title:"What this file will change",subtitle:`${n} · nothing has been written yet.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:s,icon:s?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:l,children:s?"Importing…":`Import ${w} changes`})]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(ct,{sections:t}),u>0&&e.jsxs(x,{tone:"warning",children:[u," entries will not be imported. Each says why below — read them before you continue, because nothing here retries on its own."]}),i.length>0&&e.jsx("ul",{className:"space-y-1 text-xs text-warning",children:i.map(p=>e.jsx("li",{children:p},p))}),t.map(p=>e.jsx(dt,{section:p},p.id))]})})}function ut({choice:t,held:n,onChoose:i,onBack:s,onNext:d}){return e.jsx(k,{steps:y,activeStep:1,title:"This instance already has configuration",subtitle:n,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:s,children:"Choose another file"}),e.jsx(f,{variant:"primary",disabled:!t,onClick:d,children:t==="merge"?"Continue with merge":"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"warning",children:"An import into a configured instance can only add and update — it never deletes what is here. Pick how the two should meet."}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(le,{name:"Stop, keep this instance",description:"Nothing is written. Use this if you meant to import into a fresh instance.",icon:e.jsx(Ee,{className:"size-5"}),selected:t==="abort",onSelect:()=>i?.("abort")}),e.jsx(le,{name:"Merge the file in",description:"Adds what is missing and updates what differs. Existing accounts keep their server settings.",icon:e.jsx(at,{className:"size-5"}),selected:t==="merge",onSelect:()=>i?.("merge")})]}),t==="merge"&&e.jsx("p",{className:"text-xs text-fg-muted",children:"The next screen lists every add and update before anything is written."})]})})}function mt(t){return t==="entered"?e.jsx(O,{tone:"positive",children:"ready"}):t==="failed"?e.jsx(O,{tone:"danger",children:"sign-in failed"}):e.jsx(O,{tone:"danger",children:"credentials needed"})}function ht({accounts:t,busyAccountId:n,onOpen:i}){return e.jsx("ul",{className:"divide-y divide-line",children:t.map(s=>e.jsxs("li",{className:s.state==="entered"?"flex flex-wrap items-start justify-between gap-3 py-3":"flex flex-wrap items-start justify-between gap-3 border-l-2 border-danger bg-danger-soft py-3 pl-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-fg",children:s.address}),mt(s.state)]}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[s.displayName," ·"," ",s.connector==="microsoft"?"Microsoft 365":"IMAP / SMTP"," ","· ",s.server]}),s.state!=="entered"&&e.jsx("p",{className:"mt-1 text-xs text-danger",children:s.failure??(s.connector==="microsoft"?"Config files never carry OAuth tokens. Reconnect with Microsoft to start syncing this account.":"Config files never carry passwords. Enter this mailbox's password to start syncing.")})]}),s.state!=="entered"&&e.jsx(f,{variant:"primary",size:"sm",disabled:n===s.accountId,icon:n===s.accountId?e.jsx(_,{className:"size-3.5 animate-spin"}):s.connector==="microsoft"?e.jsx(Oe,{className:"size-3.5"}):e.jsx(it,{className:"size-3.5"}),onClick:()=>i?.(s),children:n===s.accountId?"Redirecting…":s.connector==="microsoft"?"Reconnect":s.state==="failed"?"Try again":"Enter password"})]},s.accountId))})}function pt({accounts:t,busyAccountId:n,error:i,onOpen:s,onNext:d}){const l=t.filter(h=>h.state!=="entered").length;return e.jsx(k,{steps:y,activeStep:2,title:"These accounts need credentials",subtitle:"The config file carries servers and settings. Passwords and Microsoft sign-ins it deliberately leaves out.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:l>0?"Settings › Accounts keeps asking until every account is signed in.":"Every account can sync."}),e.jsx(f,{variant:"primary",onClick:d,children:l>0?"Finish later":"All accounts connected"})]}),children:e.jsxs("div",{className:"space-y-4",children:[i&&e.jsx(x,{tone:"danger",children:i}),l>0&&e.jsxs(x,{tone:"danger",children:[l," of ",t.length," accounts cannot sync yet. They stay listed in Settings, marked like this, until you sign in — no mail arrives for them in the meantime."]}),e.jsx(ht,{accounts:t,busyAccountId:n,onOpen:s})]})})}function ft({account:t,position:n,total:i,error:s,busy:d=!1,onBack:l,onNext:h}){return e.jsx(k,{steps:y,activeStep:2,title:`Reconnect ${t.address}`,subtitle:`Account ${n} of ${i} · Microsoft 365`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:l,children:"Back"}),e.jsx(f,{variant:"primary",disabled:d,icon:d?e.jsx(_,{className:"size-3.5 animate-spin"}):void 0,onClick:h,children:d?"Redirecting…":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-4",children:[s&&e.jsx(x,{tone:"danger",children:s}),e.jsx(x,{tone:"info",children:"A config file never carries an OAuth token — one only works for the instance it was granted to. Signing in here mints a fresh one for this instance."}),e.jsxs("div",{className:"rounded-sm border border-line px-3 py-2.5",children:[e.jsx("p",{className:"text-sm text-fg",children:t.displayName}),e.jsxs("p",{className:"mt-0.5 text-xs text-fg-subtle",children:[t.address," · ",t.server]})]}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"You will be sent to Microsoft and returned here. If your organisation requires admin approval, the sign-in stops there and this account keeps waiting."})]})})}function gt({folders:t,onNext:n}){return e.jsx(k,{steps:y,activeStep:3,title:t.length>0?"Waiting on folders":"Import finished",subtitle:t.length>0?"The config names folders this server has not shown us yet.":"Everything in the file landed, and every folder it named resolved.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Folder discovery runs with every sync."}),e.jsx(f,{variant:"primary",onClick:n,children:"Go to inbox"})]}),children:e.jsx("div",{className:"space-y-4",children:t.length>0?e.jsxs(e.Fragment,{children:[e.jsxs(x,{tone:"warning",children:[t.length," settings are imported but switched off. Each turns itself on the moment its folder appears — nothing was dropped. If a folder never appears, create it in your mail client, or edit the setting in Settings → Senders & Rules."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(nt,{className:"size-4"}),"Folder discovery runs with every sync of the account."]}),e.jsx("div",{className:"divide-y divide-line",children:t.map(i=>e.jsx(fe,{label:i.path,detail:i.waitingFor,state:"pending"},`${i.accountId??""}-${i.path}-${i.waitingFor}`))})]}):e.jsx(x,{tone:"success",children:"Every account, rule, label and sender in the file is live on this instance."})})})}function xt({failure:t,onBack:n}){return e.jsx(k,{steps:y,activeStep:0,title:t.title,subtitle:"Nothing was imported.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"This instance is unchanged."}),e.jsx(f,{variant:"primary",onClick:n,children:"Choose another file"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(x,{tone:"danger",children:t.explanation}),e.jsx("p",{className:"text-sm text-fg",children:t.fix}),e.jsx(Y,{children:t.raw})]})})}function jt(t){return t==="landed"?"ok":t==="failed"||t==="unknown"?"failed":"pending"}function vt({results:t,message:n,raw:i,nothingLanded:s,onBack:d,onNext:l}){const h=t.filter(u=>u.state==="landed").length,w=t.some(u=>u.state==="unknown");return e.jsx(k,{steps:y,activeStep:1,title:s?"The import stopped, and nothing landed":"The import stopped part-way",subtitle:s?"No section of the file was written.":w?"It did not say how far it got, so check Settings before importing again.":`${h} of ${t.length} sections landed.`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"ghost",onClick:d,children:"Choose another file"}),e.jsx(f,{variant:"primary",onClick:l,children:s?"Try the import again":"Retry the rest"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{tone:"danger",children:n}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Retrying is safe: an import folds into what is already here rather than replacing it, so what landed is recognised and left alone."}),e.jsx("div",{className:"divide-y divide-line",children:t.map(u=>e.jsx(fe,{label:u.title,detail:u.detail,state:jt(u.state)},u.section))}),e.jsx(Y,{children:i})]})})}const je=(t,n)=>t?"tls":n?"starttls":"none",yt=t=>({host:t.imapHost,port:t.imapPort,security:je(t.imapTls,t.imapStartTls)}),wt=t=>({host:t.smtpEnabled?t.smtpHost:"",port:t.smtpPort,security:je(t.smtpTls,t.smtpStartTls)}),he=(t,n,i)=>{const s=t.authType==="oauthMicrosoft"?"microsoft":"imap",d=!i&&(s==="microsoft"?t.connectionState==="reauth_required":t.connectionState==="credentials_missing");return{accountId:t.accountId,address:t.email,displayName:t.displayName?.trim()||t.email,connector:s,server:`${t.imapHost}:${t.imapPort}`,state:n?"failed":d?"needed":"entered",failure:n}},bt=t=>{if(!t)return"This instance already holds configuration of its own.";const n=[["accounts","account"],["labels","label"],["filters","rule"],["addressFlags","flagged sender"]].map(([i,s])=>({count:Number(t[i]??0),noun:s})).filter(i=>i.count>0).map(i=>`${i.count} ${i.noun}${i.count===1?"":"s"}`);return n.length===0?"This instance already holds configuration of its own.":`${n.join(", ")} are set up here already.`},W=(t,n)=>{if(t instanceof Error)return t.message;if(typeof t=="object"&&t!==null){const i=t.message;if(typeof i=="string")return i}return n};function kt({onDone:t}){const n=pe(),[i,s]=r.useState("file"),[d,l]=r.useState(!1),[h,w]=r.useState(!1),[u,p]=r.useState(void 0),[j,S]=r.useState(void 0),[R,N]=r.useState(void 0),[m,b]=r.useState(void 0),[Z,ee]=r.useState("abort"),[te,se]=r.useState(void 0),[ye,K]=r.useState(void 0),[C,we]=r.useState([]),[Q,be]=r.useState([]),[g,I]=r.useState(null),[T,U]=r.useState({username:"",password:""}),[F,V]=r.useState({}),[ke,ne]=r.useState(void 0),[G,z]=r.useState(null),[B,Se]=r.useState([]),{data:$}=ze({...Be(),enabled:C.length>0||i==="folders"}),A=r.useMemo(()=>{const a=new Map;for(const o of $?.accounts??[])a.set(o.accountId,o);return a},[$]),Ne=r.useMemo(()=>C.map(a=>A.get(a)).filter(a=>!!a).map(a=>he(a,F[a.accountId],Q.includes(a.accountId))),[C,A,F,Q]),c=g?A.get(g):void 0,ie=g?C.indexOf(g)+1:0,P=q({...$e(),meta:de(409)}),ae=q({...Pe(),meta:de(403,404)}),re=q(De()),oe=q(Le());We(G!==null,()=>{n.invalidateQueries({queryKey:J()}),z(null)});const ce=He(a=>{z(null),a==="stalled"&&ne(Ue)}),Ce=r.useCallback(a=>{l(!1),w(!0),p({name:a.name,size:a.size}),N(void 0),S(void 0),a.text().then(o=>Ge(a.name,a.size,o)).then(o=>{if(w(!1),!o.ok){N(o.failure);return}S(o.document)}).catch(o=>{w(!1),N({title:"That file could not be read",explanation:`The browser could not read ${a.name} from disk, so nothing was sent.`,fix:"Check the file is still there and try again.",raw:W(o,"the file read was refused")})})},[]),D=r.useCallback((a,o)=>{j&&(K(void 0),P.mutate({body:{mode:a,onExisting:o,document:j}},{onSuccess:v=>{if(b(v),ue(v)){s("rejected");return}if(me(v)){s("partial");return}if(a==="validate"){s("review");return}if(Se(Xe(v)),n.invalidateQueries({queryKey:J()}),v.accountsNeedingCredentials.length>0){we([...v.accountsNeedingCredentials]),s("credentials");return}s("folders")},onError:v=>{const L=Je(v);if(L){K(L),se(void 0),s("conflict");return}N({title:"The import could not be sent",explanation:"The request to this instance failed before it produced a report, so nothing was written.",fix:"Check your connection and try again.",raw:W(v,"POST /config/import failed")}),s("file")}}))},[j,P,n]),Ie=r.useCallback(a=>{if(I(a.accountId),ne(void 0),a.connector==="microsoft"){s("account-oauth");return}const o=A.get(a.accountId);U({username:o?.username||a.address,password:""}),s("account-password")},[A]),Te=r.useCallback(()=>{g&&ae.mutate({path:{accountId:g},body:{password:T.password,isActive:!0}},{onSuccess:()=>{re.mutate({path:{accountId:g}}),be(a=>a.includes(g)?a:[...a,g]),V(a=>{const o={...a};return delete o[g],o}),n.invalidateQueries({queryKey:J()}),U({username:"",password:""}),I(null),s("credentials")},onError:a=>{V(o=>({...o,[g]:W(a,"The password was verified but could not be stored. Try again.")})),I(null),s("credentials")}})},[g,T.password,n,re,ae]),Re=r.useCallback(()=>{c&&(z(c.accountId),oe.mutate({body:{email:c.email}},{onSuccess:a=>{ce(),window.location.assign(a.authorizationUrl)},onError:a=>{z(null),V(o=>({...o,[c.accountId]:W(a,"Microsoft sign-in could not be started.")})),I(null),s("credentials")}}))},[c,ce,oe]),Fe=r.useCallback((a,o)=>U({username:a,password:o}),[]),Ae=r.useMemo(()=>{const a=$?.pendingImport?.folderPaths;if(!a)return B;const o=new Set(a),v=B.filter(E=>o.has(E.path)),L=a.filter(E=>!B.some(Me=>Me.path===E)).map(E=>({path:E,waitingFor:"An imported setting"}));return[...v,...L]},[$,B]),M=r.useCallback(()=>{b(void 0),K(void 0),N(void 0),p(void 0),S(void 0),ee("abort"),s("file")},[]);switch(i){case"file":return e.jsx(ot,{state:h?"reading":P.isPending?"checking":d?"dragging":"idle",file:u,ready:j!==void 0,failure:R,onChoose:Ce,onDragStateChange:l,onNext:()=>D("validate",Z)});case"rejected":return e.jsx(xt,{failure:(m&&ue(m))??R??{title:"The file could not be imported",explanation:"The import was refused and nothing was written.",fix:"Re-export the configuration and try again.",raw:"no error was reported"},onBack:M});case"conflict":return e.jsx(ut,{choice:te,held:bt(ye?.details),onChoose:se,onBack:M,onNext:()=>{if(te==="abort"){t("abandoned");return}ee("merge"),D("validate","merge")}});case"review":return e.jsx(lt,{sections:et(m?.items??[]),fileName:u?.name??"the config file",warnings:(m?.warnings??[]).map(a=>a.message),applying:P.isPending,onBack:M,onNext:()=>D("apply",Z)});case"partial":{if(!m)return e.jsx(St,{onBack:M});const a=me(m);return e.jsx(vt,{results:Ze(m),message:a?.message??"The import stopped before it finished.",raw:`${a?.code??Ye}: ${a?.message??"no message"}`,nothingLanded:!m.applied,onBack:M,onNext:()=>D("apply","merge")})}case"credentials":return e.jsx(pt,{accounts:Ne,busyAccountId:G??void 0,error:ke,onOpen:Ie,onNext:()=>s("folders")});case"account-password":return c?e.jsx(Ke,{steps:y,activeStep:2,title:`Sign in to ${c.email}`,subtitle:`Account ${ie} of ${C.length} · ${c.imapHost}:${c.imapPort}`,email:c.email,username:T.username,password:T.password,error:F[c.accountId],continueLabel:"Test and continue",notice:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(Qe,{className:"size-3.5"}),"Server settings came from the config file — edit them in Settings if they are wrong."]}),onContinue:()=>s("account-test"),onBack:()=>{I(null),s("credentials")},onChange:Fe}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-test":return c?e.jsx(_e,{steps:y,activeStep:2,email:c.email,imapConfig:yt(c),smtpConfig:wt(c),username:T.username,password:T.password,credentialsBackLabel:"Back to the password",serversBackLabel:"Back to the password",successLabel:"Save and continue",onSuccess:Te,onBackToCredentials:()=>s("account-password"),onBackToServers:()=>s("account-password")}):e.jsx(X,{onBack:()=>t("abandoned")});case"account-oauth":return c?e.jsx(ft,{account:he(c,F[c.accountId],Q.includes(c.accountId)),position:ie,total:C.length,error:F[c.accountId],busy:G===c.accountId,onBack:()=>{I(null),s("credentials")},onNext:Re}):e.jsx(X,{onBack:()=>t("abandoned")});case"folders":return e.jsx(gt,{folders:Ae,onNext:()=>t("imported")})}}function ve({children:t,label:n,onBack:i}){return e.jsxs("div",{className:"mx-auto max-w-lg p-6",children:[e.jsx(x,{tone:"danger",children:t}),e.jsx("button",{type:"button",className:"mt-3 text-sm text-accent underline",onClick:i,children:n})]})}function X({onBack:t}){return e.jsx(ve,{label:"Go to inbox",onBack:t,children:"That account is no longer in this instance's configuration, so there is nothing left to sign in to. Open Settings › Accounts to see what is here."})}function St({onBack:t}){return e.jsx(ve,{label:"Choose another file",onBack:t,children:"The import stopped but produced no report, so nothing here can say what it wrote. Open Settings to see what this instance holds before importing again."})}function At(){const t=qe(),n=pe(),i=r.useCallback(s=>{st({queryClient:n,recordCompleted:()=>{s==="imported"&&t.recordEvent("config.imported")},navigateToInbox:()=>{window.location.assign("/mail")}})},[t,n]);return e.jsx(kt,{onDone:i})}export{At as component};