import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{l as t,p as n,t as r}from"./vendor-react-iIHq6SOl.js";import{i,n as a,o}from"./main-DgxOmW_I.js";var s=e(n(),1),c=r(),l=o(`/image/icon.png`),u=o(`/image/login_bg.jpg`);function d(){t();let{loginContext:e}=(0,s.useContext)(a),[n,r]=(0,s.useState)(``),[o,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(!1),v=async()=>{if(!n||!o){h(`Masukkan username dan password.`);return}_(!0),h(``);try{let t=await i(n,o),r=t.data?.token||t.token,a=t.data?.user||t.data?.admin||t.user||t.admin||{name:n};if(!r)throw Error(`Token tidak ditemukan dalam respons`);e(a,r),window.location.href=`/admin/dashboard`}catch(e){h(e.response?.data?.message||e.message||`Username atau password salah.`)}finally{_(!1)}};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`style`,{children:`
        .login-screen { min-height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('${u}') center/cover no-repeat; padding:24px; }
        .login-card { background:white; border-radius:20px; padding:40px 36px; width:100%; max-width:400px; box-shadow:0 24px 64px rgba(0,17,120,0.22); border:1px solid rgba(228, 231, 237, 0.8); }
        .login-logo { text-align:center; margin-bottom:28px; }
        .login-logo h2 { color:#001178; font-size:22px; font-weight:800; margin-top:12px; letter-spacing:-0.4px; }
        .login-logo p { color:#64748B; font-size:13.5px; margin-top:4px; }
        .login-field { display:flex; flex-direction:column; gap:6px; margin-bottom:18px; }
        .login-field label { font-size:12px; font-weight:700; color:#334155; text-transform:uppercase; letter-spacing:0.5px; }
        .login-field input { border:1px solid #D9DEE5; border-radius:8px; padding:11px 14px; min-height:44px; font-size:13.5px; font-family:inherit; background:#fff; width:100%; color:#0F172A; box-sizing:border-box; transition:border-color 0.2s, box-shadow 0.2s; }
        .login-field input:focus { outline:none; border-color:#0028B3; box-shadow:0 0 0 3.5px rgba(0,40,179,0.15); }
        .pw-wrapper { position:relative; }
        .pw-wrapper input { padding-right:44px !important; }
        .btn-pw { position:absolute; right:12px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; color:#64748B; padding:4px; display:flex; align-items:center; transition:color 0.15s; }
        .btn-pw:hover { color:#0028B3; }
        .btn-login { width:100%; background:#0028B3; color:white; border:none; border-radius:8px; padding:12px; min-height:46px; font-size:14.5px; font-weight:700; cursor:pointer; font-family:inherit; transition:all 0.2s cubic-bezier(0.4,0,0.2,1); margin-top:6px; box-shadow:0 4px 16px rgba(0,40,179,0.25); display:inline-flex; align-items:center; justify-content:center; }
        .btn-login:hover:not(:disabled) { background:#001178; transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,17,120,0.3); }
        .btn-login:active:not(:disabled) { transform:translateY(0); }
        .btn-login:disabled { background:#94A3B8; cursor:not-allowed; transform:none; }
        .login-err { color:#B91C1C; font-size:13px; text-align:center; margin-top:14px; padding:8px 12px; background:#FEF2F2; border-radius:8px; border:1px solid #FCA5A5; }
      `}),(0,c.jsx)(`div`,{className:`login-screen`,children:(0,c.jsxs)(`div`,{className:`login-card`,children:[(0,c.jsxs)(`div`,{className:`login-logo`,children:[(0,c.jsx)(`img`,{src:l,alt:`Logo`,style:{height:`48px`,width:`auto`,margin:`0 auto`,display:`block`},referrerPolicy:`no-referrer`}),(0,c.jsx)(`h2`,{children:`Admin Login`}),(0,c.jsx)(`p`,{children:`Sistem Kunjungan Kerja`})]}),(0,c.jsxs)(`div`,{className:`login-field`,children:[(0,c.jsx)(`label`,{children:`Username`}),(0,c.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&v(),placeholder:`Masukkan username`})]}),(0,c.jsxs)(`div`,{className:`login-field`,children:[(0,c.jsx)(`label`,{children:`Password`}),(0,c.jsxs)(`div`,{className:`pw-wrapper`,children:[(0,c.jsx)(`input`,{type:f?`text`:`password`,value:o,onChange:e=>d(e.target.value),onKeyDown:e=>e.key===`Enter`&&v(),placeholder:`Masukkan password`}),(0,c.jsx)(`button`,{type:`button`,className:`btn-pw`,onClick:()=>p(!f),children:f?(0,c.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,c.jsx)(`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`}),(0,c.jsx)(`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`}),(0,c.jsx)(`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`}),(0,c.jsx)(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`})]}):(0,c.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,c.jsx)(`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`}),(0,c.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})})]})]}),(0,c.jsx)(`button`,{className:`btn-login`,disabled:g,onClick:v,children:g?`Memeriksa...`:`Masuk`}),m&&(0,c.jsx)(`p`,{className:`login-err`,children:m})]})})]})}export{d as default};