@remit/web-client-dist 0.0.624 → 0.0.626

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/assets/{BriefPane-BjUmHKNU.js → BriefPane-_14jyTNU.js} +1 -1
  2. package/assets/CalendarComposePane-CvXktapf.js +1 -0
  3. package/assets/{CalendarComposeSeed-CeMPzriy.js → CalendarComposeSeed-CifBLPSk.js} +1 -1
  4. package/assets/{CalendarShell-q8nTThqJ.js → CalendarShell-CQKMfTHS.js} +1 -1
  5. package/assets/{EmptyState-DxHRPzWP.js → EmptyState-DFn4LB7J.js} +1 -1
  6. package/assets/{ErrorState-B7NbYqTc.js → ErrorState-wz9YaOol.js} +1 -1
  7. package/assets/FlaggedPane-CGhj--Hm.js +1 -0
  8. package/assets/{FullCompose-Co7TPnxX.js → FullCompose-ChHG83dJ.js} +1 -1
  9. package/assets/MailListHeader-DfOCZnRx.js +7 -0
  10. package/assets/MailNav-CjfpinUe.js +1 -0
  11. package/assets/{MailShell-CBAHJ7P0.js → MailShell-C1jECwgj.js} +1 -1
  12. package/assets/{MailViewChrome-SWxm38ad.js → MailViewChrome-XZUEJlo5.js} +1 -1
  13. package/assets/{MailboxPane-S4RjLCSn.js → MailboxPane-Czwm70WW.js} +1 -1
  14. package/assets/{NavMenuButton-CRz4o42Z.js → NavMenuButton-DeFLPsFB.js} +1 -1
  15. package/assets/{OnboardingWizard-eRXMySJ0.js → OnboardingWizard-B-CFGg5s.js} +1 -1
  16. package/assets/OpenCalendarEvent-DFERZRRh.js +2 -0
  17. package/assets/{OutboxPane-CXpqcg1M.js → OutboxPane-HIJT_kwS.js} +1 -1
  18. package/assets/_calendarObjectId-CHrSuJ4j.js +1 -0
  19. package/assets/_mailboxId-Cx59NB_O.js +1 -0
  20. package/assets/_messageId-428jqG1g.js +1 -0
  21. package/assets/_messageId-BqS3jo2k.js +1 -0
  22. package/assets/_messageId-DLcoHrvg.js +1 -0
  23. package/assets/_outboxMessageId-DgbOcdNZ.js +1 -0
  24. package/assets/_recurrenceId-BNEK4esm.js +1 -0
  25. package/assets/_threadId-BpGxTAyH.js +1 -0
  26. package/assets/_threadId-DBQCQCIO.js +1 -0
  27. package/assets/_threadId-Li52F0Cd.js +1 -0
  28. package/assets/{_view._date-hlYMd7kn.js → _view._date-CvSVriaI.js} +1 -1
  29. package/assets/accounts-UiS1FK2e.js +1 -0
  30. package/assets/{advanced-CWj1vJ3f.js → advanced-LKQZxDeW.js} +2 -2
  31. package/assets/{appearance-DXdbCOhL.js → appearance-Csl0uD9E.js} +1 -1
  32. package/assets/{attendee-row-Dgh-0GlX.js → attendee-row-BhqXy1fZ.js} +1 -1
  33. package/assets/{avatar-BuiXyp5p.js → avatar-Dq9zVRVl.js} +1 -1
  34. package/assets/{bell-off-PwhHcUK1.js → bell-off-zJIQc-fQ.js} +1 -1
  35. package/assets/{bottom-sheet-BuyceQDS.js → bottom-sheet-CqUVoKvb.js} +1 -1
  36. package/assets/brief-CuAyGW-_.js +1 -0
  37. package/assets/{brief-itwy9KeE.js → brief-i89ZY7Gu.js} +1 -1
  38. package/assets/{browser-ponyfill-XC3MKgZo.js → browser-ponyfill-32LE6w6g.js} +2 -2
  39. package/assets/{bug-CFbZ4o5k.js → bug-BX9QtfhB.js} +1 -1
  40. package/assets/calendar-DLPNVzNq.js +1 -0
  41. package/assets/{calendar-clash-strip-ChVtknHT.js → calendar-clash-strip-Bid2cYhz.js} +1 -1
  42. package/assets/calendar-format-M4S5xU7P.js +1 -0
  43. package/assets/calendar-suggestion-Dz1CYPKE.js +1 -0
  44. package/assets/{calendars-CI4Tye4t.js → calendars-D_kCUTOt.js} +1 -1
  45. package/assets/{card-Dfe50axc.js → card-DgdelB3M.js} +1 -1
  46. package/assets/chevron-left-Dd68kT1Y.js +1 -0
  47. package/assets/{circle-check-DMqAgBOj.js → circle-check-B0R88gmM.js} +1 -1
  48. package/assets/{circle-check-big-CYIqB7G_.js → circle-check-big-DrhQmTbc.js} +1 -1
  49. package/assets/{circle-help-Bn5rsX9v.js → circle-help-Bh3n-6_h.js} +1 -1
  50. package/assets/{clock-zhYrOi0n.js → clock-ByuYhL7c.js} +1 -1
  51. package/assets/compose._-_outboxMessageId_-CJP6aGKp.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-CMXTsNxj.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-DIUaW_Wi.js +1 -0
  54. package/assets/compose._-_outboxMessageId_-ZpGAMi--.js +1 -0
  55. package/assets/{config-import-PZAIf0rl.js → config-import-Bugb2aMh.js} +1 -1
  56. package/assets/{confirm-dialog-BBNecW64.js → confirm-dialog-D0wfxRPd.js} +1 -1
  57. package/assets/{copy-DYN1Qqcn.js → copy-baeOC0XH.js} +1 -1
  58. package/assets/{credential-steps-BvLk_5Sd.js → credential-steps-DOdW-2H8.js} +1 -1
  59. package/assets/{download-DSk-iXt6.js → download-C79uP4C7.js} +1 -1
  60. package/assets/{file-json-CnG7YYof.js → file-json-CGQXrNbO.js} +1 -1
  61. package/assets/{filters-pA2rkirY.js → filters-CAsK70Nx.js} +1 -1
  62. package/assets/flagged-CEg9zmAF.js +1 -0
  63. package/assets/{flagged-0DaGnTzF.js → flagged-uALUxb-O.js} +1 -1
  64. package/assets/folder-failure-CqkVSsrb.js +1 -0
  65. package/assets/folders-Bx3SMw7d.js +1 -0
  66. package/assets/{help-copy-DUM-3tGw.js → help-copy-C9SzNfoi.js} +1 -1
  67. package/assets/{import-iEpa-yKD.js → import-BwX6jaiD.js} +1 -1
  68. package/assets/index-B_wiLLnW.js +1 -0
  69. package/assets/index-BulHQ3Bz.js +1 -0
  70. package/assets/index-Bz3z8-Ud.js +1 -0
  71. package/assets/{index-N25dfLEk.js → index-CLg2znEx.js} +1 -1
  72. package/assets/index-Caogy7TQ.js +1 -0
  73. package/assets/index-Cfb74LIY.js +1 -0
  74. package/assets/index-CvxW8FM1.js +1 -0
  75. package/assets/index-Cy75NEgh.js +1 -0
  76. package/assets/index-D4ZeuNuq.js +55 -0
  77. package/assets/index-DLcoHrvg.js +1 -0
  78. package/assets/index-DmMeuJEG.js +1 -0
  79. package/assets/{index-Cvg1ICmg.js → index-UydO8d8c.js} +69 -69
  80. package/assets/{kbd-CqsQh3Yv.js → kbd-Dr4usi4j.js} +1 -1
  81. package/assets/{labels-d9EnCfKK.js → labels-D22q095l.js} +1 -1
  82. package/assets/mail-CWdYkVJO.js +1 -0
  83. package/assets/{mail-i5djtULt.js → mail-Db9OjHYL.js} +1 -1
  84. package/assets/{map-pin-BNehUfT9.js → map-pin-HJKJCWdt.js} +1 -1
  85. package/assets/{menu-CzfZlboy.js → menu-CbYnJN5U.js} +1 -1
  86. package/assets/new-kq63OZ83.js +1 -0
  87. package/assets/onboarding-DXy2aNhI.js +1 -0
  88. package/assets/{onboarding-completion-LMYPue3i.js → onboarding-completion-BlaYncdL.js} +1 -1
  89. package/assets/outbox-CT3Ok2c-.js +1 -0
  90. package/assets/{pencil-Cbc_bTFZ.js → pencil-u2t1F29A.js} +1 -1
  91. package/assets/{popover-menu-BOPw-RvI.js → popover-menu--AoVAv-y.js} +1 -1
  92. package/assets/{refresh-cw-gehoG8pf.js → refresh-cw-Qp6f0dRu.js} +1 -1
  93. package/assets/{rich-text-DYTexR3K.js → rich-text-D3RBxInX.js} +2 -2
  94. package/assets/{rich-text-spellcheck-worker-provider-Be6BN4oD.js → rich-text-spellcheck-worker-provider-9h-DIyCe.js} +1 -1
  95. package/assets/{rotate-ccw-BUQyyEmS.js → rotate-ccw-SdroQT7m.js} +1 -1
  96. package/assets/{roving-focus-DwDXHttZ.js → roving-focus-BNBmBfAx.js} +1 -1
  97. package/assets/{row-actions-CzWFmX-0.js → row-actions-IPR7z5tr.js} +1 -1
  98. package/assets/{search-mirror-CG0SD5Nw.js → search-mirror-Cv2S0VbB.js} +1 -1
  99. package/assets/{search-token-index-CMfLsCex.js → search-token-index-AOAqpH15.js} +1 -1
  100. package/assets/{sections-DZNHkQyT.js → sections-EqJpt3TQ.js} +1 -1
  101. package/assets/{senders-zOwXF1CW.js → senders-DnFn3aNI.js} +1 -1
  102. package/assets/settings-CNMUput2.js +1 -0
  103. package/assets/{settings-screen-BVNyrrqp.js → settings-screen-WQb7kG5A.js} +1 -1
  104. package/assets/{shield-check-gQitY-yx.js → shield-check-D7EcTf9d.js} +1 -1
  105. package/assets/{suggested-vips-DrD2TuQ1.js → suggested-vips-QYhd7mHg.js} +1 -1
  106. package/assets/undo-2-CveuEJjH.js +1 -0
  107. package/assets/useCalendarData-CMPLRued.js +1 -0
  108. package/assets/{useCalendarWrites--n8KbD7U.js → useCalendarWrites-BASehFYp.js} +1 -1
  109. package/assets/useCalendars-DR1_eTjS.js +1 -0
  110. package/assets/{useDebouncedValue-abnXV_Ax.js → useDebouncedValue-Dt6rAAol.js} +1 -1
  111. package/assets/{useFilters-e6-LOuFX.js → useFilters-Bbcl4di_.js} +1 -1
  112. package/assets/{useLabels-Dm-tUvjJ.js → useLabels-DQs2z0T7.js} +1 -1
  113. package/assets/{useLayoutTier-id3G6JgO.js → useLayoutTier-CF_kWPgV.js} +1 -1
  114. package/assets/{useMessageBodyContent-DK0INN0c.js → useMessageBodyContent-DiiU1g37.js} +1 -1
  115. package/assets/{useQueries-B8LmhXDj.js → useQueries-CJUjXxvq.js} +1 -1
  116. package/assets/{useRefreshControl-BY1Z-PWr.js → useRefreshControl-BUZDaiTn.js} +1 -1
  117. package/assets/{useResultFolderIndex-D442PBpq.js → useResultFolderIndex-D9ADFT-m.js} +1 -1
  118. package/assets/{useSearchTokenContext-8rnAiWTU.js → useSearchTokenContext-CBDSw3gJ.js} +3 -3
  119. package/assets/{useSemanticSearch-CCCY9PAD.js → useSemanticSearch-B7rQKIm8.js} +1 -1
  120. package/assets/{useSignature-BPTjqaqF.js → useSignature-DruMb0cI.js} +1 -1
  121. package/index.html +1 -1
  122. package/package.json +1 -1
  123. package/assets/CalendarComposePane-CQquoIIA.js +0 -1
  124. package/assets/FlaggedPane-C0O-H48H.js +0 -1
  125. package/assets/MailListHeader-C_n4dLUO.js +0 -7
  126. package/assets/MailNav-DsFM4Zbb.js +0 -1
  127. package/assets/OpenCalendarEvent-BgYFqkWO.js +0 -2
  128. package/assets/_calendarObjectId-CAZamn7y.js +0 -1
  129. package/assets/_mailboxId-BmIDt2GW.js +0 -1
  130. package/assets/_messageId-CigPBylW.js +0 -1
  131. package/assets/_messageId-R9ftzZBW.js +0 -1
  132. package/assets/_messageId-Xz7zDM4l.js +0 -1
  133. package/assets/_outboxMessageId-DxrO7cYW.js +0 -1
  134. package/assets/_recurrenceId-C1Ir6dGL.js +0 -1
  135. package/assets/_threadId-CIO_w6bi.js +0 -1
  136. package/assets/_threadId-CjQQJEhB.js +0 -1
  137. package/assets/_threadId-luQhGDWk.js +0 -1
  138. package/assets/accounts-BHBATOBL.js +0 -1
  139. package/assets/attachment-file-rUVfXWEQ.js +0 -1
  140. package/assets/brief-Dl4eEpFB.js +0 -1
  141. package/assets/calendar-Dabme7v4.js +0 -1
  142. package/assets/calendar-format-_D2qlvSu.js +0 -1
  143. package/assets/calendar-suggestion-DoL5BXEv.js +0 -1
  144. package/assets/chevron-left-Cp_sl0gi.js +0 -1
  145. package/assets/compose._-_outboxMessageId_-C7e7F6Id.js +0 -1
  146. package/assets/compose._-_outboxMessageId_-DMdCmVMA.js +0 -1
  147. package/assets/compose._-_outboxMessageId_-O4p9O2gf.js +0 -1
  148. package/assets/compose._-_outboxMessageId_-VcBR_Wg2.js +0 -1
  149. package/assets/flagged-CffT7Fd9.js +0 -1
  150. package/assets/folders-BZ2ei1sV.js +0 -1
  151. package/assets/index-BvAEy50E.js +0 -1
  152. package/assets/index-Bw48MPd4.js +0 -1
  153. package/assets/index-C280EmcF.js +0 -1
  154. package/assets/index-CeB8dMXm.js +0 -1
  155. package/assets/index-CigPBylW.js +0 -1
  156. package/assets/index-ClrSu-J7.js +0 -1
  157. package/assets/index-DDZEuXNA.js +0 -1
  158. package/assets/index-DK4QmBvZ.js +0 -1
  159. package/assets/index-sAVS5SaO.js +0 -1
  160. package/assets/index-yhiT7pf4.js +0 -55
  161. package/assets/mail-DvBCqkl1.js +0 -1
  162. package/assets/new-w9LeiqvV.js +0 -1
  163. package/assets/onboarding-CGyR6f-U.js +0 -1
  164. package/assets/outbox-B7-uw0-A.js +0 -1
  165. package/assets/settings-BJ3vobZ5.js +0 -1
  166. package/assets/useCalendarData-DXephWeP.js +0 -1
  167. package/assets/useCalendars-BiHQwoqg.js +0 -1
