"use strict";(()=>{var e={};e.id=6836,e.ids=[6836],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")},48852:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>f,requestAsyncStorage:()=>d,routeModule:()=>p,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m});var n={};r.r(n),r.d(n,{GET:()=>l});var s=r(49303),a=r(88716),o=r(60670),i=r(87070),u=r(8194),c=r(95456);async function l(e){try{let t=await (0,c.ts)();if(!t)return i.NextResponse.json({error:"Unauthorized"},{status:401});let r=e.nextUrl.searchParams.get("q")||"";if(r.length<2)return i.NextResponse.json({customers:[]});let n=await u._.customer.findMany({where:{tenantId:t.tenantId,isActive:!0,OR:[{name:{contains:r}},{phone:{contains:r}}]},select:{id:!0,name:!0,phone:!0,email:!0,loyaltyPoints:!0,lifetimePoints:!0},take:5,orderBy:{totalOrders:"desc"}});return i.NextResponse.json({customers:n})}catch{return i.NextResponse.json({error:"Internal server error"},{status:500})}}let p=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/customers/search/route",pathname:"/api/customers/search",filename:"route",bundlePath:"app/api/customers/search/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\customers\\search\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:d,staticGenerationAsyncStorage:m,serverHooks:x}=p,h="/api/customers/search/route";function f(){return(0,o.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>p,MH:()=>h,PT:()=>f,RA:()=>d,WX:()=>m,c_:()=>l,ts:()=>x});var n=r(41482),s=r.n(n),a=r(42023),o=r.n(a),i=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function l(e){return o().hash(e,12)}async function p(e,t){return o().compare(e,t)}function d(e){return s().sign(e,c,{expiresIn:"7d"})}function m(e){try{return s().verify(e,c)}catch{return null}}async function x(){let e=await (0,i.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=m(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function h(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(48852));module.exports=n})();