"use strict";(()=>{var e={};e.id=3662,e.ids=[3662],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")},18147:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>w,patchFetch:()=>h,requestAsyncStorage:()=>p,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>d});var a={};r.r(a),r.d(a,{POST:()=>c});var o=r(49303),i=r(88716),n=r(60670),s=r(87070),l=r(56681);async function c(e){let t;try{let{keyword:r,city:a="",validate:o=!1}=await e.json();if(!r)return s.NextResponse.json({error:"Keyword is required"},{status:400});let i=(t=await l.chromium.connectOverCDP("http://localhost:9222")).contexts()[0].pages()[0],n=`https://dir.indiamart.com/search.mp?ss=${encodeURIComponent(r)}`,c=a.trim()?`${n}&cq=${encodeURIComponent(a.trim())}`:n;if(await i.goto(c,{waitUntil:"domcontentloaded",timeout:6e4}),await i.waitForTimeout(3e3),o){let e=1;for(;;){await i.evaluate(()=>window.scrollBy(0,window.innerHeight)),await i.waitForTimeout(1500);let t=await i.$('div.showmoreresultsdiv button[class="showMoreBtn"]');if(!t){console.log("No btn found.");break}console.log(`${e}...`),await t.click();try{await i.waitForSelector("#popupContact_s #form_s",{timeout:8e3});let e=await i.$("#popupContact_s #form_s > a");if(e){e.click(),console.log("found login");break}await i.waitForTimeout(1500)}catch(e){console.log("Error can be ignored!")}e++}}let u=await i.evaluate(()=>{let e=document.querySelectorAll(".listingCardContainer div.card.brs5"),t=[];return e.forEach(e=>{let r=e.querySelector('div[data-click="^Prod0Name"] a')?.innerText||"",a=e.querySelector('div[data-click="^Prod0Name"] a')?.href||"",o=e.querySelector(".companyname a")?.innerText||"",i=e.querySelector(".companyname a")?.href||"",n=e.querySelector("#citytt1 p")?.innerText||"",s=e.querySelector("div span.elps.elps1 span")?.innerText||"",l=e.querySelectorAll('.contactnumber span[data-click="^MobileNo"] span')[2]?.innerText.split(",")[0]||"";t.push({title:r,product_url:a,company:o,company_site:i,address:n,location:s,phone:[l]})}),t});return s.NextResponse.json(u)}catch(e){return console.error("Scraping Error:",e),s.NextResponse.json({error:"Failed to scrape website"},{status:500})}finally{t&&await t.close()}}let u=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/india_mart_leads/route",pathname:"/api/india_mart_leads",filename:"route",bundlePath:"app/api/india_mart_leads/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\india_mart_leads\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:p,staticGenerationAsyncStorage:d,serverHooks:m}=u,w="/api/india_mart_leads/route";function h(){return(0,n.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:d})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(18147));module.exports=a})();