const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/popup-F8WrwMZ1.js","assets/popup-YACEJWXS.css","chunks/refreshToken-E1LYTlKk.js"])))=>i.map(i=>d[i]);
import{d as i,u as c,s as e,a as s,b as u,_ as E,h as t,A as a,B as r}from"./popup-F8WrwMZ1.js";const _=i("userAccessStore",()=>({canUserAccess:async()=>{const i=c();try{if(!(await e.getUserSession()).accessToken)return void(i.isAuthorized=!1);i.isUserLoading=!0;const r=await s.getMe();if(r&&"error"in r)return;if(r?.id){i.user=r,i.isAuthorized=!0,u.identify(r.id.toString(),{email:r.email,isPremium:r.active_subscription}),u.track("user_logged_in");const{useAcquisitionSurveyStore:e}=await E(async()=>{const{useAcquisitionSurveyStore:e}=await import("./popup-F8WrwMZ1.js").then(e=>e.e);return{useAcquisitionSurveyStore:e}},__vite__mapDeps([0,1]));e().maybeStart(r)}}catch(o){const n=o;if(n.isTimeout||"ECONNABORTED"===n.code)return void(await t(o,{method:a.GET_USER}));if(401===n.response?.status){const t=await(async()=>{const t=c();try{const{refreshToken:i}=await E(async()=>{const{refreshToken:e}=await import("./refreshToken-E1LYTlKk.js");return{refreshToken:e}},__vite__mapDeps([2,0,1])),a=await i();if(a){const e=await s.getMe();if(e&&!("error"in e)&&e.id)return t.user=e,t.isAuthorized=!0,chrome.runtime.sendMessage({type:r.UPDATE_REFRESH_TOKEN_TIMER,data:{expiresIn:a}}),!0}return t.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0}),!1}catch(i){return t.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0}),!1}})();if(t)return}else await t(o,{method:a.GET_USER}),i.isAuthorized=!1,e.clearUserSession(),chrome.runtime.sendMessage({type:r.RESET_REFRESH_TOKEN_TIMER,data:!0})}finally{i.isUserLoading=!1}}}));export{_ as useUserAccessStore};