@@ -0,0 +1 @@
1
+ import{e as V,t as f,j as s,ar as Z,r as p,W as ee,X as te,dn as se,f as R,aQ as ne,ah as ae,b_ as k,eu as re,s as W,c as U,ev as ie,h as oe,i as A,ew as le,ex as ce,ey as de,ez as ue,aH as me,aI as fe}from"./index-UydO8d8c.js";import{c as xe,R as pe,z as he,A as ge,B as G,C as ye,x as F,E as I,F as be,e as _,G as L,y as ve}from"./calendar-format-M4S5xU7P.js";import{M}from"./mail-Db9OjHYL.js";import{G as q}from"./map-pin-HJKJCWdt.js";import{u as Ne}from"./useQueries-CJUjXxvq.js";import{f as je}from"./ErrorState-wz9YaOol.js";import{b as y,e as H}from"./useCalendars-DR1_eTjS.js";const Ce=V("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function Se(e){const t=xe(e.color),n=e.rsvp==="tentative"||e.status==="tentative";return f("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",t.soft,t.text,t.rail,e.layout==="column"||e.stacked?"flex-col":"items-center gap-1.5",n&&"border-y border-r border-dashed",n&&t.border,e.rsvp==="declined"&&"opacity-60",e.selected&&"ring-2 ring-ring",e.density==="compact"?"text-2xs":"text-xs")}function ke({title:e,timeText:t,layout:n,rsvp:a,hasThread:i,isRecurring:l,zoneCertainty:c,trailing:r,detail:u}){const o=n==="column",d=c==="ambiguous",m=!o&&u!==void 0,x=s.jsxs("span",{className:f("flex min-w-0 items-center gap-1",o&&"w-full",a==="declined"&&"line-through"),children:[t!==""&&s.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:t}),s.jsx("span",{className:"truncate font-medium",children:e})]}),g=(l||i||d)&&s.jsxs("span",{className:f("flex shrink-0 items-center gap-1",o&&"mt-0.5",!o&&r===void 0&&"ml-auto"),children:[l&&s.jsx(pe,{className:"size-2.5","aria-label":"Repeats"}),i&&s.jsx(M,{className:"size-2.5","aria-label":"From mail"}),d&&s.jsx(q,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),b=r!==void 0&&s.jsx("span",{className:f("shrink-0 opacity-80",!o&&"ml-auto"),children:r});return s.jsxs(s.Fragment,{children:[m?s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[x,g,b]}):s.jsxs(s.Fragment,{children:[x,g,b]}),u]})}function et({title:e,timeText:t,color:n,layout:a,density:i,rsvp:l,status:c,hasThread:r,isRecurring:u,zoneCertainty:o,selected:d,onClick:m,leading:x,trailing:g,detail:b}){const j=a==="column";return s.jsxs("button",{type:"button",onClick:m,"aria-pressed":d,className:f("group flex w-full min-w-0 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface",j?"h-full":"items-start",x!==void 0&&"gap-2"),children:[x,s.jsx("span",{className:f(Se({color:n,layout:a,density:i,rsvp:l,status:c,selected:d,stacked:b!==void 0}),"flex-1",j&&"h-full"),children:s.jsx(ke,{title:e,timeText:t,layout:a,rsvp:l,hasThread:r,isRecurring:u,zoneCertainty:o,trailing:g,detail:b})})]})}function tt({text:e,reportHref:t,className:n}){return s.jsxs("div",{role:"alert",className:f("flex items-start gap-1.5 rounded-md border border-danger/40 bg-danger-soft p-2 text-xs text-danger",n),children:[s.jsx(Z,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":!0}),s.jsxs("p",{className:"min-w-0 flex-1",children:[e,t&&s.jsxs(s.Fragment,{children:[" ",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]})]})]})}const P=96;function st({children:e,hasCard:t,onConfirm:n,onReject:a,blocked:i,blockedReason:l,remaining:c,confirmLabel:r="Add",emptyText:u="Nothing in your mail is waiting on a decision about time.",className:o}){const[d,m]=p.useState(0),[x,g]=p.useState(null);if(!t)return s.jsxs("div",{className:f("flex flex-col items-center gap-2 p-6 text-center",o),children:[s.jsx(ee,{className:"size-6 text-fg-subtle","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:u})]});const b=Math.abs(d)>P,j=d>0;return s.jsxs("div",{className:f("flex flex-col gap-3",o),children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${d}px) rotate(${d/40}deg)`,transition:x===null?"transform 180ms ease-out":"none"},onPointerDown:v=>{v.currentTarget.setPointerCapture(v.pointerId),g(v.clientX)},onPointerMove:v=>{x!==null&&m(v.clientX-x)},onPointerUp:()=>{Math.abs(d)>P&&(d>0&&!i&&n(),d<0&&a()),g(null),m(0)},onPointerCancel:()=>{g(null),m(0)},children:e}),b&&s.jsx("span",{className:f("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold",j?"right-3 bg-accent-soft text-accent":"left-3 bg-danger-soft text-danger"),children:j?i?l:r:"Not this"})]}),s.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[c," left · swipe right to accept, left to drop, or use the buttons"]})]})}const Ee="Pick a clock first. The mail never said, and the reader will not choose for you.";function we(e,t){const n=e.zoneOptions;return n===void 0?{settled:!0,timeZone:""}:n.some(a=>a.timeZone===t)?{settled:!0,timeZone:t}:{settled:!1,reason:Ee}}function B(e){return e.threadSubject===""?e.sender:`${e.sender} — ${e.threadSubject}`}function De(e){return e>=.85?"Read cleanly":e>=.6?"Read with gaps":"Barely read"}function nt({suggestion:e,whenText:t,onAdd:n,onReview:a,onDismiss:i,onOpenThread:l,busy:c=!1,addBlocked:r=!1,zoneChoice:u,onZoneChoice:o,addLabel:d="Add",touch:m,className:x}){const[g,b]=p.useState(""),[j,v]=p.useState(!1),w=p.useId(),D=u??g,J=h=>{v(!1),o?o(h):b(h)},N=we(e,D),T=h=>()=>{if(!N.settled){v(!0);return}h(N.timeZone)};return s.jsxs("article",{"aria-label":e.title,className:f("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",x),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",De(e.confidence)]}),s.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:e.title}),s.jsx("span",{className:"block text-xs text-fg-muted",children:t}),e.location!==""&&s.jsx("span",{className:"block truncate text-xs text-fg-muted",children:e.location})]}),s.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:i,disabled:c,className:f("flex shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",m?"size-11":"size-7"),children:s.jsx(te,{className:"size-4"})})]}),e.ambiguity!==""&&s.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[s.jsx(Z,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),e.ambiguity]}),l?s.jsxs("button",{type:"button",onClick:l,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm text-left text-2xs text-accent-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:[s.jsx(M,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:B(e)})]}):s.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[s.jsx(M,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:B(e)})]}),e.zoneOptions&&s.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[s.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[s.jsx(q,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),e.zoneOptions.map(h=>s.jsxs("button",{type:"button","aria-pressed":D===h.timeZone,onClick:()=>J(h.timeZone),className:f("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",m&&"min-h-11",D===h.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[s.jsx("span",{className:"block text-xs font-medium text-fg",children:h.label}),s.jsx("span",{className:"block text-2xs text-fg-subtle",children:h.note})]},h.timeZone))]}),!N.settled&&s.jsx(se,{id:w,reason:N.reason,nudged:j,className:"text-2xs text-warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(R,{variant:"primary",size:m?"md":"sm",icon:s.jsx(ne,{className:"size-3.5"}),onClick:T(n),disabled:c||r,"aria-describedby":N.settled?void 0:w,className:f(m&&"min-h-11 flex-1",!N.settled&&"opacity-55"),children:d}),a&&s.jsx(R,{variant:"secondary",size:m?"md":"sm",icon:s.jsx(Ce,{className:"size-3.5"}),onClick:T(a),disabled:c,"aria-describedby":N.settled?void 0:w,className:f(m&&"min-h-11",!N.settled&&"opacity-55"),children:"Change first"})]})]})}function at(e){return e.defaultCalendarId!==""?"ready":e.error!==null?"failed":e.isLoading?"loading":"none"}function rt(e,t){if(e!=="ready")return e==="loading"?"Reading your calendars…":e==="failed"?s.jsxs(s.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):s.jsxs(s.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",s.jsx(ae,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Ae=24,Q=7,Ie=52,E=Ie*7,ze=e=>({from:y(e,-10),to:y(e,Ae),floor:y(e,-E),ceiling:y(e,E)}),Oe=e=>e.from<=e.floor,Me=e=>e.to>=e.ceiling,Te=(e,t)=>e>t?e:t,Re=(e,t)=>e<t?e:t,Fe=e=>Oe(e)?e:{...e,from:Te(y(e.from,-Q),e.floor)},_e=e=>Me(e)?e:{...e,to:Re(y(e.to,Q),e.ceiling)},it=e=>Fe({...e,floor:y(e.from,-E)}),ot=e=>_e({...e,ceiling:y(e.to,E)});function lt(e,t){return t>=e.from&&t<=e.to?e:ze(t)}function ct(e){const t=new Map;for(const n of e){const a=H("week",n);t.has(a.from)||t.set(a.from,a)}return[...t.values()]}const dt=e=>H("week",e).from,Le=1440,$=e=>e.getHours()*60+e.getMinutes();function K(e,t){const n=new Set(e),a=new Map;for(const i of t){const l=new Date(i.start),c=new Date(i.end);if(Number.isNaN(l.getTime())||Number.isNaN(c.getTime())||c.getTime()<=l.getTime())continue;const r=k(l),u=k(new Date(c.getTime()-1));for(let o=r;o<=u;o=y(o,1)){if(!n.has(o))continue;const d=o===r?$(l):0,m=k(c)===o?$(c):Le;if(m<=d)continue;const x=a.get(o);x?x.push({from:d,to:m}):a.set(o,[{from:d,to:m}])}}for(const[i,l]of a)a.set(i,he(l));return a}function ut(e,t){const n=K(e,t);return new Map(e.map(a=>[a,G(a,n.get(a)??[])]))}const mt=e=>ge(e.from,e.to),Pe=W(400,404);function ft(e){const t=Ne({queries:e.map(r=>({...re({query:{from:r.from,to:r.to}}),meta:Pe,staleTime:ye}))}),n=e.map(r=>r.from).join("|"),a=t.map(r=>r.data),i=t.map(r=>r.isPending).join("|"),l=p.useMemo(()=>a.flatMap(r=>r?.items??[]),[n,i]),c=p.useMemo(()=>{const r=new Set;return e.forEach((u,o)=>{t[o]?.isPending&&r.add(u.from)}),r},[n,i]);return{spans:l,pendingWindows:c,error:t.find(r=>r.error)?.error??null,refetch:()=>{for(const r of t)r.error&&r.refetch()}}}const C=W(400,404),Be=new Set(["calendarSuggestionOperationsListCalendarSuggestions","messageCalendarSuggestionOperationsListMessageCalendarSuggestions","calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy","filterOperationsListFilters"]),$e=e=>e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const a=n._id;return typeof a=="string"&&Be.has(a)}});function xt(e){const{data:t,isLoading:n,error:a}=U({...ie({path:{messageId:e}}),meta:C});return{suggestions:t?.items??[],isLoading:n,error:a??null}}function pt(){const{data:e,isLoading:t,error:n}=U({...ue({query:{state:"Pending"}}),meta:C});return{suggestions:e?.items??[],isLoading:t,error:n??null}}const z={kind:"answered"},O=e=>({kind:"refused",message:je(e)});function ht(){const e=oe(),t=p.useCallback(()=>$e(e),[e]),n=A({...le(),meta:C,onSuccess:t}),a=A({...ce(),meta:C,onSuccess:t}),i=A({...de(),meta:C,onSuccess:t}),l=p.useCallback((u,o)=>n.mutateAsync({path:{suggestionId:u},body:{calendarId:o}}).then(()=>z).catch(O),[n]),c=p.useCallback(u=>a.mutateAsync({path:{suggestionId:u}}).then(()=>z).catch(O),[a]),r=p.useCallback((u,o)=>i.mutateAsync({path:{suggestionId:u},body:{muteSender:o}}).then(()=>z).catch(O),[i]);return p.useMemo(()=>({accept:l,decline:c,dismiss:r,isAnswering:n.isPending||a.isPending||i.isPending}),[l,c,r,n.isPending,a.isPending,i.isPending])}function gt(e){return me(fe({title:`Calendar invitation: ${e}`,errorMessage:e}))}const S=30,Ze=6,X={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},We="The invitation named a time zone nothing could resolve, so this time may be hours out.";function yt(e){if(e.state!=="Dismissed")return e.method==="Cancel"?e.state==="Pending"?{state:"cancelled",rsvp:"noReply"}:void 0:e.state==="Superseded"?{state:"superseded",rsvp:"noReply"}:e.state==="Accepted"?{state:"answered",rsvp:"accepted"}:e.state==="Declined"?{state:"answered",rsvp:"declined"}:e.state==="Tentative"?{state:"answered",rsvp:"tentative"}:{state:"pending",rsvp:"noReply"}}const Ue=e=>e.source!=="TextHeuristic";function bt(e){return e.allDay?e.dtStart.slice(0,10):k(new Date(e.dtStart))}const Y=e=>e.summary===""?"Untitled event":e.summary;function vt(e){if(e.allDay){const t=e.dtStart.slice(0,10),n=e.dtEnd.slice(0,10),a=n>t?y(n,-1):t;return a===t?`${I(t)}, all day`:`${I(t)} – ${I(a)}, all day`}return be({start:e.dtStart,end:e.dtEnd,allDay:e.allDay})}function Ge(e,t){return{id:e.suggestionId,calendarId:t.calendarId,title:Y(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,notes:"",attendees:[],myRsvp:"noReply",threadId:t.threadId,threadSubject:t.threadSubject,timeZone:"",zoneCertainty:X[e.zoneCertainty],recurrenceRule:"",seriesId:"",seriesException:!1,status:"confirmed"}}function Nt(e,t,n){const a=e.organizer===""?n.senderName:e.organizer;return{id:e.suggestionId,threadId:n.threadId,proposed:Ge(e,n),organizerName:a===""?"The sender":a,organizerEmail:e.organizer,method:"ics",evidence:"",state:t,sequence:e.sequence}}function jt(e,t){return{id:e.suggestionId,title:Y(e),start:e.dtStart,end:e.dtEnd,allDay:e.allDay,location:e.location,threadId:t.threadId,threadSubject:t.threadSubject,sender:t.sender,senderAddress:e.organizer,confidence:Ue(e)?1:.6,ambiguity:e.zoneCertainty==="Ambiguous"?We:"",suggestedCalendarId:t.calendarId,timeZone:"",zoneCertainty:X[e.zoneCertainty]}}const qe=(e,t)=>Date.parse(t.start)<Date.parse(e.end)&&Date.parse(t.end)>Date.parse(e.start);function Ct(e,t){return t.filter(n=>qe(e,n)).map(n=>({id:`${n.start}/${n.end}`,label:`Busy ${F(n.start)} – ${F(n.end)}`}))}function St(e,t){const n=K([e],t).get(e)??[],a=[];for(const i of G(e,n,S))for(let l=i.startMinute;l+S<=i.endMinute&&a.length<Ze;l+=S)a.push({date:e,endDate:e,startTime:_(l),endTime:_(l+S),allDay:!1});return a}function kt(e,t,n){const a=t.filter(i=>n.includes(i.startTime)).map(i=>`${L(i.startTime)} – ${L(i.endTime)}`);return`${ve(e)}: ${a.join(", ")}`}export{Ue as A,yt as B,et as C,bt as D,nt as E,Ct as F,Nt as G,St as H,kt as I,Ee as Z,ke as a,lt as b,Se as c,mt as d,dt as e,ut as f,Fe as g,_e as h,ot as i,Me as j,Oe as k,it as l,tt as m,st as n,pt as o,ht as p,vt as q,ze as r,we as s,jt as t,ft as u,gt as v,ct as w,rt as x,at as y,xt as z};
@@ -1 +1 @@
1
- import{e as z,h as D,r,b9 as Q,i as j,ba as V,bb as W,bc as Z,s as E,j as e,ay as K,az as A,B as N,f as b,aM as B,a3 as I,g as X,bd as F,aB as q,be as J,c as Y,bf as ee,bg as M,bh as se,bi as ae,bj as te,u as ne,aL as re,aN as ie}from"./index-Cvg1ICmg.js";import{S as de}from"./settings-screen-BVNyrrqp.js";import{C as O,a as R,b as P,c as L}from"./card-Dfe50axc.js";import{U as y,u as oe}from"./useCalendars-BiHQwoqg.js";import{C as $}from"./confirm-dialog-BBNecW64.js";import{f as _,E as ce}from"./ErrorState-B7NbYqTc.js";import{R as le}from"./refresh-cw-gehoG8pf.js";import{C as me}from"./copy-DYN1Qqcn.js";import{u as ue}from"./useCalendarWrites--n8KbD7U.js";import"./avatar-BuiXyp5p.js";import"./chevron-left-Cp_sl0gi.js";import"./menu-CzfZlboy.js";import"./circle-help-Bn5rsX9v.js";const he=z("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"}]]);const pe=z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),k=E(400,404),S={kind:"written"},w=s=>({kind:"refused",message:_(s)});function H(){const s=D(),t=ue(),n=r.useCallback(()=>s.invalidateQueries({queryKey:Q()}),[s]),a=r.useCallback(()=>(t(),n()),[t,n]),o=j({...V(),meta:k,onSuccess:n}),d=j({...W(),meta:k,onSuccess:a}),l=j({...Z(),meta:k,onSuccess:a}),h=r.useCallback(i=>o.mutateAsync({body:i}).then(()=>S).catch(w),[o]),m=r.useCallback((i,u)=>d.mutateAsync({path:{calendarId:i},body:u}).then(()=>S).catch(w),[d]),c=r.useCallback(i=>l.mutateAsync({path:{calendarId:i}}).then(()=>S).catch(w),[l]);return r.useMemo(()=>({createCalendar:h,updateCalendar:m,deleteCalendar:c,isWriting:o.isPending||d.isPending||l.isPending}),[h,m,c,o.isPending,d.isPending,l.isPending])}const T=Intl.supportedValuesOf("timeZone");function U({id:s,value:t,disabled:n,onChange:a}){const o=t===y||T.includes(t)?T:[t,...T];return e.jsxs(K,{id:s,value:t,disabled:n,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:y,children:"None (read as UTC)"}),o.map(d=>e.jsx("option",{value:d,children:d},d))]})}const xe=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),fe=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);function ge({isBusy:s,problem:t,onCreate:n}){const[a,o]=r.useState(""),[d,l]=r.useState(void 0),[h,m]=r.useState(y),c=r.useId(),i=r.useId(),u=r.useId(),f=r.useId(),g=d??fe(a),x=a.trim()!==""&&g.trim()!=="";return e.jsxs(O,{className:"max-w-xl",role:"region","aria-labelledby":c,children:[e.jsx(R,{children:e.jsx(P,{id:c,children:"New calendar"})}),e.jsx(L,{children:e.jsxs("form",{className:"space-y-3",onSubmit:p=>{p.preventDefault(),x&&n({displayName:a.trim(),urlSegment:g.trim(),timezone:h}).then(v=>{v&&(o(""),l(void 0),m(y))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(A,{id:i,value:a,maxLength:140,disabled:s,onChange:p=>o(p.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(A,{id:u,value:g,maxLength:64,disabled:s,onChange:p=>l(p.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(U,{id:f,value:h,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),t!==""&&e.jsxs(N,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:t})]}),e.jsx(b,{type:"submit",variant:"primary",size:"sm",disabled:s||!x,icon:e.jsx(B,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function be({calendarName:s,timezone:t,isBusy:n,problem:a,onSave:o,onDelete:d}){const[l,h]=r.useState(s),[m,c]=r.useState(t),[i,u]=r.useState(!1),f=r.useId(),g=r.useId(),x=l.trim(),p=x!==s||m!==t,v=xe(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!p||x==="")&&o({displayName:x,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(A,{id:f,value:l,maxLength:140,disabled:n,onChange:C=>h(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:g,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(U,{id:g,value:m,disabled:n,onChange:c})]})]}),a!==""&&e.jsxs(N,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"submit",variant:"secondary",size:"sm",disabled:n||!p||x==="",icon:e.jsx(pe,{className:"size-3.5"}),children:"Save changes"}),e.jsx(b,{type:"button",variant:"danger",size:"sm",disabled:n,icon:e.jsx(I,{className:"size-3.5"}),onClick:()=>u(!0),children:"Delete calendar"})]})]}),e.jsx($,{isOpen:i,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{u(!1),d()},onCancel:()=>u(!1)})]})}const ve=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."}),Ce=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 je({calendarName:s,url:t,onDismiss:n}){const[a,o]=r.useState(!1),[d,l]=r.useState(!1),h=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(h.current),[]);const m=()=>{navigator.clipboard.writeText(t).then(()=>{l(!1),o(!0),h.current=window.setTimeout(()=>o(!1),2e3)}).catch(()=>l(!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:t,"aria-label":`Subscription address for ${s}`,onFocus:c=>c.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(b,{variant:"primary",size:"sm",icon:a?e.jsx(q,{className:"size-3.5"}):e.jsx(me,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(N,{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(b,{variant:"ghost",size:"sm",onClick:n,children:"I've saved it"})]})}function ye({createdAt:s,rotatedAt:t,isBusy:n,onRotate:a,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(X,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",F(s,"medium"),t>0?`, last replaced ${F(t,"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(b,{variant:"secondary",size:"sm",disabled:n,icon:e.jsx(le,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(b,{variant:"danger",size:"sm",disabled:n,icon:e.jsx(I,{className:"size-3.5"}),onClick:o,children:"Stop sharing"})]})]})}function Ne({calendarName:s,details:t,state:n,mintedUrl:a,isBusy:o,actionError:d,onMint:l,onRevoke:h,onDismissMinted:m,onRetry:c}){const[i,u]=r.useState("none"),f=r.useId(),g=()=>{const p=i;u("none"),p==="rotate"&&l(),p==="revoke"&&h()},x=i==="revoke"?Ce(s):ve(s);return e.jsxs(O,{className:"max-w-xl",role:"region","aria-labelledby":f,children:[e.jsx(R,{children:e.jsx(P,{id:f,children:s})}),e.jsxs(L,{children:[t&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:t}),n.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),n.status==="unreadable"&&a===""&&e.jsx(ce,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:n.error,onRetry:c}),n.status==="absent"&&a===""&&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(b,{variant:"primary",size:"sm",disabled:o,icon:e.jsx(he,{className:"size-3.5"}),onClick:l,children:o?"Creating…":"Create subscription address"})]}),n.status==="active"&&e.jsx(ye,{createdAt:n.createdAt,rotatedAt:n.rotatedAt,isBusy:o,onRotate:()=>u("rotate"),onRevoke:()=>u("revoke")}),d!=null&&e.jsxs(N,{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:_(d)})]}),a!==""&&e.jsx(je,{calendarName:s,url:a,onDismiss:m})]}),e.jsx($,{isOpen:i!=="none",title:x.title,description:x.description,confirmLabel:i==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:g,onCancel:()=>u("none")})]})}const ke="/feeds/calendar/",Se=".ics",we=(s,t)=>`webcal://${s}${ke}${t}${Se}`;function Te(s){const t=D(),[n,a]=r.useState(""),o=J({path:{calendarId:s}}),d=Y({...ee({path:{calendarId:s}}),meta:E(404,403),retry:!1}),l=()=>{t.invalidateQueries({queryKey:o})},h=r.useRef(()=>{}),m=j({...se(),meta:M,onMutate:()=>{h.current()},onSuccess:()=>{a(""),l()}}),c=j({...ae(),meta:M,gcTime:0,onMutate:()=>{m.reset()},onSuccess:G=>{a(we(window.location.host,G.feedToken)),l()}});h.current=c.reset;const{mutate:i,reset:u}=c,{mutate:f}=m,g=r.useCallback(()=>{i({path:{calendarId:s}})},[s,i]),x=r.useCallback(()=>{f({path:{calendarId:s}})},[s,f]),p=r.useCallback(()=>{a(""),u()},[u]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ae(d),mintedUrl:n,isBusy:c.isPending||m.isPending,actionError:c.error??m.error,mint:g,revoke:x,dismissMinted:p,retry:C}}function Ae(s){return s.error?te(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 Fe({calendarId:s,calendarName:t,details:n}){const a=Te(s);return e.jsx(Ne,{calendarName:t,details:n,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function Me({calendarId:s,calendarName:t,timezone:n}){const{updateCalendar:a,deleteCalendar:o,isWriting:d}=H(),[l,h]=r.useState(""),m=c=>h(c.kind==="refused"?c.message:"");return e.jsx(Fe,{calendarId:s,calendarName:t,details:e.jsx(be,{calendarName:t,timezone:n,isBusy:d,problem:l,onSave:c=>{h(""),a(s,c).then(m)},onDelete:()=>{h(""),o(s).then(m)}},`${t}\0${n}`)})}const ze=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),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 Ve(){const s=ne(),[t,n]=r.useState(!0),{calendars:a,timeZoneByCalendarId:o,isLoading:d}=oe(),{createCalendar:l,isWriting:h}=H(),[m,c]=r.useState("");return e.jsx(de,{items:re,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, and share one with any client that can subscribe to a URL.",help:ze,helpOpen:t,onToggleHelp:()=>n(i=>!i),onSelect:i=>{const u=ie[i];u&&s({to:u})},onBackToMail:()=>{s({to:"/mail"})},children:d?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(i=>e.jsx(Me,{calendarId:i.id,calendarName:i.name,timezone:o[i.id]??""},i.id)),e.jsx(ge,{isBusy:h,problem:m,onCreate:i=>(c(""),l(i).then(u=>u.kind==="written"?!0:(c(u.message),!1)))})]})})}export{Ve as component};
1
+ import{e as D,h as M,r,bb as Q,i as j,bc as V,bd as W,be as Z,s as E,j as e,ay as K,az as A,B as N,f as b,aQ as B,a3 as I,g as X,bf as F,aB as J,bg as q,c as Y,bh as ee,aJ as z,bi as se,bj as ae,bk as te,u as ne,aP as re,aR as ie}from"./index-UydO8d8c.js";import{S as de}from"./settings-screen-WQb7kG5A.js";import{C as R,a as O,b as P,c as L}from"./card-DgdelB3M.js";import{U as y,u as oe}from"./useCalendars-DR1_eTjS.js";import{C as $}from"./confirm-dialog-D0wfxRPd.js";import{f as _,E as ce}from"./ErrorState-wz9YaOol.js";import{R as le}from"./refresh-cw-Qp6f0dRu.js";import{C as me}from"./copy-baeOC0XH.js";import{u as ue}from"./useCalendarWrites-BASehFYp.js";import"./avatar-Dq9zVRVl.js";import"./chevron-left-Dd68kT1Y.js";import"./menu-CbYnJN5U.js";import"./circle-help-Bh3n-6_h.js";const he=D("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"}]]);const pe=D("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),k=E(400,404),S={kind:"written"},w=s=>({kind:"refused",message:_(s)});function H(){const s=M(),t=ue(),n=r.useCallback(()=>s.invalidateQueries({queryKey:Q()}),[s]),a=r.useCallback(()=>(t(),n()),[t,n]),o=j({...V(),meta:k,onSuccess:n}),d=j({...W(),meta:k,onSuccess:a}),l=j({...Z(),meta:k,onSuccess:a}),h=r.useCallback(i=>o.mutateAsync({body:i}).then(()=>S).catch(w),[o]),m=r.useCallback((i,u)=>d.mutateAsync({path:{calendarId:i},body:u}).then(()=>S).catch(w),[d]),c=r.useCallback(i=>l.mutateAsync({path:{calendarId:i}}).then(()=>S).catch(w),[l]);return r.useMemo(()=>({createCalendar:h,updateCalendar:m,deleteCalendar:c,isWriting:o.isPending||d.isPending||l.isPending}),[h,m,c,o.isPending,d.isPending,l.isPending])}const T=Intl.supportedValuesOf("timeZone");function U({id:s,value:t,disabled:n,onChange:a}){const o=t===y||T.includes(t)?T:[t,...T];return e.jsxs(K,{id:s,value:t,disabled:n,onChange:d=>a(d.target.value),children:[e.jsx("option",{value:y,children:"None (read as UTC)"}),o.map(d=>e.jsx("option",{value:d,children:d},d))]})}const xe=s=>({title:`Delete ${s}?`,description:`This removes ${s} and every event in it, and any subscription address stops working. It cannot be undone.`}),fe=s=>s.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);function ge({isBusy:s,problem:t,onCreate:n}){const[a,o]=r.useState(""),[d,l]=r.useState(void 0),[h,m]=r.useState(y),c=r.useId(),i=r.useId(),u=r.useId(),f=r.useId(),g=d??fe(a),x=a.trim()!==""&&g.trim()!=="";return e.jsxs(R,{className:"max-w-xl",role:"region","aria-labelledby":c,children:[e.jsx(O,{children:e.jsx(P,{id:c,children:"New calendar"})}),e.jsx(L,{children:e.jsxs("form",{className:"space-y-3",onSubmit:p=>{p.preventDefault(),x&&n({displayName:a.trim(),urlSegment:g.trim(),timezone:h}).then(v=>{v&&(o(""),l(void 0),m(y))})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:i,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(A,{id:i,value:a,maxLength:140,disabled:s,onChange:p=>o(p.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-medium text-fg-muted",children:"Address"}),e.jsx(A,{id:u,value:g,maxLength:64,disabled:s,onChange:p=>l(p.target.value)})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(U,{id:f,value:h,disabled:s,onChange:m})]})]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"The address names the calendar for CalDAV clients and cannot be changed later. The name and zone can."}),t!==""&&e.jsxs(N,{tone:"danger",variant:"soft",children:[e.jsx("p",{className:"font-medium",children:"The calendar was not added."}),e.jsx("p",{className:"mt-0.5 break-words",children:t})]}),e.jsx(b,{type:"submit",variant:"primary",size:"sm",disabled:s||!x,icon:e.jsx(B,{className:"size-3.5"}),children:s?"Adding…":"Add calendar"})]})})]})}function be({calendarName:s,timezone:t,isBusy:n,problem:a,onSave:o,onDelete:d}){const[l,h]=r.useState(s),[m,c]=r.useState(t),[i,u]=r.useState(!1),f=r.useId(),g=r.useId(),x=l.trim(),p=x!==s||m!==t,v=xe(s);return e.jsxs(e.Fragment,{children:[e.jsxs("form",{className:"space-y-3",onSubmit:C=>{C.preventDefault(),!(!p||x==="")&&o({displayName:x,timezone:m})},children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:f,className:"text-xs font-medium text-fg-muted",children:"Name"}),e.jsx(A,{id:f,value:l,maxLength:140,disabled:n,onChange:C=>h(C.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:g,className:"text-xs font-medium text-fg-muted",children:"Time zone"}),e.jsx(U,{id:g,value:m,disabled:n,onChange:c})]})]}),a!==""&&e.jsxs(N,{tone:"danger",variant:"soft",children:[e.jsxs("p",{className:"font-medium",children:[s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:a})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"submit",variant:"secondary",size:"sm",disabled:n||!p||x==="",icon:e.jsx(pe,{className:"size-3.5"}),children:"Save changes"}),e.jsx(b,{type:"button",variant:"danger",size:"sm",disabled:n,icon:e.jsx(I,{className:"size-3.5"}),onClick:()=>u(!0),children:"Delete calendar"})]})]}),e.jsx($,{isOpen:i,title:v.title,description:v.description,confirmLabel:"Delete calendar",destructive:!0,onConfirm:()=>{u(!1),d()},onCancel:()=>u(!1)})]})}const ve=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."}),Ce=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 je({calendarName:s,url:t,onDismiss:n}){const[a,o]=r.useState(!1),[d,l]=r.useState(!1),h=r.useRef(0);r.useEffect(()=>()=>window.clearTimeout(h.current),[]);const m=()=>{navigator.clipboard.writeText(t).then(()=>{l(!1),o(!0),h.current=window.setTimeout(()=>o(!1),2e3)}).catch(()=>l(!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:t,"aria-label":`Subscription address for ${s}`,onFocus:c=>c.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(b,{variant:"primary",size:"sm",icon:a?e.jsx(J,{className:"size-3.5"}):e.jsx(me,{className:"size-3.5"}),onClick:m,children:a?"Copied":"Copy address"})]}),d&&e.jsx(N,{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(b,{variant:"ghost",size:"sm",onClick:n,children:"I've saved it"})]})}function ye({createdAt:s,rotatedAt:t,isBusy:n,onRotate:a,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(X,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",F(s,"medium"),t>0?`, last replaced ${F(t,"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(b,{variant:"secondary",size:"sm",disabled:n,icon:e.jsx(le,{className:"size-3.5"}),onClick:a,children:"Replace address"}),e.jsx(b,{variant:"danger",size:"sm",disabled:n,icon:e.jsx(I,{className:"size-3.5"}),onClick:o,children:"Stop sharing"})]})]})}function Ne({calendarName:s,details:t,state:n,mintedUrl:a,isBusy:o,actionError:d,onMint:l,onRevoke:h,onDismissMinted:m,onRetry:c}){const[i,u]=r.useState("none"),f=r.useId(),g=()=>{const p=i;u("none"),p==="rotate"&&l(),p==="revoke"&&h()},x=i==="revoke"?Ce(s):ve(s);return e.jsxs(R,{className:"max-w-xl",role:"region","aria-labelledby":f,children:[e.jsx(O,{children:e.jsx(P,{id:f,children:s})}),e.jsxs(L,{children:[t&&e.jsx("div",{className:"mb-4 border-b border-line pb-4",children:t}),n.status==="loading"&&a===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),n.status==="unreadable"&&a===""&&e.jsx(ce,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:n.error,onRetry:c}),n.status==="absent"&&a===""&&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(b,{variant:"primary",size:"sm",disabled:o,icon:e.jsx(he,{className:"size-3.5"}),onClick:l,children:o?"Creating…":"Create subscription address"})]}),n.status==="active"&&e.jsx(ye,{createdAt:n.createdAt,rotatedAt:n.rotatedAt,isBusy:o,onRotate:()=>u("rotate"),onRevoke:()=>u("revoke")}),d!=null&&e.jsxs(N,{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:_(d)})]}),a!==""&&e.jsx(je,{calendarName:s,url:a,onDismiss:m})]}),e.jsx($,{isOpen:i!=="none",title:x.title,description:x.description,confirmLabel:i==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:g,onCancel:()=>u("none")})]})}const ke="/feeds/calendar/",Se=".ics",we=(s,t)=>`webcal://${s}${ke}${t}${Se}`;function Te(s){const t=M(),[n,a]=r.useState(""),o=q({path:{calendarId:s}}),d=Y({...ee({path:{calendarId:s}}),meta:E(404,403),retry:!1}),l=()=>{t.invalidateQueries({queryKey:o})},h=r.useRef(()=>{}),m=j({...se(),meta:z,onMutate:()=>{h.current()},onSuccess:()=>{a(""),l()}}),c=j({...ae(),meta:z,gcTime:0,onMutate:()=>{m.reset()},onSuccess:G=>{a(we(window.location.host,G.feedToken)),l()}});h.current=c.reset;const{mutate:i,reset:u}=c,{mutate:f}=m,g=r.useCallback(()=>{i({path:{calendarId:s}})},[s,i]),x=r.useCallback(()=>{f({path:{calendarId:s}})},[s,f]),p=r.useCallback(()=>{a(""),u()},[u]),{refetch:v}=d,C=r.useCallback(()=>{v()},[v]);return{state:Ae(d),mintedUrl:n,isBusy:c.isPending||m.isPending,actionError:c.error??m.error,mint:g,revoke:x,dismissMinted:p,retry:C}}function Ae(s){return s.error?te(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 Fe({calendarId:s,calendarName:t,details:n}){const a=Te(s);return e.jsx(Ne,{calendarName:t,details:n,state:a.state,mintedUrl:a.mintedUrl,isBusy:a.isBusy,actionError:a.actionError,onMint:a.mint,onRevoke:a.revoke,onDismissMinted:a.dismissMinted,onRetry:a.retry})}function ze({calendarId:s,calendarName:t,timezone:n}){const{updateCalendar:a,deleteCalendar:o,isWriting:d}=H(),[l,h]=r.useState(""),m=c=>h(c.kind==="refused"?c.message:"");return e.jsx(Fe,{calendarId:s,calendarName:t,details:e.jsx(be,{calendarName:t,timezone:n,isBusy:d,problem:l,onSave:c=>{h(""),a(s,c).then(m)},onDelete:()=>{h(""),o(s).then(m)}},`${t}\0${n}`)})}const De=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each calendar has a name, a time zone its floating times are read in, and an address CalDAV clients reach it by. The address is fixed when the calendar is added; the name and zone can change. Deleting a calendar deletes every event in it. The default calendar is where accepted invitations land, so it cannot be deleted."}),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 Ve(){const s=ne(),[t,n]=r.useState(!0),{calendars:a,timeZoneByCalendarId:o,isLoading:d}=oe(),{createCalendar:l,isWriting:h}=H(),[m,c]=r.useState("");return e.jsx(de,{items:re,activeId:"calendars",title:"Calendars",description:"Add, rename and delete calendars, and share one with any client that can subscribe to a URL.",help:De,helpOpen:t,onToggleHelp:()=>n(i=>!i),onSelect:i=>{const u=ie[i];u&&s({to:u})},onBackToMail:()=>{s({to:"/mail"})},children:d?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):e.jsxs("div",{className:"space-y-4",children:[a.map(i=>e.jsx(ze,{calendarId:i.id,calendarName:i.name,timezone:o[i.id]??""},i.id)),e.jsx(ge,{isBusy:h,problem:m,onCreate:i=>(c(""),l(i).then(u=>u.kind==="written"?!0:(c(u.message),!1)))})]})})}export{Ve as component};
@@ -1 +1 @@
1
- import{j as r,t}from"./index-Cvg1ICmg.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-UydO8d8c.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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-ChHG83dJ.js";import"./index-UydO8d8c.js";import"./ErrorState-wz9YaOol.js";import"./index-D4ZeuNuq.js";import"./useMessageBodyContent-DiiU1g37.js";import"./useSignature-DruMb0cI.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Dt6rAAol.js";import"./sections-EqJpt3TQ.js";import"./confirm-dialog-D0wfxRPd.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-ChHG83dJ.js";import"./index-UydO8d8c.js";import"./ErrorState-wz9YaOol.js";import"./index-D4ZeuNuq.js";import"./useMessageBodyContent-DiiU1g37.js";import"./useSignature-DruMb0cI.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Dt6rAAol.js";import"./sections-EqJpt3TQ.js";import"./confirm-dialog-D0wfxRPd.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-ChHG83dJ.js";import"./index-UydO8d8c.js";import"./ErrorState-wz9YaOol.js";import"./index-D4ZeuNuq.js";import"./useMessageBodyContent-DiiU1g37.js";import"./useSignature-DruMb0cI.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Dt6rAAol.js";import"./sections-EqJpt3TQ.js";import"./confirm-dialog-D0wfxRPd.js";const c=o;export{c as component};
@@ -0,0 +1 @@
1
+ import{F as o}from"./FullCompose-ChHG83dJ.js";import"./index-UydO8d8c.js";import"./ErrorState-wz9YaOol.js";import"./index-D4ZeuNuq.js";import"./useMessageBodyContent-DiiU1g37.js";import"./useSignature-DruMb0cI.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Dt6rAAol.js";import"./sections-EqJpt3TQ.js";import"./confirm-dialog-D0wfxRPd.js";const c=o;export{c as component};
@@ -1 +1 @@
1
- import{b3 as v,b4 as T}from"./index-Cvg1ICmg.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{b5 as v,b6 as T}from"./index-UydO8d8c.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,G as x,H as f,j as e,J as b,t as a}from"./index-Cvg1ICmg.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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,ay as F,aB as _,t as E,r as n,g as B,aQ as R,az as C,i as G,aw as Q,B as X,aA as J,f as N}from"./index-Cvg1ICmg.js";import{C as K}from"./card-Dfe50axc.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(K,{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:y}){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:y}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:y})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,disabled:o,value:a,onValueChange:m}):t.jsx(M,{id:h,disabled:o,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=y=>{y.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 U(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(),y=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!y||!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:y,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=U(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=U(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 gt(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 yt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:y="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),g=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!g){k("Enter your username and password.");return}k(null),v()},[g,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:y}),t.jsx(N,{variant:"primary",onClick:L,children:x})]}),children:t.jsxs("div",{className:"space-y-3",children:[m&&t.jsx(X,{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(J,{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:y="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({...Q()});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 $=O=>{const A=O?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},V=!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":V?"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:g}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(g==="auth-failure"?m():g==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,m,x]);const L=g==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:y}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="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"})]}):g==="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}),(g==="auth-failure"||g==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[g==="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{ot as A,q as C,ht as R,ut as S,H as W,pt as a,xt as b,vt as c,yt as d,dt as e,gt as f,ct as g,ft as h,D as s,et as u};
1
+ import{e as W,j as t,ay as F,aB as _,t as E,r as n,g as B,aU as R,az as C,i as G,aw as X,B as J,aA as K,f as N}from"./index-UydO8d8c.js";import{C as Q}from"./card-DgdelB3M.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:y}){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:y}):t.jsx(C,{id:b,readOnly:o,defaultValue:e,placeholder:y})]}),t.jsxs("div",{children:[t.jsx(R,{htmlFor:h,children:"Security"}),m?t.jsx(M,{id:h,disabled:o,value:a,onValueChange:m}):t.jsx(M,{id:h,disabled:o,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=y=>{y.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 U(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(),y=c.querySelector("hostname")?.textContent?.trim(),v=c.querySelector("port")?.textContent?.trim(),b=c.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!l||!m||!y||!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:y,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=U(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=U(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 gt(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 yt({steps:r,activeStep:i,title:s,subtitle:e,email:a,username:o,password:c,notice:l,error:m,continueLabel:x="Test connection",backLabel:y="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),g=p.trim()!==""&&S.trim()!=="";n.useEffect(()=>{h(p,S)},[p,S,h]);const L=n.useCallback(()=>{if(!g){k("Enter your username and password.");return}k(null),v()},[g,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:y}),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:y="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 $=O=>{const A=O?.toLowerCase()??"";return A.includes("auth")||A.includes("login")||A.includes("535")||A.includes("credential")},V=!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":V?"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:g}=h;n.useEffect(()=>{const u=j=>{j.key==="Escape"&&(g==="auth-failure"?m():g==="network-failure"&&x())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[g,m,x]);const L=g==="auth-failure"?t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"ghost",onClick:m,children:y}),t.jsx(N,{variant:"primary",onClick:()=>S(u=>u+1),children:"Retry"})]}):g==="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"})]}):g==="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}),(g==="auth-failure"||g==="network-failure")&&h.rawError&&t.jsxs("div",{className:"py-3",children:[g==="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{ot as A,q as C,ht as R,ut as S,H as W,pt as a,xt as b,vt as c,yt as d,dt as e,gt as f,ct as g,ft as h,D as s,et as u};
@@ -1 +1 @@
1
- import{e}from"./index-Cvg1ICmg.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-UydO8d8c.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-Cvg1ICmg.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-UydO8d8c.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,bk as ee,bl as te,r as x,bm as se,j as t,bn as ae,bo as ie,L as R,f as N,bp as ne,aI as re,g as oe,bq as le,br as ce,a3 as de,c as P,K as me,bs as ue,ae as pe,af as xe,bt as fe,bu as he,u as ge,d as be,aL as ve,aN as ye}from"./index-Cvg1ICmg.js";import{S as je}from"./settings-screen-BVNyrrqp.js";import{B as Ne}from"./bottom-sheet-BuyceQDS.js";import{u as Ce,a as Se}from"./useLabels-Dm-tUvjJ.js";import{b as Fe,N as S,p as Ie,u as Me,r as we,a as Ee,S as A,c as Oe,n as De,f as Le,d as Ae,e as ke,g as Te}from"./useFilters-e6-LOuFX.js";import{C as L}from"./circle-check-DMqAgBOj.js";import{E as $}from"./ErrorState-B7NbYqTc.js";import"./avatar-BuiXyp5p.js";import"./chevron-left-Cp_sl0gi.js";import"./menu-CzfZlboy.js";import"./circle-help-Bn5rsX9v.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=Ie(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),I=x.useRef(0),{count:C}=Me(e,we(n)),j=Re(e,s.filterId),b=Ee(e),{createFolderIn:F}=se(e),{createLabel:E}=Ce(e),M=async o=>{const a=await E(o);return{id:a.labelId,name:a.name,color:a.color}},p=()=>u({mode:"add",draft:{field:A[0],value:""}}),w=o=>{const a=n.clauses.find(y=>y.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(y=>m.mode==="edit"&&m.clauseId?{...y,clauses:y.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(I.current+=1,{...y,clauses:[...y.clauses,{id:`new-${I.current}`,field:o,value:a}]})),u(void 0))},B=o=>l(a=>({...a,clauses:a.clauses.filter(y=>y.id!==o)})),Q=o=>l(a=>({...a,matchOperator:o})),q=o=>l(a=>({...a,moveMailboxId:o||void 0})),G=o=>l(a=>({...a,labelId:o||void 0})),H=o=>l(a=>({...a,name:o})),J=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),j.updateFilter(a)},Y=()=>b.start(Oe(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(Qe,{progress:b.progress,isDone:b.isDone,onClose:d}):j.isPending?t.jsx(Ke,{}):j.isError?t.jsx(qe,{onRetry:j.reset,onClose:d}):j.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:A,anchorLocked:!0,clauseEdit:m,onStartAddClause:p,onStartEditClause:w,onRemoveClause:B,onChangeDraftField:O,onChangeDraftValue:K,onSubmitClause:U,onCancelClause:()=>u(void 0),onChangeMatchOperator:Q,onChangeMove:q,onCreateFolder:F,onChangeLabel:G,onCreateLabel:M,onChangeName:H,onChangeScope:J,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(L,{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(L,{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 Qe({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(L,{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 He({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=Le(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=Ae(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 Je=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]),I=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]),j=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]),M=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}),M&&t.jsx(Ge,{accountId:s,filter:M,folders:C,delimiter:j,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(He,{filters:r,mailboxName:I,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=ye[l];m&&e({to:m})};return t.jsx(je,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Je,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};
1
+ import{h as X,i as Z,bl as ee,bm as te,r as x,bn as se,j as t,bo as ae,bp as ie,L as R,f as N,bq as ne,aM as re,g as oe,br as le,bs as ce,a3 as de,c as P,K as me,bt as ue,ae as pe,af as xe,bu as fe,bv as he,u as ge,d as be,aP as ve,aR as ye}from"./index-UydO8d8c.js";import{S as je}from"./settings-screen-WQb7kG5A.js";import{B as Ne}from"./bottom-sheet-CqUVoKvb.js";import{u as Ce,a as Se}from"./useLabels-DQs2z0T7.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-Bbcl4di_.js";import{C as A}from"./circle-check-B0R88gmM.js";import{E as $}from"./ErrorState-wz9YaOol.js";import"./avatar-Dq9zVRVl.js";import"./chevron-left-Dd68kT1Y.js";import"./menu-CbYnJN5U.js";import"./circle-help-Bh3n-6_h.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)),j=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(y=>y.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(y=>m.mode==="edit"&&m.clauseId?{...y,clauses:y.clauses.map(D=>D.id===m.clauseId?{id:D.id,field:o,value:a}:D)}:(M.current+=1,{...y,clauses:[...y.clauses,{id:`new-${M.current}`,field:o,value:a}]})),u(void 0))},B=o=>l(a=>({...a,clauses:a.clauses.filter(y=>y.id!==o)})),Q=o=>l(a=>({...a,matchOperator:o})),q=o=>l(a=>({...a,moveMailboxId:o||void 0})),G=o=>l(a=>({...a,labelId:o||void 0})),H=o=>l(a=>({...a,name:o})),J=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),j.updateFilter(a)},Y=()=>b.start(Oe(n));return b.isStarting||b.isRunning||b.isDone?t.jsx(Qe,{progress:b.progress,isDone:b.isDone,onClose:d}):j.isPending?t.jsx(Ke,{}):j.isError?t.jsx(qe,{onRetry:j.reset,onClose:d}):j.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:Q,onChangeMove:q,onCreateFolder:F,onChangeLabel:G,onCreateLabel:I,onChangeName:H,onChangeScope:J,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 Qe({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 He({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 Je=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 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]),j=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:j,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(He,{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=ye[l];m&&e({to:m})};return t.jsx(je,{items:ve,activeId:"filters",title:"Filters",description:"Standing and temporary rules created by Organize, per account.",help:Je,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-UydO8d8c.js";import{a as m}from"./MailShell-C1jECwgj.js";import{F as r}from"./FlaggedPane-CGhj--Hm.js";import{a as p}from"./search-token-index-AOAqpH15.js";import{u as e}from"./search-mirror-Cv2S0VbB.js";import"./FullCompose-ChHG83dJ.js";import"./ErrorState-wz9YaOol.js";import"./index-D4ZeuNuq.js";import"./useMessageBodyContent-DiiU1g37.js";import"./useSignature-DruMb0cI.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue-Dt6rAAol.js";import"./sections-EqJpt3TQ.js";import"./confirm-dialog-D0wfxRPd.js";import"./useSearchTokenContext-CBDSw3gJ.js";import"./kbd-Dr4usi4j.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-DfOCZnRx.js";import"./roving-focus-BNBmBfAx.js";import"./popover-menu--AoVAv-y.js";import"./mail-Db9OjHYL.js";import"./avatar-Dq9zVRVl.js";import"./EmptyState-DFn4LB7J.js";import"./undo-2-CveuEJjH.js";import"./download-C79uP4C7.js";import"./calendar-suggestion-Dz1CYPKE.js";import"./calendar-format-M4S5xU7P.js";import"./useQueries-CJUjXxvq.js";import"./useCalendars-DR1_eTjS.js";import"./map-pin-HJKJCWdt.js";import"./attendee-row-BhqXy1fZ.js";import"./clock-ByuYhL7c.js";import"./calendar-clash-strip-Bid2cYhz.js";import"./bell-off-zJIQc-fQ.js";import"./copy-baeOC0XH.js";import"./shield-check-D7EcTf9d.js";import"./useFilters-Bbcl4di_.js";import"./useLayoutTier-CF_kWPgV.js";import"./menu-CbYnJN5U.js";import"./MailViewChrome-XZUEJlo5.js";import"./refresh-cw-Qp6f0dRu.js";import"./wizard-selection-DxUM65kM.js";function X(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{X as component};
@@ -1 +1 @@
1
- import{j as r}from"./index-Cvg1ICmg.js";import{E as o}from"./ErrorState-B7NbYqTc.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-UydO8d8c.js";import{E as o}from"./ErrorState-wz9YaOol.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
+ const t=e=>{if(e.syncStatus!=="failed")return;const r=e.syncFailureReason.trim();return r.length===0?"The last change to this folder failed.":`The mail server refused the last change: ${r}`};export{t as f};
@@ -0,0 +1 @@
1
+ import{j as e,f as j,a3 as B,bw as W,r as c,aM as X,X as Y,aU as he,az as J,a2 as xe,aX as H,bx as fe,ay as pe,aB as ge,B as z,aW as be,by as ve,h as Z,Q as ee,o as se,bz as ye,bA as je,aT as Ne,P as ke,bB as Ce,bC as _,bD as we,bE as Se,bF as te,bG as Me,bH as Q,bn as ae,bt as re,bu as Ie,af as K,ae as ne,L as G,bI as q,bJ as Ee,ar as De,bK as Ae,u as Oe,c as ie,d as Te,aP as Re,aR as Fe,K as Pe,i as V,s as $e,bL as Le,bM as ze,bN as _e,a$ as Be,bO as Ke,bP as Ge}from"./index-UydO8d8c.js";import{P as He}from"./pencil-u2t1F29A.js";import{S as Qe}from"./settings-screen-WQb7kG5A.js";import{E as oe}from"./ErrorState-wz9YaOol.js";import{f as qe}from"./folder-failure-CqkVSsrb.js";import"./avatar-Dq9zVRVl.js";import"./chevron-left-Dd68kT1Y.js";import"./menu-CbYnJN5U.js";import"./circle-help-Bh3n-6_h.js";const Ve=({label:s,onRename:t,onDelete:a,deleteBlockedReason:l,renameLabel:u=m=>`Rename ${m}`,deleteLabel:r=m=>`Delete ${m}`})=>{const m=l?`${r(s)} — ${l}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(He,{className:"size-3.5"}),"aria-label":u(s),onClick:t}),e.jsx("span",{title:l,children:e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),"aria-label":m,disabled:l!==void 0,onClick:a})})]})},Ue=({folders:s,onRename:t,onDelete:a,onCreateFolder:l,delimiter:u,labels:r})=>{const m=new Map(s.map(o=>[o.id,o]));return e.jsx(W,{folders:s,onCreateFolder:l,delimiter:u,labels:{treeAriaLabel:"Your folders",optionLabel:o=>o.label,...r},rowFailure:o=>m.get(o.id)?.failure,rowActions:o=>{const i=m.get(o.id);return i?e.jsx(Ve,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},We=({open:s,folderLabel:t,defaultLabel:a,name:l,onNameChange:u,onSubmit:r,onClose:m,pending:o=!1,error:i})=>{const d=c.useId(),p=`Rename ${t}`;return s?e.jsxs(X,{open:s,onClose:m,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Y,{className:"size-3.5"}),onClick:m,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(J,{id:d,value:l,placeholder:a,onChange:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:m,children:"Cancel"}),e.jsx(j,{variant:"primary",size:"sm",onClick:r,disabled:o,children:o?"Saving…":"Save name"})]})]}):null},Xe=["inbox","drafts","sent","archive","junk","trash"],U="",Ye={mailboxId:null,source:"None"};function Je(s){const t=s.messageCount===1?"msg":"msgs";return`${H(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Ze=(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 es({role:s,folders:t,appointment:a,displayName:l,onAppoint:u,onRename:r}){const[m,o]=c.useState(l),i=c.useRef(null),d=c.useRef(!1),p=c.useId(),{mailboxId:g,source:v,staleFolderPath:y}=a,h=t.find(N=>N.mailboxId===g)??null,f=be(s),O=h!=null&&m.trim()!==l.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const I=(()=>{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:`${Ze(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${H(h.providerPath,h.hierarchyDelimiter)} instead.`:"",A=`The folder you chose for ${f}${y?` — ${y} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:h?.mailboxId??U,"aria-label":`Folder for ${f}`,"aria-describedby":I||v==="Stale"?p:void 0,onChange:N=>u(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:Je(N)},N.mailboxId))]}),v==="Proposed"&&h&&e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,u(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"flex-1",value:m,placeholder:f,"aria-label":`Display name for ${f}`,onChange:N=>o(N.target.value)}),O&&e.jsx(j,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,m)})]})]}),I,v==="Stale"&&e.jsx(z,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:p,className:"flex-1",children:A}),e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function ss(){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 ts({accountEmail:s,folders:t,appointments:a,displayNames:l={},onAppoint:u,onRename:r}){const m=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),o=t.filter(i=>!m.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Xe.map(i=>{const d=a[i]??Ye;return e.jsx(es,{role:i,folders:t,appointment:d,displayName:d.mailboxId?l[d.mailboxId]??"":"",onAppoint:u,onRename:r},i)})}),o.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:o.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:H(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const as=12e4,rs=2e3,ns="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(l=>l.mailboxId===t);if(!a)throw new Error(ns);return a},is=(s,t)=>ce(s,t).lastSyncedAt??0;async function os({readMailboxes:s,mailboxId:t,since:a,signal:l,segmentMs:u=as,pollIntervalMs:r=rs,delay:m=ve,now:o=Date.now}){const i=o()+u;for(;;){l?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(o()>=i)return{status:"pending"};await m(r,l)}}const de=50,ls=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:ls(t)})),cs=async(s,t,a,l)=>{const u=[];let r;for(let m=0;m<de;m+=1){if(l.aborted)return u;const{data:o}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of o.items)if(!i.isDeleted&&!t.has(i.messageId)&&!u.includes(i.messageId)&&(u.push(i.messageId),u.length>=a))return u;if(!o.continuationToken)break;r=o.continuationToken}return u},ds=async(s,t)=>{let a=0,l;for(let u=0;u<de;u+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:l},throwOnError:!0});for(const m of r.items)m.isDeleted||(a+=1);if(!r.continuationToken)break;l=r.continuationToken}return a};function ms({accountId:s,mailboxId:t,onDeleted:a}){const l=Z(),[u,r]=c.useState("idle"),[m,o]=c.useState(null),[i,d]=c.useState(),[p,g]=c.useState(),v=c.useRef(null),y=c.useRef(void 0),h=c.useCallback(()=>{l.invalidateQueries({queryKey:ee({path:{accountId:s}})}),l.invalidateQueries({queryKey:se()})},[l,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(ye({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),I=c.useCallback(()=>l.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[l,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const M=y.current!==void 0,C=await $((async()=>(M||(S.throwIfAborted(),y.current=is(await I(),t),S.throwIfAborted(),g(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),os({readMailboxes:I,mailboxId:t,since:y.current??0,signal:S})))());return S.aborted?(r("idle"),y.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(y.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(y.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,I,f,h]),A=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:M}=S;r("moving"),d(void 0);const C=await $(O());if(M.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);o(x);const E=new Set;for(;;){if(M.aborted)return;const n=await $(cs(t,E,Me,M));if(M.aborted)return;if(!n.ok){x=_(x,n.error),o(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(M.aborted)return;if(!T.ok){x=_(x,T.error),o(x),d(T.error),r("error");return}for(const P of b)E.add(P);x=Se(x,b.length),o(x)}const D=await $(ds(t,M));if(!M.aborted){if(!D.ok){x=_(x,D.error),o(x),d(D.error),r("error");return}if(D.value>0){const n=`${D.value} ${D.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),o(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,y.current=void 0,r("idle"),o(null),d(void 0),g(void 0)},[]);return{phase:u,progress:m,errorMessage:i,checkStartedAt:p,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:N,cancel:A,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function us({open:s,accountId:t,folder:a,mailboxes:l,appointments:u,onClose:r}){const[m,o]=c.useState(()=>Q(a.messageCount)),[i,d]=c.useState(),[p,g]=c.useState(),{createFolderIn:v}=ae(t),y=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:I,deleteMailbox:w,deleteIfEmpty:A,moveThenDelete:N,cancel:R,reset:k}=ms({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,M]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||I===void 0)return;const F=()=>M(Ae(Date.now()-I));F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[C,I]),c.useEffect(()=>{s&&(o(Q(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 A();F.status==="blocked"&&(d(F.messageCount),o("choose-fate"))},[A]),D=c.useMemo(()=>Ie({mailboxes:l,folderAppointments:u,excludeMailboxId:a.mailboxId,translator:y}),[l,u,a.mailboxId,y]),n=D.find(F=>F.id===p),b=c.useMemo(()=>K(a,ne(u).get(a.mailboxId),y),[a,u,y]);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(G,{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(G,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(G,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[q(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):m==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):m==="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:()=>o("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:()=>o("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):m==="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(j,{variant:"secondary",size:"sm",onClick:()=>o("choose-fate"),children:"Back"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(B,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",L(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(W,{folders:D,selectedId:p,delimiter:l[0]?.hierarchyDelimiter??"/",onSelect:g,onCreateFolder:v,onCancel:()=>{g(void 0),o("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(j,{variant:"danger",onClick:()=>N(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${L(P)} to ${n.label}`})})})]});return e.jsxs(X,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(De,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Y,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}function hs({account:s}){const t=Z(),a=s.accountId,l=re(),{data:u,isPending:r,isError:m,error:o,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,y]=c.useState(),[h,f]=c.useState(),[O,I]=c.useState(""),w=c.useMemo(()=>u?.items??[],[u]),A=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:K(n,A.get(n.mailboxId),l),path:n.fullPath,deleteBlockedReason:_e(n,w,s.folderAppointments).message,failure:qe(n)})),[w,A,l,s.folderAppointments]),R=(n,b)=>{p.mutate({path:{accountId:a,role:Ge[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(m)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:o,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),M={};for(const n of s.folderAppointments){const b=Be[n.role];b&&(M[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),D=x(v);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:Ke(p.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(ts,{accountEmail:s.email,folders:S,appointments:M,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(Ue,{folders:N,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),I(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>y(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(We,{open:!0,folderLabel:K(E,A.get(E.mailboxId),l),defaultLabel:K({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},A.get(E.mailboxId),l),name:O,onNameChange:I,pending:g.isPending,error:g.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();g.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),D&&e.jsx(us,{open:!0,accountId:a,folder:D,mailboxes:w,appointments:s.folderAppointments,onClose:()=>y(void 0)})]})}function ks(){const s=Oe(),[t,a]=c.useState(!0),{data:l,isPending:u,isError:r,error:m,refetch:o}=ie(Te()),i=d=>{const p=Fe[d];p&&s({to:p})};return e.jsx(Qe,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(ss,{}),helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:u?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:m,onRetry:()=>{o()}}):l.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:l.accounts.map(d=>e.jsx(hs,{account:d},d.accountId))})})}export{ks as component};
@@ -1 +1 @@
1
- import{j as e}from"./index-Cvg1ICmg.js";import{K as s}from"./kbd-CqsQh3Yv.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-UydO8d8c.js";import{K as s}from"./kbd-Dr4usi4j.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};