(()=>{var e={};e.id=234,e.ids=[234],e.modules={2849:e=>{function t(e){var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=2849,e.exports=t},399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},4300:e=>{"use strict";e.exports=require("buffer")},6113:e=>{"use strict";e.exports=require("crypto")},2361:e=>{"use strict";e.exports=require("events")},1808:e=>{"use strict";e.exports=require("net")},2254:e=>{"use strict";e.exports=require("node:buffer")},5714:e=>{"use strict";e.exports=require("node:diagnostics_channel")},7282:e=>{"use strict";e.exports=require("process")},2781:e=>{"use strict";e.exports=require("stream")},1576:e=>{"use strict";e.exports=require("string_decoder")},9512:e=>{"use strict";e.exports=require("timers")},4404:e=>{"use strict";e.exports=require("tls")},7310:e=>{"use strict";e.exports=require("url")},3837:e=>{"use strict";e.exports=require("util")},9796:e=>{"use strict";e.exports=require("zlib")},6476:(e,t,r)=>{"use strict";r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>_,requestAsyncStorage:()=>A,routeModule:()=>f,serverHooks:()=>S,staticGenerationAsyncStorage:()=>E});var s={};r.r(s),r.d(s,{POST:()=>g});var o=r(9303),a=r(8716),i=r(670),n=r(7070),u=r(6113),c=r(9487),l=r(446);async function p(e){let t=process.env.TIKTOK_ACCESS_TOKEN?.trim(),r="D7J8DHJC77U6LKRKU4MG".trim();if(!t||!r)return;let s={event_source:"web",event_source_id:r,data:[{event:e.eventName,event_time:Math.floor(Date.now()/1e3),event_id:e.eventId,user:{user_agent:e.userAgent,ip:e.ip},page:{url:e.url},properties:{content_id:e.contentId,content_name:e.contentName}}]};try{let e=await fetch("https://business-api.tiktok.com/open_api/v1.3/event/track/",{method:"POST",headers:{"Content-Type":"application/json","Access-Token":t},body:JSON.stringify(s)});if(!e.ok){let t=await e.text();console.error("TikTok Events API error:",e.status,t)}}catch(e){console.error("TikTok Events API request failed:",e)}}var d=r(1850);let h=d._.length-1,m=d._[h];async function g(e){try{let{page:t,status:r,plan:s,ttEvents:o}=await e.json().catch(()=>({})),a=e.cookies.get(l.sV)?.value,i=(0,l.ij)(a);i.userId||(i.userId=(0,u.randomUUID)());let g=i.userId;if(t){let e=function(e){let t=d._.indexOf(e);return -1===t?0:Math.round(t/h*100)}(t),o=i.utmAd??null,a="purchased"===r?"purchased":t===m?"completed":"in_progress";await c.Z.execute(`INSERT INTO onboarding_users (id, current_page, progress, status, plan, utm_ad)
         VALUES (?, ?, ?, ?, ?, ?)
         ON DUPLICATE KEY UPDATE
           current_page = IF(VALUES(progress) >= progress, VALUES(current_page), current_page),
           progress     = GREATEST(progress, VALUES(progress)),
           status       = CASE
                            WHEN VALUES(status) = 'purchased' THEN 'purchased'
                            WHEN status = 'purchased' THEN 'purchased'
                            WHEN VALUES(status) = 'completed' THEN 'completed'
                            WHEN status = 'completed' AND VALUES(status) = 'in_progress' THEN 'completed'
                            ELSE VALUES(status)
                          END,
           plan         = COALESCE(VALUES(plan), plan),
           utm_ad       = COALESCE(utm_ad, VALUES(utm_ad))`,[g,t,e,a,s??null,o]),i.choices[t]=r??"visited",i.updatedAt=new Date().toISOString()}if(o?.length){let t=e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??e.headers.get("x-real-ip")??"0.0.0.0",r=e.headers.get("user-agent")??"",s=e.headers.get("referer")??"";for(let e of o)p({eventName:e.eventName,eventId:e.eventId,ip:t,userAgent:r,url:s,contentId:e.contentId,contentName:e.contentName}).catch(()=>{})}let f=n.NextResponse.json({ok:!0});return f.cookies.set(l.sV,(0,l.tg)(i),{path:"/",httpOnly:!0,sameSite:"lax",maxAge:86400}),f}catch(e){return console.error("Track API error:",e),n.NextResponse.json({error:"Internal error"},{status:500})}}let f=new o.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/track/route",pathname:"/api/track",filename:"route",bundlePath:"app/api/track/route"},resolvedPagePath:"D:\\Programming\\javascript\\nextjs\\ONBOARDStolaunch\\ONBaya\\onboardaya\\app\\api\\track\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:A,staticGenerationAsyncStorage:E,serverHooks:S}=f,v="/api/track/route";function _(){return(0,i.patchFetch)({serverHooks:S,staticGenerationAsyncStorage:E})}},1850:(e,t,r)=>{"use strict";r.d(t,{_:()=>s,j:()=>o});let s=["welcome","social-proof","quran-familiarity","quran-frequency","relationship-allah","spiritual-fulfillment","sleep-duration","sleep-trouble","worried-evening","calm-sleep","yearly-goal","audio-interest","story-themes","divine-guidance","story-adam","story-nuh","story-muhammad","loading-plan","growth-chart","plansone"],o={"audio-interest":{title:"Why are you interested in audio Quranic stories?",subtitle:"Select all that apply",topics:[{id:"reduce-stress",label:"Reduce stress"},{id:"spiritual-peace",label:"Feel spiritual peace"},{id:"emotional-comfort",label:"Emotional comfort"},{id:"better-sleep",label:"Better sleep"},{id:"other",label:"Other"}]},"story-themes":{title:"Which story themes interest you?",subtitle:"Select all that apply",topics:[{id:"hope-faith",label:"Hope & faith"},{id:"peace-comfort",label:"Peace & comfort"},{id:"forgiveness-healing",label:"Forgiveness & healing"},{id:"strength-resilience",label:"Strength & resilience"}]}}},9487:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});let s=r(3785).createPool({host:process.env.MYSQL_HOST??"localhost",port:Number(process.env.MYSQL_PORT??3306),user:process.env.MYSQL_USER??"root",password:process.env.MYSQL_PASSWORD??"",database:process.env.MYSQL_DATABASE??"onboarding_tracker",waitForConnections:!0,connectionLimit:10})},446:(e,t,r)=>{"use strict";r.d(t,{ij:()=>o,sV:()=>s,tg:()=>a});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 a(e){return JSON.stringify({choices:e.choices,updatedAt:e.updatedAt,userId:e.userId,utmAd:e.utmAd})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[633,972,785],()=>r(6476));module.exports=s})();