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"))},48325,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),i=e.i(61916),s=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),h=e.i(70101),R=e.i(26937),x=e.i(10372),m=e.i(93695);e.i(52474);var v=e.i(220),E=e.i(89171),f=e.i(93458),g=e.i(24652),w=e.i(62294);let _=process.env.JWT_SECRET;async function b(e){try{let{searchParams:t}=new URL(e.url),r=t.get("scope"),a=await (0,f.cookies)(),n=a.get("token")?.value;if(!n)return E.NextResponse.json({error:"No autorizado"},{status:401});let i=g.default.verify(n,_).id,s=`
      SELECT 
        u.id, 
        u.role, 
        u.full_name, 
        u.leader_id, 
        m.neighborhood,
        m.created_by as owner_id
      FROM users u
      LEFT JOIN militants m ON u.militant_id = m.id
      WHERE 1=1
    `,o=[];"mine"===r&&(s+=" AND m.created_by = ?",o.push(i));let[l]=await w.db.query(s,o),d=`
      SELECT id, first_name, last_name_paternal, last_name_maternal, 
             leader_id, brigadist_id, neighborhood, section_number, created_by
      FROM militants m
      WHERE m.id NOT IN (SELECT u2.militant_id FROM users u2 WHERE u2.militant_id IS NOT NULL)
    `,u=[];"mine"===r&&(d+=" AND m.created_by = ?",u.push(i));let[p]=await w.db.query(d,u),c=l.filter(e=>"leader"===e.role).map(e=>({...e,brigadists:l.filter(t=>"brigadist"===t.role&&t.leader_id===e.id).map(e=>({...e,militants:p.filter(t=>t.brigadist_id===e.id)})),directMilitants:p.filter(t=>t.leader_id===e.id&&!t.brigadist_id)}));return E.NextResponse.json(c)}catch(e){return console.error("STRUCTURE_ERROR_DETAIL:",e),E.NextResponse.json({error:"Error en el servidor"},{status:500})}}e.s(["GET",0,b],72233);var y=e.i(72233);let C=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/militants/structure/route",pathname:"/api/militants/structure",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/militants/structure/route.ts",nextConfigOutput:"",userland:y,...{}}),{workAsyncStorage:N,workUnitAsyncStorage:T,serverHooks:A}=C;async function O(e,t,a){a.requestMeta&&(0,n.setRequestMeta)(e,a.requestMeta),C.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let E="/api/militants/structure/route";E=E.replace(/\/index$/,"")||"/";let f=await C.prepare(e,t,{srcPage:E,multiZoneDraftMode:!1});if(!f)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:g,params:w,nextConfig:_,parsedUrl:b,isDraftMode:y,prerenderManifest:N,routerServerContext:T,isOnDemandRevalidate:A,revalidateOnlyGenerated:O,resolvedPathname:q,clientReferenceManifest:S,serverActionsManifest:P}=f,k=(0,o.normalizeAppPath)(E),j=!!(N.dynamicRoutes[k]||N.routes[q]),H=async()=>((null==T?void 0:T.render404)?await T.render404(e,t,b,!1):t.end("This page could not be found"),null);if(j&&!y){let e=!!N.routes[q],t=N.dynamicRoutes[k];if(t&&!1===t.fallback&&!e){if(_.adapterPath)return await H();throw new m.NoFallbackError}}let I=null;!j||C.isDev||y||(I="/index"===(I=q)?"/":I);let U=!0===C.isDev||!j,M=j&&!U;P&&S&&(0,s.setManifestsSingleton)({page:E,clientReferenceManifest:S,serverActionsManifest:P});let D=e.method||"GET",L=(0,i.getTracer)(),F=L.getActiveScopeSpan(),$=!!(null==T?void 0:T.isWrappedByNextServer),K=!!(0,n.getRequestMeta)(e,"minimalMode"),W=(0,n.getRequestMeta)(e,"incrementalCache")||await C.getIncrementalCache(e,_,N,K);null==W||W.resetRequestCache(),globalThis.__incrementalCache=W;let B={params:w,previewProps:N.preview,renderOpts:{experimental:{authInterrupts:!!_.experimental.authInterrupts},cacheComponents:!!_.cacheComponents,supportsDynamicResponse:U,incrementalCache:W,cacheLifeProfiles:_.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>C.onRequestError(e,t,a,n,T)},sharedContext:{buildId:g}},G=new l.NodeNextRequest(e),V=new l.NodeNextResponse(t),X=d.NextRequestAdapter.fromNodeNextRequest(G,(0,d.signalFromNodeResponse)(t));try{let n,s=async e=>C.handle(X,B).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")!==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} ${E}`)}),o=async n=>{var i,o;let l=async({previousCacheEntry:r})=>{try{if(!K&&A&&O&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await s(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let o=B.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let l=B.renderOpts.collectedTags;if(!j)return await (0,c.sendResponse)(G,V,i,B.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);l&&(t[x.NEXT_CACHE_TAGS_HEADER]=l),!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:v.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await C.onRequestError(e,t,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:A})},!1,T),t}},d=await C.handleResponse({req:e,nextConfig:_,cacheKey:I,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:O,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:K});if(!j)return null;if((null==d||null==(i=d.value)?void 0:i.kind)!==v.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});K||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),y&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return K&&j||u.delete(x.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,R.getCacheControlHeader)(d.cacheControl)),await (0,c.sendResponse)(G,V,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};$&&F?await o(F):(n=L.getActiveScopeSpan(),await L.withPropagatedContext(e.headers,()=>L.trace(u.BaseServerSpan.handleRequest,{spanName:`${D} ${E}`,kind:i.SpanKind.SERVER,attributes:{"http.method":D,"http.target":e.url}},o),void 0,!$))}catch(t){if(t instanceof m.NoFallbackError||await C.onRequestError(e,t,{routerKind:"App Router",routePath:k,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:A})},!1,T),j)throw t;return await (0,c.sendResponse)(G,V,new Response(null,{status:500})),null}}e.s(["handler",0,O,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:N,workUnitAsyncStorage:T})},"routeModule",0,C,"serverHooks",0,A,"workAsyncStorage",0,N,"workUnitAsyncStorage",0,T],48325)}];

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