@remit/web-client-dist 0.0.671 → 0.0.672

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 (176) hide show
  1. package/assets/BriefPane-B6R3KmQZ.js +1 -0
  2. package/assets/CalendarComposePane-QYpMNL9q.js +1 -0
  3. package/assets/{CalendarComposeSeed-sw3-kicN.js → CalendarComposeSeed-C9w7BCjb.js} +1 -1
  4. package/assets/{CalendarShell-DhpD8MqL.js → CalendarShell-DhMfxOKQ.js} +1 -1
  5. package/assets/{EmptyState-BvdGNd01.js → EmptyState-Lplntbv_.js} +1 -1
  6. package/assets/{ErrorState-C-GqtxHT.js → ErrorState-U7sVw9dY.js} +1 -1
  7. package/assets/FlaggedPane-IbpzjKsY.js +1 -0
  8. package/assets/{FullCompose-B7Gvo6hb.js → FullCompose-C97Y0rHa.js} +1 -1
  9. package/assets/LabelApplyTrigger-MvfgBk5z.js +1 -0
  10. package/assets/{MailNav-DLpm1pnY.js → MailNav-DVs9SxH3.js} +1 -1
  11. package/assets/{MailShell-CsFJTXUG.js → MailShell-YyCoPjof.js} +1 -1
  12. package/assets/{MailViewChrome-CjK9Dnpp.js → MailViewChrome-Dh-GY2tA.js} +1 -1
  13. package/assets/MailboxPane-bFOldx9r.js +1 -0
  14. package/assets/{useSearchTokenContext-PpLW_UHw.js → MessageBody-C676rd7J.js} +2 -2
  15. package/assets/MessageToolbar-BxFKpYvj.js +1 -0
  16. package/assets/{NavMenuButton-8KfNqFDk.js → NavMenuButton-CIu2PlpX.js} +1 -1
  17. package/assets/{OnboardingWizard-VEiZ5SiP.js → OnboardingWizard-DMYpSH3N.js} +1 -1
  18. package/assets/{OpenCalendarEvent-lS6fjUiq.js → OpenCalendarEvent-Cqy0hp_A.js} +2 -2
  19. package/assets/OutboxPane-BRXDNKGE.js +1 -0
  20. package/assets/{SignInAgain-DH1Fdj-N.js → SignInAgain-PV_y3RtI.js} +1 -1
  21. package/assets/_calendarObjectId-C554QO4A.js +1 -0
  22. package/assets/_mailboxId-CP2xm7mJ.js +1 -0
  23. package/assets/_messageId-Co-XhbCe.js +1 -0
  24. package/assets/_messageId-Dm-cFvWc.js +1 -0
  25. package/assets/_messageId-qftp2SP8.js +1 -0
  26. package/assets/_outboxMessageId-BxIJdt9e.js +1 -0
  27. package/assets/_recurrenceId-DygnfvYv.js +1 -0
  28. package/assets/_threadId-CPjiITcE.js +1 -0
  29. package/assets/_threadId-D5zlF-gr.js +1 -0
  30. package/assets/_threadId-DftsiPw3.js +1 -0
  31. package/assets/_view._date-Dt8xCWQ_.js +1 -0
  32. package/assets/{accounts-CjiarZXs.js → accounts-D-wXF-E_.js} +1 -1
  33. package/assets/{advanced-SAvf5P8v.js → advanced-BoeTrbqE.js} +1 -1
  34. package/assets/{appearance-CUPwkBCw.js → appearance-DrAyJE0x.js} +1 -1
  35. package/assets/{attendee-row-D_Iu4VYw.js → attendee-row-CfV-VGdv.js} +1 -1
  36. package/assets/{avatar-ByFhyZLr.js → avatar-DPq_EAZk.js} +1 -1
  37. package/assets/{bell-off-C0wHlgOp.js → bell-off-TX9ZjBn9.js} +1 -1
  38. package/assets/{bottom-sheet-DQgPWkXI.js → bottom-sheet-DxTFUy2E.js} +1 -1
  39. package/assets/{brief-UmPkAR4U.js → brief-CpJ2qh9a.js} +1 -1
  40. package/assets/brief-DOAeAabQ.js +1 -0
  41. package/assets/{bug-BckO5YCO.js → bug-DvYTwFLF.js} +1 -1
  42. package/assets/{calendar-Dc-B3sio.js → calendar-7FnOinQ7.js} +1 -1
  43. package/assets/{calendar-clash-strip-DoAFMGom.js → calendar-clash-strip-CZKSYHne.js} +1 -1
  44. package/assets/{calendar-report-C-XuHGk-.js → calendar-report-DdEEmF6Z.js} +1 -1
  45. package/assets/calendar-suggestion-CEyL4gPa.js +1 -0
  46. package/assets/calendars-CYORrHmn.js +1 -0
  47. package/assets/{card-Bk8XYDq2.js → card-o848IbRj.js} +1 -1
  48. package/assets/{checkbox-D0odK_wH.js → checkbox-CjTT5ES0.js} +1 -1
  49. package/assets/chevron-left-BVg2BJhm.js +1 -0
  50. package/assets/{circle-check-big-4GwHrTFa.js → circle-check-big-DbaQY2vy.js} +1 -1
  51. package/assets/{circle-check-BZo2PeBJ.js → circle-check-lnLFo0FD.js} +1 -1
  52. package/assets/{circle-help-QkeLuDiC.js → circle-help-B6vmvmbF.js} +1 -1
  53. package/assets/{clock-DHHTtMvk.js → clock-Cv1IU_So.js} +1 -1
  54. package/assets/compose._-_outboxMessageId_-C-0N5b4O.js +1 -0
  55. package/assets/compose._-_outboxMessageId_-CLmL6rNy.js +1 -0
  56. package/assets/compose._-_outboxMessageId_-CrGQAmBh.js +1 -0
  57. package/assets/compose._-_outboxMessageId_-DsyC1LHn.js +1 -0
  58. package/assets/{config-import-BAGzZhCz.js → config-import-Cn_3moj6.js} +1 -1
  59. package/assets/{confirm-dialog-B9re_jFm.js → confirm-dialog-DcfLr_VV.js} +1 -1
  60. package/assets/{copy-Ctmrzdfp.js → copy-BOxB39My.js} +1 -1
  61. package/assets/{credential-steps-CZFDsRoC.js → credential-steps-BYXdvc6X.js} +1 -1
  62. package/assets/{download-hgu-A5WC.js → download-BIBKQvTj.js} +1 -1
  63. package/assets/{external-link-Dhni3Eg5.js → external-link-8knc6nvP.js} +1 -1
  64. package/assets/{file-json-C-t1pL6m.js → file-json-YOrGpuD8.js} +1 -1
  65. package/assets/{filters-DvW0WvCf.js → filters-Cv1Gmsq9.js} +1 -1
  66. package/assets/flagged-CHQmCz7D.js +1 -0
  67. package/assets/{flagged-VOnkzcbc.js → flagged-CqMpCGJo.js} +1 -1
  68. package/assets/{folders-DtPDNl-l.js → folders-Cja3LAC_.js} +1 -1
  69. package/assets/{help-copy-CdYqiDpm.js → help-copy-S6Ri4ByH.js} +1 -1
  70. package/assets/{import-BtgA3dex.js → import-B2ANVOl-.js} +1 -1
  71. package/assets/index-4EaeJ4jf.js +1 -0
  72. package/assets/{index-CF22K49S.js → index-5tcvhU2B.js} +1 -1
  73. package/assets/index-BdpT1uQw.js +1 -0
  74. package/assets/index-BqqvJwGn.js +1 -0
  75. package/assets/index-C1x7--DZ.js +1 -0
  76. package/assets/index-Co-XhbCe.js +1 -0
  77. package/assets/{index-BVefvGgO.js → index-CwI22pqH.js} +4 -4
  78. package/assets/{index-cubACEd8.js → index-D4MtLdrW.js} +4 -4
  79. package/assets/index-DJzaAYGf.js +1 -0
  80. package/assets/index-jmt1GqpT.js +1 -0
  81. package/assets/index-qTS44Ji9.js +1 -0
  82. package/assets/index-qftp2SP8.js +1 -0
  83. package/assets/{kbd-C6M51ovo.js → kbd-B6fJcnhn.js} +1 -1
  84. package/assets/{labels-QNRXqxQK.js → labels-BTYKFfU4.js} +1 -1
  85. package/assets/{mail-CfslMQ7s.js → mail-B1xchVjt.js} +1 -1
  86. package/assets/{mail-4zzmmiWK.js → mail-f9ZAFfdw.js} +1 -1
  87. package/assets/{map-pin-CO81Zh5s.js → map-pin-35e-1RVT.js} +1 -1
  88. package/assets/{menu-BkQ4G0tI.js → menu-hJvWIs1N.js} +1 -1
  89. package/assets/minus-u23qRtsG.js +1 -0
  90. package/assets/new-DUufBdYM.js +1 -0
  91. package/assets/onboarding-Uk6iFlNr.js +1 -0
  92. package/assets/{onboarding-completion-CgqykfP5.js → onboarding-completion-CbQwAlqk.js} +1 -1
  93. package/assets/outbox-BvVfW0CI.js +1 -0
  94. package/assets/{pencil-DYtxEeVu.js → pencil-DpNZS_31.js} +1 -1
  95. package/assets/{popover-menu-BFWBKaTJ.js → popover-menu-B2lo44EX.js} +1 -1
  96. package/assets/{refresh-cw-CuDrOkmw.js → refresh-cw-CDQ2xZbt.js} +1 -1
  97. package/assets/{rich-text-spellcheck-worker-provider-BTpAV_xA.js → rich-text-spellcheck-worker-provider-Cw0xnZKP.js} +1 -1
  98. package/assets/{rich-text-DyZjqA4b.js → rich-text-vG9mdl0O.js} +1 -1
  99. package/assets/{rotate-ccw-gM8iCdpA.js → rotate-ccw-BKGT9oCK.js} +1 -1
  100. package/assets/{roving-focus-pflLgyvB.js → roving-focus-B2beIkcs.js} +1 -1
  101. package/assets/{row-actions-DqODANSe.js → row-actions-B32GgPjM.js} +1 -1
  102. package/assets/{search-mirror-BPmmvfUK.js → search-mirror-CCS7HTrR.js} +1 -1
  103. package/assets/{search-query-Bfvoxxg4.js → search-query-CAVAQ88t.js} +1 -1
  104. package/assets/{search-token-index-DnVW2A-U.js → search-token-index-CpNMPGXa.js} +1 -1
  105. package/assets/{sections-CI8sUA-m.js → sections-yYR5lj5B.js} +1 -1
  106. package/assets/{senders-CXDuYLon.js → senders-BQUohPe4.js} +1 -1
  107. package/assets/settings-8vexnTwM.js +1 -0
  108. package/assets/{settings-screen-a-xqubF0.js → settings-screen-DIq3lhTN.js} +1 -1
  109. package/assets/{shield-check-C76VpI9Q.js → shield-check-82yPViXE.js} +1 -1
  110. package/assets/{suggested-vips-DKoHfOxA.js → suggested-vips-pyfL4tBL.js} +1 -1
  111. package/assets/suggestion._suggestionId-DSXOmfLm.js +1 -0
  112. package/assets/{undo-2-DlatIdv3.js → undo-2-DiDBLYQX.js} +1 -1
  113. package/assets/useCalendarData-CCBsntW3.js +1 -0
  114. package/assets/{calendar-format-BovOEuV7.js → useCalendarEvents-CrWcNz4p.js} +1 -1
  115. package/assets/useCalendarFreeBusy-DuQyTiBf.js +1 -0
  116. package/assets/{useCalendarWrites-BGQ8emvx.js → useCalendarWrites-BV5Czl6K.js} +1 -1
  117. package/assets/{useCalendars-DpG3wNVl.js → useCalendars-7HDjkRuY.js} +1 -1
  118. package/assets/{useDebouncedValue-D87mJggE.js → useDebouncedValue-VlBdfJHe.js} +1 -1
  119. package/assets/{useFilters-CjhcpObW.js → useFilters-C8oAo8fh.js} +1 -1
  120. package/assets/{useLabels-BZ4I9RAK.js → useLabels-UgAc0ur8.js} +1 -1
  121. package/assets/{useLayoutTier-Cme1U69S.js → useLayoutTier-DAXt_X3A.js} +1 -1
  122. package/assets/{useMessageBodyContent-oSPoCcAo.js → useMessageBodyContent-CnzHiG9b.js} +1 -1
  123. package/assets/{useQueries-BgVJvl8E.js → useQueries-ktaWu7Pv.js} +1 -1
  124. package/assets/useRefreshControl-DQ537M3s.js +1 -0
  125. package/assets/{useResultFolderIndex-q07DaZO-.js → useResultFolderIndex-CkQexziN.js} +1 -1
  126. package/assets/{useSignature-C8_KOsXT.js → useSignature-CD6M-2Jc.js} +1 -1
  127. package/assets/{warnings-Ba73_41o.js → warnings-lUeu-pd_.js} +1 -1
  128. package/index.html +6 -10
  129. package/package.json +2 -2
  130. package/spellcheck/de99b00dc30674fd/NOTICE.txt +1 -1
  131. package/spellcheck/de99b00dc30674fd/manifest.json +1 -1
  132. package/assets/BriefPane-CjGWdd8a.js +0 -1
  133. package/assets/CalendarComposePane-Dx8OkeLw.js +0 -1
  134. package/assets/FlaggedPane-BxOdsnw1.js +0 -1
  135. package/assets/MailListHeader-CRcUWHvS.js +0 -1
  136. package/assets/MailboxPane-Bo9JttiA.js +0 -1
  137. package/assets/OutboxPane-CP5sRwfd.js +0 -1
  138. package/assets/_calendarObjectId-BnSnl92f.js +0 -1
  139. package/assets/_mailboxId-CNwKdI8w.js +0 -1
  140. package/assets/_messageId-C9wsfdzq.js +0 -1
  141. package/assets/_messageId-DBNLE0tb.js +0 -1
  142. package/assets/_messageId-HdLzcjMe.js +0 -1
  143. package/assets/_outboxMessageId-DHN5fMou.js +0 -1
  144. package/assets/_recurrenceId-CniHh10K.js +0 -1
  145. package/assets/_threadId-C3p0YYSS.js +0 -1
  146. package/assets/_threadId-ChtUn47n.js +0 -1
  147. package/assets/_threadId-DFtqyHil.js +0 -1
  148. package/assets/_view._date-CZQj0j1i.js +0 -1
  149. package/assets/brief-Drn9-8tt.js +0 -1
  150. package/assets/calendar-suggestion-C_OSjndS.js +0 -1
  151. package/assets/calendars-DBG7BQZr.js +0 -1
  152. package/assets/chevron-left-SkeGnPD1.js +0 -1
  153. package/assets/compose._-_outboxMessageId_-B-R8VIDx.js +0 -1
  154. package/assets/compose._-_outboxMessageId_-CRT9iVyv.js +0 -1
  155. package/assets/compose._-_outboxMessageId_-Cd-9BJez.js +0 -1
  156. package/assets/compose._-_outboxMessageId_-Cnw34yB-.js +0 -1
  157. package/assets/flagged-CGRoEDEr.js +0 -1
  158. package/assets/index-91ywJtSA.js +0 -1
  159. package/assets/index-BSloTjxB.js +0 -1
  160. package/assets/index-C9wsfdzq.js +0 -1
  161. package/assets/index-CFGRT_20.js +0 -1
  162. package/assets/index-CzzzRc7f.js +0 -1
  163. package/assets/index-D-aF7kT3.js +0 -1
  164. package/assets/index-DBNLE0tb.js +0 -1
  165. package/assets/index-DFpmjJVI.js +0 -1
  166. package/assets/index-hMino1Zj.js +0 -1
  167. package/assets/minus-tJx7k6NN.js +0 -1
  168. package/assets/new-CFrxbOp1.js +0 -1
  169. package/assets/onboarding-BfZPTDb2.js +0 -1
  170. package/assets/outbox-CS_GQ7eb.js +0 -1
  171. package/assets/result-count-BTXdc_1e.js +0 -1
  172. package/assets/settings-CLLqV8u4.js +0 -1
  173. package/assets/suggestion._suggestionId-Cz28HTX7.js +0 -1
  174. package/assets/useCalendarData-DbJEV-YD.js +0 -1
  175. package/assets/useCalendarFreeBusy-q7sx9n0O.js +0 -1
  176. package/assets/useRefreshControl-DPzIiFlp.js +0 -1
