module.exports=[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"))},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"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},51615,(e,t,r)=>{t.exports=e.x("node:buffer",()=>require("node:buffer"))},68105,e=>{"use strict";var t=e.i(24652);let r=process.env.JWT_SECRET;e.s(["createToken",0,function(e){return t.default.sign(e,r,{expiresIn:"7d"})},"verifyToken",0,function(e){try{return t.default.verify(e,r)}catch{return null}}])},46464,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),p=e.i(47587),c=e.i(66012),R=e.i(70101),h=e.i(26937),x=e.i(10372),v=e.i(93695);e.i(52474);var E=e.i(220),f=e.i(89171),g=e.i(62294),m=e.i(93458),C=e.i(68105);async function w(){try{let e=await (0,m.cookies)(),t=e.get("token")?.value;if(!t)return f.NextResponse.json({error:"No hay token"},{status:401});let r=(0,C.verifyToken)(t);if(!r||"leader"!==r.role)return f.NextResponse.json({error:"No autorizado"},{status:403});let a=r.id,[n]=await g.db.query("SELECT militant_id FROM users WHERE id = ?",[a]),s=n[0]?.militant_id,[i]=await g.db.query(`
      SELECT 
        COUNT(*) as totalMilitantes,
        (SELECT COUNT(*) FROM users WHERE leader_id = ?) as totalBrigadistas
      FROM militants 
      WHERE leader_id = ?
    `,[a,s]),[o]=await g.db.query(`
      SELECT 
        COUNT(DISTINCT neighborhood) as colonias,
        COUNT(DISTINCT section_number) as secciones
      FROM militants 
      WHERE leader_id = ?
    `,[s]);return f.NextResponse.json({totalMilitantes:i[0].totalMilitantes||0,totalBrigadistas:i[0].totalBrigadistas||0,colonias:o[0].colonias||0,secciones:o[0].secciones||0,userName:r.name})}catch(e){return console.error("LEADER_STATS_ERROR:",e),f.NextResponse.json({error:"Error en la consulta de base de datos"},{status:500})}}e.s(["GET",0,w],17110);var y=e.i(17110);let T=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/admin/stats/leader/route",pathname:"/api/admin/stats/leader",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/admin/stats/leader/route.ts",nextConfigOutput:"",userland:y,...{}}),{workAsyncStorage:N,workUnitAsyncStorage:b,serverHooks:A}=T;async function S(e,t,a){a.requestMeta&&(0,n.setRequestMeta)(e,a.requestMeta),T.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let f="/api/admin/stats/leader/route";f=f.replace(/\/index$/,"")||"/";let g=await T.prepare(e,t,{srcPage:f,multiZoneDraftMode:!1});if(!g)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:C,nextConfig:w,parsedUrl:y,isDraftMode:N,prerenderManifest:b,routerServerContext:A,isOnDemandRevalidate:S,revalidateOnlyGenerated:_,resolvedPathname:O,clientReferenceManifest:q,serverActionsManifest:k}=g,P=(0,o.normalizeAppPath)(f),M=!!(b.dynamicRoutes[P]||b.routes[O]),j=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,y,!1):t.end("This page could not be found"),null);if(M&&!N){let e=!!b.routes[O],t=b.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(w.adapterPath)return await j();throw new v.NoFallbackError}}let H=null;!M||T.isDev||N||(H="/index"===(H=O)?"/":H);let I=!0===T.isDev||!M,U=M&&!I;k&&q&&(0,i.setManifestsSingleton)({page:f,clientReferenceManifest:q,serverActionsManifest:k});let D=e.method||"GET",F=(0,s.getTracer)(),L=F.getActiveScopeSpan(),B=!!(null==A?void 0:A.isWrappedByNextServer),$=!!(0,n.getRequestMeta)(e,"minimalMode"),K=(0,n.getRequestMeta)(e,"incrementalCache")||await T.getIncrementalCache(e,w,b,$);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let W={params:C,previewProps:b.preview,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:I,incrementalCache:K,cacheLifeProfiles:w.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>T.onRequestError(e,t,a,n,A)},sharedContext:{buildId:m}},G=new l.NodeNextRequest(e),V=new l.NodeNextResponse(t),X=d.NextRequestAdapter.fromNodeNextRequest(G,(0,d.signalFromNodeResponse)(t));try{let n,i=async e=>T.handle(X,W).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.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=`${D} ${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(`${D} ${f}`)}),o=async n=>{var s,o;let l=async({previousCacheEntry:r})=>{try{if(!$&&S&&_&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=W.renderOpts.fetchMetrics;let o=W.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=W.renderOpts.collectedTags;if(!M)return await (0,c.sendResponse)(G,V,s,W.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,R.toNodeOutgoingHttpHeaders)(s.headers);l&&(t[x.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==W.renderOpts.collectedRevalidate&&!(W.renderOpts.collectedRevalidate>=x.INFINITE_CACHE)&&W.renderOpts.collectedRevalidate,a=void 0===W.renderOpts.collectedExpire||W.renderOpts.collectedExpire>=x.INFINITE_CACHE?void 0:W.renderOpts.collectedExpire;return{value:{kind:E.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:f,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:S})},!1,A),t}},d=await T.handleResponse({req:e,nextConfig:w,cacheKey:H,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:S,revalidateOnlyGenerated:_,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:$});if(!M)return null;if((null==d||null==(s=d.value)?void 0:s.kind)!==E.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(o=d.value)?void 0:o.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});$||t.setHeader("x-nextjs-cache",S?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),N&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,R.fromNodeOutgoingHttpHeaders)(d.value.headers);return $&&M||u.delete(x.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,h.getCacheControlHeader)(d.cacheControl)),await (0,c.sendResponse)(G,V,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&L?await o(L):(n=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${D} ${f}`,kind:s.SpanKind.SERVER,attributes:{"http.method":D,"http.target":e.url}},o),void 0,!B))}catch(t){if(t instanceof v.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:S})},!1,A),M)throw t;return await (0,c.sendResponse)(G,V,new Response(null,{status:500})),null}}e.s(["handler",0,S,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:N,workUnitAsyncStorage:b})},"routeModule",0,T,"serverHooks",0,A,"workAsyncStorage",0,N,"workUnitAsyncStorage",0,b],46464)}];

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