import{Z as t,_,V as $,$ as B,a0 as I,s as H,j as e,g as a,a1 as k,a2 as M}from"./index-OkLaRrT4.js";import{r as d,a1 as V,E as G}from"./mui-icons-DSJWgROT.js";import{l as W}from"./mui-x-datagrid-Uj6xW2G5.js";import{T as g,p as Y}from"./mui-x-charts-BC4WZfuI.js";import"./mui-x-pickers-DVr_eQ3-.js";const K=t.div`
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  width: 678px;
  max-width: 100%;
  min-height: 480px;

  /* Tablet */
  @media (max-width: 900px) {
    width: min(678px, calc(100% - 48px));
  }

  /* Mobile */
  @media (max-width: 599px) {
    width: calc(100% - 32px);
    min-height: 420px;
    border-radius: 12px;
  }
`,Q=t.div`
  position: absolute;
  top: 0;
  height: 100%;
  transition: all 0.6s ease-in-out;
  left: 0;
  width: 50%;
  opacity: 0;
  z-index: 1;
  ${n=>!n.signinIn&&`
    transform: translateX(100%);
    opacity: 1;
    z-index: 5;
  `}

  @media (max-width: 599px) {
    width: 100%;
  }
`,Z=t.div`
  position: absolute;
  top: 0;
  height: 100%;
  transition: all 0.6s ease-in-out;
  left: 0;
  width: 50%;
  z-index: 2;
  ${n=>n.signinIn?null:"transform: translateX(100%);"}

  /* Full width on mobile — overlay is hidden */
  @media (max-width: 599px) {
    width: 100%;
  }
`,S=t.form`
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 30px;
  height: 100%;
  text-align: center;

  @media (max-width: 599px) {
    padding: 24px 20px;
  }
`,c=t.h1`
  font-weight: bold;
  margin: 0;

  @media (max-width: 599px) {
    font-size: 1.4rem;
  }
`,o=t.input`
  background-color: #eee;
  border: none;
  padding: 12px 15px;
  margin: 8px 0;
  width: 100%;
  border-radius: 4px;

  @media (max-width: 599px) {
    padding: 10px 14px;
    font-size: 15px;
  }
`,h=t.button`
  border-radius: 20px;
  border: 1px solid #196ae5;
  background-color: #196ae5;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  font-weight: bold;
  padding: 12px 45px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 80ms ease-in;
  &:active {
    transform: scale(0.95);
  }
  &:focus {
    outline: none;
  }

  @media (max-width: 599px) {
    width: 100%;
    padding: 12px 20px;
  }
`,v=t(h)`
  background-color: transparent;
  border-color: #ffffff;
  cursor: pointer;
`;t.a`
  color: #333;
  font-size: 14px;
  text-decoration: none;
  margin: 15px 0;
`;const q=t.div`
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  overflow: hidden;
  transition: transform 0.6s ease-in-out;
  z-index: 100;
  ${n=>n.signinIn?null:"transform: translateX(-100%);"}

  /* Hide the overlay panel on mobile — form takes full width */
  @media (max-width: 599px) {
    display: none;
  }
`,J=t.div`
  background: #b060bc;
  background: -webkit-linear-gradient(45deg, #b060bcba, #23a6d5c2);
  background: linear-gradient(45deg, #b060bcba, #23a6d5c2);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 0 0;
  color: #ffffff;
  position: relative;
  left: -100%;
  height: 100%;
  width: 200%;
  transform: translateX(0);
  transition: transform 0.6s ease-in-out;
  ${n=>n.signinIn?null:"transform: translateX(50%);"}
`,P=t.div`
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 40px;
  text-align: center;
  top: 0;
  height: 100%;
  width: 50%;
  transform: translateX(0);
  transition: transform 0.6s ease-in-out;
`,ee=t(P)`
  transform: translateX(-20%);
  ${n=>n.signinIn?null:"transform: translateX(0);"}
`,ne=t(P)`
  right: 0;
  transform: translateX(0);
  ${n=>n.signinIn?null:"transform: translateX(20%);"}
`,T=t.p`
  font-size: 14px;
  font-weight: 100;
  line-height: 20px;
  letter-spacing: 0.5px;
  margin: 20px 0 30px;
`;function C(n){return a(g,{variant:"body2",color:"text.secondary",align:"center",...n,mt:2,children:["Copyright © ",e(M,{color:"inherit",href:"https://huewine.com/",target:"_blank",children:"Huewine Technologies"})," ",new Date().getFullYear(),"."]})}const te=V();G("div")(({theme:n})=>({...n.typography.button,backgroundColor:n.palette.background.paper,padding:n.spacing(1),textAlign:"center"}));function ge(){const[n,i]=d.useState(""),m=_(),f=$(),[D]=B();I({userRoleDTOList:[]},{});const[r,x]=d.useState(!0),[ae,ie]=d.useState({firstName:"",userName:"",phoneNumber:void 0,password:"",gender:""}),{userId:E,accessToken:re}=H(l=>l.user),{data:z,isFetching:N,error:oe}=I({userRoleDTOList:[]},{skip:!E}),U=async l=>{l.preventDefault();const w=new FormData(l.currentTarget),p=w.get("username"),u=w.get("password");if(p.trim()){if(!u.trim()){i("Please enter your password.");return}}else{i("Please enter your username.");return}const A="admin",F="admin123",R="mocked-static-token-123",X=1;if(p===A&&u===F){m(k({userId:X,accessToken:R})),f("/");return}const O={userName:p,password:u,applicationName:"ERP"};try{const s=await D({Login:O});if("data"in s)if(s.data&&s.data.code===200){const y=s.data,L=y.user.id,j=y.user.token;m(k({userId:L,accessToken:j})),f("/")}else i("Login Failed. Invalid credentials.");else i("Login Failed. Please try again.")}catch{i("Login Failed. Please try again.")}};d.useEffect(()=>{},[z,N]);const b=()=>{i("")};return e(Y,{theme:te,children:e(W,{className:"loginpage",sx:{position:"fixed",inset:0,display:"flex",justifyContent:"center",alignItems:"center",zIndex:1300,p:{xs:2,sm:3}},children:a(K,{children:[e(Q,{signinIn:r,children:a(S,{className:"no-spinner",onSubmit:()=>{},children:[e(c,{children:"Create Account"}),e(o,{type:"text",placeholder:"Name"}),e(o,{type:"text",placeholder:"Username"}),e(o,{type:"password",placeholder:"Password"}),e(o,{type:"number",placeholder:"Phone Number"}),e(h,{children:"Sign Up"}),e(C,{})]})}),e(Z,{signinIn:r,children:a(S,{onSubmit:U,children:[e(g,{variant:"button",display:"block",gutterBottom:!0,style:{textAlign:"center",fontSize:"1.5rem"},children:"Huewine"}),e(c,{children:"Sign in"}),e(o,{type:"text",placeholder:"Username",name:"username",onChange:b}),e(o,{type:"password",autoComplete:"off",placeholder:"Password",name:"password",onChange:b}),n.length>0&&e(g,{style:{color:"red",margin:"10px 0px"},children:n}),e(h,{type:"submit",style:{marginTop:"10px"},children:"Sign In"}),e(C,{})]})}),e(q,{signinIn:r,children:a(J,{signinIn:r,children:[a(ee,{signinIn:r,children:[e(c,{children:"Welcome Back!"}),e(T,{children:"To keep connected with us please login with your personal info"}),e(v,{onClick:()=>x(!0),children:"Sign In"})]}),a(ne,{signinIn:r,children:[e(c,{children:"Hello, Friend!"}),e(T,{children:"Enter Your personal details and start a journey with us"}),e(v,{onClick:()=>x(!1),children:"Sign Up"})]})]})})]})})})}export{ge as default};
