module.exports=[579848,e=>{"use strict";var t=e.i(747909),a=e.i(174017),n=e.i(996250),r=e.i(759756),i=e.i(561916),o=e.i(174677),s=e.i(869741),l=e.i(316795),d=e.i(487718),c=e.i(995169),u=e.i(47587),p=e.i(666012),h=e.i(570101),m=e.i(626937),g=e.i(10372),f=e.i(193695);e.i(52474);var w=e.i(600220),v=e.i(89171),x=e.i(793603);e.i(287500);var R=e.i(847733);async function b(t,a){try{var n,r,i;let o,s,l,{id:d}=await a.params,c=parseInt(d),u=t.headers.get("authorization"),p=t.cookies.get("session"),h=null;if(u?h=u.replace("Bearer ",""):p?.value&&(h=p.value),!h)return v.NextResponse.json({error:"Session not found. Please login first."},{status:401});let m=await (0,R.decrypt)(h);if(!m?.id)return v.NextResponse.json({error:"Invalid session. Please login again."},{status:401});let{searchParams:g}=new URL(t.url),f=g.get("wardId"),w=f?parseInt(f):void 0,b="admin"===m.role||"super_admin"===m.role?await (0,x.getBeneficiariesForExportForAdminService)(c,w):await (0,x.getBeneficiariesForExportService)(Number(m.id),c,w);if(!b.success||!b.data)return v.NextResponse.json({error:b.message||"Failed to fetch data"},{status:b.statusCode||500});let{program:E,beneficiaries:A,institute:N}=b.data,{launchBrowser:T}=e.r(35355),$=await T(),P=await $.newPage(),S=(n=E,r=A,i=N,o=n.distribution?`${n.distribution}${n.quantity?` (${n.quantity})`:""}`:"",s="",r.forEach((e,t)=>{var a,n;s+=`
      <tr class="${t%2==0?"even":"odd"}">
        <td class="text-center">${C(t+1)}</td>
        <td>${y(e.nameBn||"")}</td>
        <td>${y(e.fatherName||"")}</td>
        <td>${y(e.villageName||"")}</td>
        <td class="text-center">${a=e.ward,n=e.wardId,a?.nameBn?C(a.nameBn):`ওয়ার্ড - ${C(n)}`}</td>
        <td class="text-center">${y(e.dob||"")}</td>
        <td class="text-center">${y(e.nid||"")}</td>
        <td class="text-center">${y(o)}</td>
        <td class="signature-cell beneficiary"></td>
        <td class="signature-cell distributor"></td>
        <td class="signature-cell guardian"></td>
      </tr>
    `}),l="",i&&(l=`
      <div class="institute-header">
        <div class="institute-name">${y(i.name||"")}</div>
        <div class="institute-address">${y(i.fullAddress||"")}</div>
      </div>
    `),`
    <!DOCTYPE html>
    <html lang="bn">
    <head>
      <meta charset="UTF-8">
      <title>VGF Master Role - ${y(n.name)}</title>
      <link href="https://banglawebfonts.pages.dev/css/kalpurush.css" rel="stylesheet">
      <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        @page {
          size: A4 landscape;
          margin: 20mm 10mm 5mm 10mm;
        }
        @page :first {
          margin-top: 5mm;
        }
        body {
          font-family: "Kalpurush", "Noto Sans Bengali", Arial, sans-serif;
          font-size: 10px;
          line-height: 1.2;
          color: #000;
          background: #fff;
        }
        .institute-header {
          text-align: center;
          margin-bottom: 4mm;
        }
        .institute-name {
          font-size: 16px;
          font-weight: bold;
          margin-bottom: 2mm;
        }
        .institute-address {
          font-size: 12px;
          color: #444;
        }
        .program-title {
          text-align: center;
          font-size: 15px;
          font-weight: bold;
          margin-bottom: 4mm;
        }
        .meta-info {
          display: flex;
          justify-content: space-between;
          margin-bottom: 4mm;
          font-size: 10px;
          color: #666;
        }
        .table-container {
          width: 100%;
        }
        table {
          width: 100%;
          border-collapse: collapse;
          font-size: 11px;
          table-layout: fixed;
        }
        thead {
          background: transparent;
        }
        th {
          padding: 6px 4px;
          text-align: center;
          font-weight: 600;
          border: 1px solid #000;
          font-size: 11px;
        }
        td {
          padding: 28px 6px;
          border: 1px solid #000;
          min-height: 80px;
        }
        tr.even { background: transparent; }
        td.text-center { text-align: center; }
        .signature-cell {
          min-height: 25px;
        }
        .footer {
          margin-top: 6mm;
          text-align: center;
          font-size: 9px;
          color: #000;
        }
      </style>
    </head>
    <body>
      ${l}

      <div class="program-title">${y(n.name||"")} - মাস্টার রোল</div>

      <div class="meta-info">
        <span>অর্থবছর: ${y(n.financialYear||"N/A")}</span>
        <span>মোট সুবিধাভোগী: ${C(r.length)} জন</span>
      </div>

      <div class="table-container">
        <table>
          <thead>
            <tr>
              <th width="4%">ক্র.</th>
              <th width="15%">নাম</th>
              <th width="15%">পিতা/স্বামী</th>
              <th width="12%">গ্রাম</th>
              <th width="7%">ওয়ার্ড</th>
              <th width="10%">জন্ম তারিখ</th>
              <th width="14%">এনআইডি</th>
              <th width="11%">বিতরণ</th>
              <th width="8%">শনাক্ত কারীর স্বাক্ষর</th>
              <th width="8%">বিতরণ কারীর স্বাক্ষর</th>
              <th width="17%">গ্রহণ কারীর স্বাক্ষর</th>
            </tr>
          </thead>
          <tbody>
            ${s}
          </tbody>
        </table>
      </div>

      <div class="footer">
        Generated by ekappbd.com | ${new Date().toLocaleDateString("bn-BD")}
      </div>
    </body>
    </html>
  `);await P.setContent(S,{waitUntil:["networkidle0","domcontentloaded"],timeout:3e4}),await P.evaluate(()=>Promise.all([document.fonts.ready])),await new Promise(e=>setTimeout(e,1e3));let O=await P.pdf({format:"A4",landscape:!0,printBackground:!0,margin:{top:"10mm",right:"10mm",bottom:"10mm",left:"10mm"}});return await $.close(),new v.NextResponse(O,{headers:{"Content-Type":"application/pdf","Content-Disposition":`attachment; filename="VGF-MasterRole-${new Date().toISOString().split("T")[0]}.pdf"; filename*=UTF-8''${encodeURIComponent(`VGF-MasterRole-${E.name?.replace(/\s+/g,"-")}-${new Date().toISOString().split("T")[0]}.pdf`)}`,"Cache-Control":"no-cache"}})}catch(e){return console.error("VGF Master Role PDF generation error:",e),v.NextResponse.json({error:"Failed to generate PDF",message:e.message},{status:500})}}function C(e){let t=["০","১","২","৩","৪","৫","৬","৭","৮","৯"];return String(e).replace(/\d/g,e=>t[parseInt(e)])}function y(e){if(!e)return"";let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,e=>t[e])}let E=async()=>new Response(null,{status:204,headers:{"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,OPTIONS","Access-Control-Allow-Headers":"Authorization, Content-Type"}});e.s(["GET",0,b,"OPTIONS",0,E],329094);var A=e.i(329094);let N=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/vgf/export/master/[id]/route",pathname:"/api/vgf/export/master/[id]",filename:"route",bundlePath:""},distDir:"_next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/vgf/export/master/[id]/route.ts",nextConfigOutput:"standalone",userland:A,...{}}),{workAsyncStorage:T,workUnitAsyncStorage:$,serverHooks:P}=N;async function S(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),N.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/vgf/export/master/[id]/route";v=v.replace(/\/index$/,"")||"/";let x=await N.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:R,params:b,nextConfig:C,parsedUrl:y,isDraftMode:E,prerenderManifest:A,routerServerContext:T,isOnDemandRevalidate:$,revalidateOnlyGenerated:P,resolvedPathname:S,clientReferenceManifest:O,serverActionsManifest:I}=x,_=(0,s.normalizeAppPath)(v),k=!!(A.dynamicRoutes[_]||A.routes[S]),D=async()=>((null==T?void 0:T.render404)?await T.render404(e,t,y,!1):t.end("This page could not be found"),null);if(k&&!E){let e=!!A.routes[S],t=A.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(C.adapterPath)return await D();throw new f.NoFallbackError}}let q=null;!k||N.isDev||E||(q="/index"===(q=S)?"/":q);let F=!0===N.isDev||!k,U=k&&!F;I&&O&&(0,o.setManifestsSingleton)({page:v,clientReferenceManifest:O,serverActionsManifest:I});let M=e.method||"GET",H=(0,i.getTracer)(),B=H.getActiveScopeSpan(),z=!!(null==T?void 0:T.isWrappedByNextServer),j=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await N.getIncrementalCache(e,C,A,j);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let K={params:b,previewProps:A.preview,renderOpts:{experimental:{authInterrupts:!!C.experimental.authInterrupts},cacheComponents:!!C.cacheComponents,supportsDynamicResponse:F,incrementalCache:G,cacheLifeProfiles:C.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,n,r)=>N.onRequestError(e,t,n,r,T)},sharedContext:{buildId:R}},L=new l.NodeNextRequest(e),V=new l.NodeNextResponse(t),W=d.NextRequestAdapter.fromNodeNextRequest(L,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>N.handle(W,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=H.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==c.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=a.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${v}`)}),s=async r=>{var i,s;let l=async({previousCacheEntry:a})=>{try{if(!j&&$&&P&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await o(r);e.fetchMetrics=K.renderOpts.fetchMetrics;let s=K.renderOpts.pendingWaitUntil;s&&n.waitUntil&&(n.waitUntil(s),s=void 0);let l=K.renderOpts.collectedTags;if(!k)return await (0,p.sendResponse)(L,V,i,K.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:n}}}}catch(t){throw(null==a?void 0:a.isStale)&&await N.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:$})},!1,T),t}},d=await N.handleResponse({req:e,nextConfig:C,cacheKey:q,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:$,revalidateOnlyGenerated:P,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:j});if(!k)return null;if((null==d||null==(i=d.value)?void 0:i.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(s=d.value)?void 0:s.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});j||t.setHeader("x-nextjs-cache",$?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),E&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let c=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return j&&k||c.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||c.get("Cache-Control")||c.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(L,V,new Response(d.value.body,{headers:c,status:d.value.status||200})),null};z&&B?await s(B):(r=H.getActiveScopeSpan(),await H.withPropagatedContext(e.headers,()=>H.trace(c.BaseServerSpan.handleRequest,{spanName:`${M} ${v}`,kind:i.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},s),void 0,!z))}catch(t){if(t instanceof f.NoFallbackError||await N.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:$})},!1,T),k)throw t;return await (0,p.sendResponse)(L,V,new Response(null,{status:500})),null}}e.s(["handler",0,S,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:T,workUnitAsyncStorage:$})},"routeModule",0,N,"serverHooks",0,P,"workAsyncStorage",0,T,"workUnitAsyncStorage",0,$],579848)}];

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