1import{_ as Y}from"./DpXlyjdQ.js";import{O as Z,bF as ee,ca as V,c5 as se,aG as d,C as g,ba as e,y as p,cd as r,N as n,k as te,x as a,a$ as c,z as _,c as le,aV as ae,aw as B,j as oe,l as ie,ap as ne,v as h,aL as re,aQ as U,bd as de}from"./7weB9Jpk.js";import{_ as ce}from"./BLWvW_tm.js";import{_ as ue}from"./DRGbWVaC.js";import{_ as me}from"./Cjcp9JsE.js";import{_ as pe}from"./B_QYPJ5E.js";import{_ as fe}from"./JW5oNITO.js";import{_ as _e}from"./BqdmyltT.js";import{o as he,q as z,g as ye,t as ve,c as be,w as ge,i as xe,n as we}from"./CP4Qu65_.js";import{u as ke}from"./CKOVWS8a.js";import{u as O}from"./DXqKKzIc.js";import"./D_tcJjQ7.js";import"./B9q3AVR2.js";import"./xxyCIjo-.js";import"./6iigAg6S.js";import"./Ch9CtwdU.js";import"./D1NbHQ0M.js";import"./jFYhBC76.js";import"./CwrDtWby.js";import"./DhCED4Vf.js";import"./pRFPp8Qp.js";import"./D4k11_F0.js";const Ke={class:"space-y-6"},Ie={class:"space-y-1"},$e={class:"text-lg font-semibold"},Ce={class:"text-sm text-muted"},Ue={class:"list-inside list-disc space-y-1"},Se={class:"text-xs text-muted"},Re={class:"flex flex-wrap items-center gap-2 mt-4"},Ve=["onClick"],Be={class:"text-sm font-medium"},ze={class:"flex justify-end"},Oe={class:"flex items-center gap-3"},je={class:"flex size-10 items-center justify-center rounded-full bg-error/10"},Fe={class:"font-semibold"},Le={key:0,class:"text-sm text-muted"},Me={class:"space-y-4"},Pe={class:"text-sm"},qe={class:"text-sm font-medium text-error"},Ae={class:"flex justify-end gap-3"},fs=Z({__name:"reinstall",async setup(De){let u,y;const{t:s}=ee(),{cloudId:x}=ke(),{data:f,pending:j,error:Ne,refresh:Ee}=([u,y]=V(()=>O(()=>`/cloud/${x.value}/reinstall`,{lazy:!0,watch:[x]})),u=await u,y(),u),F=h(()=>{const l=f.value?.data?.os??[];return[{label:s("cloud.details.reinstall.selectOsPlaceholder"),value:null},...l.map(o=>({label:o.text,value:o.value}))]}),w=h(()=>f.value?.data?.server),L=h(()=>f.value?.data?.server?.paidReinstall??!1),M=h(()=>f.value?.data?.server?.paidReinstallMsg),{data:P}=([u,y]=V(()=>O("/user/ssh",{lazy:!0})),u=await u,y(),u),v=h(()=>P.value?.data?.keys??[]),q=he({os:z(ge([xe(),we()]),be(l=>l!==null&&l>0,s("cloud.details.reinstall.validation.osRequired"))),password:z(ve(),ye(1,s("cloud.details.reinstall.validation.passwordRequired")))}),t=re({os:null,password:"",sshKeyIds:[]});function A(l){return l.filter(o=>o.default).map(o=>o.id)}function S(){if(t.sshKeyIds.length>0)return;const l=A(v.value);l.length&&(t.sshKeyIds=l)}const R=U(!1);se(v,l=>{R.value||l.length&&(R.value=!0,S())},{immediate:!0});function D(l){const o=t.sshKeyIds.indexOf(l);o===-1?t.sshKeyIds.push(l):t.sshKeyIds.splice(o,1)}function k(l){return t.sshKeyIds.includes(l)}const b=U(!1),m=U(!1);function N(){m.value=!0}async function E(){b.value=!0,m.value=!1;try{const l={os:t.os,password:t.password,ssh_keys:t.sshKeyIds};await de(`/cloud/${x.value}/reinstall`,{method:"POST",body:l}),t.os=null,t.password="",t.sshKeyIds=[],S()}finally{b.value=!1}}async function G(l){N()}return(l,o)=>{const H=Y,K=te,Q=ce,I=ue,$=oe,T=me,C=ie,J=pe,W=fe,X=_e;return d(),g("div",Ke,[e(j)&&!e(f)?(d(),p(H,{key:0,class:"h-64 w-full"})):(d(),p(W,{key:1,class:"bg-default"},{header:r(()=>[a("div",Ie,[a("h3",$e,c(e(s)("cloud.details.reinstall.title")),1),a("p",Ce,c(e(s)("cloud.details.reinstall.description")),1)])]),default:r(()=>[n(K,{color:"error",icon:"i-lucide-alert-triangle",variant:"soft",title:e(s)("cloud.details.reinstall.notice.title"),class:"mb-6"},{description:r(()=>[a("ul",Ue,[a("li",null,c(e(s)("cloud.details.reinstall.notice.dataLoss")),1),a("li",null,c(e(s)("cloud.details.reinstall.notice.license")),1)])]),_:1},8,["title"]),e(L)?(d(),p(K,{key:0,color:"warning",variant:"soft",icon:"i-lucide-credit-card",title:e(s)("cloud.details.reinstall.paidReinstall.title"),description:e(M)||e(s)("cloud.details.reinstall.paidReinstall.description"),class:"mb-6"},null,8,["title","description"])):_("",!0),n(J,{schema:e(q),state:e(t),class:"space-y-6",onSubmit:G},{default:r(()=>[n(I,{label:e(s)("cloud.details.reinstall.selectOs"),name:"os",required:""},{default:r(()=>[n(Q,{modelValue:e(t).os,"onUpdate:modelValue":o[0]||(o[0]=i=>e(t).os=i),items:e(F),"value-key":"value",class:"w-full",placeholder:e(s)("cloud.details.reinstall.selectOsPlaceholder")},null,8,["modelValue","items","placeholder"])]),_:1},8,["label"]),e(v).length>0?(d(),p(I,{key:0,label:e(s)("cloud.details.reinstall.sshKeys.label")},{description:r(()=>[a("span",Se,c(e(s)("cloud.details.reinstall.sshKeys.description")),1)]),default:r(()=>[a("div",Re,[(d(!0),g(le,null,ae(e(v),i=>(d(),g("div",{key:i.id,class:B(["relative flex items-center gap-2 px-4 py-2 rounded-lg border cursor-pointer transition-all hover:border-primary/50 bg-default",k(i.id
1)?"border-primary bg-primary/5":"border-default"]),onClick:Ge=>D(i.id)},[a("div",{class:B(["w-4 h-4 rounded border-2 flex items-center justify-center transition-colors",k(i.id)?"bg-primary border-primary":"border-muted"])},[k(i.id)?(d(),p($,{key:0,name:"i-lucide-check",class:"size-3 text-white"})):_("",!0)],2),n($,{name:"i-lucide-key",class:"size-4 text-muted"}),a("span",Be,c(i.name),1)],10,Ve))),128))]),e(t).sshKeyIds.length>0?(d(),p(K,{key:0,color:"info",variant:"soft",icon:"i-lucide-shield-check",title:e(s)("cloud.details.reinstall.sshKeys.keysSelected.title"),description:e(s)("cloud.details.reinstall.sshKeys.keysSelected.description"),class:"mt-4"},null,8,["title","description"])):_("",!0)]),_:1},8,["label"])):_("",!0),n(I,{label:e(s)("cloud.details.reinstall.confirmPassword"),name:"password",description:e(s)("cloud.details.reinstall.passwordHelp"),required:""},{default:r(()=>[n(T,{modelValue:e(t).password,"onUpdate:modelValue":o[1]||(o[1]=i=>e(t).password=i),type:"password",placeholder:e(s)("cloud.details.reinstall.confirmPassword"),class:"w-full"},null,8,["modelValue","placeholder"])]),_:1},8,["label","description"]),a("div",ze,[n(C,{type:"submit",color:"error",icon:"i-lucide-refresh-cw",label:e(s)("cloud.details.reinstall.reinstallButton"),loading:e(b),disabled:!e(t).os||!e(t).password},null,8,["label","loading","disabled"])])]),_:1},8,["schema","state"])]),_:1})),n(X,{open:e(m),"onUpdate:open":o[3]||(o[3]=i=>ne(m)?m.value=i:null)},{header:r(()=>[a("div",Oe,[a("div",je,[n($,{name:"i-lucide-alert-triangle",class:"size-5 text-error"})]),a("div",null,[a("h3",Fe,c(e(s)("cloud.details.reinstall.reinstallButton")),1),e(w)?(d(),g("p",Le,c(e(w).label||e(w).name),1)):_("",!0)])])]),body:r(()=>[a("div",Me,[a("p",Pe,c(e(s)("cloud.details.reinstall.notice.dataLoss")),1),a("p",qe,c(e(s)("cloud.details.reinstall.notice.cannotBeUndone")),1)])]),footer:r(()=>[a("div",Ae,[n(C,{label:e(s)("common.actions.cancel"),color:"neutral",variant:"ghost",onClick:o[2]||(o[2]=i=>m.value=!1)},null,8,["label"]),n(C,{label:e(s)("cloud.details.reinstall.reinstallButton"),color:"error",loading:e(b),onClick:E},null,8,["label","loading"])])]),_:1},8,["open"])])}}});export{fs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.