"use strict";(()=>{var e={};e.id=4108,e.ids=[4108],e.modules={72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},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")},94454:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>f,requestAsyncStorage:()=>p,routeModule:()=>d,serverHooks:()=>x,staticGenerationAsyncStorage:()=>g});var n={};r.r(n),r.d(n,{GET:()=>l});var s=r(49303),a=r(88716),i=r(60670),o=r(87070),u=r(8194),c=r(95456);async function l(e){try{let t=await (0,c.ts)();if(!t)return o.NextResponse.json({error:"Unauthorized"},{status:401});if(!["owner","admin"].includes(t.role))return o.NextResponse.json({error:"Forbidden"},{status:403});let r=e.nextUrl.searchParams,n=parseInt(r.get("page")||"1"),s=parseInt(r.get("limit")||"25"),a=(n-1)*s,i=r.get("entity"),l=r.get("action"),d=r.get("userId"),p=r.get("startDate"),g=r.get("endDate"),x={tenantId:t.tenantId};if(i&&(x.entity=i),l&&(x.action=l),d&&(x.userId=d),(p||g)&&(x.createdAt={},p&&(x.createdAt.gte=new Date(p)),g)){let e=new Date(g);e.setHours(23,59,59,999),x.createdAt.lte=e}let[m,f]=await Promise.all([u._.auditLog.findMany({where:x,orderBy:{createdAt:"desc"},take:s,skip:a}),u._.auditLog.count({where:x})]);return o.NextResponse.json({logs:m,pagination:{page:n,limit:s,total:f,totalPages:Math.ceil(f/s)}})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}let d=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/audit-logs/route",pathname:"/api/audit-logs",filename:"route",bundlePath:"app/api/audit-logs/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\audit-logs\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:p,staticGenerationAsyncStorage:g,serverHooks:x}=d,m="/api/audit-logs/route";function f(){return(0,i.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:g})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>d,MH:()=>m,PT:()=>f,RA:()=>p,WX:()=>g,c_:()=>l,ts:()=>x});var n=r(41482),s=r.n(n),a=r(42023),i=r.n(a),o=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function l(e){return i().hash(e,12)}async function d(e,t){return i().compare(e,t)}function p(e){return s().sign(e,c,{expiresIn:"7d"})}function g(e){try{return s().verify(e,c)}catch{return null}}async function x(){let e=await (0,o.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=g(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function m(e,t){return t.includes(e)}function f(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>s});let n=require("@prisma/client"),s=globalThis.prisma??new n.PrismaClient}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948,5972,4261,2023],()=>r(94454));module.exports=n})();