"use strict";(()=>{var e={};e.id=179,e.ids=[179],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")},67509:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>y,patchFetch:()=>x,requestAsyncStorage:()=>f,routeModule:()=>m,serverHooks:()=>v,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>p,PUT:()=>l});var n=t(49303),o=t(88716),i=t(60670),a=t(87070),u=t(14184),c=t(29045),d=t(95456);async function l(e,{params:r}){try{let{valid:t,error:s}=(0,d.Gl)(e);if(!t)return a.NextResponse.json({success:!1,error:s},{status:401});await (0,u.Z)();let n=await e.json(),o=await c.Z.findByIdAndUpdate(r.id,{$set:n},{new:!0,runValidators:!0});if(!o)return a.NextResponse.json({success:!1,error:"Block not found"},{status:404});return a.NextResponse.json({success:!0,data:o})}catch(e){return a.NextResponse.json({success:!1,error:e instanceof Error?e.message:"Failed to process request"},{status:500})}}async function p(e,{params:r}){try{let{valid:t,error:s}=(0,d.Gl)(e);if(!t)return a.NextResponse.json({success:!1,error:s},{status:401});if(await (0,u.Z)(),!await c.Z.findByIdAndDelete(r.id))return a.NextResponse.json({success:!1,error:"Block not found"},{status:404});return a.NextResponse.json({success:!0,data:{id:r.id}})}catch(e){return a.NextResponse.json({success:!1,error:e instanceof Error?e.message:"Failed to process request"},{status:500})}}let m=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/schedule/block/[id]/route",pathname:"/api/schedule/block/[id]",filename:"route",bundlePath:"app/api/schedule/block/[id]/route"},resolvedPagePath:"E:\\WEB Project\\My Plan\\src\\app\\api\\schedule\\block\\[id]\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:f,staticGenerationAsyncStorage:h,serverHooks:v}=m,y="/api/schedule/block/[id]/route";function x(){return(0,i.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:h})}},95456:(e,r,t)=>{t.d(r,{Gl:()=>a,fT:()=>i});var s=t(41482),n=t.n(s);let o=process.env.JWT_SECRET||"my-plan-app-secret-key-change-this";function i(e,r){return n().sign(e,r||o,{expiresIn:"30d"})}function a(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:()=>a});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 i=global.mongoose;i||(i=global.mongoose={conn:null,promise:null});let a=async function(){if(i.conn)return i.conn;i.promise||(i.promise=n().connect(o,{bufferCommands:!1}));try{i.conn=await i.promise}catch(e){throw i.promise=null,e}return i.conn}},29045:(e,r,t)=>{t.d(r,{Z:()=>i});var s=t(11185),n=t.n(s);let o=new s.Schema({dayOfWeek:{type:String,required:!0},startTime:{type:String,required:!0},endTime:{type:String,required:!0},activityName:{type:String,required:!0},blockType:{type:String,required:!0},color:{type:String,required:!0}}),i=n().models.ScheduleBlock||n().model("ScheduleBlock",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],()=>t(67509));module.exports=s})();