"use strict";(()=>{var e={};e.id=338,e.ids=[338],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},67006:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>m,originalPathname:()=>y,requestAsyncStorage:()=>g,routeModule:()=>l,serverHooks:()=>P,staticGenerationAsyncStorage:()=>p,staticGenerationBailout:()=>h});var a={};t.r(a),t.d(a,{GET:()=>u,POST:()=>c}),t(95655);var o=t(83323),n=t(54647),i=t(66886),s=t(30953);async function u(){try{let e=await s._.category.findMany({include:{_count:{select:{products:!0}}},orderBy:{nameEn:"asc"}});return i.Z.json(e,{headers:{"Cache-Control":"s-maxage=60, stale-while-revalidate=300"}})}catch(e){return console.error("Error fetching categories:",e),i.Z.json({error:"Failed to fetch categories"},{status:500})}}async function c(e){try{let r=await e.json(),{nameEn:t,nameFr:a,descriptionEn:o,descriptionFr:n,image:u,slug:c}=r;if(!t||!c)return i.Z.json({error:"Name (EN) and Slug are required"},{status:400});let d=await s._.category.findUnique({where:{slug:c}});if(d)return i.Z.json({error:"Category with this slug already exists"},{status:400});let l=await s._.category.create({data:{nameEn:t,nameFr:a||t,descriptionEn:o,descriptionFr:n,image:u,slug:c}});return i.Z.json(l)}catch(e){return console.error("Error creating category:",e),i.Z.json({error:"Failed to create category"},{status:500})}}let d=o.AppRouteRouteModule,l=new d({definition:{kind:n.x.APP_ROUTE,page:"/api/admin/categories/route",pathname:"/api/admin/categories",filename:"route",bundlePath:"app/api/admin/categories/route"},resolvedPagePath:".\\app\\api\\admin\\categories\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:g,staticGenerationAsyncStorage:p,serverHooks:P,headerHooks:m,staticGenerationBailout:h}=l,y="/api/admin/categories/route"},30953:(e,r,t)=>{t.d(r,{_:()=>n});var a=t(53524);let o=globalThis,n=o.prisma??new a.PrismaClient},54647:(e,r)=>{var t;Object.defineProperty(r,"x",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(t||(t={}))}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[9727,3497,6886],()=>t(67006));module.exports=a})();