(()=>{var e={};e.id=9810,e.ids=[9810],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,t,r)=>{"use strict";function n(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function s(e){let t=e.headers.get("authorization");if(t&&t.startsWith("Bearer "))return t.slice(7);let r=e.cookies.get("admin_token")?.value;if(r)return r;let n=e.cookies.get("token")?.value;return n||null}r.d(t,{V:()=>s,u:()=>n})},15151:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>y,routeModule:()=>A,serverHooks:()=>w,workAsyncStorage:()=>g,workUnitAsyncStorage:()=>h});var n={};r.r(n),r.d(n,{GET:()=>f,POST:()=>v});var s=r(96559),a=r(48088),i=r(37719),o=r(32190),u=r(43205),c=r.n(u),d=r(96330),p=r(12909);let l=new d.PrismaClient,m=(0,p.u)();async function x(e){let t=(0,p.V)(e);if(!t)return null;try{let e=c().verify(t,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function f(e){try{if(!await x(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await l.announcement.findMany({orderBy:{createdAt:"desc"}});return await l.$disconnect(),o.NextResponse.json({announcements:t.map(e=>({id:e.id,title:e.title,content:e.content,isActive:e.isActive,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()}))})}catch(e){return console.error("Get announcements error:",e),await l.$disconnect(),o.NextResponse.json({error:"Server error"},{status:500})}}async function v(e){try{if(!await x(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let{title:t,content:r,isActive:n}=await e.json();if(!t||!r)return o.NextResponse.json({error:"Title and content are required"},{status:400});let s=await l.announcement.create({data:{title:t,content:r,isActive:void 0===n||n}});return await l.$disconnect(),o.NextResponse.json({message:"Announcement created successfully",announcement:{id:s.id,title:s.title,content:s.content,isActive:s.isActive,createdAt:s.createdAt.toISOString(),updatedAt:s.updatedAt.toISOString()}})}catch(t){console.error("Create announcement error:",t),await l.$disconnect();let e=t?.message||"Server error";return o.NextResponse.json({error:e},{status:500})}}let A=new s.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/admin/announcements/route",pathname:"/api/admin/announcements",filename:"route",bundlePath:"app/api/admin/announcements/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/announcements/route.ts",nextConfigOutput:"standalone",userland:n}),{workAsyncStorage:g,workUnitAsyncStorage:h,serverHooks:w}=A;function y(){return(0,i.patchFetch)({workAsyncStorage:g,workUnitAsyncStorage:h})}},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{"use strict";e.exports=require("crypto")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[4447,580,3205],()=>r(15151));module.exports=n})();