import{h as x,f as w,i as f,au as y,E as I}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{j as e,S as j,v,h as c}from"./vendor-ClLR6ncd.js";import{u as b}from"./useCleaningReplQueriesCache-Cg0Wo1gv.js";import{W as C}from"./WarningMessage-4TK5GdCH.js";import{S}from"./SmallStandardSelect-7k6-Wr8Q.js";import{I as N,i as u,a as P,e as i,n as T,u as M,C as r}from"./inputsContext-DcO_XRZd.js";import{A as k}from"./Autocomplete-Cjt7Q9VV.js";function G(t,s,{onDownloadProgress:l,onMutate:o}={}){const n=b(),a=x((p,h)=>{const d=new URL(w(h,"repl",s),window.origin);for(const[g,{value:m}]of Object.entries(t))g==="catalog"&&m==="root"||m&&d.searchParams.append(g,m);return f({url:d.toString(),method:"put",onDownloadProgress:l})},{onMutate:o,onSuccess:n});return y("The conversion action will continue in the background. Are you sure?",a.isLoading),a}const R=new URL(window.origin).protocol.slice(0,-1),q={scheme:R,host:{isInvalid:u,errorMessage:i("Host")},port:{isInvalid:P,errorMessage:T("Port")},user:{error:i("User"),isInvalid:u,errorMessage:i("User")},password:{error:i("Password"),isInvalid:u,errorMessage:i("Password")},group:"",instanceName:""},J={...q,catalog:"",name:{isInvalid:u,errorMessage:i("Repository")}},L=["http","https"].map(t=>({label:t,value:t}));function V({initOptions:t,children:s}){const l=I(["host-port-info"],async()=>{const o=await f({url:"/hostPortInfo"});return{host:o.hostname,port:n=>n.scheme.value==="http"?o.http:o.https}});return e.jsx(N,{initOptions:t,queryHook:l,children:s})}const A={pr:0,pb:"15px"},E=t=>t==="127.0.0.1"||t==="127.1"||t==="::1"||t==="[::1]"||t==="0.0.0.0"||t==="localhost";function Y({warningMessage:t,startMessage:s}){return e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"h5",children:"About it"}),e.jsx(c,{children:s}),e.jsx(c,{children:"In this dialog you must specify the location of this repository instance in a way that's reachable from all other machines on which you'll run replicas of this instance. Don't use localhost as the host name unless you plan to run all cluster instances on this one machine."}),e.jsx(c,{children:"The instance will start a network listener on a port within the range specified by ReplicationPorts in agraph.cfg. If none were specified then the operating system will choose a random port. This port must be reachable from all other instances on all other machines that run instances of this cluster in the future."}),e.jsx(C,{text:t})]})}function _({catalogs:t}){const{options:s,optionsSetter:l,optionsTargetValueSetter:o,queryHook:{isLoading:n}}=M(),a=E(s.host.value);return e.jsxs(j,{children:[e.jsx(S,{items:L,value:s.scheme.value,onChange:o.scheme,label:"Scheme",sx:A}),e.jsx(r,{disabled:n,required:!0,label:"Host",optionName:"host",focused:a,color:a?"warning":void 0,helperText:a?"You should avoid the hostname localhost as that will not work properly for access from other machines.":void 0}),e.jsx(r,{disabled:n,required:!0,label:"Port",optionName:"port"}),t?e.jsxs(e.Fragment,{children:[e.jsx(k,{options:t,onChange:(p,h)=>l.catalog(h||""),renderInput:p=>e.jsx(v,{...p,variant:"standard",label:"Catalog",helperText:"If not specified root catalog is used"})}),e.jsx(r,{required:!0,label:"Repository",optionName:"name"})]}):null,e.jsx(r,{required:!0,label:"Username",optionName:"user"}),e.jsx(r,{required:!0,label:"Password",type:"password",optionName:"password"}),e.jsx(r,{label:"Group",optionName:"group"}),e.jsx(r,{label:"Instance name",optionName:"instanceName"})]})}export{V as C,Y as I,_ as N,J as a,q as i,G as u};
