{"version":3,"file":"Email_Collector.CUeffJWk.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/oKDjjcv9kYVwF7JuByTT/ok2ng9XGbyRi9kXhGDXY/Email_Collector.js"],"sourcesContent":["// GatsboyEmailCollector.tsx\n// @framerDisableUnlink\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";// @framerDisableUnlink\nexport default function GatsboyEmailCollector(props){const{emailLabel,emailPlaceholder,buttonText,successMessage,errorMessage,backgroundColor,inputBackground,inputBorder,inputBorderFocus,textColor,labelColor,buttonColor,buttonTextColor,buttonHoverColor,borderRadius,inputBorderRadius,gap,previewDisabled,disabledBackgroundColor,disabledTextColor,disabledMessage}=props;const[email,setEmail]=useState(\"\");const[status,setStatus]=useState(\"idle\");const[focusedField,setFocusedField]=useState(null);const[isLive,setIsLive]=useState(false);const[siteId,setSiteId]=useState(null);useEffect(()=>{// Check if we're in a live environment (not Framer canvas)\nconst checkEnvironment=()=>{const gatsboy=window.Gatsboy;if(gatsboy?.siteId){setIsLive(true);setSiteId(gatsboy.siteId);}};checkEnvironment();// Re-check after a short delay in case runtime loads async\nconst timer=setTimeout(checkEnvironment,500);return()=>clearTimeout(timer);},[]);const handleSubmit=async e=>{e.preventDefault();if(!isLive||!siteId){// On canvas, just show success state briefly\nsetStatus(\"success\");setTimeout(()=>setStatus(\"idle\"),2e3);return;}setStatus(\"submitting\");try{const response=await fetch(\"https://xjbxfwdqtfnnpvgpykiz.supabase.co/functions/v1/form-submit\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({site_id:siteId,form_type:\"email_collector\",payload:{email},email,page_url:window.location.href,referrer:document.referrer||null})});if(!response.ok)throw new Error(\"Failed to submit\");setStatus(\"success\");setEmail(\"\");setTimeout(()=>setStatus(\"idle\"),3e3);}catch(err){console.error(\"Email collector submission error:\",err);setStatus(\"error\");setTimeout(()=>setStatus(\"idle\"),3e3);}};// Check if module should show as disabled\nconst showDisabled=previewDisabled&&!isLive;if(showDisabled){return /*#__PURE__*/_jsx(\"div\",{style:{backgroundColor:disabledBackgroundColor,borderRadius,padding:24,textAlign:\"center\"},children:/*#__PURE__*/_jsx(\"p\",{style:{color:disabledTextColor,margin:0,fontSize:14},children:disabledMessage})});}const inputStyle={width:\"100%\",padding:\"12px 16px\",fontSize:16,color:textColor,backgroundColor:inputBackground,border:\"1px solid \"+(focusedField===\"email\"?inputBorderFocus:inputBorder),borderRadius:inputBorderRadius,outline:\"none\",transition:\"border-color 0.2s ease\",boxSizing:\"border-box\"};return /*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{backgroundColor,borderRadius,padding:24,display:\"flex\",flexDirection:\"column\",gap},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:6},children:[/*#__PURE__*/_jsx(\"label\",{style:{fontSize:14,fontWeight:500,color:labelColor},children:emailLabel}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",required:true,placeholder:emailPlaceholder,value:email,onChange:e=>setEmail(e.target.value),onFocus:()=>setFocusedField(\"email\"),onBlur:()=>setFocusedField(null),disabled:status===\"submitting\",style:inputStyle})]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"submitting\",style:{width:\"100%\",padding:\"14px 24px\",fontSize:16,fontWeight:600,color:buttonTextColor,backgroundColor:status===\"submitting\"?buttonHoverColor:buttonColor,border:\"none\",borderRadius:inputBorderRadius,cursor:status===\"submitting\"?\"not-allowed\":\"pointer\",transition:\"background-color 0.2s ease\",opacity:status===\"submitting\"?.7:1},onMouseEnter:e=>{if(status!==\"submitting\"){e.currentTarget.style.backgroundColor=buttonHoverColor;}},onMouseLeave:e=>{if(status!==\"submitting\"){e.currentTarget.style.backgroundColor=buttonColor;}},children:status===\"submitting\"?\"Subscribing...\":buttonText}),status===\"success\"&&/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#ECFDF5\",borderRadius:inputBorderRadius,color:\"#065F46\",fontSize:14,textAlign:\"center\"},children:successMessage}),status===\"error\"&&/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#FEF2F2\",borderRadius:inputBorderRadius,color:\"#991B1B\",fontSize:14,textAlign:\"center\"},children:errorMessage})]});}addPropertyControls(GatsboyEmailCollector,{// Labels\nemailLabel:{type:ControlType.String,title:\"Email Label\",defaultValue:\"Email\"},emailPlaceholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"you@example.com\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Subscribe\"},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Thanks for subscribing!\"},errorMessage:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Something went wrong. Please try again.\"},// Styling\nbackgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},inputBackground:{type:ControlType.Color,title:\"Input BG\",defaultValue:\"#F9FAFB\"},inputBorder:{type:ControlType.Color,title:\"Input Border\",defaultValue:\"#E5E7EB\"},inputBorderFocus:{type:ControlType.Color,title:\"Focus Border\",defaultValue:\"#3B82F6\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#111827\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#374151\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#3B82F6\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},buttonHoverColor:{type:ControlType.Color,title:\"Button Hover\",defaultValue:\"#2563EB\"},borderRadius:{type:ControlType.Number,title:\"Card Radius\",defaultValue:12,min:0,max:32,unit:\"px\"},inputBorderRadius:{type:ControlType.Number,title:\"Input Radius\",defaultValue:8,min:0,max:24,unit:\"px\"},gap:{type:ControlType.Number,title:\"Field Gap\",defaultValue:16,min:8,max:32,unit:\"px\"},// Disabled state\npreviewDisabled:{type:ControlType.Boolean,title:\"Preview Disabled\",defaultValue:false},disabledBackgroundColor:{type:ControlType.Color,title:\"Disabled BG\",defaultValue:\"#F9FAFB\"},disabledTextColor:{type:ControlType.Color,title:\"Disabled Text\",defaultValue:\"#6B7280\"},disabledMessage:{type:ControlType.String,title:\"Disabled Message\",defaultValue:\"Email signup is disabled\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GatsboyEmailCollector\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Email_Collector.map"],"mappings":"iMAGA,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,aAAW,mBAAiB,aAAW,iBAAe,eAAa,kBAAgB,kBAAgB,cAAY,mBAAiB,YAAU,aAAW,cAAY,kBAAgB,mBAAiB,eAAa,oBAAkB,MAAI,kBAAgB,0BAAwB,oBAAkB,mBAAiB,EAAW,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAO,GAAWA,EAAS,OAAO,CAAM,CAAC,EAAa,GAAiBA,EAAS,KAAK,CAAM,CAAC,EAAO,GAAWA,EAAS,GAAM,CAAM,CAAC,EAAO,GAAWA,EAAS,KAAK,CAAC,MAAc,CAC7kB,IAAM,MAAqB,CAAC,IAAM,EAAQ,EAAO,QAAW,GAAS,SAAQ,EAAU,GAAK,CAAC,EAAU,EAAQ,OAAO,GAAI,GAAkB,CAC5I,IAAM,EAAM,WAAW,EAAiB,IAAI,CAAC,UAAU,aAAa,EAAM,EAAG,EAAE,CAAC,CAAC,IAAM,EAAa,KAAM,IAAG,CAAoB,GAAnB,EAAE,gBAAgB,CAAI,CAAC,GAAQ,CAAC,EAAO,CACrJ,EAAU,UAAU,CAAC,eAAe,EAAU,OAAO,CAAC,IAAI,CAAC,OAAQ,EAAU,aAAa,CAAC,GAAG,CAAoT,GAAG,EAAvS,MAAM,MAAM,oEAA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