"use strict";(()=>{var e={};e.id=585,e.ids=[585],e.modules={3480:(e,s,t)=>{e.exports=t(5600)},4919:(e,s,t)=>{t.a(e,async(e,r)=>{try{t.r(s),t.d(s,{default:()=>o});var n=t(6373),i=e([n]);async function o(e,s){if("POST"!==e.method)return s.status(405).json({success:!1,message:"Method not allowed"});try{console.log("Subscribe request received:",e.body);let{email:t}=e.body;if(!t||!/^\S+@\S+\.\S+$/.test(t))return console.log("Invalid email format:",t),s.status(400).json({success:!1,message:"Please provide a valid email address"});let r=process.env.RESEND_API_KEY,i=process.env.RESEND_AUDIENCE_ID;if(!r)return s.status(500).json({success:!1,message:"Server not configured: RESEND_API_KEY is missing."});if(!i)return s.status(500).json({success:!1,message:"Server not configured: RESEND_AUDIENCE_ID is missing."});console.log(`Attempting to add ${t} to audience ${i}`);let o=new n.Resend(r),a=await o.contacts.create({email:t,audienceId:i,firstName:"",lastName:"",unsubscribed:!1});if(console.log("Resend API response:",a),a&&a.error){let e=a.error,t=e?.message||"Error subscribing to the newsletter.";if(/already exists|conflict|duplicate/i.test(t||""))return s.status(200).json({success:!0,message:"You're already subscribed to this list.",debug:void 0});return s.status(500).json({success:!1,message:t,debug:void 0})}return s.status(200).json({success:!0,message:"Subscription successful! Thanks for joining our mailing list.",debug:void 0})}catch(e){return console.error("Error subscribing:",e),s.status(500).json({success:!1,message:"Error subscribing to the newsletter. Please try again later.",debug:void 0})}}n=(i.then?(await i)():i)[0],r()}catch(e){r(e)}})},5600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},6373:e=>{e.exports=import("resend")},6435:(e,s)=>{Object.defineProperty(s,"M",{enumerable:!0,get:function(){return function e(s,t){return t in s?s[t]:"then"in s&&"function"==typeof s.then?s.then(s=>e(s,t)):"function"==typeof s&&"default"===t?s:void 0}}})},6976:(e,s,t)=>{t.a(e,async(e,r)=>{try{t.r(s),t.d(s,{config:()=>d,default:()=>c,routeModule:()=>l});var n=t(3480),i=t(8667),o=t(6435),a=t(4919),u=e([a]);a=(u.then?(await u)():u)[0];let c=(0,o.M)(a,"default"),d=(0,o.M)(a,"config"),l=new n.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/subscribe",pathname:"/api/subscribe",bundlePath:"",filename:""},userland:a});r()}catch(e){r(e)}})},8667:(e,s)=>{Object.defineProperty(s,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})}};var s=require("../../webpack-api-runtime.js");s.C(e);var t=s(s.s=6976);module.exports=t})();