@remit/web-client-dist 0.0.299 → 0.0.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/assets/{ComposeBody-B0UEQwhO.js → ComposeBody-juaUBP4S.js} +1 -1
  2. package/assets/{ConfirmDialog-BmMCdRRY.js → ConfirmDialog-ibkpk4-g.js} +1 -1
  3. package/assets/{ErrorState-aw5jVL68.js → ErrorState-fTSnQm24.js} +1 -1
  4. package/assets/{OnboardingWizard-ZIKb4R7f.js → OnboardingWizard-fxENOx3_.js} +1 -1
  5. package/assets/{account-form-helpers-DfMv3Vm9.js → account-form-helpers-tzWGkuwE.js} +1 -1
  6. package/assets/{accounts-CrTDi8os.js → accounts-DhTQAW84.js} +1 -1
  7. package/assets/{advanced-BgKEb2Uu.js → advanced-T1USmwbt.js} +1 -1
  8. package/assets/{appearance-BqTD1S6E.js → appearance-HxmtBphn.js} +1 -1
  9. package/assets/{avatar-DJyeiQWZ.js → avatar-CNVLVI-H.js} +1 -1
  10. package/assets/{browser-ponyfill-Dh60wXQI.js → browser-ponyfill-vZmAO0yp.js} +1 -1
  11. package/assets/{circle-check-D80BeTT0.js → circle-check-YlWZv9Mc.js} +1 -1
  12. package/assets/{download-CL5tLTIq.js → download-BPUwUMyv.js} +1 -1
  13. package/assets/{filters-CmAhUtr7.js → filters-DvBwrQoM.js} +1 -1
  14. package/assets/{flagged-FVOnHcGW.js → flagged-C-GEyHjm.js} +1 -1
  15. package/assets/{folders-C3nXyWs-.js → folders--i3KprM0.js} +1 -1
  16. package/assets/{index-DDXUQNXW.js → index-9nXytSEy.js} +1 -1
  17. package/assets/{index-Cn3FYNrs.js → index-VdDpazZy.js} +4 -4
  18. package/assets/index-VtPj5yVn.js +1 -0
  19. package/assets/{kbd-kS7fe5CA.js → kbd-C_D2WkrL.js} +1 -1
  20. package/assets/{labels-B5UsoCQq.js → labels-CVh5IQqs.js} +1 -1
  21. package/assets/{mail-C8lnWIJ3.js → mail-C5gYU3Wn.js} +3 -3
  22. package/assets/{move-options-afteG1Yt.js → move-options-AJw5FKbX.js} +1 -1
  23. package/assets/{onboarding-DpCrXMCi.js → onboarding-Tw77yHgF.js} +1 -1
  24. package/assets/{pencil-DZXg9Ca_.js → pencil-QGnkKuCC.js} +1 -1
  25. package/assets/{senders-DbIAqf8q.js → senders-CVxr8qGf.js} +1 -1
  26. package/assets/settings-CYzcIkDy.js +1 -0
  27. package/assets/{settings-screen-DkAiLtxH.js → settings-screen-DT-hrfDz.js} +1 -1
  28. package/assets/{shield-check-D6oCvWFI.js → shield-check-COYytpct.js} +1 -1
  29. package/assets/{suggested-vips-Dgcx59pV.js → suggested-vips-ce9dYb3K.js} +1 -1
  30. package/assets/{useDebouncedValue-DPVybDdU.js → useDebouncedValue-jZo-6AMN.js} +1 -1
  31. package/assets/{useFilters-CuXoCjbt.js → useFilters-DywOhPbr.js} +1 -1
  32. package/assets/{useLabels-Ch9GQZe_.js → useLabels-B-Dlq3rb.js} +1 -1
  33. package/assets/{useSignature-CBloimjZ.js → useSignature-CrZdaMCZ.js} +1 -1
  34. package/index.html +1 -1
  35. package/package.json +1 -1
  36. package/assets/index-DaAOT-u4.js +0 -1
  37. package/assets/settings-CvsCRNt8.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as wi,r as z,j as M,B as Ff,d0 as eu,c0 as tu,d as Af,d1 as Yg,d2 as Xg,G as Gg,a0 as nu,d3 as Zg}from"./index-Cn3FYNrs.js";import{s as Ga,U as Qg,c as ru,a as ep}from"./mail-C8lnWIJ3.js";import{C as tp}from"./ConfirmDialog-BmMCdRRY.js";import"./pencil-DZXg9Ca_.js";import"./avatar-DJyeiQWZ.js";import"./kbd-kS7fe5CA.js";import"./shield-check-D6oCvWFI.js";import"./account-form-helpers-DfMv3Vm9.js";import"./useSignature-CBloimjZ.js";import"./useDebouncedValue-DPVybDdU.js";import"./useFilters-CuXoCjbt.js";import"./ErrorState-aw5jVL68.js";import"./format-CKZmh-Ru.js";import"./move-options-afteG1Yt.js";import"./download-CL5tLTIq.js";import"./useLabels-Ch9GQZe_.js";import"./circle-check-D80BeTT0.js";const np=wi("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const rp=wi("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const ip=wi("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const op=wi("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const sp=wi("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]),ap=({language:n,languages:e,onSelect:t,helpText:r})=>{const[i,o]=z.useState(!1),s=z.useRef(null),a=z.useRef(null),l=z.useRef(null),u=z.useId(),c=z.useCallback(h=>{o(!1),h&&a.current?.focus()},[]);z.useEffect(()=>{if(!i)return;const h=g=>{s.current?.contains(g.target)||o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),z.useEffect(()=>{if(!i)return;const h=l.current?.querySelector('[aria-checked="true"]'),g=l.current?.querySelector('[role="menuitemradio"]');(h??g)?.focus()},[i]);const f=h=>{if(h.key==="Escape"){h.preventDefault(),c(!0);return}const g=[...l.current?.querySelectorAll('[role="menuitemradio"]')??[]],m=g.indexOf(document.activeElement),p=Xg(h.key,m,g.length);p!==null&&(h.preventDefault(),g[p]?.focus())},d=h=>{t(h),c(!0)};return M.jsxs("div",{ref:s,className:"relative",children:[M.jsx(Ff,{ref:a,variant:"ghost",size:"md","aria-label":`Message language: ${tu(n)}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,onClick:()=>o(h=>!h),"data-testid":"compose-language-chip","data-language":n,className:"min-h-11 min-w-11 shrink-0 px-2 font-medium",children:eu(n)}),i&&M.jsxs("div",{ref:l,id:u,role:"menu","aria-label":"Message language",onKeyDown:f,"data-testid":"compose-language-menu",className:"absolute right-0 top-full z-50 mt-1 flex max-h-[60dvh] min-w-56 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg",children:[e.map(h=>M.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h===n,lang:h,onClick:()=>d(h),className:Af("flex min-h-11 items-center justify-between gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",h===n&&"bg-accent-2-soft"),children:[tu(h),M.jsx("span",{className:"shrink-0 text-xs text-fg-subtle",children:eu(h)})]},h)),M.jsx("p",{"data-testid":"compose-language-help",className:"border-t border-line px-4 pb-1 pt-2 text-xs text-fg-muted",children:r??Yg(navigator.userAgent)})]})]})},lp=({mode:n,onToggle:e})=>M.jsx(Ff,{variant:"ghost",size:"md","aria-pressed":n==="plain",title:"Plain text",onClick:e,"data-testid":"compose-mode-toggle",className:Af("min-h-11 shrink-0",n==="plain"&&"bg-accent-2-soft text-accent-2"),children:"Plain text"});function D(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function zf(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);t.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Ve=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,up=Ve&&"documentMode"in document?document.documentMode:null,St=Ve&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),$t=Ve&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),vr=!(!Ve||!("InputEvent"in window)||up)&&"getTargetRanges"in new window.InputEvent("input"),mn=Ve&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Of=Ve&&/Android/.test(navigator.userAgent),Ti=Ve&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Of,Mf=Ve&&/^(?=.*Chrome).*/i.test(navigator.userAgent),po=Ve&&Of&&Mf,Ei=Ve&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&St&&!Mf,cp=0,fp=1,dp=2,Ys=1,Xs=2,Gs=4,Zs=8,hp=16,vs=32,Ss=64,Za=128,gp=1,pp=2,mp=3,yp=4,_p=5,bp=6,ui=Ti||mn||Ei?" ":"​",$n=`
1
+ import{a as wi,r as z,j as M,B as Ff,d0 as eu,c0 as tu,d as Af,d1 as Yg,d2 as Xg,G as Gg,a0 as nu,d3 as Zg}from"./index-VdDpazZy.js";import{s as Ga,U as Qg,c as ru,a as ep}from"./mail-C5gYU3Wn.js";import{C as tp}from"./ConfirmDialog-ibkpk4-g.js";import"./pencil-QGnkKuCC.js";import"./avatar-CNVLVI-H.js";import"./kbd-C_D2WkrL.js";import"./shield-check-COYytpct.js";import"./account-form-helpers-tzWGkuwE.js";import"./useSignature-CrZdaMCZ.js";import"./useDebouncedValue-jZo-6AMN.js";import"./useFilters-DywOhPbr.js";import"./ErrorState-fTSnQm24.js";import"./format-CKZmh-Ru.js";import"./move-options-AJw5FKbX.js";import"./download-BPUwUMyv.js";import"./useLabels-B-Dlq3rb.js";import"./circle-check-YlWZv9Mc.js";const np=wi("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const rp=wi("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const ip=wi("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const op=wi("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const sp=wi("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]),ap=({language:n,languages:e,onSelect:t,helpText:r})=>{const[i,o]=z.useState(!1),s=z.useRef(null),a=z.useRef(null),l=z.useRef(null),u=z.useId(),c=z.useCallback(h=>{o(!1),h&&a.current?.focus()},[]);z.useEffect(()=>{if(!i)return;const h=g=>{s.current?.contains(g.target)||o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),z.useEffect(()=>{if(!i)return;const h=l.current?.querySelector('[aria-checked="true"]'),g=l.current?.querySelector('[role="menuitemradio"]');(h??g)?.focus()},[i]);const f=h=>{if(h.key==="Escape"){h.preventDefault(),c(!0);return}const g=[...l.current?.querySelectorAll('[role="menuitemradio"]')??[]],m=g.indexOf(document.activeElement),p=Xg(h.key,m,g.length);p!==null&&(h.preventDefault(),g[p]?.focus())},d=h=>{t(h),c(!0)};return M.jsxs("div",{ref:s,className:"relative",children:[M.jsx(Ff,{ref:a,variant:"ghost",size:"md","aria-label":`Message language: ${tu(n)}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,onClick:()=>o(h=>!h),"data-testid":"compose-language-chip","data-language":n,className:"min-h-11 min-w-11 shrink-0 px-2 font-medium",children:eu(n)}),i&&M.jsxs("div",{ref:l,id:u,role:"menu","aria-label":"Message language",onKeyDown:f,"data-testid":"compose-language-menu",className:"absolute right-0 top-full z-50 mt-1 flex max-h-[60dvh] min-w-56 flex-col overflow-y-auto overscroll-contain rounded-md border border-line bg-surface py-1 shadow-lg",children:[e.map(h=>M.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h===n,lang:h,onClick:()=>d(h),className:Af("flex min-h-11 items-center justify-between gap-3 px-4 py-2.5 text-left text-sm text-fg transition-colors hover:bg-surface-sunken",h===n&&"bg-accent-2-soft"),children:[tu(h),M.jsx("span",{className:"shrink-0 text-xs text-fg-subtle",children:eu(h)})]},h)),M.jsx("p",{"data-testid":"compose-language-help",className:"border-t border-line px-4 pb-1 pt-2 text-xs text-fg-muted",children:r??Yg(navigator.userAgent)})]})]})},lp=({mode:n,onToggle:e})=>M.jsx(Ff,{variant:"ghost",size:"md","aria-pressed":n==="plain",title:"Plain text",onClick:e,"data-testid":"compose-mode-toggle",className:Af("min-h-11 shrink-0",n==="plain"&&"bg-accent-2-soft text-accent-2"),children:"Plain text"});function D(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function zf(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);t.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Ve=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,up=Ve&&"documentMode"in document?document.documentMode:null,St=Ve&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),$t=Ve&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),vr=!(!Ve||!("InputEvent"in window)||up)&&"getTargetRanges"in new window.InputEvent("input"),mn=Ve&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Of=Ve&&/Android/.test(navigator.userAgent),Ti=Ve&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Of,Mf=Ve&&/^(?=.*Chrome).*/i.test(navigator.userAgent),po=Ve&&Of&&Mf,Ei=Ve&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&St&&!Mf,cp=0,fp=1,dp=2,Ys=1,Xs=2,Gs=4,Zs=8,hp=16,vs=32,Ss=64,Za=128,gp=1,pp=2,mp=3,yp=4,_p=5,bp=6,ui=Ti||mn||Ei?" ":"​",$n=`
2
2
 
3
3
  `,Qa=$t?" ":ui,rn={bold:1,capitalize:1024,code:16,highlight:Za,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},kp={directionless:1,unmergeable:2},mo={center:2,end:6,justify:4,left:1,right:3,start:5},xp={[pp]:"center",[bp]:"end",[yp]:"justify",[gp]:"left",[mp]:"right",[_p]:"start"},Cp={normal:0,segmented:2,token:1},vp={[cp]:"normal",[dp]:"segmented",[fp]:"token"},iu="$config";function ou(){return Ce()._blockCursorElement}function Sp(n){return n!==null&&n.nodeType===1&&n.hasAttribute("data-lexical-slot")}let jf=class no{element;before;after;constructor(e,t,r){this.element=e,this.before=t||null,this.after=r||null}withBefore(e){return new no(this.element,e,this.after)}withAfter(e){return new no(this.element,this.before,e)}withElement(e){return this.element===e?this:new no(e,this.before,this.after)}insertChild(e){const t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&D(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&D(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&D(359),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,r){if(this.element===e)return t===e&&r===0?"before":"after";const i=su(e,this.element);if(i===null)return"after";const o=Array.prototype.indexOf.call(e.childNodes,i);if(o<0)return"after";if(t===e)return r<=o?"before":"after";const s=su(e,t);if(s===null)return"after";const a=Array.prototype.indexOf.call(e.childNodes,s);return a>=0&&a<=o?"before":"after"}getInsertionAnchor(){return this.before}};function su(n,e){let t=e;for(;t!==null&&t.parentNode!==n;)t=t.parentNode;return t}let Rf=class ro extends jf{withBefore(e){return new ro(this.element,e,this.after)}withAfter(e){return new ro(this.element,this.before,e)}withElement(e){return this.element===e?this:new ro(e,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let e=super.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;for(;Sp(t);)e=t,t=t.nextSibling;const r=e?e.nextSibling:this.element.firstChild;return r!==null&&r===ou()?r:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Ei||mn||Ti);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,r=e.nodeName==="IMG"?e.nextSibling:null;r&&t.removeChild(r),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const r=this.element,i=this.before,o=re().createElement("br");if(o.setAttribute("data-lexical-managed-linebreak","true"),r.insertBefore(o,i),e){const s=re().createElement("img");s.setAttribute("data-lexical-managed-linebreak","true"),s.style.setProperty("display","inline","important"),s.style.setProperty("border","0px","important"),s.style.setProperty("margin","0px","important"),s.alt="",r.insertBefore(s,o),r.__lexicalLineBreak=s}else r.__lexicalLineBreak=o}getFirstChildOffset(){const e=this.getFirstChild(),t=this.getInsertionAnchor();let r=0;for(let i=this.element.firstChild;i!==null&&i!==e&&i!==t;i=i.nextSibling)r++;return r}resolveChildIndex(e,t,r,i){if(r===this.element){const l=this.getFirstChildOffset(),u=ou(),c=this.element.childNodes,f=Math.min(i,c.length);let d=0;for(let h=l;h<f;h++)c[h]!==u&&d++;return[e,Math.min(d,e.getChildrenSize())]}const o=au(t,r);o.push(i);const s=au(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<s.length;l++){const u=o[l],c=s[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}};function au(n,e){const t=[];let r=e;for(;r!==n&&r!==null;r=r.parentNode){let i=0;for(let o=r.previousSibling;o!==null;o=o.previousSibling)i++;t.push(i)}return r!==n&&D(225),t.reverse()}let Pf;try{Pf="0.49.0+prod.esm"}catch{}const If=Pf??'"<unknown>+source"';let Ur=class{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(e){return delete this._cache,this._front.has(e)||this._back.add(e),this}addFront(e){return delete this._cache,this._back.has(e)||this._front.add(e),this}delete(e){return delete this._cache,this._front.delete(e)||this._back.delete(e)}toArray(){const e=Array.from(this._front).reverse();for(const t of this._back)e.push(t);return e}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};const wn=null;function Lf(n,e=1e3){return n instanceof Qs?n.clone():n.size<e?new Map(n):new Qs().init(new Map(n),void 0,n.size)}let Qs=class Bf{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new Bf().init(this._old,this._nursery,this._size)}init(e,t,r){return this._old=e,this._nursery=t,this._size=r,this}get size(){return this._size}has(e){return this.get(e)!==void 0}getWithTombstone(e){const t=this._nursery&&this._nursery.get(e);return t!==void 0?t:this._old&&this._old.get(e)}get(e){const t=this.getWithTombstone(e);return t===wn?void 0:t}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(e=!1){if(this._nursery&&this._nursery.size>0&&(e||this.shouldCompact())){const t=new Map(this._old);for(const[r,i]of this._nursery)i!==wn?t.set(r,i):t.delete(r);this._old=t,this._nursery=void 0}return this._mutable=!1,this}set(e,t){const r=this.getWithTombstone(e);if(r===t)return this;const i=this.getNursery();return r!==wn&&r!==void 0||(this._size++,r===wn&&i.delete(e)),i.set(e,t),this}delete(e){const t=this.has(e);return t&&(this.getNursery().set(e,wn),this._size--),t}getOrInsert(e,t){const r=this.get(e);return r!==void 0?r:(this.set(e,t),t)}getOrInsertComputed(e,t){const r=this.get(e);if(r!==void 0)return r;const i=t(e);return this.set(e,i),i}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(const e of this.entries())yield e[0]}*values(){for(const e of this.entries())yield e[1]}*entries(){const e=this._nursery,t=this._old;if(t)for(const r of t){const i=r[0],o=e?e.get(i):void 0;o!==wn&&(o!==void 0&&(r[1]=o),yield r)}if(e)for(const r of e)r[1]===wn||t&&t.has(r[0])||(yield r)}forEach(e,t){t!==void 0&&(e=e.bind(t));for(const[r,i]of this.entries())e(i,r,this)}get[Symbol.toStringTag](){return"GenMap"}[Symbol.iterator](){return this.entries()}};function yo(n,e,t,r,i,o){if(x(n)){let s=n.getFirstChild();for(;s!==null;){const a=s.__key;s.__parent===e&&((x(s)||tn(s)&&s.__slots!==null)&&yo(s,a,t,r,i,o),t.has(a)||o.delete(a),i.push(a)),s=s.getNextSibling()}}for(const s of tn(n)&&n.__slots!==null?n.__slots.values():[]){const a=r.get(s);a!==void 0&&In(a)&&a.__slotHost===e&&((x(a)||tn(a)&&a.__slots!==null)&&yo(a,s,t,r,i,o),t.has(s)||o.delete(s),i.push(s))}}let ea=!1,el=0;function wp(n){el=n.timeStamp}function ws(n,e,t){const r=n.nodeName==="BR",i=e.__lexicalLineBreak;return i&&(n===i||r&&n.previousSibling===i)||r&&Lr(n,t)!==void 0}function Tp(n,e,t){const r=Oe(ot(t)),i=r&&rt(r,t._rootElement);let o=null,s=null;i!==null&&i.anchorNode===n&&(o=i.anchorOffset,s=i.focusOffset);const a=n.nodeValue;a!==null&&Cl(e,a,o,s,!1)}function Ep(n,e,t){if(N(n)){const r=n.anchor.getNode();if(r.is(t)&&n.format!==r.getFormat())return!1}return it(e)&&t.isAttached()}function Np(n,e,t){for(let r=n;r&&!hh(r);r=Vn(r)){const i=Lr(r,e);if(i!==void 0){const o=ie(i,t);if(o)return Q(o)||!K(r)?void 0:[r,o]}}}function Kf(n,e,t){ea=!0;const r=performance.now()-el>100;try{yt(n,()=>{const i=A()||(function(f){return f.read("latest",()=>{const d=A();return d!==null?d.clone():null})})(n),o=new Map,s=n._editorState,a=n._blockCursorElement;let l=!1,u="";for(let f=0;f<e.length;f++){const d=e[f],h=d.type,g=d.target,m=Np(g,n,s);if(!m)continue;const[p,y]=m;if(h==="characterData")r&&$(y)&&it(g)&&Ep(i,g,y)&&Tp(g,y,n);else if(h==="childList"){l=!0;const _=d.addedNodes;for(let S=0;S<_.length;S++){const C=_[S],w=Zd(C),v=C.parentNode;if(!(v==null||C===a||w!==null||ws(C,v,n)||n._slotsUsed&&K(C)&&C.hasAttribute("data-lexical-slot")||hh(C))){if($t){const T=(K(C)?C.innerText:null)||C.nodeValue;T&&(u+=T)}v.removeChild(C)}}const b=d.removedNodes,k=b.length;if(k>0){let S=0;for(let C=0;C<k;C++){const w=b[C];(ws(w,g,n)||a===w)&&(g.appendChild(w),S++)}k!==S&&o.set(p,y)}}}if(o.size>0)for(const[f,d]of o)d.reconcileObservedMutation(f,n);const c=t.takeRecords();if(c.length>0){for(let f=0;f<c.length;f++){const d=c[f],h=d.addedNodes,g=d.target;for(let m=0;m<h.length;m++){const p=h[m],y=p.parentNode;y==null||p.nodeName!=="BR"||ws(p,g,n)||y.removeChild(p)}}t.takeRecords()}i!==null&&(l&&pe(i),$t&&ih(n)&&i.insertRawText(u))})}finally{ea=!1}}function Wf(n){const e=n._observer;e!==null&&Kf(n,e.takeRecords(),e)}function qf(n){(function(e){el===0&&ot(e).addEventListener("textInput",wp,!0)})(n),n._observer=new MutationObserver((e,t)=>{Kf(n,e,t)})}const lu="latest";let Dp=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Ap).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Ni(n,e){return new Dp(n,e)}function Di(n,e,t=lu){const r=(t===lu?n.getLatest():n).__state;return r?r.getValue(e):e.defaultValue}function hr(n,e,t){let r;if(Me(),typeof t=="function"){const o=n.getLatest(),s=Di(o,e);if(r=t(s),e.isEqual(s,r))return o}else r=t;const i=n.getWritable();return Hf(i).updateFromKnown(e,r),i}function $p(n){const e=new Map,t=new Set;for(const{ownNodeConfig:r}of Nl(typeof n=="function"?n:n.replace))if(r&&r.stateConfigs)for(const i of r.stateConfigs){let o;"stateConfig"in i?(o=i.stateConfig,i.flat&&t.add(o.key)):o=i,e.set(o.key,o)}return{flatKeys:t,sharedConfigMap:e}}const uu=new Set(["__proto__","constructor","prototype"]);let Fp=class Uf{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,r=void 0,i=new Map,o=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=r,this.knownState=i;const{sharedConfigMap:s}=this.sharedNodeState,a=o!==void 0?o:(function(l,u,c){let f=c.size;if(u)for(const d in u){const h=l.get(d);h&&c.has(h)||f++}return f})(s,r,i);this.size=a}getValue(e){const t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let r=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){const i=this.unknownState[e.key];i!==void 0&&(r=e.parse(i)),this.updateFromKnown(e,r)}return r}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const e={...this.unknownState},t={};for(const[r,i]of this.knownState)r.isEqual(i,r.defaultValue)?delete e[r.key]:e[r.key]=r.unparse(i);for(const r of this.sharedNodeState.flatKeys)r in e&&(t[r]=e[r],delete e[r]);return cu(e)&&(t.$=e),t}getWritable(e){if(this.node===e)return this;const{sharedNodeState:t,unknownState:r}=this,i=new Map(this.knownState);return new Uf(e,t,(function(o,s,a){let l;if(a)for(const[u,c]of Object.entries(a)){if(uu.has(u))continue;const f=o.get(u);f?s.has(f)||s.set(f,f.parse(c)):(l=l||{},l[u]=c)}return l})(t.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(const e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){const r=e.key;this.sharedNodeState.sharedConfigMap.set(r,e);const{knownState:i,unknownState:o}=this;i.has(e)||o&&r in o||(o&&(delete o[r],this.unknownState=cu(o)),this.size++),i.set(e,t)}updateFromUnknown(e,t){if(uu.has(e))return;const r=this.sharedNodeState.sharedConfigMap.get(e);r?this.updateFromKnown(r,r.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){const{knownState:t}=this;for(const r of t.keys())t.set(r,r.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(const[r,i]of Object.entries(e))this.updateFromUnknown(r,i)}};function Hf(n){const e=n.getWritable(),t=e.__state?e.__state.getWritable(e):new Fp(e,Jf(e));return e.__state=t,t}function Jf(n){return n.__state?n.__state.sharedNodeState:Yd(Ce(),n.getType()).sharedNodeState}function cu(n){if(n)for(const e in n)return n}function Ap(n){return n}function fu(n,e,t){for(const[r,i]of e.knownState){if(n.has(r.key))continue;n.add(r.key);const o=t?t.getValue(r):r.defaultValue;if(o!==i&&!r.isEqual(o,i))return!0}return!1}function du(n,e,t){const{unknownState:r}=e,i=t?t.unknownState:void 0;if(r){for(const[o,s]of Object.entries(r))if(!n.has(o)&&(n.add(o),s!==(i?i[o]:void 0)))return!0}return!1}function hu(n,e){const t=n.__state;return t&&t.node===n?t.getWritable(e):t}function gu(n,e){const t=n.__mode,r=n.__format,i=n.__style,o=e.__mode,s=e.__format,a=e.__style,l=n.__state,u=e.__state;return(t===null||t===o)&&(r===null||r===s)&&(i===null||i===a)&&(n.__state===null||l===u||(function(c,f){if(c===f)return!0;const d=new Set;return!(c&&fu(d,c,f)||f&&fu(d,f,c)||c&&du(d,c,f)||f&&du(d,f,c))})(l,u))}function pu(n,e){const t=n.mergeWithSibling(e),r=fe()._normalizedNodes;return r.add(n.__key),r.add(e.__key),t}function mu(n){let e,t,r=n;if(r.__text!==""||!r.isSimpleText()||r.isUnmergeable()){for(;(e=r.getPreviousSibling())!==null&&$(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(gu(e,r)){r=pu(e,r);break}break}e.remove()}for(;(t=r.getNextSibling())!==null&&$(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(gu(r,t)){r=pu(r,t);break}break}t.remove()}}else r.remove()}function Ot(n){return yu(n.anchor),yu(n.focus),n}function yu(n){for(;n.type==="element";){const e=n.getNode(),t=n.offset;let r,i;if(t===e.getChildrenSize()?(r=e.getChildAtIndex(t-1),i=!0):(r=e.getChildAtIndex(t),i=!1),$(r)){n.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!x(r))break;n.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}const ci=Symbol.for("@lexical/CachedTextSize");function _u(n,e){return na.read(()=>{let t=0,r=n;for(let i=0;i<e&&r!==null;i++){const o=wt.get(r);if(o===void 0&&D(345,r),x(o)){const s=Se.get(r);if(s!==void 0&&x(s)&&s.__parent!==o.__parent)t+=o.getTextContentSize();else{const a=On.get(r),l=a&&a.__lexicalTextContent;typeof l!="string"&&D(346,o.getType()),t+=l.length}i<e-1&&!o.isInline()&&(t+=2)}else{const s=o[ci];s===void 0&&D(347,o.getType(),r),t+=s}r=o.__next}return t},{editor:ue})}function Vf(n){x(n)||n[ci]===void 0&&(n[ci]=$(n)?n.__text.length:n.getTextContentSize())}const zp=4;let fi,ue,di,ee="",Te=null,qe=null,Ie=null;function Mt(){return{firstTextKey:Ie,format:Te,style:qe}}function ht(n){n.firstTextKey!==null&&(Te=n.format,qe=n.style,Ie=n.firstTextKey)}function ta(n){if(Ie!==null)return;const e=n.__lexicalFirstTextKey;if(e===void 0&&D(348),e===null)return;const t=Se.get(e);$(t)&&(Te=t.getFormat(),qe=t.getStyle(),Ie=e)}let Go,ri,ii,wt,na,Se,On,ra,hi,Mn,Zt=!1,_o=!1;function fn(n,e){const t=wt.get(n),r=Se.has(n);if(e!==null){const i=la(n);i.parentNode===e&&e.removeChild(i)}if(!r){if(ue._keyToDOMMap.delete(n),x(t)){const i=Ro(t,wt);ia(i,0,i.length-1,null)}if(t!==void 0){for(const i of at(t).values()){const o=sa(i);fn(i,null),o!==null&&o.remove()}vl(hi,di,Go,t,"destroyed")}}}function ia(n,e,t,r){for(let i=e;i<=t;++i){const o=n[i];o!==void 0&&fn(o,r)}}function Tn(n,e){n.setProperty("text-align",e)}const Op="40px";function Yf(n,e){const t=fi.theme.indent;if(typeof t=="string"){const r=n.classList.contains(t);e>0&&!r?n.classList.add(t):e<1&&r&&n.classList.remove(t)}n.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * var(--lexical-indent-base-value, ${Op}))`)}function Xf(n,e){const t=n.style;e===0?Tn(t,""):e===1?Tn(t,"left"):e===2?Tn(t,"center"):e===3?Tn(t,"right"):e===4?Tn(t,"justify"):e===5?Tn(t,"start"):e===6&&Tn(t,"end")}function oa(n,e){const t=(function(r){const i=r.__dir;if(i!==null)return i;if(Ne(r))return null;const o=r.getParent();return o===null||xe(o)&&o.__dir===null?"auto":null})(e);t!==null?n.dir=t:n.removeAttribute("dir")}function Gf(n){const e=re().createElement("div");return e.setAttribute("data-lexical-slot",n),e.style.display="none",e}function Zf(n,e,t){e||n.contentEditable==="false"?qm(t,ue):t.removeAttribute("contenteditable")}function bu(n,e,t){const r=ee,i=Mt();ee="";let o="";const s=Q(n);for(const[a,l]of t){const u=Gf(a);Zf(e,s,u),e.appendChild(u),ee="";const c=Mt();dn(l,xt(n,u,ue)),ht(c),Qf(n,a,e,u),o+=ee}return ht(i),ee=r,o}function at(n){return tn(n)&&n.__slots!==null?n.__slots:mh}function Qf(n,e,t,r){const i=Mn.$getSlotTargetElement(n,e,t,ue);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display="")}function sa(n){const e=On.get(n);return e!==void 0?e.parentElement:null}function ku(n,e,t){const r=at(n),i=at(e);for(const[c,f]of r)if(!i.has(c)){const d=sa(f);fn(f,null),d!==null&&d.remove()}const o=ee,s=Mt();let a="",l=null;const u=Q(e);for(const[c,f]of i){const d=r.get(c);let h=d!==void 0?sa(d):null;ee="";const g=Mt();if(h===null){h=Gf(c);let m=null;for(const p of t.children)if(!p.hasAttribute("data-lexical-slot")){m=p;break}t.insertBefore(h,m),dn(f,xt(e,h,ue))}else d===f?Gt(f,h):(d!==void 0&&fn(d,h),dn(f,xt(e,h,ue)));if(ht(g),Zf(t,u,h),Qf(e,c,t,h),a+=ee,h.parentElement===t){const m=l===null?t.firstChild:l.nextSibling;m!==h&&t.insertBefore(h,m),l=h}}return ht(s),ee=o,a}function dn(n,e){const t=Se.get(n);if(t===void 0&&D(60),e!==null){const i=wt.get(n);if(i!==void 0){const o=On.get(n);if(o!==void 0){const s=In(i)?i.__slotHost:null,a=In(t)?t.__slotHost:null,l=i.__parent!==t.__parent||s!==a,u=a!==null&&o.parentElement!==e.element;if(l||u)return e.insertChild(o),Gt(n,e.element)}}}const r=Mn.$createDOM(t,ue);if((function(i,o,s){const a=s._keyToDOMMap;Qd(o,s,i),a.set(i,o)})(n,r,ue),$(t)?r.setAttribute("data-lexical-text","true"):Q(t)&&(r.setAttribute("data-lexical-decorator","true"),Mo(r,{captureSelection:!0})),x(t)){const i=t.__indent,o=t.__size;oa(r,t),i!==0&&Yf(r,i);const s=at(t),a=s.size>0?bu(t,r,s):"";if(o===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,ee+=a,s.size>0&&(r.__lexicalSlotTextLength=a.length);else{const u=ee,c=o-1;if(aa(Ro(t,Se),t,0,c,xt(t,r,ue)),a!==""){const f=r.__lexicalTextContent||"";r.__lexicalTextContent=a+f,ee=u+a+f}s.size>0&&(r.__lexicalSlotTextLength=a.length)}const l=t.__format;l!==0&&Xf(r,l),t.isInline()||ed(null,t,r)}else{const i=t.getTextContent();if(Q(t)){const o=t.decorate(ue,fi);o!==null&&td(n,o),r.contentEditable="false";const s=at(t);s.size>0&&bu(t,r,s)}ee+=i}return e!==null&&e.insertChild(r),Mn.$decorateDOM(t,null,r,ue),Vf(t),vl(hi,di,Go,t,"created"),r}function aa(n,e,t,r,i){const o=ee,s=Mt();ee="",Te=null,qe=null,Ie=null;let a=t;for(;a<=r;++a){const u=Mt();dn(n[a],i);const c=Se.get(n[a]);c!==null&&$(c)?Te===null&&(Te=c.getFormat(),qe=c.getStyle(),Ie=c.__key):x(c)&&a<r&&!c.isInline()&&(ee+=$n),ht(u)}const l=ue._keyToDOMMap.get(e.__key);l===void 0&&D(349,e.__key),l.__lexicalTextContent=ee,l.__lexicalFirstTextKey=Ie,ee=o+ee,ht(s)}function ed(n,e,t){const r=xt(e,t,ue),i=r.element.__lexicalLastChildKind??null,o=(function(s,a){if(s){const l=s.__last;if(l){const u=a.get(l);if(u)return Pe(u)?"line-break":Q(u)&&u.isInline()?"decorator":null}return at(s).size>0?null:"empty"}return null})(e,Se);i!==o&&r.setManagedLineBreak(o)}function Mp(n,e,t){var r;Te=null,qe=null,Ie=null,(function(i,o,s){const a=ee,l=i.__size,u=o.__size;ee="";const c=s.element,f=ue._keyToDOMMap.get(o.__key);f===void 0&&D(351,o.__key);const d=u-l;if(!Zt&&Math.abs(d)<=1&&l>=zp&&i.__first===o.__first&&(d!==0||!ue._cloneNotNeeded.has(i.__key))){const h=f.__lexicalTextContent,g=ra.get(i.__key);if(!Zt&&typeof h=="string"&&g!==void 0){const m=(function(p,y){const _=y.size;if(_===0||_>=p.__size)return null;let b=p.__last,k=null,S=0;for(;b!==null&&S<_;){if(!y.has(b))return null;k=b;const C=Se.get(b);if(C===void 0)return null;b=C.__prev,S++}return S!==_||b!==null&&y.has(b)?null:k})(o,g);if(m!==null){const p=g.size;if(d===0){const y=_u(m,p);let _=m,b=0;for(;_!==null&&b<p;){const v=Se.get(_);if(v===void 0)break;const T=Mt();Gt(_,c),$(v)&&Te===null&&(Te=v.getFormat(),qe=v.getStyle(),Ie=v.__key),ht(T),_=v.__next,b++}let k="";for(_=m,b=0;_!==null&&b<p;){const v=Se.get(_);if(v===void 0)break;let T;if(x(v)){const F=ue._keyToDOMMap.get(_),E=F&&F.__lexicalTextContent;typeof E!="string"&&D(352,v.getType()),T=E}else T=v.getTextContent();k+=T,b<p-1&&x(v)&&!v.isInline()&&(k+=$n),_=v.__next,b++}const S=f.__lexicalSlotTextLength||0,C=S>0?h.slice(S):h,w=C.slice(0,C.length-y)+k;return f.__lexicalTextContent=w,ee=a+w,void xu(o,f,g)}if((function(y,_,b,k,S,C,w,v){if(v!==1&&v!==-1||w!==(v===1?2:1))return!1;const F=w-v;let E=y.__last;for(let ae=0;ae<F-1;ae++){if(E===null)return!1;const Ae=wt.get(E);if(Ae===void 0)return!1;E=Ae.__prev}if(E===null)return!1;const O=Se.get(C),R=wt.get(E);if(O===void 0||R===void 0||O.__prev!==R.__prev)return!1;const L=[];let J=C;for(let ae=0;ae<w;ae++){if(J===null)return!1;L.push(J);const Ae=Se.get(J);J=Ae?Ae.__next:null}const te=[];J=E;for(let ae=0;ae<F;ae++){if(J===null)return!1;te.push(J);const Ae=wt.get(J);J=Ae?Ae.__next:null}const X=new Set(te),Z=new Set(L),I=[];let P=0,W=0;for(;P<F&&W<w;)if(L[W]===te[P])I.push({key:L[W],kind:"reconcile"}),P++,W++;else if(Z.has(te[P])){if(X.has(L[W]))return!1;I.push({key:L[W],kind:"create",nextIndex:W}),W++}else I.push({key:te[P],kind:"destroy"}),P++;for(;P<F;)I.push({key:te[P++],kind:"destroy"});for(;W<w;)I.push({key:L[W],kind:"create",nextIndex:W}),W++;const ce=_u(E,F);for(const ae of I){const Ae=Mt();if(ae.kind==="reconcile")Gt(ae.key,b.element);else if(ae.kind==="destroy")fn(ae.key,b.element);else{let ft=null;for(let Zn=ae.nextIndex+1;Zn<w;Zn++){const qr=ue._keyToDOMMap.get(L[Zn]);if(qr!==void 0){ft=qr;break}}dn(ae.key,b.withBefore(ft??b.before))}if(ae.kind!=="destroy"){const ft=Se.get(ae.key);ft&&$(ft)&&Te===null&&(Te=ft.getFormat(),qe=ft.getStyle(),Ie=ft.__key)}ht(Ae)}let se="";for(let ae=0;ae<w;ae++){const Ae=Se.get(L[ae]);if(Ae===void 0)return!1;let ft;if(x(Ae)){const Zn=ue._keyToDOMMap.get(L[ae]),qr=Zn&&Zn.__lexicalTextContent;typeof qr!="string"&&D(350,Ae.getType()),ft=qr}else ft=Ae.getTextContent();se+=ft,ae<w-1&&x(Ae)&&!Ae.isInline()&&(se+=$n)}const Fe=k.__lexicalSlotTextLength||0,ct=Fe>0?S.slice(Fe):S;return k.__lexicalTextContent=ct.slice(0,ct.length-ce)+se,!0})(i,0,s,f,h,m,p,d)){const y=f.__lexicalTextContent;return typeof y!="string"&&D(353),ee=a+y,void xu(o,f,g)}}}if(d===0){let m=i.__first,p=0;for(;m!==null;){const y=Se.get(m);if(y===void 0)break;const _=Zt||ii.has(m)||ri.has(m),b=Mt();if(_)Gt(m,c);else{let k,S;if(x(y)){S=On.get(m);const C=S&&S.__lexicalTextContent;typeof C!="string"&&D(354,y.getType()),k=C}else k=y.getTextContent();ee+=k,S!==void 0&&ta(S)}$(y)?Te===null&&(Te=y.getFormat(),qe=y.getStyle(),Ie=y.__key):x(y)&&p<u-1&&!y.isInline()&&(ee+=$n),ht(b),m=y.__next,p++}return f.__lexicalTextContent=ee,f.__lexicalFirstTextKey=Ie,void(ee=a+ee)}}if(l===1&&u===1){const h=i.__first,g=o.__first;if(h===g)Gt(h,c);else{const p=la(h),y=dn(g,null);try{p.parentNode===c?c.replaceChild(y,p):s.insertChild(y)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${c.tagName}, new child: {tag: ${y.tagName} key: ${g}}, old child: {tag: ${p.tagName}, key: ${h}}.`;throw new Error(b)}throw _}fn(h,null)}const m=Se.get(g);$(m)&&Te===null&&(Te=m.getFormat(),qe=m.getStyle(),Ie=m.__key)}else{const h=Ro(i,wt),g=Ro(o,Se);if(h.length!==l&&D(227),g.length!==u&&D(228),l===0)u!==0&&aa(g,o,0,u-1,s);else if(u===0){if(l!==0){const m=s.after==null&&s.before==null&&at(o).size===0&&s.element.__lexicalLineBreak==null;ia(h,0,l-1,m?null:c),m&&(c.textContent="")}}else(function(m,p,y,_,b,k){const S=_-1,C=b-1;let w,v,T=k.getFirstChild(),F=0,E=0;for(;F<=S&&E<=C;){const L=p[F],J=y[E],te=Mt();if(L===J)T=Ts(Gt(J,k.element)),F++,E++;else{if(v===void 0&&(v=Cu(y,E)),w===void 0)w=Cu(p,F);else if(!w.has(L)){F++,ht(te);continue}if(!v.has(L)){T=Ts(la(L)),fn(L,k.element),F++,w.delete(L),ht(te);continue}if(w.has(J)){const Z=Dr(ue,J);Z!==T&&k.withBefore(T??k.before).insertChild(Z),T=Ts(Gt(J,k.element)),F++,E++}else dn(J,k.withBefore(T??k.before)),E++}const X=Se.get(J);X!==null&&$(X)?Te===null&&(Te=X.getFormat(),qe=X.getStyle(),Ie=X.__key):x(X)&&E<=C&&!X.isInline()&&(ee+=$n),ht(te)}const O=F>S,R=E>C;if(O&&!R){const L=y[C+1],J=L===void 0?null:ue.getElementByKey(L);aa(y,m,E,C,k.withBefore(J??k.before))}else R&&!O&&ia(p,F,S,k.element)})(o,h,g,l,u,s)}f.__lexicalTextContent=ee,f.__lexicalFirstTextKey=Ie,ee=a+ee})(n,e,xt(e,t,ue)),xe(e)||(r=e,Te==null||Te===r.__textFormat||_o||r.setTextFormat(Te),(function(i){qe==null||qe===i.__textStyle||_o||i.setTextStyle(qe)})(e))}function xu(n,e,t){const r=e.__lexicalFirstTextKey;if(r!=null){const i=n.__key;let o=r;for(;o!==null;){const s=Se.get(o);if(s===void 0){o=null;break}if(s.__parent===i)break;o=s.__parent}if(o!==null&&!t.has(o)){const s=Se.get(r);if($(s))return Te=s.getFormat(),void(qe=s.getStyle())}}e.__lexicalFirstTextKey=Ie}function Gt(n,e){const t=wt.get(n);let r=Se.get(n);t!==void 0&&r!==void 0||D(61);const i=Zt||ii.has(n)||ri.has(n),o=Dr(ue,n);if(t===r&&!i){let s;if(x(t)){const a=o.__lexicalTextContent;typeof a!="string"&&D(355,t.getType()),s=a,ta(o)}else s=t.getTextContent();return ee+=s,o}if(t!==r&&i&&vl(hi,di,Go,r,"updated"),Mn.$updateDOM(r,t,o,ue)){const s=dn(n,null);return e===null&&D(62),e.replaceChild(s,o),fn(n,null),s}if(x(t)){x(r)||D(334,n);const s=r.__indent;(Zt||s!==t.__indent)&&Yf(o,s);const a=r.__format;(Zt||a!==t.__format)&&Xf(o,a);const l=i&&(at(r).size>0||at(t).size>0)?ku(t,r,o):"";if(i){const u=ee;if(Mp(t,r,o),Ne(r)||r.isInline()||ed(0,r,o),l!==""){const c=o.__lexicalTextContent||"";o.__lexicalTextContent=l+c,ee=u+l+c,o.__lexicalSlotTextLength=l.length}else(at(r).size>0||at(t).size>0)&&(o.__lexicalSlotTextLength=0)}else{const u=o.__lexicalTextContent;typeof u!="string"&&D(356,t.getType()),ee+=u,ta(o)}if((Zt||r.__dir!==t.__dir||r.__parent!==t.__parent)&&(oa(o,r),Ne(r)&&!Zt))for(const u of r.getChildren())x(u)&&oa(Dr(ue,u.getKey()),u)}else{const s=r.getTextContent();if(Q(r)){const a=r.decorate(ue,fi);a!==null&&td(n,a),i&&(at(r).size>0||at(t).size>0)&&ku(t,r,o)}ee+=s}if(!_o&&Ne(r)){const s=r.getLatest();if(s.__cachedText!==ee){const a=s.getWritable();a.__cachedText=ee,r=a}}return Mn.$decorateDOM(r,t,o,ue),Vf(r),o}function td(n,e){let t=ue._pendingDecorators;const r=ue._decorators;if(t===null){if(r[n]===e)return;t=eh(ue)}t[n]=e}function Ts(n){let e=n.nextSibling;return e!==null&&e===ue._blockCursorElement&&(e=e.nextSibling),e}function Cu(n,e){const t=new Set;for(let r=e;r<n.length;r++)t.add(n[r]);return t}function jp(n,e,t,r,i,o){ee="",Te=null,qe=null,Ie=null,Zt=r===2,ue=t,fi=t._config,Mn=t._config.dom||$o,di=t._nodes,Go=ue._listeners.mutation,ri=i,ii=o,wt=n._nodeMap,na=n,Se=e._nodeMap,_o=e._readOnly,On=Lf(t._keyToDOMMap),ra=(function(){const a=new Map,l=u=>{for(const c of u){const f=Se.get(c);if(f===void 0)continue;const d=f.__parent;if(d===null)continue;let h=a.get(d);h===void 0&&(h=new Set,a.set(d,h)),h.add(c)}};return l(ri.keys()),l(ii),a})();const s=new Map;return hi=s,Gt("root",null),ue=void 0,di=void 0,ri=void 0,ii=void 0,wt=void 0,na=void 0,Se=void 0,fi=void 0,On=void 0,ra=void 0,hi=void 0,Mn=$o,s}function la(n){const e=On.get(n);return e===void 0&&D(75,n),e}function B(n){return{type:n}}const jt=B("SELECTION_CHANGE_COMMAND"),nd=B("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Zo=B("CLICK_COMMAND"),rd=B("BEFORE_INPUT_COMMAND"),id=B("INPUT_COMMAND"),od=B("COMPOSITION_START_COMMAND"),sd=B("COMPOSITION_END_COMMAND"),hn=B("DELETE_CHARACTER_COMMAND"),gr=B("INSERT_LINE_BREAK_COMMAND"),jn=B("INSERT_PARAGRAPH_COMMAND"),An=B("CONTROLLED_TEXT_INSERTION_COMMAND"),Pr=B("PASTE_COMMAND"),io=B("REMOVE_TEXT_COMMAND"),Sr=B("DELETE_WORD_COMMAND"),wr=B("DELETE_LINE_COMMAND"),Tt=B("FORMAT_TEXT_COMMAND"),Rp=B("SET_TEXT_FORMAT_COMMAND"),Qo=B("UNDO_COMMAND"),es=B("REDO_COMMAND"),tl=B("KEYDOWN_COMMAND"),nl=B("KEY_ARROW_RIGHT_COMMAND"),ad=B("MOVE_TO_END"),rl=B("KEY_ARROW_LEFT_COMMAND"),ld=B("MOVE_TO_START"),il=B("KEY_ARROW_UP_COMMAND"),ol=B("KEY_ARROW_DOWN_COMMAND"),bo=B("KEY_ENTER_COMMAND"),ud=B("KEY_SPACE_COMMAND"),ts=B("KEY_BACKSPACE_COMMAND"),sl=B("KEY_ESCAPE_COMMAND"),al=B("KEY_DELETE_COMMAND"),ll=B("KEY_TAB_COMMAND"),Pp=B("INSERT_TAB_COMMAND"),Ip=B("INDENT_CONTENT_COMMAND"),vu=B("OUTDENT_CONTENT_COMMAND"),cd=B("DROP_COMMAND"),fd=B("FORMAT_ELEMENT_COMMAND"),dd=B("DRAGSTART_COMMAND"),hd=B("DRAGOVER_COMMAND"),Lp=B("DRAGEND_COMMAND"),$i=B("COPY_COMMAND"),ns=B("CUT_COMMAND"),ul=B("SELECT_ALL_COMMAND"),Bp=B("CLEAR_EDITOR_COMMAND"),Kp=B("CLEAR_HISTORY_COMMAND"),Zr=B("CAN_REDO_COMMAND"),Qr=B("CAN_UNDO_COMMAND"),gd=B("FOCUS_COMMAND"),Wp=B("BLUR_COMMAND"),qp=B("KEY_MODIFIER_COMMAND");function Up(n){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(t,r){let i=e.get(t);i===void 0&&(i={dispose:n(t,r),holders:new Set},e.set(t,i));const o=()=>{const s=e.get(t);s&&s.holders.delete(o)&&s.holders.size===0&&(e.delete(t),s.dispose())};return i.holders.add(o),o}}}function oi(n,e,t,r){return n.addEventListener(e,t,r),n.removeEventListener.bind(n,e,t,r)}const Vt=Object.freeze({}),ua=[["keydown",function(n,e){const t=e._inputState;t.lastKeyDownTimeStamp=n.timeStamp,t.lastKeyCode=n.key,n.key!=="Backspace"&&gi(t),!e.isComposing()&&j(e,tl,n)}],["pointerdown",function(n,e){const t=Pn(n),r=n.pointerType;Ft(t)&&r!=="touch"&&r!=="pen"&&n.button===0&&yt(e,()=>{jo(t,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(n,e){j(e,od,n)}],["compositionend",function(n,e){const t=e._inputState;$t?t.compositionPhase="ending-firefox":mn||!Ti&&!Ei?j(e,sd,n):(t.compositionPhase="ending-safari",t.compositionEndData=n.data)}],["input",function(n,e){n.stopPropagation();const t=e._inputState;gi(t),yt(e,()=>{_d(n,e)||e.dispatchCommand(id,n)},{event:n}),t.unprocessedBeforeInputData=null}],["click",function(n,e){yt(e,()=>{const t=A(),r=Oe(ot(e)),i=lt();if(r){if(N(t)){const o=t.anchor,s=o.getNode();o.type==="element"&&o.offset===0&&t.isCollapsed()&&!Ne(s)&&me().getChildrenSize()===1&&s.getTopLevelElementOrThrow().isEmpty()&&i!==null&&t.is(i)&&(r.removeAllRanges(),t.dirty=!0)}else if(n.pointerType==="touch"||n.pointerType==="pen"){const o=rt(r,e._rootElement).anchorNode;(K(o)||it(o))&&pe(mi(i,r,e,n))}}if($t&&r!==null&&r.rangeCount===0){const o=e._rootElement;if(o!==null&&n.target===o){const s=n.clientY;let a=o.childNodes.length;for(let u=0;u<o.childNodes.length;u++){const c=o.childNodes[u];if(K(c)){const f=c.getBoundingClientRect();if(s<=(f.top+f.bottom)/2){a=u;break}}}r.setBaseAndExtent(o,a,o,a);const l=mi(i,r,e,n);l!==null?pe(l):r.removeAllRanges()}}j(e,Zo,n)})}],["cut",Vt],["copy",Vt],["dragstart",Vt],["dragover",Vt],["dragend",Vt],["paste",Vt],["focus",Vt],["blur",Vt],["drop",Vt]];vr&&ua.push(["beforeinput",(n,e)=>(function(t,r){const i=t.inputType;i==="deleteCompositionText"||$t&&ih(r)||i!=="insertCompositionText"&&yt(r,()=>{_d(t,r)||j(r,rd,t)},{event:t})})(n,e)]);const ca=new WeakMap,ko=new WeakMap,Hp=Up(n=>(n.addEventListener("selectionchange",Nu),()=>n.removeEventListener("selectionchange",Nu)));function pd(n,e,t,r,i,o){const s=n.anchor,a=n.focus,l=s.getNode(),u=fe();let c;if(o!==void 0)c=o;else{const m=Oe(ot(u));c=m!==null?rt(m,u._rootElement):null}const f=c!==null?c.anchorNode:null,d=s.key,h=u.getElementByKey(d),g=t.length;return d!==a.key||!$(l)||(!i&&(!vr||u._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||l.isDirty()&&g<2||th(t))&&s.offset!==a.offset&&!l.isComposing()||_t(l)||l.isDirty()&&g>1||(i||!vr)&&h!==null&&!l.isComposing()&&f!==pn(l,h,u)||c!==null&&e!==null&&(!e.collapsed||e.startContainer!==c.anchorNode||e.startOffset!==c.anchorOffset)||!l.isComposing()&&(l.getFormat()!==n.format||l.getStyle()!==n.style)||(function(m,p){if(p.isSegmented())return!0;if(!m.isCollapsed())return!1;const y=m.anchor.offset,_=p.getParentOrThrow(),b=Fo(p);return y===0?!p.canInsertTextBefore()||!_.canInsertTextBefore()&&!p.isComposing()||b||(function(k){const S=k.getPreviousSibling();return($(S)||x(S)&&S.isInline())&&!S.canInsertTextAfter()})(p):y===p.getTextContentSize()&&(!p.canInsertTextAfter()||!_.canInsertTextAfter()&&!p.isComposing()||b)})(n,l)}function Su(n,e){return it(n)&&n.nodeValue!==null&&e!==0&&e!==n.nodeValue.length}function wu(n,e,t){const{anchorNode:r,anchorOffset:i,focusNode:o,focusOffset:s}=rt(n,e._rootElement),a=e._inputState;a.isSelectionChangeFromDOMUpdate&&(a.isSelectionChangeFromDOMUpdate=!1,Su(r,i)&&Su(o,s)&&!a.postDeleteSelectionToRestore)||yt(e,()=>{if(!t)return void pe(null);if(!zi(e,r,o))return;let l=A();if(a.postDeleteSelectionToRestore&&N(l)&&l.isCollapsed()){const u=l.anchor,c=a.postDeleteSelectionToRestore.anchor;(u.key===c.key&&u.offset===c.offset+1||u.offset===1&&c.getNode().is(u.getNode().getPreviousSibling()))&&(l=a.postDeleteSelectionToRestore.clone(),pe(l))}if(a.postDeleteSelectionToRestore=null,N(l)){const u=l.anchor,c=u.getNode();if(l.isCollapsed()){n.type==="Range"&&r===o&&(l.dirty=!0);const f=ot(e).event,d=f?f.timeStamp:performance.now(),{format:h,style:g,offset:m,key:p,timeStamp:y}=a.collapsedSelectionFormat,_=me(),b=e.isComposing()===!1&&_.getTextContent()==="";if(d<y+200&&u.offset===m&&u.key===p)oo(l,h,g);else if(u.type==="text")$(c)||D(141),md(l,c);else if(u.type==="element"&&!b){x(c)||D(259);const k=u.getNode();k.isEmpty()?(function(S,C){const w=C.getTextFormat(),v=C.getTextStyle();oo(S,w,v)})(l,k):oo(l,l.format,"")}}else{const f=u.key,d=l.focus.key,h=l.getNodes(),g=h.length,m=l.isBackward(),p=m?s:i,y=m?i:s,_=m?d:f,b=m?f:d;let k=2047,S=!1;for(let C=0;C<g;C++){const w=h[C],v=w.getTextContentSize();if($(w)&&v!==0&&!(C===0&&w.__key===_&&p===v||C===g-1&&w.__key===b&&y===0)&&(S=!0,k&=w.getFormat(),k===0))break}l.format=S?k:0}}j(e,jt)})}function oo(n,e,t){n.format===e&&n.style===t||(n.format=e,n.style=t,n.dirty=!0)}function md(n,e){oo(n,e.getFormat(),e.getStyle())}function yd(n){if(!n.getTargetRanges)return null;const e=n.getTargetRanges();return e.length===0?null:e[0]}function Tu(n){const{lastKeyCode:e}=fe()._inputState;if(n==null||n.length<=1||e==null)return;const t=e.length===1?e:e==="Enter"?`
4
4
  `:e==="Tab"?" ":null;if(!t)return;const r=A();if(!N(r)||!r.isCollapsed())return;const i=r.anchor.getNode();if(!$(i))return;const{offset:o}=r.anchor;if(i.getTextContentSize()===o){const s=i.getNextSibling();if(t===`
@@ -1 +1 @@
1
- import{r as s,j as t,at as o}from"./index-Cn3FYNrs.js";const g=({isOpen:n,title:i,description:l,confirmLabel:d,cancelLabel:u="Cancel",destructive:m=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=s.useRef(null),a=s.useCallback(e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),r())},[r]);return s.useEffect(()=>{if(n)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[n,a]),s.useEffect(()=>{if(!n)return;const e=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{e?.isConnected&&e.focus()}},[n]),n?t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm","aria-hidden":"true",onClick:r}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),t.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[t.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:u}),t.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",m?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{g as C};
1
+ import{r as s,j as t,at as o}from"./index-VdDpazZy.js";const g=({isOpen:n,title:i,description:l,confirmLabel:d,cancelLabel:u="Cancel",destructive:m=!1,isBusy:f=!1,onConfirm:x,onCancel:r})=>{const c=s.useRef(null),a=s.useCallback(e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),r())},[r]);return s.useEffect(()=>{if(n)return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[n,a]),s.useEffect(()=>{if(!n)return;const e=document.activeElement instanceof HTMLElement?document.activeElement:null;return c.current?.focus(),()=>{e?.isConnected&&e.focus()}},[n]),n?t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-canvas/80 backdrop-blur-sm","aria-hidden":"true",onClick:r}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:o("relative z-10 w-full max-w-sm","bg-surface border border-line rounded-sm shadow-lg","p-6"),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-lg font-semibold",children:i}),l&&t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:l}),t.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[t.jsx("button",{ref:c,type:"button",onClick:r,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors","border border-line hover:bg-surface-raised"),children:u}),t.jsx("button",{type:"button",onClick:x,disabled:f,className:o("min-h-11 inline-flex items-center justify-center px-4 rounded text-sm font-medium transition-colors",m?"bg-danger text-canvas hover:bg-danger/90":"bg-accent text-accent-fg hover:bg-accent-hover","disabled:opacity-50 disabled:cursor-not-allowed"),children:d})]})]})]}):null};export{g as C};
@@ -1 +1 @@
1
- import{j as t,g as r}from"./index-Cn3FYNrs.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
1
+ import{j as t,g as r}from"./index-VdDpazZy.js";const d=e=>e instanceof Error?e.message:typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:"An unexpected error occurred",l=({title:e="Couldn't load content",error:a,onRetry:s,variant:i="block"})=>{const n=d(a);return i==="inline"?t.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",children:[t.jsx(r,{className:"size-4 shrink-0 text-danger mt-0.5","aria-hidden":"true"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-fg-muted mt-0.5 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"shrink-0 text-sm font-medium text-accent hover:underline",children:"Retry"})]}):t.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center gap-3 p-8 text-center",children:[t.jsx(r,{className:"size-8 text-danger","aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-danger",children:e}),t.jsx("p",{className:"text-sm text-fg-muted mt-1 break-words",children:n})]}),s&&t.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center rounded-md border border-line bg-canvas px-4 py-2 text-sm font-medium hover:bg-surface-raised transition-colors",children:"Retry"})]})};export{l as E,d as f};
@@ -1 +1 @@
1
- import{a as re,j as e,d as z,c6 as V,l as oe,r as i,e as he,cl as I,c7 as F,ab as xe,aJ as X,b_ as fe,c5 as ye,aG as Q,av as Y,aR as ne,B as C,L as D,c4 as ge,c8 as ve,G as q,cg as be,q as je}from"./index-Cn3FYNrs.js";import{K as Se}from"./kbd-kS7fe5CA.js";import{c as we,M as ke}from"./account-form-helpers-DfMv3Vm9.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function $e({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function De({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=Q(ne()),w=X({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx(D,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(D,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=X({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Qe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=X({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),$=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=Q({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(D,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(D,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx($e,{onStart:h});case"connector":return e.jsx(De,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Qe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
1
+ import{a as re,j as e,d as z,c6 as V,l as oe,r as i,e as he,cl as I,c7 as F,ab as xe,aJ as X,b_ as fe,c5 as ye,aG as Q,av as Y,aR as ne,B as C,L as D,c4 as ge,c8 as ve,G as q,cg as be,q as je}from"./index-VdDpazZy.js";import{K as Se}from"./kbd-C_D2WkrL.js";import{c as we,M as ke}from"./account-form-helpers-tzWGkuwE.js";const K=re("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);const Ce=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Ne({url:t}){return e.jsxs("p",{className:"text-2xs text-fg-subtle",children:["Stored encrypted, used only to connect to your mail server."," ",t?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"How to create an app password"}):e.jsx("span",{children:"Check your provider's help for app password instructions."})]})}function Ee({raised:t,className:o,...s}){return e.jsx("div",{className:z("rounded-sm border border-line bg-surface",t?"bg-surface-raised shadow-sm":"",o),...s})}function J({value:t,defaultValue:o,onValueChange:s,...a}){return s?e.jsxs(V,{value:t,onChange:n=>s(n.target.value),...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]}):e.jsxs(V,{defaultValue:o??t,...a,children:[e.jsx("option",{value:"tls",children:"TLS/SSL"}),e.jsx("option",{value:"starttls",children:"STARTTLS"}),e.jsx("option",{value:"none",children:"None (insecure)"})]})}function G(t){return{tls:t==="tls",startTls:t==="starttls"}}function Te({steps:t,activeStep:o}){return e.jsx("ol",{className:"flex items-center gap-1",children:t.map((s,a)=>{const n=a<o,r=a===o;return e.jsxs("li",{className:"flex items-center gap-1",children:[a>0&&e.jsx("span",{className:"h-px w-5 bg-line","aria-hidden":!0}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:z("flex size-5 items-center justify-center rounded-full text-2xs font-semibold tabular-nums",n&&"bg-accent text-accent-fg",r&&"bg-accent-soft text-accent ring-1 ring-accent",!n&&!r&&"bg-surface-sunken text-fg-subtle"),children:n?e.jsx(oe,{className:"size-3"}):a+1}),e.jsx("span",{className:z("hidden text-2xs sm:inline",r?"font-medium text-fg":"text-fg-subtle"),children:s})]})]},s)})})}function L({steps:t,activeStep:o,title:s,subtitle:a,children:n,footer:r,hideSteps:u}){return e.jsxs("div",{className:"flex min-h-dvh w-full flex-col items-center overflow-y-auto bg-canvas pb-[max(2rem,env(safe-area-inset-bottom,0px))] pl-[max(2rem,env(safe-area-inset-left,0px))] pr-[max(2rem,env(safe-area-inset-right,0px))] pt-[max(2rem,env(safe-area-inset-top,0px))] font-sans text-fg sm:pt-[30vh]",children:[!u&&e.jsx("div",{className:"mb-5 w-full max-w-xl",children:e.jsx(Te,{steps:t,activeStep:o})}),e.jsxs(Ee,{raised:!0,className:"w-full max-w-xl",children:[e.jsxs("div",{className:"px-5 pt-5",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s}),a&&e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:a})]}),e.jsx("div",{className:"px-5 py-5",children:n}),r&&e.jsx("div",{className:"flex items-center justify-between gap-3 border-t border-line px-5 py-3",children:r})]})]})}const Pe="Coming soon — use IMAP for now.";function W({name:t,description:o,icon:s,comingSoon:a,selected:n,onSelect:r}){const[u,h]=i.useState(!1),c=()=>{if(r){r();return}a&&h(!0)};return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c,"aria-disabled":a||void 0,className:z("flex flex-col items-start gap-2 rounded-sm border p-3 text-left transition-colors",n?"border-accent-2 bg-accent-2-soft":"border-line bg-surface hover:border-line-strong",a&&"opacity-55"),children:[e.jsx("span",{className:z("text-fg-muted",n&&"text-accent-2"),children:s}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:t}),a&&e.jsx("span",{className:"rounded-full bg-surface-sunken px-1.5 py-0.5 text-2xs text-fg-subtle",children:"soon"})]}),e.jsx("span",{className:"text-xs text-fg-subtle",children:o})]}),u&&e.jsx("p",{className:"text-2xs text-fg-subtle",children:Pe})]})}function Z({legend:t,badge:o,host:s,port:a,security:n,readOnly:r,onHostChange:u,onPortChange:h,onSecurityChange:c,hostPlaceholder:v,portPlaceholder:j}){const S=i.useId(),y=i.useId(),w=i.useId();return e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"flex items-center gap-2 text-sm font-semibold text-fg",children:[t,o&&e.jsx(he,{tone:o.tone,children:o.label})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_6rem_8rem] sm:gap-2",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:S,children:"Host"}),u?e.jsx(F,{id:S,readOnly:r,value:s,onChange:x=>u(x.target.value),placeholder:v}):e.jsx(F,{id:S,readOnly:r,defaultValue:s,placeholder:v})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:y,children:"Port"}),h?e.jsx(F,{id:y,readOnly:r,value:a,onChange:x=>h(x.target.value),placeholder:j}):e.jsx(F,{id:y,readOnly:r,defaultValue:a,placeholder:j})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:w,children:"Security"}),c?e.jsx(J,{id:w,value:n,onValueChange:c}):e.jsx(J,{id:w,defaultValue:n})]})]})]})}function _({label:t,detail:o,state:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsxs("span",{className:z("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full text-2xs",s==="ok"&&"bg-positive text-accent-fg",s==="failed"&&"bg-danger text-accent-fg",s==="running"&&"border border-accent text-accent",s==="pending"&&"border border-line text-fg-subtle"),children:[s==="ok"&&e.jsx(oe,{className:"size-3"}),s==="failed"&&"!",s==="running"&&e.jsx("span",{className:"size-2 animate-pulse rounded-full bg-accent"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:z("text-sm",s==="failed"?"font-medium text-danger":"text-fg"),children:t}),o&&e.jsx("div",{className:"mt-0.5 text-xs text-fg-subtle",children:o})]})]})}const Ae=(t,o)=>{const s=i.useRef(o);s.current=o,i.useEffect(()=>{if(!t)return;const a=()=>{document.visibilityState==="visible"&&s.current()};return document.addEventListener("visibilitychange",a),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("pageshow",a)}},[t])},Ie={"gmail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"googlemail.com":{imap:{host:"imap.gmail.com",port:993,security:"tls"},smtp:{host:"smtp.gmail.com",port:587,security:"starttls"},source:"provider-table"},"outlook.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"hotmail.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"live.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"msn.com":{imap:{host:"outlook.office365.com",port:993,security:"tls"},smtp:{host:"smtp.office365.com",port:587,security:"starttls"},source:"provider-table"},"icloud.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"me.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"mac.com":{imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},source:"provider-table"},"fastmail.com":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"fastmail.fm":{imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},source:"provider-table"},"yahoo.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"yahoo.co.uk":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"ymail.com":{imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},source:"provider-table"},"aol.com":{imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},source:"provider-table"},"zoho.com":{imap:{host:"imap.zoho.com",port:993,security:"tls"},smtp:{host:"smtp.zoho.com",port:465,security:"tls"},source:"provider-table"},"gmx.com":{imap:{host:"imap.gmx.com",port:993,security:"tls"},smtp:{host:"smtp.gmx.com",port:587,security:"starttls"},source:"provider-table"},"gmx.net":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"gmx.de":{imap:{host:"imap.gmx.net",port:993,security:"tls"},smtp:{host:"mail.gmx.net",port:587,security:"starttls"},source:"provider-table"},"web.de":{imap:{host:"imap.web.de",port:993,security:"tls"},smtp:{host:"smtp.web.de",port:587,security:"starttls"},source:"provider-table"},"mail.com":{imap:{host:"imap.mail.com",port:993,security:"tls"},smtp:{host:"smtp.mail.com",port:465,security:"tls"},source:"provider-table"},"hey.com":{imap:{host:"imap.hey.com",port:993,security:"tls"},smtp:{host:"smtp.hey.com",port:465,security:"tls"},source:"provider-table"},"tutanota.com":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"tuta.io":{imap:{host:"mail.tutanota.com",port:993,security:"tls"},smtp:{host:"mail.tutanota.com",port:465,security:"tls"},source:"provider-table"},"posteo.de":{imap:{host:"posteo.de",port:993,security:"tls"},smtp:{host:"posteo.de",port:465,security:"tls"},source:"provider-table"},"runbox.com":{imap:{host:"imap.runbox.com",port:993,security:"tls"},smtp:{host:"smtp.runbox.com",port:587,security:"starttls"},source:"provider-table"},"mailbox.org":{imap:{host:"imap.mailbox.org",port:993,security:"tls"},smtp:{host:"smtp.mailbox.org",port:465,security:"tls"},source:"provider-table"},"hushmail.com":{imap:{host:"imap.hushmail.com",port:993,security:"tls"},smtp:{host:"smtp.hushmail.com",port:465,security:"tls"},source:"provider-table"}},Le={"gmail.com":"https://support.google.com/accounts/answer/185833","googlemail.com":"https://support.google.com/accounts/answer/185833","yahoo.com":"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html","icloud.com":"https://support.apple.com/en-us/102654","me.com":"https://support.apple.com/en-us/102654","mac.com":"https://support.apple.com/en-us/102654","fastmail.com":"https://www.fastmail.help/hc/en-us/articles/360058752854","fastmail.fm":"https://www.fastmail.help/hc/en-us/articles/360058752854","outlook.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","hotmail.com":"https://support.microsoft.com/en-us/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9","zoho.com":"https://help.zoho.com/portal/en/kb/zoho-mail/client-configuration/imap-access/articles/zoho-mail-app-passwords"};function ae(t){try{const s=new DOMParser().parseFromString(t,"application/xml");if(s.querySelector("parsererror"))return null;const a=s.querySelectorAll("incomingServer[type='imap']"),n=s.querySelectorAll("outgoingServer[type='smtp']");if(!a.length||!n.length)return null;const r=a[0],u=n[0],h=r.querySelector("hostname")?.textContent?.trim(),c=r.querySelector("port")?.textContent?.trim(),v=r.querySelector("socketType")?.textContent?.trim().toUpperCase(),j=u.querySelector("hostname")?.textContent?.trim(),S=u.querySelector("port")?.textContent?.trim(),y=u.querySelector("socketType")?.textContent?.trim().toUpperCase();if(!h||!c||!j||!S)return null;const w=x=>x==="SSL"||x==="TLS"||x==="SSL/TLS"?"tls":x==="STARTTLS"?"starttls":"none";return{imap:{host:h,port:Number.parseInt(c,10),security:w(v)},smtp:{host:j,port:Number.parseInt(S,10),security:w(y)},source:"mozilla-autoconfig"}}catch{return null}}async function Me(t,o){try{const s=`https://autoconfig.thunderbird.net/v1.1/${t}`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r||null}catch{return null}}async function Fe(t,o){try{const s=`https://autoconfig.${t}/mail/config-v1.1.xml`,a=await fetch(s,{signal:o});if(!a.ok)return null;const n=await a.text(),r=ae(n);return r?{...r,source:"domain-autoconfig"}:null}catch{return null}}function Re(t){return{imap:{host:`imap.${t}`,port:993,security:"tls"},smtp:{host:`smtp.${t}`,port:587,security:"starttls"},source:"heuristic"}}async function Oe(t,o=1500){const s=t.indexOf("@");if(s===-1)return null;const a=t.slice(s+1).toLowerCase();if(!a)return null;const n=Ie[a];if(n)return n;const r=new AbortController,u=setTimeout(()=>r.abort(),o);try{const h=await Me(a,r.signal);if(h)return h;const c=await Fe(a,r.signal);if(c)return c}finally{clearTimeout(u)}return Re(a)}function ze(t){const o=t.indexOf("@");return o===-1?"Looking up server settings…":`Looking up settings for ${t.slice(o+1)}…`}function ie(t){const o=t.indexOf("@");if(o===-1)return;const s=t.slice(o+1).toLowerCase();return Le[s]}const ce=[{id:"icloud",label:"iCloud",username:"full-email",imap:{host:"imap.mail.me.com",port:993,security:"tls"},smtp:{host:"smtp.mail.me.com",port:587,security:"starttls"},passwordHelp:{text:"iCloud requires an app-specific password, not your Apple ID password. Generate one under Sign-In & Security → App-Specific Passwords.",url:"https://support.apple.com/en-us/102654"}},{id:"yahoo",label:"Yahoo",username:"full-email",imap:{host:"imap.mail.yahoo.com",port:993,security:"tls"},smtp:{host:"smtp.mail.yahoo.com",port:465,security:"tls"},passwordHelp:{text:"Yahoo requires an app password, not your login password. Generate one under Account Security.",url:"https://help.yahoo.com/kb/generate-manage-third-party-passwords-sln15241.html"}},{id:"aol",label:"AOL",username:"full-email",imap:{host:"imap.aol.com",port:993,security:"tls"},smtp:{host:"smtp.aol.com",port:465,security:"tls"},passwordHelp:{text:"AOL requires an app password, not your login password. Generate one under Account Security.",url:"https://login.aol.com/account/security"}},{id:"fastmail",label:"Fastmail",username:"full-email",imap:{host:"imap.fastmail.com",port:993,security:"tls"},smtp:{host:"smtp.fastmail.com",port:465,security:"tls"},passwordHelp:{text:"Fastmail requires an app password, not your login password. Create one under Settings → Privacy & Security → App passwords.",url:"https://www.fastmail.help/hc/en-us/articles/360058752854"}}];function ee(t){return ce.find(o=>o.id===t)}const _e={"icloud.com":"icloud","me.com":"icloud","mac.com":"icloud","yahoo.com":"yahoo","yahoo.co.uk":"yahoo","ymail.com":"yahoo","aol.com":"aol","fastmail.com":"fastmail","fastmail.fm":"fastmail"};function He(t){const o=t.indexOf("@");if(o===-1)return"";const s=t.slice(o+1).toLowerCase();return _e[s]??""}const M=["Connector","Address","Servers","Credentials","Test","Sync"],R={connector:0,address:1,servers:2,credentials:3,test:4,sync:5},te={host:"",port:993,security:"tls"},se={host:"",port:587,security:"starttls"};function $e({onStart:t}){return i.useEffect(()=>{const o=s=>{s.key==="Enter"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),e.jsx(L,{steps:M,activeStep:0,hideSteps:!0,title:"Welcome to Remit",subtitle:"One inbox for all your mail, with context about every message.",footer:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-2xs text-fg-subtle",children:[e.jsx(Se,{children:"Enter"})," to continue"]}),e.jsx(C,{variant:"primary",onClick:t,children:"Add your first account"})]}),children:e.jsxs("div",{className:"flex flex-col items-start py-5",children:[e.jsx("span",{className:"flex size-14 items-center justify-center rounded-md bg-accent-soft",children:e.jsx(ke,{className:"size-7 text-accent"})}),e.jsx("p",{className:"mt-5 max-w-sm text-sm leading-relaxed text-fg-muted",children:"Remit syncs your existing mailboxes and tells you who is really writing to you — sender history, authenticity checks, and similar messages, right next to every email."})]})})}function De({onContinue:t,onMicrosoft:o,onBack:s,showBack:a}){const[n,r]=i.useState("imap");i.useEffect(()=>{const h=c=>{c.key==="Enter"&&(n==="microsoft"?o():t()),c.key==="Escape"&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,o,s,n]);const u=()=>{n==="microsoft"?o():t()};return e.jsx(L,{steps:M,activeStep:R.connector,title:"How does this account connect?",subtitle:"Choose a sign-in method. IMAP works with any provider.",footer:e.jsxs(e.Fragment,{children:[a?e.jsx(C,{variant:"ghost",onClick:s,children:"Back"}):e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:u,children:n==="microsoft"?"Continue with Microsoft":"Continue with IMAP"})]}),children:e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[e.jsx(W,{name:"IMAP / SMTP",description:"Any mail provider — Fastmail, iCloud, your own server.",icon:e.jsx(Ce,{className:"size-5"}),selected:n==="imap",onSelect:()=>r("imap")}),e.jsx(W,{name:"Gmail",description:"Sign in with Google. No app passwords.",icon:e.jsx(K,{className:"size-5"}),comingSoon:!0}),e.jsx(W,{name:"Outlook / Microsoft 365",description:"Sign in with Microsoft. Works with Outlook.com and work accounts.",icon:e.jsx(je,{className:"size-5"}),selected:n==="microsoft",onSelect:()=>r("microsoft")})]})})}function qe({onBack:t,onConnected:o}){const[s,a]=i.useState(""),[n,r]=i.useState(null),[u,h]=i.useState(!1),[c,v]=i.useState(!1),j=i.useRef(!0);i.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const S=i.useRef(new Set),{refetch:y}=Q(ne()),w=X({...be(),onSuccess:p=>{j.current&&(h(!0),window.location.assign(p.authorizationUrl))},onError:p=>{v(!1),r(p instanceof Error?p.message:"Failed to start sign-in")}});Ae(u,i.useCallback(()=>{v(!1),y().then(({data:p,isError:m})=>{if(!j.current)return;if(m||!p){r("Couldn't check whether the sign-in finished. Open Settings › Accounts to see whether the account is connected.");return}r(null);const N=p.accounts.find(b=>!S.current.has(b.accountId));N&&o(N.accountId)})},[y,o]));const x=c||w.isPending,f=()=>{x||(r(null),v(!0),y().then(({data:p,isError:m})=>{if(j.current){if(m||!p){v(!1),r("Couldn't read this instance's accounts, so sign-in can't be tracked. Check your connection and try again.");return}S.current=new Set(p.accounts.map(N=>N.accountId)),w.mutate({body:{email:s.trim()||void 0}})}}))},l=i.useRef(f);return l.current=f,i.useEffect(()=>{const p=m=>{m.key==="Enter"&&l.current(),m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e.jsx(L,{steps:M,activeStep:R.connector,title:"Sign in with Microsoft",subtitle:"You'll be redirected to Microsoft to sign in securely.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,disabled:x,icon:x?e.jsx(D,{className:"size-4 animate-spin"}):void 0,children:x?"Redirecting…":u?"Start over":"Sign in with Microsoft"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"microsoft-email",children:"Email address (optional)"}),e.jsx(F,{id:"microsoft-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@outlook.com",value:s,onChange:p=>a(p.target.value),type:"email",autoComplete:"email"}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"Pre-fills the Microsoft sign-in form. Leave blank to choose on the Microsoft page."})]}),u&&e.jsx(q,{tone:"info",children:"Waiting for Microsoft. Finish signing in — this window carries on the moment the account is connected, wherever you finished."}),n&&e.jsx(q,{tone:"danger",children:n})]})})}function Ge({initialEmail:t,initialDisplayName:o,onContinue:s,onBack:a}){const[n,r]=i.useState(t),[u,h]=i.useState(o),[c,v]=i.useState(!1),[j,S]=i.useState(""),[y,w]=i.useState(null),x=i.useCallback(async()=>{const f=n.trim();if(!f.includes("@")||!f.includes(".")){w("Enter a valid email address.");return}w(null),v(!0),S(ze(f));try{const l=await Oe(f);s(f,u.trim(),l)}finally{v(!1)}},[n,u,s]);return i.useEffect(()=>{const f=l=>{l.key==="Enter"&&!c&&x(),l.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[x,c,a]),e.jsx(L,{steps:M,activeStep:R.address,title:"What's the email address?",subtitle:"We'll detect the server settings for you.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:a,children:"Back"}),e.jsx(C,{variant:"primary",disabled:c,onClick:()=>{x()},children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-email",children:"Email address"}),e.jsx(F,{id:"onboarding-email",icon:e.jsx(K,{className:"size-4"}),placeholder:"you@example.com",value:n,onChange:f=>{r(f.target.value),w(null)},type:"email",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"onboarding-display-name",children:"Display name (optional)"}),e.jsx(F,{id:"onboarding-display-name",placeholder:"Alice",value:u,onChange:f=>h(f.target.value)}),e.jsx("p",{className:"mt-1.5 text-2xs text-fg-subtle",children:"What to call this account in Remit. Leave blank to use a name derived from the address."})]}),c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-fg-muted",children:[e.jsx(D,{className:"size-3.5 animate-spin text-accent"}),j]}),y&&!c&&e.jsx("div",{className:"mt-3",children:e.jsx(q,{tone:"danger",children:y})})]})})}function Be({email:t,imapConfig:o,smtpConfig:s,discovered:a,onContinue:n,onBack:r,onChange:u}){const[h,c]=i.useState(o),[v,j]=i.useState(s),[S,y]=i.useState(()=>He(t)),[w,x]=i.useState(!1),[f,l]=i.useState(null),p=ee(S),m=p!==void 0&&!w,N=i.useCallback(g=>{y(g),x(!1),l(null);const d=ee(g);d&&(c({host:d.imap.host,port:d.imap.port,security:d.imap.security}),j({host:d.smtp.host,port:d.smtp.port,security:d.smtp.security}))},[]);i.useEffect(()=>{u(h,v)},[h,v,u]);const b=h.host.trim()!=="",k=i.useCallback(()=>{if(!b){l("Enter the IMAP host.");return}l(null),n()},[b,n]);i.useEffect(()=>{const g=d=>{d.key==="Enter"&&k(),d.key==="Escape"&&r()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[k,r]);const T=t.split("@")[1]??"your domain",O=p?"Pick your provider to fill in the right settings — or choose Custom to enter them by hand.":a?"Found via autodiscovery — adjust anything that looks off.":`We couldn't detect settings for ${T} — enter them manually.`,P=m?{label:"preset",tone:"neutral"}:!p&&a?{label:"detected",tone:"positive"}:void 0,A=p?.passwordHelp.url??ie(t);return e.jsx(L,{steps:M,activeStep:R.servers,title:"Confirm server settings",subtitle:O,footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:r,children:"Back"}),e.jsx(C,{variant:"primary",onClick:k,children:"Continue"})]}),children:e.jsxs("div",{className:"space-y-5",children:[f&&e.jsx(q,{tone:"danger",children:f}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"provider-select",children:"Provider"}),e.jsxs(V,{id:"provider-select",value:S,onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"",children:"Custom / other"}),ce.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))]}),p&&e.jsx("p",{className:"mt-1 text-2xs text-fg-subtle",children:m?e.jsxs(e.Fragment,{children:["Server settings are pre-filled for ",p.label," and locked."," ",e.jsx("button",{type:"button",className:"text-accent underline",onClick:()=>x(!0),children:"Advanced"})," ","lets you edit them by hand."]}):e.jsxs(e.Fragment,{children:["Editing ",p.label,"'s settings by hand."]})})]}),e.jsx(Z,{legend:"IMAP — incoming",badge:P,readOnly:m,host:h.host,port:String(h.port),security:h.security,hostPlaceholder:"imap.example.com",portPlaceholder:"993",onHostChange:g=>{c(d=>({...d,host:g})),l(null)},onPortChange:g=>c(d=>({...d,port:Number(g)})),onSecurityChange:g=>c(d=>({...d,security:g}))}),e.jsx("p",{className:"text-2xs text-fg-subtle",children:"Sending (SMTP) is optional — leave it blank to set up a receive-only account and add sending later in Settings."}),e.jsx(Z,{legend:"SMTP — outgoing (optional)",badge:P,readOnly:m,host:v.host,port:String(v.port),security:v.security,hostPlaceholder:"smtp.example.com",portPlaceholder:"587",onHostChange:g=>{j(d=>({...d,host:g})),l(null)},onPortChange:g=>j(d=>({...d,port:Number(g)})),onSecurityChange:g=>j(d=>({...d,security:g}))}),p&&e.jsxs("p",{className:"text-2xs text-fg-subtle",children:[p.passwordHelp.text," ",A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"Get an app password"})]})]})})}function Ue({email:t,username:o,password:s,onContinue:a,onBack:n,onChange:r}){const[u,h]=i.useState(o||t),[c,v]=i.useState(s),[j,S]=i.useState(null),y=t.split("@")[1]??"",w=ie(t),x=u.trim()!==""&&c.trim()!=="";i.useEffect(()=>{r(u,c)},[u,c,r]);const f=i.useCallback(()=>{if(!x){S("Enter your username and password.");return}S(null),a()},[x,a]);return i.useEffect(()=>{const l=p=>{p.key==="Enter"&&f(),p.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[f,n]),e.jsx(L,{steps:M,activeStep:R.credentials,title:`Sign in to ${y||"your mail server"}`,subtitle:"Many providers require an app password instead of your normal one.",footer:e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:n,children:"Back"}),e.jsx(C,{variant:"primary",onClick:f,children:"Test connection"})]}),children:e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("div",{className:"rounded-md bg-danger-soft px-3 py-2 text-sm text-danger",children:j}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-username",children:"Username"}),e.jsx(F,{id:"credentials-username",value:u,onChange:l=>{h(l.target.value),S(null)},autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"credentials-password",children:"Password or app password"}),e.jsx(ve,{id:"credentials-password",value:c,onChange:l=>{v(l.target.value),S(null)},autoComplete:"current-password"})]}),e.jsx(Ne,{url:w})]})})}function We({email:t,imapConfig:o,smtpConfig:s,username:a,password:n,onSuccess:r,onBackToCredentials:u,onBackToServers:h}){const[c,v]=i.useState({imapState:"running",smtpState:"pending",phase:"running"}),[j,S]=i.useState(0),y=s.host.trim()!=="",w=G(o.security),x=G(s.security),f=X({...ge()});i.useEffect(()=>{let m=!1;const N=[];return v({imapState:"running",smtpState:"pending",phase:"running"}),f.mutate({body:{username:a,password:n,imapHost:o.host,imapPort:o.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:s.host,smtpPort:s.port,smtpTls:x.tls,smtpStartTls:x.startTls}},{onSuccess:b=>{if(m)return;const k=b.imapSuccess,T=y?b.smtpSuccess:!0;v({imapState:k?"ok":"failed",smtpState:y?"running":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,phase:"running"}),N.push(window.setTimeout(()=>{if(m)return;const O=A=>{const g=A?.toLowerCase()??"";return g.includes("auth")||g.includes("login")||g.includes("535")||g.includes("credential")},P=!k&&O(b.imapError)||k&&y&&!b.smtpSuccess&&O(b.smtpError);v({imapState:k?"ok":"failed",smtpState:y?b.smtpSuccess?"ok":"failed":"ok",imapDetail:k?`Connected — ${o.host}:${o.port}`:b.imapError,smtpDetail:y?b.smtpSuccess?`Connected — ${s.host}:${s.port}`:b.smtpError:"Not set up — receive-only",rawError:k?y&&!b.smtpSuccess?b.smtpError:void 0:b.imapError,phase:k&&T?"success":P?"auth-failure":"network-failure"}),k&&T&&N.push(window.setTimeout(()=>{m||r()},800))},400))},onError:b=>{if(m)return;const k=b instanceof Error?b.message:"Connection failed";v({imapState:"failed",smtpState:"failed",imapDetail:k,smtpDetail:k,rawError:k,phase:"network-failure"})}}),()=>{m=!0;for(const b of N)window.clearTimeout(b)}},[j]);const{phase:l}=c;i.useEffect(()=>{const m=N=>{N.key==="Escape"&&(l==="auth-failure"?u():l==="network-failure"&&h())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l,u,h]);const p=l==="auth-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:u,children:"Back to credentials"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="network-failure"?e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"ghost",onClick:h,children:"Back to servers"}),e.jsx(C,{variant:"primary",onClick:()=>S(m=>m+1),children:"Retry"})]}):l==="success"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Connection verified"}),e.jsx(C,{variant:"primary",onClick:r,children:"Start syncing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Testing…"}),e.jsx("span",{})]});return e.jsx(L,{steps:M,activeStep:R.test,title:"Testing the connection",subtitle:`Checking ${t}`,footer:p,children:e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:`IMAP — ${o.host}:${o.port}`,detail:c.imapDetail,state:c.imapState}),e.jsx(_,{label:y?`SMTP — ${s.host}:${s.port}`:"SMTP — sending",detail:y?c.smtpDetail:"Not set up — you can add sending later in Settings",state:c.smtpState}),(l==="auth-failure"||l==="network-failure")&&c.rawError&&e.jsxs("div",{className:"py-3",children:[l==="auth-failure"&&e.jsx("p",{className:"mb-2 text-xs text-fg-muted",children:"Check your password — many providers require an app password."}),e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:c.rawError})]})]})})}const Ve=2e4;function Qe({email:t,displayName:o,imapConfig:s,smtpConfig:a,username:n,password:r,onGoToInbox:u}){const h=xe(),[c,v]=i.useState(null),[j,S]=i.useState(null),y=i.useRef(!1),w=G(s.security),x=G(a.security),f=X({...ye(),onSuccess:E=>{v(E.accountId),h.invalidateQueries({queryKey:fe()})},onError:E=>{S(E instanceof Error?E.message:"Failed to create account")}});i.useEffect(()=>{if(y.current)return;y.current=!0;const E=a.host.trim()!=="",H=we({imapHost:s.host,smtpHost:a.host,smtpPort:a.port}),$=E?H??{smtpHost:a.host,smtpPort:a.port,smtpTls:x.tls,smtpStartTls:x.startTls}:null;f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:$?.smtpHost||void 0,smtpPort:$?.smtpPort||void 0,smtpTls:$?.smtpTls??!1,smtpStartTls:$?.smtpStartTls??!1}})},[]);const{data:l,isError:p}=Q({...Y({path:{accountId:c??""}}),enabled:!!c,refetchInterval:E=>{const H=E.state.data?.syncPhase;return H==="complete"||H==="error"?!1:2e3}}),m=l?.syncPhase==="error",{data:N}=Q({...ne(),enabled:!!c&&m}),b=N?.accounts.find(E=>E.accountId===c)?.lastError,k=l?.mailboxes.find(E=>E.fullPath==="INBOX"||E.fullPath==="Inbox"),T=l?.mailboxCountTotal??0,O=l?.mailboxCountSynced??0,P=k?.messagesTotal??0,A=k?.messagesSynced??0,g=P>0?A/P:0,d=l?.syncPhase,le=m?"failed":d==="idle"||d===void 0||d==="discovering_mailboxes"?"running":T>0?"ok":"running",B=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"?"pending":d==="syncing_inbox"||d==="syncing_others"?"running":"ok",U=m?"failed":!d||d==="idle"||d==="discovering_mailboxes"||d==="syncing_inbox"?"pending":d==="syncing_others"?"running":"ok",me=A>0||k?.phase==="complete"||d==="complete"||m,[ue,de]=i.useState(!1);i.useEffect(()=>{if(!c)return;const E=setTimeout(()=>de(!0),Ve);return()=>clearTimeout(E)},[c]);const pe=!!c&&(me||p||ue);return j?e.jsx(L,{steps:M,activeStep:R.sync,title:"Couldn't create account",subtitle:"Something went wrong saving your account.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx(C,{variant:"primary",onClick:()=>{y.current=!1,S(null),f.mutate({body:{email:t,displayName:o||void 0,username:n!==t?n:void 0,password:r,imapHost:s.host,imapPort:s.port,imapTls:w.tls,imapStartTls:w.startTls,smtpHost:a.host||void 0,smtpPort:a.port||void 0,smtpTls:x.tls,smtpStartTls:x.startTls}})},children:"Retry"})]}),children:e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:j})}):e.jsx(L,{steps:M,activeStep:R.sync,title:`Syncing ${t}`,subtitle:"Newest mail first — you can start reading right away.",footer:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xs text-fg-subtle",children:"Sync continues in the background"}),pe?e.jsx(C,{variant:"primary",onClick:()=>c&&u(c),children:"Go to inbox"}):e.jsx(C,{variant:"primary",disabled:!0,icon:e.jsx(D,{className:"size-3.5 animate-spin"}),children:"Getting your mail…"})]}),children:f.isPending?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-muted",children:[e.jsx(D,{className:"size-4 animate-spin text-accent"}),"Creating your account…"]}):e.jsxs("div",{className:"space-y-3",children:[P>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[e.jsx("span",{className:"font-medium text-fg",children:"INBOX"}),e.jsxs("span",{className:"text-fg-subtle tabular-nums",children:[A.toLocaleString()," / ",P.toLocaleString()," ","messages"]})]}),e.jsx("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-surface-sunken",children:e.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500",style:{width:`${Math.max(2,g*100)}%`}})})]}),e.jsxs("div",{className:"divide-y divide-line",children:[e.jsx(_,{label:"Mailboxes discovered",detail:T>0?`${T} mailbox${T===1?"":"es"} found`:"Discovering…",state:le}),e.jsx(_,{label:"INBOX",detail:B==="ok"?`${A.toLocaleString()} messages synced`:B==="running"?"Syncing newest first…":"Queued",state:B}),O>1||d==="syncing_others"||d==="complete"?e.jsx(_,{label:"Other mailboxes",detail:U==="ok"?`${O-1} mailboxes synced`:U==="running"?"Syncing…":"Queued",state:U}):null]}),m&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-xs text-danger",children:["Sync stalled. The account is still active —"," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>{h.invalidateQueries({queryKey:Y({path:{accountId:c??""}}).queryKey})},children:"retry"})]}),b&&e.jsx("code",{className:"block rounded bg-surface-sunken px-2.5 py-2 text-2xs text-fg-muted",children:b})]})]})})}function Je({skipWelcome:t=!1,onComplete:o,onCancel:s}){const[a,n]=i.useState(t?"connector":"welcome"),[r,u]=i.useState({email:"",displayName:"",imapConfig:te,smtpConfig:se,username:"",password:"",discoveryResult:null,discovered:!1,createdAccountId:null}),h=i.useCallback(()=>n("connector"),[]),c=i.useCallback(()=>n("address"),[]),v=i.useCallback(()=>n("microsoft-email"),[]),j=i.useCallback(()=>{t?s?.():n("welcome")},[t,s]),S=i.useCallback((l,p,m)=>{let N=te,b=se,k=!1;m&&(k=m.source!=="heuristic",N={host:m.imap.host,port:m.imap.port,security:m.imap.security},b={host:m.smtp.host,port:m.smtp.port,security:m.smtp.security}),u(T=>({...T,email:l,displayName:p,imapConfig:N,smtpConfig:b,discoveryResult:m,discovered:k,username:l})),n("servers")},[]),y=i.useCallback((l,p)=>{u(m=>({...m,imapConfig:l,smtpConfig:p}))},[]),w=i.useCallback((l,p)=>{u(m=>({...m,username:l,password:p}))},[]),x=i.useCallback(()=>n("sync"),[]),f=i.useCallback(l=>{o(l)},[o]);switch(a){case"welcome":return e.jsx($e,{onStart:h});case"connector":return e.jsx(De,{onContinue:c,onMicrosoft:v,onBack:j,showBack:!t});case"microsoft-email":return e.jsx(qe,{onBack:()=>n("connector"),onConnected:f});case"address":return e.jsx(Ge,{initialEmail:r.email,initialDisplayName:r.displayName,onContinue:S,onBack:()=>n("connector")});case"servers":return e.jsx(Be,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,discovered:r.discovered,onContinue:()=>n("credentials"),onBack:()=>n("address"),onChange:y});case"credentials":return e.jsx(Ue,{email:r.email,username:r.username,password:r.password,onContinue:()=>n("test"),onBack:()=>n("servers"),onChange:w});case"test":return e.jsx(We,{email:r.email,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onSuccess:x,onBackToCredentials:()=>n("credentials"),onBackToServers:()=>n("servers")});case"sync":return e.jsx(Qe,{email:r.email,displayName:r.displayName,imapConfig:r.imapConfig,smtpConfig:r.smtpConfig,username:r.username,password:r.password,onGoToInbox:f})}}export{Je as O,ce as P,ee as g,G as s,Ae as u};
@@ -1 +1 @@
1
- import{a as s}from"./index-Cn3FYNrs.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,d as a,l as b,a as c,c as d};
1
+ import{a as s}from"./index-VdDpazZy.js";const u=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),o=587,i=!1,e=!0,c=t=>t.replace(/^imap\./i,"smtp."),a=t=>{if((t.smtpHost?.trim()??"").length>0)return null;const n=t.imapHost.trim();return n.length===0?null:{smtpHost:c(n),smtpPort:o,smtpTls:i,smtpStartTls:e}},m=t=>{const r=t?.toLowerCase()??"";return r.includes("auth")||r.includes("login")||r.includes("535")||r.includes("credential")},l=(t,r)=>!t||!r||!m(t)?t:`${t} — ${r}`,d=t=>t.smtpEnabled!==!0;export{u as M,d as a,l as b,a as c,c as d};