{"version":3,"file":"NewsletterInput.C2RpOS7h.mjs","names":["useState","useRef","email"],"sources":["https:/framerusercontent.com/modules/GNe6dtZaVeKNcxV9sxpv/S8Kzh6xbHPJrmgKXxwa1/NewsletterInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef}from\"react\";export default function NewsletterInput({apiUrl=\"https://newsletter-backend-i8h7gi2v6-cleo-academys-projects.vercel.app/api/newsletter-signup\",listId=11}={}){const[email,setEmail]=useState(\"\");const[isHovered,setIsHovered]=useState(false);const[isFocused,setIsFocused]=useState(false);const[error,setError]=useState(null);const[isSubmitting,setIsSubmitting]=useState(false);const[isSuccess,setIsSuccess]=useState(false);const inputRef=useRef(null);// Detect browser language\nconst isFrench=typeof navigator!==\"undefined\"&&navigator.language.startsWith(\"fr\");// Translations\nconst translations={placeholder:isFrench?\"Email\":\"Email\",emailRequired:isFrench?\"Email requis\":\"Email required\",emailInvalid:isFrench?\"Email invalide\":\"Invalid email\",signupFailed:isFrench?\"\\xc9chec de l'inscription\":\"Signup failed\",errorOccurred:isFrench?\"Une erreur est survenue\":\"An error occurred\",successMessage:isFrench?\"Vous \\xeates enregistr\\xe9s\":\"You're registered\"};// Email validation regex\nconst validateEmail=email=>{const emailRegex=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;return emailRegex.test(email);};// Handle form submission\nconst handleSubmit=async e=>{e.preventDefault();// Reset states\nsetError(null);// Validate email\nif(!email.trim()){setError(translations.emailRequired);return;}if(!validateEmail(email)){setError(translations.emailInvalid);return;}setIsSubmitting(true);try{// VERCEL EDGE FUNCTION - Sécurisé\nconst response=await fetch(apiUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({email:email,listId:listId})});const data=await response.json();if(!response.ok){throw new Error(data.error||translations.signupFailed);}// Success\nsetIsSuccess(true);setEmail(\"\");}catch(err){setError(err instanceof Error?err.message:translations.errorOccurred);}finally{setIsSubmitting(false);}};// Handle blur event for validation\nconst handleBlur=()=>{setIsFocused(false);if(email&&!validateEmail(email)){setError(translations.emailInvalid);}};// Handle focus event\nconst handleFocus=()=>{setIsFocused(true);setError(null);setIsSuccess(false);};// Determine background color based on state\nconst getBackgroundColor=()=>{if(error)return\"#ffffff\";if(isSuccess)return\"#ffffff\";if(isFocused)return\"#F8FAFC\"// Slate-50\n;if(isHovered)return\"#475569\"// Slate-600\n;return\"#1E293B\"// Slate-800\n;};// Determine text color based on state\nconst getTextColor=()=>{if(error||isSuccess)return\"#000000\";if(isFocused)return\"#0F172A\"// Slate-900\n;if(isHovered)return\"#CBD5E1\"// Slate-300\n;return\"#CBD5E1\"// Slate-300\n;};// Determine border color based on state\nconst getBorderColor=()=>{if(error)return\"#ef4444\";if(isFocused)return\"#E2E8F0\"// Slate-200\n;return\"#475569\"// Slate-600\n;};// Container style\nconst containerStyle={width:\"100%\",maxWidth:\"448px\",margin:\"0 auto\"};// Success container style\nconst successContainerStyle={display:\"flex\",width:\"100%\",padding:\"16px\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"flex-start\",gap:\"16px\",borderRadius:\"24px\",border:\"1px solid #475569\",background:\"#1E293B\",boxShadow:\"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",animation:\"fadeInSlideUp 300ms ease-out\"};// Input wrapper style\nconst inputWrapperStyle={position:\"relative\",width:\"100%\",borderRadius:\"24px\",backgroundColor:getBackgroundColor(),border:`1px solid ${getBorderColor()}`,boxShadow:\"0 1px 2px 0 rgba(0, 0, 0, 0.05)\",transition:\"all 300ms ease-in-out\",overflow:\"hidden\"};// Input flex container style\nconst inputFlexStyle={display:\"flex\",alignItems:\"center\"};// Error indicator style\nconst errorIndicatorStyle={position:\"absolute\",left:\"16px\",width:\"24px\",height:\"24px\",borderRadius:\"50%\",backgroundColor:\"#ef4444\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",animation:\"zoomIn 200ms ease-out\"};// Input field style\nconst inputStyle={flex:1,paddingLeft:error?\"56px\":\"24px\",paddingRight:\"64px\",paddingTop:\"16px\",paddingBottom:\"16px\",backgroundColor:\"transparent\",color:getTextColor(),outline:\"none\",transition:\"all 300ms ease-in-out\",fontSize:\"16px\",border:\"none\"};// Submit button style\nconst submitButtonStyle={position:\"absolute\",right:\"8px\",width:\"40px\",height:\"40px\",borderRadius:\"50%\",backgroundColor:\"#0E2AD6\",border:\"none\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",transition:\"all 200ms ease-in-out\",opacity:isSubmitting?.5:1,animation:isSubmitting?\"pulse 2s infinite\":\"none\"};// Error message style\nconst errorMessageStyle={marginTop:\"8px\",fontSize:\"14px\",color:\"#ef4444\",marginLeft:\"24px\",animation:\"slideInFromTop 200ms ease-out\"};// Success content style\nconst successContentStyle={display:\"flex\",alignItems:\"center\",gap:\"12px\"};// Success checkmark container style\nconst checkmarkContainerStyle={width:\"24px\",height:\"24px\",borderRadius:\"50%\",backgroundColor:\"#22c55e\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",animation:\"zoomIn 500ms ease-out\"};// Success text style\nconst successTextStyle={color:\"#FFF\",fontFamily:\"Inter\",fontSize:\"16px\",fontStyle:\"normal\",fontWeight:400,lineHeight:\"normal\"};// Success content wrapper\nconst successContentWrapperStyle={display:\"flex\",justifyContent:\"space-between\",alignItems:\"center\",width:\"100%\"};// Reset button style\nconst resetButtonStyle={width:\"40px\",height:\"40px\",borderRadius:\"50%\",backgroundColor:\"#0E2AD6\",border:\"none\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",transition:\"background-color 200ms ease-in-out\"};return /*#__PURE__*/_jsxs(\"div\",{style:containerStyle,children:[isSuccess?// Success State\n/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{style:successContainerStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:successContentWrapperStyle,children:[/*#__PURE__*/_jsx(\"span\",{style:successTextStyle,children:translations.successMessage}),/*#__PURE__*/_jsx(\"div\",{style:checkmarkContainerStyle,children:/*#__PURE__*/_jsx(\"svg\",{width:\"14\",height:\"11\",viewBox:\"0 0 14 11\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M1 5.5L5 9.5L13 1.5\",stroke:\"white\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})})})]})})}):// Input Form\n/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{position:\"relative\"},children:[/*#__PURE__*/_jsx(\"div\",{style:inputWrapperStyle,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),children:/*#__PURE__*/_jsxs(\"div\",{style:inputFlexStyle,children:[error&&/*#__PURE__*/_jsx(\"div\",{style:errorIndicatorStyle,children:/*#__PURE__*/_jsx(\"span\",{style:{color:\"white\",fontSize:\"14px\",fontWeight:\"bold\"},children:\"!\"})}),/*#__PURE__*/_jsx(\"input\",{ref:inputRef,type:\"email\",value:email,onChange:e=>{setEmail(e.target.value);setError(null);},onFocus:handleFocus,onBlur:handleBlur,placeholder:translations.placeholder,style:inputStyle,disabled:isSubmitting}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:isSubmitting,style:submitButtonStyle,onMouseOver:e=>{if(!isSubmitting){e.currentTarget.style.backgroundColor=\"#0E2AD6\";}},onMouseOut:e=>{e.currentTarget.style.backgroundColor=\"#0E2AD6\";},onMouseDown:e=>{e.currentTarget.style.transform=\"scale(0.95)\";},onMouseUp:e=>{e.currentTarget.style.transform=\"scale(1)\";},\"aria-label\":\"Submit\",children:isSubmitting?// Loading Spinner\n/*#__PURE__*/_jsx(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{animation:\"spin 1s linear infinite\"},children:/*#__PURE__*/_jsx(\"circle\",{cx:\"8\",cy:\"8\",r:\"6\",stroke:\"white\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeDasharray:\"30 10\"})}):// Arrow Icon\n/*#__PURE__*/_jsx(\"svg\",{width:\"12\",height:\"12\",viewBox:\"0 0 12 12\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M6 10L6 2M6 2L2 6M6 2L10 6\",stroke:\"white\",strokeWidth:\"1\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})})})]})}),error&&/*#__PURE__*/_jsx(\"p\",{style:errorMessageStyle,children:error})]}),/*#__PURE__*/_jsx(\"style\",{children:`\n        @keyframes zoomIn {\n          from {\n            transform: scale(0);\n          }\n          to {\n            transform: scale(1);\n          }\n        }\n\n        @keyframes fadeInSlideUp {\n          from {\n            opacity: 0;\n            transform: translateY(8px);\n          }\n          to {\n            opacity: 1;\n            transform: translateY(0);\n          }\n        }\n\n        @keyframes slideInFromTop {\n          from {\n            opacity: 0;\n            transform: translateY(-4px);\n          }\n          to {\n            opacity: 1;\n            transform: translateY(0);\n          }\n        }\n\n        @keyframes spin {\n          from {\n            transform: rotate(0deg);\n          }\n          to {\n            transform: rotate(360deg);\n          }\n        }\n\n        input::placeholder {\n          color: ${isFocused?\"#94A3B8\":isHovered?\"#CBD5E1\":\"#64748B\"};\n        }\n      `})]});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NewsletterInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NewsletterInput.map"],"mappings":"8IAA4F,SAAwB,EAAgB,CAAC,SAAO,+FAA+F,SAAO,IAAI,EAAE,CAAC,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EA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