"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3545],{1506:(e,t,r)=>{r.d(t,{W:()=>a,o:()=>l});let a=(0,r(1934).v)(e=>({toasts:[],addToast:t=>{let r=crypto.randomUUID(),a={...t,id:r,duration:t.duration??5e3};e(e=>({toasts:[...e.toasts,a]}))},removeToast:t=>{e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))},clearToasts:()=>{e({toasts:[]})}}));function o(e,t,r,o){let l="string"==typeof r?{message:r}:r;a.getState().addToast({type:e,title:t,message:l?.message,action:l?.action,duration:l?.duration??o})}let l={success:(e,t)=>o("success",e,t),error:(e,t)=>o("error",e,t,1e4),info:(e,t)=>o("info",e,t),warning:(e,t)=>o("warning",e,t)}},9385:(e,t,r)=>{r.d(t,{$:()=>o,v:()=>l});var a=r(12115);let o=(0,a.createContext)(null);function l(){return(0,a.useContext)(o)}},10977:(e,t,r)=>{r.d(t,{TourProvider:()=>A,M:()=>C});var a=r(95155),o=r(12115),l=r(40091),n=r(555),i=r(64223),s=r(1934),c=r(51342),u=r(10541);class d{async request(e,t,r){let a={"X-WebDAV-Method":e,"X-WebDAV-Path":t,...(0,c.A)(),...r?.headers};return(0,u.nr)(this.proxyUrl,{method:"POST",headers:a,body:r?.body})}async checkSupport(){try{let e=await this.request("PROPFIND","/",{headers:{Depth:"0","Content-Type":"application/xml; charset=utf-8"},body:`<?xml version="1.0" encoding="utf-8"?>
<D:propfind xmlns:D="DAV:">
  <D:prop>
    <D:resourcetype/>
  </D:prop>
</D:propfind>`});return 207===e.status}catch{return!1}}async list(e="/"){let t=await this.request("PROPFIND",e,{headers:{Depth:"1","Content-Type":"application/xml; charset=utf-8"},body:`<?xml version="1.0" encoding="utf-8"?>
<D:propfind xmlns:D="DAV:">
  <D:prop>
    <D:resourcetype/>
    <D:getcontenttype/>
    <D:getcontentlength/>
    <D:getlastmodified/>
    <D:getetag/>
    <D:displayname/>
  </D:prop>
