import{w as P,O as d,L as p,J as t,G as n,P as O,V as E,W as F,R as v,F as y,S as g,N as l,r as c,b as k,T as M,I as a,U as _,Y as x,Z as V,_ as W,K as S,M as C,Q as T,$ as j,e as z}from"./index-iCRehgtD.js";import{u as D,Q as q}from"./useSetupWs-P74ozpSr.js";import{u as G}from"./setup-B2WhYkmc.js";const H={key:0,class:"q-mt-md q-ml-lg q-gutter-md"},J={class:"row justify-between"},K={class:"row q-gutter-sm"},oe={__name:"RepoSetupPage",setup(Y){const w=M(),o=G(),{send:R,messages:h,clearMessages:I}=D(),u=c(!1),f=c(!1),m=c(0),i=c([]),b=c(null),Q=k(()=>o.osInfo?`${o.repoType==="subscription"?"https://download.bareos.com/bareos/release/latest":"https://download.bareos.org/current"}/${B(o.osInfo.distro,o.osInfo.version)}/`:"(OS not yet detected)");function B(s,e){return["almalinux","centos","ol","openela","oracle","rocky"].includes(s)?`EL_${String(e).split(".")[0]}`:`${s?s.charAt(0).toUpperCase()+s.slice(1):""}_${e}`}const U=k(()=>{var s,e;return!((s=o.osInfo)!=null&&s.distro)||!((e=o.osInfo)!=null&&e.version)?!1:o.repoType==="subscription"?!!o.repoCredentials.login&&!!o.repoCredentials.password:!0});P(h,s=>{const e=s[s.length-1];!e||!u.value||(e.type==="output"?(i.value.push({text:e.line,cls:e.stream==="stderr"?"output-line-err":"output-line-out"}),z(()=>{b.value&&(b.value.scrollTop=b.value.scrollHeight)})):e.type==="done"?(u.value=!1,f.value=!0,m.value=e.exit_code,e.exit_code===0&&(o.repoAdded=!0)):e.type==="error"&&(u.value=!1,f.value=!0,m.value=1,i.value.push({text:e.message||"Repository setup failed.",cls:"output-line-err"})))},{deep:!0});function $(){var s,e;I(),i.value=[],f.value=!1,u.value=!0,o.repoAdded=!1,R({action:"run_step",id:"add_repo",sudo:!0,repo_type:o.repoType,distro:(s=o.osInfo)==null?void 0:s.distro,version:(e=o.osInfo)==null?void 0:e.version,repo_login:o.repoType==="subscription"?o.repoCredentials.login:"",repo_password:o.repoType==="subscription"?o.repoCredentials.password:""})}function A(){o.prevStep(),w.push("/os")}function L(){o.nextStep(),w.push("/install")}return(s,e)=>(a(),d("div",null,[e[5]||(e[5]=p("div",{class:"step-header"},"Configure Repository",-1)),e[6]||(e[6]=p("p",{class:"text-body2 q-mb-md"}," Choose the Bareos package repository to use for installation. ",-1)),t(O,{flat:"",bordered:"",class:"q-mb-md"},{default:n(()=>[t(_,null,{default:n(()=>[t(x,{modelValue:l(o).repoType,"onUpdate:modelValue":e[0]||(e[0]=r=>l(o).repoType=r),val:"subscription",label:"Subscription (requires Bareos subscription)",color:"primary"},null,8,["modelValue"]),l(o).repoType==="subscription"?(a(),d("div",H,[t(V,{modelValue:l(o).repoCredentials.login,"onUpdate:modelValue":e[1]||(e[1]=r=>l(o).repoCredentials.login=r),label:"Subscription login",dense:"",outlined:"",rules:[r=>!!r||"Login is required"]},null,8,["modelValue","rules"]),t(V,{modelValue:l(o).repoCredentials.password,"onUpdate:modelValue":e[2]||(e[2]=r=>l(o).repoCredentials.password=r),label:"Subscription password",type:"password",dense:"",outlined:"",rules:[r=>!!r||"Password is required"]},null,8,["modelValue","rules"])])):v("",!0)]),_:1}),t(W),t(_,null,{default:n(()=>[t(x,{modelValue:l(o).repoType,"onUpdate:modelValue":e[3]||(e[3]=r=>l(o).repoType=r),val:"community",label:"Community (free)",color:"primary"},null,8,["modelValue"])]),_:1})]),_:1}),t(q,{class:"bg-info text-white q-mb-lg",rounded:""},{avatar:n(()=>[t(T,{name:"info"})]),default:n(()=>[e[4]||(e[4]=S(" Repository URL: ",-1)),p("code",null,C(Q.value),1)]),_:1}),i.value.length?(a(),d("div",{key:0,class:"output-console q-mb-md",ref_key:"console_",ref:b},[(a(!0),d(E,null,F(i.value,(r,N)=>(a(),d("div",{key:N,class:j(r.cls)},C(r.text),3))),128))],512)):v("",!0),f.value&&m.value!==0?(a(),y(q,{key:1,class:"bg-negative text-white q-mb-md",rounded:""},{avatar:n(()=>[t(T,{name:"error"})]),default:n(()=>[S(" Repository setup failed (exit code "+C(m.value)+"). Check output above. ",1)]),_:1})):v("",!0),p("div",J,[t(g,{flat:"",label:"Back",icon:"arrow_back",disable:u.value,onClick:A},null,8,["disable"]),p("div",K,[l(o).repoAdded?(a(),y(g,{key:1,label:"Continue",color:"primary","icon-right":"arrow_forward",onClick:L})):(a(),y(g,{key:0,label:"Add Repository",color:"secondary",icon:"source",loading:u.value,disable:!U.value,onClick:$},null,8,["loading","disable"]))])])]))}};export{oe as default};
