"use strict";(()=>{var e={};e.id=3558,e.ids=[3558],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")},39491:e=>{e.exports=require("assert")},14300:e=>{e.exports=require("buffer")},32081:e=>{e.exports=require("child_process")},6113:e=>{e.exports=require("crypto")},82361:e=>{e.exports=require("events")},57147:e=>{e.exports=require("fs")},13685:e=>{e.exports=require("http")},85158:e=>{e.exports=require("http2")},95687:e=>{e.exports=require("https")},41808:e=>{e.exports=require("net")},15673:e=>{e.exports=require("node:events")},97742:e=>{e.exports=require("node:process")},47261:e=>{e.exports=require("node:util")},22037:e=>{e.exports=require("os")},71017:e=>{e.exports=require("path")},77282:e=>{e.exports=require("process")},85477:e=>{e.exports=require("punycode")},63477:e=>{e.exports=require("querystring")},12781:e=>{e.exports=require("stream")},24404:e=>{e.exports=require("tls")},76224:e=>{e.exports=require("tty")},57310:e=>{e.exports=require("url")},73837:e=>{e.exports=require("util")},59796:e=>{e.exports=require("zlib")},56675:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>_,patchFetch:()=>y,requestAsyncStorage:()=>q,routeModule:()=>h,serverHooks:()=>g,staticGenerationAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{POST:()=>v,runtime:()=>c});var a=t(49303),o=t(88716),i=t(60670),n=t(87070),p=t(97816),u=t(71017),l=t.n(u),d=t(57147);let c="nodejs",x=["date","enquiry","name","phone","email","address","city","pin","state","country"];async function v(e){try{let{fileData:r,sheetUrl:t}=await e.json();if(!r||!t)return n.NextResponse.json({error:"Missing lead data or sheet URL"},{status:400});let s=t.match(/\/d\/([a-zA-Z0-9-_]+)/),a=s?.[1];if(!a)return n.NextResponse.json({error:"Invalid Google Sheet URL"},{status:400});let o=JSON.parse(await d.promises.readFile(l().join(process.cwd(),"json-service.json"),"utf-8")),i=new p.lkr.auth.GoogleAuth({credentials:{client_email:o.client_email,private_key:o.private_key},scopes:["https://www.googleapis.com/auth/spreadsheets"]}),u=p.lkr.sheets({version:"v4",auth:i}),c=await u.spreadsheets.values.get({spreadsheetId:a,range:"Sheet1!A1:J1"}),v=c.data.values?.[0]||[];0===v.length&&await u.spreadsheets.values.update({spreadsheetId:a,range:"Sheet1!A1",valueInputOption:"RAW",requestBody:{values:[x]}});let h=(Array.isArray(r)?r:[r]).map(e=>{var r;return r={date:e.date||new Date().toLocaleString(),...e},x.map(e=>void 0===r[e]||null===r[e]?"":r[e])});return await u.spreadsheets.values.append({spreadsheetId:a,range:"Sheet1",valueInputOption:"USER_ENTERED",insertDataOption:"INSERT_ROWS",requestBody:{values:h}}),n.NextResponse.json({message:"Leads saved successfully",rowsInserted:h.length},{status:200})}catch(e){return n.NextResponse.json({error:"Failed to save leads",message:e.message},{status:500})}}let h=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/save_client_leads/route",pathname:"/api/save_client_leads",filename:"route",bundlePath:"app/api/save_client_leads/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\save_client_leads\\route.js",nextConfigOutput:"",userland:s}),{requestAsyncStorage:q,staticGenerationAsyncStorage:m,serverHooks:g}=h,_="/api/save_client_leads/route";function y(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:m})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972,6577,820,7816],()=>t(56675));module.exports=s})();