{"version":3,"file":"DownloadPdfButton.B404s-eR.mjs","names":["React.useState","React.useCallback","__legacyOverrideHOC_DataObserverContext","_jsx","useCallback","__esmMin","ne","init_npm_react_18_3_1","oe","window","init_ssg_sandbox_shims","ce","init_jsx_runtime","_e","addPropertyControls","ControlType","DataObserverContext","init_framer_BL70qLPA","getFormRoot","forms","FORM_NAME","el","findInputByName","root","name","wrapper","val","digits","s","validEmail","lower","blocked","b","domain","EnableDownloadButton","enabled","setEnabled","validate","v","N","emailInput","emailCheck","ok","init","onInput","mo","onKeyDown","gate","withEnableDownloadButton","C","props","init_EnableDownloadButton","DownloadPdfButton","handleDownload","pdfFile","response","url","blob","link","fileName","style","textColor","font","label","init_DownloadPdfButton"],"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":"A,qNAEA,SAASkB,GAAa,CAAC,IAAMC,EAAM,MAAM,KAAK,SAAS,iBAAiB,sBAAsBC,EAAU,GAAG,CAAC,EAA+B,OAAzBD,EAAM,OAA0BA,EAAM,KAAK,GAAIE,EAAG,eAAe,IAAI,GAAGF,EAAMA,EAAM,OAAO,GAAvE,IAA0E,CAAC,SAASG,EAAgB,EAAK,CAAC,IAAMC,EAAKL,EAAY,EAAE,GAAG,CAACK,EAAK,OAAO,KAAK,I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