module.exports=[54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},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"))},20635,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/action-async-storage.external.js",()=>require("next/dist/server/app-render/action-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"))},63021,(e,t,r)=>{t.exports=e.x("@prisma/client-2c3a283f134fdcb6",()=>require("@prisma/client-2c3a283f134fdcb6"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},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"))},98043,e=>{"use strict";var t=e.i(63021);let r=globalThis.prisma??new t.PrismaClient;e.s(["default",0,r])},24868,(e,t,r)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},62816,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),p=e.i(87718),u=e.i(95169),d=e.i(47587),c=e.i(66012),h=e.i(70101),m=e.i(26937),x=e.i(10372),g=e.i(93695);e.i(52474);var f=e.i(220),v=e.i(79832),R=e.i(89171),y=e.i(24868);async function w(e,t){try{let r=(await (0,y.readFile)(e)).toString("base64"),a=e.endsWith(".png")?"image/png":"image/jpeg",n=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({model:"gpt-4o",messages:[{role:"system",content:`You are an expert OCR system for Bengali voter list documents. Extract all voter information from the image and return it in JSON format.

The voter list contains:
- Sheet header info: Sheet number, District (জেলা), Upazila (উপজেলা), Union (ইউনিয়ন), Post Office (ডাকঘর), Area Code (ভোটার এলাকার কোড), Area Name (ভোটার এলাকার নাম)
- Voter entries with: Entry Number (ক্রমিক নং), Voter Number (ভোটার নং), Name (নাম), Father Name (পিতা), Mother Name (মাতা), Occupation (পেশা), Date of Birth (জন্ম তারিখ), Address (ঠিকানা)

Return JSON in this exact format:
{
  "sheetInfo": {
    "sheetNumber": number,
    "district": "string",
    "upazila": "string",
    "union": "string",
    "postOffice": "string",
    "areaCode": "string",
    "areaName": "string"
  },
  "voters": [
    {
      "entryNumber": number,
      "voterNumber": "string",
      "name": "string",
      "fatherName": "string",
      "motherName": "string",
      "occupation": "string",
      "dateOfBirth": "DD/MM/YYYY",
      "address": "string"
    }
  ]
}

Extract ALL voters visible in the image. Keep the Bengali text as-is.`},{role:"user",content:[{type:"text",text:"Extract all voter information from this voter list image. Return only valid JSON."},{type:"image_url",image_url:{url:`data:${a};base64,${r}`}}]}],max_tokens:4096,temperature:0})});if(!n.ok){let e=await n.json();throw Error(e.error?.message||"OpenAI API error")}let s=await n.json(),o=s.choices[0]?.message?.content;if(!o)throw Error("No content in response");let i=o,l=o.match(/```(?:json)?\s*([\s\S]*?)```/);l&&(i=l[1]);let p=JSON.parse(i.trim());return{success:!0,imagePath:e,sheetInfo:p.sheetInfo,voters:p.voters,rawResponse:o}}catch(t){return{success:!1,imagePath:e,error:t instanceof Error?t.message:"Processing failed"}}}async function E(e){if(!await (0,v.auth)())return R.NextResponse.json({error:"Unauthorized"},{status:401});try{let{imagePaths:t,apiKey:r}=await e.json();if(!t||!Array.isArray(t)||0===t.length)return R.NextResponse.json({error:"No image paths provided"},{status:400});if(!r)return R.NextResponse.json({error:"OpenAI API key is required"},{status:400});let a=[];for(let e of t){let t=await w(e,r);a.push(t)}let n=a.filter(e=>e.success).length,s=a.filter(e=>!e.success).length;return R.NextResponse.json({success:!0,results:a,summary:{total:a.length,successful:n,failed:s}})}catch(e){return console.error("Processing error:",e),R.NextResponse.json({error:"Failed to process images"},{status:500})}}e.s(["POST",()=>E],84558);var N=e.i(84558);let b=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/import/process/route",pathname:"/api/import/process",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/import/process/route.ts",nextConfigOutput:"standalone",userland:N}),{workAsyncStorage:A,workUnitAsyncStorage:C,serverHooks:O}=b;function P(){return(0,a.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:C})}async function j(e,t,a){b.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/import/process/route";v=v.replace(/\/index$/,"")||"/";let R=await b.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!R)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:y,params:w,nextConfig:E,parsedUrl:N,isDraftMode:A,prerenderManifest:C,routerServerContext:O,isOnDemandRevalidate:P,revalidateOnlyGenerated:j,resolvedPathname:S,clientReferenceManifest:T,serverActionsManifest:q}=R,k=(0,i.normalizeAppPath)(v),_=!!(C.dynamicRoutes[k]||C.routes[S]),I=async()=>((null==O?void 0:O.render404)?await O.render404(e,t,N,!1):t.end("This page could not be found"),null);if(_&&!A){let e=!!C.routes[S],t=C.dynamicRoutes[k];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await I();throw new g.NoFallbackError}}let U=null;!_||b.isDev||A||(U="/index"===(U=S)?"/":U);let D=!0===b.isDev||!_,H=_&&!D;q&&T&&(0,o.setManifestsSingleton)({page:v,clientReferenceManifest:T,serverActionsManifest:q});let M=e.method||"GET",$=(0,s.getTracer)(),F=$.getActiveScopeSpan(),B={params:w,prerenderManifest:C,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:D,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>b.onRequestError(e,t,a,n,O)},sharedContext:{buildId:y}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),z=p.NextRequestAdapter.fromNodeNextRequest(K,(0,p.signalFromNodeResponse)(t));try{let o=async e=>b.handle(z,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=$.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.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 a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${v}`)}),i=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let p=async({previousCacheEntry:r})=>{try{if(!i&&P&&j&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await o(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let p=B.renderOpts.collectedTags;if(!_)return await (0,c.sendResponse)(K,L,s,B.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);p&&(t[x.NEXT_CACHE_TAGS_HEADER]=p),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=x.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,a=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=x.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:f.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await b.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:P})},!1,O),t}},u=await b.handleResponse({req:e,nextConfig:E,cacheKey:U,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:P,revalidateOnlyGenerated:j,responseGenerator:p,waitUntil:a.waitUntil,isMinimalMode:i});if(!_)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==f.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",P?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let g=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return i&&_||g.delete(x.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||g.get("Cache-Control")||g.set("Cache-Control",(0,m.getCacheControlHeader)(u.cacheControl)),await (0,c.sendResponse)(K,L,new Response(u.value.body,{headers:g,status:u.value.status||200})),null};F?await l(F):await $.withPropagatedContext(e.headers,()=>$.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${v}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof g.NoFallbackError||await b.onRequestError(e,t,{routerKind:"App Router",routePath:k,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:P})},!1,O),_)throw t;return await (0,c.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>j,"patchFetch",()=>P,"routeModule",()=>b,"serverHooks",()=>O,"workAsyncStorage",()=>A,"workUnitAsyncStorage",()=>C],62816)}];

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