import{d as D,r as B,ez as I,ey as j,u as e,b as c,c as d,w as a,f as u,aA as r,bZ as s,cA as x,ev as P,cm as E,t as R}from"./outputWidgets.0fb707c7.js";import{W as S}from"./workspaces.3d9f34c7.js";import{l as p}from"./DocsButton.vue_vue_type_script_setup_true_lang.6262c519.js";import{p as U}from"./popupNotifcation.c01c5f2c.js";import{a as M}from"./asyncComputed.a0ca296c.js";import{S as N}from"./index.4da42521.js";import"./index.f819ebc9.js";import{M as h}from"./transButton.220177fb.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[l]="6310419b-37b2-4259-93be-84e1a5c43256",n._sentryDebugIdIdentifier="sentry-dbid-6310419b-37b2-4259-93be-84e1a5c43256")}catch{}})();const V=D({__name:"LoginBlock",setup(n){var b;const l="https://cloud.abstra.io/api-key?"+new URLSearchParams({redirect:location.href}),i=B(!1),f=(b=N.instance)==null?void 0:b.deployEnabled,{loading:y,result:t,refetch:g}=M(()=>p.get()),k=I(),v=j();function w(){const o=new URL(location.href);o.searchParams.delete("api-key"),v.replace(o.pathname+o.search)}function L(){var o;(o=t.value)!=null&&o.logged?h.success({title:"You're logged in!",content:"You can now deploy your project to Abstra Cloud."}):h.error({title:"Login failed",content:"Please try again. If the problem persists, contact help@abstra.io."})}const _=k.query["api-key"];typeof _=="string"&&p.create(_).then(g).then(w).then(L);async function A(){!t.value||(await p.delete(),g())}async function C(){if(!!t.value){i.value=!0;try{await S.deploy(),window.open(`https://cloud.abstra.io/projects/${t.value.logged&&t.value.project_id}/builds`,"_blank")}catch(o){U("Deploy failed",String(o))}i.value=!1}}return(o,G)=>{var m;return(m=e(t))!=null&&m.logged?(c(),d(e(E),{key:0},{default:a(()=>[u(e(s),{href:`https://cloud.abstra.io/projects/${e(t).project_id}`,target:"_blank"},{default:a(()=>[r(" Go to console ")]),_:1},8,["href"]),!i.value&&e(f)?(c(),d(e(x),{key:0,title:"Are you sure you want to deploy this project to Abstra Cloud?",onConfirm:C},{default:a(()=>[u(e(s),null,{default:a(()=>[r("Deploy")]),_:1})]),_:1})):e(f)?(c(),d(e(s),{key:1,loading:""},{default:a(()=>[r("Deploying")]),_:1})):P("",!0),u(e(s),{onClick:A},{default:a(()=>[r("Logout")]),_:1})]),_:1})):(c(),d(e(s),{key:1,href:l,loading:e(y),disabled:e(y)},{default:a(()=>[r(" Login to deploy ")]),_:1},8,["loading","disabled"]))}}});const Z=R(V,[["__scopeId","data-v-7b8037ee"]]);export{Z as L};
//# sourceMappingURL=LoginBlock.6bf0eeec.js.map
