module.exports=[968600,e=>{"use strict";var t=e.i(747909),r=e.i(174017),a=e.i(996250),n=e.i(759756),s=e.i(561916),o=e.i(174677),i=e.i(869741),l=e.i(316795),c=e.i(487718),u=e.i(995169),d=e.i(47587),p=e.i(666012),h=e.i(570101),m=e.i(626937),f=e.i(10372),g=e.i(193695);e.i(52474);var R=e.i(600220),y=e.i(89171),C=e.i(306971),v=e.i(547740);let E=`You are a Bangladeshi Education Board Certificate OCR expert. Extract information from JSC/JDC/SSC/Dakhil/HSC/Alim certificates and mark sheets.

FIELDS TO EXTRACT:
- nameBn: Full name in Bangla script (নাম)
- nameEn: Full name in English (Name)
- father: Father's name in Bangla script (পিতা/স্বামীর নাম)
- mother: Mother's name in Bangla script (মাতার নাম)
- roll: Roll number/Registration number (রোল/রেজিঃ নং)
- reg: Registration number (if available separately)
- board: Board name (e.g., ঢাকা, রাজশাহী, কুমিল্লা, etc.)
- boardEn: Board name in English (Dhaka, Rajshahi, Comilla, etc.)
- year: Passing year (পাশের সাল)
- exam: Exam type - MUST be one of: "jsc", "ssc", "hsc"
- gpa: GPA/Grade (if available)
- school: School name (if available)

EXAM TYPE DETECTION RULES:
- If certificate contains "জেএসসি", "JSC", or "জেডিC" → set exam: "jsc"
- If certificate contains "এসএসসি", "SSC", or "দাখিল" → set exam: "ssc"
- If certificate contains "এইচএসসি", "HSC", "আলিম", or "এইচবিএম" → set exam: "hsc"
- DO NOT detect PSC/Primary - this system only supports JSC/SSC/HSC

CRITICAL RULES:
1. Return ONLY valid JSON, no markdown, no code blocks
2. All Bangla text must be in proper Bangla Unicode script
3. board field must be in Bangla (e.g., "ঢাকা", "রাজশাহী")
4. boardEn field must be in English (e.g., "Dhaka", "Rajshahi")
5. year must be 4 digits (e.g., "2023")
6. If any field is not visible or readable, set it to null

Return format:
{"nameBn":"...","nameEn":"...","father":"...","mother":"...","roll":"...","reg":"...","board":"...","boardEn":"...","year":"...","exam":"...","gpa":"...","school":"..."}`;async function S(e){try{let t=await (0,C.default)(e).metadata();if(e.length<512e3&&1280>(t.width||0))return{buffer:e,mimeType:`image/${t.format||"jpeg"}`};return{buffer:await (0,C.default)(e).resize({width:1280,withoutEnlargement:!0}).jpeg({quality:85,mozjpeg:!0}).toBuffer(),mimeType:"image/jpeg"}}catch{return{buffer:e,mimeType:"image/jpeg"}}}async function b(e,t){let r,a=await fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=AIzaSyA1LDCUCnYcgIIrKf_XfTZ8MuyIVBOi2c8",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contents:[{parts:[{text:E},{inline_data:{mime_type:t,data:e}}]}],generationConfig:{temperature:.1,maxOutputTokens:2048}})});if(!a.ok)return{success:!1,error:"OCR service error",details:await a.text(),status:502};let n=await a.json(),s=n?.candidates?.[0]?.content?.parts?.[0]?.text||"";if(!s)return{success:!1,error:"No response from OCR service",status:500};let o=s.trim();if(o.startsWith("```")&&(o=o.replace(/^```(?:json)?\n?/,"").replace(/\n?```$/,"")),(o.match(/{/g)||[]).length!==(o.match(/}/g)||[]).length)return{success:!1,error:"OCR response was incomplete. Please try again with a clearer photo.",raw:o.substring(0,200)+"...",status:500};try{r=JSON.parse(o)}catch(e){return{success:!1,error:"Failed to parse OCR result. Response may be incomplete.",raw:o.substring(0,200)+"...",status:500}}return{success:!0,data:{nameBn:r.nameBn||null,nameEn:r.nameEn||null,father:r.father||null,mother:r.mother||null,roll:r.roll||null,reg:r.reg||null,board:r.board||null,boardEn:r.boardEn||null,year:r.year||null,exam:r.exam||null,gpa:r.gpa||null,school:r.school||null}}}async function w(e){try{let t,r,a,{requestToken:n}=await e.json();if(!n)return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Missing request token. Please encrypt your request first."}))});let s=(0,v.decryptData)(n);if(!s)return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Invalid or expired request token"}))});try{t=JSON.parse(s)}catch(e){return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Failed to parse request parameters"}))})}let{image:o}=t;if(!o)return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"No image provided"}))});if(o.startsWith("data:")){let e=o.match(/^data:([^;]+);base64,(.+)$/);if(!e)return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Invalid data URI format"}))});a=e[1],r=e[2]}else r=o,a="image/jpeg";let i=Buffer.from(r,"base64"),{buffer:l,mimeType:c}=await S(i),u=l.toString("base64");a=c;let d=await b(u,a);if(!d.success){let e={success:!1,error:d.error||"OCR service error"};return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify(e))})}if(d.data.exam&&!["jsc","ssc","hsc"].includes(d.data.exam))return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Only JSC/SSC/HSC certificates are supported. PSC certificates cannot be auto-verified."}))});let p={success:!0,data:d.data};return y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify(p))})}catch(e){return console.error("Board Certificate OCR error:",e),y.NextResponse.json({success:!0,responseToken:(0,v.encryptData)(JSON.stringify({success:!1,error:"Internal server error"}))})}}let x=async()=>new Response(null,{status:204,headers:{"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,OPTIONS","Access-Control-Allow-Headers":"Authorization, Content-Type, X-Requested-With"}});e.s(["OPTIONS",0,x,"POST",0,w],316578);var O=e.i(316578);let T=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ocr/board-certificate/route",pathname:"/api/ocr/board-certificate",filename:"route",bundlePath:""},distDir:"_next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ocr/board-certificate/route.ts",nextConfigOutput:"standalone",userland:O,...{}}),{workAsyncStorage:N,workUnitAsyncStorage:A,serverHooks:P}=T;async function I(e,t,a){a.requestMeta&&(0,n.setRequestMeta)(e,a.requestMeta),T.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/ocr/board-certificate/route";y=y.replace(/\/index$/,"")||"/";let C=await T.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!C)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:v,params:E,nextConfig:S,parsedUrl:b,isDraftMode:w,prerenderManifest:x,routerServerContext:O,isOnDemandRevalidate:N,revalidateOnlyGenerated:A,resolvedPathname:P,clientReferenceManifest:I,serverActionsManifest:k}=C,j=(0,i.normalizeAppPath)(y),D=!!(x.dynamicRoutes[j]||x.routes[P]),_=async()=>((null==O?void 0:O.render404)?await O.render404(e,t,b,!1):t.end("This page could not be found"),null);if(D&&!w){let e=!!x.routes[P],t=x.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await _();throw new g.NoFallbackError}}let q=null;!D||T.isDev||w||(q="/index"===(q=P)?"/":q);let B=!0===T.isDev||!D,H=D&&!B;k&&I&&(0,o.setManifestsSingleton)({page:y,clientReferenceManifest:I,serverActionsManifest:k});let U=e.method||"GET",M=(0,s.getTracer)(),J=M.getActiveScopeSpan(),F=!!(null==O?void 0:O.isWrappedByNextServer),$=!!(0,n.getRequestMeta)(e,"minimalMode"),L=(0,n.getRequestMeta)(e,"incrementalCache")||await T.getIncrementalCache(e,S,x,$);null==L||L.resetRequestCache(),globalThis.__incrementalCache=L;let K={params:E,previewProps:x.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:B,incrementalCache:L,cacheLifeProfiles:S.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>T.onRequestError(e,t,a,n,O)},sharedContext:{buildId:v}},X=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),z=c.NextRequestAdapter.fromNodeNextRequest(X,(0,c.signalFromNodeResponse)(t));try{let n,o=async e=>T.handle(z,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=M.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=`${U} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t),n&&n!==e&&(n.setAttribute("http.route",a),n.updateName(t))}else e.updateName(`${U} ${y}`)}),i=async n=>{var s,i;let l=async({previousCacheEntry:r})=>{try{if(!$&&N&&A&&!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=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&a.waitUntil&&(a.waitUntil(i),i=void 0);let l=K.renderOpts.collectedTags;if(!D)return await (0,p.sendResponse)(X,W,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);l&&(t[f.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,a=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:R.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 T.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:N})},!1,O),t}},c=await T.handleResponse({req:e,nextConfig:S,cacheKey:q,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:x,isRoutePPREnabled:!1,isOnDemandRevalidate:N,revalidateOnlyGenerated:A,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:$});if(!D)return null;if((null==c||null==(s=c.value)?void 0:s.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(i=c.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});$||t.setHeader("x-nextjs-cache",N?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),w&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(c.value.headers);return $&&D||u.delete(f.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(X,W,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};F&&J?await i(J):(n=M.getActiveScopeSpan(),await M.withPropagatedContext(e.headers,()=>M.trace(u.BaseServerSpan.handleRequest,{spanName:`${U} ${y}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},i),void 0,!F))}catch(t){if(t instanceof g.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:N})},!1,O),D)throw t;return await (0,p.sendResponse)(X,W,new Response(null,{status:500})),null}}e.s(["handler",0,I,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:N,workUnitAsyncStorage:A})},"routeModule",0,T,"serverHooks",0,P,"workAsyncStorage",0,N,"workUnitAsyncStorage",0,A],968600)}];

//# sourceMappingURL=node_modules_next_dist_esm_build_templates_app-route_08qg5zd.js.map