import{d as L,r as v,b as u,er as P,u as a,c,w as o,f as s,b0 as r,cb as p,cM as A,cy as N,cE as C,eu as D,bu as T,eB as E,eC as S,e as B,v as M}from"./registerWidgets.9fce82a0.js";import{W as U}from"./workspaces.7ad2f8ea.js";import{l as f}from"./DocsButton.vue_vue_type_script_setup_true_lang.41ad9626.js";import{p as K}from"./popupNotifcation.29bb6cec.js";import{a as O}from"./asyncComputed.a4b709a3.js";import{A as j}from"./index.2c964e80.js";import{A as x,M as F}from"./Title.26974edb.js";import"./index.02615dca.js";import{F as V}from"./Form.413853c0.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[d]="caed3b71-d67f-402f-965e-368d5b5d4143",t._sentryDebugIdIdentifier="sentry-dbid-caed3b71-d67f-402f-965e-368d5b5d4143")}catch{}})();const G=t=>(E("data-v-5c1cce26"),t=t(),S(),t),W=G(()=>B("a",{href:"https://cloud.abstra.io",target:"_blank"},"cloud.abstra.io",-1)),$=L({__name:"LoginBlock",setup(t){const d=v(!1),e=v({state:"CLOSED"}),{loading:g,result:i,refetch:_}=O(()=>f.get());function m(){e.value={state:"INPUT",apiKey:"",loading:!1}}function b(){e.value={state:"CLOSED"}}async function I(){if(e.value.state!=="INPUT")return;const l=e.value.apiKey;try{e.value={state:"INPUT",apiKey:l,loading:!0};const n=await f.create(l);n.logged?(e.value={state:"CLOSED"},_()):n.reason==="INVALID_API_TOKEN"?e.value={state:"INPUT",apiKey:l,errorMessage:"Invalid API Token",loading:!1}:n.reason==="NO_API_TOKEN"?e.value={state:"INPUT",apiKey:l,errorMessage:"No API Token provided",loading:!1}:e.value={state:"INPUT",apiKey:l,errorMessage:"Unknown error",loading:!1}}catch(n){e.value={state:"INPUT",apiKey:l,errorMessage:String(n),loading:!1}}}async function k(){!i.value||(await f.delete(),_())}async function h(){if(!!i.value){d.value=!0;try{await U.deploy(),window.open(`https://cloud.abstra.io/projects/${i.value.logged&&i.value.project_id}/builds`,"_blank")}catch(l){K("Deploy failed",String(l))}d.value=!1}}return(l,n)=>{var y;return u(),P(T,null,[(y=a(i))!=null&&y.logged?(u(),c(a(N),{key:0},{default:o(()=>[s(a(p),{href:`https://cloud.abstra.io/projects/${a(i).project_id}`,target:"_blank"},{default:o(()=>[r("Go to console ")]),_:1},8,["href"]),d.value?(u(),c(a(p),{key:1,loading:""},{default:o(()=>[r("Deploying")]),_:1})):(u(),c(a(A),{key:0,title:"Are you sure you want to deploy this project to Abstra Cloud?",onConfirm:h},{default:o(()=>[s(a(p),null,{default:o(()=>[r("Deploy")]),_:1})]),_:1})),s(a(p),{onClick:k},{default:o(()=>[r("Logout")]),_:1})]),_:1})):(u(),c(a(p),{key:1,loading:a(g),disabled:a(g),onClick:m},{default:o(()=>[r("Login to deploy")]),_:1},8,["loading","disabled"])),s(a(F),{open:e.value.state!=="CLOSED",title:"Login","confirm-loading":e.value.state!=="CLOSED"&&e.value.loading,onCancel:b,onOk:I},{default:o(()=>[e.value.state==="INPUT"?(u(),c(a(V),{key:0,layout:"vertical"},{default:o(()=>[s(a(j),null,{default:o(()=>[r(" Login to our console at "),W,r(" and get an API Key to deploy your Projects. ")]),_:1}),s(a(x),{label:"API Key",help:e.value.errorMessage,"validate-status":e.value.errorMessage&&"error"},{default:o(()=>[s(a(C),{value:e.value.apiKey,"onUpdate:value":n[0]||(n[0]=w=>e.value.apiKey=w),disabled:e.value.loading},null,8,["value","disabled"])]),_:1},8,["help","validate-status"])]),_:1})):D("",!0)]),_:1},8,["open","confirm-loading"])],64)}}});const ee=M($,[["__scopeId","data-v-5c1cce26"]]);export{ee as L};
//# sourceMappingURL=LoginBlock.cb84a0a2.js.map