</D:propfind>`});if(207!==t.status)throw Error(`PROPFIND failed: ${t.status} ${t.statusText}`);let r=await t.text(),a=t.headers.get("X-WebDAV-Request-URI")||"";return this.parseMultistatus(r,a)}async createDirectory(e){let t=await this.request("MKCOL",e);if(201!==t.status&&204!==t.status)throw Error(`MKCOL failed: ${t.status} ${t.statusText}`)}async uploadFile(e,t,r,a,o){if(a)return new Promise((l,n)=>{let i=new XMLHttpRequest;i.open("POST",(0,u.hd)(this.proxyUrl)),i.setRequestHeader("X-WebDAV-Method","PUT"),i.setRequestHeader("X-WebDAV-Path",e);let s=(0,c.A)();s["X-JMAP-Cookie-Slot"]&&i.setRequestHeader("X-JMAP-Cookie-Slot",s["X-JMAP-Cookie-Slot"]),i.setRequestHeader("Content-Type",r||(t instanceof File?t.type:"application/octet-stream")),o&&o.addEventListener("abort",()=>{i.abort(),n(new DOMException("Upload aborted","AbortError"))}),i.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded,e.total)},i.onload=()=>{200===i.status||201===i.status||204===i.status?l():n(Error(`PUT failed: ${i.status} ${i.statusText}`))},i.onerror=()=>n(Error("Upload failed")),i.send(t)});let l=await this.request("PUT",e,{headers:{"Content-Type":r||(t instanceof File?t.type:"application/octet-stream")},body:t});if(201!==l.status&&204!==l.status&&200!==l.status)throw Error(`PUT failed: ${l.status} ${l.statusText}`)}async downloadFile(e){let t=await this.request("GET",e);if(!t.ok)throw Error(`GET failed: ${t.status} ${t.statusText}`);let r=await t.blob();return{blob:r,contentType:t.headers.get("Content-Type")||"application/octet-stream",filename:e.split("/").pop()||"download"}}async delete(e){let t=await this.request("DELETE",e);if(204!==t.status&&200!==t.status)throw Error(`DELETE failed: ${t.status} ${t.statusText}`)}async move(e,t){let r=await this.request("MOVE",e,{headers:{"X-WebDAV-Destination":t,Overwrite:"F"}});if(201!==r.status&&204!==r.status)throw Error(`MOVE failed: ${r.status} ${r.statusText}`)}async copy(e,t){let r=await this.request("COPY",e,{headers:{"X-WebDAV-Destination":t,Overwrite:"F"}});if(201!==r.status&&204!==r.status)throw Error(`COPY failed: ${r.status} ${r.statusText}`)}parseMultistatus(e,t){let r=new DOMParser().parseFromString(e,"application/xml").getElementsByTagNameNS("DAV:","response"),a=[],o=t.replace(/\/+$/,"");for(let e=0;e<r.length;e++){let t=r[e],l=t.getElementsByTagNameNS("DAV:","href")[0];if(!l?.textContent)continue;let n=decodeURIComponent(l.textContent),i=n.replace(/\/+$/,"");if(this.isSameResource(i,o))continue;let s=t.getElementsByTagNameNS("DAV:","propstat")[0];if(!s)continue;let c=s.getElementsByTagNameNS("DAV:","status")[0];if(c?.textContent&&!c.textContent.includes("200"))continue;let u=s.getElementsByTagNameNS("DAV:","prop")[0];if(!u)continue;let d=u.getElementsByTagNameNS("DAV:","resourcetype")[0],p=!!d?.getElementsByTagNameNS("DAV:","collection")[0],m=u.getElementsByTagNameNS("DAV:","displayname")[0]?.textContent||"",h=u.getElementsByTagNameNS("DAV:","getcontenttype")[0]?.textContent||"",f=u.getElementsByTagNameNS("DAV:","getcontentlength")[0]?.textContent||"0",g=u.getElementsByTagNameNS("DAV:","getlastmodified")[0]?.textContent||"",y=u.getElementsByTagNameNS("DAV:","getetag")[0]?.textContent||"",w=n.replace(/\/+$/,"").split("/"),b=m||w[w.length-1]||"";a.push({href:n,name:b,isDirectory:p,contentType:p?"":h,contentLength:parseInt(f,10)||0,lastModified:g,etag:y})}return a.sort((e,t)=>e.isDirectory!==t.isDirectory?e.isDirectory?-1:1:e.name.localeCompare(t.name)),a}isSameResource(e,t){try{let r=new URL(e,"http://dummy").pathname.replace(/\/+$/,""),a=new URL(t,"http://dummy").pathname.replace(/\/+$/,"");return r===a}catch{return e===t}}constructor(){this.proxyUrl="/api/webdav"}}let p=(0,s.v)((e,t)=>({currentPath:"/",resources:[],isLoading:!1,error:null,supportsWebDAV:null,selectedResources:new Set,uploadProgress:null,webdavClient:null,clipboard:null,uploadAbortController:null,lastAction:null,favorites:(()=>{try{return JSON.parse(localStorage.getItem("webdav-favorites")||"[]")}catch{return[]}})(),recentFiles:(()=>{try{return JSON.parse(localStorage.getItem("webdav-recent-files")||"[]")}catch{return[]}})(),initClient:()=>{e({webdavClient:new d})},checkSupport:async()=>{let{webdavClient:r}=t();if(!r)return!1;try{let t=await r.checkSupport();return e({supportsWebDAV:t}),t}catch{return e({supportsWebDAV:!1}),!1}},navigate:async r=>{let{webdavClient:a}=t();if(a){e({isLoading:!0,error:null,currentPath:r,selectedResources:new Set});try{localStorage.setItem("webdav-last-path",r)}catch{}try{let t=await a.list(r);e({resources:t,isLoading:!1})}catch(t){e({error:t instanceof Error?t.message:"Failed to list directory",isLoading:!1,resources:[]})}}},refresh:async()=>{let{currentPath:e,navigate:r}=t();await r(e)},createDirectory:async e=>{let{webdavClient:r,currentPath:a,refresh:o}=t();if(!r)return;let l="/"===a?`/${e}`:`${a}/${e}`;await r.createDirectory(l),await o()},uploadFile:async r=>{let{webdavClient:a,currentPath:o}=t();if(!a)return;let l=new AbortController;e({uploadAbortController:l});let n="/"===o?`/${r.name}`:`${o}/${r.name}`;e({uploadProgress:{name:r.name,loaded:0,total:r.size,current:1,totalFiles:1}});try{await a.uploadFile(n,r,void 0,(t,a)=>{e({uploadProgress:{name:r.name,loaded:t,total:a,current:1,totalFiles:1}})},l.signal)}finally{e({uploadProgress:null,uploadAbortController:null})}},uploadFiles:async r=>{let{webdavClient:a,currentPath:o,resources:l}=t();if(!a)return;let n=new AbortController;e({uploadAbortController:n});let i=r.length,s=new Set(l.map(e=>e.name));for(let t=0;t<r.length&&!n.signal.aborted;t++){let l=r[t],c=function(e,t){if(!t.has(e))return e;let r=e.lastIndexOf("."),a=r>0?e.substring(0,r):e,o=r>0?e.substring(r):"",l=1;for(;t.has(`${a} (${l})${o}`);)l++;return`${a} (${l})${o}`}(l.name,s);s.add(c);let u="/"===o?`/${c}`:`${o}/${c}`;e({uploadProgress:{name:l.name,loaded:0,total:l.size,current:t+1,totalFiles:i}});try{await a.uploadFile(u,l,void 0,(r,a)=>{e({uploadProgress:{name:l.name,loaded:r,total:a,current:t+1,totalFiles:i}})},n.signal)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)break;throw e({uploadProgress:null,uploadAbortController:null}),t}}e({uploadProgress:null,uploadAbortController:null}),await t().refresh()},cancelUpload:()=>{let{uploadAbortController:r}=t();r&&(r.abort(),e({uploadProgress:null,uploadAbortController:null}))},uploadFolder:async r=>{let{webdavClient:a,currentPath:o}=t();if(!a||0===r.length)return;let l=new AbortController;e({uploadAbortController:l});let n=r.length,i=new Set;for(let e of r){let t=(e.webkitRelativePath||e.name).split("/");for(let e=1;e<t.length;e++)i.add(t.slice(0,e).join("/"))}for(let e of[...i].sort((e,t)=>e.split("/").length-t.split("/").length)){if(l.signal.aborted)break;let t="/"===o?`/${e}`:`${o}/${e}`;try{await a.createDirectory(t)}catch{}}for(let t=0;t<r.length&&!l.signal.aborted;t++){let i=r[t],s=i.webkitRelativePath||i.name,c="/"===o?`/${s}`:`${o}/${s}`;e({uploadProgress:{name:s,loaded:0,total:i.size,current:t+1,totalFiles:n}});try{await a.uploadFile(c,i,void 0,(r,a)=>{e({uploadProgress:{name:s,loaded:r,total:a,current:t+1,totalFiles:n}})},l.signal)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)break;throw e({uploadProgress:null,uploadAbortController:null}),t}}e({uploadProgress:null,uploadAbortController:null}),await t().refresh()},deleteResource:async e=>{let{webdavClient:r,currentPath:a,refresh:o}=t();if(!r)return;let l="/"===a?`/${e}`:`${a}/${e}`;await r.delete(l),await o()},deleteResources:async r=>{let{webdavClient:a,currentPath:o,refresh:l}=t();if(a){for(let e of r){let t="/"===o?`/${e}`:`${o}/${e}`;await a.delete(t)}e({selectedResources:new Set}),await l()}},renameResource:async(r,a)=>{let{webdavClient:o,currentPath:l,refresh:n}=t();if(!o)return;let i="/"===l?`/${r}`:`${l}/${r}`,s="/"===l?`/${a}`:`${l}/${a}`;await o.move(i,s),e({lastAction:{type:"rename",entries:[{from:i,to:s}],sourcePath:l}}),await n()},downloadResource:async e=>{let{webdavClient:r,currentPath:a}=t();if(!r)return;let o="/"===a?`/${e}`:`${a}/${e}`,{blob:l,filename:n}=await r.downloadFile(o),i=URL.createObjectURL(l),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)},downloadResources:async e=>{let{downloadResource:r}=t();for(let t of e)await r(t)},getImageUrl:async e=>{let{webdavClient:r,currentPath:a}=t();if(!r)throw Error("No client");let o="/"===a?`/${e}`:`${a}/${e}`,{blob:l}=await r.downloadFile(o);return URL.createObjectURL(l)},getFileContent:async e=>{let{webdavClient:r,currentPath:a}=t();if(!r)throw Error("No client");let o="/"===a?`/${e}`:`${a}/${e}`,{blob:l,contentType:n}=await r.downloadFile(o);return{blob:l,contentType:n}},createTextFile:async e=>{let{webdavClient:r,currentPath:a,refresh:o}=t();if(!r)return;let l="/"===a?`/${e}`:`${a}/${e}`;await r.uploadFile(l,new Blob([""],{type:"text/plain"}),"text/plain"),await o()},duplicateResource:async e=>{let{webdavClient:r,currentPath:a,refresh:o}=t();if(!r)return;let l="/"===a?`/${e}`:`${a}/${e}`,n=e.lastIndexOf("."),i=n>0?`${e.substring(0,n)} (copy)${e.substring(n)}`:`${e} (copy)`,s="/"===a?`/${i}`:`${a}/${i}`;await r.copy(l,s),await o()},moveToFolder:async(r,a)=>{let{webdavClient:o,currentPath:l,refresh:n}=t();if(!o)return;let i="/"===l?`/${a}`:`${l}/${a}`,s=[];for(let e of r){let t="/"===l?`/${e}`:`${l}/${e}`,r=`${i}/${e}`;await o.move(t,r),s.push({from:t,to:r})}e({selectedResources:new Set,lastAction:{type:"move",entries:s,sourcePath:l}}),await n()},cutResources:r=>{let{currentPath:a}=t();e({clipboard:{mode:"cut",paths:r.map(e=>"/"===a?`/${e}`:`${a}/${e}`),names:r,sourcePath:a}})},copyResources:r=>{let{currentPath:a}=t();e({clipboard:{mode:"copy",paths:r.map(e=>"/"===a?`/${e}`:`${a}/${e}`),names:r,sourcePath:a}})},pasteResources:async()=>{let{webdavClient:r,currentPath:a,clipboard:o,refresh:l}=t();if(!r||!o)return;let n=[];for(let e=0;e<o.paths.length;e++){let t=o.paths[e],l="/"===a?`/${o.names[e]}`:`${a}/${o.names[e]}`;"cut"===o.mode?(await r.move(t,l),n.push({from:t,to:l})):await r.copy(t,l)}"cut"===o.mode&&e({clipboard:null,lastAction:{type:"move",entries:n,sourcePath:a}}),await l()},selectResource:t=>{e({selectedResources:t?new Set([t]):new Set})},toggleSelect:r=>{let{selectedResources:a}=t(),o=new Set(a);o.has(r)?o.delete(r):o.add(r),e({selectedResources:o})},selectAll:()=>{let{resources:r}=t();e({selectedResources:new Set(r.map(e=>e.name))})},clearSelection:()=>{e({selectedResources:new Set})},setSelection:t=>{e({selectedResources:new Set(t)})},listPath:async e=>{let{webdavClient:r}=t();return r?r.list(e):[]},toggleFavorite:r=>{let{favorites:a}=t(),o=a.includes(r)?a.filter(e=>e!==r):[...a,r];e({favorites:o});try{localStorage.setItem("webdav-favorites",JSON.stringify(o))}catch{}},addRecentFile:(r,a)=>{let{recentFiles:o}=t(),l=[{name:r,path:a,timestamp:Date.now()},...o.filter(e=>e.path!==a)].slice(0,20);e({recentFiles:l});try{localStorage.setItem("webdav-recent-files",JSON.stringify(l))}catch{}},undoLastAction:async()=>{let{webdavClient:r,lastAction:a,refresh:o}=t();if(r&&a){for(let e of a.entries)await r.move(e.to,e.from);e({lastAction:null}),await o()}}}));var m=r(88230),h=r(23837);let f=[{id:"sidebar",target:'[data-tour="sidebar"]',titleKey:"tour.sidebar_title",descriptionKey:"tour.sidebar_desc",placement:"right"},{id:"compose",target:'[data-tour="compose-button"]',titleKey:"tour.compose_title",descriptionKey:"tour.compose_desc",placement:"right",interactive:!0},{id:"search",target:'[data-tour="search-input"]',titleKey:"tour.search_title",descriptionKey:"tour.search_desc",placement:"bottom",interactive:!0},{id:"email-list",target:'[data-tour="email-list"]',titleKey:"tour.email_list_title",descriptionKey:"tour.email_list_desc",placement:"right"},{id:"email-viewer",target:'[data-tour="email-viewer"]',titleKey:"tour.email_viewer_title",descriptionKey:"tour.email_viewer_desc",placement:"left",beforeAction:()=>{let e=document.querySelector('[data-tour="email-list"]');if(!e)return;let t=e.querySelectorAll(".cursor-pointer"),r=null;for(let e of t)if(e.textContent?.includes("Welcome to Bulwark Mail")){r=e;break}r||(r=e.querySelector(".cursor-pointer")),r&&r.click()}},{id:"keywords",target:'[data-tour="keyword-tags"]',titleKey:"tour.keywords_title",descriptionKey:"tour.keywords_desc",placement:"right"},{id:"nav-calendar",target:'[data-tour="nav-calendar"]',titleKey:"tour.calendar_title",descriptionKey:"tour.calendar_desc",placement:"right"},{id:"nav-contacts",target:'[data-tour="nav-contacts"]',titleKey:"tour.contacts_title",descriptionKey:"tour.contacts_desc",placement:"right"},{id:"nav-settings",target:'[data-tour="nav-settings"]',titleKey:"tour.settings_title",descriptionKey:"tour.settings_desc",placement:"right"},{id:"shortcuts",target:'[data-tour="nav-shortcuts"]',titleKey:"tour.shortcuts_title",descriptionKey:"tour.shortcuts_desc",placement:"right",interactive:!0}],g=[{id:"compose-open",target:'[data-tour="composer"]',titleKey:"tour.compose_open_title",descriptionKey:"tour.compose_open_desc",placement:"left",demoOnly:!0,beforeAction:()=>{let e=document.querySelector('[data-tour="compose-button"]');e&&e.click()}},{id:"calendar-view",target:'[data-tour="calendar-view"]',titleKey:"tour.calendar_view_title",descriptionKey:"tour.calendar_view_desc",placement:"bottom",page:"/calendar",demoOnly:!0},{id:"create-event",target:'[data-tour="create-event-button"]',titleKey:"tour.create_event_title",descriptionKey:"tour.create_event_desc",placement:"bottom",page:"/calendar",interactive:!0,demoOnly:!0},{id:"event-modal",target:'[data-tour="event-modal"]',titleKey:"tour.event_modal_title",descriptionKey:"tour.event_modal_desc",placement:"left",page:"/calendar",interactive:!0,demoOnly:!0,beforeAction:()=>{let e=document.querySelector('[data-tour="create-event-button"]');e&&e.click()}},{id:"contacts-list",target:'[data-tour="contacts-list"]',titleKey:"tour.contacts_list_title",descriptionKey:"tour.contacts_list_desc",placement:"right",page:"/contacts",demoOnly:!0},{id:"settings-tabs",target:'[data-tour="settings-tabs"]',titleKey:"tour.settings_tabs_title",descriptionKey:"tour.settings_tabs_desc",placement:"right",page:"/settings",demoOnly:!0},{id:"nav-files",target:'[data-tour="nav-files"]',titleKey:"tour.files_title",descriptionKey:"tour.files_desc",placement:"right",demoOnly:!0},{id:"demo-banner",target:'[data-tour="demo-banner"]',titleKey:"tour.demo_banner_title",descriptionKey:"tour.demo_banner_desc",placement:"bottom",page:"/",demoOnly:!0},{id:"quota",target:'[data-tour="storage-quota"]',titleKey:"tour.quota_title",descriptionKey:"tour.quota_desc",placement:"right",demoOnly:!0}];var y=r(47650),w=r(50910),b=r(91337),v=r(20043);function x(){let e=(0,w.c)(),{currentStep:t,totalSteps:r,steps:l,nextStep:n,prevStep:i,stopTour:s}=C(),c=l[t],[u,d]=(0,o.useState)(null),[p,m]=(0,o.useState)(null),[h,f]=(0,o.useState)(!1),[g,x]=(0,o.useState)(!1),$=(0,o.useRef)(null),S=(0,o.useRef)(null),E=(0,o.useRef)(()=>{}),A=(0,o.useRef)(()=>{});A.current=n;let D=(0,v.r)({isActive:h,onEscape:s,restoreFocus:!0});(0,o.useEffect)(()=>{x(!0)},[]);let k=(0,o.useCallback)(()=>{if(!c)return;let e=function(e){let t=document.querySelector(e);if(!t)return null;let r=t.getBoundingClientRect();return 0===r.width&&0===r.height?null:{top:r.top,left:r.left,width:r.width,height:r.height}}(c.target);if(e&&(d(e),$.current)){let{width:t,height:r}=$.current.getBoundingClientRect(),a=function(e,t,r){let a=window.innerWidth,o=window.innerHeight,l=Math.max(r.width,200),n=Math.max(r.height,100),i={bottom:{top:e.top+e.height+8+12,left:e.left+e.width/2-l/2},top:{top:e.top-8-12-n,left:e.left+e.width/2-l/2},right:{top:e.top+e.height/2-n/2,left:e.left+e.width+8+12},left:{top:e.top+e.height/2-n/2,left:e.left-8-12-l}},s=e=>e.top>=8&&e.left>=8&&e.top+n<=o-8&&e.left+l<=a-8;for(let e of[t,"bottom","right","left","top"]){let t=i[e];if(s(t))return{...t,actualPlacement:e}}let c=i[t];return{top:Math.max(8,Math.min(c.top,o-n-8)),left:Math.max(8,Math.min(c.left,a-l-8)),actualPlacement:t}}(e,c.placement,{width:t,height:r});m({top:a.top,left:a.left})}},[c]);if(E.current=k,(0,o.useEffect)(()=>{if(!c)return;console.log(`[Tour] Step ${t+1}/${r}: "${c.id}" - target: ${c.target}, placement: ${c.placement}, interactive: ${!!c.interactive}`),f(!1),S.current&&(clearTimeout(S.current),S.current=null),c.beforeAction&&c.beforeAction();let e=0,a=!1,o=()=>{if(a)return!0;let r=document.querySelector(c.target);if(r){let e=r.getBoundingClientRect();return console.log(`[Tour] Step ${t+1} "${c.id}": element FOUND (${e.width}x${e.height} at ${Math.round(e.left)},${Math.round(e.top)})`),r.scrollIntoView({behavior:"smooth",block:"nearest"}),S.current=setTimeout(()=>{a||(console.log(`[Tour] Step ${t+1} "${c.id}": showing tooltip`),E.current(),f(!0),requestAnimationFrame(()=>{a||E.current()}))},200),!0}return e%10==0&&console.log(`[Tour] Step ${t+1} "${c.id}": element NOT found (attempt ${e+1}/50)`),!1};if(o())return()=>{a=!0};let l=setInterval(()=>{e++,(o()||e>=50)&&(clearInterval(l),e>=50&&!a&&(console.warn(`[Tour] Step ${t+1} "${c.id}": SKIPPED - element never appeared after 50 attempts`),A.current()))},100);return()=>{a=!0,clearInterval(l),S.current&&(clearTimeout(S.current),S.current=null)}},[c,t]),(0,o.useEffect)(()=>{if(!h)return;let e=null,t=()=>{e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{k()})};return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0),e&&cancelAnimationFrame(e)}},[h,k]),(0,o.useEffect)(()=>{let e=e=>{"ArrowRight"===e.key||"Enter"===e.key?(e.preventDefault(),e.stopPropagation(),n()):"ArrowLeft"===e.key?(e.preventDefault(),e.stopPropagation(),i()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[n,i,s]),(0,o.useEffect)(()=>{if(!h||!$.current)return;let e=requestAnimationFrame(()=>{k()});return()=>cancelAnimationFrame(e)},[h,k,t]),!g||!c)return null;let _=u?{x:u.left-8,y:u.top-8,w:u.width+16,h:u.height+16}:null,T=t>=r-1,N=0===t,P=c.interactive,R=window.matchMedia("(prefers-reduced-motion: reduce)").matches,O=R?"none":"all 300ms ease";return(0,y.createPortal)((0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("svg",{className:"fixed inset-0 z-[9998]",width:"100%",height:"100%",style:{pointerEvents:P?"none":"auto"},onClick:s,children:[(0,a.jsx)("defs",{children:(0,a.jsxs)("mask",{id:"tour-mask",children:[(0,a.jsx)("rect",{fill:"white",width:"100%",height:"100%"}),_&&(0,a.jsx)("rect",{fill:"black",x:_.x,y:_.y,width:_.w,height:_.h,rx:"8",style:{transition:O}})]})}),(0,a.jsx)("rect",{fill:"black",opacity:"0.5",mask:"url(#tour-mask)",width:"100%",height:"100%"})]}),P&&_&&(0,a.jsx)("div",{className:"fixed z-[9998]",style:{top:_.y,left:_.x,width:_.w,height:_.h,pointerEvents:"none",transition:O}}),!P&&_&&(0,a.jsx)("div",{className:"fixed z-[9998]",style:{top:_.y,left:_.x,width:_.w,height:_.h,pointerEvents:"none"}}),(0,a.jsx)("div",{ref:e=>{$.current=e,D.current=e},role:"dialog","aria-modal":"true","aria-label":e(c.titleKey),className:(0,b.cn)("fixed z-[9999] transition-all",h?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:{top:p?.top??-9999,left:p?.left??-9999,maxWidth:360,transition:R?"none":"opacity 200ms ease, transform 200ms ease, top 300ms ease, left 300ms ease",pointerEvents:"auto"},onClick:e=>e.stopPropagation(),children:(0,a.jsxs)("div",{className:"bg-background border border-border rounded-xl shadow-2xl p-4",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground mb-1","aria-live":"polite",children:e("tour.step_counter",{current:t+1,total:r})}),(0,a.jsx)("h3",{className:"font-semibold text-sm text-foreground",children:e(c.titleKey)}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:e(c.descriptionKey)}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-3",children:[(0,a.jsx)("button",{onClick:s,className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-muted",children:e("tour.skip")}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:i,disabled:N,className:(0,b.cn)("text-xs px-3 py-1.5 rounded-md border border-border transition-colors",N?"opacity-40 cursor-not-allowed":"hover:bg-muted"),children:e("tour.back")}),(0,a.jsx)("button",{onClick:n,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:e(T?"tour.finish":"tour.next")})]})]}),(0,a.jsx)("div",{className:"flex justify-center gap-1 mt-2",children:l.map((e,r)=>(0,a.jsx)("span",{className:(0,b.cn)("w-1.5 h-1.5 rounded-full transition-colors",r===t?"bg-primary":"bg-muted-foreground/30")},r))})]})})]}),document.body)}let $="tour_completed",S="tour_current_step",E=(0,o.createContext)(null);function C(){let e=(0,o.useContext)(E);if(!e)throw Error("useTour must be used within TourProvider");return e}function A({children:e}){var t;let r,s=(0,l.rd)(),c=(0,l.a8)(),{isDemoMode:u}=(0,n.useAuthStore)(),{supportsCalendar:d}=(0,i.V)(),y=(0,h.V)(e=>e.isFeatureEnabled("calendarEnabled")),{supportsWebDAV:w}=p(),b=(0,m.C$)(e=>e.tourCompleted),v=(0,m.C$)(e=>e.showOnboardingOnNewDevices),C=(0,m.C$)(e=>e.updateSetting),[D,k]=(0,o.useState)(!1),[_,T]=(0,o.useState)(0),[N,P]=(0,o.useState)(!1),R=(t={isDemoMode:u,supportsCalendar:d&&y,supportsWebDAV:!1!==w},r=[...f],t.supportsCalendar||(r=r.filter(e=>"nav-calendar"!==e.id)),t.isDemoMode&&(r=[...r,...g.filter(e=>("nav-files"!==e.id||!!t.supportsWebDAV)&&("calendar-view"!==e.id&&"create-event"!==e.id&&"event-modal"!==e.id||!!t.supportsCalendar))]),r);(0,o.useEffect)(()=>{try{"true"!==localStorage.getItem($)||b||C("tourCompleted",!0)}catch{}},[b,C]),(0,o.useEffect)(()=>{if(!b)return void P(!1);if(v)try{P("true"===localStorage.getItem($));return}catch{}P(!0)},[b,v]);let O=(0,o.useCallback)(()=>{let e=0;try{let t=localStorage.getItem(S);if(t){let r=parseInt(t,10);!isNaN(r)&&r>=0&&(e=r)}}catch{}e>=R.length&&(e=0);let t=R[e]?.page??"/";c!==t&&s.push(t),T(e),k(!0)},[R,c,s]),L=(0,o.useCallback)(()=>{k(!1);try{localStorage.removeItem(S)}catch{}},[]),K=(0,o.useCallback)(()=>{k(!1),P(!0),C("tourCompleted",!0);try{localStorage.setItem($,"true"),localStorage.removeItem(S)}catch{}},[C]),M=(0,o.useCallback)(()=>{if(_>=R.length-1)return void K();let e=_+1,t=R[e],r=R[_];T(e);try{localStorage.setItem(S,String(e))}catch{}let a=t?.page??"/";a!==(r?.page??"/")&&s.push(a)},[_,R,K,s]),V=(0,o.useCallback)(()=>{if(_<=0)return;let e=_-1,t=R[e];T(e);try{localStorage.setItem(S,String(e))}catch{}t?.page?s.push(t.page):R[_]?.page&&s.push("/")},[_,R,s]),F=(0,o.useCallback)(()=>{P(!1),C("tourCompleted",!1);try{localStorage.removeItem($),localStorage.removeItem(S)}catch{}},[C]),I={isActive:D,currentStep:_,totalSteps:R.length,steps:R,startTour:O,stopTour:L,nextStep:M,prevStep:V,hasCompletedTour:N,resetTourCompletion:F};return(0,a.jsxs)(E.Provider,{value:I,children:[e,D&&(0,a.jsx)(x,{})]})}},19284:(e,t,r)=>{r.d(t,{GM:()=>u,X3:()=>s,al:()=>c});var a=r(12115),o=r(72345),l=r(9385);let n=()=>!1;function i(e){let t=(0,a.useCallback)(t=>{let r=window.matchMedia(e);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[e]),r=(0,a.useCallback)(()=>window.matchMedia(e).matches,[e]);return(0,a.useSyncExternalStore)(t,r,n)}function s(){var e;let{setDeviceType:t,isMobile:r,isTablet:n,isDesktop:s}=(0,o.j)(),c=null===(e=(0,l.v)())?null:{isMobile:e<768,isTablet:e>=768&&e<1024,isDesktop:e>=1024},u=i(`(max-width: ${767}px)`),d=i(`(min-width: 768px) and (max-width: ${1023}px)`),p=i("(min-width: 1024px)");return((0,a.useEffect)(()=>{c||t(u,d,p)},[u,d,p,t,c]),c)?c:{isMobile:r,isTablet:n,isDesktop:s}}function c(){let e=(0,l.v)(),t=i(`(max-width: ${767}px)`);return null!==e?e<768:t}function u(){let e=(0,l.v)(),t=i("(min-width: 1024px)");return null!==e?e>=1024:t}},20043:(e,t,r)=>{r.d(t,{r:()=>o});var a=r(12115);function o({isActive:e,onEscape:t,restoreFocus:r=!0}){let l=(0,a.useRef)(null),n=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!e||!l.current)return;n.current=document.activeElement;let a=l.current,o=a.querySelectorAll('button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"]):not(:disabled)')[0];o&&o.focus();let i=e=>{if("Escape"===e.key&&t)return void t();if("Tab"===e.key){let t=a.querySelectorAll('button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"]):not(:disabled)'),r=t[0],o=t[t.length-1];e.shiftKey?document.activeElement===r&&(o?.focus(),e.preventDefault()):document.activeElement===o&&(r?.focus(),e.preventDefault())}};return a.addEventListener("keydown",i),()=>{a.removeEventListener("keydown",i),r&&n.current&&n.current.focus()}},[e,t,r]),l}},40091:(e,t,r)=>{r.d(t,{N_:()=>l,a8:()=>i,rd:()=>s});var a=r(71281),o=r(26433);let{Link:l,redirect:n,usePathname:i,useRouter:s}=(0,a.A)(o.DT)},48791:(e,t,r)=>{r.d(t,{B1:()=>u,Jy:()=>d,Ry:()=>c,d5:()=>i,hJ:()=>p,tK:()=>s});let a=[],o=new Set;function l(){for(let e of o)try{e()}catch{}}function n(e){let t={...e,id:Math.random().toString(36).slice(2)+Date.now().toString(36)};return a.push(t),l(),{id:t.id}}function i(){return a[0]??null}function s(e){let t=a.shift();if(t){try{t.resolve(e)}catch{}l()}}function c(e){let t=!1;for(let o=a.length-1;o>=0;o--)if(a[o].pluginId===e){let e=a[o];a.splice(o,1);try{var r;e.resolve((r=e.kind,"prompt"===r&&null))}catch{}t=!0}t&&l()}function u(e){return o.add(e),()=>{o.delete(e)}}function d(e){return new Promise(t=>{n({...e,resolve:e=>t(!0===e)})})}function p(e){return new Promise(t=>{n({...e,resolve:e=>t(e&&"object"==typeof e?e:null)})})}},51342:(e,t,r)=>{r.d(t,{A:()=>l});var a=r(60062),o=r(555);function l(){let e,t,r,l,n=(e=o.useAuthStore.getState(),t=a.E.getState(),l=(r=e.activeAccountId??t.activeAccountId)?t.getAccountById(r):t.getActiveAccount(),"number"==typeof l?.cookieSlot?l.cookieSlot:null);return null===n?{}:{"X-JMAP-Cookie-Slot":String(n)}}},72345:(e,t,r)=>{r.d(t,{j:()=>a});let a=(0,r(1934).v)((e,t)=>({activeView:"list",sidebarOpen:!1,tabletListVisible:!0,isMobile:!1,isTablet:!1,isDesktop:!0,sidebarWidth:256,emailListWidth:384,emailListHeight:320,sidebarCollapsed:!1,setActiveView:t=>e({activeView:t}),setSidebarOpen:t=>e({sidebarOpen:t}),toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen})),setTabletListVisible:t=>e({tabletListVisible:t}),setDeviceType:(t,r,a)=>e({isMobile:t,isTablet:r,isDesktop:a}),setSidebarWidth:t=>e({sidebarWidth:Math.min(400,Math.max(180,t))}),setEmailListWidth:t=>e({emailListWidth:Math.min(600,Math.max(240,t))}),setEmailListHeight:t=>e({emailListHeight:Math.min(800,Math.max(160,t))}),resetSidebarWidth:()=>{e({sidebarWidth:256});let{emailListWidth:r,emailListHeight:a}=t();try{localStorage.setItem("column-widths",JSON.stringify({sidebarWidth:256,emailListWidth:r,emailListHeight:a}))}catch{}},resetEmailListWidth:()=>{e({emailListWidth:384});let{sidebarWidth:r,emailListHeight:a}=t();try{localStorage.setItem("column-widths",JSON.stringify({sidebarWidth:r,emailListWidth:384,emailListHeight:a}))}catch{}},resetEmailListHeight:()=>{e({emailListHeight:320});let{sidebarWidth:r,emailListWidth:a}=t();try{localStorage.setItem("column-widths",JSON.stringify({sidebarWidth:r,emailListWidth:a,emailListHeight:320}))}catch{}},persistColumnWidths:()=>{let{sidebarWidth:e,emailListWidth:r,emailListHeight:a}=t();try{localStorage.setItem("column-widths",JSON.stringify({sidebarWidth:e,emailListWidth:r,emailListHeight:a}))}catch{}},setSidebarCollapsed:t=>e({sidebarCollapsed:t}),toggleSidebarCollapsed:()=>e(e=>({sidebarCollapsed:!e.sidebarCollapsed})),showEmailList:()=>{let{isMobile:r}=t();r&&e({activeView:"list",sidebarOpen:!1})},showEmailViewer:()=>{let{isMobile:r}=t();r&&e({activeView:"viewer"})},goBack:()=>{let{activeView:r,isMobile:a}=t();a&&("viewer"===r?e({activeView:"list"}):"list"===r&&e({sidebarOpen:!0}))}}))}}]);