(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{296:(e,r,t)=>{"use strict";t.d(r,{default:()=>i});var a=t(5155),o=t(2115);async function n(e){if("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)return console.log("Development environment detected, using mock reCAPTCHA token"),"localhost-development-token";let r="6LdJdlArAAAAAO-X73zoegHTsZ8i-IEMiP0_o917";if(!r)throw Error("reCAPTCHA site key is not set");if(document.querySelector("script[src*='recaptcha/api.js']")||await new Promise((e,t)=>{let a=document.createElement("script");a.src="https://www.google.com/recaptcha/api.js?render=".concat(r),a.async=!0,a.onload=()=>e(),a.onerror=()=>t(Error("Failed to load reCAPTCHA script")),document.head.appendChild(a)}),"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)return"localhost-development-token";if(await new Promise((e,r)=>{if(window.grecaptcha)return e();let t=0,a=setInterval(()=>{if(window.grecaptcha){clearInterval(a),e();return}++t>=20&&(clearInterval(a),r(Error("reCAPTCHA failed to load after timeout")))},50)}),!window.grecaptcha)throw Error("reCAPTCHA not loaded");return await window.grecaptcha.execute(r,{action:e})}var s=t(5695);function i(){var e;let[r,t]=(0,o.useState)(""),[i,l]=(0,o.useState)(""),[d,c]=(0,o.useState)("idle"),[u,m]=(0,o.useState)(""),h=(0,s.useRouter)();e="6LdJdlArAAAAAO-X73zoegHTsZ8i-IEMiP0_o917",(0,o.useEffect)(()=>{if("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||!e||document.querySelector("script[src*='recaptcha/api.js']"))return;let r=document.createElement("script");r.src="https://www.google.com/recaptcha/api.js?render=".concat(e),r.async=!0,document.head.appendChild(r)},[e]);let p=async e=>{if(e.preventDefault(),!i){c("error"),m("Please enter your email address");return}if(!r){c("error"),m("Please enter your name");return}c("loading");try{let e;try{e=await n("newsletter_signup")}catch(r){if(console.error("reCAPTCHA error:",r),"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)e="localhost-development-token";else throw r}let t=await fetch("/api/newsletter/subscribe",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({name:r,email:i,recaptchaToken:e})}),a=await t.json();if(!t.ok){c("error"),m(a.message||"Failed to subscribe");return}h.push("/newsletter/thank-you")}catch(e){c("error"),e instanceof Error?e.message.includes("reCAPTCHA")?m("reCAPTCHA failed to load. Please try again later."):e.message.includes("fetch")?m("Could not connect to server. Please try again later."):m(e.message):m("An unexpected error occurred. Please try again.")}};return(0,a.jsxs)("div",{className:"bg-opacity-20 bg-brand-primary p-6 rounded-lg",children:[(0,a.jsx)("h3",{className:"text-xl font-bold text-white mb-2",children:"Stay Updated"}),(0,a.jsxs)("p",{className:"mb-4 text-white",children:["Be the first to discover new products and get access to our exclusive offers."," "]}),(0,a.jsxs)("form",{onSubmit:p,className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"name",className:"sr-only",children:"Full Name"}),(0,a.jsx)("input",{id:"name",name:"name",type:"text",value:r,onChange:e=>t(e.target.value),placeholder:"Enter your full name",className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-brand-primary focus:border-brand-primary mb-2",disabled:"loading"===d,required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"email",className:"sr-only",children:"Email address"}),(0,a.jsx)("input",{id:"email",name:"email",type:"email",value:i,onChange:e=>l(e.target.value),placeholder:"Enter your email",className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-brand-primary focus:border-brand-primary mb-2",disabled:"loading"===d,required:!0})]}),"error"===d&&(0,a.jsxs)("div",{className:"p-3 bg-red-100 text-red-700 rounded-md",children:[u," "]}),(0,a.jsx)("button",{type:"submit",disabled:"loading"===d,className:"w-full bg-brand-primary-2dark hover:bg-brand-primary-dark text-white py-2 px-4 rounded-md transition-colors disabled:opacity-50",children:"loading"===d?"Subscribing...":"Subscribe"})]})]})}},5695:(e,r,t)=>{"use strict";var a=t(8999);t.o(a,"usePathname")&&t.d(r,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(r,{useRouter:function(){return a.useRouter}})},8483:(e,r,t)=>{Promise.resolve().then(t.t.bind(t,6874,23)),Promise.resolve().then(t.t.bind(t,3063,23)),Promise.resolve().then(t.bind(t,296))}},e=>{var r=r=>e(e.s=r);e.O(0,[874,63,441,684,358],()=>r(8483)),_N_E=e.O()}]);