@remit/web-client-dist 0.0.326 → 0.0.327
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-Blw3XOe0.js +1 -0
- package/assets/{ErrorState-B2fd0qgi.js → ErrorState-CHBHNYQS.js} +1 -1
- package/assets/FlaggedPane-vTEeU26L.js +1 -0
- package/assets/MailListHeader-BLdUipHt.js +52 -0
- package/assets/{MailViewChrome-GG569jO2.js → MailViewChrome-Be3ErsZj.js} +1 -1
- package/assets/MailboxPane-DkW1kOf1.js +1 -0
- package/assets/{NavMenuButton-C6EakwyV.js → NavMenuButton-wyXvU-7L.js} +1 -1
- package/assets/{OnboardingWizard-Do-jHxM2.js → OnboardingWizard-04ayePfk.js} +1 -1
- package/assets/{OutboxPane-DQdJ-OYf.js → OutboxPane-C46PUaxA.js} +1 -1
- package/assets/_mailboxId-C5XAukHU.js +1 -0
- package/assets/_messageId-DwAktSw7.js +1 -0
- package/assets/_messageId-MQs0xH0E.js +1 -0
- package/assets/_outboxMessageId-WzAAWQTg.js +1 -0
- package/assets/_threadId-BW0Lu8jC.js +1 -0
- package/assets/_threadId-D-3tCJO-.js +1 -0
- package/assets/{account-form-helpers-DJ_MzJcJ.js → account-form-helpers-Cxg4r3BT.js} +1 -1
- package/assets/{accounts-n0zA_Sx3.js → accounts-C0rRiLSk.js} +1 -1
- package/assets/{advanced-DojBSLk8.js → advanced-Csf3s7-H.js} +1 -1
- package/assets/{appearance-BzWMGiHV.js → appearance-4VPGzqyq.js} +1 -1
- package/assets/{avatar-CL8zAkeN.js → avatar-jOP6UWqK.js} +1 -1
- package/assets/{bottom-sheet-DPBukuGw.js → bottom-sheet-8yl8cuX7.js} +1 -1
- package/assets/brief-Dh0osHhT.js +1 -0
- package/assets/{brief-CAYvnZkP.js → brief-DjQNM-D4.js} +1 -1
- package/assets/{browser-ponyfill-BiTPbbJ0.js → browser-ponyfill-CVJcT5S6.js} +1 -1
- package/assets/{circle-check-T7inrSlr.js → circle-check-BEVn-TI1.js} +1 -1
- package/assets/{circle-check-big-YyhTtChH.js → circle-check-big-DAFbfJi2.js} +1 -1
- package/assets/{circle-help-BiPu3ew0.js → circle-help-CZnon8UJ.js} +1 -1
- package/assets/{clock-BBDUXchk.js → clock-DU7TCwP7.js} +1 -1
- package/assets/{confirm-dialog-B8hW3xTl.js → confirm-dialog-fW2VFpuf.js} +1 -1
- package/assets/{download-BBvTCHi6.js → download-C16RP9CN.js} +1 -1
- package/assets/filters-vwPVGk6q.js +1 -0
- package/assets/{flagged-BqqINerN.js → flagged-BVJOxgjJ.js} +1 -1
- package/assets/flagged-qLRCdG5g.js +1 -0
- package/assets/{folders-CGxUJePq.js → folders-DWVAXg-C.js} +1 -1
- package/assets/index-3DZJ6uTl.js +1 -0
- package/assets/index-BKpJMo5D.js +1 -0
- package/assets/{index-O2cdx0UD.js → index-Bwp5OQpQ.js} +4 -4
- package/assets/{index-rGtSoq8U.css → index-DUKJ-tDb.css} +1 -1
- package/assets/index-DWsgj0VV.js +1 -0
- package/assets/index-DsHWjJXW.js +1 -0
- package/assets/index-LJ5w3k2V.js +1 -0
- package/assets/index-MQs0xH0E.js +1 -0
- package/assets/index-wdeYr6S8.js +1 -0
- package/assets/{kbd-fGjl0R2R.js → kbd-CPcSanPY.js} +1 -1
- package/assets/{labels-Hz_yvydt.js → labels-DeKjPNT1.js} +1 -1
- package/assets/layout-breakpoints-BWjiUQKh.js +1 -0
- package/assets/mail-CJgTO01Z.js +1 -0
- package/assets/{menu-749yYaOs.js → menu-DPE9pjqH.js} +1 -1
- package/assets/{move-options-CbYTh-jY.js → move-options-Csbk4V5Q.js} +1 -1
- package/assets/{nav-link-Dvrt0ixJ.js → nav-link-DkNRr0qZ.js} +1 -1
- package/assets/{onboarding-CJIW5F4z.js → onboarding-DZMOJYSS.js} +1 -1
- package/assets/outbox-BzsZDEbQ.js +1 -0
- package/assets/{pencil-LMlr37Ux.js → pencil-DRb3y29N.js} +1 -1
- package/assets/rich-text-BkPjntEn.js +29 -0
- package/assets/{rotate-ccw-Ba9ztbIZ.js → rotate-ccw-CvEB1LaO.js} +1 -1
- package/assets/{row-actions-slyfr_Fo.js → row-actions-BTJtEh-M.js} +1 -1
- package/assets/{search-scope-BHR9t-UV.js → search-scope-VKguXzKa.js} +1 -1
- package/assets/search-token-index-LTew3OxT.js +1 -0
- package/assets/{search-view-BRKrXRVq.js → search-view-C4zDDGmW.js} +1 -1
- package/assets/{senders-BI6ZBV3I.js → senders-Dv1kQnSF.js} +1 -1
- package/assets/settings-BQNqJIMg.js +1 -0
- package/assets/{settings-screen-BeqFPGur.js → settings-screen-Bz53mSfP.js} +1 -1
- package/assets/{shield-check-CR6WHaFj.js → shield-check-CsFZbw84.js} +1 -1
- package/assets/{suggested-vips-CfOezvuC.js → suggested-vips-dDlp-3pf.js} +1 -1
- package/assets/use-match-media-Bahc65V3.js +1 -0
- package/assets/{useDebouncedValue-BfpIwZPB.js → useDebouncedValue-CZlpqWW6.js} +1 -1
- package/assets/useFilters-8lyeAYaZ.js +1 -0
- package/assets/{useLabels-BR_qCBVH.js → useLabels-DX0u5BY7.js} +1 -1
- package/assets/{useRefreshControl-DRuoqMcf.js → useRefreshControl-COhqTZ8E.js} +1 -1
- package/assets/{useSearchMirror-CfmNf2s0.js → useSearchMirror-D7jaJTls.js} +1 -1
- package/assets/useSearchTokenContext-BObYEOel.js +67 -0
- package/assets/{useSignature-CbQsXZmF.js → useSignature-Jio0QfkY.js} +1 -1
- package/assets/{useThreadRow-BLHtBJE7.js → useThreadRow-D-CBhW5T.js} +1 -1
- package/index.html +2 -2
- package/package.json +1 -1
- package/assets/BriefPane-BOamyVfq.js +0 -1
- package/assets/FlaggedPane-DJe2knEd.js +0 -1
- package/assets/MailListHeader-COc4jxBW.js +0 -52
- package/assets/MailboxPane-DMQ_53Cu.js +0 -1
- package/assets/_mailboxId-D0m5vIUm.js +0 -1
- package/assets/_messageId-BaBQqN5q.js +0 -1
- package/assets/_messageId-D-NZRHdU.js +0 -1
- package/assets/_outboxMessageId-CagBcpOi.js +0 -1
- package/assets/_threadId-D_3J8QyJ.js +0 -1
- package/assets/_threadId-E5xGF5G1.js +0 -1
- package/assets/brief-D6IyB6xl.js +0 -1
- package/assets/filters-Dh23PxPJ.js +0 -1
- package/assets/flagged-sOFg3fem.js +0 -1
- package/assets/index-Bhl5AGoD.js +0 -1
- package/assets/index-BkEqKpJ2.js +0 -1
- package/assets/index-C4jTXJZN.js +0 -1
- package/assets/index-C6oLigoT.js +0 -1
- package/assets/index-D-NZRHdU.js +0 -1
- package/assets/index-D2GH2NJx.js +0 -1
- package/assets/index-mv235hnx.js +0 -1
- package/assets/mail-DDw_CO7o.js +0 -1
- package/assets/outbox-BO_GhwQo.js +0 -1
- package/assets/rich-text-DvlhJ2bG.js +0 -29
- package/assets/search-token-index-ITFIDClQ.js +0 -1
- package/assets/settings-DNkY3n-6.js +0 -1
- package/assets/useFilters-DU-FFtjR.js +0 -1
- package/assets/useMediaQuery-7tN-xCT2.js +0 -1
- package/assets/useSearchTokenContext-BiFMzo8q.js +0 -67
|
@@ -1 +0,0 @@
|
|
|
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-O2cdx0UD.js";import{u as ee,b as te,S as ne}from"./search-scope-BHR9t-UV.js";import{a as L,D as oe}from"./useMediaQuery-7tN-xCT2.js";const ve=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 Ie=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 Ne(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 Te(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})]})},De=({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 Pe({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 Ke=({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})]})},Me=({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}),Re=()=>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},Le=({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 Ae(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 je=({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,Fe=e=>e!=="desktop",qe=()=>{const e=L(`(min-width: ${we}px)`);return L(oe)?"desktop":e?"tablet":"phone"};function Oe(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 Be(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 He(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 _e(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{ve as B,Ke as D,se as K,Ie as R,De as S,Re as a,Me as b,Be as c,qe as d,je as e,Pe as f,Oe as g,ke as h,Fe as i,Le as j,re as k,Ne as l,de as m,He as n,_e as o,ae as s,Te as t,Ae as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,a0 as o}from"./index-O2cdx0UD.js";const n=()=>t.jsx(o,{});export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as m,ag as b,cR as E,x as C,cS as x,cA as F,cT as D,s as M,cU as N,cV as P,cW as L,cX as z}from"./index-O2cdx0UD.js";const B=(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"},K=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?"+":"-",l=Math.abs(o),c=String(Math.floor(l/60)).padStart(2,"0"),f=String(l%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}${c}:${f}`},h="None",V=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}),X=({mode:e,ruleScope:t})=>t==="standing"?"standing":t==="until"?"temporary":e==="selected"?"just-these":"all-like-these",G=({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}:{}}),T=new Set(["Complete","Failed"]),v=e=>e!==void 0&&T.has(e),w=1e3,J=15e3,R=e=>{const t=Math.max(0,e),r=w*2**t;return Math.min(r,J)},_=(e,t,r)=>{if(e)return{kind:r?"restartFailed":"startFailed",error:e};if(t)return{kind:"statusUnreadable",error:t}},Y=e=>{const[t,r]=m.useState(),a=b({...E(),onSuccess:g=>r(g.organizeJobId)}),{mutate:i}=a,n=C({...x({path:{accountId:e??"",organizeJobId:t??""}}),enabled:!!e&&!!t,refetchInterval:g=>{const I=g.state.data?.state;return v(I)?!1:R(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]),l=n.data,c=a.isPending?void 0:l,f=c?.state??a.data?.state,u=v(c?.state),p={state:f,matchedCount:c?.matchedCount??0,appliedCount:c?.appliedCount??0,failedCount:c?.failedCount??0,errorMessage:c?.errorMessage??""};return{start:s,refreshStatus:d,progress:p,isStarting:a.isPending,isRunning:!!t&&!u,isDone:u,failure:_(a.error,n.error,!!l)}},Z=["From","Subject","HasWords","ListId","FromDomain"],$=e=>{const t=e.trim(),r=t.match(/<([^>]+)>/);return(r?r[1]:t).trim().toLowerCase()},ee=(e,t)=>e==="ListId"?$(t):t.trim(),k=e=>e==="all"?"And":"Or",U=(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:k(e.matchOperator),literalClauses:a}},Q=e=>e.anchorMessageId!==void 0||!e.literalClauses.some(t=>t.field==="HasWords"),W=e=>JSON.stringify({anchor:e.anchorMessageId??null,operator:e.matchOperator,clauses:e.literalClauses.map(t=>`${t.field} ${t.value}`)}),te=(e,t)=>{const r=U(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}},j=(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},q=350,re=(e,t,r)=>{const a=b(F()),{mutateAsync:i}=a,n=W(t),[s,o]=m.useState(()=>({})),d=m.useRef(t);d.current=t;const l=m.useRef(n),c=Q(t);return m.useEffect(()=>{if(!e||!c||n===s.previewedSignature||n===s.errorSignature)return;const f=setTimeout(()=>{const u=n;l.current=u,i({path:{accountId:e},body:y({...d.current})}).then(p=>{l.current===u&&o({count:p.matchedCount,matchedIds:p.messageIds,previewedSignature:u})}).catch(p=>{l.current===u&&o(g=>({...g,error:p instanceof Error?p.message:"Couldn't count matches.",errorSignature:u}))})},q);return()=>clearTimeout(f)},[e,c,n,s.previewedSignature,s.errorSignature,i]),c?{count:j(s,n),matchedIds:s.previewedSignature===n?s.matchedIds??[]:[]}:{count:{status:"error",reason:D},matchedIds:[]}},A=e=>P({path:{accountId:e}}),se=e=>{const t=C({...L({path:{accountId:e??""}}),enabled:!!e});return{filters:t.data?.items??[],isPending:t.isPending,isError:t.isError,error:t.error,refetch:t.refetch}},ae=e=>{const t=M(),r=b({...N(),onSuccess:()=>{e&&t.invalidateQueries({queryKey:A(e)})}}),{mutate:a,mutateAsync:i}=r,n=m.useCallback((o,d,l)=>{e&&a({path:{accountId:e},body:S(o,d,l)})},[e,a]),s=m.useCallback(async(o,d,l)=>e?i({path:{accountId:e},body:S(o,d,l)}).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}},ne=e=>{const t=M(),r=b({...z(),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,Z as S,Y as a,A as b,te as c,K as d,se as e,B as f,ne as g,y as h,ae as i,G as j,V as k,ee as n,X as o,O as p,U as r,re as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s}from"./index-O2cdx0UD.js";const r=1024,c=`(min-width: ${r}px) and (not ((orientation: portrait) and (pointer: coarse)))`,d=e=>{const[o,n]=s.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const t=window.matchMedia(e),a=i=>n(i.matches);return n(t.matches),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),o},m=()=>d(c);export{c as D,d as a,m as u};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import{c4 as X,r as f,j as a,b as B,I as Y,a2 as Z,n as P,s as W,x as J,cs as H,cr as ee,ae as te,ag as se,ah as re,bb as ne,e as ae,X as oe,K as C,o as ie}from"./index-O2cdx0UD.js";import{K as L}from"./kbd-fGjl0R2R.js";import{M as Q}from"./enums-CCxx0t2v.js";import{u as ce,i as le}from"./search-scope-BHR9t-UV.js";const de=(e,t)=>{const r=e==="newsletter"||e==="marketing"||t;return{framed:r,isPlain:!r}},ue=()=>`
|
|
2
|
-
/* Zero the UA default body margin and clamp the document to the iframe width so
|
|
3
|
-
wide author markup can't push the body (and the page) past the viewport. */
|
|
4
|
-
html, body {
|
|
5
|
-
margin: 0;
|
|
6
|
-
padding: 0;
|
|
7
|
-
max-width: 100%;
|
|
8
|
-
}
|
|
9
|
-
body {
|
|
10
|
-
overflow-wrap: anywhere;
|
|
11
|
-
word-break: break-word;
|
|
12
|
-
}
|
|
13
|
-
/* Media never wider than the frame; keep aspect ratio when width is capped. */
|
|
14
|
-
img, video, iframe, svg, canvas {
|
|
15
|
-
max-width: 100% !important;
|
|
16
|
-
height: auto;
|
|
17
|
-
}
|
|
18
|
-
/* Fixed-width author tables (\`<table width="600">\`) collapse to fit. */
|
|
19
|
-
table {
|
|
20
|
-
max-width: 100% !important;
|
|
21
|
-
table-layout: auto;
|
|
22
|
-
}
|
|
23
|
-
/* Cells carry the fixed widths in real newsletters (\`<td width="600">\`);
|
|
24
|
-
cap them too or the table can't actually shrink. */
|
|
25
|
-
td, th {
|
|
26
|
-
max-width: 100% !important;
|
|
27
|
-
}
|
|
28
|
-
/* \`max-width\` alone can't beat an inline \`min-width\`; zeroing the min lets
|
|
29
|
-
flex / grid / table children actually collapse to the clamped width. */
|
|
30
|
-
* {
|
|
31
|
-
min-width: 0;
|
|
32
|
-
}
|
|
33
|
-
/* Long unbroken strings (URLs, tokens) wrap instead of forcing a wide line. */
|
|
34
|
-
pre, code {
|
|
35
|
-
white-space: pre-wrap;
|
|
36
|
-
overflow-wrap: anywhere;
|
|
37
|
-
word-break: break-word;
|
|
38
|
-
}
|
|
39
|
-
`,fe=e=>{const t=new Map;for(const s of e){if(!s.contentId||s.contentUrl.length===0)continue;const r=s.contentId.replace(/^<|>$/g,"");t.set(r,s.contentUrl)}return s=>t.get(s.replace(/^<|>$/g,""))},me=/^(none|transparent|inherit|initial|unset)\s*$/i,he=e=>{const t=[],s=/<style[^>]*>([\s\S]*?)<\/style>/gi;let r;for(r=s.exec(e);r!==null;)t.push(r[1]),r=s.exec(e);return t},ge=e=>{const t=/background(?:-color)?\s*:\s*([^;}\n]+)/gi;let s;for(s=t.exec(e);s!==null;){const r=s[1].trim();if(!me.test(r))return!0;s=t.exec(e)}return!1},pe=e=>{if(/\bstyle\s*=\s*["'][^"']*background/i.test(e)||/\bbgcolor\s*=/i.test(e))return!0;for(const t of he(e))if(ge(t))return!0;return!1},ye=["script","iframe","object","embed","form","input","button","textarea","select","meta","link","base"],be=["onerror","onload","onclick","onmouseover","onmouseout","onfocus","onblur","onsubmit","onkeydown","onkeyup","formaction","xlink:href","data-bind"],xe="data:image/svg+xml,"+encodeURIComponent(`
|
|
40
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">
|
|
41
|
-
<rect fill="#f0f0f0" width="100" height="100"/>
|
|
42
|
-
<text x="50" y="50" text-anchor="middle" dy=".3em" fill="#999" font-size="12">
|
|
43
|
-
Image blocked
|
|
44
|
-
</text>
|
|
45
|
-
</svg>
|
|
46
|
-
`),we=e=>e.replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),ve=e=>e.replace(/@import[^;]*;/gi,"/* @import blocked */").replace(/url\s*\([^)]*\)/gi,"none").replace(/expression\s*\([^)]*\)/gi,"").replace(/-moz-binding\s*:[^;]*/gi,""),ke=(e={})=>{const t=X(),s={FORBID_TAGS:ye,FORBID_ATTR:be,ALLOW_DATA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1};return t.addHook("afterSanitizeAttributes",r=>{if(r.tagName==="IMG"){const n=r.getAttribute("src")||"";if(n.startsWith("data:"))return;if(n.startsWith("cid:")){const c=n.slice(4).replace(/^<|>$/g,""),m=e.resolveCid?.(c);m&&(r.setAttribute("src",m),r.classList.add("inline-content"));return}e.allowExternalImages||(r.setAttribute("data-blocked-src",n),r.setAttribute("src",xe),r.setAttribute("alt","[Blocked image]"),r.classList.add("blocked-image"))}if(r.tagName==="A"){const n=r.getAttribute("href")||"";if(/^(javascript|data):/i.test(n)){r.removeAttribute("href");return}r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer nofollow"),r.classList.add("external-link")}if(r.hasAttribute("style")){const n=r.getAttribute("style")||"";r.setAttribute("style",we(n))}}),t.addHook("uponSanitizeElement",(r,n)=>{if(n.tagName==="style"){const o=r.textContent||"";r.textContent=ve(o)}}),r=>{const n=pe(r),o=t.sanitize(r,s);return{html:`<style>${ue()}</style>${o}`,hasAuthorBackground:n}}},Ee='"Geist Variable", "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',_={light:{fg:"oklch(0.3 0.025 235)",surface:"oklch(0.975 0.012 90)",accent:"oklch(0.55 0.14 150)"},dark:{fg:"oklch(0.88 0.02 90)",surface:"oklch(0.25 0.025 220)",accent:"oklch(0.78 0.16 150)"}},Ae=/prefers-color-scheme\s*:\s*dark|color-scheme\s*:\s*[^;}"']*\bdark\b/i,O='<meta name="viewport" content="width=device-width, initial-scale=1">',Se=e=>{const t=e?_.dark:_.light;return`
|
|
47
|
-
/* Plain-email base: UI font-stack + theme-aware colors (#424) */
|
|
48
|
-
html, body {
|
|
49
|
-
font-family: ${Ee};
|
|
50
|
-
font-size: 14px;
|
|
51
|
-
line-height: 1.6;
|
|
52
|
-
color: ${t.fg};
|
|
53
|
-
background-color: ${t.surface};
|
|
54
|
-
margin: 0;
|
|
55
|
-
padding: 0;
|
|
56
|
-
}
|
|
57
|
-
/* Strip author unreadable text colors and element backgrounds, scoped to body
|
|
58
|
-
descendants so the themed html/body surface above survives this reset. */
|
|
59
|
-
body * {
|
|
60
|
-
color: inherit !important;
|
|
61
|
-
background-color: transparent !important;
|
|
62
|
-
}
|
|
63
|
-
a, a:visited {
|
|
64
|
-
color: ${t.accent} !important;
|
|
65
|
-
text-decoration: underline;
|
|
66
|
-
}
|
|
67
|
-
`},Te=(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}",Ne=(e,t,s)=>{if(t==="plain")return`${O}<style>${Se(s)}</style>${e}`;const r=Ae.test(e);return`${O}<style>${Te(s,r)}</style>${e}`},je=5e4,Re=1e4,Ce="(max-width: 640px)",Me=.4,Le="allow-same-origin allow-popups allow-popups-to-escape-sandbox",I=(e,t,s)=>Math.min(Math.ceil(Math.max(e,t)),s),Be=(e,t)=>e<=0||t<=0||e<=t?1:Math.max(Me,t/e),De=e=>{const[t,s]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e);s(r.matches);const n=o=>s(o.matches);return r.addEventListener("change",n),()=>r.removeEventListener("change",n)},[e]),t},$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=f.useRef(null),o=f.useRef(null),[c,m]=f.useState(0),[i,l]=f.useState(0),[p,d]=f.useState(0),g=De(Ce),x=f.useMemo(()=>Ne(e,t,s),[e,t,s]);f.useEffect(()=>{const b=n.current;if(!b)return;const k=()=>d(E=>E===b.clientWidth?E:b.clientWidth);k();const w=new ResizeObserver(k);return w.observe(b),()=>w.disconnect()},[]),f.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,je);m(S=>S===R?S:R);const $=I(y.body.scrollWidth,j?.scrollWidth??0,Re);l(S=>S===$?S:$)};let w,E;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),E=y)};return b.addEventListener("load",N),()=>{b.removeEventListener("load",N),E?.removeEventListener("keydown",U),w?.disconnect()}},[]);const u=g?Be(i,p):1,h=u<1,v=h?`${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:Le,srcDoc:x,className:h?void 0:r,scrolling:"no",style:{width:v,maxWidth:h?"none":void 0,border:"none",display:"block",height:M,overflow:"hidden",transform:h?`scale(${u})`:void 0,transformOrigin:h?"top left":void 0,colorScheme:"normal"}});return a.jsx("div",{ref:n,className:h?r:void 0,children:h?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:m})=>{const i=f.useMemo(()=>!e||typeof document>"u"?null:ke({allowExternalImages:n,resolveCid:o})(e),[e,n,o]),l=i?.html??null,{framed:p,isPlain:d}=de(r,i?.hasAuthorBackground??!1),g=f.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:m?.(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 vt({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,kt=(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 A 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 A("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 A(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 A("content-type-mismatch",`Refusing to render message body — expected ${t}, got Content-Type ${c}`);const m=await o.text();if(Ge(m,c))throw new A("spa-shell-leak","Refusing to render message body — response looks like the SPA shell (CloudFront 403/404 fallback leaked through to /content/*)");return m},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=f.useRef(null),m=W(),i=f.useRef(!1),l=f.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:(h,v)=>Ve(h,v,o),refetchDescribeMessage:()=>m.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,h)=>h instanceof A&&h.reason==="not-ready"?u<We:u<1,retryDelay:(u,h)=>h instanceof A&&h.reason==="not-ready"?(i.current=!0,(h.retryAfterSeconds??1)*1e3):1e3,meta:{softError:!0}}),g=d.isLoading&&!!r;f.useEffect(()=>{g&&(c.current=performance.now())},[g]),f.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,h])=>({queryKey:u,data:h}));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]=f.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return f.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 A?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,m]=f.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:()=>m(!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:m})=>{const[i,l]=f.useState(!1),p=r||i,d=tt(),{toggleTrusted:g,isPending:x}=et({messageId:n??""}),u=!!e&&e.length>0,{picked:h,data:v,isLoading:M,isError:T,error:b,refetch:k}=Ye({messageId:n,bodyParts:e,enabled:u}),w=f.useMemo(()=>fe(e??[]),[e]),E=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",m),children:a.jsx(it,{})});if(T)return a.jsx("div",{className:C("message-body",m),children:a.jsx(ot,{error:b,onRetry:()=>k()})});if(!h)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})})}else if(!t&&!s)return a.jsx("div",{className:C("message-body",m),children:a.jsx(z,{})});const y=!!(o&&n),j=()=>{!o||x||(l(!0),g(o,!1))};return a.jsx(Oe,{className:m,html:E,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])),At=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 St(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 Tt(e,t){return G(e).filter(s=>s.raw!==t.raw).map(s=>s.raw).join(" ")}function Nt(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 jt(){const{mailboxNameIndex:e,accountNameIndex:t}=ie();return{...ce({select:r=>le(r.matches)})?{}:{mailboxesByName:e},accountsByName:t}}export{Oe as M,vt as R,dt as S,G as a,Ue as b,Ye as c,et as d,Qe as e,Et as f,Nt as g,At as h,St as p,Tt as r,kt as s,jt as u};
|