"use strict";(()=>{var e={};e.id=3248,e.ids=[3248],e.modules={20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},56681:e=>{e.exports=require("playwright")},57147:e=>{e.exports=require("fs")},71017:e=>{e.exports=require("path")},76251:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>S,patchFetch:()=>_,requestAsyncStorage:()=>g,routeModule:()=>v,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var a={};r.r(a),r.d(a,{POST:()=>y});var o=r(49303),s=r(88716),i=r(60670),n=r(87070),c=r(56681),l=r(57147),p=r.n(l),u=r(71017),d=r.n(u);let h=d().resolve(process.cwd(),".."),m=d().join(h,"data","meesho_temp_data"),w=async(e,t)=>{try{p().existsSync(m)||p().mkdirSync(m,{recursive:!0});let r=t.replace(/[^a-zA-Z0-9]/g,"_"),a=d().join(m,`${r}.json`);p().writeFileSync(a,JSON.stringify(e,null,2),"utf-8")}catch(e){console.error("❌ Error saving data:",e.message)}};async function y(e){try{let t=new AbortController,r=t.signal;e.signal?.addEventListener("abort",()=>{t.abort()});let{query:a,limit:o,headless:s}=await e.json();if(!a)return n.NextResponse.json({error:"query is required"},{status:400});let i=(await c.chromium.connectOverCDP("http://localhost:9222")).contexts()[0].pages()[0],l=`https://www.meesho.com/search?q=${a}&searchType=manual&searchIdentifier=text_search`;await i.goto(l,{waitUntil:"domcontentloaded",timeout:6e4}),await i.waitForTimeout(3e3);let p=0,u=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,d=new Set,h=[],m=[],y=o?15:3;for(;p<=y&&!r.aborted;){for(let e of(await i.$$("div[height] div[data-index]"))){let t=await e.evaluate(e=>e.getAttribute("data-index"));d.has(t)?await e.dispose():(d.add(t),h.push(e))}await i.evaluate(()=>{window.scrollBy({top:window.innerHeight,behavior:"smooth"})}),await i.waitForTimeout(u(1e3,2580)),p++}for(let e of h){let t=await e.evaluate(e=>{let t=e.querySelector("a"),r=t?.href||"",a=t.querySelector('span[color="pinkBase"] div p')?.innerText.trim()||"",o=t.querySelector('span[color="pinkBase"] div h5')?.innerText.trim()||"",s=t.querySelector('span[color="pinkBase"] div h5')?.innerText.trim()||"",i=t.querySelector("div.NewProductCardstyled__RatingSection-sc-6y2tys-9.fyvrGC span.Rating__StyledPill-sc-12htng8-1.cgkleE")?.innerText||"",n=t.querySelector("div.NewProductCardstyled__RatingSection-sc-6y2tys-9.fyvrGC .NewProductCardstyled__RatingCount-sc-6y2tys-22")?.innerText||"";if(r)return{product_url:r,title:a,price:o,original_price:s,email:"N/A",website:"N/A",phone:"N/A",whatsapp:"N/A",seller:"N/A",rating_star:i,rating_count:n,source:"meesho"}});m.push(t)}let v=[...new Set(m)].map(e=>({...e,query:a}));return await w(v,`${a}`,"meesho_temp_data"),n.NextResponse.json(v)}catch(e){return console.error("Scraping Error:",e),n.NextResponse.json({error:"Failed to scrape website"},{status:500})}}let v=new o.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/meesho_scraper/route",pathname:"/api/meesho_scraper",filename:"route",bundlePath:"app/api/meesho_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\meesho_scraper\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:g,staticGenerationAsyncStorage:x,serverHooks:f}=v,S="/api/meesho_scraper/route";function _(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(76251));module.exports=a})();