import{B as C}from"./Button-LyDQSUp0.js";import{d as E,n as x,b2 as b,c as a,x as s,O as u,B as m,o as r,l as B}from"./index-BXlk60bP.js";import{S,a7 as h,a1 as p,$ as o}from"./common-vYHpopNV.js";import"./_commonjsHelpers-BosuxZz1.js";const N={class:"flex flex-col items-center space-y-5"},$={class:"flex items-center space-x-5"},q={class:"text-2xl font-bold text-gray-dark"},F={class:"text-sm text-gray"},P={class:"w-md text-lg space-y-3"},R={class:"flex justify-between"},j={class:"flex-row-center space-x-3"},A={key:0,class:"i-fa:question text-gray"},M={key:1,class:"i-fa:close text-red-400 mx-auto"},V={key:2,class:"i-fa:check text-green-400 mx-auto"},O={class:"w-30"},Y={class:"flex justify-between"},D={class:"flex-row-center space-x-3"},H={key:0,class:"i-fa:question text-gray"},J={key:1,class:"i-fa:close text-red-400 mx-auto"},K={key:2,class:"i-fa:check text-green-400 mx-auto"},L={class:"w-30"},T={key:0,class:"w-full p-4 border rounded-md text-base text-dark bg-orange-100"},X=E({__name:"Check",setup(z){const k=t=>{switch(t.status){case 401:return"Your session has expired, please log in again.";case 429:return"Limit refresh every minute, please try again later.";case 400:return"Auth Error: Please log in to Fansly.com and try again.";default:return`${t.code}: ${t.message}`}},_=b(),f=x(()=>{var t;if((t=_.query)!=null&&t.error){const e=JSON.parse(_.query.error);return{title:"An error occurred during the download process",message:k(e)}}return{title:"Please log in to Fansly.com and try again.",message:"Auth Error"}}),n=S({session:0,network:0}),c=h(!1),y=async()=>{c.value=!0;const t=await chrome.runtime.sendMessage({method:"RECHECK"});n.session=t?2:1,c.value=!1},l=h(!1),i=h(""),g=B("checkFn"),v=async()=>{var t;l.value=!0;try{const e=await g.value();n.network=2,i.value=""}catch(e){e.status||(e.status=((t=e.response)==null?void 0:t.status)||0),i.value=k(e),n.network=1}l.value=!1},w=x(()=>n.session==2&&n.network==2);return(t,e)=>{const d=C;return r(),a("div",N,[s("div",$,[e[1]||(e[1]=s("div",{class:"i-fa:warning w-8 h-8 text-orange-500"},null,-1)),s("div",null,[s("h1",q,p(o(f).title),1),s("p",F,p(o(f).message),1)])]),s("div",P,[s("div",R,[s("div",j,[e[2]||(e[2]=s("p",null,"Session Status: ",-1)),o(n).session==0?(r(),a("div",A)):o(n).session==1?(r(),a("div",M)):o(n).session==2?(r(),a("div",V)):u("",!0)]),s("div",O,[m(d,{loading:o(c),onClick:y,type:"primary",text:"Check"},null,8,["loading"])])]),s("div",Y,[s("div",D,[e[3]||(e[3]=s("p",null,"Network Status: ",-1)),o(n).network==0?(r(),a("div",H)):o(n).network==1?(r(),a("div",J)):o(n).network==2?(r(),a("div",K)):u("",!0)]),s("div",L,[m(d,{loading:o(l),onClick:v,type:"primary",text:"Check"},null,8,["loading"])])])]),o(i)?(r(),a("div",T,[s("p",null,p(o(i)),1)])):u("",!0),m(d,{type:o(w)?"success":"primary",icon:"i-ant-design:home-twotone",onClick:e[0]||(e[0]=G=>t.$router.push("/")),text:"RETRY"},null,8,["type"])])}}});export{X as default};
