"use strict";(()=>{var e={};e.id=7701,e.ids=[7701],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")},99305:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>S,patchFetch:()=>v,requestAsyncStorage:()=>g,routeModule:()=>x,serverHooks:()=>q,staticGenerationAsyncStorage:()=>f});var a={};r.r(a),r.d(a,{POST:()=>y});var o=r(49303),n=r(88716),i=r(60670),s=r(87070),u=r(56681),c=r(57147),p=r.n(c),l=r(71017),d=r.n(l);let m=d().resolve(process.cwd(),".."),h=d().join(m,"data","myntra_temp_data"),w=async(e,t)=>{try{p().existsSync(h)||p().mkdirSync(h,{recursive:!0});let r=t.replace(/[^a-zA-Z0-9]/g,"_"),a=d().join(h,`${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,countryUrl:n}=await e.json();if(!a)return s.NextResponse.json({error:"query is required"},{status:400});let i=await u.chromium.connectOverCDP("http://localhost:9222"),c=i.contexts()[0].pages()[0],p=`https://www.myntra.com/shoes?rawQuery=${a}`;await c.goto(p,{waitUntil:"domcontentloaded",timeout:6e4}),await c.waitForTimeout(3e3);let l=[];if(o)for(;!r.aborted;){let e=(await c.evaluate(()=>{let e=document.querySelectorAll("ul.results-base li.product-base"),t=[];return e.forEach(e=>{let r=e.querySelector('a[data-refreshpage="true"]')?.href||"",a=e.querySelector("h3")?.innerText.trim()||"",o=e.querySelector(".product-productMetaInfo .product-price span.product-discountedPrice")?.innerText.trim()||"",n=e.querySelector(".product-productMetaInfo .product-price span.product-strike")?.innerText.trim()||"",i=e.querySelector(".product-productMetaInfo .product-price span.product-discountPercentage")?.innerText.trim()||"",s=e.querySelector(".product-ratingsContainer span")?.innerText||"",u=e.querySelector(".product-ratingsContainer .product-ratingsCount")?.innerText||"";r&&t.push({product_url:r,title:a,price:o,original_price:n,off:i,email:"N/A",website:"N/A",phone:"N/A",whatsapp:"N/A",seller:"N/A",rating_star:s,rating_count:u,source:"myntra"})}),t})).map(e=>({...e,query:a}));l.push(...e),await w(l,`${a}`,"myntra_temp_data");let t=await c.$("li.pagination-next");if(!t)break;await c.waitForTimeout(1500+Math.floor(500*Math.random()));let r=await t.boundingBox();r&&await c.mouse.move(r.x+r.width/2,r.y+r.height/2),await Promise.all([t.click(),c.waitForNavigation({waitUntil:"domcontentloaded"})]),await c.waitForTimeout(1500+Math.floor(500*Math.random()))}if(l.length)return await i.close(),s.NextResponse.json(l);{let e=(await c.evaluate(()=>{let e=document.querySelectorAll("ul.results-base li.product-base"),t=[];return e.forEach(e=>{let r=e.querySelector('a[data-refreshpage="true"]')?.href||"",a=e.querySelector("h3")?.innerText.trim()||"",o=e.querySelector(".product-productMetaInfo .product-price span.product-discountedPrice")?.innerText.trim()||"",n=e.querySelector(".product-productMetaInfo .product-price span.product-strike")?.innerText.trim()||"",i=e.querySelector(".product-productMetaInfo .product-price span.product-discountPercentage")?.innerText.trim()||"",s=e.querySelector(".product-ratingsContainer span")?.innerText||"",u=e.querySelector(".product-ratingsContainer .product-ratingsCount")?.innerText||"";r&&t.push({product_url:r,title:a,price:o,original_price:n,off:i,email:"N/A",website:"N/A",phone:"N/A",whatsapp:"N/A",seller:"N/A",rating_star:s,rating_count:u,source:"myntra"})}),t})).map(e=>({...e,query:a}));return await w(e,`${a}`,"myntra_temp_data"),await i.close(),s.NextResponse.json(e)}}catch(e){return console.error("Scraping Error:",e),s.NextResponse.json({error:"Failed to scrape website"},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/myntra_scraper/route",pathname:"/api/myntra_scraper",filename:"route",bundlePath:"app/api/myntra_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\myntra_scraper\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:g,staticGenerationAsyncStorage:f,serverHooks:q}=x,S="/api/myntra_scraper/route";function v(){return(0,i.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:f})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(99305));module.exports=a})();