"use strict";(()=>{var e={};e.id=75,e.ids=[75],e.modules={399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},6113:e=>{e.exports=require("crypto")},8848:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>y,patchFetch:()=>v,requestAsyncStorage:()=>h,routeModule:()=>g,serverHooks:()=>f,staticGenerationAsyncStorage:()=>A});var s={};r.r(s),r.d(s,{POST:()=>m});var o=r(9303),n=r(8716),i=r(670),a=r(7070),u=r(6113),d=r(446),c=r(9833);let p=new Set,l=e=>{p.add(e),setTimeout(()=>p.delete(e),6e4)};async function m(e){let{step:t,choice:r,utmAd:s}=await e.json().catch(()=>({}));if(!t)return a.NextResponse.json({error:"Missing step"},{status:400});let o=e.cookies.get(d.sV)?.value,n=(0,d.ij)(o);n.userId||(n.userId=(0,u.randomUUID)());let i=n.choices[t];n.choices[t]=r,n.updatedAt=new Date().toISOString(),"string"==typeof s&&s&&(n.utmAd=n.utmAd??s);let m=n.userId;if(("plans"===t||"plansone"===t)&&"visited"===r&&"visited"!==i&&m&&!p.has(m))try{let e=n.utmAd?`ad ${n.utmAd}`:"ad unknown";await (0,c.T)(`Ayatique onboarding complete for user ${m} (${e})`),l(m)}catch(e){console.error("Failed to notify onboarding completion",e)}let g=a.NextResponse.json({status:"ok",session:n});return g.cookies.set(d.sV,(0,d.tg)(n),{path:"/",httpOnly:!0,sameSite:"lax",maxAge:86400}),g}let g=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/session/route",pathname:"/api/session",filename:"route",bundlePath:"app/api/session/route"},resolvedPagePath:"D:\\Programming\\javascript\\nextjs\\ONBOARDStolaunch\\ONBaya\\onboardaya\\app\\api\\session\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:A,serverHooks:f}=g,y="/api/session/route";function v(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:A})}},446:(e,t,r)=>{r.d(t,{ij:()=>o,sV:()=>s,tg:()=>n});let s="onboarding_session";function o(e){if(!e)return{choices:{}};try{let t=JSON.parse(e);return{choices:t.choices??{},updatedAt:t.updatedAt,userId:t.userId,utmAd:t.utmAd}}catch{return{choices:{}}}}function n(e){return JSON.stringify({choices:e.choices,updatedAt:e.updatedAt,userId:e.userId,utmAd:e.utmAd})}},9833:(e,t,r)=>{r.d(t,{T:()=>i});let s=process.env.TELEGRAM_BOT_TOKEN,o=process.env.TELEGRAM_CHAT_ID,n=e=>`https://api.telegram.org/bot${e}/sendMessage`;async function i(e){if(!s||!o)throw console.error("Telegram credentials missing in environment"),Error("telegram configuration missing");let t=await fetch(n(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:o,text:e})});if(!t.ok){let e=await t.text();throw console.error("Telegram request failed",e),Error(e)}}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[633,972],()=>r(8848));module.exports=s})();