"use strict";(()=>{var e={};e.id=571,e.ids=[571],e.modules={11185:e=>{e.exports=require("mongoose")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},56501:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>g,requestAsyncStorage:()=>f,routeModule:()=>v,serverHooks:()=>h,staticGenerationAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{POST:()=>d});var n=t(49303),o=t(88716),a=t(60670),i=t(87070),u=t(98691),p=t(14184),c=t(58480),l=t(95456);async function d(e){try{await (0,p.Z)();let{password:r}=await e.json();if(!r)return i.NextResponse.json({success:!1,error:"Password is required"},{status:400});let t=await c.Z.findOne();if(!t)return i.NextResponse.json({success:!1,error:"App not set up. Call /api/auth/setup first."},{status:404});if(!await u.ZP.compare(r,t.passwordHash))return i.NextResponse.json({success:!1,error:"Invalid password"},{status:401});let s=process.env.JWT_SECRET||t.jwtSecret,n=(0,l.fT)({role:"user"},s);return i.NextResponse.json({success:!0,data:{token:n}})}catch(e){return i.NextResponse.json({success:!1,error:e instanceof Error?e.message:"Failed to verify password"},{status:500})}}let v=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/auth/verify/route",pathname:"/api/auth/verify",filename:"route",bundlePath:"app/api/auth/verify/route"},resolvedPagePath:"E:\\WEB Project\\My Plan\\src\\app\\api\\auth\\verify\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:f,staticGenerationAsyncStorage:m,serverHooks:h}=v,x="/api/auth/verify/route";function g(){return(0,a.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:m})}},95456:(e,r,t)=>{t.d(r,{Gl:()=>i,fT:()=>a});var s=t(41482),n=t.n(s);let o=process.env.JWT_SECRET||"my-plan-app-secret-key-change-this";function a(e,r){return n().sign(e,r||o,{expiresIn:"30d"})}function i(e){var r;let t=(r=e.headers.get("Authorization"))&&r.startsWith("Bearer ")?r.slice(7):null;return t?!function(e,r){try{return n().verify(e,r||o)}catch{return null}}(t,process.env.JWT_SECRET||o)?{valid:!1,error:"Invalid or expired token"}:{valid:!0}:{valid:!1,error:"No token provided"}}},14184:(e,r,t)=>{t.d(r,{Z:()=>i});var s=t(11185),n=t.n(s);let o=process.env.MONGODB_URI;if(!o)throw Error("Please define the MONGODB_URI environment variable inside .env.local");let a=global.mongoose;a||(a=global.mongoose={conn:null,promise:null});let i=async function(){if(a.conn)return a.conn;a.promise||(a.promise=n().connect(o,{bufferCommands:!1}));try{a.conn=await a.promise}catch(e){throw a.promise=null,e}return a.conn}},58480:(e,r,t)=>{t.d(r,{Z:()=>a});var s=t(11185),n=t.n(s);let o=new s.Schema({passwordHash:{type:String,required:!0},jwtSecret:{type:String,required:!0}},{timestamps:!0}),a=n().models.AppSettings||n().model("AppSettings",o)}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[948,972,843,482,691],()=>t(56501));module.exports=s})();