@remit/web-client-dist 0.0.569 → 0.0.571

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 (149) hide show
  1. package/assets/{BriefPane-C4qdevvj.js → BriefPane-C-AXD_S1.js} +1 -1
  2. package/assets/{CalendarComposePane-DYTk75gD.js → CalendarComposePane-ZInEcl83.js} +1 -1
  3. package/assets/{CalendarComposeSeed-DHxzgOBp.js → CalendarComposeSeed-BXablasw.js} +1 -1
  4. package/assets/{CalendarShell-urPv2Ap7.js → CalendarShell-D8PXYY5k.js} +1 -1
  5. package/assets/{EmptyState-DW9m2lvX.js → EmptyState-BdQOG7lh.js} +1 -1
  6. package/assets/{ErrorState-BRKdts_G.js → ErrorState-yTshApcZ.js} +1 -1
  7. package/assets/{FlaggedPane-DJzefBDR.js → FlaggedPane-DBMd-f82.js} +1 -1
  8. package/assets/{FullCompose-Da6so-wh.js → FullCompose-DFM5SSTD.js} +1 -1
  9. package/assets/MailListHeader-DixjeKWo.js +7 -0
  10. package/assets/{MailNav-DtB-SFXW.js → MailNav-B16LaKDW.js} +1 -1
  11. package/assets/{MailShell-ChH4WH5p.js → MailShell-D2tbOLnz.js} +1 -1
  12. package/assets/{MailViewChrome-DUkQ3XCS.js → MailViewChrome-B2e9uACs.js} +1 -1
  13. package/assets/{MailboxPane-AlIsjTqd.js → MailboxPane-CfT2HmEK.js} +1 -1
  14. package/assets/{NavMenuButton-Cd-vQTHA.js → NavMenuButton-DbwB8-EE.js} +1 -1
  15. package/assets/{OnboardingWizard-BrSKsD27.js → OnboardingWizard-BwDNIpbV.js} +1 -1
  16. package/assets/{OpenCalendarEvent-OnyM5Gmr.js → OpenCalendarEvent-Cp3Xxt88.js} +1 -1
  17. package/assets/{OutboxPane-DCvckDm-.js → OutboxPane-CW2jpqSm.js} +1 -1
  18. package/assets/_calendarObjectId-Bhzj_LOc.js +1 -0
  19. package/assets/_mailboxId-7CeQdqXt.js +1 -0
  20. package/assets/_messageId-9yyd8JQa.js +1 -0
  21. package/assets/_messageId-BjT0iqtE.js +1 -0
  22. package/assets/_messageId-DIrX2-NC.js +1 -0
  23. package/assets/_outboxMessageId-5Hilxc-o.js +1 -0
  24. package/assets/_recurrenceId-9zc7QOUi.js +1 -0
  25. package/assets/_threadId-BLPnJQ1O.js +1 -0
  26. package/assets/_threadId-Cj-AqWpe.js +1 -0
  27. package/assets/_threadId-DmnNT1YW.js +1 -0
  28. package/assets/{_view._date-JHbRwoWF.js → _view._date-vmYhsMe2.js} +1 -1
  29. package/assets/{accounts-B7u97VqP.js → accounts-B5b2n325.js} +1 -1
  30. package/assets/{advanced-CPfvy6Af.js → advanced-V_8Vc7Op.js} +1 -1
  31. package/assets/{appearance-Br9Kr3ss.js → appearance-B0Z3Sg7A.js} +1 -1
  32. package/assets/{attachment-file-C4FSwgIv.js → attachment-file-D1lRTIpJ.js} +1 -1
  33. package/assets/{attendee-row-D6gUCjbn.js → attendee-row-BY_sZYga.js} +1 -1
  34. package/assets/{avatar-DQ2Za_b5.js → avatar-Dc7q-vE0.js} +1 -1
  35. package/assets/{bottom-sheet-DeTeDdhV.js → bottom-sheet-Dj78OKpl.js} +1 -1
  36. package/assets/{brief-C4ZJVvSI.js → brief-Di6IdjaO.js} +1 -1
  37. package/assets/brief-pYORS2EQ.js +1 -0
  38. package/assets/{browser-ponyfill-DJl-hvK0.js → browser-ponyfill-Lmz1LgWx.js} +1 -1
  39. package/assets/{bug-D4vthdmR.js → bug-BCJlsHb-.js} +1 -1
  40. package/assets/{calendar-DETOK5EU.js → calendar-Cdtx6qRv.js} +1 -1
  41. package/assets/{calendar-color-CnMzTK_9.js → calendar-color-CREaSNOF.js} +1 -1
  42. package/assets/{calendar-event-chip-RDM5bPZZ.js → calendar-event-chip-PRMkWtmn.js} +1 -1
  43. package/assets/{calendars-D07uwzeX.js → calendars-BfHi1c8f.js} +1 -1
  44. package/assets/{card-DB95JOXm.js → card-Blb5LxlW.js} +1 -1
  45. package/assets/chevron-left-B5q2zkoV.js +1 -0
  46. package/assets/{circle-check-DTL_gl9V.js → circle-check-DQceIvPw.js} +1 -1
  47. package/assets/{circle-check-big-w157yjgs.js → circle-check-big-DrsWjtbF.js} +1 -1
  48. package/assets/{circle-help-D2hLsX4d.js → circle-help-C90h4Gxl.js} +1 -1
  49. package/assets/{clock-BAt8YXWX.js → clock-DJx8eT0h.js} +1 -1
  50. package/assets/compose._-_outboxMessageId_-Bx3jTrEX.js +1 -0
  51. package/assets/compose._-_outboxMessageId_-CCL9Z9Rr.js +1 -0
  52. package/assets/compose._-_outboxMessageId_-J5Xr0VYM.js +1 -0
  53. package/assets/compose._-_outboxMessageId_-OYQ8wE-O.js +1 -0
  54. package/assets/{config-import-qvff-XOD.js → config-import-zWUhkyrx.js} +1 -1
  55. package/assets/{confirm-dialog-DmMkRipf.js → confirm-dialog-BnvctSkU.js} +1 -1
  56. package/assets/{copy-BRGwXYIX.js → copy-CPegVmmX.js} +1 -1
  57. package/assets/{credential-steps-AWLHMdlu.js → credential-steps-03ZiFb9S.js} +1 -1
  58. package/assets/{download-BRMxQZ9H.js → download-DCjKcyoD.js} +1 -1
  59. package/assets/{file-json-t63BljCM.js → file-json-Bp9PxrXB.js} +1 -1
  60. package/assets/{filters-BTt3lCAB.js → filters-Cz6ACP3x.js} +1 -1
  61. package/assets/{flagged-DUGVCsxq.js → flagged-CVe-xaZ6.js} +1 -1
  62. package/assets/flagged-bqIrcL0D.js +1 -0
  63. package/assets/{folders-D9quIn8u.js → folders-D0RCMVTd.js} +1 -1
  64. package/assets/{help-copy-BJma-HMH.js → help-copy-Xy5HlVm9.js} +1 -1
  65. package/assets/{import-CZZBWvTv.js → import-DntPPUzf.js} +1 -1
  66. package/assets/index-4TyPLW-n.js +1 -0
  67. package/assets/index-9yyd8JQa.js +1 -0
  68. package/assets/index-BjT0iqtE.js +1 -0
  69. package/assets/index-BpsjtF88.js +1 -0
  70. package/assets/index-C-j9H2jQ.js +1 -0
  71. package/assets/index-CfHR_Ae8.js +1 -0
  72. package/assets/index-CmmqbTph.js +1 -0
  73. package/assets/{index-BstTD6DD.js → index-Dy5D6YkV.js} +4 -4
  74. package/assets/{index-s6tBUhDn.js → index-DyF2fU1Q.js} +1 -1
  75. package/assets/{index-COXmbPoi.js → index-ELhtBEwQ.js} +4 -4
  76. package/assets/index-drC6ZRdd.js +1 -0
  77. package/assets/index-iaeEYdB7.js +1 -0
  78. package/assets/{kbd-D6gO0HEI.js → kbd-6xrqVw1K.js} +1 -1
  79. package/assets/{labels-XYM303bf.js → labels-eMbeaPk4.js} +1 -1
  80. package/assets/{mail-BV5VD-Ar.js → mail-1kAZ-hEc.js} +1 -1
  81. package/assets/{mail-7UArrUpq.js → mail-w8cRSHpe.js} +1 -1
  82. package/assets/{map-pin-LNJtyvro.js → map-pin-pA2YiBQX.js} +1 -1
  83. package/assets/{menu-gXDy9USt.js → menu-BBzSZjBL.js} +1 -1
  84. package/assets/{new-D_pe05i6.js → new-a4cb6vhA.js} +1 -1
  85. package/assets/onboarding-B6cLhnyh.js +1 -0
  86. package/assets/{onboarding-completion-Bpw8967t.js → onboarding-completion-DPHalyAM.js} +1 -1
  87. package/assets/outbox-BMQSynaj.js +1 -0
  88. package/assets/{pencil-BQZnwNLu.js → pencil-DWkVPRF_.js} +1 -1
  89. package/assets/{refresh-cw-ZsadNdnS.js → refresh-cw-N6rrepD7.js} +1 -1
  90. package/assets/{rich-text-DzYAidk-.js → rich-text-CIfc5KKH.js} +1 -1
  91. package/assets/{rich-text-spellcheck-worker-provider-Bc5w98Dp.js → rich-text-spellcheck-worker-provider-B-dYPpIy.js} +1 -1
  92. package/assets/{rotate-ccw-M23y8ejM.js → rotate-ccw-Cq64A4JR.js} +1 -1
  93. package/assets/{roving-focus-DRUyjNlS.js → roving-focus-BOWQw34Y.js} +1 -1
  94. package/assets/{row-actions-DXchPOTt.js → row-actions-CHU1lTnr.js} +1 -1
  95. package/assets/{search-mirror-CZpxvipk.js → search-mirror-D__KCGFD.js} +1 -1
  96. package/assets/{search-token-index-B8GTncCY.js → search-token-index-RpS46UX-.js} +1 -1
  97. package/assets/{sections-DCf8ouIL.js → sections-DpPFeJvC.js} +1 -1
  98. package/assets/{senders-CXRiHhmT.js → senders-BzofDilD.js} +1 -1
  99. package/assets/{settings-screen-c-ew_2vr.js → settings-screen-CEtuw85p.js} +1 -1
  100. package/assets/settings-t8hjTuQb.js +1 -0
  101. package/assets/{shield-check-tsdxv3RF.js → shield-check-C-xWv7tn.js} +1 -1
  102. package/assets/{suggested-vips-B-ZJ_oSz.js → suggested-vips-D-TCsoQ_.js} +1 -1
  103. package/assets/{useCalendarData-DGI79lVd.js → useCalendarData-tBA8O6aY.js} +1 -1
  104. package/assets/{useCalendars-BTLkNtty.js → useCalendars-DmOIJuzJ.js} +1 -1
  105. package/assets/{useDebouncedValue-nhypL9_o.js → useDebouncedValue-cgYnkNgs.js} +1 -1
  106. package/assets/{useFilters-DorOGFhJ.js → useFilters-toZUnuEV.js} +1 -1
  107. package/assets/{useLabels-CUd5gWwV.js → useLabels-CuITaMaj.js} +1 -1
  108. package/assets/{useLayoutTier-wxSo1nDc.js → useLayoutTier-BiCLmmpl.js} +1 -1
  109. package/assets/{useMessageBodyContent-D8al5oah.js → useMessageBodyContent-Dqn8BKJN.js} +1 -1
  110. package/assets/{useQueries-BycE_mig.js → useQueries-BuVSZIL7.js} +1 -1
  111. package/assets/{useRefreshControl-DIWeCjZ5.js → useRefreshControl-BY8dJRFq.js} +1 -1
  112. package/assets/{useResultFolderIndex-jR4vl6Wy.js → useResultFolderIndex-Bh5N3vbq.js} +1 -1
  113. package/assets/useSearchTokenContext-BDaT1iE0.js +84 -0
  114. package/assets/{useSemanticSearch-C2nf4lR9.js → useSemanticSearch-Cr2T-SJl.js} +1 -1
  115. package/assets/{useSignature-WkO_w4sf.js → useSignature-Do1zcP6k.js} +1 -1
  116. package/assets/{window-jws2aQZO.js → window-BeKH_DgL.js} +1 -1
  117. package/index.html +1 -1
  118. package/package.json +1 -1
  119. package/assets/MailListHeader-CtLJO_kX.js +0 -7
  120. package/assets/_calendarObjectId-BTNDF6Go.js +0 -1
  121. package/assets/_mailboxId-DdOnexSL.js +0 -1
  122. package/assets/_messageId-BJI9HI_Y.js +0 -1
  123. package/assets/_messageId-DBf1JHiD.js +0 -1
  124. package/assets/_messageId-VgUm24uu.js +0 -1
  125. package/assets/_outboxMessageId-_ZBaATuU.js +0 -1
  126. package/assets/_recurrenceId-C83vhhhO.js +0 -1
  127. package/assets/_threadId-BKiZCs6r.js +0 -1
  128. package/assets/_threadId-CxJHY37y.js +0 -1
  129. package/assets/_threadId-DZiwTD8V.js +0 -1
  130. package/assets/brief-BUv_Vayt.js +0 -1
  131. package/assets/chevron-left-BGyOlrhE.js +0 -1
  132. package/assets/compose._-_outboxMessageId_-BLfWiKmz.js +0 -1
  133. package/assets/compose._-_outboxMessageId_-C2-ZvUCw.js +0 -1
  134. package/assets/compose._-_outboxMessageId_-CjcPajfp.js +0 -1
  135. package/assets/compose._-_outboxMessageId_-NBmfRz6x.js +0 -1
  136. package/assets/flagged-CPTPXLqu.js +0 -1
  137. package/assets/index-BESinRwS.js +0 -1
  138. package/assets/index-BJI9HI_Y.js +0 -1
  139. package/assets/index-BWinfpFM.js +0 -1
  140. package/assets/index-BbLX1tpD.js +0 -1
  141. package/assets/index-CWf3j_Bd.js +0 -1
  142. package/assets/index-D8UvRySx.js +0 -1
  143. package/assets/index-DBf1JHiD.js +0 -1
  144. package/assets/index-DOT9iKNA.js +0 -1
  145. package/assets/index-ef9ZOerK.js +0 -1
  146. package/assets/onboarding-Bes4tj0x.js +0 -1
  147. package/assets/outbox-DlE7p5GU.js +0 -1
  148. package/assets/settings-ejtLzHlz.js +0 -1
  149. package/assets/useSearchTokenContext-Q-PYaS79.js +0 -84
