(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,38036,e=>{"use strict";var t=e.i(54858);let r="auth_token";function s(){return localStorage.getItem(r)}function n(e){localStorage.setItem(r,e)}function o(){localStorage.removeItem(r)}function a(){return null!==s()}async function i(e){let r=await (0,t.apiRequest)("/auth/login",{method:"POST",body:JSON.stringify(e)});return n(r.token),r}function l(){o()}e.s(["getToken",()=>s,"isAuthenticated",()=>a,"login",()=>i,"logout",()=>l,"removeToken",()=>o,"setToken",()=>n])},54858,e=>{"use strict";let t="http://localhost:3000";async function r(e,s={}){let n=`${t}${e}`,o=await fetch(n,{...s,headers:{"Content-Type":"application/json",...s.headers}}),a=await o.json();if(!o.ok)throw Error(a.error||"Request failed");return a}async function s(r,n={},o){let{getToken:a,removeToken:i}=await e.A(48323),l=a();if(!l)throw o&&o(),Error("Authentication required");let u=`${t}${r}`,c=await fetch(u,{...n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`,...n.headers}}),d=await c.json();if(401===c.status)throw i(),o&&o(),Error(d.error||"Authentication failed");if(!c.ok)throw Error(d.error||"Request failed");return d}e.s(["apiRequest",()=>r,"authenticatedRequest",()=>s])},18566,(e,t,r)=>{t.exports=e.r(76562)},89954,e=>{"use strict";var t=e.i(43476),r=e.i(71645),s=e.i(18566),n=e.i(38036);function o(){let e=(0,s.useRouter)(),[o,a]=(0,r.useState)(""),[i,l]=(0,r.useState)(""),[u,c]=(0,r.useState)(null),[d,m]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(0,n.isAuthenticated)()&&e.push("/events")},[e]);let h=async t=>{t.preventDefault(),c(null),m(!0);try{await (0,n.login)({email:o,password:i}),e.push("/events")}catch(e){c(e instanceof Error?e.message:"Login failed")}finally{m(!1)}};return(0,t.jsx)("div",{className:"flex min-h-screen items-center justify-center",children:(0,t.jsxs)("main",{className:"w-full max-w-md space-y-8 rounded-lg border border-gray-200 p-8",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold text-center",children:"Login"}),(0,t.jsxs)("form",{onSubmit:h,className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",children:"Email"}),(0,t.jsx)("input",{id:"email",type:"email",value:o,onChange:e=>a(e.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",children:"Password"}),(0,t.jsx)("input",{id:"password",type:"password",value:i,onChange:e=>l(e.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),u&&(0,t.jsx)("div",{className:"text-red-600 text-sm",children:u}),(0,t.jsx)("button",{type:"submit",disabled:d,className:"w-full py-2 px-4 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Logging in...":"Login"})]})]})})}e.s(["default",()=>o])},48323,e=>{e.v(e=>Promise.resolve().then(()=>e(38036)))}]);