module.exports=[70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},23862,e=>e.a(async(t,r)=>{try{let t=await e.y("pg-587764f78a6c7a9c");e.n(t),r()}catch(e){r(e)}},!0),62294,e=>e.a(async(t,r)=>{try{let o;var a=e.i(23862),n=t([a]);async function s(e,t){let r=function(){if(!o){let e=process.env.DATABASE_URL;if(!e)throw Error("DATABASE_URL environment variable is not set");(o=new a.Pool({connectionString:e,ssl:{rejectUnauthorized:!1}})).on("error",e=>{console.error("Unexpected error on idle client",e),process.exit(-1)})}return o}();Date.now();let n=await r.query(e,t);return Date.now(),n}[a]=n.then?(await n)():n,e.s(["query",()=>s]),r()}catch(e){r(e)}},!1),66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},57688,e=>{"use strict";let t,r;var a=e.i(66680);function n(){return function(e=21){var n;n=e|=0,!t||t.length<n?(t=Buffer.allocUnsafe(128*n),a.webcrypto.getRandomValues(t),r=0):r+n>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=n;let s="";for(let a=r-e;a<r;a++)s+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return s}()}function s(e){return{id:e.id,name:e.name,email:e.email,phone:e.phone,company:e.company,address:e.address,notes:e.notes,createdAt:e.createdAt,updatedAt:e.updatedAt}}function o(e){return{id:e.id,email:e.email,name:e.name,image:e.image,createdAt:e.createdAt,updatedAt:e.updatedAt}}function i(e){return{id:e.id,description:e.description,startTime:e.startTime,endTime:e.endTime,duration:e.duration,createdAt:e.createdAt,updatedAt:e.updatedAt,customerId:e.customerId,userId:e.userId}}e.s(["generateId",()=>n,"rowToCustomer",()=>s,"rowToTimeEntry",()=>i,"rowToUser",()=>o],57688)},64013,e=>e.a(async(t,r)=>{try{var a=e.i(89171),n=e.i(62294),s=e.i(57688),o=t([n]);async function i(e){try{let t=e.nextUrl.searchParams.get("search"),r=`
      SELECT c.*
      FROM customers c
    `,o=[];t&&(r+=" WHERE c.name ILIKE $1 OR c.email ILIKE $1 OR c.company ILIKE $1",o.push(`%${t}%`)),r+=' ORDER BY c."createdAt" DESC';let i=await (0,n.query)(r,o.length>0?o:void 0),d=await Promise.all(i.rows.map(async e=>{let t=(0,s.rowToCustomer)(e),r=(await (0,n.query)(`SELECT te.*, 
            json_build_object('name', u.name, 'email', u.email) as user
           FROM time_entries te
           LEFT JOIN users u ON u.id = te."userId"
           WHERE te."customerId" = $1
           ORDER BY te."createdAt" DESC`,[t.id])).rows.map(e=>({id:e.id,description:e.description,startTime:e.startTime,endTime:e.endTime,duration:e.duration,createdAt:e.createdAt,updatedAt:e.updatedAt,customerId:e.customerId,userId:e.userId,user:"string"==typeof e.user?JSON.parse(e.user):e.user}));return{...t,timeEntries:r}}));return a.NextResponse.json(d)}catch(e){return console.error("Error fetching customers:",e),a.NextResponse.json({error:"Failed to fetch customers"},{status:500})}}async function d(e){try{let{name:t,email:r,phone:o,company:i,address:d,notes:l}=await e.json();if(!t||"string"==typeof t&&""===t.trim())return a.NextResponse.json({error:"Name is required"},{status:400});try{let e=(0,s.generateId)(),u=new Date,c=await (0,n.query)(`INSERT INTO customers (id, name, email, phone, company, address, notes, "createdAt", "updatedAt")
         VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
         RETURNING *`,[e,"string"==typeof t?t.trim():t,r&&"string"==typeof r&&""!==r.trim()?r.trim():null,o&&"string"==typeof o&&""!==o.trim()?o.trim():null,i&&"string"==typeof i&&""!==i.trim()?i.trim():null,d&&"string"==typeof d&&""!==d.trim()?d.trim():null,l&&"string"==typeof l&&""!==l.trim()?l.trim():null,u,u]),p=(0,s.rowToCustomer)(c.rows[0]);return a.NextResponse.json(p,{status:201})}catch(r){console.error("Database error creating customer:",r);let e=r instanceof Error?r.message:"Database error occurred",t=r?.code;return a.NextResponse.json({error:e,code:t,details:void 0},{status:500})}}catch(t){console.error("Error in POST /api/customers:",t);let e=t instanceof Error?t.message:String(t);return a.NextResponse.json({error:e,details:void 0},{status:500})}}[n]=o.then?(await o)():o,e.s(["GET",()=>i,"POST",()=>d]),r()}catch(e){r(e)}},!1),48681,e=>e.a(async(t,r)=>{try{var a=e.i(47909),n=e.i(74017),s=e.i(96250),o=e.i(59756),i=e.i(61916),d=e.i(74677),l=e.i(69741),u=e.i(16795),c=e.i(87718),p=e.i(95169),m=e.i(47587),h=e.i(66012),R=e.i(70101),x=e.i(26937),f=e.i(10372),y=e.i(93695);e.i(52474);var E=e.i(220),g=e.i(64013),w=t([g]);[g]=w.then?(await w)():w;let T=new a.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/customers/route",pathname:"/api/customers",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/customers/route.ts",nextConfigOutput:"standalone",userland:g}),{workAsyncStorage:C,workUnitAsyncStorage:I,serverHooks:N}=T;function v(){return(0,s.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:I})}async function A(e,t,r){T.isDev&&(0,o.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/customers/route";a=a.replace(/\/index$/,"")||"/";let s=await T.prepare(e,t,{srcPage:a,multiZoneDraftMode:!1});if(!s)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:g,params:w,nextConfig:v,parsedUrl:A,isDraftMode:C,prerenderManifest:I,routerServerContext:N,isOnDemandRevalidate:b,revalidateOnlyGenerated:O,resolvedPathname:S,clientReferenceManifest:P,serverActionsManifest:j}=s,q=(0,l.normalizeAppPath)(a),U=!!(I.dynamicRoutes[q]||I.routes[S]),_=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,A,!1):t.end("This page could not be found"),null);if(U&&!C){let e=!!I.routes[S],t=I.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(v.experimental.adapterPath)return await _();throw new y.NoFallbackError}}let D=null;!U||T.isDev||C||(D=S,D="/index"===D?"/":D);let $=!0===T.isDev||!U,k=U&&!$;j&&P&&(0,d.setManifestsSingleton)({page:a,clientReferenceManifest:P,serverActionsManifest:j});let H=e.method||"GET",L=(0,i.getTracer)(),M=L.getActiveScopeSpan(),F={params:w,prerenderManifest:I,renderOpts:{experimental:{authInterrupts:!!v.experimental.authInterrupts},cacheComponents:!!v.cacheComponents,supportsDynamicResponse:$,incrementalCache:(0,o.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:v.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>T.onRequestError(e,t,a,n,N)},sharedContext:{buildId:g}},K=new u.NodeNextRequest(e),B=new u.NodeNextResponse(t),V=c.NextRequestAdapter.fromNodeNextRequest(K,(0,c.signalFromNodeResponse)(t));try{let s=async e=>T.handle(V,F).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=L.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==p.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=r.get("next.route");if(n){let t=`${H} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${H} ${a}`)}),d=!!(0,o.getRequestMeta)(e,"minimalMode"),l=async o=>{var i,l;let u=async({previousCacheEntry:n})=>{try{if(!d&&b&&O&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await s(o);e.fetchMetrics=F.renderOpts.fetchMetrics;let i=F.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let l=F.renderOpts.collectedTags;if(!U)return await (0,h.sendResponse)(K,B,a,F.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,R.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[f.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==F.renderOpts.collectedRevalidate&&!(F.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&F.renderOpts.collectedRevalidate,n=void 0===F.renderOpts.collectedExpire||F.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:F.renderOpts.collectedExpire;return{value:{kind:E.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==n?void 0:n.isStale)&&await T.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:b})},!1,N),t}},c=await T.handleResponse({req:e,nextConfig:v,cacheKey:D,routeKind:n.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:I,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:O,responseGenerator:u,waitUntil:r.waitUntil,isMinimalMode:d});if(!U)return null;if((null==c||null==(i=c.value)?void 0:i.kind)!==E.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(l=c.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});d||t.setHeader("x-nextjs-cache",b?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let p=(0,R.fromNodeOutgoingHttpHeaders)(c.value.headers);return d&&U||p.delete(f.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||p.get("Cache-Control")||p.set("Cache-Control",(0,x.getCacheControlHeader)(c.cacheControl)),await (0,h.sendResponse)(K,B,new Response(c.value.body,{headers:p,status:c.value.status||200})),null};M?await l(M):await L.withPropagatedContext(e.headers,()=>L.trace(p.BaseServerSpan.handleRequest,{spanName:`${H} ${a}`,kind:i.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},l))}catch(t){if(t instanceof y.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:b})},!1,N),U)throw t;return await (0,h.sendResponse)(K,B,new Response(null,{status:500})),null}}e.s(["handler",()=>A,"patchFetch",()=>v,"routeModule",()=>T,"serverHooks",()=>N,"workAsyncStorage",()=>C,"workUnitAsyncStorage",()=>I]),r()}catch(e){r(e)}},!1)];

//# sourceMappingURL=%5Broot-of-the-server%5D__60db7f0c._.js.map