var T=Object.defineProperty,I=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var D=(t,a,s)=>a in t?T(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,N=(t,a)=>{for(var s in a||(a={}))O.call(a,s)&&D(t,s,a[s]);if(S)for(var s of S(a))A.call(a,s)&&D(t,s,a[s]);return t},f=(t,a)=>I(t,E(a));var y=(t,a,s)=>new Promise((x,b)=>{var h=n=>{try{l(s.next(n))}catch(r){b(r)}},u=n=>{try{l(s.throw(n))}catch(r){b(r)}},l=n=>n.done?x(n.value):Promise.resolve(n.value).then(h,u);l((s=s.apply(t,a)).next())});import{aU as P,j as e,aS as L,aX as U}from"./react-vendor-xYZnmIII.js";import{I as m}from"./input-error-_LAmvivg.js";import{L as d,at as R,au as k,av as H,aw as M,ax as q,I as p,B as _,c as F}from"./ui-components-CQM92IK3.js";import V from"./Layout-DRlegCuc.js";import Q from"./Message-CKMudK7b.js";import W from"./StepNavigator-BZxgvzIC.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const X=t=>{const{DB_HOST:a,DB_PORT:s,DB_DATABASE:x,DB_USERNAME:b,DB_PASSWORD:h,DB_CONNECTION:u,DB_CONNECTION_STATUS:l,flash:n}=t,{data:r,errors:c,post:B,setData:g}=P({db_connection:u||"mysql",db_host:a||"",db_port:s||"",db_database:x||"",db_username:b||"",db_password:h||""}),j=!!parseInt(l),i=o=>{const v=o.target;g(f(N({},r),{[v.name]:v.value}))},C=o=>y(null,null,function*(){o.preventDefault(),U.post(route("check-database"),r)}),w=o=>{o.preventDefault(),B(route("install.store-step3"))};return e.jsxs("div",{children:[e.jsx(W,{step1:"fill",step2:"fill",step3:"active"}),e.jsxs("form",{id:"dataForm",onSubmit:w,children:[e.jsx(Q,{error:n.error,success:n.success}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"Select Database Type"}),e.jsxs(R,{name:"db_connection",value:r.db_connection,onValueChange:o=>g("db_connection",o),children:[e.jsx(k,{children:e.jsx(H,{placeholder:"Select Database Type"})}),e.jsx(M,{children:e.jsx(q,{value:"mysql",children:"MySQL"})})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"DB Host"}),e.jsx(p,{id:"db_host",type:"text",name:"db_host",value:r.db_host,onChange:i,placeholder:"127.0.0.1"}),e.jsx(m,{message:c.db_host})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"DB Port"}),e.jsx(p,{id:"db_port",type:"text",name:"db_port",value:r.db_port,onChange:i,placeholder:"3306"}),e.jsx(m,{message:c.db_port})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"DB Database"}),e.jsx(p,{id:"db_database",type:"text",name:"db_database",value:r.db_database,onChange:i,placeholder:"Database Name"}),e.jsx(m,{message:c.db_database})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"DB Username"}),e.jsx(p,{id:"db_username",type:"text",name:"db_username",value:r.db_username,onChange:i,placeholder:"Username"}),e.jsx(m,{message:c.db_username})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx(d,{children:"DB Password"}),e.jsx(p,{id:"db_password",type:"password",name:"db_password",value:r.db_password,onChange:i,placeholder:"Password"}),e.jsx(m,{message:c.db_password})]}),e.jsx(_,{type:"button",className:F("w-full",j&&"bg-green-500",n.error&&"bg-red-500"),onClick:C,disabled:j,children:"Test Connection"}),e.jsxs("div",{className:"mt-12 flex items-center justify-end gap-4",children:[e.jsx(L,{href:route("install.show-step2"),children:e.jsx(_,{type:"button",variant:"outline",className:"border border-orange-500 !bg-transparent !text-orange-500 uppercase",children:"Previous Step"})}),j&&e.jsx(_,{type:"submit",className:"bg-orange-500 px-6 py-3 text-white uppercase hover:bg-orange-600/90",children:"Next Step"})]})]})]})};X.layout=t=>e.jsx(V,{children:t});export{X as default};