@@ -1 +1 @@
1
- import{j as t,ao as e}from"./index-cubACEd8.js";const s=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{s as component};
1
+ import{j as t,ao as e}from"./index-D4MtLdrW.js";const s=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{s as component};
@@ -0,0 +1 @@
1
+ import{r as m,j as c}from"./index-D4MtLdrW.js";import{y as b,C as D,j as x,s as w}from"./calendar-suggestion-CEyL4gPa.js";import{E as T}from"./EmptyState-Lplntbv_.js";import{e as C,p as j,a as A,E as v,u as k,C as N}from"./CalendarComposePane-QYpMNL9q.js";import{e as F,h as O,u as R,d as E,f as Z,U as L}from"./useCalendars-7HDjkRuY.js";import{c as P}from"./calendar-report-DdEEmF6Z.js";import{M as U,n as H}from"./useCalendarEvents-CrWcNz4p.js";import"./ErrorState-U7sVw9dY.js";import"./calendar-clash-strip-CZKSYHne.js";import"./useQueries-ktaWu7Pv.js";function z(e,t,d){const n={title:e.summary,location:e.location};if(e.allDay){const o=e.dtStart.slice(0,10),i=e.dtEnd.slice(0,10);return{...C(o,t),...n,allDay:!0,startTime:"",endDate:i>o?F(i,-1):o,endTime:""}}const a=o=>e.zoneCertainty==="Ambiguous"?o:O(o,d),s=a(e.dtStart),l=a(e.dtEnd);return{...C(s.slice(0,10),t),...n,startTime:s.slice(11,16),endDate:l.slice(0,10),endTime:l.slice(11,16)}}function B(e,t,d,n){const a=j(t,d,n);if(!a.ok)return a;const l=e.zoneCertainty==="Ambiguous"||a.patch.start!==void 0?{...a.patch,...A(d,n.clock),allDay:d.allDay,timeZone:n.anchor}:a.patch;return{ok:!0,input:{calendarId:d.calendarId,event:l}}}const g="Add from mail",M="The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";function _({suggestionId:e,onClose:t}){const{suggestion:d,isLoading:n,error:a}=b(e),s=d??void 0,[l,o]=m.useState(void 0);s!==void 0&&l===void 0&&o(s);const i=l??s;if(i!==void 0)return c.jsx($,{suggestion:i,onClose:t},i.suggestionId);if(a!==null){const u="Couldn't read what your mail is waiting on.";return c.jsx(v,{title:g,onClose:t,children:c.jsx(D,{text:`${u} Close this and try again.`,reportHref:P(u),className:"m-row-inset"})})}return c.jsx(v,{title:g,onClose:t,children:c.jsx(T,{message:n?"Reading the suggestion…":"This suggestion is no longer waiting on you. It was answered, or a later message replaced it."})})}function $({suggestion:e,onClose:t}){const{calendars:d,defaultCalendarId:n,timeZoneByCalendarId:a}=R(),s=d.filter(r=>!r.readOnly),l=x(),[o]=m.useState(()=>z(e,"",E())),[i,u]=m.useState(o),[y,f]=m.useState(""),S=k(i),p=s.some(r=>r.id===n)?n:s[0]?.id??"";m.useEffect(()=>{p!==""&&u(r=>r.calendarId===""?{...r,calendarId:p}:r)},[p]);const I=()=>{const r=B(e,o,i,{clock:E(),anchor:Z(a[i.calendarId]??L)});if(!r.ok){f(r.problem);return}f(""),l.acceptEdited(e.suggestionId,r.input).then(h=>{if(h.kind==="answered"){t();return}f(`Couldn't add this to your calendar: ${h.message}`)})};return c.jsx(N,{title:g,subtitle:w(e),notice:e.zoneCertainty==="Ambiguous"?M:"",calendars:s,draft:i,onChange:u,problem:y,saveLabel:"Add",isSaving:l.isAnswering,repeatEditable:!1,clashes:S,onSave:I,onCancel:t})}function te(){const e=U(),{closeEvent:t}=H();return e===void 0?null:c.jsx(_,{suggestionId:e,onClose:t})}export{te as component};
@@ -1 +1 @@
1
- import{e as a}from"./index-cubACEd8.js";const o=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{o as U};
1
+ import{e as a}from"./index-D4MtLdrW.js";const o=a("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);export{o as U};
@@ -0,0 +1 @@
1
+ import{r as m}from"./index-D4MtLdrW.js";import{u as C,d as g,i as I,t as v,U as p,b as D,r as E}from"./useCalendars-7HDjkRuY.js";import{x as y,I as L}from"./useCalendarEvents-CrWcNz4p.js";function Z(a,n){const t=a.map(e=>e.id);if(n.length===0)return t;const s=new Set(n),o=t.filter(e=>s.has(e));return o.length===0?t:o}function b(a){const{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,isLoading:o}=C(),e=Z(n,a),r=e.length===n.length?[]:e,c=a.length===0||n.length>0;return{calendars:n,colorByCalendarId:t,timeZoneByCalendarId:s,shown:e,narrowed:r,resolved:c,isLoading:o}}function x(a,n,t){const s=t.join(",");return m.useMemo(()=>{const o=g(),e=new Set(s===""?[]:s.split(","));return a.filter(r=>I(r)&&e.has(r.calendarId)).map(r=>v(r,n[r.calendarId]??p,o))},[a,n,s])}function S({view:a,date:n,calendarIds:t,enabled:s=!0}){const{calendars:o,colorByCalendarId:e,timeZoneByCalendarId:r,shown:c,narrowed:l,resolved:u,isLoading:w}=b(t),h=D(a,n),i=s&&u,d=y({...h,calendarIds:l,enabled:i});L(a,n,l,i);const f=x(d.instances,r,c);return{calendars:o,events:f,colorByCalendarId:e,timeZoneByCalendarId:r,isLoading:w||d.isLoading,error:d.error,retry:d.refetch,instanceOf:E}}export{x as a,S as b,b as u};
@@ -1 +1 @@
1
- import{e as A,u as M,r as d,aa as p,eI as R,eJ as _,c0 as I,y as j,cp as U,eK as S,c as W,eL as T,h as F,s as G}from"./index-cubACEd8.js";import{u as B}from"./useQueries-BgVJvl8E.js";import{b as P}from"./useCalendars-DpG3wNVl.js";const it=A("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),g=480,m=1320,v=90;function $(t){return Number(t.slice(11,13))*60+Number(t.slice(14,16))}function ut(t){const n=Math.max(0,Math.min(1440,Math.round(t)));return`${String(Math.floor(n/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`}function lt(t){const n=Math.round(t);if(n<60)return`${n}m`;const a=Math.floor(n/60),e=n%60;return e===0?`${a}h`:`${a}h ${e}m`}function O(t,n){const a=new Date(`${t}T00:00:00Z`);return a.setUTCDate(a.getUTCDate()+n),a.toISOString().slice(0,10)}function dt(t,n){return Math.round((Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/864e5)}function ft(t){const n=t.start.slice(0,10),a=t.end.slice(0,10);if(!t.allDay)return a;const e=O(a,-1);return e<n?n:e}function mt(t,n){const a=[];for(let e=t;e<=n;e=O(e,1))a.push(e);return a}function ht(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function pt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function yt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"long"})}function gt(t,n){const[a,e,o]=t.split("-").map(Number),[r,c,s]=n.split("-").map(Number),u=new Date(a,e-1,o),l=new Date(r,c-1,s),i=u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",...e===c?{}:{month:"short"}}),w=l.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return`${i} – ${w}`}function Y(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short"})}function f(t){return new Date(t).getTime()}function Z(t,n){return t.allDay?n>=t.start.slice(0,10)&&n<t.end.slice(0,10):t.start.slice(0,10)===n}function q(t,n){return f(t.start)<f(n.end)&&f(n.start)<f(t.end)}function K(t){const n=t.map(r=>[f(r.start),f(r.end)]).sort((r,c)=>r[0]-c[0]);let a=0,e=0,o=0;for(const[r,c]of n){if(r>o){a+=o-e,e=r,o=c;continue}o=Math.max(o,c)}return a+=o-e,Math.round(a/6e4)}function Q(t){const n=[];for(const a of t){const e=t.filter(r=>r.id===a.id||q(a,r)).map(r=>r.id).sort();if(e.length<2)continue;const o=e.join("|");n.some(r=>r.join("|")===o)||n.push(e)}return n.filter(a=>!n.some(e=>e!==a&&a.every(o=>e.includes(o))))}function Dt(t,n,a){const e=n.filter(r=>Z(r,t)),o=e.filter(r=>!r.allDay).sort((r,c)=>f(r.start)-f(c.start));return{date:t,weekdayLabel:Y(t),dayNumber:Number(t.slice(8)),isToday:t===a,timed:o,allDay:e.filter(r=>r.allDay),busyMinutes:K(o),conflicts:Q(o)}}function H(t){return t.timed.length===0&&t.allDay.length===0}function V(t){return x(t.timed.map(n=>({from:$(n.start),to:$(n.end)})))}function x(t){const n=[...t].sort((e,o)=>e.from-o.from),a=[];for(const e of n){const o=a[a.length-1];if(o&&e.from<=o.to){o.to=Math.max(o.to,e.to);continue}a.push({...e})}return a}function k(t){return Math.min(Math.max(t,g),m)}function z(t,n,a=v){const e=x(n);if(e.length===0)return[{date:t,startMinute:g,endMinute:m,minutes:m-g,wholeDay:!0}];const o=[];let r=g;for(const c of e){const s=k(c.from),u=k(c.to);s-r>=a&&o.push({date:t,startMinute:r,endMinute:s,minutes:s-r,wholeDay:!1}),r=Math.max(r,s,u)}return m-r>=a&&o.push({date:t,startMinute:r,endMinute:m,minutes:m-r,wholeDay:!1}),o}function J(t,n=v){return z(t.date,V(t),n)}function wt(t,n,{ignoreIds:a=[]}={}){const e=Date.parse(t.start),o=Date.parse(t.end);return n.filter(r=>r.allDay||r.myRsvp==="declined"||a.includes(r.id)?!1:Date.parse(r.start)<o&&e<Date.parse(r.end))}function bt(t,n){const a=[];let e=[];const o=()=>{e.length!==0&&(e.length===1?a.push({kind:"day",key:e[0].date,day:e[0]}):a.push({kind:"run",key:`run_${e[0].date}`,from:e[0].date,to:e[e.length-1].date,days:e.length}),e=[])};for(const r of t){if(H(r)&&!n.includes(r.date)){e.push(r);continue}o(),a.push({kind:"day",key:r.date,day:r})}return o(),a}function $t(t){const n=[];for(const a of t){const e=n[n.length-1],o=e?Math.max(...e.map(r=>Date.parse(r.end))):0;if(e&&Date.parse(a.start)<o){e.push(a);continue}n.push([a])}return n}function Mt(t,n){const a=Date.parse(n),e=n.slice(0,10),o=t.flatMap(l=>l.timed).sort((l,i)=>Date.parse(l.start)-Date.parse(i.start)),r=o.filter(l=>Date.parse(l.start)<=a&&Date.parse(l.end)>a),c=o.filter(l=>Date.parse(l.start)>a),s=c[0],u=r.filter(l=>l.start.slice(0,10)===e).length+c.filter(l=>l.start.slice(0,10)===e).length;return{running:r,next:s,minutesUntilNext:s?Math.round((Date.parse(s.start)-a)/6e4):0,after:c[1],restOfDay:u,free:X(t,n,1)[0]}}function X(t,n,a){const e=n.slice(0,10),o=$(n),r=[];for(const c of t)if(!(c.date<e))for(const s of J(c)){if(c.date>e)r.push(s);else{const u=Math.max(s.startMinute,o);if(s.endMinute-u<v)continue;r.push({...s,startMinute:u,minutes:s.endMinute-u,wholeDay:s.wholeDay&&u===s.startMinute})}if(r.length===a)return r}return r}const tt={"cal-1":{solid:"bg-cal-1",soft:"bg-cal-1-soft",text:"text-cal-1",border:"border-cal-1",rail:"border-l-cal-1"},"cal-2":{solid:"bg-cal-2",soft:"bg-cal-2-soft",text:"text-cal-2",border:"border-cal-2",rail:"border-l-cal-2"},"cal-3":{solid:"bg-cal-3",soft:"bg-cal-3-soft",text:"text-cal-3",border:"border-cal-3",rail:"border-l-cal-3"},"cal-4":{solid:"bg-cal-4",soft:"bg-cal-4-soft",text:"text-cal-4",border:"border-cal-4",rail:"border-l-cal-4"},"cal-5":{solid:"bg-cal-5",soft:"bg-cal-5-soft",text:"text-cal-5",border:"border-cal-5",rail:"border-l-cal-5"},"cal-6":{solid:"bg-cal-6",soft:"bg-cal-6-soft",text:"text-cal-6",border:"border-cal-6",rail:"border-l-cal-6"}};function Tt(t){return tt[t]}const y="/calendar/$view/$date",D="/calendar/$view/$date/suggestion/$suggestionId";function et(){const t=p({from:y,shouldThrow:!1}),n=R({from:y,shouldThrow:!1}),a=t?.view??"",e=t?.date??"",o=n?.calendarId;return d.useMemo(()=>({..._({view:a,date:e},I(new Date)),calendarIds:o??[]}),[a,e,o])}function vt(){const t=p({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=p({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=t?.calendarObjectId,e=n?.recurrenceId;return d.useMemo(()=>a?{calendarObjectId:a,recurrenceId:e}:void 0,[a,e])}function Ct(){return p({from:D,shouldThrow:!1})?.suggestionId}function Et(){const t=p({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=p({from:D,shouldThrow:!1});return t!==void 0||n!==void 0}function kt(){const t=M(),n=j(),a=U(),{view:e,date:o}=et(),r=d.useCallback(s=>{t({to:y,params:s,search:!0,hash:a})},[t,a]),c=d.useCallback(s=>n.buildLocation({to:y,params:{view:"day",date:s},search:!0,hash:a}).href,[n,a]);return d.useMemo(()=>({goToView:s=>r({view:s,date:o}),step:s=>r({view:e,date:S(o,e,s)}),goToToday:()=>r({view:e,date:I(new Date)}),setAnchorDate:s=>t({to:y,params:{view:e,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>t({href:c(s)}),dayHref:c,openEvent:(s,u)=>t(u===void 0||u===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:e,date:o,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:e,date:o,calendarObjectId:s,recurrenceId:u},search:!0,hash:a}),closeEvent:()=>r({view:e,date:o}),openComposer:()=>t({to:"/calendar/$view/$date/new",params:{view:e,date:o},search:!0,hash:a}),changeSuggestionFirst:(s,u)=>t({to:D,params:{view:e,date:u,suggestionId:s},search:!0,hash:a})}),[r,t,c,a,e,o])}function It(){const t=M();return d.useCallback((n,a,e)=>{if(e===""){t({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}t({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:e}})},[t])}function St(){const t=M();return d.useCallback((n,a)=>{t({to:D,params:{view:"day",date:n,suggestionId:a}})},[t])}const L=G(400,404),C=5*6e4,E=({from:t,to:n,calendarIds:a})=>({query:a.length===0?{from:t,to:n}:{from:t,to:n,calendarId:[...a]}});function Ot(t){const{data:n,isLoading:a,error:e,refetch:o}=W({...T(E(t)),meta:L,staleTime:C,enabled:t.enabled??!0});return{instances:n?.items??[],isLoading:a,error:e,refetch:()=>{o()}}}function xt(t,n,a){const e=B({queries:t.map(i=>({...T(E({...i,calendarIds:n})),meta:L,staleTime:C,enabled:a}))}),o=t.map(i=>i.from).join("|"),r=e.map(i=>i.data),c=e.map(i=>i.isPending).join("|"),s=e.find(i=>i.error)?.error??null,u=d.useMemo(()=>r.flatMap(i=>i?.items??[]),[o,c]),l=d.useMemo(()=>{const i=new Set;return t.forEach((w,N)=>{e[N]?.isPending&&i.add(w.from)}),i},[o,c]);return{instances:u,pendingWindows:l,error:s,refetch:()=>{for(const i of e)i.error&&i.refetch()}}}function Lt(t,n,a,e){const o=F(),r=[...a].join(",");d.useEffect(()=>{if(!e)return;const c=r===""?[]:r.split(",");for(const s of[-1,1]){const u=P(t,S(n,t,s));o.prefetchQuery({...T(E({...u,calendarIds:c})),staleTime:C})}},[o,t,n,r,e])}const b=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),at=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}),nt=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long",timeZone:"UTC"});function rt(t){return nt.format(new Date(`${t}T00:00:00Z`))}function Nt(t){if(t.allDay)return`${rt(t.start.slice(0,10))}, all day`;const n=new Date(t.start),a=new Date(t.end),e=b.format(n);return b.format(a)===e?`${e}, ${h.format(n)} – ${h.format(a)}`:`${e}, ${h.format(n)} – ${b.format(a)}, ${h.format(a)}`}function At(t){return at.format(new Date(`${t}T00:00:00Z`))}function Rt(t){return h.format(new Date(`1970-01-01T${t}:00`))}function _t(t){return h.format(new Date(t))}export{x as A,mt as B,C,g as D,z as E,rt as F,Nt as G,Rt as H,Lt as I,dt as J,ft as K,wt as L,Ct as M,it as R,gt as a,bt as b,Tt as c,$ as d,ut as e,J as f,$t as g,V as h,m as i,lt as j,O as k,pt as l,ht as m,kt as n,vt as o,xt as p,Dt as q,Mt as r,Et as s,It as t,et as u,St as v,yt as w,Ot as x,_t as y,At as z};
1
+ import{e as A,u as M,r as d,aa as p,eH as R,eI as _,c0 as I,y as j,cp as U,eJ as S,c as W,eK as T,h as F,s as G}from"./index-D4MtLdrW.js";import{u as B}from"./useQueries-ktaWu7Pv.js";import{b as P}from"./useCalendars-7HDjkRuY.js";const it=A("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),g=480,m=1320,v=90;function $(t){return Number(t.slice(11,13))*60+Number(t.slice(14,16))}function ut(t){const n=Math.max(0,Math.min(1440,Math.round(t)));return`${String(Math.floor(n/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`}function lt(t){const n=Math.round(t);if(n<60)return`${n}m`;const a=Math.floor(n/60),e=n%60;return e===0?`${a}h`:`${a}h ${e}m`}function O(t,n){const a=new Date(`${t}T00:00:00Z`);return a.setUTCDate(a.getUTCDate()+n),a.toISOString().slice(0,10)}function dt(t,n){return Math.round((Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/864e5)}function ft(t){const n=t.start.slice(0,10),a=t.end.slice(0,10);if(!t.allDay)return a;const e=O(a,-1);return e<n?n:e}function mt(t,n){const a=[];for(let e=t;e<=n;e=O(e,1))a.push(e);return a}function ht(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function pt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function yt(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"long"})}function gt(t,n){const[a,e,o]=t.split("-").map(Number),[r,c,s]=n.split("-").map(Number),u=new Date(a,e-1,o),l=new Date(r,c-1,s),i=u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",...e===c?{}:{month:"short"}}),w=l.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"});return`${i} – ${w}`}function Y(t){const[n,a,e]=t.split("-").map(Number);return new Date(n,a-1,e).toLocaleDateString("en-GB",{weekday:"short"})}function f(t){return new Date(t).getTime()}function Z(t,n){return t.allDay?n>=t.start.slice(0,10)&&n<t.end.slice(0,10):t.start.slice(0,10)===n}function q(t,n){return f(t.start)<f(n.end)&&f(n.start)<f(t.end)}function H(t){const n=t.map(r=>[f(r.start),f(r.end)]).sort((r,c)=>r[0]-c[0]);let a=0,e=0,o=0;for(const[r,c]of n){if(r>o){a+=o-e,e=r,o=c;continue}o=Math.max(o,c)}return a+=o-e,Math.round(a/6e4)}function K(t){const n=[];for(const a of t){const e=t.filter(r=>r.id===a.id||q(a,r)).map(r=>r.id).sort();if(e.length<2)continue;const o=e.join("|");n.some(r=>r.join("|")===o)||n.push(e)}return n.filter(a=>!n.some(e=>e!==a&&a.every(o=>e.includes(o))))}function Dt(t,n,a){const e=n.filter(r=>Z(r,t)),o=e.filter(r=>!r.allDay).sort((r,c)=>f(r.start)-f(c.start));return{date:t,weekdayLabel:Y(t),dayNumber:Number(t.slice(8)),isToday:t===a,timed:o,allDay:e.filter(r=>r.allDay),busyMinutes:H(o),conflicts:K(o)}}function Q(t){return t.timed.length===0&&t.allDay.length===0}function V(t){return x(t.timed.map(n=>({from:$(n.start),to:$(n.end)})))}function x(t){const n=[...t].sort((e,o)=>e.from-o.from),a=[];for(const e of n){const o=a[a.length-1];if(o&&e.from<=o.to){o.to=Math.max(o.to,e.to);continue}a.push({...e})}return a}function k(t){return Math.min(Math.max(t,g),m)}function z(t,n,a=v){const e=x(n);if(e.length===0)return[{date:t,startMinute:g,endMinute:m,minutes:m-g,wholeDay:!0}];const o=[];let r=g;for(const c of e){const s=k(c.from),u=k(c.to);s-r>=a&&o.push({date:t,startMinute:r,endMinute:s,minutes:s-r,wholeDay:!1}),r=Math.max(r,s,u)}return m-r>=a&&o.push({date:t,startMinute:r,endMinute:m,minutes:m-r,wholeDay:!1}),o}function J(t,n=v){return z(t.date,V(t),n)}function wt(t,n,{ignoreIds:a=[]}={}){const e=Date.parse(t.start),o=Date.parse(t.end);return n.filter(r=>r.allDay||r.myRsvp==="declined"||a.includes(r.id)?!1:Date.parse(r.start)<o&&e<Date.parse(r.end))}function bt(t,n){const a=[];let e=[];const o=()=>{e.length!==0&&(e.length===1?a.push({kind:"day",key:e[0].date,day:e[0]}):a.push({kind:"run",key:`run_${e[0].date}`,from:e[0].date,to:e[e.length-1].date,days:e.length}),e=[])};for(const r of t){if(Q(r)&&!n.includes(r.date)){e.push(r);continue}o(),a.push({kind:"day",key:r.date,day:r})}return o(),a}function $t(t){const n=[];for(const a of t){const e=n[n.length-1],o=e?Math.max(...e.map(r=>Date.parse(r.end))):0;if(e&&Date.parse(a.start)<o){e.push(a);continue}n.push([a])}return n}function Mt(t,n){const a=Date.parse(n),e=n.slice(0,10),o=t.flatMap(l=>l.timed).sort((l,i)=>Date.parse(l.start)-Date.parse(i.start)),r=o.filter(l=>Date.parse(l.start)<=a&&Date.parse(l.end)>a),c=o.filter(l=>Date.parse(l.start)>a),s=c[0],u=r.filter(l=>l.start.slice(0,10)===e).length+c.filter(l=>l.start.slice(0,10)===e).length;return{running:r,next:s,minutesUntilNext:s?Math.round((Date.parse(s.start)-a)/6e4):0,after:c[1],restOfDay:u,free:X(t,n,1)[0]}}function X(t,n,a){const e=n.slice(0,10),o=$(n),r=[];for(const c of t)if(!(c.date<e))for(const s of J(c)){if(c.date>e)r.push(s);else{const u=Math.max(s.startMinute,o);if(s.endMinute-u<v)continue;r.push({...s,startMinute:u,minutes:s.endMinute-u,wholeDay:s.wholeDay&&u===s.startMinute})}if(r.length===a)return r}return r}const tt={"cal-1":{solid:"bg-cal-1",soft:"bg-cal-1-soft",text:"text-cal-1",border:"border-cal-1",rail:"border-l-cal-1"},"cal-2":{solid:"bg-cal-2",soft:"bg-cal-2-soft",text:"text-cal-2",border:"border-cal-2",rail:"border-l-cal-2"},"cal-3":{solid:"bg-cal-3",soft:"bg-cal-3-soft",text:"text-cal-3",border:"border-cal-3",rail:"border-l-cal-3"},"cal-4":{solid:"bg-cal-4",soft:"bg-cal-4-soft",text:"text-cal-4",border:"border-cal-4",rail:"border-l-cal-4"},"cal-5":{solid:"bg-cal-5",soft:"bg-cal-5-soft",text:"text-cal-5",border:"border-cal-5",rail:"border-l-cal-5"},"cal-6":{solid:"bg-cal-6",soft:"bg-cal-6-soft",text:"text-cal-6",border:"border-cal-6",rail:"border-l-cal-6"}};function Tt(t){return tt[t]}const y="/calendar/$view/$date",D="/calendar/$view/$date/suggestion/$suggestionId";function et(){const t=p({from:y,shouldThrow:!1}),n=R({from:y,shouldThrow:!1}),a=t?.view??"",e=t?.date??"",o=n?.calendarId;return d.useMemo(()=>({..._({view:a,date:e},I(new Date)),calendarIds:o??[]}),[a,e,o])}function vt(){const t=p({from:"/calendar/$view/$date/$calendarObjectId",shouldThrow:!1}),n=p({from:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",shouldThrow:!1}),a=t?.calendarObjectId,e=n?.recurrenceId;return d.useMemo(()=>a?{calendarObjectId:a,recurrenceId:e}:void 0,[a,e])}function Ct(){return p({from:D,shouldThrow:!1})?.suggestionId}function Et(){const t=p({from:"/calendar/$view/$date/new",shouldThrow:!1}),n=p({from:D,shouldThrow:!1});return t!==void 0||n!==void 0}function kt(){const t=M(),n=j(),a=U(),{view:e,date:o}=et(),r=d.useCallback(s=>{t({to:y,params:s,search:!0,hash:a})},[t,a]),c=d.useCallback(s=>n.buildLocation({to:y,params:{view:"day",date:s},search:!0,hash:a}).href,[n,a]);return d.useMemo(()=>({goToView:s=>r({view:s,date:o}),step:s=>r({view:e,date:S(o,e,s)}),goToToday:()=>r({view:e,date:I(new Date)}),setAnchorDate:s=>t({to:y,params:{view:e,date:s},search:!0,hash:a,replace:!0}),zoomToDay:s=>t({href:c(s)}),dayHref:c,openEvent:(s,u)=>t(u===void 0||u===""?{to:"/calendar/$view/$date/$calendarObjectId",params:{view:e,date:o,calendarObjectId:s},search:!0,hash:a}:{to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:e,date:o,calendarObjectId:s,recurrenceId:u},search:!0,hash:a}),closeEvent:()=>r({view:e,date:o}),openComposer:()=>t({to:"/calendar/$view/$date/new",params:{view:e,date:o},search:!0,hash:a}),changeSuggestionFirst:(s,u)=>t({to:D,params:{view:e,date:u,suggestionId:s},search:!0,hash:a})}),[r,t,c,a,e,o])}function It(){const t=M();return d.useCallback((n,a,e)=>{if(e===""){t({to:"/calendar/$view/$date/$calendarObjectId",params:{view:"day",date:n,calendarObjectId:a}});return}t({to:"/calendar/$view/$date/$calendarObjectId/$recurrenceId",params:{view:"day",date:n,calendarObjectId:a,recurrenceId:e}})},[t])}function St(){const t=M();return d.useCallback((n,a)=>{t({to:D,params:{view:"day",date:n,suggestionId:a}})},[t])}const b=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long"}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),at=new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:"UTC"}),nt=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"long",timeZone:"UTC"});function rt(t){return nt.format(new Date(`${t}T00:00:00Z`))}function Ot(t){if(t.allDay)return`${rt(t.start.slice(0,10))}, all day`;const n=new Date(t.start),a=new Date(t.end),e=b.format(n);return b.format(a)===e?`${e}, ${h.format(n)} – ${h.format(a)}`:`${e}, ${h.format(n)} – ${b.format(a)}, ${h.format(a)}`}function xt(t){return at.format(new Date(`${t}T00:00:00Z`))}function Lt(t){return h.format(new Date(`1970-01-01T${t}:00`))}function Nt(t){return h.format(new Date(t))}const L=G(400,404),C=5*6e4,E=({from:t,to:n,calendarIds:a})=>({query:a.length===0?{from:t,to:n}:{from:t,to:n,calendarId:[...a]}});function At(t){const{data:n,isLoading:a,error:e,refetch:o}=W({...T(E(t)),meta:L,staleTime:C,enabled:t.enabled??!0});return{instances:n?.items??[],isLoading:a,error:e,refetch:()=>{o()}}}function Rt(t,n,a){const e=B({queries:t.map(i=>({...T(E({...i,calendarIds:n})),meta:L,staleTime:C,enabled:a}))}),o=t.map(i=>i.from).join("|"),r=e.map(i=>i.data),c=e.map(i=>i.isPending).join("|"),s=e.find(i=>i.error)?.error??null,u=d.useMemo(()=>r.flatMap(i=>i?.items??[]),[o,c]),l=d.useMemo(()=>{const i=new Set;return t.forEach((w,N)=>{e[N]?.isPending&&i.add(w.from)}),i},[o,c]);return{instances:u,pendingWindows:l,error:s,refetch:()=>{for(const i of e)i.error&&i.refetch()}}}function _t(t,n,a,e){const o=F(),r=[...a].join(",");d.useEffect(()=>{if(!e)return;const c=r===""?[]:r.split(",");for(const s of[-1,1]){const u=P(t,S(n,t,s));o.prefetchQuery({...T(E({...u,calendarIds:c})),staleTime:C})}},[o,t,n,r,e])}export{x as A,mt as B,C,g as D,z as E,rt as F,Ot as G,Lt as H,_t as I,dt as J,ft as K,wt as L,Ct as M,it as R,gt as a,bt as b,Tt as c,$ as d,ut as e,J as f,$t as g,V as h,m as i,lt as j,O as k,pt as l,ht as m,kt as n,vt as o,Rt as p,Dt as q,Mt as r,Et as s,It as t,et as u,St as v,yt as w,At as x,Nt as y,xt as z};
@@ -0,0 +1 @@
1
+ import{e as M,t as c,j as e,r as N,X as D,as as P,dA as T,f as z,aR as Z,ai as I,eG as L,s as O}from"./index-D4MtLdrW.js";import{c as _,R as F,C as B}from"./useCalendarEvents-CrWcNz4p.js";import{M as C}from"./mail-B1xchVjt.js";import{G as A}from"./map-pin-35e-1RVT.js";import{S as W}from"./useLayoutTier-DAXt_X3A.js";import{u as G}from"./useQueries-ktaWu7Pv.js";const U=M("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 X(s){const n=_(s.color),a=s.rsvp==="tentative"||s.status==="tentative";return c("flex min-w-0 overflow-hidden rounded-sm border-l-2 px-1.5 py-0.5",n.soft,n.text,n.rail,s.layout==="column"||s.stacked?"flex-col":"items-center gap-1.5",a&&"border-y border-r border-dashed",a&&n.border,s.rsvp==="declined"&&"opacity-60",s.selected&&"ring-2 ring-ring",s.density==="compact"?"text-2xs":"text-xs")}function $({title:s,timeText:n,layout:a,rsvp:l,hasThread:d,isRecurring:m,zoneCertainty:x,trailing:t,detail:p}){const r=a==="column",i=x==="ambiguous",o=!r&&p!==void 0,u=e.jsxs("span",{className:c("flex min-w-0 items-center gap-1",r&&"w-full",l==="declined"&&"line-through"),children:[n!==""&&e.jsx("span",{className:"shrink-0 tabular-nums opacity-80",children:n}),e.jsx("span",{className:"truncate font-medium",children:s})]}),h=(m||d||i)&&e.jsxs("span",{className:c("flex shrink-0 items-center gap-1",r&&"mt-0.5",!r&&t===void 0&&"ml-auto"),children:[m&&e.jsx(F,{className:"size-2.5","aria-label":"Repeats"}),d&&e.jsx(C,{className:"size-2.5","aria-label":"From mail"}),i&&e.jsx(A,{className:"size-2.5 text-warning","aria-label":"Unclear zone"})]}),g=t!==void 0&&e.jsx("span",{className:c("shrink-0 opacity-80",!r&&"ml-auto"),children:t});return e.jsxs(e.Fragment,{children:[o?e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[u,h,g]}):e.jsxs(e.Fragment,{children:[u,h,g]}),p]})}function ae({title:s,timeText:n,color:a,layout:l,density:d,rsvp:m,status:x,hasThread:t,isRecurring:p,zoneCertainty:r,selected:i,onClick:o,leading:u,trailing:h,detail:g}){const j=l==="column";return e.jsxs("button",{type:"button",onClick:o,"aria-pressed":i,className:c("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",u!==void 0&&"gap-2"),children:[u,e.jsx("span",{className:c(X({color:a,layout:l,density:d,rsvp:m,status:x,selected:i,stacked:g!==void 0}),"flex-1",j&&"h-full"),children:e.jsx($,{title:s,timeText:n,layout:l,rsvp:m,hasThread:t,isRecurring:p,zoneCertainty:r,trailing:h,detail:g})})]})}const E=96,q=6;function re({children:s,hasCard:n,onConfirm:a,onReject:l,blocked:d,blockedReason:m,remaining:x,confirmLabel:t="Add",emptyText:p="Nothing in your mail is waiting on a decision about time.",className:r}){const[i,o]=N.useState(0),[u,h]=N.useState(null);if(!n)return e.jsxs("div",{className:c("flex flex-col items-center gap-2 p-6 text-center",r),children:[e.jsx(W,{className:"size-6 text-fg-subtle","aria-hidden":!0}),e.jsx("p",{className:"text-sm text-fg-muted",children:p})]});const g=Math.abs(i)>E,j=i>0;return e.jsxs("div",{className:c("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"touch-pan-y select-none",style:{transform:`translateX(${i}px) rotate(${i/40}deg)`,transition:u===null?"transform 180ms ease-out":"none"},onPointerDown:b=>{h(b.clientX)},onPointerMove:b=>{if(u===null)return;const v=b.clientX-u;Math.abs(v)>q&&!b.currentTarget.hasPointerCapture(b.pointerId)&&b.currentTarget.setPointerCapture(b.pointerId),o(v)},onPointerUp:()=>{Math.abs(i)>E&&(i>0&&!d&&a(),i<0&&l()),h(null),o(0)},onPointerCancel:()=>{h(null),o(0)},children:s}),g&&e.jsx("span",{className:c("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?d?m:t:"Not this"})]}),e.jsxs("p",{className:"text-center text-2xs text-fg-subtle",children:[x," left · swipe right to accept, left to drop, or use the buttons"]})]})}const H="Pick a clock first. The mail never said, and the reader will not choose for you.";function K(s,n){const a=s.zoneOptions;return a===void 0?{settled:!0,timeZone:""}:a.some(l=>l.timeZone===n)?{settled:!0,timeZone:n}:{settled:!1,reason:H}}function S(s){return s.threadSubject===""?s.sender:`${s.sender} — ${s.threadSubject}`}function Q(s){return s>=.85?"Read cleanly":s>=.6?"Read with gaps":"Barely read"}function ie({suggestion:s,whenText:n,onAdd:a,onReview:l,onDismiss:d,onOpenThread:m,busy:x=!1,addBlocked:t=!1,zoneChoice:p,onZoneChoice:r,addLabel:i="Add",touch:o,className:u}){const[h,g]=N.useState(""),[j,b]=N.useState(!1),v=N.useId(),k=p??h,R=f=>{b(!1),r?r(f):g(f)},y=K(s,k),w=f=>()=>{if(!y.settled){b(!0);return}f(y.timeZone)};return e.jsxs("article",{"aria-label":s.title,className:c("flex flex-col gap-2 rounded-lg border border-dashed border-line-strong bg-surface-sunken p-3",u),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"block text-2xs uppercase tracking-wider text-fg-subtle",children:["Suggested from mail · ",Q(s.confidence)]}),e.jsx("span",{className:"block truncate text-sm font-medium text-fg",children:s.title}),e.jsx("span",{className:"block text-xs text-fg-muted",children:n}),s.location!==""&&e.jsx("span",{className:"block truncate text-xs text-fg-muted",children:s.location})]}),e.jsx("button",{type:"button","aria-label":"Dismiss suggestion",onClick:d,disabled:x,className:c("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",o?"size-11":"size-7"),children:e.jsx(D,{className:"size-4"})})]}),s.ambiguity!==""&&e.jsxs("p",{className:"flex items-start gap-1.5 text-2xs text-warning",children:[e.jsx(P,{className:"mt-0.5 size-3 shrink-0","aria-hidden":!0}),s.ambiguity]}),m?e.jsxs("button",{type:"button",onClick:m,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:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}):e.jsxs("p",{className:"flex w-full min-w-0 items-center gap-1.5 text-2xs text-fg-subtle",children:[e.jsx(C,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S(s)})]}),s.zoneOptions&&e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-warning/40 p-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-2xs font-semibold text-warning",children:[e.jsx(A,{className:"size-3 shrink-0","aria-hidden":!0}),"Which clock is this on?"]}),s.zoneOptions.map(f=>e.jsxs("button",{type:"button","aria-pressed":k===f.timeZone,onClick:()=>R(f.timeZone),className:c("rounded-md border px-2 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",o&&"min-h-11",k===f.timeZone?"border-accent bg-accent-soft":"border-line bg-surface hover:border-line-strong"),children:[e.jsx("span",{className:"block text-xs font-medium text-fg",children:f.label}),e.jsx("span",{className:"block text-2xs text-fg-subtle",children:f.note})]},f.timeZone))]}),!y.settled&&e.jsx(T,{id:v,reason:y.reason,nudged:j,className:"text-2xs text-warning"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{variant:"primary",size:o?"md":"sm",icon:e.jsx(Z,{className:"size-3.5"}),onClick:w(a),disabled:x||t,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11 flex-1",!y.settled&&"opacity-55"),children:i}),l&&e.jsx(z,{variant:"secondary",size:o?"md":"sm",icon:e.jsx(U,{className:"size-3.5"}),onClick:w(l),disabled:x,"aria-describedby":y.settled?void 0:v,className:c(o&&"min-h-11",!y.settled&&"opacity-55"),children:"Change first"})]})]})}function le(s){return s.defaultCalendarId!==""?"ready":s.error!==null?"failed":s.isLoading?"loading":"none"}function oe(s,n){if(s!=="ready")return s==="loading"?"Reading your calendars…":s==="failed"?e.jsxs(e.Fragment,{children:["Couldn't read your calendars, so there is nowhere to add this yet. Reload to try again."," ",e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"font-medium text-accent hover:underline",children:"Report an issue"})]}):e.jsxs(e.Fragment,{children:["You have no calendar yet, so there is nowhere to add this."," ",e.jsx(I,{to:"/settings/calendars",className:"font-medium text-accent hover:underline",children:"Create a calendar"})]})}const Y=O(400,404);function ce(s){const n=G({queries:s.map(t=>({...L({query:{from:t.from,to:t.to}}),meta:Y,staleTime:B}))}),a=s.map(t=>t.from).join("|"),l=n.map(t=>t.data),d=n.map(t=>t.isPending).join("|"),m=N.useMemo(()=>l.flatMap(t=>t?.items??[]),[a,d]),x=N.useMemo(()=>{const t=new Set;return s.forEach((p,r)=>{n[r]?.isPending&&t.add(p.from)}),t},[a,d]);return{spans:m,pendingWindows:x,error:n.find(t=>t.error)?.error??null,refetch:()=>{for(const t of n)t.error&&t.refetch()}}}export{ae as C,ie as E,H as Z,$ as a,re as b,X as c,oe as d,le as e,K as s,ce as u};
@@ -1 +1 @@
1
- import{h as v,r,i as c,f5 as C,f6 as h,f7 as y,s as g,b2 as m}from"./index-cubACEd8.js";import{f as I}from"./ErrorState-C-GqtxHT.js";const o=g(400,404,412),b=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),d={kind:"written"},i=e=>m(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},O={this:"This",following:"Following",all:"All"};function A(){const e=v();return r.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const s=n._id;return typeof s=="string"&&b.has(s)}})},[e])}const f=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:O[e],recurrenceId:t};function k(){const e=A(),t=c({...C(),meta:o,onSuccess:e}),n=c({...h(),meta:o,onSuccess:e}),s=c({...y(),meta:o,onSuccess:e}),l=r.useCallback(a=>t.mutateAsync({body:a}).then(()=>d).catch(i),[t]),u=r.useCallback((a,p)=>n.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...f(a)},headers:{"If-Match":a.etag},body:p}).then(()=>d).catch(i),[n]),E=r.useCallback(a=>s.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...f(a)},headers:{"If-Match":a.etag}}).then(()=>d).catch(i),[s]);return r.useMemo(()=>({createEvent:l,updateEvent:u,deleteEvent:E,isWriting:t.isPending||n.isPending||s.isPending}),[l,u,E,t.isPending,n.isPending,s.isPending])}export{k as a,A as u};
1
+ import{h as v,r,i as c,f5 as C,f6 as h,f7 as y,s as g,b2 as m}from"./index-D4MtLdrW.js";import{f as I}from"./ErrorState-U7sVw9dY.js";const o=g(400,404,412),b=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),d={kind:"written"},i=e=>m(e)===412?{kind:"conflict"}:{kind:"refused",message:I(e)},O={this:"This",following:"Following",all:"All"};function A(){const e=v();return r.useCallback(()=>{e.invalidateQueries({predicate:t=>{const n=t.queryKey[0];if(typeof n!="object"||n===null)return!1;const s=n._id;return typeof s=="string"&&b.has(s)}})},[e])}const f=({scope:e,recurrenceId:t})=>e===void 0?{}:{scope:O[e],recurrenceId:t};function k(){const e=A(),t=c({...C(),meta:o,onSuccess:e}),n=c({...h(),meta:o,onSuccess:e}),s=c({...y(),meta:o,onSuccess:e}),l=r.useCallback(a=>t.mutateAsync({body:a}).then(()=>d).catch(i),[t]),u=r.useCallback((a,p)=>n.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...f(a)},headers:{"If-Match":a.etag},body:p}).then(()=>d).catch(i),[n]),E=r.useCallback(a=>s.mutateAsync({path:{calendarObjectId:a.calendarObjectId},query:{calendarId:a.calendarId,...f(a)},headers:{"If-Match":a.etag}}).then(()=>d).catch(i),[s]);return r.useMemo(()=>({createEvent:l,updateEvent:u,deleteEvent:E,isWriting:t.isPending||n.isPending||s.isPending}),[l,u,E,t.isPending,n.isPending,s.isPending])}export{k as a,A as u};
@@ -1 +1 @@
1
- import{c as T,eH as h,r as N}from"./index-cubACEd8.js";const o=e=>String(e).padStart(2,"0"),$=e=>`${e.getUTCFullYear()}-${o(e.getUTCMonth()+1)}-${o(e.getUTCDate())}`,m=e=>{const t=e<0?"-":"+",r=Math.abs(e);return`${t}${o(Math.floor(r/60))}:${o(r%60)}`};function D(e,t){const r=new Date(`${e}T${t}:00`);return`${e}T${t}:00${m(-r.getTimezoneOffset())}`}const i=new Map;function U(e){if(i.has(e))return i.get(e);let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{t=void 0}return i.set(e,t),t}function l(e,t){const r=U(e);if(!r)return Number.NaN;const n=r.formatToParts(new Date(t)),a=b=>Number(n.find(g=>g.type===b)?.value),s=a("hour")%24;return(Date.UTC(a("year"),a("month")-1,a("day"),s,a("minute"),a("second"))-t)/6e4}function L(e,t,r){if(r==="")return`${e}T${t}:00+00:00`;const n=Date.parse(`${e}T${t}:00Z`),a=l(r,n);if(Number.isNaN(a))return D(e,t);const s=l(r,n-a*6e4);return`${e}T${t}:00${m(Number.isNaN(s)?a:s)}`}function C(e,t){const r=Date.parse(e),n=l(t,r),a=Number.isNaN(n)?-new Date(r).getTimezoneOffset():n,s=new Date(r+a*6e4);return`${$(s)}T${o(s.getUTCHours())}:${o(s.getUTCMinutes())}:${o(s.getUTCSeconds())}${m(a)}`}const u=e=>D(e,"00:00");function c(e,t){const[r,n,a]=e.split("-").map(Number);return $(new Date(Date.UTC(r,n-1,a+t)))}function d(e){const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n));return c(e,-((a.getUTCDay()+6)%7))}function E(e,t){const[r,n]=t.split("-").map(Number);if(e==="year")return[`${r}-01-01`,`${r+1}-01-01`];if(e==="month"){const s=`${r}-${o(n)}-01`,p=n===12?`${r+1}-01-01`:`${r}-${o(n+1)}-01`;return[d(s),c(d(c(p,-1)),7)]}if(e==="day")return[t,c(t,1)];const a=d(t);return[a,c(a,7)]}function M(e,t){const[r,n]=E(e,t);return{from:u(r),to:u(n)}}function F(e,t){return{from:u(e),to:u(c(e,t))}}const R=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,y="";function k(e){if(e!==y)return e;const t=R();return Intl.supportedValuesOf("timeZone").includes(t)?t:y}const v={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},w={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},I="#";function z(e,t){return t===""?e:`${e}${I}${t}`}function f(e){const t=e.indexOf(I);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const O=(e,t)=>{const r=[...e].sort((n,a)=>Date.parse(n.start)-Date.parse(a.start));return r.find(n=>Date.parse(n.end)>Date.parse(t))??r[0]};function B(e,t,r){const n=O(e.filter(a=>{const s=f(a.id);return s.calendarObjectId===t&&s.recurrenceId!==""}),r);return n?f(n.id):void 0}function H(e,t,r,n){const a=O(e.filter(s=>s.calendarObjectId===t&&j(s)).map(s=>x(s,"",n)),r);if(a)return{...f(a.id),calendarId:a.calendarId,date:a.start.slice(0,10)}}function S(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:v[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function x(e,t,r){return{id:z(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):C(e.start,r),end:e.allDay?e.end.slice(0,10):C(e.end,r),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:t,zoneCertainty:w[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const j=e=>e.status!=="Cancelled";function P(){const{data:e,isLoading:t,error:r}=T(h());return N.useMemo(()=>{const n=e?.items??[],a=n.map(S);return{calendars:a,collections:n,colorByCalendarId:Object.fromEntries(a.map(s=>[s.id,s.color])),timeZoneByCalendarId:Object.fromEntries(n.map(s=>[s.calendarId,s.timezone])),defaultCalendarId:(n.find(s=>s.source==="Default")??n[0])?.calendarId??"",isLoading:t,error:r??null}},[e,t,r])}export{y as U,F as a,M as b,z as c,R as d,c as e,k as f,L as g,C as h,j as i,H as j,f as r,B as s,x as t,P as u};
1
+ import{c as T,eS as h,r as N}from"./index-D4MtLdrW.js";const o=e=>String(e).padStart(2,"0"),$=e=>`${e.getUTCFullYear()}-${o(e.getUTCMonth()+1)}-${o(e.getUTCDate())}`,m=e=>{const t=e<0?"-":"+",r=Math.abs(e);return`${t}${o(Math.floor(r/60))}:${o(r%60)}`};function D(e,t){const r=new Date(`${e}T${t}:00`);return`${e}T${t}:00${m(-r.getTimezoneOffset())}`}const i=new Map;function U(e){if(i.has(e))return i.get(e);let t;try{t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{t=void 0}return i.set(e,t),t}function l(e,t){const r=U(e);if(!r)return Number.NaN;const n=r.formatToParts(new Date(t)),a=b=>Number(n.find(g=>g.type===b)?.value),s=a("hour")%24;return(Date.UTC(a("year"),a("month")-1,a("day"),s,a("minute"),a("second"))-t)/6e4}function L(e,t,r){if(r==="")return`${e}T${t}:00+00:00`;const n=Date.parse(`${e}T${t}:00Z`),a=l(r,n);if(Number.isNaN(a))return D(e,t);const s=l(r,n-a*6e4);return`${e}T${t}:00${m(Number.isNaN(s)?a:s)}`}function C(e,t){const r=Date.parse(e),n=l(t,r),a=Number.isNaN(n)?-new Date(r).getTimezoneOffset():n,s=new Date(r+a*6e4);return`${$(s)}T${o(s.getUTCHours())}:${o(s.getUTCMinutes())}:${o(s.getUTCSeconds())}${m(a)}`}const u=e=>D(e,"00:00");function c(e,t){const[r,n,a]=e.split("-").map(Number);return $(new Date(Date.UTC(r,n-1,a+t)))}function d(e){const[t,r,n]=e.split("-").map(Number),a=new Date(Date.UTC(t,r-1,n));return c(e,-((a.getUTCDay()+6)%7))}function E(e,t){const[r,n]=t.split("-").map(Number);if(e==="year")return[`${r}-01-01`,`${r+1}-01-01`];if(e==="month"){const s=`${r}-${o(n)}-01`,p=n===12?`${r+1}-01-01`:`${r}-${o(n+1)}-01`;return[d(s),c(d(c(p,-1)),7)]}if(e==="day")return[t,c(t,1)];const a=d(t);return[a,c(a,7)]}function M(e,t){const[r,n]=E(e,t);return{from:u(r),to:u(n)}}function F(e,t){return{from:u(e),to:u(c(e,t))}}const R=()=>Intl.DateTimeFormat().resolvedOptions().timeZone,y="";function k(e){if(e!==y)return e;const t=R();return Intl.supportedValuesOf("timeZone").includes(t)?t:y}const v={Cal1:"cal-1",Cal2:"cal-2",Cal3:"cal-3",Cal4:"cal-4",Cal5:"cal-5",Cal6:"cal-6"},w={Local:"local",Explicit:"explicit",Ambiguous:"ambiguous"},I="#";function S(e,t){return t===""?e:`${e}${I}${t}`}function f(e){const t=e.indexOf(I);return t===-1?{calendarObjectId:e,recurrenceId:""}:{calendarObjectId:e.slice(0,t),recurrenceId:e.slice(t+1)}}const O=(e,t)=>{const r=[...e].sort((n,a)=>Date.parse(n.start)-Date.parse(a.start));return r.find(n=>Date.parse(n.end)>Date.parse(t))??r[0]};function B(e,t,r){const n=O(e.filter(a=>{const s=f(a.id);return s.calendarObjectId===t&&s.recurrenceId!==""}),r);return n?f(n.id):void 0}function P(e,t,r,n){const a=O(e.filter(s=>s.calendarObjectId===t&&j(s)).map(s=>x(s,"",n)),r);if(a)return{...f(a.id),calendarId:a.calendarId,date:a.start.slice(0,10)}}function z(e){return{id:e.calendarId,accountId:e.accountConfigId,accountLabel:"",name:e.displayName,color:v[e.color]??"cal-1",...e.source==="Subscribed"?{readOnly:!0,sync:e.subscriptionEnabled?"live":"paused",syncError:e.subscriptionError}:{}}}function x(e,t,r){return{id:S(e.calendarObjectId,e.recurrenceId),calendarId:e.calendarId,title:e.summary,start:e.allDay?e.start.slice(0,10):C(e.start,r),end:e.allDay?e.end.slice(0,10):C(e.end,r),allDay:e.allDay,location:"",notes:"",attendees:[],myRsvp:"accepted",threadId:"",threadSubject:"",timeZone:t,zoneCertainty:w[e.zoneCertainty]??"explicit",recurrenceRule:e.hasRecurrence?"Repeats":"",seriesId:e.hasRecurrence?e.icalUid:"",seriesException:!1,status:e.status==="Tentative"?"tentative":"confirmed"}}const j=e=>e.status!=="Cancelled";function W(){const{data:e,isLoading:t,error:r}=T(h());return N.useMemo(()=>{const n=e?.items??[],a=n.map(z);return{calendars:a,collections:n,colorByCalendarId:Object.fromEntries(a.map(s=>[s.id,s.color])),timeZoneByCalendarId:Object.fromEntries(n.map(s=>[s.calendarId,s.timezone])),defaultCalendarId:(n.find(s=>s.source==="Default")??n[0])?.calendarId??"",isLoading:t,error:r??null}},[e,t,r])}export{y as U,F as a,M as b,S as c,R as d,c as e,k as f,L as g,C as h,j as i,P as j,f as r,B as s,x as t,W as u};
@@ -1 +1 @@
1
- import{r as o}from"./index-cubACEd8.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
1
+ import{r as o}from"./index-D4MtLdrW.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
@@ -1 +1 @@
1
- import{r as d,i as h,eT as x,c as A,eU as P,eV as N,eW as L,h as v,eX as T,eY as I,eZ as z,e_ as R,bi as w}from"./index-cubACEd8.js";const X=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},O={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},G=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?O.UserDisabled:O[e.disabledReason],Z=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},M=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,i,a]=r,n=new Date(Number(s),Number(i)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const o=-t.getTimezoneOffset(),l=o>=0?"+":"-",c=Math.abs(o),p=String(Math.floor(c/60)).padStart(2,"0"),m=String(c%60).padStart(2,"0"),u=f=>String(f).padStart(2,"0");return`${n.getFullYear()}-${u(n.getMonth()+1)}-${u(n.getDate())}T${u(n.getHours())}:${u(n.getMinutes())}:${u(n.getSeconds())}${l}${p}:${m}`},g="None",k=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:g,actionMailboxId:g}),D=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),ee=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",te=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:i})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?M(i??""):void 0}),y=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),_=new Set(["Complete","Failed"]),F=e=>e!==void 0&&_.has(e),J=1e3,$=15e3,U=e=>{const t=Math.max(0,e),r=J*2**t;return Math.min(r,$)},q=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},re=e=>{const[t,r]=d.useState(),s=h({...x(),onSuccess:b=>r(b.organizeJobId)}),{mutate:i}=s,a=A({...P({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:b=>{const E=b.state.data?.state;return F(E)?!1:U(b.state.dataUpdateCount)}}),n=d.useCallback(b=>{e&&i({path:{accountId:e},body:D(b)})},[e,i]),o=d.useCallback(b=>{e&&i({path:{accountId:e},body:k(b)})},[e,i]),{refetch:l}=a,c=d.useCallback(()=>{l()},[l]),p=a.data,m=s.isPending?void 0:p,u=m?.state??s.data?.state,f=F(m?.state),S={state:u,matchedCount:m?.matchedCount??0,appliedCount:m?.appliedCount??0,failedCount:m?.failedCount??0,errorMessage:m?.errorMessage??""};return{start:n,startForFilter:o,watch:r,refreshStatus:c,progress:S,isStarting:s.isPending,isRunning:!!t&&!f,isDone:f,failure:q(s.error,a.error,!!p)}},se=["From","Subject","HasWords","ListId","FromDomain"],Q=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ae=(e,t)=>e==="ListId"?Q(t):t.trim(),j=e=>e==="all"?"And":"Or",K=e=>({matchOperator:j(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),W=e=>!e.literalClauses.some(t=>t.field==="HasWords"),B=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=e=>{const t=K(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?M(e.until??""):void 0}},H=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},V=350,ne=(e,t,r)=>{const s=h(N()),{mutateAsync:i}=s,a=B(t),[n,o]=d.useState(()=>({})),l=d.useRef(t);l.current=t;const c=d.useRef(a),p=W(t);return d.useEffect(()=>{if(!e||!p||a===n.previewedSignature||a===n.errorSignature)return;const m=setTimeout(()=>{const u=a;c.current=u,i({path:{accountId:e},body:D({...l.current})}).then(f=>{c.current===u&&o({count:f.matchedCount,matchedIds:f.messageIds,previewedSignature:u})}).catch(f=>{c.current===u&&o(S=>({...S,error:f instanceof Error?f.message:"Couldn't count matches.",errorSignature:u}))})},V);return()=>clearTimeout(m)},[e,p,a,n.previewedSignature,n.errorSignature,i]),p?{count:H(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:L},matchedIds:[]}},C=e=>I({path:{accountId:e}}),oe=e=>{const t=A({...z({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},le=e=>{const t=v(),r=h({...T(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,mutateAsync:i}=r,a=d.useCallback((o,l,c)=>{e&&s({path:{accountId:e},body:y(o,l,c)})},[e,s]),n=d.useCallback(async(o,l,c)=>{if(e)return i({path:{accountId:e},body:y(o,l,c)}).then(p=>p,()=>{})},[e,i]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ue=e=>{const t=v(),r=h({...R(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s}=r;return{deleteFilter:d.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},de=e=>{const t=v(),r=h({...w(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,variables:i}=r,a=d.useCallback((o,l)=>{e&&s({path:{accountId:e,filterId:o},body:{state:l?"Active":"Disabled"}})},[e,s]),n=d.useCallback(()=>{i&&s(i)},[s,i]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?i?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:i?.body?.state==="Active"}};export{g as N,se as S,re as a,C as b,ie as c,G as d,Z as e,X as f,oe as g,ue as h,de as i,le as j,te as k,ae as n,ee as o,M as p,K as r,ne as u};
1
+ import{r as d,i as h,eT as x,c as A,eU as P,eV as N,eW as L,h as v,eX as T,eY as I,eZ as z,e_ as R,bi as w}from"./index-D4MtLdrW.js";const X=(e,t)=>{if(e.state==="Expired")return"Expired";const r=e.state==="Disabled"?"Disabled":"Active";if(e.scope!=="Temporary"||!e.expiresAt)return r;const s=Date.parse(e.expiresAt);return Number.isNaN(s)?r:s<=t?"Expired":r},O={UserDisabled:"Turned off. Turn it on to run it on new mail again.",AwaitingFolder:"Off until its folder exists on the mail server. It turns on by itself once the folder is created.",FolderCreateFailed:"Off: the mail server refused to create its folder. Pick another folder in the rule, then turn it on.",FolderMissing:"Off: the folder it moves mail into no longer exists. Pick another folder in the rule, then turn it on."},G=e=>e.disabledReason==="None"?void 0:(e.disabledReason==="AwaitingFolder"||e.disabledReason==="FolderCreateFailed")&&e.actionMailboxId!=="None"?O.UserDisabled:O[e.disabledReason],Z=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},M=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,s,i,a]=r,n=new Date(Number(s),Number(i)-1,Number(a),23,59,59,0);if(Number.isNaN(n.getTime()))return;const o=-t.getTimezoneOffset(),l=o>=0?"+":"-",c=Math.abs(o),p=String(Math.floor(c/60)).padStart(2,"0"),m=String(c%60).padStart(2,"0"),u=f=>String(f).padStart(2,"0");return`${n.getFullYear()}-${u(n.getMonth()+1)}-${u(n.getDate())}T${u(n.getHours())}:${u(n.getMinutes())}:${u(n.getSeconds())}${l}${p}:${m}`},g="None",k=e=>({filterId:e,matchOperator:"And",literalClauses:[],actionLabelId:g,actionMailboxId:g}),D=e=>({matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),ee=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",te=({ruleScope:e,clauses:t,matchOperator:r,moveMailboxId:s,until:i})=>({matchOperator:r==="all"?"And":"Or",literalClauses:t.map(a=>({field:a.field,value:a.value})),moveMailboxId:s,expiresAt:e==="until"?M(i??""):void 0}),y=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??g,actionMailboxId:e.moveMailboxId??g}),_=new Set(["Complete","Failed"]),F=e=>e!==void 0&&_.has(e),J=1e3,$=15e3,U=e=>{const t=Math.max(0,e),r=J*2**t;return Math.min(r,$)},q=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},re=e=>{const[t,r]=d.useState(),s=h({...x(),onSuccess:b=>r(b.organizeJobId)}),{mutate:i}=s,a=A({...P({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:b=>{const E=b.state.data?.state;return F(E)?!1:U(b.state.dataUpdateCount)}}),n=d.useCallback(b=>{e&&i({path:{accountId:e},body:D(b)})},[e,i]),o=d.useCallback(b=>{e&&i({path:{accountId:e},body:k(b)})},[e,i]),{refetch:l}=a,c=d.useCallback(()=>{l()},[l]),p=a.data,m=s.isPending?void 0:p,u=m?.state??s.data?.state,f=F(m?.state),S={state:u,matchedCount:m?.matchedCount??0,appliedCount:m?.appliedCount??0,failedCount:m?.failedCount??0,errorMessage:m?.errorMessage??""};return{start:n,startForFilter:o,watch:r,refreshStatus:c,progress:S,isStarting:s.isPending,isRunning:!!t&&!f,isDone:f,failure:q(s.error,a.error,!!p)}},se=["From","Subject","HasWords","ListId","FromDomain"],Q=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ae=(e,t)=>e==="ListId"?Q(t):t.trim(),j=e=>e==="all"?"And":"Or",K=e=>({matchOperator:j(e.matchOperator),literalClauses:e.clauses.map(t=>({field:t.field,value:t.value}))}),W=e=>!e.literalClauses.some(t=>t.field==="HasWords"),B=e=>JSON.stringify({operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=e=>{const t=K(e);return{matchOperator:t.matchOperator,literalClauses:t.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?M(e.until??""):void 0}},H=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},V=350,ne=(e,t,r)=>{const s=h(N()),{mutateAsync:i}=s,a=B(t),[n,o]=d.useState(()=>({})),l=d.useRef(t);l.current=t;const c=d.useRef(a),p=W(t);return d.useEffect(()=>{if(!e||!p||a===n.previewedSignature||a===n.errorSignature)return;const m=setTimeout(()=>{const u=a;c.current=u,i({path:{accountId:e},body:D({...l.current})}).then(f=>{c.current===u&&o({count:f.matchedCount,matchedIds:f.messageIds,previewedSignature:u})}).catch(f=>{c.current===u&&o(S=>({...S,error:f instanceof Error?f.message:"Couldn't count matches.",errorSignature:u}))})},V);return()=>clearTimeout(m)},[e,p,a,n.previewedSignature,n.errorSignature,i]),p?{count:H(n,a),matchedIds:n.previewedSignature===a?n.matchedIds??[]:[]}:{count:{status:"error",reason:L},matchedIds:[]}},C=e=>I({path:{accountId:e}}),oe=e=>{const t=A({...z({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},le=e=>{const t=v(),r=h({...T(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,mutateAsync:i}=r,a=d.useCallback((o,l,c)=>{e&&s({path:{accountId:e},body:y(o,l,c)})},[e,s]),n=d.useCallback(async(o,l,c)=>{if(e)return i({path:{accountId:e},body:y(o,l,c)}).then(p=>p,()=>{})},[e,i]);return{createFilter:a,createFilterAsync:n,data:r.data,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},ue=e=>{const t=v(),r=h({...R(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s}=r;return{deleteFilter:d.useCallback(a=>{e&&s({path:{accountId:e,filterId:a}})},[e,s]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}},de=e=>{const t=v(),r=h({...w(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:C(e)})}}),{mutate:s,variables:i}=r,a=d.useCallback((o,l)=>{e&&s({path:{accountId:e,filterId:o},body:{state:l?"Active":"Disabled"}})},[e,s]),n=d.useCallback(()=>{i&&s(i)},[s,i]);return{toggleFilter:a,retry:n,togglingFilterId:r.isPending?i?.path.filterId:void 0,isError:r.isError,error:r.error,enabling:i?.body?.state==="Active"}};export{g as N,se as S,re as a,C as b,ie as c,G as d,Z as e,X as f,oe as g,ue as h,de as i,le as j,te as k,ae as n,ee as o,M as p,K as r,ne as u};
@@ -1 +1 @@
1
- import{c as L,eB as p,h as n,i as l,eC as d,r as o,eD as y,eE as c,eF as g}from"./index-cubACEd8.js";const u=e=>y({path:{accountId:e}}),f=e=>{const r=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},h=e=>{const r=n(),t=l({...d(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},m=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,m as b,C as c,h as u};
1
+ import{c as L,eB as p,h as n,i as l,eC as d,r as o,eD as y,eE as c,eF as g}from"./index-D4MtLdrW.js";const u=e=>y({path:{accountId:e}}),f=e=>{const r=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:r.data?.items??[],isPending:r.isPending,isError:r.isError,error:r.error,refetch:r.refetch}},h=e=>{const r=n(),t=l({...d(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:s}=t;return{createLabel:o.useCallback((a,i="Default")=>e?s({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,s]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},m=e=>{const r=n(),t=l({...c(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{updateLabel:o.useCallback((a,i)=>{e&&s({path:{accountId:e,labelId:a},body:i})},[e,s]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},C=e=>{const r=n(),t=l({...g(),onSuccess:()=>{e&&r.invalidateQueries({queryKey:u(e)})}}),{mutate:s}=t;return{deleteLabel:o.useCallback(a=>{e&&s({path:{accountId:e,labelId:a}})},[e,s]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{f as a,m as b,C as c,h as u};
@@ -1 +1 @@
1
- import{e as a,c3 as t,c4 as s}from"./index-cubACEd8.js";const n=a("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),p=768,r=e=>e!=="desktop",c=()=>{const e=t(`(min-width: ${p}px)`);return t(s)?"desktop":e?"tablet":"phone"};export{n as S,r as i,c as u};
1
+ import{e as a,c3 as t,c4 as s}from"./index-D4MtLdrW.js";const n=a("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),p=768,r=e=>e!=="desktop",c=()=>{const e=t(`(min-width: ${p}px)`);return t(s)?"desktop":e?"tablet":"phone"};export{n as S,r as i,c as u};
@@ -1 +1 @@
1
- import{r as a,u as P,cp as O,cq as U,cQ as B,aa as p,cr as N,q as $,ac as D,h as F,c as L,cR as _,cF as v}from"./index-cubACEd8.js";const E="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",R="/mail/outbox/compose/{-$outboxMessageId}",S="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=p({from:E,shouldThrow:!1}),t=p({from:w,shouldThrow:!1}),s=p({from:R,shouldThrow:!1}),r=p({from:S,shouldThrow:!1});return e??t??s??r}function ee(){return T()!==void 0}function te(){return T()?.outboxMessageId}function q(e,t,s){return e==="flagged"?{to:w,params:{outboxMessageId:s}}:e==="outbox"?{to:R,params:{outboxMessageId:s}}:e==="mailbox"&&t?{to:S,params:{mailboxId:t,outboxMessageId:s}}:{to:E,params:{outboxMessageId:s}}}function b(){const e=P(),t=O(),{list:s,mailboxId:r}=U();return a.useCallback((n,o)=>{e({...q(s,r,n),search:B,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,s,r])}function se(){const e=b();return a.useCallback(()=>e(void 0),[e])}function re(){const e=b();return a.useCallback(t=>e(t),[e])}function ne(){const e=b();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function oe(){return N()}const Q=new Set(["rfc822","global"]),K=e=>e.mediaType.toUpperCase()==="MESSAGE"&&Q.has(e.mediaSubtype.toLowerCase()),k=(e,t)=>e.partPath.startsWith(`${t}.`),I=e=>{const t=e.filter(K);return e.filter(s=>!t.some(r=>k(s,r.partPath)))},ae=(e,t)=>e.filter(s=>k(s,t)),G=e=>{const t=I(e).filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},g={all:["messages"],detail:e=>[...g.all,"detail",e],body:e=>[...g.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const W=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},X=8,H="x-remit-403-reason",Y=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},z=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,j=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},J=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await v(e,{headers:r});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,W(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(H),m=Y(o.status,l);throw new f(m,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(j(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const h=await o.text();if(z(h,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return h},V=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ce=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?G(t):null,n=$(),{getToken:o}=D(),c=a.useRef(null),h=F(),l=a.useRef(!1),m=a.useRef(null),C=e&&r?`${e}:${r.contentUrl}`:null;m.current!==C&&(m.current=C,l.current=!1);const i=L({queryKey:e?[...g.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,V({fetchContent:(u,x)=>J(u,x,o),refetchDescribeMessage:()=>h.refetchQueries({queryKey:_({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:d})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<X:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),y=i.isLoading&&!!r,A=t!==void 0&&r===null;a.useEffect(()=>{y&&(c.current=performance.now())},[y]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,n]);const M=i.data&&r?{kind:r.kind,body:i.data}:void 0;return{picked:r,data:M,isLoading:y,hasNoRenderablePart:A,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,ee as a,ce as b,Y as c,te as d,ne as e,oe as f,re as g,ae as h,K as i,I as o,se as u};
1
+ import{r as a,u as P,cp as O,cq as U,cQ as B,aa as p,cr as N,q as $,ac as D,h as F,c as L,cR as _,cF as v}from"./index-D4MtLdrW.js";const E="/mail/brief/compose/{-$outboxMessageId}",w="/mail/flagged/compose/{-$outboxMessageId}",R="/mail/outbox/compose/{-$outboxMessageId}",S="/mail/$mailboxId/compose/{-$outboxMessageId}";function T(){const e=p({from:E,shouldThrow:!1}),t=p({from:w,shouldThrow:!1}),s=p({from:R,shouldThrow:!1}),r=p({from:S,shouldThrow:!1});return e??t??s??r}function ee(){return T()!==void 0}function te(){return T()?.outboxMessageId}function q(e,t,s){return e==="flagged"?{to:w,params:{outboxMessageId:s}}:e==="outbox"?{to:R,params:{outboxMessageId:s}}:e==="mailbox"&&t?{to:S,params:{mailboxId:t,outboxMessageId:s}}:{to:E,params:{outboxMessageId:s}}}function b(){const e=P(),t=O(),{list:s,mailboxId:r}=U();return a.useCallback((n,o)=>{e({...q(s,r,n),search:B,hash:o?.keepPanels?!0:t,replace:o?.replace??!1})},[e,t,s,r])}function se(){const e=b();return a.useCallback(()=>e(void 0),[e])}function re(){const e=b();return a.useCallback(t=>e(t),[e])}function ne(){const e=b();return a.useCallback(t=>e(t,{replace:!0,keepPanels:!0}),[e])}function oe(){return N()}const Q=new Set(["rfc822","global"]),K=e=>e.mediaType.toUpperCase()==="MESSAGE"&&Q.has(e.mediaSubtype.toLowerCase()),k=(e,t)=>e.partPath.startsWith(`${t}.`),I=e=>{const t=e.filter(K);return e.filter(s=>!t.some(r=>k(s,r.partPath)))},ae=(e,t)=>e.filter(s=>k(s,t)),G=e=>{const t=I(e).filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},g={all:["messages"],detail:e=>[...g.all,"detail",e],body:e=>[...g.detail(e),"body"]};class f extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const W=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},X=8,H="x-remit-403-reason",Y=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},z=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,j=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},J=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await v(e,{headers:r});if(o.status===202)throw new f("not-ready","Message body is still syncing",202,W(o.headers.get("Retry-After")));if(!o.ok){const l=o.headers.get(H),m=Y(o.status,l);throw new f(m,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(j(t,c))throw new f("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const h=await o.text();if(z(h,c))throw new f("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return h},V=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),ce=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?G(t):null,n=$(),{getToken:o}=D(),c=a.useRef(null),h=F(),l=a.useRef(!1),m=a.useRef(null),C=e&&r?`${e}:${r.contentUrl}`:null;m.current!==C&&(m.current=C,l.current=!1);const i=L({queryKey:e?[...g.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const d=l.current;return l.current=!1,V({fetchContent:(u,x)=>J(u,x,o),refetchDescribeMessage:()=>h.refetchQueries({queryKey:_({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:d})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(d,u)=>u instanceof f&&u.reason==="not-ready"?d<X:d<1,retryDelay:(d,u)=>u instanceof f&&u.reason==="not-ready"?(l.current=!0,(u.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),y=i.isLoading&&!!r,A=t!==void 0&&r===null;a.useEffect(()=>{y&&(c.current=performance.now())},[y]),a.useEffect(()=>{i.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[i.isSuccess,n]);const M=i.data&&r?{kind:r.kind,body:i.data}:void 0;return{picked:r,data:M,isLoading:y,hasNoRenderablePart:A,isError:i.isError,error:i.error,refetch:i.refetch}};export{f as B,ee as a,ce as b,Y as c,te as d,ne as e,oe as f,re as g,ae as h,K as i,I as o,se as u};
@@ -1 +1 @@
1
- import{c5 as Q,c6 as y,c7 as S,c8 as w,c9 as C,h as k,ca as q,cb as x,r as p,cc as M,cd as H,ce as L,cf as P,cg as O,ch as B,ci as A}from"./index-cubACEd8.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&O(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
1
+ import{c5 as Q,c6 as y,c7 as S,c8 as w,c9 as C,h as k,ca as q,cb as x,r as p,cc as M,cd as H,ce as L,cf as P,cg as O,ch as B,ci as A}from"./index-D4MtLdrW.js";function R(r,e){const s=new Set(e);return r.filter(t=>!s.has(t))}function T(r,e,s){const t=r.slice(0);return t[e]=s,t}var z=class extends Q{#i;#e;#n;#r;#s;#t;#o;#u;#h;#c=[];constructor(r,e,s){super(),this.#i=r,this.#r=s,this.#n=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(r=>{r.subscribe(e=>{this.#d(r,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(r=>{r.destroy()})}setQueries(r,e){this.#n=r,this.#r=e,y.batch(()=>{const s=this.#s,t=this.#f(this.#n);t.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const i=t.map(o=>o.observer),n=i.map(o=>o.getCurrentResult()),u=s.length!==i.length,a=i.some((o,d)=>o!==s[d]),f=u||a,b=f?!0:n.some((o,d)=>{const g=this.#e[d];return!g||!S(o,g)});!f&&!b||(f&&(this.#c=t,this.#s=i),this.#e=n,this.hasListeners()&&(f&&(R(s,i).forEach(o=>{o.destroy()}),R(i,s).forEach(o=>{o.subscribe(d=>{this.#d(o,d)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(r=>r.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(r,e){const s=this.#f(r),t=s.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=s.map(n=>n.defaultedQueryOptions.queryHash);return[t,n=>this.#l(n??t,e,i),()=>this.#a(t,s)]}#a(r,e){return e.map((s,t)=>{const i=r[t];return s.defaultedQueryOptions.notifyOnChangeProps?i:s.observer.trackResult(i,n=>{e.forEach(u=>{u.observer.trackProp(n)})})})}#l(r,e,s){if(e){const t=this.#h,i=s!==void 0&&t!==void 0&&(t.length!==s.length||s.some((n,u)=>n!==t[u]));return(!this.#t||this.#e!==this.#u||i||e!==this.#o)&&(this.#o=e,this.#u=this.#e,s!==void 0&&(this.#h=s),this.#t=w(this.#t,e(r))),this.#t}return r}#b(){return this.#r?.combine!==void 0&&this.#s.some((r,e)=>r.options.suspense&&this.#e[e]?.data===void 0)}#f(r){const e=new Map;this.#s.forEach(t=>{const i=t.options.queryHash;if(!i)return;const n=e.get(i);n?n.push(t):e.set(i,[t])});const s=[];return r.forEach(t=>{const i=this.#i.defaultQueryOptions(t),u=e.get(i.queryHash)?.shift()??new C(this.#i,i);s.push({defaultedQueryOptions:i,observer:u})}),s}#d(r,e){const s=this.#s.indexOf(r);s!==-1&&(this.#e=T(this.#e,s,e),this.#p())}#p(){if(this.hasListeners()){const r=this.#a(this.#e,this.#c),e=this.#b(),s=this.#t,t=e?s:this.#l(r,this.#r?.combine);(e||s!==t)&&y.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function U({queries:r,...e},s){const t=k(),i=q(),n=x(),u=p.useMemo(()=>r.map(h=>{const c=t.defaultQueryOptions(h);return c._optimisticResults=i?"isRestoring":"optimistic",c}),[r,t,i]);u.forEach(h=>{M(h);const c=t.getQueryCache().get(h.queryHash);H(h,n,c)}),L(n);const[a]=p.useState(()=>new z(t,u,e)),[f,b,o]=a.getOptimisticResult(u,e.combine),d=!i&&e.subscribed!==!1;p.useSyncExternalStore(p.useCallback(h=>d?a.subscribe(y.batchCalls(h)):P,[a,d]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setQueries(u,e)},[u,e,a]);const m=f.some((h,c)=>O(u[c],h))?f.flatMap((h,c)=>{const l=u[c];if(l&&O(l,h)){const E=new C(t,l);return B(l,E,n)}return[]}):[];if(m.length>0)throw Promise.all(m);const v=f.find((h,c)=>{const l=u[c];return l&&A({result:h,errorResetBoundary:n,throwOnError:l.throwOnError,query:t.getQueryCache().get(l.queryHash),suspense:l.suspense})});if(v?.error)throw v.error;return b(o())}export{U as u};
@@ -0,0 +1 @@
1
+ import{j as E,a1 as K,t as U,f as Q,h as N,G,r as o,aU as R,K as $,M as z,q as B,R as I,S as X,T as V,U as J}from"./index-D4MtLdrW.js";import{C as Y}from"./circle-check-big-DbaQY2vy.js";import{R as Z}from"./refresh-cw-CDQ2xZbt.js";import{u as L}from"./useQueries-ktaWu7Pv.js";function ye({state:e,onRefresh:s,label:t,errorMessage:n,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",r=e==="error",h=e==="success",S=r?E.jsx(K,{className:"size-4 text-danger"}):h?E.jsx(Y,{className:"size-4 text-positive"}):E.jsx(Z,{className:U("size-4",i&&"animate-spin")}),w=r?`${t} — failed: ${n??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(Q,{variant:"ghost",size:u,icon:S,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:r?n:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const ee=180*1e3,we=30*1e3;let P=0;const M=new Set,te=(e=Date.now())=>{P=e+ee;for(const s of M)s()},xe=(e=Date.now())=>e<P,pe=e=>(M.add(e),()=>{M.delete(e)}),T=6e4,se=new Set(["sent","drafts","trash","archive"]),_=(e,s)=>{const t=new Map;for(const n of e){const a=s.get(n.mailboxId)?.role;a&&se.has(a)||t.set(n.mailboxId,n.highWaterMarkUid)}return t},q=(e,s)=>{const t=[];for(const[n,a]of s)a>(e.get(n)??0)&&t.push(n);return t},re=(e,s)=>q(e,s).length>0,F=o.createContext(null),ne=()=>{const e=o.useContext(F);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function Ee({accountIds:e,children:s}){const t=N(),{resultFolderIndex:n}=G(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,r]=o.useState(new Set),h=L({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:T,staleTime:T,meta:{softError:!0}}))}),S=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=_(b.mailboxes??[],n),v=c.current.get(d);if(c.current.set(d,g),v){const A=q(v,g);A.length>0&&$(t,z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const W=a.current.get(d)??new Map;re(W,g)&&(f.add(d),l=!0)}),l&&r(f)},[w,S]);const y=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{r(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,_(d?.mailboxes??[],n)),u.current.add(f)}},[t,n]),m=o.useMemo(()=>({hasNewMail:y,acknowledge:x}),[y,x]);return E.jsx(F.Provider,{value:m,children:s})}const oe=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function j(e){return!!e&&oe.has(e)}const D=3e3,ae=D*2,C={syncing:!1,resolved:!1,synced:0,total:0};function be(e,s){const t=e.join(","),[n,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),ae);return()=>clearTimeout(m)},[t,s]);const i=L({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!n,refetchInterval:D,meta:{softError:!0}}))}),r=i.every(m=>m.isSuccess||m.isError),h=i.length===0||r||u;let S=!1,w=0,y=0;for(const m of i)if(j(m.data?.syncPhase)){S=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,y+=l.messagesTotal}const x=s&&h&&!S;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?C:{syncing:S,resolved:!0,synced:w,total:y}}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),k=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{V(e,{softError:!0},"user")&&J(e)},O=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:n=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const r=await s().then(y=>({ok:!0,data:y})).catch(y=>({ok:!1,error:y}));if(!r.ok)return{accountId:e,message:k(r.error)};const{syncPhase:h,lastSyncAt:S}=r.data;if((S??0)>t&&!j(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(r.data)>n&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,n,a)=>{const u=await O(e,t).then(r=>({ok:!0,lastSyncAt:r.lastSyncAt??0,inboxSyncedAt:H(r)})).catch(r=>({ok:!1,error:r}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:k(u.error)};const c=await I({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(r=>({ok:!1,error:r}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:k(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>O(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:n});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Re=(e,s={})=>{const t=N(),n=B(),{acknowledge:a}=ne(),[u,c]=o.useState("idle"),[i,r]=o.useState(),h=o.useRef(0),S=o.useRef(e);S.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const y=o.useCallback(()=>{const x=S.current;if(x.length===0){c("error"),r("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),r(void 0),te();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:X({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,n,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),r(b[0]?.message))})()},[a,t,n]);return{state:u,errorMessage:i,refresh:y}};export{we as H,Ee as M,ye as R,Re as a,j as b,be as c,xe as i,pe as s,ne as u};
@@ -1 +1 @@
1
- import{N as r,r as s,bZ as t}from"./index-cubACEd8.js";import{u as m}from"./useQueries-BgVJvl8E.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
1
+ import{N as r,r as s,bZ as t}from"./index-D4MtLdrW.js";import{u as m}from"./useQueries-ktaWu7Pv.js";const a=i=>({items:i.map(e=>e.data?.items??[]),isPending:i.some(e=>e.isPending),error:i.find(e=>e.error)?.error??null});function u(i){const e=m({queries:i.map(o=>({...r({path:{accountId:o.accountId}}),staleTime:1/0})),combine:a});return{index:s.useMemo(()=>t(i.map((o,n)=>({folderAppointments:o.folderAppointments,mailboxes:e.items[n]??[]}))),[i,e]),isPending:e.isPending,error:e.error}}export{u};
@@ -1 +1 @@
1
- import{h as g,au as p,c as f,d as m,r,i as y,aw as T,o as E,l as d}from"./index-cubACEd8.js";const i={html:"",plainText:""},x=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...d(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{x as u};
1
+ import{h as g,au as p,c as f,d as m,r,i as y,aw as T,o as E,l as d}from"./index-D4MtLdrW.js";const i={html:"",plainText:""},x=e=>{const u=g(),{pushError:o}=p(),{data:n}=f({...m(),staleTime:1/0}),l=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(a=>a.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),s=y({...d(),onSuccess:()=>{u.invalidateQueries({queryKey:E()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),c=r.useCallback((t,a)=>{e&&s.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:a}})},[e,s]);return{signature:l,setSignature:c,isSaving:s.isPending}};export{x as u};
@@ -1,4 +1,4 @@
1
- import{j as s,aN as v,f as d,aX as _,g as j,bu as N,bs as y,B as E,as as $,bL as C,bV as f,bW as A,bX as M,c as k,d as P,r as l,bY as W,aI as p,aJ as x,u as z,aQ as O,aS as L}from"./index-cubACEd8.js";import{S as q}from"./settings-screen-a-xqubF0.js";import{f as B}from"./ErrorState-C-GqtxHT.js";import{C as D}from"./copy-Ctmrzdfp.js";import{E as U}from"./external-link-Dhni3Eg5.js";import{B as h}from"./bug-BckO5YCO.js";import{C as S}from"./circle-check-BZo2PeBJ.js";import{S as F}from"./SignInAgain-DH1Fdj-N.js";import{u as G}from"./useResultFolderIndex-q07DaZO-.js";import{w as H}from"./help-copy-CdYqiDpm.js";import"./avatar-ByFhyZLr.js";import"./chevron-left-SkeGnPD1.js";import"./menu-BkQ4G0tI.js";import"./circle-help-QkeLuDiC.js";import"./useQueries-BgVJvl8E.js";import"./kbd-C6M51ovo.js";function Q({report:e,onClose:t,issueUrl:a,onCopy:n}){return e===null?null:s.jsx(v,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(D,{className:"size-3.5"}),onClick:()=>n(e),children:"Copy report"}),s.jsx(_,{external:!0,size:"sm",href:a,icon:s.jsx(U,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,T=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function J(e){const t=R(e);return T.test(t)?t:JSON.stringify(t)}const g="_not read_";function Z(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${J(t.contentType)}`)}const X="_No message content, addresses, subject, attachment names or parser output are included._";function I(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),T)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
1
+ import{j as s,aN as v,f as d,aX as _,g as j,bu as N,bs as y,B as E,as as $,bL as C,bV as f,bW as A,bX as M,c as k,d as P,r as l,bY as W,aI as p,aJ as x,u as z,aQ as O,aS as L}from"./index-D4MtLdrW.js";import{S as q}from"./settings-screen-DIq3lhTN.js";import{f as B}from"./ErrorState-U7sVw9dY.js";import{C as D}from"./copy-BOxB39My.js";import{E as U}from"./external-link-8knc6nvP.js";import{B as h}from"./bug-DvYTwFLF.js";import{C as S}from"./circle-check-lnLFo0FD.js";import{S as F}from"./SignInAgain-PV_y3RtI.js";import{u as G}from"./useResultFolderIndex-CkQexziN.js";import{w as H}from"./help-copy-S6Ri4ByH.js";import"./avatar-DPq_EAZk.js";import"./chevron-left-BVg2BJhm.js";import"./menu-hJvWIs1N.js";import"./circle-help-B6vmvmbF.js";import"./useQueries-ktaWu7Pv.js";import"./kbd-B6fJcnhn.js";function Q({report:e,onClose:t,issueUrl:a,onCopy:n}){return e===null?null:s.jsx(v,{open:!0,onClose:t,title:"Report this message",children:s.jsxs("div",{className:"flex max-h-[80vh] flex-col",children:[s.jsxs("header",{className:"space-y-1 border-b border-line px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg",children:"Report this message"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"This is everything the report contains. It describes what went wrong with the message — never its contents, addresses, subject, attachment names, folder name, or the parser's own error text."})]}),s.jsx("pre",{className:"flex-1 overflow-auto bg-surface-sunken px-4 py-3 text-2xs leading-relaxed whitespace-pre-wrap text-fg-muted",children:e}),s.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-line px-4 py-3",children:[s.jsx(d,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),s.jsx(d,{variant:"secondary",size:"sm",icon:s.jsx(D,{className:"size-3.5"}),onClick:()=>n(e),children:"Copy report"}),s.jsx(_,{external:!0,size:"sm",href:a,icon:s.jsx(U,{className:"size-3.5"}),children:"Open on GitHub"})]})]})})}const V={BodyParse:"The message is built in a way Remit could not read."};function Y(e){return V[e]}function R(e){return e.split(";")[0].trim()}const b=/^[A-Za-z0-9!#$%&'*+._-]+$/,T=/^[A-Za-z0-9!#$%&'*+._-]+\/[A-Za-z0-9!#$%&'*+._-]+$/;function m(e,t){return t.test(e)?`\`${e}\``:`\`${JSON.stringify(e).replace(/`/g,"\\u0060")}\` (malformed)`}function J(e){const t=R(e);return T.test(t)?t:JSON.stringify(t)}const g="_not read_";function Z(e){return e.length===0?["(no MIME structure was read)"]:e.map(t=>`${" ".repeat(t.depth)}- ${J(t.contentType)}`)}const X="_No message content, addresses, subject, attachment names or parser output are included._";function I(e){return{head:[`### Message quarantined at \`${e.failureStage}\``,"",`- **Failure**: \`${e.failureCode}\``,`- **Folder role**: ${e.mailboxRole??"_none appointed_"}`,`- **Failing part**: ${e.failurePartPath==null?"_whole message_":`\`${e.failurePartPath}\``}`,`- **Attempts before quarantine**: ${e.attempts}`,`- **Worker build**: ${e.workerVersion}`,`- **Message-ID hash**: ${e.messageIdHash==null?"_none declared_":`\`${e.messageIdHash}\``}`,"","#### Message shape","",`- **Content-Type**: ${e.contentType==null?g:m(R(e.contentType),T)}`,`- **Content-Transfer-Encoding**: ${e.transferEncoding==null?g:m(e.transferEncoding,b)}`,`- **Charset**: ${e.charset==null?"_not declared_":m(e.charset,b)}`,`- **Size**: ${e.sizeBytes==null?g:`${e.sizeBytes} bytes`}`,"","MIME structure:"].join(`
2
2
  `),structure:Z(e.structure).join(`
3
3
  `),disclaimer:X}}function K(e){const{head:t,structure:a,disclaimer:n}=I(e);return[t,"","```",a,"```","",n].join(`
4
4
  `)}function ee(e){return`Message quarantined: ${e.failureCode} at ${e.failureStage}`}function se(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function te({entry:e,onCutBug:t}){return s.jsxs("li",{className:"flex flex-col gap-2 border-b border-line px-row-inset py-3 last:border-b-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:"text-sm text-fg",children:Y(e.failureStage)}),s.jsx("p",{className:"truncate text-xs text-fg-muted",title:e.failureMessage,children:e.failureMessage}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-subtle",children:[e.mailboxRole&&s.jsx(j,{tone:"warning",children:N(e.mailboxRole)}),s.jsx("span",{className:"truncate",title:e.mailboxPath,children:y(e.mailboxPath,e.mailboxDelimiter)}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`uid ${e.uid}`}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:se(e.quarantinedAt)}),e.attempts>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{children:`${e.attempts} attempts`})]})]})]}),s.jsx(d,{variant:"secondary",size:"sm",className:"shrink-0",icon:s.jsx(h,{className:"size-3.5"}),onClick:()=>t(e),children:"Cut a bug"})]})}function ae({entries:e,onCutBug:t}){return s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Messages set aside"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Mail Remit could not read is set aside here instead of being skipped, so nothing goes missing quietly. The rest of the folder keeps syncing. Recovering a set-aside message is a re-sync, not a per-row action."})]}),e.length===0&&s.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-line bg-surface px-row-inset py-3",children:[s.jsx(S,{className:"size-4 shrink-0 text-positive","aria-hidden":!0}),s.jsx("p",{className:"text-sm text-fg-muted",children:"Every message has been read successfully. Nothing is set aside."})]}),e.length>1&&s.jsx(E,{tone:"warning",children:s.jsxs("p",{className:"flex items-start gap-2",children:[s.jsx($,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold",children:`${e.length} messages could not be read.`})," ","More than one means something is wrong with how Remit reads mail, not with the mail. Reporting one of these gets it fixed."]})]})}),e.length>0&&s.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:e.map(a=>s.jsx(te,{entry:a,onCutBug:t},a.quarantineId))})]})}const ne={Retrying:"The message could not be synced. Remit tries again every sync.",GaveUp:"The message body could not be downloaded. Remit has stopped trying."};function re(e){return ne[e.state]}const ie="_No message content, addresses, subject, folder name or error text are included._";function oe(e){return[`### Message failed to sync at \`${e.stage}\``,"",`- **State**: \`${e.state}\``,`- **Attempts**: ${e.attempts}`,"",ie].join(`
package/index.html CHANGED
@@ -5,9 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
6
  <title>Remit</title>
7
7
  <!--
8
- Installability. Keep in sync with harness/index.html, which is the
9
- template the shipped image builds from: this one is the dev server's.
10
- The two theme colours are the light and dark --canvas tokens from
8
+ Installability. The preset serves this page for every host. The two theme colours are the light and dark --canvas tokens from
11
9
  packages/ui/src/tokens.css.
12
10
  -->
13
11
  <link rel="manifest" href="/manifest.webmanifest" />
@@ -22,8 +20,7 @@
22
20
  <!--
23
21
  Pre-paint theme to avoid a flash-of-wrong-theme on reload. Mirrors
24
22
  theme-preference.ts: a stored "remit.theme" of "light"/"dark" wins;
25
- "system" (or no key) follows prefers-color-scheme. Keep this in sync
26
- with src/lib/theme-preference.ts (STORAGE_KEY / resolution logic).
23
+ "system" (or no key) follows prefers-color-scheme.
27
24
  -->
28
25
  <script>
29
26
  (function () {
@@ -38,17 +35,16 @@
38
35
  } catch (_) {}
39
36
  })();
40
37
  </script>
41
- <script type="module" crossorigin src="/assets/index-cubACEd8.js"></script>
38
+ <script type="module" crossorigin src="/assets/index-D4MtLdrW.js"></script>
42
39
  <link rel="stylesheet" crossorigin href="/assets/index-C2Hz4y-Q.css">
43
40
  </head>
44
41
  <body>
45
42
  <div id="root"></div>
46
43
  <!--
47
44
  Runtime deployment config. A classic (non-module) script so it runs before
48
- the deferred module bundle: it sets window.__REMIT_CONFIG__, which
49
- src/runtime-config.ts reads. Served as a static default in the built dist
50
- and replaced per deployment; never bundled, so one build serves every
51
- deployment.
45
+ the deferred module bundle: it sets window.__REMIT_CONFIG__, read by the
46
+ runtime-config primitive. Served from the distributor's public dir and
47
+ replaced per deployment; never bundled.
52
48
  -->
53
49
  <script src="/config.js"></script>
54
50
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client-dist",
3
- "version": "0.0.671",
3
+ "version": "0.0.672",
4
4
  "description": "Built Remit web client — static assets and the default runtime config.",
5
5
  "files": [
6
6
  "**/*"
@@ -11,6 +11,6 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/remit-mail/reader.git"
14
+ "url": "git+https://github.com/remit-mail/reader-ui.git"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@ Engine
10
10
  sha256: 433274dac0619cb00c2e18b43a3dd3a9d50da5b5613fa9b5c21781e35dd76bc1
11
11
  Licence: MPL-1.1 (the option taken from Hunspell's MPL-1.1/GPL-2.0/LGPL-2.1 triple)
12
12
  Licence text: LICENSE, beside this file
13
- Build recipe: docker/hunspell/build.sh
13
+ Build recipe: https://github.com/remit-mail/reader/blob/main/docker/hunspell/build.sh
14
14
 
15
15
  Dictionaries
16
16
 
@@ -4,7 +4,7 @@
4
4
  "version": "1.7.3",
5
5
  "licence": "MPL-1.1",
6
6
  "source": "https://github.com/hunspell/hunspell",
7
- "recipe": "docker/hunspell/build.sh",
7
+ "recipe": "https://github.com/remit-mail/reader/blob/main/docker/hunspell/build.sh",
8
8
  "bytes": 644566
9
9
  },
10
10
  "languages": [
@@ -1 +0,0 @@
1
- import{j as r,L as Mt,e$ as Ue,f0 as ne,ec as re,r as a,c as Ke,G as ie,bm as jt,cX as kt,N as Et,e3 as Ot,f1 as Ft,f2 as At,a1 as $e,ew as Nt,f3 as Bt,al as Lt,d7 as qt,d8 as Dt}from"./index-cubACEd8.js";import{g as Ye,e as Pt,f as Ve,u as _t,p as Qt,R as zt}from"./useSearchTokenContext-PpLW_UHw.js";import{a7 as Wt,z as Ht,B as Gt,an as Ut,ao as Kt,ap as $t,aq as De,ar as Yt,as as Vt,at as Jt,au as Zt,av as Xt,ai as es,M as ts,aw as ss,aj as os,ax as ns,ay as rs,d as as,o as is,al as cs,l as ls,S as ds,I as us,N as Pe,L as fs,J as ms,b as hs,X as gs,Y as xe,Z as ps,$ as Je,a0 as Ze,a1 as xs,a2 as Is,a3 as ys}from"./MailListHeader-CRcUWHvS.js";import{S as vs,u as bs}from"./useLayoutTier-Cme1U69S.js";import{u as Ss,a as Ts,R as Cs,b as ws,c as Rs}from"./useRefreshControl-DPzIiFlp.js";import{u as ae}from"./useQueries-BgVJvl8E.js";import{t as Xe,s as Ms,r as js,L as ks}from"./result-count-BTXdc_1e.js";import{a as Es}from"./useLabels-BZ4I9RAK.js";import{d as Os,w as Fs}from"./wizard-selection-zWa1qc6-.js";import{m as As,e as Ns,f as Bs}from"./search-token-index-DnVW2A-U.js";import{u as et}from"./sections-CI8sUA-m.js";import{R as Ls}from"./refresh-cw-CuDrOkmw.js";import{a as qs}from"./useMessageBodyContent-oSPoCcAo.js";function Ds({sync:e}){return e?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",role:"status","aria-live":"polite",children:[r.jsx(Mt,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:Ps(e)})]}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[r.jsx(vs,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),r.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),r.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Ps({synced:e,total:t}){return t>0?`${e.toLocaleString()} of ${t.toLocaleString()} messages downloaded. This list fills in as they arrive.`:"Downloading your messages. This list fills in as they arrive."}const tt=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],st="category",_s={unclassified:"uncategorized"},H=e=>Pt(e).map(t=>t.raw),W=e=>e.join(" "),Ie=e=>{const t=Ve(e);if(t)return tt.find(s=>s.name===t.name&&s.value===t.value.toLowerCase())?.id},ye=e=>{const t=Ve(e);if(!t||t.name!==st)return;const s=t.value.toLowerCase(),n=_s[s];if(n)return n;if(!(!Ue(s)||s==="all"))return s},ot=e=>tt.find(t=>t.id===e),nt=e=>ot(e)!==void 0,Qs=e=>{const t=new Set;for(const s of H(e)){const n=Ie(s);n&&t.add(n)}return t},zs=e=>{let t="all";for(const s of H(e)){const n=ye(s);n&&(t=n)}return t},Ws=(e,t)=>{const s=ot(t);if(!s)return;const n=H(e),i=n.filter(d=>Ie(d)!==t);return i.length<n.length?W(i):W([...n,Ye(s.name,s.value)])},Hs=(e,t)=>{const s=H(e).filter(n=>!ye(n));return W(t==="all"?s:[...s,Ye(st,t)])},Gs=e=>W(H(e).filter(t=>!Ie(t)&&!ye(t))),rt=e=>e.trim().length>0,_e=e=>{if(!rt(e.query))return e.ownFilters;const t=new Set(Qs(e.query));for(const s of e.ownFilters)nt(s)||t.add(s);return t},Qe=e=>rt(e.query)?zs(e.query):e.ownCategory,ze=6e4,Us=3e4,Ks={kind:"unknown"},We=e=>(t,s)=>Wt(s?.queryKey,e)?t:void 0,$s=(e,t,s)=>({...e,category:[t],limit:s,order:"desc"}),Ys=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),He=(e,t)=>({category:[t],...e.unread!==void 0?{unread:e.unread}:{},...e.starred!==void 0?{starred:e.starred}:{},...e.attachments!==void 0?{attachments:e.attachments}:{},...e.accountId!==void 0?{accountId:e.accountId}:{},...e.muted!==void 0?{muted:e.muted}:{}});function Vs({categories:e,criteria:t,limit:s,counted:n}){const i=ae({queries:e.map(c=>{const h=$s(t,c,s),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},placeholderData:We(u),staleTime:ze}})}),d=ae({queries:e.map(c=>{const h=Ys(t,c),u=He(t,c);return{queryKey:re({query:h}),queryFn:async()=>{const{data:v}=await ne({query:h,throwOnError:!0});return v},enabled:n,placeholderData:We(u),staleTime:ze}})}),m=a.useMemo(()=>e.map((c,h)=>{const u=i[h],v=d[h],p=u?.data?.items??[];return{category:c,rows:p,atCap:p.length>=s,total:n?Xe(v?.data?.count):Ks,loading:u?.isPending??!0,failed:u?.isError??!1,retry:()=>{u?.refetch(),n&&v?.refetch()}}}),[e,i,d,n,s]),l=a.useCallback(()=>{for(const c of i)c.refetch();for(const c of d)c.refetch()},[i,d]);return{sections:m,isLoading:i.length>0&&i.every(c=>c.isPending),isError:i.length>0&&i.every(c=>c.isError),refetch:l}}function Js(e,t,s){const n={...e,limit:t,order:"desc"},{data:i,isLoading:d,isError:m,refetch:l}=Ke({queryKey:re({query:n}),queryFn:async()=>{const{data:h}=await ne({query:n,throwOnError:!0});return h},enabled:s,staleTime:Us});return{rows:a.useMemo(()=>s?i?.items??[]:[],[i,s]),isLoading:s&&d,isError:s&&m,refetch:a.useCallback(()=>{l()},[l])}}const Zs=3e4,Xs={kind:"unknown"},eo=(e,t)=>({...e,mailboxId:t,order:"desc",count:!0,results:!1});function to({criteria:e,junkMailboxIds:t,enabled:s}){const n=ae({queries:t.map(i=>{const d=eo(e,i);return{queryKey:re({query:d}),queryFn:async()=>{const{data:m}=await ne({query:d,throwOnError:!0});return m},enabled:s,staleTime:Zs}})});return a.useMemo(()=>t.map((i,d)=>({mailboxId:i,count:s?Xe(n[d]?.data?.count):Xs,failed:s?n[d]?.isError??!1:!1})),[t,n,s])}const so=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),oo=e=>[...e].sort(so),no=["from","subject","category","unread","starred","attachments"],at=["contacts","today"],ro=e=>new Set(at.filter(t=>e.has(t))),ao=(e,t,s,n)=>{const i=Ht({category:e,attributes:t}),{params:d,residual:m}=Gt(s,i,no),l={...d,...i},c={muted:!1};return l.from!==void 0&&(c.from=l.from),l.subject!==void 0&&(c.subject=l.subject),l.unread!==void 0&&(c.unread=l.unread),l.starred!==void 0&&(c.starred=l.starred),l.attachments!==void 0&&(c.attachments=l.attachments),n!==void 0&&(c.accountId=n),{criteria:c,residual:m}},io=({residual:e,attributes:t})=>e.length===0&&!at.some(s=>t.has(s)),se=e=>e.count.kind==="exact"&&e.count.value>0?3:e.pageRows>0?2:e.count.kind==="unknown"?1:0,oe=e=>e.count.kind==="exact"?e.count.value:0,co=(e,t)=>se(e)!==se(t)?se(e)>se(t):oe(e)!==oe(t)?oe(e)>oe(t):e.pageRows>t.pageRows;function lo(e,{pageRowsByMailbox:t}){const s=e.map(u=>({...u,pageRows:t.get(u.mailboxId)??0}));for(const[u,v]of t)v<=0||s.some(p=>p.mailboxId===u)||s.push({mailboxId:u,count:{kind:"unknown"},failed:!1,pageRows:v});const n=s[0];if(!n)return;let i=0,d=!0,m=n;for(const u of s)u.count.kind==="unknown"?d=!1:i+=u.count.value,co(u,m)&&(m=u);const l=s.some(u=>u.pageRows>0),c=s.some(u=>u.failed);if(i===0&&!l&&(d||!c))return;const h=d&&i===0&&l;return{mailboxId:m.mailboxId,count:d&&!h?{kind:"exact",value:i}:{kind:"unknown"}}}const uo=50,fo=200,mo=[],Ge=()=>r.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>r.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[r.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsxs("div",{className:"flex justify-between gap-2",children:[r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),r.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),r.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),ho=({accountEmail:e})=>{const t=et();return r.jsxs("div",{className:"flex items-center gap-2 px-row-inset py-2 border-b border-line bg-danger-soft/40 text-xs text-danger",children:[r.jsx($e,{className:"size-3.5 shrink-0"}),r.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),r.jsx("button",{type:"button",onClick:()=>t("accounts"),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},go=(e,t)=>{if(t.size===0)return{};const s=e.filter(d=>t.has(d.id)),n=js(s.map(d=>d.accountId));if(n.restriction)return n;const i=new Set;for(const d of s)d.mailboxId&&i.add(d.mailboxId);return i.size>1?{accountId:n.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${i.size} folders`}:{accountId:n.accountId,mailboxId:i.size===1?[...i][0]:void 0}};function po({header:e,rows:t,wizard:s,children:n}){const{selectedIds:i,selectedCount:d,exitSelection:m,orderedIds:l,allSelected:c,toggleAllLoaded:h}=rs(),u=a.useMemo(()=>go(t,i),[t,i]),{junkMailboxId:v}=as(u.accountId),{labels:p}=Es(u.accountId),b=a.useMemo(()=>Array.from(i),[i]),L=a.useMemo(()=>Fs(t,i),[t,i]),x=is(v,u.mailboxId),S=a.useMemo(()=>l.length>0?{checked:c,indeterminate:d>0&&!c,onChange:h}:void 0,[l.length,c,d,h]),A=u.moveDisabledHint?{tone:"warning",text:u.moveDisabledHint}:void 0,T=R=>r.jsx(ds,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:m,onDelete:()=>s.start("delete"),onMove:()=>s.start("move"),onOrganize:()=>s.start("organize"),onJunk:x?()=>s.start("junk"):void 0,onMarkRead:()=>s.start("markRead"),overflowSlot:u.accountId&&u.mailboxId&&d>0&&p.length>0?r.jsx(ks,{accountId:u.accountId,mailboxId:u.mailboxId,messageIds:b}):void 0,selectAll:S,notice:A});return r.jsx(cs,{...e,selectionBar:T,paneOverlay:r.jsx(ls,{verb:s.verb,accountId:u.accountId,mailboxId:u.mailboxId,selection:L,selectionRestriction:u.restriction,onFinished:m}),children:n})}function xo({accounts:e,selectedMessageId:t,onOpenThread:s,commandsRef:n,onTriageContextChange:i,onDeleteMessages:d}){const{searchQuery:m,searchInput:l,resultFolderIndex:c,onSearchChange:h}=ie(),u=_t(),v=jt(),p=bs(),b=kt(),L=As(),x=a.useMemo(()=>oo(e.filter(o=>!o.muted?.value)),[e]),[S,A]=a.useState("all"),[T,R]=a.useState("all"),[N,q]=a.useState(new Set),[le,M]=a.useState(!1),D=a.useCallback(o=>{q(f=>{const g=new Set(f);return g.has(o)?g.delete(o):g.add(o),g})},[]),G=a.useCallback(()=>q(new Set),[]),E=l.trim().length>0,{freeText:w,tokens:P}=Qt(m.trim().toLowerCase(),u),y=w.length>0,_=a.useMemo(()=>_e({query:l,ownFilters:N}),[l,N]),Q=a.useMemo(()=>Qe({query:l,ownCategory:T}),[l,T]),F=a.useMemo(()=>_e({query:m,ownFilters:N}),[m,N]),C=a.useMemo(()=>Qe({query:m,ownCategory:T}),[m,T]),I=a.useCallback(o=>{if(!E||!nt(o)){D(o);return}const f=Ws(l,o);f!==void 0&&h(f)},[E,l,h,D]),j=a.useCallback(o=>{if(!E){R(o);return}h(Hs(l,o))},[E,l,h]),de=a.useMemo(()=>C==="all"&&!y?o=>{Ue(o)&&j(o)}:void 0,[C,y,j]),ue=a.useCallback(()=>{R("all"),A("all"),G(),E&&h(Gs(l))},[E,l,h,G]),U=ae({queries:x.map(o=>({...Et({path:{accountId:o.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),K=a.useMemo(()=>{const o=new Map;for(let f=0;f<x.length;f++){const g=x[f].accountId,te=(U[f]?.data?.items??[]).reduce((O,Rt)=>O+(Rt.unseenCount??0),0);o.set(g,te)}return o},[x,U]),lt=a.useMemo(()=>x.filter((o,f)=>{const g=U[f];return g?.isError?!Ot(g.error):!1}),[x,U]),{criteria:fe,residual:$}=a.useMemo(()=>ao(C,F,P,S==="all"?void 0:S),[C,F,P,S]),dt=a.useMemo(()=>C==="all"?[...Ut]:[C],[C]),ve=a.useMemo(()=>({...fe,query:w,...C==="all"?{}:{category:[C]}}),[fe,w,C]),be=io({residual:$,attributes:F}),{sections:Y,isLoading:ut,isError:ft,refetch:Se}=Vs({categories:y?mo:dt,criteria:fe,limit:C==="all"?ns:uo,counted:be}),{rows:Te,isLoading:mt,isError:ht,refetch:Ce}=Js(ve,fo,y),me=y?mt:ut,we=y?ht:ft,Re=a.useCallback(()=>{if(y){Ce();return}Se()},[y,Ce,Se]),Me=a.useMemo(()=>ro(F),[F]),V=a.useCallback(o=>Os(o).map(Kt).filter(f=>Ft(f,Me)&&$t(f,$)),[Me,$]),J=a.useMemo(()=>Y.map(o=>({category:o.category,total:o.total,atCap:o.atCap,loading:o.loading,failed:o.failed,rows:V(o.rows)})),[Y,V]),Z=a.useMemo(()=>V(Te),[Te,V]),gt=a.useCallback(o=>{Y.find(f=>f.category===o)?.retry()},[Y]),k=a.useMemo(()=>y?Z:J.flatMap(o=>o.rows),[y,Z,J]),pt=a.useMemo(()=>At(c),[c]),je=to({criteria:ve,junkMailboxIds:pt,enabled:be&&Ms({hasSearchQuery:y,freeText:w,residualTokenCount:$.length})}),{spamIds:he,briefSpamOffer:X}=a.useMemo(()=>{const o={spamIds:void 0,briefSpamOffer:void 0};if(!w)return o;const f=k.map(O=>De(O,c)),{spam:g}=Yt(f),B=new Map;for(const O of g)O.mailboxId&&B.set(O.mailboxId,(B.get(O.mailboxId)??0)+1);const te=lo(je,{pageRowsByMailbox:B});return g.length===0&&!te?o:{spamIds:g.length>0?new Set(g.map(O=>O.id)):void 0,briefSpamOffer:te}},[k,w,c,je]),ke=a.useMemo(()=>{const o=f=>he===void 0?f:f.filter(g=>!he.has(g.id));return y?[{id:"matches",threads:o(Z)}]:Vt(J.map(f=>({...f,rows:o(f.rows)})))},[y,Z,J,he]),Ee=a.useCallback((o,f)=>{const g=k.find(B=>B.id===o)?.threadId;g&&s?.({threadId:g,messageId:o},f)},[k,s]),xt=a.useCallback(o=>{const f=o.threadId??k.find(g=>g.id===o.id)?.threadId;f&&s?.({threadId:f,messageId:o.id})},[k,s]),ge=a.useMemo(()=>x.length<=1?[]:[{id:"all",label:"All",active:S==="all"},...x.map(o=>({id:o.accountId,label:o.email.split("@")[0]??o.email,count:K.get(o.accountId),active:S===o.accountId}))],[x,K,S]),z=a.useMemo(()=>e.filter(o=>o.muted?.value).length,[e]),It=a.useMemo(()=>Array.from(K.values()).reduce((o,f)=>o+f,0),[K]),pe=a.useMemo(()=>x.map(o=>o.accountId),[x]),{hasNewMail:Oe}=Ss(),{state:Fe,errorMessage:Ae,refresh:Ne}=Ts(pe,{onSettled:()=>Re()}),yt=a.useMemo(()=>r.jsx(Cs,{state:Fe,onRefresh:Ne,label:"Refresh daily brief",errorMessage:Ae,hasUpdate:Oe(pe)}),[Fe,Ne,Ae,Oe,pe]),vt=a.useMemo(()=>k.map(o=>De(o,c)),[k,c]),bt=a.useMemo(()=>{const o=Jt(ge.map(f=>({id:f.id,label:f.label,count:f.count,active:f.active})));return{categories:o.categories,filters:o.filters,sources:o.sources,sourcesNote:z>0?`+${z} muted`:void 0,selectedCategory:Q,activeFilters:_,expanded:le,onExpandedChange:M,onSelectCategory:f=>j(f),onSelectSource:A,onToggleFilter:f=>I(f),onClear:ue}},[ge,z,Q,_,le,I,j,ue]),Be=ke.length===0&&S==="all"&&w.length===0&&P.length===0,St=a.useMemo(()=>x.map(o=>o.accountId),[x]),Tt=a.useMemo(()=>x.some(o=>ws(o.syncPhase)),[x]),ee=Rs(St,Be||Tt),Le=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(Ge,{}),r.jsx(Ge,{})]}),qe=!me&&!we&&!Be,Ct=Zt({tier:p,hasLiveInput:E,hasCommittedQuery:m.trim().length>0,bodyRendersCommittedResults:!0}),wt=qe?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[X&&r.jsx(Xt,{count:X.count,onScopeToSpam:()=>L(X.mailboxId,m)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(es,{sections:ke,briefCategory:Q,Row:ts,selectedThreadId:t,onSelectThread:Ee,onShowAllSection:de,onRetrySection:gt,flat:y,onSelectBriefCategory:j,sources:ge,sourcesNote:z>0?`+${z} muted`:void 0,onSelectSource:A,activeFilters:_,onToggleFilter:I,onClearFilters:ue})})]}):me?Le:we?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[r.jsx($e,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>Re(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Ls,{className:"size-3.5"}),"Try again"]})]}):ee.resolved?r.jsx(Ds,{sync:ee.syncing?{synced:ee.synced,total:ee.total}:void 0}):Le;return r.jsx(Nt,{hasSheet:qe&&!Ct,children:r.jsx(ss,{selectedMessageId:t,rows:k,onOpen:Ee,onDeleteMessages:d,onSelectionVerb:b.start,commandsRef:n,onTriageContextChange:i,children:r.jsx(po,{wizard:b,header:{title:"Daily brief",unreadCount:It,footer:v?r.jsx(os,{}):void 0,searchFilter:bt,searchResults:vt,searchLoading:me,onSelectSearchResult:xt,spamOffer:X,searchResultsInBody:!0,refreshControl:yt},rows:k,children:r.jsxs("div",{className:"flex h-full flex-col",children:[lt.map(o=>r.jsx(ho,{accountEmail:o.email,accountId:o.accountId},o.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:wt})]})})})})}const it=a.createContext(null);function ce(){const e=a.useContext(it);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function Io({thread:e,children:t}){const s=Ns(),n=Bs(),i=et(),{searchInput:d}=ie(),m=e?.threadId,l=e?.messageId,{data:c}=Ke({...Bt(),staleTime:6e4}),h=a.useMemo(()=>c?.items??[],[c]),u=a.useMemo(()=>{if(m)return h.find(I=>I.messageId===l)??h.find(I=>I.threadId===m)},[h,m,l]),v=us(m,l),p=u??v,b=l??p?.messageId,L=a.useMemo(()=>{if(m)return{threadId:m,mailboxId:p?.mailboxId??"",subject:p?.subject,messageId:b,authenticity:p?.authenticity}},[m,p,b]),x=a.useCallback((I,j)=>{s(I,{replace:j?.replace,query:d})},[s,d]),S=a.useCallback(I=>{b&&I.includes(b)&&n()},[b,n]),A=Pe({thread:p,isOpen:!0,onAfterOptimisticRemove:S}),T=fs(),{deleteMessages:R}=ms({mailboxId:p?.mailboxId??"",messages:h,onAfterOptimisticRemove:S}),{toggleReadFor:N}=hs({mailboxId:p?.mailboxId??"",messages:h}),q=T.focusedMessageId,M=a.useMemo(()=>h.find(I=>I.messageId===q),[h,q])??p,D=Pe({thread:M,isOpen:M?.messageId===b}),G=qs(),E=Lt(),w=qt(),P=a.useMemo(()=>Dt(w,m,b),[w,m,b]),y=a.useMemo(()=>{if(M)return I=>w({threadId:M.threadId,messageId:M.messageId,mode:I})},[w,M]),{nextMessageId:_,previousMessageId:Q}=gs({context:T,orderedIds:T.orderedIds,selectedMessageId:b,enabled:!G&&!E,hasOpenThread:m!==void 0,onClose:n,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||D.deleteThread()},toggleStar:D.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||M&&N([M.messageId],!M.isRead)},goFlagged:()=>i("flagged"),goSettings:()=>i("settings")}}),F=a.useCallback(I=>{if(!I)return;const j=h.find(de=>de.messageId===I);return j?{threadId:j.threadId,messageId:I}:void 0},[h]),C={selectedMessageId:b,selectedThread:p,conversation:L,onOpenThread:x,onCloseThread:n,nextThread:F(_),previousThread:F(Q),actions:A,onReply:P,triage:T,onDeleteMessages:R,handleDeselectIfRemoved:S};return r.jsx(it.Provider,{value:C,children:t})}function ct(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:n}=ce(),{accounts:i}=ie();return r.jsx(xo,{accounts:i,selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function yo(){const e=xe(),{conversation:t,selectedThread:s,actions:n,onReply:i,handleDeselectIfRemoved:d,onOpenThread:m}=ce(),l=!!t,c=Is(t?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(ys,{hasThread:l,intelligenceOpen:c.isShowing,canToggleIntelligence:c.canToggle,onToggleIntelligence:c.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:l?n.deleteThread:void 0,onToggleStar:l?n.toggleStar:void 0,isStarred:n.isStarred,moveContext:l&&n.accountId&&n.mailboxId?{accountId:n.accountId,currentMailboxId:n.mailboxId,onMove:n.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t?r.jsx(Je,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onOpenIntelligence:c.open,listOnScreen:!0}):r.jsx(zt,{})})]}),r.jsx(Ze,{isOpen:c.drawerOpen,onClose:c.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:d,onReplyWithText:e,onOpenThread:m})]})}function vo(){const e=xe(),{selectedThread:t,handleDeselectIfRemoved:s,onOpenThread:n}=ce(),{onToggleIntelligence:i}=ie();return r.jsx(xs,{onClose:i,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:s,onReplyWithText:e,onOpenThread:n})}function bo(){const e=xe(),{selectedThread:t,conversation:s,onOpenThread:n,onCloseThread:i,nextThread:d,previousThread:m,handleDeselectIfRemoved:l}=ce(),c=ps(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Je,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:i,onOpenIntelligence:c.toggle,onSwipeNext:d?()=>n(d):void 0,onSwipePrevious:m?()=>n(m):void 0,mobileIntelligenceOpen:c.isOpen}),r.jsx(Ze,{isOpen:c.isOpen,onClose:c.close,thread:t,accountId:t?.accountId,onAfterOptimisticRemove:l,onReplyWithText:e,onOpenThread:n})]}):r.jsx("div",{className:"h-full",children:r.jsx(ct,{})})}const Bo=Object.assign(Io,{List:ct,Reading:yo,Intelligence:vo,Phone:bo});export{Bo as B};
@@ -1 +0,0 @@
1
- import{j as n,f as C,t as m,$ as X,a0 as ee,aA as N,r as w,az as te,X as ne,as as se,a1 as ae}from"./index-cubACEd8.js";import{R as _,k as $,J as ie,c as re,K as oe,x as le,L as ce,G as de}from"./calendar-format-BovOEuV7.js";import{e as ue,g as j,h as me,u as he,b as U,d as xe,i as pe,t as ye,U as ve}from"./useCalendars-DpG3wNVl.js";import{C as ge}from"./calendar-clash-strip-DoAFMGom.js";const De=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=["first","second","third","fourth","last"],k="";function fe(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[s,a,r]=e.split("-").map(Number),o=new Date(Date.UTC(s,a-1,r)),i=De[o.getUTCDay()],c=Te[Math.min(Math.floor((r-1)/7),4)],l=t===""?"":`, ${t}`,d=o.getUTCDay()>=1&&o.getUTCDay()<=5;return[`Every day${l}`,...d?[`Every weekday${l}`]:[],`Every week on ${i}${l}`,`Every month on the ${c} ${i}${l}`,`Every year on ${r} ${Ne[a-1]}${l}`]}const be="w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30",p=({draft:e,onChange:t},s,a)=>t({...e,[s]:a});function D({label:e,children:t}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:e}),t]})}function je({draft:e,onChange:t,layout:s="compact",touch:a}){const r=s==="pane";return n.jsx(N,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:o=>p({draft:e,onChange:t},"title",o.target.value),className:m(r?"text-lg font-medium":"text-md font-medium",r?"h-11":a?"min-h-11":"")})}function P(e){return e.date===""||e.endDate===""?!1:e.allDay?e.endDate<e.date:e.startTime===""||e.endTime===""?!1:`${e.endDate}T${e.endTime}`<`${e.date}T${e.startTime}`}function Ee(e,t){return t===""?{...e,date:t}:e.endDate===""?{...e,date:t,endDate:t}:e.date===""?{...e,date:t}:{...e,date:t,endDate:$(t,ie(e.date,e.endDate))}}function Ce(e,t){const s=e.date!==""&&e.endDate===$(e.date,1)&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime;return t&&s?{...e,allDay:t,endDate:e.date}:!t&&e.date!==""&&e.endDate===e.date&&e.startTime!==""&&e.endTime!==""&&e.endTime<e.startTime?{...e,allDay:t,endDate:$(e.date,1)}:{...e,allDay:t}}function $e({draft:e,onChange:t,touch:s}){const a=s?"min-h-11":"",r=P(e),o=w.useId(),i={"aria-invalid":r,"aria-describedby":r?o:void 0},c=m("w-40",a,r&&"border-danger/60"),l=m("w-28",a,r&&"border-danger/60");return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(N,{type:"date",value:e.date,"aria-label":"Date",...i,onChange:d=>t(Ee(e,d.target.value)),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.startTime,"aria-label":"Start time",...i,onChange:d=>p({draft:e,onChange:t},"startTime",d.target.value),className:l}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(N,{type:"date",value:e.endDate,"aria-label":"End date",min:e.date===""?void 0:e.date,...i,onChange:d=>p({draft:e,onChange:t},"endDate",d.target.value),className:c}),!e.allDay&&n.jsx(N,{type:"time",value:e.endTime,"aria-label":"End time",...i,onChange:d=>p({draft:e,onChange:t},"endTime",d.target.value),className:l}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:d=>t(Ce(e,d.target.checked)),className:"size-4 accent-current"}),"All day"]})]}),r&&n.jsx("p",{id:o,className:"text-xs text-danger",role:"alert",children:e.allDay?`Ends before it starts. Move the end to ${e.date} or later.`:`Ends before it starts. Move the end past ${e.date} ${e.startTime}, or start earlier.`})]})}function ke({draft:e,onChange:t,calendars:s,touch:a}){return n.jsx(Fe,{calendars:s,value:e.calendarId,onChange:r=>p({draft:e,onChange:t},"calendarId",r),touch:a})}function we({draft:e,onChange:t,touch:s,repeatEditable:a=!0,onCustom:r}){return a?n.jsx(Re,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:o=>p({draft:e,onChange:t},"repeat",o),onCustom:r,className:s?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(_,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===k?"Does not repeat":e.repeat]})}function Ae({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:a=>p({draft:e,onChange:t},"location",a.target.value),className:s?"min-h-11":""})}function Ye({draft:e,onChange:t,touch:s}){return n.jsx(N,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:a=>p({draft:e,onChange:t},"guests",a.target.value),className:s?"min-h-11":""})}function Oe({draft:e,onChange:t,layout:s="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:a=>p({draft:e,onChange:t},"notes",a.target.value),rows:s==="pane"?6:3,className:be})}function Me({draft:e,onChange:t,calendars:s,layout:a="compact",expanded:r=!1,onToggleExpanded:o,onSave:i,onCancel:c,onDelete:l,saveLabel:d="Add",header:h,repeatEditable:u=!0,guestsEditable:x=!1,calendarEditable:y=!0,onCustomRepeat:b,touch:v,className:Y}){const f=a==="pane",g={draft:e,onChange:t,layout:a,touch:v},O=n.jsx(je,{...g}),M=n.jsx($e,{...g}),R=n.jsx(ke,{...g,calendars:s}),F=n.jsx(we,{...g,repeatEditable:u,onCustom:b}),S=n.jsx(Ae,{...g}),I=n.jsx(Ye,{...g}),L=n.jsx(Oe,{...g}),B=n.jsxs("div",{className:m("flex items-center gap-2",f?"pt-2":"pt-1"),children:[n.jsx(C,{variant:"primary",size:v||f?"md":"sm",onClick:i,disabled:P(e),className:v?"min-h-11 flex-1":"",children:d}),n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:c,className:v?"min-h-11":"",children:"Cancel"}),l&&n.jsx(C,{variant:"ghost",size:v||f?"md":"sm",onClick:l,className:m("ml-auto text-danger",v&&"min-h-11"),children:"Delete"})]});if(f)return n.jsxs("div",{className:m("flex flex-col gap-5",Y),children:[h,n.jsx(D,{label:"Title",children:O}),n.jsx(D,{label:"When",children:M}),y&&n.jsx(D,{label:"Calendar",children:R}),n.jsx(D,{label:"Repeat",children:F}),n.jsx(D,{label:"Location",children:S}),x&&n.jsx(D,{label:"Guests",children:I}),n.jsx(D,{label:"Notes",children:L}),B]});const q=o!==void 0&&!r;return n.jsxs("div",{className:m("flex flex-col gap-3",Y),children:[h,O,M,y&&R,o&&n.jsxs("button",{type:"button",onClick:o,"aria-expanded":r,className:m("flex items-center gap-1 self-start rounded-sm text-xs font-medium text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",v&&"min-h-11"),children:[r?n.jsx(X,{className:"size-3.5"}):n.jsx(ee,{className:"size-3.5"}),r?"Fewer details":"More details"]}),!q&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[S,x&&I,F,L]}),B]})}const W="__custom__";function Re({value:e,date:t,startTime:s,onChange:a,onCustom:r,className:o}){const i=fe(t,s),c=e===k||i.includes(e)?i:[e,...i];return n.jsxs(te,{icon:n.jsx(_,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:l=>{if(l.target.value===W){r?.();return}a(l.target.value)},className:o,children:[n.jsx("option",{value:k,children:"Does not repeat"}),c.map(l=>n.jsx("option",{value:l,children:l},l)),r&&n.jsx("option",{value:W,children:"Custom…"})]})}function Fe({calendars:e,value:t,onChange:s,touch:a}){const r=w.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(o=>{const i=re(o.color),c=o.id===t;return n.jsxs("label",{className:m("inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 text-xs transition-colors","has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",a?"min-h-11":"h-7",c?m(i.soft,i.text,i.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:r,value:o.id,checked:c,onChange:()=>s(o.id),className:"sr-only"}),n.jsx("span",{className:m("size-2 rounded-full",i.solid)}),o.name]},o.id)})]})}function Se({title:e,subtitle:t,onClose:s,children:a,className:r}){return n.jsxs("section",{className:m("flex h-full w-full flex-col bg-surface",r),children:[n.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",children:[n.jsx("h2",{className:"shrink-0 text-xs font-medium text-fg",children:e}),t!==void 0&&t!==""&&n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-fg-muted",children:t}),n.jsx("button",{type:"button","aria-label":"Close editor",onClick:s,className:"ml-auto flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(ne,{className:"size-4"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-row-inset py-5",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:a})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["SU","MO","TU","WE","TH","FR","SA"],z=["January","February","March","April","May","June","July","August","September","October","November","December"],Z=["first","second","third","fourth","last"],A=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function K(e){const t=Ie(e);if(t==="")return"";if(t==="Every day")return"FREQ=DAILY";if(t==="Every weekday")return`FREQ=WEEKLY;BYDAY=${J}`;const s=t.match(/^Every week on (\w+)$/);if(s){const o=E.indexOf(s[1]);return o===-1?void 0:`FREQ=WEEKLY;BYDAY=${T[o]}`}const a=t.match(/^Every month on the (\w+) (\w+)$/);if(a){const o=Z.indexOf(a[1]),i=E.indexOf(a[2]);return o===-1||i===-1?void 0:`FREQ=MONTHLY;BYDAY=${A[o]}${T[i]}`}const r=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(r){const o=z.indexOf(r[2]);return o===-1?void 0:`FREQ=YEARLY;BYMONTH=${o+1};BYMONTHDAY=${Number(r[1])}`}}const Le=e=>e===""?"":`, ${e}`;function Ze(e,t){const s=new Map(e.split(";").map(i=>i.split("=")).filter(i=>i.length===2).map(([i,c])=>[i.toUpperCase(),c.toUpperCase()])),a=Le(t),r=s.get("FREQ"),o=s.get("BYDAY");if(!(s.has("INTERVAL")&&s.get("INTERVAL")!=="1")&&!(s.has("UNTIL")||s.has("COUNT"))){if(r==="DAILY")return`Every day${a}`;if(r==="WEEKLY"){if(o===void 0)return;if(o===J)return`Every weekday${a}`;const i=T.indexOf(o);return i===-1?void 0:`Every week on ${E[i]}${a}`}if(r==="MONTHLY"){const i=o?.match(/^(-?\d)([A-Z]{2})$/);if(!i)return;const c=A.indexOf(Number(i[1])),l=T.indexOf(i[2]);return c===-1||l===-1?void 0:`Every month on the ${Z[c]} ${E[l]}${a}`}if(r==="YEARLY"){const i=Number(s.get("BYMONTH")),c=Number(s.get("BYMONTHDAY"));return!i||!c||i>12?void 0:`Every year on ${c} ${z[i-1]}${a}`}}}const H=e=>Date.parse(`${e}T00:00:00Z`)/864e5;function Be(e,t,s){const a=H(s)-H(t);if(e===""||a===0||Number.isNaN(a))return e;const[r,o,i]=s.split("-").map(Number),c=new Date(Date.UTC(r,o-1,i)).getUTCDay(),l=/FREQ=(\w+)/i.exec(e)?.[1]?.toUpperCase();return e.split(";").map(d=>{const[h,u=""]=d.split("="),x=h.toUpperCase();return x==="BYDAY"&&l==="MONTHLY"?`BYDAY=${A[Math.min(Math.floor((i-1)/7),4)]}${T[c]}`:x==="BYDAY"?`BYDAY=${u.split(",").map(y=>{const b=T.indexOf(y.toUpperCase());return b===-1?y:T[(b+a+7)%7]}).join(",")}`:x==="BYMONTH"?`BYMONTH=${o}`:x==="BYMONTHDAY"?`BYMONTHDAY=${i}`:d}).join(";")}function Je(e,t){return{title:"",date:e,startTime:"09:00",endDate:e,endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function Ke(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),endDate:oe(e),endTime:e.allDay?"":e.end.slice(11,16),allDay:e.allDay,calendarId:e.calendarId,location:t.location,guests:"",notes:t.notes,repeat:t.repeat}}function Q(e,t){return e.allDay?{start:e.date,end:ue(e.endDate,1)}:{start:j(e.date,e.startTime,t),end:j(e.endDate,e.endTime,t)}}function G(e,t,s){const a=K(e.repeat)??"",r=e.allDay?e.date:me(t,s.anchor===""?"UTC":s.anchor).slice(0,10);return Be(a,e.date,r)}function V(e,t){return e.title.trim()===""?"Give the event a title before saving it.":e.date===""?"Pick the day the event is on.":e.endDate===""?"Pick the day the event ends on.":e.calendarId===""?"Pick the calendar to save the event in.":!e.allDay&&(e.startTime===""||e.endTime==="")?"Set a start and an end time, or mark the event all day.":e.allDay&&e.endDate<e.date?"The last day is before the first. Move one of them.":!e.allDay&&`${e.endDate}T${e.endTime}`<=`${e.date}T${e.startTime}`?"The end is not after the start. Move one of them.":t&&K(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Qe(e,t){const s=V(e,!0);if(s!=="")return{ok:!1,problem:s};const{start:a,end:r}=Q(e,t.clock);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:a,end:r,allDay:e.allDay,...t.anchor===""?{}:{timeZone:t.anchor},recurrenceRule:G(e,a,t)}}}function Ge(e,t,s){const a=t.repeat!==e.repeat,o=t.allDay!==e.allDay||t.date!==e.date||t.startTime!==e.startTime,i=o||t.endDate!==e.endDate||t.endTime!==e.endTime,c=V(t,a);if(c!=="")return{ok:!1,problem:c};const l={};t.title.trim()!==e.title.trim()&&(l.summary=t.title.trim()),t.location!==e.location&&(l.location=t.location),t.notes!==e.notes&&(l.description=t.notes);const{start:d,end:h}=Q(t,s.clock);return o&&(l.start=d),i&&(l.end=h,l.allDay=t.allDay,s.anchor!==""&&(l.timeZone=s.anchor)),a&&(l.recurrenceRule=G(t,d,s)),{ok:!0,patch:l}}const Ue=[],We={from:"",to:""};function Ve(e,t=""){const{timeZoneByCalendarId:s}=he(),a=e.date!==""&&!e.allDay&&e.endDate!==""&&e.startTime!==""&&e.endTime!==""&&`${e.endDate}T${e.endTime}`>`${e.date}T${e.startTime}`,{instances:r,isLoading:o,error:i}=le({...a?{from:U("week",e.date).from,to:U("week",e.endDate).to}:We,calendarIds:Ue,enabled:a}),c=xe();return w.useMemo(()=>{if(!a||o||i)return;const l=j(e.date,e.startTime,c),d=j(e.endDate,e.endTime,c),h=r.filter(u=>pe(u)&&u.calendarObjectId!==t).map(u=>ye(u,s[u.calendarId]??ve,c));return ce({start:l,end:d},h).map(u=>({id:u.id,label:`${u.title}, ${de(u)}`}))},[a,o,i,e.date,e.endDate,e.startTime,e.endTime,c,r,t,s])}function qe({title:e,subtitle:t,notice:s="",calendars:a,draft:r,onChange:o,problem:i,saveLabel:c,isSaving:l,repeatEditable:d=!0,calendarEditable:h=!0,clashes:u,onSave:x,onCancel:y}){return n.jsx(Se,{title:e,subtitle:t,onClose:y,children:n.jsx(Me,{draft:r,onChange:o,calendars:a,layout:"pane",repeatEditable:d,calendarEditable:h,saveLabel:l?"Saving…":c,onSave:x,onCancel:y,header:i===""&&s===""&&u===void 0?void 0:n.jsxs("div",{className:"space-y-2",children:[s!==""&&n.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-fg",children:[n.jsx(se,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 flex-1 break-words",children:s})]}),i!==""&&n.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[n.jsx(ae,{className:"mt-0.5 size-4 shrink-0 text-danger","aria-hidden":"true"}),n.jsx("p",{className:"min-w-0 flex-1 break-words text-fg",children:i})]}),u!==void 0&&n.jsx(ge,{clashes:u,clearText:"Nothing else is booked at this time."})]})})})}export{qe as C,Se as E,Q as a,Qe as c,Ke as d,Je as e,Be as m,Ge as p,Ze as t,Ve as u};
@@ -1 +0,0 @@
1
- import{f0 as U,r as n,ec as X,c as le,G as z,bm as ce,cX as ue,aI as ge,aJ as he,j as r,al as me,d7 as pe,d8 as fe}from"./index-cubACEd8.js";import{u as xe,p as _,R as Ie}from"./useSearchTokenContext-PpLW_UHw.js";import{z as Te,B as ye,ao as ve,ap as be,az as Re,aq as Ce,a as Se,M as we,aw as je,aA as Fe,ay as Me,l as Oe,I as ke,N as J,L as Pe,J as Le,b as Ne,X as Ae,Y as G,Z as De,$ as Y,a0 as Z,a1 as qe,a2 as Ee,a3 as Be}from"./MailListHeader-CRcUWHvS.js";import{f as We}from"./ErrorState-C-GqtxHT.js";import{u as Qe,l as ze,b as Ge,a as He}from"./MailViewChrome-CjK9Dnpp.js";import{d as Ke,w as Ve}from"./wizard-selection-zWa1qc6-.js";import{a as _e}from"./useMessageBodyContent-oSPoCcAo.js";import{e as Je,f as Ue}from"./search-token-index-DnVW2A-U.js";import{u as Xe}from"./sections-CI8sUA-m.js";const H=t=>({...t,starred:!0,order:"desc"}),Ye=(t={})=>X({query:H(t)});function $(t={}){const{data:e,isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}=Qe({queryKey:Ye(t),queryFn:async({pageParam:x})=>{const{data:u}=await U({query:{...H(t),continuationToken:x},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:x=>x.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(e?.pages??[]).flatMap(x=>x.items??[]),[e]),isLoading:s,isError:a,error:i,refetch:f,fetchNextPage:l,hasNextPage:g,isFetchingNextPage:o}}function Ze(t={}){const e={...H(t),unread:!0,count:!0,results:!1},{data:s}=le({queryKey:X({query:e}),queryFn:async()=>{const{data:a}=await U({query:e,throwOnError:!0});return a},staleTime:6e4});return s?.count}const $e=["from","subject","category","unread","starred","attachments"],et=(t,e)=>{const s=Te(t),{params:a,residual:i}=ye(e,{...s,starred:!0},$e);return{criteria:{...a,...s},residual:i}};function tt({rows:t,verb:e}){const{selectedIds:s,exitSelection:a}=Me(),i=n.useMemo(()=>Ve(t,s),[t,s]);return r.jsx(Oe,{verb:e,selection:i,selectionRestriction:"spansAccounts",onFinished:a})}function st({selectedMessageId:t,onOpenThread:e,commandsRef:s,onTriageContextChange:a,onDeleteMessages:i}){const{searchQuery:f,resultFolderIndex:l,onSearchClearQuery:g}=z(),o=xe(),k=ce(),x=ue(),[u,h]=n.useState("all"),[v,P]=n.useState(new Set),S=n.useCallback(d=>{P(C=>{const I=new Set(C);return I.has(d)?I.delete(d):I.add(d),I})},[]),w=n.useCallback(()=>{h("all"),P(new Set)},[]),T=n.useCallback(()=>{w(),g()},[w,g]),{freeText:j,tokens:b}=_(f.trim().toLowerCase(),o),L=_(f.trim(),o).freeText,{criteria:N,residual:m}=n.useMemo(()=>et({category:u,attributes:v},b),[u,v,b]),F=n.useMemo(()=>j?{...N,query:j}:N,[N,j]),{threads:A,isLoading:D,isError:y,error:E,refetch:M,fetchNextPage:B,hasNextPage:W,isFetchingNextPage:O}=$(F),p=n.useMemo(()=>Ke(A).map(ve).filter(d=>be(d,m)),[A,m]),c=n.useCallback((d,C)=>{const I=p.find(de=>de.id===d)?.threadId;I&&e?.({threadId:I,messageId:d},C)},[p,e]),R=n.useCallback(d=>{const C=d.threadId??p.find(I=>I.id===d.id)?.threadId;C&&e?.({threadId:C,messageId:d.id})},[p,e]),Q=n.useMemo(()=>Re(),[]),se=n.useMemo(()=>p.map(d=>Ce(d,l)),[p,l]),ae=Ze(F)??null,re=n.useMemo(()=>b.filter(d=>d.type!=="isStarred"),[b]),oe=ze({chips:{category:u,attributes:v},tokens:re,reach:m.length>0?"loaded-pages":"whole-folder",onClear:T}),K=D?"loading":y?"error":p.length===0?"empty":"ready",ne=n.useCallback(()=>{const d=ge(he());window.open(d,"_blank","noopener,noreferrer")},[]),V=Se(),ie=r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"divide-y divide-line",children:p.map(d=>r.jsx(we,{thread:d,active:d.id===t,onClick:()=>c(d.id)},d.id))}),W?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>B(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(Ge,{title:"Starred",unreadCount:ae,preset:Q,selectedCategory:u,activeFilters:v,onSelectCategory:h,onToggleFilter:S,onClearFilters:w,searchResults:se,searchLoading:D,onSelectSearchResult:R,searchResultsInBody:!0,children:r.jsxs(je,{selectedMessageId:t,rows:p,onOpen:c,onDeleteMessages:i,onSelectionVerb:x.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(He,{listTitle:"Starred",sections:[{id:"flagged",threads:p}],flatList:!0,hideHeader:!0,listState:V.searchResults?"ready":K,listFilter:oe,listScopeLabel:"Starred",searchQuery:L||void 0,errorMessage:y?We(E):void 0,onRetry:()=>M(),onReportError:ne,selectedThreadId:t,onSelectThread:c,isDesktop:k,selectionBar:r.jsx(Fe,{title:"Starred"}),listBody:V.searchResults??(K==="ready"?ie:void 0)}),r.jsx(tt,{rows:p,verb:x.verb})]})})}const ee=n.createContext(null);function q(){const t=n.useContext(ee);if(!t)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return t}function at({thread:t,children:e}){const s=Je(),a=Ue(),i=Xe(),{searchInput:f}=z(),l=t?.threadId,g=t?.messageId,{threads:o}=$(),k=n.useMemo(()=>{if(l)return o.find(c=>c.messageId===g)??o.find(c=>c.threadId===l)},[o,l,g]),x=ke(l,g),u=k??x,h=g??u?.messageId,v=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:h,authenticity:u?.authenticity}},[l,u,h]),P=n.useCallback((c,R)=>{s(c,{replace:R?.replace,query:f})},[s,f]),S=n.useCallback(c=>{h&&c.includes(h)&&a()},[h,a]),w=J({thread:u,isOpen:!0,onAfterOptimisticRemove:S}),T=Pe(),{deleteMessages:j}=Le({mailboxId:u?.mailboxId??"",messages:o,onAfterOptimisticRemove:S}),{toggleReadFor:b}=Ne({mailboxId:u?.mailboxId??"",messages:o}),L=T.focusedMessageId,m=n.useMemo(()=>o.find(c=>c.messageId===L),[o,L])??u,F=J({thread:m,isOpen:m?.messageId===h}),A=_e(),D=me(),y=pe(),E=n.useMemo(()=>fe(y,l,h),[y,l,h]),M=n.useMemo(()=>{if(m)return c=>y({threadId:m.threadId,messageId:m.messageId,mode:c})},[y,m]),{nextMessageId:B,previousMessageId:W}=Ae({context:T,orderedIds:T.orderedIds,selectedMessageId:h,enabled:!A&&!D,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>M?.("reply"),replyAll:()=>M?.("reply-all"),forward:()=>M?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||F.deleteThread()},toggleStar:F.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||m&&b([m.messageId],!m.isRead)},goBrief:()=>i("brief"),goSettings:()=>i("settings")}}),O=n.useCallback(c=>{if(!c)return;const R=o.find(Q=>Q.messageId===c);return R?{threadId:R.threadId,messageId:c}:void 0},[o]),p={selectedMessageId:h,selectedThread:u,conversation:v,onOpenThread:P,onCloseThread:a,nextThread:O(B),previousThread:O(W),actions:w,onReply:E,triage:T,onDeleteMessages:j,handleDeselectIfRemoved:S};return r.jsx(ee.Provider,{value:p,children:e})}function te(){const{selectedMessageId:t,onOpenThread:e,triage:s,onDeleteMessages:a}=q();return r.jsx(st,{selectedMessageId:t,onOpenThread:e,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function rt(){const t=G(),{conversation:e,selectedThread:s,actions:a,onReply:i,handleDeselectIfRemoved:f,onOpenThread:l}=q(),g=!!e,o=Ee(e?.threadId);return r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[r.jsx(Be,{hasThread:g,intelligenceOpen:o.isShowing,canToggleIntelligence:o.canToggle,onToggleIntelligence:o.toggle,onReply:i?()=>i("reply"):void 0,onReplyAll:i?()=>i("reply-all"):void 0,onForward:i?()=>i("forward"):void 0,onDelete:g?a.deleteThread:void 0,onToggleStar:g?a.toggleStar:void 0,isStarred:a.isStarred,moveContext:g&&a.accountId&&a.mailboxId?{accountId:a.accountId,currentMailboxId:a.mailboxId,onMove:a.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Y,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:o.open,listOnScreen:!0}):r.jsx(Ie,{})})]}),r.jsx(Z,{isOpen:o.drawerOpen,onClose:o.closeDrawer,thread:s,accountId:s?.accountId,onAfterOptimisticRemove:f,onReplyWithText:t,onOpenThread:l})]})}function ot(){const t=G(),{selectedThread:e,handleDeselectIfRemoved:s,onOpenThread:a}=q(),{onToggleIntelligence:i}=z();return r.jsx(qe,{onClose:i,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:s,onReplyWithText:t,onOpenThread:a})}function nt(){const t=G(),{selectedThread:e,conversation:s,onCloseThread:a,onOpenThread:i,nextThread:f,previousThread:l,handleDeselectIfRemoved:g}=q(),o=De(s?.threadId??null);return s?r.jsxs(r.Fragment,{children:[r.jsx(Y,{threadId:s.threadId,mailboxId:s.mailboxId,subject:s.subject,selectedMessageId:s.messageId,authenticity:s.authenticity,onBack:a,onOpenIntelligence:o.toggle,onSwipeNext:f?()=>i(f):void 0,onSwipePrevious:l?()=>i(l):void 0,mobileIntelligenceOpen:o.isOpen}),r.jsx(Z,{isOpen:o.isOpen,onClose:o.close,thread:e,accountId:e?.accountId,onAfterOptimisticRemove:g,onReplyWithText:t,onOpenThread:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(te,{})})}const ft=Object.assign(at,{List:te,Reading:rt,Intelligence:ot,Phone:nt});export{ft as F};