{"version":3,"file":"GuideDownloadGate.Cv48Wehs.mjs","names":["React.useState"],"sources":["https:/framerusercontent.com/modules/T4noZu6LcBzAhEZ99BL7/5tOfaiBvyQKsXftP6gWv/GuideDownloadGate.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Email-gated PDF download. User enters their email, clicks Download,\n * we (optionally) POST the email to a Tally form, then trigger the\n * PDF download. The PDF should be uploaded via the \"PDF File\" control\n * so Framer hosts it on its own CDN.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 380\n * @framerIntrinsicHeight 320\n */// Free / personal email providers. If `blockFreeEmails` is true, any\n// address whose domain matches one of these (case-insensitive) will be\n// rejected with `freeEmailErrorText`.\nconst FREE_EMAIL_DOMAINS=new Set([\"gmail.com\",\"googlemail.com\",\"yahoo.com\",\"yahoo.co.uk\",\"yahoo.co.in\",\"yahoo.fr\",\"yahoo.de\",\"yahoo.es\",\"yahoo.it\",\"ymail.com\",\"rocketmail.com\",\"hotmail.com\",\"hotmail.co.uk\",\"hotmail.fr\",\"hotmail.de\",\"outlook.com\",\"outlook.co.uk\",\"outlook.in\",\"live.com\",\"live.co.uk\",\"live.in\",\"msn.com\",\"icloud.com\",\"me.com\",\"mac.com\",\"aol.com\",\"aim.com\",\"protonmail.com\",\"proton.me\",\"pm.me\",\"gmx.com\",\"gmx.us\",\"gmx.net\",\"gmx.de\",\"mail.com\",\"zoho.com\",\"yandex.com\",\"yandex.ru\",\"fastmail.com\",\"fastmail.fm\",\"hey.com\",\"tutanota.com\",\"tutanota.de\",\"tuta.io\",\"rediffmail.com\",\"rediff.com\",\"qq.com\",\"163.com\",\"126.com\",\"naver.com\",\"daum.net\",\"hanmail.net\"]);export default function GuideDownloadGate(props){const{pdfFile=\"\",downloadFilename=\"guide.pdf\",tallyFormUrl=\"\",resourceName=\"Guide\",heading=\"Download a free copy\",sublabel=\"Your Information\",emailPlaceholder=\"Work email\",namePlaceholder=\"Full name\",showName=true,helperText=\"Please use a work email address\",buttonLabel=\"Download\",successText=\"Done — your download should start shortly.\",cardBackground=\"rgba(255, 255, 255, 0.7)\",inputBackground=\"#FFFFFF\",textColor=\"#0A0A0A\",helperColor=\"#6B6B6B\",accentColor=\"#0A0A0A\",accentTextColor=\"#FFFFFF\",radius=8,blockFreeEmails=true,freeEmailErrorText=\"Please use your work email address.\"}=props;const[name,setName]=React.useState(\"\");const[email,setEmail]=React.useState(\"\");const[status,setStatus]=React.useState(\"idle\");const[errorMsg,setErrorMsg]=React.useState(\"\");function isValidEmail(v){return/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v.trim());}function isFreeEmail(v){const at=v.lastIndexOf(\"@\");if(at===-1)return false;const domain=v.slice(at+1).trim().toLowerCase();if(!domain)return false;return FREE_EMAIL_DOMAINS.has(domain);}function triggerDownload(url,filename){const a=document.createElement(\"a\");a.href=url;a.download=filename;a.target=\"_blank\";a.rel=\"noopener\";document.body.appendChild(a);a.click();document.body.removeChild(a);}async function postToTally(formUrl,payload){if(!formUrl)return;try{// Tally accepts no-cors POSTs to the form URL with form data.\nconst fd=new FormData;for(const k of Object.keys(payload))fd.append(k,payload[k]);await fetch(formUrl,{method:\"POST\",mode:\"no-cors\",body:fd});}catch(err){// Best-effort; don't block download on submission errors.\nconsole.warn(\"Lead submit failed:\",err);}}async function handleSubmit(e){e.preventDefault();if(status===\"submitting\")return;setErrorMsg(\"\");if(showName&&!name.trim()){setStatus(\"error\");setErrorMsg(\"Please enter your name.\");return;}if(!isValidEmail(email)){setStatus(\"error\");setErrorMsg(\"Please enter a valid email.\");return;}if(blockFreeEmails&&isFreeEmail(email)){setStatus(\"error\");setErrorMsg(freeEmailErrorText);return;}if(!pdfFile){setStatus(\"error\");setErrorMsg(\"No PDF set on this component. Upload one in the right panel.\");return;}setStatus(\"submitting\");await postToTally(tallyFormUrl,{name:name.trim(),email:email.trim(),resource:resourceName});triggerDownload(pdfFile,downloadFilename);setStatus(\"done\");}const inputStyle={width:\"100%\",padding:\"12px 14px\",borderRadius:8,border:\"1px solid rgba(0,0,0,0.12)\",background:inputBackground,color:textColor,fontSize:14,lineHeight:\"1.4em\",outline:\"none\",appearance:\"none\",boxSizing:\"border-box\"};return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",background:cardBackground,borderRadius:radius,padding:20,display:\"flex\",flexDirection:\"column\",gap:12,color:textColor,boxSizing:\"border-box\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:18,fontWeight:600,letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},children:heading}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:13,color:helperColor,fontFamily:\"ui-monospace, SFMono-Regular, Menlo, monospace\",textTransform:\"uppercase\",letterSpacing:\"0.04em\"},children:sublabel}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",flexDirection:\"column\",gap:10},noValidate:true,children:[showName?/*#__PURE__*/_jsx(\"input\",{type:\"text\",placeholder:namePlaceholder,value:name,onChange:e=>setName(e.target.value),style:inputStyle,autoComplete:\"name\"}):null,/*#__PURE__*/_jsx(\"input\",{type:\"email\",placeholder:emailPlaceholder,value:email,onChange:e=>setEmail(e.target.value),style:inputStyle,autoComplete:\"email\",inputMode:\"email\"}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:12,color:helperColor,fontFamily:\"ui-monospace, SFMono-Regular, Menlo, monospace\",paddingLeft:4},children:helperText}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:status===\"submitting\",style:{width:\"100%\",padding:\"14px 18px\",borderRadius:8,border:\"none\",background:accentColor,color:accentTextColor,fontSize:15,fontWeight:600,cursor:status===\"submitting\"?\"wait\":\"pointer\",opacity:status===\"submitting\"?.7:1,transition:\"opacity 160ms ease\"},children:status===\"submitting\"?\"Sending…\":status===\"done\"?\"Downloaded ✓\":buttonLabel}),errorMsg?/*#__PURE__*/_jsx(\"div\",{style:{fontSize:13,color:\"#B00020\",paddingLeft:4},children:errorMsg}):null,status===\"done\"?/*#__PURE__*/_jsx(\"div\",{style:{fontSize:13,color:helperColor,paddingLeft:4},children:successText}):null]})]});}addPropertyControls(GuideDownloadGate,{pdfFile:{type:ControlType.File,title:\"PDF File\",allowedFileTypes:[\"pdf\"]},downloadFilename:{type:ControlType.String,title:\"Filename\",defaultValue:\"guide.pdf\",placeholder:\"guide.pdf\"},tallyFormUrl:{type:ControlType.String,title:\"Tally URL\",defaultValue:\"\",placeholder:\"https://tally.so/r/XXXXXX (optional)\"},resourceName:{type:ControlType.String,title:\"Resource Name\",defaultValue:\"Guide\",placeholder:\"e.g. Law Firm of the Future\"},heading:{type:ControlType.String,title:\"Heading\",defaultValue:\"Download a free copy\"},sublabel:{type:ControlType.String,title:\"Sublabel\",defaultValue:\"Your Information\"},emailPlaceholder:{type:ControlType.String,title:\"Email Placeholder\",defaultValue:\"Work email\"},namePlaceholder:{type:ControlType.String,title:\"Name Placeholder\",defaultValue:\"Full name\"},showName:{type:ControlType.Boolean,title:\"Show Name\",defaultValue:true},helperText:{type:ControlType.String,title:\"Helper Text\",defaultValue:\"Please use a work email address\"},buttonLabel:{type:ControlType.String,title:\"Button Label\",defaultValue:\"Download\"},successText:{type:ControlType.String,title:\"Success Text\",defaultValue:\"Done — your download should start shortly.\"},blockFreeEmails:{type:ControlType.Boolean,title:\"Block Free Emails\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},freeEmailErrorText:{type:ControlType.String,title:\"Free Email Error\",defaultValue:\"Please use your work email address.\",hidden:props=>!props.blockFreeEmails},cardBackground:{type:ControlType.Color,title:\"Card BG\",defaultValue:\"rgba(255, 255, 255, 0.7)\"},inputBackground:{type:ControlType.Color,title:\"Input BG\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#0A0A0A\"},helperColor:{type:ControlType.Color,title:\"Helper Text\",defaultValue:\"#6B6B6B\"},accentColor:{type:ControlType.Color,title:\"Button BG\",defaultValue:\"#0A0A0A\"},accentTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:40,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GuideDownloadGate\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GuideDownloadGate.map"],"mappings":"kLAa6pB,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,UAAQ,GAAG,mBAAiB,YAAY,eAAa,GAAG,eAAa,QAAQ,UAAQ,uBAAuB,WAAS,mBAAmB,mBAAiB,aAAa,kBAAgB,YAAY,WAAS,GAAK,aAAW,kCAAkC,cAAY,WAAW,cAAY,6CAA6C,iBAAe,2BAA2B,kBAAgB,UAAU,YAAU,UAAU,cAAY,UAAU,cAAY,UAAU,kBAAgB,UAAU,SAAO,EAAE,kBAAgB,GAAK,qBAAmB,uCAAuC,EAAW,CAAC,EAAK,GAASA,EAAe,GAAG,CAAM,CAAC,EAAM,GAAUA,EAAe,GAAG,CAAM,CAAC,EAAO,GAAWA,EAAe,OAAO,CAAM,CAAC,EAAS,GAAaA,EAAe,GAAG,CAAC,SAAS,EAAa,EAAE,CAAC,MAAM,6BAA6B,KAAK,EAAE,MAAM,CAAC,CAAE,SAAS,EAAY,EAAE,CAAC,IAAM,EAAG,EAAE,YAAY,IAAI,CAAC,GAAG,IAAK,GAAG,MAAO,GAAM,IAAM,EAAO,EAAE,MAAM,EAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAyB,OAApB,EAA2B,EAAmB,IAAI,EAAO,CAA3C,GAA6C,SAAS,EAAgB,EAAI,EAAS,CAAC,IAAM,EAAE,SAAS,cAAc,IAAI,CAAC,EAAE,KA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