import{rasa,jase,awasA}from"./index-CRR9sQ49.js";import{Aasb}from"./AdminAlert-DW1IRWce.js";import{AasM}from"./AdminButton-Bd2cLTu3.js";functionY(){const[t,T]=a.useState(null),[d,I]=a.useState(""),[j,L]=a.useState(""),[m,F]=a.useState("22"),[f,O]=a.useState("root"),[n,y]=a.useState("key"),[N,q]=a.useState(""),[g,U]=a.useState(""),[v,S]=a.useState(""),[w,k]=a.useState(""),[h,E]=a.useState([]),[P,u]=a.useState(!1),[H,C]=a.useState(null),[R,_]=a.useState(""),o=a.useRef(null);a.useEffect(()=>{fetch("/api/v1/public-install/config").then(s=>s.ok?s.json():Promise.reject(newError(`HTTP ${s.status}`))).then(s=>{T(s),k(s.default_install_url||"")}).catch(()=>I("Could not load installer configuration"))},[]),a.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[h]);constp=a.useCallback(s=>{E(c=>[...c.slice(-2e3),s])},[]);asyncfunction$(s){if(s.preventDefault(),_(""),E([]),C(null),!(t!=null&&t.enabled))return;constc=w.trim()||t.default_install_url,K=n==="key"?{type:"key",private_key:N,passphrase:g||null}:{type:"password",password:v},B={host:j.trim(),port:parseInt(m,10)||22,username:f.trim(),auth:K,install_url:c===t.default_install_url?null:c};u(!0);try{constl=awaitfetch("/api/v1/public-install/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)});if(!l.ok){consti=awaitl.json().catch(()=>({}));thrownewError(i.detail||`HTTP ${l.status}`)}const{job_id:W}=awaitl.json(),J=window.location.protocol==="https:"?"wss:":"ws:",x=newWebSocket(`${J}//${window.location.host}/api/v1/public-install/ws/${W}`);x.onmessage=i=>{try{constr=JSON.parse(i.data);r.type==="line"&&typeofr.text=="string"&&p(r.text),r.type==="done"&&C(typeofr.exit_code=="number"?r.exit_code:-1)}catch{p(String(i.data))}},x.onerror=()=>p("[websocket error]"),x.onclose=()=>u(!1)}catch(l){_(linstanceofError?l.message:"Request failed"),u(!1)}finally{n==="password"&&S("")}}return!t&&!d?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary",children:e.jsx("p",{className:"text-secondary mb-0",children:"Loading…"})}):d?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary p-3",children:e.jsx(b,{children:d})}):t&&!t.enabled?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary p-3",children:e.jsx("div",{className:"card shadow-sm w-100",style:{maxWidth:520},children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("h1",{className:"h4 mb-3",children:"Remote SSH installer disabled"}),e.jsxs("p",{className:"small text-secondary mb-3",children:["Enable it on the API server with environment variable"," ",e.jsx("code",{children:"ENABLE_REMOTE_INSTALLER=true"})," and restart the backend. Prefer SSH keys; exposing this endpoint increases risk."]}),e.jsx("p",{className:"small text-secondary mb-3",children:"One-liner on the target server (as root):"}),e.jsxs("pre",{className:"bg-dark text-success small p-3 rounded mb-3 mb-0 overflow-auto",children:["curl -fsSL ",t.default_install_url," | bash"]}),e.jsx(A,{to:"/login",className:"btn btn-link btn-sm px-0 mt-3",children:"Panel login"})]})})}):e.jsx("div",{className:"min-vh-100 bg-body-secondary py-4 px-3",children:e.jsxs("div",{className:"container",style:{maxWidth:900},children:[e.jsxs(b,{variant:"warning",className:"mb-3",children:[e.jsx("strong",{children:"Security warning:"})," SSH credentials are sent to this panel API and used only for this session (not stored). Prefer ",e.jsx("strong",{children:"SSH private keys"}),". Root password SSH is often disabled on Ubuntu. Non-root users need ",e.jsx("strong",{children:"passwordless sudo"})," (",e.jsx("code",{children:"sudo -n"}),") to run the installer. Allow SSH from this server to the target on port ",m,"."]}),e.jsx("div",{className:"card shadow-sm",children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("h1",{className:"h4 mb-2",children:"Remote install (SSH)"}),e.jsxs("p",{className:"small text-secondary mb-4 mb-0",children:["Runs the published ",e.jsx("co