import{r as u,e as b,n as C,l as v,q as L,$ as T,N as S,g as A,ar as H}from"./jwt-decode.esm-CX61wVx3.js";import{s as K,r as O}from"./editor-tdrTCwbw.js";import{l as p}from"./fetch-BOLOxrH8.js";import{u as d}from"./polling-DKdJFQQ3.js";import"./externalPlayer-D7i6YlKj.js";import"./workspaceStore-QlTT1mu8.js";import"./userStore-C3Z0vN5p.js";import"./runnerData-B4AKypWD.js";import"./url-D1jI6Lt8.js";import"./colorHelpers-Dde0Xcnl.js";import"./useCodebaseEvents-BK-wKPXc.js";import"./codebaseEvents-s4M7UMV6.js";import"./constants-B5rys1IL.js";import"./files-IqWfdQBD.js";import"./ts.worker-DBbJtN2A.js";import"./router-XYEQzGpi.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="5619c068-bbe7-4307-8c8a-3b61ba025d02",t._sentryDebugIdIdentifier="sentry-dbid-5619c068-bbe7-4307-8c8a-3b61ba025d02")}catch{}})();const _=8,P=3e3,k=3e3,D=1e4,N=1e3,m="abstra:web-editor:api-key-recovery-at",U=300*1e3,V=t=>/\/projects\/([^/]+)\/web-editor/.exec(t)?.[1],W=()=>{try{return Number(window.sessionStorage.getItem(m))||0}catch{return 0}},Y=()=>{try{window.sessionStorage.setItem(m,String(Date.now()))}catch{}},M=t=>{const r=t.router,o=u(""),n=u(Array(_).fill(!0));let a=0,c=!1;const s=async()=>{const e=await p("/_editor/api/web-editor/",{method:"GET"});return e.ok?await e.json():null},i=()=>{const e=new URLSearchParams;e.set("redirect",r.currentRoute.value.path),window.location.href=o.value+"?"+e.toString()},E=async()=>{try{const e=new AbortController,g=setTimeout(()=>e.abort(),P),R=await p("/_healthcheck",{method:"GET",signal:e.signal,headers:{"Content-Type":"application/json","Cache-Control":"no-cache"}});clearTimeout(g),n.value[a]=R.status===200}catch{n.value[a]=!1}if(a=(a+1)%_,n.value.every(e=>!e)&&o.value){const e=V(o.value);e&&K({type:"perceived_restart",source:"frontend",projectId:e,cause:"healthcheck_failed",healthCheckHistory:[...n.value],path:r.currentRoute.value.path}),i()}},y=async()=>{if(!(c||(await s().catch(()=>null))?.apiKeyValid!==!1||!o.value)&&!await O()){if(Date.now()-W()<U){c=!0;return}Y(),i()}},{startPolling:f,endPolling:h}=d({task:E,interval:k}),{startPolling:I,endPolling:w}=d({task:y,interval:D}),l=async()=>{const e=await s().catch(()=>null);if(!e){setTimeout(()=>{l()},N);return}e.waitingRoomUrl&&(o.value=e.waitingRoomUrl,f(),I())};return{setup:l,cleanUp:()=>{h(),w()}}},x=b({__name:"Home",setup(t){const r=S(),{setup:o,cleanUp:n}=M({router:r});return C(()=>{o()}),v(()=>{n()}),(a,c)=>{const s=T("RouterView");return A(),L(s,{class:"router"})}}}),ae=H(x,[["__scopeId","data-v-3737a9c1"]]);export{ae as default};
//# sourceMappingURL=Home-DqKbvw8s.js.map
