{"version":3,"file":"DownloadPdfButton.DBR5TMbv.mjs","names":["React.useState","React.useCallback","__legacyOverrideHOC_DataObserverContext","_jsx","useCallback"],"sources":["https:/framerusercontent.com/modules/YeauMiL4Q4O2t7OHKnNI/mftpLh09AHgCPPvluxsL/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\"// 👈 keep form name as-is\n;// ----- helpers -----\nfunction getFormRoot(){const forms=Array.from(document.querySelectorAll(`[data-framer-name=\"${FORM_NAME}\"]`));if(!forms.length)return null;// Pick the one that is visible (or fallback to last)\nreturn forms.find(el=>el.offsetParent!==null)||forms[forms.length-1];}function findInputByName(name){const root=getFormRoot();if(!root)return null;// direct match\nlet el=root.querySelector(`input[name=\"${name}\"]`);if(el)return el;// wrapper with name containing input\nconst wrapper=root.querySelector(`[name=\"${name}\"]`);if(wrapper){el=wrapper.querySelector(\"input\");if(el)return el;}// special case for phone\nif(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,\"\");}function validEmail(s){return/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(s);}// 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 allFilled=v.fullName&&v.email&&v.phone&&v.company&&v.designation;let ok=Boolean(allFilled);// strict rules: valid email + phone ≥ 7 digits\nif(ok){if(!validEmail(v.email))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});// 🚫 handle Enter key\nconst onKeyDown=e=>{if(e.key===\"Enter\"){if(!validate()){e.preventDefault();e.stopPropagation();// 🔔 trigger native validation popup\nif(root){const firstInvalid=root.querySelector(\"input:invalid\");if(firstInvalid){firstInvalid.reportValidity();firstInvalid.focus();}}}}};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\",\"framerSupportedLayo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