@remit/web-client-dist 0.0.564 → 0.0.566
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-BSJc4ufm.js +1 -0
- package/assets/CalendarComposePane-DAQHpMrQ.js +1 -0
- package/assets/{CalendarComposeSeed-DNwuCKpr.js → CalendarComposeSeed-BoJ25Z4n.js} +1 -1
- package/assets/{CalendarShell-CGVvcfrA.js → CalendarShell-t1-2Y_Mx.js} +1 -1
- package/assets/{EmptyState-BTKm9F6Q.js → EmptyState-aKocWGoA.js} +1 -1
- package/assets/ErrorState-LP7AwW_p.js +1 -0
- package/assets/FlaggedPane-BBHVAfeU.js +1 -0
- package/assets/{FullCompose-AEoBq77L.js → FullCompose-BGRUJh6v.js} +1 -1
- package/assets/MailListHeader-sHAZiuvt.js +7 -0
- package/assets/MailNav-CJLhcbFk.js +1 -0
- package/assets/{MailShell-DX1zBcaU.js → MailShell-1bk-N22N.js} +1 -1
- package/assets/MailViewChrome-DXBi4P0H.js +1 -0
- package/assets/MailboxPane-DG81nhZp.js +1 -0
- package/assets/{NavMenuButton-CgziJeDD.js → NavMenuButton-BfJ2z8-p.js} +1 -1
- package/assets/{OnboardingWizard-Cq8ycceQ.js → OnboardingWizard-CmZ01AQi.js} +1 -1
- package/assets/OpenCalendarEvent-B7sk8Y9D.js +2 -0
- package/assets/OutboxPane-DffQA6-a.js +1 -0
- package/assets/_calendarObjectId-CZhe2ZOn.js +1 -0
- package/assets/_mailboxId-CeGv_4X5.js +1 -0
- package/assets/_messageId-Brtone_a.js +1 -0
- package/assets/_messageId-CjcRJFc4.js +1 -0
- package/assets/_messageId-CsrcFMPz.js +1 -0
- package/assets/_outboxMessageId-Ct60rh-G.js +1 -0
- package/assets/_recurrenceId-BEl7wwCo.js +1 -0
- package/assets/_threadId-B2k2md9Y.js +1 -0
- package/assets/_threadId-B9wrJ2nR.js +1 -0
- package/assets/_threadId-C181ZJF2.js +1 -0
- package/assets/_view._date-CvsLA6jP.js +1 -0
- package/assets/accounts-Bvb71cuD.js +1 -0
- package/assets/{advanced-D2ikJQGg.js → advanced-DFF0GBZN.js} +3 -3
- package/assets/{appearance-DsXwlVTk.js → appearance-COIu5SBk.js} +1 -1
- package/assets/{attachment-file-BRLoj6sG.js → attachment-file-Dpl8hNc0.js} +1 -1
- package/assets/{attendee-row-OHoLTo23.js → attendee-row-C4aifNUr.js} +1 -1
- package/assets/{avatar-BuUa_-Ae.js → avatar-C4qRFeeX.js} +1 -1
- package/assets/{bottom-sheet-BUcSDGQJ.js → bottom-sheet-A__0esXP.js} +1 -1
- package/assets/brief-CnRsQwJb.js +1 -0
- package/assets/{brief--NWfZGeB.js → brief-e1MDqt0Y.js} +1 -1
- package/assets/{browser-ponyfill-C1Yxcmyx.js → browser-ponyfill-DIGDHadX.js} +2 -2
- package/assets/{bug-C0Ms2LYI.js → bug-DTaMGe9c.js} +1 -1
- package/assets/{calendar-Bx2owKH5.js → calendar-B3bdWTl1.js} +1 -1
- package/assets/{calendar-color-PMGOIawE.js → calendar-color-C1HATGvz.js} +1 -1
- package/assets/{calendar-event-chip-CX0GIGM0.js → calendar-event-chip-CNYRAKOE.js} +1 -1
- package/assets/calendars-DRiWSSoo.js +1 -0
- package/assets/{card-Drp0FnU2.js → card-CgowAhQY.js} +1 -1
- package/assets/chevron-left-k4hHGFxU.js +1 -0
- package/assets/{circle-check-8G_6IWKh.js → circle-check-C6InBO6B.js} +1 -1
- package/assets/{circle-check-big-CVRDL2A5.js → circle-check-big-BrbWEiEZ.js} +1 -1
- package/assets/{circle-help-Ck_g9Pip.js → circle-help-CXIkMdfH.js} +1 -1
- package/assets/{clock-KUoHWkrr.js → clock-Dm6u_ukU.js} +1 -1
- package/assets/compose._-_outboxMessageId_-B8MenUoB.js +1 -0
- package/assets/compose._-_outboxMessageId_-B_gpxVdz.js +1 -0
- package/assets/compose._-_outboxMessageId_-C4Ava6lK.js +1 -0
- package/assets/compose._-_outboxMessageId_-DY2D7fpo.js +1 -0
- package/assets/{config-import-DJqfxqLZ.js → config-import-CfF4lyQV.js} +1 -1
- package/assets/{confirm-dialog-BVXTDPyQ.js → confirm-dialog-CABiCtGp.js} +1 -1
- package/assets/{copy-D_J7-xdX.js → copy-BIEy2UO-.js} +1 -1
- package/assets/{credential-steps-CuyQQqOh.js → credential-steps-DM1fuM06.js} +1 -1
- package/assets/{download-cdI2QZPl.js → download-1tA41rYM.js} +1 -1
- package/assets/{file-json-CxdRqoDn.js → file-json-CCwrBIYv.js} +1 -1
- package/assets/{filters-CVrzif88.js → filters-BEDbiXL6.js} +1 -1
- package/assets/flagged-CtYcd1p3.js +1 -0
- package/assets/{flagged-CaNZehgH.js → flagged-KaUU5BlX.js} +1 -1
- package/assets/folders-CltOBBCV.js +1 -0
- package/assets/{help-copy-CbN-pFZa.js → help-copy-DmIwayFx.js} +1 -1
- package/assets/{import-CmBHI3PY.js → import-DXciaSb6.js} +1 -1
- package/assets/{index-BsL3dqbS.js → index-2ffnljAr.js} +7 -7
- package/assets/{index-BSMLcnNv.js → index-B2JlIrVH.js} +80 -80
- package/assets/index-BHbbifX5.js +1 -0
- package/assets/index-C1bmRGl4.js +1 -0
- package/assets/index-CEbjxa0F.js +1 -0
- package/assets/index-CFa_ITEH.js +1 -0
- package/assets/index-CjcRJFc4.js +1 -0
- package/assets/index-CsrcFMPz.js +1 -0
- package/assets/{index-qHz-C81K.js → index-D1lrZZom.js} +1 -1
- package/assets/index-DhG8aWpV.js +1 -0
- package/assets/index-TiiA2WZz.js +1 -0
- package/assets/index-iHWlHwnx.js +1 -0
- package/assets/{kbd-MeQzj_AS.js → kbd-TVUw5dQH.js} +1 -1
- package/assets/{labels-DIjqFgrM.js → labels-CTevNzRb.js} +1 -1
- package/assets/{mail-zfMejK7g.js → mail-BQ0Xqoj_.js} +1 -1
- package/assets/mail-DRM5ncN9.js +1 -0
- package/assets/{map-pin-DHhEILKJ.js → map-pin-Dc-USzX4.js} +1 -1
- package/assets/{menu-D4SB6ohG.js → menu-CTvIK5Qx.js} +1 -1
- package/assets/{new-CEVTgWfF.js → new-DV2drXW-.js} +1 -1
- package/assets/onboarding-BPSBX3tT.js +1 -0
- package/assets/{onboarding-completion-Dr1hm10w.js → onboarding-completion-BhqyiyYl.js} +1 -1
- package/assets/outbox-DxSSQPiK.js +1 -0
- package/assets/{pencil-BSemJDIl.js → pencil-C__8PZQ-.js} +1 -1
- package/assets/{refresh-cw-Bdx0EEOe.js → refresh-cw-CijD9tc5.js} +1 -1
- package/assets/{rich-text-C_I7yglD.js → rich-text-DJQbTsPr.js} +15 -15
- package/assets/{rich-text-spellcheck-worker-provider-fakJuGkh.js → rich-text-spellcheck-worker-provider-sncBwGVt.js} +1 -1
- package/assets/{rotate-ccw-rjesddf9.js → rotate-ccw-BhqDWKvR.js} +1 -1
- package/assets/{roving-focus-JRZm8Nsl.js → roving-focus-BWokg8ha.js} +1 -1
- package/assets/{row-actions-BAj0uoQs.js → row-actions-CdfQhGZT.js} +1 -1
- package/assets/{search-mirror-CD8ms6aC.js → search-mirror-B1Zf9cCU.js} +1 -1
- package/assets/search-token-index-27XVZbA6.js +1 -0
- package/assets/{sections-B3k1IUqe.js → sections-Clno-i5j.js} +1 -1
- package/assets/senders-ClVGlZzf.js +1 -0
- package/assets/settings-CYdqGIm_.js +1 -0
- package/assets/{settings-screen-CX00GQZz.js → settings-screen-X-U5v_Fa.js} +1 -1
- package/assets/{shield-check-B34-2hLP.js → shield-check-BGc8_VeV.js} +1 -1
- package/assets/suggested-vips-B5a-Xv9j.js +1 -0
- package/assets/{useCalendarData-BtwJetQk.js → useCalendarData-CrF9X78_.js} +1 -1
- package/assets/{useCalendars-D7gapaJ1.js → useCalendars-Dzvxbs9C.js} +1 -1
- package/assets/{useDebouncedValue--1NwWG_J.js → useDebouncedValue-B2LCK_pq.js} +1 -1
- package/assets/{useFilters-BYL5dTX8.js → useFilters-A9SedagU.js} +1 -1
- package/assets/{useLabels-BTBI_l7Q.js → useLabels-5zE8gASV.js} +1 -1
- package/assets/{useLayoutTier-C5sdkyR7.js → useLayoutTier-DcOqI0AI.js} +1 -1
- package/assets/{useMessageBodyContent-BuyQJK-3.js → useMessageBodyContent-D2Bi044R.js} +1 -1
- package/assets/{useQueries-hzIIiVUF.js → useQueries-Cf2uvzGz.js} +1 -1
- package/assets/useRefreshControl-C7RXJa78.js +1 -0
- package/assets/{useResultFolderIndex-DfM23jXb.js → useResultFolderIndex-DjdYfjMq.js} +1 -1
- package/assets/{useSearchTokenContext-BOZY3WZQ.js → useSearchTokenContext-C0dIvEKK.js} +3 -3
- package/assets/useSemanticSearch-DyTFmiDr.js +1 -0
- package/assets/{useSignature-B3bSZUlR.js → useSignature-KOdqyay3.js} +1 -1
- package/assets/{window-ZjseaC3I.js → window-C_72cp1d.js} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/assets/BriefPane-DojIZDdy.js +0 -1
- package/assets/CalendarComposePane-B3fOrTrG.js +0 -1
- package/assets/ErrorState-jZhKH-Aj.js +0 -1
- package/assets/FlaggedPane-Gh0sDSpK.js +0 -1
- package/assets/MailListHeader-CP5Mrq7I.js +0 -7
- package/assets/MailNav-_b1NBnYa.js +0 -1
- package/assets/MailViewChrome-WyEJa7LW.js +0 -1
- package/assets/MailboxPane-B0QAN8MQ.js +0 -1
- package/assets/OpenCalendarEvent-CWAwJawV.js +0 -2
- package/assets/OutboxPane-CQ3uaHpb.js +0 -1
- package/assets/_calendarObjectId-CCinxQsA.js +0 -1
- package/assets/_mailboxId-BLTbspU-.js +0 -1
- package/assets/_messageId-BdFNsbyK.js +0 -1
- package/assets/_messageId-DGh1GohX.js +0 -1
- package/assets/_messageId-Rx6VPRb8.js +0 -1
- package/assets/_outboxMessageId-Ds-AxAdc.js +0 -1
- package/assets/_recurrenceId-CnuWP_v3.js +0 -1
- package/assets/_threadId-14e9BvEq.js +0 -1
- package/assets/_threadId-CaHK3QT7.js +0 -1
- package/assets/_threadId-zRV3tTyF.js +0 -1
- package/assets/_view._date-CzvdNpZJ.js +0 -1
- package/assets/accounts-BZE9IR6B.js +0 -1
- package/assets/brief-BzLBKBJb.js +0 -1
- package/assets/calendars-CJ1pdgeL.js +0 -1
- package/assets/chevron-left-BW6j5W1b.js +0 -1
- package/assets/compose._-_outboxMessageId_-BT5t9O9p.js +0 -1
- package/assets/compose._-_outboxMessageId_-DVisJU-4.js +0 -1
- package/assets/compose._-_outboxMessageId_-PDyjMj_y.js +0 -1
- package/assets/compose._-_outboxMessageId_-kk1Oxbpv.js +0 -1
- package/assets/flagged-DgBi4zNy.js +0 -1
- package/assets/folders-D6pNCcVN.js +0 -1
- package/assets/format-bkonYesy.js +0 -1
- package/assets/index-B5pFel5d.js +0 -1
- package/assets/index-BeGGBd6V.js +0 -1
- package/assets/index-CRC7JV7N.js +0 -1
- package/assets/index-CdtVuvhW.js +0 -1
- package/assets/index-CwgKXaQc.js +0 -1
- package/assets/index-CyAwBGa1.js +0 -1
- package/assets/index-DGh1GohX.js +0 -1
- package/assets/index-DIINe8ie.js +0 -1
- package/assets/index-aVEEHAqm.js +0 -1
- package/assets/mail-DNGMGkWt.js +0 -1
- package/assets/onboarding-CHzcHHo-.js +0 -1
- package/assets/outbox-BQPbQr6w.js +0 -1
- package/assets/search-token-index-srRTXc29.js +0 -1
- package/assets/senders-BorZpOXg.js +0 -1
- package/assets/settings-BV8meyD4.js +0 -1
- package/assets/suggested-vips-C60kF2rS.js +0 -1
- package/assets/useRefreshControl-D15eEjeE.js +0 -1
- package/assets/useSemanticSearch-DT9Nt957.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as a,an as De,f as te,W as Ps,X as Ce,ao as ks,ap as Vs,aq as ut,E as Ds,r as C,F as Cs,t as Ge,ar as ee,h as ft,as as Fs,c as Jt,d as Xt,at as Os,i as Se,au as Is,o as Te,l as es,av as Rs,aw as Ms,ax as Ls,ay as ve,az as At,L as it,aA as Tt,aB as Us,aC as Re,aD as be,aE as Et,aa as Hs,aF as zs,aG as Bs,aH as ts,aI as _t,u as qs,n as Ws,aJ as $s,aK as Gs,B as Pt,g as Ks,aL as kt,aM as Ys,a2 as Qs}from"./index-BSMLcnNv.js";import{R as Zs}from"./row-actions-BAj0uoQs.js";import{S as Js,A as Xs}from"./settings-screen-CX00GQZz.js";import{g as Vt,P as er,O as tr}from"./OnboardingWizard-Cq8ycceQ.js";import{s as Be,u as sr,b as rr,R as ar}from"./credential-steps-CuyQQqOh.js";import{u as ir}from"./useSignature-B3bSZUlR.js";import{c as nr,a as Dt,d as or}from"./account-form-helpers-DhckT_PN.js";import{D as lr}from"./download-cdI2QZPl.js";import{E as cr}from"./ErrorState-jZhKH-Aj.js";import{f as dr}from"./format-bkonYesy.js";import{a as ur}from"./help-copy-CbN-pFZa.js";import"./avatar-BuUa_-Ae.js";import"./chevron-left-BW6j5W1b.js";import"./menu-D4SB6ohG.js";import"./circle-help-Ck_g9Pip.js";import"./kbd-MeQzj_AS.js";import"./mail-zfMejK7g.js";import"./file-json-CxdRqoDn.js";import"./card-Drp0FnU2.js";const fr=e=>{const s=new Set(e.map(ks));return Vs.map(t=>t.tag).filter(t=>!s.has(t)).sort((t,i)=>De(t).localeCompare(De(i)))},mr=({value:e,onChange:s,busy:t=!1})=>{const i=fr(e);return a.jsxs("div",{className:"space-y-2","data-testid":"compose-language-setting",children:[a.jsx("ul",{className:"space-y-1",children:e.map((o,d)=>a.jsxs("li",{"data-testid":`compose-language-row-${o}`,className:"flex items-center gap-2 rounded-md border border-line bg-surface-sunken px-3 py-1.5",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-fg",lang:o,children:De(o)}),d===0?a.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-fg-subtle",children:"Default"}):a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ps,{className:"size-3.5"}),disabled:t,"aria-label":`Write new messages in ${De(o)} by default`,onClick:()=>s([o,...e.filter(n=>n!==o)]),children:"Default"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),disabled:t||e.length===1,"aria-label":`Remove ${De(o)}`,onClick:()=>s(e.filter(n=>n!==o))})]},o))}),a.jsxs("select",{"aria-label":"Add a language",value:"",disabled:t||i.length===0,onChange:o=>{o.target.value!==""&&s([...e,o.target.value])},className:"w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none transition-colors focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30",children:[a.jsx("option",{value:"",children:"Add a language…"}),i.map(o=>a.jsx("option",{value:o,children:De(o)},o))]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"A message is tagged with the language you write it in, picked from this list. Your browser, not this app, decides which dictionaries it spellchecks against — add the language there too to get its underlines."})]})};function pr({title:e,description:s,action:t}){return a.jsxs("div",{className:"rounded-sm border border-danger/50",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-danger/30 bg-danger-soft px-row-inset py-2",children:[a.jsx(ut,{className:"size-4 text-danger"}),a.jsx("h2",{className:"text-sm font-semibold text-danger",children:"Danger zone"})]}),a.jsxs("div",{className:"flex flex-col gap-3 px-row-inset py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-fg",children:e}),a.jsx("p",{className:"text-xs text-fg-muted",children:s})]}),a.jsx("div",{className:"shrink-0",children:t})]})]})}function Ct({isOpen:e,onClose:s,title:t,children:i,footer:o}){Ds({id:"slide-panel",open:e,answers:{back:s}});const d=C.useRef(null);return Cs(d,e),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:Ge("fixed inset-0 z-40 bg-black/30 transition-opacity",e?"opacity-100":"pointer-events-none opacity-0"),onClick:s,"aria-hidden":"true"}),a.jsxs("div",{ref:d,className:Ge("safe-area-frame fixed top-0 right-0 z-50 flex h-full w-full flex-col border-l border-line bg-canvas shadow-xl sm:w-[400px] sm:max-w-[90vw]","transform transition-transform duration-200 ease-out",e?"translate-x-0":"pointer-events-none translate-x-full"),role:"dialog","aria-modal":"true","aria-hidden":!e,inert:!e,"aria-labelledby":"slide-panel-title",tabIndex:-1,children:[a.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-line px-4",children:[a.jsx("h2",{id:"slide-panel-title",className:"font-semibold",children:t}),a.jsx("button",{type:"button",onClick:s,className:"rounded-md p-1.5 transition-colors hover:bg-surface-raised","aria-label":"Close",children:a.jsx(Ce,{className:"size-5"})})]}),a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{className:"flex-1 overflow-auto p-4",children:i}),o&&a.jsx("div",{className:"flex justify-end gap-3 border-t border-line bg-canvas p-4",children:o})]})]})]})}var Ue=e=>e.type==="checkbox",je=e=>e instanceof Date,K=e=>e==null;const mt=e=>typeof e=="object";var H=e=>!K(e)&&!Array.isArray(e)&&mt(e)&&!je(e),hr=e=>H(e)&&e.target?Ue(e.target)?e.target.checked:e.target.value:e,gr=(e,s)=>s.split(".").some((t,i,o)=>!isNaN(Number(t))&&e.has(o.slice(0,i).join("."))),ss=e=>{const s=e.constructor&&e.constructor.prototype;return H(s)&&s.hasOwnProperty("isPrototypeOf")},Qe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function z(e){if(e instanceof Date)return new Date(e);const s=typeof FileList<"u"&&e instanceof FileList;if(Qe&&(e instanceof Blob||s))return e;const t=Array.isArray(e);if(!t&&!(H(e)&&ss(e)))return e;const i=t?[]:Object.create(Object.getPrototypeOf(e));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=z(e[o]));return i}const ke={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ue={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},de={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},rs="root",pt=["__proto__","constructor","prototype"],xr=/^\w*$/;var He=e=>xr.test(e),M=e=>e===void 0;const yr=/[.[\]'"]/;var Ze=e=>e.split(yr).filter(Boolean),y=(e,s,t)=>{if(!s||!H(e))return t;const i=He(s)?[s]:Ze(s);if(i.some(d=>pt.includes(d)))return t;const o=i.reduce((d,n)=>K(d)?void 0:d[n],e);return M(o)||o===e?M(e[s])?t:e[s]:o},pe=e=>typeof e=="boolean",ie=e=>typeof e=="function",F=(e,s,t)=>{let i=-1;const o=He(s)?[s]:Ze(s),d=o.length,n=d-1;for(;++i<d;){const u=o[i];let j=t;if(i!==n){const E=e[u];j=H(E)||Array.isArray(E)?E:isNaN(+o[i+1])?{}:[]}if(pt.includes(u))return;e[u]=j,e=e[u]}};const vr=ee.createContext(null);vr.displayName="HookFormControlContext";var br=(e,s,t,i=!0)=>{const o={};for(const d in e)Object.defineProperty(o,d,{get:()=>{const n=d;return s._proxyFormState[n]!==ue.all&&(s._proxyFormState[n]=!i||ue.all),e[n]}});return o};const jr=Qe?ee.useLayoutEffect:ee.useEffect;var Y=e=>typeof e=="string",Sr=(e,s,t,i,o)=>Y(e)?(i&&s.watch.add(e),y(t,e,o)):Array.isArray(e)?e.map(d=>(i&&s.watch.add(d),y(t,d))):(i&&(s.watchAll=!0),t),nt=e=>K(e)||!mt(e);const Ft=(e,s)=>s.length===0&&!Array.isArray(e)&&!ss(e);function he(e,s,t=new WeakMap){if(e===s)return!0;if(nt(e)||nt(s))return Object.is(e,s);if(je(e)&&je(s))return Object.is(e.getTime(),s.getTime());const i=Object.keys(e),o=Object.keys(s);if(i.length!==o.length)return!1;if(Ft(e,i)||Ft(s,o))return Object.is(e,s);if(!i.length&&Array.isArray(e)!==Array.isArray(s))return!1;const d=t.get(e);if(d&&d.has(s))return!0;if(d)d.add(s);else{const n=new WeakSet;n.add(s),t.set(e,n)}for(const n of i){const u=e[n];if(!(n in s))return!1;if(n!=="ref"){const j=s[n];if(je(u)&&je(j)||(H(u)||Array.isArray(u))&&(H(j)||Array.isArray(j))?!he(u,j,t):!Object.is(u,j))return!1}}return!0}var qe=e=>({isOnSubmit:!e||e===ue.onSubmit,isOnBlur:e===ue.onBlur,isOnChange:e===ue.onChange,isOnAll:e===ue.all,isOnTouch:e===ue.onTouched}),st=(e,s,t)=>{if(t)return!1;if(s.watchAll||s.watch.has(e))return!0;for(const i of s.watch)if(e.startsWith(i)&&e.charAt(i.length)===".")return!0;return!1};const Le=(e,s,t,i)=>{for(const o of t||Object.keys(e)){const d=y(e,o);if(d){const{_f:n,...u}=d;if(n){if(n.refs&&n.refs[0]&&s(n.refs[0],o)&&!i)return!0;if(n.ref&&s(n.ref,n.name)&&!i)return!0;if(Le(u,s))break}else if(H(u)&&Le(u,s))break}}};var Ot=(e,s,t)=>{const i=y(e,t),o=Array.isArray(i)?i:[];return F(o,rs,s[t]),F(e,t,o),e},G=e=>H(e)&&!Object.keys(e).length,ht=e=>e.type==="file",Ke=e=>{if(!Qe)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},gt=e=>e.type==="radio",Ye=e=>e instanceof RegExp,xt=(e,s,t,i,o)=>s?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:o||!0}}:{};const It={value:!1,isValid:!1},Rt={value:!0,isValid:!0};var as=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!M(e[0].attributes.value)?M(e[0].value)||e[0].value===""?Rt:{value:e[0].value,isValid:!0}:Rt:It}return It};const Mt={isValid:!1,value:null};var is=e=>Array.isArray(e)?e.reduce((s,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:s,Mt):Mt;function Lt(e,s,t="validate"){if(Y(e)||Array.isArray(e)&&e.every(Y)||pe(e)&&!e)return{type:t,message:Y(e)?e:"",ref:s}}var Ve=e=>H(e)&&!Ye(e)?e:{value:e,message:""},Ut=async(e,s,t,i,o,d)=>{const{ref:n,refs:u,required:j,maxLength:E,minLength:P,min:U,max:R,pattern:O,validate:_,name:f,valueAsNumber:b,mount:re}=e._f,N=y(t,f);if(!re||s.has(f))return{};const W=u?u[0]:n,I=T=>{if(o&&W.reportValidity){const k=pe(T)?"":T||"";u?u.forEach(D=>D.setCustomValidity(k)):W.setCustomValidity(k),W.reportValidity()}},A={},ne=gt(n),ae=Ue(n),ge=ne||ae,oe=(b||ht(n))&&M(n.value)&&M(N)||Ke(n)&&n.value===""||N===""||Array.isArray(N)&&!N.length,Q=xt.bind(null,f,i,A),le=(T,k,D,q=de.maxLength,Z=de.minLength)=>{const S=T?k:D;A[f]={type:T?q:Z,message:S,ref:n,...Q(T?q:Z,S)}};if(d?!Array.isArray(N)||!N.length:j&&(!ge&&(oe||K(N))||pe(N)&&!N||ae&&!as(u).isValid||ne&&!is(u).isValid)){const{value:T,message:k}=Y(j)?{value:!!j,message:j}:Ve(j);if(T&&(A[f]={type:de.required,message:k,ref:W,...Q(de.required,k)},!i))return I(k),A}if(!oe&&(!K(U)||!K(R))){let T,k;const D=Ve(R),q=Ve(U);if(!K(N)&&!isNaN(N)){const Z=n.valueAsNumber||N&&+N;K(D.value)||(T=Z>D.value),K(q.value)||(k=Z<q.value)}else{const Z=n.valueAsDate||new Date(N),S=fe=>new Date(new Date().toDateString()+" "+fe),J=n.type=="time",$=n.type=="week";Y(D.value)&&N&&(T=J?S(N)>S(D.value):$?N>D.value:Z>new Date(D.value)),Y(q.value)&&N&&(k=J?S(N)<S(q.value):$?N<q.value:Z<new Date(q.value))}if((T||k)&&(le(!!T,D.message,q.message,de.max,de.min),!i))return I(A[f].message),A}if((E||P)&&!oe&&(Y(N)||d&&Array.isArray(N))){const T=Ve(E),k=Ve(P),D=!K(T.value)&&N.length>+T.value,q=!K(k.value)&&N.length<+k.value;if((D||q)&&(le(D,T.message,k.message),!i))return I(A[f].message),A}if(O&&!oe&&Y(N)){const{value:T,message:k}=Ve(O);if(Ye(T)&&!N.match(T)&&(A[f]={type:de.pattern,message:k,ref:n,...Q(de.pattern,k)},!i))return I(k),A}if(_){if(ie(_)){const T=await _(N,t),k=Lt(T,W);if(k&&(A[f]={...k,...Q(de.validate,k.message)},!i))return I(k.message),A}else if(H(_)){let T={};for(const k in _){if(!G(T)&&!i)break;const D=Lt(await _[k](N,t),W,k);D&&(T={...D,...Q(k,D.message)},I(D.message),i&&(A[f]=T))}if(!G(T)&&(A[f]={ref:W,...T},!i))return A}}return I(!0),A},$e=e=>Array.isArray(e)?e:[e],ns=e=>Array.isArray(e)?e.filter(Boolean):[];function wr(e,s){const t=s.slice(0,-1).length;let i=0;for(;i<t;){if(K(e)){e=void 0;break}e=e[s[i]],i++}return e}function Nr(e){for(const s in e)if(e.hasOwnProperty(s)&&!M(e[s]))return!1;return!0}function B(e,s){if(Y(s)&&Object.prototype.hasOwnProperty.call(e,s))return delete e[s],e;const t=Array.isArray(s)?s:He(s)?[s]:Ze(s);if(t.some(n=>pt.includes(String(n))))return e;const i=t.length===1?e:wr(e,t),o=t.length-1,d=t[o];return i&&delete i[d],o!==0&&(H(i)&&G(i)||Array.isArray(i)&&Nr(i))&&B(e,t.slice(0,-1)),e}const os=e=>{const s={};for(const t of Object.keys(e))if(mt(e[t])&&e[t]!==null&&!je(e[t])){const i=os(e[t]);for(const o of Object.keys(i))s[`${t}.${o}`]=i[o]}else s[t]=e[t];return s},Ar=ee.createContext(null);Ar.displayName="HookFormContext";var Ht=()=>{let e=[];return{get observers(){return e},next:o=>{for(const d of e)d.next&&d.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(d=>d!==o)}}),unsubscribe:()=>{e=[]}}};function ls(e,s){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=e[i],d=s[i];if(o&&H(o)&&d){const n=ls(o,d);H(n)&&(t[i]=n)}else e[i]&&(t[i]=d)}return t}var cs=e=>e.type==="select-multiple",Tr=e=>gt(e)||Ue(e),rt=e=>Ke(e)&&e.isConnected,Er=e=>{for(const s in e)if(ie(e[s]))return!0;return!1};function ds(e){return Array.isArray(e)||H(e)&&!Er(e)}function us(e){return!!(e&&"_f"in e)}function fs(e){return Array.isArray(e)?!e.some(s=>!M(s)):!Object.keys(e).length}function ot(e,s){Array.isArray(e)?e[s]=void 0:delete e[s]}function lt(e,s={},t){for(const i in e){const o=e[i],d=t&&t[i];ds(o)&&(!Array.isArray(o)||!us(d))?(s[i]=Array.isArray(o)?[]:{},lt(o,s[i],d),fs(s[i])&&ot(s,i)):M(o)||(s[i]=!0)}return s}function Ae(e,s,t,i){t||(t=lt(s,{},i));for(const o in e){const d=e[o],n=i&&i[o];ds(d)&&(!Array.isArray(d)||!us(n))?(M(s)||nt(t[o])?t[o]=lt(d,Array.isArray(d)?[]:{},n):Ae(d,K(s)?{}:s[o],t[o],n),fs(t[o])&&ot(t,o)):he(d,s[o])?ot(t,o):t[o]=!0}return t}var ms=(e,{valueAsNumber:s,valueAsDate:t,setValueAs:i})=>M(e)?e:s?e===""?NaN:e&&+e:t&&Y(e)?new Date(e):i?i(e):e;function zt(e){const s=e.ref;return ht(s)?s.files:gt(s)?is(e.refs).value:cs(s)?[...s.selectedOptions].map(({value:t})=>t):Ue(s)?as(e.refs).value:ms(M(s.value)?e.ref.value:s.value,e)}var _r=(e,s,t,i)=>{const o={};for(const d of e){const n=y(s,d);n&&F(o,d,n._f)}return{criteriaMode:t,names:[...e],fields:o,shouldUseNativeValidation:i}},Me=e=>M(e)?e:Ye(e)?e.source:H(e)?Ye(e.value)?e.value.source:e.value:e;const Bt="AsyncFunction";var Pr=e=>{if(!e||!e.validate)return!1;if(ie(e.validate))return e.validate.constructor.name===Bt;if(H(e.validate)){for(const s in e.validate)if(e.validate[s].constructor.name===Bt)return!0}return!1},kr=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function qt(e,s,t){const i=y(e,t);if(i||He(t))return{error:i,name:t};const o=t.split(".");for(;o.length;){const d=o.join("."),n=y(s,d),u=y(e,d);if(n&&!Array.isArray(n)&&t!==d)return{name:t};if(u&&u.type)return{name:d,error:u};if(u&&u.root&&u.root.type)return{name:`${d}.root`,error:u.root};o.pop()}return{name:t}}var Vr=(e,s,t,i)=>{t(e);const{name:o,...d}=e,n=Object.keys(d);return!n.length||i&&n.length>=Object.keys(s).length||n.find(u=>s[u]===(!i||ue.all))},Dr=(e,s,t)=>!e||!s||e===s||$e(e).some(i=>i&&(t?i===s||i.startsWith(s+"."):i.startsWith(s)||s.startsWith(i))),Cr=(e,s,t,i,o)=>o.isOnAll?!1:!t&&o.isOnTouch?!(s||e):(t?i.isOnBlur:o.isOnBlur)?!e:(t?i.isOnChange:o.isOnChange)?e:!0,Fr=(e,s)=>!ns(y(e,s)).length&&B(e,s);const Or={mode:ue.onSubmit,reValidateMode:ue.onChange,shouldFocusError:!0},at="form",ps={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function Ir(e={}){let s={...Or,...e},t={...z(ps),isLoading:ie(s.defaultValues),errors:s.errors||{},disabled:s.disabled||!1},i={},o=H(s.defaultValues)||H(s.values)?z(s.defaultValues||s.values)||{}:{},d=s.shouldUnregister?{}:z(o),n={action:!1,mount:!1,watch:!1,keepIsValid:!1},u={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const j={},E={};let P=0,U=qe(s.mode),R=qe(s.reValidateMode);const O={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},_={...O};let f={..._};const b={array:Ht(),state:Ht()};let re=0;const N=s.criteriaMode===ue.all,W=(r,l)=>c=>{clearTimeout(E[r]),E[r]=setTimeout(l,c)},I=async r=>{if(!n.keepIsValid&&!s.disabled&&(_.isValid||f.isValid||r)){const l=++re;let c;s.resolver?(c=G((await D()).errors),l===re&&A()):c=await S({fields:i,onlyCheckValid:!0,eventType:ke.VALID}),l===re&&c!==t.isValid&&b.state.next({isValid:c})}},A=(r,l)=>{!s.disabled&&(_.isValidating||_.validatingFields||f.isValidating||f.validatingFields)&&((r||Array.from(u.mount)).forEach(c=>{c&&(l?F(t.validatingFields,c,l):B(t.validatingFields,c))}),b.state.next({validatingFields:t.validatingFields,isValidating:!G(t.validatingFields)}))},ne=()=>{t.dirtyFields=Ae(o,d,void 0,i)},ae=(r,l=[],c,m,p=!0,x=!0)=>{if(m&&c&&!s.disabled){if(n.action=!0,x&&Array.isArray(y(i,r))){const g=c(y(i,r),m.argA,m.argB);p&&F(i,r,g)}if(x&&Array.isArray(y(t.errors,r))){const g=c(y(t.errors,r),m.argA,m.argB);p&&F(t.errors,r,g),Fr(t.errors,r)}if((_.touchedFields||f.touchedFields)&&x&&Array.isArray(y(t.touchedFields,r))){const g=c(y(t.touchedFields,r),m.argA,m.argB);p&&F(t.touchedFields,r,g)}(_.dirtyFields||f.dirtyFields)&&ne(),b.state.next({name:r,isDirty:$(r,l),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else F(d,r,l)},ge=(r,l)=>{F(t.errors,r,l),t.errors={...t.errors},b.state.next({errors:t.errors})},oe=r=>{t.errors=r,b.state.next({errors:t.errors,isValid:!1})},Q=r=>{const l=He(r)?[r]:Ze(r);let c=d,m=o;for(let p=0;p<l.length-1;p++){const x=l[p];if(c=K(c)?c:c[x],m=K(m)?m:m[x],c===null&&m!==null)return!0}return!1},le=(r,l,c,m)=>{const p=y(i,r);if(p){if(Q(r))return;const x=M(y(d,r)),g=y(d,r,M(c)?y(o,r):c);M(g)||m&&m.defaultChecked||l?F(d,r,l?g:zt(p._f)):we(r,g),n.mount&&!n.action&&(I(),x&&t.isDirty&&(_.isDirty||f.isDirty)&&($()||(t.isDirty=!1,b.state.next({...t}))),e.shouldUnregister&&x&&!M(y(d,r))&&st(r,u)&&(n.watch=!0))}},T=(r,l,c,m,p)=>{let x=!1,g=!1;const v={name:r};if(!s.disabled||m===!0){if(!c||m){const w=he(y(o,r),l);(_.isDirty||f.isDirty)&&(g=t.isDirty,t.isDirty=v.isDirty=!w||$(),x=g!==v.isDirty),g=!!y(t.dirtyFields,r),w!==t.isDirty?t.dirtyFields=Ae(o,d,void 0,i):w?B(t.dirtyFields,r):F(t.dirtyFields,r,!0),v.dirtyFields=t.dirtyFields,x=x||(_.dirtyFields||f.dirtyFields)&&g!==!w}if(c){const w=y(t.touchedFields,r);w||(F(t.touchedFields,r,c),v.touchedFields=t.touchedFields,x=x||(_.touchedFields||f.touchedFields)&&w!==c)}x&&p&&b.state.next(v)}return x?v:{}},k=(r,l,c,m)=>{const p=y(t.errors,r),x=(_.isValid||f.isValid)&&pe(l)&&t.isValid!==l;if(s.delayError&&c?(j[r]=W(r,()=>ge(r,c)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r],c?F(t.errors,r,c):B(t.errors,r),t.errors={...t.errors}),(c?!he(p,c):p)||!G(m)||x){const g={...m,...x&&pe(l)?{isValid:l}:{},errors:t.errors,name:r};t={...t,...g},b.state.next(g)}},D=async r=>(A(r,!0),await s.resolver(d,s.context,_r(r||u.mount,i,s.criteriaMode,s.shouldUseNativeValidation))),q=async r=>{const{errors:l}=await D(r);if(A(r),r){for(const c of r){const m=y(l,c);m?u.array.has(c)&&H(m)&&!Object.keys(m).some(p=>!Number.isNaN(Number(p)))?Ot(t.errors,{[c]:m},c):F(t.errors,c,m):B(t.errors,c)}t.errors={...t.errors}}else t.errors=l;return l},Z=async({name:r,eventType:l})=>{if(e.validate){const c=await e.validate({formValues:d,formState:t,name:r,eventType:l});if(H(c))for(const m in c){const p=c[m];p&&ze(`${at}.${m}`,{message:Y(p.message)?p.message:"",type:p.type||de.validate})}else Y(c)||!c?ze(at,{message:c||"",type:de.validate}):Pe(at);return c}return!0},S=async({fields:r,onlyCheckValid:l,name:c,eventType:m,context:p={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(p.runRootValidation=!0,!await Z({name:c,eventType:m})&&(p.valid=!1,l)))return p.valid;for(const x in r){const g=r[x];if(g){const{_f:v,...w}=g;if(v){const L=u.array.has(v.name),X=g._f&&Pr(g._f),xe=_.validatingFields||_.isValidating||f.validatingFields||f.isValidating;X&&xe&&A([v.name],!0);const ye=await Ut(g,u.disabled,d,N,s.shouldUseNativeValidation&&!l,L);if(X&&xe&&A([v.name]),ye[v.name]&&(p.valid=!1,l)||(!l&&(y(ye,v.name)?L?Ot(t.errors,ye,v.name):F(t.errors,v.name,ye[v.name]):B(t.errors,v.name)),e.shouldUseNativeValidation&&ye[v.name]))break}!G(w)&&await S({context:p,onlyCheckValid:l,fields:w,name:x,eventType:m})}}return p.valid},J=()=>{for(const r of u.unMount){const l=y(i,r);l&&(l._f.refs?l._f.refs.every(c=>!rt(c)):!rt(l._f.ref))&&Xe(r)}u.unMount=new Set},$=(r,l)=>(r&&l&&F(d,r,l),!he(n.mount?d:o,o)),fe=(r,l,c)=>Sr(r,u,{...n.mount?d:M(l)?o:Y(r)?{[r]:l}:l},c,l),Ee=r=>ns(y(n.mount?d:o,r,s.shouldUnregister?y(o,r,[]):[])),we=(r,l,c={},m=!1,p=!1)=>{const x=y(i,r);let g=l;if(x){const v=x._f;v&&(!v.disabled&&F(d,r,ms(l,v)),g=Ke(v.ref)&&K(l)?"":l,cs(v.ref)?[...v.ref.options].forEach(w=>w.selected=g.includes(w.value)):v.refs?Ue(v.ref)?v.refs.forEach(w=>{(!w.defaultChecked||!w.disabled)&&(Array.isArray(g)?w.checked=!!g.find(L=>L===w.value):w.checked=g===w.value||!!g)}):v.refs.forEach(w=>w.checked=w.value===g):ht(v.ref)?v.ref.value="":(v.ref.value=g,!v.ref.type&&!p&&b.state.next({name:r,values:m?d:z(d)})))}(c.shouldDirty||c.shouldTouch)&&T(r,g,c.shouldTouch,c.shouldDirty,!p),c.shouldValidate&&me(r,{delayError:c.delayError})},_e=(r,l,c,m=!1,p=!1)=>{for(const x in l){if(!l.hasOwnProperty(x))return;const g=l[x],v=r+"."+x,w=y(i,v);(u.array.has(r)||H(g)||w&&!w._f)&&!je(g)?_e(v,g,c,m,p):we(v,g,c,m,p)}},Je=(r,l,c,m,p=!1)=>{const x=y(i,r),g=u.array.has(r),v=m?l:z(l),w=y(d,r),L=he(w,v);if(L||F(d,r,v),g)b.array.next({name:r,values:m?d:z(d)}),(_.isDirty||_.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&(ne(),p||b.state.next({name:r,dirtyFields:t.dirtyFields,isDirty:$(r,v)}));else{const X=Array.isArray(v)&&!v.length||G(v);!x||x._f||K(v)||X?we(r,v,c,m,p):_e(r,v,c,m,p)}if(!L&&!p){const X=st(r,u),xe=m?d:z(d);b.state.next({...X&&t,name:n.mount||X?r:void 0,values:xe})}},h=(r,l,c={})=>Je(r,l,c,!1),V=(r,l={})=>{const c=ie(r)?r(d):r;if(!he(d,c)){d={...d,...c};const m=os(c);for(const p of u.mount)p in m&&Je(p,m[p],l,!0,!0);b.state.next({...t,name:void 0,type:void 0,...P?{values:d}:{}}),l.shouldValidate&&I()}},ce=async r=>{n.mount=!0;const l=r.target;let c=l.name,m=!0;const p=y(i,c),x=g=>{m=Number.isNaN(g)||je(g)&&isNaN(g.getTime())||he(g,y(d,c,g))};if(p){let g,v;const w=l.type?zt(p._f):hr(r),L=r.type===ke.BLUR||r.type===ke.FOCUS_OUT,X=!kr(p._f)&&!e.validate&&!s.resolver&&!y(t.errors,c)&&!p._f.deps,xe=X||Cr(L,y(t.touchedFields,c),t.isSubmitted,R,U),ye=st(c,u,L);if(F(d,c,w),L){if(!l||!l.readOnly){p._f.onBlur&&p._f.onBlur(r);const Ie=j[c];Ie&&Ie(0)}}else p._f.onChange&&p._f.onChange(r);const Oe=T(c,w,L),Es=!G(Oe)||ye;if(!L&&b.state.next({name:c,type:r.type,...P?{values:z(d)}:{}}),xe)return(!X||!t.isValid)&&(_.isValid||f.isValid)&&(s.mode==="onBlur"?L&&I():L||I()),Es&&b.state.next({name:c,...ye?{}:Oe});if(!s.resolver&&e.validate&&await Z({name:c,eventType:r.type}),!L&&ye&&b.state.next({...t}),s.resolver){const{errors:Ie}=await D([c]);if(A([c]),x(w),!m){!G(Oe)&&b.state.next(Oe);return}const _s=qt(t.errors,i,c),Nt=qt(Ie,i,_s.name||c);g=Nt.error,c=Nt.name,v=G(Ie)}else A([c],!0),g=(await Ut(p,u.disabled,d,N,s.shouldUseNativeValidation))[c],A([c]),x(w),m&&(g?v=!1:(_.isValid||f.isValid)&&(v=await S({fields:i,onlyCheckValid:!0,name:c,eventType:r.type})));m&&(p._f.deps&&(!Array.isArray(p._f.deps)||p._f.deps.length>0)&&me(p._f.deps),k(c,v,g,Oe))}},se=(r,l)=>{if(y(t.errors,l)&&r.focus)return r.focus(),1},me=async(r,l={})=>{let c,m;const p=$e(r);if(s.resolver){const x=await q(M(r)?r:p);c=G(x),m=r?!p.some(g=>y(x,g)):c}else r?(m=(await Promise.all(p.map(async x=>{const g=y(i,x);return await S({fields:g&&g._f?{[x]:g}:g,eventType:ke.TRIGGER})}))).every(Boolean),!(!m&&!t.isValid)&&I()):m=c=await S({fields:i,name:r,eventType:ke.TRIGGER});if(l.delayError&&s.delayError&&Y(r)){const x=y(t.errors,r);x?(B(t.errors,r),j[r]=W(r,()=>ge(r,x)),j[r](s.delayError)):(clearTimeout(E[r]),delete j[r])}return b.state.next({...!Y(r)||(_.isValid||f.isValid)&&c!==t.isValid?{}:{name:r},...s.resolver||!r?{isValid:c}:{},errors:t.errors}),l.shouldFocus&&!m&&Le(i,se,r?p:u.mount),m},Ne=(r,l)=>{let c={...n.mount?d:o};return l&&(c=ls(l.dirtyFields?t.dirtyFields:t.touchedFields,c)),M(r)?c:Y(r)?y(c,r):r.map(m=>y(c,m))},Fe=(r,l)=>({invalid:!!y((l||t).errors,r),isDirty:!!y((l||t).dirtyFields,r),error:y((l||t).errors,r),isValidating:!!y(t.validatingFields,r),isTouched:!!y((l||t).touchedFields,r)}),Pe=r=>{const l=r?$e(r):void 0;l?.forEach(c=>B(t.errors,c)),l?l.forEach(c=>{b.state.next({name:c,errors:t.errors})}):b.state.next({errors:{}})},ze=(r,l,c)=>{const m=(y(i,r,{_f:{}})._f||{}).ref,p=y(t.errors,r)||{},{ref:x,message:g,type:v,...w}=p;F(t.errors,r,{...w,...l,ref:m}),b.state.next({name:r,errors:t.errors,isValid:!1}),c&&c.shouldFocus&&m&&m.focus&&m.focus()},js=(r,l)=>{if(ie(r)){P++;const{unsubscribe:c}=b.state.subscribe({next:p=>"values"in p&&r(p.values||fe(void 0,l),p)});let m=!1;return{unsubscribe:()=>{m||(m=!0,P--,c())}}}return fe(r,l,!0)},yt=r=>{var l;const c=!!(!((l=r.formState)===null||l===void 0)&&l.values);c&&P++;const{unsubscribe:m}=b.state.subscribe({next:x=>{if(Dr(r.name,x.name,r.exact)&&Vr(x,r.formState||_,Ts,r.reRenderRoot)){const g={...d};r.callback({values:g,...t,...x,defaultValues:o})}}});if(!c)return m;let p=!1;return()=>{p||(p=!0,P--,m())}},Ss=r=>(n.mount=!0,f={...f,...r.formState},yt({...r,formState:{...O,...r.formState}})),Xe=(r,l={})=>{for(const c of r?$e(r):u.mount)u.mount.delete(c),u.array.delete(c),l.keepValue||(B(i,c),B(d,c)),!l.keepError&&B(t.errors,c),!l.keepDirty&&B(t.dirtyFields,c),!l.keepTouched&&B(t.touchedFields,c),!l.keepIsValidating&&B(t.validatingFields,c),!s.shouldUnregister&&!l.keepDefaultValue&&B(o,c);b.state.next({values:z(d)}),b.state.next({...t,...l.keepDirty?{isDirty:$()}:{}}),!l.keepIsValid&&I()},vt=({disabled:r,name:l})=>{if(pe(r)&&n.mount||r||u.disabled.has(l)){const p=u.disabled.has(l)!==!!r;r?u.disabled.add(l):u.disabled.delete(l),p&&n.mount&&!n.action&&I()}},et=(r,l={})=>{let c=y(i,r);const m=pe(l.disabled)||pe(s.disabled),p=!u.registerName.has(r)&&c&&c._f&&!c._f.mount;return F(i,r,{...c||{},_f:{...c&&c._f?c._f:{ref:{name:r}},name:r,mount:!0,...l}}),u.mount.add(r),c&&!p?vt({disabled:pe(l.disabled)?l.disabled:s.disabled,name:r}):le(r,!0,l.value),{...m?{disabled:l.disabled||s.disabled}:{},...s.progressive?{required:!!l.required,min:Me(l.min),max:Me(l.max),minLength:Me(l.minLength),maxLength:Me(l.maxLength),pattern:Me(l.pattern)}:{},name:r,onChange:ce,onBlur:ce,ref:x=>{if(x){u.registerName.add(r),et(r,l),u.registerName.delete(r),c=y(i,r);const g=M(x.value)&&x.querySelectorAll&&x.querySelectorAll("input,select,textarea")[0]||x,v=Tr(g),w=c._f.refs||[];if(v?w.find(L=>L===g):g===c._f.ref)return;F(i,r,{_f:{...c._f,...v?{refs:[...w.filter(rt),g,...Array.isArray(y(o,r))?[{}]:[]],ref:{type:g.type,name:r}}:{ref:g}}}),le(r,!1,void 0,g)}else c=y(i,r,{}),c._f&&(c._f.mount=!1),(s.shouldUnregister||l.shouldUnregister)&&!(gr(u.array,r)&&n.action)&&u.unMount.add(r)}}},tt=()=>s.shouldFocusError&&!s.shouldUseNativeValidation&&Le(i,se,u.mount),ws=r=>{pe(r)&&(b.state.next({disabled:r}),Le(i,(l,c)=>{const m=y(i,c);m&&(l.disabled=m._f.disabled||r,Array.isArray(m._f.refs)&&m._f.refs.forEach(p=>{p.disabled=m._f.disabled||r}))},0,!1))},bt=(r,l)=>async c=>{let m;c&&(c.preventDefault&&c.preventDefault(),c.persist&&c.persist());let p=z(d);if(b.state.next({isSubmitting:!0}),s.resolver){const{errors:x,values:g}=await D();A(),t.errors=x,p=z(g)}else await S({fields:i,eventType:ke.SUBMIT});if(u.disabled.size)for(const x of u.disabled)B(p,x);if(B(t.errors,rs),G(t.errors)){b.state.next({errors:{}});try{await r(p,c)}catch(x){m=x}}else l&&await l({...t.errors},c),tt(),setTimeout(tt);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(t.errors)&&!m,submitCount:t.submitCount+1,errors:t.errors}),m)throw m},Ns=(r,l={})=>{y(i,r)&&(M(l.defaultValue)?h(r,z(y(o,r))):(h(r,l.defaultValue),F(o,r,z(l.defaultValue))),l.keepTouched||B(t.touchedFields,r),l.keepDirty||(B(t.dirtyFields,r),t.isDirty=l.defaultValue?$(r,z(y(o,r))):$()),l.keepError||(B(t.errors,r),_.isValid&&I()),b.state.next({...t}))},jt=(r,l={})=>{const c=r?z(r):o,m=z(c),p=G(r),x=m,g=i;if(l.keepDefaultValues||(o=c),!l.keepValues){if(l.keepDirtyValues){const v=new Set([...u.mount,...Object.keys(Ae(o,d,void 0,g))]);for(const w of Array.from(v)){const L=y(t.dirtyFields,w),X=y(d,w),xe=y(x,w);L&&!M(X)?F(x,w,X):!L&&!M(xe)&&h(w,xe)}}else{if(Qe&&M(r))for(const v of u.mount){const w=y(i,v);if(w&&w._f){const L=Array.isArray(w._f.refs)?w._f.refs[0]:w._f.ref;if(Ke(L)){const X=L.closest("form");if(X){X.reset();break}}}}if(l.keepFieldsRef)for(const v of u.mount)h(v,y(x,v));else i={}}if(s.shouldUnregister){if(d=l.keepDefaultValues?z(o):{},l.keepFieldsRef)for(const v of u.mount)F(d,v,y(x,v))}else d=z(x);b.array.next({values:{...x}}),b.state.next({name:void 0,type:void 0,values:{...x}})}u={mount:l.keepDirtyValues?u.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},n.mount=!_.isValid||!!l.keepIsValid||!!l.keepDirtyValues||!s.shouldUnregister&&!G(x),n.watch=!!s.shouldUnregister,n.keepIsValid=!!l.keepIsValid,n.action=!1,l.keepErrors||(t.errors={}),b.state.next({submitCount:l.keepSubmitCount?t.submitCount:0,isDirty:p?!1:l.keepDirty?t.isDirty:l.keepValues?$():!!(l.keepDefaultValues&&!he(r,o)),isSubmitted:l.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:p?{}:l.keepDirtyValues?l.keepDefaultValues&&d?Ae(o,d,void 0,g):t.dirtyFields:l.keepDefaultValues&&r?Ae(o,r,void 0,g):l.keepDirty?t.dirtyFields:{},touchedFields:l.keepTouched?t.touchedFields:{},errors:l.keepErrors?t.errors:{},isSubmitSuccessful:l.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},St=(r,l)=>jt(ie(r)?r(d):r,{...s.resetOptions,...l}),As=(r,l={})=>{const c=y(i,r),m=c&&c._f;if(m){const p=m.refs?m.refs[0]:m.ref;p.focus&&setTimeout(()=>{p.focus(),l.shouldSelect&&ie(p.select)&&p.select()})}},Ts=r=>{const{name:l,type:c,values:m,...p}=r;t={...t,...p}},wt={control:{register:et,unregister:Xe,getFieldState:Fe,handleSubmit:bt,setError:ze,_subscribe:yt,_runSchema:D,_updateIsValidating:A,_focusError:tt,_getWatch:fe,_getDirty:$,_setValid:I,_setFieldArray:ae,_setDisabledField:vt,_setErrors:oe,_getFieldArray:Ee,_reset:jt,_resetDefaultValues:()=>ie(s.defaultValues)&&s.defaultValues().then(r=>{St(r,s.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:ws,_subjects:b,_proxyFormState:_,get _fields(){return i},get _formValues(){return d},get _state(){return n},set _state(r){n=r},get _defaultValues(){return o},get _names(){return u},set _names(r){u=r},get _formState(){return t},get _options(){return s},set _options(r){s={...s,...r},U=qe(s.mode),R=qe(s.reValidateMode)}},subscribe:Ss,trigger:me,register:et,handleSubmit:bt,watch:js,setValue:h,setValues:V,getValues:Ne,reset:St,resetField:Ns,resetDefaultValues:(r,l={})=>{if(o=z(r),!l.keepDirty){const c=Ae(o,d,void 0,i);t.dirtyFields=c,t.isDirty=!G(c)}l.keepIsValid||I(),b.state.next({...t,defaultValues:o})},clearErrors:Pe,unregister:Xe,setError:ze,setFocus:As,getFieldState:Fe};return{...wt,formControl:wt}}function Rr(e={}){const s=ee.useRef(void 0),t=ee.useRef(void 0),i=ee.useRef(e.formControl),[o,d]=ee.useState(()=>({...z(ps),isLoading:ie(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ie(e.defaultValues)?void 0:e.defaultValues}));if(!s.current||e.formControl&&i.current!==e.formControl)if(i.current=e.formControl,e.formControl)s.current={...e.formControl,formState:o},e.defaultValues&&!ie(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:u,...j}=Ir(e);s.current={...j,formState:o}}const n=s.current.control;return n._options=e,jr(()=>{const u=n._subscribe({formState:n._proxyFormState,callback:()=>d({...n._formState,defaultValues:n._defaultValues}),reRenderRoot:!0});return d(j=>({...j,isReady:!0})),n._formState.isReady=!0,u},[n]),ee.useEffect(()=>n._disableForm(e.disabled),[n,e.disabled]),ee.useEffect(()=>{e.mode&&(n._options.mode=e.mode),e.reValidateMode&&(n._options.reValidateMode=e.reValidateMode)},[n,e.mode,e.reValidateMode]),ee.useEffect(()=>{e.errors&&(n._setErrors(e.errors),n._focusError())},[n,e.errors]),ee.useEffect(()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})},[n,e.shouldUnregister]),ee.useEffect(()=>{if(n._proxyFormState.isDirty){const u=n._getDirty();u!==o.isDirty&&n._subjects.state.next({isDirty:u})}},[n,o.isDirty]),ee.useEffect(()=>{var u;e.values&&!he(e.values,t.current)?(n._reset(e.values,{keepFieldsRef:!0,...n._options.resetOptions}),!((u=n._options.resetOptions)===null||u===void 0)&&u.keepIsValid||n._setValid(),t.current=e.values,d(j=>({...j}))):n._resetDefaultValues()},[n,e.values]),ee.useEffect(()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()}),s.current.formState=ee.useMemo(()=>br(o,n),[n,o]),s.current}const Wt=(e,s,t)=>{if(e&&"reportValidity"in e){const i=y(t,s);e.setCustomValidity(i&&i.message||""),e.reportValidity()}},ct=(e,s)=>{for(const t in s.fields){const i=s.fields[t];i&&i.ref&&"reportValidity"in i.ref?Wt(i.ref,t,e):i&&i.refs&&i.refs.forEach(o=>Wt(o,t,e))}},$t=(e,s)=>{s.shouldUseNativeValidation&&ct(e,s);const t={};for(const i in e){const o=y(s.fields,i),d=Object.assign(e[i]||{},{ref:o&&o.ref});if(Mr(s.names||Object.keys(e),i)){const n=Object.assign({},y(t,i));F(n,"root",d),F(t,i,n)}else F(t,i,d)}return t},Mr=(e,s)=>{const t=Gt(s).replace(/[.*+?^${}()|\\]/g,"\\$&");return e.some(i=>Gt(i).match(`^${t}\\.\\d+`))};function Gt(e){return e.replace(/[\[\]]/g,"")}function hs(e,s,t){function i(u,j){var E;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(E=u._zod).traits??(E.traits=new Set),u._zod.traits.add(e),s(u,j);for(const P in n.prototype)P in u||Object.defineProperty(u,P,{value:n.prototype[P].bind(u)});u._zod.constr=n,u._zod.def=j}const o=t?.Parent??Object;class d extends o{}Object.defineProperty(d,"name",{value:e});function n(u){var j;const E=t?.Parent?new d:this;i(E,u),(j=E._zod).deferred??(j.deferred=[]);for(const P of E._zod.deferred)P();return E}return Object.defineProperty(n,"init",{value:i}),Object.defineProperty(n,Symbol.hasInstance,{value:u=>t?.Parent&&u instanceof t.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}class Lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ur={};function gs(e){return Ur}function Hr(e,s){return typeof s=="bigint"?s.toString():s}const xs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function We(e){return typeof e=="string"?e:e?.message}function ys(e,s,t){const i={...e,path:e.path??[]};if(!e.message){const o=We(e.inst?._zod.def?.error?.(e))??We(s?.error?.(e))??We(t.customError?.(e))??We(t.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,s?.reportInput||delete i.input,i}const vs=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(s,Hr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zr=hs("$ZodError",vs),bs=hs("$ZodError",vs,{Parent:Error}),Br=e=>(s,t,i,o)=>{const d=i?Object.assign(i,{async:!1}):{async:!1},n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise)throw new Lr;if(n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},qr=Br(bs),Wr=e=>async(s,t,i,o)=>{const d=i?Object.assign(i,{async:!0}):{async:!0};let n=s._zod.run({value:t,issues:[]},d);if(n instanceof Promise&&(n=await n),n.issues.length){const u=new(o?.Err??e)(n.issues.map(j=>ys(j,d,gs())));throw xs(u,o?.callee),u}return n.value},$r=Wr(bs);function dt(){return dt=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},dt.apply(null,arguments)}function Kt(e,s){try{var t=e()}catch(i){return s(i)}return t&&t.then?t.then(void 0,s):t}function Gr(e,s){for(var t={};e.length;){var i=e[0],o=i.code,d=i.message,n=i.path.join(".");if(!t[n])if("unionErrors"in i){var u=i.unionErrors[0].errors[0];t[n]={message:u.message,type:u.code}}else t[n]={message:d,type:o};if("unionErrors"in i&&i.unionErrors.forEach(function(P){return P.errors.forEach(function(U){return e.push(U)})}),s){var j=t[n].types,E=j&&j[i.code];t[n]=xt(n,s,t,o,E?[].concat(E,i.message):i.message)}e.shift()}return t}function Kr(e,s){for(var t={},i=function(){var o=e[0],d=o.code,n=o.message,u=o.path.join(".");if(!t[u])if(o.code==="invalid_union"&&o.errors.length>0){var j=o.errors[0][0];t[u]={message:j.message,type:j.code}}else t[u]={message:n,type:d};if(o.code==="invalid_union"&&o.errors.forEach(function(U){return U.forEach(function(R){return e.push(dt({},R,{path:[].concat(o.path,R.path)}))})}),s){var E=t[u].types,P=E&&E[o.code];t[u]=xt(u,s,t,d,P?[].concat(P,o.message):o.message)}e.shift()};e.length;)i();return t}function Yr(e,s,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return Array.isArray(u?.issues)})(n))return{values:{},errors:$t(Gr(n.errors,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(e))return function(i,o,d){try{return Promise.resolve(Kt(function(){return Promise.resolve((t.mode==="sync"?qr:$r)(e,i,s)).then(function(n){return d.shouldUseNativeValidation&&ct({},d),{errors:{},values:t.raw?Object.assign({},i):n}})},function(n){if((function(u){return u instanceof zr})(n))return{values:{},errors:$t(Kr(n.issues,!d.shouldUseNativeValidation&&d.criteriaMode==="all"),d)};throw n}))}catch(n){return Promise.reject(n)}};throw new Error("Invalid input: not a Zod schema")}const Qr=e=>{const s=ft(),{pushError:t}=Fs(),{data:i}=Jt({...Xt(),staleTime:1/0}),o=i?.accounts.find(j=>j.accountId===e)?.composeLanguages,d=C.useMemo(()=>o&&o.length>0?[...o]:Os(navigator.languages),[o]),n=Se({...es(),onSuccess:()=>{s.invalidateQueries({queryKey:Te()})},onError:j=>{t(Is("Couldn't save languages","The writing languages weren't saved.",j))}}),u=C.useCallback(j=>{e&&n.mutate({path:{accountId:e},body:{composeLanguages:j}})},[e,n]);return{languages:d,setLanguages:u,isSaving:n.isPending}},Zr=e=>e.authType==="oauthMicrosoft",Jr="••••••••••",Xr=e=>{const s=e.smtpUsername?.trim();return s?s!==e.username:!1},ea=Us({email:be().email().min(1,"Email is required"),displayName:be().optional(),username:be().optional(),password:be().optional(),imapHost:be().min(1,"IMAP host is required"),imapPort:Et.number().int().min(1).max(65535),imapTls:Re(),imapStartTls:Re(),smtpHost:be().optional(),smtpPort:Et.number().int().min(1).max(65535).optional(),smtpTls:Re().optional(),smtpStartTls:Re().optional(),smtpUsername:be().optional(),smtpPassword:be().optional(),useDifferentSmtpCreds:Re().optional()}),ta=({isOpen:e,onClose:s,account:t,focusSmtp:i})=>{const o=ft(),d=!!t,[n,u]=C.useState(!1),[j,E]=C.useState(""),[P,U]=C.useState(!1),R=Vt(j),O=!!R&&!P,_=C.useRef(null),f=Rr({resolver:Yr(ea),defaultValues:{email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}});C.useEffect(()=>{if(t){const h=Xr(t);f.reset({email:t.email,displayName:t.displayName||"",username:t.username||"",password:Jr,imapHost:t.imapHost,imapPort:t.imapPort,imapTls:t.imapTls,imapStartTls:t.imapStartTls,smtpHost:t.smtpHost||"",smtpPort:t.smtpPort||587,smtpTls:t.smtpTls||!1,smtpStartTls:t.smtpStartTls||!0,smtpUsername:h&&t.smtpUsername||"",smtpPassword:"",useDifferentSmtpCreds:h}),u(!1)}else f.reset({email:"",displayName:"",username:"",password:"",imapHost:"",imapPort:993,imapTls:!0,imapStartTls:!1,smtpHost:"",smtpPort:587,smtpTls:!1,smtpStartTls:!0,useDifferentSmtpCreds:!1}),u(!1)},[t,f]);const b=Se({...Rs()}),re=Se({...Ms(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),N=Se({...es(),onSuccess:()=>{o.invalidateQueries({queryKey:Te()}),s()}}),W=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls}})},I=()=>{const h=f.getValues(),V=d&&!n;b.mutate({body:{accountId:V?t?.accountId:void 0,username:h.username||h.email,password:V?void 0:h.password||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:h.smtpHost||void 0,smtpPort:h.smtpPort?Number(h.smtpPort):void 0,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls,smtpUsername:h.useDifferentSmtpCreds?h.smtpUsername:void 0,smtpPassword:h.useDifferentSmtpCreds?h.smtpPassword:void 0}})},A=f.handleSubmit(h=>{if(!d&&!h.password){f.setError("password",{message:"Password is required"});return}const V=nr({imapHost:h.imapHost,smtpHost:h.smtpHost,smtpPort:h.smtpPort,smtpTls:h.smtpTls,smtpStartTls:h.smtpStartTls});V&&(f.setValue("smtpHost",V.smtpHost),f.setValue("smtpPort",V.smtpPort),f.setValue("smtpTls",V.smtpTls),f.setValue("smtpStartTls",V.smtpStartTls));const ce=V?.smtpHost??h.smtpHost,se=V?.smtpPort??h.smtpPort,me=V?.smtpTls??h.smtpTls,Ne=V?.smtpStartTls??h.smtpStartTls,Fe={email:h.email,displayName:h.displayName?.trim()||void 0,username:h.username||void 0,imapHost:h.imapHost,imapPort:Number(h.imapPort),imapTls:h.imapTls,imapStartTls:h.imapStartTls,smtpHost:ce||void 0,smtpPort:se?Number(se):void 0,smtpTls:me,smtpStartTls:Ne,smtpUsername:h.useDifferentSmtpCreds&&h.smtpUsername||void 0,smtpPassword:h.useDifferentSmtpCreds&&h.smtpPassword||void 0};if(d&&t){const Pe={...Fe,password:n?h.password:void 0};N.mutate({path:{accountId:t.accountId},body:Pe})}else{const Pe={...Fe,password:h.password};re.mutate({body:Pe})}}),ne=re.isPending||N.isPending,{signature:ae,setSignature:ge,isSaving:oe}=ir(t?.accountId),[Q,le]=C.useState(ae.plainText),{languages:T,setLanguages:k,isSaving:D}=Qr(t?.accountId),q=a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Writing languages"}),a.jsx(mr,{value:T,onChange:k,busy:D})]});C.useEffect(()=>{le(ae.plainText)},[ae.plainText]),C.useEffect(()=>{if(!e||!i)return;const h=_.current;if(!h)return;const V=window.setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},250);return()=>window.clearTimeout(V)},[e,i]);const Z=C.useCallback(()=>{Q!==ae.plainText&&ge(Q,Q)},[Q,ae.plainText,ge]),S=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("imapTls",V),f.setValue("imapStartTls",ce);const se=f.getValues("imapPort");(se===993||se===143)&&f.setValue("imapPort",h==="tls"?993:143)},J=h=>{const{tls:V,startTls:ce}=Be(h);f.setValue("smtpTls",V),f.setValue("smtpStartTls",ce);const se=f.getValues("smtpPort");if(se===465||se===587||se===25){const Ne=h==="tls"?465:h==="starttls"?587:25;f.setValue("smtpPort",Ne)}},$=()=>{const h=f.getValues("imapHost");f.setValue("smtpHost",or(h)),f.setValue("smtpTls",!1),f.setValue("smtpStartTls",!0),f.setValue("smtpPort",587)},fe=h=>{E(h),U(!1);const V=Vt(h);if(!V)return;const ce=Be(V.imap.security);f.setValue("imapHost",V.imap.host),f.setValue("imapPort",V.imap.port),f.setValue("imapTls",ce.tls),f.setValue("imapStartTls",ce.startTls);const se=Be(V.smtp.security);f.setValue("smtpHost",V.smtp.host),f.setValue("smtpPort",V.smtp.port),f.setValue("smtpTls",se.tls),f.setValue("smtpStartTls",se.startTls);const me=f.getValues("email").trim(),Ne=f.getValues("username")?.trim();me&&!Ne&&f.setValue("username",me)},Ee=R?.passwordHelp.text,we=Dt(b.data?.imapError,Ee),_e=Dt(b.data?.smtpError,Ee);return(t?Zr(t):!1)&&d?a.jsx(Ct,{isOpen:e,onClose:s,title:"Edit Account",footer:a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Close"}),children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Microsoft 365 Account"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Email"}),a.jsx("span",{className:"text-fg",children:t?.email})]}),a.jsxs("div",{className:"rounded-md border border-line bg-surface-sunken px-3 py-2.5 text-sm text-fg-muted",children:[a.jsx("span",{className:"block text-2xs font-medium uppercase tracking-wider text-fg-subtle mb-1",children:"Authentication"}),a.jsx("span",{className:"text-fg",children:"Microsoft OAuth (XOAUTH2)"})]}),a.jsx("p",{className:"text-xs text-fg-muted",children:"Server settings are managed automatically for Microsoft 365 accounts. To update credentials, use the Reconnect button."})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-view",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-view",value:Q,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})}):a.jsx(Ct,{isOpen:e,onClose:s,title:d?"Edit Account":"Add Account",footer:a.jsxs(a.Fragment,{children:[a.jsx(te,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),a.jsx(te,{type:"submit",form:"account-form",variant:"primary",disabled:ne,children:ne?"Saving...":"Save Account"})]}),children:a.jsxs("form",{id:"account-form",onSubmit:A,className:"space-y-6",children:[a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Account Information"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-provider",className:"text-sm font-medium mb-1.5 block",children:"Provider"}),a.jsxs(Ls,{id:"account-provider",value:j,onChange:h=>fe(h.target.value),children:[a.jsx("option",{value:"",children:"Custom / other"}),er.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))]}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Pick your email provider to fill in server settings automatically, or choose Custom to enter them by hand."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-email",className:"text-sm font-medium mb-1.5 block",children:"Email Address"}),a.jsx(ve,{id:"account-email",...f.register("email"),placeholder:"alice@example.com"}),f.formState.errors.email&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.email.message})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-displayName",className:"text-sm font-medium mb-1.5 block",children:"Display name (optional)"}),a.jsx(ve,{id:"account-displayName",...f.register("displayName"),placeholder:"Alice"}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-username",className:"text-sm font-medium mb-1.5 block",children:"Username"}),a.jsx(ve,{id:"account-username",...f.register("username"),placeholder:"Same as email if empty"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"account-password",className:"text-sm font-medium mb-1.5 block",children:"Password"}),a.jsx(At,{id:"account-password",...f.register("password",{onChange:()=>u(!0)}),onFocus:()=>{d&&!n&&(f.setValue("password",""),u(!0))},placeholder:d?"Leave empty to keep current":""}),f.formState.errors.password&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.password.message}),R&&a.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[R.passwordHelp.text," ",a.jsx("a",{href:R.passwordHelp.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"Get an app password"})]})]})]})]}),a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Incoming Mail (IMAP)"}),R&&a.jsx("button",{type:"button",onClick:()=>U(h=>!h),className:"text-xs text-fg-muted hover:text-fg transition-colors",children:P?"Use preset settings":"Advanced"})]}),O&&a.jsxs("p",{className:"text-xs text-fg-muted mb-3",children:["Server settings are pre-filled for ",R?.label," and locked. Choose Advanced to edit them by hand."]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"imap-host",...f.register("imapHost"),readOnly:O,placeholder:"imap.example.com"}),f.formState.errors.imapHost&&a.jsx("p",{className:"text-sm text-danger mt-1",children:f.formState.errors.imapHost.message})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"imap-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"imap-port",...f.register("imapPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("imapTls"),onChange:()=>S("tls")}),"TLS (Port 993)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&f.watch("imapStartTls"),onChange:()=>S("starttls")}),"STARTTLS (Port 143)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("imapTls")&&!f.watch("imapStartTls"),onChange:()=>S("none")}),"None (Unencrypted)"]})]})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:W,disabled:b.isPending,className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test IMAP Connection"}),b.data&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.imapSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.imapSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ce,{className:"inline size-4 mr-1"}),b.data.imapSuccess?"IMAP Connected":we]})]})]}),a.jsxs("section",{ref:_,"data-testid":"smtp-section",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider",children:"Outgoing Mail (SMTP)"}),!O&&a.jsx("button",{type:"button",onClick:$,disabled:!f.watch("imapHost"),className:"text-xs text-fg-muted hover:text-fg transition-colors disabled:opacity-50",children:"Pre-fill from IMAP"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-host",className:"text-sm font-medium mb-1.5 block",children:"Server"}),a.jsx(ve,{id:"smtp-host",...f.register("smtpHost"),readOnly:O,placeholder:"smtp.example.com"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-port",className:"text-sm font-medium mb-1.5 block",children:"Port"}),a.jsx(ve,{id:"smtp-port",...f.register("smtpPort"),readOnly:O,type:"number"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm font-medium mb-1.5 block",children:"Security"}),a.jsxs("div",{className:"space-y-1.5 mt-2",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:f.watch("smtpTls")===!0,onChange:()=>J("tls")}),"TLS (Port 465)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&f.watch("smtpStartTls")===!0,onChange:()=>J("starttls")}),"STARTTLS (Port 587)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"radio",disabled:O,checked:!f.watch("smtpTls")&&!f.watch("smtpStartTls"),onChange:()=>J("none")}),"None (Unencrypted)"]})]})]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx("input",{type:"checkbox",...f.register("useDifferentSmtpCreds")}),"Use different credentials for SMTP"]}),f.watch("useDifferentSmtpCreds")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-username",className:"text-sm font-medium mb-1.5 block",children:"SMTP Username"}),a.jsx(ve,{id:"smtp-username",...f.register("smtpUsername")})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"smtp-password",className:"text-sm font-medium mb-1.5 block",children:"SMTP Password"}),a.jsx(At,{id:"smtp-password",...f.register("smtpPassword")})]})]}),a.jsx(te,{type:"button",variant:"secondary",onClick:I,disabled:b.isPending||!f.watch("smtpHost"),className:"w-full",icon:b.isPending?a.jsx(it,{className:"size-4 animate-spin"}):void 0,children:b.isPending?"Testing...":"Test SMTP Connection"}),b.data?.smtpSuccess!==void 0&&a.jsxs("div",{className:Ge("p-2 rounded-md text-sm",b.data.smtpSuccess?"bg-positive/10 text-positive":"bg-danger-soft text-danger"),children:[b.data.smtpSuccess?a.jsx(Tt,{className:"inline size-4 mr-1"}):a.jsx(Ce,{className:"inline size-4 mr-1"}),b.data.smtpSuccess?"SMTP Connected":_e]})]})]}),d&&a.jsxs("section",{children:[a.jsx("h3",{className:"text-2xs font-semibold text-fg-subtle uppercase tracking-wider mb-3",children:"Signature"}),a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("label",{htmlFor:"email-sig-edit",className:"text-sm font-medium mb-1.5 block",children:"Email Signature"}),a.jsx("textarea",{id:"email-sig-edit",value:Q,onChange:h=>le(h.target.value),onBlur:Z,rows:5,className:"w-full px-3 py-2 border border-line rounded-md bg-surface-sunken text-sm text-fg placeholder:text-fg-subtle focus-within:border-line-strong focus-within:ring-2 focus-within:ring-ring/30 transition-colors resize-y outline-none",placeholder:"Enter your email signature..."}),a.jsx("p",{className:"text-xs text-fg-muted mt-1",children:oe?"Saving signature...":"This signature will be appended to new emails."})]})})]}),d&&q]})})};function Yt({open:e,onClose:s,accountEmail:t,signOut:i}){const[o,d]=C.useState(""),[n,u]=C.useState(!1),[j,E]=C.useState(!1),P=Se({...zs(),onSuccess:()=>{E(!0),setTimeout(()=>i(),2e3)}}),U=Se(Bs()),R=()=>{P.isPending||(d(""),u(!1),E(!1),P.reset(),U.reset(),s())},O=()=>{if(o.trim().toLowerCase()!==t.toLowerCase()){u(!0);return}u(!1),P.mutate({body:{confirmEmail:o.trim()}})};return a.jsxs(ts,{open:e,onClose:R,title:"Delete your Remit account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete your Remit account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),onClick:R,"aria-label":"Cancel"})]}),j?a.jsxs("div",{className:"px-5 py-6 text-sm text-fg-muted",children:[a.jsx("p",{className:"font-medium text-fg",children:"Account deletion scheduled."}),a.jsx("p",{className:"mt-1",children:"Your data will be erased shortly. Signing you out…"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{children:"This permanently erases everything Remit holds for you:"}),a.jsxs("ul",{className:"space-y-1.5 text-xs",children:[a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"All connected accounts disconnected and access tokens revoked."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Synced mail cache and search index."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"AI history and insights."]}),a.jsxs("li",{className:"flex gap-2",children:[a.jsx("span",{className:"text-danger",children:"•"}),"Preferences and rules."]})]}),a.jsxs("div",{className:"rounded-sm border border-line bg-surface-sunken px-3 py-2 text-xs",children:[a.jsx("strong",{className:"text-fg",children:"Your mail at Gmail / IMAP is not deleted."})," ","This only removes Remit's copy and its access — the mail stays in your provider mailboxes."]}),a.jsxs("div",{className:"text-xs",children:[a.jsxs("button",{type:"button",onClick:()=>U.mutate({}),"aria-busy":U.isPending,className:"inline-flex items-center gap-1.5 font-medium text-accent hover:underline",children:[a.jsx(lr,{className:"size-3.5"}),U.isPending?"Requesting export…":"Export my data first"]}),U.isSuccess&&a.jsx("p",{className:"mt-1.5 text-fg-muted",role:"status",children:"Export requested. We'll prepare a ZIP of your mail — find it under your data exports when it's ready."}),U.isError&&a.jsx("p",{className:"mt-1.5 text-danger",role:"alert",children:"Couldn't start the export. Please try again."})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"confirm-remit-email",className:"mb-1 block text-xs font-medium text-fg",children:["Type"," ",a.jsx("span",{className:"font-mono text-fg-muted",children:t})," ","to confirm"]}),a.jsx(ve,{id:"confirm-remit-email",type:"email",placeholder:t,value:o,onChange:_=>{d(_.target.value),n&&u(!1),P.isError&&P.reset()},autoComplete:"off"}),n&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:"That doesn't match your account email. Type it exactly to confirm."}),P.isError&&a.jsx("p",{className:"mt-1.5 text-xs text-danger",role:"alert",children:P.error instanceof Error?P.error.message:"Something went wrong. Please try again."})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:R,children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm",onClick:O,"aria-busy":P.isPending,children:P.isPending?"Deleting…":"Delete everything"})]})]})]})}function sa(e){const{Account:s}=Hs();return a.jsx(s,{fallback:a.jsx(Yt,{...e,accountEmail:"",signOut:()=>{}}),children:({email:t,signOut:i})=>a.jsx(Yt,{...e,accountEmail:t??"",signOut:i})})}function ra(){const[e,s]=C.useState(!1);return a.jsxs("section",{className:"mt-8 border-t border-line pt-6",children:[a.jsx(pr,{title:"Delete your Remit account",description:"Disconnects every account and erases Remit's copy of your mail, insights and preferences. Your mail at the providers is untouched.",action:a.jsx(te,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete your Remit account"})}),a.jsx(sa,{open:e,onClose:()=>s(!1)})]})}function aa(e){const s=e.toLowerCase();return s==="access_denied"?"You cancelled the sign-in.":s==="consent_required"||s.includes("admin_consent")||s.includes("interaction_required")?"Your organisation's admin needs to approve Remit. Ask your IT admin to grant the required permissions.":s.includes("imap_disabled")||s.includes("imap disabled")?"IMAP is disabled for this account. Ask your admin to enable IMAP access in the Microsoft 365 admin centre.":`Sign-in failed: ${e}. Please try again.`}function ia(e){const s=e.split("@")[0]??"";return s?s.split(/[._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):e}function na(e){const s=e.displayName?.trim();return s||ia(e.email)}function oa(e){if(!e.lastSyncAt)return"never synced";const s=dr(e.lastSyncAt);return s?`synced ${s}`:"never synced"}function Qt(e){return e.muted?.value?"muted":e.lastError?"error":e.connectionState==="authenticated"?"healthy":"error"}function Zt(e){return e.connectionState==="reauth_required"}function la(e){return e.connectionState==="credentials_missing"}const ca=()=>a.jsx("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading accounts",children:["skeleton-0","skeleton-1"].map(e=>a.jsx("div",{className:"rounded-sm border border-line bg-surface animate-pulse p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"size-10 rounded-full bg-surface-sunken"}),a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("div",{className:"h-4 bg-surface-sunken rounded w-1/3"}),a.jsx("div",{className:"h-3 bg-surface-sunken rounded w-2/3"})]})]})},e))});function Va(){const e=_t.useSearch(),s=qs({from:_t.fullPath}),[t,i]=C.useState(!0),[o,d]=C.useState(!1),[n,u]=C.useState(!1),[j,E]=C.useState(null),[P,U]=C.useState(!1),[R,O]=C.useState(null),[_,f]=C.useState(null),[b,re]=C.useState(null),[N,W]=C.useState(null),I=ft(),{data:A,isPending:ne,isError:ae,error:ge,refetch:oe}=Jt(Xt());C.useEffect(()=>{e.editAccountId&&(E(e.editAccountId),U(!!e.focusSmtp),s({search:{editAccountId:void 0,focusSmtp:void 0,connected:e.connected,oauthError:e.oauthError},replace:!0}))},[e.editAccountId,e.focusSmtp,s,e.connected,e.oauthError]),C.useEffect(()=>{e.connected&&(f("Account connected successfully."),E(e.connected),I.invalidateQueries({queryKey:Te()}),s({search:{connected:void 0,oauthError:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.connected,s,I]),C.useEffect(()=>{e.oauthError&&(re(aa(e.oauthError)),W(null),s({search:{oauthError:void 0,connected:void 0,editAccountId:void 0,focusSmtp:void 0},replace:!0}))},[e.oauthError,s]),sr(N!==null,()=>{I.invalidateQueries({queryKey:Te()})}),C.useEffect(()=>{if(!N||!A)return;const S=A.accounts.find(J=>J.accountId===N);(!S||!Zt(S))&&W(null)},[A,N]);const Q=rr(S=>{W(null),S==="stalled"&&re(ar)}),le=Se({...Ws(),onSuccess:S=>{Q(),window.location.assign(S.authorizationUrl)},onError:S=>{re(S instanceof Error?S.message:"Failed to start reconnect"),W(null)}}),T=Se({...$s(),onSuccess:()=>{I.invalidateQueries({queryKey:Te()}),O(null)}}),k=A?.accounts.find(S=>S.accountId===R),D=A?.accounts.find(S=>S.accountId===j),q=()=>{d(!1),u(!1),E(null),U(!1)},Z=S=>{const J=Ys[S];J&&s({to:J})};return a.jsxs(Js,{items:Gs,activeId:"accounts",title:"Accounts",description:"Every account keeps syncing — muted ones just stay out of unified views.",help:ur,helpOpen:t,onToggleHelp:()=>i(S=>!S),onSelect:Z,onBackToMail:()=>{s({to:"/mail"})},children:[_&&a.jsx(Pt,{tone:"success",variant:"soft","data-testid":"oauth-success-banner",onDismiss:()=>f(null),children:_}),b&&a.jsx(Pt,{tone:"danger",variant:"soft","data-testid":"oauth-error-banner",onDismiss:()=>re(null),children:b}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ks,{tone:"neutral",children:ne||ae?"accounts":`${A.accounts.length} ${A.accounts.length===1?"account":"accounts"}`}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add account"})]}),ne?a.jsx(ca,{}):ae?a.jsx(cr,{title:"Couldn't load accounts",error:ge,onRetry:()=>{oe()}}):A.accounts.length===0?a.jsxs("div",{className:"py-12 text-sm text-fg-muted","data-testid":"accounts-empty",children:[a.jsx("p",{className:"mb-3",children:"No accounts configured."}),a.jsx(te,{variant:"primary",size:"sm",icon:a.jsx(kt,{className:"size-3.5"}),onClick:()=>u(!0),children:"Add your first account"})]}):a.jsx("div",{className:"space-y-3",children:A.accounts.map(S=>{const J=Zt(S),$=la(S),fe=S.authType==="oauthMicrosoft",Ee=N===S.accountId,we=J&&fe?{label:"Reconnect",variant:"secondary",busy:Ee,busyLabel:"Redirecting…",onClick:()=>{W(S.accountId),le.mutate({body:{email:S.email}})}}:$?{label:"Enter password",variant:"secondary",onClick:()=>E(S.accountId)}:Qt(S)==="error"?{label:"Reconnect",variant:"secondary",onClick:()=>E(S.accountId)}:{label:"Manage",variant:"ghost",onClick:()=>E(S.accountId)},_e=a.jsx(Zs,{actions:[we],destructive:{label:"Delete account",iconOnly:!0,icon:a.jsx(Qs,{className:"size-3.5"}),onClick:()=>O(S.accountId)}});return a.jsx(Xs,{label:na(S),email:S.email,connector:fe?"Microsoft 365":"IMAP",syncLabel:oa(S),state:Qt(S),errorDetail:J?S.lastError??"Re-authentication required":$?"Imported from a config file, which carries no password. Enter one to start syncing.":S.lastError,trailing:_e},S.accountId)})}),n&&a.jsx("div",{className:"fixed inset-0 z-40 overflow-auto bg-canvas",children:a.jsx(tr,{skipWelcome:!0,onComplete:()=>{u(!1),I.invalidateQueries({queryKey:Te()})},onCancel:()=>u(!1)})}),a.jsx(ta,{isOpen:o||!!j,account:D,focusSmtp:P,onClose:q}),a.jsxs(ts,{open:!!R,onClose:()=>O(null),title:"Delete account",children:[a.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[a.jsx(ut,{className:"size-4 shrink-0 text-danger"}),a.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:"Delete account"}),a.jsx(te,{variant:"ghost",size:"sm",icon:a.jsx(Ce,{className:"size-3.5"}),onClick:()=>O(null),"aria-label":"Cancel"})]}),a.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[a.jsx("p",{className:"text-center text-lg font-medium text-fg",children:"Are you sure?"}),k&&a.jsx("p",{className:"text-center",children:k.email}),a.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[a.jsx("li",{children:"Remove the account from your settings"}),a.jsx("li",{children:"Stop syncing mail for this account"}),a.jsx("li",{children:"Delete all associated data (within 24 hours)"})]})]}),a.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[a.jsx(te,{variant:"secondary",size:"sm",onClick:()=>O(null),children:"Cancel"}),a.jsx(te,{variant:"danger",size:"sm","aria-busy":T.isPending,icon:T.isPending?a.jsx(it,{className:"size-3.5 animate-spin"}):void 0,onClick:()=>{T.isPending||R&&T.mutate({path:{accountId:R}})},children:T.isPending?"Deleting…":"Delete account"})]})]}),a.jsx(ra,{})]})}export{Va as component,aa as mapOauthError};
|
package/assets/brief-BzLBKBJb.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r,O as i}from"./index-BSMLcnNv.js";import{a as m}from"./MailShell-DX1zBcaU.js";import{B as o}from"./BriefPane-DojIZDdy.js";import{d as p}from"./search-token-index-srRTXc29.js";import{u as e}from"./search-mirror-CD8ms6aC.js";import"./FullCompose-AEoBq77L.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./EmptyState-BTKm9F6Q.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./useLayoutTier-C5sdkyR7.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./useQueries-hzIIiVUF.js";import"./menu-D4SB6ohG.js";import"./useRefreshControl-D15eEjeE.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./useSemanticSearch-DT9Nt957.js";import"./useLabels-BTBI_l7Q.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function X(){const t=p();return e({to:"/mail/brief"}),r.jsx(o,{thread:t,children:r.jsx(m,{phone:r.jsx(o.Phone,{}),list:r.jsx(o.List,{}),reading:r.jsx(i,{}),intelligence:r.jsx(o.Intelligence,{}),hasThread:!!t})})}export{X as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as N,r as i,j as e,f as m,B as j,g as T,a2 as F,aA as M,h as A,b7 as E,c as R,b8 as O,i as v,b9 as y,ba as D,bb as P,bc as z,s as $,u as _,aK as H,aM as I}from"./index-BSMLcnNv.js";import{S as L}from"./settings-screen-CX00GQZz.js";import{C as G,a as B,b as Q,c as K}from"./card-Drp0FnU2.js";import{C as U}from"./confirm-dialog-BVXTDPyQ.js";import{E as X,f as V}from"./ErrorState-jZhKH-Aj.js";import{a as C}from"./format-bkonYesy.js";import{R as J}from"./refresh-cw-Bdx0EEOe.js";import{C as W}from"./copy-D_J7-xdX.js";import{u as Y}from"./useCalendars-D7gapaJ1.js";import"./avatar-BuUa_-Ae.js";import"./chevron-left-BW6j5W1b.js";import"./menu-D4SB6ohG.js";import"./circle-help-Ck_g9Pip.js";const Z=N("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),q=s=>({title:`Replace the address for ${s}?`,description:"Every client already subscribed to the current address stops updating and has to be pointed at the new one. The new address is shown once."}),ee=s=>({title:`Stop sharing ${s}?`,description:"The address stops working immediately and every client subscribed to it stops updating. Sharing again mints a different address."});function se({calendarName:s,url:a,onDismiss:t}){const[n,o]=i.useState(!1),[r,c]=i.useState(!1),u=i.useRef(0);i.useEffect(()=>()=>window.clearTimeout(u.current),[]);const l=()=>{navigator.clipboard.writeText(a).then(()=>{c(!1),o(!0),u.current=window.setTimeout(()=>o(!1),2e3)}).catch(()=>c(!0))};return e.jsxs("div",{className:"mt-3 space-y-2 rounded-sm border border-accent-2/40 bg-accent-2/10 px-3 py-2.5",children:[e.jsx("p",{className:"text-sm font-medium text-fg",children:"Subscribe with this address. It is shown once and cannot be read back."}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{readOnly:!0,value:a,"aria-label":`Subscription address for ${s}`,onFocus:d=>d.currentTarget.select(),className:"min-w-0 flex-1 rounded-sm border border-line bg-surface px-2 py-1.5 font-mono text-xs text-fg"}),e.jsx(m,{variant:"primary",size:"sm",icon:n?e.jsx(M,{className:"size-3.5"}):e.jsx(W,{className:"size-3.5"}),onClick:l,children:n?"Copied":"Copy address"})]}),r&&e.jsx(j,{tone:"warning",variant:"soft",children:"The address could not be copied to the clipboard. Select it above and copy it by hand before leaving this page."}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Anyone holding this address can read every event in this calendar, without signing in. Rotate it if it reaches the wrong person."}),e.jsx(m,{variant:"ghost",size:"sm",onClick:t,children:"I've saved it"})]})}function te({createdAt:s,rotatedAt:a,isBusy:t,onRotate:n,onRevoke:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(T,{tone:"positive",children:"shared"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Address created ",C(s,"medium"),a>0?`, last replaced ${C(a,"medium")}`:""]})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"The address itself is not stored in readable form, so it cannot be shown again. Replace it if you no longer know where it went."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(m,{variant:"secondary",size:"sm",disabled:t,icon:e.jsx(J,{className:"size-3.5"}),onClick:n,children:"Replace address"}),e.jsx(m,{variant:"danger",size:"sm",disabled:t,icon:e.jsx(F,{className:"size-3.5"}),onClick:o,children:"Stop sharing"})]})]})}function ae({calendarName:s,state:a,mintedUrl:t,isBusy:n,actionError:o,onMint:r,onRevoke:c,onDismissMinted:u,onRetry:l}){const[d,p]=i.useState("none"),h=i.useId(),f=()=>{const b=d;p("none"),b==="rotate"&&r(),b==="revoke"&&c()},x=d==="revoke"?ee(s):q(s);return e.jsxs(G,{className:"max-w-xl",role:"region","aria-labelledby":h,children:[e.jsx(B,{children:e.jsx(Q,{id:h,children:s})}),e.jsxs(K,{children:[a.status==="loading"&&t===""&&e.jsx("div",{className:"h-12 animate-pulse rounded-sm bg-surface-sunken","aria-busy":"true","aria-label":`Loading the subscription address for ${s}`}),a.status==="unreadable"&&t===""&&e.jsx(X,{variant:"inline",title:`Couldn't read whether ${s} is shared`,error:a.error,onRetry:l}),a.status==="absent"&&t===""&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"Give this calendar a secret address and Apple Calendar, Google Calendar, Outlook and Thunderbird can subscribe to it read-only. Nobody signs in — the address is the credential, so treat it like a password."}),e.jsx(m,{variant:"primary",size:"sm",disabled:n,icon:e.jsx(Z,{className:"size-3.5"}),onClick:r,children:n?"Creating…":"Create subscription address"})]}),a.status==="active"&&e.jsx(te,{createdAt:a.createdAt,rotatedAt:a.rotatedAt,isBusy:n,onRotate:()=>p("rotate"),onRevoke:()=>p("revoke")}),o!=null&&e.jsxs(j,{tone:"danger",variant:"soft",className:"mt-3",children:[e.jsxs("p",{className:"font-medium",children:["The subscription address for ",s," was not changed."]}),e.jsx("p",{className:"mt-0.5 break-words",children:V(o)})]}),t!==""&&e.jsx(se,{calendarName:s,url:t,onDismiss:u})]}),e.jsx(U,{isOpen:d!=="none",title:x.title,description:x.description,confirmLabel:d==="revoke"?"Stop sharing":"Replace address",destructive:!0,onConfirm:f,onCancel:()=>p("none")})]})}const ne="/feeds/calendar/",re=".ics",ie=(s,a)=>`webcal://${s}${ne}${a}${re}`;function oe(s){const a=A(),[t,n]=i.useState(""),o=E({path:{calendarId:s}}),r=R({...O({path:{calendarId:s}}),meta:$(404,403),retry:!1}),c=()=>{a.invalidateQueries({queryKey:o})},u=i.useRef(()=>{}),l=v({...D(),meta:y,onMutate:()=>{u.current()},onSuccess:()=>{n(""),c()}}),d=v({...P(),meta:y,gcTime:0,onMutate:()=>{l.reset()},onSuccess:S=>{n(ie(window.location.host,S.feedToken)),c()}});u.current=d.reset;const{mutate:p,reset:h}=d,{mutate:f}=l,x=i.useCallback(()=>{p({path:{calendarId:s}})},[s,p]),b=i.useCallback(()=>{f({path:{calendarId:s}})},[s,f]),k=i.useCallback(()=>{n(""),h()},[h]),{refetch:g}=r,w=i.useCallback(()=>{g()},[g]);return{state:de(r),mintedUrl:t,isBusy:d.isPending||l.isPending,actionError:d.error??l.error,mint:x,revoke:b,dismissMinted:k,retry:w}}function de(s){return s.error?z(s.error)?{status:"absent"}:{status:"unreadable",error:s.error}:s.isPending?{status:"loading"}:s.data?{status:"active",createdAt:s.data.createdAt,rotatedAt:s.data.rotatedAt}:{status:"absent"}}function ce({calendarId:s,calendarName:a}){const t=oe(s);return e.jsx(ae,{calendarName:a,state:t.state,mintedUrl:t.mintedUrl,isBusy:t.isBusy,actionError:t.actionError,onMint:t.mint,onRevoke:t.revoke,onDismissMinted:t.dismissMinted,onRetry:t.retry})}const le=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"A subscription address lets Apple Calendar, Google Calendar, Outlook and Thunderbird show a calendar from here, read-only and kept up to date."}),e.jsx("p",{children:"Those clients never sign in, so the address itself is the credential. Anyone who has it can read the calendar; nobody who has it can change anything."}),e.jsx("p",{children:"Only a hash of the address is stored, so it is shown once and cannot be looked up later. Replacing it breaks every subscription built on the old one, which is how a shared address is taken back."})]});function we(){const s=_(),[a,t]=i.useState(!0),{calendars:n,isLoading:o}=Y();return e.jsx(L,{items:H,activeId:"calendars",title:"Calendars",description:"Share a calendar with any client that can subscribe to a URL.",help:le,helpOpen:a,onToggleHelp:()=>t(r=>!r),onSelect:r=>{const c=I[r];c&&s({to:c})},onBackToMail:()=>{s({to:"/mail"})},children:o?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading calendars"}):n.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No calendars yet."}):e.jsx("div",{className:"space-y-4",children:n.map(r=>e.jsx(ce,{calendarId:r.id,calendarName:r.name},r.id))})})}export{we as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e}from"./index-BSMLcnNv.js";const t=e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);export{t as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as o}from"./FullCompose-AEoBq77L.js";import"./index-BSMLcnNv.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";const C=o;export{C as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as o}from"./FullCompose-AEoBq77L.js";import"./index-BSMLcnNv.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";const C=o;export{C as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as o}from"./FullCompose-AEoBq77L.js";import"./index-BSMLcnNv.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";const C=o;export{C as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as o}from"./FullCompose-AEoBq77L.js";import"./index-BSMLcnNv.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";const C=o;export{C as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o,O as i}from"./index-BSMLcnNv.js";import{a as m}from"./MailShell-DX1zBcaU.js";import{F as r}from"./FlaggedPane-Gh0sDSpK.js";import{d as p}from"./search-token-index-srRTXc29.js";import{u as e}from"./search-mirror-CD8ms6aC.js";import"./FullCompose-AEoBq77L.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./EmptyState-BTKm9F6Q.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./useLayoutTier-C5sdkyR7.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./useQueries-hzIIiVUF.js";import"./menu-D4SB6ohG.js";import"./MailViewChrome-WyEJa7LW.js";import"./refresh-cw-Bdx0EEOe.js";import"./wizard-selection-DxUM65kM.js";function Q(){const t=p();return e({to:"/mail/flagged"}),o.jsx(r,{thread:t,children:o.jsx(m,{phone:o.jsx(r.Phone,{}),list:o.jsx(r.List,{}),reading:o.jsx(i,{}),intelligence:o.jsx(r.Intelligence,{}),hasThread:!!t})})}export{Q as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,f as j,a2 as H,bo as Y,r as c,aH as W,X,aO as he,ay as Z,a0 as xe,aR as G,bp as fe,ax as pe,aA as ge,B as z,aQ as be,bq as ve,h as J,N as ee,o as se,br as ye,bs as je,aN as Ne,M as ke,bt as Ce,bu as _,bv as we,bw as Se,bx as te,by as Me,bz as K,bf as ae,bl as re,bm as Ie,ae as B,ad as ne,L as q,bA as Q,bB as Ee,aq as Ae,bC as De,u as Oe,c as ie,d as Te,aK as Re,aM as Fe,H as Pe,i as V,s as $e,bD as Le,bE as ze,bF as _e,aV as He,bG as Be,bH as qe}from"./index-BSMLcnNv.js";import{P as Ge}from"./pencil-BSemJDIl.js";import{S as Ke}from"./settings-screen-CX00GQZz.js";import{E as oe}from"./ErrorState-jZhKH-Aj.js";import"./avatar-BuUa_-Ae.js";import"./chevron-left-BW6j5W1b.js";import"./menu-D4SB6ohG.js";import"./circle-help-Ck_g9Pip.js";const Qe=({label:s,onRename:t,onDelete:a,deleteBlockedReason:o,renameLabel:m=u=>`Rename ${u}`,deleteLabel:r=u=>`Delete ${u}`})=>{const u=o?`${r(s)} — ${o}`:r(s);return e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 pr-2",children:[e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(Ge,{className:"size-3.5"}),"aria-label":m(s),onClick:t}),e.jsx("span",{title:o,children:e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(H,{className:"size-3.5"}),"aria-label":u,disabled:o!==void 0,onClick:a})})]})},Ve=({folders:s,onRename:t,onDelete:a,onCreateFolder:o,delimiter:m,labels:r})=>{const u=new Map(s.map(l=>[l.id,l]));return e.jsx(Y,{folders:s,onCreateFolder:o,delimiter:m,labels:{treeAriaLabel:"Your folders",optionLabel:l=>l.label,...r},rowActions:l=>{const i=u.get(l.id);return i?e.jsx(Qe,{label:i.label,deleteBlockedReason:i.deleteBlockedReason,renameLabel:r?.rename,deleteLabel:r?.remove,onRename:()=>t(i),onDelete:()=>a(i)}):null}})},Ue=({open:s,folderLabel:t,defaultLabel:a,name:o,onNameChange:m,onSubmit:r,onClose:u,pending:l=!1,error:i})=>{const d=c.useId(),p=`Rename ${t}`;return s?e.jsxs(W,{open:s,onClose:u,title:p,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:p}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:u,"aria-label":"Cancel"})]}),e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("div",{children:[e.jsx(he,{htmlFor:d,children:"Folder name"}),e.jsx(Z,{id:d,value:o,placeholder:a,onChange:g=>m(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r())}})]}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Shown everywhere in Remit. Leave it blank to use"," ",e.jsx("span",{className:"font-medium text-fg",children:a}),"."]}),i&&e.jsx("p",{className:"text-xs text-danger",role:"alert",children:i})]}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:u,children:"Cancel"}),e.jsx(j,{variant:"primary",size:"sm",onClick:r,disabled:l,children:l?"Saving…":"Save name"})]})]}):null},Ye=["inbox","drafts","sent","archive","junk","trash"],U="",We={mailboxId:null,source:"None"};function Xe(s){const t=s.messageCount===1?"msg":"msgs";return`${G(s.providerPath,s.hierarchyDelimiter)} · ${s.messageCount} ${t}`}const le=s=>`${s} ${s===1?"message":"messages"}`,Ze=(s,t)=>s==="Appointed"?"Chosen by you":s==="Flagged"?`The mail server marks it as ${t}`:s==="Reserved"?"The account's own INBOX":"Matched by name, not confirmed";function Je({role:s,folders:t,appointment:a,displayName:o,onAppoint:m,onRename:r}){const[u,l]=c.useState(o),i=c.useRef(null),d=c.useRef(!1),p=c.useId(),{mailboxId:g,source:v,staleFolderPath:y}=a,h=t.find(N=>N.mailboxId===g)??null,f=be(s),O=h!=null&&u.trim()!==o.trim();c.useEffect(()=>{!d.current||v==="Proposed"||(d.current=!1,i.current?.focus())},[v]);const I=(()=>{if(v==="None"){const N=s==="trash"?" Deleting mail needs one.":"";return e.jsx("span",{id:p,className:"pl-[7.5rem] text-xs text-fg-muted",children:`Not set — pick the folder this account uses for ${f}.${N}`})}return v==="Stale"||!h?null:e.jsx("span",{id:p,className:"truncate pl-[7.5rem] text-2xs text-fg-subtle",title:h.providerPath,children:`${Ze(v,f)} · ${h.providerPath} · ${le(h.messageCount)}`})})(),w=s==="trash"?" Deleting mail is stopped until you pick another one.":h?` reader is using ${G(h.providerPath,h.hierarchyDelimiter)} instead.`:"",D=`The folder you chose for ${f}${y?` — ${y} —`:""} is gone from the mail server.${w}`;return e.jsxs("div",{className:"flex flex-col gap-1 border-b border-line px-row-inset py-2.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex w-28 shrink-0 items-center gap-2 text-sm font-medium text-fg",children:[fe(s),f]}),e.jsxs(pe,{ref:i,className:"w-56 shrink-0",value:h?.mailboxId??U,"aria-label":`Folder for ${f}`,"aria-describedby":I||v==="Stale"?p:void 0,onChange:N=>m(s,N.target.value),children:[!h&&e.jsx("option",{value:U,disabled:!0,children:"Choose a folder"}),t.map(N=>e.jsx("option",{value:N.mailboxId,children:Xe(N)},N.mailboxId))]}),v==="Proposed"&&h&&e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.current=!0,m(s,h.mailboxId)},children:`Set as ${f}`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"flex-1",value:u,placeholder:f,"aria-label":`Display name for ${f}`,onChange:N=>l(N.target.value)}),O&&e.jsx(j,{variant:"ghost",size:"sm",className:"shrink-0",icon:e.jsx(ge,{className:"size-4"}),"aria-label":"Save display name",onClick:()=>r(h.mailboxId,u)})]})]}),I,v==="Stale"&&e.jsx(z,{tone:"warning",variant:"soft",className:"ml-[7.5rem]",children:e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:p,className:"flex-1",children:D}),e.jsx(j,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>i.current?.focus(),children:"Pick a folder"})]})})]})}function es(){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Each canonical role — Inbox, Drafts, Sent, Archive, Spam, Trash — points at one of your account's real folders. Pick the one that actually holds the mail; the message counts tell real folders from empty look-alikes."}),e.jsx("p",{children:`Appointing a folder to a role here doesn't touch any other role, and doesn't move or rename anything on the server — it just tells Remit which folder to treat as e.g. "Drafts" everywhere (sidebar, unread badges, the compose flow).`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:"Your folders"})," is the account's real hierarchy. Open a folder to see what's inside it, make a new one where you're looking, and rename or delete any of them from its row."]})]})}function ss({accountEmail:s,folders:t,appointments:a,displayNames:o={},onAppoint:m,onRename:r}){const u=new Set(Object.values(a).map(i=>i.mailboxId).filter(i=>i!=null)),l=t.filter(i=>!u.has(i.mailboxId));return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-sm font-semibold text-fg",children:["Folder roles — ",s]}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Each row says where its answer came from — your choice, the mail server's own flag, or a name reader matched."})]}),e.jsx("div",{className:"rounded-sm border border-line bg-surface",children:Ye.map(i=>{const d=a[i]??We;return e.jsx(Je,{role:i,folders:t,appointment:d,displayName:d.mailboxId?o[d.mailboxId]??"":"",onAppoint:m,onRename:r},i)})}),l.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-xs font-medium text-fg-muted",children:"Other folders"}),e.jsx("ul",{className:"rounded-sm border border-line bg-surface",children:l.map(i=>e.jsxs("li",{className:"flex items-center gap-2 border-b border-line px-row-inset py-2 text-sm text-fg last:border-b-0",children:[e.jsx(xe,{className:"size-4 shrink-0 text-fg-subtle"}),e.jsx("span",{className:"truncate",children:G(i.providerPath,i.hierarchyDelimiter)}),e.jsx("span",{className:"ml-auto shrink-0 text-2xs text-fg-subtle",children:le(i.messageCount)})]},i.mailboxId))})]})]})}const ts=12e4,as=2e3,rs="This folder is no longer in the account's folder list, so nothing was deleted.",ce=(s,t)=>{const a=s.find(o=>o.mailboxId===t);if(!a)throw new Error(rs);return a},ns=(s,t)=>ce(s,t).lastSyncedAt??0;async function is({readMailboxes:s,mailboxId:t,since:a,signal:o,segmentMs:m=ts,pollIntervalMs:r=as,delay:u=ve,now:l=Date.now}){const i=l()+m;for(;;){o?.throwIfAborted();const d=ce(await s(),t);if((d.lastSyncedAt??0)>a)return{status:"fresh",messageCount:d.messagesTotal};if(l()>=i)return{status:"pending"};await u(r,o)}}const de=50,os=s=>s instanceof Error?s.message:"Something went wrong.",$=s=>s.then(t=>({ok:!0,value:t}),t=>({ok:!1,error:os(t)})),ls=async(s,t,a,o)=>{const m=[];let r;for(let u=0;u<de;u+=1){if(o.aborted)return m;const{data:l}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:r},throwOnError:!0});for(const i of l.items)if(!i.isDeleted&&!t.has(i.messageId)&&!m.includes(i.messageId)&&(m.push(i.messageId),m.length>=a))return m;if(!l.continuationToken)break;r=l.continuationToken}return m},cs=async(s,t)=>{let a=0,o;for(let m=0;m<de;m+=1){if(t.aborted)return a;const{data:r}=await te({path:{mailboxId:s},query:{order:"desc",continuationToken:o},throwOnError:!0});for(const u of r.items)u.isDeleted||(a+=1);if(!r.continuationToken)break;o=r.continuationToken}return a};function ds({accountId:s,mailboxId:t,onDeleted:a}){const o=J(),[m,r]=c.useState("idle"),[u,l]=c.useState(null),[i,d]=c.useState(),[p,g]=c.useState(),v=c.useRef(null),y=c.useRef(void 0),h=c.useCallback(()=>{o.invalidateQueries({queryKey:ee({path:{accountId:s}})}),o.invalidateQueries({queryKey:se()})},[o,s]),f=c.useCallback(async()=>{r("deleting");const k=await $(ye({path:{accountId:s,mailboxId:t},throwOnError:!0}));if(!k.ok){d(k.error),r("error");return}h(),r("done"),a()},[s,t,h,a]),O=c.useCallback(()=>je({path:{accountId:s},throwOnError:!0}).then(({data:k})=>k.items.find(S=>S.mailboxId===t)?.messageCount??0),[s,t]),I=c.useCallback(()=>o.fetchQuery({...Ne({path:{accountId:s}}),staleTime:0}).then(k=>k.mailboxes??[]),[o,s]),w=c.useCallback(async()=>{const k=new AbortController;v.current=k;const{signal:S}=k;r("checking"),d(void 0);const M=y.current!==void 0,C=await $((async()=>(M||(S.throwIfAborted(),y.current=ns(await I(),t),S.throwIfAborted(),g(Date.now()),await ke({path:{accountId:s},throwOnError:!0})),is({readMailboxes:I,mailboxId:t,since:y.current??0,signal:S})))());return S.aborted?(r("idle"),y.current=void 0,{status:"failed"}):C.ok?C.value.status==="pending"?(r("check-stalled"),{status:"pending"}):(y.current=void 0,C.value.messageCount>0?(r("idle"),h(),{status:"blocked",messageCount:C.value.messageCount}):(await f(),{status:"deleted"})):(y.current=void 0,d(C.error),r("error"),{status:"failed"})},[s,t,I,f,h]),D=c.useCallback(()=>{v.current?.abort()},[]),N=c.useCallback(async k=>{const S=new AbortController;v.current=S;const{signal:M}=S;r("moving"),d(void 0);const C=await $(O());if(M.aborted)return;if(!C.ok){d(C.error),r("error");return}let x=Ce(C.value);l(x);const E=new Set;for(;;){if(M.aborted)return;const n=await $(ls(t,E,Me,M));if(M.aborted)return;if(!n.ok){x=_(x,n.error),l(x),d(n.error),r("error");return}const b=n.value;if(b.length===0)break;const T=await $(we({body:{messageIds:b,destinationMailboxId:k},throwOnError:!0}));if(M.aborted)return;if(!T.ok){x=_(x,T.error),l(x),d(T.error),r("error");return}for(const P of b)E.add(P);x=Se(x,b.length),l(x)}const A=await $(cs(t,M));if(!M.aborted){if(!A.ok){x=_(x,A.error),l(x),d(A.error),r("error");return}if(A.value>0){const n=`${A.value} ${A.value===1?"email is":"emails are"} still syncing. Re-open delete to finish removing this folder.`;x=_(x,n),l(x),d(n),r("error"),h();return}await f()}},[t,O,f,h]),R=c.useCallback(()=>{v.current?.abort(),v.current=null,y.current=void 0,r("idle"),l(null),d(void 0),g(void 0)},[]);return{phase:m,progress:u,errorMessage:i,checkStartedAt:p,deleteMailbox:f,deleteIfEmpty:w,moveThenDelete:N,cancel:D,reset:R}}const L=s=>`${s} ${s===1?"email":"emails"}`;function ms({open:s,accountId:t,folder:a,mailboxes:o,appointments:m,onClose:r}){const[u,l]=c.useState(()=>K(a.messageCount)),[i,d]=c.useState(),[p,g]=c.useState(),{createFolderIn:v}=ae(t),y=re(),{phase:h,progress:f,errorMessage:O,checkStartedAt:I,deleteMailbox:w,deleteIfEmpty:D,moveThenDelete:N,cancel:R,reset:k}=ds({accountId:t,mailboxId:a.mailboxId,onDeleted:r}),[S,M]=c.useState("0:00"),C=h==="checking"||h==="check-stalled";c.useEffect(()=>{if(!C||I===void 0)return;const F=()=>M(De(Date.now()-I));F();const ue=setInterval(F,1e3);return()=>clearInterval(ue)},[C,I]),c.useEffect(()=>{s&&(l(K(a.messageCount)),d(void 0),k())},[s,k]),c.useEffect(()=>{s&&g(void 0)},[s]),c.useEffect(()=>R,[R]);const x=c.useCallback(()=>{R(),r()},[R,r]),E=c.useCallback(async()=>{const F=await D();F.status==="blocked"&&(d(F.messageCount),l("choose-fate"))},[D]),A=c.useMemo(()=>Ie({mailboxes:o,folderAppointments:m,excludeMailboxId:a.mailboxId,translator:y}),[o,m,a.mailboxId,y]),n=A.find(F=>F.id===p),b=c.useMemo(()=>B(a,ne(m).get(a.mailboxId),y),[a,m,y]);if(!s)return null;const T=`Delete ${b}`,P=i??a.messageCount,me=h==="moving"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Moving emails…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:f?Q(f):"Moved 0 of 0"})]}):h==="checking"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Checking the folder on the mail server…"}),e.jsx("p",{className:"text-xs text-fg-muted",role:"status","aria-live":"polite",children:`Waiting ${S}. Nothing is deleted until the server answers.`})]}):h==="check-stalled"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"warning",variant:"soft",children:`The mail server hasn't reported back on this folder yet — ${S} so far. Nothing has been deleted.`}),e.jsx("p",{className:"text-xs text-fg-muted",children:"A sync covers the whole account, so a busy mailbox can take a while to come round to this folder."}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{size:"sm",onClick:()=>E(),children:"Keep waiting"})]})]}):h==="deleting"||h==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 px-5 py-10 text-center",children:[e.jsx(q,{className:"size-8 animate-spin text-accent-2"}),e.jsx("p",{className:"text-sm font-medium text-fg",children:"Deleting folder…"})]}):h==="error"?e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[e.jsx(z,{tone:"danger",variant:"soft",children:O??"Something went wrong. Please try again."}),f&&e.jsxs("p",{className:"text-xs text-fg-muted",children:[Q(f),". Already-moved emails stay moved — re-open delete to continue with the rest."]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Close"})})]}):u==="confirm-empty"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b}),"? This folder is empty and will be removed from the server."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(H,{className:"size-3.5"}),onClick:()=>E(),children:"Delete folder"})]})]}):u==="choose-fate"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:[i!==void 0&&e.jsx(z,{tone:"warning",variant:"soft",children:`This folder is not empty: the mail server reports ${L(i)} in it. Nothing was deleted.`}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-fg",children:b})," holds"," ",L(P),". What should happen to them?"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>l("confirm-delete-all"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(H,{className:"size-4 shrink-0 text-danger"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Delete them with the folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"The emails are removed from the server and can't be recovered."})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("pick-destination"),className:"flex w-full items-center gap-3 rounded-sm border border-line px-3 py-2.5 text-left hover:bg-surface-raised",children:[e.jsx(Ee,{className:"size-4 shrink-0 text-accent-2"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:"Move them to another folder"}),e.jsx("span",{className:"block text-xs text-fg-muted",children:"Keep the emails, then delete the emptied folder."})]})]})]})]}),e.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:e.jsx(j,{variant:"secondary",size:"sm",onClick:x,children:"Cancel"})})]}):u==="confirm-delete-all"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3 px-5 py-4 text-sm text-fg-muted",children:e.jsxs("p",{children:["Delete ",e.jsx("strong",{className:"text-fg",children:b})," and its"," ",L(P),"? The messages are removed from the server with the folder and can't be recovered."]})}),e.jsxs("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>l("choose-fate"),children:"Back"}),e.jsx(j,{variant:"danger",size:"sm",icon:e.jsx(H,{className:"size-3.5"}),onClick:()=>w(),children:"Delete folder and emails"})]})]}):e.jsxs("div",{className:"flex h-[26rem] flex-col",children:[e.jsxs("p",{className:"px-5 pt-4 text-sm text-fg-muted",children:["Move the ",L(P)," in"," ",e.jsx("strong",{className:"text-fg",children:b})," to:"]}),e.jsx("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:e.jsx(Y,{folders:A,selectedId:p,delimiter:o[0]?.hierarchyDelimiter??"/",onSelect:g,onCreateFolder:v,onCancel:()=>{g(void 0),l("choose-fate")},labels:{filterPlaceholder:"Move emails to…"}})}),n&&e.jsx("footer",{className:"shrink-0 border-t border-line p-2",children:e.jsx(j,{variant:"danger",onClick:()=>N(n.id),className:"h-11 w-full font-semibold",children:e.jsx("span",{className:"truncate",children:`Move ${L(P)} to ${n.label}`})})})]});return e.jsxs(W,{open:s,onClose:x,title:T,children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-line px-5 py-3",children:[e.jsx(Ae,{className:"size-4 shrink-0 text-danger"}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-fg",children:T}),e.jsx(j,{variant:"ghost",size:"sm",icon:e.jsx(X,{className:"size-3.5"}),onClick:x,"aria-label":"Cancel"})]}),me]})}function us({account:s}){const t=J(),a=s.accountId,o=re(),{data:m,isPending:r,isError:u,error:l,refetch:i}=ie(Pe({path:{accountId:a}})),{createFolderIn:d}=ae(a),p=V({...Le(),meta:$e(409),onSuccess:()=>{t.invalidateQueries({queryKey:se()})}}),g=V({...ze(),onSuccess:()=>{t.invalidateQueries({queryKey:ee({path:{accountId:a}})})}}),[v,y]=c.useState(),[h,f]=c.useState(),[O,I]=c.useState(""),w=c.useMemo(()=>m?.items??[],[m]),D=c.useMemo(()=>ne(s.folderAppointments),[s.folderAppointments]),N=c.useMemo(()=>w.map(n=>({id:n.mailboxId,label:B(n,D.get(n.mailboxId),o),path:n.fullPath,deleteBlockedReason:_e(n,w,s.folderAppointments).message})),[w,D,o,s.folderAppointments]),R=(n,b)=>{p.mutate({path:{accountId:a,role:qe[n]},body:{mailboxId:b}})},k=(n,b)=>{const T=b.trim();g.mutate({path:{accountId:a,mailboxId:n},body:{displayNameOverride:T===""?null:T}})};if(r)return e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":`Loading folders for ${s.email}`});if(u)return e.jsx(oe,{variant:"inline",title:`Couldn't load folders for ${s.email}`,error:l,onRetry:()=>{i()}});const S=w.map(n=>({mailboxId:n.mailboxId,providerPath:n.fullPath,hierarchyDelimiter:n.hierarchyDelimiter,messageCount:n.messageCount})),M={};for(const n of s.folderAppointments){const b=He[n.role];b&&(M[b]={mailboxId:n.mailboxId??null,source:n.source,staleFolderPath:n.staleAppointmentPath})}const C={};for(const n of w)n.displayNameOverride&&(C[n.mailboxId]=n.displayNameOverride);const x=n=>w.find(b=>b.mailboxId===n),E=x(h),A=x(v);return e.jsxs("div",{className:"space-y-4",children:[(p.isError||g.isError)&&e.jsx(z,{tone:"danger",variant:"soft",children:Be(p.error)?"That folder is still being created on the mail server — wait for it to finish, then try again.":"Couldn't save that change. Please try again."}),e.jsx(ss,{accountEmail:s.email,folders:S,appointments:M,displayNames:C,onAppoint:R,onRename:k}),e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["Your folders — ",s.email]}),e.jsx("div",{className:"flex h-[28rem] flex-col overflow-hidden rounded-sm border border-line bg-surface",children:e.jsx(Ve,{folders:N,delimiter:w[0]?.hierarchyDelimiter??"/",onCreateFolder:d,onRename:n=>{f(n.id),I(x(n.id)?.displayNameOverride?.trim()??"")},onDelete:n=>y(n.id),labels:{treeAriaLabel:`All folders for ${s.email}`}})})]}),E&&e.jsx(Ue,{open:!0,folderLabel:B(E,D.get(E.mailboxId),o),defaultLabel:B({fullPath:E.fullPath,hierarchyDelimiter:E.hierarchyDelimiter},D.get(E.mailboxId),o),name:O,onNameChange:I,pending:g.isPending,error:g.isError?"Couldn't save that name. Please try again.":void 0,onSubmit:()=>{const n=O.trim();g.mutate({path:{accountId:a,mailboxId:E.mailboxId},body:{displayNameOverride:n===""?null:n}},{onSuccess:()=>f(void 0)})},onClose:()=>f(void 0)}),A&&e.jsx(ms,{open:!0,accountId:a,folder:A,mailboxes:w,appointments:s.folderAppointments,onClose:()=>y(void 0)})]})}function js(){const s=Oe(),[t,a]=c.useState(!0),{data:o,isPending:m,isError:r,error:u,refetch:l}=ie(Te()),i=d=>{const p=Fe[d];p&&s({to:p})};return e.jsx(Ke,{items:Re,activeId:"folders",title:"Folder roles",description:"Appoint which real folder fills each canonical role, per account.",help:e.jsx(es,{}),helpOpen:t,onToggleHelp:()=>a(d=>!d),onSelect:i,onBackToMail:()=>{s({to:"/mail"})},children:m?e.jsx("div",{className:"h-24 animate-pulse rounded-sm border border-line bg-surface","aria-busy":"true","aria-label":"Loading accounts"}):r?e.jsx(oe,{title:"Couldn't load accounts",error:u,onRetry:()=>{l()}}):o.accounts.length===0?e.jsx("p",{className:"py-12 text-sm text-fg-muted",children:"No accounts configured."}):e.jsx("div",{className:"space-y-8",children:o.accounts.map(d=>e.jsx(us,{account:d},d.accountId))})})}export{js as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aB as l,aC as T,cF as m,aD as u,cG as h,cH as D,cI as k,cJ as d}from"./index-BSMLcnNv.js";l({kind:m("Boolean"),value:T()});l({kind:m("String"),value:u()});l({kind:m("Number"),value:h()});l({kind:m("StringList"),value:D(u())});l({kind:m("Map"),value:k(u(),u())});l({kind:m("MutedFlag"),value:l({value:T(),setAt:h(),setBy:u().optional(),expiresAt:h().optional(),reason:u().optional()})});const v=(e,t)=>{switch(e.kind){case"appointed":case"flagged":return{allowed:!0,mailbox:e.mailbox};case"proposed":return t==="resolved"?{allowed:!0,mailbox:e.mailbox}:{allowed:!1,reason:"unconfirmed"};case"appointment_stale":return{allowed:!1,reason:"stale"};default:return{allowed:!1,reason:"none"}}},x=(e,t)=>v(e,t).allowed,$={[d.Appointed]:{kind:"appointed",mailbox:null},[d.Flagged]:{kind:"flagged",mailbox:null},[d.Reserved]:{kind:"reserved",mailbox:null},[d.Proposed]:{kind:"proposed",mailbox:null},[d.Stale]:{kind:"appointment_stale",appointedMailboxId:"",fallback:{kind:"none"}},[d.None]:{kind:"none"}},M=(e,t)=>x($[e],t),g=()=>typeof navigator<"u"&&(navigator.language||navigator.languages?.[0])||"en-US",w=(e,t)=>new Intl.NumberFormat(g(),t).format(e),N=/^-?\d+$/,p=e=>{if(e instanceof Date)return e;if(typeof e=="number")return new Date(e);if(typeof e=="string"){const t=e.trim();return N.test(t)?new Date(Number(t)):new Date(t)}return new Date(Number.NaN)},b=e=>Number.isFinite(e.getTime()),c=(e,t)=>{const n=p(e);return b(n)?new Intl.DateTimeFormat(g(),t).format(n):""},S=(e,t)=>c(e,{short:{month:"short",day:"numeric"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"},time:{hour:"numeric",minute:"numeric"},datetime:{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}}[t]),I=e=>{const t=p(e);if(!b(t))return"";const n=new Intl.RelativeTimeFormat(g(),{numeric:"auto"}),i=Date.now(),r=t.getTime()-i,s=Math.round(r/1e3),a=Math.round(r/(1e3*60)),o=Math.round(r/(1e3*60*60)),f=Math.round(r/(1e3*60*60*24)),y=Math.round(r/(1e3*60*60*24*7));return Math.abs(s)<60?n.format(s,"second"):Math.abs(a)<60?n.format(a,"minute"):Math.abs(o)<24?n.format(o,"hour"):Math.abs(f)<7?n.format(f,"day"):Math.abs(y)<4?n.format(y,"week"):S(t,"medium")},L=e=>{const t=p(e);if(!b(t))return"";const n=new Date,i=t.toDateString()===n.toDateString(),r=new Date(n);r.setDate(r.getDate()-1);const s=t.toDateString()===r.toDateString(),a=new Date(n);a.setDate(a.getDate()-6);const o=t>=a&&t<n,f=t.getFullYear()===n.getFullYear();return i?c(t,{hour:"numeric",minute:"numeric"}):s?"Yesterday":o?c(t,{weekday:"long"}):f?c(t,{month:"short",day:"numeric"}):c(t,{month:"short",day:"numeric",year:"numeric"})},F=e=>`Move ${e===1?"1":w(e)} ${e===1?"message":"messages"} to Trash?`,A=({targets:e,trashByAccount:t,hasAppointments:n,isError:i})=>{if(i)return"unavailable";if(!n||e.length===0)return"unknown";let r=!1,s=!1;for(const a of e){if(a.accountId===void 0)return"unknown";const o=t.get(a.accountId);if(o===void 0)return"unknown";if(o.source==="Stale")return"staleTrash";if(o.mailboxId===void 0)return"noTrash";o.mailboxId===a.mailboxId&&(r=!0,M(o.source,"confirmed")||(s=!0))}return s?"unconfirmed":r?"permanent":"trash"},R=e=>e==="permanent"||e==="unconfirmed",E=(e,t,n={})=>{const i=e===1?"1":w(e),r=e===1?"message":"messages",{trashFolderLabel:s,staleFolderLabel:a}=n;if(t==="noTrash")return{title:`Can't delete ${i} ${r} yet`,description:"No folder on this account is set as Trash, so there is nowhere to move the mail. Nothing has been deleted.",confirmLabel:"Pick a Trash folder"};if(t==="staleTrash")return{title:`Can't delete ${i} ${r} yet`,description:a?`The folder you set as this account's Trash — ${a} — is gone from the mail server. Nothing has been deleted.`:"The folder you set as this account's Trash is gone from the mail server. Nothing has been deleted.",confirmLabel:"Pick another folder"};if(t==="unconfirmed"){const o=s?`reader files this account's deleted mail in ${s} because of its name — nobody confirmed it.`:"reader files this account's deleted mail in a folder it matched by name — nobody confirmed it.";return{title:"Confirm this account's Trash folder",description:e>0?`${o} Deleting ${i} ${r} there erases them from the mail server, and that cannot be restored. Nothing has been deleted.`:`${o} Emptying a folder erases everything in it from the mail server, and that cannot be restored. Nothing has been emptied.`,confirmLabel:"Confirm the folder"}}return t==="unavailable"?{title:`Can't delete ${i} ${r}`,description:"reader couldn't read this account's folder settings, so it can't say whether this would move the mail to Trash or erase it. Nothing has been deleted.",confirmLabel:"Sign in again"}:t==="unknown"?{title:`Delete ${i} ${r}?`,description:"Checking where this account files deleted mail…",confirmLabel:"Delete"}:t==="permanent"?{title:`Permanently delete ${i} ${r}?`,description:"They are erased from the mail server and cannot be restored.",confirmLabel:"Delete permanently"}:{title:F(e),description:"You can restore them from Trash later.",confirmLabel:"Move to Trash"}};export{S as a,c as b,L as c,E as d,w as e,I as f,A as g,R as h,p as t};
|
package/assets/index-B5pFel5d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-BSMLcnNv.js";import{F as r}from"./FlaggedPane-Gh0sDSpK.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./useQueries-hzIIiVUF.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./MailViewChrome-WyEJa7LW.js";import"./refresh-cw-Bdx0EEOe.js";import"./wizard-selection-DxUM65kM.js";function J(){return o.jsx(r.Reading,{})}export{J as component};
|
package/assets/index-BeGGBd6V.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-BSMLcnNv.js";import{B as o}from"./BriefPane-DojIZDdy.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./useQueries-hzIIiVUF.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./useRefreshControl-D15eEjeE.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./useSemanticSearch-DT9Nt957.js";import"./useLabels-BTBI_l7Q.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function M(){return r.jsx(o.Reading,{})}export{M as component};
|
package/assets/index-CRC7JV7N.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-BSMLcnNv.js";import{O as t}from"./OutboxPane-CQ3uaHpb.js";import"./roving-focus-JRZm8Nsl.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-CVRDL2A5.js";import"./clock-KUoHWkrr.js";import"./row-actions-BAj0uoQs.js";import"./rotate-ccw-rjesddf9.js";import"./NavMenuButton-CgziJeDD.js";import"./menu-D4SB6ohG.js";import"./format-bkonYesy.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function d(){return o.jsx(t.Reading,{})}export{d as component};
|
package/assets/index-CdtVuvhW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-BSMLcnNv.js";import{M as i}from"./MailboxPane-B0QAN8MQ.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-D15eEjeE.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./useQueries-hzIIiVUF.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./MailViewChrome-WyEJa7LW.js";import"./NavMenuButton-CgziJeDD.js";import"./useLabels-BTBI_l7Q.js";import"./useSemanticSearch-DT9Nt957.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BUcSDGQJ.js";import"./circle-help-Ck_g9Pip.js";import"./circle-check-8G_6IWKh.js";function T(){return o.jsx(i.Reading,{})}export{T as component};
|
package/assets/index-CwgKXaQc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-BSMLcnNv.js";import{M as r}from"./MailboxPane-B0QAN8MQ.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./useRefreshControl-D15eEjeE.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./useQueries-hzIIiVUF.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./MailViewChrome-WyEJa7LW.js";import"./NavMenuButton-CgziJeDD.js";import"./useLabels-BTBI_l7Q.js";import"./useSemanticSearch-DT9Nt957.js";import"./search-query-Cr_ZXBCp.js";import"./bottom-sheet-BUcSDGQJ.js";import"./circle-help-Ck_g9Pip.js";import"./circle-check-8G_6IWKh.js";function S(){return o.jsx(r.Reading,{})}export{S as component};
|
package/assets/index-CyAwBGa1.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{eq as o,j as r}from"./index-BSMLcnNv.js";import{O as m}from"./OpenCalendarEvent-CWAwJawV.js";import"./CalendarComposePane-B3fOrTrG.js";import"./window-ZjseaC3I.js";import"./ErrorState-jZhKH-Aj.js";import"./calendar-color-PMGOIawE.js";import"./attendee-row-OHoLTo23.js";import"./avatar-BuUa_-Ae.js";import"./clock-KUoHWkrr.js";import"./map-pin-DHhEILKJ.js";import"./mail-zfMejK7g.js";import"./pencil-BSemJDIl.js";import"./useCalendars-D7gapaJ1.js";import"./useCalendarData-BtwJetQk.js";import"./useQueries-hzIIiVUF.js";function R(){const{calendarObjectId:t}=o.useParams();return r.jsx(m,{calendarObjectId:t})}export{R as component};
|
package/assets/index-DGh1GohX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o}from"./index-BSMLcnNv.js";import{F as r}from"./FlaggedPane-Gh0sDSpK.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./useQueries-hzIIiVUF.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./MailViewChrome-WyEJa7LW.js";import"./refresh-cw-Bdx0EEOe.js";import"./wizard-selection-DxUM65kM.js";function I(){return o.jsx(r.Reading,{})}export{I as component};
|
package/assets/index-DIINe8ie.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,am as o}from"./index-BSMLcnNv.js";const n=()=>t.jsx(o,{to:"/settings/accounts"});export{n as component};
|
package/assets/index-aVEEHAqm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-BSMLcnNv.js";import{B as o}from"./BriefPane-DojIZDdy.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./search-scope-B5-OK3Cq.js";import"./MailListHeader-CP5Mrq7I.js";import"./roving-focus-JRZm8Nsl.js";import"./search-token-index-srRTXc29.js";import"./useLayoutTier-C5sdkyR7.js";import"./useQueries-hzIIiVUF.js";import"./attachment-file-BRLoj6sG.js";import"./mail-zfMejK7g.js";import"./avatar-BuUa_-Ae.js";import"./index-BsL3dqbS.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./EmptyState-BTKm9F6Q.js";import"./ErrorState-jZhKH-Aj.js";import"./download-cdI2QZPl.js";import"./calendar-event-chip-CX0GIGM0.js";import"./calendar-color-PMGOIawE.js";import"./map-pin-DHhEILKJ.js";import"./attendee-row-OHoLTo23.js";import"./clock-KUoHWkrr.js";import"./shield-check-B34-2hLP.js";import"./useFilters-BYL5dTX8.js";import"./confirm-dialog-BVXTDPyQ.js";import"./menu-D4SB6ohG.js";import"./useRefreshControl-D15eEjeE.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./useSemanticSearch-DT9Nt957.js";import"./useLabels-BTBI_l7Q.js";import"./search-query-Cr_ZXBCp.js";import"./wizard-selection-DxUM65kM.js";function N(){return r.jsx(o.Reading,{})}export{N as component};
|
package/assets/mail-DNGMGkWt.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as ee,j as s,t as F,v as se,f as I,w as te,x as M,r as u,y as P,z as ne,A as oe,C as ae,h as Q,D as re,E as ie,F as ce,G as le,X as ue,H as de,a as me,b as pe,J as he,K as fe,M as xe,N as ge,P as ve,Q as be,R as ye,u as Se,c as je,d as Ce,S as Ie,O as Ne,T as we}from"./index-BSMLcnNv.js";import{S as Me,D as Ee,a as Oe,b as Re,u as Pe,s as Te,i as ke,t as Le,K as Ae,c as De,d as Fe,e as Qe,f as Ke}from"./search-token-index-srRTXc29.js";import{u as O,a as _e}from"./useMessageBodyContent-BuyQJK-3.js";import{P as ze}from"./pencil-BSemJDIl.js";import{c as Be,s as He,M as Ve}from"./MailShell-DX1zBcaU.js";import{u as qe,a as $e,R as Ge,s as Ue,i as We,H as Ye,M as Je}from"./useRefreshControl-D15eEjeE.js";import{M as Xe}from"./menu-D4SB6ohG.js";import{B as Ze}from"./bug-C0Ms2LYI.js";import{S as es,A as ss,L as ts,M as ns}from"./MailNav-_b1NBnYa.js";import{A as os}from"./avatar-BuUa_-Ae.js";import{u as as}from"./sections-B3k1IUqe.js";import{E as rs}from"./ErrorState-jZhKH-Aj.js";import{K as T}from"./kbd-MeQzj_AS.js";import{u as is}from"./index-BsL3dqbS.js";import{u as K,i as cs}from"./useLayoutTier-C5sdkyR7.js";import{u as ls}from"./useQueries-hzIIiVUF.js";import{u as us}from"./useResultFolderIndex-DfM23jXb.js";import{u as ds}from"./useDebouncedValue--1NwWG_J.js";import"./search-scope-B5-OK3Cq.js";import"./FullCompose-AEoBq77L.js";import"./confirm-dialog-BVXTDPyQ.js";import"./circle-check-big-CVRDL2A5.js";import"./refresh-cw-Bdx0EEOe.js";import"./roving-focus-JRZm8Nsl.js";import"./outbox-status-BlKn6P0x.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./format-bkonYesy.js";const ms=ee("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);function ps({leading:e,search:t,actions:n,className:a}){return s.jsxs("header",{className:F("flex min-h-pane-header w-full shrink-0 items-center gap-2 border-b border-line bg-canvas px-row-inset py-1",a),children:[e&&s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:e}),s.jsx("div",{className:"flex min-w-0 flex-1 justify-start",children:s.jsx("div",{className:"w-full max-w-xs transition-[max-width] duration-150 ease-out focus-within:max-w-lg",children:t})}),n&&s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n})]})}function hs(){const e=se();if(!e)return null;const t=e.showNavPane?!e.navCollapsed:!1;return s.jsx(I,{variant:"ghost",size:"sm",icon:s.jsx(Xe,{className:"size-4"}),onClick:e.toggleNav,"aria-label":t?"Hide folders":"Show folders","aria-expanded":t,title:"Folders",className:"shrink-0"})}const fs={global:"Search all mail",pending:"Search mail",scoped:"Search this folder"};function xs({search:e,onCompose:t,onReportBug:n,onOpenSettings:a,composeShortcut:o,refreshControl:r,account:c}){return s.jsx(ps,{leading:s.jsx(hs,{}),search:s.jsx(Me,{value:e.value,onChange:e.onChange,onClear:e.onClear,onClearQuery:e.onClearQuery,chips:e.chips,onRemoveChip:e.onRemoveChip,placeholder:fs[e.scope]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(I,{variant:"ghost",size:"sm",icon:s.jsx(ms,{className:"size-4"}),title:o?`Compose (${o})`:"Compose","aria-label":"Compose",onClick:t}),s.jsx(I,{variant:"ghost",size:"sm",icon:s.jsx(Ze,{className:"size-4"}),title:"Report a bug","aria-label":"Report a bug",onClick:n}),s.jsx(I,{variant:"ghost",size:"sm",icon:s.jsx(es,{className:"size-4"}),title:"Settings","aria-label":"Settings",onClick:a}),r,c]})})}function gs(){const e=te(),t=M({select:l=>P(l.location.pathname)}),n=M({select:l=>ne(l.location.search)}),[a,o]=u.useState(n),r=ds(a,200),[c,d]=u.useState(t);if(c!==t){const l=He(c,t,n);d(t),l!==void 0&&o(l)}const p=u.useCallback(l=>{d(P(e.state.location.pathname)),o(l)},[e]);return{searchInput:a,committedQuery:Be(a,r),viewKey:t,setSearchInput:p}}const vs=()=>{const e=O();return oe()?null:s.jsx("button",{type:"button",onClick:e,"aria-label":"Compose new message",className:"lg:hidden fixed right-4 z-30 h-14 w-14 rounded-full bg-accent text-accent-fg shadow-lg flex items-center justify-center hover:opacity-90 active:scale-95 transition-all",style:{bottom:"calc(env(safe-area-inset-bottom, 0) + 1rem)"},children:s.jsx(ze,{className:"size-6"})})},bs=({email:e,onSignOut:t})=>{const n=e??"Account";return s.jsxs(Ee,{trigger:s.jsx(os,{name:n,email:e??void 0,size:"sm"}),align:"right",children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 py-2 text-xs text-fg-muted truncate",title:e,"data-testid":"account-menu-email",children:e}),s.jsx(Oe,{})]}),s.jsxs(Re,{onClick:t,children:[s.jsx(ts,{className:"size-4"}),"Sign out"]})]})},ys=()=>s.jsx(ss,{children:({email:e,signOut:t})=>s.jsx(bs,{email:e,onSignOut:t})});function Ss({accounts:e}){const{searchInput:t,onSearchChange:n,onSearchClear:a,onSearchClearQuery:o,resultFolderIndex:r}=ae(),c=Q(),d=as(),p=O(),{scope:l,clearScope:x}=Pe(e),f=l.kind==="scoped"?[{id:l.chip.id,label:l.chip.label,tone:"scope"}]:void 0,m=u.useMemo(()=>e.map(v=>v.accountId),[e]),{hasNewMail:i}=qe(),{state:h,errorMessage:y,refresh:g}=$e(m,{onSettled:()=>ke(c,Le(r.keys()))});return s.jsx(xs,{search:{value:t,scope:l.kind,chips:f,onChange:n,onClear:a,onClearQuery:o,onRemoveChip:x},onCompose:p,onReportBug:re,onOpenSettings:()=>d("accounts"),composeShortcut:Te("compose"),refreshControl:s.jsx(Ge,{state:h,onRefresh:g,label:"Refresh all accounts",errorMessage:y,hasUpdate:i(m)}),account:s.jsx(ys,{})})}const js=({isOpen:e,onClose:t})=>{const n=u.useRef(null);return ie({id:"shortcuts",open:e,answers:{back:t}}),ce(n,e),e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx(le,{label:"Dismiss keyboard shortcuts",onDismiss:t,className:"backdrop-blur-sm"}),s.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-label":"Keyboard shortcuts",tabIndex:-1,className:F("relative z-10 max-h-[85vh] w-full max-w-2xl overflow-y-auto","rounded-lg border border-line bg-surface shadow-lg","p-6"),children:[s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Keyboard shortcuts"}),s.jsx("button",{type:"button",onClick:t,className:"p-1 text-fg-muted transition-colors hover:text-fg","aria-label":"Close",children:s.jsx(ue,{className:"size-5"})})]}),s.jsx("div",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2",children:Ae.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"mb-3 text-sm font-medium text-fg-muted",children:a.title}),s.jsx("div",{className:"space-y-2",children:a.hints.map(o=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"text-sm",children:o.description}),s.jsx("span",{className:"flex shrink-0 items-center gap-1",children:o.keys.map((r,c)=>s.jsxs(u.Fragment,{children:[c>0&&o.keys[0]==="g"&&s.jsx("span",{className:"text-2xs text-fg-subtle",children:"then"}),s.jsx(T,{children:r})]},r))})]},`${o.action}-${o.keys.join("+")}`))})]},a.title))}),s.jsx("div",{className:"mt-6 border-t border-line pt-4",children:s.jsxs("p",{className:"text-center text-xs text-fg-muted",children:["Press ",s.jsx(T,{children:"Esc"})," to close"]})})]})]}):null};function Cs(e){const t=ls({queries:e.map(n=>({...de({path:{accountId:n.accountId}}),staleTime:1/0}))});return u.useMemo(()=>De(t.map(n=>n.data?.items??[])),[t])}const _="remit:intelligence-open";function Is(){try{return localStorage.getItem(_)!=="closed"}catch{return!0}}function Ns(e){try{localStorage.setItem(_,e?"open":"closed")}catch{}}function k({panels:e,prefersOpen:t,isDesktop:n,hasThread:a,raisedFor:o,openMessage:r}){return o!==null&&o===r?!0:e.length>0?e.includes("intelligence"):n&&a&&t}const ws=()=>{const e=K(),t=me(),n=pe(),a=t.find(he),o=Fe(),[r,c]=u.useState(Is),d=o?`${o.threadId}/${o.messageId??""}`:null,[p,l]=u.useState(null),x={panels:t,prefersOpen:r,isDesktop:e==="desktop",hasThread:o!==void 0,openMessage:d},f=k({...x,raisedFor:p}),m=k({...x,raisedFor:null}),i=u.useCallback((v,S)=>{n([...v?["intelligence"]:[],...S?[S]:[]])},[n]),h=u.useCallback(v=>{i(m,v)},[m,i]),y=u.useCallback(()=>{if(f&&!m){l(null);return}const v=!f;Ns(v),c(v),l(null),i(v,a)},[m,f,a,i]),g=u.useCallback(()=>{l(d)},[d]);return{openOverlay:a,intelligenceOpen:f,showOverlay:h,toggleIntelligence:y,raiseIntelligence:g}};var j={exports:{}},L;function Ms(){if(L)return j.exports;L=1;const e=(t,n,a)=>new Promise((o,r)=>{if(a=Object.assign({concurrency:1/0},a),typeof n!="function")throw new TypeError("Mapper function is required");const{concurrency:c}=a;if(!(typeof c=="number"&&c>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${c}\` (${typeof c})`);const d=[],p=t[Symbol.iterator]();let l=!1,x=!1,f=0,m=0;const i=()=>{if(l)return;const h=p.next(),y=m;if(m++,h.done){x=!0,f===0&&o(d);return}f++,Promise.resolve(h.value).then(g=>n(g,y)).then(g=>{d[y]=g,f--,i()},g=>{l=!0,r(g)})};for(let h=0;h<c&&(i(),!x);h++);});return j.exports=e,j.exports.default=e,j.exports}var Es=Ms();const Os=fe(Es),Rs=900*1e3,Ps=30,Ts=(e,t)=>{if(!e)return t;const n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:t},ks=30*1e3,Ls=e=>Math.max(Ts(e,Ps)*1e3,ks),z=Ls(ye().mailboxPollIntervalSeconds),C=(e=Date.now(),t=z)=>We(e)?Math.min(Ye,t):t,As=5,E=new Set,Ds=(e,t,n=Rs)=>e.filter(a=>{const o=a.lastSyncAt;return o==null?!0:t-o>n}).map(a=>a.accountId),Fs=(e,t,n=z)=>e-t>=n,Qs=(e,t)=>e.filter(n=>!t.has(n)),A=(e,t)=>{if(E.delete(e),ve(t,{softError:!0},"nobody")){be(t);return}console.warn("[remit] background mailbox sync failed",{accountId:e,error:t})},D=(e,t)=>xe({path:{accountId:e},throwOnError:!0}).then(()=>{t.invalidateQueries({queryKey:ge({path:{accountId:e}})})}),Ks=e=>{const t=Q(),n=u.useRef(e);n.current=e;const a=e.map(o=>o.accountId).join(",");u.useEffect(()=>{const o=Date.now(),c=Ds(n.current,o).filter(d=>!E.has(d));if(c.length!==0)for(const d of c)E.add(d),D(d,t).catch(p=>{A(d,p)})},[a,t]),u.useEffect(()=>{let o=Date.now(),r;const c=new Set,d=()=>{o=Date.now();const m=Qs(n.current.map(i=>i.accountId),c);for(const i of m)c.add(i);Os(m,i=>D(i,t).catch(h=>{A(i,h)}).finally(()=>{c.delete(i)}),{concurrency:As})},p=()=>{if(document.visibilityState==="visible"){d(),r=setTimeout(p,C());return}},l=()=>{if(document.visibilityState!=="visible")return;r!==void 0&&clearTimeout(r);const m=Date.now(),i=C(m);if(Fs(m,o,i)){d(),r=setTimeout(p,i);return}r=setTimeout(p,o+i-m)},x=()=>{document.visibilityState==="visible"&&(r!==void 0&&clearTimeout(r),o=Date.now(),r=setTimeout(p,C()))};r=setTimeout(p,C()),document.addEventListener("visibilitychange",l);const f=Ue(x);return()=>{r!==void 0&&clearTimeout(r),document.removeEventListener("visibilitychange",l),f()}},[a,t])};function ht(){const e=Se(),t=K(),n=cs(t),{openOverlay:a,intelligenceOpen:o,showOverlay:r,toggleIntelligence:c,raiseIntelligence:d}=ws(),p=a==="shortcuts",l=a==="nav",{searchInput:x,committedQuery:f,viewKey:m,setSearchInput:i}=gs(),{data:h,isLoading:y,isError:g,error:v,refetch:S}=je({...Ce(),staleTime:1/0}),N=!!(h&&(h.accounts?.length??0)===0);u.useEffect(()=>{N&&e({to:"/onboarding",replace:!0})},[N,e]),is({enabled:!p,bindings:[{key:"?",action:"help",handler:()=>r("shortcuts"),noModifiers:!1,preventDefault:!0}]});const R=O(),B=_e(),H=M({select:w=>we(w.matches)?.list==="mailbox"}),V=u.useMemo(()=>({compose:R}),[R]);Qe({enabled:!H&&!B,handlers:V});const q=u.useCallback(()=>{i("")},[i]),$=u.useCallback(()=>{i("")},[i]),b=h?.accounts??[],G=u.useMemo(()=>b.map(w=>w.accountId),[b]),U=Cs(b),W=us(b).index,Y=u.useMemo(()=>Ke(b),[b]);Ks(b);const J=u.useCallback(()=>{a==="nav"&&r(void 0)},[a,r]),X={accounts:b,mailboxNameIndex:U,accountNameIndex:Y,resultFolderIndex:W,searchQuery:f,searchInput:x,searchViewKey:m,onSearchChange:i,onSearchClear:q,onSearchClearQuery:$,intelligenceOpen:o,onToggleIntelligence:c,onRaiseIntelligence:d},Z={isSinglePane:n,isLoading:y||N,intelligenceOpen:o,nav:s.jsx(ns,{accounts:b,onMailboxSelect:J}),topBar:n?void 0:s.jsx(Ss,{accounts:b}),overlay:n?s.jsx(vs,{}):void 0,navOpen:l,onOpenNav:()=>r("nav"),onCloseNav:()=>r(void 0)};return s.jsx(Ie.Provider,{value:X,children:s.jsxs(Je,{accountIds:G,children:[g?s.jsx("div",{className:"flex h-full items-center justify-center bg-canvas p-4",children:s.jsx(rs,{title:"Couldn't load your account",error:v,onRetry:()=>{S()}})}):s.jsx(Ve,{chrome:Z,children:s.jsx(Ne,{})}),s.jsx(js,{isOpen:p,onClose:()=>r(void 0)})]})})}export{ht as component,ae as useMailContext};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{q as n,h as i,u as a,r as m,j as s}from"./index-BSMLcnNv.js";import{O as p}from"./OnboardingWizard-Cq8ycceQ.js";import{c}from"./onboarding-completion-Dr1hm10w.js";import"./kbd-MeQzj_AS.js";import"./credential-steps-CuyQQqOh.js";import"./card-Drp0FnU2.js";import"./account-form-helpers-DhckT_PN.js";import"./mail-zfMejK7g.js";import"./file-json-CxdRqoDn.js";function O(){const o=n(),e=i(),t=a(),r=m.useCallback(l=>{c({queryClient:e,recordCompleted:()=>o.recordEvent("onboarding.completed"),navigateToInbox:()=>{window.location.assign("/mail")}})},[o,e]);return s.jsx(p,{skipWelcome:!1,onComplete:r,onImportConfig:()=>{t({to:"/import"})}})}export{O as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as o,O as i}from"./index-BSMLcnNv.js";import{a as m}from"./MailShell-DX1zBcaU.js";import{u as p,O as t}from"./OutboxPane-CQ3uaHpb.js";import{u as s}from"./search-mirror-CD8ms6aC.js";import"./FullCompose-AEoBq77L.js";import"./ErrorState-jZhKH-Aj.js";import"./index-BsL3dqbS.js";import"./useMessageBodyContent-BuyQJK-3.js";import"./useSignature-B3bSZUlR.js";import"./account-form-helpers-DhckT_PN.js";import"./useDebouncedValue--1NwWG_J.js";import"./sections-B3k1IUqe.js";import"./format-bkonYesy.js";import"./confirm-dialog-BVXTDPyQ.js";import"./roving-focus-JRZm8Nsl.js";import"./useSearchTokenContext-BOZY3WZQ.js";import"./kbd-MeQzj_AS.js";import"./search-scope-B5-OK3Cq.js";import"./circle-check-big-CVRDL2A5.js";import"./clock-KUoHWkrr.js";import"./row-actions-BAj0uoQs.js";import"./rotate-ccw-rjesddf9.js";import"./NavMenuButton-CgziJeDD.js";import"./menu-D4SB6ohG.js";import"./outbox-status-BlKn6P0x.js";import"./search-query-Cr_ZXBCp.js";function w(){const r=p();return s({to:"/mail/outbox"}),o.jsx(t,{outboxMessageId:r,children:o.jsx(m,{phone:o.jsx(t.Phone,{}),list:o.jsx(t.List,{}),reading:o.jsx(i,{})})})}export{w as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as m,a1 as H,t as k,c8 as U,X as V,c9 as R,ca as _,cb as z,cc as G,cd as X,a8 as x,u as J,ce as Y,cf as w,cg as W,E as Z,ah as ee,ch as te,ci as ne,ab as se,H as N,ad as re,ae as oe,C as ae,cj as K}from"./index-BSMLcnNv.js";import{s as ie,S as ce}from"./search-scope-B5-OK3Cq.js";import{a as le}from"./useLayoutTier-C5sdkyR7.js";import{u as L}from"./useQueries-hzIIiVUF.js";const ue=[{action:"focusNext",keys:["j","k"],label:"navigate"},{action:"muteSender",keys:["m"],label:"mute"},{action:"help",keys:["?"],label:"all shortcuts"}];function Ee(e){return ue.filter(t=>e[t.action]!==void 0)}const fe=[{title:"Navigation",hints:[{action:"focusNext",keys:["j"],description:"Focus the message below"},{action:"focusPrevious",keys:["k"],description:"Focus the message above"},{action:"focusNext",keys:["↓"],description:"Focus the message below"},{action:"focusPrevious",keys:["↑"],description:"Focus the message above"},{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 de(e){for(const t of fe){const n=t.hints.find(s=>s.action===e);if(n)return n.keys}}function pe(e){const t=de(e);return!t||t.length===0?"":t.length===1?t[0]??"":t[0]==="g"?t.join(" then "):t.join("")}function Ke(e){const t=pe(e);return t===""?"":`(${t})`}function me({key:e,shiftKey:t=!1,repeat:n=!1,caretAtStart:s,hasValue:o,chipCount:r}){const i=r-1;return e==="Escape"?o?{type:"clearQuery"}:{type:"blur"}:e==="Tab"&&t?r===0?{type:"none"}:{type:"focusChip",index:i}:e==="Backspace"||e==="ArrowLeft"?!s||r===0?{type:"none"}:n?{type:"none"}:{type:"focusChip",index:i}:{type:"none"}}function he({key:e,repeat:t=!1,index:n,chipCount:s}){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>=s-1?{type:"focusInput"}:{type:"focusChip",index:n+1}:e==="Enter"||e===" "?{type:"activateChip",index:n}:e==="Escape"?{type:"focusInput"}:{type:"none"}}function ye(e,t){const n=t-1;return n<=0?null:e<n?e:n-1}const ge=e=>e instanceof HTMLElement?e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable:!1,be=({chips:e=[],onRemoveChip:t,value:n,onChange:s,onClear:o,onClearQuery:r,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h="sm",inputId:f,suggest:d,className:b})=>{const F=l.useId(),M=f??F,I=l.useRef(null),j=l.useRef([]),A=r??o,[D,C]=l.useState(null),v=l.useRef(void 0),[$,q]=l.useState(""),T=e.length>0;l.useEffect(()=>{C(a=>a!==null&&a>=e.length?null:a)},[e.length]),l.useEffect(()=>{const a=v.current;if(a!==void 0){if(v.current=void 0,a===null){I.current?.focus();return}j.current[a]?.focus()}});const P=l.useRef(void 0);l.useEffect(()=>{const a=d?.caret;if(!a||a===P.current)return;P.current=a;const c=I.current;!c||c.ownerDocument.activeElement!==c||(c.setSelectionRange(a.cursor,a.cursor),d?.onCaretChange(a.cursor))});const S=a=>{d?.onCaretChange(a.selectionStart??a.value.length)},y=l.useCallback(a=>{C(a),v.current=a},[]),E=l.useCallback(a=>{const c=e[a];c&&t&&(y(ye(a,e.length)),q(`${c.label} removed`),t(c.id))},[e,t,y]),O=l.useCallback(()=>{y(null),o()},[o,y]),Q=l.useCallback(a=>{const c=a.currentTarget;if(d?.onKeyDown(a))return;const g=me({key:a.key,shiftKey:a.shiftKey,repeat:a.repeat,caretAtStart:c.selectionStart===0&&c.selectionEnd===0,hasValue:n.length>0,chipCount:e.length});switch(g.type){case"focusChip":a.preventDefault(),y(g.index);return;case"clearQuery":A();return;case"blur":c.blur();return;case"none":return}},[e.length,n,A,y,d]),B=l.useCallback(a=>c=>{const g=he({key:c.key,repeat:c.repeat,index:a,chipCount:e.length});switch(g.type!=="none"&&c.preventDefault(),g.type){case"removeChip":E(g.index);return;case"focusChip":y(g.index);return;case"focusInput":y(null);return;case"activateChip":return;case"none":return}},[e,E,y]);return l.useEffect(()=>{if(!u)return;const a=c=>{c.key!=="/"||c.metaKey||c.ctrlKey||c.altKey||ge(c.target)||R("focusSearch")||(c.preventDefault(),I.current?.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[u]),m.jsxs("label",{htmlFor:M,className:k("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",b),children:[m.jsx(H,{className:k("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:[T&&m.jsx("div",{role:"grid","aria-label":"Search filters",className:"flex min-w-0 flex-wrap items-center gap-1",children:e.map((a,c)=>m.jsx(U,{ref:g=>{j.current[c]=g},label:a.label,tone:a.tone,focused:D===c,onFocusLabel:()=>C(c),onKeyDown:B(c),onRemove:()=>E(c)},a.id))}),m.jsx("input",{ref:I,id:M,name:"q",type:"text","aria-label":"Search mail",autoComplete:"off",value:n,tabIndex:D===null?0:-1,onChange:a=>{s(a.target.value),S(a.target)},onKeyDown:Q,onKeyUp:a=>S(a.currentTarget),onClick:a=>S(a.currentTarget),onFocus:a=>{C(null),d?.onFocusChange?.(!0),S(a.currentTarget)},onBlur:()=>d?.onFocusChange?.(!1),...d?.comboboxProps,placeholder:T?void 0:i,className:"min-w-24 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted"})]}),(n||T)&&p&&m.jsx("button",{type:"button",onClick:O,className:"shrink-0 rounded p-0.5 hover:bg-surface-raised transition-colors","aria-label":"Clear search",children:m.jsx(V,{className:k("text-fg-muted",h==="lg"?"size-5":"size-4")})}),m.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:$})]})},Ne=({value:e,onChange:t,onClear:n,onClearQuery:s,chips:o,onRemoveChip:r,placeholder:i="Search mail...",globalFocusKey:u=!0,showClearButton:p=!0,size:h,inputId:f,suggest:d,className:b})=>m.jsx(be,{value:e,onChange:t,onClear:n,onClearQuery:s,chips:o,onRemoveChip:r,placeholder:i,globalFocusKey:u,showClearButton:p,size:h,inputId:f,suggest:d,className:b});function Le({handlers:e,enabled:t=!0,target:n,sequenceTimeoutMs:s=1e3}){const o=l.useRef(e);o.current=e;const r=l.useRef(null),i=l.useRef(null);l.useEffect(()=>{if(!t)return;const u=()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},p=f=>{const d=_({key:f.key,shiftKey:f.shiftKey,metaKey:f.metaKey,ctrlKey:f.ctrlKey,altKey:f.altKey,inEditable:G(f.target),onControl:z(f.target)},r.current);if(X().length>0){u(),r.current=null;return}if(u(),r.current=d.nextPrefix,d.nextPrefix!==null&&(i.current=setTimeout(()=>{r.current=null,i.current=null},s)),d.action===null||R(d.action)!==null)return;const b=o.current[d.action];b&&(d.preventDefault&&f.preventDefault(),b())},h=n===void 0?window:n;if(h!==null)return h.addEventListener("keydown",p),()=>{h.removeEventListener("keydown",p),u(),r.current=null}},[t,s,n])}function Me(){const e=x({from:"/mail/brief/$threadId",shouldThrow:!1}),t=x({from:"/mail/brief/$threadId/$messageId",shouldThrow:!1}),n=x({from:"/mail/flagged/$threadId",shouldThrow:!1}),s=x({from:"/mail/flagged/$threadId/$messageId",shouldThrow:!1}),o=x({from:"/mail/$mailboxId/$threadId",shouldThrow:!1}),r=x({from:"/mail/$mailboxId/$threadId/$messageId",shouldThrow:!1}),i=e?.threadId??n?.threadId??o?.threadId,u=t?.messageId??s?.messageId??r?.messageId;return l.useMemo(()=>i?{threadId:i,messageId:u}:void 0,[i,u])}function je(){const e=J(),t=Y(),{list:n,mailboxId:s}=w();return l.useCallback((o,r)=>{const i=r?.query,p={search:f=>i===void 0?f:{...f,q:i||void 0},hash:t,replace:r?.replace??!1};if(n==="flagged"){e({to:"/mail/flagged/$threadId/$messageId",params:o,...p});return}const h=r?.mailboxId??s;if(n==="mailbox"&&h){e({to:"/mail/$mailboxId/$threadId/$messageId",params:{mailboxId:h,...o},...p});return}e({to:"/mail/brief/$threadId/$messageId",params:o,...p})},[e,t,n,s])}function Ae(){return W()}const De=({trigger:e,children:t,align:n="right"})=>{const[s,o]=l.useState(!1),r=l.useRef(null),i=l.useCallback(u=>{r.current&&!r.current.contains(u.target)&&o(!1)},[]);return Z({id:"dropdown-menu",open:s,answers:{back:()=>o(!1)}}),l.useEffect(()=>(s&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)),[s,i]),m.jsxs("div",{ref:r,className:"relative",children:[m.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),o(!s)},className:k("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}),s&&m.jsx("div",{className:k("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})]})},Pe=({onClick:e,disabled:t,destructive:n,children:s})=>m.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),t||e()},disabled:t,className:k("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:s}),Re=()=>m.jsx("div",{className:"my-1 h-px bg-line"}),xe=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages),ke=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),we=(e,t)=>e===void 0?e:xe(e)?{...e,pages:e.pages.map(n=>({...n,items:t(n.items)}))}:ke(e)?{...e,items:t(e.items)}:e,Fe=e=>{const t=[];for(const n of new Set(e))t.push(ee({path:{mailboxId:n}})),t.push(te({path:{mailboxId:n}}));return t.push(ne()),t},$e=(e,t)=>Promise.all(t.map(n=>e.cancelQueries({queryKey:n}))),qe=(e,t)=>t.flatMap(n=>e.getQueriesData({queryKey:n})).filter(n=>n[1]!==void 0).map(([n,s])=>({queryKey:n,data:s})),Oe=(e,t,n)=>{const s=o=>we(o,n);for(const o of t)e.setQueriesData({queryKey:o},s)},Qe=(e,t)=>{for(const n of t)e.setQueryData(n.queryKey,n.data)},Be=(e,t)=>{for(const n of t)e.invalidateQueries({queryKey:n})},Ie=({accounts:e})=>{const{list:t,mailboxId:n}=w(),{t:s}=se("mail",{useSuspense:!1}),o=l.useCallback((i,u)=>s(i,{defaultValue:u}),[s]),r=L({queries:e.map(i=>({...N({path:{accountId:i.accountId}}),staleTime:1/0}))});if(t==="outbox")return"Outbox";if(!n)return null;for(let i=0;i<e.length;i++){const u=r[i]?.data?.items;if(!u)continue;const p=u.find(f=>f.mailboxId===n);if(!p)continue;const h=re(e[i].folderAppointments);return oe(p,h.get(n),o)}return null},He=({accounts:e})=>{const{mailboxId:t}=w(),n=L({queries:e.map(s=>({...N({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return null;for(const s of n){const o=s.data?.items;if(!o)continue;const r=o.find(i=>i.mailboxId===t);if(r)return r.unseenCount}return null},Ue=({accounts:e})=>{const{mailboxId:t}=w(),n=L({queries:e.map(s=>({...N({path:{accountId:s.accountId}}),staleTime:1/0}))});if(!t)return 0;for(const s of n){const o=s.data?.items;if(!o)continue;const r=o.find(i=>i.mailboxId===t);if(r)return r.messageCount}return 0};function Ve(e){const t=le(),{searchInput:n}=ae(),s=Ie({accounts:e}),o=w(),r=l.useMemo(()=>ie(o,s),[o,s]),i=l.useCallback(u=>{u===ce&&t(n)},[t,n]);return{scope:r,clearScope:i}}function _e(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase(),o=s.split("@")[0];o&&!t.has(o)&&t.set(o,n.accountId),t.has(s)||t.set(s,n.accountId)}return t}function ze(e){const t=new Map;for(const n of e)for(const s of n){const o=s.fullPath?.toLowerCase();if(!o)continue;const r=K(s).toLowerCase();t.has(o)||t.set(o,s.mailboxId),t.has(r)||t.set(r,s.mailboxId)}return t}function Ge(e,t=[]){const n=e.flat().filter(r=>r.fullPath),s=new Map;for(const r of n){const i=K(r).toLowerCase();s.set(i,(s.get(i)??0)+1)}const o=new Map(t.map(r=>[r.accountId,r.email]));return n.map(r=>{const i=K(r),u=s.get(i.toLowerCase())===1,p=t.length>1?o.get(r.accountId):void 0;return{value:u?i:r.fullPath,label:r.displayNameOverride?.trim()||i,...p?{hint:p}:{}}})}function Xe(e){const t=new Map;for(const n of e){const s=n.email.toLowerCase().split("@")[0]??"";t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=n.email.split("@")[0]??n.email,o=t.get(s.toLowerCase())===1,r=n.displayName?.trim();return{value:o?s:n.email,label:r||n.email,...r?{hint:n.email}:{}}})}export{Ee as A,De as D,fe as K,Ne as S,Re as a,Pe as b,ze as c,Me as d,Le as e,_e as f,je as g,Ae as h,Be as i,Ie as j,He as k,Ue as l,ue as m,$e as n,qe as o,Oe as p,we as q,Qe as r,pe as s,Fe as t,Ve as u,xe as v,ke as w,Ke as x,Ge as y,Xe as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,t as S,u as L,r as c,aK as M,ay as O,a1 as T,aM as $,c as I,bJ as A,h as C,i as k,bK as q,bL as P,f as N,W as K,bM as R,X as G}from"./index-BSMLcnNv.js";import{K as f}from"./kbd-MeQzj_AS.js";import{S as Q,a as E}from"./settings-screen-CX00GQZz.js";import{E as V}from"./ErrorState-jZhKH-Aj.js";import{u as _}from"./useDebouncedValue--1NwWG_J.js";import{b as B}from"./format-bkonYesy.js";import{s as D}from"./help-copy-CbN-pFZa.js";import"./avatar-BuUa_-Ae.js";import"./chevron-left-BW6j5W1b.js";import"./menu-D4SB6ohG.js";import"./circle-help-Ck_g9Pip.js";function F({options:t,active:r,onSelect:m}){return e.jsx("div",{role:"tablist",className:S("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:()=>m(a.id),className:S("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:S("text-2xs tabular-nums",d?"text-accent-2":"text-fg-subtle"),children:a.count??"—"})]},a.id)})})}const v={vip:"VIPs",muted:"Muted",blocked:"Blocked"};function H({query:t,onCount:r}){const{data:m,isPending:a,isError:d,error:b}=I(A()),g=C(),i=k({...P(),onSettled:()=>{g.invalidateQueries({queryKey:q()})}}),l=m?.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(f,{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(N,{variant:"ghost",size:"sm",icon:e.jsx(K,{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 J({group:t,query:r,onCount:m}){const a=_(r.trim(),300),d=C(),[b,g]=c.useState(null),i=a.length>=2,l=R({query:{q:a,limit:50}}),{data:p,isPending:u,isError:n,error:j}=I({...l,enabled:i}),x=k({...P(),onSuccess:()=>{d.invalidateQueries({queryKey:l.queryKey})}}),h=(p?.items??[]).filter(s=>t==="muted"?s.flags?.muted?.value??!1:s.flags?.blocked?.value??!1);return c.useEffect(()=>{m?.(i?h.length:0,null)},[m,i,h.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})}):h.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:h.map(s=>{const o=t==="muted"?s.flags?.muted:s.flags?.blocked,y=o?[`${t}`,o.setAt&&B(o.setAt,{month:"short",year:"numeric"})||null,o.reason?`— ${o.reason}`:null].filter(Boolean).join(" "):t,w=x.isPending&&x.variables?.path.addressId===s.addressId,z=x.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(N,{variant:"secondary",size:"sm",onClick:()=>{g(s.addressId),x.mutate({path:{addressId:s.addressId},body:{flags:{[t]:null}}})},children:"Retry"}):e.jsx(N,{variant:"ghost",size:"sm",icon:e.jsx(G,{className:"size-3.5"}),"aria-busy":w,"aria-label":`Remove ${t} flag`,onClick:()=>{w||(g(s.addressId),x.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(f,{children:"m"})," on any message to mute its sender; ",e.jsx(f,{children:"b"})," to block."]})]})}function ie(){const t=L(),[r,m]=c.useState("vip"),[a,d]=c.useState(""),[b,g]=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]),x=p[r],h=s=>{const o=$[s];o&&t({to:o})};return e.jsx(Q,{items:M,activeId:"senders",title:"Senders & Rules",description:"Per-sender preferences — set with one key from any message, managed here.",flush:!0,help:D,helpOpen:b,onToggleHelp:()=>g(s=>!s),onSelect:h,onBackToMail:()=>{t({to:"/mail"})},children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsx(F,{active:r,onSelect:s=>{m(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(T,{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(J,{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:x!=null?`${i} of ${x} flagged senders`:`${i} flagged senders`}),e.jsxs("span",{children:[e.jsx(f,{children:"j"})," ",e.jsx(f,{children:"k"})," navigate · ",e.jsx(f,{children:"⌫"})," remove flag"]})]})]})]})})}export{ie as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,O as o}from"./index-BSMLcnNv.js";const n=()=>t.jsx(o,{});export{n as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,am as e}from"./index-BSMLcnNv.js";const o=()=>t.jsx(e,{to:"/settings/senders",replace:!0});export{o as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as E,_ as Q,t as W,f as U,r as o,aN as R,h as O,C as $,q as z,M as B,N as G,P as I,Q as X}from"./index-BSMLcnNv.js";import{C as V}from"./circle-check-big-CVRDL2A5.js";import{R as J}from"./refresh-cw-Bdx0EEOe.js";import{u as P}from"./useQueries-hzIIiVUF.js";import{i as Y,t as Z}from"./search-token-index-srRTXc29.js";function we({state:e,onRefresh:s,label:t,errorMessage:r,hasUpdate:a,size:u="sm",className:c}){const i=e==="refreshing",n=e==="error",h=e==="success",y=n?E.jsx(Q,{className:"size-4 text-danger"}):h?E.jsx(V,{className:"size-4 text-positive"}):E.jsx(J,{className:W("size-4",i&&"animate-spin")}),w=n?`${t} — failed: ${r??"try again"}`:i?`${t} — refreshing`:h?`${t} — up to date`:a?`${t} — new mail`:t;return E.jsxs("div",{className:"relative inline-flex",children:[E.jsx(U,{variant:"ghost",size:u,icon:y,onClick:s,disabled:i,"aria-label":w,"aria-busy":i||void 0,title:n?r:t,className:c}),e==="idle"&&a&&E.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-accent-2"})]})}const ee=new Set(["discovering_mailboxes","syncing_inbox","syncing_others"]);function L(e){return!!e&&ee.has(e)}const q=3e3,te=q*2,T={syncing:!1,resolved:!1,synced:0,total:0};function xe(e,s){const t=e.join(","),[r,a]=o.useState(!1),[u,c]=o.useState(!1);o.useEffect(()=>{a(!1),c(!1)},[t,s]),o.useEffect(()=>{if(!s)return;const m=setTimeout(()=>c(!0),te);return()=>clearTimeout(m)},[t,s]);const i=P({queries:e.map(m=>({...R({path:{accountId:m}}),enabled:s&&!r,refetchInterval:q,meta:{softError:!0}}))}),n=i.every(m=>m.isSuccess||m.isError),h=i.length===0||n||u;let y=!1,w=0,S=0;for(const m of i)if(L(m.data?.syncPhase)){y=!0;for(const l of m.data?.mailboxes??[])w+=l.messagesSynced,S+=l.messagesTotal}const x=s&&h&&!y;return o.useEffect(()=>{x&&a(!0)},[x]),!s||!h?T:{syncing:y,resolved:!0,synced:w,total:S}}const se=180*1e3,pe=30*1e3;let F=0;const M=new Set,ne=(e=Date.now())=>{F=e+se;for(const s of M)s()},Ee=(e=Date.now())=>e<F,be=e=>(M.add(e),()=>{M.delete(e)}),_=6e4,re=new Set(["sent","drafts","trash","archive"]),C=(e,s)=>{const t=new Map;for(const r of e){const a=s.get(r.mailboxId)?.role;a&&re.has(a)||t.set(r.mailboxId,r.messagesTotal)}return t},j=(e,s)=>{const t=[];for(const[r,a]of s)a>(e.get(r)??0)&&t.push(r);return t},oe=(e,s)=>j(e,s).length>0,D=o.createContext(null),ae=()=>{const e=o.useContext(D);if(!e)throw new Error("useMailFreshness must be used inside <MailFreshnessProvider>");return e};function Re({accountIds:e,children:s}){const t=O(),{resultFolderIndex:r}=$(),a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef(new Map),[i,n]=o.useState(new Set),h=P({queries:e.map(l=>({...R({path:{accountId:l}}),refetchInterval:_,staleTime:_,meta:{softError:!0}}))}),y=h.map(l=>l.dataUpdatedAt).join(","),w=e.join(",");o.useEffect(()=>{let l=!1;const f=new Set(i);e.forEach((d,p)=>{const b=h[p]?.data;if(!b)return;const g=C(b.mailboxes??[],r),k=c.current.get(d);if(c.current.set(d,g),k){const A=j(k,g);A.length>0&&Y(t,Z(A))}if(!u.current.has(d)){u.current.add(d),a.current.set(d,g);return}if(f.has(d))return;const K=a.current.get(d)??new Map;oe(K,g)&&(f.add(d),l=!0)}),l&&n(f)},[w,y]);const S=o.useCallback(l=>l.some(f=>i.has(f)),[i]),x=o.useCallback(l=>{n(f=>{if(l.every(p=>!f.has(p)))return f;const d=new Set(f);for(const p of l)d.delete(p);return d});for(const f of l){const d=t.getQueryData(R({path:{accountId:f}}).queryKey);a.current.set(f,C(d?.mailboxes??[],r)),u.current.add(f)}},[t,r]),m=o.useMemo(()=>({hasNewMail:S,acknowledge:x}),[S,x]);return E.jsx(D.Provider,{value:m,children:s})}const ie=2e3,ce=45e3,ue=e=>new Promise(s=>setTimeout(s,e)),v=e=>e instanceof Error&&e.message?e.message:"Something went wrong",le=e=>{I(e,{softError:!0},"user")&&X(e)},N=(e,s)=>e.fetchQuery({...R({path:{accountId:s}}),staleTime:0}),H=e=>e.mailboxes?.find(s=>s.fullPath?.toUpperCase()==="INBOX")?.lastSyncedAt??0,fe=async({accountId:e,readStatus:s,baselineLastSyncAt:t,baselineInboxSyncedAt:r=0,onInboxSynced:a,deadline:u,pollMs:c=ie})=>{let i=!1;for(;;){const n=await s().then(S=>({ok:!0,data:S})).catch(S=>({ok:!1,error:S}));if(!n.ok)return{accountId:e,message:v(n.error)};const{syncPhase:h,lastSyncAt:y}=n.data;if((y??0)>t&&!L(h))return h==="error"?{accountId:e,message:"Sync failed for this account"}:void 0;if(!i&&H(n.data)>r&&(i=!0,a?.()),Date.now()>=u)return{accountId:e,message:"Refresh is taking longer than usual"};await ue(c)}},de=async(e,s,t,r,a)=>{const u=await N(e,t).then(n=>({ok:!0,lastSyncAt:n.lastSyncAt??0,inboxSyncedAt:H(n)})).catch(n=>({ok:!1,error:n}));if(!u.ok)return{accountId:t,enqueued:!1,ok:!1,message:v(u.error)};const c=await B({path:{accountId:t},throwOnError:!0}).then(()=>({ok:!0})).catch(n=>({ok:!1,error:n}));if(!c.ok)return le(c.error),{accountId:t,enqueued:!1,ok:!1,message:v(c.error)};s.recordEvent("sync.triggered");const i=await fe({accountId:t,readStatus:()=>N(e,t),baselineLastSyncAt:u.lastSyncAt,baselineInboxSyncedAt:u.inboxSyncedAt,onInboxSynced:()=>a(t),deadline:r});return i?{accountId:t,enqueued:!0,ok:!1,message:i.message}:{accountId:t,enqueued:!0,ok:!0}},Me=(e,s={})=>{const t=O(),r=z(),{acknowledge:a}=ae(),[u,c]=o.useState("idle"),[i,n]=o.useState(),h=o.useRef(0),y=o.useRef(e);y.current=e;const w=o.useRef(s);w.current=s,o.useEffect(()=>{if(u!=="success")return;const x=setTimeout(()=>c("idle"),2e3);return()=>clearTimeout(x)},[u]);const S=o.useCallback(()=>{const x=y.current;if(x.length===0){c("error"),n("Nothing to refresh yet");return}const m=++h.current;c("refreshing"),n(void 0),ne();const l=f=>{h.current===m&&(t.invalidateQueries({queryKey:G({path:{accountId:f}})}),w.current.onSettled?.())};(async()=>{const f=Date.now()+ce,d=await Promise.all(x.map(g=>de(t,r,g,f,l)));if(h.current!==m)return;const p=d.filter(g=>g.enqueued).map(g=>g.accountId);for(const g of p)l(g);p.length>0&&a(p);const b=d.filter(g=>!g.ok);b.length===0?c("success"):(c("error"),n(b[0]?.message))})()},[a,t,r]);return{state:u,errorMessage:i,refresh:S}};export{pe as H,Re as M,we as R,Me as a,L as b,xe as c,Ee as i,be as s,ae as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as L,as as M,i as k,cz as I,d_ as E,r as v,j as p,d$ as h,e0 as A,e1 as R,C as _,cf as w,c as D,dA as j,cV as z}from"./index-BSMLcnNv.js";import{P as N}from"./attachment-file-BRLoj6sG.js";import{an as Q,ao as O}from"./MailListHeader-CP5Mrq7I.js";import{i as P,t as U}from"./search-token-index-srRTXc29.js";import{a as q}from"./useLabels-BTBI_l7Q.js";import{n as B}from"./search-query-Cr_ZXBCp.js";import{b as G}from"./search-scope-B5-OK3Cq.js";import{u as H,p as F}from"./useSearchTokenContext-BOZY3WZQ.js";const re=e=>{const t=new Set;for(const s of e)s&&t.add(s);return t.size>1?{accountId:void 0,restriction:"spansAccounts",moveDisabledHint:"Move only works within one account — clear selection or pick messages from a single account"}:{accountId:t.size===1?[...t][0]:void 0,restriction:void 0,moveDisabledHint:void 0}},V=e=>{const{mailboxId:t,messages:s}=e,n=L(),{pushError:l}=M(),{mutateAsync:c,isPending:a}=k({...E(),onError:(r,u)=>{l({title:u.body.action==="Remove"?"Couldn't remove label":"Couldn't apply label",detail:I(r),error:r})},onSettled:(r,u,d)=>{P(n,U(Q(d.body.messageIds??[],s??[],t)))}});return{applyLabel:v.useCallback((r,u,d)=>{r.length!==0&&O(r,m=>c({body:{messageIds:m,labelId:u,action:d}}))},[c]),isPending:a}};function ie({accountId:e,mailboxId:t,messageIds:s}){const{labels:n}=q(e),{applyLabel:l}=V({mailboxId:t}),c=v.useMemo(()=>n.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:()=>l(s,a.labelId,"Apply")})),[n,s,l]);return c.length===0?null:p.jsx(N,{triggerLabel:"Apply label to selected messages",triggerIcon:p.jsx(R,{className:"size-4 text-fg-subtle"}),triggerText:"Apply label",items:c,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 $=3,ce=({hasSearchQuery:e,freeText:t,residualTokenCount:s})=>{if(!e||s>0)return!1;const n=t.trim();return n.length===0||n.length>=$},le=e=>e===void 0?{kind:"unknown"}:{kind:"exact",value:e},K=20,Y=new Set(Object.values(z)),J=e=>e!==void 0&&Y.has(e)?e:void 0,W=e=>{if(e.some(t=>t.type==="isUnread"))return!1;if(e.some(t=>t.type==="isRead"))return!0};function ue({mailboxId:e,filterCategory:t}={}){const{searchQuery:s}=_(),n=H(),l=w(),c=B(s),{freeText:a,tokens:i}=F(c,n),r=a.length>0,u=i.find(o=>o.type==="category"),d=J(t)??u?.category,m=i.some(o=>o.type==="hasAttachment")?!0:void 0,f=i.some(o=>o.type==="isStarred")?!0:void 0,y=W(i),b=i.find(o=>o.type==="after"),g=i.find(o=>o.type==="before"),x=i.find(o=>o.type==="in"),S=G({browsed:l,callerMailboxId:e,inTokenMailboxId:x?.mailboxId}),{data:T,isLoading:C}=D({...j({query:{query:a,mailboxId:S,limit:K,...d!==void 0?{category:d}:{},...m!==void 0?{hasAttachment:m}:{},...f!==void 0?{hasStars:f}:{},...y!==void 0?{isRead:y}:{},...b?{sentDateFrom:b.epochSeconds}:{},...g?{sentDateTo:g.epochSeconds}:{}}}),enabled:r,staleTime:6e4});return{hits:T?.items??[],isLoading:r&&C}}export{ie as L,re as r,ce as s,le as t,ue as u};
|