@@ -1 +1 @@
1
- import{j as r,L as Tt,W as wt,ev as _e,ew as ue,dX as me,r as n,c as Qe,C as J,bm as Rt,cN as Mt,K as jt,dN as kt,ex as Et,a0 as ze,ee as At,ey as Ft,al as Ot,cZ as Nt,c_ as Bt}from"./index-BstTD6DD.js";import{g as He,e as Lt,f as Ke,u as qt,p as Pt,R as Dt}from"./useSearchTokenContext-Q-PYaS79.js";import{a8 as _t,A as Qt,E as zt,ak as Ht,al as Kt,am as Gt,an as Wt,ao as Ut,ap as Fe,aq as Yt,ar as $t,as as Vt,a7 as Zt,at as Jt,au as Xt,av as es,af as ts,M as ss,aw as os,ag as rs,ax as ns,ay as as,e as is,p as cs,ai as ls,m as ds,S as us,J as ms,O as Oe,N as fs,K as hs,d as gs,Y as ps,Z as xs,$ as Ge,a0 as We,a1 as Is,a2 as ys,a3 as vs}from"./MailListHeader-CtLJO_kX.js";import{u as bs,a as Ss,R as Cs,b as Ts,c as ws}from"./useRefreshControl-DIWeCjZ5.js";import{u as fe}from"./useQueries-BycE_mig.js";import{t as Rs,u as Ms,r as js,L as ks}from"./useSemanticSearch-C2nf4lR9.js";import{a as Es}from"./useLabels-CUd5gWwV.js";import{u as As,b as Fs}from"./useLayoutTier-wxSo1nDc.js";import{d as Os,w as Ns}from"./wizard-selection-DxUM65kM.js";import{u as Ue}from"./sections-DCf8ouIL.js";import{R as Bs}from"./refresh-cw-ZsadNdnS.js";import{a as Ls}from"./useMessageBodyContent-D8al5oah.js";import{g as qs,h as Ps}from"./search-token-index-B8GTncCY.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(Tt,{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:_s(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(wt,{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 _s({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 Ye=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],$e="category",Qs={unclassified:"uncategorized"},H=e=>Lt(e).map(t=>t.raw),z=e=>e.join(" "),he=e=>{const t=Ke(e);if(t)return Ye.find(o=>o.name===t.name&&o.value===t.value.toLowerCase())?.id},ge=e=>{const t=Ke(e);if(!t||t.name!==$e)return;const o=t.value.toLowerCase(),a=Qs[o];if(a)return a;if(!(!_e(o)||o==="all"))return o},Ve=e=>Ye.find(t=>t.id===e),Ze=e=>Ve(e)!==void 0,zs=e=>{const t=new Set;for(const o of H(e)){const a=he(o);a&&t.add(a)}return t},Hs=e=>{let t="all";for(const o of H(e)){const a=ge(o);a&&(t=a)}return t},Ks=(e,t)=>{const o=Ve(t);if(!o)return;const a=H(e),c=a.filter(d=>he(d)!==t);return c.length<a.length?z(c):z([...a,He(o.name,o.value)])},Gs=(e,t)=>{const o=H(e).filter(a=>!ge(a));return z(t==="all"?o:[...o,He($e,t)])},Ws=e=>z(H(e).filter(t=>!he(t)&&!ge(t))),Je=e=>e.trim().length>0,Ne=e=>{if(!Je(e.query))return e.ownFilters;const t=new Set(zs(e.query));for(const o of e.ownFilters)Ze(o)||t.add(o);return t},Be=e=>Je(e.query)?Hs(e.query):e.ownCategory,Le=6e4,Us=3e4,Ys={kind:"unknown"},qe=e=>(t,o)=>_t(o?.queryKey,e)?t:void 0,$s=(e,t,o)=>({...e,category:[t],limit:o,order:"desc"}),Vs=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),Pe=(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}:{}});function Zs({categories:e,criteria:t,limit:o,counted:a}){const c=fe({queries:e.map(m=>{const f=$s(t,m,o),g=Pe(t,m);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},placeholderData:qe(g),staleTime:Le}})}),d=fe({queries:e.map(m=>{const f=Vs(t,m),g=Pe(t,m);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},enabled:a,placeholderData:qe(g),staleTime:Le}})}),l=n.useMemo(()=>e.map((m,f)=>{const g=c[f],T=d[f],I=g?.data?.items??[];return{category:m,rows:I,atCap:I.length>=o,total:a?Rs(T?.data?.count):Ys,loading:g?.isPending??!0,failed:g?.isError??!1,retry:()=>{g?.refetch(),a&&T?.refetch()}}}),[e,c,d,a,o]),u=n.useCallback(()=>{for(const m of c)m.refetch();for(const m of d)m.refetch()},[c,d]);return{sections:l,isLoading:c.length>0&&c.every(m=>m.isPending),isError:c.length>0&&c.every(m=>m.isError),refetch:u}}function Js(e,t,o){const a={...e,limit:t,order:"desc"},{data:c,isLoading:d,isError:l,refetch:u}=Qe({queryKey:me({query:a}),queryFn:async()=>{const{data:f}=await ue({query:a,throwOnError:!0});return f},enabled:o,staleTime:Us});return{rows:n.useMemo(()=>o?c?.items??[]:[],[c,o]),isLoading:o&&d,isError:o&&l,refetch:n.useCallback(()=>{u()},[u])}}const Xs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),eo=e=>[...e].sort(Xs),to=["category","unread","starred","attachments"],Xe=["contacts","today"],so=e=>new Set(Xe.filter(t=>e.has(t))),oo=(e,t,o)=>{const a=Qt({category:e,attributes:t}),{params:c,residual:d}=zt(o,a,to),l={...c,...a},u={};return l.unread!==void 0&&(u.unread=l.unread),l.starred!==void 0&&(u.starred=l.starred),l.attachments!==void 0&&(u.attachments=l.attachments),{criteria:u,residual:d}},ro=({residual:e,attributes:t,accountScoped:o})=>e.length===0&&!o&&!Xe.some(a=>t.has(a)),no=50,ao=200,io=[],De=()=>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))}),co=({accountEmail:e})=>{const t=Ue();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(ze,{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"})]})},lo=(e,t)=>{if(t.size===0)return{};const o=e.filter(d=>t.has(d.id)),a=js(o.map(d=>d.accountId));if(a.restriction)return a;const c=new Set;for(const d of o)d.mailboxId&&c.add(d.mailboxId);return c.size>1?{accountId:a.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${c.size} folders`}:{accountId:a.accountId,mailboxId:c.size===1?[...c][0]:void 0}};function uo({header:e,rows:t,wizard:o,children:a}){const{selectedIds:c,selectedCount:d,exitSelection:l,orderedIds:u,allSelected:m,toggleAllLoaded:f}=as(),g=n.useMemo(()=>lo(t,c),[t,c]),{junkMailboxId:T}=is(g.accountId),{labels:I}=Es(g.accountId),v=n.useMemo(()=>Array.from(c),[c]),B=n.useMemo(()=>Ns(t,c),[t,c]),p=cs(T,g.mailboxId),b=n.useMemo(()=>u.length>0?{checked:m,indeterminate:d>0&&!m,onChange:f}:void 0,[u.length,m,d,f]),F=g.moveDisabledHint?{tone:"warning",text:g.moveDisabledHint}:void 0,S=R=>r.jsx(us,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:l,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:p?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:g.accountId&&g.mailboxId&&d>0&&I.length>0?r.jsx(ks,{accountId:g.accountId,mailboxId:g.mailboxId,messageIds:v}):void 0,selectAll:b,notice:F});return r.jsx(ls,{...e,selectionBar:S,paneOverlay:r.jsx(ds,{verb:o.verb,accountId:g.accountId,mailboxId:g.mailboxId,selection:B,selectionRestriction:g.restriction,onFinished:l}),children:a})}function mo({accounts:e,selectedMessageId:t,onOpenThread:o,commandsRef:a,onTriageContextChange:c,onDeleteMessages:d}){const{searchQuery:l,searchInput:u,resultFolderIndex:m,onSearchChange:f}=J(),g=qt(),T=Rt(),I=As(),v=Mt(),B=Fs(),p=n.useMemo(()=>eo(e.filter(s=>!s.muted?.value)),[e]),[b,F]=n.useState("all"),[S,R]=n.useState("all"),[O,L]=n.useState(new Set),[ee,M]=n.useState(!1),q=n.useCallback(s=>{L(i=>{const h=new Set(i);return h.has(s)?h.delete(s):h.add(s),h})},[]),K=n.useCallback(()=>L(new Set),[]),E=u.trim().length>0,{freeText:j,tokens:P}=Pt(l.trim().toLowerCase(),g),y=j.length>0,D=n.useMemo(()=>Ne({query:u,ownFilters:O}),[u,O]),_=n.useMemo(()=>Be({query:u,ownCategory:S}),[u,S]),A=n.useMemo(()=>Ne({query:l,ownFilters:O}),[l,O]),C=n.useMemo(()=>Be({query:l,ownCategory:S}),[l,S]),x=n.useCallback(s=>{if(!E||!Ze(s)){q(s);return}const i=Ks(u,s);i!==void 0&&f(i)},[E,u,f,q]),k=n.useCallback(s=>{if(!E){R(s);return}f(Gs(u,s))},[E,u,f]),te=n.useMemo(()=>C==="all"&&!y?s=>{_e(s)&&k(s)}:void 0,[C,y,k]),se=n.useCallback(()=>{R("all"),F("all"),K(),E&&f(Ws(u))},[E,u,f,K]),G=fe({queries:p.map(s=>({...jt({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),W=n.useMemo(()=>{const s=new Map;for(let i=0;i<p.length;i++){const h=p[i].accountId,bt=(G[i]?.data?.items??[]).reduce((St,Ct)=>St+(Ct.unseenCount??0),0);s.set(h,bt)}return s},[p,G]),st=n.useMemo(()=>p.filter((s,i)=>{const h=G[i];return h?.isError?!kt(h.error):!1}),[p,G]),{criteria:oe,residual:re}=n.useMemo(()=>oo(C,A,P),[C,A,P]),ot=n.useMemo(()=>C==="all"?[...Ht]:[C],[C]),rt=n.useMemo(()=>({...oe,query:j,...C==="all"?{}:{category:[C]}}),[oe,j,C]),nt=ro({residual:re,attributes:A,accountScoped:b!=="all"}),{sections:U,isLoading:at,isError:it,refetch:pe}=Zs({categories:y?io:ot,criteria:oe,limit:C==="all"?ns:no,counted:nt}),{rows:xe,isLoading:ct,isError:lt,refetch:Ie}=Js(rt,ao,y),ne=y?ct:at,ye=y?lt:it,ve=n.useCallback(()=>{if(y){Ie();return}pe()},[y,Ie,pe]),be=n.useMemo(()=>so(A),[A]),Y=n.useCallback(s=>Os(Kt(s)).map(Gt).filter(i=>(b==="all"||i.accountId===b)&&Et(i,be)&&Wt(i,re)),[b,be,re]),$=n.useMemo(()=>U.map(s=>({category:s.category,total:Ut(s.total,s.rows),atCap:s.atCap,loading:s.loading,failed:s.failed,rows:Y(s.rows)})),[U,Y]),V=n.useMemo(()=>Y(xe),[xe,Y]),dt=n.useCallback(s=>{U.find(i=>i.category===s)?.retry()},[U]),w=n.useMemo(()=>y?V:$.flatMap(s=>s.rows),[y,V,$]),{spamIds:ae,briefSpamOffer:ie}=n.useMemo(()=>{const s={spamIds:void 0,briefSpamOffer:void 0};if(!j)return s;const i=w.map(N=>Fe(N,m)),{spam:h}=Yt(i);return h.length===0?s:{spamIds:new Set(h.map(N=>N.id)),briefSpamOffer:$t(i)}},[w,j,m]),Se=n.useMemo(()=>{const s=i=>ae===void 0?i:i.filter(h=>!ae.has(h.id));return y?[{id:"matches",threads:s(V)}]:Vt($.map(i=>({...i,rows:s(i.rows)})))},[y,V,$,ae]),Ce=n.useCallback((s,i)=>{const h=w.find(N=>N.id===s)?.threadId;h&&o?.({threadId:h,messageId:s},i)},[w,o]),ut=n.useCallback(s=>{const i=s.threadId??w.find(h=>h.id===s.id)?.threadId;i&&o?.({threadId:i,messageId:s.id})},[w,o]),ce=n.useMemo(()=>p.length<=1?[]:[{id:"all",label:"All",active:b==="all"},...p.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:W.get(s.accountId),active:b===s.accountId}))],[p,W,b]),Q=n.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),mt=n.useMemo(()=>Array.from(W.values()).reduce((s,i)=>s+i,0),[W]),le=n.useMemo(()=>p.map(s=>s.accountId),[p]),{hasNewMail:Te}=bs(),{state:we,errorMessage:Re,refresh:Me}=Ss(le,{onSettled:()=>ve()}),ft=n.useMemo(()=>r.jsx(Cs,{state:we,onRefresh:Me,label:"Refresh daily brief",errorMessage:Re,hasUpdate:Te(le)}),[we,Me,Re,Te,le]),de=n.useMemo(()=>w.map(s=>Fe(s,m)),[w,m]),{hits:je,isLoading:ht}=Ms(),gt=n.useMemo(()=>{const s=new Map(w.map(h=>[h.id,h.threadId])),i=de.map(h=>s.get(h.id)).filter(h=>h!=null);return Zt(je,i,m)},[je,de,w,m]),pt=n.useMemo(()=>{const s=Jt(ce.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:s.categories,filters:s.filters,sources:s.sources,sourcesNote:Q>0?`+${Q} muted`:void 0,selectedCategory:_,activeFilters:D,expanded:ee,onExpandedChange:M,onSelectCategory:i=>k(i),onSelectSource:F,onToggleFilter:i=>x(i),onClear:se}},[ce,Q,_,D,ee,x,k,se]),ke=Se.length===0&&b==="all"&&j.length===0&&P.length===0,xt=n.useMemo(()=>p.map(s=>s.accountId),[p]),It=n.useMemo(()=>p.some(s=>Ts(s.syncPhase)),[p]),Z=ws(xt,ke||It),Ee=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(De,{}),r.jsx(De,{})]}),Ae=!ne&&!ye&&!ke,yt=Xt({tier:I,hasLiveInput:E,hasCommittedQuery:l.trim().length>0,bodyRendersCommittedResults:!0}),vt=Ae?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ie&&r.jsx(es,{count:ie.count,onScopeToSpam:()=>B(ie.mailboxId,l)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ts,{sections:Se,briefCategory:_,Row:ss,selectedThreadId:t,onSelectThread:Ce,onShowAllSection:te,onRetrySection:dt,flat:y,onSelectBriefCategory:k,sources:ce,sourcesNote:Q>0?`+${Q} muted`:void 0,onSelectSource:F,activeFilters:D,onToggleFilter:x,onClearFilters:se})})]}):ne?Ee:ye?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(ze,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>ve(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Bs,{className:"size-3.5"}),"Try again"]})]}):Z.resolved?r.jsx(Ds,{sync:Z.syncing?{synced:Z.synced,total:Z.total}:void 0}):Ee;return r.jsx(At,{hasSheet:Ae&&!yt,children:r.jsx(os,{selectedMessageId:t,rows:w,onOpen:Ce,onDeleteMessages:d,onSelectionVerb:v.start,commandsRef:a,onTriageContextChange:c,children:r.jsx(uo,{wizard:v,header:{title:"Daily brief",unreadCount:mt,footer:T?r.jsx(rs,{}):void 0,searchFilter:pt,searchResults:de,searchLoading:ne,relatedResults:gt,relatedLoading:ht,onSelectSearchResult:ut,searchResultsInBody:!0,refreshControl:ft},rows:w,children:r.jsxs("div",{className:"flex h-full flex-col",children:[st.map(s=>r.jsx(co,{accountEmail:s.email,accountId:s.accountId},s.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:vt})]})})})})}const et=n.createContext(null);function X(){const e=n.useContext(et);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function fo({thread:e,children:t}){const o=qs(),a=Ps(),c=Ue(),{searchInput:d}=J(),l=e?.threadId,u=e?.messageId,{data:m}=Qe({...Ft(),staleTime:6e4}),f=n.useMemo(()=>m?.items??[],[m]),g=n.useMemo(()=>{if(l)return f.find(x=>x.messageId===u)??f.find(x=>x.threadId===l)},[f,l,u]),T=ms(l,u),I=g??T,v=u??I?.messageId,B=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:v,authenticity:I?.authenticity}},[l,I,v]),p=n.useCallback((x,k)=>{o(x,{replace:k?.replace,query:d})},[o,d]),b=n.useCallback(x=>{v&&x.includes(v)&&a()},[v,a]),F=Oe({thread:I,isOpen:!0,onAfterOptimisticRemove:b}),S=fs(),{deleteMessages:R}=hs({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:b}),{toggleReadFor:O}=gs({mailboxId:I?.mailboxId??"",messages:f}),L=S.focusedMessageId,M=n.useMemo(()=>f.find(x=>x.messageId===L),[f,L])??I,q=Oe({thread:M,isOpen:M?.messageId===v}),K=Ls(),E=Ot(),j=Nt(),P=n.useMemo(()=>Bt(j,l,v),[j,l,v]),y=n.useMemo(()=>{if(M)return x=>j({threadId:M.threadId,messageId:M.messageId,mode:x})},[j,M]),{nextMessageId:D,previousMessageId:_}=ps({context:S,orderedIds:S.orderedIds,selectedMessageId:v,enabled:!K&&!E,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||q.deleteThread()},toggleStar:q.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||M&&O([M.messageId],!M.isRead)},goFlagged:()=>c("flagged"),goSettings:()=>c("settings")}}),A=n.useCallback(x=>{if(!x)return;const k=f.find(te=>te.messageId===x);return k?{threadId:k.threadId,messageId:x}:void 0},[f]),C={selectedMessageId:v,selectedThread:I,conversation:B,onOpenThread:p,onCloseThread:a,nextThread:A(D),previousThread:A(_),actions:F,onReply:P,triage:S,onDeleteMessages:R,handleDeselectIfRemoved:b};return r.jsx(et.Provider,{value:C,children:t})}function tt(){const{selectedMessageId:e,onOpenThread:t,triage:o,onDeleteMessages:a}=X(),{accounts:c}=J();return r.jsx(mo,{accounts:c,selectedMessageId:e,onOpenThread:t,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:a})}function ho(){const{conversation:e,selectedThread:t,actions:o,onReply:a,handleDeselectIfRemoved:c}=X(),d=!!e,l=ys(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(vs,{hasThread:d,intelligenceOpen:l.isShowing,canToggleIntelligence:l.canToggle,onToggleIntelligence:l.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:d?o.deleteThread:void 0,onToggleStar:d?o.toggleStar:void 0,isStarred:o.isStarred,moveContext:d&&o.accountId&&o.mailboxId?{accountId:o.accountId,currentMailboxId:o.mailboxId,onMove:o.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Ge,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:l.open,listOnScreen:!0}):r.jsx(Dt,{})})]}),r.jsx(We,{isOpen:l.drawerOpen,onClose:l.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:c})]})}function go(){const{selectedThread:e,handleDeselectIfRemoved:t}=X(),{onToggleIntelligence:o}=J();return r.jsx(Is,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function po(){const{selectedThread:e,conversation:t,onOpenThread:o,onCloseThread:a,nextThread:c,previousThread:d,handleDeselectIfRemoved:l}=X(),u=xs(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(Ge,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:a,onOpenIntelligence:u.toggle,onSwipeNext:c?()=>o(c):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:u.isOpen}),r.jsx(We,{isOpen:u.isOpen,onClose:u.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:l})]}):r.jsx("div",{className:"h-full",children:r.jsx(tt,{})})}const Eo=Object.assign(fo,{List:tt,Reading:ho,Intelligence:go,Phone:po});export{Eo as B};
1
+ import{j as r,L as Tt,W as wt,ev as _e,ew as ue,dX as me,r as n,c as Qe,C as J,bm as Rt,cN as Mt,K as jt,dN as kt,ex as Et,a0 as ze,ee as At,ey as Ft,al as Ot,cZ as Nt,c_ as Bt}from"./index-Dy5D6YkV.js";import{g as He,e as Lt,f as Ke,u as qt,p as Pt,R as Dt}from"./useSearchTokenContext-BDaT1iE0.js";import{a8 as _t,A as Qt,E as zt,ak as Ht,al as Kt,am as Gt,an as Wt,ao as Ut,ap as Fe,aq as Yt,ar as $t,as as Vt,a7 as Zt,at as Jt,au as Xt,av as es,af as ts,M as ss,aw as os,ag as rs,ax as ns,ay as as,e as is,p as cs,ai as ls,m as ds,S as us,J as ms,O as Oe,N as fs,K as hs,d as gs,Y as ps,Z as xs,$ as Ge,a0 as We,a1 as Is,a2 as ys,a3 as vs}from"./MailListHeader-DixjeKWo.js";import{u as bs,a as Ss,R as Cs,b as Ts,c as ws}from"./useRefreshControl-BY8dJRFq.js";import{u as fe}from"./useQueries-BuVSZIL7.js";import{t as Rs,u as Ms,r as js,L as ks}from"./useSemanticSearch-Cr2T-SJl.js";import{a as Es}from"./useLabels-CuITaMaj.js";import{u as As,b as Fs}from"./useLayoutTier-BiCLmmpl.js";import{d as Os,w as Ns}from"./wizard-selection-DxUM65kM.js";import{u as Ue}from"./sections-DpPFeJvC.js";import{R as Bs}from"./refresh-cw-N6rrepD7.js";import{a as Ls}from"./useMessageBodyContent-Dqn8BKJN.js";import{g as qs,h as Ps}from"./search-token-index-RpS46UX-.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(Tt,{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:_s(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(wt,{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 _s({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 Ye=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],$e="category",Qs={unclassified:"uncategorized"},H=e=>Lt(e).map(t=>t.raw),z=e=>e.join(" "),he=e=>{const t=Ke(e);if(t)return Ye.find(o=>o.name===t.name&&o.value===t.value.toLowerCase())?.id},ge=e=>{const t=Ke(e);if(!t||t.name!==$e)return;const o=t.value.toLowerCase(),a=Qs[o];if(a)return a;if(!(!_e(o)||o==="all"))return o},Ve=e=>Ye.find(t=>t.id===e),Ze=e=>Ve(e)!==void 0,zs=e=>{const t=new Set;for(const o of H(e)){const a=he(o);a&&t.add(a)}return t},Hs=e=>{let t="all";for(const o of H(e)){const a=ge(o);a&&(t=a)}return t},Ks=(e,t)=>{const o=Ve(t);if(!o)return;const a=H(e),c=a.filter(d=>he(d)!==t);return c.length<a.length?z(c):z([...a,He(o.name,o.value)])},Gs=(e,t)=>{const o=H(e).filter(a=>!ge(a));return z(t==="all"?o:[...o,He($e,t)])},Ws=e=>z(H(e).filter(t=>!he(t)&&!ge(t))),Je=e=>e.trim().length>0,Ne=e=>{if(!Je(e.query))return e.ownFilters;const t=new Set(zs(e.query));for(const o of e.ownFilters)Ze(o)||t.add(o);return t},Be=e=>Je(e.query)?Hs(e.query):e.ownCategory,Le=6e4,Us=3e4,Ys={kind:"unknown"},qe=e=>(t,o)=>_t(o?.queryKey,e)?t:void 0,$s=(e,t,o)=>({...e,category:[t],limit:o,order:"desc"}),Vs=(e,t)=>({...e,category:[t],order:"desc",count:!0,results:!1}),Pe=(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}:{}});function Zs({categories:e,criteria:t,limit:o,counted:a}){const c=fe({queries:e.map(m=>{const f=$s(t,m,o),g=Pe(t,m);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},placeholderData:qe(g),staleTime:Le}})}),d=fe({queries:e.map(m=>{const f=Vs(t,m),g=Pe(t,m);return{queryKey:me({query:f}),queryFn:async()=>{const{data:T}=await ue({query:f,throwOnError:!0});return T},enabled:a,placeholderData:qe(g),staleTime:Le}})}),l=n.useMemo(()=>e.map((m,f)=>{const g=c[f],T=d[f],I=g?.data?.items??[];return{category:m,rows:I,atCap:I.length>=o,total:a?Rs(T?.data?.count):Ys,loading:g?.isPending??!0,failed:g?.isError??!1,retry:()=>{g?.refetch(),a&&T?.refetch()}}}),[e,c,d,a,o]),u=n.useCallback(()=>{for(const m of c)m.refetch();for(const m of d)m.refetch()},[c,d]);return{sections:l,isLoading:c.length>0&&c.every(m=>m.isPending),isError:c.length>0&&c.every(m=>m.isError),refetch:u}}function Js(e,t,o){const a={...e,limit:t,order:"desc"},{data:c,isLoading:d,isError:l,refetch:u}=Qe({queryKey:me({query:a}),queryFn:async()=>{const{data:f}=await ue({query:a,throwOnError:!0});return f},enabled:o,staleTime:Us});return{rows:n.useMemo(()=>o?c?.items??[]:[],[c,o]),isLoading:o&&d,isError:o&&l,refetch:n.useCallback(()=>{u()},[u])}}const Xs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),eo=e=>[...e].sort(Xs),to=["category","unread","starred","attachments"],Xe=["contacts","today"],so=e=>new Set(Xe.filter(t=>e.has(t))),oo=(e,t,o)=>{const a=Qt({category:e,attributes:t}),{params:c,residual:d}=zt(o,a,to),l={...c,...a},u={};return l.unread!==void 0&&(u.unread=l.unread),l.starred!==void 0&&(u.starred=l.starred),l.attachments!==void 0&&(u.attachments=l.attachments),{criteria:u,residual:d}},ro=({residual:e,attributes:t,accountScoped:o})=>e.length===0&&!o&&!Xe.some(a=>t.has(a)),no=50,ao=200,io=[],De=()=>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))}),co=({accountEmail:e})=>{const t=Ue();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(ze,{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"})]})},lo=(e,t)=>{if(t.size===0)return{};const o=e.filter(d=>t.has(d.id)),a=js(o.map(d=>d.accountId));if(a.restriction)return a;const c=new Set;for(const d of o)d.mailboxId&&c.add(d.mailboxId);return c.size>1?{accountId:a.accountId,restriction:"spansFolders",moveDisabledHint:`Move only works within one folder — this selection spans ${c.size} folders`}:{accountId:a.accountId,mailboxId:c.size===1?[...c][0]:void 0}};function uo({header:e,rows:t,wizard:o,children:a}){const{selectedIds:c,selectedCount:d,exitSelection:l,orderedIds:u,allSelected:m,toggleAllLoaded:f}=as(),g=n.useMemo(()=>lo(t,c),[t,c]),{junkMailboxId:T}=is(g.accountId),{labels:I}=Es(g.accountId),v=n.useMemo(()=>Array.from(c),[c]),B=n.useMemo(()=>Ns(t,c),[t,c]),p=cs(T,g.mailboxId),b=n.useMemo(()=>u.length>0?{checked:m,indeterminate:d>0&&!m,onChange:f}:void 0,[u.length,m,d,f]),F=g.moveDisabledHint?{tone:"warning",text:g.moveDisabledHint}:void 0,S=R=>r.jsx(us,{title:R.title,navSlot:R.navSlot,titleMeta:R.titleMeta,searchSlot:R.searchSlot,searchField:R.searchField,idleSlot:R.makeFilterSlot,count:d,onCancel:l,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:p?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:g.accountId&&g.mailboxId&&d>0&&I.length>0?r.jsx(ks,{accountId:g.accountId,mailboxId:g.mailboxId,messageIds:v}):void 0,selectAll:b,notice:F});return r.jsx(ls,{...e,selectionBar:S,paneOverlay:r.jsx(ds,{verb:o.verb,accountId:g.accountId,mailboxId:g.mailboxId,selection:B,selectionRestriction:g.restriction,onFinished:l}),children:a})}function mo({accounts:e,selectedMessageId:t,onOpenThread:o,commandsRef:a,onTriageContextChange:c,onDeleteMessages:d}){const{searchQuery:l,searchInput:u,resultFolderIndex:m,onSearchChange:f}=J(),g=qt(),T=Rt(),I=As(),v=Mt(),B=Fs(),p=n.useMemo(()=>eo(e.filter(s=>!s.muted?.value)),[e]),[b,F]=n.useState("all"),[S,R]=n.useState("all"),[O,L]=n.useState(new Set),[ee,M]=n.useState(!1),q=n.useCallback(s=>{L(i=>{const h=new Set(i);return h.has(s)?h.delete(s):h.add(s),h})},[]),K=n.useCallback(()=>L(new Set),[]),E=u.trim().length>0,{freeText:j,tokens:P}=Pt(l.trim().toLowerCase(),g),y=j.length>0,D=n.useMemo(()=>Ne({query:u,ownFilters:O}),[u,O]),_=n.useMemo(()=>Be({query:u,ownCategory:S}),[u,S]),A=n.useMemo(()=>Ne({query:l,ownFilters:O}),[l,O]),C=n.useMemo(()=>Be({query:l,ownCategory:S}),[l,S]),x=n.useCallback(s=>{if(!E||!Ze(s)){q(s);return}const i=Ks(u,s);i!==void 0&&f(i)},[E,u,f,q]),k=n.useCallback(s=>{if(!E){R(s);return}f(Gs(u,s))},[E,u,f]),te=n.useMemo(()=>C==="all"&&!y?s=>{_e(s)&&k(s)}:void 0,[C,y,k]),se=n.useCallback(()=>{R("all"),F("all"),K(),E&&f(Ws(u))},[E,u,f,K]),G=fe({queries:p.map(s=>({...jt({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),W=n.useMemo(()=>{const s=new Map;for(let i=0;i<p.length;i++){const h=p[i].accountId,bt=(G[i]?.data?.items??[]).reduce((St,Ct)=>St+(Ct.unseenCount??0),0);s.set(h,bt)}return s},[p,G]),st=n.useMemo(()=>p.filter((s,i)=>{const h=G[i];return h?.isError?!kt(h.error):!1}),[p,G]),{criteria:oe,residual:re}=n.useMemo(()=>oo(C,A,P),[C,A,P]),ot=n.useMemo(()=>C==="all"?[...Ht]:[C],[C]),rt=n.useMemo(()=>({...oe,query:j,...C==="all"?{}:{category:[C]}}),[oe,j,C]),nt=ro({residual:re,attributes:A,accountScoped:b!=="all"}),{sections:U,isLoading:at,isError:it,refetch:pe}=Zs({categories:y?io:ot,criteria:oe,limit:C==="all"?ns:no,counted:nt}),{rows:xe,isLoading:ct,isError:lt,refetch:Ie}=Js(rt,ao,y),ne=y?ct:at,ye=y?lt:it,ve=n.useCallback(()=>{if(y){Ie();return}pe()},[y,Ie,pe]),be=n.useMemo(()=>so(A),[A]),Y=n.useCallback(s=>Os(Kt(s)).map(Gt).filter(i=>(b==="all"||i.accountId===b)&&Et(i,be)&&Wt(i,re)),[b,be,re]),$=n.useMemo(()=>U.map(s=>({category:s.category,total:Ut(s.total,s.rows),atCap:s.atCap,loading:s.loading,failed:s.failed,rows:Y(s.rows)})),[U,Y]),V=n.useMemo(()=>Y(xe),[xe,Y]),dt=n.useCallback(s=>{U.find(i=>i.category===s)?.retry()},[U]),w=n.useMemo(()=>y?V:$.flatMap(s=>s.rows),[y,V,$]),{spamIds:ae,briefSpamOffer:ie}=n.useMemo(()=>{const s={spamIds:void 0,briefSpamOffer:void 0};if(!j)return s;const i=w.map(N=>Fe(N,m)),{spam:h}=Yt(i);return h.length===0?s:{spamIds:new Set(h.map(N=>N.id)),briefSpamOffer:$t(i)}},[w,j,m]),Se=n.useMemo(()=>{const s=i=>ae===void 0?i:i.filter(h=>!ae.has(h.id));return y?[{id:"matches",threads:s(V)}]:Vt($.map(i=>({...i,rows:s(i.rows)})))},[y,V,$,ae]),Ce=n.useCallback((s,i)=>{const h=w.find(N=>N.id===s)?.threadId;h&&o?.({threadId:h,messageId:s},i)},[w,o]),ut=n.useCallback(s=>{const i=s.threadId??w.find(h=>h.id===s.id)?.threadId;i&&o?.({threadId:i,messageId:s.id})},[w,o]),ce=n.useMemo(()=>p.length<=1?[]:[{id:"all",label:"All",active:b==="all"},...p.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:W.get(s.accountId),active:b===s.accountId}))],[p,W,b]),Q=n.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),mt=n.useMemo(()=>Array.from(W.values()).reduce((s,i)=>s+i,0),[W]),le=n.useMemo(()=>p.map(s=>s.accountId),[p]),{hasNewMail:Te}=bs(),{state:we,errorMessage:Re,refresh:Me}=Ss(le,{onSettled:()=>ve()}),ft=n.useMemo(()=>r.jsx(Cs,{state:we,onRefresh:Me,label:"Refresh daily brief",errorMessage:Re,hasUpdate:Te(le)}),[we,Me,Re,Te,le]),de=n.useMemo(()=>w.map(s=>Fe(s,m)),[w,m]),{hits:je,isLoading:ht}=Ms(),gt=n.useMemo(()=>{const s=new Map(w.map(h=>[h.id,h.threadId])),i=de.map(h=>s.get(h.id)).filter(h=>h!=null);return Zt(je,i,m)},[je,de,w,m]),pt=n.useMemo(()=>{const s=Jt(ce.map(i=>({id:i.id,label:i.label,count:i.count,active:i.active})));return{categories:s.categories,filters:s.filters,sources:s.sources,sourcesNote:Q>0?`+${Q} muted`:void 0,selectedCategory:_,activeFilters:D,expanded:ee,onExpandedChange:M,onSelectCategory:i=>k(i),onSelectSource:F,onToggleFilter:i=>x(i),onClear:se}},[ce,Q,_,D,ee,x,k,se]),ke=Se.length===0&&b==="all"&&j.length===0&&P.length===0,xt=n.useMemo(()=>p.map(s=>s.accountId),[p]),It=n.useMemo(()=>p.some(s=>Ts(s.syncPhase)),[p]),Z=ws(xt,ke||It),Ee=r.jsxs("div",{className:"h-full overflow-y-auto",children:[r.jsx(De,{}),r.jsx(De,{})]}),Ae=!ne&&!ye&&!ke,yt=Xt({tier:I,hasLiveInput:E,hasCommittedQuery:l.trim().length>0,bodyRendersCommittedResults:!0}),vt=Ae?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ie&&r.jsx(es,{count:ie.count,onScopeToSpam:()=>B(ie.mailboxId,l)}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(ts,{sections:Se,briefCategory:_,Row:ss,selectedThreadId:t,onSelectThread:Ce,onShowAllSection:te,onRetrySection:dt,flat:y,onSelectBriefCategory:k,sources:ce,sourcesNote:Q>0?`+${Q} muted`:void 0,onSelectSource:F,activeFilters:D,onToggleFilter:x,onClearFilters:se})})]}):ne?Ee:ye?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(ze,{className:"size-8 text-danger"}),r.jsx("p",{children:"Couldn't load your messages"}),r.jsxs("button",{type:"button",onClick:()=>ve(),className:"flex items-center gap-1 text-accent underline text-xs",children:[r.jsx(Bs,{className:"size-3.5"}),"Try again"]})]}):Z.resolved?r.jsx(Ds,{sync:Z.syncing?{synced:Z.synced,total:Z.total}:void 0}):Ee;return r.jsx(At,{hasSheet:Ae&&!yt,children:r.jsx(os,{selectedMessageId:t,rows:w,onOpen:Ce,onDeleteMessages:d,onSelectionVerb:v.start,commandsRef:a,onTriageContextChange:c,children:r.jsx(uo,{wizard:v,header:{title:"Daily brief",unreadCount:mt,footer:T?r.jsx(rs,{}):void 0,searchFilter:pt,searchResults:de,searchLoading:ne,relatedResults:gt,relatedLoading:ht,onSelectSearchResult:ut,searchResultsInBody:!0,refreshControl:ft},rows:w,children:r.jsxs("div",{className:"flex h-full flex-col",children:[st.map(s=>r.jsx(co,{accountEmail:s.email,accountId:s.accountId},s.accountId)),r.jsx("div",{className:"min-h-0 flex-1",children:vt})]})})})})}const et=n.createContext(null);function X(){const e=n.useContext(et);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function fo({thread:e,children:t}){const o=qs(),a=Ps(),c=Ue(),{searchInput:d}=J(),l=e?.threadId,u=e?.messageId,{data:m}=Qe({...Ft(),staleTime:6e4}),f=n.useMemo(()=>m?.items??[],[m]),g=n.useMemo(()=>{if(l)return f.find(x=>x.messageId===u)??f.find(x=>x.threadId===l)},[f,l,u]),T=ms(l,u),I=g??T,v=u??I?.messageId,B=n.useMemo(()=>{if(l)return{threadId:l,mailboxId:I?.mailboxId??"",subject:I?.subject,messageId:v,authenticity:I?.authenticity}},[l,I,v]),p=n.useCallback((x,k)=>{o(x,{replace:k?.replace,query:d})},[o,d]),b=n.useCallback(x=>{v&&x.includes(v)&&a()},[v,a]),F=Oe({thread:I,isOpen:!0,onAfterOptimisticRemove:b}),S=fs(),{deleteMessages:R}=hs({mailboxId:I?.mailboxId??"",messages:f,onAfterOptimisticRemove:b}),{toggleReadFor:O}=gs({mailboxId:I?.mailboxId??"",messages:f}),L=S.focusedMessageId,M=n.useMemo(()=>f.find(x=>x.messageId===L),[f,L])??I,q=Oe({thread:M,isOpen:M?.messageId===v}),K=Ls(),E=Ot(),j=Nt(),P=n.useMemo(()=>Bt(j,l,v),[j,l,v]),y=n.useMemo(()=>{if(M)return x=>j({threadId:M.threadId,messageId:M.messageId,mode:x})},[j,M]),{nextMessageId:D,previousMessageId:_}=ps({context:S,orderedIds:S.orderedIds,selectedMessageId:v,enabled:!K&&!E,hasOpenThread:l!==void 0,onClose:a,handlers:{reply:()=>y?.("reply"),replyAll:()=>y?.("reply-all"),forward:()=>y?.("forward"),delete:()=>{S.listCommandsRef.current?.requestVerb("delete")||q.deleteThread()},toggleStar:q.toggleStar,toggleRead:()=>{S.listCommandsRef.current?.requestVerb("markRead")||M&&O([M.messageId],!M.isRead)},goFlagged:()=>c("flagged"),goSettings:()=>c("settings")}}),A=n.useCallback(x=>{if(!x)return;const k=f.find(te=>te.messageId===x);return k?{threadId:k.threadId,messageId:x}:void 0},[f]),C={selectedMessageId:v,selectedThread:I,conversation:B,onOpenThread:p,onCloseThread:a,nextThread:A(D),previousThread:A(_),actions:F,onReply:P,triage:S,onDeleteMessages:R,handleDeselectIfRemoved:b};return r.jsx(et.Provider,{value:C,children:t})}function tt(){const{selectedMessageId:e,onOpenThread:t,triage:o,onDeleteMessages:a}=X(),{accounts:c}=J();return r.jsx(mo,{accounts:c,selectedMessageId:e,onOpenThread:t,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:a})}function ho(){const{conversation:e,selectedThread:t,actions:o,onReply:a,handleDeselectIfRemoved:c}=X(),d=!!e,l=ys(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(vs,{hasThread:d,intelligenceOpen:l.isShowing,canToggleIntelligence:l.canToggle,onToggleIntelligence:l.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:d?o.deleteThread:void 0,onToggleStar:d?o.toggleStar:void 0,isStarred:o.isStarred,moveContext:d&&o.accountId&&o.mailboxId?{accountId:o.accountId,currentMailboxId:o.mailboxId,onMove:o.moveThread}:void 0}),r.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?r.jsx(Ge,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,onOpenIntelligence:l.open,listOnScreen:!0}):r.jsx(Dt,{})})]}),r.jsx(We,{isOpen:l.drawerOpen,onClose:l.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:c})]})}function go(){const{selectedThread:e,handleDeselectIfRemoved:t}=X(),{onToggleIntelligence:o}=J();return r.jsx(Is,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function po(){const{selectedThread:e,conversation:t,onOpenThread:o,onCloseThread:a,nextThread:c,previousThread:d,handleDeselectIfRemoved:l}=X(),u=xs(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(Ge,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:a,onOpenIntelligence:u.toggle,onSwipeNext:c?()=>o(c):void 0,onSwipePrevious:d?()=>o(d):void 0,mobileIntelligenceOpen:u.isOpen}),r.jsx(We,{isOpen:u.isOpen,onClose:u.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:l})]}):r.jsx("div",{className:"h-full",children:r.jsx(tt,{})})}const Eo=Object.assign(fo,{List:tt,Reading:ho,Intelligence:go,Phone:po});export{Eo as B};
@@ -1 +1 @@
1
- import{a as ee,i as _}from"./window-jws2aQZO.js";import{j as n,f as j,t as d,_ as te,$ as ne,aA as f,r as p,az as ae,X as se,i as T,eF as re,eG as ie,eH as le,h as oe,s as ce,b4 as de,a0 as ue}from"./index-BstTD6DD.js";import{f as me}from"./ErrorState-BRKdts_G.js";import{R as z,c as he}from"./calendar-color-CnMzTK_9.js";const xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pe=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=["first","second","third","fourth","last"],A="";function ye(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,s,i]=e.split("-").map(Number),r=new Date(Date.UTC(a,s-1,i)),l=xe[r.getUTCDay()],o=fe[Math.min(Math.floor((i-1)/7),4)],c=t===""?"":`, ${t}`,y=r.getUTCDay()>=1&&r.getUTCDay()<=5;return[`Every day${c}`,...y?[`Every weekday${c}`]:[],`Every week on ${l}${c}`,`Every month on the ${o} ${l}${c}`,`Every year on ${i} ${pe[s-1]}${c}`]}const ve="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",u=({draft:e,onChange:t},a,s)=>t({...e,[a]:s});function x({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 ge({draft:e,onChange:t,layout:a="compact",touch:s}){const i=a==="pane";return n.jsx(f,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:r=>u({draft:e,onChange:t},"title",r.target.value),className:d(i?"text-lg font-medium":"text-md font-medium",i?"h-11":s?"min-h-11":"")})}function H(e){return e.allDay||e.startTime===""||e.endTime===""?!1:e.endTime<e.startTime}function be({draft:e,onChange:t,touch:a}){const s=a?"min-h-11":"",i=H(e),r=p.useId();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(f,{type:"date",value:e.date,"aria-label":"Date",onChange:l=>u({draft:e,onChange:t},"date",l.target.value),className:d("w-40",s)}),e.allDay?n.jsx("span",{className:"text-sm text-fg-muted",children:"All day"}):n.jsxs(n.Fragment,{children:[n.jsx(f,{type:"time",value:e.startTime,"aria-label":"Start time",max:e.endTime===""?void 0:e.endTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"startTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(f,{type:"time",value:e.endTime,"aria-label":"End time",min:e.startTime===""?void 0:e.startTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"endTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")})]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:l=>u({draft:e,onChange:t},"allDay",l.target.checked),className:"size-4 accent-current"}),"All day"]})]}),i&&n.jsxs("p",{id:r,className:"text-xs text-danger",role:"alert",children:["Ends before it starts. Move the end past ",e.startTime,", or start earlier."]})]})}function Ee({draft:e,onChange:t,calendars:a,touch:s}){return n.jsx(Ae,{calendars:a,value:e.calendarId,onChange:i=>u({draft:e,onChange:t},"calendarId",i),touch:s})}function Ne({draft:e,onChange:t,touch:a,repeatEditable:s=!0,onCustom:i}){return s?n.jsx(ke,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:r=>u({draft:e,onChange:t},"repeat",r),onCustom:i,className:a?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(z,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===A?"Does not repeat":e.repeat]})}function je({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:s=>u({draft:e,onChange:t},"location",s.target.value),className:a?"min-h-11":""})}function Te({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:s=>u({draft:e,onChange:t},"guests",s.target.value),className:a?"min-h-11":""})}function Ce({draft:e,onChange:t,layout:a="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:s=>u({draft:e,onChange:t},"notes",s.target.value),rows:a==="pane"?6:3,className:ve})}function De({draft:e,onChange:t,calendars:a,layout:s="compact",expanded:i=!1,onToggleExpanded:r,onSave:l,onCancel:o,onDelete:c,saveLabel:y="Add",header:g,repeatEditable:b=!0,guestsEditable:I=!1,calendarEditable:M=!0,onCustomRepeat:X,touch:m,className:$}){const v=s==="pane",h={draft:e,onChange:t,layout:s,touch:m},w=n.jsx(ge,{...h}),S=n.jsx(be,{...h}),F=n.jsx(Ee,{...h,calendars:a}),R=n.jsx(Ne,{...h,repeatEditable:b,onCustom:X}),Y=n.jsx(je,{...h}),L=n.jsx(Te,{...h}),P=n.jsx(Ce,{...h}),W=n.jsxs("div",{className:d("flex items-center gap-2",v?"pt-2":"pt-1"),children:[n.jsx(j,{variant:"primary",size:m||v?"md":"sm",onClick:l,disabled:H(e),className:m?"min-h-11 flex-1":"",children:y}),n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:o,className:m?"min-h-11":"",children:"Cancel"}),c&&n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:c,className:d("ml-auto text-danger",m&&"min-h-11"),children:"Delete"})]});if(v)return n.jsxs("div",{className:d("flex flex-col gap-5",$),children:[g,n.jsx(x,{label:"Title",children:w}),n.jsx(x,{label:"When",children:S}),M&&n.jsx(x,{label:"Calendar",children:F}),n.jsx(x,{label:"Repeat",children:R}),n.jsx(x,{label:"Location",children:Y}),I&&n.jsx(x,{label:"Guests",children:L}),n.jsx(x,{label:"Notes",children:P}),W]});const Z=r!==void 0&&!i;return n.jsxs("div",{className:d("flex flex-col gap-3",$),children:[g,w,S,M&&F,r&&n.jsxs("button",{type:"button",onClick:r,"aria-expanded":i,className:d("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",m&&"min-h-11"),children:[i?n.jsx(te,{className:"size-3.5"}):n.jsx(ne,{className:"size-3.5"}),i?"Fewer details":"More details"]}),!Z&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[Y,I&&L,R,P]}),W]})}const U="__custom__";function ke({value:e,date:t,startTime:a,onChange:s,onCustom:i,className:r}){const l=ye(t,a),o=e===A||l.includes(e)?l:[e,...l];return n.jsxs(ae,{icon:n.jsx(z,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:c=>{if(c.target.value===U){i?.();return}s(c.target.value)},className:r,children:[n.jsx("option",{value:A,children:"Does not repeat"}),o.map(c=>n.jsx("option",{value:c,children:c},c)),i&&n.jsx("option",{value:U,children:"Custom…"})]})}function Ae({calendars:e,value:t,onChange:a,touch:s}){const i=p.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(r=>{const l=he(r.color),o=r.id===t;return n.jsxs("label",{className:d("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",s?"min-h-11":"h-7",o?d(l.soft,l.text,l.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:i,value:r.id,checked:o,onChange:()=>a(r.id),className:"sr-only"}),n.jsx("span",{className:d("size-2 rounded-full",l.solid)}),r.name]},r.id)})]})}function Oe({title:e,subtitle:t,onClose:a,children:s,className:i}){return n.jsxs("section",{className:d("flex h-full w-full flex-col bg-surface",i),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:a,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(se,{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:s})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["SU","MO","TU","WE","TH","FR","SA"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"],G=["first","second","third","fourth","last"],K=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(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 a=t.match(/^Every week on (\w+)$/);if(a){const r=E.indexOf(a[1]);return r===-1?void 0:`FREQ=WEEKLY;BYDAY=${N[r]}`}const s=t.match(/^Every month on the (\w+) (\w+)$/);if(s){const r=G.indexOf(s[1]),l=E.indexOf(s[2]);return r===-1||l===-1?void 0:`FREQ=MONTHLY;BYDAY=${K[r]}${N[l]}`}const i=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(i){const r=Q.indexOf(i[2]);return r===-1?void 0:`FREQ=YEARLY;BYMONTH=${r+1};BYMONTHDAY=${Number(i[1])}`}}const Me=e=>e===""?"":`, ${e}`;function Pe(e,t){const a=new Map(e.split(";").map(l=>l.split("=")).filter(l=>l.length===2).map(([l,o])=>[l.toUpperCase(),o.toUpperCase()])),s=Me(t),i=a.get("FREQ"),r=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(i==="DAILY")return`Every day${s}`;if(i==="WEEKLY"){if(r===void 0)return;if(r===J)return`Every weekday${s}`;const l=N.indexOf(r);return l===-1?void 0:`Every week on ${E[l]}${s}`}if(i==="MONTHLY"){const l=r?.match(/^(-?\d)([A-Z]{2})$/);if(!l)return;const o=K.indexOf(Number(l[1])),c=N.indexOf(l[2]);return o===-1||c===-1?void 0:`Every month on the ${G[o]} ${E[c]}${s}`}if(i==="YEARLY"){const l=Number(a.get("BYMONTH")),o=Number(a.get("BYMONTHDAY"));return!l||!o||l>12?void 0:`Every year on ${o} ${Q[l-1]}${s}`}}}function We(e,t){return{title:"",date:e,startTime:"09:00",endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function _e(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),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:ee(e.date,1)}:{start:_(e.date,e.startTime,t),end:_(e.date,e.endTime,t)}}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.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.endTime<=e.startTime?"The end time is not after the start time. Move one of them.":t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Ue(e,t){const a=V(e,!0);if(a!=="")return{ok:!1,problem:a};const{start:s,end:i}=q(e,t);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:s,end:i,allDay:e.allDay,...t===""?{}:{timeZone:t},recurrenceRule:O(e.repeat)??""}}}function Be(e,t,a){const s=t.repeat!==e.repeat,i=V(t,s);if(i!=="")return{ok:!1,problem:i};const r={};if(t.title.trim()!==e.title.trim()&&(r.summary=t.title.trim()),t.location!==e.location&&(r.location=t.location),t.notes!==e.notes&&(r.description=t.notes),t.date!==e.date||t.startTime!==e.startTime||t.endTime!==e.endTime||t.allDay!==e.allDay){const{start:o,end:c}=q(t,a);r.start=o,r.end=c,r.allDay=t.allDay,a!==""&&(r.timeZone=a)}return s&&(r.recurrenceRule=O(t.repeat)??""),{ok:!0,patch:r}}const C=ce(400,404,412),$e=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),D={kind:"written"},k=e=>de(e)===412?{kind:"conflict"}:{kind:"refused",message:me(e)},we={this:"This",following:"Following",all:"All"};function Se(){const e=oe();return p.useCallback(()=>{e.invalidateQueries({predicate:t=>{const a=t.queryKey[0];if(typeof a!="object"||a===null)return!1;const s=a._id;return typeof s=="string"&&$e.has(s)}})},[e])}const B=({scope:e,recurrenceId:t})=>e===void 0||e==="all"?{}:{scope:we[e],recurrenceId:t};function ze(){const e=Se(),t=T({...re(),meta:C,onSuccess:e}),a=T({...ie(),meta:C,onSuccess:e}),s=T({...le(),meta:C,onSuccess:e}),i=p.useCallback(o=>t.mutateAsync({body:o}).then(()=>D).catch(k),[t]),r=p.useCallback((o,c)=>a.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag},body:c}).then(()=>D).catch(k),[a]),l=p.useCallback(o=>s.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag}}).then(()=>D).catch(k),[s]);return p.useMemo(()=>({createEvent:i,updateEvent:r,deleteEvent:l,isWriting:t.isPending||a.isPending||s.isPending}),[i,r,l,t.isPending,a.isPending,s.isPending])}function He({title:e,subtitle:t,calendars:a,draft:s,onChange:i,problem:r,saveLabel:l,isSaving:o,repeatEditable:c=!0,calendarEditable:y=!0,onSave:g,onCancel:b}){return n.jsx(Oe,{title:e,subtitle:t,onClose:b,children:n.jsx(De,{draft:s,onChange:i,calendars:a,layout:"pane",repeatEditable:c,calendarEditable:y,saveLabel:o?"Saving…":l,onSave:g,onCancel:b,header:r===""?void 0: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(ue,{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:r})]})})})}export{He as C,Ue as c,_e as d,We as e,Be as p,Pe as t,ze as u};
1
+ import{a as ee,i as _}from"./window-BeKH_DgL.js";import{j as n,f as j,t as d,_ as te,$ as ne,aA as f,r as p,az as ae,X as se,i as T,eF as re,eG as ie,eH as le,h as oe,s as ce,b4 as de,a0 as ue}from"./index-Dy5D6YkV.js";import{f as me}from"./ErrorState-yTshApcZ.js";import{R as z,c as he}from"./calendar-color-CREaSNOF.js";const xe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pe=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=["first","second","third","fourth","last"],A="";function ye(e,t){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return[];const[a,s,i]=e.split("-").map(Number),r=new Date(Date.UTC(a,s-1,i)),l=xe[r.getUTCDay()],o=fe[Math.min(Math.floor((i-1)/7),4)],c=t===""?"":`, ${t}`,y=r.getUTCDay()>=1&&r.getUTCDay()<=5;return[`Every day${c}`,...y?[`Every weekday${c}`]:[],`Every week on ${l}${c}`,`Every month on the ${o} ${l}${c}`,`Every year on ${i} ${pe[s-1]}${c}`]}const ve="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",u=({draft:e,onChange:t},a,s)=>t({...e,[a]:s});function x({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 ge({draft:e,onChange:t,layout:a="compact",touch:s}){const i=a==="pane";return n.jsx(f,{value:e.title,placeholder:"Title","aria-label":"Title",onChange:r=>u({draft:e,onChange:t},"title",r.target.value),className:d(i?"text-lg font-medium":"text-md font-medium",i?"h-11":s?"min-h-11":"")})}function H(e){return e.allDay||e.startTime===""||e.endTime===""?!1:e.endTime<e.startTime}function be({draft:e,onChange:t,touch:a}){const s=a?"min-h-11":"",i=H(e),r=p.useId();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(f,{type:"date",value:e.date,"aria-label":"Date",onChange:l=>u({draft:e,onChange:t},"date",l.target.value),className:d("w-40",s)}),e.allDay?n.jsx("span",{className:"text-sm text-fg-muted",children:"All day"}):n.jsxs(n.Fragment,{children:[n.jsx(f,{type:"time",value:e.startTime,"aria-label":"Start time",max:e.endTime===""?void 0:e.endTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"startTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")}),n.jsx("span",{className:"text-sm text-fg-subtle",children:"to"}),n.jsx(f,{type:"time",value:e.endTime,"aria-label":"End time",min:e.startTime===""?void 0:e.startTime,"aria-invalid":i,"aria-describedby":i?r:void 0,onChange:l=>u({draft:e,onChange:t},"endTime",l.target.value),className:d("w-28",s,i&&"border-danger/60")})]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:e.allDay,onChange:l=>u({draft:e,onChange:t},"allDay",l.target.checked),className:"size-4 accent-current"}),"All day"]})]}),i&&n.jsxs("p",{id:r,className:"text-xs text-danger",role:"alert",children:["Ends before it starts. Move the end past ",e.startTime,", or start earlier."]})]})}function Ee({draft:e,onChange:t,calendars:a,touch:s}){return n.jsx(Ae,{calendars:a,value:e.calendarId,onChange:i=>u({draft:e,onChange:t},"calendarId",i),touch:s})}function Ne({draft:e,onChange:t,touch:a,repeatEditable:s=!0,onCustom:i}){return s?n.jsx(ke,{value:e.repeat,date:e.date,startTime:e.startTime,onChange:r=>u({draft:e,onChange:t},"repeat",r),onCustom:i,className:a?"min-h-11":""}):n.jsxs("p",{className:"flex items-center gap-2 text-sm text-fg-muted",children:[n.jsx(z,{className:"size-4 shrink-0 text-fg-subtle","aria-hidden":!0}),e.repeat===A?"Does not repeat":e.repeat]})}function je({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.location,placeholder:"Location","aria-label":"Location",onChange:s=>u({draft:e,onChange:t},"location",s.target.value),className:a?"min-h-11":""})}function Te({draft:e,onChange:t,touch:a}){return n.jsx(f,{value:e.guests,placeholder:"Guests, comma separated","aria-label":"Guests",onChange:s=>u({draft:e,onChange:t},"guests",s.target.value),className:a?"min-h-11":""})}function Ce({draft:e,onChange:t,layout:a="compact"}){return n.jsx("textarea",{value:e.notes,placeholder:"Notes","aria-label":"Notes",onChange:s=>u({draft:e,onChange:t},"notes",s.target.value),rows:a==="pane"?6:3,className:ve})}function De({draft:e,onChange:t,calendars:a,layout:s="compact",expanded:i=!1,onToggleExpanded:r,onSave:l,onCancel:o,onDelete:c,saveLabel:y="Add",header:g,repeatEditable:b=!0,guestsEditable:I=!1,calendarEditable:M=!0,onCustomRepeat:X,touch:m,className:$}){const v=s==="pane",h={draft:e,onChange:t,layout:s,touch:m},w=n.jsx(ge,{...h}),S=n.jsx(be,{...h}),F=n.jsx(Ee,{...h,calendars:a}),R=n.jsx(Ne,{...h,repeatEditable:b,onCustom:X}),Y=n.jsx(je,{...h}),L=n.jsx(Te,{...h}),P=n.jsx(Ce,{...h}),W=n.jsxs("div",{className:d("flex items-center gap-2",v?"pt-2":"pt-1"),children:[n.jsx(j,{variant:"primary",size:m||v?"md":"sm",onClick:l,disabled:H(e),className:m?"min-h-11 flex-1":"",children:y}),n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:o,className:m?"min-h-11":"",children:"Cancel"}),c&&n.jsx(j,{variant:"ghost",size:m||v?"md":"sm",onClick:c,className:d("ml-auto text-danger",m&&"min-h-11"),children:"Delete"})]});if(v)return n.jsxs("div",{className:d("flex flex-col gap-5",$),children:[g,n.jsx(x,{label:"Title",children:w}),n.jsx(x,{label:"When",children:S}),M&&n.jsx(x,{label:"Calendar",children:F}),n.jsx(x,{label:"Repeat",children:R}),n.jsx(x,{label:"Location",children:Y}),I&&n.jsx(x,{label:"Guests",children:L}),n.jsx(x,{label:"Notes",children:P}),W]});const Z=r!==void 0&&!i;return n.jsxs("div",{className:d("flex flex-col gap-3",$),children:[g,w,S,M&&F,r&&n.jsxs("button",{type:"button",onClick:r,"aria-expanded":i,className:d("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",m&&"min-h-11"),children:[i?n.jsx(te,{className:"size-3.5"}):n.jsx(ne,{className:"size-3.5"}),i?"Fewer details":"More details"]}),!Z&&n.jsxs("div",{className:"flex flex-col gap-2 border-t border-line pt-3",children:[Y,I&&L,R,P]}),W]})}const U="__custom__";function ke({value:e,date:t,startTime:a,onChange:s,onCustom:i,className:r}){const l=ye(t,a),o=e===A||l.includes(e)?l:[e,...l];return n.jsxs(ae,{icon:n.jsx(z,{className:"size-4"}),"aria-label":"Repeat",value:e,onChange:c=>{if(c.target.value===U){i?.();return}s(c.target.value)},className:r,children:[n.jsx("option",{value:A,children:"Does not repeat"}),o.map(c=>n.jsx("option",{value:c,children:c},c)),i&&n.jsx("option",{value:U,children:"Custom…"})]})}function Ae({calendars:e,value:t,onChange:a,touch:s}){const i=p.useId();return n.jsxs("fieldset",{className:"flex flex-wrap gap-1.5",children:[n.jsx("legend",{className:"sr-only",children:"Calendar"}),e.map(r=>{const l=he(r.color),o=r.id===t;return n.jsxs("label",{className:d("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",s?"min-h-11":"h-7",o?d(l.soft,l.text,l.border):"border-line text-fg-muted hover:bg-surface-sunken"),children:[n.jsx("input",{type:"radio",name:i,value:r.id,checked:o,onChange:()=>a(r.id),className:"sr-only"}),n.jsx("span",{className:d("size-2 rounded-full",l.solid)}),r.name]},r.id)})]})}function Oe({title:e,subtitle:t,onClose:a,children:s,className:i}){return n.jsxs("section",{className:d("flex h-full w-full flex-col bg-surface",i),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:a,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(se,{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:s})})]})}const E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["SU","MO","TU","WE","TH","FR","SA"],Q=["January","February","March","April","May","June","July","August","September","October","November","December"],G=["first","second","third","fourth","last"],K=[1,2,3,4,-1],J="MO,TU,WE,TH,FR",Ie=e=>e.replace(/,\s*\d{2}:\d{2}$/,"").trim();function O(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 a=t.match(/^Every week on (\w+)$/);if(a){const r=E.indexOf(a[1]);return r===-1?void 0:`FREQ=WEEKLY;BYDAY=${N[r]}`}const s=t.match(/^Every month on the (\w+) (\w+)$/);if(s){const r=G.indexOf(s[1]),l=E.indexOf(s[2]);return r===-1||l===-1?void 0:`FREQ=MONTHLY;BYDAY=${K[r]}${N[l]}`}const i=t.match(/^Every year on (\d{1,2}) (\w+)$/);if(i){const r=Q.indexOf(i[2]);return r===-1?void 0:`FREQ=YEARLY;BYMONTH=${r+1};BYMONTHDAY=${Number(i[1])}`}}const Me=e=>e===""?"":`, ${e}`;function Pe(e,t){const a=new Map(e.split(";").map(l=>l.split("=")).filter(l=>l.length===2).map(([l,o])=>[l.toUpperCase(),o.toUpperCase()])),s=Me(t),i=a.get("FREQ"),r=a.get("BYDAY");if(!(a.has("INTERVAL")&&a.get("INTERVAL")!=="1")&&!(a.has("UNTIL")||a.has("COUNT"))){if(i==="DAILY")return`Every day${s}`;if(i==="WEEKLY"){if(r===void 0)return;if(r===J)return`Every weekday${s}`;const l=N.indexOf(r);return l===-1?void 0:`Every week on ${E[l]}${s}`}if(i==="MONTHLY"){const l=r?.match(/^(-?\d)([A-Z]{2})$/);if(!l)return;const o=K.indexOf(Number(l[1])),c=N.indexOf(l[2]);return o===-1||c===-1?void 0:`Every month on the ${G[o]} ${E[c]}${s}`}if(i==="YEARLY"){const l=Number(a.get("BYMONTH")),o=Number(a.get("BYMONTHDAY"));return!l||!o||l>12?void 0:`Every year on ${o} ${Q[l-1]}${s}`}}}function We(e,t){return{title:"",date:e,startTime:"09:00",endTime:"10:00",allDay:!1,calendarId:t,location:"",guests:"",notes:"",repeat:""}}function _e(e,t){return{title:e.title,date:e.start.slice(0,10),startTime:e.allDay?"":e.start.slice(11,16),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:ee(e.date,1)}:{start:_(e.date,e.startTime,t),end:_(e.date,e.endTime,t)}}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.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.endTime<=e.startTime?"The end time is not after the start time. Move one of them.":t&&O(e.repeat)===void 0?"This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.":""}function Ue(e,t){const a=V(e,!0);if(a!=="")return{ok:!1,problem:a};const{start:s,end:i}=q(e,t);return{ok:!0,input:{calendarId:e.calendarId,summary:e.title.trim(),description:e.notes,location:e.location,start:s,end:i,allDay:e.allDay,...t===""?{}:{timeZone:t},recurrenceRule:O(e.repeat)??""}}}function Be(e,t,a){const s=t.repeat!==e.repeat,i=V(t,s);if(i!=="")return{ok:!1,problem:i};const r={};if(t.title.trim()!==e.title.trim()&&(r.summary=t.title.trim()),t.location!==e.location&&(r.location=t.location),t.notes!==e.notes&&(r.description=t.notes),t.date!==e.date||t.startTime!==e.startTime||t.endTime!==e.endTime||t.allDay!==e.allDay){const{start:o,end:c}=q(t,a);r.start=o,r.end=c,r.allDay=t.allDay,a!==""&&(r.timeZone=a)}return s&&(r.recurrenceRule=O(t.repeat)??""),{ok:!0,patch:r}}const C=ce(400,404,412),$e=new Set(["calendarEventOperationsListCalendarEvents","calendarEventDetailOperationsGetCalendarEvent","calendarFreeBusyOperationsListCalendarFreeBusy"]),D={kind:"written"},k=e=>de(e)===412?{kind:"conflict"}:{kind:"refused",message:me(e)},we={this:"This",following:"Following",all:"All"};function Se(){const e=oe();return p.useCallback(()=>{e.invalidateQueries({predicate:t=>{const a=t.queryKey[0];if(typeof a!="object"||a===null)return!1;const s=a._id;return typeof s=="string"&&$e.has(s)}})},[e])}const B=({scope:e,recurrenceId:t})=>e===void 0||e==="all"?{}:{scope:we[e],recurrenceId:t};function ze(){const e=Se(),t=T({...re(),meta:C,onSuccess:e}),a=T({...ie(),meta:C,onSuccess:e}),s=T({...le(),meta:C,onSuccess:e}),i=p.useCallback(o=>t.mutateAsync({body:o}).then(()=>D).catch(k),[t]),r=p.useCallback((o,c)=>a.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag},body:c}).then(()=>D).catch(k),[a]),l=p.useCallback(o=>s.mutateAsync({path:{calendarObjectId:o.calendarObjectId},query:{calendarId:o.calendarId,...B(o)},headers:{"If-Match":o.etag}}).then(()=>D).catch(k),[s]);return p.useMemo(()=>({createEvent:i,updateEvent:r,deleteEvent:l,isWriting:t.isPending||a.isPending||s.isPending}),[i,r,l,t.isPending,a.isPending,s.isPending])}function He({title:e,subtitle:t,calendars:a,draft:s,onChange:i,problem:r,saveLabel:l,isSaving:o,repeatEditable:c=!0,calendarEditable:y=!0,onSave:g,onCancel:b}){return n.jsx(Oe,{title:e,subtitle:t,onClose:b,children:n.jsx(De,{draft:s,onChange:i,calendars:a,layout:"pane",repeatEditable:c,calendarEditable:y,saveLabel:o?"Saving…":l,onSave:g,onCancel:b,header:r===""?void 0: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(ue,{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:r})]})})})}export{He as C,Ue as c,_e as d,We as e,Be as p,Pe as t,ze as u};
@@ -1 +1 @@
1
- import{j as t,r as e}from"./index-BstTD6DD.js";const o=e.createContext(void 0),C=({pick:s,children:r})=>t.jsx(o.Provider,{value:s,children:r}),d=()=>e.useContext(o);export{C,d as u};
1
+ import{j as t,r as e}from"./index-Dy5D6YkV.js";const o=e.createContext(void 0),C=({pick:s,children:r})=>t.jsx(o.Provider,{value:s,children:r}),d=()=>e.useContext(o);export{C,d as u};
@@ -1 +1 @@
1
- import{r,j as n,am as l,an as o}from"./index-BstTD6DD.js";const i=r.createContext(null),v=({chrome:s,children:a})=>n.jsx(i.Provider,{value:s,children:a});function C({workspace:s,reading:a,hasOpenEvent:x}){const e=r.useContext(i);if(!e)return n.jsx(l,{});const t={nav:e.nav,skeleton:n.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav,listBias:"list"};return e.isSinglePane?n.jsx(o,{...t,list:x?a:s}):n.jsx(o,{...t,list:s,reading:a})}export{v as C,C as a};
1
+ import{r,j as n,am as l,an as o}from"./index-Dy5D6YkV.js";const i=r.createContext(null),v=({chrome:s,children:a})=>n.jsx(i.Provider,{value:s,children:a});function C({workspace:s,reading:a,hasOpenEvent:x}){const e=r.useContext(i);if(!e)return n.jsx(l,{});const t={nav:e.nav,skeleton:n.jsx(l,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav,listBias:"list"};return e.isSinglePane?n.jsx(o,{...t,list:x?a:s}):n.jsx(o,{...t,list:s,reading:a})}export{v as C,C as a};
@@ -1 +1 @@
1
- import{j as e}from"./index-BstTD6DD.js";const x=({message:s,icon:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&e.jsx("div",{className:"mb-4 text-fg-muted",children:t}),e.jsx("p",{className:"text-fg-muted",children:s})]});export{x as E};
1
+ import{j as e}from"./index-Dy5D6YkV.js";const x=({message:s,icon:t})=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t&&e.jsx("div",{className:"mb-4 text-fg-muted",children:t}),e.jsx("p",{className:"text-fg-muted",children:s})]});export{x as E};
@@ -1 +1 @@
1
- import{j as t,a0 as r}from"./index-BstTD6DD.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.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:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,a0 as r}from"./index-Dy5D6YkV.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.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:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -1 +1 @@
1
- import{ew as H,r as n,dX as G,c as J,C as V,bm as ge,cN as he,a_ as me,a$ as pe,j as r,al as fe,cZ as Ie,c_ as xe}from"./index-BstTD6DD.js";import{u as Te,p as U,R as ye}from"./useSearchTokenContext-Q-PYaS79.js";import{A as be,E as ve,am as X,az as Se,aA as Ce,an as we,aB as Re,ap as Fe,b as Me,M as je,aw as Oe,aC as ke,ay as Pe,m as Ae,J as Le,O as $,N as Ne,K as Ee,d as qe,Y as De,Z as Be,$ as Y,a0 as ee,a1 as Qe,a2 as _e,a3 as Ke}from"./MailListHeader-CtLJO_kX.js";import{u as ze,l as He,b as Ge,a as Ve}from"./MailViewChrome-DUkQ3XCS.js";import{f as We}from"./ErrorState-BRKdts_G.js";import{d as z,w as Ze}from"./wizard-selection-DxUM65kM.js";import{a as Ue}from"./useMessageBodyContent-D8al5oah.js";import{g as Xe,h as $e}from"./search-token-index-B8GTncCY.js";import{u as Je}from"./sections-DCf8ouIL.js";const q=e=>({...e,starred:!0,order:"desc"}),Ye=(e={})=>G({query:q(e)});function te(e={}){const{data:t,isLoading:s,isError:a,error:l,refetch:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:h}=ze({queryKey:Ye(e),queryFn:async({pageParam:I})=>{const{data:u}=await H({query:{...q(e),continuationToken:I},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:I=>I.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(t?.pages??[]).flatMap(I=>I.items??[]),[t]),isLoading:s,isError:a,error:l,refetch:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:h}}function et(e,t){const s=e.query??"",a={...q(e),limit:t},{data:l}=J({queryKey:G({query:a}),queryFn:async()=>{const{data:c}=await H({query:a,throwOnError:!0});return c},enabled:s.length>0,staleTime:3e4});return n.useMemo(()=>l?.items??[],[l])}function tt(e={}){const t={...q(e),unread:!0,count:!0,results:!1},{data:s}=J({queryKey:G({query:t}),queryFn:async()=>{const{data:a}=await H({query:t,throwOnError:!0});return a},staleTime:6e4});return s?.count}const st=["category","unread","starred","attachments"],at=(e,t)=>{const s=be(e),{params:a,residual:l}=ve(t,{...s,starred:!0},st);return{criteria:{...a,...s},residual:l}},rt=200;function ot({rows:e,verb:t}){const{selectedIds:s,exitSelection:a}=Pe(),l=n.useMemo(()=>Ze(e,s),[e,s]);return r.jsx(Ae,{verb:t,selection:l,selectionRestriction:"spansAccounts",onFinished:a})}function nt({selectedMessageId:e,onOpenThread:t,commandsRef:s,onTriageContextChange:a,onDeleteMessages:l}){const{searchQuery:c,resultFolderIndex:i,onSearchClearQuery:g}=V(),h=Te(),k=ge(),I=he(),[u,m]=n.useState("all"),[S,P]=n.useState(new Set),w=n.useCallback(d=>{P(b=>{const f=new Set(b);return f.has(d)?f.delete(d):f.add(d),f})},[]),R=n.useCallback(()=>{m("all"),P(new Set)},[]),T=n.useCallback(()=>{R(),g()},[R,g]),{freeText:x,tokens:C}=U(c.trim().toLowerCase(),h),A=U(c.trim(),h).freeText,{criteria:F,residual:p}=n.useMemo(()=>at({category:u,attributes:S},C),[u,S,C]),M=n.useMemo(()=>x?{...F,query:x}:F,[F,x]),{threads:L,isLoading:N,isError:v,error:B,refetch:j,fetchNextPage:Q,hasNextPage:_,isFetchingNextPage:O}=te(F),E=et(M,rt),o=n.useMemo(()=>{const d=z(L).map(X),b=x?Se(d.filter(f=>Ce(f,x)),z(E).map(X)):d;return z(b).filter(f=>we(f,p))},[L,E,x,p]),y=n.useCallback((d,b)=>{const f=o.find(ue=>ue.id===d)?.threadId;f&&t?.({threadId:f,messageId:d},b)},[o,t]),K=n.useCallback(d=>{const b=d.threadId??o.find(f=>f.id===d.id)?.threadId;b&&t?.({threadId:b,messageId:d.id})},[o,t]),re=n.useMemo(()=>Re(),[]),oe=n.useMemo(()=>o.map(d=>Fe(d,i)),[o,i]),ne=tt(M)??null,ie=n.useMemo(()=>C.filter(d=>d.type!=="isStarred"),[C]),de=He({chips:{category:u,attributes:S},tokens:ie,reach:p.length>0||x?"loaded-pages":"whole-folder",onClear:T}),W=N?"loading":v?"error":o.length===0?"empty":"ready",le=n.useCallback(()=>{const d=me(pe());window.open(d,"_blank","noopener,noreferrer")},[]),Z=Me(),ce=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:o.map(d=>r.jsx(je,{thread:d,active:d.id===e,onClick:()=>y(d.id)},d.id))}),_?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>Q(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(Ge,{title:"Starred",unreadCount:ne,preset:re,selectedCategory:u,activeFilters:S,onSelectCategory:m,onToggleFilter:w,onClearFilters:R,searchResults:oe,searchLoading:N,onSelectSearchResult:K,searchResultsInBody:!0,children:r.jsxs(Oe,{selectedMessageId:e,rows:o,onOpen:y,onDeleteMessages:l,onSelectionVerb:I.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(Ve,{listTitle:"Starred",sections:[{id:"flagged",threads:o}],flatList:!0,hideHeader:!0,listState:Z.searchResults?"ready":W,listFilter:de,listScopeLabel:"Starred",searchQuery:A||void 0,errorMessage:v?We(B):void 0,onRetry:()=>j(),onReportError:le,selectedThreadId:e,onSelectThread:y,isDesktop:k,selectionBar:r.jsx(ke,{title:"Starred"}),listBody:Z.searchResults??(W==="ready"?ce:void 0)}),r.jsx(ot,{rows:o,verb:I.verb})]})})}const se=n.createContext(null);function D(){const e=n.useContext(se);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function it({thread:e,children:t}){const s=Xe(),a=$e(),l=Je(),{searchInput:c}=V(),i=e?.threadId,g=e?.messageId,{threads:h}=te(),k=n.useMemo(()=>{if(i)return h.find(o=>o.messageId===g)??h.find(o=>o.threadId===i)},[h,i,g]),I=Le(i,g),u=k??I,m=g??u?.messageId,S=n.useMemo(()=>{if(i)return{threadId:i,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:m,authenticity:u?.authenticity}},[i,u,m]),P=n.useCallback((o,y)=>{s(o,{replace:y?.replace,query:c})},[s,c]),w=n.useCallback(o=>{m&&o.includes(m)&&a()},[m,a]),R=$({thread:u,isOpen:!0,onAfterOptimisticRemove:w}),T=Ne(),{deleteMessages:x}=Ee({mailboxId:u?.mailboxId??"",messages:h,onAfterOptimisticRemove:w}),{toggleReadFor:C}=qe({mailboxId:u?.mailboxId??"",messages:h}),A=T.focusedMessageId,p=n.useMemo(()=>h.find(o=>o.messageId===A),[h,A])??u,M=$({thread:p,isOpen:p?.messageId===m}),L=Ue(),N=fe(),v=Ie(),B=n.useMemo(()=>xe(v,i,m),[v,i,m]),j=n.useMemo(()=>{if(p)return o=>v({threadId:p.threadId,messageId:p.messageId,mode:o})},[v,p]),{nextMessageId:Q,previousMessageId:_}=De({context:T,orderedIds:T.orderedIds,selectedMessageId:m,enabled:!L&&!N,hasOpenThread:i!==void 0,onClose:a,handlers:{reply:()=>j?.("reply"),replyAll:()=>j?.("reply-all"),forward:()=>j?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||M.deleteThread()},toggleStar:M.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||p&&C([p.messageId],!p.isRead)},goBrief:()=>l("brief"),goSettings:()=>l("settings")}}),O=n.useCallback(o=>{if(!o)return;const y=h.find(K=>K.messageId===o);return y?{threadId:y.threadId,messageId:o}:void 0},[h]),E={selectedMessageId:m,selectedThread:u,conversation:S,onOpenThread:P,onCloseThread:a,nextThread:O(Q),previousThread:O(_),actions:R,onReply:B,triage:T,onDeleteMessages:x,handleDeselectIfRemoved:w};return r.jsx(se.Provider,{value:E,children:t})}function ae(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:a}=D();return r.jsx(nt,{selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function dt(){const{conversation:e,selectedThread:t,actions:s,onReply:a,handleDeselectIfRemoved:l}=D(),c=!!e,i=_e(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(Ke,{hasThread:c,intelligenceOpen:i.isShowing,canToggleIntelligence:i.canToggle,onToggleIntelligence:i.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:c?s.deleteThread:void 0,onToggleStar:c?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:c&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.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:i.open,listOnScreen:!0}):r.jsx(ye,{})})]}),r.jsx(ee,{isOpen:i.drawerOpen,onClose:i.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:l})]})}function lt(){const{selectedThread:e,handleDeselectIfRemoved:t}=D(),{onToggleIntelligence:s}=V();return r.jsx(Qe,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function ct(){const{selectedThread:e,conversation:t,onCloseThread:s,onOpenThread:a,nextThread:l,previousThread:c,handleDeselectIfRemoved:i}=D(),g=Be(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(Y,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:s,onOpenIntelligence:g.toggle,onSwipeNext:l?()=>a(l):void 0,onSwipePrevious:c?()=>a(c):void 0,mobileIntelligenceOpen:g.isOpen}),r.jsx(ee,{isOpen:g.isOpen,onClose:g.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(ae,{})})}const yt=Object.assign(it,{List:ae,Reading:dt,Intelligence:lt,Phone:ct});export{yt as F};
1
+ import{ew as H,r as n,dX as G,c as J,C as V,bm as ge,cN as he,a_ as me,a$ as pe,j as r,al as fe,cZ as Ie,c_ as xe}from"./index-Dy5D6YkV.js";import{u as Te,p as U,R as ye}from"./useSearchTokenContext-BDaT1iE0.js";import{A as be,E as ve,am as X,az as Se,aA as Ce,an as we,aB as Re,ap as Fe,b as Me,M as je,aw as Oe,aC as ke,ay as Pe,m as Ae,J as Le,O as $,N as Ne,K as Ee,d as qe,Y as De,Z as Be,$ as Y,a0 as ee,a1 as Qe,a2 as _e,a3 as Ke}from"./MailListHeader-DixjeKWo.js";import{u as ze,l as He,b as Ge,a as Ve}from"./MailViewChrome-B2e9uACs.js";import{f as We}from"./ErrorState-yTshApcZ.js";import{d as z,w as Ze}from"./wizard-selection-DxUM65kM.js";import{a as Ue}from"./useMessageBodyContent-Dqn8BKJN.js";import{g as Xe,h as $e}from"./search-token-index-RpS46UX-.js";import{u as Je}from"./sections-DpPFeJvC.js";const q=e=>({...e,starred:!0,order:"desc"}),Ye=(e={})=>G({query:q(e)});function te(e={}){const{data:t,isLoading:s,isError:a,error:l,refetch:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:h}=ze({queryKey:Ye(e),queryFn:async({pageParam:I})=>{const{data:u}=await H({query:{...q(e),continuationToken:I},throwOnError:!0});return u},initialPageParam:void 0,getNextPageParam:I=>I.continuationToken,staleTime:6e4});return{threads:n.useMemo(()=>(t?.pages??[]).flatMap(I=>I.items??[]),[t]),isLoading:s,isError:a,error:l,refetch:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:h}}function et(e,t){const s=e.query??"",a={...q(e),limit:t},{data:l}=J({queryKey:G({query:a}),queryFn:async()=>{const{data:c}=await H({query:a,throwOnError:!0});return c},enabled:s.length>0,staleTime:3e4});return n.useMemo(()=>l?.items??[],[l])}function tt(e={}){const t={...q(e),unread:!0,count:!0,results:!1},{data:s}=J({queryKey:G({query:t}),queryFn:async()=>{const{data:a}=await H({query:t,throwOnError:!0});return a},staleTime:6e4});return s?.count}const st=["category","unread","starred","attachments"],at=(e,t)=>{const s=be(e),{params:a,residual:l}=ve(t,{...s,starred:!0},st);return{criteria:{...a,...s},residual:l}},rt=200;function ot({rows:e,verb:t}){const{selectedIds:s,exitSelection:a}=Pe(),l=n.useMemo(()=>Ze(e,s),[e,s]);return r.jsx(Ae,{verb:t,selection:l,selectionRestriction:"spansAccounts",onFinished:a})}function nt({selectedMessageId:e,onOpenThread:t,commandsRef:s,onTriageContextChange:a,onDeleteMessages:l}){const{searchQuery:c,resultFolderIndex:i,onSearchClearQuery:g}=V(),h=Te(),k=ge(),I=he(),[u,m]=n.useState("all"),[S,P]=n.useState(new Set),w=n.useCallback(d=>{P(b=>{const f=new Set(b);return f.has(d)?f.delete(d):f.add(d),f})},[]),R=n.useCallback(()=>{m("all"),P(new Set)},[]),T=n.useCallback(()=>{R(),g()},[R,g]),{freeText:x,tokens:C}=U(c.trim().toLowerCase(),h),A=U(c.trim(),h).freeText,{criteria:F,residual:p}=n.useMemo(()=>at({category:u,attributes:S},C),[u,S,C]),M=n.useMemo(()=>x?{...F,query:x}:F,[F,x]),{threads:L,isLoading:N,isError:v,error:B,refetch:j,fetchNextPage:Q,hasNextPage:_,isFetchingNextPage:O}=te(F),E=et(M,rt),o=n.useMemo(()=>{const d=z(L).map(X),b=x?Se(d.filter(f=>Ce(f,x)),z(E).map(X)):d;return z(b).filter(f=>we(f,p))},[L,E,x,p]),y=n.useCallback((d,b)=>{const f=o.find(ue=>ue.id===d)?.threadId;f&&t?.({threadId:f,messageId:d},b)},[o,t]),K=n.useCallback(d=>{const b=d.threadId??o.find(f=>f.id===d.id)?.threadId;b&&t?.({threadId:b,messageId:d.id})},[o,t]),re=n.useMemo(()=>Re(),[]),oe=n.useMemo(()=>o.map(d=>Fe(d,i)),[o,i]),ne=tt(M)??null,ie=n.useMemo(()=>C.filter(d=>d.type!=="isStarred"),[C]),de=He({chips:{category:u,attributes:S},tokens:ie,reach:p.length>0||x?"loaded-pages":"whole-folder",onClear:T}),W=N?"loading":v?"error":o.length===0?"empty":"ready",le=n.useCallback(()=>{const d=me(pe());window.open(d,"_blank","noopener,noreferrer")},[]),Z=Me(),ce=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:o.map(d=>r.jsx(je,{thread:d,active:d.id===e,onClick:()=>y(d.id)},d.id))}),_?r.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>Q(),disabled:O,children:O?"Loading…":"Load more"}):null]})});return r.jsx(Ge,{title:"Starred",unreadCount:ne,preset:re,selectedCategory:u,activeFilters:S,onSelectCategory:m,onToggleFilter:w,onClearFilters:R,searchResults:oe,searchLoading:N,onSelectSearchResult:K,searchResultsInBody:!0,children:r.jsxs(Oe,{selectedMessageId:e,rows:o,onOpen:y,onDeleteMessages:l,onSelectionVerb:I.start,commandsRef:s,onTriageContextChange:a,children:[r.jsx(Ve,{listTitle:"Starred",sections:[{id:"flagged",threads:o}],flatList:!0,hideHeader:!0,listState:Z.searchResults?"ready":W,listFilter:de,listScopeLabel:"Starred",searchQuery:A||void 0,errorMessage:v?We(B):void 0,onRetry:()=>j(),onReportError:le,selectedThreadId:e,onSelectThread:y,isDesktop:k,selectionBar:r.jsx(ke,{title:"Starred"}),listBody:Z.searchResults??(W==="ready"?ce:void 0)}),r.jsx(ot,{rows:o,verb:I.verb})]})})}const se=n.createContext(null);function D(){const e=n.useContext(se);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function it({thread:e,children:t}){const s=Xe(),a=$e(),l=Je(),{searchInput:c}=V(),i=e?.threadId,g=e?.messageId,{threads:h}=te(),k=n.useMemo(()=>{if(i)return h.find(o=>o.messageId===g)??h.find(o=>o.threadId===i)},[h,i,g]),I=Le(i,g),u=k??I,m=g??u?.messageId,S=n.useMemo(()=>{if(i)return{threadId:i,mailboxId:u?.mailboxId??"",subject:u?.subject,messageId:m,authenticity:u?.authenticity}},[i,u,m]),P=n.useCallback((o,y)=>{s(o,{replace:y?.replace,query:c})},[s,c]),w=n.useCallback(o=>{m&&o.includes(m)&&a()},[m,a]),R=$({thread:u,isOpen:!0,onAfterOptimisticRemove:w}),T=Ne(),{deleteMessages:x}=Ee({mailboxId:u?.mailboxId??"",messages:h,onAfterOptimisticRemove:w}),{toggleReadFor:C}=qe({mailboxId:u?.mailboxId??"",messages:h}),A=T.focusedMessageId,p=n.useMemo(()=>h.find(o=>o.messageId===A),[h,A])??u,M=$({thread:p,isOpen:p?.messageId===m}),L=Ue(),N=fe(),v=Ie(),B=n.useMemo(()=>xe(v,i,m),[v,i,m]),j=n.useMemo(()=>{if(p)return o=>v({threadId:p.threadId,messageId:p.messageId,mode:o})},[v,p]),{nextMessageId:Q,previousMessageId:_}=De({context:T,orderedIds:T.orderedIds,selectedMessageId:m,enabled:!L&&!N,hasOpenThread:i!==void 0,onClose:a,handlers:{reply:()=>j?.("reply"),replyAll:()=>j?.("reply-all"),forward:()=>j?.("forward"),delete:()=>{T.listCommandsRef.current?.requestVerb("delete")||M.deleteThread()},toggleStar:M.toggleStar,toggleRead:()=>{T.listCommandsRef.current?.requestVerb("markRead")||p&&C([p.messageId],!p.isRead)},goBrief:()=>l("brief"),goSettings:()=>l("settings")}}),O=n.useCallback(o=>{if(!o)return;const y=h.find(K=>K.messageId===o);return y?{threadId:y.threadId,messageId:o}:void 0},[h]),E={selectedMessageId:m,selectedThread:u,conversation:S,onOpenThread:P,onCloseThread:a,nextThread:O(Q),previousThread:O(_),actions:R,onReply:B,triage:T,onDeleteMessages:x,handleDeselectIfRemoved:w};return r.jsx(se.Provider,{value:E,children:t})}function ae(){const{selectedMessageId:e,onOpenThread:t,triage:s,onDeleteMessages:a}=D();return r.jsx(nt,{selectedMessageId:e,onOpenThread:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:a})}function dt(){const{conversation:e,selectedThread:t,actions:s,onReply:a,handleDeselectIfRemoved:l}=D(),c=!!e,i=_e(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(Ke,{hasThread:c,intelligenceOpen:i.isShowing,canToggleIntelligence:i.canToggle,onToggleIntelligence:i.toggle,onReply:a?()=>a("reply"):void 0,onReplyAll:a?()=>a("reply-all"):void 0,onForward:a?()=>a("forward"):void 0,onDelete:c?s.deleteThread:void 0,onToggleStar:c?s.toggleStar:void 0,isStarred:s.isStarred,moveContext:c&&s.accountId&&s.mailboxId?{accountId:s.accountId,currentMailboxId:s.mailboxId,onMove:s.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:i.open,listOnScreen:!0}):r.jsx(ye,{})})]}),r.jsx(ee,{isOpen:i.drawerOpen,onClose:i.closeDrawer,thread:t,mailboxId:t?.mailboxId,accountId:t?.accountId,onAfterOptimisticRemove:l})]})}function lt(){const{selectedThread:e,handleDeselectIfRemoved:t}=D(),{onToggleIntelligence:s}=V();return r.jsx(Qe,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function ct(){const{selectedThread:e,conversation:t,onCloseThread:s,onOpenThread:a,nextThread:l,previousThread:c,handleDeselectIfRemoved:i}=D(),g=Be(t?.threadId??null);return t?r.jsxs(r.Fragment,{children:[r.jsx(Y,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:s,onOpenIntelligence:g.toggle,onSwipeNext:l?()=>a(l):void 0,onSwipePrevious:c?()=>a(c):void 0,mobileIntelligenceOpen:g.isOpen}),r.jsx(ee,{isOpen:g.isOpen,onClose:g.close,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:i})]}):r.jsx("div",{className:"h-full",children:r.jsx(ae,{})})}const yt=Object.assign(it,{List:ae,Reading:dt,Intelligence:lt,Phone:ct});export{yt as F};
@@ -1 +1 @@
1
- import{r as n,c as f,d as m,G as N,j as e,bm as w,X as E}from"./index-BstTD6DD.js";import{E as u}from"./ErrorState-BRKdts_G.js";import{D as r,C as x,u as k}from"./index-COXmbPoi.js";import{c as p,d as h,e as b}from"./useMessageBodyContent-D8al5oah.js";import{C as S}from"./confirm-dialog-DmMkRipf.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},q=()=>{const t=p(),i=h(),s=b(),a=w(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(E,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{q as F};
1
+ import{r as n,c as f,d as m,G as N,j as e,bm as w,X as E}from"./index-Dy5D6YkV.js";import{E as u}from"./ErrorState-yTshApcZ.js";import{D as r,C as x,u as k}from"./index-ELhtBEwQ.js";import{c as p,d as h,e as b}from"./useMessageBodyContent-Dqn8BKJN.js";import{C as S}from"./confirm-dialog-BnvctSkU.js";const C=t=>t?"Draft":"New Message",I=()=>{const t=n.useRef(!1);return n.useCallback(()=>{const s=document.querySelector("[data-subject-field]")?.value??"",o=(document.querySelector('[data-testid="compose-body"]')?.textContent??"").replace(/--\s*/g,"").trim();return t.current=s.trim().length>0||o.length>0,t.current},[])},O=()=>{const t=p(),i=h(),s=b(),a=I(),[l,o]=n.useState(!1),{isError:d,error:c,refetch:g}=f({...m(),staleTime:1/0}),j=n.useCallback(D=>{D||(a()?o(!0):s())},[s,a]),y=n.useCallback(()=>{o(!1),s()},[s]),v=n.useCallback(()=>{o(!1)},[]);return N({id:"mobile-compose",open:!0}),e.jsxs(r.Root,{open:!0,onOpenChange:j,children:[e.jsxs(r.Portal,{children:[e.jsx(r.Overlay,{className:"fixed inset-0 z-40 bg-black/40"}),e.jsxs(r.Content,{className:"fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-lg bg-canvas pb-[env(safe-area-inset-bottom,0px)]",style:{height:"95dvh"},children:[e.jsx(r.Handle,{className:"mx-auto mt-2 mb-1 h-1.5 w-12 rounded-full bg-fg-muted/30"}),e.jsx(r.Title,{className:"px-4 py-2 text-base font-semibold border-b border-line",children:C(t)}),d?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:c,onRetry:()=>{g()}})}):e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})]}),e.jsx(S,{isOpen:l,title:"Discard draft?",description:"Your message has unsaved content. Are you sure you want to discard it?",confirmLabel:"Discard",cancelLabel:"Keep editing",destructive:!0,onConfirm:y,onCancel:v})]})},q=()=>{const t=p(),i=h(),s=b(),a=w(),{isError:l,error:o,refetch:d}=f({...m(),staleTime:1/0});if(k({bindings:[{key:"Escape",handler:s,preventDefault:!0}]}),!a)return e.jsx(O,{});const c=e.jsxs("header",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-line shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h2",{className:"text-lg font-semibold truncate",children:C(t)})}),e.jsx("button",{type:"button",onClick:s,className:"p-2 rounded-md hover:bg-surface-raised transition-colors min-h-11 min-w-11 inline-flex items-center justify-center","aria-label":"Close",children:e.jsx(E,{className:"size-5"})})]});return l?e.jsxs("div",{className:"h-full flex flex-col bg-canvas",children:[c,e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx(u,{title:"Couldn't load compose",error:o,onRetry:()=>{d()}})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-canvas",children:[c,e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(x,{mode:"new",outboxMessageId:t,onDraftCreated:i,onClose:s})})]})};export{q as F};