"use strict";(()=>{var e={};e.id=7959,e.ids=[7959],e.modules={2934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},852:e=>{e.exports=require("async_hooks")},6113:e=>{e.exports=require("crypto")},7147:e=>{e.exports=require("fs")},4492:e=>{e.exports=require("node:stream")},1017:e=>{e.exports=require("path")},2781:e=>{e.exports=require("stream")},3837:e=>{e.exports=require("util")},8839:(e,t,r)=>{r.r(t),r.d(t,{headerHooks:()=>h,originalPathname:()=>f,patchFetch:()=>q,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>x,staticGenerationAsyncStorage:()=>g,staticGenerationBailout:()=>E});var s={};r.r(s),r.d(s,{GET:()=>c,PUT:()=>l});var a=r(5419),i=r(9108),o=r(9678),n=r(8070),u=r(2509),d=r(8799);async function c(e){try{let t=await (0,u.e)(),{data:{user:s},error:a}=await t.auth.getUser();if(a||!s)return n.Z.json({error:{code:"UNAUTHORIZED",message:"Authentication required"}},{status:401});let i=new URL(e.url).searchParams.get("site_id");if(!i)return n.Z.json({error:{code:"MISSING_REQUIRED_FIELD",message:"site_id is required"}},{status:400});let{createAdminClient:o}=await Promise.resolve().then(r.bind(r,2509)),c=o(),{data:l,error:p}=await c.from("sites").select("tenant_id").eq("id",i).single();if(p||!l)return n.Z.json({error:{code:"SITE_NOT_FOUND",message:"Site not found"}},{status:404});let m=await (0,d.s2)(i);return n.Z.json(m)}catch(e){return console.error("Email settings GET error:",e),n.Z.json({error:{code:"INTERNAL_ERROR",message:e instanceof Error?e.message:"Failed to fetch email settings"}},{status:500})}}async function l(e){try{let t=await (0,u.e)(),{data:{user:s},error:a}=await t.auth.getUser();if(a||!s)return n.Z.json({error:{code:"UNAUTHORIZED",message:"Authentication required"}},{status:401});let{site_id:i,enabled:o,from_email:c,reply_to:l,send_conversation_summaries:p,summary_recipients:m}=await e.json();if(!i)return n.Z.json({error:{code:"MISSING_REQUIRED_FIELD",message:"site_id is required"}},{status:400});let{createAdminClient:g}=await Promise.resolve().then(r.bind(r,2509)),x=g(),{data:h,error:E}=await x.from("sites").select("tenant_id").eq("id",i).single();if(E||!h)return n.Z.json({error:{code:"SITE_NOT_FOUND",message:"Site not found"}},{status:404});return await (0,d.zJ)(i,h.tenant_id,{enabled:o,fromEmail:c,replyTo:l,sendConversationSummaries:p,summaryRecipients:m}),n.Z.json({success:!0})}catch(e){return console.error("Email settings PUT error:",e),n.Z.json({error:{code:"INTERNAL_ERROR",message:e instanceof Error?e.message:"Failed to update email settings"}},{status:500})}}let p=new a.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/email/settings/route",pathname:"/api/email/settings",filename:"route",bundlePath:"app/api/email/settings/route"},resolvedPagePath:"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\api\\email\\settings\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:g,serverHooks:x,headerHooks:h,staticGenerationBailout:E}=p,f="/api/email/settings/route";function q(){return(0,o.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:g})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[1638,9989,6206,1788,8799],()=>r(8839));module.exports=s})();