{"version":3,"file":"DownloadPdfButton.BRAZyFVv.mjs","names":["React.useState","React.useCallback","__legacyOverrideHOC_DataObserverContext","_jsx","useCallback"],"sources":["https:/framerusercontent.com/modules/YeauMiL4Q4O2t7OHKnNI/gGRjC7rRoBPStE0azUq6/EnableDownloadButton.js","https:/framerusercontent.com/modules/UuPNi5F3EehIq4U2I34j/exmfEkINfbzMTTFFISd1/DownloadPdfButton.js"],"sourcesContent":["// EnableDownloadButton.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";const FORM_NAME=\"Whitepaper Form\";// ----- helpers -----\nfunction getFormRoot(){const forms=Array.from(document.querySelectorAll(`[data-framer-name=\"${FORM_NAME}\"]`));if(!forms.length)return null;return forms.find(el=>el.offsetParent!==null)||forms[forms.length-1];}function findInputByName(name){const root=getFormRoot();if(!root)return null;let el=root.querySelector(`input[name=\"${name}\"]`);if(el)return el;const wrapper=root.querySelector(`[name=\"${name}\"]`);if(wrapper){el=wrapper.querySelector(\"input\");if(el)return el;}if(name.includes(\"Phone\")){el=root.querySelector(`input[type=\"tel\"][name=\"${name}\"]`)||(wrapper?wrapper.querySelector(\"input[type='tel']\"):null);if(el)return el;}return null;}function val(name){return(findInputByName(name)?.value??\"\").trim();}function digits(s){return s.replace(/\\D/g,\"\");}// -------- EMAIL VALIDATION --------\n// ❌ Instantly invalid if email contains any personal domain keyword\nfunction validEmail(s){const lower=s.toLowerCase();const blocked=[\"gmail\",\"gmail.com\",\"yahoo\",\"yahoo.com\",\"hotmail\",\"hotmail.com\",\"outlook\",\"outlook.com\",\"live\",\"live.com\",\"aol\",\"aol.com\",\"protonmail\",\"protonmail.com\",\"icloud\",\"icloud.com\",\"me.com\",\"me\"];// ❌ if ANY blocked keyword appears anywhere in the email → invalid instantly\nif(blocked.some(b=>lower.includes(b)))return false;// Basic format check\nconst basic=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;if(!s.includes(\"@\")||s.endsWith(\"@\")||!basic.test(s)){return null// incomplete → no error yet\n;}const domain=s.split(\"@\")[1]?.toLowerCase();if(!domain)return false;// If domain itself is in blocked list → invalid\nif(blocked.includes(domain))return false;return true;}// field names\nconst N={fullName:\"Full Name*\",email:\"Email*\",phone:\"Phone Number*\",company:\"Company*\",designation:\"Designation*\"};// ----- override -----\nexport function EnableDownloadButton(){const[enabled,setEnabled]=React.useState(false);const validate=React.useCallback(()=>{const v={fullName:val(N.fullName),email:val(N.email),phone:val(N.phone),company:val(N.company),designation:val(N.designation)};const emailInput=findInputByName(N.email);// ⭐ EMAIL VALIDATES LIVE WHILE TYPING\nconst emailCheck=validEmail(v.email);if(emailInput){if(emailCheck===false){emailInput.setCustomValidity(\"Please enter your business email address.\");emailInput.reportValidity();}else{emailInput.setCustomValidity(\"\");}}// ---- Button Logic ----\nconst allFilled=v.fullName&&v.email&&v.phone&&v.company&&v.designation;let ok=Boolean(allFilled);if(!ok){setEnabled(false);return false;}if(emailCheck!==true)ok=false;if(digits(v.phone).length<7)ok=false;setEnabled(ok);return ok;},[]);React.useEffect(()=>{const init=setTimeout(()=>validate(),80);const onInput=()=>validate();document.addEventListener(\"input\",onInput,true);document.addEventListener(\"change\",onInput,true);const root=getFormRoot();const mo=root?new MutationObserver(()=>validate()):null;if(root&&mo)mo.observe(root,{childList:true,subtree:true});const onKeyDown=e=>{if(e.key===\"Enter\"){if(!validate()){e.preventDefault();e.stopPropagation();}}};if(root)root.addEventListener(\"keydown\",onKeyDown,true);return()=>{clearTimeout(init);document.removeEventListener(\"input\",onInput,true);document.removeEventListener(\"change\",onInput,true);if(mo)mo.disconnect();if(root)root.removeEventListener(\"keydown\",onKeyDown,true);};},[validate]);const gate=e=>{if(!validate()){e.preventDefault?.();e.stopPropagation?.();}};return{disabled:!enabled,style:{pointerEvents:enabled?\"auto\":\"none\",opacity:enabled?1:.5,cursor:enabled?\"pointer\":\"not-allowed\"},onClick:gate,onTap:gate};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withEnableDownloadButton(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...EnableDownloadButton(props)});};}withEnableDownloadButton.displayName=\"EnableDownloadButton\";\nexport const __FramerMetadata__ = {\"exports\":{\"EnableDownloadButton\":{\"type\":\"override\",\"name\":\"EnableDownloadButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEnableDownloadButton\":{\"type\":\"reactHoc\",\"name\":\"withEnableDownloadButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EnableDownloadButton.map","// Download PDF button with customizable filename\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useCallback}from\"react\";/**\n * Download PDF Button\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function DownloadPdfButton(props){const{label,pdfFile,fileName,background,textColor,borderRadius,font,style}=props// Destructure fileName\n;const handleDownload=useCallback(()=>{if(typeof window===\"undefined\")return;fetch(pdfFile).then(response=>response.blob()).then(blob=>{const url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=fileName||\"document.pdf\";document.body.appendChild(link);link.click();document.body.removeChild(link);window.URL.revokeObjectURL(url);});},[pdfFile,fileName]);return /*#__PURE__*/_jsx(\"button\",{style:{...style,width:\"100%\",height:\"100%\",background,color:textColor,border:\"none\",borderRadius,cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",outline:\"none\",boxShadow:\"0 2px 8px rgba(0,0,0,0.04)\",transition:\"background 0.15s\",...font},\"aria-label\":label,onClick:handleDownload,children:label});}addPropertyControls(DownloadPdfButton,{label:{type:ControlType.String,title:\"Button Label\",defaultValue:\"Download PDF\"},pdfFile:{type:ControlType.File,allowedFileTypes:[\"pdf\"],title:\"PDF File\"},fileName:{type:ControlType.String,title:\"File Name\",defaultValue:\"document.pdf\",placeholder:\"document.pdf\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#111111\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"16px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadPdfButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadPdfButton.map"],"mappings":"gNAEA,SAAS,GAAa,CAAC,IAAM,EAAM,MAAM,KAAK,SAAS,iBAAiB,sBAAsB,EAAU,IAAI,CAAC,CAA8B,OAAzB,EAAM,OAA0B,EAAM,KAAK,GAAI,EAAG,eAAe,KAAK,EAAE,EAAM,EAAM,OAAO,GAAvE,KAA2E,SAAS,EAAgB,EAAK,CAAC,IAAM,EAAK,GAAa,CAAC,GAAG,CAAC,EAAK,OAAO,KAAK,IAAI,EAAG,EAAK,cAAc,eAAe,EAAK,IAAI,CAAC,GAAG,EAAG,OAAO,EAAG,IAAM,EAAQ,EAAK,cAAc,UAAU,EAAK,IAAI,CAAkO,OAA9N,IAAS,EAAG,EAAQ,cAAc,QAAQ,CAAI,IAAiB,EAAK,SAAS,QAAQ,GAAE,EAAG,EAAK,cAAc,2BAA2B,EAAK,IAAI,GAAG,EAAQ,EAAQ,cAAc,oBAAoB,CAAC,MAAS,GAAU,EAAW,KAAM,SAAS,EAAI,EAAK,CAAC,OAAO,EAAgB,EAAK,EAAE,OAAO,IAAI,MAAM,C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