{"version":3,"file":"Substack.BPVCKykU.mjs","names":["useState","email","_Fragment"],"sources":["https:/framerusercontent.com/modules/7i2Z58e7QGSkSnOhgkwX/iBvaQKl722ZgeruTMxrM/Substack.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function SubstackSignup({workerUrl,publicationName,labelText,placeholder,successMessage,backgroundColor,borderColor,textColor,placeholderColor,gradientStart,gradientEnd,successColor,labelFont,inputFont,inputPadding,arrowSize,arrowPadding}){const[email,setEmail]=useState(\"\");const[status,setStatus]=useState(\"idle\");const[message,setMessage]=useState(\"\");const[isFocused,setIsFocused]=useState(false);const[isValid,setIsValid]=useState(false);const[showSuccessAnimation,setShowSuccessAnimation]=useState(false);// Email validation\nconst validateEmail=email=>/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);useEffect(()=>{setIsValid(validateEmail(email));},[email]);// Calculate progress\nconst getProgress=()=>{if(showSuccessAnimation)return 100;if(!email)return 0;if(isValid)return 100;const hasAt=email.includes(\"@\");const hasDot=email.includes(\".\");if(hasAt&&hasDot)return 75;if(hasAt)return 50;return 25;};const handleSubmit=async e=>{e.preventDefault();if(!email||!isValid)return;setStatus(\"loading\");try{const response=await fetch(workerUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({email,publication:publicationName})});const data=await response.json();if(data.success){setStatus(\"success\");setMessage(data.message||successMessage);setShowSuccessAnimation(true);setTimeout(()=>{setShowSuccessAnimation(false);setEmail(\"\");setIsValid(false);setStatus(\"idle\");},1500);}else{setStatus(\"error\");setMessage(data.error||\"Subscription failed\");setTimeout(()=>{setStatus(\"idle\");setMessage(\"\");},5e3);}}catch{setStatus(\"error\");setMessage(\"Network error. Please try again.\");setTimeout(()=>{setStatus(\"idle\");setMessage(\"\");},5e3);}};const progress=getProgress();const showProgress=isFocused||email||showSuccessAnimation;return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    @keyframes substackSpinner {\n                        from { transform: rotate(0deg); }\n                        to { transform: rotate(360deg); }\n                    }\n                    .substack-signup-input::placeholder {\n                        color: ${placeholderColor};\n                        opacity: 1;\n                        white-space: nowrap;\n                        overflow: hidden;\n                        text-overflow: ellipsis;\n                    }\n                `}),/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",fontFamily:labelFont},children:[labelText&&/*#__PURE__*/_jsx(\"div\",{style:{...labelFont,color:textColor,marginBottom:16,textAlign:\"center\",marginLeft:\"12%\",marginRight:\"12%\",textWrap:\"balance\"},children:labelText}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{position:\"relative\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",background:backgroundColor,border:`1px solid ${showSuccessAnimation?successColor:borderColor}`,borderBottom:\"none\",overflow:\"visible\",transition:\"border-color 0.5s ease\"},children:[/*#__PURE__*/_jsx(\"input\",{type:\"email\",className:\"substack-signup-input\",value:email,onChange:e=>setEmail(e.target.value),onFocus:()=>setIsFocused(true),onBlur:()=>setIsFocused(false),placeholder:placeholder,disabled:status===\"loading\"||showSuccessAnimation,style:{...inputFont,color:textColor,width:\"100%\",padding:inputPadding,border:\"none\",outline:\"none\",background:\"transparent\",WebkitAppearance:\"none\",textOverflow:\"ellipsis\",whiteSpace:\"nowrap\",overflow:\"hidden\"}}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"loading\"||!isValid||showSuccessAnimation,style:{position:\"absolute\",right:8,top:\"50%\",transform:\"translateY(-50%)\",background:\"none\",border:\"none\",padding:arrowPadding,cursor:isValid&&!showSuccessAnimation?\"pointer\":\"default\",opacity:isValid||showSuccessAnimation?1:.3,transition:\"all 0.5s ease\",fontSize:arrowSize,display:\"flex\",color:showSuccessAnimation?successColor:textColor,alignItems:\"center\",justifyContent:\"center\"},children:status===\"loading\"?// Loading spinner\n/*#__PURE__*/_jsxs(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{animation:\"substackSpinner 1s linear infinite\"},children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:\"currentColor\",strokeWidth:\"3\",strokeLinecap:\"round\",strokeDasharray:\"31.4 31.4\",transform:\"rotate(-90 12 12)\",opacity:\"0.25\"}),/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:\"currentColor\",strokeWidth:\"3\",strokeLinecap:\"round\",strokeDasharray:\"15.7 47.1\",transform:\"rotate(-90 12 12)\"})]}):showSuccessAnimation?// Success checkmark\n/*#__PURE__*/_jsx(\"svg\",{width:arrowSize,height:arrowSize*.8,viewBox:\"0 0 21 17\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M19 2L7 14L2 9\",stroke:\"currentColor\",strokeWidth:\"3\"})}):// Arrow\n/*#__PURE__*/_jsx(\"svg\",{width:arrowSize+4,height:arrowSize,viewBox:\"0 0 28 25\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M25.127 10.0049L25.1328 10L27.2539 12.1211L27.248 12.126L27.2539 12.1328L25.1328 14.2539L25.127 14.248L15.2334 24.1416L13.1123 22.0205L21.6328 13.5H0V10.5H21.3789L13.1113 2.23242L15.2334 0.111328L25.127 10.0049Z\",fill:\"currentColor\"})})})]}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:4,background:showSuccessAnimation?successColor:borderColor,transition:\"background 0.5s ease\",marginTop:-1},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:0,top:0,height:\"100%\",width:showProgress?`${progress}%`:\"0%\",background:showSuccessAnimation?successColor:`linear-gradient(90deg, ${gradientStart} 0%, ${gradientEnd} 100%)`,transition:\"width 0.3s ease-out\"}})})]}),message&&/*#__PURE__*/_jsx(\"div\",{style:{marginTop:16,fontSize:\"1rem\",color:status===\"error\"?\"#f02f2f\":textColor,transition:\"opacity 0.3s ease\"},children:message})]})]});}// Add Framer property controls\naddPropertyControls(SubstackSignup,{inputFont:{type:ControlType.Font,title:\"Input Font\",controls:\"extended\"},labelFont:{type:ControlType.Font,title:\"Label Font\",controls:\"extended\"},inputPadding:{type:ControlType.Padding,defaultValue:\"24px 56px 24px 29px\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:24,min:10,max:256,unit:\"px\"},arrowPadding:{type:ControlType.Padding,defaultValue:\"12px\"},workerUrl:{type:ControlType.String,title:\"Worker URL\",defaultValue:\"https://substackthing.benellisgold.workers.dev/\"},publicationName:{type:ControlType.String,title:\"Publication\",defaultValue:\"designerfund\"},labelText:{type:ControlType.String,title:\"Label\",defaultValue:\"\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"lauren.ipsum@gmail.com\"},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Check your email to finish subscribing!\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#1f2a47\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000c2d\"},placeholderColor:{type:ControlType.Color,title:\"Placeholder\",defaultValue:\"#999999\"},gradientStart:{type:ControlType.Color,title:\"Gradient Start\",defaultValue:\"#20de86\"},gradientEnd:{type:ControlType.Color,title:\"Gradient End\",defaultValue:\"#4bd1cc\"},successColor:{type:ControlType.Color,title:\"Success Color\",defaultValue:\"#20de86\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SubstackSignup\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingUR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