@remit/web-client-dist 0.0.329 → 0.0.331
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.
- package/assets/BriefPane-B4OnBw7A.js +1 -0
- package/assets/{ErrorState-CzVRekaj.js → ErrorState-9wFdKXpo.js} +1 -1
- package/assets/FlaggedPane-VNYPSCvj.js +1 -0
- package/assets/MailListHeader-CA5lvtZs.js +52 -0
- package/assets/{MailViewChrome-BUsgxqXW.js → MailViewChrome-D-68x2uE.js} +1 -1
- package/assets/{MailboxPane-CqHZRWpk.js → MailboxPane-BWOjvlNs.js} +1 -1
- package/assets/{NavMenuButton-CLIGmcnp.js → NavMenuButton-cseqHrgr.js} +1 -1
- package/assets/{OnboardingWizard-BjqUPTrN.js → OnboardingWizard-DAdN9w-x.js} +1 -1
- package/assets/{OutboxPane-BttDTEiM.js → OutboxPane-VocIZWXW.js} +1 -1
- package/assets/_mailboxId-BYy5x0wE.js +1 -0
- package/assets/_messageId-0tY_nYQ1.js +1 -0
- package/assets/_messageId-C7Dc1hnG.js +1 -0
- package/assets/_messageId-C8LAzwtA.js +1 -0
- package/assets/_outboxMessageId-BHx_kFyq.js +1 -0
- package/assets/_threadId-BpoqHy6Q.js +1 -0
- package/assets/_threadId-Dcpkewj-.js +1 -0
- package/assets/_threadId-QRWabVsi.js +1 -0
- package/assets/{account-form-helpers-D3BmrOtk.js → account-form-helpers-COfJkI9V.js} +1 -1
- package/assets/{accounts-BCJcVJMA.js → accounts-CZ83UwON.js} +1 -1
- package/assets/{advanced-DTlPeWfG.js → advanced-CIk7-tvi.js} +1 -1
- package/assets/{appearance-CvjOQyT-.js → appearance-DamZUddD.js} +1 -1
- package/assets/{avatar-BaI4pwX1.js → avatar-BvDbtKy6.js} +1 -1
- package/assets/{bottom-sheet-hxzJ8dsp.js → bottom-sheet-0UhJ47Gv.js} +1 -1
- package/assets/brief-CAe8f7q6.js +1 -0
- package/assets/{brief-BoSR0o3w.js → brief-JcrOpUjt.js} +1 -1
- package/assets/{browser-ponyfill-VD1oW-Yx.js → browser-ponyfill-CU-pwafu.js} +1 -1
- package/assets/{circle-check-DwqsdvSv.js → circle-check-Bxbx7HfB.js} +1 -1
- package/assets/{circle-check-big-dKcwkkHZ.js → circle-check-big-CjzecMB6.js} +1 -1
- package/assets/{circle-help-xXiA5uCy.js → circle-help-BK_hzj_i.js} +1 -1
- package/assets/{clock-PKLYWi-Z.js → clock-B1X_i57Q.js} +1 -1
- package/assets/{confirm-dialog-CNtS-ofA.js → confirm-dialog-Dh8sRH0e.js} +1 -1
- package/assets/{download-CdHAEhpF.js → download-CZ0V6I3x.js} +1 -1
- package/assets/{filters-mjAb27fM.js → filters-CdfgcLH2.js} +1 -1
- package/assets/flagged-5fgl4f2w.js +1 -0
- package/assets/{flagged-ed3sNTxR.js → flagged-DZMd8zSP.js} +1 -1
- package/assets/{folders-BUABNsk3.js → folders-CWWWGsQ5.js} +1 -1
- package/assets/index-B3m_6Q-7.js +1 -0
- package/assets/index-C7Dc1hnG.js +1 -0
- package/assets/index-C8LAzwtA.js +1 -0
- package/assets/index-CHntB8XM.js +1 -0
- package/assets/index-DIEk2vzA.js +1 -0
- package/assets/index-DdWkZUge.js +1 -0
- package/assets/index-DgAf2bQz.js +1 -0
- package/assets/index-DuJrRaFE.js +1 -0
- package/assets/{index-DUmy4dAt.js → index-tka6wZr_.js} +61 -61
- package/assets/{kbd-ZwFtVenb.js → kbd-Dt_vzEGr.js} +1 -1
- package/assets/{labels-VFREJRVy.js → labels-DIFvP3py.js} +1 -1
- package/assets/mail-O6_yrku3.js +1 -0
- package/assets/{menu--KUkZ_qm.js → menu-DAXEVDbj.js} +1 -1
- package/assets/{move-options-no92VJ_6.js → move-options-MgiRekSU.js} +1 -1
- package/assets/{nav-link-BNOG4p36.js → nav-link-CBO_nghm.js} +1 -1
- package/assets/{onboarding-Xfopwu7x.js → onboarding-BY09gnzV.js} +1 -1
- package/assets/outbox-CvxSD7ed.js +1 -0
- package/assets/{pencil-HMl3G0Nq.js → pencil-B5Es_aSh.js} +1 -1
- package/assets/rich-text-DmHS1zFG.js +29 -0
- package/assets/rich-text-spellcheck-words-C1Zx88ZY.js +1 -0
- package/assets/rich-text-spellcheck-worker-C399ph5r.js +1 -0
- package/assets/rich-text-spellcheck-worker-provider-CYQ5Q4f9.js +1 -0
- package/assets/{rotate-ccw-BGsIm2za.js → rotate-ccw-Bez3srEV.js} +1 -1
- package/assets/{row-actions-B_xPLliI.js → row-actions-Bqp5HmTh.js} +1 -1
- package/assets/{search-scope-C067nTlg.js → search-scope-By6SdCOd.js} +1 -1
- package/assets/{search-token-index-DnLe4VlS.js → search-token-index-Bw0eYLiL.js} +1 -1
- package/assets/{search-view-DrM1GpjF.js → search-view-Cv6MXaNP.js} +1 -1
- package/assets/{senders-ChArrWrQ.js → senders-FBv_d32p.js} +1 -1
- package/assets/settings-C-JiUEpC.js +1 -0
- package/assets/{settings-screen-D-2-s5YM.js → settings-screen-ClWEZnOS.js} +1 -1
- package/assets/{shield-check-BanN6jve.js → shield-check-C78q6yIg.js} +1 -1
- package/assets/{suggested-vips-DVPOXeTj.js → suggested-vips-BFYmT1iv.js} +1 -1
- package/assets/{use-match-media-Bro6bqz1.js → use-match-media-BrJFrufZ.js} +1 -1
- package/assets/{useDebouncedValue-BLNE_op6.js → useDebouncedValue-DiRlxnWS.js} +1 -1
- package/assets/{useFilters-DL6piWYB.js → useFilters-Cafs9rMu.js} +1 -1
- package/assets/{useLabels-wWpLbrY0.js → useLabels-Dg_FXfB1.js} +1 -1
- package/assets/{useRefreshControl-IFhiGJ9D.js → useRefreshControl-BHJbdmbT.js} +1 -1
- package/assets/useSearchMirror-Df_I-_ih.js +1 -0
- package/assets/{useSearchTokenContext-CZgI6mWz.js → useSearchTokenContext-B60LlfMs.js} +2 -2
- package/assets/useSemanticSearch-ocRX-T7M.js +1 -0
- package/assets/{useSignature-Qknwuq_2.js → useSignature-BboURLQ5.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-BQXNleTu.js +0 -1
- package/assets/FlaggedPane-CpZ2OcAe.js +0 -1
- package/assets/MailListHeader-4AXtZpJh.js +0 -52
- package/assets/_mailboxId-BsIJ5Qw5.js +0 -1
- package/assets/_messageId-C31FR9YI.js +0 -1
- package/assets/_messageId-CneQEKP9.js +0 -1
- package/assets/_outboxMessageId-LJ-b0Bec.js +0 -1
- package/assets/_threadId-BWscYtJo.js +0 -1
- package/assets/_threadId-BkNHmpCT.js +0 -1
- package/assets/brief-ktYSYjs0.js +0 -1
- package/assets/flagged-CSN_JZPp.js +0 -1
- package/assets/index-BR4_kYTA.js +0 -1
- package/assets/index-CAzOXl8W.js +0 -1
- package/assets/index-Chctq97r.js +0 -1
- package/assets/index-CneQEKP9.js +0 -1
- package/assets/index-D8AjAH7I.js +0 -1
- package/assets/index-DC5aSwUJ.js +0 -1
- package/assets/index-EaqnUHk6.js +0 -1
- package/assets/mail-DlChE-xq.js +0 -1
- package/assets/outbox-D_eo85RF.js +0 -1
- package/assets/rich-text-Ddj-I29Y.js +0 -29
- package/assets/settings-Do-rJEIv.js +0 -1
- package/assets/useSearchMirror-B6ug5uo6.js +0 -1
- package/assets/useThreadRow-Bnc-PwcT.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const v=(t,n)=>{const r=new Map,s=new Map,o=new Set;let a={state:"opening",language:t};const d=(e,c)=>{const l=s.get(e);l&&(s.delete(e),l.abandon(new Error(c)))},i=e=>{for(const c of[...s.keys()])d(c,e)},u=e=>{a=e;for(const c of o)c(e)};return n.listen(e=>{if(e.type==="ready"){u({state:"ready",language:t});return}if(e.type==="failed"){u({state:"failed",language:t,reason:e.reason,detail:e.detail}),i(e.detail);return}if(e.type==="suggested"){const l=s.get(e.requestId);if(!l)return;s.delete(e.requestId),l.settle({requestId:e.requestId,word:e.word,suggestions:e.suggestions});return}const c=r.get(e.requestId);c&&(r.delete(e.requestId),c({requestId:e.requestId,revision:e.revision,findings:e.findings}))}),n.fail(e=>{u({state:"failed",language:t,reason:"worker",detail:e}),i(e)}),n.post({type:"open",language:t}),{language:t,onStatus:e=>(o.add(e),e(a),()=>{o.delete(e)}),check:e=>new Promise(c=>{r.set(e.requestId,c),n.post({type:"check",...e})}),suggest:e=>new Promise((c,l)=>{const f=setTimeout(()=>d(e.requestId,`no suggestions for "${e.word}" within 5000ms`),5e3);s.set(e.requestId,{settle:p=>{clearTimeout(f),c(p)},abandon:p=>{clearTimeout(f),l(p)}}),n.post({type:"suggest",...e})}),close:()=>{r.clear(),i("the checker closed"),o.clear(),n.terminate()}}},b=5,w=new Set(["a","about","address","after","afternoon","again","agenda","all","already","also","always","an","and","answer","any","apologies","approved","are","as","at","attached","available","be","because","been","before","both","budget","but","by","calendar","call","can","change","client","colleague","come","confirm","could","customer","day","deadline","decision","definitely","delivery","did","do","document","does","done","down","draft","each","email","end","environment","even","every","few","figures","find","first","follow","for","forward","friday","from","get","give","go","good","had","has","have","he","help","her","here","him","his","how","i","if","in","into","invoice","is","it","its","just","keep","know","last","let","like","long","look","made","make","many","may","me","meeting","message","month","more","morning","most","much","must","my","necessary","need","new","next","no","not","note","notes","now","number","numbers","occurred","of","off","office","on","once","one","only","or","other","our","out","over","own","page","payment","people","please","presentation","price","process","product","project","put","quarter","question","read","ready","receipt","receive","received","recommend","regards","report","review","right","same","say","schedule","see","send","sent","separate","service","she","should","show","since","so","some","sorry","still","such","summary","support","take","team","tell","than","thanks","that","the","their","them","then","there","these","they","thing","think","this","those","through","time","to","today","together","tomorrow","too","two","up","update","us","use","version","very","want","was","way","we","week","welcome","well","were","what","when","where","which","while","who","why","will","with","word","work","would","year","yes","you","your"]),y=new Map([["en",w]]),k=t=>y.get(t.toLowerCase().split("-")[0])??null,m=t=>t.toLowerCase().replace(/’/g,"'"),h=2,g=(t,n)=>{let r=[],s=Array.from({length:n.length+1},(o,a)=>a);for(let o=1;o<=t.length;o+=1){const a=[o];let d=o;for(let i=1;i<=n.length;i+=1){const u=t[o-1]===n[i-1]?0:1;let e=Math.min(a[i-1]+1,s[i]+1,s[i-1]+u);o>1&&i>1&&t[o-1]===n[i-2]&&t[o-2]===n[i-1]&&(e=Math.min(e,r[i-2]+1)),a[i]=e,e<d&&(d=e)}if(d>h)return h+1;r=s,s=a}return s[n.length]},I=(t,n)=>{let r=0;for(;r<t.length&&r<n.length&&t[r]===n[r];)r+=1;return r},S=(t,n)=>{const r=t.toUpperCase();return t===r&&t!==t.toLowerCase()?n.toUpperCase():t[0]===r[0]&&t[0]!==t.toLowerCase()[0]?n[0].toUpperCase()+n.slice(1):n},E=(t,n)=>{const r=m(t);if(r.length<2||n.has(r))return[];const s=[];for(const o of n){if(Math.abs(o.length-r.length)>h)continue;const a=g(r,o);a>h||s.push({candidate:o,distance:a,prefix:I(r,o)})}return s.sort((o,a)=>o.distance-a.distance||a.prefix-o.prefix||o.candidate.localeCompare(a.candidate)),s.slice(0,5).map(({candidate:o})=>S(t,o))};export{b as S,k as d,m as n,v as o,E as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const g=new Set(["a","about","address","after","afternoon","again","agenda","all","already","also","always","an","and","answer","any","apologies","approved","are","as","at","attached","available","be","because","been","before","both","budget","but","by","calendar","call","can","change","client","colleague","come","confirm","could","customer","day","deadline","decision","definitely","delivery","did","do","document","does","done","down","draft","each","email","end","environment","even","every","few","figures","find","first","follow","for","forward","friday","from","get","give","go","good","had","has","have","he","help","her","here","him","his","how","i","if","in","into","invoice","is","it","its","just","keep","know","last","let","like","long","look","made","make","many","may","me","meeting","message","month","more","morning","most","much","must","my","necessary","need","new","next","no","not","note","notes","now","number","numbers","occurred","of","off","office","on","once","one","only","or","other","our","out","over","own","page","payment","people","please","presentation","price","process","product","project","put","quarter","question","read","ready","receipt","receive","received","recommend","regards","report","review","right","same","say","schedule","see","send","sent","separate","service","she","should","show","since","so","some","sorry","still","such","summary","support","take","team","tell","than","thanks","that","the","their","them","then","there","these","they","thing","think","this","those","through","time","to","today","together","tomorrow","too","two","up","update","us","use","version","very","want","was","way","we","week","welcome","well","were","what","when","where","which","while","who","why","will","with","word","work","would","year","yes","you","your"]),d=new Map([["en",g]]),u=e=>d.get(e.toLowerCase().split("-")[0])??null,p=e=>e.toLowerCase().replace(/’/g,"'"),f=(e,n)=>{const s=new RegExp("\\p{L}[\\p{L}\\p{M}'’]*","gu"),r=[];let t=s.exec(e);for(;t;){const o=t[0];o.length>1&&!n.has(p(o))&&r.push({start:t.index,end:t.index+o.length}),t=s.exec(e)}return r},l=2,m=(e,n)=>{let s=[],r=Array.from({length:n.length+1},(t,o)=>o);for(let t=1;t<=e.length;t+=1){const o=[t];let h=t;for(let a=1;a<=n.length;a+=1){const b=e[t-1]===n[a-1]?0:1;let i=Math.min(o[a-1]+1,r[a]+1,r[a-1]+b);t>1&&a>1&&e[t-1]===n[a-2]&&e[t-2]===n[a-1]&&(i=Math.min(i,s[a-2]+1)),o[a]=i,i<h&&(h=i)}if(h>l)return l+1;s=r,r=o}return r[n.length]},w=(e,n)=>{let s=0;for(;s<e.length&&s<n.length&&e[s]===n[s];)s+=1;return s},y=(e,n)=>{const s=e.toUpperCase();return e===s&&e!==e.toLowerCase()?n.toUpperCase():e[0]===s[0]&&e[0]!==e.toLowerCase()[0]?n[0].toUpperCase()+n.slice(1):n},v=(e,n)=>{const s=p(e);if(s.length<2||n.has(s))return[];const r=[];for(const t of n){if(Math.abs(t.length-s.length)>l)continue;const o=m(s,t);o>l||r.push({candidate:t,distance:o,prefix:w(s,t)})}return r.sort((t,o)=>t.distance-o.distance||o.prefix-t.prefix||t.candidate.localeCompare(o.candidate)),r.slice(0,5).map(({candidate:t})=>y(e,t))},I=e=>{const n=u(e.language);return n?e.spans.flatMap(s=>f(s.text,n).map(r=>({spanId:s.spanId,start:r.start,end:r.end,kind:"spelling",suggestions:[]}))):[]},c=globalThis;c.addEventListener("message",({data:e})=>{if(e.type==="open"){c.postMessage({type:"ready",language:e.language});return}if(e.type==="suggest"){const n=u(e.language);c.postMessage({type:"suggested",requestId:e.requestId,word:e.word,suggestions:n?v(e.word,n):[]});return}c.postMessage({type:"checked",requestId:e.requestId,revision:e.revision,findings:I(e)})})})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as s,o}from"./rich-text-spellcheck-words-C1Zx88ZY.js";const n=e=>({post:r=>e.postMessage(r),listen:r=>e.addEventListener("message",t=>r(t.data)),fail:r=>e.addEventListener("error",t=>r(t.message)),terminate:()=>e.terminate()}),i=async e=>{if(!s(e))return null;const r=new Worker(new URL("/assets/rich-text-spellcheck-worker-C399ph5r.js",import.meta.url),{type:"module"});return o(e,n(r))};export{i as openSpellcheckWorker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./index-
|
|
1
|
+
import{c as t}from"./index-tka6wZr_.js";const e=t("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);export{e as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,j as l,B as b,b as y,
|
|
1
|
+
import{r as e,j as l,B as b,b as y,an as x}from"./index-tka6wZr_.js";const i=()=>l.jsx(x,{className:"size-3.5 animate-spin"}),m=(s,n)=>n?l.jsx("span",{className:"sr-only",children:s}):s;function p({actions:s=[],destructive:n,className:o}){const[f,r]=e.useState(!1);return f&&n?.confirm?l.jsxs("div",{className:y("flex items-center gap-2",o),children:[l.jsx("span",{className:"text-xs text-fg-muted",children:n.confirm.prompt}),l.jsx(b,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:n.confirm.cancelLabel??"Cancel"}),l.jsx(b,{variant:"danger",size:"sm","aria-busy":n.busy,icon:n.busy?i():void 0,onClick:()=>{n.busy||n.onClick()},children:n.busy?n.busyLabel??"Working…":n.confirm.confirmLabel??n.label})]}):l.jsxs("div",{className:y("flex items-center gap-2",o),children:[s.map(a=>l.jsx(b,{variant:a.variant??"ghost",size:"sm","aria-busy":a.busy,"aria-label":a.iconOnly?a.label:void 0,icon:a.busy?i():a.icon,onClick:()=>{a.busy||a.onClick()},children:a.busy&&a.busyLabel?a.busyLabel:m(a.label,a.iconOnly)},a.label)),n&&l.jsx(b,{variant:"ghost",size:"sm","aria-busy":n.busy,"aria-label":n.iconOnly?n.label:void 0,icon:n.busy?i():n.icon,onClick:()=>{if(!n.busy){if(n.confirm){r(!0);return}n.onClick()}},children:n.busy&&n.busyLabel?n.busyLabel:m(n.label,n.iconOnly)})]})}export{p as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c8 as n,cZ as s,c_ as u,c$ as r}from"./index-tka6wZr_.js";function f(e){const t=n({warn:e?.router===void 0}),o=e?.router||t;return s(o.stores.__store,u(e,o))}const i="search-scope";function c(e){const t=e.trim().replace(/\s+/g," ").toLowerCase();return/\s/.test(t)?`in:"${t}"`:`in:${t}`}function a(e){const t=r(e);return t!==void 0&&t.list!=="brief"}function l(e){const t=r(e);return t?.list==="mailbox"?t.mailboxId:void 0}function b(e){const t=l(e.matches);return t||(a(e.matches)?e.callerMailboxId:e.callerMailboxId??e.inTokenMailboxId)}function p(e,t){const o=r(e);return o?.list==="flagged"?{kind:"scoped",chip:{id:i,label:"is:starred"}}:o?.list==="outbox"?{kind:"scoped",chip:{id:i,label:"in:outbox"}}:o?.list==="mailbox"?t?{kind:"scoped",chip:{id:i,label:c(t)}}:{kind:"pending"}:{kind:"global"}}function x(e,t,o){return t.kind==="global"?{kind:"global"}:r(e)?.list==="flagged"?{kind:"collection"}:{kind:"folder",...o?{role:o}:{}}}export{i as S,x as a,p as b,a as i,l as r,b as s,f as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as A,r as u,j as m,g as V,b as I,cN as z,X as G,K as N,D as j,l as $,t as X,v as F,w as q,z as W,E as J,p as Y,o as Z,cp as R}from"./index-DUmy4dAt.js";import{u as ee,b as te,S as ne}from"./search-scope-C067nTlg.js";import{u as L}from"./use-match-media-Bro6bqz1.js";import{D as oe}from"./layout-breakpoints-BWjiUQKh.js";const Ie=A("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);const Ne=A("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),re=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Te(e){return re.filter(t=>e[t.action]!==void 0)}const se=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus next message"},{action:"focusPrevious",keys:["k"],description:"Focus previous message"},{action:"focusNext",keys:["↓"],description:"Focus next message"},{action:"focusPrevious",keys:["↑"],description:"Focus previous message"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function ie(e){for(const t of se){const n=t.hints.find(r=>r.action===e);if(n)return n.keys}}function ae(e){const t=ie(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function De(e){const t=ae(e);return t===""?"":`(${t})`}const b={action:null,nextPrefix:null,preventDefault:!1},ce={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},le={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function ue(e,t){const n=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...b,nextPrefix:t==="g"?null:t};if(e.onControl&&(n==="enter"||n===" "))return{...b,nextPrefix:t==="g"?null:t};if(r&&n==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&n==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...b,nextPrefix:t==="g"?null:t};if(n==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const a=ce[n===","?",":n]??null;return{action:a,nextPrefix:null,preventDefault:a!==null}}if(n==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const s=n==="j"||n==="arrowdown";if(s||(n==="k"||n==="arrowup"))return{action:s?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const o=le[n];if(o){const s=o.requireShift===!0,a=n.length===1&&!/[a-z0-9]/.test(n);return!s&&e.shiftKey&&!a?b:{action:o.action,nextPrefix:null,preventDefault:!0}}return b}function fe(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const de="data-message-row",pe='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function me(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(pe);return t?!t.hasAttribute(de):!1}function he({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:r,hasValue:o,chipCount:s}){const a=s-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?s===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!r||s===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function ye({key:e,repeat:t=!1,index:n,chipCount:r}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=r-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ge(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const xe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,be=({chips:e=[],onRemoveChip:t,value:n,onChange:r,onClear:o,onClearQuery:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h="sm",inputId:p,suggest:d,className:x})=>{const O=u.useId(),T=p??O,k=u.useRef(null),D=u.useRef([]),P=s??o,[K,w]=u.useState(null),C=u.useRef(void 0),[B,H]=u.useState(""),E=e.length>0;u.useEffect(()=>{w(i=>i!==null&&i>=e.length?null:i)},[e.length]),u.useEffect(()=>{const i=C.current;if(i!==void 0){if(C.current=void 0,i===null){k.current?.focus();return}D.current[i]?.focus()}});const M=u.useRef(void 0);u.useEffect(()=>{const i=d?.caret;if(!i||i===M.current)return;M.current=i;const l=k.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(i.cursor,i.cursor),d?.onCaretChange(i.cursor))});const S=i=>{d?.onCaretChange(i.selectionStart??i.value.length)},y=u.useCallback(i=>{w(i),C.current=i},[]),v=u.useCallback(i=>{const l=e[i];l&&t&&(y(ge(i,e.length)),H(`${l.label} removed`),t(l.id))},[e,t,y]),_=u.useCallback(()=>{y(null),o()},[o,y]),U=u.useCallback(i=>{const l=i.currentTarget;if(d?.onKeyDown(i))return;const g=he({key:i.key,shiftKey:i.shiftKey,repeat:i.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":i.preventDefault(),y(g.index);return;case"clearQuery":P();return;case"blur":l.blur();return;case"none":return}},[e.length,n,P,y,d]),Q=u.useCallback(i=>l=>{const g=ye({key:l.key,repeat:l.repeat,index:i,chipCount:e.length});switch(g.type!=="none"&&l.preventDefault(),g.type){case"removeChip":v(g.index);return;case"focusChip":y(g.index);return;case"focusInput":y(null);return;case"activateChip":return;case"none":return}},[e,v,y]);return u.useEffect(()=>{if(!c)return;const i=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||xe(l.target)||(l.preventDefault(),k.current?.focus())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),m.jsxs("label",{htmlFor:T,className:I("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[m.jsx(V,{className:I("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[E&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((i,l)=>m.jsx(z,{ref:g=>{D.current[l]=g},label:i.label,tone:i.tone,focused:K===l,onFocusLabel:()=>w(l),onKeyDown:Q(l),onRemove:()=>v(l)},i.id))}),m.jsx("input",{ref:k,id:T,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:K===null?0:-1,onChange:i=>{r(i.target.value),S(i.target)},onKeyDown:U,onKeyUp:i=>S(i.currentTarget),onClick:i=>S(i.currentTarget),onFocus:i=>{w(null),d?.onFocusChange?.(!0),S(i.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:E?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||E)&&f&&m.jsx("button",{type:"button",onClick:_,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:I("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:B})]})},Pe=({value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h,inputId:p,suggest:d,className:x})=>m.jsx(be,{value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a,globalFocusKey:c,showClearButton:f,size:h,inputId:p,suggest:d,className:x});function Ke({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:r=1e3}){const o=u.useRef(e);o.current=e;const s=u.useRef(null),a=u.useRef(null);u.useEffect(()=>{if(!t)return;const c=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},f=p=>{const d=ue({key:p.key,shiftKey:p.shiftKey,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,inEditable:fe(p.target),onControl:me(p.target)},s.current);if(c(),s.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{s.current=null,a.current=null},r)),d.action===null)return;const x=o.current[d.action];x&&(d.preventDefault&&p.preventDefault(),x())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",f),()=>{h.removeEventListener("keydown",f),c(),s.current=null}},[t,r,n])}const Me=({trigger:e,children:t,align:n="right"})=>{const[r,o]=u.useState(!1),s=u.useRef(null),a=u.useCallback(f=>{s.current&&!s.current.contains(f.target)&&o(!1)},[]),c=u.useCallback(f=>{f.key==="Escape"&&o(!1)},[]);return u.useEffect(()=>(r&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",c)),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",c)}),[r,a,c]),m.jsxs("div",{ref:s,className:"relative",children:[m.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o(!r)},className:N("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&m.jsx("div",{className:N("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Re=({onClick:e,disabled:t,destructive:n,children:r})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:N("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:r}),Le=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ke=({accounts:e})=>{const t=j({strict:!1}),n=$(),r=t.mailboxId,{t:o}=X("mail",{useSuspense:!1}),s=u.useCallback((c,f)=>o(c,{defaultValue:f}),[o]),a=F({queries:e.map(c=>({...q({path:{accountId:c.accountId}}),staleTime:1/0}))});if(n.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let c=0;c<e.length;c++){const f=a[c]?.data?.items;if(!f)continue;const h=f.find(d=>d.mailboxId===r);if(!h)continue;const p=W(e[c].folderAppointments);return J(h,p.get(r),s)}return null},Ae=({accounts:e})=>{const n=j({strict:!1}).mailboxId,r=F({queries:e.map(o=>({...q({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!n)return null;for(const o of r){const s=o.data?.items;if(!s)continue;const a=s.find(c=>c.mailboxId===n);if(a)return a.unseenCount}return null};function je(e){const t=Y(),{searchInput:n}=Z(),r=ke({accounts:e}),o=ee({select:c=>c.matches}),s=te(o,r),a=u.useCallback(c=>{c===ne&&t({to:"/mail/brief",search:{q:n||void 0}})},[t,n]);return{scope:s,clearScope:a}}const Fe=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=u.useCallback(o=>{const s=o.target;if(!(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable))for(const a of t){if(!(o.key.toLowerCase()===a.key.toLowerCase())||a.requireShift!==void 0&&a.requireShift!==o.shiftKey)continue;const f=o.ctrlKey||o.metaKey;if(a.requireMeta!==void 0){if(a.requireMeta!==f)continue}else{const h=a.noModifiers??!0,p=f||o.altKey||a.requireShift===void 0&&o.shiftKey;if(h&&p)continue}a.preventDefault&&o.preventDefault(),a.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),a.handler(o);return}},[t]);u.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},we=768,qe=e=>e!=="desktop",Oe=()=>{const e=L(`(min-width: ${we}px)`);return L(oe)?"desktop":e?"tablet":"phone"};function Be(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase(),o=r.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(r)||t.set(r,n.accountId)}return t}function He(e){const t=new Map;for(const n of e)for(const r of n){const o=r.fullPath?.toLowerCase();if(!o)continue;const s=o.split("/").pop();t.has(o)||t.set(o,r.mailboxId),s&&!t.has(s)&&t.set(s,r.mailboxId)}return t}function _e(e,t=[]){const n=e.flat().filter(s=>s.fullPath),r=new Map;for(const s of n){const a=R(s.fullPath).toLowerCase();r.set(a,(r.get(a)??0)+1)}const o=new Map(t.map(s=>[s.accountId,s.email]));return n.map(s=>{const a=R(s.fullPath),c=r.get(a.toLowerCase())===1,f=t.length>1?o.get(s.accountId):void 0;return{value:c?a:s.fullPath,label:s.displayNameOverride?.trim()||a,...f?{hint:f}:{}}})}function Ue(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase().split("@")[0]??"";t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=n.email.split("@")[0]??n.email,o=t.get(r.toLowerCase())===1,s=n.displayName?.trim();return{value:o?r:n.email,label:s||n.email,...s?{hint:n.email}:{}}})}export{Ie as B,Me as D,se as K,Ne as R,Pe as S,Le as a,Re as b,He as c,Oe as d,Fe as e,Ke as f,Be as g,ke as h,qe as i,Ae as j,re as k,Te as l,de as m,_e as n,Ue as o,ae as s,De as t,je as u};
|
|
1
|
+
import{c as A,r as u,j as m,g as V,b as I,cM as z,X as G,K as N,D as j,l as $,t as X,v as F,w as q,z as W,E as J,p as Y,o as Z,cn as R}from"./index-tka6wZr_.js";import{u as ee,b as te,S as ne}from"./search-scope-By6SdCOd.js";import{u as L}from"./use-match-media-BrJFrufZ.js";import{D as oe}from"./layout-breakpoints-BWjiUQKh.js";const Ie=A("BellOff",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);const Ne=A("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),re=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Te(e){return re.filter(t=>e[t.action]!==void 0)}const se=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus next message"},{action:"focusPrevious",keys:["k"],description:"Focus previous message"},{action:"focusNext",keys:["↓"],description:"Focus next message"},{action:"focusPrevious",keys:["↑"],description:"Focus previous message"},{action:"focusFirst",keys:["Home"],description:"Focus first"},{action:"focusLast",keys:["End"],description:"Focus last"},{action:"openFocused",keys:["Enter"],description:"Open focused thread"},{action:"back",keys:["Esc"],description:"Back / close overlay"}]},{title:"Selection",hints:[{action:"toggleSelect",keys:["x"],description:"Toggle select"},{action:"toggleSelect",keys:["Space"],description:"Toggle select"},{action:"extendSelectDown",keys:["Shift","j"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","k"],description:"Extend selection up"},{action:"extendSelectDown",keys:["Shift","↓"],description:"Extend selection down"},{action:"extendSelectUp",keys:["Shift","↑"],description:"Extend selection up"},{action:"selectAll",keys:["⌘","A"],description:"Select all"}]},{title:"Actions",hints:[{action:"reply",keys:["r"],description:"Reply"},{action:"replyAll",keys:["a"],description:"Reply all"},{action:"forward",keys:["f"],description:"Forward"},{action:"delete",keys:["#"],description:"Delete"},{action:"toggleStar",keys:["s"],description:"Star / unstar"},{action:"toggleRead",keys:["u"],description:"Toggle read / unread"}]},{title:"Sender",hints:[{action:"muteSender",keys:["m"],description:"Mute sender"},{action:"blockSender",keys:["b"],description:"Block sender"},{action:"vipSender",keys:["v"],description:"VIP sender"},{action:"markJunk",keys:["!"],description:"Mark junk"}]},{title:"Go to",hints:[{action:"goBrief",keys:["g","b"],description:"Daily brief"},{action:"goInbox",keys:["g","i"],description:"Inbox"},{action:"goSent",keys:["g","s"],description:"Sent"},{action:"goFlagged",keys:["g","f"],description:"Starred"},{action:"goSettings",keys:["g",","],description:"Settings"}]},{title:"View & global",hints:[{action:"toggleIntelligence",keys:["i"],description:"Toggle intelligence"},{action:"toggleDensity",keys:["d"],description:"Toggle density"},{action:"focusSearch",keys:["/"],description:"Focus search"},{action:"compose",keys:["c"],description:"Compose"},{action:"compose",keys:["⌘","N"],description:"Compose"},{action:"help",keys:["?"],description:"Shortcut help"}]}];function ie(e){for(const t of se){const n=t.hints.find(r=>r.action===e);if(n)return n.keys}}function ae(e){const t=ie(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function De(e){const t=ae(e);return t===""?"":`(${t})`}const b={action:null,nextPrefix:null,preventDefault:!1},ce={b:"goBrief",i:"goInbox",s:"goSent",f:"goFlagged",",":"goSettings"},le={j:{action:"focusNext"},k:{action:"focusPrevious"},arrowdown:{action:"focusNext"},arrowup:{action:"focusPrevious"},home:{action:"focusFirst"},end:{action:"focusLast"},enter:{action:"openFocused"}," ":{action:"toggleSelect"},delete:{action:"delete"},backspace:{action:"delete"},u:{action:"toggleRead"},x:{action:"toggleSelect"},r:{action:"reply"},a:{action:"replyAll"},f:{action:"forward"},"#":{action:"delete"},s:{action:"toggleStar"},m:{action:"muteSender"},b:{action:"blockSender"},v:{action:"vipSender"},"!":{action:"markJunk"},i:{action:"toggleIntelligence"},d:{action:"toggleDensity"},"/":{action:"focusSearch"},c:{action:"compose"},"?":{action:"help"}};function ue(e,t){const n=e.key.toLowerCase(),r=e.metaKey||e.ctrlKey;if(e.inEditable)return{...b,nextPrefix:t==="g"?null:t};if(e.onControl&&(n==="enter"||n===" "))return{...b,nextPrefix:t==="g"?null:t};if(r&&n==="n")return{action:"compose",nextPrefix:null,preventDefault:!0};if(r&&n==="a")return{action:"selectAll",nextPrefix:null,preventDefault:!0};if(r)return{...b,nextPrefix:t==="g"?null:t};if(n==="escape")return{action:"back",nextPrefix:null,preventDefault:!1};if(t==="g"){const a=ce[n===","?",":n]??null;return{action:a,nextPrefix:null,preventDefault:a!==null}}if(n==="g"&&!e.shiftKey)return{action:null,nextPrefix:"g",preventDefault:!0};if(e.shiftKey){const s=n==="j"||n==="arrowdown";if(s||(n==="k"||n==="arrowup"))return{action:s?"extendSelectDown":"extendSelectUp",nextPrefix:null,preventDefault:!0}}const o=le[n];if(o){const s=o.requireShift===!0,a=n.length===1&&!/[a-z0-9]/.test(n);return!s&&e.shiftKey&&!a?b:{action:o.action,nextPrefix:null,preventDefault:!0}}return b}function fe(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}const de="data-message-row",pe='button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [role="switch"], [role="checkbox"]';function me(e){if(!(e instanceof HTMLElement))return!1;const t=e.closest(pe);return t?!t.hasAttribute(de):!1}function he({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:r,hasValue:o,chipCount:s}){const a=s-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?s===0?{type:"none"}:{type:"focusChip",index:a}:e==="Backspace"||e==="ArrowLeft"?!r||s===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:a}:{type:"none"}}function ye({key:e,repeat:t=!1,index:n,chipCount:r}){return e==="Backspace"||e==="Delete"?t?{type:"none"}:{type:"removeChip",index:n}:e==="ArrowLeft"?n===0?{type:"none"}:{type:"focusChip",index:n-1}:e==="ArrowRight"?n>=r-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ge(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const xe=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,be=({chips:e=[],onRemoveChip:t,value:n,onChange:r,onClear:o,onClearQuery:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h="sm",inputId:p,suggest:d,className:x})=>{const O=u.useId(),T=p??O,k=u.useRef(null),D=u.useRef([]),P=s??o,[K,w]=u.useState(null),C=u.useRef(void 0),[B,H]=u.useState(""),E=e.length>0;u.useEffect(()=>{w(i=>i!==null&&i>=e.length?null:i)},[e.length]),u.useEffect(()=>{const i=C.current;if(i!==void 0){if(C.current=void 0,i===null){k.current?.focus();return}D.current[i]?.focus()}});const M=u.useRef(void 0);u.useEffect(()=>{const i=d?.caret;if(!i||i===M.current)return;M.current=i;const l=k.current;!l||l.ownerDocument.activeElement!==l||(l.setSelectionRange(i.cursor,i.cursor),d?.onCaretChange(i.cursor))});const S=i=>{d?.onCaretChange(i.selectionStart??i.value.length)},y=u.useCallback(i=>{w(i),C.current=i},[]),v=u.useCallback(i=>{const l=e[i];l&&t&&(y(ge(i,e.length)),H(`${l.label} removed`),t(l.id))},[e,t,y]),_=u.useCallback(()=>{y(null),o()},[o,y]),U=u.useCallback(i=>{const l=i.currentTarget;if(d?.onKeyDown(i))return;const g=he({key:i.key,shiftKey:i.shiftKey,repeat:i.repeat,caretAtStart:l.selectionStart===0&&l.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":i.preventDefault(),y(g.index);return;case"clearQuery":P();return;case"blur":l.blur();return;case"none":return}},[e.length,n,P,y,d]),Q=u.useCallback(i=>l=>{const g=ye({key:l.key,repeat:l.repeat,index:i,chipCount:e.length});switch(g.type!=="none"&&l.preventDefault(),g.type){case"removeChip":v(g.index);return;case"focusChip":y(g.index);return;case"focusInput":y(null);return;case"activateChip":return;case"none":return}},[e,v,y]);return u.useEffect(()=>{if(!c)return;const i=l=>{l.key!=="/"||l.metaKey||l.ctrlKey||l.altKey||xe(l.target)||(l.preventDefault(),k.current?.focus())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),m.jsxs("label",{htmlFor:T,className:I("flex w-full items-center gap-1.5 text-sm","bg-surface-sunken/50 border border-transparent","focus-within:bg-canvas focus-within:border-line focus-within:ring-2 focus-within:ring-ring","transition-colors",h==="lg"?"rounded-xl px-4 py-2":"rounded-md px-2.5 py-1",x),children:[m.jsx(V,{className:I("shrink-0 text-fg-muted pointer-events-none",h==="lg"?"size-5":"size-4")}),m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[E&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((i,l)=>m.jsx(z,{ref:g=>{D.current[l]=g},label:i.label,tone:i.tone,focused:K===l,onFocusLabel:()=>w(l),onKeyDown:Q(l),onRemove:()=>v(l)},i.id))}),m.jsx("input",{ref:k,id:T,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:K===null?0:-1,onChange:i=>{r(i.target.value),S(i.target)},onKeyDown:U,onKeyUp:i=>S(i.currentTarget),onClick:i=>S(i.currentTarget),onFocus:i=>{w(null),d?.onFocusChange?.(!0),S(i.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:E?void 0:a,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||E)&&f&&m.jsx("button",{type:"button",onClick:_,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(G,{className:I("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:B})]})},Pe=({value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a="Search mail...",globalFocusKey:c=!0,showClearButton:f=!0,size:h,inputId:p,suggest:d,className:x})=>m.jsx(be,{value:e,onChange:t,onClear:n,onClearQuery:r,chips:o,onRemoveChip:s,placeholder:a,globalFocusKey:c,showClearButton:f,size:h,inputId:p,suggest:d,className:x});function Ke({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:r=1e3}){const o=u.useRef(e);o.current=e;const s=u.useRef(null),a=u.useRef(null);u.useEffect(()=>{if(!t)return;const c=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},f=p=>{const d=ue({key:p.key,shiftKey:p.shiftKey,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,inEditable:fe(p.target),onControl:me(p.target)},s.current);if(c(),s.current=d.nextPrefix,d.nextPrefix!==null&&(a.current=setTimeout(()=>{s.current=null,a.current=null},r)),d.action===null)return;const x=o.current[d.action];x&&(d.preventDefault&&p.preventDefault(),x())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",f),()=>{h.removeEventListener("keydown",f),c(),s.current=null}},[t,r,n])}const Me=({trigger:e,children:t,align:n="right"})=>{const[r,o]=u.useState(!1),s=u.useRef(null),a=u.useCallback(f=>{s.current&&!s.current.contains(f.target)&&o(!1)},[]),c=u.useCallback(f=>{f.key==="Escape"&&o(!1)},[]);return u.useEffect(()=>(r&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",c)),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",c)}),[r,a,c]),m.jsxs("div",{ref:s,className:"relative",children:[m.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),o(!r)},className:N("p-1.5 min-h-11 min-w-11 inline-flex items-center justify-center rounded-md transition-colors","hover:bg-surface-raised text-fg-muted hover:text-fg"),children:e}),r&&m.jsx("div",{className:N("absolute z-50 mt-1 min-w-[180px] py-1","bg-surface border border-line rounded-md shadow-lg",n==="right"?"right-0":"left-0"),children:t})]})},Re=({onClick:e,disabled:t,destructive:n,children:r})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:N("w-full px-3 py-2 text-left text-sm transition-colors","flex items-center gap-2",t&&"opacity-50 cursor-not-allowed",!t&&"hover:bg-surface-raised",n&&"text-danger hover:text-danger"),children:r}),Le=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),ke=({accounts:e})=>{const t=j({strict:!1}),n=$(),r=t.mailboxId,{t:o}=X("mail",{useSuspense:!1}),s=u.useCallback((c,f)=>o(c,{defaultValue:f}),[o]),a=F({queries:e.map(c=>({...q({path:{accountId:c.accountId}}),staleTime:1/0}))});if(n.pathname.startsWith("/mail/outbox"))return"Outbox";if(!r)return null;for(let c=0;c<e.length;c++){const f=a[c]?.data?.items;if(!f)continue;const h=f.find(d=>d.mailboxId===r);if(!h)continue;const p=W(e[c].folderAppointments);return J(h,p.get(r),s)}return null},Ae=({accounts:e})=>{const n=j({strict:!1}).mailboxId,r=F({queries:e.map(o=>({...q({path:{accountId:o.accountId}}),staleTime:1/0}))});if(!n)return null;for(const o of r){const s=o.data?.items;if(!s)continue;const a=s.find(c=>c.mailboxId===n);if(a)return a.unseenCount}return null};function je(e){const t=Y(),{searchInput:n}=Z(),r=ke({accounts:e}),o=ee({select:c=>c.matches}),s=te(o,r),a=u.useCallback(c=>{c===ne&&t({to:"/mail/brief",search:{q:n||void 0}})},[t,n]);return{scope:s,clearScope:a}}const Fe=({enabled:e=!0,bindings:t,capture:n=!1})=>{const r=u.useCallback(o=>{const s=o.target;if(!(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable))for(const a of t){if(!(o.key.toLowerCase()===a.key.toLowerCase())||a.requireShift!==void 0&&a.requireShift!==o.shiftKey)continue;const f=o.ctrlKey||o.metaKey;if(a.requireMeta!==void 0){if(a.requireMeta!==f)continue}else{const h=a.noModifiers??!0,p=f||o.altKey||a.requireShift===void 0&&o.shiftKey;if(h&&p)continue}a.preventDefault&&o.preventDefault(),a.stopPropagation&&(o.stopPropagation(),o.stopImmediatePropagation()),a.handler(o);return}},[t]);u.useEffect(()=>{if(e)return window.addEventListener("keydown",r,n),()=>window.removeEventListener("keydown",r,n)},[e,r,n])},we=768,qe=e=>e!=="desktop",Oe=()=>{const e=L(`(min-width: ${we}px)`);return L(oe)?"desktop":e?"tablet":"phone"};function Be(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase(),o=r.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(r)||t.set(r,n.accountId)}return t}function He(e){const t=new Map;for(const n of e)for(const r of n){const o=r.fullPath?.toLowerCase();if(!o)continue;const s=o.split("/").pop();t.has(o)||t.set(o,r.mailboxId),s&&!t.has(s)&&t.set(s,r.mailboxId)}return t}function _e(e,t=[]){const n=e.flat().filter(s=>s.fullPath),r=new Map;for(const s of n){const a=R(s.fullPath).toLowerCase();r.set(a,(r.get(a)??0)+1)}const o=new Map(t.map(s=>[s.accountId,s.email]));return n.map(s=>{const a=R(s.fullPath),c=r.get(a.toLowerCase())===1,f=t.length>1?o.get(s.accountId):void 0;return{value:c?a:s.fullPath,label:s.displayNameOverride?.trim()||a,...f?{hint:f}:{}}})}function Ue(e){const t=new Map;for(const n of e){const r=n.email.toLowerCase().split("@")[0]??"";t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=n.email.split("@")[0]??n.email,o=t.get(r.toLowerCase())===1,s=n.displayName?.trim();return{value:o?r:n.email,label:s||n.email,...s?{hint:n.email}:{}}})}export{Ie as B,Me as D,se as K,Ne as R,Pe as S,Le as a,Re as b,He as c,Oe as d,Fe as e,Ke as f,Be as g,ke as h,qe as i,Ae as j,re as k,Te as l,de as m,_e as n,Ue as o,ae as s,De as t,je as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as a,
|
|
1
|
+
import{r as c,j as a,a4 as i,a5 as u,a6 as v}from"./index-tka6wZr_.js";const p=c.createContext(null),x=({chrome:r,children:n})=>a.jsx(p.Provider,{value:r,children:n});function h({phone:r,list:n,reading:t,intelligence:o,hasThread:s=!1}){const e=c.useContext(p);if(!e)return a.jsx(i,{});const l={nav:e.nav,overlay:e.overlay,skeleton:a.jsx(i,{}),isLoading:e.isLoading,navOpen:e.navOpen,onOpenNav:e.onOpenNav,onCloseNav:e.onCloseNav};return e.isSinglePane?a.jsx(u,{...l,list:r,intelligenceOpen:e.intelligenceOpen}):a.jsx(u,{...l,topBar:e.topBar,list:n,reading:t,intelligence:o,intelligenceOpen:e.intelligenceOpen,hasThread:s})}function O(r,n,t){if(r!==n)return t}function S(r,n){return r===""?"":n}function d({searchInput:r,committedQuery:n,urlQuery:t,pathname:o,listPath:s}){return!v(o,s)||n!==r?!1:n!==t}export{x as M,h as a,d as b,S as c,O as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,b as N,p as
|
|
1
|
+
import{j as e,b as N,p as T,r as c,az as L,al as O,g as $,aD as q,x as I,b8 as A,s as k,af as C,b9 as M,ba as P,B as S,a as R,bb as B,X as G}from"./index-tka6wZr_.js";import{K as m}from"./kbd-Dt_vzEGr.js";import{S as Q,a as E}from"./settings-screen-ClWEZnOS.js";import{E as V}from"./ErrorState-9wFdKXpo.js";import{u as D}from"./useDebouncedValue-DiRlxnWS.js";import{a as K}from"./format-De9HZKjg.js";import"./avatar-BvDbtKy6.js";import"./menu-DAXEVDbj.js";import"./circle-help-BK_hzj_i.js";function _({options:t,active:r,onSelect:x}){return e.jsx("div",{role:"tablist",className:N("flex shrink-0 gap-1 overflow-x-auto border-b border-line p-2","lg:w-44 lg:flex-col lg:gap-0 lg:overflow-visible lg:border-r lg:border-b-0 lg:py-2 lg:pr-2 lg:pl-3"),children:t.map(a=>{const d=a.id===r;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,onClick:()=>x(a.id),className:N("flex min-h-11 shrink-0 items-center gap-2 rounded-md px-3 text-left text-sm transition-colors lg:min-h-0 lg:px-2 lg:py-1",d?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface-sunken hover:text-fg"),children:[e.jsx("span",{className:"flex-1 truncate",children:a.label}),e.jsx("span",{className:N("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:a.count??"—"})]},a.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"},F=e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"VIP"})," senders get priority surface in the daily brief and notification escalation, even when an account is quiet."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Muted"})," senders never notify and stay out of the brief. Their mail still syncs and stays searchable."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Blocked"})," senders never load images and go straight to junk."]}),e.jsxs("p",{children:["Tip: flag from the keyboard on any message — ",e.jsx(m,{children:"v"})," VIP,"," ",e.jsx(m,{children:"m"})," mute, ",e.jsx(m,{children:"b"})," block. Every rule an automation creates shows up here and can be removed."]})]});function H({query:t,onCount:r}){const{data:x,isPending:a,isError:d,error:b}=I(A()),h=k(),i=C({...P(),onSettled:()=>{h.invalidateQueries({queryKey:M()})}}),l=x?.suggestions??[],p=t.trim().toLowerCase(),u=p?l.filter(n=>(n.displayName??"").toLowerCase().includes(p)||n.normalizedEmail.toLowerCase().includes(p)):l;return c.useEffect(()=>{r?.(u.length,l.length)},[r,u.length,l.length]),a?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Loading VIP suggestions…"}):d?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Couldn't load VIP suggestions",error:b})}):l.length===0?e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIP suggestions yet. As you reply to senders, they'll appear here. Press ",e.jsx(m,{children:"v"})," on any message to promote a sender to VIP."]}):u.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No VIPs match “",t,"”."]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-row-inset py-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Suggested — promote to VIP"}),u.map(n=>e.jsx(E,{name:n.displayName??n.normalizedEmail,email:n.normalizedEmail,meta:n.replyCount>0?`${n.inboundCount} received · you replied ${n.replyCount}×`:`${n.inboundCount} received · you've never replied`,trailing:e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(R,{className:"size-3.5"}),"aria-busy":i.isPending,onClick:()=>{i.isPending||i.mutate({path:{addressId:n.addressId},body:{flags:{vip:{value:!0,setAt:Date.now(),setBy:"user"}}}})},children:"Add VIP"})},n.addressId))]})}function U({group:t,query:r,onCount:x}){const a=D(r.trim(),300),d=k(),[b,h]=c.useState(null),i=a.length>=2,l=B({query:{q:a,limit:50}}),{data:p,isPending:u,isError:n,error:j}=I({...l,enabled:i}),g=C({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),f=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{x?.(i?f.length:0,null)},[x,i,f.length]),i?u?e.jsx("div",{className:"px-row-inset py-3 text-sm text-fg-subtle animate-pulse",children:"Searching…"}):n?e.jsx("div",{className:"px-row-inset py-3",children:e.jsx(V,{variant:"inline",title:"Search failed",error:j})}):f.length===0?e.jsxs("p",{className:"px-row-inset py-5 text-sm text-fg-subtle",children:["No ",v[t].toLowerCase()," senders matching “",a,"”."]}):e.jsx(e.Fragment,{children:f.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&K(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=g.isPending&&g.variables?.path.addressId===s.addressId,z=g.isError&&b===s.addressId;return e.jsx(E,{name:s.displayName??s.normalizedEmail,email:s.normalizedEmail,danger:t==="blocked",meta:y,trailing:z?e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>{h(s.addressId),g.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(S,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(h(s.addressId),g.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}}))}})},s.addressId)})}):e.jsxs("div",{className:"px-row-inset py-5 text-sm text-fg-subtle space-y-2",children:[e.jsxs("p",{children:["Type 2+ characters to search ",v[t].toLowerCase()," ","senders by name or address."]}),e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Note: a dedicated flagged-address list endpoint is in the backlog. Press ",e.jsx(m,{children:"m"})," on any message to mute its sender; ",e.jsx(m,{children:"b"})," to block."]})]})}function ae(){const t=T(),[r,x]=c.useState("vip"),[a,d]=c.useState(""),[b,h]=c.useState(!0),[i,l]=c.useState(0),[p,u]=c.useState({vip:0,muted:null,blocked:null}),n=c.useCallback((s,o)=>{l(s),u(y=>({...y,vip:o}))},[]),j=c.useCallback((s,o)=>{l(s),u(y=>({...y,[r]:s}))},[r]),g=p[r],f=s=>{const o=q[s];o&&t({to:o})};return e.jsx(Q,{items:L,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:F,helpOpen:b,onToggleHelp:()=>h(s=>!s),onSelect:f,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(_,{active:r,onSelect:s=>{x(s),d("")},options:["vip","muted","blocked"].map(s=>({id:s,label:v[s],count:p[s]}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("div",{className:"border-b border-line px-row-inset py-2",children:e.jsx(O,{icon:e.jsx($,{className:"size-4"}),placeholder:`Filter ${v[r].toLowerCase()} by name or address`,className:"h-8 max-w-sm",value:a,onChange:s=>d(s.target.value)})}),e.jsx("div",{className:"min-h-0 flex-1 divide-y divide-line overflow-y-auto",children:r==="vip"?e.jsx(H,{query:a,onCount:n}):e.jsx(U,{group:r,query:a,onCount:j})}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-line px-row-inset py-1 text-2xs text-fg-subtle",children:[e.jsx("span",{children:g!=null?`${i} of ${g} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(m,{children:"j"})," ",e.jsx(m,{children:"k"})," navigate · ",e.jsx(m,{children:"⌫"})," remove flag"]})]})]})]})})}export{ae as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,a0 as o}from"./index-tka6wZr_.js";const n=()=>t.jsx(o,{});export{n as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z,r as j,j as e,b as f,B as i,X as N,
|
|
1
|
+
import{c as z,r as j,j as e,b as f,B as i,X as N,aB as S}from"./index-tka6wZr_.js";import{A as w}from"./avatar-BvDbtKy6.js";import{M as B}from"./menu-DAXEVDbj.js";import{C as v}from"./circle-help-BK_hzj_i.js";const h=z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function F({items:l,activeId:t,title:c,description:n,children:r,help:s,helpOpen:d=!0,flush:o,onSelect:k,onToggleHelp:u,onBackToMail:m}){const[y,x]=j.useState(!1),[b,C]=j.useState(!1),p=!!s&&d,g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-3 pb-1 text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Settings"}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-1",children:l.map(a=>e.jsxs("button",{type:"button",onClick:()=>{k?.(a.id),x(!1)},className:f("flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm transition-colors lg:min-h-0",a.id===t?"bg-accent-2-soft font-medium text-accent-2":"text-fg-muted hover:bg-surface hover:text-fg"),children:[a.icon&&e.jsx("span",{className:f("shrink-0",a.id===t?"text-accent-2":"text-fg-subtle"),children:a.icon}),a.label]},a.id))})]});return e.jsxs("div",{className:"safe-area-frame flex h-dvh w-full overflow-hidden bg-canvas font-sans text-fg",children:[e.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-line bg-surface-sunken lg:flex",children:[e.jsx("div",{className:"flex h-pane-header shrink-0 items-center border-b border-line px-2",children:e.jsxs("button",{type:"button",onClick:m,className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]})}),g]}),y&&e.jsxs("div",{className:"fixed inset-0 z-50 flex lg:hidden",children:[e.jsx("button",{type:"button","aria-label":"Close menu",className:"absolute inset-0 bg-canvas/60",onClick:()=>x(!1)}),e.jsxs("aside",{className:"safe-area-frame relative flex w-72 max-w-[85%] flex-col border-r border-line bg-surface-sunken",children:[e.jsxs("div",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-2",children:[e.jsxs("button",{type:"button",onClick:()=>{m?.(),x(!1)},className:"flex items-center gap-2 rounded-md px-2 py-1 text-left text-sm text-fg-muted hover:bg-surface hover:text-fg",children:[e.jsx(h,{className:"size-4 text-fg-subtle"}),"Back to mail"]}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-4"}),onClick:()=>x(!1),"aria-label":"Close menu"})]}),g]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center gap-3 border-b border-line px-3 lg:px-5",children:[m&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(h,{className:"size-4"}),className:"-ml-1 lg:hidden",onClick:m,"aria-label":"Back to mail"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(B,{className:"size-4"}),className:"lg:hidden",onClick:()=>x(!0),"aria-label":"Open settings menu"}),e.jsx("h1",{className:"text-md font-semibold text-fg",children:c}),n&&e.jsx("p",{className:"hidden min-w-0 truncate text-xs text-fg-subtle lg:block",children:n}),s&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"ml-auto lg:hidden",onClick:()=>C(a=>!a),"aria-label":"Tips","aria-expanded":b}),s&&!p&&e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(v,{className:"size-4"}),className:"hidden ml-auto lg:inline-flex",onClick:u,"aria-label":"Show tips"})]}),s&&b&&e.jsx("div",{className:"border-b border-line bg-surface-sunken px-row-inset py-3 text-xs leading-relaxed text-fg-muted lg:hidden",children:s}),o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-2xl px-3 py-5 lg:px-5",children:e.jsx("div",{className:"space-y-5",children:r})})})]}),p&&e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-l border-line bg-surface-sunken lg:flex",children:[e.jsxs("header",{className:"flex h-pane-header shrink-0 items-center justify-between border-b border-line px-row-inset",children:[e.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider text-fg-subtle",children:"Tips & tricks"}),e.jsx(i,{variant:"ghost",size:"sm",icon:e.jsx(N,{className:"size-3.5"}),onClick:u,"aria-label":"Collapse tips"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-row-inset py-3 text-xs leading-relaxed text-fg-muted",children:s})]})]})}function R({name:l,email:t,meta:c,caption:n,danger:r,trailing:s}){return e.jsxs("div",{className:"flex items-center gap-3 px-row-inset py-2 hover:bg-surface-sunken",children:[e.jsx("span",{className:f(r&&"rounded-full ring-2 ring-danger/40"),children:e.jsx(w,{name:l,email:t,size:"sm"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-0 sm:flex-row sm:items-baseline sm:gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-fg",children:l}),e.jsx("span",{className:"truncate text-2xs text-fg-subtle",children:t})]}),e.jsxs("div",{className:"text-xs text-fg-subtle",children:[c,n&&e.jsxs("span",{className:"text-fg-muted",children:[" · ",n]})]})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]})}const O={healthy:{tone:"positive",label:"healthy"},error:{tone:"danger",label:"error"},muted:{tone:"neutral",label:"muted"}};function X({label:l,email:t,connector:c,syncLabel:n,state:r,errorDetail:s,trailing:d}){const o=O[r];return e.jsxs("div",{className:f("rounded-sm border border-line bg-surface",r==="muted"&&"opacity-65"),children:[e.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx(w,{name:l,email:t,size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-fg",children:l}),e.jsx(S,{tone:o.tone,dot:!0,children:o.label})]}),e.jsxs("div",{className:"truncate text-xs text-fg-subtle",children:[t," · ",c," · ",n]})]})]}),d&&e.jsx("div",{className:"shrink-0",children:d})]}),s&&e.jsx("div",{className:"border-t border-line px-row-inset py-2",children:e.jsx("code",{className:"block rounded-xs bg-danger-soft px-2 py-1 text-2xs text-danger",children:s})})]})}export{X as A,F as S,R as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./index-
|
|
1
|
+
import{c as e}from"./index-tka6wZr_.js";const c=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);export{c as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,
|
|
1
|
+
import{j as t,a7 as e}from"./index-tka6wZr_.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d}from"./index-
|
|
1
|
+
import{r as d}from"./index-tka6wZr_.js";const r=e=>{const[i,n]=d.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return d.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e);n(t.matches);const a=s=>n(s.matches);return t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),i};export{r as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o}from"./index-
|
|
1
|
+
import{r as o}from"./index-tka6wZr_.js";const n=(e,t)=>{const[r,u]=o.useState(e);return o.useEffect(()=>{const s=setTimeout(()=>u(e),t);return()=>clearTimeout(s)},[e,t]),r};export{n as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,
|
|
1
|
+
import{r as m,af as b,cQ as E,x as C,cR as D,cz as x,cS as F,s as M,cT as P,cU as N,cV as z,cW as L}from"./index-tka6wZr_.js";import{u as T}from"./use-match-media-BrJFrufZ.js";import{D as w}from"./layout-breakpoints-BWjiUQKh.js";const G=()=>T(w),X=(e,t)=>{if(e.state==="Expired")return"Expired";if(e.scope!=="Temporary"||!e.expiresAt)return"Active";const r=Date.parse(e.expiresAt);return Number.isNaN(r)?"Active":r<=t?"Expired":"Active"},Z=e=>{if(!e)return;const t=Date.parse(e);if(!Number.isNaN(t))return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},O=(e,t=new Date)=>{if(!e)return;const r=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!r)return;const[,a,i,n]=r,s=new Date(Number(a),Number(i)-1,Number(n),23,59,59,0);if(Number.isNaN(s.getTime()))return;const o=-t.getTimezoneOffset(),d=o>=0?"+":"-",c=Math.abs(o),l=String(Math.floor(c/60)).padStart(2,"0"),f=String(c%60).padStart(2,"0"),u=p=>String(p).padStart(2,"0");return`${s.getFullYear()}-${u(s.getMonth()+1)}-${u(s.getDate())}T${u(s.getHours())}:${u(s.getMinutes())}:${u(s.getSeconds())}${d}${l}:${f}`},h="None",ee=e=>!e.literalClauses.some(t=>t.field==="HasWords"),y=e=>({...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h}),te=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",re=({mode:e,ruleScope:t,anchorMessageId:r,clauses:a,matchOperator:i,moveMailboxId:n,until:s})=>({...e==="similar"&&r?{anchorMessageId:r}:{},matchOperator:i==="all"?"And":"Or",literalClauses:a.map(o=>({field:o.field,value:o.value})),moveMailboxId:n,expiresAt:t==="until"?O(s??""):void 0}),S=(e,t,r)=>({name:r,scope:t==="standing"?"Standing":"Temporary",...t==="temporary"&&e.expiresAt?{expiresAt:e.expiresAt}:{},matchOperator:e.matchOperator,literalClauses:e.literalClauses,actionLabelId:e.labelId??h,actionMailboxId:e.moveMailboxId??h,...e.anchorMessageId?{anchorMessageId:e.anchorMessageId}:{}}),_=new Set(["Complete","Failed"]),v=e=>e!==void 0&&_.has(e),R=1e3,k=15e3,J=e=>{const t=Math.max(0,e),r=R*2**t;return Math.min(r,k)},$=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},se=e=>{const[t,r]=m.useState(),a=b({...E(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=a,n=C({...D({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return v(I)?!1:J(g.state.dataUpdateCount)}}),s=m.useCallback(g=>{e&&i({path:{accountId:e},body:y(g)})},[e,i]),{refetch:o}=n,d=m.useCallback(()=>{o()},[o]),c=n.data,l=a.isPending?void 0:c,f=l?.state??a.data?.state,u=v(l?.state),p={state:f,matchedCount:l?.matchedCount??0,appliedCount:l?.appliedCount??0,failedCount:l?.failedCount??0,errorMessage:l?.errorMessage??""};return{start:s,refreshStatus:d,progress:p,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:$(a.error,n.error,!!c)}},ae=["From","Subject","HasWords","ListId","FromDomain"],U=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ne=(e,t)=>e==="ListId"?U(t):t.trim(),Q=e=>e==="all"?"And":"Or",W=(e,t)=>{const r=e.widen!==void 0&&!e.widen.inactive,a=e.clauses.map(i=>({field:i.field,value:i.value}));return{...r&&t?{anchorMessageId:t}:{},matchOperator:Q(e.matchOperator),literalClauses:a}},j=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),q=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),ie=(e,t)=>{const r=W(e,t);return{...r.anchorMessageId?{anchorMessageId:r.anchorMessageId}:{},matchOperator:r.matchOperator,literalClauses:r.literalClauses,moveMailboxId:e.moveMailboxId,labelId:e.labelId,expiresAt:e.scope==="until"?O(e.until??""):void 0}},H=(e,t)=>e.error!==void 0&&e.errorSignature===t?{status:"error",reason:e.error}:e.count===void 0?{status:"loading"}:e.previewedSignature===t?{status:"ready",count:e.count}:{status:"ready",count:e.count,stale:!0},K=350,oe=(e,t,r)=>{const a=b(x()),{mutateAsync:i}=a,n=q(t),[s,o]=m.useState(()=>({})),d=m.useRef(t);d.current=t;const c=m.useRef(n),l=j(t);return m.useEffect(()=>{if(!e||!l||n===s.previewedSignature||n===s.errorSignature)return;const f=setTimeout(()=>{const u=n;c.current=u,i({path:{accountId:e},body:y({...d.current})}).then(p=>{c.current===u&&o({count:p.matchedCount,matchedIds:p.messageIds,previewedSignature:u})}).catch(p=>{c.current===u&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:u}))})},K);return()=>clearTimeout(f)},[e,l,n,s.previewedSignature,s.errorSignature,i]),l?{count:H(s,n),matchedIds:s.previewedSignature===n?s.matchedIds??[]:[]}:{count:{status:"error",reason:F},matchedIds:[]}},A=e=>N({path:{accountId:e}}),ue=e=>{const t=C({...z({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ce=e=>{const t=M(),r=b({...P(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a,mutateAsync:i}=r,n=m.useCallback((o,d,c)=>{e&&a({path:{accountId:e},body:S(o,d,c)})},[e,a]),s=m.useCallback(async(o,d,c)=>e?i({path:{accountId:e},body:S(o,d,c)}).then(()=>!0,()=>!1):!1,[e,i]);return{createFilter:n,createFilterAsync:s,isPending:r.isPending,isSuccess:r.isSuccess,isError:r.isError,error:r.error,reset:r.reset}},le=e=>{const t=M(),r=b({...L(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a}=r;return{deleteFilter:m.useCallback(n=>{e&&a({path:{accountId:e,filterId:n}})},[e,a]),isPending:r.isPending,deletingFilterId:r.isPending?r.variables?.path.filterId:void 0}};export{h as N,ae as S,se as a,A as b,ie as c,G as d,Z as e,X as f,ue as g,le as h,y as i,ce as j,re as k,ee as l,ne as n,te as o,O as p,W as r,oe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as L,
|
|
1
|
+
import{x as L,bA as p,s as n,af as l,bB as d,r as o,bC as y,bD as c,bE as g}from"./index-tka6wZr_.js";const u=e=>y({path:{accountId:e}}),P=e=>{const s=L({...p({path:{accountId:e??""}}),enabled:!!e});return{labels:s.data?.items??[],isPending:s.isPending,isError:s.isError,error:s.error,refetch:s.refetch}},m=e=>{const s=n(),t=l({...d(),onSuccess:()=>{e&&s.invalidateQueries({queryKey:u(e)})}}),{mutateAsync:r}=t;return{createLabel:o.useCallback((a,i="Default")=>e?r({path:{accountId:e},body:{name:a,color:i}}):Promise.reject(new Error("No account")),[e,r]),isPending:t.isPending,isError:t.isError,error:t.error,reset:t.reset}},C=e=>{const s=n(),t=l({...c(),onSuccess:()=>{e&&s.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{updateLabel:o.useCallback((a,i)=>{e&&r({path:{accountId:e,labelId:a},body:i})},[e,r]),isPending:t.isPending,updatingLabelId:t.isPending?t.variables?.path.labelId:void 0}},h=e=>{const s=n(),t=l({...g(),onSuccess:()=>{e&&s.invalidateQueries({queryKey:u(e)})}}),{mutate:r}=t;return{deleteLabel:o.useCallback(a=>{e&&r({path:{accountId:e,labelId:a}})},[e,r]),isPending:t.isPending,deletingLabelId:t.isPending?t.variables?.path.labelId:void 0}};export{P as a,C as b,h as c,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as E,e as q,b as j,B as D,r as i,v as C,
|
|
1
|
+
import{j as E,e as q,b as j,B as D,r as i,v as C,aF as R,s as P,o as K,a2 as Q,Q as A,P as $,R as z,U as B}from"./index-tka6wZr_.js";import{C as G}from"./circle-check-big-CjzecMB6.js";import{R as H}from"./search-token-index-Bw0eYLiL.js";function oe({state:e,onRefresh:t,label:s,errorMessage:a,hasUpdate:n,size:u="sm",className:c}){const o=e==="refreshing",f=e==="error",h=e==="success",g=f?E.jsx(q,{className:"size-4 text-danger"}):h?E.jsx(G,{className:"size-4 text-positive"}):E.jsx(H,{className:j("size-4",o&&"animate-spin")}),y=f?`${s} — failed: ${a??"try again"}`:o?`${s} — refreshing`:h?`${s} — up to date`:n?`${s} — new mail`:s;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(D,{variant:"ghost",size:u,icon:g,onClick:t,disabled:o,"aria-label":y,"aria-busy":o||void 0,title:f?a:s,className:c}),e==="idle"&&n&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const U=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function F(e){return!!e&&U.has(e)}const N=3e3,W=N*2,v={syncing:!1,resolved:!1,synced:0,total:0};function ie(e,t){const s=e.join(","),[a,n]=i.useState(!1),[u,c]=i.useState(!1);i.useEffect(()=>{n(!1),c(!1)},[s,t]),i.useEffect(()=>{if(!t)return;const r=setTimeout(()=>c(!0),W);return()=>clearTimeout(r)},[s,t]);const o=C({queries:e.map(r=>({...R({path:{accountId:r}}),enabled:t&&!a,refetchInterval:N,meta:{softError:!0}}))}),f=o.every(r=>r.isSuccess||r.isError),h=o.length===0||f||u;let g=!1,y=0,w=0;for(const r of o)if(F(r.data?.syncPhase)){g=!0;for(const l of r.data?.mailboxes??[])y+=l.messagesSynced,w+=l.messagesTotal}const S=t&&h&&!g;return i.useEffect(()=>{S&&n(!0)},[S]),!t||!h?v:{syncing:g,resolved:!0,synced:y,total:w}}const M=6e4,I=new Set(["sent","drafts","trash","archive"]),k=(e,t)=>{const s=new Map;for(const a of e){const n=t.get(a.mailboxId)?.role;n&&I.has(n)||s.set(a.mailboxId,a.messagesTotal)}return s},X=(e,t)=>{for(const[s,a]of t)if(a>(e.get(s)??0))return!0;return!1},_=i.createContext(null),J=()=>{const e=i.useContext(_);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function ce({accountIds:e,children:t}){const s=P(),{resultFolderIndex:a}=K(),n=i.useRef(new Map),u=i.useRef(new Set),[c,o]=i.useState(new Set),f=C({queries:e.map(r=>({...R({path:{accountId:r}}),refetchInterval:M,staleTime:M,meta:{softError:!0}}))}),h=f.map(r=>r.dataUpdatedAt).join(","),g=e.join(",");i.useEffect(()=>{let r=!1;const l=new Set(c);e.forEach((d,x)=>{const p=f[x]?.data;if(!p)return;const m=k(p.mailboxes??[],a);if(!u.current.has(d)){u.current.add(d),n.current.set(d,m);return}if(l.has(d))return;const T=n.current.get(d)??new Map;X(T,m)&&(l.add(d),r=!0)}),r&&o(l)},[g,h]);const y=i.useCallback(r=>r.some(l=>c.has(l)),[c]),w=i.useCallback(r=>{o(l=>{if(r.every(x=>!l.has(x)))return l;const d=new Set(l);for(const x of r)d.delete(x);return d});for(const l of r){const d=s.getQueryData(R({path:{accountId:l}}).queryKey);n.current.set(l,k(d?.mailboxes??[],a)),u.current.add(l)}},[s,a]),S=i.useMemo(()=>({hasNewMail:y,acknowledge:w}),[y,w]);return E.jsx(_.Provider,{value:S,children:t})}const V=2e3,Y=45e3,Z=e=>new Promise(t=>setTimeout(t,e)),b=e=>e instanceof Error&&e.message?e.message:"Something went wrong",ee=e=>{z(e,{softError:!0})&&B(e)},L=e=>e.reduce((t,s)=>Math.max(t,s.lastSyncedAt??0),0),O=(e,t)=>e.fetchQuery({...R({path:{accountId:t}}),staleTime:0}),se=async(e,t,s,a)=>{let n=!1;for(;;){const u=await O(e,t).then(f=>({ok:!0,data:f})).catch(f=>({ok:!1,error:f}));if(!u.ok)return{accountId:t,message:b(u.error)};const{syncPhase:c,mailboxes:o}=u.data;if(F(c))n=!0;else if(n||L(o??[])>s)return c==="error"?{accountId:t,message:"Sync failed for this account"}:void 0;if(Date.now()>=a)return{accountId:t,message:"Refresh is taking longer than usual"};await Z(V)}},te=async(e,t,s,a)=>{const n=await O(e,s).then(o=>({ok:!0,maxLastSynced:L(o.mailboxes??[])})).catch(o=>({ok:!1,error:o}));if(!n.ok)return{accountId:s,enqueued:!1,ok:!1,message:b(n.error)};const u=await $({path:{accountId:s},throwOnError:!0}).then(()=>({ok:!0})).catch(o=>({ok:!1,error:o}));if(!u.ok)return ee(u.error),{accountId:s,enqueued:!1,ok:!1,message:b(u.error)};t.recordEvent("sync.triggered");const c=await se(e,s,n.maxLastSynced,a);return c?{accountId:s,enqueued:!0,ok:!1,message:c.message}:{accountId:s,enqueued:!0,ok:!0}},ue=(e,t={})=>{const s=P(),a=Q(),{acknowledge:n}=J(),[u,c]=i.useState("idle"),[o,f]=i.useState(),h=i.useRef(0),g=i.useRef(e);g.current=e;const y=i.useRef(t);y.current=t,i.useEffect(()=>{if(u!=="success")return;const S=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(S)},[u]);const w=i.useCallback(()=>{const S=g.current;if(S.length===0){c("error"),f("Nothing to refresh yet");return}const r=++h.current;c("refreshing"),f(void 0),(async()=>{const l=Date.now()+Y,d=await Promise.all(S.map(m=>te(s,a,m,l)));if(h.current!==r)return;const x=d.filter(m=>m.enqueued).map(m=>m.accountId);for(const m of x)s.invalidateQueries({queryKey:A({path:{accountId:m}})});x.length>0&&(y.current.onSettled?.(),n(x));const p=d.filter(m=>!m.ok);p.length===0?c("success"):(c("error"),f(p[0]?.message))})()},[n,s,a]);return{state:u,errorMessage:o,refresh:w}};export{ce as M,oe as R,ue as a,ie as b,F as i,J as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as y,o as d,W as x,r as p}from"./index-tka6wZr_.js";import{u as Q}from"./search-scope-By6SdCOd.js";import{b as v}from"./search-view-Cv6MXaNP.js";function M(o){const a=y(),{searchInput:c,searchQuery:r}=d(),{q:i=""}=x({from:"/mail"}),n=Q({select:l=>l.location.pathname}),s=p.useRef(i);s.current=i;const{to:e}=o,t="params"in o?o.params.mailboxId:void 0,m=t?`/mail/${t}`:e;p.useEffect(()=>{if(!v({searchInput:c,committedQuery:r,urlQuery:s.current,pathname:n,listPath:m}))return;const f=!!r&&s.current!==r,u=h=>({...h,q:r||void 0});if(!f){a({to:".",search:u,replace:!0});return}if(e==="/mail/$mailboxId"){if(!t)return;a({to:e,params:{mailboxId:t},search:u,replace:!0});return}a({to:e,search:u,replace:!0})},[c,r,a,e,t,m,n])}export{M as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c2 as X,r as h,j as a,b as B,I as Y,a2 as Z,n as P,s as W,x as J,cq as H,cp as ee,ad as te,af as se,ag as re,ba as ne,e as ae,X as oe,K as C,o as ie}from"./index-tka6wZr_.js";import{K as L}from"./kbd-Dt_vzEGr.js";import{u as ce}from"./use-match-media-BrJFrufZ.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as le,i as de}from"./search-scope-By6SdCOd.js";const ue=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},fe=()=>`
|
|
2
2
|
/* Zero the UA default body margin and clamp the document to the iframe width so
|
|
3
3
|
wide author markup can't push the body (and the page) past the viewport. */
|
|
4
4
|
html, body {
|
|
@@ -64,4 +64,4 @@ a, a:visited {
|
|
|
64
64
|
color: ${t.accent} !important;
|
|
65
65
|
text-decoration: underline;
|
|
66
66
|
}
|
|
67
|
-
`},Ne=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",je=(e,t,s)=>{if(t==="plain")return`${O}<style>${Te(s)}</style>${e}`;const r=Se.test(e);return`${O}<style>${Ne(s,r)}</style>${e}`},Re=5e4,Ce=1e4,Me="(max-width: 640px)",Le=.4,Be="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),De=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Le,t/e),$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=h.useRef(null),o=h.useRef(null),[c,f]=h.useState(0),[i,l]=h.useState(0),[p,d]=h.useState(0),g=ce(Me),x=h.useMemo(()=>je(e,t,s),[e,t,s]);h.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(A=>A===b.clientWidth?A:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),h.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,Re);f(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Ce);l(S=>S===$?S:$)};let w,A;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),A=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),A?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?De(i,p):1,m=u<1,v=m?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Be,srcDoc:x,className:m?void 0:r,scrolling:"no",style:{width:v,maxWidth:m?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:m?`scale(${u})`:void 0,transformOrigin:m?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:m?r:void 0,children:m?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:f})=>{const i=h.useMemo(()=>!e||typeof document>"u"?null:Ae({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=ue(r,i?.hasAuthorBackground??!1),g=h.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:f?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:B("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Y,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function G(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class E extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},Ge=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,qe=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new E("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new E(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(qe(t,c))throw new E("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const f=await o.text();if(Ge(f,c))throw new E("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return f},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=h.useRef(null),f=W(),i=h.useRef(!1),l=h.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(m,v)=>Ve(m,v,o),refetchDescribeMessage:()=>f.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,m)=>m instanceof E&&m.reason==="not-ready"?u<We:u<1,retryDelay:(u,m)=>m instanceof E&&m.reason==="not-ready"?(i.current=!0,(m.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;h.useEffect(()=>{g&&(c.current=performance.now())},[g]),h.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},q=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=q(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,m])=>({queryKey:u,data:m}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:q(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=h.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return h.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof E?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[c,f]=h.useState(!1),{Account:i}=P();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ae,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>f(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(oe,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:f})=>{const[i,l]=h.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:m,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=h.useMemo(()=>me(e??[]),[e]),A=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",f),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",f),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!m)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:f,html:A,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),St=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(Q).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ue(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return mt(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of G(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function jt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function Rt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...le({select:r=>de(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,kt as R,dt as S,G as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,jt as g,St as h,Tt as p,Nt as r,At as s,Rt as u};
|
|
67
|
+
`},Ne=(e,t)=>e?t?"html,body{margin:0;color-scheme:dark light}":"html{margin:0;background-color:#ffffff;filter:invert(0.92) hue-rotate(180deg)}body{margin:0}img,picture,video,svg,canvas,[style*='background-image'],[background]{filter:invert(0.92) hue-rotate(180deg)}":"html,body{margin:0;background-color:#ffffff;color-scheme:light}",je=(e,t,s)=>{if(t==="plain")return`${O}<style>${Te(s)}</style>${e}`;const r=Se.test(e);return`${O}<style>${Ne(s,r)}</style>${e}`},Re=5e4,Ce=1e4,Me="(max-width: 640px)",Le=.4,Be="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),De=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Le,t/e),$e=new Set(["Enter","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),_e=e=>e===" "?!1:e.length===1?!0:$e.has(e),U=e=>{if(e.metaKey||e.ctrlKey||e.altKey||!_e(e.key))return;const t=e.currentTarget??e.target,s=t?.defaultView?.parent;!s||s===t?.defaultView||s.dispatchEvent(new KeyboardEvent("keydown",{key:e.key,code:e.code,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0}))},K=({html:e,variant:t="framed",isDark:s=!1,className:r})=>{const n=h.useRef(null),o=h.useRef(null),[c,f]=h.useState(0),[i,l]=h.useState(0),[p,d]=h.useState(0),g=ce(Me),x=h.useMemo(()=>je(e,t,s),[e,t,s]);h.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(A=>A===b.clientWidth?A:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),h.useEffect(()=>{const b=o.current;if(!b)return;const k=()=>{const y=b.contentDocument;if(!y?.body)return;const j=y.documentElement,R=I(y.body.scrollHeight,j?.scrollHeight??0,Re);f(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Ce);l(S=>S===$?S:$)};let w,A;const N=()=>{k();const y=b.contentDocument;y?.body&&(w=new ResizeObserver(k),w.observe(y.body),y.documentElement&&w.observe(y.documentElement),y.addEventListener("keydown",U),A=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),A?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?De(i,p):1,m=u<1,v=m?`${i}px`:g?"100%":t==="framed"&&i>0?`max(100%, ${i}px)`:i===0?"100%":`${i}px`,M=c===0?"1px":`${c}px`,T=a.jsx("iframe",{ref:o,title:"Email content",sandbox:Be,srcDoc:x,className:m?void 0:r,scrolling:"no",style:{width:v,maxWidth:m?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:m?`scale(${u})`:void 0,transformOrigin:m?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:m?r:void 0,children:m?a.jsx("div",{style:{width:"100%",height:`${Math.ceil(c*u)}px`,overflow:"hidden"},children:T}):T})},F=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Oe=({html:e,text:t,isDark:s=!1,category:r,allowImages:n=!1,resolveCid:o,className:c,renderBlockedNotice:f})=>{const i=h.useMemo(()=>!e||typeof document>"u"?null:Ae({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=ue(r,i?.hasAuthorBackground??!1),g=h.useMemo(()=>!l||n?0:(l.match(/data-blocked-src/g)||[]).length,[l,n]);return!l&&!t?a.jsx("div",{className:B("message-body",c),children:a.jsx(F,{})}):a.jsxs("div",{className:B("message-body",c),children:[g>0&&a.jsx("div",{className:"message-body-notice",children:f?.(g)}),l?p?a.jsx("div",{className:"w-full max-w-full overflow-x-auto",children:a.jsx(K,{html:l,variant:"framed",isDark:s})}):a.jsx("div",{className:"max-w-full overflow-x-auto lg:max-w-2xl",children:a.jsx(K,{html:l,variant:d?"plain":"framed",isDark:s})}):t?a.jsx("pre",{className:"email-text whitespace-pre-wrap text-sm leading-relaxed",children:t}):a.jsx(F,{})]})};function kt({message:e="Select a thread to read",icon:t,showHints:s=!0,className:r}){return a.jsxs("div",{className:B("flex flex-1 flex-col items-center justify-center text-center",r),children:[t??a.jsx(Y,{className:"size-10 text-fg-subtle"}),a.jsx("p",{className:"mt-3 text-sm text-fg-muted",children:e}),s&&a.jsxs("p",{className:"text-2xs text-fg-subtle",children:[a.jsx(L,{children:"j"})," / ",a.jsx(L,{children:"k"})," to move, ",a.jsx(L,{children:"Enter"})," to open"]})]})}function q(e){const t=[];let s=-1,r=!1;for(let n=0;n<e.length;n++){const o=e[n];if(o==='"'){r=!r,s<0&&(s=n);continue}if(!r&&/\s/.test(o)){s>=0&&t.push({raw:e.slice(s,n),start:s,end:n}),s=-1;continue}s<0&&(s=n)}return s>=0&&t.push({raw:e.slice(s),start:s,end:e.length}),t}const Ie=e=>{if(!e.startsWith('"'))return e;const t=e.slice(1);return t.endsWith('"')?t.slice(0,-1):t};function Ue(e){const t=e.indexOf(":");if(t<=0)return;const s=e.slice(t+1);return{name:e.slice(0,t).toLowerCase(),value:Ie(s),rawValue:s}}const Ke=e=>/[\s"]/.test(e),Fe=e=>Ke(e)?`"${e.replace(/"/g,"")}"`:e,At=(e,t)=>`${e}:${Fe(t)}`,ze=e=>{const t=e.filter(n=>!n.isMultipart&&n.disposition!=="attachment"&&n.mediaType==="TEXT"&&n.contentUrl.length>0),s=t.find(n=>n.mediaSubtype.toUpperCase()==="HTML");if(s)return{kind:"html",contentUrl:s.contentUrl};const r=t.find(n=>n.mediaSubtype.toUpperCase()==="PLAIN");return r?{kind:"text",contentUrl:r.contentUrl}:null},D={all:["messages"],detail:e=>[...D.all,"detail",e],body:e=>[...D.detail(e),"body"]};class E extends Error{reason;status;retryAfterSeconds;constructor(t,s,r,n){super(s),this.name="BodyFetchError",this.reason=t,this.status=r,this.retryAfterSeconds=n}}const Pe=e=>{const t=Number.parseInt(e??"",10);return!Number.isFinite(t)||t<=0?1:Math.min(t,30)},We=8,He="x-remit-403-reason",Qe=(e,t)=>{const s=t?.trim()??"";return e===401?"auth":e===403?s.length>0?"auth":"body-missing":e===404?"body-missing":"generic"},qe=(e,t)=>(t??"").toLowerCase().startsWith("text/html")?/<div\s+id=["']root["']/i.test(e):!1,Ge=(e,t)=>{const s=(t??"").toLowerCase();return!!(e==="text"&&s.startsWith("text/html"))},Ve=async(e,t,s=async()=>null)=>{const r={},n=await s();n&&(r.Authorization=`Bearer ${n}`);const o=await ee(e,{headers:r});if(o.status===202)throw new E("not-ready","Message body is still syncing",202,Pe(o.headers.get("Retry-After")));if(!o.ok){const i=o.headers.get(He),l=Qe(o.status,i);throw new E(l,`Failed to load message body (${o.status} ${o.statusText})`,o.status)}const c=o.headers.get("content-type");if(Ge(t,c))throw new E("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const f=await o.text();if(qe(f,c))throw new E("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return f},Xe=async(e,t)=>(t.isRetryAfterNotReady&&await e.refetchDescribeMessage(),e.fetchContent(t.contentUrl,t.kind)),Ye=({messageId:e,bodyParts:t,enabled:s=!0})=>{const r=t?ze(t):null,n=Z(),{getToken:o}=P(),c=h.useRef(null),f=W(),i=h.useRef(!1),l=h.useRef(null),p=e&&r?`${e}:${r.contentUrl}`:null;l.current!==p&&(l.current=p,i.current=!1);const d=J({queryKey:e?[...D.body(e),r?.contentUrl??null]:["messages","body","noop"],queryFn:()=>{if(!r)throw new Error("No renderable body part");if(!e)throw new Error("No messageId");const u=i.current;return i.current=!1,Xe({fetchContent:(m,v)=>Ve(m,v,o),refetchDescribeMessage:()=>f.refetchQueries({queryKey:H({path:{messageId:e}})})},{contentUrl:r.contentUrl,kind:r.kind,isRetryAfterNotReady:u})},enabled:s&&!!e&&!!r,staleTime:300*1e3,gcTime:1800*1e3,retry:(u,m)=>m instanceof E&&m.reason==="not-ready"?u<We:u<1,retryDelay:(u,m)=>m instanceof E&&m.reason==="not-ready"?(i.current=!0,(m.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;h.useEffect(()=>{g&&(c.current=performance.now())},[g]),h.useEffect(()=>{d.isSuccess&&c.current!==null&&(n.recordTiming("message.body.load",Math.round(performance.now()-c.current)),c.current=null)},[d.isSuccess,n]);const x=d.data&&r?{kind:r.kind,body:d.data}:void 0;return{picked:r,data:x,isLoading:g,isError:d.isError,error:d.error,refetch:d.refetch}},G=(e,t=Date.now())=>({value:e,setAt:t}),Ze=(e,t,s,r)=>{if(e.addressId!==t)return e;const n={...e.flags??{}};return s?n.trusted=G(!0,r):delete n.trusted,{...e,flags:n}},Je=(e,t,s,r)=>{const n=o=>o.map(c=>Ze(c,t,s,r));return{...e,envelope:{...e.envelope,from:n(e.envelope.from),to:n(e.envelope.to),cc:n(e.envelope.cc),bcc:n(e.envelope.bcc),replyTo:n(e.envelope.replyTo)}}},et=({messageId:e})=>{const t=W(),{pushError:s}=te(),{mutate:r,isPending:n,error:o,reset:c}=se({...ne(),onMutate:async i=>{const l=i.path.addressId,d=i.body.flags?.trusted?.value===!0,g=H({path:{messageId:e}});await t.cancelQueries({queryKey:g});const x=t.getQueriesData({queryKey:g}).filter(u=>u[1]!==void 0).map(([u,m])=>({queryKey:u,data:m}));return t.setQueriesData({queryKey:g},u=>u&&Je(u,l,d)),{describePrefix:g,previous:x}},onError:(i,l,p)=>{if(p)for(const d of p.previous)t.setQueryData(d.queryKey,d.data);s(re("Couldn't trust sender","The change wasn't saved.",i))},onSettled:(i,l,p,d)=>{d&&t.invalidateQueries({queryKey:d.describePrefix})}});return{toggleTrusted:(i,l)=>{r({path:{addressId:i},body:{flags:{trusted:G(!l)}}})},isPending:n,error:o,reset:c}},tt=()=>{const[e,t]=h.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return h.useEffect(()=>{const s=document.documentElement,r=new MutationObserver(()=>{t(s.classList.contains("dark"))});return r.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),e},st=({blockedImageCount:e,canAlwaysTrust:t,isTrustPending:s,onLoadOnce:r,onAlwaysTrust:n})=>a.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-md bg-surface-sunken/50 px-3 py-2 text-sm",children:[a.jsxs("span",{className:"text-fg-muted",children:[e," image",e>1?"s":""," blocked for privacy"]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:r,className:"text-accent hover:underline",children:"Load once"}),t&&a.jsx("button",{type:"button",onClick:n,"aria-busy":s,className:"text-accent hover:underline aria-busy:opacity-50",children:s?"Trusting…":"Always trust"})]})]}),rt=(e,t)=>{switch(e){case"auth":return{title:"Your session expired",detail:"Sign in again to reload the message body. Other parts of the app may also stop responding until you do."};case"body-missing":return{title:"Message body is missing in storage",detail:"A sync failure may have left this message without its body bytes. Contact support, or run the reconcile script to refetch from the upstream IMAP server."};case"content-type-mismatch":return{title:"Couldn't load message body",detail:"The server returned an unexpected content type for this part. The message body has not been rendered to keep you safe."};case"spa-shell-leak":return{title:"Couldn't load message body",detail:"The server returned the app shell instead of the message body. This is an infrastructure bug — please report it."};case"not-ready":return{title:"Message body is still syncing",detail:"This message's body hasn't finished downloading from the mail server yet. It should appear shortly — reopen the message to try again."};default:return{title:"Couldn't load message body",detail:t}}},nt=e=>e instanceof E?e.reason:"generic",at=e=>e instanceof Error?e.message:typeof e=="string"?e:"An unexpected error occurred while loading the message body.",ot=({error:e,onRetry:t})=>{const s=nt(e),r=at(e),{title:n,detail:o}=rt(s,r),[c,f]=h.useState(!1),{Account:i}=P();return c?null:a.jsxs("div",{role:"alert","data-testid":"message-body-error-banner","data-reason":s,className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[a.jsx(ae,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"font-medium text-danger",children:n}),a.jsx("p",{className:"text-fg-muted mt-1 break-words",children:o})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s==="auth"&&a.jsx(i,{children:({signOut:l})=>a.jsx("button",{type:"button",onClick:()=>l(),className:"text-sm font-medium text-accent hover:underline",children:"Sign in again"})}),t&&a.jsx("button",{type:"button",onClick:t,className:"text-sm font-medium text-accent hover:underline",children:"Retry"}),a.jsx("button",{type:"button",onClick:()=>f(!0),"aria-label":"Dismiss message body error",className:"rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors",children:a.jsx(oe,{className:"size-4","aria-hidden":"true"})})]})]})},it=()=>a.jsxs("div",{className:"animate-pulse space-y-2",role:"status","aria-label":"Loading message body",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-11/12"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"}),a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-5/6"})]}),z=()=>a.jsx("p",{className:"text-fg-muted text-sm italic",children:"This message has no body content."}),Et=({bodyParts:e,html:t,text:s,isTrusted:r=!1,messageId:n,fromAddressId:o,category:c,className:f})=>{const[i,l]=h.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:m,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=h.useMemo(()=>me(e??[]),[e]),A=u&&v?.kind==="html"?v.body:t,N=u&&v?.kind==="text"?v.body:s;if(u){if(M)return a.jsx("div",{className:C("message-body",f),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",f),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!m)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",f),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:f,html:A,text:N,isDark:d,category:c,allowImages:p,resolveCid:w,renderBlockedNotice:R=>a.jsx(st,{blockedImageCount:R,canAlwaysTrust:y,isTrustPending:x,onLoadOnce:()=>l(!0),onAlwaysTrust:j})})},V={personal:"Personal",uncategorized:"Unclassified",transactional:"Transactional",newsletter:"Newsletter",marketing:"Marketing",social:"Social",automated:"Automated"},ct=Object.values(Q).map(e=>({value:e,label:V[e]})),lt={unclassified:"uncategorized"},dt=[{name:"from",label:"Sender",values:"contact"},{name:"subject",label:"Subject",values:"text"},{name:"category",label:"Category",values:"fixed",options:ct},{name:"is",label:"State",values:"fixed",options:[{value:"unread",label:"Unread"},{value:"read",label:"Read"},{value:"starred",label:"Starred"}]},{name:"has",label:"Contents",values:"fixed",options:[{value:"attachment",label:"Has attachment"}]},{name:"in",label:"Folder",values:"mailbox"},{name:"account",label:"Account",values:"account"},{name:"after",label:"Sent on or after",values:"date"},{name:"before",label:"Sent before",values:"date"}],ut=new Map(dt.map(e=>[e.name,e])),St=e=>ut.get(e.toLowerCase()),ft=/^\d{4}-\d{2}-\d{2}$/;function mt(e,t,s){if(!ft.test(s))return;const r=Date.parse(`${s}T00:00:00Z`);if(!Number.isNaN(r))return{type:e,raw:t,value:s,epochSeconds:Math.floor(r/1e3)}}function ht(e){const t=e.toLowerCase(),s=lt[t];return s||Object.values(Q).find(n=>n===t)}function gt(e,t){switch(t.toLowerCase()){case"unread":return{type:"isUnread",raw:e};case"read":return{type:"isRead",raw:e};case"starred":case"flagged":return{type:"isStarred",raw:e};default:return}}function pt(e,t){const s=Ue(e);if(!s||s.value.length===0)return;const{name:r,value:n}=s;switch(r){case"from":return{type:"from",raw:e,value:n};case"subject":return{type:"subject",raw:e,value:n};case"category":{const o=ht(n);return o?{type:"category",raw:e,value:n,category:o}:void 0}case"is":return gt(e,n);case"has":return n.toLowerCase()==="attachment"?{type:"hasAttachment",raw:e}:void 0;case"before":case"after":return mt(r,e,n);case"in":{const o=t.mailboxesByName?.get(n.toLowerCase());return o?{type:"in",raw:e,value:n,mailboxId:o}:void 0}case"account":{const o=t.accountsByName?.get(n.toLowerCase());return o?{type:"account",raw:e,value:n,accountId:o}:void 0}default:return}}function Tt(e,t={}){const s=[],r=[];for(const n of q(e)){const o=pt(n.raw,t);o?s.push(o):r.push(n.raw)}return{freeText:r.join(" "),tokens:s}}function Nt(e,t){return q(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function jt(e){switch(e.type){case"from":return`From: ${e.value}`;case"subject":return`Subject: ${e.value}`;case"category":return`Category: ${V[e.category]}`;case"hasAttachment":return"Has attachment";case"isUnread":return"Unread";case"isRead":return"Read";case"isStarred":return"Starred";case"before":return`Before ${e.value}`;case"after":return`After ${e.value}`;case"in":return`In: ${e.value}`;case"account":return`Account: ${e.value}`}}function Rt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...le({select:r=>de(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,kt as R,dt as S,q as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,jt as g,St as h,Tt as p,Nt as r,At as s,Rt as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as L,ad as C,af as k,bu as I,bv as E,r as x,j as p,bw as h,bx as A,by as j,o as R,x as Q,bz as z}from"./index-tka6wZr_.js";import{aj as D,ak as O,al as _,am as N,an as P}from"./MailListHeader-CA5lvtZs.js";import{a as q}from"./useLabels-Dg_FXfB1.js";import{M as w}from"./enums-CCxx0t2v.js";import{u as U,s as B}from"./search-scope-By6SdCOd.js";import{n as F}from"./search-query-Cr_ZXBCp.js";import{u as G,p as K}from"./useSearchTokenContext-B60LlfMs.js";const V=t=>{const{mailboxId:s,messages:i}=t,l=L(),{pushError:c}=C(),{mutateAsync:r,isPending:a}=k({...E(),onError:(o,u)=>{c({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:I(o),error:o})},onSettled:(o,u,m)=>{D(l,O(_(m.body.messageIds??[],i??[],s)))}});return{applyLabel:x.useCallback((o,u,m)=>{o.length!==0&&N(o,d=>r({body:{messageIds:d,labelId:u,action:m}}))},[r]),isPending:a}};function oe({accountId:t,mailboxId:s,messageIds:i}){const{labels:l}=q(t),{applyLabel:c}=V({mailboxId:s}),r=x.useMemo(()=>l.map(a=>({key:a.labelId,label:a.name,icon:p.jsx("span",{className:`size-2.5 rounded-full ${A(a.color)?h[a.color]:h.Default}`}),onSelect:()=>c(i,a.labelId,"Apply")})),[l,i,c]);return r.length===0?null:p.jsx(P,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(j,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:r,align:"start",nested:!0,touch:!1,triggerClassName:"min-h-11 w-full justify-start gap-3 px-4 py-2.5 text-sm font-normal text-fg"})}const $=20,H=new Set(Object.values(w)),J=t=>t!==void 0&&H.has(t)?t:void 0,W=t=>{if(t.some(s=>s.type==="isUnread"))return!1;if(t.some(s=>s.type==="isRead"))return!0};function ne({mailboxId:t,filterCategory:s}={}){const{searchQuery:i}=R(),l=G(),c=U({select:e=>e.matches}),r=F(i),{freeText:a,tokens:n}=K(r,l),o=a.length>0,u=n.find(e=>e.type==="category"),m=J(s)??u?.category,d=n.some(e=>e.type==="hasAttachment")?!0:void 0,y=n.some(e=>e.type==="isStarred")?!0:void 0,b=W(n),f=n.find(e=>e.type==="after"),g=n.find(e=>e.type==="before"),S=n.find(e=>e.type==="in"),v=B({matches:c,callerMailboxId:t,inTokenMailboxId:S?.mailboxId}),{data:M,isLoading:T}=Q({...z({query:{query:a,mailboxId:v,limit:$,...m!==void 0?{category:m}:{},...d!==void 0?{hasAttachment:d}:{},...y!==void 0?{hasStars:y}:{},...b!==void 0?{isRead:b}:{},...f?{sentDateFrom:f.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:o,staleTime:6e4});return{hits:M?.items??[],isLoading:o&&T}}export{oe as L,ne as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as c,
|
|
1
|
+
import{s as c,ad as f,x as p,Z as m,r,af as y,ag as T,a1 as x,ah as E}from"./index-tka6wZr_.js";const i={html:"",plainText:""},h=e=>{const u=c(),{pushError:o}=f(),{data:n}=p({...m(),staleTime:1/0}),g=r.useMemo(()=>{if(!e||!n)return i;const t=n.accounts.find(s=>s.accountId===e);return t?{html:t.signatureHtml??"",plainText:t.signaturePlainText??""}:i},[e,n]),a=y({...E(),onSuccess:()=>{u.invalidateQueries({queryKey:x()})},onError:t=>{o(T("Couldn't save signature","The signature wasn't saved.",t))}}),l=r.useCallback((t,s)=>{e&&a.mutate({path:{accountId:e},body:{signatureHtml:t,signaturePlainText:s}})},[e,a]);return{signature:g,setSignature:l,isSaving:a.isPending}};export{h as u};
|
package/index.html
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
} catch (_) {}
|
|
39
39
|
})();
|
|
40
40
|
</script>
|
|
41
|
-
<script type="module" crossorigin src="/assets/index-
|
|
41
|
+
<script type="module" crossorigin src="/assets/index-tka6wZr_.js"></script>
|
|
42
42
|
<link rel="stylesheet" crossorigin href="/assets/index-DUKJ-tDb.css">
|
|
43
43
|
</head>
|
|
44
44
|
<body>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as a,ao as Ze,S as Xe,bA as et,o as F,bf as tt,p as ae,r as n,x as te,bB as se,v as st,w as at,bC as ot,bD as nt,bt as rt,e as Te,by as it,i as lt}from"./index-DUmy4dAt.js";import{s as Re,a as ct,b as we,u as dt,p as ut,R as mt}from"./useSearchTokenContext-CZgI6mWz.js";import{ai as ve,t as ye,aj as ft,m as ht,a as gt,r as Ce,ak as xt,al as pt,am as It,a9 as bt,an as vt,ao as yt,ap as Ct,M as St,T as jt,ag as Tt,d as Rt,x as wt,P as Mt,ah as kt,S as At,L as Nt,e as Se,g as Bt,h as Ft,i as Ot,j as Lt,C as Me,D as Dt,I as ke,k as Et}from"./MailListHeader-4AXtZpJh.js";import{u as qt,a as Pt,R as zt,i as Ht,b as Qt}from"./useRefreshControl-IFhiGJ9D.js";import{a as _t}from"./useLabels-wWpLbrY0.js";import{d as $t,R as Wt}from"./search-token-index-DnLe4VlS.js";import{d as Ut}from"./useFilters-DL6piWYB.js";import{a as Vt,L as Gt,u as Yt}from"./useThreadRow-Bnc-PwcT.js";function Jt({sync:e}){return e?a.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:[a.jsx(Ze,{className:"size-8 animate-spin text-fg-subtle","aria-hidden":"true"}),a.jsx("p",{className:"text-sm font-medium text-fg",children:"Still syncing your mail"}),a.jsx("p",{className:"text-xs text-fg-subtle",children:Kt(e)})]}):a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center px-4",children:[a.jsx(Xe,{className:"size-8 text-fg-subtle","aria-hidden":"true"}),a.jsx("p",{className:"text-sm font-medium text-fg",children:"You're caught up"}),a.jsx("p",{className:"text-xs text-fg-subtle",children:"Nothing needs attention."})]})}function Kt({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 Ae=[{id:"unread",name:"is",value:"unread"},{id:"attachment",name:"has",value:"attachment"}],Ne="category",Zt={unclassified:"uncategorized"},q=e=>ct(e).map(t=>t.raw),E=e=>e.join(" "),oe=e=>{const t=we(e);if(t)return Ae.find(o=>o.name===t.name&&o.value===t.value.toLowerCase())?.id},ne=e=>{const t=we(e);if(!t||t.name!==Ne)return;const o=t.value.toLowerCase(),r=Zt[o];if(r)return r;if(!(!et(o)||o==="all"))return o},Be=e=>Ae.find(t=>t.id===e),Fe=e=>Be(e)!==void 0,Xt=e=>{const t=new Set;for(const o of q(e)){const r=oe(o);r&&t.add(r)}return t},es=e=>{let t="all";for(const o of q(e)){const r=ne(o);r&&(t=r)}return t},ts=(e,t)=>{const o=Be(t);if(!o)return;const r=q(e),c=r.filter(l=>oe(l)!==t);return c.length<r.length?E(c):E([...r,Re(o.name,o.value)])},ss=(e,t)=>{const o=q(e).filter(r=>!ne(r));return E(t==="all"?o:[...o,Re(Ne,t)])},as=e=>E(q(e).filter(t=>!oe(t)&&!ne(t))),Oe=e=>e.trim().length>0,os=e=>{if(!Oe(e.query))return e.ownFilters;const t=new Set(Xt(e.query));for(const o of e.ownFilters)Fe(o)||t.add(o);return t},ns=e=>Oe(e.query)?es(e.query):e.ownCategory,rs=(e,t)=>e.createdAt!==t.createdAt?e.createdAt-t.createdAt:e.accountId.localeCompare(t.accountId),is=e=>[...e].sort(rs),ls=200,je=()=>a.jsx("div",{className:"animate-pulse",children:Array.from({length:3}).map((e,t)=>a.jsxs("div",{className:"flex items-start gap-3 py-2 pl-5 pr-4 border-b border-line",children:[a.jsx("div",{className:"size-7 rounded-full bg-surface-sunken shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsxs("div",{className:"flex justify-between gap-2",children:[a.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-28"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-12"})]}),a.jsx("div",{className:"h-3.5 bg-surface-sunken rounded w-48"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]})]},t))}),cs=({accountEmail:e})=>{const t=ae();return a.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:[a.jsx(Te,{className:"size-3.5 shrink-0"}),a.jsxs("span",{className:"flex-1 truncate",children:[e," can't connect"]}),a.jsx("button",{type:"button",onClick:()=>t({to:"/settings/accounts"}),className:"shrink-0 underline text-danger hover:opacity-80",children:"Reconnect"})]})},ds=(e,t)=>{if(t.size===0)return{};const o=new Set,r=new Set;for(const l of e)t.has(l.id)&&(l.accountId&&o.add(l.accountId),l.mailboxId&&r.add(l.mailboxId));if(o.size>1)return{moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"};const c=o.size===1?[...o][0]:void 0;return r.size>1?{accountId:c,moveDisabledHint:`Move only works within one folder — this selection spans ${r.size} folders`}:{accountId:c,mailboxId:r.size===1?[...r][0]:void 0}};function us({header:e,rows:t,wizard:o,children:r}){const{selectedIds:c,selectedCount:l,exitSelection:p,orderedIds:u,allSelected:x,toggleAllLoaded:y}=Rt(),m=n.useMemo(()=>ds(t,c),[t,c]),{junkMailboxId:C}=wt(m.accountId),{labels:O}=_t(m.accountId),M=n.useMemo(()=>Array.from(c),[c]),j=n.useMemo(()=>t.filter(g=>c.has(g.id)).map(g=>({id:g.id,sender:g.fromName,email:g.fromEmail,subject:g.subject,date:g.timeLabel})),[t,c]),h=Mt(C,m.mailboxId),I=n.useMemo(()=>u.length>0?{checked:x,indeterminate:l>0&&!x,onChange:y}:void 0,[u.length,x,l,y]),b=m.moveDisabledHint?{tone:"warning",text:m.moveDisabledHint}:void 0,B=g=>a.jsx(Nt,{title:g.title,navSlot:g.navSlot,titleMeta:g.titleMeta,searchSlot:g.searchSlot,searchField:g.searchField,idleSlot:g.makeFilterSlot,count:l,onCancel:p,onDelete:()=>o.start("delete"),onMove:()=>o.start("move"),onOrganize:()=>o.start("organize"),onJunk:h?()=>o.start("junk"):void 0,onMarkRead:()=>o.start("markRead"),overflowSlot:m.accountId&&m.mailboxId&&l>0&&O.length>0?a.jsx(Gt,{accountId:m.accountId,mailboxId:m.mailboxId,messageIds:M}):void 0,selectAll:I,notice:b});return a.jsx(kt,{...e,selectionBar:B,paneOverlay:a.jsx(At,{verb:o.verb,accountId:m.accountId,mailboxId:m.mailboxId,selection:j,crossAccount:m.moveDisabledHint!==void 0,onFinished:p}),children:r})}function ms({accounts:e,selectedMessageId:t,onOpenThread:o,commandsRef:r,onTriageContextChange:c,onDeleteMessages:l}){const{searchQuery:p,searchInput:u,resultFolderIndex:x,onSearchChange:y}=F(),m=dt(),C=Ut(),O=$t(),M=tt(),j=ae(),h=n.useMemo(()=>is(e.filter(s=>!s.muted?.value)),[e]),[I,b]=n.useState("all"),[B,g]=n.useState("all"),[L,V]=n.useState(new Set),[k,P]=n.useState(!1),z=n.useCallback(s=>{V(i=>{const d=new Set(i);return d.has(s)?d.delete(s):d.add(s),d})},[]),H=n.useCallback(()=>V(new Set),[]),S=u.trim().length>0,A=n.useMemo(()=>os({query:u,ownFilters:L}),[u,L]),f=n.useMemo(()=>ns({query:u,ownCategory:B}),[u,B]),T=n.useCallback(s=>{if(!S||!Fe(s)){z(s);return}const i=ts(u,s);i!==void 0&&y(i)},[S,u,y,z]),N=n.useCallback(s=>{if(!S){g(s);return}y(ss(u,s))},[S,u,y]),G=n.useCallback(()=>{g("all"),b("all"),H(),S&&y(as(u))},[S,u,y,H]),{data:Q,isLoading:Y,isError:re,refetch:ie}=te({...se(),staleTime:6e4}),_=st({queries:h.map(s=>({...at({path:{accountId:s.accountId}}),staleTime:1/0,meta:{softError:!0}}))}),$=n.useMemo(()=>{const s=new Map;for(let i=0;i<h.length;i++){const d=h[i].accountId,Ye=(_[i]?.data?.items??[]).reduce((Je,Ke)=>Je+(Ke.unseenCount??0),0);s.set(d,Ye)}return s},[h,_]),Ee=n.useMemo(()=>h.filter((s,i)=>{const d=_[i];return d?.isError?!ot(d.error):!1}),[h,_]),{freeText:R,tokens:J}=ut(p.trim().toLowerCase(),m),{data:le,isFetching:qe}=te({...se({query:{query:R,limit:ls}}),enabled:R.length>0,staleTime:3e4}),v=n.useMemo(()=>{const s=ve(Q?.items??[]).map(ye);return(R?ft(s.filter(d=>ht(d,R)),ve(le?.items??[]).map(ye)):s).filter(d=>(I==="all"||d.accountId===I)&>(d,J))},[Q,le,I,R,J]),{bodyRows:ce,briefSpamOffer:K}=n.useMemo(()=>{if(!R)return{bodyRows:v,briefSpamOffer:void 0};const s=v.map(w=>Ce(w,x)),{spam:i}=xt(s);if(i.length===0)return{bodyRows:v,briefSpamOffer:void 0};const d=new Set(i.map(w=>w.id));return{bodyRows:v.filter(w=>!d.has(w.id)),briefSpamOffer:pt(s)}},[v,R,x]),de=n.useMemo(()=>It(ce),[ce]),ue=n.useCallback((s,i)=>{const d=v.find(w=>w.id===s)?.threadId;d&&o?.({threadId:d,messageId:s},i)},[v,o]),Pe=n.useCallback(s=>{const i=s.threadId??v.find(d=>d.id===s.id)?.threadId;i&&o?.({threadId:i,messageId:s.id})},[v,o]),Z=n.useMemo(()=>h.length<=1?[]:[{id:"all",label:"All",active:I==="all"},...h.map(s=>({id:s.accountId,label:s.email.split("@")[0]??s.email,count:$.get(s.accountId),active:I===s.accountId}))],[h,$,I]),D=n.useMemo(()=>e.filter(s=>s.muted?.value).length,[e]),ze=n.useMemo(()=>Array.from($.values()).reduce((s,i)=>s+i,0),[$]),X=n.useMemo(()=>h.map(s=>s.accountId),[h]),{hasNewMail:me}=qt(),{state:fe,errorMessage:he,refresh:ge}=Pt(X,{onSettled:()=>ie()}),He=n.useMemo(()=>a.jsx(zt,{state:fe,onRefresh:ge,label:"Refresh daily brief",errorMessage:he,hasUpdate:me(X)}),[fe,ge,he,me,X]),ee=n.useMemo(()=>v.filter(s=>(f==="all"||s.category===f)&&nt(s,A)).map(s=>Ce(s,x)),[v,f,A,x]),{hits:xe,isLoading:Qe}=Vt(),_e=n.useMemo(()=>{const s=new Map;for(const d of Q?.items??[])s.set(d.messageId,d.threadId);const i=ee.map(d=>s.get(d.id)).filter(d=>d!=null);return bt(xe,i,x)},[xe,ee,Q,x]),$e=n.useMemo(()=>{const s=vt(Z.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:D>0?`+${D} muted`:void 0,selectedCategory:f,activeFilters:A,expanded:k,onExpandedChange:P,onSelectCategory:i=>N(i),onSelectSource:b,onToggleFilter:i=>T(i),onClear:G}},[Z,D,f,A,k,T,N,G]),pe=de.length===0&&I==="all"&&R.length===0&&J.length===0,We=n.useMemo(()=>h.map(s=>s.accountId),[h]),Ue=n.useMemo(()=>h.some(s=>Ht(s.syncPhase)),[h]),W=Qt(We,pe||Ue),Ie=a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(je,{}),a.jsx(je,{})]}),be=!Y&&!re&&!pe,Ve=yt({tier:O,hasLiveInput:S,hasCommittedQuery:p.trim().length>0,bodyRendersCommittedResults:!0}),Ge=be?a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[K&&a.jsx(Ct,{count:K.count,onScopeToSpam:()=>j({to:"/mail/$mailboxId",params:{mailboxId:K.mailboxId},search:{q:p||void 0}})}),a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(rt,{sections:de,briefCategory:f,Row:St,selectedThreadId:t,onSelectThread:ue,onSelectBriefCategory:N,sources:Z,sourcesNote:D>0?`+${D} muted`:void 0,onSelectSource:b,activeFilters:A,onToggleFilter:T,onClearFilters:G})})]}):Y?Ie:re?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 py-12 text-sm text-fg-muted",children:[a.jsx(Te,{className:"size-8 text-danger"}),a.jsx("p",{children:"Couldn't load your messages"}),a.jsxs("button",{type:"button",onClick:()=>ie(),className:"flex items-center gap-1 text-accent underline text-xs",children:[a.jsx(Wt,{className:"size-3.5"}),"Try again"]})]}):W.resolved?a.jsx(Jt,{sync:W.syncing?{synced:W.synced,total:W.total}:void 0}):Ie;return a.jsx(it,{hasSheet:be&&!Ve,children:a.jsx(jt,{selectedMessageId:t,onOpen:ue,onDeleteMessages:l,onSelectionVerb:M.start,wizardOpen:M.isOpen,commandsRef:r,onTriageContextChange:c,children:a.jsx(us,{wizard:M,header:{title:"Daily brief",unreadCount:ze,footer:C?a.jsx(Tt,{}):void 0,searchFilter:$e,searchResults:ee,searchLoading:Y||qe,relatedResults:_e,relatedLoading:Qe,onSelectSearchResult:Pe,searchResultsInBody:!0,refreshControl:He},rows:v,children:a.jsxs("div",{className:"flex h-full flex-col",children:[Ee.map(s=>a.jsx(cs,{accountEmail:s.email,accountId:s.accountId},s.accountId)),a.jsx("div",{className:"min-h-0 flex-1",children:Ge})]})})})})}const Le=n.createContext(null);function U(){const e=n.useContext(Le);if(!e)throw new Error("BriefPane.* must be used inside <BriefPane>");return e}function fs({thread:e,children:t}){const o=ae(),{searchInput:r}=F(),c=e?.threadId,l=e?.messageId,{data:p}=te({...se(),staleTime:6e4}),u=n.useMemo(()=>p?.items??[],[p]),x=n.useMemo(()=>{if(c)return u.find(f=>f.messageId===l)??u.find(f=>f.threadId===c)},[u,c,l]),y=Yt(c,l),m=x??y,C=l??m?.messageId,O=n.useMemo(()=>{if(c)return{threadId:c,mailboxId:m?.mailboxId??"",subject:m?.subject,messageId:C,authenticity:m?.authenticity}},[c,m,C]),M=n.useCallback((f,T)=>{o({to:"/mail/brief/$threadId/$messageId",params:f,replace:T?.replace,search:N=>({...N,q:r||void 0})})},[o,r]),j=n.useCallback(()=>{o({to:"/mail/brief",search:f=>f})},[o]),h=n.useCallback(f=>{C&&f.includes(C)&&j()},[C,j]),I=Se({thread:m,onAfterOptimisticRemove:h}),b=Bt(),{deleteMessages:B}=Ft({mailboxId:m?.mailboxId??"",messages:u,onAfterOptimisticRemove:h}),{toggleReadFor:g}=Ot({mailboxId:m?.mailboxId??"",messages:u}),L=b.focusedMessageId,k=n.useMemo(()=>u.find(f=>f.messageId===L),[u,L])??m,P=Se({thread:k}),{nextMessageId:z,previousMessageId:H}=Lt({context:b,orderedIds:b.orderedIds,selectedMessageId:C,onClose:j,handlers:{reply:()=>I.requestCompose("reply"),replyAll:()=>I.requestCompose("reply_all"),forward:()=>I.requestCompose("forward"),delete:()=>{b.listCommandsRef.current?.requestVerb("delete")||P.deleteThread()},toggleStar:P.toggleStar,toggleRead:()=>{b.listCommandsRef.current?.requestVerb("markRead")||k&&g([k.messageId],!k.isRead)},goFlagged:()=>o({to:"/mail/flagged"}),goSettings:()=>o({to:"/settings"})}}),S=n.useCallback(f=>{if(!f)return;const T=u.find(N=>N.messageId===f);return T?{threadId:T.threadId,messageId:f}:void 0},[u]),A={selectedMessageId:C,selectedThread:m,conversation:O,onOpenThread:M,onCloseThread:j,nextThread:S(z),previousThread:S(H),actions:I,triage:b,onDeleteMessages:B,handleDeselectIfRemoved:h};return a.jsx(Le.Provider,{value:A,children:t})}function De(){const{selectedMessageId:e,onOpenThread:t,triage:o,onDeleteMessages:r}=U(),{accounts:c}=F();return a.jsx(ms,{accounts:c,selectedMessageId:e,onOpenThread:t,commandsRef:o.listCommandsRef,onTriageContextChange:o.onTriageContextChange,onDeleteMessages:r})}function hs(){const{conversation:e,actions:t}=U(),{intelligenceOpen:o,onToggleIntelligence:r}=F(),c=lt()?.showIntelligencePane??!1,l=!!e,p=c&&l;return a.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsx(Et,{hasThread:l,intelligenceOpen:p&&o,canToggleIntelligence:p,onToggleIntelligence:r,onReply:l?()=>t.requestCompose("reply"):void 0,onReplyAll:l?()=>t.requestCompose("reply_all"):void 0,onForward:l?()=>t.requestCompose("forward"):void 0,onDelete:l?t.deleteThread:void 0,onToggleStar:l?t.toggleStar:void 0,isStarred:t.isStarred,moveContext:l&&t.accountId&&t.mailboxId?{accountId:t.accountId,currentMailboxId:t.mailboxId,onMove:t.moveThread}:void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?a.jsx(Me,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,selectedMessageId:e.messageId,authenticity:e.authenticity,composeRequest:t.composeRequest,onComposeClose:t.clearComposeRequest}):a.jsx(mt,{})})]})}function gs(){const{selectedThread:e,handleDeselectIfRemoved:t}=U(),{onToggleIntelligence:o}=F();return a.jsx(ke,{onClose:o,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function xs(){const{selectedThread:e,conversation:t,onOpenThread:o,onCloseThread:r,nextThread:c,previousThread:l,handleDeselectIfRemoved:p}=U(),{intelligenceOpen:u,onToggleIntelligence:x}=F();return t?a.jsxs(a.Fragment,{children:[a.jsx(Me,{threadId:t.threadId,mailboxId:t.mailboxId,subject:t.subject,selectedMessageId:t.messageId,authenticity:t.authenticity,onBack:r,onOpenIntelligence:x,onSwipeNext:c?()=>o(c):void 0,onSwipePrevious:l?()=>o(l):void 0,mobileIntelligenceOpen:u}),a.jsx(Dt,{isOpen:u,onClose:x,ariaLabel:"Message details",side:"right",children:a.jsx(ke,{onClose:x,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,hideCloseButton:!0,onAfterOptimisticRemove:p})})]}):a.jsx("div",{className:"h-full",children:a.jsx(De,{})})}const Ts=Object.assign(fs,{List:De,Reading:hs,Intelligence:gs,Phone:xs});export{Ts as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bd as G,r as i,be as U,o as j,bf as J,bg as X,bh as Y,j as a,p as Z,i as $}from"./index-DUmy4dAt.js";import{u as ee,p as te,R as se}from"./useSearchTokenContext-CZgI6mWz.js";import{t as ae,m as oe,a as re,f as ne,r as ie,b as le,M as de,T as ce,c as ue,d as ge,S as he,e as O,g as me,h as fe,i as xe,j as pe,C as A,D as Ie,I as E,k as be}from"./MailListHeader-4AXtZpJh.js";import{u as Te,M as Ce,a as ve}from"./MailViewChrome-BUsgxqXW.js";import{f as ye}from"./ErrorState-CzVRekaj.js";import{d as Se}from"./useFilters-DL6piWYB.js";const Re=()=>U({query:{starred:!0,order:"desc"}});function D(){const{data:e,isLoading:t,isError:s,error:n,refetch:l,fetchNextPage:o,hasNextPage:c,isFetchingNextPage:g}=Te({queryKey:Re(),queryFn:async({pageParam:d})=>{const{data:m}=await G({query:{starred:!0,order:"desc",continuationToken:d},throwOnError:!0});return m},initialPageParam:void 0,getNextPageParam:d=>d.continuationToken,staleTime:6e4});return{threads:i.useMemo(()=>(e?.pages??[]).flatMap(d=>d.items??[]),[e]),isLoading:t,isError:s,error:n,refetch:l,fetchNextPage:o,hasNextPage:c,isFetchingNextPage:g}}const je=e=>{const t=new Set;return e.filter(s=>t.has(s.threadId)?!1:(t.add(s.threadId),!0))},Fe={unread:e=>!e.isRead,attachment:e=>e.hasAttachment===!0};function we({rows:e,verb:t}){const{selectedIds:s,exitSelection:n}=ge(),l=i.useMemo(()=>e.filter(o=>s.has(o.id)).map(o=>({id:o.id,sender:o.fromName,email:o.fromEmail,subject:o.subject,date:o.timeLabel})),[e,s]);return a.jsx(he,{verb:t,selection:l,crossAccount:!0,onFinished:n})}function Pe({selectedMessageId:e,onSelectMessage:t,commandsRef:s,onTriageContextChange:n,onDeleteMessages:l}){const{searchQuery:o,resultFolderIndex:c}=j(),g=ee(),x=Se(),d=J(),[m,T]=i.useState("all"),[p,w]=i.useState(new Set),I=i.useCallback(r=>{w(u=>{const b=new Set(u);return b.has(r)?b.delete(r):b.add(r),b})},[]),C=i.useCallback(()=>{T("all"),w(new Set)},[]),{threads:v,isLoading:y,isError:S,error:h,refetch:P,fetchNextPage:M,hasNextPage:H,isFetchingNextPage:k}=D(),{freeText:R,tokens:L}=te(o.trim().toLowerCase(),g),f=i.useMemo(()=>{const r=Array.from(p).map(u=>Fe[u]).filter(u=>u!=null);return je(v).map(ae).filter(u=>(m==="all"||u.category===m)&&r.every(b=>b(u))&&(!R||oe(u,R))&&re(u,L))},[v,m,p,R,L]),Q=i.useMemo(()=>ne(),[]),V=i.useMemo(()=>f.map(r=>ie(r,c)),[f,c]),_=i.useMemo(()=>f.filter(r=>!r.isRead).length,[f]),q=y?"loading":S?"error":f.length===0?"empty":"ready",K=i.useCallback(()=>{const r=X(Y());window.open(r,"_blank","noopener,noreferrer")},[]),N=le(),W=a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"divide-y divide-line",children:f.map(r=>a.jsx(de,{thread:r,active:r.id===e,onClick:()=>t?.(r.id)},r.id))}),H?a.jsx("button",{type:"button",className:"w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50",onClick:()=>M(),disabled:k,children:k?"Loading…":"Load more"}):null]})});return a.jsx(Ce,{title:"Starred",unreadCount:_,preset:Q,selectedCategory:m,activeFilters:p,onSelectCategory:T,onToggleFilter:I,onClearFilters:C,searchResults:V,searchLoading:y,onSelectSearchResult:r=>t?.(r.id),searchResultsInBody:!0,children:a.jsxs(ce,{selectedMessageId:e,onOpen:(r,u)=>t?.(r,u),onDeleteMessages:l,onSelectionVerb:d.start,wizardOpen:d.isOpen,commandsRef:s,onTriageContextChange:n,children:[a.jsx(ve,{listTitle:"Starred",sections:[{id:"flagged",threads:f}],flatList:!0,hideHeader:!0,listState:N.searchResults?"ready":q,searchQuery:R?o:void 0,errorMessage:S?ye(h):void 0,onRetry:()=>P(),onReportError:K,selectedThreadId:e,onSelectThread:t,isDesktop:x,selectionBar:a.jsx(ue,{title:"Starred"}),listBody:N.searchResults??(q==="ready"?W:void 0)}),a.jsx(we,{rows:f,verb:d.verb})]})})}const B=i.createContext(null);function F(){const e=i.useContext(B);if(!e)throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");return e}function Me({selectedMessageId:e,children:t}){const s=Z(),{threads:n}=D(),l=i.useMemo(()=>{if(e)return n.find(h=>h.messageId===e)},[n,e]),o=i.useCallback((h,P)=>{s({to:"/mail/flagged",search:M=>({...M,selectedMessageId:h}),replace:P?.replace})},[s]),c=i.useCallback(()=>{s({to:"/mail/flagged",search:h=>({...h,selectedMessageId:void 0})})},[s]),g=i.useCallback(h=>{e&&h.includes(e)&&c()},[e,c]),x=O({thread:l,onAfterOptimisticRemove:g}),d=me(),{deleteMessages:m}=fe({mailboxId:l?.mailboxId??"",messages:n,onAfterOptimisticRemove:g}),{toggleReadFor:T}=xe({mailboxId:l?.mailboxId??"",messages:n}),p=d.focusedMessageId,I=i.useMemo(()=>n.find(h=>h.messageId===p),[n,p])??l,C=O({thread:I}),{nextMessageId:v,previousMessageId:y}=pe({context:d,orderedIds:d.orderedIds,selectedMessageId:e,onClose:c,handlers:{reply:()=>x.requestCompose("reply"),replyAll:()=>x.requestCompose("reply_all"),forward:()=>x.requestCompose("forward"),delete:()=>{d.listCommandsRef.current?.requestVerb("delete")||C.deleteThread()},toggleStar:C.toggleStar,toggleRead:()=>{d.listCommandsRef.current?.requestVerb("markRead")||I&&T([I.messageId],!I.isRead)},goBrief:()=>s({to:"/mail/brief"}),goSettings:()=>s({to:"/settings"})}}),S={selectedMessageId:e,selectedThread:l,onSelectMessage:o,onCloseThread:c,actions:x,triage:d,onDeleteMessages:m,nextMessageId:v,previousMessageId:y,handleDeselectIfRemoved:g};return a.jsx(B.Provider,{value:S,children:t})}function z(){const{selectedMessageId:e,onSelectMessage:t,triage:s,onDeleteMessages:n}=F();return a.jsx(Pe,{selectedMessageId:e,onSelectMessage:t,commandsRef:s.listCommandsRef,onTriageContextChange:s.onTriageContextChange,onDeleteMessages:n})}function ke(){const{selectedThread:e,actions:t}=F(),{intelligenceOpen:s,onToggleIntelligence:n}=j(),l=$()?.showIntelligencePane??!1,o=!!e,c=l&&o;return a.jsxs("section",{className:"flex h-full w-full min-w-0 flex-col bg-canvas",children:[a.jsx(be,{hasThread:o,intelligenceOpen:c&&s,canToggleIntelligence:c,onToggleIntelligence:n,onReply:o?()=>t.requestCompose("reply"):void 0,onReplyAll:o?()=>t.requestCompose("reply_all"):void 0,onForward:o?()=>t.requestCompose("forward"):void 0,onDelete:o?t.deleteThread:void 0,onToggleStar:o?t.toggleStar:void 0,isStarred:t.isStarred,moveContext:o&&t.accountId&&t.mailboxId?{accountId:t.accountId,currentMailboxId:t.mailboxId,onMove:t.moveThread}:void 0}),a.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e?a.jsx(A,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,authenticity:e.authenticity,composeRequest:t.composeRequest,onComposeClose:t.clearComposeRequest}):a.jsx(se,{})})]})}function Le(){const{selectedThread:e,handleDeselectIfRemoved:t}=F(),{onToggleIntelligence:s}=j();return a.jsx(E,{onClose:s,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,onAfterOptimisticRemove:t})}function qe(){const{selectedThread:e,onCloseThread:t,onSelectMessage:s,nextMessageId:n,previousMessageId:l,handleDeselectIfRemoved:o}=F(),{intelligenceOpen:c,onToggleIntelligence:g}=j();return e?a.jsxs(a.Fragment,{children:[a.jsx(A,{threadId:e.threadId,mailboxId:e.mailboxId,subject:e.subject,authenticity:e.authenticity,onBack:t,onOpenIntelligence:g,onSwipeNext:n?()=>s(n):void 0,onSwipePrevious:l?()=>s(l):void 0,mobileIntelligenceOpen:c}),a.jsx(Ie,{isOpen:c,onClose:g,ariaLabel:"Message details",side:"right",children:a.jsx(E,{onClose:g,thread:e,mailboxId:e?.mailboxId,accountId:e?.accountId,hideCloseButton:!0,onAfterOptimisticRemove:o})})]}):a.jsx("div",{className:"h-full",children:a.jsx(z,{})})}const ze=Object.assign(Me,{List:z,Reading:ke,Intelligence:Le,Phone:qe});export{ze as F};
|