(()=>{var e={};e.id=3745,e.ids=[3745],e.modules={10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},77598:e=>{"use strict";e.exports=require("node:crypto")},76550:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>m,routeModule:()=>c,serverHooks:()=>d,workAsyncStorage:()=>f,workUnitAsyncStorage:()=>g});var n={};t.r(n),t.d(n,{GET:()=>p});var s=t(42706),i=t(28203),o=t(45994),u=t(39187),a=t(98095),l=t(89249);async function p(e){try{if("mysql"!==(0,a.f)())return u.NextResponse.json({error:"Sesion local deshabilitada."},{status:404});let r=String(e.cookies.get(l.CA())?.value||"").trim();if(!r)return u.NextResponse.json({error:"No autenticado."},{status:401});let t=(0,l.zP)(r);if(!t)return u.NextResponse.json({error:"Sesion invalida."},{status:401});return u.NextResponse.json({authenticated:!0,user:t.user,exp:t.exp})}catch(e){return console.error("[GET /api/auth/session] error:",e),u.NextResponse.json({error:"Error interno."},{status:500})}}let c=new s.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/auth/session/route",pathname:"/api/auth/session",filename:"route",bundlePath:"app/api/auth/session/route"},resolvedPagePath:"C:\\omrwebapp-git-roregar.cl\\src\\app\\api\\auth\\session\\route.ts",nextConfigOutput:"standalone",userland:n}),{workAsyncStorage:f,workUnitAsyncStorage:g,serverHooks:d}=c;function m(){return(0,o.patchFetch)({workAsyncStorage:f,workUnitAsyncStorage:g})}},96487:()=>{},78335:()=>{},98095:(e,r,t)=>{"use strict";function n(){return"mysql"===String(process.env.AUTH_MODE||process.env.NEXT_PUBLIC_AUTH_MODE||"").trim().toLowerCase()?"mysql":"firebase"}t.d(r,{f:()=>n})},89249:(e,r,t)=>{"use strict";t.d(r,{$G:()=>d,C0:()=>m,CA:()=>l,Q7:()=>c,zP:()=>g});var n=t(77598),s=t.n(n);let i="omr_local_session";function o(e){return(Buffer.isBuffer(e)?e:Buffer.from(e)).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function u(e){let r=String(e||"").replace(/-/g,"+").replace(/_/g,"/"),t=r.length%4==0?"":"=".repeat(4-r.length%4);return Buffer.from(r+t,"base64")}function a(){return String(process.env.AUTH_SESSION_SECRET||process.env.NEXTAUTH_SECRET||process.env.AUTH_DB_PASSWORD||"").trim()||"omr-local-session-dev-secret-change-me"}function l(){return String(process.env.AUTH_SESSION_COOKIE_NAME||i).trim()||i}function p(){let e=Number(process.env.AUTH_SESSION_TTL_HOURS||168);return Math.round(3600*(Number.isFinite(e)&&e>0?e:168))}function c(e){let r=Math.floor(Date.now()/1e3),t={v:1,iat:r,exp:r+p(),user:e},n=o(JSON.stringify({alg:"HS256",typ:"JWT"})),i=o(JSON.stringify(t)),u=`${n}.${i}`,l=o(s().createHmac("sha256",a()).update(u).digest());return`${u}.${l}`}function f(e){try{return JSON.parse(e)}catch{return null}}function g(e){let r=String(e||"").trim().split(".");if(3!==r.length)return null;let[t,n,i]=r;if(!t||!n||!i)return null;let l=`${t}.${n}`,p=o(s().createHmac("sha256",a()).update(l).digest()),c=Buffer.from(p),g=Buffer.from(i);if(c.length!==g.length||!s().timingSafeEqual(c,g))return null;let d=f(u(t).toString("utf8"));if(!d||"HS256"!==d.alg||"JWT"!==d.typ)return null;let m=f(u(n).toString("utf8"));if(!m||1!==m.v)return null;let S=Math.floor(Date.now()/1e3);if(!Number.isFinite(m.exp)||m.exp<=S)return null;let h=m.user;return h&&String(h.id||"").trim()&&String(h.email||"").trim()?m:null}function d(e,r){e.cookies.set(l(),r,{httpOnly:!0,sameSite:"lax",secure:!0,path:"/",maxAge:p()})}function m(e){e.cookies.set(l(),"",{httpOnly:!0,sameSite:"lax",secure:!0,path:"/",maxAge:0})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),n=r.X(0,[1989,5452],()=>t(76550));module.exports=n})();